[i2c] MAX1236 with smbus (CS5536 ACB0)

Jonathan Cameron jic23 at cam.ac.uk
Wed Oct 15 13:10:00 CEST 2008


Andreas Seidler wrote:
> Jonathan Cameron schrieb:
>> A driver that should work with this chip is part of the
>> iio subsystem, so I have a fair bit of familiarity (though
>> only via 1238 rather than this exact model)
> 
> I found this subsystem too and its promising, but it depends on RTC with
> periodic Interupts - and most of embedded hardware lacks of such RTCs.
In current code periodic interrupts are only required if you want to use
a polled ring buffer.  This is now a Kconfig option and if you turn it off
you'll still have sysfs type interfaces for reading directly from the
device.  A direct chrdev access to 'scan' the device is on the todo list,
but isn't there yet.

Hopefully (after fighting with git this afternoon) I should shortly have
a repository up so its easier for people to get the current code and to
send patches against it.

Jonathan
> 
> is it possible to attach a ds1307 for this reason?
You could, but I'd imagine this is unnecessary. 
The reason for using periodic interrupts from an rtc as an initial means
of performing periodic sampling was that I had one to hand (pxa27x)
and was being lazy.  There are lots of other ways of achieving a similar
result not requiring specialist hardware and at least one other option
will need to be available before the code is ready to go into mainline.

Jonathan
 
> 
>> Done a bit of digging around and my original test code was
>>
>> #include <fcntl.h>
>>
>> #include "i2c-dev.h"
>>
>> int main(int argc, char* argv[])
>> {
>>   
>>   struct i2c_smbus_ioctl_data arg;
>>   union i2c_smbus_data data;
>>   int adaptor_nr=atoi(argv[1]); //check this
>>   char filename[20];
>>   sprintf(filename,"/dev/i2c-%d",adaptor_nr);
>>
>>   int file;
>>   if((file = open(filename, O_RDWR))<0)
>>     {
>>       printf("could not open /dev/i2c-%u\n", adaptor_nr);
>>       exit(-1);
>>     }
>>   if(ioctl(file,I2C_SLAVE, 0x34) < 0)
>>     {
>>       printf("could not set slave address \n");
>>       return -1;
>>     }
>>   
>>   arg.size = I2C_SMBUS_BYTE;
>>   arg.read_write = I2C_SMBUS_WRITE;
>>   arg.command = I2C_SMBUS_BYTE;
>>   
>>   data.byte = 8;
>>   arg.data = &data;
>>   
>>   char buf[2] = {0x79, 0x92};
>>   write(file,  buf,2);
>>   int i;
>>   for(i = 0; i < 20; i++)
>>     {
>>       read(file,buf,2);
>>       
>>       unsigned int a =0;
>>       a = (buf[0] & 0xF) << 8 | buf[1] ;
>>       printf("reading %u\n",a);
>>
>>         sleep(1);
>>     }
>>
>> }
>>
>> No idea why I did it without using the smbus_write commands
>> though. The iio driver is i2c_transfers I'm afraid.
>>
>> as for i2c detect, I've just blugeoned it into building for
>> the pxa271 board I'm using and it picks up a max1239 just fine.
> 
> can i access the ringbuffer of this driver via sysfs or how userspace side
> should work?
> 
> 
> Regards
> Andreas
> 
> 
> _______________________________________________
> i2c mailing list
> i2c at lm-sensors.org
> http://lists.lm-sensors.org/mailman/listinfo/i2c
> 




More information about the i2c mailing list