![]() |
ISSDK
1.7
IoT Sensing Software Development Kit
|
The orientaion_application_baremetal_agm04.c file implements the ISSDK baremetal orientation application for FRDM-STBC-AGM04 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 "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 |
volatile bool | gStreamingEnabled |
uint8_t | gPrimaryStreamID |
char | boardString [ADS_MAX_STRING_LENGTH] = {0} |
char | shieldString [ADS_MAX_STRING_LENGTH] = {0} |
char | embAppName [ADS_MAX_STRING_LENGTH] = {0} |
uint8_t | orientOutputBuffer [STREAMING_HEADER_LEN+STREAMING_PAYLOAD_LEN] |
struct PhysicalSensor | sensors [3] |
registerDeviceInfo_t | i2cBusInfo |
The orientaion_application_baremetal_agm04.c file implements the ISSDK baremetal orientation application for FRDM-STBC-AGM04 using sensor fusion core functional interfaces and host i/o interface.
Definition in file orientaion_application_baremetal_agm04.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 89 of file orientaion_application_baremetal_agm04.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 91 of file orientaion_application_baremetal_agm04.c.
Referenced by main().
#define BOARDINFO_SIZE (1) /* Orientation Packet: BoardInfo field size */ |
Definition at line 85 of file orientaion_application_baremetal_agm04.c.
#define BUILDNAME_SIZE (2) /* Orientation Packet: BuildInfo field size */ |
Definition at line 86 of file orientaion_application_baremetal_agm04.c.
#define COORDINATES_SIZE (1) /* Orientation Packet: coordinates field size */ |
Definition at line 84 of file orientaion_application_baremetal_agm04.c.
#define EULERANGLE_DATA_SIZE (6) /* Orientation Packet: Roll,Pitch,Compass Euler angles packet field size */ |
Definition at line 82 of file orientaion_application_baremetal_agm04.c.
#define FITERROR_DATA_SIZE (2) /* Orientation Packet: FitError% field size */ |
Definition at line 83 of file orientaion_application_baremetal_agm04.c.
#define NINEAXISSENSOR_DATA_SIZE (18) /* Orientation Packet: 9 Axis Sensor Data, Accel, Mag, Gyro field size */ |
Definition at line 80 of file orientaion_application_baremetal_agm04.c.
#define QUATERNION_SIZE (8) /* Orientation Packet: Quaternion field size */ |
Definition at line 81 of file orientaion_application_baremetal_agm04.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 94 of file orientaion_application_baremetal_agm04.c.
#define SYSTICKINFO_SIZE (2) /* Orientation Packet: SysTick field size */ |
Definition at line 87 of file orientaion_application_baremetal_agm04.c.
#define TIMESTAMP_DATA_SIZE (4) /* Orientation Packet: TimeStamp field size */ |
Definition at line 79 of file orientaion_application_baremetal_agm04.c.
void appendZerosOrientBuf | ( | uint8_t * | pDest, |
uint16_t * | pIndex, | ||
uint16_t | numZeros | ||
) |
appendZerosOrientBuf utility function
Definition at line 241 of file orientaion_application_baremetal_agm04.c.
References sBufAppendItem().
int main | ( | void | ) |
Main function.
Initialize the MCU hardware.
Run ADS.
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
Required to check incoming host command and send response before host times out
assume NORMAL status for next pass through the loop
Required to check incoming host command and send response before host times out
Encode Orietantion Stream Packet and send packet to host
Definition at line 463 of file orientaion_application_baremetal_agm04.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, 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 144 of file orientaion_application_baremetal_agm04.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 252 of file orientaion_application_baremetal_agm04.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 105 of file orientaion_application_baremetal_agm04.c.
Referenced by main(), and process_host_command().
char embAppName[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 107 of file orientaion_application_baremetal_agm04.c.
Referenced by main(), and process_host_command().
ControlSubsystem gOrientationControlSubsystem |
Definition at line 101 of file orientaion_application_baremetal_agm04.c.
uint8_t gPrimaryStreamID |
Definition at line 104 of file orientaion_application_baremetal_agm04.c.
Referenced by process_host_command().
volatile bool gStreamingEnabled |
Definition at line 103 of file orientaion_application_baremetal_agm04.c.
Referenced by process_host_command().
registerDeviceInfo_t i2cBusInfo |
Definition at line 113 of file orientaion_application_baremetal_agm04.c.
uint8_t orientOutputBuffer[STREAMING_HEADER_LEN+STREAMING_PAYLOAD_LEN] |
Definition at line 109 of file orientaion_application_baremetal_agm04.c.
struct PhysicalSensor sensors[3] |
Definition at line 112 of file orientaion_application_baremetal_agm04.c.
Definition at line 100 of file orientaion_application_baremetal_agm04.c.
char shieldString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 106 of file orientaion_application_baremetal_agm04.c.
Referenced by main(), and process_host_command().
StatusSubsystem statusSubsystem |
Definition at line 102 of file orientaion_application_baremetal_agm04.c.