board.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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_ebi.h>
  41. #include <efm32_rtc.h>
  42. #include <efm32_timer.h>
  43. #include <efm32_gpio.h>
  44. #include <efm32_acmp.h>
  45. #include <efm32_adc.h>
  46. #include <efm32_usart.h>
  47. #include <efm32_leuart.h>
  48. #include <efm32_i2c.h>
  49. #include <rtthread.h>
  50. #if (defined(EFM32_GXXX_DK) || defined(EFM32GG_DK3750))
  51. #include <dvk.h>
  52. #endif
  53. /* Exported types ------------------------------------------------------------*/
  54. /* Exported constants --------------------------------------------------------*/
  55. /* Exported variables --------------------------------------------------------*/
  56. extern volatile rt_uint32_t rt_system_status;
  57. /* Exported macro ------------------------------------------------------------*/
  58. #ifdef EFM32_DEBUG
  59. #define DEBUG_EFM
  60. #define DEBUG_EFM_USER
  61. #define EFM32_SWO_ENABLE
  62. #endif
  63. #define EFM32_NO_DATA (0)
  64. #define EFM32_NO_POINTER (RT_NULL)
  65. #define EFM32_NO_OFFSET (-1)
  66. #define EFM32_NO_DMA (-1)
  67. /* SECTION: SPI Flash */
  68. #if defined(EFM32_USING_SFLASH)
  69. #define SFLASH_CS_PORT (gpioPortC)
  70. #define SFLASH_CS_PIN (8)
  71. #endif
  72. /* SECTION: Micro SD */
  73. #if defined(EFM32_USING_SPISD)
  74. #if defined(EFM32_GXXX_DK)
  75. #define SD_CS_PORT (gpioPortC)
  76. #define SD_CS_PIN (8)
  77. #elif defined(EFM32GG_DK3750)
  78. #define SD_CS_PORT (gpioPortE)
  79. #define SD_CS_PIN (4)
  80. #endif
  81. #endif
  82. /* SECTION: Ethernet */
  83. #if defined(EFM32_USING_ETHERNET)
  84. #if defined(EFM32_GXXX_DK)
  85. #define ETH_CS_PORT (gpioPortB)
  86. #define ETH_CS_PIN (6)
  87. #elif defined(EFM32GG_DK3750)
  88. #define ETH_CS_PORT (gpioPortD)
  89. #define ETH_CS_PIN (3)
  90. #endif
  91. #endif
  92. /* SECTION: LCD */
  93. #if defined(EFM32_USING_LCD)
  94. #if defined(EFM32GG_DK3750)
  95. #define LCD_CS_PORT (gpioPortD)
  96. #define LCD_CS_PIN (3)
  97. #endif
  98. #endif
  99. /* SECTION: SYSTEM */
  100. #define EFM32_SRAM_END (SRAM_BASE + SRAM_SIZE)
  101. #define EFM32_BASE_PRI_DEFAULT (0x0UL << 5)
  102. #define EFM32_IRQ_PRI_DEFAULT (0x4UL << 5)
  103. /* SECTION: CLOCK */
  104. #define EFM32_USING_HFXO
  105. #define EFM32_USING_LFXO
  106. #if defined(EFM32_USING_HFXO)
  107. #if (defined(EFM32_G8XX_STK) || defined(EFM32_GXXX_DK))
  108. #define EFM32_HFXO_FREQUENCY (32000000)
  109. #elif defined(EFM32GG_DK3750)
  110. #define EFM32_HFXO_FREQUENCY (48000000)
  111. #else
  112. #define EFM32_HFXO_FREQUENCY (00000000)
  113. #endif
  114. #endif
  115. /* SECTION: USART */
  116. #define USART_RX_BUFFER_SIZE (64)
  117. #define LEUART_RX_BUFFER_SIZE (64)
  118. /* Location count (start from 0) */
  119. #if defined(_EFM32_GECKO_FAMILY)
  120. #define EFM32_USART_LOCATION_COUNT (3)
  121. #define EFM32_UART_LOCATION_COUNT (4)
  122. #define EFM32_LEUART_LOCATION_COUNT (3)
  123. #elif defined(_EFM32_GIANT_FAMILY)
  124. #define EFM32_USART_LOCATION_COUNT (6)
  125. #define EFM32_UART_LOCATION_COUNT (4)
  126. #define EFM32_LEUART_LOCATION_COUNT (5)
  127. #endif
  128. /* SUBSECTION: UART */
  129. #define UART_BAUDRATE (115200)
  130. /* SUBSECTION: SPI */
  131. /* Max SPI clock: HFPERCLK/2 for master, HFPERCLK/8 for slave */
  132. #define SPI_BAUDRATE (4000000)
  133. /* SECTION: I2C */
  134. #define IIC_RX_BUFFER_SIZE (32)
  135. #if defined(_EFM32_GECKO_FAMILY)
  136. #define EFM32_IIC_LOCATION_COUNT (4)
  137. #elif defined(_EFM32_GIANT_FAMILY)
  138. #define EFM32_IIC_LOCATION_COUNT (7)
  139. #endif
  140. /* SECTION: ADC */
  141. #define ADC_CALI_REF (adcRef2V5)
  142. #define ADC_CALI_CH (adcSingleInpCh5)
  143. #define ADC_CONVERT_FREQUENCY (7000000)
  144. #if (RT_CONSOLE_DEVICE == EFM_USART0)
  145. #define CONSOLE_DEVICE RT_USART0_NAME
  146. #elif (RT_CONSOLE_DEVICE == EFM_USART1)
  147. #define CONSOLE_DEVICE RT_USART1_NAME
  148. #elif (RT_CONSOLE_DEVICE == EFM_USART2)
  149. #define CONSOLE_DEVICE RT_USART2_NAME
  150. #elif (RT_CONSOLE_DEVICE == EFM_UART0)
  151. #define CONSOLE_DEVICE RT_UART0_NAME
  152. #elif (RT_CONSOLE_DEVICE == EFM_UART1)
  153. #define CONSOLE_DEVICE RT_UART1_NAME
  154. #elif (RT_CONSOLE_DEVICE == EFM_LEUART0)
  155. #define CONSOLE_DEVICE RT_LEUART0_NAME
  156. #elif (RT_CONSOLE_DEVICE == EFM_LEUART1)
  157. #define CONSOLE_DEVICE RT_LEUART1_NAME
  158. #else
  159. #define CONSOLE_DEVICE "NONE"
  160. #endif
  161. /* The following defines should be consistent with those in diskio.h */
  162. #define CTRL_SYNC 0
  163. #define GET_SECTOR_COUNT 1
  164. #define GET_SECTOR_SIZE 2
  165. #define GET_BLOCK_SIZE 3
  166. #define MMC_GET_TYPE 10
  167. #define MMC_GET_CSD 11
  168. #define MMC_GET_CID 12
  169. #define MMC_GET_OCR 13
  170. #define MMC_GET_SDSTAT 14
  171. /* The above defines should be consistent with those in diskio.h */
  172. /* I/O control options */
  173. #define RT_DEVICE_CTRL_SD_SYNC CTRL_SYNC
  174. #define RT_DEVICE_CTRL_SD_GET_SCOUNT GET_SECTOR_COUNT
  175. #define RT_DEVICE_CTRL_SD_GET_SSIZE GET_SECTOR_SIZE
  176. #define RT_DEVICE_CTRL_SD_GET_BSIZE GET_BLOCK_SIZE
  177. #define RT_DEVICE_CTRL_SD_GET_TYPE MMC_GET_TYPE
  178. #define RT_DEVICE_CTRL_SD_GET_CSD MMC_GET_CSD
  179. #define RT_DEVICE_CTRL_SD_GET_CID MMC_GET_CID
  180. #define RT_DEVICE_CTRL_SD_GET_OCR MMC_GET_OCR
  181. #define RT_DEVICE_CTRL_SD_GET_SDSTAT MMC_GET_SDSTAT
  182. /*! fixme: move the following define to Rtdef.h */
  183. #define RT_DEVICE_CTRL_USART_RBUFFER (0xF1) /*!< set USART/UART rx buffer */
  184. #define RT_DEVICE_CTRL_LEUART_RBUFFER (0xF2) /*!< set LEUART rx buffer */
  185. #define RT_DEVICE_CTRL_IIC_SETTING (0xF3) /*!< change IIC setting */
  186. #define RT_DEVICE_CTRL_TIMER_PERIOD (0xF4) /*!< set Timer timeout period */
  187. #define RT_DEVICE_CTRL_ADC_MODE (0xF5) /*!< change ADC mode */
  188. #define RT_DEVICE_CTRL_ADC_RESULT (0xF6) /*!< get ADC result */
  189. #define RT_DEVICE_CTRL_ACMP_INIT (0xF7) /*!< Initialize ACMP */
  190. #define RT_DEVICE_CTRL_ACMP_OUTPUT (0xF8) /*!< get ACMP output */
  191. /* Exported functions ------------------------------------------------------- */
  192. void rt_hw_board_init(void);
  193. void rt_hw_driver_init(void);
  194. rt_uint32_t rt_hw_interrupt_check(void);
  195. #endif /*__BOARD_H__ */