Compare commits
2 Commits
58b4bc4004
...
5a38ef7f78
| Author | SHA1 | Date | |
|---|---|---|---|
|
5a38ef7f78
|
|||
|
ae599f587a
|
@ -31,7 +31,6 @@ pub mod keys;
|
|||||||
pub mod layer;
|
pub mod layer;
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
pub mod logger;
|
pub mod logger;
|
||||||
pub mod neopixel;
|
|
||||||
pub mod rgb;
|
pub mod rgb;
|
||||||
pub mod rtt;
|
pub mod rtt;
|
||||||
pub mod serial_proto;
|
pub mod serial_proto;
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
.program ws2812
|
|
||||||
.side_set 1
|
|
||||||
.wrap_target
|
|
||||||
bitloop:
|
|
||||||
out x 1 side 0 [6]; Drive low. Side-set still takes place before instruction stalls.
|
|
||||||
jmp !x do_zero side 1 [3]; Branch on the bit we shifted out previous delay. Drive high.
|
|
||||||
do_one:
|
|
||||||
jmp bitloop side 1 [4]; Continue driving high, for a one (long pulse)
|
|
||||||
do_zero:
|
|
||||||
nop side 0 [4]; Or drive low, for a zero (short pulse)
|
|
||||||
.wrap
|
|
||||||
@ -1,122 +0,0 @@
|
|||||||
/*
|
|
||||||
use embassy_rp::{
|
|
||||||
gpio::{AnyPin, Drive, SlewRate},
|
|
||||||
peripherals::{DMA_CH0, PIO0},
|
|
||||||
pio::{FifoJoin, PioPeripheral, PioStateMachine, ShiftDirection},
|
|
||||||
pio_instr_util,
|
|
||||||
relocate::RelocatedProgram,
|
|
||||||
PeripheralRef,
|
|
||||||
};
|
|
||||||
use embassy_time::{Duration, Timer};
|
|
||||||
|
|
||||||
#[embassy_executor::task]
|
|
||||||
pub async fn test(pio: PIO0, pin: AnyPin, dma: DMA_CH0) {
|
|
||||||
let (_common, mut sm, ..) = pio.split();
|
|
||||||
let mut dma = PeripheralRef::new(dma);
|
|
||||||
|
|
||||||
let pio_program = pio_proc::pio_file!("src/neopixel.pio");
|
|
||||||
|
|
||||||
let relocated = RelocatedProgram::new(&pio_program.program);
|
|
||||||
sm.write_instr(relocated.origin() as usize, relocated.code());
|
|
||||||
pio_instr_util::exec_jmp(&mut sm, relocated.origin());
|
|
||||||
|
|
||||||
let pin = sm.make_pio_pin(pin);
|
|
||||||
sm.set_set_pins(&[&pin]);
|
|
||||||
sm.set_sideset_base_pin(&pin);
|
|
||||||
sm.set_sideset_count(1);
|
|
||||||
|
|
||||||
// Clock config
|
|
||||||
// TODO CLOCK_FREQ should come from embassy_rp
|
|
||||||
const CLOCK_FREQ: u32 = 125_000_000;
|
|
||||||
const WS2812_FREQ: u32 = 800_000;
|
|
||||||
const CYCLES_PER_BIT: u32 = 16;
|
|
||||||
|
|
||||||
let bit_freq = WS2812_FREQ * CYCLES_PER_BIT;
|
|
||||||
let mut int = CLOCK_FREQ / bit_freq;
|
|
||||||
let rem = CLOCK_FREQ - (int * bit_freq);
|
|
||||||
let frac = (rem * 256) / bit_freq;
|
|
||||||
// 65536.0 is represented as 0 in the pio's clock divider
|
|
||||||
if int == 65536 {
|
|
||||||
int = 0;
|
|
||||||
}
|
|
||||||
sm.set_clkdiv((int << 8) | frac);
|
|
||||||
let pio::Wrap { source, target } = relocated.wrap();
|
|
||||||
sm.set_wrap(source, target);
|
|
||||||
|
|
||||||
sm.set_autopull(true);
|
|
||||||
sm.set_fifo_join(FifoJoin::TxOnly);
|
|
||||||
sm.set_pull_threshold(8); // 24?
|
|
||||||
sm.set_out_shift_dir(ShiftDirection::Left);
|
|
||||||
|
|
||||||
sm.set_enable(true);
|
|
||||||
|
|
||||||
log::info!("wrap: {:?}", sm.get_wrap());
|
|
||||||
log::info!("addr: {:?}", sm.get_addr());
|
|
||||||
log::info!("sideset_base: {:?}", sm.get_sideset_base());
|
|
||||||
log::info!("sideset_count: {:?}", sm.get_sideset_count());
|
|
||||||
log::info!("in_base: {:?}", sm.get_in_base());
|
|
||||||
log::info!("jmp_pin: {:?}", sm.get_jmp_pin());
|
|
||||||
log::info!("set_range: {:?}", sm.get_set_range());
|
|
||||||
log::info!("out_range: {:?}", sm.get_out_range());
|
|
||||||
log::info!("pull_threshold: {:?}", sm.get_pull_threshold());
|
|
||||||
log::info!("push_threshold: {:?}", sm.get_push_threshold());
|
|
||||||
|
|
||||||
//sm = rp2pio.StateMachine(
|
|
||||||
// assembled,
|
|
||||||
// frequency=12_800_000, # to get appropriate sub-bit times in PIO program
|
|
||||||
// first_sideset_pin=NEOPIXEL,
|
|
||||||
// auto_pull=True,
|
|
||||||
// out_shift_right=False,
|
|
||||||
// pull_threshold=8,
|
|
||||||
//)
|
|
||||||
|
|
||||||
loop {
|
|
||||||
log::info!("sending dma");
|
|
||||||
|
|
||||||
sm.dma_push(dma.reborrow(), &[0x0a, 0x00, 0x00]).await;
|
|
||||||
Timer::after(Duration::from_millis(500)).await;
|
|
||||||
sm.dma_push(dma.reborrow(), &[0x00, 0x0a, 0x00]).await;
|
|
||||||
Timer::after(Duration::from_millis(500)).await;
|
|
||||||
sm.dma_push(dma.reborrow(), &[0x00, 0x00, 0x0a]).await;
|
|
||||||
Timer::after(Duration::from_millis(500)).await;
|
|
||||||
|
|
||||||
//sm0.set_enable(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[embassy_executor::task]
|
|
||||||
pub async fn test_blink(pio: PIO0, pin: AnyPin) {
|
|
||||||
log::info!("test blink hehe");
|
|
||||||
let (_, mut sm, ..) = pio.split();
|
|
||||||
// Setup sm2
|
|
||||||
|
|
||||||
// blink
|
|
||||||
let prg = pio_proc::pio_file!("src/blink.pio");
|
|
||||||
|
|
||||||
let relocated = RelocatedProgram::new(&prg.program);
|
|
||||||
let out_pin = sm.make_pio_pin(pin);
|
|
||||||
let pio_pins = [&out_pin];
|
|
||||||
sm.set_set_pins(&pio_pins);
|
|
||||||
sm.set_set_range(25, 1);
|
|
||||||
|
|
||||||
sm.write_instr(relocated.origin() as usize, relocated.code());
|
|
||||||
pio_instr_util::exec_jmp(&mut sm, relocated.origin());
|
|
||||||
// sm.set_clkdiv((65535 << 8) + 255 as u32);
|
|
||||||
// sm.set_clkdiv(0);
|
|
||||||
|
|
||||||
let pio::Wrap { source, target } = relocated.wrap();
|
|
||||||
sm.set_wrap(source, target);
|
|
||||||
|
|
||||||
// sm.set_clkdiv((125e6 / 20.0 / 2e2 * 256.0) as u32);
|
|
||||||
sm.set_enable(true);
|
|
||||||
// sm.wait_push().await as i32;
|
|
||||||
// sm.push_tx(1);
|
|
||||||
sm.wait_push(125_000_000).await;
|
|
||||||
log::info!("started");
|
|
||||||
|
|
||||||
loop {
|
|
||||||
sm.wait_irq(3).await;
|
|
||||||
log::info!("did it!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
.program ws2812
|
|
||||||
.origin 0
|
|
||||||
.wrap_target
|
|
||||||
out x 1
|
|
||||||
set pins,1 [1]
|
|
||||||
mov pins,x [1]
|
|
||||||
set pins,0
|
|
||||||
.wrap
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
use core::{
|
use core::{
|
||||||
cell::UnsafeCell,
|
cell::UnsafeCell,
|
||||||
fmt::{self, Debug, Display, Write},
|
fmt::{self, Debug, Display, Write},
|
||||||
iter,
|
|
||||||
mem::MaybeUninit,
|
mem::MaybeUninit,
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
};
|
};
|
||||||
@ -169,11 +168,12 @@ pub fn display_len(t: &impl Display) -> usize {
|
|||||||
pub struct DisplayPack<T>(pub T);
|
pub struct DisplayPack<T>(pub T);
|
||||||
impl<T: Display> MsgPack for DisplayPack<T> {
|
impl<T: Display> MsgPack for DisplayPack<T> {
|
||||||
fn pack(&self) -> impl Iterator<Item = msgpck::Piece<'_>> {
|
fn pack(&self) -> impl Iterator<Item = msgpck::Piece<'_>> {
|
||||||
let len = display_len(&self.0) as u32;
|
"TODO".pack()
|
||||||
|
//let len = display_len(&self.0) as u32;
|
||||||
|
|
||||||
[msgpck::Marker::Str32.into(), len.into()]
|
//[msgpck::Marker::Str32.into(), len.into()]
|
||||||
.into_iter()
|
// .into_iter()
|
||||||
.chain(iter::from_fn(move || None)) // TODO
|
// .chain(iter::from_fn(move || None)) // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pack_with_writer(&self, w: &mut dyn msgpck::Write) -> Result<usize, PackErr> {
|
fn pack_with_writer(&self, w: &mut dyn msgpck::Write) -> Result<usize, PackErr> {
|
||||||
|
|||||||
@ -43,8 +43,6 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
neopixel.write(&[Rgb::new(0xFF, 0x00, 0x00)]).await;
|
neopixel.write(&[Rgb::new(0xFF, 0x00, 0x00)]).await;
|
||||||
|
|
||||||
//Timer::after(Duration::from_millis(3000)).await;
|
|
||||||
|
|
||||||
let layers = include_bytes!("layers.pc");
|
let layers = include_bytes!("layers.pc");
|
||||||
let Ok(layers): Result<Vec<Vec<Layer>>, _> = postcard::from_bytes(layers) else {
|
let Ok(layers): Result<Vec<Vec<Layer>>, _> = postcard::from_bytes(layers) else {
|
||||||
log::error!("Failed to deserialize layer config");
|
log::error!("Failed to deserialize layer config");
|
||||||
@ -54,7 +52,6 @@ async fn main(_spawner: Spawner) {
|
|||||||
let keyboard = KeyboardConfig {
|
let keyboard = KeyboardConfig {
|
||||||
half,
|
half,
|
||||||
pins: [
|
pins: [
|
||||||
// TODO: reconfigure these for right PCB
|
|
||||||
// row 1
|
// row 1
|
||||||
board.d12.degrade(),
|
board.d12.degrade(),
|
||||||
board.d11.degrade(),
|
board.d11.degrade(),
|
||||||
|
|||||||
Reference in New Issue
Block a user