19 #include "clock_config.h" 21 #include "fsl_debug_console.h" 26 #include "Driver_I2C.h" 29 #include "issdk_hal.h" 35 #define MAG3110_DATA_SIZE (6) 81 PRINTF(
"\r\n ISSDK MAG3110 sensor driver example demonstration with oneshot mode\r\n");
85 if (ARM_DRIVER_OK != status)
87 PRINTF(
"\r\n I2C Initialization Failed\r\n");
92 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
93 if (ARM_DRIVER_OK != status)
95 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
100 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
101 if (ARM_DRIVER_OK != status)
103 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
112 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
115 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
123 if (ARM_DRIVER_OK != status)
125 PRINTF(
"\r\nWrite Failed.\r\n");
128 PRINTF(
"\r\nMAG3110 will now trigger acquisitioin of one sample and then read the data...\r\n");
134 if (ARM_DRIVER_OK != status)
136 PRINTF(
"\r\nWrite Failed.\r\n");
143 if (ARM_DRIVER_OK != status)
145 PRINTF(
"\r\nRead Failed.\r\n");
153 if (ARM_DRIVER_OK != status)
155 PRINTF(
"\r\n Read Failed. \r\n");
160 rawData.
mag[0] = ((int16_t)data[0] << 8) | data[1];
161 rawData.
mag[1] = ((int16_t)data[2] << 8) | data[3];
162 rawData.
mag[2] = ((int16_t)data[4] << 8) | data[5];
164 PRINTF(
"\r\n Mag X = %d Y = %d Z = %d\r\n", rawData.
mag[0], rawData.
mag[1], rawData.
mag[2]);
This structure defines the device specific info required by register I/O.
This structure defines the Write command List.
int32_t MAG3110_I2C_Initialize(mag3110_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor.
#define ASK_USER_TO_RESUME(x)
#define MAG3110_CTRL_REG2_MAG_RST_EN
This structure defines the mag3110 data buffer.
#define MAG3110_CTRL_REG2_MAG_RST_MASK
#define __END_WRITE_DATA__
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define I2C_S_SIGNAL_EVENT
int32_t Sensor_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)
Write register data to a sensor.
#define BOARD_BootClockRUN
ARM_DRIVER_I2C * pCommDrv
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
int main(void)
Main function.
uint8_t data[FXLS8962_DATA_SIZE]
#define __END_READ_DATA__
int32_t MAG3110_I2C_ReadData(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define MAG3110_CTRL_REG1_TM_MASK
fxos8700_accelmagdata_t rawData
#define MAG3110_CTRL_REG1_TM_TRIGGER
const registerreadlist_t cMag3110OutputNormal[]
Address and size of Raw Magnetic Strength Data.
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_MASK
#define MAG3110_CTRL_REG2_RAW_RAW
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_EN
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
This defines the sensor specific information.
This structure defines the Read command List.
#define MAG3110_WHOAMI_VALUE
const registerreadlist_t cMag3110GetOST[]
Address of Register containing OST Bit.
#define I2C_S_DEVICE_INDEX
#define MAG3110_DATA_SIZE
void BOARD_InitDebugConsole(void)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define MAG3110_CTRL_REG2_RAW_MASK
registeridlefunction_t idleFunction
The mag3110_drv.h file describes the MAG3110 driver interface and structures.
const registerwritelist_t cMag3110ConfigOneShot[]
Register settings for Magnetic Strength readings in One-Shot mode.
const registerwritelist_t cMag3110SetOST[]
Register settings for Triggring One-Shot Sampling.