这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

ADC API 参考

ADC

WM_ADC_GET_RESULT(value)

ADC get result.

struct wm_drv_adc_cfg_t

ADC cfg type.

wm_device_t *wm_drv_adc_init(char *dev_name)

Initialize adc dev.

参数:

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

返回:

  • device handle: device handle, used wm_device_t

  • NULL: failed

int wm_drv_adc_deinit(wm_device_t *dev)

Deinit adc dev.

参数:

dev[in] use

  • wm_device_t

返回:

  • 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.

警告

In the w80x chip, both gian1 and gain 2 in cfg need to be set to LEVEL0

参数:
返回:

  • 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.

参数:
  • dev[in] use

    • wm_device_t

  • intr_type[in] use

    • wm_drv_adc_intr_type_t

  • adc_callback[in] use

    • wm_drv_adc_callback_t

  • user_data[in]

返回:

  • 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.

参数:
  • dev[in] use

    • wm_device_t

  • adc_channel[in] use

    • wm_adc_channel_t

  • result[out] unit: millivolt

返回:

  • 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.

参数:
  • dev[in] use

    • wm_device_t

  • adc_channel[in] use

    • wm_adc_channel_t

  • buf[out] adc polling data unit: millivolt

  • count[in] adc polling data count

  • timeout[in] not used for w800

返回:

  • 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 and interrupted data will not be converted and requires calling wm_drv_adc_cal_voltage to convert voltage.

警告

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

参数:
  • dev[in] use

    • wm_device_t

  • adc_channel[in] use

    • wm_adc_channel_t

返回:

  • 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.

参数:
  • dev[in] use

    • wm_device_t

  • adc_channel[in] use

    • wm_adc_channel_t

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_thermal_sensor_read_temperature(wm_device_t *dev, int *temperature_val)

Get chip inner temperature.

参数:
  • dev[in] use

    • wm_device_t

  • temperature_val[out] unit: millidegree

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_chip_voltage_read_vdd(wm_device_t *dev, int *voltage)

Get chip voltage.

参数:
  • dev[in] use

    • wm_device_t

  • voltage[out] unit: millivolt

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_adc_cal_voltage(wm_device_t *dev, int vol)

Calculate voltage value based on register value.

参数:
  • dev[in] use

    • wm_device_t

  • vol[in] adc result register value

返回:

  • calculate voltage result