Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
uart_arch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Antoine Drouin <poinix@gmail.com>
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 
26 #ifndef UART_ARCH_H
27 #define UART_ARCH_H
28 
29 // higher default uart buffer sizes on linux
30 #ifndef UART_RX_BUFFER_SIZE
31 #define UART_RX_BUFFER_SIZE 512
32 #endif
33 #ifndef UART_TX_BUFFER_SIZE
34 #define UART_TX_BUFFER_SIZE 512
35 #endif
36 
37 #include "mcu_periph/uart.h"
38 
39 // for definition of baud rates
40 #if !USE_ARBITRARY_BAUDRATE
41 #include <termios.h>
42 #else
43 #include <linux/termios.h>
44 #endif
45 
46 // strange speed for SBUS
47 #ifndef B100000
48 #define B100000 100000
49 #endif
50 
51 // for conversion between linux baud rate definition and actual speed
52 static inline int uart_speed(int def)
53 {
54  switch (def) {
55  case B1200: return 1200;
56  case B2400: return 2400;
57  case B4800: return 4800;
58  case B9600: return 9600;
59  case B19200: return 19200;
60  case B38400: return 38400;
61  case B57600: return 57600;
62  case B100000: return 100000;
63  case B115200: return 115200;
64  case B230400: return 230400;
65 #ifdef B921600
66  case B921600: return 921600;
67 #endif
68  default: return 9600;
69  }
70 }
71 #define UART_SPEED(_def) uart_speed(_def)
72 
73 #endif /* UART_ARCH_H */
#define B38400
Definition: uart_arch.h:45
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define B115200
Definition: uart_arch.h:48
static int uart_speed(int def)
Definition: uart_arch.h:52
#define B100000
Definition: uart_arch.h:48
#define B230400
Definition: uart_arch.h:49
#define B921600
Definition: uart_arch.h:50
#define B19200
Definition: uart_arch.h:44
#define B4800
Definition: uart_arch.h:42
#define B2400
Definition: uart_arch.h:41
#define B9600
Definition: uart_arch.h:43
#define B1200
Definition: uart_arch.h:40
#define B57600
Definition: uart_arch.h:46