Sensor Fusion Library 0.6.1
Orientation sensing for Espressif (ESP32, ESP8266) processors
Loading...
Searching...
No Matches
control.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
27#ifndef _CONTROL_H_
28#define _CONTROL_H_
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#define MAX_LEN_SERIAL_OUTPUT_BUF 255 // larger than the nominal 124 byte size for outgoing packets
35
40typedef int8_t (writePort_t) (SensorFusionGlobals *sfg);
41typedef int8_t (readCommand_t) (SensorFusionGlobals *sfg);
42typedef void (injectCommand_t) (SensorFusionGlobals *sfg, uint8_t input_buffer[], uint16_t nbytes);
43typedef void (streamData_t)(SensorFusionGlobals *sfg);
45
51typedef struct ControlSubsystem {
52 quaternion_type DefaultQuaternionPacketType; // default quaternion transmitted at power on
53 volatile quaternion_type QuaternionPacketType; // quaternion type transmitted over UART
54 volatile uint8_t AngularVelocityPacketOn; // flag to enable angular velocity packet
55 volatile uint8_t DebugPacketOn; // flag to enable debug packet
56 volatile uint8_t RPCPacketOn; // flag to enable roll, pitch, compass packet
57 volatile uint8_t AltPacketOn; // flag to enable altitude packet
58 volatile int8_t AccelCalPacketOn; // variable used to coordinate accelerometer calibration
59 uint8_t *serial_out_buf; //buffer containing the output stream (data packet)
60 uint16_t bytes_to_send; //how many bytes in output stream waiting to go out
61 const void *serial_port; //cast to Serial * and used to output to the serial port
62 const void *tcp_client; //cast to WiFiClient * and used to output to a connected TCP client
63
64 writePort_t *write; // function to write output buffer to the output(s)
65 readCommand_t *readCommands; // function to check for incoming commands and process them
66 injectCommand_t *injectCommand; // function that provides a command directly and processes it
67 streamData_t *stream; // function to create output data packets and place in buffer
69
71 ControlSubsystem *pComm, const void *serial_port,
72 const void *tcp_client); // Initialize structures, ports, etc.
73
74//updates pointer to the TCP client. Call whenever new client connects or disconnects
75void UpdateTCPClient(ControlSubsystem *pComm,void *tcp_client);
76
77// Located in output_stream.c:
82
89void DecodeCommandBytes(SensorFusionGlobals *sfg, uint8_t input_buffer[], uint16_t nbytes);
90
92void OutputBufAppendItem(uint8_t *pDest, uint16_t *pIndex, uint8_t *pSource, uint16_t iBytesToCopy);
93
94#ifdef __cplusplus
95}
96#endif
97
98
99#endif /* _CONTROL_H_ */
bool initializeIOSubsystem(ControlSubsystem *pComm, const void *serial_port, const void *tcp_client)
Initialize the control subsystem and all related hardware.
Definition control.cc:112
void CreateOutgoingPackets(SensorFusionGlobals *sfg)
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.
void DecodeCommandBytes(SensorFusionGlobals *sfg, uint8_t input_buffer[], uint16_t nbytes)
enum quaternion quaternion_type
the quaternion type to be transmitted
The ControlSubsystem encapsulates command and data streaming functions.
Definition control.h:51
The top level fusion structure.