Fix lints
This commit is contained in:
parent
21282033b4
commit
fc1aa617af
|
|
@ -1,9 +1,8 @@
|
||||||
use core::fmt::write;
|
|
||||||
|
|
||||||
use embedded_cli::cli::CliBuilder;
|
use embedded_cli::cli::CliBuilder;
|
||||||
use embedded_cli::Command;
|
use embedded_cli::Command;
|
||||||
use esp_hal::{Async, uart::{TxError, UartRx}};
|
use esp_hal::{Async, uart::{TxError, UartRx}};
|
||||||
use log::{debug, info, error};
|
use log::{info, error};
|
||||||
|
|
||||||
use crate::logging::with_uart_tx;
|
use crate::logging::with_uart_tx;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,64 +1,19 @@
|
||||||
use core::alloc::Layout;
|
use core::cell::RefCell;
|
||||||
use core::cell::{OnceCell, RefCell};
|
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
use core::time::Duration;
|
|
||||||
|
|
||||||
use alloc::boxed::Box;
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use alloc::vec;
|
|
||||||
use bt_hci::controller::ExternalController;
|
|
||||||
use critical_section::{CriticalSection, Mutex};
|
use critical_section::{CriticalSection, Mutex};
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use esp_hal::uart::UartTx;
|
||||||
use embassy_executor::Spawner;
|
use esp_hal::Blocking;
|
||||||
use embassy_time::Timer;
|
use log::{LevelFilter, Log};
|
||||||
use esp_alloc::{HeapRegion, MemoryCapability};
|
|
||||||
use esp_hal::clock::CpuClock;
|
|
||||||
use esp_hal::dma::{BurstConfig, DmaDescriptor, DmaTxBuf, ExternalBurstConfig};
|
|
||||||
use esp_hal::gpio::{Flex, Input, InputConfig, Io, Level, Output, OutputConfig, Pull};
|
|
||||||
use esp_hal::handler;
|
|
||||||
use esp_hal::i2c::master::{I2c, I2cAddress};
|
|
||||||
use esp_hal::interrupt::Priority;
|
|
||||||
use esp_hal::interrupt::software::SoftwareInterruptControl;
|
|
||||||
use esp_hal::lcd_cam::LcdCam;
|
|
||||||
use esp_hal::lcd_cam::lcd::dpi::Dpi;
|
|
||||||
use esp_hal::mcpwm::{McPwm, PeripheralClockConfig};
|
|
||||||
use esp_hal::peripherals::Peripherals;
|
|
||||||
use esp_hal::psram::{FlashFreq, PsramConfig, PsramSize, SpiRamFreq, SpiTimingConfigCoreClock};
|
|
||||||
use esp_hal::rng::TrngSource;
|
|
||||||
use esp_hal::system::Stack;
|
|
||||||
use esp_hal::time::Instant;
|
|
||||||
use esp_hal::timer::timg::TimerGroup;
|
|
||||||
use esp_hal::uart::{Uart, UartTx};
|
|
||||||
use esp_hal::usb_serial_jtag::{UsbSerialJtag, UsbSerialJtagTx};
|
|
||||||
use esp_hal::{Blocking, ram};
|
|
||||||
use esp_radio::Controller;
|
|
||||||
use esp_radio::ble::controller::BleConnector;
|
|
||||||
use esp_rtos::embassy::{Executor, InterruptExecutor};
|
|
||||||
use esp_storage::FlashStorage;
|
|
||||||
use itertools::chain;
|
|
||||||
use log::{LevelFilter, Log, error, info};
|
|
||||||
use rmk::channel::EVENT_CHANNEL;
|
|
||||||
use rmk::config::{BehaviorConfig, PositionalConfig, RmkConfig, StorageConfig, VialConfig};
|
|
||||||
use rmk::debounce::default_debouncer::DefaultDebouncer;
|
|
||||||
use rmk::embassy_futures::yield_now;
|
|
||||||
use rmk::input_device::Runnable;
|
|
||||||
use rmk::{join_all};
|
|
||||||
use rmk::keyboard::Keyboard;
|
|
||||||
use rmk::storage::async_flash_wrapper;
|
|
||||||
use rmk::{initialize_keymap_and_storage, run_devices, run_rmk};
|
|
||||||
use slint::platform::software_renderer::{Rgb565Pixel, TargetPixel};
|
|
||||||
use slint::{ComponentHandle, PhysicalSize, WindowSize};
|
|
||||||
use slint::platform::Platform;
|
|
||||||
use static_cell::StaticCell;
|
|
||||||
|
|
||||||
static ALT_LOGGER_UART: Mutex<RefCell<Option<UartTx<'static, Blocking>>>> = Mutex::new(RefCell::new(None));
|
static ALT_LOGGER_UART: Mutex<RefCell<Option<UartTx<'static, Blocking>>>> = Mutex::new(RefCell::new(None));
|
||||||
|
|
||||||
pub fn with_uart_tx<R>(mut f: impl FnOnce(CriticalSection<'_>, &'_ mut UartTx<'static, Blocking>) -> R) -> R {
|
pub fn with_uart_tx<R>(f: impl FnOnce(CriticalSection<'_>, &'_ mut UartTx<'static, Blocking>) -> R) -> R {
|
||||||
critical_section::with(|cs| {
|
critical_section::with(|cs| {
|
||||||
let mut uart = ALT_LOGGER_UART.borrow(cs).borrow_mut();
|
let mut uart = ALT_LOGGER_UART.borrow(cs).borrow_mut();
|
||||||
let mut uart = uart.as_mut().unwrap();
|
let uart = uart.as_mut().unwrap();
|
||||||
|
|
||||||
(f)(cs, &mut uart)
|
(f)(cs, uart)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,11 +54,9 @@ macro_rules! println {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "alt-log"))]
|
|
||||||
use esp_println::println;
|
|
||||||
|
|
||||||
fn do_print(args: core::fmt::Arguments<'_>) {
|
fn do_print(args: core::fmt::Arguments<'_>) {
|
||||||
with_uart_tx(|cs, uart| {
|
with_uart_tx(|_, uart| {
|
||||||
uart.write_fmt(args).unwrap();
|
uart.write_fmt(args).unwrap();
|
||||||
uart.write_str("\n").unwrap();
|
uart.write_str("\n").unwrap();
|
||||||
uart.flush().unwrap();
|
uart.flush().unwrap();
|
||||||
|
|
@ -124,7 +77,7 @@ fn print_log_record(uart: &mut UartTx<'_, Blocking>, record: &log::Record) {
|
||||||
uart.flush().unwrap();
|
uart.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "alt-log")]
|
#[cfg(not(feature = "usb-log"))]
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic_handler(info: &core::panic::PanicInfo) -> ! {
|
fn panic_handler(info: &core::panic::PanicInfo) -> ! {
|
||||||
use esp_backtrace::Backtrace;
|
use esp_backtrace::Backtrace;
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use core::alloc::Layout;
|
use core::alloc::Layout;
|
||||||
use core::cell::{OnceCell, RefCell};
|
use core::cell::RefCell;
|
||||||
use core::fmt::Write;
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
|
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
|
|
@ -14,36 +13,28 @@ use alloc::rc::Rc;
|
||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
use shadow_rs::shadow;
|
use shadow_rs::shadow;
|
||||||
use bt_hci::controller::ExternalController;
|
use bt_hci::controller::ExternalController;
|
||||||
use critical_section::Mutex;
|
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_time::Timer;
|
|
||||||
use esp_alloc::{HeapRegion, MemoryCapability};
|
use esp_alloc::{HeapRegion, MemoryCapability};
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::dma::{BurstConfig, DmaDescriptor, DmaTxBuf, ExternalBurstConfig};
|
use esp_hal::dma::{BurstConfig, DmaDescriptor, DmaTxBuf, ExternalBurstConfig};
|
||||||
use esp_hal::gpio::{Flex, Input, InputConfig, Io, Level, Output, OutputConfig, Pull};
|
use esp_hal::gpio::{Flex, Input, InputConfig, Io, Level, Output, OutputConfig, Pull};
|
||||||
use esp_hal::handler;
|
use esp_hal::handler;
|
||||||
use esp_hal::i2c::master::{I2c, I2cAddress};
|
use esp_hal::i2c::master::{I2c, I2cAddress};
|
||||||
use esp_hal::interrupt::Priority;
|
|
||||||
use esp_hal::interrupt::software::SoftwareInterruptControl;
|
use esp_hal::interrupt::software::SoftwareInterruptControl;
|
||||||
use esp_hal::lcd_cam::LcdCam;
|
use esp_hal::lcd_cam::LcdCam;
|
||||||
use esp_hal::lcd_cam::lcd::dpi::Dpi;
|
use esp_hal::lcd_cam::lcd::dpi::Dpi;
|
||||||
use esp_hal::mcpwm::{McPwm, PeripheralClockConfig};
|
use esp_hal::mcpwm::{McPwm, PeripheralClockConfig};
|
||||||
use esp_hal::peripherals::Peripherals;
|
|
||||||
use esp_hal::psram::{FlashFreq, PsramConfig, PsramSize, SpiRamFreq, SpiTimingConfigCoreClock};
|
use esp_hal::psram::{FlashFreq, PsramConfig, PsramSize, SpiRamFreq, SpiTimingConfigCoreClock};
|
||||||
use esp_hal::rng::TrngSource;
|
use esp_hal::rng::TrngSource;
|
||||||
use esp_hal::system::Stack;
|
use esp_hal::system::Stack;
|
||||||
use esp_hal::time::Instant;
|
use esp_hal::time::Instant;
|
||||||
use esp_hal::timer::timg::TimerGroup;
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
use esp_hal::uart::Uart;
|
|
||||||
use esp_hal::usb_serial_jtag::{UsbSerialJtag, UsbSerialJtagTx};
|
|
||||||
use esp_hal::{Blocking, ram};
|
use esp_hal::{Blocking, ram};
|
||||||
use esp_radio::Controller;
|
use esp_radio::Controller;
|
||||||
use esp_radio::ble::controller::BleConnector;
|
use esp_radio::ble::controller::BleConnector;
|
||||||
use esp_rtos::embassy::{Executor, InterruptExecutor};
|
use esp_rtos::embassy::Executor;
|
||||||
use esp_storage::FlashStorage;
|
use esp_storage::FlashStorage;
|
||||||
use itertools::chain;
|
use log::{LevelFilter, error, info};
|
||||||
use log::{LevelFilter, Log, debug, error, info};
|
|
||||||
use rmk::channel::EVENT_CHANNEL;
|
use rmk::channel::EVENT_CHANNEL;
|
||||||
use rmk::config::{BehaviorConfig, PositionalConfig, RmkConfig, StorageConfig, VialConfig};
|
use rmk::config::{BehaviorConfig, PositionalConfig, RmkConfig, StorageConfig, VialConfig};
|
||||||
use rmk::debounce::default_debouncer::DefaultDebouncer;
|
use rmk::debounce::default_debouncer::DefaultDebouncer;
|
||||||
|
|
@ -53,9 +44,8 @@ use rmk::{join_all};
|
||||||
use rmk::keyboard::Keyboard;
|
use rmk::keyboard::Keyboard;
|
||||||
use rmk::storage::async_flash_wrapper;
|
use rmk::storage::async_flash_wrapper;
|
||||||
use rmk::{initialize_keymap_and_storage, run_devices, run_rmk};
|
use rmk::{initialize_keymap_and_storage, run_devices, run_rmk};
|
||||||
use slint::platform::software_renderer::{Rgb565Pixel, TargetPixel};
|
use slint::platform::software_renderer::Rgb565Pixel;
|
||||||
use slint::{ComponentHandle, PhysicalSize, WindowSize};
|
use slint::{ComponentHandle, PhysicalSize, WindowSize};
|
||||||
use slint::platform::Platform;
|
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
use ui::AppWindow;
|
use ui::AppWindow;
|
||||||
use {esp_alloc as _, esp_backtrace as _};
|
use {esp_alloc as _, esp_backtrace as _};
|
||||||
|
|
@ -70,6 +60,8 @@ mod peripherals;
|
||||||
mod vial;
|
mod vial;
|
||||||
mod ui;
|
mod ui;
|
||||||
mod logging;
|
mod logging;
|
||||||
|
|
||||||
|
#[cfg(feature = "alt-log")]
|
||||||
mod console;
|
mod console;
|
||||||
|
|
||||||
shadow!(build);
|
shadow!(build);
|
||||||
|
|
@ -104,6 +96,8 @@ async fn main(_spawner: Spawner) {
|
||||||
|
|
||||||
#[cfg(feature = "alt-log")]
|
#[cfg(feature = "alt-log")]
|
||||||
let alt_uart_rx_task = {
|
let alt_uart_rx_task = {
|
||||||
|
use esp_hal::uart::Uart;
|
||||||
|
|
||||||
let (uart_rx, uart_tx) = Uart::new(peripherals.UART2, Default::default()).unwrap().with_tx(peripherals.GPIO12).with_rx(peripherals.GPIO5).split();
|
let (uart_rx, uart_tx) = Uart::new(peripherals.UART2, Default::default()).unwrap().with_tx(peripherals.GPIO12).with_rx(peripherals.GPIO5).split();
|
||||||
logging::setup_alternative_logging(uart_tx, LOG_LEVEL_FILTER);
|
logging::setup_alternative_logging(uart_tx, LOG_LEVEL_FILTER);
|
||||||
info!("Logger initialized!");
|
info!("Logger initialized!");
|
||||||
|
|
@ -151,20 +145,23 @@ async fn main(_spawner: Spawner) {
|
||||||
esp_rtos::start(
|
esp_rtos::start(
|
||||||
timg0.timer0, /*, software_interrupt.software_interrupt0 */
|
timg0.timer0, /*, software_interrupt.software_interrupt0 */
|
||||||
);
|
);
|
||||||
// Enable the TRNG source, so `Trng` can be constructed.
|
|
||||||
let _trng_source = TrngSource::new(peripherals.RNG, peripherals.ADC1);
|
|
||||||
let mut rng = esp_hal::rng::Trng::try_new().unwrap();
|
|
||||||
static RADIO: StaticCell<Controller<'static>> = StaticCell::new();
|
|
||||||
let radio = RADIO.init(esp_radio::init().unwrap());
|
|
||||||
let bluetooth = peripherals.BT;
|
|
||||||
let connector = BleConnector::new(radio, bluetooth, Default::default()).unwrap();
|
|
||||||
let controller: ExternalController<_, 20> = ExternalController::new(connector);
|
|
||||||
let central_addr = [0x18, 0xe2, 0x21, 0x80, 0xc0, 0xc7];
|
|
||||||
#[cfg(feature = "ble")]
|
#[cfg(feature = "ble")]
|
||||||
let mut host_resources = rmk::HostResources::new();
|
let mut host_resources = rmk::HostResources::new();
|
||||||
#[cfg(feature = "ble")]
|
#[cfg(feature = "ble")]
|
||||||
let stack =
|
let stack = {
|
||||||
rmk::ble::build_ble_stack(controller, central_addr, &mut rng, &mut host_resources).await;
|
// Enable the TRNG source, so `Trng` can be constructed.
|
||||||
|
let _trng_source = TrngSource::new(peripherals.RNG, peripherals.ADC1);
|
||||||
|
let mut rng = esp_hal::rng::Trng::try_new().unwrap();
|
||||||
|
static RADIO: StaticCell<Controller<'static>> = StaticCell::new();
|
||||||
|
let radio = RADIO.init(esp_radio::init().unwrap());
|
||||||
|
let bluetooth = peripherals.BT;
|
||||||
|
let connector = BleConnector::new(radio, bluetooth, Default::default()).unwrap();
|
||||||
|
let controller: ExternalController<_, 20> = ExternalController::new(connector);
|
||||||
|
let central_addr = [0x18, 0xe2, 0x21, 0x80, 0xc0, 0xc7];
|
||||||
|
|
||||||
|
rmk::ble::build_ble_stack(controller, central_addr, &mut rng, &mut host_resources).await
|
||||||
|
};
|
||||||
|
|
||||||
// Initialize USB
|
// Initialize USB
|
||||||
#[cfg(not(feature = "no-usb"))]
|
#[cfg(not(feature = "no-usb"))]
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ pub async fn spi_write(
|
||||||
cs.set_high();
|
cs.set_high();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[expect(unused)]
|
||||||
pub async fn spi_read(
|
pub async fn spi_read(
|
||||||
command: u8,
|
command: u8,
|
||||||
dummy_cycle: bool,
|
dummy_cycle: bool,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue