Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
test_uart_lisal.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2009 Antoine Drouin <poinix@gmail.com>
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
24 #include <stm32/rcc.h>
25 #include <stm32/gpio.h>
26 
27 #include <stm32/flash.h>
28 #include <stm32/misc.h>
29 
30 #include BOARD_CONFIG
31 #include "mcu.h"
32 #include "mcu_periph/uart.h"
33 #include "mcu_periph/sys_time.h"
34 #include "led.h"
35 
36 static inline void main_init( void );
37 static inline void main_periodic( void );
38 
39 int main(void) {
40 
41  main_init();
42 
43  while (1) {
45  main_periodic();
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  Uart1Transmit('a');
59  Uart2Transmit('b');
60  Uart3Transmit('c');
61 
62  if (Uart1ChAvailable()) {
63  ch = Uart1Getch();
64  if (ch == 'a') {
65  LED_OFF(0);
66  LED_ON(1);
67  } else {
68  LED_ON(0);
69  LED_ON(1);
70  }
71  } else {
72  LED_ON(0);
73  LED_OFF(1);
74  }
75 
76  if (Uart2ChAvailable()) {
77  ch = Uart2Getch();
78  if (ch == 'b') {
79  LED_OFF(2);
80  LED_ON(3);
81  } else {
82  LED_ON(2);
83  LED_ON(3);
84  }
85  } else {
86  LED_ON(2);
87  LED_OFF(3);
88  }
89 
90  if (Uart3ChAvailable()) {
91  ch = Uart3Getch();
92  if (ch == 'c') {
93  LED_OFF(4);
94  LED_ON(5);
95  } else {
96  LED_ON(4);
97  LED_ON(5);
98  }
99  } else {
100  LED_ON(4);
101  LED_OFF(5);
102  }
103 
104  LED_PERIODIC();
105 }
106 
107 
108 
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define LED_ON(i)
Definition: led_hw.h:28
int main(void)
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
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:35
static bool_t sys_time_check_and_ack_timer(tid_t id)
Definition: sys_time.h:90
static void main_init(void)
#define LED_PERIODIC()
Definition: led_hw.h:8
arch independent mcu ( Micro Controller Unit ) utilities
#define LED_OFF(i)
Definition: led_hw.h:29
arch independent LED (Light Emitting Diodes) API
void mcu_init(void)
Definition: mcu.c:57