1#![allow(clippy::upper_case_acronyms, missing_docs)]
11use crate::hal::gpio::{p0, Floating, Input, Output, Pin, PushPull};
12
13pub type PAD0<MODE> = p0::P0_03<MODE>;
15pub type PAD1<MODE> = p0::P0_02<MODE>;
16pub type PAD2<MODE> = p0::P0_01<MODE>;
17
18pub const NUM_COLS: usize = 9;
20pub type COL1 = p0::P0_04<Output<PushPull>>;
21pub type COL2 = p0::P0_05<Output<PushPull>>;
22pub type COL3 = p0::P0_06<Output<PushPull>>;
23pub type COL4 = p0::P0_07<Output<PushPull>>;
24pub type COL5 = p0::P0_08<Output<PushPull>>;
25pub type COL6 = p0::P0_09<Output<PushPull>>;
26pub type COL7 = p0::P0_10<Output<PushPull>>;
27pub type COL8 = p0::P0_11<Output<PushPull>>;
28pub type COL9 = p0::P0_12<Output<PushPull>>;
29
30pub const NUM_ROWS: usize = 3;
31pub type ROW1 = p0::P0_13<Output<PushPull>>;
32pub type ROW2 = p0::P0_14<Output<PushPull>>;
33pub type ROW3 = p0::P0_15<Output<PushPull>>;
34
35pub struct DisplayPins {
44 pub col1: COL1,
45 pub col2: COL2,
46 pub col3: COL3,
47 pub col4: COL4,
48 pub col5: COL5,
49 pub col6: COL6,
50 pub col7: COL7,
51 pub col8: COL8,
52 pub col9: COL9,
53 pub row1: ROW1,
54 pub row2: ROW2,
55 pub row3: ROW3,
56}
57
58type LED = Pin<Output<PushPull>>;
59
60impl DisplayPins {
61 pub fn degrade(self) -> ([LED; NUM_COLS], [LED; NUM_ROWS]) {
62 (
63 [
64 self.col1.degrade(),
65 self.col2.degrade(),
66 self.col3.degrade(),
67 self.col4.degrade(),
68 self.col5.degrade(),
69 self.col6.degrade(),
70 self.col7.degrade(),
71 self.col8.degrade(),
72 self.col9.degrade(),
73 ],
74 [
75 self.row1.degrade(),
76 self.row2.degrade(),
77 self.row3.degrade(),
78 ],
79 )
80 }
81}
82
83#[macro_export]
103macro_rules! display_pins {
104 ( $p0parts:expr ) => {{
105 use microbit::{gpio::DisplayPins, hal::gpio::Level};
106
107 DisplayPins {
108 row1: $p0parts.p0_13.into_push_pull_output(Level::Low),
109 row2: $p0parts.p0_14.into_push_pull_output(Level::Low),
110 row3: $p0parts.p0_15.into_push_pull_output(Level::Low),
111 col1: $p0parts.p0_04.into_push_pull_output(Level::Low),
112 col2: $p0parts.p0_05.into_push_pull_output(Level::Low),
113 col3: $p0parts.p0_06.into_push_pull_output(Level::Low),
114 col4: $p0parts.p0_07.into_push_pull_output(Level::Low),
115 col5: $p0parts.p0_08.into_push_pull_output(Level::Low),
116 col6: $p0parts.p0_09.into_push_pull_output(Level::Low),
117 col7: $p0parts.p0_10.into_push_pull_output(Level::Low),
118 col8: $p0parts.p0_11.into_push_pull_output(Level::Low),
119 col9: $p0parts.p0_12.into_push_pull_output(Level::Low),
120 }
121 }};
122}
123
124pub type BTN_A = p0::P0_17<Input<Floating>>;
126pub type BTN_B = p0::P0_26<Input<Floating>>;
127
128pub type MOSI<MODE> = p0::P0_21<MODE>;
130pub type MISO<MODE> = p0::P0_22<MODE>;
131pub type SCK<MODE> = p0::P0_23<MODE>;
132
133pub type SCL = p0::P0_00<Input<Floating>>;
135pub type SDA = p0::P0_30<Input<Floating>>;
136
137pub type UART_TX = p0::P0_24<Output<PushPull>>;
139pub type UART_RX = p0::P0_25<Input<Floating>>;
140
141pub type EDGE03 = COL1;
143pub type EDGE00<MODE> = PAD0<MODE>; pub type EDGE04 = COL2;
145pub type EDGE05 = BTN_A;
146pub type EDGE06 = COL9;
147pub type EDGE07 = COL8;
148pub type EDGE01<MODE> = PAD1<MODE>; pub type EDGE08<MODE> = p0::P0_18<MODE>;
150pub type EDGE09 = COL7;
151pub type EDGE10 = COL3;
152pub type EDGE11 = BTN_B;
153pub type EDGE12<MODE> = p0::P0_20<MODE>;
154pub type EDGE02<MODE> = PAD2<MODE>; pub type EDGE13<MODE> = SCK<MODE>;
156pub type EDGE14<MODE> = MISO<MODE>;
157pub type EDGE15<MODE> = MOSI<MODE>;
158pub type EDGE16<MODE> = p0::P0_16<MODE>;
159pub type EDGE19 = SCL;
163pub type EDGE20 = SDA;
164