* Re: [lm-sensors] HMC6343 [not found] ` <20090707095934.7b86524f-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> @ 2009-07-07 11:38 ` Jonathan Cameron [not found] ` <4A5333C6.3080802-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Jonathan Cameron @ 2009-07-07 11:38 UTC (permalink / raw) Cc: Hugo Meric, linux-i2c-u79uwXL29TY76Z2rM5mHXA Moved to linux-i2c, as per Jean's suggestion. > On Tue, 7 Jul 2009 01:04:30 +0000 (GMT), Hugo Meric wrote: >> Hello, >> >> I'm currently working with the HMC6343. I don't succeed to >> communicate using the i2c interface and unfortunately the company >> does not have any experience with Linux... Just to simplify things (specifically people looking for data sheets to try and answer your question) please put more details / links in for the chips you are talking about. I already use your file >> i2c-dev.h to communicate with four DS1050 Googling suggests that's a pulse-width modulator http://www.maxim-ic.com/getds.cfm?qv_pk=2614 and one SRF02, Ultrasonic range finder? http://www.robot-electronics.co.uk/htm/srf02techSer.htm and I'd >> like to know if it is possible to use it for the HMC6343 because >> the communication protocol seems to be different. http://www.magneticsensors.com/datasheets/HMC6343.pdf Basically it's protocol is a standard smbus type write byte command (address 0x19) followed by a delay (command specific) and then a read of multiple bytes (number is command dependant.) Unfortunately the device doesn't seem do anything helpful like notify you of how many bytes it is sending (as per smbus block read). I fear to make this work you'll need to write a kernel space driver. The first step is a conventional smbus send byte command. Follow this with a suitable delay. The second will need to make use of i2c_transfer with a msg looking something like char bob[6]; struct i2c_msg read_msg = { .addr = 0x19, .flags = I2C_M_RD, .len = 6, // as appropriate to the command .buf = bob, }; then i2c_transfer(adap, &read_msg, 1); should do the job. --- Jonathan Cameron ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <4A5333C6.3080802-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>]
* Re: [lm-sensors] HMC6343 [not found] ` <4A5333C6.3080802-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org> @ 2009-07-07 11:46 ` Jean Delvare [not found] ` <20090707134638.6ff1b324-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Jean Delvare @ 2009-07-07 11:46 UTC (permalink / raw) To: Jonathan Cameron; +Cc: Hugo Meric, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Tue, 07 Jul 2009 11:38:46 +0000, Jonathan Cameron wrote: > Basically it's protocol is a standard smbus type write byte command > (address 0x19) followed by a delay (command specific) and then > a read of multiple bytes (number is command dependant.) > > Unfortunately the device doesn't seem do anything helpful like notify > you of how many bytes it is sending (as per smbus block read). > > I fear to make this work you'll need to write a kernel space driver. > The first step is a conventional smbus send byte command. Follow this > with a suitable delay. The second will need to make use of > i2c_transfer with a msg looking something like > > char bob[6]; > struct i2c_msg read_msg = { > .addr = 0x19, > .flags = I2C_M_RD, > .len = 6, // as appropriate to the command > .buf = bob, > }; > > then i2c_transfer(adap, &read_msg, 1); > > should do the job. Note: this could be done from userspace too if needed. The i2c-dev interface supports raw reads and writes. -- Jean Delvare ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20090707134638.6ff1b324-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>]
* Re: [lm-sensors] HMC6343 [not found] ` <20090707134638.6ff1b324-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> @ 2009-07-07 11:54 ` Jonathan Cameron [not found] ` <4A53375B.9070304-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org> [not found] ` <874671.80619.qm@web28313.mail.ukl.yahoo.com> 0 siblings, 2 replies; 5+ messages in thread From: Jonathan Cameron @ 2009-07-07 11:54 UTC (permalink / raw) To: Jean Delvare; +Cc: Hugo Meric, linux-i2c-u79uwXL29TY76Z2rM5mHXA Jean Delvare wrote: > On Tue, 07 Jul 2009 11:38:46 +0000, Jonathan Cameron wrote: >> Basically it's protocol is a standard smbus type write byte command >> (address 0x19) followed by a delay (command specific) and then >> a read of multiple bytes (number is command dependant.) >> >> Unfortunately the device doesn't seem do anything helpful like notify >> you of how many bytes it is sending (as per smbus block read). >> >> I fear to make this work you'll need to write a kernel space driver. >> The first step is a conventional smbus send byte command. Follow this >> with a suitable delay. The second will need to make use of >> i2c_transfer with a msg looking something like >> >> char bob[6]; >> struct i2c_msg read_msg = { >> .addr = 0x19, >> .flags = I2C_M_RD, >> .len = 6, // as appropriate to the command >> .buf = bob, >> }; >> >> then i2c_transfer(adap, &read_msg, 1); >> >> should do the job. > > Note: this could be done from userspace too if needed. The i2c-dev > interface supports raw reads and writes. > Good point, I'd missed that functionality (did seem a little odd that I couldn't find it!) Method's much the same, but involves using the relevant ioctl (I2C_RDWR), in conjunction iwth an appropriately filled i2c_rdwr_ioctl_data structure. The i2c_smbus_access function in i2c-dev.h (lm-sensors version) is similar enough to show how to do it. Jonathan ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <4A53375B.9070304-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>]
* Re: HMC6343 [not found] ` <4A53375B.9070304-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org> @ 2009-07-07 12:20 ` Jean Delvare 0 siblings, 0 replies; 5+ messages in thread From: Jean Delvare @ 2009-07-07 12:20 UTC (permalink / raw) To: Jonathan Cameron; +Cc: Hugo Meric, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Tue, 07 Jul 2009 11:54:03 +0000, Jonathan Cameron wrote: > Jean Delvare wrote: > > Note: this could be done from userspace too if needed. The i2c-dev > > interface supports raw reads and writes. > > > Good point, I'd missed that functionality (did seem a little odd > that I couldn't find it!) > > Method's much the same, but involves using the relevant ioctl > (I2C_RDWR), in conjunction iwth an appropriately filled > i2c_rdwr_ioctl_data structure. > > The i2c_smbus_access function in i2c-dev.h (lm-sensors version) > is similar enough to show how to do it. Actually: i2c-tools version of i2c-dev.h As some point in the future I'll try to get it generated from the kernel's one so that it gets integrated into the standard kernel-headers package. But this involves moving some of the helper functions to a new library and I could never find the time to set this up. -- Jean Delvare ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <874671.80619.qm@web28313.mail.ukl.yahoo.com>]
[parent not found: <874671.80619.qm-KpgP/9vcbyPGRxTy+Q50vsz6deESKz/lQQ4Iyu8u01E@public.gmane.org>]
* Re: Re : [lm-sensors] HMC6343 [not found] ` <874671.80619.qm-KpgP/9vcbyPGRxTy+Q50vsz6deESKz/lQQ4Iyu8u01E@public.gmane.org> @ 2009-07-08 10:37 ` Jonathan Cameron 0 siblings, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2009-07-08 10:37 UTC (permalink / raw) To: Hugo Meric; +Cc: Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA Hugo Meric wrote: > > Thank you for the advice. So today I try and I finally got something > (using code on the internet: > http://www.stlinux.com/docs/manual/distribution/distribution_guide6.php#1124364 > ). The code seems right and the only problem is that I don't know how to > get the data at the end. > > After the call ioctl(file, I2C_RDWR, (unsigned long)&work_queue), the > datas are in work_queue (I hope so) but I don't know how to get the 6 > values of the HMC6343 sensor. That's a somewhat odd looking bit of code. I'm not remotely sure what they are doing with it. As I've never used this particular ioctl, Jean please correct me if I'm wrong. For some reason they've configured the messages to have length 0 and no associated data buffer. (work_queue.msgs[idx]).len = 0; //this next line is really odd. Either they were adressing a whole array //or something no where near standard. This should be fixed at the address //of the chip you are talking to. (work_queue.msgs[idx]).addr = start_address + idx; (work_queue.msgs[idx]).buf = NULL; so set len to 6 and the buf to point to a 6 byte character array. You'll also need to set .flags = I2C_M_RD in the msg in question in order to ensure a read occurs (rather than attempting to write the contents of buf. After the ioctl call, your data should be character array that you set the pointer buf to point at. Note you only want the one message to be sent after the delay after your command message (for which you can use a simple smbus write byte command). Jonathan ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-07-08 10:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <23114.97301.qm@web28307.mail.ukl.yahoo.com>
[not found] ` <20090707095934.7b86524f@hyperion.delvare>
[not found] ` <20090707095934.7b86524f-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-07 11:38 ` [lm-sensors] HMC6343 Jonathan Cameron
[not found] ` <4A5333C6.3080802-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2009-07-07 11:46 ` Jean Delvare
[not found] ` <20090707134638.6ff1b324-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-07 11:54 ` Jonathan Cameron
[not found] ` <4A53375B.9070304-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2009-07-07 12:20 ` HMC6343 Jean Delvare
[not found] ` <874671.80619.qm@web28313.mail.ukl.yahoo.com>
[not found] ` <874671.80619.qm-KpgP/9vcbyPGRxTy+Q50vsz6deESKz/lQQ4Iyu8u01E@public.gmane.org>
2009-07-08 10:37 ` Re : [lm-sensors] HMC6343 Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).