mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-25 23:46:04 +08:00
[setup] one usb_tunnel for both lpc21 and stm32
This commit is contained in:
@@ -27,6 +27,9 @@ AHRS_ALIGNER_LED ?= none
|
||||
GPS_LED ?= none
|
||||
SYS_TIME_LED ?= none
|
||||
|
||||
TUNNEL_RX_LED ?= 1
|
||||
TUNNEL_TX_LED ?= 2
|
||||
|
||||
|
||||
#
|
||||
# default uart settings
|
||||
|
||||
@@ -73,7 +73,16 @@ TUNNEL_BAUD ?= B115200
|
||||
usb_tunnel.CFLAGS += -DUSE_$(TUNNEL_PORT_UPPER) -D$(TUNNEL_PORT_UPPER)_BAUD=$(TUNNEL_BAUD)
|
||||
usb_tunnel.CFLAGS += -DUSB_TUNNEL_UART=$(TUNNEL_PORT_LOWER)
|
||||
usb_tunnel.CFLAGS += -DUSE_USB_LINE_CODING -DUSE_USB_SERIAL
|
||||
usb_tunnel.srcs += $(SRC_ARCH)/usb_tunnel.c $(SRC_ARCH)/usb_ser_hw.c
|
||||
usb_tunnel.srcs += $(SRC_FIRMWARE)/usb_tunnel.c $(SRC_ARCH)/usb_ser_hw.c
|
||||
|
||||
TUNNEL_RX_LED ?= 2
|
||||
TUNNEL_TX_LED ?= 3
|
||||
ifneq ($(TUNNEL_TX_LED),none)
|
||||
usb_tunnel.CFLAGS += -DTUNNEL_TX_LED=$(TUNNEL_TX_LED)
|
||||
endif
|
||||
ifneq ($(TUNNEL_RX_LED),none)
|
||||
usb_tunnel.CFLAGS += -DTUNNEL_RX_LED=$(TUNNEL_RX_LED)
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), lpc21)
|
||||
# for the usb_tunnel we need to set PCLK higher with the flag USE_USB_HIGH_PCLK
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Martin Mueller
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file usb_tunnel.c
|
||||
* \brief USB tunnel application
|
||||
*
|
||||
* This creates a USB serial port that connects to UART0 or UART1
|
||||
* port of the LPC processor. This enables you to configure the gps
|
||||
* receiver or the modem without removing it.
|
||||
*/
|
||||
|
||||
#include "std.h"
|
||||
#include "mcu.h"
|
||||
#include "mcu_periph/sys_time.h"
|
||||
#include "led.h"
|
||||
#include "mcu_periph/uart.h"
|
||||
#include "mcu_periph/usb_serial.h"
|
||||
|
||||
/* minimum LED blink on time 10Hz = 100ms */
|
||||
#define BLINK_MIN 10
|
||||
|
||||
#ifndef USB_TUNNEL_UART
|
||||
#if USE_UART0
|
||||
#define USB_TUNNEL_UART uart0
|
||||
#else
|
||||
#define USB_TUNNEL_UART uart1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
INFO_VAR(USB_TUNNEL_UART)
|
||||
|
||||
int main( void ) {
|
||||
unsigned char inc;
|
||||
unsigned int rx_time=0, tx_time=0;
|
||||
|
||||
mcu_init();
|
||||
sys_time_init();
|
||||
led_init();
|
||||
VCOM_allow_linecoding(1);
|
||||
|
||||
VCOM_init();
|
||||
|
||||
mcu_int_enable();
|
||||
|
||||
#if USE_LED_3
|
||||
LED_ON(3);
|
||||
#endif
|
||||
|
||||
while(1) {
|
||||
|
||||
#if USE_LED_1
|
||||
if (T0TC > (rx_time+((PCLK / T0_PCLK_DIV) / BLINK_MIN))) LED_OFF(1);
|
||||
#endif
|
||||
#if USE_LED_2
|
||||
if (T0TC > (tx_time+((PCLK / T0_PCLK_DIV) / BLINK_MIN))) LED_OFF(2);
|
||||
#endif
|
||||
|
||||
if (uart_char_available(&USB_TUNNEL_UART) && VCOM_check_free_space(1)) {
|
||||
#if USE_LED_1
|
||||
LED_ON(1);
|
||||
#endif
|
||||
rx_time = T0TC;
|
||||
inc = uart_getch(&USB_TUNNEL_UART);
|
||||
VCOM_putchar(inc);
|
||||
}
|
||||
if (VCOM_check_available() && uart_check_free_space(&USB_TUNNEL_UART, 1)) {
|
||||
#if USE_LED_2
|
||||
LED_ON(2);
|
||||
#endif
|
||||
tx_time = T0TC;
|
||||
inc = VCOM_getchar();
|
||||
uart_transmit(&USB_TUNNEL_UART, inc);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Martin Mueller
|
||||
* 2014 Felix Ruess <felix.ruess@gmail.com
|
||||
* 2014 Felix Ruess <felix.ruess@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
@@ -41,23 +41,43 @@
|
||||
#error USB_TUNNEL_UART not defined. Add <configure name="TUNNEL_PORT" value="UARTx"/>
|
||||
#endif
|
||||
|
||||
INFO_VAR(USB_TUNNEL_UART)
|
||||
PRINT_CONFIG_VAR(USB_TUNNEL_UART)
|
||||
|
||||
PRINT_CONFIG_VAR(TUNNEL_RX_LED)
|
||||
PRINT_CONFIG_VAR(TUNNEL_TX_LED)
|
||||
|
||||
static void tunnel_event(void)
|
||||
/** minimum LED blink on time in ms */
|
||||
#define BLINK_MIN 100
|
||||
|
||||
static inline void tunnel_event(void)
|
||||
{
|
||||
static unsigned char inc;
|
||||
unsigned char inc;
|
||||
|
||||
#ifdef TUNNEL_RX_LED
|
||||
static uint32_t rx_time=0;
|
||||
if (get_sys_time_msec() > rx_time + BLINK_MIN) {
|
||||
LED_OFF(TUNNEL_RX_LED);
|
||||
}
|
||||
#endif
|
||||
#ifdef TUNNEL_TX_LED
|
||||
static uint32_t tx_time=0;
|
||||
if (get_sys_time_msec() > tx_time + BLINK_MIN) {
|
||||
LED_OFF(TUNNEL_TX_LED);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (uart_char_available(&USB_TUNNEL_UART) && VCOM_check_free_space(1)) {
|
||||
#if USE_LED_2
|
||||
LED_TOGGLE(2);
|
||||
#ifdef TUNNEL_RX_LED
|
||||
LED_ON(TUNNEL_RX_LED);
|
||||
rx_time = get_sys_time_msec();
|
||||
#endif
|
||||
inc = uart_getch(&USB_TUNNEL_UART);
|
||||
VCOM_putchar(inc);
|
||||
}
|
||||
if (VCOM_check_available() && uart_check_free_space(&USB_TUNNEL_UART, 1)) {
|
||||
#if USE_LED_3
|
||||
LED_TOGGLE(3);
|
||||
#ifdef TUNNEL_TX_LED
|
||||
LED_ON(TUNNEL_TX_LED);
|
||||
tx_time = get_sys_time_msec();
|
||||
#endif
|
||||
inc = VCOM_getchar();
|
||||
uart_transmit(&USB_TUNNEL_UART, inc);
|
||||
Reference in New Issue
Block a user