Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
uart.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 The Paparazzi Team
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 
23 #include "mcu_periph/uart.h"
24 
25 #ifdef USE_UART0
26 struct uart_periph uart0;
27 #endif
28 
29 #ifdef USE_UART1
30 struct uart_periph uart1;
31 #endif
32 
33 #ifdef USE_UART2
34 struct uart_periph uart2;
35 #endif
36 
37 #ifdef USE_UART3
38 struct uart_periph uart3;
39 #endif
40 
41 #ifdef USE_UART4
42 struct uart_periph uart4;
43 #endif
44 
45 #ifdef USE_UART5
46 struct uart_periph uart5;
47 #endif
48 
49 #ifdef USE_UART6
50 struct uart_periph uart6;
51 #endif
52 
54  p->rx_insert_idx = 0;
55  p->rx_extract_idx = 0;
56  p->tx_insert_idx = 0;
57  p->tx_extract_idx = 0;
58  p->tx_running = FALSE;
59  p->ore = 0;
60  p->ne_err = 0;
61  p->fe_err = 0;
62 }
63 
65  int16_t space = p->tx_extract_idx - p->tx_insert_idx;
66  if (space <= 0)
67  space += UART_TX_BUFFER_SIZE;
68  return (uint16_t)(space - 1) >= len;
69 }
70 
72  uint8_t ret = p->rx_buf[p->rx_extract_idx];
74  return ret;
75 }
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint8_t uart_getch(struct uart_periph *p)
Definition: uart.c:71
volatile uint16_t ore
overrun error counter
Definition: uart.h:70
volatile uint16_t fe_err
framing error counter
Definition: uart.h:72
uint8_t tx_running
Definition: uart.h:65
volatile uint16_t ne_err
noise error counter
Definition: uart.h:71
uint16_t tx_extract_idx
Definition: uart.h:64
#define FALSE
Definition: imu_chimu.h:141
UART peripheral.
Definition: uart.h:56
#define UART_TX_BUFFER_SIZE
Definition: uart.h:35
void uart_periph_init(struct uart_periph *p)
Definition: uart.c:53
signed short int16_t
Definition: types.h:17
uint16_t rx_insert_idx
Definition: uart.h:59
bool_t uart_check_free_space(struct uart_periph *p, uint8_t len)
Definition: uart.c:64
unsigned char uint8_t
Definition: types.h:14
uint16_t tx_insert_idx
Definition: uart.h:63
uint8_t rx_buf[UART_RX_BUFFER_SIZE]
Receive buffer.
Definition: uart.h:58
static float p[2][2]
uint16_t rx_extract_idx
Definition: uart.h:60
#define UART_RX_BUFFER_SIZE
Definition: uart.h:34