@allen 发表于 2017-5-19 16:49:09

S500 ADC使用

本帖最后由 @allen 于 2017-5-22 09:35 编辑

S500 ADC
ADC 的分辨率为10位,即1/1024。
模拟输入电压:0 ~ +3.0V。
采样频率:3.2 kHz。


比如CubieBoard6 扩展pin LRADC0 ,ADC_COM

1. 在上层,用现有class 接口,直接读取ADC的值cat /sys/class/hwmon/hwmon0/device/aux0打印 1023/1024
电压值= 3.0X1023/1024
接近最大值 3V
如果用杜邦线短接到地,再读的话为 0/ 1024 ,证明ADC 的值准确

2. 在内核层使用炬芯PMU驱动给出来的接口函数读出ADC值。此方法方便其他驱动来读ADC值。这里使用的是atc260x_ex_auxadc_read_by_name,详情请看include/linux/mfd/atc260x/atc260x.h 头文件。#include <linux/time.h>
#include <linux/mfd/atc260x/atc260x.h>

u8ret=0;
u32 d;
ret=atc260x_ex_auxadc_read_by_name("AUX0",&d);
if(ret < 0)
    printk("cannot get the AUX0 correct translation data!\n");
printk("AUX0 value=%d\n",d);
ret=atc260x_ex_auxadc_read_by_name("AUX2",&d);
if(ret < 0)
    printk("cannot get the AUX2 correct translation data!\n");
printk("AUX2 value=%d\n",d);
页: [1]
查看完整版本: S500 ADC使用