17 #include "clock_config.h" 19 #include "fsl_debug_console.h" 22 #include "Driver_I2C.h" 25 #include "issdk_hal.h" 27 #include "gpio_driver.h" 33 #define MMA9553_ACCEL_DATA_SIZE (6) 34 #define MMA9553_INT_O A0 96 PRINTF(
"\r\n ISSDK MMA9553 sensor driver example for Interrupt Mode. \r\n");
106 if (ARM_DRIVER_OK != status)
108 PRINTF(
"\r\n I2C Initialization Failed\r\n");
113 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
114 if (ARM_DRIVER_OK != status)
116 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
121 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
122 if (ARM_DRIVER_OK != status)
124 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
132 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
135 PRINTF(
"\r\n Successfully Initialized Sensor. \r\n");
146 PRINTF(
"\r\n MMA9553 Sensor Configuration Failed, Err = %d \r\n", status);
154 if (ARM_DRIVER_OK != status)
156 PRINTF(
"\r\n Enable Interrupt Failed. \r\n");
160 PRINTF(
"\r\n Successfully Applied MMA9553 Sensor Configuration\r\n");
177 (uint8_t *)&pedometerData);
178 if (ARM_DRIVER_OK != status)
180 PRINTF(
"\r\n Read Failed. \r\n");
185 pedometerData.statusRegister = (pedometerData.statusRegister >> 8) | (pedometerData.statusRegister << 8);
186 pedometerData.stepCount = (pedometerData.stepCount >> 8) | (pedometerData.stepCount << 8);
187 pedometerData.distance = (pedometerData.distance >> 8) | (pedometerData.distance << 8);
188 pedometerData.speed = (pedometerData.speed >> 8) | (pedometerData.speed << 8);
189 pedometerData.calories = (pedometerData.calories >> 8) | (pedometerData.calories << 8);
190 pedometerData.sleepCount = (pedometerData.sleepCount >> 8) | (pedometerData.sleepCount << 8);
192 PRINTF(
"\r\n Steps = %d Distance = %dm Speed = %dm/h Calories = %d \r\n", pedometerData.stepCount,
193 pedometerData.distance, pedometerData.speed, pedometerData.calories);
197 if (ARM_DRIVER_OK != status)
199 PRINTF(
"\r\n Read Failed. \r\n");
203 PRINTF(
"\r\n Accel X = %d Y = %d Z = %d \r\n", rawData.
accel[0], rawData.
accel[1], rawData.
accel[2]);
const uint8_t SetAFEPriority_for3Hz[5]
#define MMA9553_ACCEL_DATA_SIZE
This defines the sensor specific information for I2C.
#define ASK_USER_TO_RESUME(x)
const registercommandlist_t cMma9553ReadPedometerCommand[]
void MMA9553_I2C_SetIdleTask(mma9553_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
const uint8_t SetSampleRate_3Hz[5]
const registerreadlist_t cMma9553ReadPedometerOutput[]
const uint8_t ReadPedometerData[4]
Command to Read Pedometer Data.
This structure defines the Size of response for pedometer data read command.
const registercommandlist_t cMma9553Config30Hz[]
This structure defines the Block command List.
Access structure of the GPIO Driver.
void mma9553_int_data_ready_callback(void *pUserData)
const registerreadlist_t cMma9553ReadRawOutput[]
int32_t MMA9553_I2C_Configure(mma9553_i2c_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList)
The interface function to configure he sensor.
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
The mma9553_drv.h file describes the MMA9553L driver interface and structures.
This structure defines the mma9553 pedometer data buffer.
#define I2C_S_SIGNAL_EVENT
const uint8_t SetFSRange_2g[5]
Full-Scale Range Selections.
#define MMA9553_XYZ_DATA_OFFSET
XYZ Data Register Offset.
#define BOARD_BootClockRUN
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
const registercommandlist_t cMma9553EnableInterruptCommand[]
volatile bool gMma9553DataReady
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
const uint8_t SetMBoxPriority_for3Hz[5]
GENERIC_DRIVER_GPIO * pGpioDriver
int32_t MMA9553_I2C_CommandResponse(mma9553_i2c_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList, const registerreadlist_t *pResponseList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define __END_READ_DATA__
#define __END_WRITE_CMD__
fxos8700_accelmagdata_t rawData
int32_t MMA9553_I2C_Initialize(mma9553_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress)
The interface function to initialize the sensor.
void(* toggle_pin)(pinID_t aPinId)
int main(void)
Main function.
void BOARD_SystickEnable(void)
Function to enable systicks framework.
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 structure defines the Read command List.
gpioHandleKSDK_t GREEN_LED
#define I2C_S_DEVICE_INDEX
const uint8_t SetLegacyIntMode[5]
Set Sensor to Legacy Mode with INT_O interrupt on completion of the AFE sampling. ...
void BOARD_InitDebugConsole(void)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.