user_adc.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef _USER_ADC_H__
  2. #define _USER_ADC_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "define.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define TEMPE_OWNER 0
  10. #define TEMP_INTERVAL 1000
  11. #define ADC_TASK_PRIO (configMAX_PRIORITIES - 1)
  12. #define ADC_VDDA 3300
  13. #define ADC_BUFFER_SIZE 100
  14. #if TEMPE_OWNER == 1
  15. #define TEMPE_AVG_SLOPE -4.3f //内部温度斜率mV
  16. #define TEMPE_V_25 1400.0f //25摄氏度是电压mV
  17. #define ADC_COUNT 3
  18. #else
  19. #define ADC_COUNT 2
  20. #endif
  21. #define ADC_RCC_ENABLE RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE );
  22. #define ADC_GPIO_RCC_ENABLE RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  23. #define ADC_CHANNEL ADC1
  24. /*!< GPIO define */
  25. #define LEFT_NTC_GPIO GPIOA
  26. #define LEFT_NTC_PIN GPIO_Pin_0
  27. #define LEFT_NTC_CHANNEL ADC_Channel_0
  28. #define RIGHT_NTC_GPIO GPIOA
  29. #define RIGHT_NTC_PIN GPIO_Pin_1
  30. #define RIGHT_NTC_CHANNEL ADC_Channel_1
  31. typedef struct{
  32. uint16_t left_ntc;
  33. uint16_t right_ntc;
  34. #if TEMPE_OWNER == 1
  35. float tmp_chip;
  36. #endif
  37. }adc_data_s;
  38. typedef void (*adc_upload_func)(adc_data_s data, bool tmp_stat);
  39. //初始化SAADC,配置使用的SAADC通道的参数和缓存
  40. void set_adc_upload_func(adc_upload_func func);
  41. void adc_init(void);
  42. void adc_task_start(void);
  43. uint16_t adc_task_process_event(uint8_t task_id, uint16_t events);
  44. void vUser_adc_dma_finish(void);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif // BAT_H__
  49. /** @} */