api_sdadc.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _API_SDADC_H
  2. #define _API_SDADC_H
  3. /* [Warming] please use new api "thread_aupcm_callback_register" and "thread_aupcm_msg_post */
  4. /* In the new api, you should use custom msg instead of following msg */
  5. #define SDADC_DONE_TYPEDEF uint8_t
  6. #define SDADC_ALL_DONE 0
  7. #define SDADC_HALF_DONE 1
  8. typedef enum {
  9. MIC_ANALOG_CFG_NOT_RC = 0,
  10. MIC_ANALOG_CFG_NOT_R,
  11. MIC_ANALOG_CFG_NORMAL,
  12. MIC_ANALOG_CFG_DIRECT,
  13. } MIC_ADC_CFG;
  14. /* [Warming] please use new api "thread_aupcm_callback_register" and "thread_aupcm_msg_post */
  15. typedef void (*sdadc_done_callback)(SDADC_DONE_TYPEDEF msg);
  16. /**
  17. * @brief Set the sdadc sampling completion callback function
  18. This callback function will be called after sdadc_done_proc_kick is executed
  19. * @param func:callback function
  20. */
  21. /* [WARMING] please use new api thread_aupcm_callback_register */
  22. void sdadc_done_callback_set(sdadc_done_callback func);
  23. /**
  24. * @brief Triggers the adpcm thread to handle the sdadc callback function, which will be set by sdadc_done_callback_set.
  25. This function is usually called inside the sdadc interrupt function
  26. * @param type:SDADC_ALL_DONE or SDADC_HALF_DONE
  27. */
  28. /* [WARMING] please use new api thread_aupcm_msg_post */
  29. void sdadc_done_proc_kick(SDADC_DONE_TYPEDEF msg);
  30. void mic_adc_init(MIC_ADC_CFG mic_type);
  31. void mic_adc_deinit(void);
  32. /**
  33. * @brief Enable and set the bias voltage of the mic pin, mic_bias pin only map to PB1.
  34. Before use, you need to set the PB1 pin to analog output, turn off the pull up and down
  35. This function must be called after sdadc_init
  36. * @param level: [0,7], bias voltage = 1.8V + level * 0.2V
  37. * @param res: [8,4,2,1], res = 8k, 4k, 2k, 1k
  38. */
  39. void mic_bias_open(u8 level, u8 res);
  40. void mic_bias_close(void);
  41. /**
  42. * @brief Enable and set the bias voltage of the mic pin, mic_bias pin only map to PB1.
  43. Before use, you need to set the PB1 pin to analog output, turn off the pull up and down
  44. This function must be called after sdadc_init
  45. * @param level: [0,7], bias voltage = 1.8V + level * 0.2V
  46. */
  47. void mic_bias_level_set(u8 level);
  48. /**
  49. * @brief Set mic analog gain
  50. * @param level: [0,7], analog gain = -6dB + level * 6dB
  51. */
  52. void mic_analog_gain_set(u8 level);
  53. #endif //_API_SDADC_H