CubieBoard中文论坛

 找回密码
 立即注册
搜索
热搜: unable
查看: 6460|回复: 0

S500 ADC使用

[复制链接]
发表于 2017-5-19 16:49:09 | 显示全部楼层 |阅读模式
本帖最后由 @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的值
  1. 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 头文件。
  1. #include <linux/time.h>
  2. #include <linux/mfd/atc260x/atc260x.h>

  3. u8  ret=0;
  4. u32 d;
  5. ret=atc260x_ex_auxadc_read_by_name("AUX0",&d);
  6. if(ret < 0)
  7.     printk("cannot get the AUX0 correct translation data!\n");
  8. printk("AUX0 value=%d\n",d);
  9. ret=atc260x_ex_auxadc_read_by_name("AUX2",&d);
  10. if(ret < 0)
  11.     printk("cannot get the AUX2 correct translation data!\n");
  12. printk("AUX2 value=%d\n",d);
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|粤ICP备13051116号|cubie.cc---深刻的嵌入式技术讨论社区

GMT+8, 2024-4-19 15:45 , Processed in 0.021037 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2012 Comsenz Inc. | Style by Coxxs

返回顶部