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_led.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 "led.h"
25 
26 void Delay(volatile uint32_t nCount);
27 void led_on(int i);
28 void led_off(int i);
29 
30 #ifdef BOARD_LISA_L
31 #define LED_PROGRAM_SIZE 26
32 
33 const int LED_PROG_ON[LED_PROGRAM_SIZE] = { 3, 5, 7, 1, -1, -1, -1, -1, 2, 4, 6, 0, 3, 5, 7, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
34 const int LED_PROG_OFF[LED_PROGRAM_SIZE] = {-1, -1, -1, -1, 3, 5, 7, 1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 5, 7, 1, 2, 4, 6, 0, -1, -1 };
35 #endif
36 
37 #ifdef BOARD_LISA_M
38 #define LED_PROGRAM_SIZE 10
39 
40 const int LED_PROG_ON[LED_PROGRAM_SIZE] = { 1, 2, -1, -1, -1, 2, 1, -1, -1, -1 };
41 const int LED_PROG_OFF[LED_PROGRAM_SIZE] = { -1, -1, 1, 2, -1, -1, -1, 2, 1, -1 };
42 #endif
43 
44 void led_on(int i) {
45 #ifdef BOARD_LISA_L
46  LED_ON(i);
47 #endif
48 
49 #ifdef BOARD_LISA_M
50  switch (i) {
51  case 1:
52  LED_ON(1);
53  break;
54  case 2:
55  LED_ON(2);
56  break;
57  default:
58  /* ignore as we only have 2 led's for now on lisa/m */
59  break;
60  }
61 #endif
62 }
63 
64 void led_off(int i) {
65 #ifdef BOARD_LISA_L
66  LED_OFF(i);
67 #endif
68 
69 #ifdef BOARD_LISA_M
70  switch (i) {
71  case 1:
72  LED_OFF(1);
73  break;
74  case 2:
75  LED_OFF(2);
76  break;
77  default:
78  /* ignore as we only have 2 led's for now on lisa/m */
79  break;
80  }
81 #endif
82 }
83 
84 int main(void) {
85  int i = 0;
86  mcu_init();
87  while (1) {
88  for (i=0; i< LED_PROGRAM_SIZE; i++)
89  {
90  if (LED_PROG_ON[i] >= 0)
91  led_on(LED_PROG_ON[i]);
92  LED_PERIODIC();
93  Delay(2000000);
94  if (LED_PROG_OFF[i] >= 0)
95  led_off(LED_PROG_OFF[i]);
96  }
97  };
98  return 0;
99 }
100 
101 /*
102  * XXX: do we really need volatile here?
103  *
104  * Also we should probably use systime instead as it is being linked into this
105  * test anyways...
106  */
107 void Delay(volatile uint32_t nCount) {
108  for(; nCount != 0; nCount--);
109 }
110 
111 
void mcu_init(void)
Microcontroller peripherals initialization.
Definition: mcu.c:61
void Delay(volatile uint32_t nCount)
Definition: test_led.c:107
void led_on(int i)
Definition: test_led.c:44
int main(void)
Definition: test_led.c:84
#define LED_ON(i)
Definition: led_hw.h:28
unsigned long uint32_t
Definition: types.h:18
void led_off(int i)
Definition: test_led.c:64
#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