30 #include "fsl_os_abstraction.h"
64 #define MAX_GYRO_FULL_SCALE_RANGE 2
66 #define FXAS21002_SAMPLE_PERIOD_MAX 640000 // Maximum sample period supported by the FXAS21002.
67 #define FXAS21002_SAMPLE_PERIOD_MIN 5000 // Minimum sample period supported by the FXAS21002.
68 #define GET_ODR_CONFIG 0x0 // Flag enables the configuration value.
69 #define GET_ODR_VALUE 0x01 // Flag enables the ODR value.
71 #define MAX_FXAS21002_DM_BYTES 0x16 // Maximum number of read/write using direct device messaging to address the registers. This is the maximum number of register in 8700.
72 #define NUM_INTERNAL_ADDRESS_BYTES 0x1 // Size of the internal address byte.
115 { 0.200, 0.0, 13107, 0},
116 { 0.100, 0.0, 6554, 0},
117 { 0.050, 0.0, 3277, 0},
118 { 0.025, 0.0, 1638, 0}
122 { 0.0625, 0.0, 4096, 0},
123 { 0.03125, 0.0, 2048, 0},
124 { 0.01563, 0.0, 1024, 0},
125 { 0.00782, 0.0, 512, 0}
135 #define MAX_DATA_READ_SIZE 6 // Maximum number of data
136 #define MAX_BUF_SIZE 6 // Maximum buffer size
142 #define TEMPERATURE_DATA_READ_SIZE 1
148 #define TEMPERATURE_BUF_SIZE 1
155 #define FXAS21002_TEMP_FLOAT_CONVERSION_FACTOR (1.0F/65536.0F)
156 #define FXAS21002_TEMP_FLOAT_CONVERSION_OFFSET 0.0
163 #define FXAS21002_TEMP_FIXED_CONVERSION_FACTOR 65536
164 #define FXAS21002_TEMP_FIXED_CONVERSION_OFFSET 0
184 if (NULL == pSensorHandle) {
198 if (NULL == pDeviceDescriptor) {
207 pCurrentSampleBuffer->
gyro[0] = 0;
208 pCurrentSampleBuffer->
gyro[1] = 0;
209 pCurrentSampleBuffer->
gyro[2] = 0;
243 if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->
deviceSemaphore, 1)){
270 if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
303 #ifdef DEBUG_READ_ALL_REGS
304 static uint8 debugRegs[120];
309 if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
322 if ((NULL == pDeviceDescriptor) || (NULL == pSpecificSettings))
333 goto unlockdescriptor;
339 goto unlockdescriptor;
365 for (
uint32 reg=0; reg < cnt ; reg++)
388 #ifdef DEBUG_READ_ALL_REGS
389 for (
int i=0; i<
sizeof(debugRegs); i++)
439 if (NULL == pSensorHandle) {
448 if (NULL == pDeviceDescriptor)
458 goto unlockdescriptor;
463 goto unlockdescriptor;
468 goto unlockdescriptor;
472 goto unlockdescriptor;
501 if(NULL == pSensorHandle){
510 if (NULL == pDeviceDescriptor)
520 goto unlockdescriptor;
529 goto unlockdescriptor;
536 goto unlockdescriptor;
583 if(NULL == pSensorHandle){
614 if (NULL == pSensorHandle) {
627 if (NULL == pDeviceDescriptor){
646 if (kStatus_OSA_Success !=OSA_SemaWait(&pDeviceDescriptor->
deviceSemaphore, OSA_WAIT_FOREVER))
648 goto unlockdescriptor;
654 goto unlockdescriptor;
660 #ifdef DEBUG_READ_ALL_REGS
661 for (
int i=0; i<
sizeof(debugRegs); i++)
691 *pFifoEntry = *pCurrentSampleBuffer;
699 pCurrentSampleBuffer,
732 void *pConvertedSample,
741 switch (convertToType)
745 pConverter = float_gyro3d_converter;
747 pConverter = fixed_gyro3d_converter;
749 pConverter = count_gyro3d_converter;
754 pConverter = float_temp1d_converter;
756 pConverter = fixed_temp1d_converter;
762 if (pConverter == NULL)
765 retStatus = pConverter(
767 (fxas21002_DataBuffer_t *)pNativeSample,
810 conversionFactor *= 2.0;
832 convertedSample->
angularVelocity[0] = (nativeSample->
gyro[0] * conversionFactor) + conversionOffset;
833 convertedSample->
angularVelocity[1] = (nativeSample->
gyro[1] * conversionFactor) + conversionOffset;
834 convertedSample->
angularVelocity[2] = (nativeSample->
gyro[2] * conversionFactor) + conversionOffset;
846 convertedSample->
angularVelocity[0] = (nativeSample->
gyro[0] * conversionFactor) + conversionOffset;
847 convertedSample->
angularVelocity[1] = (nativeSample->
gyro[1] * conversionFactor) + conversionOffset;
848 convertedSample->
angularVelocity[2] = (nativeSample->
gyro[2] * conversionFactor) + conversionOffset;
882 uint8 buffer[1] = {0x00};
886 if (whoami == buffer[0]) {
988 if(fxas21000_odrTable[i].periodNormalMode == samplePeriod)
1007 if(fxas21002_odrTable[i].periodNormalMode == samplePeriod)
isf_timestamp_t timestamp
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
isf_temperature_degC_float_t temperature
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 ...
void * pSensorSpecificSettings
the structure defines the ODR table between Hybrid and normal mode of FXAS21000 operation.
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. ...
#define FXAS21002_TEMP_FIXED_CONVERSION_FACTOR
FXAS21002 temperature conversion to store in ISF sensors standard fixed point temperature (degC) ...
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.
Standard fixed type for three axis accelerometers.
int32 fxas21002_Status_t
FXAS21002 internal return codes.
#define FXAS21002_ACTIVE_MASK
#define MAX_DATA_READ_SIZE
isf_timestamp_t timestamp
const struct @15 fxas21002GyroConvTable[]
const uint8 fxas21002_extendAddress[]
The table that describes the extended address space.
uint32 isf_time_util_get_usec(void)
This API returns the time in microseconds.
isf_status_t dm_device_open(dm_ChannelDescriptor_t *apChannelDescriptor, void *apDevice, dm_DeviceDescriptor_t *apDeviceDescriptor)
This function creates a device handle for a device at a specified channel address.
This structure defines the dummy DSA data buffer format.
The fsl_fxas21002_i2cspi_3D_gyro.h file contains the definitions and functions supporting the FXAS210...
isf_dsa_ControlData_t controlData
isf_fifo_status_t isf_fifo_lock(isf_fifo_t *pFifo)
Lock a sample buffer for exclusive access.
comm_State_t dm_channel_get_state(dm_ChannelDescriptor_t *apChannelDescriptor)
This function returns the channel state.
isf_fifo_status_t isf_fifo_unlock(isf_fifo_t *pFifo)
Release the exclusive access lock on a sample buffer.
Standard floating point type for single axis temperature sensor.
isf_SensorTypes_t fxas21002_SupportedSensorTypes[]
Supported sensor and data types for FXAS21002.
isf_fifo_status_t isf_fifo_el_increment(isf_fifo_t *pFifo)
Routine increments the insert pointer after direct access.
isf_sensors.h contains the ISF Generic Sensor definitions and data structures required when a client ...
const struct @15 fxas21000GyroConvTable[]
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
dm_DeviceDescriptor_t deviceHandle
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
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.
#define FXAS21002_ZYXDR_MASK
Define the sensor device descriptor.
#define FXAS21002_WHOAMI_VALUE_RELEASE
The fxas21002.h file contains the FXAS21002 Magnetometer register definitions, access macros...
#define FXAS21002_TEMP_FLOAT_CONVERSION_FACTOR
FXAS21002 temperature conversion to store in ISF sensors standard floating point temperature (degC) ...
dm_ChannelDescriptor_t cDescriptor
isf_status_t dm_device_write(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apWriteBuffer, uint32 aBuffsize, uint32 aNbyteWrite)
This function writes to a device.
isf_status_t bm_unregister_callback(bm_callback_token_t aToken)
This API unregisters one or more callbacks.
isf_timestamp_t timestamp
#define FXAS21002_WHOAMI_VALUE_PRE_RELEASE
const fxas21002_ODR_Table_t fxas21002_odrTable[]
The table that describes the configuration value based on ODR (output data rate). Note: This table is...
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
#define FXAS21000_WHOAMI_VALUE
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.
isf_temperature_degC_fixed_32s1i16_t temperature
Standard raw type for three axes accelerometers.
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
The isf_gyrometer_types.h file contains the ISF data type definitions for use with the ISF generic gy...
uint16 isf_swap2byte(uint16 n)
2 byte swapping method
Standard float type for three axis accelerometers.
isf_gyrometer_dps_fixed_32s1i16_t angularVelocity[3]
isf_timestamp_t timestamp
isf_status_t dm_channel_acquire_lock(dm_ChannelDescriptor_t *apChannelDescriptor, isf_duration_t aTimeout)
This function locks the channel for exclusive access.
The isf_sensor_types.h contains the enumerated list of sensor types used by ISF.
The isf_util.h file contains the utility method declarations and macros.
#define FXAS21002_SET_FIELD(name, val)
enum isf_dsa_result_enums isf_dsa_result_types_t
bm_callback_token_t bm_register_periodic_callback(isf_duration_t aPeriod, bm_callback_t *pCallback, void *pCbData)
This API schedules a callback at the specified period.
isf_gyrometer_dps_raw_16count_t angularVelocity[3]
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...
isf_dsa_result_types_t resultFormat
isf_status_t dm_channel_init(dm_ChannelId_t aChannelId, dm_ChannelDescriptor_t *apChannelDescriptor)
This function initializes a channel.
The isf_temperature_fixed_t.h file contains the ISF data type definitions for use with the ISF generi...
isf_status_t bm_stop(bm_callback_token_t aTokens)
This API stops one or more callback(s) by setting them to the inactive state.
const isf_SensorConfig_t * pSensorStaticConfig
isf_status_t bm_start(boolean aSync, bm_callback_token_t aTokens)
This API sets one or more callback(s) to the active state.
uint32 isf_duration_t
ISF time duration in microseconds.
isf_SensorDataTypes_t resultType
Main ISF header file. Contains code common to all ISF components.
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
#define FXAS21002_TEMP_FIXED_CONVERSION_OFFSET
isf_dsa_AdapterStatus_t adapterStatus
sys_channelId_t channelId
#define TEMPERATURE_DATA_READ_SIZE
Size of Device Temperature Data to be Read.
Standard fixed type for single axis pressure sensor.
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 .
isf_timestamp_t timestamp
isf_SensorDataTypes_t fxas21002_SupportedDataTypes[]
isf_fifo_t * pSampleBufferInfo
isf_status_t dm_device_read(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apReadBuffer, uint32 aBuffsize, uint32 aNbyteRead)
This function reads from a device.
void fsl_fxas21002_i2cspi_3D_gyro_PeriodicCallback(void *pSensorHandle)
The callback function for the Bus Manager(BM).
#define BM_ERROR
This value specifies a general Bus Manager error. If an error occurs in registering a callback...
isf_gyrometer_dps_float_t angularVelocity[3]
int32 isf_status_t
ISF return status type.
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.
This defines the DSA sensor configuration parameter structure configuring the sensor settings by a su...
isf_comm.h defines the common types for the Communications Service Family of the Intelligent Sensing ...
isf_dsa_SensorSettings_t sensorSettings
#define FXAS21002_TEMP_FLOAT_CONVERSION_OFFSET
enum fxas21002_Power_tag fxas21002_Power_t
Enumeration for the FXAS21002 power modes.
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
isf_status_t dm_channel_release_lock(dm_ChannelDescriptor_t *apChannelDescriptor)
This function releases exclusive channel access.
const fxas21000_ODR_Table_t fxas21000_odrTable[]
The table that describes the configuration value based on ODR (output data rate). Note: This table is...
This structure defines a handle for the device.
#define FXAS21002_READY_MASK
fxas21002_Sensor_Specific_Reg_t regPairs[]
#define TEMPERATURE_BUF_SIZE
Size of Temperature buffer size.
semaphore_t deviceSemaphore
This structure is a declaration of a channel descriptor type.
bm_callback_token_t token
the structure defines the ODR table between Hybrid and normal mode of FXAS21002 operation.