46 #include "clock_config.h" 47 #include "fsl_debug_console.h" 52 #include "Driver_I2C.h" 57 #include "issdk_hal.h" 58 #include "gpio_driver.h" 64 #define MAG3110_DATA_SIZE (6) 128 PRINTF(
"\r\n ISSDK MAG3110 sensor driver example demonstration with interrupt mode.\r\n");
138 if (ARM_DRIVER_OK != status)
140 PRINTF(
"\r\n I2C Initialization Failed\r\n");
145 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
146 if (ARM_DRIVER_OK != status)
148 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
153 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
154 if (ARM_DRIVER_OK != status)
156 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
165 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
168 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
180 PRINTF(
"\r\n nMAG3110 Sensor Configuration Failed, Err = %d\r\n", status);
183 PRINTF(
"\r\n Successfully Applied MAG3110 Sensor Configuration\r\n");
201 if (ARM_DRIVER_OK != status)
203 PRINTF(
"\r\n Read Failed. \r\n");
208 rawData.
mag[0] = ((int16_t)data[0] << 8) | data[1];
209 rawData.
mag[1] = ((int16_t)data[2] << 8) | data[3];
210 rawData.
mag[2] = ((int16_t)data[4] << 8) | data[5];
215 PRINTF(
"\r\n Mag X = %d Y = %d Z = %d\r\n", rawData.
mag[0], rawData.
mag[1], rawData.
mag[2]);
const registerreadlist_t cMag3110OutputNormal[]
Address and size of Raw Pressure+Temperature Data in Normal Mode.
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 __END_WRITE_DATA__
#define MAG3110_CTRL_REG1_DR_ODR_2
#define MAG3110_CTRL_REG2_MAG_RST_EN
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
#define BOARD_BootClockRUN
int32_t MAG3110_I2C_Configure(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MAG3110_DATA_SIZE
The mag3110_drv.h file describes the MAG3110 driver interface and structures.
This defines the sensor specific information.
uint8_t data[FXLS8962_DATA_SIZE]
void(* toggle_pin)(pinID_t aPinId)
void BOARD_InitDebugConsole(void)
#define MAG3110_CTRL_REG1_OS_OSR_32
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
#define MAG3110_CTRL_REG1_OS_MASK
#define MAG3110_CTRL_REG2_RAW_RAW
#define __END_READ_DATA__
GENERIC_DRIVER_GPIO * pGpioDriver
void MAG3110_I2C_SetIdleTask(mag3110_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
This structure defines the mag3110 data buffer.
gpioHandleKSDK_t GREEN_LED
void MAG3110_CalibrateHardIronOffset(int16_t *xValue, int16_t *yValue, int16_t *zValue)
Calibrates the magnetometer reading by determining the current hard iron offset.
#define MAG3110_CTRL_REG1_DR_MASK
#define MAG3110_CTRL_REG2_MAG_RST_MASK
#define ASK_USER_TO_RESUME(x)
#define MAG3110_CTRL_REG2_RAW_MASK
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_EN
#define I2C_S_DEVICE_INDEX
const registerwritelist_t cMag3110ConfigNormal[]
Register settings for Normal (non buffered) mode since Interrupt is enabled implicitly.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
volatile bool gMag3110DataReady
void mag3110_int_data_ready_callback(void *pUserData)
This is the Sensor Data Ready ISR implementation.
int main(void)
This is the The main function implementation.
Access structure of the GPIO Driver.
fxls8962_acceldataUser_t rawData
This structure defines the Write command List.
This structure defines the Read command List.
#define MAG3110_WHOAMI_VALUE
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
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 BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_MASK
#define I2C_S_SIGNAL_EVENT