mirror of
https://github.com/LegitCamper/picocalc-os-rs.git
synced 2025-12-27 07:45:28 +00:00
fix comp time and rename feature to psram
This commit is contained in:
@@ -11,11 +11,13 @@ doctest = false
|
||||
bench = false
|
||||
|
||||
[features]
|
||||
default = ["rp235x", "defmt", "fps"]
|
||||
pimoroni2w = ["rp235x"]
|
||||
rp2040 = ["embassy-rp/rp2040"]
|
||||
default = ["rp235x", "defmt"]
|
||||
pimoroni2w = ["rp235x", "psram"]
|
||||
# rp2040 = ["embassy-rp/rp2040"] # unsupported, ram too small for fb
|
||||
rp235x = ["embassy-rp/rp235xb"]
|
||||
trouble = ["dep:bt-hci", "dep:cyw43", "dep:cyw43-pio", "dep:trouble-host"]
|
||||
psram = ["dep:embedded-alloc"]
|
||||
fps = []
|
||||
defmt = [
|
||||
"dep:defmt",
|
||||
"panic-probe/print-defmt",
|
||||
@@ -30,7 +32,6 @@ defmt = [
|
||||
# "cyw43/defmt",
|
||||
# "cyw43-pio/defmt",
|
||||
]
|
||||
fps = []
|
||||
|
||||
[dependencies]
|
||||
embassy-executor = { version = "0.9", features = [
|
||||
@@ -79,7 +80,6 @@ st7365p-lcd = { git = "https://github.com/legitcamper/st7365p-lcd-rs", rev = "a7
|
||||
embedded-graphics = { version = "0.8.1" }
|
||||
embedded-text = "0.7.2"
|
||||
embedded-layout = "0.4.2"
|
||||
kolibri-embedded-gui = "0.1.0"
|
||||
|
||||
strum = { version = "0.27.2", default-features = false }
|
||||
rand = { version = "0.9.0", default-features = false }
|
||||
@@ -91,7 +91,9 @@ spin = "0.10.0"
|
||||
num_enum = { version = "0.7.4", default-features = false }
|
||||
goblin = { version = "0.10.1", default-features = false, features = ["elf32"] }
|
||||
talc = "4.4.3"
|
||||
embedded-alloc = { version = "0.6.0", features = ["allocator_api"] }
|
||||
embedded-alloc = { version = "0.6.0", features = [
|
||||
"allocator_api",
|
||||
], optional = true }
|
||||
bumpalo = "3.19.0"
|
||||
|
||||
abi_sys = { path = "../abi_sys" }
|
||||
|
||||
@@ -10,6 +10,9 @@ use embedded_graphics::draw_target::DrawTarget;
|
||||
use embedded_sdmmc::LfnBuffer;
|
||||
use heapless::spsc::Queue;
|
||||
|
||||
#[cfg(feature = "psram")]
|
||||
use crate::heap::HEAP;
|
||||
|
||||
use crate::{
|
||||
display::FRAMEBUFFER,
|
||||
framebuffer::FB_PAUSED,
|
||||
@@ -20,10 +23,14 @@ const _: AllocAbi = alloc;
|
||||
pub extern "C" fn alloc(layout: CLayout) -> *mut u8 {
|
||||
// SAFETY: caller guarantees layout is valid
|
||||
unsafe {
|
||||
if cfg!(feature = "pimoroni2w") {
|
||||
crate::heap::HEAP.alloc(layout.into())
|
||||
} else {
|
||||
alloc::alloc::alloc(layout.into())
|
||||
#[cfg(feature = "psram")]
|
||||
{
|
||||
return HEAP.alloc(layout.into());
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "psram"))]
|
||||
{
|
||||
return alloc::alloc::alloc(layout.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,12 +38,14 @@ pub extern "C" fn alloc(layout: CLayout) -> *mut u8 {
|
||||
const _: DeallocAbi = dealloc;
|
||||
pub extern "C" fn dealloc(ptr: *mut u8, layout: CLayout) {
|
||||
// SAFETY: caller guarantees ptr and layout are valid
|
||||
unsafe {
|
||||
if cfg!(feature = "pimoroni2w") {
|
||||
crate::heap::HEAP.dealloc(ptr, layout.into())
|
||||
} else {
|
||||
alloc::alloc::dealloc(ptr, layout.into())
|
||||
}
|
||||
#[cfg(feature = "psram")]
|
||||
{
|
||||
unsafe { HEAP.dealloc(ptr, layout.into()) }
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "psram"))]
|
||||
{
|
||||
unsafe { alloc::alloc::dealloc(ptr, layout.into()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ use embedded_graphics::{
|
||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||
use st7365p_lcd::ST7365P;
|
||||
|
||||
#[cfg(feature = "psram")]
|
||||
use crate::heap::HEAP;
|
||||
|
||||
#[cfg(feature = "fps")]
|
||||
pub use framebuffer::fps::{FPS_CANVAS, FPS_COUNTER};
|
||||
|
||||
@@ -32,18 +35,21 @@ pub static mut FRAMEBUFFER: Option<AtomicFrameBuffer> = None;
|
||||
|
||||
fn init_fb() {
|
||||
unsafe {
|
||||
FRAMEBUFFER = Some(if cfg!(not(feature = "pimoroni2w")) {
|
||||
static mut BUF: [u16; framebuffer::SIZE] = [0; framebuffer::SIZE];
|
||||
AtomicFrameBuffer::new(&mut BUF)
|
||||
} else {
|
||||
let slab = crate::heap::HEAP.alloc(Layout::array::<u16>(framebuffer::SIZE).unwrap())
|
||||
as *mut u16;
|
||||
#[cfg(feature = "psram")]
|
||||
{
|
||||
let slab = HEAP.alloc(Layout::array::<u16>(framebuffer::SIZE).unwrap()) as *mut u16;
|
||||
let buf = core::slice::from_raw_parts_mut(slab, framebuffer::SIZE);
|
||||
|
||||
let mut fb = AtomicFrameBuffer::new(buf);
|
||||
fb.clear(Rgb565::BLACK).unwrap();
|
||||
fb
|
||||
});
|
||||
FRAMEBUFFER = Some(fb);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "psram"))]
|
||||
{
|
||||
static mut BUF: [u16; framebuffer::SIZE] = [0; framebuffer::SIZE];
|
||||
FRAMEBUFFER = Some(AtomicFrameBuffer::new(&mut BUF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,29 +12,30 @@ mod abi;
|
||||
mod display;
|
||||
mod elf;
|
||||
mod framebuffer;
|
||||
#[allow(unused)]
|
||||
mod heap;
|
||||
mod peripherals;
|
||||
#[allow(unused)]
|
||||
mod psram;
|
||||
mod scsi;
|
||||
mod storage;
|
||||
mod ui;
|
||||
mod usb;
|
||||
mod utils;
|
||||
|
||||
#[cfg(feature = "pimoroni2w")]
|
||||
use crate::{heap::init_qmi_psram_heap, psram::init_psram_qmi};
|
||||
#[cfg(feature = "psram")]
|
||||
#[allow(unused)]
|
||||
mod heap;
|
||||
#[cfg(feature = "psram")]
|
||||
#[allow(unused)]
|
||||
mod psram;
|
||||
|
||||
#[cfg(feature = "psram")]
|
||||
use crate::{heap::HEAP, heap::init_qmi_psram_heap, psram::init_psram, psram::init_psram_qmi};
|
||||
|
||||
use crate::{
|
||||
abi::{KEY_CACHE, MS_SINCE_LAUNCH},
|
||||
display::{FRAMEBUFFER, display_handler, init_display},
|
||||
heap::HEAP,
|
||||
peripherals::{
|
||||
conf_peripherals,
|
||||
keyboard::{KeyState, read_keyboard_fifo},
|
||||
},
|
||||
psram::init_psram,
|
||||
scsi::MSC_SHUTDOWN,
|
||||
storage::{SDCARD, SdCard},
|
||||
ui::{SELECTIONS, clear_selection, ui_handler},
|
||||
@@ -270,22 +271,22 @@ async fn setup_display(display: Display, spawner: Spawner) {
|
||||
|
||||
// psram is kind of useless on the pico calc
|
||||
// ive opted to use the pimoroni with on onboard xip psram instead
|
||||
async fn setup_psram(psram: Psram) {
|
||||
let psram = init_psram(
|
||||
psram.pio, psram.sclk, psram.mosi, psram.miso, psram.cs, psram.dma1, psram.dma2,
|
||||
)
|
||||
.await;
|
||||
// async fn setup_psram(psram: Psram) {
|
||||
// let psram = init_psram(
|
||||
// psram.pio, psram.sclk, psram.mosi, psram.miso, psram.cs, psram.dma1, psram.dma2,
|
||||
// )
|
||||
// .await;
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::info!("psram size: {}", psram.size);
|
||||
// #[cfg(feature = "defmt")]
|
||||
// defmt::info!("psram size: {}", psram.size);
|
||||
|
||||
if psram.size == 0 {
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::info!("\u{1b}[1mExternal PSRAM was NOT found!\u{1b}[0m");
|
||||
}
|
||||
}
|
||||
// if psram.size == 0 {
|
||||
// #[cfg(feature = "defmt")]
|
||||
// defmt::info!("\u{1b}[1mExternal PSRAM was NOT found!\u{1b}[0m");
|
||||
// }
|
||||
// }
|
||||
|
||||
#[cfg(feature = "pimoroni2w")]
|
||||
#[cfg(feature = "psram")]
|
||||
async fn setup_qmi_psram() {
|
||||
Timer::after_millis(250).await;
|
||||
let psram_qmi_size = init_psram_qmi(&embassy_rp::pac::QMI, &embassy_rp::pac::XIP_CTRL);
|
||||
@@ -322,7 +323,7 @@ async fn kernel_task(
|
||||
watchdog: Peri<'static, WATCHDOG>,
|
||||
display: Display,
|
||||
sd: Sd,
|
||||
psram: Psram,
|
||||
_psram: Psram,
|
||||
mcu: Mcu,
|
||||
usb: Peri<'static, USB>,
|
||||
) {
|
||||
@@ -337,7 +338,7 @@ async fn kernel_task(
|
||||
Timer::after_millis(100).await;
|
||||
|
||||
// setup_psram(psram).await;
|
||||
#[cfg(feature = "pimoroni2w")]
|
||||
#[cfg(feature = "psram")]
|
||||
setup_qmi_psram().await;
|
||||
|
||||
Timer::after_millis(100).await;
|
||||
|
||||
Reference in New Issue
Block a user