ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
fsl_fxas21002_i2cspi_3D_gyro.c File Reference

The FXAS21002 is a 3-axis Angular Rate Gyroscope from Freescale that supports both I2C and SPI protocols. This source file implements the interface for the FXAS21002 Sensor Adapter. It uses Device Messaging (DM), which abstracts away the differences between the I2C and SPI protocols, to communicate with the device. This choice is made via the system communication file, isf_sysconf_comms.c. This file also uses the Bus Manager (BM) to schedule a periodic callback for reading new sensor data and sending the data to the Sensor Manager (SM). More...

#include <isf.h>
#include <isf_types.h>
#include <isf_sm_api.h>
#include <isf_dsa_adapter.h>
#include <isf_bm.h>
#include <isf_sensor_types.h>
#include <isf_fifo.h>
#include <isf_gyrometer_types.h>
#include <isf_temperature_types.h>
#include <isf_comm.h>
#include <isf_util.h>
#include <isf_sensors.h>
#include "fsl_os_abstraction.h"
#include "fsl_fxas21002_i2cspi_3D_gyro.h"
#include "fxas21002.h"
Include dependency graph for fsl_fxas21002_i2cspi_3D_gyro.c:

Go to the source code of this file.

Macros

#define MAX_GYRO_FULL_SCALE_RANGE   2
 
#define FXAS21002_SAMPLE_PERIOD_MAX   640000
 
#define FXAS21002_SAMPLE_PERIOD_MIN   5000
 
#define GET_ODR_CONFIG   0x0
 
#define GET_ODR_VALUE   0x01
 
#define MAX_FXAS21002_DM_BYTES   0x16
 
#define NUM_INTERNAL_ADDRESS_BYTES   0x1
 
#define MAX_DATA_READ_SIZE   6
 
#define MAX_BUF_SIZE   6
 
#define TEMPERATURE_DATA_READ_SIZE   1
 Size of Device Temperature Data to be Read. More...
 
#define TEMPERATURE_BUF_SIZE   1
 Size of Temperature buffer size. More...
 
#define FXAS21002_TEMP_FLOAT_CONVERSION_FACTOR   (1.0F/65536.0F)
 FXAS21002 temperature conversion to store in ISF sensors standard floating point temperature (degC) More...
 
#define FXAS21002_TEMP_FLOAT_CONVERSION_OFFSET   0.0
 
#define FXAS21002_TEMP_FIXED_CONVERSION_FACTOR   65536 /* 16bits left shift */
 FXAS21002 temperature conversion to store in ISF sensors standard fixed point temperature (degC) More...
 
#define FXAS21002_TEMP_FIXED_CONVERSION_OFFSET   0
 

Functions

isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Initialize (isf_SensorHandle_t *pSensorHandle)
 This is the concrete implementation of the FXAS21002 sensor adapter initialization. More...
 
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_ValidateSettings (isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
 This is the concrete implementation of the FXAS21002 sensor adapter for validating current settings. More...
 
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Configure (isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
 This is the concrete implementation of the FXAS21002 sensor adapter for configuration. More...
 
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_StartData (isf_SensorHandle_t *pSensorHandle)
 This is the concrete implementation of the FXAS21002 sensor adapter for start Data. More...
 
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_EndData (isf_SensorHandle_t *pSensorHandle)
 This is the concrete implementation of the FXAS21002 sensor adapter for End Data. More...
 
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Calibrate (isf_SensorHandle_t *pSensorHandle, void *pCalData)
 This is the concrete implementation of the FXAS21002 sensor adapter for calibration . More...
 
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Shutdown (isf_SensorHandle_t *pSensorHandle)
 This is the concrete implementation of the FXAS21002 sensor adapter for shutdown . More...
 
void fsl_fxas21002_i2cspi_3D_gyro_PeriodicCallback (void *pSensorHandle)
 The callback function for the Bus Manager(BM). More...
 
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Convert (volatile isf_SensorHandle_t *pSensorHandle, isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType, void *pNativeSample, void *pConvertedSample, int32 *numBytes)
 This function coverts the raw sample data to the desired output type. More...
 

Variables

uint8 whoami_read_val
 
isf_SensorTypes_t fxas21002_SupportedSensorTypes [] = { TYPE_THERMOMETER, TYPE_GYROMETER_3D, TYPE_NATIVE_SENSOR_TYPE }
 Supported sensor and data types for FXAS21002. More...
 
isf_SensorDataTypes_t fxas21002_SupportedDataTypes [] = { TYPE_TEMPERATURE, TYPE_ROTATIONAL_RATE_3D , TYPE_NATIVE_SENSOR_DATA_TYPE }
 
const fxas21000_ODR_Table_t fxas21000_odrTable []
 The table that describes the configuration value based on ODR (output data rate). Note: This table is irregular after the 25HZ, so can't use FLOORLOG2 algorithm. More...
 
const fxas21002_ODR_Table_t fxas21002_odrTable []
 The table that describes the configuration value based on ODR (output data rate). Note: This table is irregular after the 25HZ, so can't use FLOORLOG2 algorithm. More...
 
struct {
   float   floatFactor
 
   float   floatOffset
 
   int32   fixedFactor
 
   int32   fixedOffset
 
fxas21000GyroConvTable []
 
struct {
   float   floatFactor
 
   float   floatOffset
 
   int32   fixedFactor
 
   int32   fixedOffset
 
fxas21002GyroConvTable []
 
const uint8 fxas21002_extendAddress [] = {FXAS21002_F_STATUS, FXAS21002_F_SETUP, FXAS21002_F_EVENT, FXAS21002_INT_SRC_FLAG}
 The table that describes the extended address space. More...
 

Detailed Description

The FXAS21002 is a 3-axis Angular Rate Gyroscope from Freescale that supports both I2C and SPI protocols. This source file implements the interface for the FXAS21002 Sensor Adapter. It uses Device Messaging (DM), which abstracts away the differences between the I2C and SPI protocols, to communicate with the device. This choice is made via the system communication file, isf_sysconf_comms.c. This file also uses the Bus Manager (BM) to schedule a periodic callback for reading new sensor data and sending the data to the Sensor Manager (SM).

File: fsl_fxas21002_i2cspi_3D_gyro.c.c

Copyright (c) 2015, Freescale Semiconductor, Inc.

Definition in file fsl_fxas21002_i2cspi_3D_gyro.c.

Macro Definition Documentation

#define FXAS21002_SAMPLE_PERIOD_MAX   640000

Definition at line 66 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define FXAS21002_SAMPLE_PERIOD_MIN   5000

Definition at line 67 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define FXAS21002_TEMP_FIXED_CONVERSION_FACTOR   65536 /* 16bits left shift */

FXAS21002 temperature conversion to store in ISF sensors standard fixed point temperature (degC)

Definition at line 163 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define FXAS21002_TEMP_FIXED_CONVERSION_OFFSET   0

Definition at line 164 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define FXAS21002_TEMP_FLOAT_CONVERSION_FACTOR   (1.0F/65536.0F)

FXAS21002 temperature conversion to store in ISF sensors standard floating point temperature (degC)

Definition at line 155 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define FXAS21002_TEMP_FLOAT_CONVERSION_OFFSET   0.0

Definition at line 156 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define GET_ODR_CONFIG   0x0

Definition at line 68 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define GET_ODR_VALUE   0x01

Definition at line 69 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define MAX_BUF_SIZE   6
#define MAX_DATA_READ_SIZE   6
#define MAX_FXAS21002_DM_BYTES   0x16

Definition at line 71 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define MAX_GYRO_FULL_SCALE_RANGE   2

Definition at line 64 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define NUM_INTERNAL_ADDRESS_BYTES   0x1

Definition at line 72 of file fsl_fxas21002_i2cspi_3D_gyro.c.

#define TEMPERATURE_BUF_SIZE   1

Size of Temperature buffer size.

Definition at line 148 of file fsl_fxas21002_i2cspi_3D_gyro.c.

Referenced by fsl_fxas21002_i2cspi_3D_gyro_PeriodicCallback().

#define TEMPERATURE_DATA_READ_SIZE   1

Size of Device Temperature Data to be Read.

Definition at line 142 of file fsl_fxas21002_i2cspi_3D_gyro.c.

Referenced by fsl_fxas21002_i2cspi_3D_gyro_PeriodicCallback().

Variable Documentation

int32 fixedFactor

Definition at line 111 of file fsl_fxas21002_i2cspi_3D_gyro.c.

int32 fixedOffset

Definition at line 112 of file fsl_fxas21002_i2cspi_3D_gyro.c.

float floatFactor

Definition at line 109 of file fsl_fxas21002_i2cspi_3D_gyro.c.

float floatOffset

Definition at line 110 of file fsl_fxas21002_i2cspi_3D_gyro.c.

const fxas21000_ODR_Table_t fxas21000_odrTable[]
Initial value:
={
{ 5000, 0},
{ 10000, 1},
{ 20000, 2},
{ 40000, 3},
{ 80000, 4},
{ 160000, 5},
{ 320000, 6},
{ 640000, 7},
}

The table that describes the configuration value based on ODR (output data rate). Note: This table is irregular after the 25HZ, so can't use FLOORLOG2 algorithm.

Definition at line 79 of file fsl_fxas21002_i2cspi_3D_gyro.c.

const { ... } fxas21000GyroConvTable[]
Initial value:
=
{
{ 0.200, 0.0, 13107, 0},
{ 0.100, 0.0, 6554, 0},
{ 0.050, 0.0, 3277, 0},
{ 0.025, 0.0, 1638, 0}
}

The table that describes the extended address space.

Definition at line 133 of file fsl_fxas21002_i2cspi_3D_gyro.c.

const fxas21002_ODR_Table_t fxas21002_odrTable[]
Initial value:
={
{ 1250, 0},
{ 2500, 1},
{ 5000, 2},
{ 10000, 3},
{ 20000, 4},
{ 40000, 5},
{ 80000, 6},
{ 80000, 7},
}

The table that describes the configuration value based on ODR (output data rate). Note: This table is irregular after the 25HZ, so can't use FLOORLOG2 algorithm.

Definition at line 94 of file fsl_fxas21002_i2cspi_3D_gyro.c.

const { ... } fxas21002GyroConvTable[]
Initial value:
=
{
{ 0.0625, 0.0, 4096, 0},
{ 0.03125, 0.0, 2048, 0},
{ 0.01563, 0.0, 1024, 0},
{ 0.00782, 0.0, 512, 0}
}
uint8 whoami_read_val