Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
uart_tunnel.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#include BOARD_CONFIG
23#include "mcu.h"
24#include "mcu_periph/sys_time.h"
25#include "mcu_periph/gpio.h"
26#include "led.h"
27
28/* UART1 */
29#define A_PORT GPIOA
30#define A_RX_PIN GPIO10
31#define A_RX_PORT A_PORT
32#define A_TX_PIN GPIO9
33#define A_TX_PORT A_PORT
34
35/* UART2 */
36#define B_PORT GPIOA
37#define B_RX_PIN GPIO3
38#define B_RX_PORT B_PORT
39#define B_TX_PIN GPIO2
40#define B_TX_PORT B_PORT
41
42static inline void main_periodic(void);
43static inline void main_event(void);
44void Delay(volatile uint32_t nCount);
45
46void Delay(volatile uint32_t nCount)
47{
48 for (; nCount != 0; nCount--);
49}
50
51int main(void)
52{
53
54 mcu_init();
56
57 /* Init GPIO for rx pins */
60
61 /* Init GPIO for tx pins */
64
66
67 /* */
68 while (1) {
71 }
72 main_event();
73 }
74
75 return 0;
76}
77
78
79
80static inline void main_periodic(void)
81{
83}
84
85static inline void main_event(void)
86{
87 // Delay(2000);
88 static uint8_t foo = 0;
89 foo++;
90
91#if 0
92 if (!(foo % 2)) {
94 } else {
96 }
97#endif
98
99#if 0
100 if (!(foo % 2)) {
102 } else {
104 }
105#endif
106
107#if 1
108 /* passthrough B_RX to A_TX */
109 if (GPIO_IDR(B_RX_PORT) & B_RX_PIN) {
111 } else {
113 }
114#endif
115 /* passthrough A_RX to B_TX */
118 LED_ON(2);
119 } else {
121 LED_OFF(2);
122 }
123
124
125}
#define LED_ON(i)
Definition led_hw.h:51
#define LED_OFF(i)
Definition led_hw.h:52
#define LED_PERIODIC()
Definition led_hw.h:55
void gpio_setup_input_pullup(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs with pull up resistor enabled.
Definition gpio_arch.c:47
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition gpio_arch.c:33
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
Definition gpio_arch.h:104
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
Definition gpio_arch.h:114
static uint8_t gpio_get(ioportid_t port, uint16_t pin)
Get level of a gpio.
Definition gpio_arch.h:94
Some architecture independent helper functions for GPIOs.
void mcu_init(void)
Microcontroller peripherals initialization.
Definition mcu.c:98
arch independent LED (Light Emitting Diodes) API
uint16_t foo
Definition main_demo5.c:58
Arch independent mcu ( Micro Controller Unit ) utilities.
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition sys_time.c:43
Architecture independent timing functions.
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
Definition sys_time.h:123
#define A_TX_PIN
Definition uart_tunnel.c:32
#define A_TX_PORT
Definition uart_tunnel.c:33
static void main_event(void)
Definition uart_tunnel.c:85
static void main_periodic(void)
Definition uart_tunnel.c:80
#define B_TX_PIN
Definition uart_tunnel.c:39
#define A_RX_PIN
Definition uart_tunnel.c:30
#define B_RX_PORT
Definition uart_tunnel.c:38
int main(void)
Definition uart_tunnel.c:51
#define A_RX_PORT
Definition uart_tunnel.c:31
#define B_RX_PIN
Definition uart_tunnel.c:37
#define B_TX_PORT
Definition uart_tunnel.c:40
void Delay(volatile uint32_t nCount)
Definition uart_tunnel.c:46
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.