aboutsummaryrefslogtreecommitdiff
path: root/examples/src/bin/hello.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/src/bin/hello.rs')
-rw-r--r--examples/src/bin/hello.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/src/bin/hello.rs b/examples/src/bin/hello.rs
index f426d1898..e371d9413 100644
--- a/examples/src/bin/hello.rs
+++ b/examples/src/bin/hello.rs
@@ -2,27 +2,29 @@
2#![no_main] 2#![no_main]
3 3
4use embassy_executor::Spawner; 4use embassy_executor::Spawner;
5use embassy_mcxa::clocks::config::Div8;
5use hal::lpuart::{Blocking, Config, Lpuart}; 6use hal::lpuart::{Blocking, Config, Lpuart};
6use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; 7use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _};
7 8
8/// Simple helper to write a byte as hex to UART 9/// Simple helper to write a byte as hex to UART
9fn write_hex_byte(uart: &mut Lpuart<'_, Blocking>, byte: u8) { 10fn write_hex_byte(uart: &mut Lpuart<'_, Blocking>, byte: u8) {
10 const HEX_DIGITS: &[u8] = b"0123456789ABCDEF"; 11 const HEX_DIGITS: &[u8] = b"0123456789ABCDEF";
11 uart.write_byte(HEX_DIGITS[(byte >> 4) as usize]); 12 let _ = uart.write_byte(HEX_DIGITS[(byte >> 4) as usize]);
12 uart.write_byte(HEX_DIGITS[(byte & 0xF) as usize]); 13 let _ = uart.write_byte(HEX_DIGITS[(byte & 0xF) as usize]);
13} 14}
14 15
15#[embassy_executor::main] 16#[embassy_executor::main]
16async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
17 let p = hal::init(hal::config::Config::default()); 18 let mut cfg = hal::config::Config::default();
19 cfg.clock_cfg.sirc.fro_12m_enabled = true;
20 cfg.clock_cfg.sirc.fro_lf_div = Some(Div8::no_div());
21 let p = hal::init(cfg);
18 22
19 defmt::info!("boot"); 23 defmt::info!("boot");
20 24
21 // Create UART configuration 25 // Create UART configuration
22 let config = Config { 26 let config = Config {
23 baudrate_bps: 115_200, 27 baudrate_bps: 115_200,
24 enable_tx: true,
25 enable_rx: true,
26 ..Default::default() 28 ..Default::default()
27 }; 29 };
28 30
@@ -97,7 +99,7 @@ async fn main(_spawner: Spawner) {
97 // Regular character 99 // Regular character
98 buffer[buf_idx] = byte; 100 buffer[buf_idx] = byte;
99 buf_idx += 1; 101 buf_idx += 1;
100 uart.write_byte(byte); 102 let _ = uart.write_byte(byte);
101 } 103 }
102 } 104 }
103} 105}