drv_adc.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**************************************************************************//**
  2. *
  3. * @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2021-4-7 Wayne First version
  10. *
  11. ******************************************************************************/
  12. #ifndef __DRV_ADC_H__
  13. #define __DRV_ADC_H__
  14. #include <rtthread.h>
  15. #include "nu_adc.h"
  16. #if defined(BSP_USING_ADC_TOUCH)
  17. #include "touch.h"
  18. #endif
  19. #define TOUCH_MQ_LENGTH 64
  20. #define DEF_CAL_POINT_NUM 5
  21. typedef enum
  22. {
  23. eAdc_MF, //0
  24. eAdc_KPEF, //1
  25. eAdc_PEDEF, //2
  26. eAdc_KPUEF, //3
  27. eAdc_PEUEF, //4
  28. eAdc_TF = 8, //8
  29. eAdc_ZF, //9
  30. eAdc_NACF, //10
  31. eAdc_VBF, //11
  32. eAdc_KPCF, //12
  33. eAdc_SELFTF, //13
  34. eAdc_INTKP = 16, //16
  35. eAdc_INTTC, //17
  36. eAdc_ISR_CNT //18
  37. } E_ADC_ISR_EVENT;
  38. typedef enum
  39. {
  40. eAdc_WKPEF,
  41. eAdc_WPEDEF,
  42. eAdc_WKISR_CNT
  43. } E_ADC_WKISR_EVENT;
  44. typedef struct
  45. {
  46. ADC_CALLBACK cbfunc;
  47. uint32_t private_data;
  48. } nu_adc_cb;
  49. typedef nu_adc_cb *nu_adc_cb_t;
  50. #if defined(BSP_USING_ADC_TOUCH)
  51. typedef struct
  52. {
  53. int32_t x;
  54. int32_t y;
  55. } S_COORDINATE_POINT;
  56. typedef struct
  57. {
  58. int32_t a;
  59. int32_t b;
  60. int32_t c;
  61. int32_t d;
  62. int32_t e;
  63. int32_t f;
  64. int32_t div;
  65. } S_CALIBRATION_MATRIX;
  66. int32_t nu_adc_touch_read_xyz(uint32_t *bufX, uint32_t *bufY, uint32_t *bufZ0, uint32_t *bufZ1, int32_t dataCnt);
  67. rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch);
  68. rt_err_t nu_adc_touch_disable(void);
  69. void nu_adc_touch_detect(rt_bool_t bStartDetect);
  70. void nu_adc_touch_start_conv(void);
  71. #endif
  72. #endif /* __DRV_ADC_H__ */