ADC driver api.
#define ADC_DEV_NAME "adc1"
#define ADC_DEV_CHANNEL 5
#define REFER_VOLTAGE 330
#define CONVERT_BITS (1 << 12)
static int adc_vol_sample(int argc, char *argv[])
{
rt_uint32_t value, vol;
rt_err_t ret = RT_EOK;
if (adc_dev == RT_NULL)
{
rt_kprintf("adc sample run failed! can't find %s device!\n", ADC_DEV_NAME);
return -RT_ERROR;
}
rt_kprintf("the value is :%d \n", value);
vol = value * REFER_VOLTAGE / CONVERT_BITS;
rt_kprintf("the voltage is :%d.%02d \n", vol / 100, vol % 100);
return ret;
}
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_int8_t channel)
enable the adc channel
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_int8_t channel)
read the adc value
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_int8_t channel)
disable the adc channel
#define MSH_CMD_EXPORT(...)
Definition: finsh.h:142
adc device
Definition: adc.h:87