Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare LPSPI driver for embedded-hal 1.0 rework #149

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Prev Previous commit
More cs pin fixes
  • Loading branch information
Finomnis committed Feb 24, 2024
commit 90322f75a07ac8c5cfe816b9238cfbd9c174d126
5 changes: 2 additions & 3 deletions board/src/imxrt1010evk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl Specifics {
let gpio2 = unsafe { ral::gpio::GPIO2::instance() };
let mut gpio2 = hal::gpio::Port::new(gpio2);

let led = gpio1.output(iomuxc.gpio.p11);
let led = gpio1.output(iomuxc.gpio.p11, false);
let button = gpio2.input(iomuxc.gpio_sd.p05);

let lpuart1 = unsafe { ral::lpuart::LPUART1::instance() };
Expand All @@ -191,13 +191,12 @@ impl Specifics {
sdo: iomuxc.gpio_ad.p04,
sdi: iomuxc.gpio_ad.p03,
sck: iomuxc.gpio_ad.p06,
pcs0: iomuxc.gpio_ad.p05,
};
let mut spi = Spi::new(lpspi1, pins);
spi.disabled(|spi| {
spi.set_clock_hz(super::LPSPI_CLK_FREQUENCY, super::SPI_BAUD_RATE_FREQUENCY);
});
let spi_cs = todo!();
let spi_cs = gpio1.output(iomuxc.gpio_ad.p05, true);
(spi, spi_cs)
};

Expand Down
8 changes: 5 additions & 3 deletions board/src/imxrt1060evk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,15 @@

let gpio1 = unsafe { ral::gpio::GPIO1::instance() };
let mut gpio1 = hal::gpio::Port::new(gpio1);
let led = gpio1.output(iomuxc.gpio_ad_b0.p09);
let led = gpio1.output(iomuxc.gpio_ad_b0.p09, false);

let gpio5 = unsafe { ral::gpio::GPIO5::instance() };
let mut gpio5 = hal::gpio::Port::new(gpio5);
let button = hal::gpio::Input::without_pin(&mut gpio5, 0);

let gpio3 = unsafe { ral::gpio::GPIO3::instance() };
let mut gpio3 = hal::gpio::Port::new(gpio3);

Check warning on line 166 in board/src/imxrt1060evk.rs

View workflow job for this annotation

GitHub Actions / examples (--examples --features=board/imxrt1060evk,board/lcd1602)

unused variable: `gpio3`

Check warning on line 166 in board/src/imxrt1060evk.rs

View workflow job for this annotation

GitHub Actions / examples (--examples --features=board/imxrt1060evk,board/lcd1602)

variable does not need to be mutable

let lpuart1 = unsafe { ral::lpuart::LPUART1::instance() };
let mut console = hal::lpuart::Lpuart::new(
lpuart1,
Expand All @@ -182,13 +185,12 @@
sdo: iomuxc.gpio_sd_b0.p02,
sdi: iomuxc.gpio_sd_b0.p03,
sck: iomuxc.gpio_sd_b0.p00,
pcs0: iomuxc.gpio_sd_b0.p01,
};
let mut spi = Spi::new(lpspi1, pins);
spi.disabled(|spi| {
spi.set_clock_hz(super::LPSPI_CLK_FREQUENCY, super::SPI_BAUD_RATE_FREQUENCY);
});
let spi_cs = todo!();
let spi_cs = gpio3.output(iomuxc.gpio_sd_b0.p01, true);
(spi, spi_cs)
};
#[cfg(not(feature = "spi"))]
Expand Down
5 changes: 2 additions & 3 deletions board/src/imxrt1170evk-cm7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl Specifics {

let gpio9 = unsafe { ral::gpio::GPIO9::instance() };
let mut gpio9 = hal::gpio::Port::new(gpio9);
let led = gpio9.output(iomuxc.gpio_ad.p04);
let led = gpio9.output(iomuxc.gpio_ad.p04, false);

let console = unsafe { ral::lpuart::Instance::<{ CONSOLE_INSTANCE }>::instance() };
let mut console = hal::lpuart::Lpuart::new(
Expand All @@ -212,13 +212,12 @@ impl Specifics {
sdo: iomuxc.gpio_ad.p30,
sdi: iomuxc.gpio_ad.p31,
sck: iomuxc.gpio_ad.p28,
pcs0: iomuxc.gpio_ad.p29,
};
let mut spi = Spi::new(lpspi1, pins);
spi.disabled(|spi| {
spi.set_clock_hz(LPSPI_CLK_FREQUENCY, super::SPI_BAUD_RATE_FREQUENCY);
});
let spi_cs = todo!();
let spi_cs = gpio9.output(iomuxc.gpio_ad.p29, true);
(spi, spi_cs)
};
#[cfg(not(feature = "spi"))]
Expand Down
2 changes: 1 addition & 1 deletion src/common/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//! let gpio_b0_04 = // Handle to GPIO_B0_04 IOMUXC pin, provided by BSP or higher-level HAL...
//! # unsafe { imxrt_iomuxc::imxrt1060::gpio_b0::GPIO_B0_04::new() };
//!
//! let output = gpio2.output(gpio_b0_04);
//! let output = gpio2.output(gpio_b0_04, false);
//! output.set();
//! output.clear();
//! output.toggle();
Expand Down
Loading