19 #include "clock_config.h" 21 #include "fsl_debug_console.h" 26 #include "Driver_I2C.h" 31 #include "issdk_hal.h" 32 #include "gpio_driver.h" 38 #define MAG3110_DATA_SIZE (6) 102 PRINTF(
"\r\n ISSDK MAG3110 sensor driver example demonstration with interrupt mode.\r\n");
112 if (ARM_DRIVER_OK != status)
114 PRINTF(
"\r\n I2C Initialization Failed\r\n");
119 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
120 if (ARM_DRIVER_OK != status)
122 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
127 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
128 if (ARM_DRIVER_OK != status)
130 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
139 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
142 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
154 PRINTF(
"\r\n nMAG3110 Sensor Configuration Failed, Err = %d\r\n", status);
157 PRINTF(
"\r\n Successfully Applied MAG3110 Sensor Configuration\r\n");
175 if (ARM_DRIVER_OK != status)
177 PRINTF(
"\r\n Read Failed. \r\n");
182 rawData.
mag[0] = ((int16_t)data[0] << 8) | data[1];
183 rawData.
mag[1] = ((int16_t)data[2] << 8) | data[3];
184 rawData.
mag[2] = ((int16_t)data[4] << 8) | data[5];
189 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 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_REG1_DR_ODR_2
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
#define MAG3110_CTRL_REG2_MAG_RST_EN
const registerwritelist_t cMag3110ConfigNormal[]
Register settings for Normal (non buffered) mode since Interrupt is enabled implicitly.
This structure defines the mag3110 data buffer.
Access structure of the GPIO Driver.
#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 MAG3110_I2C_Configure(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define BOARD_BootClockRUN
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
GENERIC_DRIVER_GPIO * pGpioDriver
uint8_t data[FXLS8962_DATA_SIZE]
#define __END_READ_DATA__
const registerreadlist_t cMag3110OutputNormal[]
Address and size of Raw Pressure+Temperature Data in Normal Mode.
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.
void mag3110_int_data_ready_callback(void *pUserData)
This is the Sensor Data Ready ISR implementation.
fxos8700_accelmagdata_t rawData
#define MAG3110_CTRL_REG1_DR_MASK
void(* toggle_pin)(pinID_t aPinId)
#define MAG3110_CTRL_REG1_OS_MASK
#define MAG3110_DATA_SIZE
#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...
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
This defines the sensor specific information.
This structure defines the Read command List.
#define MAG3110_WHOAMI_VALUE
void MAG3110_CalibrateHardIronOffset(int16_t *xValue, int16_t *yValue, int16_t *zValue)
Calibrates the magnetometer reading by determining the current hard iron offset.
gpioHandleKSDK_t GREEN_LED
#define I2C_S_DEVICE_INDEX
volatile bool gMag3110DataReady
void BOARD_InitDebugConsole(void)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
void MAG3110_I2C_SetIdleTask(mag3110_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MAG3110_CTRL_REG1_OS_OSR_32
#define MAG3110_CTRL_REG2_RAW_MASK
The mag3110_drv.h file describes the MAG3110 driver interface and structures.
int main(void)
This is the The main function implementation.