]> rtime.felk.cvut.cz Git - sysless.git/blob - board/arm/lpc2364_addat/libs/deb_led_board.h
lpc21xx: Add bits of PCON register
[sysless.git] / board / arm / lpc2364_addat / libs / deb_led_board.h
1 #ifndef DEB_LED_BOARD_H
2 #define DEB_LED_BOARD_H
3
4 #include <lpc2xxx.h>
5
6 #define __LED_SHIFT 25
7 #define __LED_MASK 0x0f
8
9 #define LEDG (1<<0)             // LED R (1<<25)
10 #define LEDR (1<<1)             // LED G (1<<26)
11 #define LEDY (1<<2)             // LED B (1<<27)
12 #define LEDB (1<<3)             // LED Y (1<<28)
13
14 #define DEB_LED_ERROR LEDR      /* Error occured */
15 #define DEB_LED_RUN   LEDG      /* Should blink when running */
16
17 static inline unsigned
18 __deb_led_get()
19 {
20         return (FIO1PIN >> __LED_SHIFT) & __LED_MASK;
21 }
22
23 static inline void
24 __deb_led_on(unsigned leds)
25 {
26         FIO1CLR = (leds & __LED_MASK) << __LED_SHIFT;
27 }
28
29 static inline void
30 __deb_led_off(unsigned leds)
31 {
32         FIO1SET = (leds & __LED_MASK) << __LED_SHIFT;
33 }
34
35 static inline void
36 __deb_led_set(unsigned leds)
37 {
38         __deb_led_on(~leds);
39         __deb_led_off(leds);
40 }
41
42 static inline void
43 __deb_led_change(unsigned leds)
44 {
45         __deb_led_set(__deb_led_get() ^ leds);
46 }
47
48 static inline void
49 __deb_led_init()
50 {
51         FIO1DIR |= (__LED_MASK << __LED_SHIFT);
52         __deb_led_set(0xF);
53 }
54
55 #endif