board.h 5.1 KB

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