46 #include "clock_config.h" 47 #include "fsl_debug_console.h" 52 #include "Driver_I2C.h" 55 #include "issdk_hal.h" 61 #define MMA865x_ACCEL_DATA_SIZE (6) 103 PRINTF(
"\r\n ISSDK MMA865x sensor driver example for Polling Mode. \r\n");
107 if (ARM_DRIVER_OK != status)
109 PRINTF(
"\r\n I2C Initialization Failed\r\n");
114 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
115 if (ARM_DRIVER_OK != status)
117 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
122 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
123 if (ARM_DRIVER_OK != status)
125 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
134 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
137 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
146 PRINTF(
"\r\n MMA865x Sensor Configuration Failed, Err = %d \r\n", status);
149 PRINTF(
"\r\n MMA865x now active and entering data read loop... \r\n");
162 if (ARM_DRIVER_OK != status)
164 PRINTF(
"\r\n Read Failed. \r\n");
169 rawData.
accel[0] = ((int16_t)data[0] << 8) | data[1];
170 rawData.
accel[0] /= 16;
171 rawData.
accel[1] = ((int16_t)data[2] << 8) | data[3];
172 rawData.
accel[1] /= 16;
173 rawData.
accel[2] = ((int16_t)data[4] << 8) | data[5];
174 rawData.
accel[2] /= 16;
177 PRINTF(
"\r\n Accel X = %d Y = %d Z = %d \r\n", rawData.
accel[0], rawData.
accel[1], rawData.
accel[2]);
#define MMA865x_XYZ_DATA_CFG_FS_MASK
const registerreadlist_t cMma865xDataReady[]
#define __END_WRITE_DATA__
int32_t MMA865x_I2C_Initialize(mma865x_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor.
This structure defines the mma865x raw data buffer.
const registerreadlist_t cMma865xOutputValues[]
#define BOARD_BootClockRUN
uint8_t data[FXLS8962_DATA_SIZE]
int32_t MMA865x_I2C_ReadData(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
int main(void)
Main function.
void BOARD_InitDebugConsole(void)
This defines the sensor specific information.
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
#define MMA865x_CTRL_REG1_DR_MASK
#define __END_READ_DATA__
#define MMA865x_ACCEL_DATA_SIZE
#define MMA865x_CTRL_REG1_DR_6_25HZ
void MMA865x_I2C_SetIdleTask(mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MMA8652_WHOAMI_VALUE
#define ASK_USER_TO_RESUME(x)
int32_t MMA865x_I2C_Configure(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MMA865x_XYZ_DATA_CFG_FS_2G
#define MMA865x_CTRL_REG2_MODS_MASK
const registerwritelist_t cMma865xConfigNormal[]
#define MMA865x_STATUS_ZYXDR_MASK
#define I2C_S_DEVICE_INDEX
The mma865x_drv.h file describes the MMA865x driver interface and structures.
fxls8962_acceldataUser_t rawData
#define MMA865x_CTRL_REG2_MODS_HR
This structure defines the Write command List.
This structure defines the Read command List.
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define I2C_S_SIGNAL_EVENT