Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
generic_uart.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Freek van Tienen <freek.v.tienen@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, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
29#include "mcu_periph/uart.h"
30
31/* Default end character */
32#ifndef GENERIC_UART_ENDCHAR
33#define GENERIC_UART_ENDCHAR '>'
34#endif
35
36/* Default max sending message */
37#ifndef GENERIC_UART_MAX_SENDLEN
38#define GENERIC_UART_MAX_SENDLEN 64
39#endif
40
41/* Default max buffer size */
42#ifndef GENERIC_UART_MAX_BUFSIZE
43#define GENERIC_UART_MAX_BUFSIZE 128
44#endif
45
46/* Main variables */
47static struct link_device *gen_uart_dev = (&((GENERIC_UART_PORT).device));
48
49/* Event function to read UART message and forward to downlink */
51 // Receive buffer
53 static uint8_t gen_msg_cnt = 0;
54
55 // Look for data on serial port and save it in the buffer
57 gen_msg_buf[gen_msg_cnt++] = gen_uart_dev->get_byte(gen_uart_dev->periph);
58
60 break;
61 }
62
63 // Forward the message to the GCS
66
67 gen_msg_buf[0] = 0;
68 gen_msg_cnt = 0;
69 }
70}
#define GENERIC_UART_MAX_BUFSIZE
#define GENERIC_UART_MAX_SENDLEN
static struct link_device * gen_uart_dev
UART device for communication.
#define GENERIC_UART_ENDCHAR
void generic_uart_event(void)
uint16_t foo
Definition main_demo5.c:58
static int char_available(struct linkdev *d)
Periodic telemetry system header (includes downlink utility and generated code).
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.