Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
led_hw.h
Go to the documentation of this file.
1 #ifndef LED_HW_H
2 #define LED_HW_H
3 
4 #include BOARD_CONFIG
5 #include "LPC21xx.h"
6 #include "std.h"
7 
8 #define LED_PERIODIC() {}
9 
10 #define __LED_DIR(i) IO ## i ## DIR
11 #define _LED_DIR(i) __LED_DIR(i)
12 #define __LED_CLR(i) IO ## i ## CLR
13 #define _LED_CLR(i) __LED_CLR(i)
14 #define __LED_SET(i) IO ## i ## SET
15 #define _LED_SET(i) __LED_SET(i)
16 #define __LED_PIN_REG(i) IO ## i ## PIN
17 #define _LED_PIN_REG(i) __LED_PIN_REG(i)
18 
19 #define LED_DIR(i) _LED_DIR(LED_ ## i ## _BANK)
20 #define LED_CLR(i) _LED_CLR(LED_ ## i ## _BANK)
21 #define LED_SET(i) _LED_SET(LED_ ## i ## _BANK)
22 #define LED_PIN_REG(i) _LED_PIN_REG(LED_ ## i ## _BANK)
23 #define LED_PIN(i) LED_ ## i ## _PIN
24 
25 /* set pin as output */
26 #define LED_INIT(i) LED_DIR(i) |= _BV(LED_PIN(i))
27 
28 #define LED_ON(i) LED_CLR(i) = _BV(LED_PIN(i));
29 #define LED_OFF(i) LED_SET(i) = _BV(LED_PIN(i));
30 #define LED_TOGGLE(i) { \
31  if (LED_PIN_REG(i) & _BV(LED_PIN(i))) \
32  LED_ON(i) \
33  else \
34  LED_OFF(i) \
35  }
36 
37 #endif /* LED_HW_H */