16 #include "clock_config.h" 18 #include "fsl_debug_console.h" 19 #include "fsl_irqsteer.h" 22 #include "Driver_I2C.h" 25 #include "issdk_hal.h" 63 ipc = BOARD_InitRpc();
70 PRINTF(
"\r\n ------------------------------------------------------------------\r\n");
71 PRINTF(
"\r\n ISSDK FXAS21002 sensor driver example demonstration with POLL mode\r\n");
72 PRINTF(
"\r\n ------------------------------------------------------------------\r\n");
75 if (sc_pm_set_resource_power_mode(ipc, SC_R_I2C_0, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
77 PRINTF(
"Error: Failed to power on LPI2C\r\n");
81 freq = CLOCK_SetIpFreq(kCLOCK_DMA_Lpi2c0, SC_24MHZ);
84 PRINTF(
"Error: Failed to set LPI2C frequency\r\n");
88 #if (MIMX8QM_CM4_CORE0) 89 if (sc_pm_set_resource_power_mode(ipc, SC_R_IRQSTR_M4_0, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
91 PRINTF(
"Error: Failed to power on IRQSTEER M4_0\r\n");
93 #elif (MIMX8QM_CM4_CORE1) 94 if (sc_pm_set_resource_power_mode(ipc, SC_R_IRQSTR_M4_1, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
96 PRINTF(
"Error: Failed to power on IRQSTEER M4_1\r\n");
101 IRQSTEER_Init(IRQSTEER);
102 IRQSTEER_EnableInterrupt(IRQSTEER, DMA_I2C0_INT_IRQn);
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");
133 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
136 PRINTF(
"\r\n Successfully Initiliazed FXAS21002 Sensor\r\n");
143 PRINTF(
"\r\n FXAS21002 Sensor Configuration Failed, Err = %d\r\n", status);
146 PRINTF(
"\r\n Successfully Applied FXAS21002 Sensor Configuration\r\n");
148 PRINTF(
"\r\n Reading FXAS21002 Gyro Values in POLL mode\r\n");
161 if (ARM_DRIVER_OK != status)
163 PRINTF(
"\r\n Read Failed. \r\n");
168 rawData.
gyro[0] = ((int16_t)data[0] << 8) | data[1];
169 rawData.
gyro[1] = ((int16_t)data[2] << 8) | data[3];
170 rawData.
gyro[2] = ((int16_t)data[4] << 8) | data[5];
173 PRINTF(
"\r\n Gyro X = %d Y = %d Z = %d\r\n", rawData.
gyro[0], rawData.
gyro[1], rawData.
gyro[2]);
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
This structure defines the Write command List.
#define ASK_USER_TO_RESUME(x)
const registerreadlist_t fxas21002_Output_Values[]
int32_t FXAS21002_I2C_Initialize(fxas21002_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 fxas21002_DRDY[]
This structure defines the fxas21002 raw data buffer.
#define __END_WRITE_DATA__
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
int32_t FXAS21002_I2C_Configure(fxas21002_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
This defines the sensor specific information for I2C.
#define BOARD_BootClockRUN
#define FXAS21002_I2C_ADDR
uint8_t data[FXLS8962_DATA_SIZE]
#define FXAS21002_DR_STATUS_ZYXDR_MASK
#define __END_READ_DATA__
The fxas21002_drv.h file describes the fxas21002 driver interface and structures. ...
int32_t FXAS21002_I2C_ReadData(fxas21002_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
fxos8700_accelmagdata_t rawData
#define FXAS21002_GYRO_DATA_SIZE
The size of the FXAS21002 gyro data.
#define FXAS21002_CTRL_REG1_DR_MASK
int main(void)
Main function.
This structure defines the Read command List.
const registerwritelist_t fxas21002_Config_Normal[]
#define I2C_S_DEVICE_INDEX
#define FXAS21002_CTRL_REG1_DR_12_5HZ
void BOARD_InitDebugConsole(void)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.