46 #include "clock_config.h" 47 #include "fsl_debug_console.h" 52 #include "Driver_I2C.h" 55 #include "issdk_hal.h" 98 PRINTF(
"\r\n ISSDK MMA845x sensor driver example for Polling Mode\r\n");
102 if (ARM_DRIVER_OK != status)
104 PRINTF(
"\r\n I2C Initialization Failed\r\n");
109 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
110 if (ARM_DRIVER_OK != status)
112 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
117 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
118 if (ARM_DRIVER_OK != status)
120 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
129 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
132 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
141 PRINTF(
"\r\n MMA845x Sensor Configuration Failed, Err = %d\r\n", status);
144 PRINTF(
"\r\n MMA845x now active and entering data read loop... \r\n");
157 if (ARM_DRIVER_OK != status)
159 PRINTF(
"\r\n Read Failed. \r\n");
164 rawData.
accel[0] = ((int16_t)data[0] << 8) | data[1];
165 rawData.
accel[0] /= 4;
166 rawData.
accel[1] = ((int16_t)data[2] << 8) | data[3];
167 rawData.
accel[1] /= 4;
168 rawData.
accel[2] = ((int16_t)data[4] << 8) | data[5];
169 rawData.
accel[2] /= 4;
172 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__
This defines the sensor specific information.
#define BOARD_BootClockRUN
uint8_t data[FXLS8962_DATA_SIZE]
void BOARD_InitDebugConsole(void)
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
int32_t MMA845x_I2C_Initialize(mma845x_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_READ_DATA__
#define MMA845x_CTRL_REG2_MODS_HIGHRES
This structure defines the mma845x raw data buffer.
#define MMA845x_F_SETUP_F_MODE_FIFODISABLED
const registerwritelist_t mma845x_Config_Normal[]
#define ASK_USER_TO_RESUME(x)
#define I2C_S_DEVICE_INDEX
int32_t MMA845x_I2C_ReadData(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define MMA845x_CTRL_REG1_MODE_STANDBY
const registerreadlist_t mma845x_Data_Ready[]
int32_t MMA845x_I2C_Configure(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MMA845x_STATUS_ZYXDR_MASK
fxls8962_acceldataUser_t rawData
const registerreadlist_t mma845x_Output_Values[]
This structure defines the Write command List.
int main(void)
Main function.
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 MMA845x_I2C_SetIdleTask(mma845x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MMA845x_ACCEL_DATA_SIZE
The size of the MMA845x accel data.
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define I2C_S_SIGNAL_EVENT
#define MMA8451_WHO_AM_I_WHOAMI_VALUE
The mma845x_drv.h file describes the MMA845x driver interface and structures.
#define MMA845x_CTRL_REG1_DR_12DOT5HZ