2014-02-15 02:59 AM
Hi,
I am looking for SPI driver interface for magnetometer LSM303D thanks #lsm303d-spi-driver2014-10-22 02:10 AM
Hi, I also.... You have found LSM303D.c and LSM303D.h?
2015-03-12 02:34 AM
Me also waiting platform independant LSM303D.
Unfortunatly LSM303DLHC is different and the only solution is to upgrade\modify LSM303DLHC driver library.... long time spent for that2015-03-18 06:24 AM
What processor or language do you need the driver for? The SPI interface is very easy to use. I'm trying* to use it with a Tiva LM4C129 processor, which has a SPI hardware module, but it's almost as easy to bit-bang. Here are the basic routines in C for reading and writing LSM303D registers: (assuming your processor has SPI hardware)
uint8_t read_LSM303D_reg(uint8_t reg) { uint8_t value; CLEAR_LSM303_CHIP_SELECT; SSI3_DR_R = reg|0x80; // send register number with 'read' bit set SSI3_DR_R = DUMMY_DATA; while (SSIBusy(SSI3_BASE)); SET_LSM303_CHIP_SELECT; value = SSI3_DR_R; value = SSI3_DR_R; return (value); } void write_LSM303D_reg(char *name, uint8_t reg, uint8_t value) { uint8_t temp; CLEAR_LSM303_CHIP_SELECT; SSI3_DR_R = reg; SSI3_DR_R = value; while (SSIBusy(SSI3_BASE)); SET_LSM303_CHIP_SELECT; temp = SSI3_DR_R; // empty the FIFO temp = SSI3_DR_R; } Maybe that helps? Patrick * I said ''trying'' because the LSM303D is not behaving for us and we can't get any help from ST! I can read and write the registers just fine, and I get good values for the accelerometer and magnetometer most of the time. Once in a while, the accelerometer in the LSM303D seems to lock up such that the X and Z values are the same value and never change, and the Y value is usually the same value as X and Z but varies by +/- 1 or 2 every now and then. The rest of the chip continues to work just fine, but the accelerometer is locked into this state, and it appears that no one at ST wants to address the issue. Hope you don't run into the same problems?