From 80410884a3300c73ccf086fcbe7780089b423f77 Mon Sep 17 00:00:00 2001 From: Jonathan 'theJPster' Pallant Date: Sun, 1 Sep 2024 18:02:34 +0100 Subject: [PATCH] Fix two more. --- rp235x-hal-examples/Cargo.toml | 7 ++++++- rp235x-hal-examples/riscv_examples.txt | 2 ++ rp235x-hal-examples/src/bin/i2c_async.rs | 8 ++++---- rp235x-hal-examples/src/bin/i2c_async_cancelled.rs | 8 ++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/rp235x-hal-examples/Cargo.toml b/rp235x-hal-examples/Cargo.toml index 4df1b14d1..837f45f9c 100644 --- a/rp235x-hal-examples/Cargo.toml +++ b/rp235x-hal-examples/Cargo.toml @@ -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"} diff --git a/rp235x-hal-examples/riscv_examples.txt b/rp235x-hal-examples/riscv_examples.txt index 9e23a6d23..6ca5e7001 100644 --- a/rp235x-hal-examples/riscv_examples.txt +++ b/rp235x-hal-examples/riscv_examples.txt @@ -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 diff --git a/rp235x-hal-examples/src/bin/i2c_async.rs b/rp235x-hal-examples/src/bin/i2c_async.rs index 8b104bc99..f77c7159c 100644 --- a/rp235x-hal-examples/src/bin/i2c_async.rs +++ b/rp235x-hal-examples/src/bin/i2c_async.rs @@ -23,7 +23,6 @@ use hal::{ gpio::bank0::{Gpio20, Gpio21}, gpio::{FunctionI2C, Pin, PullUp}, i2c::Controller, - pac::interrupt, Clock, I2C, }; @@ -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::::on_interrupt(); @@ -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 diff --git a/rp235x-hal-examples/src/bin/i2c_async_cancelled.rs b/rp235x-hal-examples/src/bin/i2c_async_cancelled.rs index f9b069389..7b7a4d07c 100644 --- a/rp235x-hal-examples/src/bin/i2c_async_cancelled.rs +++ b/rp235x-hal-examples/src/bin/i2c_async_cancelled.rs @@ -27,7 +27,6 @@ use hal::{ gpio::bank0::{Gpio20, Gpio21}, gpio::{FunctionI2C, Pin, PullUp}, i2c::Controller, - pac::interrupt, Clock, I2C, }; @@ -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::::on_interrupt(); @@ -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;