Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
firmware
boards
airbourne
airbourne
include
rc_sbus.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017, James Jackson
3
*
4
* All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions are met:
8
*
9
* * Redistributions of source code must retain the above copyright notice, this
10
* list of conditions and the following disclaimer.
11
*
12
* * Redistributions in binary form must reproduce the above copyright notice,
13
* this list of conditions and the following disclaimer in the documentation
14
* and/or other materials provided with the distribution.
15
*
16
* * Neither the name of the copyright holder nor the names of its
17
* contributors may be used to endorse or promote products derived from
18
* this software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32
#ifndef RC_SBUS_H
33
#define RC_SBUS_H
34
35
#include "
system.h
"
36
37
#include "
rc_base.h
"
38
#include "
gpio.h
"
39
#include "
uart.h
"
40
41
class
RC_SBUS
:
public
RC_BASE
42
{
43
44
private
:
45
46
enum
47
{
48
START_BYTE
= 0x0F,
49
END_BYTE
= 0x00
50
};
51
52
typedef
enum
53
{
54
SBUS_SIGNAL_OK
,
55
SBUS_SIGNAL_LOST
,
56
SBUS_SIGNAL_FAILSAFE
57
}
failsafe_state_t
;
58
59
struct
dataFrame_s
60
{
61
uint8_t
startByte
;
62
unsigned
int
chan0
: 11;
63
unsigned
int
chan1
: 11;
64
unsigned
int
chan2
: 11;
65
unsigned
int
chan3
: 11;
66
unsigned
int
chan4
: 11;
67
unsigned
int
chan5
: 11;
68
unsigned
int
chan6
: 11;
69
unsigned
int
chan7
: 11;
70
unsigned
int
chan8
: 11;
71
unsigned
int
chan9
: 11;
72
unsigned
int
chan10
: 11;
73
unsigned
int
chan11
: 11;
74
unsigned
int
chan12
: 11;
75
unsigned
int
chan13
: 11;
76
unsigned
int
chan14
: 11;
77
unsigned
int
chan15
: 11;
78
uint8_t
digichannels
;
79
uint8_t
endByte
;
80
}
__attribute__
((__packed__));
81
82
typedef
union
83
{
84
uint8_t data[25];
85
struct
dataFrame_s
frame;
86
}
SBUS_t
;
87
88
SBUS_t
sbus_union_
;
89
90
failsafe_state_t
failsafe_status_
;
91
92
GPIO
*
inv_pin_
;
93
UART
*
uart_
;
94
uint32_t
raw_
[18];
95
uint32_t
frame_start_ms_
= 0;
96
uint8_t
buffer_
[25];
97
uint8_t
buffer_pos_
= 0;
98
uint32_t
errors_
= 0;
99
uint8_t
prev_byte_
= 0;
100
bool
frame_started_
=
false
;
101
102
void
decode_buffer
();
103
104
public
:
105
106
void
init
(
GPIO
*inv_pin,
UART
*uart);
107
void
read_cb
(uint8_t byte);
108
float
read
(uint8_t channel);
109
bool
lost
();
110
inline
uint32_t
get_errors
()
111
{
112
return
errors_
;
113
}
114
115
};
116
117
#endif // RC_SBUS_H
RC_SBUS::__attribute__
typedef __attribute__
uart.h
RC_SBUS::dataFrame_s::chan2
unsigned int chan2
Definition:
rc_sbus.h:64
RC_SBUS::SBUS_SIGNAL_FAILSAFE
Definition:
rc_sbus.h:56
RC_SBUS::dataFrame_s::endByte
uint8_t endByte
Definition:
rc_sbus.h:79
RC_SBUS::inv_pin_
GPIO * inv_pin_
Definition:
rc_sbus.h:92
gpio.h
RC_SBUS::dataFrame_s::chan12
unsigned int chan12
Definition:
rc_sbus.h:74
RC_SBUS::lost
bool lost()
Definition:
rc_sbus.cpp:62
RC_SBUS::SBUS_SIGNAL_LOST
Definition:
rc_sbus.h:55
RC_SBUS::decode_buffer
void decode_buffer()
Definition:
rc_sbus.cpp:67
RC_SBUS::dataFrame_s::chan7
unsigned int chan7
Definition:
rc_sbus.h:69
rc_base.h
RC_SBUS::dataFrame_s::chan5
unsigned int chan5
Definition:
rc_sbus.h:67
RC_SBUS::dataFrame_s::chan0
unsigned int chan0
Definition:
rc_sbus.h:62
RC_SBUS::dataFrame_s::chan11
unsigned int chan11
Definition:
rc_sbus.h:73
RC_SBUS::frame_start_ms_
uint32_t frame_start_ms_
Definition:
rc_sbus.h:95
RC_SBUS
Definition:
rc_sbus.h:41
RC_SBUS::dataFrame_s::startByte
uint8_t startByte
Definition:
rc_sbus.h:61
RC_SBUS::get_errors
uint32_t get_errors()
Definition:
rc_sbus.h:110
RC_SBUS::errors_
uint32_t errors_
Definition:
rc_sbus.h:98
RC_SBUS::prev_byte_
uint8_t prev_byte_
Definition:
rc_sbus.h:99
RC_SBUS::dataFrame_s::chan3
unsigned int chan3
Definition:
rc_sbus.h:65
RC_SBUS::dataFrame_s::chan14
unsigned int chan14
Definition:
rc_sbus.h:76
RC_SBUS::read_cb
void read_cb(uint8_t byte)
Definition:
rc_sbus.cpp:110
RC_SBUS::dataFrame_s::chan1
unsigned int chan1
Definition:
rc_sbus.h:63
RC_SBUS::failsafe_status_
failsafe_state_t failsafe_status_
Definition:
rc_sbus.h:90
UART
Definition:
uart.h:43
RC_BASE
Definition:
rc_base.h:39
RC_SBUS::uart_
UART * uart_
Definition:
rc_sbus.h:93
RC_SBUS::SBUS_SIGNAL_OK
Definition:
rc_sbus.h:54
RC_SBUS::sbus_union_
SBUS_t sbus_union_
Definition:
rc_sbus.h:88
RC_SBUS::SBUS_t
Definition:
rc_sbus.h:82
GPIO
Definition:
gpio.h:37
system.h
RC_SBUS::raw_
uint32_t raw_[18]
Definition:
rc_sbus.h:94
RC_SBUS::failsafe_state_t
failsafe_state_t
Definition:
rc_sbus.h:52
RC_SBUS::dataFrame_s::chan4
unsigned int chan4
Definition:
rc_sbus.h:66
RC_SBUS::dataFrame_s
Definition:
rc_sbus.h:59
RC_SBUS::dataFrame_s::chan8
unsigned int chan8
Definition:
rc_sbus.h:70
RC_SBUS::init
void init(GPIO *inv_pin, UART *uart)
Definition:
rc_sbus.cpp:42
RC_SBUS::dataFrame_s::chan15
unsigned int chan15
Definition:
rc_sbus.h:77
RC_SBUS::END_BYTE
Definition:
rc_sbus.h:49
RC_SBUS::frame_started_
bool frame_started_
Definition:
rc_sbus.h:100
RC_SBUS::dataFrame_s::chan13
unsigned int chan13
Definition:
rc_sbus.h:75
RC_SBUS::buffer_pos_
uint8_t buffer_pos_
Definition:
rc_sbus.h:97
RC_SBUS::dataFrame_s::digichannels
uint8_t digichannels
Definition:
rc_sbus.h:78
RC_SBUS::dataFrame_s::chan6
unsigned int chan6
Definition:
rc_sbus.h:68
RC_SBUS::read
float read(uint8_t channel)
Definition:
rc_sbus.cpp:57
RC_SBUS::START_BYTE
Definition:
rc_sbus.h:48
RC_SBUS::dataFrame_s::chan9
unsigned int chan9
Definition:
rc_sbus.h:71
RC_SBUS::buffer_
uint8_t buffer_[25]
Definition:
rc_sbus.h:96
RC_SBUS::dataFrame_s::chan10
unsigned int chan10
Definition:
rc_sbus.h:72
rosflight_firmware
Author(s): Daniel Koch
, James Jackson
autogenerated on Wed Jul 3 2019 19:59:25