Skip to content

Commit

Permalink
Fix two more.
Browse files Browse the repository at this point in the history
  • Loading branch information
thejpster committed Sep 1, 2024
1 parent 9e18c29 commit 8041088
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
7 changes: 6 additions & 1 deletion rp235x-hal-examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ futures = {version = "0.3.30", default-features = false, features = ["async-awai
hd44780-driver = "0.4.0"
heapless = "0.8.0"
nb = "1.0"
nostd_async = {version = "0.6.1", features = ["cortex_m"]}
panic-halt = "0.2.0"
pio = "0.2.0"
pio-proc = "0.2.0"
rp235x-hal = {path = "../rp235x-hal", version = "0.2.0", features = ["binary-info", "critical-section-impl", "rt", "defmt"]}
usb-device = "0.3.2"
usbd-serial = "0.2.2"

[target.'thumbv8m.main-none-eabihf'.dependencies]
nostd_async = {version = "0.6.1", features = ["cortex_m"]}

[target.riscv32imac-unknown-none-elf.dependencies]
nostd_async = {version = "0.6.1"}
2 changes: 2 additions & 0 deletions rp235x-hal-examples/riscv_examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ gpio_dyn_pin_array
gpio_in_out
gpio_irq_example
i2c
i2c_async
i2c_async_cancelled
lcd_display
mem_to_mem_dma
pio_blink
Expand Down
8 changes: 4 additions & 4 deletions rp235x-hal-examples/src/bin/i2c_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use hal::{
gpio::bank0::{Gpio20, Gpio21},
gpio::{FunctionI2C, Pin, PullUp},
i2c::Controller,
pac::interrupt,
Clock, I2C,
};

Expand All @@ -40,7 +39,8 @@ pub static IMAGE_DEF: hal::block::ImageDef = hal::block::ImageDef::secure_exe();
const XTAL_FREQ_HZ: u32 = 12_000_000u32;

/// Bind the interrupt handler with the peripheral
#[interrupt]
#[no_mangle]
#[allow(non_snake_case)]
unsafe fn I2C0_IRQ() {
use hal::async_utils::AsyncPeripheral;
I2C::<hal::pac::I2C0, (Gpio20, Gpio21), Controller>::on_interrupt();
Expand Down Expand Up @@ -98,8 +98,8 @@ async fn demo() {
// Each core has its own NVIC so these needs to executed from the core where the IRQ are
// expected.
unsafe {
cortex_m::peripheral::NVIC::unpend(hal::pac::Interrupt::I2C0_IRQ);
cortex_m::peripheral::NVIC::unmask(hal::pac::Interrupt::I2C0_IRQ);
hal::arch::interrupt_unmask(hal::pac::Interrupt::I2C0_IRQ);
hal::arch::interrupt_enable();
}

// Asynchronously write three bytes to the I²C device with 7-bit address 0x2C
Expand Down
8 changes: 4 additions & 4 deletions rp235x-hal-examples/src/bin/i2c_async_cancelled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use hal::{
gpio::bank0::{Gpio20, Gpio21},
gpio::{FunctionI2C, Pin, PullUp},
i2c::Controller,
pac::interrupt,
Clock, I2C,
};

Expand All @@ -42,7 +41,8 @@ pub static IMAGE_DEF: hal::block::ImageDef = hal::block::ImageDef::secure_exe();
/// Adjust if your board has a different frequency
const XTAL_FREQ_HZ: u32 = 12_000_000u32;

#[interrupt]
#[no_mangle]
#[allow(non_snake_case)]
unsafe fn I2C0_IRQ() {
use hal::async_utils::AsyncPeripheral;
I2C::<hal::pac::I2C0, (Gpio20, Gpio21), Controller>::on_interrupt();
Expand Down Expand Up @@ -98,8 +98,8 @@ async fn demo() {

// Unmask the interrupt in the NVIC to let the core wake up & enter the interrupt handler.
unsafe {
cortex_m::peripheral::NVIC::unpend(hal::pac::Interrupt::I2C0_IRQ);
cortex_m::peripheral::NVIC::unmask(hal::pac::Interrupt::I2C0_IRQ);
hal::arch::interrupt_unmask(hal::pac::Interrupt::I2C0_IRQ);
hal::arch::interrupt_enable();
}

let mut cnt = 0;
Expand Down

0 comments on commit 8041088

Please sign in to comment.