board.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2010-12-21 onelife Initial creation for EFM32
  9. * 2011-05-06 onelife Add EFM32 development kit and SPI Flash support
  10. * 2011-07-12 onelife Add prototype for SWO output enable and interrupt
  11. * context check functions
  12. * 2011-12-08 onelife Add giant gecko development kit support
  13. * 2011-12-09 onelife Add giant gecko support
  14. * 2011-12-09 onelife Add LEUART module support
  15. * 2011-12-14 onelife Add LFXO enabling routine in driver initialization function
  16. * 2011-12-20 onelife Move SPI Auto-CS setting to "rtconfig.h"
  17. * 2012-05-15 onelife Modified to compatible with CMSIS v3
  18. */
  19. #ifndef __BOARD_H__
  20. #define __BOARD_H__
  21. #if defined(EFM32G890F128)
  22. #elif defined(EFM32G290F128)
  23. #elif defined(EFM32G230F128)
  24. #elif defined(EFM32GG990F1024)
  25. #else
  26. #error Unknown MCU type
  27. #endif
  28. /* Includes ------------------------------------------------------------------*/
  29. #include <efm32.h>
  30. #include <em_chip.h>
  31. #include <em_cmu.h>
  32. #include <em_rmu.h>
  33. #include <em_emu.h>
  34. #include <em_dma.h>
  35. #include <em_ebi.h>
  36. #include <em_rtc.h>
  37. #include <em_timer.h>
  38. #include <em_letimer.h>
  39. #include <em_gpio.h>
  40. #include <em_acmp.h>
  41. #include <em_adc.h>
  42. #include <em_usart.h>
  43. #include <em_leuart.h>
  44. #include <em_i2c.h>
  45. #include <rtthread.h>
  46. #if (defined(EFM32_GXXX_DK) || defined(EFM32GG_DK3750))
  47. #include <dvk.h>
  48. #endif
  49. #include "drv_emu.h"
  50. /* Exported types ------------------------------------------------------------*/
  51. /* Exported constants --------------------------------------------------------*/
  52. /* Exported variables --------------------------------------------------------*/
  53. extern volatile rt_uint32_t rt_system_status;
  54. /* Exported macro ------------------------------------------------------------*/
  55. #ifdef EFM32_DEBUG
  56. #define DEBUG_EFM
  57. #define DEBUG_EFM_USER
  58. #define EFM32_SWO_ENABLE
  59. #endif
  60. #define EFM32_NO_DATA (0)
  61. #define EFM32_NO_POINTER (RT_NULL)
  62. #define EFM32_NO_OFFSET (-1)
  63. #define EFM32_NO_DMA (-1)
  64. /* SECTION: SPI Flash */
  65. #if defined(EFM32_USING_SFLASH)
  66. #define SFLASH_CS_PORT (gpioPortC)
  67. #define SFLASH_CS_PIN (8)
  68. #endif
  69. /* SECTION: Micro SD */
  70. #if defined(EFM32_USING_SPISD)
  71. #if defined(EFM32_GXXX_DK)
  72. #define SD_CS_PORT (gpioPortC)
  73. #define SD_CS_PIN (8)
  74. #elif defined(EFM32GG_DK3750)
  75. #define SD_CS_PORT (gpioPortE)
  76. #define SD_CS_PIN (4)
  77. #endif
  78. #endif
  79. /* SECTION: Ethernet */
  80. #if defined(EFM32_USING_ETHERNET)
  81. #if defined(EFM32_GXXX_DK)
  82. #define ETH_CS_PORT (gpioPortB)
  83. #define ETH_CS_PIN (6)
  84. #elif defined(EFM32GG_DK3750)
  85. #define ETH_CS_PORT (gpioPortD)
  86. #define ETH_CS_PIN (3)
  87. #endif
  88. #endif
  89. /* SECTION: LCD */
  90. #if defined(EFM32_USING_LCD)
  91. #if defined(EFM32GG_DK3750)
  92. #define LCD_CS_PORT (gpioPortD)
  93. #define LCD_CS_PIN (3)
  94. #endif
  95. #endif
  96. /* SECTION: SYSTEM */
  97. #define EFM32_SRAM_END (SRAM_BASE + SRAM_SIZE)
  98. #define EFM32_BASE_PRI_DEFAULT (0x0UL << 5)
  99. #define EFM32_IRQ_PRI_DEFAULT (0x4UL << 5)
  100. /* SECTION: CLOCK */
  101. #define EFM32_USING_HFXO
  102. #define EFM32_USING_LFXO
  103. #if defined(EFM32_USING_HFXO)
  104. #if (defined(EFM32_G8XX_STK) || defined(EFM32_GXXX_DK))
  105. #define EFM32_HFXO_FREQUENCY (32000000)
  106. #elif defined(EFM32GG_DK3750)
  107. #define EFM32_HFXO_FREQUENCY (48000000)
  108. #else
  109. #define EFM32_HFXO_FREQUENCY (00000000)
  110. #endif
  111. #endif
  112. #if defined(EFM32_USING_LFXO)
  113. #if (defined(EFM32_G8XX_STK) || defined(EFM32_GXXX_DK))
  114. #define EFM32_LETIMER_TOP_100HZ (41)
  115. #elif defined(EFM32GG_DK3750)
  116. #define EFM32_LETIMER_TOP_100HZ (41)
  117. #else
  118. #define EFM32_LETIMER_TOP_100HZ (41)
  119. #endif
  120. #endif
  121. /* SECTION: USART */
  122. #define USART_RX_BUFFER_SIZE (64)
  123. #define LEUART_RX_BUFFER_SIZE (64)
  124. /* Location count (start from 0) */
  125. #if defined(_EFM32_GECKO_FAMILY)
  126. #define EFM32_USART_LOCATION_COUNT (3)
  127. #define EFM32_UART_LOCATION_COUNT (4)
  128. #define EFM32_LEUART_LOCATION_COUNT (3)
  129. #elif defined(_EFM32_GIANT_FAMILY)
  130. #define EFM32_USART_LOCATION_COUNT (6)
  131. #define EFM32_UART_LOCATION_COUNT (4)
  132. #define EFM32_LEUART_LOCATION_COUNT (5)
  133. #endif
  134. /* SUBSECTION: UART */
  135. #define UART_BAUDRATE (115200)
  136. /* SUBSECTION: SPI */
  137. /* Max SPI clock: HFPERCLK/2 for master, HFPERCLK/8 for slave */
  138. #define SPI_BAUDRATE (4000000)
  139. /* SECTION: I2C */
  140. #define IIC_RX_BUFFER_SIZE (32)
  141. #if defined(_EFM32_GECKO_FAMILY)
  142. #define EFM32_IIC_LOCATION_COUNT (4)
  143. #elif defined(_EFM32_GIANT_FAMILY)
  144. #define EFM32_IIC_LOCATION_COUNT (7)
  145. #endif
  146. /* SECTION: ADC */
  147. #define ADC_CALI_REF (adcRef2V5)
  148. #define ADC_CALI_CH (adcSingleInpCh5)
  149. #define ADC_CONVERT_FREQUENCY (7000000)
  150. #if (RT_CONSOLE_DEVICE == EFM_USART0)
  151. #define CONSOLE_DEVICE RT_USART0_NAME
  152. #elif (RT_CONSOLE_DEVICE == EFM_USART1)
  153. #define CONSOLE_DEVICE RT_USART1_NAME
  154. #elif (RT_CONSOLE_DEVICE == EFM_USART2)
  155. #define CONSOLE_DEVICE RT_USART2_NAME
  156. #elif (RT_CONSOLE_DEVICE == EFM_UART0)
  157. #define CONSOLE_DEVICE RT_UART0_NAME
  158. #elif (RT_CONSOLE_DEVICE == EFM_UART1)
  159. #define CONSOLE_DEVICE RT_UART1_NAME
  160. #elif (RT_CONSOLE_DEVICE == EFM_LEUART0)
  161. #define CONSOLE_DEVICE RT_LEUART0_NAME
  162. #elif (RT_CONSOLE_DEVICE == EFM_LEUART1)
  163. #define CONSOLE_DEVICE RT_LEUART1_NAME
  164. #else
  165. #define CONSOLE_DEVICE "NONE"
  166. #endif
  167. /* The following defines should be consistent with those in diskio.h */
  168. #define CTRL_SYNC 0
  169. #define GET_SECTOR_COUNT 1
  170. #define GET_SECTOR_SIZE 2
  171. #define GET_BLOCK_SIZE 3
  172. #define MMC_GET_TYPE 10
  173. #define MMC_GET_CSD 11
  174. #define MMC_GET_CID 12
  175. #define MMC_GET_OCR 13
  176. #define MMC_GET_SDSTAT 14
  177. /* The above defines should be consistent with those in diskio.h */
  178. /* I/O control options */
  179. #define RT_DEVICE_CTRL_SD_SYNC CTRL_SYNC
  180. #define RT_DEVICE_CTRL_SD_GET_SCOUNT GET_SECTOR_COUNT
  181. #define RT_DEVICE_CTRL_SD_GET_SSIZE GET_SECTOR_SIZE
  182. #define RT_DEVICE_CTRL_SD_GET_BSIZE GET_BLOCK_SIZE
  183. #define RT_DEVICE_CTRL_SD_GET_TYPE MMC_GET_TYPE
  184. #define RT_DEVICE_CTRL_SD_GET_CSD MMC_GET_CSD
  185. #define RT_DEVICE_CTRL_SD_GET_CID MMC_GET_CID
  186. #define RT_DEVICE_CTRL_SD_GET_OCR MMC_GET_OCR
  187. #define RT_DEVICE_CTRL_SD_GET_SDSTAT MMC_GET_SDSTAT
  188. /*! fixme: move the following define to Rtdef.h */
  189. #define RT_DEVICE_CTRL_USART_RBUFFER (0xF1) /*!< set USART/UART rx buffer */
  190. #define RT_DEVICE_CTRL_LEUART_RBUFFER (0xF2) /*!< set LEUART rx buffer */
  191. #define RT_DEVICE_CTRL_IIC_SETTING (0xF3) /*!< change IIC setting */
  192. #define RT_DEVICE_CTRL_TIMER_PERIOD (0xF4) /*!< set Timer timeout period */
  193. #define RT_DEVICE_CTRL_ADC_MODE (0xF5) /*!< change ADC mode */
  194. #define RT_DEVICE_CTRL_ADC_RESULT (0xF6) /*!< get ADC result */
  195. #define RT_DEVICE_CTRL_ACMP_INIT (0xF7) /*!< Initialize ACMP */
  196. #define RT_DEVICE_CTRL_ACMP_OUTPUT (0xF8) /*!< get ACMP output */
  197. /* Exported functions ------------------------------------------------------- */
  198. void rt_hw_board_init(void);
  199. void rt_hw_driver_init(void);
  200. rt_uint32_t rt_hw_interrupt_check(void);
  201. #endif /*__BOARD_H__ */