LSM303DLHC

Two of the sensors in the F3, the magnetometer and the accelerometer, are packaged in a singlecomponent: the LSM303DLHC integrated circuit. These two sensors can be accessed via an I2C bus. Eachsensor behaves like an I2C slave and has a different address.

Each sensor has its own memory where it stores the results of sensing its environment. Ourinteraction with these sensors will mainly involve reading their memory.

The memory of these sensors is modeled as byte addressable registers. These sensors can beconfigured too; that’s done by writing to their registers. So, in a sense, these sensors are verysimilar to the peripherals inside the microcontroller. The difference is that their registers arenot mapped into the microcontrollers’ memory. Instead, their registers have to be accessed via theI2C bus.

The main source of information about the LSM303DLHC is its Data Sheet. Read through it to see howone can read the sensors’ registers. That part is in:

Section 5.1.1 I2C Operation - Page 20 - LSM303DLHC Data Sheet

The other part of the documentation relevant to this book is the description of the registers. Thatpart is in:

Section 7 Register description - Page 25 - LSM303DLHC Data Sheet