board.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_SFLASH_DEBUG
  50. #define EFM32_NO_DATA (0)
  51. #define EFM32_NO_OFFSET (-1)
  52. #define EFM32_NO_POINTER (RT_NULL)
  53. #define EFM32_SRAM_END (RAM_MEM_BASE + SRAM_SIZE)
  54. #define EFM32_BASE_PRI_DEFAULT (0x0UL << 5)
  55. #define EFM32_IRQ_PRI_DEFAULT (0x4UL << 5)
  56. #if (defined(EFM32_G890_STK) || defined(EFM32_G290_DK))
  57. #define EFM32_HFXO_FREQUENCY (32000000)
  58. #else
  59. #define EFM32_HFXO_FREQUENCY (00000000)
  60. #endif
  61. #define UART_BAUDRATE (115200)
  62. #define USART_RX_BUFFER_SIZE (64)
  63. /* Max SPI clock: HFPERCLK/2 for master, HFPERCLK/8 for slave */
  64. #define SPI_BAUDRATE (4000000)
  65. /* Slave select PIN setting for unit 2, 1 and 0 */
  66. #define SPI_AUTOCS_ENABLE ((0 << 2) | (0 << 1) | (1 << 0))
  67. #define IIC_RX_BUFFER_SIZE (32)
  68. #define ADC_INIT_REF adcRef2V5
  69. #define ADC_INIT_CH adcSingleInpCh5
  70. #define ADC_CONVERT_FREQUENCY (7000000)
  71. #if (RT_CONSOLE_DEVICE == 0x0UL)
  72. #define CONSOLE_DEVICE RT_USART0_NAME
  73. #elif (RT_CONSOLE_DEVICE == 0x1UL)
  74. #define CONSOLE_DEVICE RT_USART1_NAME
  75. #elif (RT_CONSOLE_DEVICE == 0x2UL)
  76. #define CONSOLE_DEVICE RT_USART2_NAME
  77. #else
  78. #define CONSOLE_DEVICE "no"
  79. #endif
  80. #if defined(EFM32_G290_DK)
  81. #define EFM32_USING_SFLASH
  82. #endif
  83. #define SFLASH_USING_DEVICE_NAME RT_USART0_NAME
  84. /*! fixme: move the following define to Rtdef.h */
  85. #define RT_DEVICE_CTRL_USART_RBUFFER (0xF1) /*!< set USART rx buffer */
  86. #define RT_DEVICE_CTRL_IIC_SETTING (0xF2) /*!< change IIC setting */
  87. #define RT_DEVICE_CTRL_TIMER_PERIOD (0xF3) /*!< set Timer timeout period */
  88. #define RT_DEVICE_CTRL_ADC_MODE (0xF4) /*!< change ADC mode */
  89. #define RT_DEVICE_CTRL_ADC_RESULT (0xF5) /*!< get ADC result */
  90. #define RT_DEVICE_CTRL_ACMP_INIT (0xF6) /*!< Initialize ACMP */
  91. #define RT_DEVICE_CTRL_ACMP_OUTPUT (0xF7) /*!< get ACMP output */
  92. /* Exported functions --------------------------------------------------------- */
  93. void rt_hw_board_init(void);
  94. void rt_hw_driver_init(void);
  95. #endif /*__BOARD_H__ */