ISSDK  1.7
IoT Sensing Software Development Kit
Data Structures | Macros | Functions | Variables
fxas21002_demo.c File Reference

The fxas21002_demo.c file implements the ISSDK FXAS21002 sensor demo example demonstration with interrupt mode. More...

#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "Driver_I2C.h"
#include "Driver_USART.h"
#include "issdk_hal.h"
#include "gpio_driver.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "fxas21002_drv.h"
#include "auto_detection_service.h"
Include dependency graph for fxas21002_demo.c:

Go to the source code of this file.

Data Structures

struct  fxas21002_gyrodataUser_t
 This structure defines the fxas21002 raw data buffer. More...
 

Macros

#define FXAS21002_STREAM_DATA_SIZE   12
 
#define APPLICATION_NAME   "FXAS21002 Gyroscope Demo"
 Unique Name for this application which should match the target GUI pkg name. More...
 
#define APPLICATION_VERSION   "2.5"
 Version to distinguish between instances the same application based on target Shield and updates. More...
 
#define SKIP_PACKET_COUNT   5
 

Functions

void fxas21002_int_data_ready_callback (void *pUserData)
 
bool process_host_command (uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
 
int main (void)
 Main function. More...
 

Variables

const registerwritelist_t fxas21002_Config_Isr []
 
const registerreadlist_t fxas21002_Output_Values []
 
const registerreadlist_t fxas21002_Reg []
 
const registerreadlist_t fxas21002_Temp []
 
char boardString [ADS_MAX_STRING_LENGTH] = {0}
 
char shieldString [ADS_MAX_STRING_LENGTH] = {0}
 
char embAppName [ADS_MAX_STRING_LENGTH] = {0}
 
volatile bool bStreamingEnabled = false
 
volatile bool bFxas21002DataReady = false
 
volatile bool bFxas21002Ready = false
 
volatile uint8_t bSkipPacket = 0
 
uint8_t gStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The fxas21002_demo.c file implements the ISSDK FXAS21002 sensor demo example demonstration with interrupt mode.

Definition in file fxas21002_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "FXAS21002 Gyroscope Demo"

Unique Name for this application which should match the target GUI pkg name.

Definition at line 70 of file fxas21002_demo.c.

Referenced by main().

◆ APPLICATION_VERSION

#define APPLICATION_VERSION   "2.5"

Version to distinguish between instances the same application based on target Shield and updates.

Definition at line 72 of file fxas21002_demo.c.

Referenced by main().

◆ FXAS21002_STREAM_DATA_SIZE

#define FXAS21002_STREAM_DATA_SIZE   12

Definition at line 67 of file fxas21002_demo.c.

Referenced by main().

◆ SKIP_PACKET_COUNT

#define SKIP_PACKET_COUNT   5

Definition at line 74 of file fxas21002_demo.c.

Referenced by process_host_command().

Function Documentation

◆ fxas21002_int_data_ready_callback()

void fxas21002_int_data_ready_callback ( void *  pUserData)

Set flag to indicate Sensor has signalled data ready.

Definition at line 127 of file fxas21002_demo.c.

References bFxas21002DataReady.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware.

Initialize FXAS21002 pin used by FRDM board

Initialize RGB LED pin used by FRDM board

Initialize the I2C driver.

Set the I2C Power mode.

Set the I2C bus speed.

Initialize the UART driver.

Set the UART Power mode.

Set UART Baud Rate.

Initialize FXAS21002 sensor driver.

Set the task to be executed while waiting for SPI transactions to complete.

Configure the FXAS21002 sensor.

Initialize streaming and assign a Stream ID.

Populate streaming header.

Clear the data ready flag, it will be set again by the ISR.

Read new raw sensor data from the FXAS21002.

Convert the raw sensor data to signed 16-bit container for display to the debug port.

Definition at line 217 of file fxas21002_demo.c.

References ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bFxas21002DataReady, bFxas21002Ready, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bSkipPacket, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, fxas21002_i2c_sensorhandle_t::deviceInfo, embAppName, FXAS21002_GYRO_DATA_SIZE, FXAS21002_I2C_ADDR, FXAS21002_I2C_Configure(), FXAS21002_I2C_Initialize(), FXAS21002_I2C_ReadData(), FXAS21002_I2C_SetIdleTask(), FXAS21002_INT1, fxas21002_int_data_ready_callback(), FXAS21002_STREAM_DATA_SIZE, FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE, GPIO_DIRECTION_IN, GPIO_DIRECTION_OUT, GREEN_LED, gStreamID, gSystick, fxas21002_gyrodataUser_t::gyro, HOST_FORMAT_HDLC, Host_IO_Add_ISO_Header(), Host_IO_Init(), Host_IO_Receive(), Host_IO_Send(), HOST_S_DRIVER, HOST_S_SIGNAL_EVENT, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, int32_t(), fxas21002_gyrodataUser_t::intsrc, fxas21002_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, process_host_command(), rawData, SENSOR_ERROR_NONE, SHIELD_NAME, shieldString, SMC, SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, streamingPacket, fxas21002_gyrodataUser_t::temp, fxas21002_gyrodataUser_t::timestamp, fxls8962_acceldataUser_t::timestamp, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ process_host_command()

bool process_host_command ( uint8_t  tag,
uint8_t *  hostCommand,
uint8_t *  hostResponse,
size_t *  hostMsgSize,
size_t  respBufferSize 
)

Variable Documentation

◆ bFxas21002DataReady

volatile bool bFxas21002DataReady = false

Definition at line 117 of file fxas21002_demo.c.

Referenced by fxas21002_int_data_ready_callback(), and main().

◆ bFxas21002Ready

volatile bool bFxas21002Ready = false

Definition at line 117 of file fxas21002_demo.c.

Referenced by main(), and process_host_command().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 115 of file fxas21002_demo.c.

Referenced by main(), and process_host_command().

◆ bSkipPacket

volatile uint8_t bSkipPacket = 0

Definition at line 118 of file fxas21002_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 117 of file fxas21002_demo.c.

Referenced by main(), and process_host_command().

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 116 of file fxas21002_demo.c.

Referenced by main(), and process_host_command().

◆ fxas21002_Config_Isr

const registerwritelist_t fxas21002_Config_Isr[]
Initial value:
= {
{FXAS21002_F_SETUP, 0x00, 0x00},
{FXAS21002_CTRL_REG3, 0x00, 0x00},
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_MASK
Definition: fxas21002.h:783
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_INT1
Definition: fxas21002.h:812
#define FXAS21002_CTRL_REG2_INT_EN_RT_ENABLE
Definition: fxas21002.h:813
#define FXAS21002_CTRL_REG2_IPOL_MASK
Definition: fxas21002.h:780
#define __END_WRITE_DATA__
Definition: sensor_drv.h:71
#define FXAS21002_CTRL_REG1_DR_MASK
Definition: fxas21002.h:710
#define FXAS21002_CTRL_REG2_INT_EN_DRDY_ENABLE
Definition: fxas21002.h:809
#define FXAS21002_CTRL_REG2_INT_CFG_DRDY_MASK
Definition: fxas21002.h:786
#define FXAS21002_CTRL_REG2_INT_EN_RT_MASK
Definition: fxas21002.h:789
#define FXAS21002_CTRL_REG2_IPOL_ACTIVE_HIGH
Definition: fxas21002.h:808
#define FXAS21002_CTRL_REG1_DR_12_5HZ
Definition: fxas21002.h:736

Prepare the register write list to configure FXAS21002 in non-FIFO mode.

Definition at line 89 of file fxas21002_demo.c.

◆ fxas21002_Output_Values

const registerreadlist_t fxas21002_Output_Values[]
Initial value:
= {
#define __END_READ_DATA__
Definition: sensor_drv.h:77
#define FXAS21002_GYRO_DATA_SIZE
The size of the FXAS21002 gyro data.
Definition: fxas21002_drv.h:87

Prepare the register read list to read the raw gyro data from the FXAS21002.

Definition at line 103 of file fxas21002_demo.c.

◆ fxas21002_Reg

const registerreadlist_t fxas21002_Reg[]
Initial value:
= {
{.readFrom = FXAS21002_INT_SRC_FLAG, .numBytes = 1}, __END_READ_DATA__}
#define __END_READ_DATA__
Definition: sensor_drv.h:77

Definition at line 106 of file fxas21002_demo.c.

◆ fxas21002_Temp

const registerreadlist_t fxas21002_Temp[]
Initial value:
= {
{.readFrom = FXAS21002_TEMP, .numBytes = 1}, __END_READ_DATA__}
#define __END_READ_DATA__
Definition: sensor_drv.h:77

Definition at line 109 of file fxas21002_demo.c.

◆ gStreamID

uint8_t gStreamID

Definition at line 119 of file fxas21002_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 120 of file fxas21002_demo.c.

Referenced by main(), and process_host_command().

◆ pGpioDriver

Definition at line 121 of file fxas21002_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 115 of file fxas21002_demo.c.

Referenced by main(), and process_host_command().