45 #define MAG3110_COUNTSPERUT 10 // fixed range for MAG3110 magnetometer 92 #if (MAG_ODR_HZ <= 10) // select 10Hz ODR 94 #elif (MAG_ODR_HZ <= 30) // select 20Hz ODR (to give lower noise with standard 25Hz build) 96 #elif (MAG_ODR_HZ <= 40) // select 40Hz ODR 98 #else // select 80Hz ODR 141 uint8_t I2C_Buffer[6];
151 sample[
CHX] = (I2C_Buffer[0] << 8) | I2C_Buffer[1];
152 sample[
CHY] = (I2C_Buffer[2] << 8) | I2C_Buffer[3];
153 sample[
CHZ] = (I2C_Buffer[4] << 8) | I2C_Buffer[5];
156 sample[
CHZ] = -sample[
CHZ];
The sensor_drv.h file contains sensor state and error definitions.
#define MAG3110_COUNTSPERUT
registerreadlist_t MAG3110_DATA_READ[]
#define __END_WRITE_DATA__
void * bus_driver
should be of type (ARM_DRIVER_I2C* for I2C-based sensors, ARM_DRIVER_SPI* for SPI) ...
#define CHY
Used to access Y-channel entries in various data data structures.
int8_t MAG3110_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
const registerwritelist_t MAG3110_IDLE[]
float fuTPerCount
uT per count
#define MAG_FIFO_SIZE
FXOS8700 (mag), MAG3110 have no FIFO so equivalent to 1 element FIFO.
int32_t Sensor_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerreadlist_t *pReadList, uint8_t *pOutBuffer)
Read register data from a sensor.
uint8_t iWhoAmI
sensor whoami
#define __END_READ_DATA__
bool isEnabled
true if the device is sampling
The top level fusion structure.
int8_t MAG3110_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
The mag3110.h contains the MAG3110 Magnetic sensor register definitions, access macros, and device access functions.
struct MagSensor Mag
magnetometer storage
uint16_t addr
I2C address if applicable.
void addToFifo(union FifoSensor *sensor, uint16_t maxFifoSize, int16_t sample[3])
addToFifo is called from within sensor driver read functions
The sensor_fusion.h file implements the top level programming interface.
The FifoSensor union allows us to use common pointers for Accel, Mag & Gyro logical sensor structures...
#define CHZ
Used to access Z-channel entries in various data data structures.
uint16_t isInitialized
Bitfields to indicate sensor is active (use SensorBitFields from build.h)
registerDeviceInfo_t deviceInfo
I2C device context.
Provides function prototypes for driver level interfaces.
const registerwritelist_t MAG3110_Initialization[]
const registerreadlist_t MAG3110_DR_STATUS_READ[]
#define CHX
Used to access X-channel entries in various data data structures.
int16_t iCountsPeruT
counts per uT
void conditionSample(int16_t sample[3])
conditionSample ensures that we never encounter the maximum negative two's complement value for a 16-...
const registerreadlist_t MAG3110_WHO_AM_I_READ[]
int32_t Register_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
The interface function to read a sensor register.
This structure defines the Write command List.
This structure defines the Read command List.
float fCountsPeruT
counts per uT
#define MAG3110_WHOAMI_VALUE
int8_t MAG3110_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
An instance of PhysicalSensor structure type should be allocated for each physical sensors (combo dev...
The sensor_io_i2c.h file declares low-level interface functions for reading and writing sensor regist...
int32_t Sensor_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)
Write register data to a sensor.