board.h 7.3 KB

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