Firmware
sbus.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
42 #pragma once
43 
44 #include <stdint.h>
45 #include <stdbool.h>
46 
47 __BEGIN_DECLS
48 
49 #define SBUS_FRAME_SIZE 25
50 #define SBUS_BUFFER_SIZE (SBUS_FRAME_SIZE + SBUS_FRAME_SIZE / 2)
51 
52 typedef uint8_t sbus_frame_t[SBUS_FRAME_SIZE + (SBUS_FRAME_SIZE / 2)];
53 
54 
55 __EXPORT int sbus_init(const char *device, bool singlewire);
56 
74 __EXPORT int sbus_config(int sbus_fd, bool singlewire);
75 __EXPORT bool sbus_input(int sbus_fd, uint16_t *values, uint16_t *num_values, bool *sbus_failsafe,
76  bool *sbus_frame_drop,
77  uint16_t max_channels);
78 __EXPORT bool sbus_parse(uint64_t now, uint8_t *frame, unsigned len, uint16_t *values,
79  uint16_t *num_values, bool *sbus_failsafe, bool *sbus_frame_drop, unsigned *frame_drops, uint16_t max_channels);
80 __EXPORT void sbus1_output(int sbus_fd, uint16_t *values, uint16_t num_values);
81 __EXPORT void sbus2_output(int sbus_fd, uint16_t *values, uint16_t num_values);
82 __EXPORT void sbus1_set_output_rate_hz(uint16_t rate_hz);
83 
87 __EXPORT unsigned sbus_dropped_frames(void);
88 
89 __END_DECLS
__EXPORT unsigned sbus_dropped_frames(void)
The number of incomplete frames we encountered.
Definition: sbus.cpp:128
Namespace encapsulating all device framework classes, functions and data.
Definition: CDev.cpp:47
Definition: I2C.hpp:51
__EXPORT int sbus_config(int sbus_fd, bool singlewire)
Parse serial bytes on the S.BUS bus.
Definition: sbus.cpp:153