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 RAW_ACCEL_DATA_SIZE (6) 135 PRINTF(
"\r\n ISSDK FXOS8700 sensor driver example demonstration with interrupt mode.\r\n");
145 if (ARM_DRIVER_OK != status)
147 PRINTF(
"\r\n I2C Initialization Failed\r\n");
152 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
153 if (ARM_DRIVER_OK != status)
155 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
160 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
161 if (ARM_DRIVER_OK != status)
163 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
172 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
175 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
184 PRINTF(
"\r\n FXOS8700 Sensor Configuration Failed, Err = %d\r\n", status);
187 PRINTF(
"\r\n Successfully Applied FXOS8700 Sensor Configuration\r\n");
205 if (ARM_DRIVER_OK != status)
207 PRINTF(
"\r\n Read Failed. \r\n");
212 rawData.
accel[0] = ((int16_t)data[0] << 8) | data[1];
213 rawData.
accel[0] /= 4;
214 rawData.
accel[1] = ((int16_t)data[2] << 8) | data[3];
215 rawData.
accel[1] /= 4;
216 rawData.
accel[2] = ((int16_t)data[4] << 8) | data[5];
217 rawData.
accel[2] /= 4;
220 PRINTF(
"\r\n Accel X = %d Y = %d Z = %d\r\n", rawData.
accel[0], rawData.
accel[1], rawData.
accel[2]);
#define __END_WRITE_DATA__
The fxos8700_drv.h file describes the fxos8700 driver interface and structures.
This structure defines the fxos8700 raw data buffer.
void FXOS8700_I2C_SetIdleTask(fxos8700_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
#define BOARD_BootClockRUN
#define FXOS8700_CTRL_REG1_DR_SINGLE_12P5_HZ
#define FXOS8700_CTRL_REG4_INT_EN_DRDY_EN
uint8_t data[FXLS8962_DATA_SIZE]
void(* toggle_pin)(pinID_t aPinId)
#define FXOS8700_M_CTRL_REG2_M_AUTOINC_ACCEL_ONLY_MODE
void BOARD_InitDebugConsole(void)
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
This defines the sensor specific information for I2C.
#define FXOS8700_CTRL_REG3_IPOL_ACTIVE_HIGH
#define __END_READ_DATA__
#define FXOS8700_CTRL_REG4_INT_EN_DRDY_MASK
#define FXOS8700_WHO_AM_I_PROD_VALUE
#define FXOS8700_CTRL_REG3_PP_OD_PUSH_PULL
gpioHandleKSDK_t GREEN_LED
const registerwritelist_t fxos8700_Config_Interrupt[]
#define FXOS8700_M_CTRL_REG2_M_AUTOINC_MASK
#define ASK_USER_TO_RESUME(x)
#define FXOS8700_CTRL_REG5_INT_CFG_DRDY_INT2
int32_t FXOS8700_I2C_Initialize(fxos8700_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor.
int32_t FXOS8700_I2C_ReadData(fxos8700_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define I2C_S_DEVICE_INDEX
#define FXOS8700_CTRL_REG5_INT_CFG_DRDY_MASK
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
int32_t FXOS8700_I2C_Configure(fxos8700_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define FXOS8700_CTRL_REG1_DR_MASK
Access structure of the GPIO Driver.
fxls8962_acceldataUser_t rawData
This structure defines the Write command List.
void fxos8700_isr_callback(void *pUserData)
This is the Sensor Data Ready ISR implementation.
This structure defines the Read command List.
const registerreadlist_t FXOS8700_ACCEL_READ[]
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
#define FXOS8700_CTRL_REG3_IPOL_MASK
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define FXOS8700_I2C_ADDR
#define FXOS8700_CTRL_REG3_PP_OD_MASK
volatile bool fxos8700Interrupt
#define I2C_S_SIGNAL_EVENT
int main(void)
This is the The main function implementation.
const registerreadlist_t FXOS8700_STATUS_READ[]
#define RAW_ACCEL_DATA_SIZE