Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sbus_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Alexandre Bustico, Gautier Hattenberger
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef RC_SBUS_COMMON_H
23 #define RC_SBUS_COMMON_H
24 
30 #include "std.h"
31 #include "mcu_periph/uart.h"
32 
39 #define RC_PPM_TICKS_OF_USEC(_v) ((((_v) - 880) * 8) / 5)
40 #define RC_PPM_SIGNED_TICKS_OF_USEC(_v) (((_v) * 8) / 5)
41 #define USEC_OF_RC_PPM_TICKS(_v) ((((_v) * 5) / 8) + 880)
42 
47 #include "generated/radio.h"
48 
58 #define SBUS_BUF_LENGTH 24
59 #define SBUS_NB_CHANNEL 16
60 #define RADIO_CONTROL_NB_CHANNEL SBUS_NB_CHANNEL
61 
65 struct _sbus {
68  bool_t frame_available;
72 };
73 
77 void sbus_common_init(struct _sbus* sbus, struct uart_periph* dev);
78 
82 void sbus_common_decode_event(struct _sbus* sbus, struct uart_periph* dev);
83 
84 
85 #endif /* RC_SBUS_H */
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
SBUS structure.
Definition: sbus_common.h:65
uint8_t status
decoder state machine status
Definition: sbus_common.h:71
struct _sbus sbus
SBUS struct.
Definition: sbus.c:33
UART peripheral.
Definition: uart.h:55
uint16_t ppm[SBUS_NB_CHANNEL]
decoded and converted values
Definition: sbus_common.h:67
uint8_t buffer[SBUS_BUF_LENGTH]
input buffer
Definition: sbus_common.h:69
uint16_t pulses[SBUS_NB_CHANNEL]
decoded values
Definition: sbus_common.h:66
void sbus_common_init(struct _sbus *sbus, struct uart_periph *dev)
Init function.
Definition: sbus_common.c:58
#define SBUS_BUF_LENGTH
Generated code holding the description of a given transmitter.
Definition: sbus_common.h:58
bool_t frame_available
new frame available
Definition: sbus_common.h:68
void sbus_common_decode_event(struct _sbus *sbus, struct uart_periph *dev)
Decoding event function.
Definition: sbus_common.c:114
unsigned char uint8_t
Definition: types.h:14
#define SBUS_NB_CHANNEL
Definition: sbus_common.h:59
uint8_t idx
input index
Definition: sbus_common.h:70