Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
test_uart_lisam.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Antoine Drouin <poinix@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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 //#include <libopencm3/stm32/f1/rcc.h>
23 //#include <libopencm3/stm32/f1/gpio.h>
24 
25 //#include <libopencm3/stm32/f1/flash.h>
26 
27 //#include <libopencm3/cm3/common.h>
28 
29 #include BOARD_CONFIG
30 #include "mcu.h"
31 #include "mcu_periph/uart.h"
32 #include "mcu_periph/sys_time.h"
33 #include "led.h"
34 
35 static inline void main_init( void );
36 static inline void main_periodic( void );
37 
38 int main(void) {
39 
40  main_init();
41 
42  while (1) {
44  main_periodic();
45  }
46 
47  return 0;
48 }
49 
50 static inline void main_init( void ) {
51  mcu_init();
53 }
54 
55 static inline void main_periodic( void ) {
56  char ch;
57 
58  uart_transmit(&uart1, 'a');
59  uart_transmit(&uart2, 'b');
60  uart_transmit(&uart3, 'c');
61  uart_transmit(&uart5, 'd');
62 
63  LED_OFF(1);
64  LED_OFF(2);
65 
66  if (uart_char_available(&uart1)) {
67  ch = uart_getch(&uart1);
68  if (ch == 'a') {
69  LED_ON(1);
70  } else {
71  LED_ON(2);
72  }
73  }
74 
75  if (uart_char_available(&uart2)) {
76  ch = uart_getch(&uart2);
77  if (ch == 'b') {
78  LED_ON(1);
79  } else {
80  LED_ON(2);
81  }
82  }
83 
84  if (uart_char_available(&uart3)) {
85  ch = uart_getch(&uart3);
86  if (ch == 'c') {
87  LED_ON(1);
88  } else {
89  LED_ON(2);
90  }
91  }
92 
93  if (uart_char_available(&uart5)) {
94  ch = uart_getch(&uart5);
95  if (ch == 'd') {
96  LED_ON(1);
97  } else {
98  LED_ON(2);
99  }
100  }
101 }
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void mcu_init(void)
Microcontroller peripherals initialization.
Definition: mcu.c:61
uint8_t uart_getch(struct uart_periph *p)
Definition: uart.c:71
static void main_init(void)
static void main_periodic(void)
static bool_t uart_char_available(struct uart_periph *p)
Definition: uart.h:83
#define LED_ON(i)
Definition: led_hw.h:28
void uart_transmit(struct uart_periph *p, uint8_t data)
Definition: uart_arch.c:71
Architecture independent timing functions.
int sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:37
static bool_t sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
Definition: sys_time.h:111
Arch independent mcu ( Micro Controller Unit ) utilities.
int main(void)
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
#define LED_OFF(i)
Definition: led_hw.h:29
arch independent LED (Light Emitting Diodes) API