Note

This is the documentation for the latest development branch and may refer to features that are not available in released versions. If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

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~4095

  • When 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 number

  • ref_uv: reference voltage value, unit is μV (if the default 1.8V is used, pass DRV_ADC_DEFAULT_REF_UV)

Return Value:

  • Converted voltage value (μV)


Example#

Please refer to src/rtsmart/libs/testcases/rtsmart_hal/test_adc.c

Comments list
Comments
Log in