Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
test_led.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/flash.h>
25 #include <stm32/misc.h>
26 
27 #include BOARD_CONFIG
28 #include "mcu.h"
29 #include "led.h"
30 
31 void Delay(__IO uint32_t nCount);
32 void led_on(int i);
33 void led_off(int i);
34 
35 #ifdef BOARD_LISA_L
36 #define LED_PROGRAM_SIZE 26
37 
38 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 };
39 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 };
40 #endif
41 
42 #ifdef BOARD_LISA_M
43 #define LED_PROGRAM_SIZE 10
44 
45 const int LED_PROG_ON[LED_PROGRAM_SIZE] = { 1, 2, -1, -1, -1, 2, 1, -1, -1, -1 };
46 const int LED_PROG_OFF[LED_PROGRAM_SIZE] = { -1, -1, 1, 2, -1, -1, -1, 2, 1, -1 };
47 #endif
48 
49 void led_on(int i) {
50 #ifdef BOARD_LISA_L
51  LED_ON(i);
52 #endif
53 
54 #ifdef BOARD_LISA_M
55  switch (i) {
56  case 1:
57  LED_ON(1);
58  break;
59  case 2:
60  LED_ON(2);
61  break;
62  default:
63  /* ignore as we only have 2 led's for now on lisa/m */
64  break;
65  }
66 #endif
67 }
68 
69 void led_off(int i) {
70 #ifdef BOARD_LISA_L
71  LED_OFF(i);
72 #endif
73 
74 #ifdef BOARD_LISA_M
75  switch (i) {
76  case 1:
77  LED_OFF(1);
78  break;
79  case 2:
80  LED_OFF(2);
81  break;
82  default:
83  /* ignore as we only have 2 led's for now on lisa/m */
84  break;
85  }
86 #endif
87 }
88 
89 int main(void) {
90  int i = 0;
91  mcu_init();
92  while (1) {
93  for (i=0; i< LED_PROGRAM_SIZE; i++)
94  {
95  if (LED_PROG_ON[i] >= 0)
96  led_on(LED_PROG_ON[i]);
97  LED_PERIODIC();
98  Delay(2000000);
99  if (LED_PROG_OFF[i] >= 0)
100  led_off(LED_PROG_OFF[i]);
101  }
102  };
103  return 0;
104 }
105 
106 void Delay(__IO uint32_t nCount) {
107  for(; nCount != 0; nCount--);
108 }
109 
110 
void led_on(int i)
Definition: test_led.c:49
int main(void)
Definition: test_led.c:89
#define LED_ON(i)
Definition: led_hw.h:28
void Delay(__IO uint32_t nCount)
Definition: test_led.c:106
unsigned long uint32_t
Definition: types.h:18
void led_off(int i)
Definition: test_led.c:69
#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