Sensor Fusion Library 0.6.1
Orientation sensing for Espressif (ESP32, ESP8266) processors
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
control.h File Reference

Defines control sub-system. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ControlSubsystem
 The ControlSubsystem encapsulates command and data streaming functions. More...
 

Macros

#define MAX_LEN_SERIAL_OUTPUT_BUF   255
 

Typedefs

typedef struct ControlSubsystem ControlSubsystem
 The ControlSubsystem encapsulates command and data streaming functions.
 
Control Port Function Type Definitions

"write" "stream" and "readCommands" provide three control functions visible at the main() level. These typedefs define the structure of those calls.

typedef int8_t() writePort_t(SensorFusionGlobals *sfg)
 
typedef int8_t() readCommand_t(SensorFusionGlobals *sfg)
 
typedef void() injectCommand_t(SensorFusionGlobals *sfg, uint8_t input_buffer[], uint16_t nbytes)
 
typedef void() streamData_t(SensorFusionGlobals *sfg)
 

Functions

bool initializeIOSubsystem (ControlSubsystem *pComm, const void *serial_port, const void *tcp_client)
 Initialize the control subsystem and all related hardware.
 
void UpdateTCPClient (ControlSubsystem *pComm, void *tcp_client)
 
void CreateOutgoingPackets (SensorFusionGlobals *sfg)
 
void DecodeCommandBytes (SensorFusionGlobals *sfg, uint8_t input_buffer[], uint16_t nbytes)
 
void OutputBufAppendItem (uint8_t *pDest, uint16_t *pIndex, uint8_t *pSource, uint16_t iBytesToCopy)
 Utility function used to place data in output buffer about to be transmitted via UART.
 

Detailed Description

Defines control sub-system.

Each sensor fusion application will have its own set of functions to control the fusion process and report results. This file defines the programming interface that should be followed in order for the fusion functions to operate correctly out of the box. The actual command interpreter is defined separately in control_input.c. The output streaming function is defined in control_output.c. Via these three files, the NXP Sensor Fusion Library provides a default set of functions which are compatible with the Sensor Fusion Toolbox. Use of the toolbox is highly recommended at least during initial development, as it provides many useful debug features. The NXP development team will typically require use of the toolbox as a pre-requisite for providing software support. Data packets are sent via serial interface, which can be a wired UART, Bluetooth, socket via WiFi, etc. Currently UART & WiFi are implemented.

Definition in file control.h.

Macro Definition Documentation

◆ MAX_LEN_SERIAL_OUTPUT_BUF

#define MAX_LEN_SERIAL_OUTPUT_BUF   255

Definition at line 34 of file control.h.

Typedef Documentation

◆ ControlSubsystem

The ControlSubsystem encapsulates command and data streaming functions.

The ControlSubsystem encapsulates command and data streaming functions for the library. A C++-like typedef structure which includes executable methods for the subsystem is defined here.

◆ injectCommand_t

typedef void() injectCommand_t(SensorFusionGlobals *sfg, uint8_t input_buffer[], uint16_t nbytes)

Definition at line 42 of file control.h.

◆ readCommand_t

typedef int8_t() readCommand_t(SensorFusionGlobals *sfg)

Definition at line 41 of file control.h.

◆ streamData_t

typedef void() streamData_t(SensorFusionGlobals *sfg)

Definition at line 43 of file control.h.

◆ writePort_t

typedef int8_t() writePort_t(SensorFusionGlobals *sfg)

Definition at line 40 of file control.h.

Function Documentation

◆ CreateOutgoingPackets()

void CreateOutgoingPackets ( SensorFusionGlobals sfg)

Called once per fusion cycle to stream information required by the NXP Sensor Fusion Toolbox. Packet protocols are defined in the NXP Sensor Fusion for Kinetis Product Development Kit User Guide.

Definition at line 118 of file control_output.c.

◆ DecodeCommandBytes()

void DecodeCommandBytes ( SensorFusionGlobals sfg,
uint8_t  input_buffer[],
uint16_t  nbytes 
)

Located in control_input.c: This function is responsible for decoding commands, which can arrive externally (serial or WiFi) when sent by the NXP Sensor Fusion Toolbox, or by direct call. This function sets the appropriate flags in the ControlSubsystem data structure, or performs whatever other appropriate action called for by the command. Packet protocols are defined in the NXP Sensor Fusion for Kinetis Product Development Kit User Guide.

Definition at line 70 of file control_input.c.

◆ initializeIOSubsystem()

bool initializeIOSubsystem ( ControlSubsystem pComm,
const void *  serial_port,
const void *  tcp_client 
)

Initialize the control subsystem and all related hardware.

Parameters
pCommpointer to the control subystem structure

Definition at line 112 of file control.cc.

◆ OutputBufAppendItem()

void OutputBufAppendItem ( uint8_t *  pDest,
uint16_t *  pIndex,
uint8_t *  pSource,
uint16_t  iBytesToCopy 
)

Utility function used to place data in output buffer about to be transmitted via UART.

Definition at line 34 of file control_output.c.

◆ UpdateTCPClient()

void UpdateTCPClient ( ControlSubsystem pComm,
void *  tcp_client 
)

Definition at line 142 of file control.cc.