board.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-08-10 charlown first version
  9. */
  10. #ifndef __BOARD_H__
  11. #define __BOARD_H__
  12. #include "ch32f10x.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #define CH32_FLASH_START_ADRESS ((uint32_t)0x08000000)
  17. #define FLASH_PAGE_SIZE (64)
  18. #define CH32_FLASH_SIZE (1024 * 1024)
  19. #define CH32_FLASH_END_ADDRESS ((uint32_t)(CH32_FLASH_START_ADRESS + CH32_FLASH_SIZE))
  20. #define CH32_SRAM_SIZE 20
  21. #define CH32_SRAM_END (0x20000000 + CH32_SRAM_SIZE * 1024)
  22. #if defined(__ARMCC_VERSION)
  23. extern int Image$$RW_IRAM1$$ZI$$Limit;
  24. #define HEAP_BEGIN ((void *)&Image$$RW_IRAM1$$ZI$$Limit)
  25. #elif __ICCARM__
  26. #pragma section="CSTACK"
  27. #define HEAP_BEGIN (__segment_end("CSTACK"))
  28. #else
  29. extern int __bss_end;
  30. #define HEAP_BEGIN ((void *)&__bss_end)
  31. #endif
  32. #define HEAP_END CH32_SRAM_END
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36. rt_uint32_t ch32_get_sysclock_frequency(void);
  37. #ifdef BSP_USING_UART
  38. void ch32f1_usart_clock_and_io_init(USART_TypeDef* usartx);
  39. #endif
  40. #ifdef BSP_USING_SPI
  41. void ch32f1_spi_clock_and_io_init(SPI_TypeDef* spix);
  42. rt_uint32_t ch32f1_spi_clock_get(SPI_TypeDef* spix);
  43. #endif
  44. #ifdef BSP_USING_HWI2C
  45. void ch32f1_i2c_clock_and_io_init(I2C_TypeDef* i2cx);
  46. void ch32f1_i2c_config(I2C_TypeDef* i2cx);
  47. #endif
  48. #ifdef BSP_USING_TIM
  49. void ch32f1_tim_clock_init(TIM_TypeDef *timx);
  50. rt_uint32_t ch32f1_tim_clock_get(TIM_TypeDef *timx);
  51. #ifdef BSP_USING_HWTIMER
  52. struct rt_hwtimer_info* ch32f1_hwtimer_info_config_get(TIM_TypeDef *timx);
  53. #endif
  54. #ifdef BSP_USING_PWM
  55. void ch32f1_pwm_io_init(TIM_TypeDef *timx, rt_uint8_t channel);
  56. #endif
  57. #endif
  58. #endif /* __BOARD_H__ */