109 unsigned tempCounter = 0;
110 bool isInitialized =
false;
112 enum Registers : uint8_t
114 OFFSET_X_REG_L = 0x45,
115 OFFSET_X_REG_H = 0x46,
116 OFFSET_Y_REG_L = 0x47,
117 OFFSET_Y_REG_H = 0x48,
118 OFFSET_Z_REG_L = 0x49,
119 OFFSET_Z_REG_H = 0x4a,
128 INT_SOURCE_REG = 0x64,
129 INT_THS_L_REG = 0x65,
130 INT_THS_H_REG = 0x66,
140 TEMP_OUT_L_REG = 0x6e,
141 TEMP_OUT_H_REG = 0x6f,
144 static constexpr uint32_t WHO_AM_I_VALUE = 0x40;
145 static constexpr uint32_t CONTINUOS_CONVERSION = 0x0;
147 static constexpr float REFERENCE_TEMPERATURE = 25;
148 static constexpr float DEG_PER_LSB = 0.125;
150 static constexpr float GAUSS_PER_LSB = 0.0015;
152 static constexpr uint32_t ENABLE_TEMPERATURE_COMP = 1 << 7;
153 static constexpr uint32_t ENABLE_SELF_TEST = 1 << 1;
154 static constexpr uint32_t ENABLE_BDU = 1 << 4;
155 static constexpr uint32_t ENABLE_4WSPI = 1 << 2;
156 static constexpr uint32_t OFFSET_CANCELLATION = 1 << 1;
157 static constexpr uint32_t I2C_DISABLE = 1 << 5;
Driver for LIS2MDL, a three-axis magnetic sensor.
LIS2MDL(SPIBusInterface &bus, miosix::GpioPin pin, SPIBusConfig spiConfig, Config config)
bool init() override
Initialize the sensor.
bool applyConfig(Config config)
Overwrites the sensor settings.
LIS2MDLData sampleImpl() override
Read a data sample from the sensor. In case of errors, the method should return the last available co...
bool selfTest() override
Check if the sensor is working.
static SPIBusConfig getDefaultSPIConfig()
static PrintLogger getLogger(const string &name)
Interface for low level access of a SPI bus as a master.
Base sensor class with has to be extended by any sensor driver.
This file includes all the types the logdecoder script will decode.
unsigned temperatureDivider
Divide the temperature sampling rate.
SPI Bus configuration for a specific slave.
Contains information about a single SPI slave device.