omnitiles/hw/
pins_f767zi.rs1use stm32f7xx_hal::{
7 gpio::{
8 gpioa, gpiob, gpioc, gpiod, Alternate, Analog, Floating, Input, OpenDrain, Output, PushPull,
9 },
10 pac,
11 prelude::*,
12};
13
14pub struct BoardPins {
15 pub leds: Leds,
16 pub usart3: Usart3Pins,
17 pub spi1: Spi1Pins,
18 pub m1: Motor1Pins,
19 pub m2: Motor2Pins,
20 pub i2c1: I2c1Pins,
21}
22
23pub struct Leds {
24 pub green: gpiob::PB0<Output<PushPull>>, pub blue: gpiob::PB7<Output<PushPull>>, pub red: gpiob::PB14<Output<PushPull>>, }
28
29pub struct Usart3Pins {
30 pub tx: gpiod::PD8<Alternate<7>>,
31 pub rx: gpiod::PD9<Alternate<7>>,
32}
33
34pub struct Spi1Pins {
35 pub sck: gpioa::PA5<Alternate<5>>,
36 pub miso: gpioa::PA6<Alternate<5>>,
37 pub mosi: gpioa::PA7<Alternate<5>>,
38 pub cs: gpioc::PC3<Output<PushPull>>,
39 pub drdy: gpioa::PA3<Input<Floating>>,
40}
41
42pub struct Motor1Pins {
43 pub in1: gpioc::PC6<Alternate<2>>, pub in2: gpioc::PC7<Alternate<2>>, pub cs: gpiod::PD0<Output<PushPull>>,
46 pub nsleep: gpiod::PD1<Output<PushPull>>,
47 pub disable: gpiod::PD2<Output<PushPull>>,
48 pub adc: gpiob::PB1<Analog>,
49}
50
51pub struct I2c1Pins {
52 pub scl: gpiob::PB8<Alternate<4, OpenDrain>>,
53 pub sda: gpiob::PB9<Alternate<4, OpenDrain>>,
54}
55
56pub struct Motor2Pins {
57 pub in1: gpioc::PC8<Alternate<2>>, pub in2: gpioc::PC9<Alternate<2>>, pub cs: gpiod::PD3<Output<PushPull>>,
60 pub nsleep: gpiod::PD4<Output<PushPull>>,
61 pub disable: gpiod::PD5<Output<PushPull>>,
62 pub adc: gpioc::PC2<Analog>,
63}
64
65impl BoardPins {
66 pub fn new(gpioa: pac::GPIOA, gpiob: pac::GPIOB, gpioc: pac::GPIOC, gpiod: pac::GPIOD) -> Self {
67 let gpioa = gpioa.split();
68 let gpiob = gpiob.split();
69 let gpioc = gpioc.split();
70 let gpiod = gpiod.split();
71
72 Self {
73 leds: Leds {
74 green: gpiob.pb0.into_push_pull_output(),
75 blue: gpiob.pb7.into_push_pull_output(),
76 red: gpiob.pb14.into_push_pull_output(),
77 },
78
79 usart3: Usart3Pins {
80 tx: gpiod.pd8.into_alternate::<7>(),
81 rx: gpiod.pd9.into_alternate::<7>(),
82 },
83
84 spi1: Spi1Pins {
85 sck: gpioa.pa5.into_alternate::<5>(),
86 miso: gpioa.pa6.into_alternate::<5>(),
87 mosi: gpioa.pa7.into_alternate::<5>(),
88 cs: gpioc.pc3.into_push_pull_output(),
89 drdy: gpioa.pa3.into_floating_input(),
90 },
91
92 m1: Motor1Pins {
93 in1: gpioc.pc6.into_alternate::<2>(),
94 in2: gpioc.pc7.into_alternate::<2>(),
95 cs: gpiod.pd0.into_push_pull_output(),
96 nsleep: gpiod.pd1.into_push_pull_output(),
97 disable: gpiod.pd2.into_push_pull_output(),
98 adc: gpiob.pb1.into_analog(),
99 },
100
101 m2: Motor2Pins {
102 in1: gpioc.pc8.into_alternate::<2>(),
103 in2: gpioc.pc9.into_alternate::<2>(),
104 cs: gpiod.pd3.into_push_pull_output(),
105 nsleep: gpiod.pd4.into_push_pull_output(),
106 disable: gpiod.pd5.into_push_pull_output(),
107 adc: gpioc.pc2.into_analog(),
108 },
109
110 i2c1: I2c1Pins {
111 scl: gpiob.pb8.into_alternate_open_drain::<4>(),
112 sda: gpiob.pb9.into_alternate_open_drain::<4>(),
113 },
114 }
115 }
116}