MDKA5D3x-EK开发板I2C扩展ADC_ADS1110,cortex a5 linux3.6.9,Device Tree(DTB,FTD)

MDKA5D3x-EK开发板I2C扩展ADC_ADS1110,cortex a5 linux3.6.9,Device Tree(DTB,FTD)


by Mcuzone


MDKA5D3x-EK开发板TWI1通过I2C扩展ADC_ADS1110

关键字:

ARM cortex a5
Atmel sama5d31 sama5d33 sama5d34 sama5d35
linux kernel 3.x;linux3.6.9
Device Tree Blob (DTB,FDT,DTS)
ADC ads1110 drivers

硬件原理图:


Device Tree

i2c1: i2c@f0018000 {
        ads1110: adc@48 {
                compatible = "ti,ads1110ED0";
                reg = <0x48>;
        };
};

关于device tree, 请参考:
http://devicetree.org/Main_Page
http://elinux.org/Device_Trees
https://events.linuxfoundation.org/images/stories/pdf/lf_elc12_abraham.pdf

ads1110 driver
#include

#ifdev CONFIG_OF
static const struct of_device_id ads1110_of_match[] __devinitconst = {
        { .compatible = "ti,ads1110ED0" },
        {}
};
MOUDLE_DEVICE_TABLE(of,ads1110_of_match);
#endif

static struct i2c_driver ads1110_driver = {
      .driver = {
             xxx
        .of_match_table = of_match_ptr(ads1110_of_match),
        },
              xxxx
};

测试:

    [root@mcuzone root]#insmod ads1110drvb.ko
ads1110_probe in single address mode for ads1110ED0
adc_ads1110 0-0048: ads1110_validate got 7a aa c 0 from addr[0x48]
adc_ads1110 0-0048: chip found, address=0x48, driver version 0.0.1
adc_ads1110 0-0048: ads1110_probe char dev added, major=250 minor=0
ads1110_init Oct 25 2013 12:34:32, return 0
[root@mcuzone root]#cp /mnt/mmc/mmcblk0p1/tst_ads1110 .
[root@mcuzone root]#./tst_ads1110
adc_ads1110 0-0048: ads1110_open for major 250 minor 0
adc_ads1110 0-0048: ads1110_ioctl got cmd = 40044119 dat = 1900
adc_ads1110 0-0048: set PGA: cr = 0xc
set adc_ads1110 0-0048: ads1110_ioctl got cmd = 40044128 dat = 328
PGA [adc_ads1110 0-0048: set SPS: cr = 0xc
0]=0
set SPS [0]=0
ads1110_read enter
adc_ads1110 0-0048: ads1110_read exit with result=4
Readadc_ads1110 0-0048: ads1110_close
[4] char: [7a] [aa] [c] [0]
new data read
Data Rate: 15SPS
GAIN: 1
input 1962mV
[root@mcuzone root]# 

需要注意的是I2C需要有上拉电阻,ADS1110有8个地址需要确认,其他更详细的关于ADS1110的精度、采样率、输入范围等请参考芯片数据手册。


没有更多推荐了,返回首页