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