drv_adc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /***************************************************************************//**
  2. * @file drv_adc.h
  3. * @brief ADC 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-02-21 onelife Initial creation for EFM32
  15. * 2011-07-14 onelife Add multiple channels support for scan mode
  16. ******************************************************************************/
  17. #ifndef __DRV_ADC_H__
  18. #define __DRV_ADC_H__
  19. /* Includes ------------------------------------------------------------------*/
  20. /* Exported types ------------------------------------------------------------*/
  21. struct efm32_adc_device_t
  22. {
  23. ADC_TypeDef *adc_device;
  24. rt_uint8_t mode;
  25. rt_uint8_t singleCount;
  26. rt_uint8_t singleDmaChannel;
  27. rt_uint8_t scanCount;
  28. rt_uint8_t scanDmaChannel;
  29. };
  30. struct efm32_adc_control_single_t
  31. {
  32. rt_uint8_t count;
  33. rt_uint8_t dmaChannel;
  34. ADC_InitSingle_TypeDef *init;
  35. };
  36. struct efm32_adc_control_scan_t
  37. {
  38. rt_uint8_t count;
  39. rt_uint8_t dmaChannel;
  40. ADC_InitScan_TypeDef *init;
  41. };
  42. struct efm32_adc_control_t
  43. {
  44. rt_uint8_t mode;
  45. struct efm32_adc_control_scan_t scan;
  46. struct efm32_adc_control_single_t single;
  47. };
  48. struct efm32_adc_result_t
  49. {
  50. rt_uint8_t mode;
  51. void *buffer;
  52. };
  53. /* Exported constants --------------------------------------------------------*/
  54. /* Exported macro ------------------------------------------------------------*/
  55. #define ADC_MODE_SINGLE (0x01)
  56. #define ADC_MODE_SCAN (0x02)
  57. #define ADC_MODE_TAILGATE (0x04)
  58. #define ADC_OP_SINGLE_REPEAT (0x10)
  59. #define ADC_OP_SCAN_REPEAT (0x20)
  60. #define ADC_MASK_MODE (0x0f)
  61. #define ADC_MASK_OP (0xf0)
  62. /* Exported functions ------------------------------------------------------- */
  63. void rt_hw_adc_init(void);
  64. #endif /*__DRV_ADC_H__ */