19 #define FXLS8952_COUNTSPERG 512 20 #define FXLS8952_ACCEL_FIFO_SIZE 32 48 { FXLS8952_SENS_CONFIG1, 0x00, 0x00 },
58 { FXLS8952_BUF_CONFIG1, 0x20, 0x00 },
67 { FXLS8952_SENS_CONFIG2, 0x50, 0x00 },
84 #if (ACCEL_ODR_HZ <= 1) // select 0.781Hz ODR 85 { FXLS8952_SENS_CONFIG3, 0xC0, 0x00 },
86 #elif (ACCEL_ODR_HZ <= 2) // select 1.5625Hz ODR 87 { FXLS8952_SENS_CONFIG3, 0x80, 0x00 },
88 #elif (ACCEL_ODR_HZ <= 3) // select 3.125Hz ODR 89 { FXLS8952_SENS_CONFIG3, 0xA0, 0x00 },
90 #elif (ACCEL_ODR_HZ <= 6) // select 6.25Hz ODR 91 { FXLS8952_SENS_CONFIG3, 0x90, 0x00 },
92 #elif (ACCEL_ODR_HZ <= 12) // select 12.5Hz ODR 93 { FXLS8952_SENS_CONFIG3, 0x80, 0x00 },
94 #elif (ACCEL_ODR_HZ <= 25) // select 25Hz ODR 95 { FXLS8952_SENS_CONFIG3, 0x70, 0x00 },
96 #elif (ACCEL_ODR_HZ <= 50) // select 50Hz ODR 97 { FXLS8952_SENS_CONFIG3, 0x60, 0x00 },
98 #elif (ACCEL_ODR_HZ <= 100) // select 100Hz ODR 99 { FXLS8952_SENS_CONFIG3, 0x50, 0x00 },
100 #elif (ACCEL_ODR_HZ <= 200) // select 200Hz ODR 101 { FXLS8952_SENS_CONFIG3, 0x40, 0x00 },
102 #elif (ACCEL_ODR_HZ <= 400) // select 400Hz ODR 103 { FXLS8952_SENS_CONFIG3, 0x30, 0x00 },
104 #elif (ACCEL_ODR_HZ <= 800) // select 800Hz ODR 105 { FXLS8952_SENS_CONFIG3, 0x20, 0x00 },
106 #elif (ACCEL_ODR_HZ <= 1600) // select 1600Hz ODR 107 { FXLS8952_SENS_CONFIG3, 0x10, 0x00 },
108 #else // select 3200Hz ODR 109 { FXLS8952_SENS_CONFIG3, 0x00, 0x00 },
119 { FXLS8952_SENS_CONFIG1, 0x03, 0x00 },
134 if (reg==FXLS8952_WHOAMI_VALUE) {
135 sfg->Accel.iWhoAmI = reg;
153 sfg->Accel.isEnabled =
true;
163 uint8_t sensor_fifo_count = 1;
174 sensor_fifo_count = I2C_Buffer[0] & 0x3F;
177 if (sensor_fifo_count == 0)
return status;
182 FXLS8952_DATA_READ[0].
numBytes = 6 * sensor_fifo_count;
187 for (j = 0; j < sensor_fifo_count; j++)
190 sample[
CHX] = (I2C_Buffer[6 * j + 1] << 8) | I2C_Buffer[6 * j + 0];
191 sample[
CHY] = (I2C_Buffer[6 * j + 3] << 8) | I2C_Buffer[6 * j + 2];
192 sample[
CHZ] = (I2C_Buffer[6 * j + 5] << 8) | I2C_Buffer[6 * j + 4];
206 { FXLS8952_SENS_CONFIG1, 0x00, 0x01 },
217 sfg->Accel.isEnabled =
false;
223 #endif // if F_USING_ACCEL #define FXLS8952_ACCEL_FIFO_SIZE
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.
#define F_USING_ACCEL
nominally 0x0001 if an accelerometer is to be used, 0x0000 otherwise
Provides function prototypes for driver level interfaces.
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.
#define FXLS8952_COUNTSPERG
An instance of PhysicalSensor structure type should be allocated for each physical sensors (combo dev...
void conditionSample(int16_t sample[3])
conditionSample ensures that we never encounter the maximum negative two's complement value for a 16-...
int8_t FXLS8952_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
#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
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.
#define ACCEL_FIFO_SIZE
FXOS8700 (accel), MMA8652, FXLS8952 all have 32 element FIFO.
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.
The sensor_fusion.h file implements the top level programming interface.
#define __END_READ_DATA__
int8_t FXLS8952_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
uint16_t isInitialized
Bitfields to indicate sensor is active (use SensorBitFields from build.h)
int8_t FXLS8952_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
This structure defines the Read command List.
#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...
uint16_t addr
I2C address if applicable.
The sensor_io_i2c.h file declares low-level interface functions for reading and writing sensor regist...