23 #include "Ac_Fixed_utils.h"
61 if ( NULL == pSensorHandle){
77 if (NULL == pDeviceDescriptor) {
126 if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->
deviceSemaphore, 1)){
151 if ((NULL == pSensorHandle) || (NULL == pSubSettings)) {
177 #ifdef DEBUG_READ_ALL_REGS
178 static uint8 debugRegs[18];
183 if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
194 if (NULL == pDeviceDescriptor)
205 goto unlockdescriptor;
210 if ( pConfigSpecific->configureCommands.numCommands > 0)
215 if (pDeviceDescriptor->
token)
222 goto unlockdescriptor;
255 if(NULL == pSensorHandle){
266 if (NULL == pDeviceDescriptor)
276 goto unlockdescriptor;
286 goto unlockdescriptor;
316 if(NULL == pSensorHandle){
328 if (NULL == pDeviceDescriptor)
338 goto unlockdescriptor;
348 goto unlockdescriptor;
352 if ( pConfigSpecific->endDataCommands.numCommands > 0)
402 if(NULL == pSensorHandle){
416 if ( pConfigSpecific->shutdownCommands.numCommands > 0)
443 if(NULL == pSensorHandle){
457 if (NULL == pDeviceDescriptor){
465 if (kStatus_OSA_Success != OSA_SemaWait(&pDeviceDescriptor->
deviceSemaphore, OSA_WAIT_FOREVER))
467 goto unlockdescriptor;
474 goto unlockdescriptor;
502 pCurrentSampleBuffer,
533 void *pConvertedSample,
542 switch (convertToType)
546 pConverter = float_mma955x_converter;
548 pConverter = fixed_mma955x_converter;
554 if (pConverter == NULL)
557 retStat = pConverter(
559 (mma955x_DataBuffer_t *)pNativeSample,
585 st = float_mma955x_converter(pSC, nativeSample, &floatSample);
605 if ( pConfigSpecific->validateSettingsCommands.numCommands > 0)
607 *status =
mma955x_send(pDeviceHandle, &pConfigSpecific->validateSettingsCommands);
629 pConfigSpecific->sampleDataOffset,
630 pConfigSpecific->sampleDataSize,
646 if ( pConfigSpecific->getPedometerDataCommands.numCommands > 0)
654 pConfigSpecific->commandReadOffset,
655 pConfigSpecific->commandReadSize,
681 if ( pConfigSpecific->readConfigCommands.numCommands > 0)
689 pConfigSpecific->commandReadOffset,
690 pConfigSpecific->commandReadSize,
720 for(i=0; i<pConfigSpecific->writeConfigCommands.commands->nByteWrite; i++)
722 buffer[i] = pConfigSpecific->writeConfigCommands.commands->pWriteBuffer[i];
725 for(j=0; j<pConfigSpecific->commandReadSize; i++,j++)
727 buffer[i] = ((
uint8*)pConfig)[j];
737 pConfigSpecific->writeConfigCommands.commands->offset,
754 retStat =
dm_device_read(pDeviceHandle, offset, pBuffer, numBytes, numBytes);
794 uint8 cmdComplete = 0;
796 uint8 buffer[2] = { 0x00, 0xFF };
807 cmdComplete = buffer[1] & 0x80;
809 if (!cmdComplete) OSA_TimeDelay(1);
812 return buffer[1] & 0x7F;
isf_dsa_status_t fsl_mma955x_EndData(isf_SensorHandle_t *pSensorHandle)
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
int32 mma955x_GetPedometerData(isf_SensorHandle_t *pSensorHandle, mma955x_PedometerData_t *pData)
void * pSensorSpecificSettings
uint16 sleep_count_threshold
Standard fixed type for three axis accelerometers.
isf_dsa_status_t fsl_mma955x_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_timestamp_t timestamp
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_status_t fsl_mma955x_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
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.
LWSEM_STRUCT deviceSemaphore
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 ...
dm_ChannelDescriptor_t * pChannelDescriptor
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
int32 mma955x_send(dm_DeviceDescriptor_t *pDeviceHandle, const mma955x_CommandList_t *aCommandList)
const uint8 engFixedIntegerWidth
isf_dsa_status_t fsl_mma955x_Convert(volatile isf_SensorHandle_t *pSensorHandle, isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType, void *pNativeSample, void *pConvertedSample, int32 *numBytes)
This function converts the raw sample data to the desired output type.
int32 mma955x_GetData(int32_t *status, isf_SensorHandle_t *pSensorHandle, void *pBuffer)
This function retrieves the raw data from the MAG3110 sensor.
bm_callback_token_t token
int32 mma955x_read(dm_DeviceDescriptor_t *pDeviceHandle, int32 offset, int32 numBytes, uint8 *pBuffer)
void fsl_mma955x_PeriodicCallback(void *pSensorHandle)
void mma955xSetSamplingRate(uint32 index)
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.
int32 mma955x_WriteConfig(isf_SensorHandle_t *pSensorHandle, mma955x_appConfigRegister_t *pConfig)
isf_dsa_status_t fsl_mma955x_Initialize(isf_SensorHandle_t *pSensorHandle)
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
isf_dsa_status_t fsl_mma955x_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
isf_acceleration_g_fixed_32s1i16_t accel[3]
isf_dsa_status_t fsl_mma955x_Shutdown(isf_SensorHandle_t *pSensorHandle)
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
mma955x_PedometerData_t pedometerData
isf_acceleration_g_float_t accel[3]
This structure defines the Pedometer sample data buffer format.
uint8 *const pWriteBuffer
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.
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.
uint16 pedometer_status_register
mma955x_appConfigRegister_t localCfgBuffer
dm_DeviceDescriptor_t deviceHandle
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.
uint32 float32_To_AcFixed(float fN, uint8 W, uint8 I, uint8 S, int32 *status)
This function converts an IEEE-754 32-bit floating point number into a fixed point integer format...
const mma955x_CommandList_t startDataCommands
This structure defines the Pedometer Native data buffer format.
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.
uint8 mma955x_waitForCoCo(dm_DeviceDescriptor_t *pDeviceHandle)
mma955x_appConfigRegister_t configData
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.
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
uint16 activity_count_threshold
Standard float type for three axis accelerometers.
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...
isf_SensorDataTypes_t mma955x_SupportedDataTypes[]
int32 isf_status_t
ISF return status type.
This defines the DSA sensor configuration parameter structure configuring the sensor settings by a su...
const mma955x_Command_t * commands
isf_comm.h defines the common types for the Communications Service Family of the Intelligent Sensing ...
isf_dsa_SensorSettings_t sensorSettings
isf_timestamp_t timestamp
int32 mma955x_GetConfig(isf_SensorHandle_t *pSensorHandle, mma955x_appConfigRegister_t *pConfig)
The mma955x.h contains the mma955x Intelligent Sensor register definitions, access macros...
const uint8 engFixedSignBit
isf_dsa_status_t fsl_mma955x_StartData(isf_SensorHandle_t *pSensorHandle)
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
mma955x_DataBuffer_t * pCurrentSample
isf_status_t dm_channel_release_lock(dm_ChannelDescriptor_t *apChannelDescriptor)
This function releases exclusive channel access.
isf_SensorTypes_t mma955x_SupportedSensorTypes[]
Supported sensor and data types.
const float engFloatConversionFactor
mma955x_PedometerData_t pedometerData
This structure defines a handle for the device.
void mma955x_ValidateConfig(int32_t *status, isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
This function validates the configuration for the MAG3110 sensor.
const mma955x_CommandList_t initializeCommands
const uint8 engFixedTotalWidth
This structure is a declaration of a channel descriptor type.
dm_ChannelDescriptor_t cDescriptor