NinjaFlight
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
serial.h
Go to the documentation of this file.
1
/*
2
* This file is part of Ninjaflight.
3
*
4
* Copyright: collective.
5
* Cleanup: Martin Schröder <mkschreder.uk@gmail.com>
6
* Original source from Cleanflight.
7
*
8
* Ninjaflight is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* Ninjaflight is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#pragma once
23
24
// TODO: this should not depend on target just for serial_port_count
25
#include "target.h"
26
28
typedef
enum
{
29
SERIAL_PORT_NONE
= -1,
30
SERIAL_PORT_UART1
= 0,
31
SERIAL_PORT_UART2
,
32
SERIAL_PORT_UART3
,
33
SERIAL_PORT_UART4
,
34
SERIAL_PORT_UART5
,
35
SERIAL_PORT_USB_VCP
= 20,
36
SERIAL_PORT_SOFTSERIAL1
= 30,
37
SERIAL_PORT_SOFTSERIAL2
,
38
SERIAL_PORT_IDENTIFIER_MAX
=
SERIAL_PORT_SOFTSERIAL2
39
}
serialPortIdentifier_e
;
40
41
typedef
enum
{
42
PORTSHARING_UNUSED
= 0,
43
PORTSHARING_NOT_SHARED
,
44
PORTSHARING_SHARED
45
}
portSharing_e
;
46
47
typedef
enum
{
48
FUNCTION_NONE
= 0,
49
FUNCTION_MSP
= (1 << 0),
// 1
50
FUNCTION_GPS
= (1 << 1),
// 2
51
FUNCTION_TELEMETRY_FRSKY
= (1 << 2),
// 4
52
FUNCTION_TELEMETRY_HOTT
= (1 << 3),
// 8
53
FUNCTION_TELEMETRY_LTM
= (1 << 4),
// 16
54
FUNCTION_TELEMETRY_SMARTPORT
= (1 << 5),
// 32
55
FUNCTION_RX_SERIAL
= (1 << 6),
// 64
56
FUNCTION_BLACKBOX
= (1 << 7),
// 128
57
FUNCTION_TELEMETRY_MAVLINK
= (1 << 8)
// 256
58
}
serialPortFunction_e
;
59
60
typedef
enum
{
61
BAUD_AUTO
= 0,
62
BAUD_9600
,
63
BAUD_19200
,
64
BAUD_38400
,
65
BAUD_57600
,
66
BAUD_115200
,
67
BAUD_230400
,
68
BAUD_250000
,
69
}
baudRate_e
;
70
71
struct
serial_port_config
{
72
serialPortIdentifier_e
identifier
;
73
uint16_t
functionMask
;
74
uint8_t
msp_baudrateIndex
;
75
uint8_t
gps_baudrateIndex
;
76
uint8_t
blackbox_baudrateIndex
;
77
uint8_t
telemetry_baudrateIndex
;
// not used for all telemetry systems, e.g. HoTT only works at 19200.
78
}
__attribute__
((packed)) ;
79
80
struct
serial_config
{
81
uint8_t
reboot_character
;
// which byte is used to reboot. Default 'R', could be changed carefully to something else.
82
struct
serial_port_config
portConfigs
[
SERIAL_PORT_COUNT
];
83
}
__attribute__
((packed)) ;
84
BAUD_9600
Definition:
serial.h:62
FUNCTION_TELEMETRY_LTM
Definition:
serial.h:53
SERIAL_PORT_UART1
Definition:
serial.h:30
serial_port_config::telemetry_baudrateIndex
uint8_t telemetry_baudrateIndex
Definition:
serial.h:77
portSharing_e
portSharing_e
Definition:
serial.h:41
BAUD_230400
Definition:
serial.h:67
PORTSHARING_SHARED
Definition:
serial.h:44
serial_port_config::gps_baudrateIndex
uint8_t gps_baudrateIndex
Definition:
serial.h:75
serial_port_config::functionMask
uint16_t functionMask
Definition:
serial.h:73
SERIAL_PORT_COUNT
#define SERIAL_PORT_COUNT
Definition:
target.h:92
serial_port_config
Definition:
serial.h:71
SERIAL_PORT_UART3
Definition:
serial.h:32
serialPortIdentifier_e
serialPortIdentifier_e
serial port identifiers
Definition:
serial.h:28
BAUD_AUTO
Definition:
serial.h:61
serial_port_config::msp_baudrateIndex
uint8_t msp_baudrateIndex
Definition:
serial.h:74
SERIAL_PORT_UART2
Definition:
serial.h:31
SERIAL_PORT_USB_VCP
Definition:
serial.h:35
BAUD_250000
Definition:
serial.h:68
SERIAL_PORT_UART4
Definition:
serial.h:33
BAUD_115200
Definition:
serial.h:66
FUNCTION_RX_SERIAL
Definition:
serial.h:55
FUNCTION_MSP
Definition:
serial.h:49
serialPortFunction_e
serialPortFunction_e
Definition:
serial.h:47
FUNCTION_TELEMETRY_SMARTPORT
Definition:
serial.h:54
serial_port_config::identifier
serialPortIdentifier_e identifier
Definition:
serial.h:72
SERIAL_PORT_NONE
Definition:
serial.h:29
baudRate_e
baudRate_e
Definition:
serial.h:60
serial_config
Definition:
serial.h:80
FUNCTION_GPS
Definition:
serial.h:50
SERIAL_PORT_SOFTSERIAL2
Definition:
serial.h:37
PORTSHARING_NOT_SHARED
Definition:
serial.h:43
serial_config::portConfigs
struct serial_port_config portConfigs[SERIAL_PORT_COUNT]
Definition:
serial.h:82
FUNCTION_NONE
Definition:
serial.h:48
FUNCTION_TELEMETRY_FRSKY
Definition:
serial.h:51
SERIAL_PORT_SOFTSERIAL1
Definition:
serial.h:36
BAUD_19200
Definition:
serial.h:63
serial_config::reboot_character
uint8_t reboot_character
Definition:
serial.h:81
BAUD_38400
Definition:
serial.h:64
PORTSHARING_UNUSED
Definition:
serial.h:42
FUNCTION_TELEMETRY_HOTT
Definition:
serial.h:52
FUNCTION_TELEMETRY_MAVLINK
Definition:
serial.h:57
serial_port_config::blackbox_baudrateIndex
uint8_t blackbox_baudrateIndex
Definition:
serial.h:76
SERIAL_PORT_IDENTIFIER_MAX
Definition:
serial.h:38
__attribute__
typedef __attribute__
BAUD_57600
Definition:
serial.h:65
SERIAL_PORT_UART5
Definition:
serial.h:34
FUNCTION_BLACKBOX
Definition:
serial.h:56
src
main
config
serial.h
Generated on Mon Dec 12 2016 15:48:45 for NinjaFlight by
1.8.7