board.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. ******************************************************************************/
  19. #ifndef __BOARD_H__
  20. #define __BOARD_H__
  21. #if defined(EFM32G890F128)
  22. #elif defined(EFM32G290F128)
  23. #elif defined(EFM32G230F128)
  24. #else
  25. #error Unknown MCU type
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include <efm32.h>
  29. #include <efm32_chip.h>
  30. #include <efm32_cmu.h>
  31. #include <efm32_rmu.h>
  32. #include <efm32_dma.h>
  33. #include <efm32_rtc.h>
  34. #include <efm32_timer.h>
  35. #include <efm32_gpio.h>
  36. #include <efm32_acmp.h>
  37. #include <efm32_adc.h>
  38. #include <efm32_usart.h>
  39. #include <efm32_i2c.h>
  40. #include <rtthread.h>
  41. #if defined(EFM32_G290_DK)
  42. #include <dvk.h>
  43. #endif
  44. /* Exported types ------------------------------------------------------------*/
  45. /* Exported constants --------------------------------------------------------*/
  46. /* Exported variables --------------------------------------------------------*/
  47. extern volatile rt_uint32_t rt_system_status;
  48. /* Exported macro ------------------------------------------------------------*/
  49. #ifdef EFM32_DEBUG
  50. #define DEBUG_EFM
  51. #define DEBUG_EFM_USER
  52. #define EFM32_SWO_ENABLE
  53. #endif
  54. #define EFM32_NO_DATA (0)
  55. #define EFM32_NO_POINTER (RT_NULL)
  56. #define EFM32_NO_OFFSET (-1)
  57. #define EFM32_NO_DMA (-1)
  58. /* SECTION: SPI Flash */
  59. #if defined(EFM32_USING_SFLASH)
  60. #define USART_0_AUTOCS (0)
  61. #define SFLASH_CS_PORT (gpioPortC)
  62. #define SFLASH_CS_PIN (8)
  63. #endif
  64. /* SECTION: Micro SD */
  65. #if defined(EFM32_USING_SPISD)
  66. #define USART_0_AUTOCS (1)
  67. #define SD_CS_PORT (gpioPortC)
  68. #define SD_CS_PIN (8)
  69. #endif
  70. /* SECTION: Ethernet */
  71. #if defined(EFM32_USING_ETHERNET)
  72. #define USART_2_AUTOCS (0)
  73. #define ETH_CS_PORT (gpioPortB)
  74. #define ETH_CS_PIN (6)
  75. #endif
  76. /* SECTION: SYSTEM */
  77. #define EFM32_SRAM_END (SRAM_BASE + SRAM_SIZE)
  78. #define EFM32_BASE_PRI_DEFAULT (0x0UL << 5)
  79. #define EFM32_IRQ_PRI_DEFAULT (0x4UL << 5)
  80. #if (defined(EFM32_G890_STK) || defined(EFM32_G290_DK))
  81. #define EFM32_HFXO_FREQUENCY (32000000)
  82. #else
  83. #define EFM32_HFXO_FREQUENCY (00000000)
  84. #endif
  85. /* SECTION: USART */
  86. #define USART_RX_BUFFER_SIZE (64)
  87. /* SUBSECTION: UART */
  88. #define UART_BAUDRATE (115200)
  89. /* SUBSECTION: SPI */
  90. /* Max SPI clock: HFPERCLK/2 for master, HFPERCLK/8 for slave */
  91. #define SPI_BAUDRATE (4000000)
  92. #ifndef USART_0_AUTOCS
  93. #define USART_0_AUTOCS (0)
  94. #endif
  95. #ifndef USART_1_AUTOCS
  96. #define USART_1_AUTOCS (0)
  97. #endif
  98. #ifndef USART_2_AUTOCS
  99. #define USART_2_AUTOCS (0)
  100. #endif
  101. /* Auto Slave Select */
  102. #define SPI_AUTOCS_ENABLE ((USART_2_AUTOCS << 2) | \
  103. (USART_1_AUTOCS << 1) | \
  104. (USART_0_AUTOCS << 0))
  105. /* SECTION: I2C */
  106. #define IIC_RX_BUFFER_SIZE (32)
  107. /* SECTION: ADC */
  108. #define ADC_CALI_REF adcRef2V5
  109. #define ADC_CALI_CH adcSingleInpCh5
  110. #define ADC_CONVERT_FREQUENCY (7000000)
  111. #if (RT_CONSOLE_DEVICE == 0x0UL)
  112. #define CONSOLE_DEVICE RT_USART0_NAME
  113. #elif (RT_CONSOLE_DEVICE == 0x1UL)
  114. #define CONSOLE_DEVICE RT_USART1_NAME
  115. #elif (RT_CONSOLE_DEVICE == 0x2UL)
  116. #define CONSOLE_DEVICE RT_USART2_NAME
  117. #else
  118. #define CONSOLE_DEVICE "no"
  119. #endif
  120. /* The following defines should be consistent with those in diskio.h */
  121. #define CTRL_SYNC 0
  122. #define GET_SECTOR_COUNT 1
  123. #define GET_SECTOR_SIZE 2
  124. #define GET_BLOCK_SIZE 3
  125. #define MMC_GET_TYPE 10
  126. #define MMC_GET_CSD 11
  127. #define MMC_GET_CID 12
  128. #define MMC_GET_OCR 13
  129. #define MMC_GET_SDSTAT 14
  130. /* The above defines should be consistent with those in diskio.h */
  131. /* I/O control options */
  132. #define RT_DEVICE_CTRL_SD_SYNC CTRL_SYNC
  133. #define RT_DEVICE_CTRL_SD_GET_SCOUNT GET_SECTOR_COUNT
  134. #define RT_DEVICE_CTRL_SD_GET_SSIZE GET_SECTOR_SIZE
  135. #define RT_DEVICE_CTRL_SD_GET_BSIZE GET_BLOCK_SIZE
  136. #define RT_DEVICE_CTRL_SD_GET_TYPE MMC_GET_TYPE
  137. #define RT_DEVICE_CTRL_SD_GET_CSD MMC_GET_CSD
  138. #define RT_DEVICE_CTRL_SD_GET_CID MMC_GET_CID
  139. #define RT_DEVICE_CTRL_SD_GET_OCR MMC_GET_OCR
  140. #define RT_DEVICE_CTRL_SD_GET_SDSTAT MMC_GET_SDSTAT
  141. /*! fixme: move the following define to Rtdef.h */
  142. #define RT_DEVICE_CTRL_USART_RBUFFER (0xF1) /*!< set USART rx buffer */
  143. #define RT_DEVICE_CTRL_IIC_SETTING (0xF2) /*!< change IIC setting */
  144. #define RT_DEVICE_CTRL_TIMER_PERIOD (0xF3) /*!< set Timer timeout period */
  145. #define RT_DEVICE_CTRL_ADC_MODE (0xF4) /*!< change ADC mode */
  146. #define RT_DEVICE_CTRL_ADC_RESULT (0xF5) /*!< get ADC result */
  147. #define RT_DEVICE_CTRL_ACMP_INIT (0xF6) /*!< Initialize ACMP */
  148. #define RT_DEVICE_CTRL_ACMP_OUTPUT (0xF7) /*!< get ACMP output */
  149. /* Exported functions ------------------------------------------------------- */
  150. void rt_hw_board_init(void);
  151. void rt_hw_driver_init(void);
  152. rt_uint32_t rt_hw_interrupt_check(void);
  153. #endif /*__BOARD_H__ */