23 #include "Ac_Fixed_utils.h"
60 if ( NULL == pSensorHandle){
76 if (NULL == pDeviceDescriptor) {
111 if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->
deviceSemaphore, 1)){
136 if ((NULL == pSensorHandle) || (NULL == pSubSettings)) {
163 #ifdef DEBUG_READ_ALL_REGS
164 static uint8 debugRegs[18];
169 if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
180 if (NULL == pDeviceDescriptor)
190 goto unlockdescriptor;
195 if ( pConfigSpecific->initializeCommands.numCommands > 0)
213 if ( pConfigSpecific->configureCommands.numCommands > 0)
218 if (pDeviceDescriptor->
token)
226 goto unlockdescriptor;
259 if(NULL == pSensorHandle){
270 if (NULL == pDeviceDescriptor)
279 goto unlockdescriptor;
289 goto unlockdescriptor;
318 if(NULL == pSensorHandle){
330 if (NULL == pDeviceDescriptor)
338 goto unlockdescriptor;
346 goto unlockdescriptor;
349 if ( pConfigSpecific->endDataCommands.numCommands > 0)
398 if(NULL == pSensorHandle){
406 if ( pConfigSpecific->shutdownCommands.numCommands > 0)
434 if(NULL == pSensorHandle)
449 if (NULL == pDeviceDescriptor)
458 if (kStatus_OSA_Success != OSA_SemaWait(&pDeviceDescriptor->
deviceSemaphore, OSA_WAIT_FOREVER))
460 goto unlockdescriptor;
466 goto unlockdescriptor;
483 *pFifoEntry = *pCurrentSampleBuffer;
491 pCurrentSampleBuffer,
533 if ((NULL == pSensorHandle) || (NULL == pFlashData))
538 static bool flashingInProgress =
FALSE;
544 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
547 if(numBytes == 1 && flashingInProgress ==
FALSE && *((
uint8*)pFlashData) == 0x00)
549 flashingInProgress =
TRUE;
552 else if(numBytes == 1 && flashingInProgress ==
TRUE && *((
uint8*)pFlashData) == 0xFF)
554 flashingInProgress =
FALSE;
557 else if(numBytes >= 8 && flashingInProgress ==
TRUE)
560 #define CI_READ_WRITE_MAX_LEN 32
561 #define CI_READ_WRITE_HDR_LEN 6
562 #define CI_READ_WRITE_ADDR_LEN 2
563 uint8 bytesToPageBoundary = 0xFF - *((
uint8*)pFlashData+3) + 1;
564 uint8 bytesAfterPageBoundary = numBytes - bytesToPageBoundary - 4;
566 if(bytesToPageBoundary > 0 && bytesToPageBoundary < numBytes - 4)
572 writeFlashCommand[1] = (*((
uint8*)pFlashData+1) == 0)?0x1F&(bytesToPageBoundary):0xC0|(bytesToPageBoundary);
578 writeFlashCommand_2[1] = (*((
uint8*)pFlashData+1) == 0)?0x1F&(bytesAfterPageBoundary):0xC0|(bytesAfterPageBoundary);
579 uint8 address[] = { *((
uint8*)pFlashData+CI_READ_WRITE_ADDR_LEN+1), *((
uint8*)pFlashData+CI_READ_WRITE_ADDR_LEN) };
580 *((
uint16*)address) += bytesToPageBoundary;
583 for(
int i=0; i<bytesAfterPageBoundary;i++)
593 .pWriteBuffer = (
uint8*
const)writeFlashCommand
598 .pWriteBuffer = (
uint8*
const)writeFlashCommand_2
604 .commands = writeFlashSequence
608 status =
fxlc95000_send(&pDeviceDescriptor->deviceHandle, &writeflashCommand);
613 writeFlashCommand[1] = (*((
uint8*)pFlashData+1)== 0)?0x1F&(numBytes-4):0xC0|(numBytes-4);
615 for(
int i=CI_READ_WRITE_ADDR_LEN; i<numBytes;i++)
624 .pWriteBuffer = (
uint8*
const)writeFlashCommand
629 .commands = writeFlashSequence
633 status =
fxlc95000_send(&pDeviceDescriptor->deviceHandle, &writeflashCommand);
643 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
656 void *pConvertedSample,
665 switch (convertToType)
669 pConverter = float_fxlc95000_converter;
671 pConverter = fixed_fxlc95000_converter;
677 if (pConverter == NULL)
680 retStat = pConverter(
682 (fxlc95000_DataBuffer_t *)pNativeSample,
708 st = float_fxlc95000_converter(pSC, nativeSample, &floatSample);
799 buffer[i] = ((
uint8*)pConfig)[j];
826 retStat =
dm_device_read(pDeviceHandle, offset, pBuffer, numBytes, numBytes);
866 uint8 cmdComplete = 0;
868 uint8 buffer[2] = { 0x00, 0xFF };
879 cmdComplete = buffer[1] & 0x80;
881 if (!cmdComplete) OSA_TimeDelay(1);
884 return buffer[1] & 0x7F;
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
void * pSensorSpecificSettings
isf_dsa_status_t fsl_fxlc95000_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
uint8 nMode
sensor specific mode
Standard fixed type for three axis accelerometers.
isf_timestamp_t timestamp
const fxlc95000_CommandList_t startDataCommands
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.
const int32 sampleDataOffset
int32 fxlc95000_read(dm_DeviceDescriptor_t *pDeviceHandle, int32 offset, int32 numBytes, uint8 *pBuffer)
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.
const int32 configRegisterReadOffset
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_dsa_status_t fsl_fxlc95000_Flash(isf_SensorHandle_t *pSensorHandle, void *pFlashData, uint8 numBytes)
isf_SensorDataTypes_t fxlc95000_SupportedDataTypes[]
uint8 nCurrentResolution
Expected sensor resolution.
dm_ChannelDescriptor_t * pChannelDescriptor
const fxlc95000_CommandList_t flashPostprocessCommands
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...
const int32 configRegisterReadSize
fxlc95000_SensorSetting_t settings
dm_DeviceDescriptor_t deviceHandle
This structure defines the dummy DSA data buffer format.
const fxlc95000_CommandList_t flashPreprocessCommands
isf_dsa_status_t fsl_fxlc95000_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.
isf_dsa_status_t fsl_fxlc95000_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_dsa_status_t fsl_fxlc95000_EndData(isf_SensorHandle_t *pSensorHandle)
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.
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
int32 fxlc95000_send(dm_DeviceDescriptor_t *pDeviceHandle, const fxlc95000_CommandList_t *aCommandList)
isf_acceleration_g_fixed_32s1i16_t accel[3]
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
int32 fxlc95000_GetData(int32_t *status, isf_SensorHandle_t *pSensorHandle, void *pBuffer)
This function retrieves the raw data from the MAG3110 sensor.
isf_acceleration_g_float_t accel[3]
const fxlc95000_Command_t * commands
int32 fxlc95000_WriteConfig(isf_SensorHandle_t *pSensorHandle, fxlc95000_appConfigRegister_t *pConfig)
isf_SensorTypes_t fxlc95000_SupportedSensorTypes[]
Supported sensor and data types.
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.
int32 fxlc95000_GetConfig(isf_SensorHandle_t *pSensorHandle, fxlc95000_appConfigRegister_t *pConfig)
enum isf_dsa_result_enums isf_dsa_result_types_t
const uint8 engFixedIntegerWidth
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.
uint32 nCurrentReportRate
Sample period in microseconds.
The fxlc95000.h contains the FXLC95000 Intelligent Sensor register definitions, access macros...
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...
bm_callback_token_t token
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.
isf_dsa_status_t fsl_fxlc95000_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
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
unsigned short int uint16
#define CI_READ_WRITE_HDR_LEN
const fxlc95000_CommandList_t validateSettingsCommands
Standard float type for three axis accelerometers.
isf_dsa_status_t fsl_fxlc95000_StartData(isf_SensorHandle_t *pSensorHandle)
fxlc95000_DataBuffer_t * pCurrentSample
isf_dsa_status_t fsl_fxlc95000_Initialize(isf_SensorHandle_t *pSensorHandle)
semaphore_t deviceSemaphore
isf_dsa_status_t fsl_fxlc95000_Shutdown(isf_SensorHandle_t *pSensorHandle)
#define CI_READ_WRITE_ADDR_LEN
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...
const uint8 engFixedTotalWidth
dm_ChannelDescriptor_t cDescriptor
void fsl_fxlc95000_PeriodicCallback(void *pSensorHandle)
int32 isf_status_t
ISF return status type.
This defines the DSA sensor configuration parameter structure configuring the sensor settings by a su...
const float engFloatConversionFactor
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
uint32 isf_swap4byte(uint32 n)
4 byte swapping method
void fxlc95000_ValidateConfig(int32_t *status, isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
This function validates the configuration for the MAG3110 sensor.
const fxlc95000_CommandList_t writeConfigRegisterPreamble
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 int32 sampleDataSize
fxlc95000_appConfigRegister_t localCfgBuffer
This structure defines a handle for the device.
uint8 nRange
Expected sensor dynamic range.
#define CI_READ_WRITE_MAX_LEN
const uint8 engFixedSignBit
uint8 fxlc95000_waitForCoCo(dm_DeviceDescriptor_t *pDeviceHandle)
This structure is a declaration of a channel descriptor type.
const fxlc95000_CommandList_t readConfigCommands
uint8 *const pWriteBuffer