21 #define FXAS21000_STATUS 0x00 22 #define FXAS21000_F_STATUS 0x08 23 #define FXAS21000_F_SETUP 0x09 24 #define FXAS21000_WHO_AM_I 0x0C 25 #define FXAS21000_CTRL_REG0 0x0D 26 #define FXAS21000_CTRL_REG1 0x13 27 #define FXAS21000_CTRL_REG2 0x14 28 #define FXAS21000_WHO_AM_I_VALUE 0xD1 // engineering and production 29 #define FXAS21000_COUNTSPERDEGPERSEC 20 // 1600dps range 30 #define FXAS21002_COUNTSPERDEGPERSEC 16 // for 2000dps=32000 counts 32 #define FXAS21002_GYRO_FIFO_SIZE 32 92 #if (GYRO_ODR_HZ <= 1) // select 1.5625Hz ODR 94 #elif (GYRO_ODR_HZ <= 3) // select 3.125Hz ODR 96 #elif (GYRO_ODR_HZ <= 6) // select 6.25Hz ODR 98 #elif (GYRO_ODR_HZ <= 12) // select 12.5Hz ODR 100 #elif (GYRO_ODR_HZ <= 25) // select 25.0Hz ODR 102 #elif (GYRO_ODR_HZ <= 50) // select 50.0Hz ODR 104 #elif (GYRO_ODR_HZ <= 100) // select 100.0Hz ODR 106 #else // select 200Hz ODR 159 #if (GYRO_ODR_HZ <= 12) // select 12.5Hz ODR 161 #elif (GYRO_ODR_HZ <= 25) // select 25Hz ODR 163 #elif (GYRO_ODR_HZ <= 50) // select 50Hz ODR 165 #elif (GYRO_ODR_HZ <= 100) // select 100Hz ODR 167 #elif (GYRO_ODR_HZ <= 200) // select 200Hz ODR 169 #elif (GYRO_ODR_HZ <= 400) // select 400Hz ODR 171 #else // select 800Hz ODR 189 sfg->Gyro.iWhoAmI = reg;
203 switch (sfg->Gyro.iWhoAmI) {
218 sfg->Gyro.iFIFOCount=0;
220 sfg->Gyro.isEnabled =
true;
229 uint8_t sensor_fifo_count = 1;
241 #ifdef SIMULATOR_MODE 242 sensor_fifo_count = 1;
259 FXAS21002_DATA_READ[0].
numBytes = 6;
262 for (j = 0; j < sensor_fifo_count; j++)
269 sample[
CHX] = (I2C_Buffer[0] << 8) | I2C_Buffer[1];
270 sample[
CHY] = (I2C_Buffer[2] << 8) | I2C_Buffer[3];
271 sample[
CHZ] = (I2C_Buffer[4] << 8) | I2C_Buffer[5];
281 FXAS21002_DATA_READ[0].
numBytes = 6 * sensor_fifo_count;
285 for (j = 0; j < sensor_fifo_count; j++) {
287 sample[
CHX] = (I2C_Buffer[6*j + 0] << 8) | I2C_Buffer[6*j + 1];
288 sample[
CHY] = (I2C_Buffer[6*j + 2] << 8) | I2C_Buffer[6*j + 3];
289 sample[
CHZ] = (I2C_Buffer[6*j + 4] << 8) | I2C_Buffer[6*j + 5];
315 sfg->Gyro.isEnabled =
false;
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
#define F_USING_GYRO
nominally 0x0004 if a gyro is to be used, 0x0000 otherwise
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.
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...
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
#define FXAS21000_COUNTSPERDEGPERSEC
#define FXAS21002_F_STATUS_F_CNT_MASK
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.
int8_t FXAS21002_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
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 fxas21002.h contains the fxas21002 sensor register definitions and its bit mask.
The sensor_fusion.h file implements the top level programming interface.
#define FXAS21002_WHO_AM_I_WHOAMI_OLD_VALUE
#define __END_READ_DATA__
#define FXAS21002_GYRO_FIFO_SIZE
FXAX21000, FXAS21002 have 32 element FIFO.
#define FXAS21000_F_SETUP
int8_t FXAS21002_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
#define FXAS21000_CTRL_REG1
#define FXAS21000_WHO_AM_I_VALUE
#define FXAS21002_COUNTSPERDEGPERSEC
#define GYRO_FIFO_SIZE
FXAX21000, FXAS21002 have 32 element FIFO.
uint16_t isInitialized
Bitfields to indicate sensor is active (use SensorBitFields from build.h)
#define FXAS21002_WHO_AM_I_WHOAMI_PRE_VALUE
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.
int8_t FXAS21002_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
#define FXAS21000_CTRL_REG0
The sensor_io_i2c.h file declares low-level interface functions for reading and writing sensor regist...