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" 106 PRINTF(
"\r\n ISSDK MMA845x sensor driver example for interrupt mode.\r\n");
115 if (ARM_DRIVER_OK != status)
117 PRINTF(
"\r\n I2C Initialization Failed\r\n");
122 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
123 if (ARM_DRIVER_OK != status)
125 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
130 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
131 if (ARM_DRIVER_OK != status)
133 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
142 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
145 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
154 PRINTF(
"\r\n MMA845x Sensor Configuration Failed, Err = %d\r\n", status);
157 PRINTF(
"\r\n Successfully Applied MMA845x Sensor Configuration\r\n");
175 if (ARM_DRIVER_OK != status)
177 PRINTF(
"\r\n Read Failed. \r\n");
182 rawData.
accel[0] = ((int16_t)data[0] << 8) | data[1];
183 rawData.
accel[0] /= 4;
184 rawData.
accel[1] = ((int16_t)data[2] << 8) | data[3];
185 rawData.
accel[1] /= 4;
186 rawData.
accel[2] = ((int16_t)data[4] << 8) | data[5];
187 rawData.
accel[2] /= 4;
190 PRINTF(
"\r\n Accel X = %d Y = %d Z = %d\r\n", rawData.
accel[0], rawData.
accel[1], rawData.
accel[2]);
#define MMA845x_CTRL_REG1_DR_12DOT5HZ
#define MMA8451_WHO_AM_I_WHOAMI_VALUE
#define MMA845x_CTRL_REG5_INT_CFG_DRDY_INT1
This structure defines the Write command List.
#define ASK_USER_TO_RESUME(x)
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
int32_t MMA845x_I2C_Configure(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
Access structure of the GPIO Driver.
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.
const registerreadlist_t MMA845x_Data_Ready[]
volatile bool mma845xInterrupt
int main(void)
This is the The main function implementation.
#define __END_WRITE_DATA__
void MMA845x_I2C_SetIdleTask(mma845x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
This structure defines the mma845x raw data buffer.
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define I2C_S_SIGNAL_EVENT
#define BOARD_BootClockRUN
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
uint8_t data[FXLS8962_DATA_SIZE]
#define MMA845x_CTRL_REG2_MODS_HIGHRES
#define __END_READ_DATA__
void mma845x_isr(void *pUserData)
This is the Sensor Data Ready ISR implementation.
const registerreadlist_t mma845x_Output_Values[]
fxos8700_accelmagdata_t rawData
const registerwritelist_t mma845x_Config_Isr[]
void(* toggle_pin)(pinID_t aPinId)
#define MMA845x_F_SETUP_F_MODE_FIFODISABLED
#define MMA845x_ACCEL_DATA_SIZE
The size of the MMA845x accel data.
#define MMA845x_CTRL_REG3_IPOL_HIGH
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
#define MMA845x_CTRL_REG1_MODE_STANDBY
This defines the sensor specific information.
The mma845x_drv.h file describes the MMA845x driver interface and structures.
void BOARD_InitDebugConsole(void)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define MMA845x_CTRL_REG4_INT_EN_DRDY_ENABLED
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.