drv_leuart.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /***************************************************************************//**
  2. * @file drv_leuart.h
  3. * @brief LEUART driver of RT-Thread RTOS for EFM32
  4. * COPYRIGHT (C) 2012, RT-Thread Development Team
  5. * @author onelife
  6. * @version 1.0
  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. * 2011-12-09 onelife Initial creation for EFM32
  15. ******************************************************************************/
  16. #ifndef __DRV_LEUSART_H__
  17. #define __DRV_LEUSART_H__
  18. /* Includes ------------------------------------------------------------------*/
  19. /* Exported types ------------------------------------------------------------*/
  20. struct efm32_leuart_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_leuart_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_leuart_device_t
  35. {
  36. /* Counter */
  37. rt_uint32_t counter;
  38. /* Lock */
  39. struct rt_semaphore *lock;
  40. /* Unit number */
  41. rt_uint8_t unit;
  42. /* State */
  43. volatile rt_uint8_t state;
  44. /* Pointer to LEUART device structure */
  45. LEUART_TypeDef *leuart_device;
  46. /* Pointer to RX structure */
  47. void *rx_mode;
  48. /* Pointer to TX structure */
  49. void *tx_mode;
  50. };
  51. /* Exported constants --------------------------------------------------------*/
  52. /* Exported macro ------------------------------------------------------------*/
  53. #define LEUART_WAIT_TIME_TX (RT_TICK_PER_SECOND / 100 * 3)
  54. #define LEUART_STATE_CONSOLE (1 << 0)
  55. #define LEUART_STATE_SYNC (1 << 1)
  56. #define LEUART_STATE_MASTER (1 << 2)
  57. #define LEUART_STATE_AUTOCS (1 << 3)
  58. #define LEUART_STATE_TX_BUSY (1 << 4)
  59. #define LEUART_STATE_RX_BUSY (1 << 5)
  60. /* Exported functions ------------------------------------------------------- */
  61. void rt_hw_leuart_init(void);
  62. #endif /* __DRV_LEUSART_H__ */