update credits
[librepilot.git] / flight / pios / inc / pios_srxl_priv.h
blobb6dc4763c24b65758a855af9c8069aa1e7067a71
1 /**
2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
4 * @{
5 * @addtogroup PIOS_SRXL Multiplex SRXL receiver functions
6 * @brief Code to read Multiplex SRXL receiver serial stream
7 * @{
9 * @file pios_srxl_priv.h
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
11 * @brief Code to read Multiplex SRXL receiver serial stream
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
24 * for more details.
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_SRXL_PRIV_H
32 #define PIOS_SRXL_PRIV_H
34 #include <pios.h>
35 #include <pios_stm32.h>
36 #include <pios_usart_priv.h>
39 * Multiplex SRXL serial port settings:
40 * 115200bps inverted serial stream, 8 bits, no parity, 1 stop bits
41 * frame period is 14ms (FastResponse ON) or 21ms (FastResponse OFF)
43 * Frame structure:
44 * 1 byte - start and version
45 * 0xa1 (v1 12-channels)
46 * 0xa2 (v2 16-channels)
47 * 24/32 bytes - channel data (4 + 12 bit/channel, 12/16 channels, MSB first)
48 * 16 bits per channel. 4 first reserved/not used. 12 bits channel data in
49 * 4095 steps, 0x000(800µs) - 0x800(1500µs) - 0xfff(2200µs)
50 * 2 bytes checksum (calculated over all bytes including start and version)
52 * Checksum calculation:
53 * u16 CRC16(u16 crc, u8 value) {
54 * u8 i;
55 * crc = crc ^ (s16)value << 8;
56 * for(i = 0; i < 8; i++) {
57 * if(crc & 0x8000) {
58 * crc = crc << 1 ^ 0x1021;
59 * } else {
60 * crc = crc << 1;
61 * }
62 * }
63 * return crc;
64 * }
67 #define SRXL_V1_HEADER 0xa1
68 #define SRXL_V2_HEADER 0xa2
70 #define SRXL_HEADER_LENGTH 1
71 #define SRXL_CHECKSUM_LENGTH 2
72 #define SRXL_V1_CHANNEL_DATA_BYTES (12 * 2)
73 #define SRXL_V2_CHANNEL_DATA_BYTES (16 * 2)
74 #define SRXL_FRAME_LENGTH (SRXL_HEADER_LENGTH + SRXL_V2_CHANNEL_DATA_BYTES + SRXL_CHECKSUM_LENGTH)
77 * Multiplex SRXL protocol provides 16 proportional channels.
78 * Do not change unless driver code is updated accordingly.
80 #if (PIOS_SRXL_NUM_INPUTS != 16)
81 #error "Multiplex SRXL protocol provides 16 proportional channels."
82 #endif
84 extern const struct pios_rcvr_driver pios_srxl_rcvr_driver;
86 extern int32_t PIOS_SRXL_Init(uint32_t *srxl_id,
87 const struct pios_com_driver *driver,
88 uint32_t lower_id);
90 #endif /* PIOS_SRXL_PRIV_H */
92 /**
93 * @}
94 * @}