2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
5 * @addtogroup PIOS_SBus S.Bus Functions
6 * @brief PIOS interface to read and write from Futaba S.Bus port
9 * @file pios_sbus_priv.h
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
11 * @brief Futaba S.Bus Private structures.
12 * @see The GNU Public License (GPL) Version 3
14 *****************************************************************************/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #ifndef PIOS_SBUS_PRIV_H
32 #define PIOS_SBUS_PRIV_H
35 #include <pios_stm32.h>
36 #include <pios_usart_priv.h>
39 * S.Bus serial port settings:
40 * 100000bps inverted serial stream, 8 bits, even parity, 2 stop bits
41 * frame period is 7ms (HS) or 14ms (FS)
44 * 1 byte - 0x0f (start of frame byte)
45 * 22 bytes - channel data (11 bit/channel, 16 channels, LSB first)
47 * 0x01 - discrete channel 1,
48 * 0x02 - discrete channel 2,
49 * 0x04 - lost frame flag,
50 * 0x08 - failsafe flag,
52 * 1 byte - 0x00 (end of frame byte)
54 * The R7008SB receiver has four different end of frame bytes, which rotates in order:
61 #define SBUS_FRAME_LENGTH (1 + 22 + 1 + 1)
62 #define SBUS_SOF_BYTE 0x0f
63 #define SBUS_EOF_BYTE 0x00
64 #define SBUS_FLAG_DC1 0x01
65 #define SBUS_FLAG_DC2 0x02
66 #define SBUS_FLAG_FL 0x04
67 #define SBUS_FLAG_FS 0x08
69 #define SBUS_R7008SB_EOF_COUNTER_MASK 0xCB
72 * S.Bus protocol provides 16 proportional and 2 discrete channels.
73 * Do not change unless driver code is updated accordingly.
75 #if (PIOS_SBUS_NUM_INPUTS != (16 + 2))
76 #error "S.Bus protocol provides 16 proportional and 2 discrete channels"
79 /* Discrete channels represented as bits, provide values for them */
80 #define SBUS_VALUE_MIN 352
81 #define SBUS_VALUE_MAX 1696
84 * S.Bus configuration programmable invertor
86 struct pios_sbus_cfg
{
90 extern const struct pios_rcvr_driver pios_sbus_rcvr_driver
;
92 extern int32_t PIOS_SBus_Init(uint32_t *sbus_id
,
93 const struct pios_sbus_cfg
*cfg
,
94 const struct pios_com_driver
*driver
,
97 #endif /* PIOS_SBUS_PRIV_H */