30 #define MAG3110_MAG_FLOAT_CONVERSION_FACTOR (0.1)
31 #define MAG3110_MAG_FLOAT_CONVERSION_OFFSET (0.0)
32 #define MAG3110_MAG_FIXED_CONVERSION_FACTOR (1638)
33 #define MAG3110_MAG_FIXED_CONVERSION_OFFSET (0)
66 if ( NULL == pSensorHandle){
83 if (NULL == pDeviceDescriptor) {
91 pCurrentSampleBuffer->
mag[0] = 0;
92 pCurrentSampleBuffer->
mag[1] = 0;
93 pCurrentSampleBuffer->
mag[2] = 0;
118 _time_delay_ticks(1);
158 if ((NULL == pSensorHandle) || (NULL == pSubSettings)) {
185 #ifdef DEBUG_READ_ALL_REGS
186 static uint8 debugRegs[18];
191 if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
203 if (NULL == pDeviceDescriptor)
213 goto unlockdescriptor;
219 goto unlockdescriptor;
234 #ifdef DEBUG_READ_ALL_REGS
235 for (
int i=0; i<
sizeof(debugRegs); i++)
286 if(NULL == pSensorHandle){
297 if (NULL == pDeviceDescriptor)
306 goto unlockdescriptor;
312 goto unlockdescriptor;
317 goto unlockdescriptor;
347 if(NULL == pSensorHandle){
360 if (NULL == pDeviceDescriptor)
368 goto unlockdescriptor;
375 goto unlockdescriptor;
381 goto unlockdescriptor;
430 if(NULL == pSensorHandle){
459 if(NULL == pSensorHandle){
473 if (NULL == pDeviceDescriptor){
491 if (MQX_OK !=_lwsem_wait_ticks(&pDeviceDescriptor->
deviceSemaphore, 0))
493 goto unlockdescriptor;
500 goto unlockdescriptor;
507 pCurrentSampleBuffer->
mag[0] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->
mag[0]);
508 pCurrentSampleBuffer->
mag[1] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->
mag[1]);
509 pCurrentSampleBuffer->
mag[2] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->
mag[2]);
511 #ifdef DEBUG_READ_ALL_REGS
512 for (
int i=0; i<
sizeof(debugRegs); i++)
528 *pFifoEntry = *pCurrentSampleBuffer;
536 pCurrentSampleBuffer,
567 void *pConvertedSample,
576 switch (convertToType)
580 pConverter = float_magfs3d_converter;
582 pConverter = fixed_magfs3d_converter;
588 if (pConverter == NULL)
591 retStat = pConverter(
593 (mag3110_DataBuffer_t *)pNativeSample,
692 uint8 buffer[1] = {0x00};
772 for (
uint32 reg=0; reg < pConfigSpecific->regCount; reg++)
774 buffer[0] = pConfigSpecific->regPairs[reg].regValue;
784 #if 0 // Mode is no longer set through subscription
785 uint8 buffer[1] = {0x00};
786 if((FSL_MAG3110_MODE_NON_RAW_FAST == pSubSettings->nMode) || (FSL_MAG3110_MODE_RAW_FAST == pSubSettings->nMode)){
886 shiftedPeriod = (cfg->
period)>>(*osbits+2);
891 op =
ff1(shiftedPeriod);
899 while ( opl > 20 && *osbits ) {
908 while ( opl < 13 && (*osbits < 3) ) {
916 if ( op > 20) opl = 20;
917 if ( op < 13) opl = 13;
920 *ratebits = 20 - opl;
923 cfg->
period = 12500<<(*ratebits + *osbits);
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
void * pSensorSpecificSettings
unsigned char uint8
This defines uint8 as unsigned char.
This structure defines the dummy DSA data buffer format.
isf_dsa_status_t fsl_mag3110_i2c_3D_mag_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
isf_dsa_status_t fsl_mag3110_i2c_3D_mag_Shutdown(isf_SensorHandle_t *pSensorHandle)
fsl_i2c_master_driver.h defines structures and types for the i2c master driver.
void fsl_mag3110_i2c_3D_mag_PeriodicCallback(void *pSensorHandle)
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.
#define MAG3110_MAG_FIXED_CONVERSION_OFFSET
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_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 ...
Information necessary to communicate with an I2C slave device.
#define MAG3110_MAG_FLOAT_CONVERSION_OFFSET
void mag3110_Reset(int32_t *status, isf_SensorHandle_t *pSensorHandle)
This function resets the MAG3110 sensor resulting in a default configuration for all registers...
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...
The fsl_mag3110_i2c_3D_mag.h file contains the definitions and functions supporting the MAG3110 Senso...
Define the sensor device descriptor.
LWSEM_STRUCT deviceSemaphore
isf_dsa_status_t fsl_mag3110_i2c_3D_mag_EndData(isf_SensorHandle_t *pSensorHandle)
unsigned long uint32
This defines uint32 as unsigned long.
uint8 get_config_bits(mag_config_t *cfg, uint8 *ratebits, uint8 *osbits)
This function obtains the configuration register values for a given user configuration of the MAG3110...
dm_ChannelDescriptor_t cDescriptor
isf_dsa_status_t fsl_mag3110_i2c_3D_mag_Initialize(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.
isf_dsa_status_t fsl_mag3110_i2c_3D_mag_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
isf_dsa_status_t fsl_mag3110_i2c_3D_mag_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_timestamp_t timestamp
isf_SensorDataTypes_t mag3110_SupportedDataTypes[]
The mag3110.h contains the MAG3110 Magnetometer register definitions, access macros, and device access functions.
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
isf_SensorTypes_t mag3110_SupportedSensorTypes[]
Supported sensor and data types for MMA8652.
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
uint32 ff1(uint32 doubleword)
find first-in.
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.
void mag3110_CheckId(int32_t *status, isf_SensorHandle_t *pSensorHandle)
This function validates the MAG3110 sensor is connected via the I2C bus.
#define MAG3110_MAG_FIXED_CONVERSION_FACTOR
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.
void mag3110_SetMode(int32_t *status, isf_SensorHandle_t *pSensorHandle, int32_t Mode)
This function sets the MAG3110 part to the requested mode.
#define MAG3110_SET_FIELD(name, val)
void mag3110_GetData(int32_t *status, isf_SensorHandle_t *pSensorHandle, void *pBuffer)
This function retrieves the raw data from the MAG3110 sensor.
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.
long int32
This defines int32 as long.
isf_timestamp_t timestamp
isf_SensorDataTypes_t resultType
Main ISF header file. Contains code common to all ISF components.
LWEVENT_STRUCT * pEventGroup
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
The structure defines the MAG3110 configuration.
isf_dsa_AdapterStatus_t adapterStatus
sys_channelId_t channelId
isf_dsa_status_t fsl_mag3110_i2c_3D_mag_StartData(isf_SensorHandle_t *pSensorHandle)
isf_microTeslas_fixed_32s1i14_t fieldStrength[3]
#define MAG3110_NUMBER_BYTES_AXIS
#define MAG3100_READ_BUF_SIZE
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.
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 MAG3110_WHOAMI_VALUE
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.
This structure defines a handle for the device.
void mag3110_ValidateConfig(int32_t *status, isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
This function validates the configuration for the MAG3110 sensor.
isf_SensorDataTypes_t TYPE_MAGNETIC_FIELD_STRENGTH_3D
isf_dsa_status_t fsl_mag3110_i2c_3D_mag_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.
#define MAG3110_MAG_FLOAT_CONVERSION_FACTOR
This structure is a declaration of a channel descriptor type.
bm_callback_token_t token
void mag3110_SetConfig(int32_t *status, isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
This function sets the MAG3110 sensor configuration.
#define MAG3110_NUMBER_AXIS
The MAG3110 registers, masks, and constants.