diff options
| author | Felipe Balbi <[email protected]> | 2025-11-07 10:06:55 -0800 |
|---|---|---|
| committer | Felipe Balbi <[email protected]> | 2025-11-07 10:06:55 -0800 |
| commit | cb2ac2790f4b037056f9571abeb4d62360199426 (patch) | |
| tree | f9f163e4340d11ddc54c24ab8cf7624e83f1fd18 /examples | |
| parent | a71eff2e1cea55b393e793c023b8e51e5cc369a1 (diff) | |
Reduce number of features
We don't need features for drivers that always exist.
Signed-off-by: Felipe Balbi <[email protected]>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/adc_interrupt.rs | 54 | ||||
| -rw-r--r-- | examples/adc_polling.rs | 47 | ||||
| -rw-r--r-- | examples/blink.rs | 6 | ||||
| -rw-r--r-- | examples/hello.rs | 14 | ||||
| -rw-r--r-- | examples/lpuart_buffered.rs | 6 | ||||
| -rw-r--r-- | examples/lpuart_polling.rs | 16 | ||||
| -rw-r--r-- | examples/ostimer_alarm.rs | 16 | ||||
| -rw-r--r-- | examples/ostimer_async.rs | 20 | ||||
| -rw-r--r-- | examples/ostimer_counter.rs | 16 | ||||
| -rw-r--r-- | examples/ostimer_race_test.rs | 17 | ||||
| -rw-r--r-- | examples/rtc_alarm.rs | 25 | ||||
| -rw-r--r-- | examples/uart_interrupt.rs | 21 |
12 files changed, 58 insertions, 200 deletions
diff --git a/examples/adc_interrupt.rs b/examples/adc_interrupt.rs index 452eaae01..26afd70b4 100644 --- a/examples/adc_interrupt.rs +++ b/examples/adc_interrupt.rs | |||
| @@ -1,28 +1,23 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use embassy_mcxa276 as hal; | ||
| 5 | use cortex_m; | 4 | use cortex_m; |
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mcxa276 as hal; | ||
| 7 | 7 | ||
| 8 | use hal::adc::{TriggerPriorityPolicy, LpadcConfig}; | 8 | use hal::adc::{LpadcConfig, TriggerPriorityPolicy}; |
| 9 | use hal::pac::adc1::cfg::{Refsel, Pwrsel}; | 9 | use hal::pac::adc1::cfg::{Pwrsel, Refsel}; |
| 10 | use hal::pac::adc1::tctrl::{Tcmd}; | ||
| 11 | use hal::pac::adc1::cmdl1::{Adch, Mode}; | 10 | use hal::pac::adc1::cmdl1::{Adch, Mode}; |
| 12 | use hal::pac::adc1::ctrl::{CalAvgs}; | 11 | use hal::pac::adc1::ctrl::CalAvgs; |
| 12 | use hal::pac::adc1::tctrl::Tcmd; | ||
| 13 | 13 | ||
| 14 | use hal::uart; | 14 | use hal::uart; |
| 15 | mod common; | 15 | mod common; |
| 16 | 16 | ||
| 17 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | use defmt_rtt as _; | ||
| 19 | #[cfg(feature = "defmt")] | ||
| 20 | use panic_probe as _; | ||
| 21 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 22 | use rtt_target as _; | ||
| 23 | 18 | ||
| 24 | use hal::bind_interrupts; | ||
| 25 | use hal::InterruptExt; | 19 | use hal::InterruptExt; |
| 20 | use hal::bind_interrupts; | ||
| 26 | 21 | ||
| 27 | bind_interrupts!(struct Irqs { | 22 | bind_interrupts!(struct Irqs { |
| 28 | ADC1 => hal::adc::AdcHandler; | 23 | ADC1 => hal::adc::AdcHandler; |
| @@ -40,7 +35,7 @@ async fn main(_spawner: Spawner) { | |||
| 40 | common::init_uart2(hal::pac()); | 35 | common::init_uart2(hal::pac()); |
| 41 | } | 36 | } |
| 42 | 37 | ||
| 43 | let src = unsafe { hal::clocks::uart2_src_hz(hal::pac()) }; | 38 | let src = unsafe { hal::clocks::uart2_src_hz(hal::pac()) }; |
| 44 | let uart = uart::Uart::<uart::Lpuart2>::new(p.LPUART2, uart::Config::new(src)); | 39 | let uart = uart::Uart::<uart::Lpuart2>::new(p.LPUART2, uart::Config::new(src)); |
| 45 | 40 | ||
| 46 | uart.write_str_blocking("\r\n=== ADC interrupt Example ===\r\n"); | 41 | uart.write_str_blocking("\r\n=== ADC interrupt Example ===\r\n"); |
| @@ -48,19 +43,18 @@ async fn main(_spawner: Spawner) { | |||
| 48 | unsafe { | 43 | unsafe { |
| 49 | common::init_adc(hal::pac()); | 44 | common::init_adc(hal::pac()); |
| 50 | } | 45 | } |
| 51 | 46 | ||
| 52 | |||
| 53 | let adc_config = LpadcConfig { | 47 | let adc_config = LpadcConfig { |
| 54 | enable_in_doze_mode: true, | 48 | enable_in_doze_mode: true, |
| 55 | conversion_average_mode: CalAvgs::Average128, | 49 | conversion_average_mode: CalAvgs::Average128, |
| 56 | enable_analog_preliminary: true, | 50 | enable_analog_preliminary: true, |
| 57 | power_up_delay: 0x80, | 51 | power_up_delay: 0x80, |
| 58 | reference_voltage_source: Refsel::Option3, | 52 | reference_voltage_source: Refsel::Option3, |
| 59 | power_level_mode: Pwrsel::Lowest, | 53 | power_level_mode: Pwrsel::Lowest, |
| 60 | trigger_priority_policy: TriggerPriorityPolicy::ConvPreemptImmediatelyNotAutoResumed, | 54 | trigger_priority_policy: TriggerPriorityPolicy::ConvPreemptImmediatelyNotAutoResumed, |
| 61 | enable_conv_pause: false, | 55 | enable_conv_pause: false, |
| 62 | conv_pause_delay: 0, | 56 | conv_pause_delay: 0, |
| 63 | fifo_watermark: 0, | 57 | fifo_watermark: 0, |
| 64 | }; | 58 | }; |
| 65 | let adc = hal::adc::Adc::<hal::adc::Adc1>::new(p.ADC1, adc_config); | 59 | let adc = hal::adc::Adc::<hal::adc::Adc1>::new(p.ADC1, adc_config); |
| 66 | 60 | ||
| @@ -78,7 +72,7 @@ async fn main(_spawner: Spawner) { | |||
| 78 | adc.set_conv_trigger_config(0, &conv_trigger_config); | 72 | adc.set_conv_trigger_config(0, &conv_trigger_config); |
| 79 | 73 | ||
| 80 | uart.write_str_blocking("\r\n=== ADC configuration done... ===\r\n"); | 74 | uart.write_str_blocking("\r\n=== ADC configuration done... ===\r\n"); |
| 81 | 75 | ||
| 82 | adc.enable_interrupt(0x1); | 76 | adc.enable_interrupt(0x1); |
| 83 | 77 | ||
| 84 | unsafe { | 78 | unsafe { |
| @@ -92,15 +86,9 @@ async fn main(_spawner: Spawner) { | |||
| 92 | loop { | 86 | loop { |
| 93 | adc.do_software_trigger(1); | 87 | adc.do_software_trigger(1); |
| 94 | while !adc.is_interrupt_triggered() { | 88 | while !adc.is_interrupt_triggered() { |
| 95 | // Wait until the interrupt is triggered | 89 | // Wait until the interrupt is triggered |
| 96 | } | 90 | } |
| 97 | uart.write_str_blocking("\r\n*** ADC interrupt TRIGGERED! ***\r\n"); | 91 | uart.write_str_blocking("\r\n*** ADC interrupt TRIGGERED! ***\r\n"); |
| 98 | //TBD need to print the value | 92 | //TBD need to print the value |
| 99 | } | 93 | } |
| 100 | } | 94 | } |
| 101 | |||
| 102 | #[cfg(not(feature = "defmt"))] | ||
| 103 | #[panic_handler] | ||
| 104 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 105 | loop {} | ||
| 106 | } \ No newline at end of file | ||
diff --git a/examples/adc_polling.rs b/examples/adc_polling.rs index 7cb728e91..90be87c3f 100644 --- a/examples/adc_polling.rs +++ b/examples/adc_polling.rs | |||
| @@ -5,27 +5,21 @@ use embassy_mcxa276 as hal; | |||
| 5 | 5 | ||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | 7 | ||
| 8 | use hal::adc::{TriggerPriorityPolicy, LpadcConfig, ConvResult}; | 8 | use hal::adc::{ConvResult, LpadcConfig, TriggerPriorityPolicy}; |
| 9 | use hal::pac::adc1::cfg::{Refsel, Pwrsel}; | 9 | use hal::pac::adc1::cfg::{Pwrsel, Refsel}; |
| 10 | use hal::pac::adc1::tctrl::{Tcmd}; | ||
| 11 | use hal::pac::adc1::cmdl1::{Adch, Mode}; | 10 | use hal::pac::adc1::cmdl1::{Adch, Mode}; |
| 12 | use hal::pac::adc1::ctrl::{CalAvgs}; | 11 | use hal::pac::adc1::ctrl::CalAvgs; |
| 12 | use hal::pac::adc1::tctrl::Tcmd; | ||
| 13 | 13 | ||
| 14 | use hal::uart; | 14 | use hal::uart; |
| 15 | 15 | ||
| 16 | mod common; | 16 | mod common; |
| 17 | 17 | ||
| 18 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | use defmt_rtt as _; | ||
| 20 | #[cfg(feature = "defmt")] | ||
| 21 | use panic_probe as _; | ||
| 22 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 23 | use rtt_target as _; | ||
| 24 | 19 | ||
| 25 | use core::fmt::Write; | 20 | use core::fmt::Write; |
| 26 | use heapless::String; | 21 | use heapless::String; |
| 27 | 22 | ||
| 28 | |||
| 29 | const G_LPADC_RESULT_SHIFT: u32 = 0; | 23 | const G_LPADC_RESULT_SHIFT: u32 = 0; |
| 30 | 24 | ||
| 31 | #[embassy_executor::main] | 25 | #[embassy_executor::main] |
| @@ -44,19 +38,18 @@ async fn main(_spawner: Spawner) { | |||
| 44 | unsafe { | 38 | unsafe { |
| 45 | common::init_adc(hal::pac()); | 39 | common::init_adc(hal::pac()); |
| 46 | } | 40 | } |
| 47 | 41 | ||
| 48 | |||
| 49 | let adc_config = LpadcConfig { | 42 | let adc_config = LpadcConfig { |
| 50 | enable_in_doze_mode: true, | 43 | enable_in_doze_mode: true, |
| 51 | conversion_average_mode: CalAvgs::Average128, | 44 | conversion_average_mode: CalAvgs::Average128, |
| 52 | enable_analog_preliminary: true, | 45 | enable_analog_preliminary: true, |
| 53 | power_up_delay: 0x80, | 46 | power_up_delay: 0x80, |
| 54 | reference_voltage_source: Refsel::Option3, | 47 | reference_voltage_source: Refsel::Option3, |
| 55 | power_level_mode: Pwrsel::Lowest, | 48 | power_level_mode: Pwrsel::Lowest, |
| 56 | trigger_priority_policy: TriggerPriorityPolicy::ConvPreemptImmediatelyNotAutoResumed, | 49 | trigger_priority_policy: TriggerPriorityPolicy::ConvPreemptImmediatelyNotAutoResumed, |
| 57 | enable_conv_pause: false, | 50 | enable_conv_pause: false, |
| 58 | conv_pause_delay: 0, | 51 | conv_pause_delay: 0, |
| 59 | fifo_watermark: 0, | 52 | fifo_watermark: 0, |
| 60 | }; | 53 | }; |
| 61 | let adc = hal::adc::Adc::<hal::adc::Adc1>::new(p.ADC1, adc_config); | 54 | let adc = hal::adc::Adc::<hal::adc::Adc1>::new(p.ADC1, adc_config); |
| 62 | 55 | ||
| @@ -74,7 +67,7 @@ async fn main(_spawner: Spawner) { | |||
| 74 | adc.set_conv_trigger_config(0, &conv_trigger_config); | 67 | adc.set_conv_trigger_config(0, &conv_trigger_config); |
| 75 | 68 | ||
| 76 | uart.write_str_blocking("\r\n=== ADC configuration done... ===\r\n"); | 69 | uart.write_str_blocking("\r\n=== ADC configuration done... ===\r\n"); |
| 77 | 70 | ||
| 78 | loop { | 71 | loop { |
| 79 | adc.do_software_trigger(1); | 72 | adc.do_software_trigger(1); |
| 80 | let mut result: Option<ConvResult> = None; | 73 | let mut result: Option<ConvResult> = None; |
| @@ -87,9 +80,3 @@ async fn main(_spawner: Spawner) { | |||
| 87 | uart.write_str_blocking(&buf); | 80 | uart.write_str_blocking(&buf); |
| 88 | } | 81 | } |
| 89 | } | 82 | } |
| 90 | |||
| 91 | #[cfg(not(feature = "defmt"))] | ||
| 92 | #[panic_handler] | ||
| 93 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 94 | loop {} | ||
| 95 | } \ No newline at end of file | ||
diff --git a/examples/blink.rs b/examples/blink.rs index 6289ac14e..a9b6e7093 100644 --- a/examples/blink.rs +++ b/examples/blink.rs | |||
| @@ -85,9 +85,3 @@ async fn main(_spawner: Spawner) { | |||
| 85 | Timer::after(Duration::from_millis(1000)).await; | 85 | Timer::after(Duration::from_millis(1000)).await; |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | |||
| 89 | #[cfg(not(feature = "defmt"))] | ||
| 90 | #[panic_handler] | ||
| 91 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 92 | loop {} | ||
| 93 | } | ||
diff --git a/examples/hello.rs b/examples/hello.rs index 591bf2460..e39adaced 100644 --- a/examples/hello.rs +++ b/examples/hello.rs | |||
| @@ -7,12 +7,7 @@ use hal::uart; | |||
| 7 | 7 | ||
| 8 | mod common; | 8 | mod common; |
| 9 | 9 | ||
| 10 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | use defmt_rtt as _; | ||
| 12 | #[cfg(feature = "defmt")] | ||
| 13 | use panic_probe as _; | ||
| 14 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 15 | use rtt_target as _; | ||
| 16 | 11 | ||
| 17 | /// Simple helper to write a byte as hex to UART | 12 | /// Simple helper to write a byte as hex to UART |
| 18 | fn write_hex_byte(uart: &hal::uart::Uart<hal::uart::Lpuart2>, byte: u8) { | 13 | fn write_hex_byte(uart: &hal::uart::Uart<hal::uart::Lpuart2>, byte: u8) { |
| @@ -25,7 +20,6 @@ fn write_hex_byte(uart: &hal::uart::Uart<hal::uart::Lpuart2>, byte: u8) { | |||
| 25 | async fn main(_spawner: Spawner) { | 20 | async fn main(_spawner: Spawner) { |
| 26 | let p = hal::init(hal::config::Config::default()); | 21 | let p = hal::init(hal::config::Config::default()); |
| 27 | 22 | ||
| 28 | #[cfg(feature = "defmt")] | ||
| 29 | defmt::info!("boot"); | 23 | defmt::info!("boot"); |
| 30 | 24 | ||
| 31 | // Board-level init for UART2 clocks and pins. | 25 | // Board-level init for UART2 clocks and pins. |
| @@ -118,9 +112,3 @@ fn parse_u8(bytes: &[u8]) -> Result<u8, ()> { | |||
| 118 | } | 112 | } |
| 119 | Ok(result) | 113 | Ok(result) |
| 120 | } | 114 | } |
| 121 | |||
| 122 | #[cfg(not(feature = "defmt"))] | ||
| 123 | #[panic_handler] | ||
| 124 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 125 | loop {} | ||
| 126 | } | ||
diff --git a/examples/lpuart_buffered.rs b/examples/lpuart_buffered.rs index 88f256096..d0d4d2ee0 100644 --- a/examples/lpuart_buffered.rs +++ b/examples/lpuart_buffered.rs | |||
| @@ -80,9 +80,3 @@ async fn main(_spawner: Spawner) { | |||
| 80 | tx.write_all(&buf[..]).await.unwrap(); | 80 | tx.write_all(&buf[..]).await.unwrap(); |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | |||
| 84 | #[cfg(not(feature = "defmt"))] | ||
| 85 | #[panic_handler] | ||
| 86 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 87 | loop {} | ||
| 88 | } | ||
diff --git a/examples/lpuart_polling.rs b/examples/lpuart_polling.rs index c83c959e8..f9172de40 100644 --- a/examples/lpuart_polling.rs +++ b/examples/lpuart_polling.rs | |||
| @@ -1,16 +1,11 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use crate::hal::lpuart::{lib, Config, Lpuart}; | 4 | use crate::hal::lpuart::{Config, Lpuart, lib}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mcxa276 as hal; | 6 | use embassy_mcxa276 as hal; |
| 7 | 7 | ||
| 8 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | use defmt_rtt as _; | ||
| 10 | #[cfg(feature = "defmt")] | ||
| 11 | use panic_probe as _; | ||
| 12 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 13 | use rtt_target as _; | ||
| 14 | 9 | ||
| 15 | mod common; | 10 | mod common; |
| 16 | 11 | ||
| @@ -19,7 +14,6 @@ async fn main(_spawner: Spawner) { | |||
| 19 | let _p = hal::init(hal::config::Config::default()); | 14 | let _p = hal::init(hal::config::Config::default()); |
| 20 | let p2 = lib::init(); | 15 | let p2 = lib::init(); |
| 21 | 16 | ||
| 22 | #[cfg(feature = "defmt")] | ||
| 23 | defmt::info!("boot"); | 17 | defmt::info!("boot"); |
| 24 | 18 | ||
| 25 | // Board-level init for UART2 clocks and pins. | 19 | // Board-level init for UART2 clocks and pins. |
| @@ -59,9 +53,3 @@ async fn main(_spawner: Spawner) { | |||
| 59 | tx.blocking_write(&buf).unwrap(); | 53 | tx.blocking_write(&buf).unwrap(); |
| 60 | } | 54 | } |
| 61 | } | 55 | } |
| 62 | |||
| 63 | #[cfg(not(feature = "defmt"))] | ||
| 64 | #[panic_handler] | ||
| 65 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 66 | loop {} | ||
| 67 | } | ||
diff --git a/examples/ostimer_alarm.rs b/examples/ostimer_alarm.rs index 823e37c15..eca669509 100644 --- a/examples/ostimer_alarm.rs +++ b/examples/ostimer_alarm.rs | |||
| @@ -9,12 +9,7 @@ use hal::uart; | |||
| 9 | 9 | ||
| 10 | mod common; | 10 | mod common; |
| 11 | 11 | ||
| 12 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | use defmt_rtt as _; | ||
| 14 | #[cfg(feature = "defmt")] | ||
| 15 | use panic_probe as _; | ||
| 16 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 17 | use rtt_target as _; | ||
| 18 | 13 | ||
| 19 | use embassy_mcxa276::bind_interrupts; | 14 | use embassy_mcxa276::bind_interrupts; |
| 20 | 15 | ||
| @@ -61,7 +56,8 @@ async fn main(_spawner: Spawner) { | |||
| 61 | init_match_max: true, | 56 | init_match_max: true, |
| 62 | clock_frequency_hz: 1_000_000, // 1MHz | 57 | clock_frequency_hz: 1_000_000, // 1MHz |
| 63 | }; | 58 | }; |
| 64 | let ostimer = hal::ostimer::Ostimer::<hal::ostimer::Ostimer0>::new(p.OSTIMER0, config, hal::pac()); | 59 | let ostimer = |
| 60 | hal::ostimer::Ostimer::<hal::ostimer::Ostimer0>::new(p.OSTIMER0, config, hal::pac()); | ||
| 65 | 61 | ||
| 66 | // Create alarm with callback | 62 | // Create alarm with callback |
| 67 | let alarm = hal::ostimer::Alarm::new() | 63 | let alarm = hal::ostimer::Alarm::new() |
| @@ -118,9 +114,3 @@ async fn main(_spawner: Spawner) { | |||
| 118 | 114 | ||
| 119 | uart.write_str_blocking("Example complete\n"); | 115 | uart.write_str_blocking("Example complete\n"); |
| 120 | } | 116 | } |
| 121 | |||
| 122 | #[cfg(not(feature = "defmt"))] | ||
| 123 | #[panic_handler] | ||
| 124 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 125 | loop {} | ||
| 126 | } | ||
diff --git a/examples/ostimer_async.rs b/examples/ostimer_async.rs index 181ce58ef..37fb3b3d1 100644 --- a/examples/ostimer_async.rs +++ b/examples/ostimer_async.rs | |||
| @@ -7,16 +7,9 @@ use hal::uart; | |||
| 7 | 7 | ||
| 8 | mod common; | 8 | mod common; |
| 9 | 9 | ||
| 10 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 11 | use defmt_rtt as _; | ||
| 12 | #[cfg(feature = "defmt")] | ||
| 13 | use panic_probe as _; | ||
| 14 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 15 | use rtt_target as _; | ||
| 16 | |||
| 17 | use embassy_time::{Duration, Timer}; | ||
| 18 | |||
| 19 | use embassy_mcxa276::bind_interrupts; | 10 | use embassy_mcxa276::bind_interrupts; |
| 11 | use embassy_time::{Duration, Timer}; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | ||
| 20 | 13 | ||
| 21 | // Bind only OS_EVENT, and retain the symbol explicitly so it can’t be GC’ed. | 14 | // Bind only OS_EVENT, and retain the symbol explicitly so it can’t be GC’ed. |
| 22 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| @@ -57,20 +50,11 @@ async fn main(_spawner: Spawner) { | |||
| 57 | // Removed force-pend; rely on real hardware match to trigger OS_EVENT. | 50 | // Removed force-pend; rely on real hardware match to trigger OS_EVENT. |
| 58 | 51 | ||
| 59 | // Log using defmt if enabled | 52 | // Log using defmt if enabled |
| 60 | #[cfg(feature = "defmt")] | ||
| 61 | defmt::info!("OSTIMER async example starting..."); | 53 | defmt::info!("OSTIMER async example starting..."); |
| 62 | 54 | ||
| 63 | loop { | 55 | loop { |
| 64 | #[cfg(feature = "defmt")] | ||
| 65 | defmt::info!("tick"); | 56 | defmt::info!("tick"); |
| 66 | #[cfg(not(feature = "defmt"))] | ||
| 67 | uart.write_str_blocking("tick\n"); | 57 | uart.write_str_blocking("tick\n"); |
| 68 | Timer::after(Duration::from_millis(1000)).await; | 58 | Timer::after(Duration::from_millis(1000)).await; |
| 69 | } | 59 | } |
| 70 | } | 60 | } |
| 71 | |||
| 72 | #[cfg(not(feature = "defmt"))] | ||
| 73 | #[panic_handler] | ||
| 74 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 75 | loop {} | ||
| 76 | } | ||
diff --git a/examples/ostimer_counter.rs b/examples/ostimer_counter.rs index 3af0f03f2..1f5bdf434 100644 --- a/examples/ostimer_counter.rs +++ b/examples/ostimer_counter.rs | |||
| @@ -9,12 +9,7 @@ | |||
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 11 | 11 | ||
| 12 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | use defmt_rtt as _; | ||
| 14 | #[cfg(feature = "defmt")] | ||
| 15 | use panic_probe as _; | ||
| 16 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 17 | use rtt_target as _; | ||
| 18 | 13 | ||
| 19 | use embassy_mcxa276 as hal; | 14 | use embassy_mcxa276 as hal; |
| 20 | use hal::bind_interrupts; | 15 | use hal::bind_interrupts; |
| @@ -37,7 +32,8 @@ async fn main(_spawner: Spawner) { | |||
| 37 | common::init_uart2(hal::pac()); | 32 | common::init_uart2(hal::pac()); |
| 38 | } | 33 | } |
| 39 | let src = unsafe { hal::clocks::uart2_src_hz(hal::pac()) }; | 34 | let src = unsafe { hal::clocks::uart2_src_hz(hal::pac()) }; |
| 40 | let mut uart = hal::uart::Uart::<hal::uart::Lpuart2>::new(p.LPUART2, hal::uart::Config::new(src)); | 35 | let mut uart = |
| 36 | hal::uart::Uart::<hal::uart::Lpuart2>::new(p.LPUART2, hal::uart::Config::new(src)); | ||
| 41 | 37 | ||
| 42 | uart.write_str_blocking("OSTIMER Counter Reading and Reset Example\n"); | 38 | uart.write_str_blocking("OSTIMER Counter Reading and Reset Example\n"); |
| 43 | 39 | ||
| @@ -134,9 +130,3 @@ fn write_u64(uart: &mut hal::uart::Uart<hal::uart::Lpuart2>, value: u64) { | |||
| 134 | } | 130 | } |
| 135 | } | 131 | } |
| 136 | } | 132 | } |
| 137 | |||
| 138 | #[cfg(not(feature = "defmt"))] | ||
| 139 | #[panic_handler] | ||
| 140 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 141 | loop {} | ||
| 142 | } | ||
diff --git a/examples/ostimer_race_test.rs b/examples/ostimer_race_test.rs index 4470b65fd..072310309 100644 --- a/examples/ostimer_race_test.rs +++ b/examples/ostimer_race_test.rs | |||
| @@ -12,16 +12,10 @@ | |||
| 12 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::{Duration, Timer}; |
| 14 | 14 | ||
| 15 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 16 | use defmt_rtt as _; | ||
| 17 | #[cfg(feature = "defmt")] | ||
| 18 | use panic_probe as _; | ||
| 19 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 20 | use rtt_target as _; | ||
| 21 | |||
| 22 | use core::sync::atomic::{AtomicU32, Ordering}; | 15 | use core::sync::atomic::{AtomicU32, Ordering}; |
| 23 | use embassy_mcxa276 as hal; | 16 | use embassy_mcxa276 as hal; |
| 24 | use hal::bind_interrupts; | 17 | use hal::bind_interrupts; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | ||
| 25 | 19 | ||
| 26 | mod common; | 20 | mod common; |
| 27 | 21 | ||
| @@ -86,7 +80,8 @@ async fn main(_spawner: Spawner) { | |||
| 86 | common::init_uart2(hal::pac()); | 80 | common::init_uart2(hal::pac()); |
| 87 | } | 81 | } |
| 88 | let src = unsafe { hal::clocks::uart2_src_hz(hal::pac()) }; | 82 | let src = unsafe { hal::clocks::uart2_src_hz(hal::pac()) }; |
| 89 | let mut uart = hal::uart::Uart::<hal::uart::Lpuart2>::new(p.LPUART2, hal::uart::Config::new(src)); | 83 | let mut uart = |
| 84 | hal::uart::Uart::<hal::uart::Lpuart2>::new(p.LPUART2, hal::uart::Config::new(src)); | ||
| 90 | 85 | ||
| 91 | uart.write_str_blocking("OSTIMER Race Condition Test Starting...\n"); | 86 | uart.write_str_blocking("OSTIMER Race Condition Test Starting...\n"); |
| 92 | 87 | ||
| @@ -403,9 +398,3 @@ fn write_u64(uart: &mut hal::uart::Uart<hal::uart::Lpuart2>, value: u64) { | |||
| 403 | } | 398 | } |
| 404 | } | 399 | } |
| 405 | } | 400 | } |
| 406 | |||
| 407 | #[cfg(not(feature = "defmt"))] | ||
| 408 | #[panic_handler] | ||
| 409 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 410 | loop {} | ||
| 411 | } | ||
diff --git a/examples/rtc_alarm.rs b/examples/rtc_alarm.rs index 8f4ff1623..a190b8ba5 100644 --- a/examples/rtc_alarm.rs +++ b/examples/rtc_alarm.rs | |||
| @@ -1,26 +1,21 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | |||
| 5 | use embassy_mcxa276 as hal; | ||
| 6 | use cortex_m; | 4 | use cortex_m; |
| 7 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mcxa276 as hal; | ||
| 7 | use hal::InterruptExt; | ||
| 8 | use hal::rtc::{RtcDateTime, RtcInterruptEnable}; | 8 | use hal::rtc::{RtcDateTime, RtcInterruptEnable}; |
| 9 | use hal::uart; | 9 | use hal::uart; |
| 10 | use hal::InterruptExt; | ||
| 11 | 10 | ||
| 12 | mod common; | 11 | mod common; |
| 13 | 12 | ||
| 14 | type MyRtc = hal::rtc::Rtc<hal::rtc::Rtc0>; | 13 | type MyRtc = hal::rtc::Rtc<hal::rtc::Rtc0>; |
| 15 | 14 | ||
| 16 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | use defmt_rtt as _; | ||
| 18 | #[cfg(feature = "defmt")] | ||
| 19 | use panic_probe as _; | ||
| 20 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 21 | use rtt_target as _; | ||
| 22 | 16 | ||
| 23 | use embassy_mcxa276::bind_interrupts; | 17 | use embassy_mcxa276::bind_interrupts; |
| 18 | |||
| 24 | bind_interrupts!(struct Irqs { | 19 | bind_interrupts!(struct Irqs { |
| 25 | RTC => hal::rtc::RtcHandler; | 20 | RTC => hal::rtc::RtcHandler; |
| 26 | }); | 21 | }); |
| @@ -31,7 +26,6 @@ static KEEP_RTC: unsafe extern "C" fn() = RTC; | |||
| 31 | 26 | ||
| 32 | #[embassy_executor::main] | 27 | #[embassy_executor::main] |
| 33 | async fn main(_spawner: Spawner) { | 28 | async fn main(_spawner: Spawner) { |
| 34 | |||
| 35 | let p = hal::init(hal::config::Config::default()); | 29 | let p = hal::init(hal::config::Config::default()); |
| 36 | 30 | ||
| 37 | unsafe { | 31 | unsafe { |
| @@ -58,12 +52,11 @@ async fn main(_spawner: Spawner) { | |||
| 58 | second: 0, | 52 | second: 0, |
| 59 | }; | 53 | }; |
| 60 | 54 | ||
| 61 | |||
| 62 | rtc.stop(); | 55 | rtc.stop(); |
| 63 | 56 | ||
| 64 | uart.write_str_blocking("Time set to: 2025-10-15 14:30:00\r\n"); | 57 | uart.write_str_blocking("Time set to: 2025-10-15 14:30:00\r\n"); |
| 65 | rtc.set_datetime(now); | 58 | rtc.set_datetime(now); |
| 66 | 59 | ||
| 67 | let mut alarm = now; | 60 | let mut alarm = now; |
| 68 | alarm.second += 10; | 61 | alarm.second += 10; |
| 69 | 62 | ||
| @@ -92,14 +85,6 @@ async fn main(_spawner: Spawner) { | |||
| 92 | } | 85 | } |
| 93 | 86 | ||
| 94 | uart.write_str_blocking("Example complete - Test PASSED!\r\n"); | 87 | uart.write_str_blocking("Example complete - Test PASSED!\r\n"); |
| 95 | |||
| 96 | loop { | ||
| 97 | |||
| 98 | } | ||
| 99 | } | ||
| 100 | 88 | ||
| 101 | #[cfg(not(feature = "defmt"))] | ||
| 102 | #[panic_handler] | ||
| 103 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 104 | loop {} | 89 | loop {} |
| 105 | } | 90 | } |
diff --git a/examples/uart_interrupt.rs b/examples/uart_interrupt.rs index 85743bb64..bd734f859 100644 --- a/examples/uart_interrupt.rs +++ b/examples/uart_interrupt.rs | |||
| @@ -8,14 +8,8 @@ use hal::uart; | |||
| 8 | 8 | ||
| 9 | mod common; | 9 | mod common; |
| 10 | 10 | ||
| 11 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 12 | use defmt_rtt as _; | ||
| 13 | #[cfg(feature = "defmt")] | ||
| 14 | use panic_probe as _; | ||
| 15 | #[cfg(all(feature = "defmt", feature = "defmt-rtt"))] | ||
| 16 | use rtt_target as _; | ||
| 17 | |||
| 18 | use embassy_mcxa276::bind_interrupts; | 11 | use embassy_mcxa276::bind_interrupts; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | ||
| 19 | 13 | ||
| 20 | // Bind LPUART2 interrupt to our handler | 14 | // Bind LPUART2 interrupt to our handler |
| 21 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| @@ -57,7 +51,6 @@ async fn main(_spawner: Spawner) { | |||
| 57 | uart.write_str_blocking("Type characters to echo them back.\r\n"); | 51 | uart.write_str_blocking("Type characters to echo them back.\r\n"); |
| 58 | 52 | ||
| 59 | // Log using defmt if enabled | 53 | // Log using defmt if enabled |
| 60 | #[cfg(feature = "defmt")] | ||
| 61 | defmt::info!("UART interrupt echo demo starting..."); | 54 | defmt::info!("UART interrupt echo demo starting..."); |
| 62 | 55 | ||
| 63 | loop { | 56 | loop { |
| @@ -74,15 +67,3 @@ async fn main(_spawner: Spawner) { | |||
| 74 | } | 67 | } |
| 75 | } | 68 | } |
| 76 | } | 69 | } |
| 77 | |||
| 78 | #[cfg(feature = "defmt")] | ||
| 79 | #[export_name = "_defmt_timestamp"] | ||
| 80 | fn defmt_timestamp(_fmt: defmt::Formatter<'_>) { | ||
| 81 | // Return empty timestamp for now | ||
| 82 | } | ||
| 83 | |||
| 84 | #[cfg(not(feature = "defmt"))] | ||
| 85 | #[panic_handler] | ||
| 86 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 87 | loop {} | ||
| 88 | } | ||
