![]() |
ISSDK
1.8
IoT Sensing Software Development Kit
|
The orientaion_application_baremetal_agm01.c file implements the ISSDK baremetal orientation application for FRDM-STBC-AGM01 using sensor fusion core functional interfaces and host i/o interface. More...
#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_port.h"
#include "fsl_i2c.h"
#include "fsl_pit.h"
#include "Driver_USART.h"
#include "fsl_i2c_cmsis.h"
#include "fsl_uart_cmsis.h"
#include "fxas21002.h"
#include "fxos8700.h"
#include "register_io_i2c.h"
#include "host_io_uart.h"
#include "gpio_driver.h"
#include "auto_detection_service.h"
#include "systick_utils.h"
#include "sensor_fusion.h"
#include "control.h"
#include "status.h"
#include "drivers.h"
#include "driver_pit.h"
Go to the source code of this file.
Macros | |
#define | TIMESTAMP_DATA_SIZE (4) /* Orientation Packet: TimeStamp field size */ |
#define | NINEAXISSENSOR_DATA_SIZE (18) /* Orientation Packet: 9 Axis Sensor Data, Accel, Mag, Gyro field size */ |
#define | QUATERNION_SIZE (8) /* Orientation Packet: Quaternion field size */ |
#define | EULERANGLE_DATA_SIZE (6) /* Orientation Packet: Roll,Pitch,Compass Euler angles packet field size */ |
#define | FITERROR_DATA_SIZE (2) /* Orientation Packet: FitError% field size */ |
#define | COORDINATES_SIZE (1) /* Orientation Packet: coordinates field size */ |
#define | BOARDINFO_SIZE (1) /* Orientation Packet: BoardInfo field size */ |
#define | BUILDNAME_SIZE (2) /* Orientation Packet: BuildInfo field size */ |
#define | SYSTICKINFO_SIZE (2) /* Orientation Packet: SysTick field size */ |
#define | APPLICATION_NAME "9 Axis Orientation Sensor Demo" /* Orientation Application Name */ |
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 | STREAMING_PAYLOAD_LEN (TIMESTAMP_DATA_SIZE + NINEAXISSENSOR_DATA_SIZE + QUATERNION_SIZE + EULERANGLE_DATA_SIZE + FITERROR_DATA_SIZE + COORDINATES_SIZE + BOARDINFO_SIZE + BUILDNAME_SIZE + SYSTICKINFO_SIZE) |
Functions | |
void | readAlgoParams (SV_ptr data, Quaternion *fq, int16_t *iPhi, int16_t *iThe, int16_t *iRho, int16_t iOmega[], uint16_t *isystick) |
Utility function for reading common algorithm parameters. More... | |
bool | process_host_command (uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize) |
void | appendZerosOrientBuf (uint8_t *pDest, uint16_t *pIndex, uint16_t numZeros) |
appendZerosOrientBuf utility function More... | |
int | main (void) |
Main function. More... | |
Variables | |
SensorFusionGlobals | sfg |
ControlSubsystem | gOrientationControlSubsystem |
StatusSubsystem | statusSubsystem |
char | boardString [ADS_MAX_STRING_LENGTH] = {0} |
char | shieldString [ADS_MAX_STRING_LENGTH] = {0} |
char | embAppName [ADS_MAX_STRING_LENGTH] = {0} |
volatile bool | gStreamingEnabled |
uint8_t | gPrimaryStreamID |
uint8_t | orientOutputBuffer [STREAMING_HEADER_LEN+STREAMING_PAYLOAD_LEN] |
struct PhysicalSensor | sensors [2] |
registerDeviceInfo_t | i2cBusInfo |
The orientaion_application_baremetal_agm01.c file implements the ISSDK baremetal orientation application for FRDM-STBC-AGM01 using sensor fusion core functional interfaces and host i/o interface.
Definition in file orientaion_application_baremetal_agm01.c.
#define APPLICATION_NAME "9 Axis Orientation Sensor Demo" /* Orientation Application Name */ |
Unique Name for this application which should match the target GUI pkg name.
Definition at line 64 of file orientaion_application_baremetal_agm01.c.
Referenced by main().
#define APPLICATION_VERSION "2.5" |
Version to distinguish between instances the same application based on target Shield and updates.
Definition at line 66 of file orientaion_application_baremetal_agm01.c.
Referenced by main().
#define BOARDINFO_SIZE (1) /* Orientation Packet: BoardInfo field size */ |
Definition at line 60 of file orientaion_application_baremetal_agm01.c.
#define BUILDNAME_SIZE (2) /* Orientation Packet: BuildInfo field size */ |
Definition at line 61 of file orientaion_application_baremetal_agm01.c.
#define COORDINATES_SIZE (1) /* Orientation Packet: coordinates field size */ |
Definition at line 59 of file orientaion_application_baremetal_agm01.c.
#define EULERANGLE_DATA_SIZE (6) /* Orientation Packet: Roll,Pitch,Compass Euler angles packet field size */ |
Definition at line 57 of file orientaion_application_baremetal_agm01.c.
#define FITERROR_DATA_SIZE (2) /* Orientation Packet: FitError% field size */ |
Definition at line 58 of file orientaion_application_baremetal_agm01.c.
#define NINEAXISSENSOR_DATA_SIZE (18) /* Orientation Packet: 9 Axis Sensor Data, Accel, Mag, Gyro field size */ |
Definition at line 55 of file orientaion_application_baremetal_agm01.c.
#define QUATERNION_SIZE (8) /* Orientation Packet: Quaternion field size */ |
Definition at line 56 of file orientaion_application_baremetal_agm01.c.
#define STREAMING_PAYLOAD_LEN (TIMESTAMP_DATA_SIZE + NINEAXISSENSOR_DATA_SIZE + QUATERNION_SIZE + EULERANGLE_DATA_SIZE + FITERROR_DATA_SIZE + COORDINATES_SIZE + BOARDINFO_SIZE + BUILDNAME_SIZE + SYSTICKINFO_SIZE) |
Definition at line 69 of file orientaion_application_baremetal_agm01.c.
#define SYSTICKINFO_SIZE (2) /* Orientation Packet: SysTick field size */ |
Definition at line 62 of file orientaion_application_baremetal_agm01.c.
#define TIMESTAMP_DATA_SIZE (4) /* Orientation Packet: TimeStamp field size */ |
Definition at line 54 of file orientaion_application_baremetal_agm01.c.
void appendZerosOrientBuf | ( | uint8_t * | pDest, |
uint16_t * | pIndex, | ||
uint16_t | numZeros | ||
) |
appendZerosOrientBuf utility function
Definition at line 216 of file orientaion_application_baremetal_agm01.c.
References sBufAppendItem().
int main | ( | void | ) |
Main function.
Initialize the MCU hardware.
Initialize and set the KSDK driver for the I2C port
Initialize the UART driver.
Set UART Power mode.
Set UART Baud Rate.
Initialize control sub-system for orientation packet streaming
Initialize sensor fusion status sub-system
Initialize sensor fusion global metadata
Install the sensors to be used by sensor fusion
Initialize streaming and assign Stream IDs.
Initialize sensor fusion engine
pitIsrFlag will be set true at FUSION_HZ periodic intervals
Check whether occur interupt
Check for incoming commands form Host.
Reads sensors, applies HAL and does averaging (if applicable)
Condition sensor data, magCal is run as part of this
Run fusion algorithms
Apply debug perturbation
assume NORMAL status for next pass through the loop
Encode Orietantion Stream Packet and send packet to host
Definition at line 438 of file orientaion_application_baremetal_agm01.c.
References ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickEnable(), boardString, embAppName, HOST_S_DRIVER, HOST_S_SIGNAL_EVENT, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, I2Cdrv, int32_t(), SHIELD_NAME, shieldString, and status.
bool process_host_command | ( | uint8_t | tag, |
uint8_t * | hostCommand, | ||
uint8_t * | hostResponse, | ||
size_t * | hostMsgSize, | ||
size_t | respBufferSize | ||
) |
Definition at line 119 of file orientaion_application_baremetal_agm01.c.
References boardString, embAppName, gPrimaryStreamID, gStreamingEnabled, HOST_CMD_START, HOST_CMD_STOP, HOST_MSG_CMD_ACT_OFFSET, HOST_MSG_LEN_LSB_OFFSET, HOST_PRO_CMD_W_CFG_TAG, HOST_PRO_INT_CMD_TAG, HOST_PRO_INT_DEV_TAG, LED_GREEN_ON, and shieldString.
void readAlgoParams | ( | SV_ptr | data, |
Quaternion * | fq, | ||
int16_t * | iPhi, | ||
int16_t * | iThe, | ||
int16_t * | iRho, | ||
int16_t | iOmega[], | ||
uint16_t * | isystick | ||
) |
Utility function for reading common algorithm parameters.
Definition at line 227 of file orientaion_application_baremetal_agm01.c.
References CHX, CHY, CHZ, SV_COMMON::fOmega, SV_COMMON::fPhi, SV_COMMON::fq, SV_COMMON::fRho, SV_COMMON::fThe, and SV_COMMON::systick.
char boardString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 78 of file orientaion_application_baremetal_agm01.c.
Referenced by main(), and process_host_command().
char embAppName[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 79 of file orientaion_application_baremetal_agm01.c.
Referenced by main(), and process_host_command().
ControlSubsystem gOrientationControlSubsystem |
Definition at line 76 of file orientaion_application_baremetal_agm01.c.
uint8_t gPrimaryStreamID |
Definition at line 81 of file orientaion_application_baremetal_agm01.c.
Referenced by process_host_command().
volatile bool gStreamingEnabled |
Definition at line 80 of file orientaion_application_baremetal_agm01.c.
Referenced by process_host_command().
registerDeviceInfo_t i2cBusInfo |
Definition at line 88 of file orientaion_application_baremetal_agm01.c.
uint8_t orientOutputBuffer[STREAMING_HEADER_LEN+STREAMING_PAYLOAD_LEN] |
Definition at line 83 of file orientaion_application_baremetal_agm01.c.
struct PhysicalSensor sensors[2] |
Definition at line 86 of file orientaion_application_baremetal_agm01.c.
Definition at line 75 of file orientaion_application_baremetal_agm01.c.
Referenced by FXOS8700_Init(), and initializeSensors().
char shieldString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 78 of file orientaion_application_baremetal_agm01.c.
Referenced by main(), and process_host_command().
StatusSubsystem statusSubsystem |
Definition at line 77 of file orientaion_application_baremetal_agm01.c.