Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
uart.h
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
28#ifndef MCU_PERIPH_UART_H
29#define MCU_PERIPH_UART_H
30
31#include "mcu_periph/uart_arch.h"
32#include "pprzlink/pprzlink_device.h"
33#include "std.h"
34
35#ifndef UART_RX_BUFFER_SIZE
36// Only for the STM32F1 less buffer
37#if defined(STM32F1)
38#define UART_RX_BUFFER_SIZE 128
39#else
40#define UART_RX_BUFFER_SIZE 256
41#endif
42#endif
43
44#ifndef UART_TX_BUFFER_SIZE
45// Only for the STM32F1 less buffer
46#if defined(STM32F1)
47#define UART_TX_BUFFER_SIZE 128
48#else
49#define UART_TX_BUFFER_SIZE 256
50#endif
51#endif
52
53#define UART_DEV_NAME_SIZE 16
54
55/*
56 * UART Baud rate defines in arch/x/mcu_periph/uart_arch.h
57 */
58
59#define UBITS_7 7
60#define UBITS_8 8
61
62#define USTOP_1 1
63#define USTOP_2 2
64
65#define UPARITY_NO 0
66#define UPARITY_ODD 1
67#define UPARITY_EVEN 2
68
96
97
98extern void uart_periph_init(struct uart_periph *p);
101extern void uart_periph_set_mode(struct uart_periph *p, bool tx_enabled, bool rx_enabled, bool hw_flow_control);
102extern void uart_periph_invert_data_logic(struct uart_periph *p, bool invert_rx, bool invert_tx);
103extern void uart_put_byte(struct uart_periph *p, long fd, uint8_t data);
104extern void uart_put_buffer(struct uart_periph *p, long fd, const uint8_t *data, uint16_t len);
105extern int uart_check_free_space(struct uart_periph *p, long *fd, uint16_t len);
106extern void uart_send_message(struct uart_periph *p, long fd);
107extern uint8_t uart_getch(struct uart_periph *p);
108
113extern int uart_char_available(struct uart_periph *p);
114
115
116extern void uart_arch_init(void);
117
118#if USE_UART0
119extern struct uart_periph uart0;
120extern void uart0_init(void);
121#endif // USE_UART0
122
123#if USE_UART1
124extern struct uart_periph uart1;
125extern void uart1_init(void);
126#endif // USE_UART1
127
128#if USE_UART2
129extern struct uart_periph uart2;
130extern void uart2_init(void);
131#endif // USE_UART2
132
133#if USE_UART3
134extern struct uart_periph uart3;
135extern void uart3_init(void);
136#endif // USE_UART3
137
138#if USE_UART4
139extern struct uart_periph uart4;
140extern void uart4_init(void);
141#endif // USE_UART4
142
143#if USE_UART5
144extern struct uart_periph uart5;
145extern void uart5_init(void);
146#endif // USE_UART5
147
148#if USE_UART6
149extern struct uart_periph uart6;
150extern void uart6_init(void);
151#endif // USE_UART6
152
153#if USE_UART7
154extern struct uart_periph uart7;
155extern void uart7_init(void);
156#endif // USE_UART7
157
158#if USE_UART8
159extern struct uart_periph uart8;
160extern void uart8_init(void);
161#endif // USE_UART8
162
163#endif /* MCU_PERIPH_UART_H */
static float p[2][2]
uint16_t foo
Definition main_demo5.c:58
int fd
Definition serial.c:26
#define UART_TX_BUFFER_SIZE
Definition uart.h:49
uint16_t rx_insert_idx
Definition uart.h:75
void uart_send_message(struct uart_periph *p, long fd)
Definition uart.c:170
void uart_periph_set_bits_stop_parity(struct uart_periph *p, uint8_t bits, uint8_t stop, uint8_t parity)
Definition uart_arch.c:296
void * init_struct
User init struct.
Definition uart.h:87
uint16_t tx_extract_idx
Definition uart.h:80
#define UART_DEV_NAME_SIZE
Definition uart.h:53
void uart_periph_set_mode(struct uart_periph *p, bool tx_enabled, bool rx_enabled, bool hw_flow_control)
Definition uart_arch.c:92
void uart_periph_set_baudrate(struct uart_periph *p, uint32_t baud)
Definition uart_arch.c:280
void uart_periph_init(struct uart_periph *p)
Definition uart.c:126
void uart_put_byte(struct uart_periph *p, long fd, uint8_t data)
Definition uart_arch.c:306
void uart_periph_invert_data_logic(struct uart_periph *p, bool invert_rx, bool invert_tx)
Definition uart.c:194
volatile uint8_t tx_running
Definition uart.h:81
#define UART_RX_BUFFER_SIZE
Definition uart.h:40
char dev[UART_DEV_NAME_SIZE]
UART Dev (linux)
Definition uart.h:89
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
Definition uart_arch.c:357
void uart_arch_init(void)
Definition uart_arch.c:54
int uart_check_free_space(struct uart_periph *p, long *fd, uint16_t len)
Definition uart.c:151
struct link_device device
Generic device interface.
Definition uart.h:94
uint16_t rx_extract_idx
Definition uart.h:76
uint8_t tx_buf[UART_TX_BUFFER_SIZE]
Transmit buffer.
Definition uart.h:78
volatile uint16_t ne_err
noise error counter
Definition uart.h:91
uint8_t rx_buf[UART_RX_BUFFER_SIZE]
Receive buffer.
Definition uart.h:74
void uart_put_buffer(struct uart_periph *p, long fd, const uint8_t *data, uint16_t len)
Definition uart.c:161
volatile uint16_t fe_err
framing error counter
Definition uart.h:92
uint8_t uart_getch(struct uart_periph *p)
Definition uart_arch.c:348
int baudrate
UART Baudrate.
Definition uart.h:85
uint16_t tx_insert_idx
Definition uart.h:79
void * reg_addr
UART Register.
Definition uart.h:83
volatile uint16_t ore
overrun error counter
Definition uart.h:90
UART peripheral.
Definition uart.h:72
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.