31 #include "fsl_os_abstraction.h"
63 #define FXOS8700_MAG_FLOAT_CONVERSION_FACTOR (0.1)
64 #define FXOS8700_MAG_FLOAT_CONVERSION_OFFSET (0.0)
65 #define FXOS8700_MAG_FIXED_CONVERSION_FACTOR (6554)
66 #define FXOS8700_MAG_FIXED_CONVERSION_OFFSET (0)
68 #define MAX_ACCEL_FULL_SCALE_RANGE 2
70 #define FXOS8700_SAMPLE_PERIOD_MAX 640000 // Maximum sample period supported by the FXOS8700.
71 #define FXOS8700_SAMPLE_PERIOD_MIN 1250 // Minimum sample period supported by the FXOS8700.
72 #define GET_ODR_CONFIG 0x0 // Flag enables the configuration value.
73 #define GET_ODR_VALUE 0x01 // Flag enables the ODR value.
75 #define NUM_STATUS_BYTES 1 // Number of status byte.
77 #define NUMBER_OF_AXES_3D 0x3 // Number of Axes for 3 dimension.
78 #define NUMBER_OF_AXES_6D 0x6 // Number of axes of 6 dimension.
79 #define MAX_NUM_AXES 0x6 // Maximum number of axes.
80 #define MAX_FXOS8700_DM_BYTES 0x79 // Maximum number of read/write using direct device messaging to address the registers,
83 #define NUM_INTERNAL_ADDRESS_BYTES 0x1 // Size of the internal address byte.
90 #define GET_MODE(mode) ((mode) <= FXOS8700_MODE_HYBRID) ? (mode) : FXOS8700_MODE_HYBRID
93 #define GET_STRUCT_MEMBER_ADDRESS(p, m) (&(p)->m)
95 #define GET_MEMBER_SIZE(p, m) sizeof((p)->m)
109 {640000, 1280000, 7},
122 { 0.000061, 0.0, 16, 0},
123 { 0.000122, 0.0, 32, 0},
124 { 0.000244, 0.0, 64, 0}
134 #define MAX_DATA_READ_SIZE (NUMBER_OF_AXES_6D * 2 + NUM_STATUS_BYTES + sizeof (extendAddress) / sizeof(uint8)) // Maximum number of data
154 if (NULL == pSensorHandle) {
169 if (NULL == pDeviceDescriptor) {
178 pCurrentSampleBuffer->
accel[0] = 0;
179 pCurrentSampleBuffer->
accel[1] = 0;
180 pCurrentSampleBuffer->
accel[2] = 0;
181 pCurrentSampleBuffer->
mag[0] = 0;
182 pCurrentSampleBuffer->
mag[1] = 0;
183 pCurrentSampleBuffer->
mag[2] = 0;
217 if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->
deviceSemaphore, 1)){
244 if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
279 #ifdef DEBUG_READ_ALL_REGS
280 static uint8 debugRegs[120];
285 if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
299 if ((NULL == pDeviceDescriptor) || (NULL == pSpecificSettings))
311 goto unlockdescriptor;
317 goto unlockdescriptor;
360 #ifdef DEBUG_READ_ALL_REGS
361 for (
int i=0; i<
sizeof(debugRegs); i++)
414 if (NULL == pSensorHandle) {
427 if (NULL == pDeviceDescriptor)
437 goto unlockdescriptor;
442 goto unlockdescriptor;
447 goto unlockdescriptor;
451 goto unlockdescriptor;
481 if(NULL == pSensorHandle){
492 if (NULL == pDeviceDescriptor)
501 goto unlockdescriptor;
509 goto unlockdescriptor;
515 goto unlockdescriptor;
563 if(NULL == pSensorHandle){
590 if (NULL == pSensorHandle) {
604 if (NULL == pDeviceDescriptor){
623 if (kStatus_OSA_Success !=OSA_SemaWait(&pDeviceDescriptor->
deviceSemaphore, OSA_WAIT_FOREVER))
625 goto unlockdescriptor;
632 goto unlockdescriptor;
638 #ifdef DEBUG_READ_ALL_REGS
639 for (
int i=0; i<
sizeof(debugRegs); i++)
645 switch(pSpecificSettings->mode)
655 pCurrentSampleBuffer->
mag[0] = 0;
656 pCurrentSampleBuffer->
mag[1] = 0;
657 pCurrentSampleBuffer->
mag[2] = 0;
665 pCurrentSampleBuffer->
accel[0] = 0;
666 pCurrentSampleBuffer->
accel[1] = 0;
667 pCurrentSampleBuffer->
accel[2] = 0;
699 *pFifoEntry = *pCurrentSampleBuffer;
707 pCurrentSampleBuffer,
739 void *pConvertedSample,
748 switch (convertToType)
752 pConverter = float_accel3d_converter;
754 pConverter = fixed_accel3d_converter;
756 pConverter = count_accel3d_converter;
761 pConverter = float_mag3d_converter;
763 pConverter = fixed_mag3d_converter;
765 pConverter = count_mag3d_converter;
771 if (pConverter == NULL)
774 retStat = pConverter(
776 (fxos8700_DataBuffer_t *)pNativeSample,
812 convertedSample->
accel[0] = nativeSample->
accel[0];
813 convertedSample->
accel[1] = nativeSample->
accel[1];
814 convertedSample->
accel[2] = nativeSample->
accel[2];
872 uint8 buffer[1] = {0x00};
875 if (whoami != buffer[0]) {
977 if(odrTable[i].periodHybridMode == samplePeriod){
981 if(odrTable[i].periodNormalMode == samplePeriod){
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
Standard raw type for three axes accelerometers.
void * pSensorSpecificSettings
#define FXOS8700_SET_FIELD(name, val)
int32 fxos8700_Status_t
FXOS8700 internal return codes.
This structure defines the dummy DSA data buffer format.
void fsl_fxos8700_i2cspi_6D_AccMag_PeriodicCallback(void *pSensorHandle)
The callback function for the Bus Manager(BM).
Standard fixed type for three axis accelerometers.
isf_timestamp_t timestamp
Standard fixed type for three axis accelerometers.
The isf_magnetometer_types.h file contains the ISF data type definitions for use with the ISF generic...
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.
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.
isf_microTeslas_raw_16count_t fieldStrength[3]
isf_timestamp_t timestamp
const struct @20 fxos8700AccelConvTable[]
#define FXOS8700_MAG_FIXED_CONVERSION_FACTOR
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 ...
isf_fieldStrength_uT_float_t fieldStrength[3]
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_fxos8700_i2cspi_6D_AccMag_Initialize(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXOS8700 sensor adapter initialization.
isf_SensorDataTypes_t TYPE_MAGNETIC_FIELD_STRENGTH_3D
const uint8 extendAddress[]
The table that describes the extended address space.
enum fxos8700_Power_tag fxos8700_Power_t
Enumeration for the FXOS8700 power modes.
Define the sensor device descriptor.
isf_microTeslas_fixed_32s1i16_t fieldStrength[3]
The fxos8700.h file describes the FXOS8700 register definition and its bit mask.
#define FXOS8700_MAG_FLOAT_CONVERSION_OFFSET
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.
#define FXOS8700_WHO_AM_I_VALUE1
FXOS8700 expected WHO_AM_I value.
#define FXOS8700_WHO_AM_I_VALUE3
isf_SensorTypes_t fxos8700_SupportedSensorTypes[]
Supported sensor and data types for FXOS8700.
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXOS8700 sensor adapter for configuration.
isf_timestamp_t timestamp
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_StartData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXOS8700 sensor adapter for start Data.
isf_acceleration_g_fixed_32s1i16_t accel[3]
#define FXOS8700_MAG_FIXED_CONVERSION_OFFSET
const fxo8700_ODR_Table_t odrTable[]
The table that describes the configuration value based on ODR (output data rate). Note: This table is...
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
This is the concrete implementation of the FXOS8700 sensor adapter for calibration ...
uint16 isf_swap2byte(uint16 n)
2 byte swapping method
isf_acceleration_g_float_t accel[3]
#define FXOS8700_WHO_AM_I_VALUE2
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.
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_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.
The isf_util.h file contains the utility method declarations and macros.
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_SensorDataTypes_t fxos8700_SupportedDataTypes[]
#define FXOS8700_ACTIVE_MASK
fxos8700_Sensor_Specific_Reg_t regPairs[]
#define FXOS8700_ZYXDR_MASK
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.
isf_timestamp_t timestamp
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.
#define FXOS8700_MAG_FLOAT_CONVERSION_FACTOR
uint32 isf_duration_t
ISF time duration in microseconds.
isf_timestamp_t timestamp
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...
isf_dsa_AdapterStatus_t adapterStatus
sys_channelId_t channelId
Standard float type for three axis accelerometers.
enum fxos8700_Mode_tag fxos8700_Mode_t
The enumeration, fxos8700_Mode_tag, defines the operational modes of the FXOS8700.
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.
#define BM_ERROR
This value specifies a general Bus Manager error. If an error occurs in registering a callback...
int32 isf_status_t
ISF return status type.
uint8 accelFullScaleRange
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_status_t fsl_fxos8700_i2cspi_6D_AccMag_Shutdown(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXOS8700 sensor adapter for shutdown . ...
isf_dsa_SensorSettings_t sensorSettings
isf_timestamp_t timestamp
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.
the structure defines the ODR table between Hybrid and normal mode of device operation.
This structure defines a handle for the device.
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_EndData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXOS8700 sensor adapter for End Data.
isf_SensorDataTypes_t TYPE_MAGNETIC_FIELD_STRENGTH_3D
The fsl_fxos8700_i2cspi_6D_AccMag.h file contains the definitions and functions supporting the FXOS87...
The isf_accelerometer_types.h file contains the ISF data type definitions for use with the ISF generi...
semaphore_t deviceSemaphore
This structure is a declaration of a channel descriptor type.
isf_acceleration_g_rawCount_t accel[3]
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXOS8700 sensor adapter for validating current settings...
bm_callback_token_t token