CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/AP_Periph/serial_options.cpp
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
/*
16
serial options support, for serial over DroneCAN
17
*/
18
19
#include "AP_Periph.h"
20
21
#ifdef HAL_PERIPH_ENABLE_SERIAL_OPTIONS
22
23
#include "serial_options.h"
24
#include <AP_SerialManager/AP_SerialManager_config.h>
25
26
extern const AP_HAL::HAL &hal;
27
28
const AP_Param::GroupInfo SerialOptions::var_info[] {
29
30
#if HAL_HAVE_SERIAL0
31
// @Group: 0_
32
// @Path: serial_options_dev.cpp
33
AP_SUBGROUPINFO(devs[0], "0_", 1, SerialOptions, SerialOptionsDev),
34
#endif
35
36
#if HAL_HAVE_SERIAL1
37
// @Group: 1_
38
// @Path: serial_options_dev.cpp
39
AP_SUBGROUPINFO(devs[1], "1_", 2, SerialOptions, SerialOptionsDev),
40
#endif
41
42
#if HAL_HAVE_SERIAL2
43
// @Group: 2_
44
// @Path: serial_options_dev.cpp
45
AP_SUBGROUPINFO(devs[2], "2_", 3, SerialOptions, SerialOptionsDev),
46
#endif
47
48
#if HAL_HAVE_SERIAL3
49
// @Group: 3_
50
// @Path: serial_options_dev.cpp
51
AP_SUBGROUPINFO(devs[3], "3_", 4, SerialOptions, SerialOptionsDev),
52
#endif
53
54
#if HAL_HAVE_SERIAL4
55
// @Group: 4_
56
// @Path: serial_options_dev.cpp
57
AP_SUBGROUPINFO(devs[4], "4_", 5, SerialOptions, SerialOptionsDev),
58
#endif
59
60
#if HAL_HAVE_SERIAL5
61
// @Group: 5_
62
// @Path: serial_options_dev.cpp
63
AP_SUBGROUPINFO(devs[5], "5_", 6, SerialOptions, SerialOptionsDev),
64
#endif
65
66
#if HAL_HAVE_SERIAL6
67
// @Group: 6_
68
// @Path: serial_options_dev.cpp
69
AP_SUBGROUPINFO(devs[6], "6_", 7, SerialOptions, SerialOptionsDev),
70
#endif
71
72
#if HAL_HAVE_SERIAL7
73
// @Group: 7_
74
// @Path: serial_options_dev.cpp
75
AP_SUBGROUPINFO(devs[7], "7_", 8, SerialOptions, SerialOptionsDev),
76
#endif
77
78
#if HAL_HAVE_SERIAL8
79
// @Group: 8_
80
// @Path: serial_options_dev.cpp
81
AP_SUBGROUPINFO(devs[8], "8_", 9, SerialOptions, SerialOptionsDev),
82
#endif
83
84
#if HAL_HAVE_SERIAL9
85
// @Group: 9_
86
// @Path: serial_options_dev.cpp
87
AP_SUBGROUPINFO(devs[9], "9_", 10, SerialOptions, SerialOptionsDev),
88
#endif
89
90
AP_GROUPEND
91
};
92
93
SerialOptions::SerialOptions(void)
94
{
95
AP_Param::setup_object_defaults(this, var_info);
96
}
97
98
void SerialOptions::init(void)
99
{
100
for (uint8_t i=0; i<ARRAY_SIZE(devs); i++) {
101
auto *uart = hal.serial(i);
102
if (uart != nullptr) {
103
auto &d = devs[i];
104
uart->set_options(d.options);
105
uart->set_flow_control(AP_HAL::UARTDriver::flow_control(d.rtscts.get()));
106
}
107
}
108
}
109
110
#endif // HAL_PERIPH_ENABLE_SERIAL_OPTIONS
111
112