1 2 3 4 5 6 7 8 9 10 11
12 /*!
13 * ======== Led ========
14 * Simple LED manager
15 */
16 @ModuleStartup
17 module Led
18 {
19 const Ptr PORT0 = 0x11;
20 const Ptr PORT1 = 0x21;
21 const Ptr PORT2 = 0x29;
22 const Ptr PORT3 = 0x19;
23 const Ptr PORT4 = 0x1D;
24 const Ptr PORT5 = 0x31;
25 const Ptr PORT6 = 0x35;
26 const Ptr PORT7 = 0x3A;
27 const Ptr PORT8 = 0x3B;
28
29 const Ptr PORTA_L = 0x202;
30 const Ptr PORTA_H = 0x203;
31 const Ptr PORTB_L = 0x222;
32 const Ptr PORTB_H = 0x223;
33 const Ptr PORTC_L = 0x242;
34 const Ptr PORTC_H = 0x243;
35 const Ptr PORTD_L = 0x262;
36 const Ptr PORTD_H = 0x263;
37 const Ptr PORTE_L = 0x282;
38 const Ptr PORTE_H = 0x283;
39 const Ptr PORTF_L = 0x2A2;
40
41 const Ptr PORT0DIR = 0x12;
42 const Ptr PORT1DIR = 0x22;
43 const Ptr PORT2DIR = 0x2A;
44 const Ptr PORT3DIR = 0x1A;
45 const Ptr PORT4DIR = 0x1E;
46 const Ptr PORT5DIR = 0x32;
47 const Ptr PORT6DIR = 0x36;
48 const Ptr PORT7DIR = 0x3C;
49 const Ptr PORT8DIR = 0x3D;
50
51 const Ptr PORTADIR_L = 0x204;
52 const Ptr PORTADIR_H = 0x205;
53 const Ptr PORTBDIR_L = 0x224;
54 const Ptr PORTBDIR_H = 0x225;
55 const Ptr PORTCDIR_L = 0x244;
56 const Ptr PORTCDIR_H = 0x245;
57 const Ptr PORTDDIR_L = 0x264;
58 const Ptr PORTDDIR_H = 0x265;
59 const Ptr PORTEDIR_L = 0x284;
60 const Ptr PORTEDIR_H = 0x285;
61 const Ptr PORTFDIR_L = 0x2A4;
62
63 /*!
64 * ======== PORT ========
65 * Address of 8-bit output port to use
66 */
67 config Ptr PORT = PORT1;
68
69 /*!
70 * ======== DIRCFG ========
71 * Address of GPIO configuration register
72 */
73 config Ptr DIRCFG = PORT1DIR;
74
75 /*!
76 * ======== RED ========
77 * Port mask for a red LED
78 */
79 config Bits8 RED = 0x1;
80
81 /*!
82 * ======== GREEN ========
83 * Port mask for a green LED
84 */
85 config Bits8 GREEN = 0x2;
86
87 /*!
88 * ======== off ========
89 * Turn specified LED off
90 */
91 @DirectCall
92 Void off(Bits8 mask);
93
94 /*!
95 * ======== on ========
96 * Turn specified LED on
97 */
98 @DirectCall
99 Void on(Bits8 mask);
100
101 /*!
102 * ======== toggle ========
103 * Toggle the state of specified LED
104 */
105 @DirectCall
106 Void toggle(Bits8 mask);
107 }