aboutsummaryrefslogtreecommitdiff
path: root/examples/src/bin/ostimer_async.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/src/bin/ostimer_async.rs')
-rw-r--r--examples/src/bin/ostimer_async.rs64
1 files changed, 0 insertions, 64 deletions
diff --git a/examples/src/bin/ostimer_async.rs b/examples/src/bin/ostimer_async.rs
deleted file mode 100644
index f043184e7..000000000
--- a/examples/src/bin/ostimer_async.rs
+++ /dev/null
@@ -1,64 +0,0 @@
1#![no_std]
2#![no_main]
3
4use embassy_executor::Spawner;
5use embassy_mcxa::bind_interrupts;
6use embassy_mcxa_examples::init_uart2_pins;
7use embassy_time::{Duration, Timer};
8use hal::lpuart::{Config, Lpuart};
9use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _};
10
11// Bind only OS_EVENT, and retain the symbol explicitly so it can’t be GC’ed.
12bind_interrupts!(struct Irqs {
13 OS_EVENT => hal::ostimer::time_driver::OsEventHandler;
14});
15
16#[used]
17#[no_mangle]
18static KEEP_OS_EVENT: unsafe extern "C" fn() = OS_EVENT;
19
20#[embassy_executor::main]
21async fn main(_spawner: Spawner) {
22 let p = hal::init(hal::config::Config::default());
23
24 // Create UART configuration
25 let config = Config {
26 baudrate_bps: 115_200,
27 enable_tx: true,
28 enable_rx: true,
29 ..Default::default()
30 };
31
32 // Create UART instance using LPUART2 with P2_2 as TX and P2_3 as RX
33 unsafe {
34 init_uart2_pins(hal::pac());
35 }
36 let mut uart = Lpuart::new_blocking(
37 p.LPUART2, // Peripheral
38 p.P2_2, // TX pin
39 p.P2_3, // RX pin
40 config,
41 )
42 .unwrap();
43 uart.blocking_write(b"boot\n").unwrap();
44
45 // Avoid mass NVIC writes here; DefaultHandler now safely returns.
46
47 // Initialize embassy-time global driver backed by OSTIMER0 (re-enables OS_EVENT with priority)
48 // The bind_interrupts! macro handles handler binding automatically
49
50 // Initialize OSTIMER with default 1MHz frequency
51 // Adjust this value to match your actual OSTIMER clock frequency
52 hal::ostimer::time_driver::init(hal::config::Config::default().time_interrupt_priority, 1_000_000);
53
54 // Removed force-pend; rely on real hardware match to trigger OS_EVENT.
55
56 // Log using defmt if enabled
57 defmt::info!("OSTIMER async example starting...");
58
59 loop {
60 defmt::info!("tick");
61 uart.write_str_blocking("tick\n");
62 Timer::after(Duration::from_millis(1000)).await;
63 }
64}