drv_usart.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /******************************************************************//**
  2. * @file drv_usart.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-22 onelife Initial creation for EFM32
  15. *********************************************************************/
  16. #ifndef __DRV_USART_H__
  17. #define __DRV_USART_H__
  18. /* Includes -------------------------------------------------------------------*/
  19. /* Exported types -------------------------------------------------------------*/
  20. struct efm32_usart_int_mode_t
  21. {
  22. rt_uint8_t *data_ptr;
  23. rt_uint8_t data_size;
  24. rt_uint32_t read_index, save_index;
  25. };
  26. struct efm32_usart_dma_mode_t
  27. {
  28. /* DMA Channel */
  29. rt_uint32_t dma_channel;
  30. /* buffer info */
  31. rt_uint32_t *data_ptr;
  32. rt_uint8_t data_size;
  33. };
  34. struct efm32_usart_device_t
  35. {
  36. /* Unit number */
  37. rt_uint8_t unit;
  38. /* State */
  39. rt_uint8_t state;
  40. /* Pointer to USART device structure */
  41. USART_TypeDef* usart_device;
  42. /* Pointer to RX structure */
  43. void *rx_mode;
  44. /* Pointer to TX structure */
  45. void *tx_mode;
  46. };
  47. /* Exported constants ---------------------------------------------------------*/
  48. /* Exported macro -------------------------------------------------------------*/
  49. #define USART_WAIT_TIME_TX (RT_TICK_PER_SECOND / 100 * 3)
  50. #define USART_STATE_CONSOLE (1 << 0)
  51. #define USART_STATE_SYNC (1 << 1)
  52. #define USART_STATE_MASTER (1 << 2)
  53. #define USART_STATE_AUTOCS (1 << 3)
  54. #define USART_STATE_TX_BUSY (1 << 4)
  55. #define USART_STATE_RX_BUSY (1 << 5)
  56. /* Exported functions --------------------------------------------------------- */
  57. void rt_hw_usart_init(void);
  58. #endif /* __DRV_USART_H__ */