45 #define FXLS8962_COUNTSPERG 512 46 #define FXLS8962_ACCEL_FIFO_SIZE 32 100 #if (ACCEL_ODR_HZ <= 1) // select 0.781Hz ODR 102 #elif (ACCEL_ODR_HZ <= 2) // select 1.5625Hz ODR 104 #elif (ACCEL_ODR_HZ <= 3) // select 3.125Hz ODR 106 #elif (ACCEL_ODR_HZ <= 6) // select 6.25Hz ODR 108 #elif (ACCEL_ODR_HZ <= 12) // select 12.5Hz ODR 110 #elif (ACCEL_ODR_HZ <= 25) // select 25Hz ODR 112 #elif (ACCEL_ODR_HZ <= 50) // select 50Hz ODR 114 #elif (ACCEL_ODR_HZ <= 100) // select 100Hz ODR 116 #elif (ACCEL_ODR_HZ <= 200) // select 200Hz ODR 118 #elif (ACCEL_ODR_HZ <= 400) // select 400Hz ODR 120 #elif (ACCEL_ODR_HZ <= 800) // select 800Hz ODR 122 #elif (ACCEL_ODR_HZ <= 1600) // select 1600Hz ODR 124 #else // select 3200Hz ODR 151 sfg->Accel.iWhoAmI = reg;
169 sfg->Accel.isEnabled =
true;
178 uint8_t sensor_data_ready = 0;
189 sensor_data_ready = I2C_Buffer[0] & 0x80;
192 if (sensor_data_ready == 0)
return status;
201 sample[
CHX] = (I2C_Buffer[1] << 8) | I2C_Buffer[0];
202 sample[
CHY] = (I2C_Buffer[3] << 8) | I2C_Buffer[2];
203 sample[
CHZ] = (I2C_Buffer[5] << 8) | I2C_Buffer[4];
227 sfg->Accel.isEnabled =
false;
233 #endif // if F_USING_ACCEL The sensor_drv.h file contains sensor state and error definitions.
#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.
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.
#define ACCEL_FIFO_SIZE
FXOS8700 (accel), MMA8652, FXLS8952 all have 32 element FIFO.
#define __END_READ_DATA__
The top level fusion structure.
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)
#define FXLS8962_COUNTSPERG
registerDeviceInfo_t deviceInfo
I2C device context.
Provides function prototypes for driver level interfaces.
int8_t FXLS8962_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
#define CHX
Used to access X-channel entries in various data data structures.
void conditionSample(int16_t sample[3])
conditionSample ensures that we never encounter the maximum negative two's complement value for a 16-...
This file contains the FXLS8962 Accelerometer register definitions, access macros, and device access functions.
#define FXLS8962_WHOAMI_VALUE
#define FXLS8962_ACCEL_FIFO_SIZE
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.
#define F_USING_ACCEL
nominally 0x0001 if an accelerometer is to be used, 0x0000 otherwise
int8_t FXLS8962_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
int8_t FXLS8962_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.