19 #include "clock_config.h" 21 #include "fsl_debug_console.h" 26 #include "Driver_I2C.h" 31 #include "issdk_hal.h" 32 #include "gpio_driver.h" 41 #define PULSE_THX 0x12 42 #define PULSE_THY 0x12 43 #define PULSE_THZ 0x12 114 uint8_t eventStatus = 0;
125 PRINTF(
"\r\n ISSDK MMA865x sensor driver example for Double-Tap detection.\r\n");
135 if (ARM_DRIVER_OK != status)
137 PRINTF(
"\r\n I2C Initialization Failed\r\n");
142 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
143 if (ARM_DRIVER_OK != status)
145 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
150 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
151 if (ARM_DRIVER_OK != status)
153 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
162 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
165 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
174 PRINTF(
"\r\n MMA865x Sensor Configuration Failed, Err = %d \r\n", status);
177 PRINTF(
"\r\n Successfully Applied MMA865x Sensor Configuration for Double-Tap Detection\r\n");
178 PRINTF(
"\r\n MMA865x is now active and detecting double-tap... \r\n");
195 if (ARM_DRIVER_OK != status)
205 PRINTF(
"\r\n Double-Tap Detected !!!");
#define MMA865x_CTRL_REG1_DR_MASK
const registerreadlist_t gMma865xReadPulseSrc[]
Read register list for MMA8652 to read status bits for the pulse detection function.
#define MMA865x_HP_FILTER_CUTOFF_PULSE_HPF_BYP_MASK
This structure defines the Write command List.
This defines the sensor specific information.
#define MMA865x_PULSE_THSY_THSY_MASK
#define MMA865x_CTRL_REG4_INT_EN_PULSE_EN
#define MMA865x_PULSE_CFG_YDPEFE_EN
volatile bool gMma865xIntFlag
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
#define MMA865x_PULSE_CFG_ZDPEFE_EN
Access structure of the GPIO Driver.
#define MMA865x_PULSE_CFG_XDPEFE_MASK
#define __END_WRITE_DATA__
#define MMA865x_CTRL_REG3_IPOL_MASK
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define MMA865x_PULSE_THSZ_THSZ_MASK
#define MMA865x_HP_FILTER_CUTOFF_PULSE_HPF_BYP_ENABLED
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.
#define MMA865x_CTRL_REG3_IPOL_ACTIVE_HIGH
#define I2C_S_SIGNAL_EVENT
#define MMA865x_CTRL_REG2_MODS_MASK
#define BOARD_BootClockRUN
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
#define MMA865x_CTRL_REG5_INT_CFG_PULSE_INT1
#define MMA865x_CTRL_REG4_INT_EN_PULSE_MASK
int main(void)
This is the The main function implementation.
int32_t MMA865x_I2C_Configure(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MMA865x_CTRL_REG1_ACTIVE_STANDBY
#define __END_READ_DATA__
The mma865x_drv.h file describes the MMA865x driver interface and structures.
#define MMA865x_CTRL_REG1_ACTIVE_MASK
#define MMA865x_CTRL_REG1_F_READ_MASK
#define MMA865x_PULSE_CFG_ZDPEFE_MASK
#define MMA865x_PULSE_SRC_DPE_MASK
void(* toggle_pin)(pinID_t aPinId)
#define MMA865x_PULSE_CFG_YDPEFE_MASK
#define MMA865x_CTRL_REG1_ASLP_RATE_MASK
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.
#define MMA865x_PULSE_CFG_XDPEFE_EN
#define MMA865x_PULSE_THSX_THSX_MASK
gpioHandleKSDK_t GREEN_LED
#define MMA865x_CTRL_REG5_INT_CFG_PULSE_MASK
#define I2C_S_DEVICE_INDEX
void MMA865x_I2C_SetIdleTask(mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
void BOARD_InitDebugConsole(void)
#define MMA8652_WHOAMI_VALUE
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.
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define MMA865x_CTRL_REG1_ASLP_RATE_50HZ
#define MMA865x_CTRL_REG2_MODS_LP
const registerwritelist_t cMma865xConfigDoubleTap[]
#define MMA865x_CTRL_REG1_F_READ_NORMAL
#define MMA865x_CTRL_REG1_DR_100HZ
void mma865x_isr_callback(void *pUserData)
This is the Sensor Event ISR implementation.