mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-02 14:44:42 +00:00
Don't use #[interrupt}
in the serial_interrupts.rs example (#1385)
This commit is contained in:
parent
256d7198f9
commit
efcf7d4074
@ -10,6 +10,8 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
|
use core::ptr::addr_of_mut;
|
||||||
|
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
|
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
|
||||||
use embassy_time::{Duration, Ticker};
|
use embassy_time::{Duration, Ticker};
|
||||||
@ -67,7 +69,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
let led = io.pins.gpio0.into_push_pull_output();
|
let led = io.pins.gpio0.into_push_pull_output();
|
||||||
|
|
||||||
let _guard = cpu_control
|
let _guard = cpu_control
|
||||||
.start_app_core(unsafe { &mut APP_CORE_STACK }, move || {
|
.start_app_core(unsafe { &mut *addr_of_mut!(APP_CORE_STACK) }, move || {
|
||||||
let executor = make_static!(Executor::new());
|
let executor = make_static!(Executor::new());
|
||||||
executor.run(|spawner| {
|
executor.run(|spawner| {
|
||||||
spawner.spawn(control_led(led, led_ctrl_signal)).ok();
|
spawner.spawn(control_led(led, led_ctrl_signal)).ok();
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
|
use core::ptr::addr_of_mut;
|
||||||
|
|
||||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
|
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
|
||||||
use embassy_time::{Duration, Ticker};
|
use embassy_time::{Duration, Ticker};
|
||||||
use embedded_hal_02::digital::v2::OutputPin;
|
use embedded_hal_02::digital::v2::OutputPin;
|
||||||
@ -109,7 +111,7 @@ fn main() -> ! {
|
|||||||
loop {}
|
loop {}
|
||||||
};
|
};
|
||||||
let _guard = cpu_control
|
let _guard = cpu_control
|
||||||
.start_app_core(unsafe { &mut APP_CORE_STACK }, cpu1_fnctn)
|
.start_app_core(unsafe { &mut *addr_of_mut!(APP_CORE_STACK) }, cpu1_fnctn)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let spawner = INT_EXECUTOR_CORE_0.start(Priority::Priority1);
|
let spawner = INT_EXECUTOR_CORE_0.start(Priority::Priority1);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::cell::RefCell;
|
use core::{cell::RefCell, ptr::addr_of_mut};
|
||||||
|
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
@ -35,7 +35,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let mut cpu_control = CpuControl::new(system.cpu_control);
|
let mut cpu_control = CpuControl::new(system.cpu_control);
|
||||||
let _guard = cpu_control
|
let _guard = cpu_control
|
||||||
.start_app_core(unsafe { &mut APP_CORE_STACK }, || {
|
.start_app_core(unsafe { &mut *addr_of_mut!(APP_CORE_STACK) }, || {
|
||||||
println!("Hello World - Core 1!");
|
println!("Hello World - Core 1!");
|
||||||
loop {
|
loop {
|
||||||
delay.delay(500.millis());
|
delay.delay(500.millis());
|
||||||
|
@ -14,10 +14,15 @@ use esp_backtrace as _;
|
|||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
delay::Delay,
|
delay::Delay,
|
||||||
|
gpio,
|
||||||
interrupt::{self, Priority},
|
interrupt::{self, Priority},
|
||||||
peripherals::{Interrupt, Peripherals, UART0},
|
peripherals::{Interrupt, Peripherals, UART0},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
uart::{config::AtCmdConfig, Uart},
|
uart::{
|
||||||
|
config::{AtCmdConfig, Config},
|
||||||
|
TxRxPins,
|
||||||
|
Uart,
|
||||||
|
},
|
||||||
Blocking,
|
Blocking,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -31,15 +36,22 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
let mut uart0 = Uart::new(peripherals.UART0, &clocks);
|
let mut uart0 = Uart::new_with_config(
|
||||||
|
peripherals.UART0,
|
||||||
|
Config::default(),
|
||||||
|
None::<TxRxPins<gpio::NoPinType, gpio::NoPinType>>,
|
||||||
|
&clocks,
|
||||||
|
Some(interrupt_handler),
|
||||||
|
);
|
||||||
|
|
||||||
|
critical_section::with(|cs| {
|
||||||
uart0.set_at_cmd(AtCmdConfig::new(None, None, None, b'#', None));
|
uart0.set_at_cmd(AtCmdConfig::new(None, None, None, b'#', None));
|
||||||
uart0.set_rx_fifo_full_threshold(30).unwrap();
|
uart0.set_rx_fifo_full_threshold(30).unwrap();
|
||||||
uart0.listen_at_cmd();
|
uart0.listen_at_cmd();
|
||||||
uart0.listen_rx_fifo_full();
|
uart0.listen_rx_fifo_full();
|
||||||
|
|
||||||
interrupt::enable(Interrupt::UART0, Priority::Priority2).unwrap();
|
SERIAL.borrow_ref_mut(cs).replace(uart0);
|
||||||
|
});
|
||||||
critical_section::with(|cs| SERIAL.borrow_ref_mut(cs).replace(uart0));
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
critical_section::with(|cs| {
|
critical_section::with(|cs| {
|
||||||
@ -52,8 +64,8 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt]
|
#[handler]
|
||||||
fn UART0() {
|
fn interrupt_handler() {
|
||||||
critical_section::with(|cs| {
|
critical_section::with(|cs| {
|
||||||
let mut serial = SERIAL.borrow_ref_mut(cs);
|
let mut serial = SERIAL.borrow_ref_mut(cs);
|
||||||
let serial = serial.as_mut().unwrap();
|
let serial = serial.as_mut().unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user