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
usb_tunnel.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009 Martin Mueller
3 * 2014 Felix Ruess <felix.ruess@gmail.com>
4 *
5 * This file is part of paparazzi.
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, write to
19 * the Free Software Foundation, 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 *
22 */
23
33#include "std.h"
34#include "mcu.h"
35#include "mcu_periph/sys_time.h"
36#include "led.h"
37#include "mcu_periph/uart.h"
39
40#ifndef USB_TUNNEL_UART
41#error USB_TUNNEL_UART not defined. Add <configure name="TUNNEL_PORT" value="UARTx"/>
42#endif
43
45
48
49
50#define BLINK_MIN 100
51
52static inline void tunnel_event(void)
53{
54 unsigned char inc;
55
56#if LED_AVAILABLE(TUNNEL_RX_LED)
57 static uint32_t rx_time = 0;
60 }
61#endif
62#if LED_AVAILABLE(TUNNEL_TX_LED)
63 static uint32_t tx_time = 0;
66 }
67#endif
68
70#if LED_AVAILABLE(TUNNEL_RX_LED)
73#endif
76 }
77 long fd = 0;
79#if LED_AVAILABLE(TUNNEL_TX_LED)
82#endif
83 inc = VCOM_getchar();
85 }
86}
87
88int main(void)
89{
90 mcu_init();
92 led_init();
93
95
96 VCOM_init();
97
98
99 while (1) {
100 VCOM_event();
101 tunnel_event();
102 }
103
104 return 0;
105}
#define LED_ON(i)
Definition led_hw.h:51
#define LED_OFF(i)
Definition led_hw.h:52
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
void mcu_init(void)
Microcontroller peripherals initialization.
Definition mcu.c:101
arch independent LED (Light Emitting Diodes) API
static void led_init(void)
Automatic initialization of actived LED Set to OFF at startup.
Definition led.h:39
void uart_put_byte(struct uart_periph *periph, long fd, uint8_t data)
Definition uart_arch.c:306
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
Definition uart_arch.c:357
uint8_t uart_getch(struct uart_periph *p)
Definition uart_arch.c:348
uint16_t foo
Definition main_demo5.c:58
Arch independent mcu ( Micro Controller Unit ) utilities.
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
int fd
Definition serial.c:26
void VCOM_event(void)
Poll usb (required by libopencm3).
Definition usb_ser_hw.c:468
int VCOM_getchar(void)
Reads one character from VCOM port.
Definition usb_ser_hw.c:425
int VCOM_putchar(int c)
Writes one character to VCOM port fifo.
Definition usb_ser_hw.c:397
int VCOM_check_available(void)
Checks if data available in VCOM buffer.
Definition usb_ser_hw.c:459
void VCOM_init(void)
Definition usb_ser_hw.c:565
bool VCOM_check_free_space(uint16_t len)
Checks if buffer free in VCOM buffer.
Definition usb_ser_hw.c:450
void sys_time_init(void)
Definition sys_time.c:119
Architecture independent timing functions.
int WEAK uart_check_free_space(struct uart_periph *p, long *fd, uint16_t len)
Definition uart.c:151
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
arch independent USB API
void VCOM_allow_linecoding(uint8_t mode)
static void tunnel_event(void)
Definition usb_tunnel.c:52
int main(void)
Definition usb_tunnel.c:88
#define BLINK_MIN
minimum LED blink on time in ms
Definition usb_tunnel.c:50
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.