fix: .expect() on board init unwraps, document forget() and fixed LoRa params

Board init: all .unwrap() → .expect() with diagnostic messages.
Vext/reset forget(): documented why pin must stay in output state.
Fixed LoRa params (PREAMBLE_LEN, CRC_ON, etc.): documented as
intentionally non-configurable.
Watch capacity: documented that display sees latest state only.
This commit is contained in:
swaits committed 2026-03-29 22:29:04 -06:00
1 parent f54579bfde
commit 99a01b867e
5 files changed
+18 -12

No files matched your search

+4 -4
View File
@@ -65,7 +65,7 @@ impl Board {
// ── Vext power: GPIO21, active LOW to enable OLED ────────── // ── Vext power: GPIO21, active LOW to enable OLED ──────────
let vext = Output::new(p.GPIO21, Level::Low); let vext = Output::new(p.GPIO21, Level::Low);
core::mem::forget(vext); core::mem::forget(vext); // hold pin low permanently; drop would reset it
// ── DMA for SPI ──────────────────────────────────────────── // ── DMA for SPI ────────────────────────────────────────────
let dma = Dma::new(p.DMA); let dma = Dma::new(p.DMA);
@@ -83,8 +83,8 @@ impl Board {
.with_dma(dma_ch); .with_dma(dma_ch);
let (rx_buf, rx_desc, tx_buf, tx_desc) = esp_hal::dma_buffers!(256); let (rx_buf, rx_desc, tx_buf, tx_desc) = esp_hal::dma_buffers!(256);
let dma_rx = esp_hal::dma::DmaRxBuf::new(rx_desc, rx_buf).unwrap(); let dma_rx = esp_hal::dma::DmaRxBuf::new(rx_desc, rx_buf).expect("DMA RX buf");
let dma_tx = esp_hal::dma::DmaTxBuf::new(tx_desc, tx_buf).unwrap(); let dma_tx = esp_hal::dma::DmaTxBuf::new(tx_desc, tx_buf).expect("DMA TX buf");
let spi = spi.with_buffers(dma_rx, dma_tx).into_async(); let spi = spi.with_buffers(dma_rx, dma_tx).into_async();
@@ -100,7 +100,7 @@ impl Board {
let dio1 = Input::new(p.GPIO14, Pull::Down); let dio1 = Input::new(p.GPIO14, Pull::Down);
let busy = Input::new(p.GPIO13, Pull::Down); let busy = Input::new(p.GPIO13, Pull::Down);
let iv = GenericSx126xInterfaceVariant::new(reset, dio1, busy, None, None).unwrap(); let iv = GenericSx126xInterfaceVariant::new(reset, dio1, busy, None, None).expect("SX1262 interface init");
let sx_config = sx126x::Config { let sx_config = sx126x::Config {
chip: Sx1262, chip: Sx1262,
+5 -5
View File
@@ -66,7 +66,7 @@ impl Board {
// ── Vext power: GPIO36 ───────────────────────────────────── // ── Vext power: GPIO36 ─────────────────────────────────────
// V4 datasheet says "pull low to enable Vext" // V4 datasheet says "pull low to enable Vext"
let vext = Output::new(p.GPIO36, Level::Low); let vext = Output::new(p.GPIO36, Level::Low);
core::mem::forget(vext); core::mem::forget(vext); // hold pin low permanently; drop would reset it
// ── DMA for SPI ──────────────────────────────────────────── // ── DMA for SPI ────────────────────────────────────────────
let dma = Dma::new(p.DMA); let dma = Dma::new(p.DMA);
@@ -84,8 +84,8 @@ impl Board {
.with_dma(dma_ch); .with_dma(dma_ch);
let (rx_buf, rx_desc, tx_buf, tx_desc) = esp_hal::dma_buffers!(256); let (rx_buf, rx_desc, tx_buf, tx_desc) = esp_hal::dma_buffers!(256);
let dma_rx = esp_hal::dma::DmaRxBuf::new(rx_desc, rx_buf).unwrap(); let dma_rx = esp_hal::dma::DmaRxBuf::new(rx_desc, rx_buf).expect("DMA RX buf");
let dma_tx = esp_hal::dma::DmaTxBuf::new(tx_desc, tx_buf).unwrap(); let dma_tx = esp_hal::dma::DmaTxBuf::new(tx_desc, tx_buf).expect("DMA TX buf");
let spi = spi.with_buffers(dma_rx, dma_tx).into_async(); let spi = spi.with_buffers(dma_rx, dma_tx).into_async();
@@ -101,7 +101,7 @@ impl Board {
let dio1 = Input::new(p.GPIO14, Pull::Down); let dio1 = Input::new(p.GPIO14, Pull::Down);
let busy = Input::new(p.GPIO13, Pull::Down); let busy = Input::new(p.GPIO13, Pull::Down);
let iv = GenericSx126xInterfaceVariant::new(reset, dio1, busy, None, None).unwrap(); let iv = GenericSx126xInterfaceVariant::new(reset, dio1, busy, None, None).expect("SX1262 interface init");
let sx_config = sx126x::Config { let sx_config = sx126x::Config {
chip: Sx1262, chip: Sx1262,
@@ -136,7 +136,7 @@ impl Board {
esp_hal::delay::Delay::new().delay_millis(10); esp_hal::delay::Delay::new().delay_millis(10);
display_rst.set_high(); display_rst.set_high();
esp_hal::delay::Delay::new().delay_millis(10); esp_hal::delay::Delay::new().delay_millis(10);
core::mem::forget(display_rst); core::mem::forget(display_rst); // hold reset high permanently
let i2c = I2c::new(p.I2C0, I2cConfig::default()) let i2c = I2c::new(p.I2C0, I2cConfig::default())
.with_sda(p.GPIO17) .with_sda(p.GPIO17)
+1 -1
View File
@@ -84,7 +84,7 @@ impl Board {
let dio1 = Input::new(AnyPin::from(p.P1_15), Pull::Down); let dio1 = Input::new(AnyPin::from(p.P1_15), Pull::Down);
let busy = Input::new(AnyPin::from(p.P1_14), Pull::Down); let busy = Input::new(AnyPin::from(p.P1_14), Pull::Down);
let iv = GenericSx126xInterfaceVariant::new(reset, dio1, busy, None, None).unwrap(); let iv = GenericSx126xInterfaceVariant::new(reset, dio1, busy, None, None).expect("SX1262 interface init");
let sx_config = sx126x::Config { let sx_config = sx126x::Config {
chip: Sx1262, chip: Sx1262,
+3 -1
View File
@@ -30,7 +30,9 @@ pub type CommandChannel = Channel<CriticalSectionRawMutex, Command, 16>;
/// Radio-to-host response channel (depth 32: buffer RX packets while USB writes). /// Radio-to-host response channel (depth 32: buffer RX packets while USB writes).
pub type ResponseChannel = Channel<CriticalSectionRawMutex, Response, 32>; pub type ResponseChannel = Channel<CriticalSectionRawMutex, Response, 32>;
/// Observable radio status for the display task (2 slots: latest + previous). /// Observable radio status for the display task (2 receivers max).
/// Display always sees the latest state — intermediate updates may be
/// skipped, which is fine for a status display.
pub type StatusWatch = Watch<CriticalSectionRawMutex, RadioStatus, 2>; pub type StatusWatch = Watch<CriticalSectionRawMutex, RadioStatus, 2>;
/// Current radio state exposed to observers (e.g. display). /// Current radio state exposed to observers (e.g. display).
+5 -1
View File
@@ -33,7 +33,11 @@ const POWER_RANGE: (i8, i8) = TX_POWER_RANGE;
type Radio = LoRa<RadioDriver, Delay>; type Radio = LoRa<RadioDriver, Delay>;
// ── LoRa radio parameters ─────────────────────────────────────────── // ── Fixed LoRa radio parameters ─────────────────────────────────────
//
// These are intentionally not host-configurable. They are sensible
// defaults for a general-purpose LoRa pipe. Making them configurable
// would add protocol complexity for marginal benefit.
/// Preamble length in symbols. 8 is the LoRa default. /// Preamble length in symbols. 8 is the LoRa default.
const PREAMBLE_LEN: u16 = 8; const PREAMBLE_LEN: u16 = 8;