switch to rp2350

This commit is contained in:
sawyer committed 2025-06-24 19:02:33 -06:00
1 parent 3392dec944
commit f8325a7750
9 files changed
+207 -1213

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
use embassy_rp::{
gpio::{Level, Output},
peripherals::{PIN_13, PIN_14, PIN_15, SPI1},
spi::{Blocking, Spi},
};
use embassy_time::Delay;
use embedded_graphics::{
Drawable,
pixelcolor::{BinaryColor, Rgb555, Rgb565},
prelude::{Point, Primitive, RgbColor},
primitives::{PrimitiveStyle, Triangle},
};
use embedded_hal_bus::spi::ExclusiveDevice;
use st7365p_lcd::ST7365P;
#[embassy_executor::task]
pub async fn display_task(
spi: Spi<'static, SPI1, Blocking>,
cs: PIN_13,
data: PIN_14,
reset: PIN_15,
) {
let spi_device = ExclusiveDevice::new(spi, Output::new(cs, Level::Low), Delay).unwrap();
let mut display = ST7365P::new(
spi_device,
Output::new(data, Level::Low),
Some(Output::new(reset, Level::High)),
true,
false,
320,
320,
);
let thin_stroke = PrimitiveStyle::with_stroke(Rgb565::RED, 1);
let yoffset = 10;
// Draw a triangle.
Triangle::new(
Point::new(16, 16 + yoffset),
Point::new(16 + 16, 16 + yoffset),
Point::new(16 + 8, yoffset),
)
.into_styled(thin_stroke)
.draw(&mut display)
.unwrap();
}
+26 -6
View File
@@ -7,10 +7,15 @@ use defmt::*;
use {defmt_rtt as _, panic_probe as _};
use embassy_executor::Spawner;
use embassy_rp::gpio::{Level, Output};
use embassy_rp::peripherals::I2C1;
use embassy_rp::spi::{self, Spi};
use embassy_rp::{bind_interrupts, i2c};
use embassy_rp::spi::Spi;
use embassy_rp::{
bind_interrupts,
gpio::{Level, Output},
i2c,
i2c::I2c,
spi,
};
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_sync::channel::Channel;
use embassy_time::Timer;
@@ -20,6 +25,8 @@ use static_cell::StaticCell;
mod peripherals;
use peripherals::{keyboard::KeyEvent, peripherals_task};
mod display;
use display::display_task;
embassy_rp::bind_interrupts!(struct Irqs {
I2C1_IRQ => i2c::InterruptHandler<I2C1>;
@@ -32,10 +39,23 @@ async fn main(spawner: Spawner) {
static KEYBOARD_EVENTS: StaticCell<Channel<NoopRawMutex, KeyEvent, 10>> = StaticCell::new();
let keyboard_events = KEYBOARD_EVENTS.init(Channel::new());
loop {
info!("im alive");
Timer::after_secs(1).await;
}
// configure keyboard event handler
let config = embassy_rp::i2c::Config::default();
let bus = embassy_rp::i2c::I2c::new_async(p.I2C1, p.PIN_27, p.PIN_26, Irqs, config);
let config = i2c::Config::default();
let i2c1 = I2c::new_async(p.I2C1, p.PIN_7, p.PIN_6, Irqs, config);
spawner
.spawn(peripherals_task(bus, keyboard_events.sender()))
.spawn(peripherals_task(i2c1, keyboard_events.sender()))
.unwrap();
// configure display handler
let mut config = spi::Config::default();
config.frequency = 10_000_000;
let spi1 = spi::Spi::new_blocking(p.SPI1, p.PIN_10, p.PIN_11, p.PIN_12, config);
spawner
.spawn(display_task(spi1, p.PIN_13, p.PIN_14, p.PIN_15))
.unwrap();
}
+1 -1
View File
@@ -1,4 +1,4 @@
//! handles polling keyboard events and battery levels from mcu over i2c1
//! handles all the peripherals exposed by mcu through i2c (keyboard & battery registers)
//!
use embassy_futures::join::join;