HMC6343
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...
I already use your file i2c-dev.h to communicate with four DS1050 and one SRF02, and I'd like to know if it is possible to use it for the HMC6343 because the communication protocol seems to be different.
Thank you
Hugo
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 4 lines · Hugo Meric
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...
I already use your filei2c-dev.hto communicate with four DS1050 and one SRF02, and I'd like to know if it is possible to use it for the HMC6343 because the communication protocol seems to be different.
Wrong mailing lists, sorry. I2C matters should be discussed on the linux-i2c list:
http://vger.kernel.org/vger-lists.html#linux-i2c
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Moved to linux-i2c, as per Jean's suggestion.
Quoted 6 lines · Hugo Meric
Quoted 5 lines
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
Quoted 1 line
Quoted 1 line
i2c-dev.hto 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
Quoted 2 lines
Quoted 2 lines
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
Quoted 20 lines · Jonathan Cameron
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_transferwith a msg looking something likechar bob[6];
struct i2c_msg read_msg = { .addr = 0x19, .flags = I2C_M_RD, .len = 6, // as appropriate to the command .buf = bob, };
Quoted 3 lines
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.
Signature · 1 line
Jean Delvare
Quoted 21 lines · Jean Delvare
Quoted 20 lines · Jonathan Cameron
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_transferwith a msg looking something likechar bob[6];
struct i2c_msg read_msg = { .addr = 0x19, .flags = I2C_M_RD, .len = 6, // as appropriate to the command .buf = bob, };
Quoted 7 lines
Quoted 3 lines
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
Quoted 7 lines · Jonathan Cameron
Quoted 3 lines · Jean Delvare
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!)
Quoted 6 lines
Method's much the same, but involves using the relevant ioctl (
I2C_RDWR), in conjunction iwth an appropriately filledi2c_rdwr_ioctl_datastructure.The
i2c_smbus_accessfunction ini2c-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.
Signature · 1 line
Jean Delvare
Quoted 10 lines · Hugo Meric
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 inwork_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