Skip to content

Commit

Permalink
update GPIO 2
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Apr 5, 2022
1 parent 884a50b commit 526a030
Show file tree
Hide file tree
Showing 21 changed files with 1,176 additions and 1,101 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* **Breaking**: Use const-generics for `GPIO`, add `DynamicPin`, `ErasedPin`,
inherent impls for `embedded-hal` like methods by-default, default modes [#334]
Remove pulling from `Input` mode. Use `internal_regiter(Pull)` instead,
add universal `into_mode::<MODE>()` pin mode converter,
restrict `into_alternate` variants depending on model (autogenerated from CubeMX + manual fixes),
`AFx` is now alias to `Alternate<x>`
* Replace crate::Never with core::convert::Infallible

* **Breaking**: Use [fugit](https://docs.rs/fugit/0.3.5/fugit/index.html) crate
Expand Down
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ features = ["medium-ethernet", "proto-ipv4", "proto-ipv6", "socket-raw"]
default = ["rt"]
device-selected = []
revision_v = []
rm0433 = [] # aka. "single core" devices
rm0399 = [] # aka. "dual core" devices
rm0455 = [] # aka. "high memory integration" devices
rm0468 = [] # aka. "high speed" devices
rm0433 = ["gpio-h747"] # aka. "single core" devices
rm0399 = ["gpio-h747"] # TODO: fix gpio # aka. "dual core" devices
rm0455 = ["gpio-h7a2"] # aka. "high memory integration" devices
rm0468 = ["gpio-h72"] # aka. "high speed" devices

gpio-h72 = []
gpio-h747 = []
gpio-h7a2 = []

dsi = []
cm4 = []
cm7 = []
Expand Down
8 changes: 4 additions & 4 deletions examples/can-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ fn main() -> ! {
let can1 = {
info!("Init CAN 1");
let gpioh = dp.GPIOH.split(ccdr.peripheral.GPIOH);
let rx = gpioh.ph14.into_alternate().set_speed(Speed::VeryHigh);
let tx = gpioh.ph13.into_alternate().set_speed(Speed::VeryHigh);
let rx = gpioh.ph14.into_alternate().speed(Speed::VeryHigh);
let tx = gpioh.ph13.into_alternate().speed(Speed::VeryHigh);

info!("-- Create CAN 1 instance");
dp.FDCAN1.fdcan(tx, rx, fdcan_prec)
Expand All @@ -81,8 +81,8 @@ fn main() -> ! {
// let can2 = {
// info!("Init CAN 2");
// let gpiob = dp.GPIOB.split(ccdr.peripheral.GPIOB);
// let rx = gpiob.pb5.into_alternate().set_speed(Speed::VeryHigh);
// let tx = gpiob.pb6.into_alternate().set_speed(Speed::VeryHigh);
// let rx = gpiob.pb5.into_alternate().speed(Speed::VeryHigh);
// let tx = gpiob.pb6.into_alternate().speed(Speed::VeryHigh);

// info!("-- Create CAN 2 instance");
// dp.FDCAN2.fdcan(tx, rx, fdcan_prec)
Expand Down
6 changes: 3 additions & 3 deletions examples/exti_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::cell::{Cell, RefCell};
use cortex_m::interrupt::{free, Mutex};
use cortex_m::peripheral::NVIC;
use cortex_m_rt::entry;
use stm32h7xx_hal::gpio::{Edge, ExtiPin, Input, Output, PullUp, PushPull};
use stm32h7xx_hal::gpio::{Edge, ExtiPin, Input, Output, PushPull};
use stm32h7xx_hal::{interrupt, pac, prelude::*};

// LED pin
Expand All @@ -25,9 +25,9 @@ use log::info;
static SEMAPHORE: Mutex<Cell<bool>> = Mutex::new(Cell::new(true));

// Setup the sharing of pins between the main loop and the interrupts
static BUTTON1_PIN: Mutex<RefCell<Option<PE3<Input<PullUp>>>>> =
static BUTTON1_PIN: Mutex<RefCell<Option<PE3<Input>>>> =
Mutex::new(RefCell::new(None));
static BUTTON2_PIN: Mutex<RefCell<Option<PC5<Input<PullUp>>>>> =
static BUTTON2_PIN: Mutex<RefCell<Option<PC5<Input>>>> =
Mutex::new(RefCell::new(None));
static LED: Mutex<RefCell<Option<PA1<Output<PushPull>>>>> =
Mutex::new(RefCell::new(None));
Expand Down
2 changes: 1 addition & 1 deletion examples/fmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro_rules! fmc_pins {
(
$(
$pin.into_push_pull_output()
.set_speed(Speed::VeryHigh)
.speed(Speed::VeryHigh)
.into_alternate::<12>()
.internal_pull_up(true)
),*
Expand Down
2 changes: 1 addition & 1 deletion examples/fractional-pll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() -> ! {

// Enable MCO2 output pin
let gpioc = dp.GPIOC.split(ccdr.peripheral.GPIOC);
let _mco2_pin = gpioc.pc9.into_alternate::<0>().set_speed(Speed::High);
let _mco2_pin = gpioc.pc9.into_alternate::<0>().speed(Speed::High);

info!("");
info!("stm32h7xx-hal example - Fractional PLL");
Expand Down
2 changes: 1 addition & 1 deletion examples/mco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() -> ! {
let gpioc = dp.GPIOC.split(ccdr.peripheral.GPIOC);

let _mco1_pin = gpioa.pa8.into_alternate::<0>();
let _mco2_pin = gpioc.pc9.into_alternate::<0>().set_speed(Speed::High);
let _mco2_pin = gpioc.pc9.into_alternate::<0>().speed(Speed::High);

info!("");
info!("stm32h7xx-hal example - MCO output");
Expand Down
22 changes: 11 additions & 11 deletions examples/octospi_hyperram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,57 +49,57 @@ fn main() -> ! {
let _ncs = gpiog
.pg12
.into_alternate::<3>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _dqs = gpiof
.pf12
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _clk = gpiof
.pf4
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _io0 = gpiof
.pf0
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _io1 = gpiof
.pf1
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _io2 = gpiof
.pf2
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _io3 = gpiof
.pf3
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _io4 = gpiog
.pg0
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _io5 = gpiog
.pg1
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _io6 = gpiog
.pg10
.into_alternate::<3>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);
let _io7 = gpiog
.pg11
.into_alternate::<9>()
.set_speed(High)
.speed(High)
.internal_pull_up(true);

info!("");
Expand Down
12 changes: 6 additions & 6 deletions examples/qspi_flash_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ fn main() -> ! {
let gpiog = dp.GPIOG.split(ccdr.peripheral.GPIOG);

// Even though it is not directly used, CS pin must be acquired and configured
let _qspi_cs = gpiog.pg6.into_alternate::<10>().set_speed(Speed::VeryHigh);
let _qspi_cs = gpiog.pg6.into_alternate::<10>().speed(Speed::VeryHigh);

let sck = gpiof.pf10.into_alternate().set_speed(Speed::VeryHigh);
let io0 = gpiof.pf8.into_alternate().set_speed(Speed::VeryHigh);
let io1 = gpiof.pf9.into_alternate().set_speed(Speed::VeryHigh);
let io2 = gpiof.pf7.into_alternate().set_speed(Speed::VeryHigh);
let io3 = gpiof.pf6.into_alternate().set_speed(Speed::VeryHigh);
let sck = gpiof.pf10.into_alternate().speed(Speed::VeryHigh);
let io0 = gpiof.pf8.into_alternate().speed(Speed::VeryHigh);
let io1 = gpiof.pf9.into_alternate().speed(Speed::VeryHigh);
let io2 = gpiof.pf7.into_alternate().speed(Speed::VeryHigh);
let io3 = gpiof.pf6.into_alternate().speed(Speed::VeryHigh);

let mut led = gpioc.pc7.into_push_pull_output();

Expand Down
4 changes: 2 additions & 2 deletions examples/rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod utilities;
#[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true)]
mod app {
use stm32h7xx_hal::gpio::gpioc::{PC13, PC3};
use stm32h7xx_hal::gpio::{Edge, ExtiPin, Floating, Input};
use stm32h7xx_hal::gpio::{Edge, ExtiPin, Input};
use stm32h7xx_hal::gpio::{Output, PushPull};
use stm32h7xx_hal::prelude::*;

Expand All @@ -19,7 +19,7 @@ mod app {
struct SharedResources {}
#[local]
struct LocalResources {
button: PC13<Input<Floating>>,
button: PC13<Input>,
led: PC3<Output<PushPull>>,
}

Expand Down
12 changes: 6 additions & 6 deletions examples/sdmmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,32 @@ fn main() -> ! {
.pc12
.into_alternate()
.internal_pull_up(false)
.set_speed(Speed::VeryHigh);
.speed(Speed::VeryHigh);
let cmd = gpiod
.pd2
.into_alternate()
.internal_pull_up(true)
.set_speed(Speed::VeryHigh);
.speed(Speed::VeryHigh);
let d0 = gpioc
.pc8
.into_alternate()
.internal_pull_up(true)
.set_speed(Speed::VeryHigh);
.speed(Speed::VeryHigh);
let d1 = gpioc
.pc9
.into_alternate()
.internal_pull_up(true)
.set_speed(Speed::VeryHigh);
.speed(Speed::VeryHigh);
let d2 = gpioc
.pc10
.into_alternate()
.internal_pull_up(true)
.set_speed(Speed::VeryHigh);
.speed(Speed::VeryHigh);
let d3 = gpioc
.pc11
.into_alternate()
.internal_pull_up(true)
.set_speed(Speed::VeryHigh);
.speed(Speed::VeryHigh);

// Create SDMMC
let mut sdmmc: Sdmmc<_, SdCard> = dp.SDMMC1.sdmmc(
Expand Down
6 changes: 3 additions & 3 deletions examples/spi-dma-rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ mod app {
let mosi = gpiob
.pb15
.into_alternate()
.set_speed(hal::gpio::Speed::VeryHigh);
.speed(hal::gpio::Speed::VeryHigh);
let sck = gpiob
.pb10
.into_alternate()
.set_speed(hal::gpio::Speed::VeryHigh);
.speed(hal::gpio::Speed::VeryHigh);
let config = hal::spi::Config::new(hal::spi::MODE_0)
.communication_mode(hal::spi::CommunicationMode::Transmitter);

Expand All @@ -91,7 +91,7 @@ mod app {
let mut cs = gpiob
.pb12
.into_push_pull_output()
.set_speed(hal::gpio::Speed::VeryHigh);
.speed(hal::gpio::Speed::VeryHigh);
cs.set_high();

// Initialize our transmit buffer.
Expand Down
Loading

0 comments on commit 526a030

Please sign in to comment.