omnitiles/hw/
pins_devboard.rs1use stm32f7xx_hal::{
7 gpio::{gpioa, gpiod, gpioe, Alternate, Output, PushPull},
8 pac,
9 prelude::*,
10};
11
12pub struct BoardPins {
18 pub leds: LedPins,
19 pub usart1: Usart1Pins,
20 pub spi4: Spi4Pins,
21 pub can1: Can1Pins,
22}
23
24pub struct LedPins {
25 pub red: gpiod::PD8<Output<PushPull>>,
26 pub yellow: gpiod::PD9<Output<PushPull>>,
27 pub green: gpiod::PD10<Output<PushPull>>,
28}
29
30pub struct Usart1Pins {
32 pub tx: gpioa::PA9<Alternate<7>>,
33 pub rx: gpioa::PA10<Alternate<7>>,
34}
35
36pub struct Spi4Pins {
38 pub sck: gpioe::PE12<Alternate<5>>,
39 pub miso: gpioe::PE13<Alternate<5>>,
40 pub mosi: gpioe::PE14<Alternate<5>>,
41 pub cs1: gpioe::PE4<Output<PushPull>>,
42 pub cs2: gpioe::PE11<Output<PushPull>>,
43}
44
45pub struct Can1Pins {
47 pub tx: gpioa::PA12<Alternate<9>>,
48 pub rx: gpioa::PA11<Alternate<9>>,
49}
50
51impl BoardPins {
52 pub fn new(gpioa: pac::GPIOA, gpiod: pac::GPIOD, gpioe: pac::GPIOE) -> Self {
54 let gpioa = gpioa.split();
55 let gpiod = gpiod.split();
56 let gpioe = gpioe.split();
57
58 Self {
59 leds: LedPins {
60 red: gpiod.pd8.into_push_pull_output(),
61 yellow: gpiod.pd9.into_push_pull_output(),
62 green: gpiod.pd10.into_push_pull_output(),
63 },
64
65 usart1: Usart1Pins {
66 tx: gpioa.pa9.into_alternate::<7>(),
67 rx: gpioa.pa10.into_alternate::<7>(),
68 },
69
70 spi4: Spi4Pins {
71 sck: gpioe.pe12.into_alternate::<5>(),
72 miso: gpioe.pe13.into_alternate::<5>(),
73 mosi: gpioe.pe14.into_alternate::<5>(),
74 cs1: gpioe.pe4.into_push_pull_output(),
75 cs2: gpioe.pe11.into_push_pull_output(),
76 },
77
78 can1: Can1Pins {
79 tx: gpioa.pa12.into_alternate::<9>(),
80 rx: gpioa.pa11.into_alternate::<9>().internal_pull_up(true),
81 },
82 }
83 }
84}