45 #include "clock_config.h" 46 #include "fsl_debug_console.h" 51 #include "issdk_hal.h" 52 #include "gpio_driver.h" 58 #include "Driver_SPI.h" 91 uint8_t gFxas21002DataReady;
103 PRINTF(
"\r\n ISSDK FXAS21002 sensor driver example demonstration for SPI with Poll Mode.\r\n");
107 if (ARM_DRIVER_OK != status)
109 PRINTF(
"\r\n SPI Initialization Failed\r\n");
114 status = pSPIdriver->PowerControl(ARM_POWER_FULL);
115 if (ARM_DRIVER_OK != status)
117 PRINTF(
"\r\n SPI Power Mode setting Failed\r\n");
122 status = pSPIdriver->Control(ARM_SPI_MODE_MASTER | ARM_SPI_CPOL0_CPHA0,
SPI_S_BAUDRATE);
123 if (ARM_DRIVER_OK != status)
125 PRINTF(
"\r\n SPI Control Mode setting Failed\r\n");
134 PRINTF(
"\r\n FXAS21002 Sensor Initialization Failed\r\n");
137 PRINTF(
"\r\n Successfully Initiliazed FXAS21002 Sensor\r\n");
146 PRINTF(
"\r\n FXAS21002 Sensor Configuration Failed, Err = %d\r\n", status);
149 PRINTF(
"\r\n Successfully Applied FXAS21002 Sensor Configuration\r\n");
162 if (ARM_DRIVER_OK != status)
164 PRINTF(
"\r\nRead Failed.\r\n");
169 rawData.
gyro[0] = ((int16_t)data[0] << 8) | data[1];
170 rawData.
gyro[1] = ((int16_t)data[2] << 8) | data[3];
171 rawData.
gyro[2] = ((int16_t)data[4] << 8) | data[5];
174 PRINTF(
"\r\n Gyro X = %d Y = %d Z = %d \r\n", rawData.
gyro[0], rawData.
gyro[1], rawData.
gyro[2]);
int32_t FXAS21002_SPI_ReadData(fxas21002_spi_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define __END_WRITE_DATA__
int main(void)
This is the The main function implementation.
#define BOARD_BootClockRUN
#define FXAS21002_CTRL_REG1_DR_MASK
uint8_t data[FXLS8962_DATA_SIZE]
const registerreadlist_t cFxas21002_DataReady[]
const registerreadlist_t cFxas21002_Output_Values[]
void FXAS21002_SPI_SetIdleTask(fxas21002_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the SPI Idle Task.
void BOARD_InitDebugConsole(void)
const registerwritelist_t cFxas21002_Config_Normal[]
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
The fxas21002_drv.h file describes the fxas21002 driver interface and structures. ...
#define __END_READ_DATA__
int32_t FXAS21002_SPI_Configure(fxas21002_spi_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define FXAS21002_DR_STATUS_ZYXDR_MASK
This structure defines the fxas21002 raw data buffer.
int32_t FXAS21002_SPI_Initialize(fxas21002_spi_sensorhandle_t *pSensorHandle, ARM_DRIVER_SPI *pBus, uint8_t index, void *pSlaveSelect, uint8_t whoAmi)
The interface function to initialize the sensor.
#define SPI_S_DEVICE_INDEX
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
#define SPI_S_BAUDRATE
Transfer baudrate - 500k.
This defines the sensor specific information for SPI.
fxls8962_acceldataUser_t rawData
#define SPI_S_SIGNAL_EVENT
This structure defines the Write command List.
This structure defines the Read command List.
#define FXAS21002_GYRO_DATA_SIZE
The size of the FXAS21002 gyro data.
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
#define FXAS21002_CTRL_REG1_DR_12_5HZ