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_lisal.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 BOARD_CONFIG
23 #include "mcu.h"
24 #include "mcu_periph/uart.h"
25 #include "mcu_periph/sys_time.h"
26 #include "led.h"
27 
28 static inline void main_init( void );
29 static inline void main_periodic( void );
30 
31 int main(void) {
32 
33  main_init();
34 
35  while (1) {
37  main_periodic();
38  }
39  return 0;
40 }
41 
42 static inline void main_init( void ) {
43  mcu_init();
45 }
46 
47 static inline void main_periodic( void ) {
48  char ch;
49 
50  uart_transmit(&uart1, 'a');
51  uart_transmit(&uart2, 'b');
52  uart_transmit(&uart3, 'c');
53 
54  if (uart_char_available(&uart1)) {
55  ch = uart_getch(&uart1);
56  if (ch == 'a') {
57  LED_OFF(0);
58  LED_ON(1);
59  } else {
60  LED_ON(0);
61  LED_ON(1);
62  }
63  } else {
64  LED_ON(0);
65  LED_OFF(1);
66  }
67 
68  if (uart_char_available(&uart2)) {
69  ch = uart_getch(&uart2);
70  if (ch == 'b') {
71  LED_OFF(2);
72  LED_ON(3);
73  } else {
74  LED_ON(2);
75  LED_ON(3);
76  }
77  } else {
78  LED_ON(2);
79  LED_OFF(3);
80  }
81 
82  if (uart_char_available(&uart3)) {
83  ch = uart_getch(&uart3);
84  if (ch == 'c') {
85  LED_OFF(4);
86  LED_ON(5);
87  } else {
88  LED_ON(4);
89  LED_ON(5);
90  }
91  } else {
92  LED_ON(4);
93  LED_OFF(5);
94  }
95 
96  LED_PERIODIC();
97 }
98 
99 
100 
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 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
int main(void)
Architecture independent timing functions.
static void main_periodic(void)
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
static void main_init(void)
#define LED_PERIODIC()
Definition: led_hw.h:8
Arch independent mcu ( Micro Controller Unit ) utilities.
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
#define LED_OFF(i)
Definition: led_hw.h:29
arch independent LED (Light Emitting Diodes) API