cargo fix

This commit is contained in:
2025-09-18 16:44:18 -06:00
parent 46c69ead67
commit fab10dfa1f
10 changed files with 43 additions and 51 deletions

5
.helix/languages.toml Normal file
View File

@@ -0,0 +1,5 @@
[[language]]
name = "rust"
[language-server.rust-analyzer.config.check]
allTargets = false

View File

@@ -1,15 +1,14 @@
#![no_std] #![no_std]
extern crate alloc; extern crate alloc;
use alloc::boxed::Box;
use core::pin::Pin; #[allow(unused)]
pub use embedded_graphics::{ use embedded_graphics::{
Pixel, Pixel,
geometry::Point, geometry::Point,
pixelcolor::{Rgb565, RgbColor}, pixelcolor::{Rgb565, RgbColor},
}; };
use shared::keyboard::{KeyCode, KeyEvent, KeyState, Modifiers}; pub use shared::keyboard::{KeyCode, KeyEvent, KeyState, Modifiers};
pub type EntryFn = fn(); pub type EntryFn = fn();
@@ -32,6 +31,7 @@ impl CallAbiTable {
pub type PrintAbi = extern "Rust" fn(msg: &str); pub type PrintAbi = extern "Rust" fn(msg: &str);
#[allow(unused)]
pub fn print(msg: &str) { pub fn print(msg: &str) {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallAbiTable::Print as usize]; let ptr = CALL_ABI_TABLE[CallAbiTable::Print as usize];
@@ -42,6 +42,7 @@ pub fn print(msg: &str) {
pub type SleepAbi = extern "Rust" fn(ms: u64); pub type SleepAbi = extern "Rust" fn(ms: u64);
#[allow(unused)]
pub fn sleep(ms: u64) { pub fn sleep(ms: u64) {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallAbiTable::Sleep as usize]; let ptr = CALL_ABI_TABLE[CallAbiTable::Sleep as usize];
@@ -52,6 +53,7 @@ pub fn sleep(ms: u64) {
pub type DrawIterAbi = extern "Rust" fn(pixels: &[Pixel<Rgb565>]); pub type DrawIterAbi = extern "Rust" fn(pixels: &[Pixel<Rgb565>]);
#[allow(unused)]
pub fn draw_iter(pixels: &[Pixel<Rgb565>]) { pub fn draw_iter(pixels: &[Pixel<Rgb565>]) {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallAbiTable::DrawIter as usize]; let ptr = CALL_ABI_TABLE[CallAbiTable::DrawIter as usize];
@@ -62,6 +64,7 @@ pub fn draw_iter(pixels: &[Pixel<Rgb565>]) {
pub type GetKeyAbi = extern "Rust" fn() -> Option<KeyEvent>; pub type GetKeyAbi = extern "Rust" fn() -> Option<KeyEvent>;
#[allow(unused)]
pub fn get_key() -> Option<KeyEvent> { pub fn get_key() -> Option<KeyEvent> {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallAbiTable::GetKey as usize]; let ptr = CALL_ABI_TABLE[CallAbiTable::GetKey as usize];

View File

@@ -1,18 +1,6 @@
use core::{pin::Pin, time::Duration}; use abi_sys::{DrawIterAbi, GetKeyAbi, PrintAbi, SleepAbi};
use abi_sys::{DrawIterAbi, GetKeyAbi, Pixel, PrintAbi, SleepAbi};
use alloc::boxed::Box;
use defmt::info;
use embassy_futures::block_on;
use embassy_rp::clocks::clk_sys_freq; use embassy_rp::clocks::clk_sys_freq;
use embassy_time::Timer; use embedded_graphics::{Pixel, draw_target::DrawTarget, pixelcolor::Rgb565};
use embedded_graphics::{
Drawable,
draw_target::DrawTarget,
pixelcolor::Rgb565,
prelude::{Point, RgbColor, Size},
primitives::{PrimitiveStyle, Rectangle, StyledDrawable},
};
use shared::keyboard::KeyEvent; use shared::keyboard::KeyEvent;
use crate::{KEY_CACHE, display::FRAMEBUFFER}; use crate::{KEY_CACHE, display::FRAMEBUFFER};

View File

@@ -28,7 +28,7 @@ pub async unsafe fn load_binary(name: &ShortFileName) -> Result<EntryFn, &str> {
let mut sd_lock = SDCARD.get().lock().await; let mut sd_lock = SDCARD.get().lock().await;
let sd = sd_lock.as_mut().unwrap(); let sd = sd_lock.as_mut().unwrap();
let mut error = ""; let error = "";
let mut entry = 0; let mut entry = 0;
let mut header_buf = [0; ELF32_HDR_SIZE]; let mut header_buf = [0; ELF32_HDR_SIZE];

View File

@@ -13,7 +13,7 @@ use embedded_graphics::{
use embedded_hal_2::digital::OutputPin; use embedded_hal_2::digital::OutputPin;
use embedded_hal_async::{delay::DelayNs, spi::SpiDevice}; use embedded_hal_async::{delay::DelayNs, spi::SpiDevice};
use heapless::Vec; use heapless::Vec;
use st7365p_lcd::{FrameBuffer, ST7365P}; use st7365p_lcd::ST7365P;
pub const TILE_SIZE: usize = 16; // 16x16 tile pub const TILE_SIZE: usize = 16; // 16x16 tile
pub const TILE_COUNT: usize = (SCREEN_WIDTH / TILE_SIZE) * (SCREEN_HEIGHT / TILE_SIZE); // 400 tiles pub const TILE_COUNT: usize = (SCREEN_WIDTH / TILE_SIZE) * (SCREEN_HEIGHT / TILE_SIZE); // 400 tiles

View File

@@ -21,7 +21,7 @@ mod utils;
use core::sync::atomic::{AtomicBool, Ordering}; use core::sync::atomic::{AtomicBool, Ordering};
use crate::{ use crate::{
display::{FRAMEBUFFER, clear_fb, display_handler, init_display}, display::{FRAMEBUFFER, display_handler, init_display},
peripherals::{ peripherals::{
conf_peripherals, conf_peripherals,
keyboard::{KeyState, read_keyboard_fifo}, keyboard::{KeyState, read_keyboard_fifo},
@@ -29,20 +29,18 @@ use crate::{
scsi::MSC_SHUTDOWN, scsi::MSC_SHUTDOWN,
storage::{SDCARD, SdCard}, storage::{SDCARD, SdCard},
ui::{SELECTIONS, clear_selection, ui_handler}, ui::{SELECTIONS, clear_selection, ui_handler},
usb::usb_handler,
}; };
use abi_sys::{EntryFn, Rgb565, RgbColor}; use abi_sys::EntryFn;
use embedded_graphics::prelude::DrawTarget; use embedded_graphics::{
pixelcolor::Rgb565,
prelude::{DrawTarget, RgbColor},
};
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
use defmt::unwrap; use defmt::unwrap;
use embassy_executor::{Executor, Spawner}; use embassy_executor::{Executor, Spawner};
use embassy_futures::{ use embassy_futures::{join::join, select::select};
join::{join, join3, join5},
select::select,
yield_now,
};
use embassy_rp::{ use embassy_rp::{
Peri, Peri,
gpio::{Input, Level, Output, Pull}, gpio::{Input, Level, Output, Pull},
@@ -56,7 +54,7 @@ use embassy_rp::{
usb as embassy_rp_usb, usb as embassy_rp_usb,
}; };
use embassy_sync::{ use embassy_sync::{
blocking_mutex::raw::CriticalSectionRawMutex, channel::Channel, mutex::Mutex, signal::Signal, blocking_mutex::raw::CriticalSectionRawMutex, channel::Channel, signal::Signal,
}; };
use embassy_time::{Delay, Timer}; use embassy_time::{Delay, Timer};
use embedded_hal_bus::spi::ExclusiveDevice; use embedded_hal_bus::spi::ExclusiveDevice;
@@ -86,7 +84,7 @@ static ENABLE_UI: AtomicBool = AtomicBool::new(true);
static UI_CHANGE: Signal<CriticalSectionRawMutex, ()> = Signal::new(); static UI_CHANGE: Signal<CriticalSectionRawMutex, ()> = Signal::new();
#[embassy_executor::main] #[embassy_executor::main]
async fn main(spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default()); let p = embassy_rp::init(Default::default());
spawn_core1( spawn_core1(
@@ -239,7 +237,7 @@ async fn kernel_task(
setup_display(display, spawner).await; setup_display(display, spawner).await;
setup_sd(sd).await; setup_sd(sd).await;
let usb = embassy_rp_usb::Driver::new(usb, Irqs); let _usb = embassy_rp_usb::Driver::new(usb, Irqs);
// spawner.spawn(usb_handler(usb)).unwrap(); // spawner.spawn(usb_handler(usb)).unwrap();
loop { loop {

View File

@@ -1,5 +1,3 @@
use core::sync::atomic::AtomicBool;
use embassy_futures::select::select; use embassy_futures::select::select;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::lazy_lock::LazyLock; use embassy_sync::lazy_lock::LazyLock;
@@ -25,7 +23,7 @@ static mut BLOCK_BUF: LazyLock<[Block; BLOCKS]> =
LazyLock::new(|| core::array::from_fn(|_| Block::new())); LazyLock::new(|| core::array::from_fn(|_| Block::new()));
pub struct MassStorageClass<'d, D: Driver<'d>> { pub struct MassStorageClass<'d, D: Driver<'d>> {
temp_sd: Option<SdCard>, // temporarly owns sdcard when scsi is running temp_sd: Option<SdCard>, // temporary owns sdcard when scsi is running
ejected: bool, ejected: bool,
pending_eject: bool, pending_eject: bool,
bulk_out: D::EndpointOut, bulk_out: D::EndpointOut,
@@ -192,12 +190,15 @@ impl<'d, 's, D: Driver<'d>> MassStorageClass<'d, D> {
Err(()) Err(())
} }
} }
ScsiCommand::RequestSense { desc, alloc_len } => Ok(()), ScsiCommand::RequestSense {
desc: _,
alloc_len: _,
} => Ok(()),
ScsiCommand::ModeSense6 { ScsiCommand::ModeSense6 {
dbd, dbd: _,
page_control, page_control: _,
page_code, page_code: _,
subpage_code, subpage_code: _,
alloc_len, alloc_len,
} => { } => {
// DBD=0, no block descriptors; total length = 4 // DBD=0, no block descriptors; total length = 4
@@ -213,10 +214,10 @@ impl<'d, 's, D: Driver<'d>> MassStorageClass<'d, D> {
self.bulk_in.write(&response[..len]).await.map_err(|_| ()) self.bulk_in.write(&response[..len]).await.map_err(|_| ())
} }
ScsiCommand::ModeSense10 { ScsiCommand::ModeSense10 {
dbd, dbd: _,
page_control, page_control: _,
page_code, page_code: _,
subpage_code, subpage_code: _,
alloc_len, alloc_len,
} => { } => {
let response = [ let response = [
@@ -377,6 +378,7 @@ impl<'d, 's, D: Driver<'d>> MassStorageClass<'d, D> {
} }
#[repr(C, packed)] #[repr(C, packed)]
#[allow(non_snake_case)]
struct CommandBlockWrapper { struct CommandBlockWrapper {
dCBWSignature: u32, dCBWSignature: u32,
dCBWTag: u32, dCBWTag: u32,
@@ -387,6 +389,7 @@ struct CommandBlockWrapper {
CBWCB: [u8; 16], CBWCB: [u8; 16],
} }
#[allow(non_snake_case)]
impl CommandBlockWrapper { impl CommandBlockWrapper {
fn parse(buf: &[u8]) -> Option<Self> { fn parse(buf: &[u8]) -> Option<Self> {
if buf.len() < 31 { if buf.len() < 31 {

View File

@@ -1,10 +1,5 @@
use num_enum::TryFromPrimitive; use num_enum::TryFromPrimitive;
#[derive(Debug, Clone, Copy)]
pub enum ScsiError {
NotReady,
}
/// THE CODE BELOW ORIGINATES FROM: https://github.com/apohrebniak/usbd-storage/blob/master/usbd-storage/src/subclass/scsi.rs /// THE CODE BELOW ORIGINATES FROM: https://github.com/apohrebniak/usbd-storage/blob/master/usbd-storage/src/subclass/scsi.rs
/// SCSI device subclass code /// SCSI device subclass code

View File

@@ -101,7 +101,7 @@ impl SdCard {
pub fn write_blocks(&self, blocks: &mut [Block], start_block_idx: BlockIdx) -> Result<(), ()> { pub fn write_blocks(&self, blocks: &mut [Block], start_block_idx: BlockIdx) -> Result<(), ()> {
let mut res: Result<(), Error> = Ok(()); let mut res: Result<(), Error> = Ok(());
self.volume_mgr.device(|sd| { self.volume_mgr.device(|sd| {
let res = sd.write(blocks, start_block_idx); res = sd.write(blocks, start_block_idx);
DummyTimeSource {} DummyTimeSource {}
}); });
res.map_err(|_| ()) res.map_err(|_| ())

View File

@@ -1,6 +1,6 @@
use crate::{scsi::MassStorageClass, storage::SdCard}; use crate::{scsi::MassStorageClass, storage::SdCard};
use core::sync::atomic::{AtomicBool, Ordering}; use core::sync::atomic::{AtomicBool, Ordering};
use embassy_futures::{join::join, select::select}; use embassy_futures::select::select;
use embassy_rp::{peripherals::USB, usb::Driver}; use embassy_rp::{peripherals::USB, usb::Driver};
use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb::{Builder, Config, UsbDevice};