feat: Heltec V3 native USB, remove all dead_code suppressions

- heltec_v3 now uses USB OTG (requires hardware mod: solder R29/R3)
- heltec_v3_uart added as fallback for stock boards
- Removed every #[allow(dead_code)] — fixed root causes instead:
  - Comm types (UsbParts/UartParts) moved to individual board files
  - USB/UART init removed from hal (boards call esp-hal directly)
  - SH1106 driver gated on boards that use it
  - UART task sends DisplayCommand::Reset at startup (variant now used)
  - ErrorCode::CrcError removed (SX1262 drops bad-CRC silently)
- check/clippy now use --release (no more Xtensa dev-mode warnings)
- Updated README with hardware mod docs and board table
This commit is contained in:
swaits committed 2026-04-07 10:52:58 -06:00
1 parent 6db287c241
commit 2b9e236f32
10 files changed
+61 -79

No files matched your search

+2 -45
View File
@@ -1,8 +1,8 @@
//! ESP32-S3 MCU initialization primitives.
//!
//! Provides low-level bus and peripheral init for ESP32-S3 boards.
//! Provides low-level bus init for ESP32-S3 boards.
//! Board files call these with specific pins and construct higher-level
//! drivers (Sx126x, SSD1306, etc.) themselves.
//! drivers (Sx126x, SSD1306, USB, UART, etc.) themselves.
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use esp_hal::dma::{DmaRxBuf, DmaTxBuf};
@@ -17,10 +17,6 @@ use static_cell::StaticCell;
pub type SpiBus = SpiDmaBus<'static, esp_hal::Async>;
pub type I2cBus = I2c<'static, esp_hal::Async>;
#[allow(dead_code)] // Used by USB boards, not UART boards
pub type UsbOtgDriver = esp_hal::otg_fs::asynch::Driver<'static>;
#[allow(dead_code)] // Used by UART boards, not USB boards
pub type UartDriver = esp_hal::uart::Uart<'static, esp_hal::Async>;
// ── Timer ───────────────────────────────────────────────────────────
@@ -33,8 +29,6 @@ pub fn start_timer(timg0: esp_hal::peripherals::TIMG0<'static>) {
// ── SPI bus ─────────────────────────────────────────────────────────
/// Initialize SPI2 with DMA and wrap in a shared bus (StaticCell + Mutex).
///
/// Returns a reference to the shared SPI bus suitable for `SpiDevice::new()`.
pub fn init_spi(
spi2: esp_hal::peripherals::SPI2<'static>,
dma_ch0: esp_hal::peripherals::DMA_CH0<'static>,
@@ -80,43 +74,6 @@ pub fn init_i2c(
.into_async()
}
// ── USB OTG ─────────────────────────────────────────────────────────
/// Initialize USB OTG FS driver for CDC-ACM.
#[allow(dead_code)] // Used by USB boards, not UART boards
pub fn init_usb(
usb0: esp_hal::peripherals::USB0<'static>,
dp: esp_hal::peripherals::GPIO20<'static>,
dm: esp_hal::peripherals::GPIO19<'static>,
) -> UsbOtgDriver {
let usb_inst = esp_hal::otg_fs::Usb::new(usb0, dp, dm);
static EP_OUT_BUF: StaticCell<[u8; 1024]> = StaticCell::new();
let ep_out_buf = EP_OUT_BUF.init([0u8; 1024]);
esp_hal::otg_fs::asynch::Driver::new(
usb_inst,
ep_out_buf,
esp_hal::otg_fs::asynch::Config::default(),
)
}
// ── UART ────────────────────────────────────────────────────────────
/// Initialize UART0 for boards with USB-UART bridge chips (e.g. CP2102).
#[allow(dead_code)] // Used by UART boards, not USB boards
pub fn init_uart(
uart0: esp_hal::peripherals::UART0<'static>,
tx: esp_hal::peripherals::GPIO43<'static>,
rx: esp_hal::peripherals::GPIO44<'static>,
) -> UartDriver {
use esp_hal::uart::{Config as UartConfig, Uart};
Uart::new(uart0, UartConfig::default())
.expect("UART init")
.with_tx(tx)
.with_rx(rx)
.into_async()
}
// ── MAC address ─────────────────────────────────────────────────────
/// Read the factory-programmed MAC address from eFuse.