SerialIO
Loading...
Searching...
No Matches
SerialIO.h
Go to the documentation of this file.
1
5#pragma once
6#ifndef SerialIO_H
7#define SerialIO_H
8#include <Arduino.h>
9#define PACKED __attribute__((packed))
10
11typedef struct rc_channels_s {
12 unsigned channel1 : 11;
13 unsigned channel2 : 11;
14 unsigned channel3 : 11;
15 unsigned channel4 : 11;
16 unsigned channel5 : 11;
17 unsigned channel6 : 11;
18 unsigned channel7 : 11;
19 unsigned channel8 : 11;
20 unsigned channel9 : 11;
21 unsigned channel10 : 11;
22 unsigned channel11 : 11;
23 unsigned channel12 : 11;
24 unsigned channel13 : 11;
25 unsigned channel14 : 11;
26 unsigned channel15 : 11;
27 unsigned channel16 : 11;
28} PACKED rc_channels_t;
29
30/**************************************************************************/
35/**************************************************************************/
36class SerialIO {
37public:
49 SerialIO(Stream *rxPort, int rxPin, int txPin, bool inverted);
50
51 virtual ~SerialIO();
52
53 /**************************************************************************/
57 /**************************************************************************/
58 virtual void begin() = 0;
59 /**************************************************************************/
63 /**************************************************************************/
64 virtual void processIncoming() = 0;
65 /**************************************************************************/
69 /**************************************************************************/
70 virtual void getChannel(rc_channels_t *channelData) = 0;
71
72protected:
73 Stream
74 *_rxPort; // Pointer to the hardware serial port used for communication.
75 bool _inverted; // Indicates whether the serial signal is inverted (true) or
76 // not (false).
77 int _rxPin; // The RX pin number.
78 int _txPin; // The TX pin number.
79 void leftShift(uint8_t arr[], size_t size);
80 void rightShift(uint8_t arr[], size_t size);
81};
82#include "crsf/crsf.h"
83#include "fport/fport.h"
84#include "ibus/ibus.h"
85#include "sbus/sbus.h"
86
87#endif
Class that stores state and functions for initialising and decoding rc protocol.
Definition SerialIO.h:36
virtual void begin()=0
Initialises the pins and setup serial port.
virtual void processIncoming()=0
decode the incoming serial data.
SerialIO(Stream *rxPort, int rxPin, int txPin, bool inverted)
Constructor for the SerialIO class.
Definition SerialIO.cpp:3
virtual void getChannel(rc_channels_t *channelData)=0
Get the ChannelData.
Header file for the CRSF protocol implementation.
Header file for the FPort Protocol definations.
Header file for the Ibus protocol implementation.
Header file for the SBUS protocol implementation.
Definition SerialIO.h:11