This is the documentation for the latest (main) development branch. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

ADC API Reference

ADC

WM_ADC_GET_RESULT(value)

ADC get result.

struct wm_drv_adc_cfg_t
wm_device_t *wm_drv_adc_init(char *dev_name)

Initialize adc dev.

Parameters:

dev_name[in] like “adc”, if device tree set

Returns:

  • device handle: device handle, used wm_device_t

  • NULL: failed

int wm_drv_adc_deinit(wm_device_t *dev)

Deinit adc dev.

Parameters:

dev[in] use

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_cfg(wm_device_t *dev, const wm_drv_adc_cfg_t *cfg)

Set adc dev config.

Parameters:
Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_register_callback(wm_device_t *dev, wm_adc_intr_type_t intr_type, wm_drv_adc_callback_t adc_callback, void *user_data)

Register adc interrupt callback.

Parameters:
  • dev[in] use

  • intr_type[in] use

    • wm_drv_adc_intr_type_t

  • adc_callback[in] use

    • wm_drv_adc_callback_t

  • user_data[in]

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_oneshot(wm_device_t *dev, wm_adc_channel_t adc_channel, int *result)

Get adc oneshot result.

Parameters:
  • dev[in] use

  • adc_channel[in] use

    • wm_adc_channel_t

  • result[out]

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_polling(wm_device_t *dev, wm_adc_channel_t adc_channel, int *buf, uint16_t count, uint32_t timeout)

Get adc polling result.

Parameters:
  • dev[in] use

  • adc_channel[in] use

    • wm_adc_channel_t

  • buf[out] adc polling data

  • count[in] adc polling data count

  • timeout[in] not used for w800

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_start_it(wm_device_t *dev, wm_adc_channel_t adc_channel)

Start adc interrupt, you must register adc interrupt callback.

Warning

We do not recommend using this method unless you need to continuously obtain data.

Parameters:
  • dev[in] use

  • adc_channel[in] use

    • wm_adc_channel_t

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_stop_it(wm_device_t *dev, wm_adc_channel_t adc_channel)

Stop adc interrupt.

Parameters:
  • dev[in] use

  • adc_channel[in] use

    • wm_adc_channel_t

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_thermal_sensor_read_temperature(wm_device_t *dev, int *temperature_val)

Get chip inner temperature.

Parameters:
  • dev[in] use

  • temperature_val[out]

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_chip_voltage_read_vdd(wm_device_t *dev, int *voltage)

Get chip voltage.

Parameters:
Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_cal_voltage(wm_device_t *dev, int vol)

Get chip voltage.

Parameters:
  • dev[in] use

  • vol[in] adc result register value

Returns:

  • calculate voltage result