1
2use lpc43xx::peripheral::gpio_port;
3
4#[derive(Copy, Clone, PartialEq)]
5pub struct GPIO {
6 port: usize,
7 pin: usize,
8}
9
10impl GPIO {
11 pub fn set(&self) {
12 gpio_port().set[self.port].write_word(1 << self.pin);
13 }
14
15 pub fn clear(&self) {
16 gpio_port().clr[self.port].write_word(1 << self.pin);
17 }
18
19 pub fn toggle(&self) {
20 gpio_port().not[self.port].write_word(1 << self.pin);
21 }
22
23 pub fn write(&self, value: u32) {
24 gpio_port().w[self.port * 32 + self.pin].write_word(value);
25 }
26}
27
28pub const LED_USB: GPIO = GPIO { port: 2, pin: 1 };
29pub const LED_RX: GPIO = GPIO { port: 2, pin: 2 };
30pub const LED_TX: GPIO = GPIO { port: 2, pin: 8 };
31
32pub const P2_0: GPIO = GPIO { port: 5, pin: 0 };
34pub const P2_1: GPIO = GPIO { port: 5, pin: 1 };
35pub const P2_3: GPIO = GPIO { port: 5, pin: 3 };
36pub const P2_8: GPIO = GPIO { port: 5, pin: 7 };
37pub const P2_4: GPIO = GPIO { port: 5, pin: 4 };
38pub const P2_9: GPIO = GPIO { port: 1, pin: 10 };
39pub const P2_13: GPIO = GPIO { port: 1, pin: 13 };
40
41pub const P1_8: GPIO = GPIO { port: 1, pin: 1 };
42pub const P1_5: GPIO = GPIO { port: 1, pin: 8 };
43pub const P6_1: GPIO = GPIO { port: 3, pin: 0 };
44pub const P6_2: GPIO = GPIO { port: 3, pin: 1 };