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