From e43dfd3fa58d6e2a2c4026a110ae2d4ed07ee170 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Tue, 9 Sep 2025 13:21:56 -1000 Subject: [PATCH 1/9] Instantiate UART peripheral for NET connection --- ui-stm32/src/board/ev13.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ui-stm32/src/board/ev13.rs b/ui-stm32/src/board/ev13.rs index 0507e652..a3c7f03c 100644 --- a/ui-stm32/src/board/ev13.rs +++ b/ui-stm32/src/board/ev13.rs @@ -1,8 +1,11 @@ use super::{Button, Keyboard, Screen, StatusLed}; use embassy_stm32::{ + bind_interrupts, exti::ExtiInput, gpio::{Input, Level, Output, Pull, Speed}, + peripherals, spi::Spi, + usart, }; use ui_app::{Led, Outputs}; @@ -14,6 +17,10 @@ pub struct Board { pub keyboard: Option, } +bind_interrupts!(struct Irqs { + USART2 => usart::InterruptHandler; +}); + impl Board { pub async fn new() -> Self { let p = embassy_stm32::init(Default::default()); @@ -64,8 +71,17 @@ impl Board { let spi1 = Spi::new_blocking_txonly(p.SPI1, p.PA5, p.PA7, config); let screen = Screen::new(chip_select, data_command, reset, backlight, spi1).await; - // TODO(RLB): NET UART - // TODO(RLB): MGMT UART + // NET UART + let net_uart = { + use embassy_stm32::usart::*; + let mut config = Config::default(); + config.baudrate = 460800; + config.data_bits = DataBits::DataBits8; + config.stop_bits = StopBits::STOP2; + config.parity = Parity::ParityNone; + + Uart::new(p.USART2, p.PA3, p.PA2, Irqs, p.DMA1_CH6, p.DMA1_CH5, config).unwrap() + }; Self { status_led, From 600116f505a66c26b94fc135550509f83ecedfa6 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Wed, 10 Sep 2025 12:56:25 -1000 Subject: [PATCH 2/9] Monitor for inbound messages --- ui-stm32/Cargo.toml | 4 ++-- ui-stm32/src/board/ev13.rs | 9 ++++++++- ui-stm32/src/main.rs | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ui-stm32/Cargo.toml b/ui-stm32/Cargo.toml index 23bb70cc..b31882ee 100644 --- a/ui-stm32/Cargo.toml +++ b/ui-stm32/Cargo.toml @@ -22,11 +22,11 @@ embassy-executor = { version = "0.8.0", features = ["arch-cortex-m", "executor-t embassy-futures = { version = "0.1.1", features = ["defmt"] } embassy-stm32 = { version = "0.3.0", features = ["defmt", "stm32f405rg", "memory-x", "time-driver-tim1", "exti", "chrono"] } embassy-time = { version = "0.4.0", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } - -heapless = { version = "0.8", default-features = false } panic-probe = { version = "1.0.0", features = ["print-defmt"] } embassy-sync = { version = "0.7.1", features = ["defmt"] } num_enum = { version = "0.7.4", default-features = false } +hex = { version = "0.4.3", default-features = false } +heapless = { version = "0.9.1", features = ["defmt"] } [profile.release] debug = 2 diff --git a/ui-stm32/src/board/ev13.rs b/ui-stm32/src/board/ev13.rs index a3c7f03c..9b8d977c 100644 --- a/ui-stm32/src/board/ev13.rs +++ b/ui-stm32/src/board/ev13.rs @@ -3,18 +3,21 @@ use embassy_stm32::{ bind_interrupts, exti::ExtiInput, gpio::{Input, Level, Output, Pull, Speed}, + mode::Async, peripherals, spi::Spi, - usart, + usart::{self, UartRx, UartTx}, }; use ui_app::{Led, Outputs}; pub struct Board { status_led: StatusLed, screen: Screen, + net_tx: UartTx<'static, Async>, pub ptt_button: Option