drv_adc.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2011-02-21 onelife Initial creation for EFM32
  9. * 2011-07-14 onelife Add multiple channels support for scan mode
  10. */
  11. #ifndef __DRV_ADC_H__
  12. #define __DRV_ADC_H__
  13. /* Includes ------------------------------------------------------------------*/
  14. /* Exported types ------------------------------------------------------------*/
  15. struct efm32_adc_device_t
  16. {
  17. ADC_TypeDef *adc_device;
  18. rt_uint8_t mode;
  19. rt_uint8_t singleCount;
  20. rt_uint8_t singleDmaChannel;
  21. rt_uint8_t scanCount;
  22. rt_uint8_t scanDmaChannel;
  23. };
  24. struct efm32_adc_control_single_t
  25. {
  26. rt_uint8_t count;
  27. rt_uint8_t dmaChannel;
  28. ADC_InitSingle_TypeDef *init;
  29. };
  30. struct efm32_adc_control_scan_t
  31. {
  32. rt_uint8_t count;
  33. rt_uint8_t dmaChannel;
  34. ADC_InitScan_TypeDef *init;
  35. };
  36. struct efm32_adc_control_t
  37. {
  38. rt_uint8_t mode;
  39. struct efm32_adc_control_scan_t scan;
  40. struct efm32_adc_control_single_t single;
  41. };
  42. struct efm32_adc_result_t
  43. {
  44. rt_uint8_t mode;
  45. void *buffer;
  46. };
  47. /* Exported constants --------------------------------------------------------*/
  48. /* Exported macro ------------------------------------------------------------*/
  49. #define ADC_MODE_SINGLE (0x01)
  50. #define ADC_MODE_SCAN (0x02)
  51. #define ADC_MODE_TAILGATE (0x04)
  52. #define ADC_OP_SINGLE_REPEAT (0x10)
  53. #define ADC_OP_SCAN_REPEAT (0x20)
  54. #define ADC_MASK_MODE (0x0f)
  55. #define ADC_MASK_OP (0xf0)
  56. /* Exported functions ------------------------------------------------------- */
  57. void rt_hw_adc_init(void);
  58. #endif /*__DRV_ADC_H__ */