omnitiles/hw/
pins_f767zi.rs

1// SPDX-License-Identifier: MIT
2// © 2025–2026 Christopher Liu
3
4//! Pin definitions for the NUCLEO-F767ZI development board.
5//!
6//! This allows for some amount of firmware testing if only the development board is available.
7
8use stm32f7xx_hal::{
9    gpio::{gpioa, gpiob, gpiod, Alternate, Output, PushPull},
10    pac,
11    prelude::*,
12};
13
14pub struct BoardPins {
15    pub leds: Leds,
16    pub usart3: Usart3Pins,
17    pub spi1: Spi1Pins,
18    pub can1: Can1Pins,
19    pub encoder: EncoderPins,
20}
21
22pub struct Leds {
23    pub green: gpiob::PB0<Output<PushPull>>, // LD1
24    pub blue: gpiob::PB7<Output<PushPull>>,  // LD3
25    pub red: gpiob::PB14<Output<PushPull>>,  // LD2
26}
27
28pub struct Usart3Pins {
29    pub tx: gpiod::PD8<Alternate<7>>,
30    pub rx: gpiod::PD9<Alternate<7>>,
31}
32
33pub struct Spi1Pins {
34    pub sck: gpioa::PA5<Alternate<5>>,
35    pub miso: gpioa::PA6<Alternate<5>>,
36    pub mosi: gpioa::PA7<Alternate<5>>,
37    pub cs: gpioa::PA4<Output<PushPull>>,
38}
39
40pub struct Can1Pins {
41    pub tx: gpioa::PA12<Alternate<9>>,
42    pub rx: gpioa::PA11<Alternate<9>>,
43}
44
45pub struct EncoderPins {
46    pub ch1: gpioa::PA0<Alternate<1>>,
47    pub ch2: gpioa::PA1<Alternate<1>>,
48}
49
50impl BoardPins {
51    pub fn new(
52        gpioa: pac::GPIOA,
53        gpiob: pac::GPIOB,
54        gpiod: pac::GPIOD,
55        _gpioe: pac::GPIOE,
56    ) -> Self {
57        let gpioa = gpioa.split();
58        let gpiob = gpiob.split();
59        let gpiod = gpiod.split();
60
61        Self {
62            leds: Leds {
63                green: gpiob.pb0.into_push_pull_output(),
64                blue: gpiob.pb7.into_push_pull_output(),
65                red: gpiob.pb14.into_push_pull_output(),
66            },
67
68            usart3: Usart3Pins {
69                tx: gpiod.pd8.into_alternate::<7>(),
70                rx: gpiod.pd9.into_alternate::<7>(),
71            },
72
73            spi1: Spi1Pins {
74                sck: gpioa.pa5.into_alternate::<5>(),
75                miso: gpioa.pa6.into_alternate::<5>(),
76                mosi: gpioa.pa7.into_alternate::<5>(),
77                cs: gpioa.pa4.into_push_pull_output(),
78            },
79
80            can1: Can1Pins {
81                tx: gpioa.pa12.into_alternate::<9>(),
82                rx: gpioa.pa11.into_alternate::<9>().internal_pull_up(true),
83            },
84
85            encoder: EncoderPins {
86                ch1: gpioa.pa0.into_alternate::<1>(),
87                ch2: gpioa.pa1.into_alternate::<1>(),
88            },
89        }
90    }
91}