ADC Hal interface documentation#
Hardware introduction#
K230 integrates an ADC converter with a total of 6 channels and a resolution of 12bit.
Function interface description#
int drv_adc_init(void);#
Function: Initialize ADC driver.
Return Value:
0: initialization successful-1: Failed to open device
int drv_adc_deinit(void);#
Function: Deinitialize ADC driver.
Return Value:
0: Success
uint32_t drv_adc_read(int channel);#
Function: Read the ADC original value of the specified channel (integer, 12bit).
parameter:
channel: ADC channel number, range[0, DRV_ADC_MAX_CHANNEL - 1]
Return Value:
When valid: ADC raw reading, range
0~4095When invalid: return
UINT32_MAX
uint32_t drv_adc_read_uv(int channel, uint32_t ref_uv);#
Function: Read the voltage value of the specified channel (unit: μV).
parameter:
channel: ADC channel numberref_uv: reference voltage value, unit is μV (if the default 1.8V is used, passDRV_ADC_DEFAULT_REF_UV)
Return Value:
Converted voltage value (μV)
Example#
Please refer to src/rtsmart/libs/testcases/rtsmart_hal/test_adc.c
