ISSDK  1.8
IoT Sensing Software Development Kit
Macros | Functions | Variables
orientaion_application_baremetal_agm04.c File Reference

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"
Include dependency graph for orientaion_application_baremetal_agm04.c:

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
 

Detailed Description

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.

Macro Definition Documentation

◆ APPLICATION_NAME

#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 63 of file orientaion_application_baremetal_agm04.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 65 of file orientaion_application_baremetal_agm04.c.

Referenced by main().

◆ BOARDINFO_SIZE

#define BOARDINFO_SIZE   (1) /* Orientation Packet: BoardInfo field size */

Definition at line 59 of file orientaion_application_baremetal_agm04.c.

◆ BUILDNAME_SIZE

#define BUILDNAME_SIZE   (2) /* Orientation Packet: BuildInfo field size */

Definition at line 60 of file orientaion_application_baremetal_agm04.c.

◆ COORDINATES_SIZE

#define COORDINATES_SIZE   (1) /* Orientation Packet: coordinates field size */

Definition at line 58 of file orientaion_application_baremetal_agm04.c.

◆ EULERANGLE_DATA_SIZE

#define EULERANGLE_DATA_SIZE   (6) /* Orientation Packet: Roll,Pitch,Compass Euler angles packet field size */

Definition at line 56 of file orientaion_application_baremetal_agm04.c.

◆ FITERROR_DATA_SIZE

#define FITERROR_DATA_SIZE   (2) /* Orientation Packet: FitError% field size */

Definition at line 57 of file orientaion_application_baremetal_agm04.c.

◆ NINEAXISSENSOR_DATA_SIZE

#define NINEAXISSENSOR_DATA_SIZE   (18) /* Orientation Packet: 9 Axis Sensor Data, Accel, Mag, Gyro field size */

Definition at line 54 of file orientaion_application_baremetal_agm04.c.

◆ QUATERNION_SIZE

#define QUATERNION_SIZE   (8) /* Orientation Packet: Quaternion field size */

Definition at line 55 of file orientaion_application_baremetal_agm04.c.

◆ STREAMING_PAYLOAD_LEN

Definition at line 68 of file orientaion_application_baremetal_agm04.c.

◆ SYSTICKINFO_SIZE

#define SYSTICKINFO_SIZE   (2) /* Orientation Packet: SysTick field size */

Definition at line 61 of file orientaion_application_baremetal_agm04.c.

◆ TIMESTAMP_DATA_SIZE

#define TIMESTAMP_DATA_SIZE   (4) /* Orientation Packet: TimeStamp field size */

Orient Packet Structure: 44 Bytes

| TimeStamp | 9 Axis Sensor data | Quaternion data | Euler angles data | FitError% data | Co-ordinates data | BoardInfo data | BuildInfo data | SysTick data | |

| 4 Bytes | 18 Bytes | 8 Bytes | 6 Bytes | 2 Bytes | 1 Bytes | 1 Byte | 2 Bytes | 2 Bytes | |

Definition at line 53 of file orientaion_application_baremetal_agm04.c.

Function Documentation

◆ appendZerosOrientBuf()

void appendZerosOrientBuf ( uint8_t *  pDest,
uint16_t *  pIndex,
uint16_t  numZeros 
)

appendZerosOrientBuf utility function

Definition at line 215 of file orientaion_application_baremetal_agm04.c.

References sBufAppendItem().

Here is the call graph for this function:

◆ main()

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 437 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, I2Cdrv, int32_t(), SHIELD_NAME, shieldString, and status.

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 
)

◆ readAlgoParams()

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 226 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.

Variable Documentation

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 79 of file orientaion_application_baremetal_agm04.c.

Referenced by main(), and process_host_command().

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 81 of file orientaion_application_baremetal_agm04.c.

Referenced by main(), and process_host_command().

◆ gOrientationControlSubsystem

ControlSubsystem gOrientationControlSubsystem

Definition at line 75 of file orientaion_application_baremetal_agm04.c.

◆ gPrimaryStreamID

uint8_t gPrimaryStreamID

Definition at line 78 of file orientaion_application_baremetal_agm04.c.

Referenced by process_host_command().

◆ gStreamingEnabled

volatile bool gStreamingEnabled

Definition at line 77 of file orientaion_application_baremetal_agm04.c.

Referenced by process_host_command().

◆ i2cBusInfo

Initial value:
= {
.deviceInstance = I2C_S_DEVICE_INDEX,
.functionParam = NULL,
.idleFunction = NULL
}
#define I2C_S_DEVICE_INDEX
Definition: issdk_hal.h:35

Definition at line 87 of file orientaion_application_baremetal_agm04.c.

◆ orientOutputBuffer

uint8_t orientOutputBuffer[STREAMING_HEADER_LEN+STREAMING_PAYLOAD_LEN]

Definition at line 83 of file orientaion_application_baremetal_agm04.c.

◆ sensors

struct PhysicalSensor sensors[3]

Definition at line 86 of file orientaion_application_baremetal_agm04.c.

◆ sfg

Definition at line 74 of file orientaion_application_baremetal_agm04.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 80 of file orientaion_application_baremetal_agm04.c.

Referenced by main(), and process_host_command().

◆ statusSubsystem

StatusSubsystem statusSubsystem

Definition at line 76 of file orientaion_application_baremetal_agm04.c.