├── .gitignore ├── rp2040-kbd ├── src │ ├── hid.rs │ ├── runtime │ │ ├── locks.rs │ │ ├── shared.rs │ │ ├── shared │ │ │ ├── press_latency_counter.rs │ │ │ ├── sleep.rs │ │ │ ├── loop_counter.rs │ │ │ ├── cores_right.rs │ │ │ ├── cores_left.rs │ │ │ └── usb.rs │ │ ├── right.rs │ │ └── left.rs │ ├── runtime.rs │ ├── timer.rs │ ├── keyboard │ │ ├── left │ │ │ └── message_receiver.rs │ │ ├── right │ │ │ └── message_serializer.rs │ │ ├── power_led.rs │ │ ├── left.rs │ │ ├── debounce.rs │ │ ├── usb_serial.rs │ │ ├── split_serial.rs │ │ ├── oled.rs │ │ ├── oled │ │ │ ├── right.rs │ │ │ └── left.rs │ │ └── right.rs │ ├── keyboard.rs │ ├── hid │ │ └── usb_hiddev.rs │ └── main.rs └── Cargo.toml ├── rp2040-kbd-lib ├── src │ ├── lib.rs │ ├── matrix.rs │ ├── queue.rs │ └── keycodes.rs └── Cargo.toml ├── .local ├── lint.sh ├── build_all.sh └── build.sh ├── memory.x ├── Todo.md ├── Readme.md ├── deny.toml ├── Cargo.toml ├── .cargo └── config.toml ├── LICENSE └── Cargo.lock /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | *.iml 3 | /target -------------------------------------------------------------------------------- /rp2040-kbd/src/hid.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "hiddev")] 2 | pub mod usb_hiddev; 3 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/locks.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "serial")] 2 | pub type UsbLock = rp2040_hal::sio::Spinlock15; 3 | -------------------------------------------------------------------------------- /rp2040-kbd-lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(not(test), no_std)] 2 | pub mod keycodes; 3 | pub mod matrix; 4 | pub mod queue; 5 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "left")] 2 | pub mod left; 3 | mod locks; 4 | #[cfg(feature = "right")] 5 | pub mod right; 6 | pub(crate) mod shared; 7 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/shared.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "left")] 2 | pub mod cores_left; 3 | #[cfg(feature = "right")] 4 | pub mod cores_right; 5 | pub mod loop_counter; 6 | pub mod sleep; 7 | 8 | pub mod press_latency_counter; 9 | 10 | #[cfg(any(feature = "left", feature = "serial"))] 11 | pub mod usb; 12 | -------------------------------------------------------------------------------- /rp2040-kbd-lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rp2040-kbd-lib" 3 | version = "0.1.0" 4 | edition = "2021" 5 | license = "GPL-3.0" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | 11 | [lints] 12 | workspace = true 13 | -------------------------------------------------------------------------------- /.local/lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cargo clippy --no-default-features --features left,serial --target thumbv6m-none-eabi 3 | cargo clippy --no-default-features --features left,hiddev --target thumbv6m-none-eabi 4 | cargo clippy --no-default-features --features right,serial --target thumbv6m-none-eabi 5 | cargo clippy --no-default-features --features right --target thumbv6m-none-eabi 6 | -------------------------------------------------------------------------------- /rp2040-kbd/src/timer.rs: -------------------------------------------------------------------------------- 1 | use rp2040_hal::Timer; 2 | 3 | pub fn wait_nanos(timer: Timer, nanos: u64) { 4 | let start = timer.get_counter(); 5 | loop { 6 | let Some(dur) = timer.get_counter().checked_duration_since(start) else { 7 | continue; 8 | }; 9 | if dur.to_nanos() >= nanos { 10 | return; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /memory.x: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100 3 | FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100 4 | RAM : ORIGIN = 0x20000000, LENGTH = 256K 5 | } 6 | 7 | EXTERN(BOOT2_FIRMWARE) 8 | 9 | SECTIONS { 10 | /* ### Boot loader */ 11 | .boot2 ORIGIN(BOOT2) : 12 | { 13 | KEEP(*(.boot2)); 14 | } > BOOT2 15 | } INSERT BEFORE .text; 16 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/left/message_receiver.rs: -------------------------------------------------------------------------------- 1 | use crate::keyboard::split_serial::UartLeft; 2 | use rp2040_kbd_lib::matrix::MatrixUpdate; 3 | 4 | pub(crate) struct MessageReceiver { 5 | pub(crate) uart: UartLeft, 6 | } 7 | 8 | impl MessageReceiver { 9 | pub fn new(uart: UartLeft) -> Self { 10 | Self { uart } 11 | } 12 | 13 | #[inline] 14 | pub(crate) fn try_read(&mut self) -> Option { 15 | self.uart.inner.read_one().and_then(MatrixUpdate::from_byte) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/right/message_serializer.rs: -------------------------------------------------------------------------------- 1 | use crate::keyboard::split_serial::UartRight; 2 | use rp2040_kbd_lib::matrix::MatrixUpdate; 3 | 4 | pub(crate) struct MessageSerializer { 5 | uart: UartRight, 6 | } 7 | 8 | impl MessageSerializer { 9 | #[inline] 10 | pub(crate) fn serialize_matrix_state(&mut self, update: MatrixUpdate) { 11 | self.uart.inner.blocking_write_byte(update.byte()); 12 | } 13 | 14 | pub fn new(uart: UartRight) -> Self { 15 | Self { uart } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Todo.md: -------------------------------------------------------------------------------- 1 | # Things remaining 2 | 3 | - [x] single-tap tilde `~`, grave`~`, and circumflex `^` on se-layouts 4 | - [x] Massive cleanup, proper lints 5 | - [x] Split into lib/bin to make tests work properly on x86_64 6 | - [x] Clippy pedantic 7 | - [x] Fixup oled on both sides 8 | - [x] Send multiple changes on the same report (mods and keypresses can go into the same, multiple keypresses) 9 | as well, but that only decreases latency if the user manager to generate more than 1 event per ms. 10 | - [x] Fix bug where sometimes key-downs aren't registered 11 | - [x] Layer fallthrough, should have thought about this earlier 12 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard.rs: -------------------------------------------------------------------------------- 1 | //! Common between sides, put everything with the same pinouts and shared hardware 2 | //! code here 3 | pub mod debounce; 4 | #[cfg(feature = "left")] 5 | pub mod left; 6 | pub mod oled; 7 | pub mod power_led; 8 | #[cfg(feature = "right")] 9 | pub mod right; 10 | pub mod split_serial; 11 | #[cfg(feature = "serial")] 12 | pub mod usb_serial; 13 | 14 | use rp2040_hal::gpio::{FunctionSio, Pin, PullUp, SioInput}; 15 | 16 | pub type ButtonPin = Pin, PullUp>; 17 | 18 | #[cfg(all(feature = "serial", feature = "left"))] 19 | pub const fn matrix_ind_to_row_col(matrix_ind: u8) -> (u8, u8) { 20 | ( 21 | matrix_ind / rp2040_kbd_lib::matrix::NUM_COLS, 22 | matrix_ind % rp2040_kbd_lib::matrix::NUM_COLS, 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/shared/press_latency_counter.rs: -------------------------------------------------------------------------------- 1 | use rp2040_hal::fugit::MicrosDurationU64; 2 | use rp2040_hal::rom_data::float_funcs::{fadd, fdiv, fsub, uint64_to_float, uint_to_float}; 3 | 4 | pub struct PressLatencyCounter { 5 | count: u32, 6 | avg: f32, 7 | } 8 | 9 | impl PressLatencyCounter { 10 | pub fn increment_get_avg(&mut self, duration: MicrosDurationU64) -> f32 { 11 | let f_val = uint64_to_float(duration.to_micros()); 12 | self.count = self.count.wrapping_add(1); 13 | if self.count == 0 { 14 | self.count = 1; 15 | self.avg = 0.0; 16 | } 17 | let count_f = uint_to_float(self.count); 18 | self.avg = fadd(self.avg, fdiv(fsub(f_val, self.avg), count_f)); 19 | self.avg 20 | } 21 | pub const fn new() -> Self { 22 | Self { count: 0, avg: 0.0 } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.local/build_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | cargo b --profile lto --no-default-features --features left,hiddev --target thumbv6m-none-eabi && elf2uf2-rs target/thumbv6m-none-eabi/lto/rp2040-kbd && echo "Left hiddev $(ls -lah target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2)" 4 | cargo b --profile lto --no-default-features --features left,serial --target thumbv6m-none-eabi && elf2uf2-rs target/thumbv6m-none-eabi/lto/rp2040-kbd && echo "Left serial $(ls -lah target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2)" 5 | cargo b --profile lto --no-default-features --features right --target thumbv6m-none-eabi && elf2uf2-rs target/thumbv6m-none-eabi/lto/rp2040-kbd && echo "Right $(ls -lah target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2)" 6 | cargo b --profile lto --no-default-features --features right,serial --target thumbv6m-none-eabi && elf2uf2-rs target/thumbv6m-none-eabi/lto/rp2040-kbd && echo "Right serial $(ls -lah target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2)" 7 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/shared/sleep.rs: -------------------------------------------------------------------------------- 1 | use rp2040_hal::timer::Instant; 2 | 3 | const SLEEP_AFTER_SECONDS: u64 = 60; 4 | 5 | pub struct SleepCountdown { 6 | is_asleep: bool, 7 | touched_last: Instant, 8 | } 9 | 10 | impl SleepCountdown { 11 | pub const fn new() -> Self { 12 | Self { 13 | is_asleep: false, 14 | touched_last: Instant::from_ticks(0), 15 | } 16 | } 17 | 18 | #[inline] 19 | pub fn touch(&mut self, now: Instant) { 20 | self.touched_last = now; 21 | self.is_asleep = false; 22 | } 23 | 24 | #[inline] 25 | pub fn should_sleep(&mut self, now: Instant) -> bool { 26 | !self.is_asleep 27 | && now 28 | .checked_duration_since(self.touched_last) 29 | .is_some_and(|dur| dur.to_secs() > SLEEP_AFTER_SECONDS) 30 | } 31 | 32 | #[inline] 33 | pub fn set_sleeping(&mut self) { 34 | self.is_asleep = true; 35 | } 36 | 37 | #[inline] 38 | pub fn is_awake(&self) -> bool { 39 | !self.is_asleep 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.local/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [[ "$1" == "l" ]] 3 | then 4 | if [[ "$2" == "d" ]] 5 | then 6 | cargo b --profile lto --no-default-features --features left,serial --target thumbv6m-none-eabi && elf2uf2-rs target/thumbv6m-none-eabi/lto/rp2040-kbd && echo "Left serial $(ls -lah target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2)" 7 | else 8 | cargo b --profile lto --no-default-features --features left,hiddev --target thumbv6m-none-eabi && elf2uf2-rs target/thumbv6m-none-eabi/lto/rp2040-kbd && echo "Left hiddev $(ls -lah target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2)" 9 | fi 10 | else 11 | if [[ "$2" == "d" ]] 12 | then 13 | cargo b --profile lto --no-default-features --features right,serial --target thumbv6m-none-eabi && elf2uf2-rs target/thumbv6m-none-eabi/lto/rp2040-kbd && echo "Right serial $(ls -lah target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2)" 14 | else 15 | cargo b --profile lto --no-default-features --features right --target thumbv6m-none-eabi && elf2uf2-rs target/thumbv6m-none-eabi/lto/rp2040-kbd && echo "Right $(ls -lah target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2)" 16 | fi 17 | fi 18 | -------------------------------------------------------------------------------- /rp2040-kbd/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rp2040-kbd" 3 | version = "0.1.0" 4 | edition = "2021" 5 | license = "GPL-3.0" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | rp2040-kbd-lib = {workspace = true} 11 | cortex-m-rt = { workspace = true } 12 | critical-section = {workspace = true } 13 | embedded-hal = { workspace = true } 14 | embedded-graphics = { workspace = true } 15 | rp2040-hal = {workspace = true, features = ["rt", "rp2040-e5", "rom-func-cache", "critical-section-impl", "rom-v2-intrinsics"]} 16 | liatris = { workspace = true } 17 | heapless = { workspace = true } 18 | usb-device = { workspace = true, default-features = false } 19 | usbd-hid = { workspace = true } 20 | usbd-serial = { workspace = true } 21 | paste = { workspace = true } 22 | pio-uart = {workspace = true} 23 | ssd1306 = { workspace = true } 24 | 25 | 26 | [features] 27 | # This is the set of features we enable by default 28 | default = [] 29 | 30 | serial = [] 31 | 32 | right = [] 33 | 34 | left = [] 35 | 36 | hiddev = [] 37 | 38 | [lints] 39 | workspace = true 40 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Keyboard firmware for the rp2040 on a lily58 2 | 3 | There are probably bugs here, don't use this! 4 | 5 | A more in-depth description of this repo is [here](https://marcusgrass.github.io/rust-kbd.html), 6 | or [here if github pages is down](https://github.com/MarcusGrass/marcusgrass.github.io/blob/main/pages/projects/RustKbd.md). 7 | 8 | ## Build and useful commands 9 | 10 | When the rp2040 goes into boot-mode it'll 11 | show up as a disk. 12 | 13 | ### Build and flash right side as hiddev 14 | 15 | Keyboard put into boot mode, shows up as /dev/sdb: 16 | 17 | 1. `.local/build.sh r h` 18 | 2. `mount /dev/sdb1 /mnt/rp2040 && cp code/rust/rp2040-kbd/target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2 /mnt/rp2040 && umount /mnt/rp2040` 19 | 20 | ### Debug through serial 21 | 22 | Build left side (for example) in debug. 23 | 24 | Creates a picocom connection to interface with the kbd. 25 | 26 | 1. `.local/build.sh l d` 27 | 2. `mount /dev/sdb1 /mnt/rp2040 && cp code/rust/rp2040-kbd/target/thumbv6m-none-eabi/lto/rp2040-kbd.uf2 /mnt/rp2040 && umount /mnt/rp2040` 28 | 3. `picocom -b 115200 -l /dev/ttyACM0` 29 | 30 | ## License 31 | 32 | [GPLV3, see here](LICENSE) 33 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/power_led.rs: -------------------------------------------------------------------------------- 1 | use embedded_hal::digital::{InputPin, OutputPin}; 2 | use rp2040_hal::gpio::bank0::Gpio24; 3 | use rp2040_hal::gpio::{FunctionSio, Pin, PullDown, SioOutput}; 4 | 5 | pub struct PowerLed { 6 | state: bool, 7 | pin: Pin, PullDown>, 8 | } 9 | 10 | impl PowerLed { 11 | pub fn new(pin: Pin, PullDown>) -> Self { 12 | let state = matches!(pin.as_input().is_low(), Ok(true)); 13 | Self { state, pin } 14 | } 15 | 16 | #[inline] 17 | #[cfg(feature = "serial")] 18 | pub fn is_on(&self) -> bool { 19 | self.state 20 | } 21 | 22 | #[inline] 23 | pub fn turn_on(&mut self) { 24 | if !self.state { 25 | self.set_true(); 26 | } 27 | } 28 | 29 | #[cold] 30 | #[inline(never)] 31 | fn set_true(&mut self) { 32 | let _ = self.pin.set_low(); 33 | self.state = true; 34 | } 35 | 36 | #[inline] 37 | pub fn turn_off(&mut self) { 38 | if self.state { 39 | self.set_false(); 40 | } 41 | } 42 | 43 | #[cold] 44 | #[inline(never)] 45 | fn set_false(&mut self) { 46 | let _ = self.pin.set_high(); 47 | self.state = false; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /deny.toml: -------------------------------------------------------------------------------- 1 | [graph] 2 | targets = [ 3 | { triple = "thumbv6m-none-eabi" }, 4 | ] 5 | 6 | [advisories] 7 | ignore = [ 8 | # proc-macro-error unmaintained 9 | "RUSTSEC-2024-0370", 10 | # paste unmaintained 11 | "RUSTSEC-2024-0436", 12 | ] 13 | 14 | [bans] 15 | multiple-versions = "deny" 16 | deny = [] 17 | skip = [ 18 | 19 | # cortex-m has a bunch of outdated deps 20 | { name = "bitfield", version = "0.13.2" }, 21 | { name = "bitfield", version = "0.14.0" }, 22 | { name = "hashbrown", version = "0.13.2" }, 23 | { name = "embedded-hal", version = "0.2.7" }, 24 | { name = "nb", version = "0.1.3" }, 25 | { name = "syn", version = "1.0.109" }, 26 | ] 27 | 28 | [sources] 29 | allow-git = [ 30 | "https://github.com/MarcusGrass/rp-hal-boards", 31 | "https://github.com/MarcusGrass/rp-hal", 32 | "https://github.com/MarcusGrass/pio-uart", 33 | "https://github.com/MarcusGrass/usb-device", 34 | ] 35 | 36 | [licenses] 37 | confidence-threshold = 1.0 38 | # I'd like to know if they pop into my dependency graph 39 | allow = [ 40 | "Apache-2.0", 41 | "BSD-3-Clause", 42 | "MIT", 43 | ] 44 | exceptions = [ 45 | { name = "rp2040-kbd", allow = ["GPL-3.0"] }, 46 | { name = "rp2040-kbd-lib", allow = ["GPL-3.0"] }, 47 | { name = "unicode-ident", allow = ["Unicode-3.0"] }, 48 | ] 49 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ "rp2040-kbd", "rp2040-kbd-lib"] 4 | 5 | [workspace.dependencies] 6 | rp2040-kbd-lib = { path = "rp2040-kbd-lib" } 7 | cortex-m-rt = "0.7.5" 8 | critical-section = "1.2.0" 9 | embedded-graphics = "0.8.1" 10 | embedded-hal = "1.0.0" 11 | fugit = "0.3.7" 12 | heapless = "0.8.0" 13 | paste = "1.0.15" 14 | pio-uart = { git = "https://github.com/MarcusGrass/pio-uart", rev = "80f5fdbdbfb56e456ece97bdb7c8aebe18d10042" } 15 | liatris = { git = "https://github.com/MarcusGrass/rp-hal-boards", rev = "748c497ce5f423599e168ca17d2f8017533c0afb" } 16 | rp2040-hal = "0.11.0" 17 | ssd1306 = "0.10.0" 18 | usb-device = { version = "0.3.2", default-features = false} 19 | usbd-hid = "0.8.2" 20 | usbd-serial = "0.2.2" 21 | 22 | [workspace.lints] 23 | clippy.pedantic = { level = "warn", priority = -1 } 24 | 25 | clippy.inline_always = "allow" 26 | clippy.allow_attributes = "warn" 27 | clippy.match_same_arms = "allow" 28 | clippy.module_name_repetitions = "allow" 29 | clippy.new_without_default = "allow" 30 | clippy.similar_names = "allow" 31 | clippy.too_many_arguments = "allow" 32 | clippy.type_complexity = "allow" 33 | clippy.unnested_or_patterns = "allow" 34 | 35 | [patch.crates-io] 36 | usb-device = { git = "https://github.com/MarcusGrass/usb-device", rev = "b0b066059065db55fc9991f18f5de755f1accd7f" } 37 | rp2040-hal = { git = "https://github.com/MarcusGrass/rp-hal", rev = "79e022ddc15377c155682db15138b623212b978d"} 38 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/left.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod message_receiver; 2 | 3 | use crate::keyboard::ButtonPin; 4 | use rp2040_hal::gpio::bank0::{ 5 | Gpio20, Gpio21, Gpio22, Gpio23, Gpio26, Gpio27, Gpio29, Gpio6, Gpio7, Gpio8, Gpio9, 6 | }; 7 | 8 | pub const ROW0: u32 = 1 << 29; 9 | pub const ROW1: u32 = 1 << 27; 10 | pub const ROW2: u32 = 1 << 6; 11 | pub const ROW3: u32 = 1 << 7; 12 | pub const ROW4: u32 = 1 << 8; 13 | pub const ROW_MASK: u32 = ROW0 | ROW1 | ROW2 | ROW3 | ROW4; 14 | 15 | pub struct LeftButtons { 16 | pub _rows: ( 17 | ButtonPin, 18 | ButtonPin, 19 | ButtonPin, 20 | ButtonPin, 21 | ButtonPin, 22 | ), 23 | pub cols: ( 24 | Option>, 25 | Option>, 26 | Option>, 27 | Option>, 28 | Option>, 29 | Option>, 30 | ), 31 | } 32 | 33 | impl LeftButtons { 34 | pub fn new( 35 | rows: ( 36 | ButtonPin, 37 | ButtonPin, 38 | ButtonPin, 39 | ButtonPin, 40 | ButtonPin, 41 | ), 42 | cols: ( 43 | Option>, 44 | Option>, 45 | Option>, 46 | Option>, 47 | Option>, 48 | Option>, 49 | ), 50 | ) -> Self { 51 | Self { _rows: rows, cols } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/shared/loop_counter.rs: -------------------------------------------------------------------------------- 1 | use rp2040_hal::fugit::MicrosDuration; 2 | use rp2040_hal::rom_data::float_funcs::{fdiv, uint64_to_float, uint_to_float}; 3 | use rp2040_hal::timer::Instant; 4 | 5 | #[derive(Debug, Copy, Clone)] 6 | pub struct LoopCount { 7 | pub duration: MicrosDuration, 8 | pub count: u32, 9 | } 10 | 11 | impl LoopCount { 12 | pub fn as_micros_fraction(&self) -> f32 { 13 | let count = uint_to_float(self.count); 14 | let micros = uint64_to_float(self.duration.to_micros()); 15 | let res = fdiv(micros, count); 16 | if res <= 999.9 { 17 | res 18 | } else { 19 | 999.9 20 | } 21 | } 22 | } 23 | 24 | pub struct LoopCounter { 25 | start: Instant, 26 | count: u32, 27 | } 28 | 29 | impl LoopCounter { 30 | pub const fn new(instant: Instant) -> Self { 31 | Self { 32 | start: instant, 33 | count: 0, 34 | } 35 | } 36 | 37 | #[inline] 38 | pub fn increment(&mut self) -> bool { 39 | self.count += 1; 40 | self.count >= N 41 | } 42 | 43 | #[inline] 44 | pub fn value(&self, now: Instant) -> LoopCount { 45 | LoopCount { 46 | duration: now 47 | .checked_duration_since(self.start) 48 | .unwrap_or(MicrosDuration::::micros(100)), 49 | count: self.count, 50 | } 51 | } 52 | 53 | #[inline] 54 | pub fn reset(&mut self, start: Instant) { 55 | self.start = start; 56 | self.count = 0; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/debounce.rs: -------------------------------------------------------------------------------- 1 | use rp2040_hal::timer::Instant; 2 | 3 | #[derive(Copy, Clone, Debug, Default)] 4 | pub struct PinDebouncer { 5 | last_touch: Option, 6 | quarantined: Option, 7 | } 8 | 9 | // Effectively, maximum presses per single key becomes is 1 per 20 millis, that's a 600 WPM with a single finger 10 | const QUARANTINE_MICROS: u64 = 10_000; 11 | 12 | impl PinDebouncer { 13 | pub const fn new() -> Self { 14 | Self { 15 | last_touch: None, 16 | quarantined: None, 17 | } 18 | } 19 | 20 | #[cfg(all(feature = "serial", feature = "right"))] 21 | pub fn diff_last(&self, now: Instant) -> Option { 22 | self.last_touch 23 | .and_then(|last| now.checked_duration_since(last)) 24 | .map(|diff| diff.to_micros()) 25 | } 26 | 27 | pub fn try_submit(&mut self, now: Instant, state: bool) -> bool { 28 | let Some(earlier) = self.last_touch else { 29 | self.last_touch = Some(now); 30 | return true; 31 | }; 32 | let Some(diff) = now.checked_duration_since(earlier) else { 33 | self.last_touch = Some(now); 34 | return true; 35 | }; 36 | if diff.to_micros() < QUARANTINE_MICROS { 37 | return if self.quarantined == Some(state) { 38 | false 39 | } else { 40 | self.quarantined = Some(state); 41 | self.last_touch = Some(now); 42 | false 43 | }; 44 | } 45 | 46 | self.last_touch = Some(now); 47 | self.quarantined.take(); 48 | true 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | # 2 | # Cargo Configuration for the https://github.com/rp-rs/rp-hal.git repository. 3 | # 4 | # Copyright (c) The RP-RS Developers, 2021 5 | # 6 | # You might want to make a similar file in your own repository if you are 7 | # writing programs for Raspberry Silicon microcontrollers. 8 | # 9 | # This file is MIT or Apache-2.0 as per the repository README.md file 10 | # 11 | 12 | [build] 13 | # Set the default target to match the Cortex-M0+ in the RP2040 14 | target = "thumbv6m-none-eabi" 15 | 16 | # Target specific options 17 | [target.thumbv6m-none-eabi] 18 | # Pass some extra options to rustc, some of which get passed on to the linker. 19 | # 20 | # * linker argument --nmagic turns off page alignment of sections (which saves 21 | # flash space) 22 | # * linker argument -Tlink.x tells the linker to use link.x as the linker 23 | # script. This is usually provided by the cortex-m-rt crate, and by default 24 | # the version in that crate will include a file called `memory.x` which 25 | # describes the particular memory layout for your specific chip. 26 | # * inline-threshold=5 makes the compiler more aggressive and inlining functions 27 | # * no-vectorize-loops turns off the loop vectorizer (seeing as the M0+ doesn't 28 | # have SIMD) 29 | rustflags = [ 30 | "-C", "link-arg=--nmagic", 31 | "-C", "link-arg=-Tlink.x", 32 | "-C", "linker-flavor=ld.lld", 33 | "-C", "llvm-args=--inline-threshold=5", 34 | "-C", "no-vectorize-loops", 35 | ] 36 | 37 | [profile.lto] 38 | codegen-units = 1 39 | debug = false 40 | inherits = "release" 41 | lto = true 42 | strip = true 43 | # This runner will make a UF2 file and then copy it to a mounted RP2040 in USB 44 | # Bootloader mode: 45 | # runner = "elf2uf2-rs -d" 46 | 47 | # This runner will find a supported SWD debug probe and flash your RP2040 over 48 | # SWD: 49 | # runner = "probe-rs run --chip RP2040" 50 | -------------------------------------------------------------------------------- /rp2040-kbd/src/hid/usb_hiddev.rs: -------------------------------------------------------------------------------- 1 | use rp2040_hal::usb::UsbBus; 2 | use usb_device::bus::UsbBusAllocator; 3 | use usb_device::device::{StringDescriptors, UsbDevice}; 4 | use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor}; 5 | use usbd_hid::hid_class::HIDClass; 6 | 7 | pub struct UsbHiddev<'a> { 8 | hid: HIDClass<'a, UsbBus>, 9 | dev: UsbDevice<'a, UsbBus>, 10 | ready: bool, 11 | } 12 | 13 | impl<'a> UsbHiddev<'a> { 14 | pub fn new(buf: &'a mut [u8], allocator: &'a UsbBusAllocator) -> Self { 15 | let hid = usbd_hid::hid_class::HIDClass::new_ep_in( 16 | allocator, 17 | usbd_hid::descriptor::KeyboardReport::desc(), 18 | 1, 19 | ); 20 | let dev = usb_device::device::UsbDeviceBuilder::new( 21 | allocator, 22 | usb_device::device::UsbVidPid(0x16c0, 0x27da), 23 | buf, 24 | ) 25 | .strings(&[StringDescriptors::default() 26 | .product("lily58") 27 | .manufacturer("splitkb") 28 | .serial_number("1")]) 29 | .unwrap() 30 | .device_class(0) 31 | .build() 32 | .unwrap(); 33 | Self { 34 | hid, 35 | dev, 36 | ready: true, 37 | } 38 | } 39 | 40 | pub fn try_submit_report(&mut self, keyboard_report: &KeyboardReport) -> bool { 41 | self.ready 42 | .then(|| { 43 | let res = self.hid.push_input(keyboard_report).is_ok(); 44 | self.ready = false; 45 | res 46 | }) 47 | .unwrap_or_default() 48 | } 49 | 50 | // Very easy to overproduce, only allow pushing after a previous poll, should come 51 | // from the OS-negotiated interrupt scheduling. 52 | // Could cache a value and immediately submit, but the producer 53 | // outpaces the os significantly so there's no need at the moment (42micros vs 1000 micros poll latency at time of writing) 54 | pub fn poll(&mut self) { 55 | self.dev.poll(&mut [&mut self.hid]); 56 | self.ready = true; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/shared/cores_right.rs: -------------------------------------------------------------------------------- 1 | use crate::runtime::shared::loop_counter::LoopCount; 2 | use core::sync::atomic::AtomicUsize; 3 | use rp2040_hal::fugit::MicrosDurationU64; 4 | use rp2040_kbd_lib::queue::{ 5 | new_atomic_producer_consumer, AtomicQueueConsumer, AtomicQueueProducer, 6 | }; 7 | 8 | #[derive(Debug, Copy, Clone)] 9 | pub enum KeycoreToAdminMessage { 10 | Loop(LoopCount), 11 | Touch { 12 | tx_bytes: u16, 13 | loop_duration: MicrosDurationU64, 14 | }, 15 | Reboot, 16 | } 17 | 18 | const QUEUE_CAPACITY: usize = 8; 19 | 20 | pub type Producer = AtomicQueueProducer<'static, KeycoreToAdminMessage, QUEUE_CAPACITY>; 21 | 22 | pub type Consumer = AtomicQueueConsumer<'static, KeycoreToAdminMessage, QUEUE_CAPACITY>; 23 | static mut ATOMIC_QUEUE_MEM_AREA: [KeycoreToAdminMessage; QUEUE_CAPACITY] = 24 | [KeycoreToAdminMessage::Reboot; QUEUE_CAPACITY]; 25 | static mut ATOMIC_QUEUE_HEAD: AtomicUsize = AtomicUsize::new(0); 26 | static mut ATOMIC_QUEUE_TAIL: AtomicUsize = AtomicUsize::new(0); 27 | pub fn new_shared_queue() -> (Producer, Consumer) { 28 | #[expect(static_mut_refs)] 29 | unsafe { 30 | new_atomic_producer_consumer( 31 | &mut ATOMIC_QUEUE_MEM_AREA, 32 | &mut ATOMIC_QUEUE_HEAD, 33 | &mut ATOMIC_QUEUE_TAIL, 34 | ) 35 | } 36 | } 37 | 38 | pub fn push_loop_to_admin(producer: &Producer, loop_count: LoopCount) -> bool { 39 | producer.push_back(KeycoreToAdminMessage::Loop(loop_count)) 40 | } 41 | 42 | pub fn try_push_touch( 43 | producer: &Producer, 44 | transmitted: u16, 45 | loop_duration: MicrosDurationU64, 46 | ) -> bool { 47 | producer.push_back(KeycoreToAdminMessage::Touch { 48 | tx_bytes: transmitted, 49 | loop_duration, 50 | }) 51 | } 52 | 53 | #[inline(never)] 54 | pub fn push_reboot_and_halt(producer: &Producer) -> ! { 55 | while !producer.push_back(KeycoreToAdminMessage::Reboot) {} 56 | panic!("HALT AFTER PUSHING REBOOT"); 57 | } 58 | 59 | pub fn pop_message(consumer: &Consumer) -> Option { 60 | consumer.pop_front() 61 | } 62 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/usb_serial.rs: -------------------------------------------------------------------------------- 1 | use core::borrow::BorrowMut; 2 | use core::fmt::Write; 3 | use rp2040_hal::usb::UsbBus; 4 | use usb_device::bus::UsbBusAllocator; 5 | use usb_device::device::{StringDescriptors, UsbDevice, UsbDeviceBuilder, UsbVidPid}; 6 | use usb_device::UsbError; 7 | use usbd_serial::SerialPort; 8 | 9 | pub struct UsbSerial<'a> { 10 | pub(crate) inner: SerialPort<'a, UsbBus>, 11 | } 12 | 13 | impl<'a> UsbSerial<'a> { 14 | pub fn new(usb_bus: &'a UsbBusAllocator) -> Self { 15 | // Set up the USB Communications Class Device driver 16 | let inner = SerialPort::new(usb_bus); 17 | Self { inner } 18 | } 19 | } 20 | 21 | impl Write for UsbSerial<'_> { 22 | fn write_str(&mut self, s: &str) -> core::fmt::Result { 23 | serial_write_all(&mut self.inner, s.as_bytes()); 24 | Ok(()) 25 | } 26 | } 27 | 28 | fn serial_write_all, B2: BorrowMut<[u8]>>( 29 | serial: &mut SerialPort, 30 | buf: &[u8], 31 | ) { 32 | for chunk in buf.chunks(16) { 33 | let mut remaining = chunk; 34 | loop { 35 | if remaining.is_empty() { 36 | break; 37 | } 38 | let written = serial.write(remaining); 39 | match written { 40 | Ok(wrote) => { 41 | remaining = &remaining[wrote..]; 42 | } 43 | Err(UsbError::WouldBlock) => { 44 | continue; 45 | } 46 | Err(_e) => { 47 | return; 48 | } 49 | } 50 | } 51 | } 52 | } 53 | 54 | pub struct UsbSerialDevice<'a> { 55 | pub(crate) inner: UsbDevice<'a, UsbBus>, 56 | } 57 | 58 | impl<'a> UsbSerialDevice<'a> { 59 | pub fn new(control_buffer: &'a mut [u8], usb_bus: &'a UsbBusAllocator) -> Self { 60 | let inner = UsbDeviceBuilder::new(usb_bus, UsbVidPid(0x16c0, 0x27dd), control_buffer) 61 | .strings(&[StringDescriptors::default() 62 | .product("lily58") 63 | .manufacturer("splitkb") 64 | .serial_number("1")]) 65 | .unwrap() 66 | .device_class(2) // from: https://www.usb.org/defined-class-codes 67 | .build() 68 | .unwrap(); 69 | Self { inner } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/split_serial.rs: -------------------------------------------------------------------------------- 1 | use liatris::pac::{PIO0, RESETS}; 2 | use rp2040_hal::fugit; 3 | use rp2040_hal::gpio::bank0::Gpio1; 4 | use rp2040_hal::gpio::{FunctionNull, Pin, PullDown}; 5 | use rp2040_hal::pio::{PIOExt, Running, UninitStateMachine, SM0, SM1, SM2, SM3}; 6 | 7 | #[cfg(feature = "left")] 8 | pub struct UartLeft { 9 | pub(crate) inner: pio_uart::PioUartRx, 10 | _prog: pio_uart::RxProgram, 11 | _sm1: UninitStateMachine<(PIO0, SM1)>, 12 | _sm2: UninitStateMachine<(PIO0, SM2)>, 13 | _sm3: UninitStateMachine<(PIO0, SM3)>, 14 | } 15 | 16 | #[cfg(feature = "left")] 17 | impl UartLeft { 18 | pub fn new( 19 | uart_pin: Pin, 20 | baud: fugit::HertzU32, 21 | system_freq: fugit::HertzU32, 22 | pio: PIO0, 23 | resets: &mut RESETS, 24 | ) -> Self { 25 | let rx_pin = uart_pin.reconfigure(); 26 | let (mut pio, sm0, sm1, sm2, sm3) = pio.split(resets); 27 | let mut rx_program = pio_uart::install_rx_program(&mut pio).ok().unwrap(); // Should never fail, because no program was loaded yet 28 | let rx = pio_uart::PioUartRx::new(rx_pin, sm0, &mut rx_program, baud, system_freq).enable(); 29 | Self { 30 | inner: rx, 31 | _prog: rx_program, 32 | _sm1: sm1, 33 | _sm2: sm2, 34 | _sm3: sm3, 35 | } 36 | } 37 | } 38 | 39 | #[cfg(feature = "right")] 40 | pub struct UartRight { 41 | pub(crate) inner: pio_uart::PioUartTx, 42 | _prog: pio_uart::TxProgram, 43 | _sm1: UninitStateMachine<(PIO0, SM1)>, 44 | _sm2: UninitStateMachine<(PIO0, SM2)>, 45 | _sm3: UninitStateMachine<(PIO0, SM3)>, 46 | } 47 | 48 | #[cfg(feature = "right")] 49 | impl UartRight { 50 | pub fn new( 51 | uart_pin: Pin, 52 | baud: fugit::HertzU32, 53 | system_freq: fugit::HertzU32, 54 | pio: PIO0, 55 | resets: &mut RESETS, 56 | ) -> Self { 57 | let rx_pin = uart_pin.reconfigure(); 58 | let (mut inner_pio, sm0, sm1, sm2, sm3) = pio.split(resets); 59 | let mut tx_program = pio_uart::install_tx_program(&mut inner_pio).ok().unwrap(); // Should never fail, because no program was loaded yet 60 | let rx = pio_uart::PioUartTx::new(rx_pin, sm0, &mut tx_program, baud, system_freq).enable(); 61 | Self { 62 | inner: rx, 63 | _prog: tx_program, 64 | _sm1: sm1, 65 | _sm2: sm2, 66 | _sm3: sm3, 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/shared/cores_left.rs: -------------------------------------------------------------------------------- 1 | use crate::keymap::KeymapLayer; 2 | use crate::runtime::shared::loop_counter::LoopCount; 3 | use core::sync::atomic::AtomicUsize; 4 | use rp2040_hal::fugit::MicrosDurationU64; 5 | use rp2040_kbd_lib::queue::{ 6 | new_atomic_producer_consumer, AtomicQueueConsumer, AtomicQueueProducer, 7 | }; 8 | 9 | #[derive(Debug, Copy, Clone)] 10 | pub enum KeycoreToAdminMessage { 11 | // Notify on any user action 12 | TouchLeft(MicrosDurationU64), 13 | TouchRight(MicrosDurationU64), 14 | // Send loop count to calculate scan latency 15 | Loop(LoopCount), 16 | // Output which layer is active 17 | LayerChange(KeymapLayer), 18 | // Output bytes received over UART 19 | Rx(u16), 20 | // Write a boot message then trigger usb-boot 21 | Reboot, 22 | } 23 | const QUEUE_CAPACITY: usize = 8; 24 | 25 | pub type Producer = AtomicQueueProducer<'static, KeycoreToAdminMessage, QUEUE_CAPACITY>; 26 | 27 | pub type Consumer = AtomicQueueConsumer<'static, KeycoreToAdminMessage, QUEUE_CAPACITY>; 28 | static mut ATOMIC_QUEUE_MEM_AREA: [KeycoreToAdminMessage; QUEUE_CAPACITY] = 29 | [KeycoreToAdminMessage::Reboot; QUEUE_CAPACITY]; 30 | static mut ATOMIC_QUEUE_HEAD: AtomicUsize = AtomicUsize::new(0); 31 | static mut ATOMIC_QUEUE_TAIL: AtomicUsize = AtomicUsize::new(0); 32 | pub fn new_shared_queue() -> (Producer, Consumer) { 33 | #[expect(static_mut_refs)] 34 | unsafe { 35 | new_atomic_producer_consumer( 36 | &mut ATOMIC_QUEUE_MEM_AREA, 37 | &mut ATOMIC_QUEUE_HEAD, 38 | &mut ATOMIC_QUEUE_TAIL, 39 | ) 40 | } 41 | } 42 | 43 | pub fn push_touch_left_to_admin( 44 | atomic_queue_producer: &Producer, 45 | duration: MicrosDurationU64, 46 | ) -> bool { 47 | atomic_queue_producer.push_back(KeycoreToAdminMessage::TouchLeft(duration)) 48 | } 49 | 50 | pub fn push_touch_right_to_admin( 51 | atomic_queue_producer: &Producer, 52 | duration: MicrosDurationU64, 53 | ) -> bool { 54 | atomic_queue_producer.push_back(KeycoreToAdminMessage::TouchRight(duration)) 55 | } 56 | 57 | pub fn push_loop_to_admin(atomic_queue_producer: &Producer, loop_count: LoopCount) -> bool { 58 | atomic_queue_producer.push_back(KeycoreToAdminMessage::Loop(loop_count)) 59 | } 60 | 61 | pub fn push_layer_change(atomic_queue_producer: &Producer, new_layer: KeymapLayer) -> bool { 62 | atomic_queue_producer.push_back(KeycoreToAdminMessage::LayerChange(new_layer)) 63 | } 64 | 65 | pub fn push_rx_change(atomic_queue_producer: &Producer, received: u16) -> bool { 66 | atomic_queue_producer.push_back(KeycoreToAdminMessage::Rx(received)) 67 | } 68 | 69 | #[inline(never)] 70 | pub fn push_reboot_and_halt(atomic_queue_producer: &Producer) -> ! { 71 | while !atomic_queue_producer.push_back(KeycoreToAdminMessage::Reboot) {} 72 | panic!("HALT AFTER PUSHING REBOOT"); 73 | } 74 | 75 | pub fn pop_message(atomic_queue_consumer: &Consumer) -> Option { 76 | atomic_queue_consumer.pop_front() 77 | } 78 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/shared/usb.rs: -------------------------------------------------------------------------------- 1 | pub struct SyncBus( 2 | core::cell::OnceCell>, 3 | ); 4 | 5 | unsafe impl Sync for SyncBus {} 6 | 7 | pub struct SyncUnsafe(core::cell::UnsafeCell); 8 | 9 | unsafe impl Sync for SyncUnsafe where T: Sync {} 10 | 11 | pub struct SyncUnsafeOnce(core::cell::OnceCell>); 12 | 13 | unsafe impl Sync for SyncUnsafeOnce where T: Sync {} 14 | 15 | impl SyncUnsafeOnce { 16 | const fn new() -> Self { 17 | Self(core::cell::OnceCell::new()) 18 | } 19 | 20 | fn set(&self, val: T) { 21 | let _ = self.0.set(SyncUnsafe(core::cell::UnsafeCell::new(val))); 22 | } 23 | 24 | /// # Safety 25 | /// Only a single reference to this is held 26 | #[inline] 27 | pub unsafe fn as_mut<'a>(&'static self) -> Option<&'a mut T> { 28 | self.0.get().and_then(|r| r.0.get().as_mut()) 29 | } 30 | } 31 | static USB_BUS: SyncBus = SyncBus(core::cell::OnceCell::new()); 32 | 33 | #[cfg(feature = "serial")] 34 | static USB_DEVICE: SyncUnsafeOnce = 35 | SyncUnsafeOnce::new(); 36 | 37 | #[cfg(feature = "serial")] 38 | static USB_SERIAL: SyncUnsafeOnce = SyncUnsafeOnce::new(); 39 | 40 | #[cfg(feature = "serial")] 41 | static USB_OUTPUT: SyncUnsafeOnce = SyncUnsafeOnce::new(); 42 | 43 | #[cfg(feature = "hiddev")] 44 | static USB_HIDDEV: SyncUnsafeOnce = SyncUnsafeOnce::new(); 45 | 46 | static mut USB_CONTROL_BUFFER: [u8; 256] = [0u8; 256]; 47 | 48 | #[cfg(feature = "serial")] 49 | #[expect(static_mut_refs)] 50 | pub unsafe fn init_usb(allocator: usb_device::bus::UsbBusAllocator) { 51 | let _ = USB_BUS.0.set(allocator); 52 | USB_OUTPUT.set(false); 53 | // Ordering here is extremely important, serial before device. 54 | USB_SERIAL.set(crate::keyboard::usb_serial::UsbSerial::new( 55 | USB_BUS.0.get().unwrap(), 56 | )); 57 | USB_DEVICE.set(crate::keyboard::usb_serial::UsbSerialDevice::new( 58 | unsafe { &mut USB_CONTROL_BUFFER }, 59 | USB_BUS.0.get().unwrap(), 60 | )); 61 | } 62 | 63 | #[cfg(feature = "serial")] 64 | pub fn acquire_usb<'a>() -> UsbGuard<'a> { 65 | let lock = crate::runtime::locks::UsbLock::claim(); 66 | UsbGuard { 67 | serial: unsafe { USB_SERIAL.as_mut() }, 68 | dev: unsafe { USB_DEVICE.as_mut() }, 69 | output: unsafe { USB_OUTPUT.as_mut().unwrap() }, 70 | _lock: lock, 71 | _pd: core::marker::PhantomData, 72 | } 73 | } 74 | 75 | #[cfg(feature = "serial")] 76 | pub struct UsbGuard<'a> { 77 | pub serial: Option<&'a mut crate::keyboard::usb_serial::UsbSerial<'static>>, 78 | pub dev: Option<&'a mut crate::keyboard::usb_serial::UsbSerialDevice<'static>>, 79 | pub output: &'a mut bool, 80 | _lock: crate::runtime::locks::UsbLock, 81 | _pd: core::marker::PhantomData<&'a ()>, 82 | } 83 | 84 | #[cfg(feature = "serial")] 85 | impl core::fmt::Write for UsbGuard<'_> { 86 | fn write_str(&mut self, s: &str) -> core::fmt::Result { 87 | if let Some(serial) = self.serial.as_mut() { 88 | if *self.output { 89 | serial.write_str(s) 90 | } else { 91 | Ok(()) 92 | } 93 | } else { 94 | Ok(()) 95 | } 96 | } 97 | } 98 | 99 | #[cfg(feature = "hiddev")] 100 | #[expect(static_mut_refs)] 101 | pub unsafe fn init_usb_hiddev( 102 | allocator: usb_device::bus::UsbBusAllocator, 103 | ) { 104 | let _ = USB_BUS.0.set(allocator); 105 | USB_HIDDEV.set(crate::hid::usb_hiddev::UsbHiddev::new( 106 | unsafe { &mut USB_CONTROL_BUFFER }, 107 | USB_BUS.0.get().unwrap(), 108 | )); 109 | } 110 | 111 | #[cfg(feature = "hiddev")] 112 | pub unsafe fn try_push_report(keyboard_report: &usbd_hid::descriptor::KeyboardReport) -> bool { 113 | critical_section::with(|_cs| { 114 | USB_HIDDEV 115 | .as_mut() 116 | .is_some_and(|hid| hid.try_submit_report(keyboard_report)) 117 | }) 118 | } 119 | 120 | #[cfg(feature = "hiddev")] 121 | pub unsafe fn hiddev_interrupt_poll() { 122 | if let Some(hid) = USB_HIDDEV.as_mut() { 123 | hid.poll(); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rp2040-kbd-lib/src/matrix.rs: -------------------------------------------------------------------------------- 1 | pub const NUM_ROWS: u8 = 5; 2 | pub const NUM_COLS: u8 = 6; 3 | 4 | #[repr(transparent)] 5 | #[derive(Debug, Copy, Clone)] 6 | pub struct RowIndex(pub u8); 7 | 8 | impl RowIndex { 9 | #[must_use] 10 | pub const fn from_value(ind: u8) -> Self { 11 | assert!( 12 | ind < NUM_ROWS, 13 | "Tried to construct row index from a bad value" 14 | ); 15 | Self(ind) 16 | } 17 | 18 | #[inline] 19 | #[must_use] 20 | pub const fn index(self) -> usize { 21 | self.0 as usize 22 | } 23 | } 24 | 25 | #[repr(transparent)] 26 | #[derive(Debug, Copy, Clone)] 27 | pub struct ColIndex(pub u8); 28 | 29 | impl ColIndex { 30 | #[must_use] 31 | pub const fn from_value(ind: u8) -> Self { 32 | assert!( 33 | ind < NUM_COLS, 34 | "Tried to construct col index from a bad value" 35 | ); 36 | Self(ind) 37 | } 38 | } 39 | 40 | #[repr(transparent)] 41 | #[derive(Debug, Copy, Clone)] 42 | pub struct MatrixIndex(u8); 43 | 44 | impl MatrixIndex { 45 | #[inline] 46 | #[must_use] 47 | pub const fn from_row_col(row_index: RowIndex, col_index: ColIndex) -> Self { 48 | Self(row_index.0 * NUM_COLS + col_index.0) 49 | } 50 | 51 | #[must_use] 52 | #[inline(always)] 53 | pub const fn byte(&self) -> u8 { 54 | self.0 55 | } 56 | 57 | #[must_use] 58 | #[inline(always)] 59 | pub const fn index(&self) -> usize { 60 | self.0 as usize 61 | } 62 | } 63 | 64 | #[repr(transparent)] 65 | #[derive(Debug, Copy, Clone)] 66 | pub struct MatrixUpdate(u8); 67 | 68 | #[derive(Debug, Copy, Clone)] 69 | pub enum MatrixChange { 70 | KeyUpdate(MatrixIndex, bool), 71 | EncoderUpdate(bool), 72 | } 73 | 74 | impl MatrixUpdate { 75 | const KEY_STATE_BIT: u8 = 0b0010_0000; 76 | 77 | const KEY_INDEX_MASK: u8 = 0b0001_1111; 78 | const ENCODER_STATE_BIT: u8 = 0b1000_0000; 79 | const ENCODER_ON: Self = Self(0b1100_0000); 80 | const ENCODER_OFF: Self = Self(0b0100_0000); 81 | #[must_use] 82 | pub fn from_byte(byte: u8) -> Option { 83 | let ind = byte & Self::KEY_INDEX_MASK; 84 | // There are 2 illegal bit-patterns 85 | (ind <= 30).then_some(Self(byte)) 86 | } 87 | 88 | #[inline] 89 | #[must_use] 90 | pub const fn from_key_update(index: MatrixIndex, state: bool) -> Self { 91 | let mut val = index.0; 92 | if state { 93 | val |= Self::KEY_STATE_BIT; 94 | } 95 | Self(val) 96 | } 97 | 98 | #[inline] 99 | #[must_use] 100 | pub const fn from_rotary_change(clockwise: bool) -> Self { 101 | if clockwise { 102 | Self::ENCODER_ON 103 | } else { 104 | Self::ENCODER_OFF 105 | } 106 | } 107 | 108 | #[inline] 109 | #[must_use] 110 | pub const fn interpret_byte(&self) -> MatrixChange { 111 | let encoder = self.0 & Self::ENCODER_ON.0; 112 | if encoder == 0 { 113 | let idx = self.0 & Self::KEY_INDEX_MASK; 114 | let state = self.0 & Self::KEY_STATE_BIT; 115 | MatrixChange::KeyUpdate(MatrixIndex(idx), state != 0) 116 | } else { 117 | MatrixChange::EncoderUpdate(encoder & Self::ENCODER_STATE_BIT != 0) 118 | } 119 | } 120 | 121 | #[inline] 122 | #[must_use] 123 | pub const fn byte(self) -> u8 { 124 | self.0 125 | } 126 | } 127 | 128 | #[cfg(test)] 129 | mod tests { 130 | use super::*; 131 | 132 | #[test] 133 | fn update_from_key() { 134 | const R1: RowIndex = RowIndex::from_value(1); 135 | const C1: ColIndex = ColIndex::from_value(4); 136 | const M1: MatrixIndex = MatrixIndex::from_row_col(R1, C1); 137 | const MU1: MatrixUpdate = MatrixUpdate::from_key_update(M1, true); 138 | assert_eq!(0b00101010, MU1.0, "{:b}", MU1.0); 139 | const EXPECT_IND: u8 = R1.0 * NUM_COLS + C1.0; 140 | assert!(matches!( 141 | MU1.interpret_byte(), 142 | MatrixChange::KeyUpdate(MatrixIndex(EXPECT_IND), true) 143 | )); 144 | const MU2: MatrixUpdate = MatrixUpdate::from_key_update(M1, false); 145 | assert!(matches!( 146 | MU2.interpret_byte(), 147 | MatrixChange::KeyUpdate(MatrixIndex(EXPECT_IND), false) 148 | )); 149 | assert_eq!(0b00001010, MU2.0, "{:b}", MU2.0); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/oled.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "left")] 2 | pub mod left; 3 | #[cfg(feature = "right")] 4 | pub mod right; 5 | 6 | use embedded_graphics::draw_target::DrawTarget; 7 | use embedded_graphics::geometry::Point; 8 | use embedded_graphics::mono_font::iso_8859_4::{FONT_4X6, FONT_5X7}; 9 | use embedded_graphics::mono_font::MonoTextStyleBuilder; 10 | use embedded_graphics::pixelcolor::BinaryColor; 11 | use embedded_graphics::prelude::Size; 12 | use embedded_graphics::primitives::Rectangle; 13 | use embedded_graphics::text::{Baseline, Text}; 14 | use embedded_graphics::Drawable; 15 | use liatris::pac::I2C1; 16 | use rp2040_hal::gpio::bank0::{Gpio2, Gpio3}; 17 | use rp2040_hal::gpio::{FunctionI2c, PullUp}; 18 | use ssd1306::mode::BufferedGraphicsMode; 19 | use ssd1306::prelude::{Brightness, DisplaySize128x32, I2CInterface}; 20 | use ssd1306::Ssd1306; 21 | 22 | #[macro_export] 23 | macro_rules! static_draw_unit_string { 24 | ($raw: literal) => {{ 25 | const _CHECK: () = assert!($raw.len() <= 8, "String too long to fit heapless string 5"); 26 | let mut s: heapless::String<8> = heapless::String::new(); 27 | let _ = s.push_str($raw); 28 | s 29 | }}; 30 | } 31 | 32 | pub type OledLineString = heapless::String<8>; 33 | pub const OLED_LINE_HEIGHT: u32 = 8; 34 | pub const OLED_LINE_WIDTH: u32 = 32; 35 | 36 | pub struct DrawUnit { 37 | pub content: OledLineString, 38 | pub needs_redraw: bool, 39 | } 40 | 41 | impl DrawUnit { 42 | pub fn new(content: OledLineString, needs_redraw: bool) -> Self { 43 | Self { 44 | content, 45 | needs_redraw, 46 | } 47 | } 48 | } 49 | 50 | pub struct OledHandle { 51 | display: Ssd1306< 52 | I2CInterface< 53 | rp2040_hal::I2C< 54 | I2C1, 55 | ( 56 | rp2040_hal::gpio::Pin, 57 | rp2040_hal::gpio::Pin, 58 | ), 59 | >, 60 | >, 61 | DisplaySize128x32, 62 | BufferedGraphicsMode, 63 | >, 64 | } 65 | 66 | impl OledHandle { 67 | pub fn new( 68 | mut display: Ssd1306< 69 | I2CInterface< 70 | rp2040_hal::I2C< 71 | I2C1, 72 | ( 73 | rp2040_hal::gpio::Pin, 74 | rp2040_hal::gpio::Pin, 75 | ), 76 | >, 77 | >, 78 | DisplaySize128x32, 79 | BufferedGraphicsMode, 80 | >, 81 | ) -> Self { 82 | let _ = display.set_brightness(Brightness::BRIGHTEST); 83 | Self { display } 84 | } 85 | 86 | pub fn clear(&mut self) { 87 | let _ = self.display.clear(BinaryColor::Off); 88 | let _ = self.display.flush(); 89 | } 90 | 91 | #[inline(never)] 92 | pub fn write_header(&mut self, l: i32, s: &str) -> bool { 93 | let text_style = MonoTextStyleBuilder::new() 94 | .font(&FONT_5X7) 95 | .text_color(BinaryColor::On) 96 | .build(); 97 | if Text::with_baseline(s, Point::new(0, l), text_style, Baseline::Top) 98 | .draw(&mut self.display) 99 | .is_ok() 100 | { 101 | return self.display.flush().is_ok(); 102 | } 103 | false 104 | } 105 | 106 | #[inline(never)] 107 | pub fn write(&mut self, l: i32, s: &str) -> bool { 108 | let text_style = MonoTextStyleBuilder::new() 109 | .font(&FONT_4X6) 110 | .text_color(BinaryColor::On) 111 | .build(); 112 | if Text::with_baseline(s, Point::new(0, l), text_style, Baseline::Top) 113 | .draw(&mut self.display) 114 | .is_ok() 115 | { 116 | return self.display.flush().is_ok(); 117 | } 118 | false 119 | } 120 | 121 | #[inline(never)] 122 | pub fn clear_line(&mut self, l: i32) -> bool { 123 | if self 124 | .display 125 | .fill_solid( 126 | &Rectangle { 127 | top_left: Point::new(0, l), 128 | size: Size::new(OLED_LINE_WIDTH, OLED_LINE_HEIGHT), 129 | }, 130 | BinaryColor::Off, 131 | ) 132 | .is_ok() 133 | { 134 | self.display.flush().is_ok() 135 | } else { 136 | false 137 | } 138 | } 139 | 140 | #[inline(never)] 141 | pub fn write_underscored_at(&mut self, l: i32) -> bool { 142 | if self 143 | .display 144 | .fill_solid( 145 | &Rectangle { 146 | top_left: Point::new(0, l), 147 | size: Size::new(OLED_LINE_WIDTH, 1), 148 | }, 149 | BinaryColor::On, 150 | ) 151 | .is_ok() 152 | { 153 | self.display.flush().is_ok() 154 | } else { 155 | false 156 | } 157 | } 158 | #[inline(never)] 159 | pub fn write_bad_boot_msg(&mut self) { 160 | let _ = self.display.clear(BinaryColor::Off); 161 | let _ = self.display.flush(); 162 | let _ = self.write(0, "BAD"); 163 | let _ = self.write(9, "IMAGE"); 164 | let _ = self.write(18, "FORCE"); 165 | let _ = self.write(27, "BOOT"); 166 | let _ = self.display.flush(); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/right.rs: -------------------------------------------------------------------------------- 1 | use crate::keyboard::oled::right::RightOledDrawer; 2 | use crate::keyboard::oled::OledHandle; 3 | use crate::keyboard::power_led::PowerLed; 4 | use crate::keyboard::right::message_serializer::MessageSerializer; 5 | use crate::keyboard::right::RightButtons; 6 | use crate::runtime::shared::cores_right::{ 7 | new_shared_queue, pop_message, push_loop_to_admin, try_push_touch, Consumer, 8 | KeycoreToAdminMessage, Producer, 9 | }; 10 | use crate::runtime::shared::loop_counter::LoopCounter; 11 | use crate::runtime::shared::press_latency_counter::PressLatencyCounter; 12 | use crate::runtime::shared::sleep::SleepCountdown; 13 | #[cfg(feature = "serial")] 14 | use core::fmt::Write; 15 | use rp2040_hal::clocks::SystemClock; 16 | use rp2040_hal::multicore::{Multicore, Stack}; 17 | use rp2040_hal::rom_data::reset_to_usb_boot; 18 | use rp2040_hal::{Clock, Timer}; 19 | 20 | static CORE_1_STACK_AREA: Stack<2048> = Stack::new(); 21 | // Boot loop if the queue is bugged, not bothering with MemUninit here 22 | #[inline(never)] 23 | pub fn run_right<'a>( 24 | mc: &'a mut Multicore<'a>, 25 | #[cfg(feature = "serial")] usb_bus: usb_device::bus::UsbBusAllocator, 26 | mut oled_handle: OledHandle, 27 | uart_driver: crate::keyboard::split_serial::UartRight, 28 | right_buttons: RightButtons, 29 | power_led_pin: PowerLed, 30 | timer: Timer, 31 | clock: &SystemClock, 32 | ) -> ! { 33 | #[cfg(feature = "serial")] 34 | unsafe { 35 | crate::runtime::shared::usb::init_usb(usb_bus); 36 | }; 37 | let cores = mc.cores(); 38 | let c1 = &mut cores[1]; 39 | let serializer = MessageSerializer::new(uart_driver); 40 | let (producer, consumer) = new_shared_queue(); 41 | if let Err(_e) = c1.spawn(CORE_1_STACK_AREA.take().unwrap(), move || { 42 | run_key_core(serializer, right_buttons, timer, producer) 43 | }) { 44 | oled_handle.clear(); 45 | oled_handle.write(0, "ERROR"); 46 | oled_handle.write(9, "SPAWN"); 47 | oled_handle.write(18, "CORE1"); 48 | oled_handle.write(27, "FAIL"); 49 | oled_handle.write(36, "BOOT"); 50 | reset_to_usb_boot(0, 0); 51 | panic!(); 52 | } 53 | run_admin_core(oled_handle, consumer, timer, power_led_pin, clock) 54 | } 55 | #[expect(clippy::needless_pass_by_value)] 56 | fn run_admin_core( 57 | oled_handle: OledHandle, 58 | consumer: Consumer, 59 | timer: Timer, 60 | mut power_led_pin: PowerLed, 61 | clock: &SystemClock, 62 | ) -> ! { 63 | let mut oled = RightOledDrawer::new(oled_handle); 64 | #[cfg(feature = "serial")] 65 | let mut last_chars = [0u8; 128]; 66 | #[cfg(feature = "serial")] 67 | let mut output_all = false; 68 | #[cfg(feature = "serial")] 69 | let mut has_dumped = false; 70 | let mut sleep = SleepCountdown::new(); 71 | let mut press_counter = PressLatencyCounter::new(); 72 | let mut tx: u16 = 0; 73 | let mut last_avail = 0; 74 | oled.set_clock(clock.freq()); 75 | loop { 76 | let now = timer.get_counter(); 77 | let avail = consumer.available(); 78 | match pop_message(&consumer) { 79 | Some(KeycoreToAdminMessage::Loop(lc)) => { 80 | if sleep.is_awake() { 81 | oled.update_scan_loop(lc.as_micros_fraction()); 82 | } 83 | } 84 | Some(KeycoreToAdminMessage::Touch { 85 | tx_bytes, 86 | loop_duration, 87 | }) => { 88 | sleep.touch(now); 89 | tx += tx_bytes; 90 | if tx > 9999 { 91 | tx = tx_bytes; 92 | } 93 | oled.update_touch(tx, press_counter.increment_get_avg(loop_duration)); 94 | oled.show(); 95 | power_led_pin.turn_on(); 96 | } 97 | Some(KeycoreToAdminMessage::Reboot) => { 98 | oled.render_boot_msg(); 99 | reset_to_usb_boot(0, 0); 100 | panic!("HALT POST RESET"); 101 | } 102 | _ => {} 103 | } 104 | if avail != last_avail { 105 | oled.update_queue(avail); 106 | last_avail = avail; 107 | } 108 | if sleep.should_sleep(now) { 109 | sleep.set_sleeping(); 110 | oled.hide(); 111 | power_led_pin.turn_off(); 112 | } 113 | oled.render(); 114 | #[cfg(feature = "serial")] 115 | { 116 | handle_usb(&mut power_led_pin, &mut last_chars, &mut output_all); 117 | if output_all && !has_dumped { 118 | let _ = 119 | crate::runtime::shared::usb::acquire_usb().write_str("Right side running\r\n"); 120 | has_dumped = true; 121 | } 122 | } 123 | } 124 | } 125 | 126 | #[cfg(feature = "serial")] 127 | fn handle_usb(power_led: &mut PowerLed, last_chars: &mut [u8], output_all: &mut bool) { 128 | let mut usb = crate::runtime::shared::usb::acquire_usb(); 129 | if usb 130 | .dev 131 | .as_mut() 132 | .unwrap() 133 | .inner 134 | .poll(&mut [&mut usb.serial.as_mut().unwrap().inner]) 135 | { 136 | let last_chars_len = last_chars.len(); 137 | let mut buf = [0u8; 64]; 138 | match usb.serial.as_mut().unwrap().inner.read(&mut buf) { 139 | Err(_e) => { 140 | // Do nothing 141 | } 142 | Ok(0) => { 143 | // Do nothing 144 | } 145 | Ok(count) => { 146 | for byte in &buf[..count] { 147 | last_chars.copy_within(1..last_chars_len, 0); 148 | last_chars[last_chars.len() - 1] = *byte; 149 | if last_chars.ends_with(b"boot") { 150 | let _ = usb.write_str("BOOT\r\n"); 151 | rp2040_hal::rom_data::reset_to_usb_boot(0, 0); 152 | } else if last_chars.ends_with(b"output") { 153 | *usb.output = true; 154 | let _ = usb.write_str("output ON\r\n"); 155 | *output_all = true; 156 | } else if last_chars.ends_with(b"led") { 157 | if power_led.is_on() { 158 | power_led.turn_off(); 159 | } else { 160 | power_led.turn_on(); 161 | } 162 | } 163 | } 164 | } 165 | } 166 | } 167 | } 168 | 169 | #[expect(clippy::needless_pass_by_value)] 170 | fn run_key_core( 171 | mut serializer: MessageSerializer, 172 | mut right_buttons: RightButtons, 173 | timer: Timer, 174 | producer: Producer, 175 | ) -> ! { 176 | let mut loop_count: LoopCounter<10_000> = LoopCounter::new(timer.get_counter()); 177 | right_buttons.scan_encoder(&mut serializer); 178 | let mut tx = 0; 179 | loop { 180 | let loop_timer = timer.get_counter(); 181 | tx += right_buttons.scan_matrix(&mut serializer, timer, &producer); 182 | if right_buttons.scan_encoder(&mut serializer) { 183 | tx += 1; 184 | } 185 | 186 | if loop_count.increment() { 187 | let now = timer.get_counter(); 188 | let lc = loop_count.value(now); 189 | if push_loop_to_admin(&producer, lc) { 190 | loop_count.reset(now); 191 | } 192 | } 193 | if tx > 0 { 194 | if let Some(dur) = timer.get_counter().checked_duration_since(loop_timer) { 195 | if try_push_touch(&producer, tx, dur) { 196 | tx = 0; 197 | } 198 | } 199 | } 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/oled/right.rs: -------------------------------------------------------------------------------- 1 | use crate::keyboard::oled::{DrawUnit, OledHandle}; 2 | use crate::static_draw_unit_string; 3 | use core::fmt::Write; 4 | use rp2040_hal::fugit::HertzU32; 5 | 6 | pub struct RightOledDrawer { 7 | handle: OledHandle, 8 | hidden: bool, 9 | header: DrawUnit, 10 | scan_loop_header: DrawUnit, 11 | scan_loop_content: DrawUnit, 12 | press_loop_content: DrawUnit, 13 | dbg_header: DrawUnit, 14 | dbg_tx: DrawUnit, 15 | dbg_queue: DrawUnit, 16 | clk_header: DrawUnit, 17 | clk_freq: DrawUnit, 18 | underscores_need_redraw: bool, 19 | } 20 | 21 | impl RightOledDrawer { 22 | pub fn new(handle: OledHandle) -> Self { 23 | let header_content = static_draw_unit_string!("RIGHT"); 24 | let scan_loop_header_content = static_draw_unit_string!("PERF"); 25 | let scan_loop_content = static_draw_unit_string!("S ..."); 26 | let press_loop_content = static_draw_unit_string!("P ..."); 27 | let dbg_header = static_draw_unit_string!("DEBUG"); 28 | let dbg_tx = static_draw_unit_string!("T ..."); 29 | let dbg_queue = static_draw_unit_string!("Q ..."); 30 | let clk_header = static_draw_unit_string!("CLOCK"); 31 | let clk_freq = static_draw_unit_string!("..."); 32 | Self { 33 | handle, 34 | hidden: false, 35 | header: DrawUnit::new(header_content, true), 36 | scan_loop_header: DrawUnit::new(scan_loop_header_content, true), 37 | scan_loop_content: DrawUnit::new(scan_loop_content, true), 38 | press_loop_content: DrawUnit::new(press_loop_content, true), 39 | dbg_header: DrawUnit::new(dbg_header, true), 40 | dbg_tx: DrawUnit::new(dbg_tx, true), 41 | dbg_queue: DrawUnit::new(dbg_queue, true), 42 | clk_header: DrawUnit::new(clk_header, true), 43 | clk_freq: DrawUnit::new(clk_freq, true), 44 | underscores_need_redraw: true, 45 | } 46 | } 47 | 48 | #[inline] 49 | pub fn hide(&mut self) { 50 | self.handle.clear(); 51 | self.hidden = true; 52 | } 53 | 54 | #[inline] 55 | pub fn show(&mut self) { 56 | if self.hidden { 57 | self.header.needs_redraw = true; 58 | self.scan_loop_header.needs_redraw = true; 59 | self.scan_loop_content.needs_redraw = true; 60 | self.press_loop_content.needs_redraw = true; 61 | self.dbg_header.needs_redraw = true; 62 | self.dbg_tx.needs_redraw = true; 63 | self.dbg_queue.needs_redraw = true; 64 | self.clk_header.needs_redraw = true; 65 | self.clk_freq.needs_redraw = true; 66 | self.underscores_need_redraw = true; 67 | } 68 | self.hidden = false; 69 | } 70 | 71 | pub fn update_scan_loop(&mut self, avg_scan_latency: f32) { 72 | self.scan_loop_content.content.clear(); 73 | let _ = self 74 | .scan_loop_content 75 | .content 76 | .write_fmt(format_args!("S {avg_scan_latency:.1}")); 77 | self.scan_loop_content.needs_redraw = true; 78 | } 79 | 80 | pub fn update_touch(&mut self, transmitted: u16, avg_latency: f32) { 81 | self.press_loop_content.content.clear(); 82 | let _ = self 83 | .press_loop_content 84 | .content 85 | .write_fmt(format_args!("P {avg_latency:.1}")); 86 | self.press_loop_content.needs_redraw = true; 87 | self.dbg_tx.content.clear(); 88 | let _ = self 89 | .dbg_tx 90 | .content 91 | .write_fmt(format_args!("T {transmitted}")); 92 | self.dbg_tx.needs_redraw = true; 93 | } 94 | pub fn update_queue(&mut self, count: usize) { 95 | self.dbg_queue.content.clear(); 96 | let _ = self.dbg_queue.content.write_fmt(format_args!("Q {count}")); 97 | self.dbg_queue.needs_redraw = true; 98 | } 99 | 100 | pub fn set_clock(&mut self, freq: HertzU32) { 101 | self.clk_freq.content.clear(); 102 | let _ = self 103 | .clk_freq 104 | .content 105 | .write_fmt(format_args!("{}Mhz", freq.to_MHz())); 106 | self.clk_freq.needs_redraw = true; 107 | } 108 | 109 | pub fn render(&mut self) { 110 | if self.hidden { 111 | return; 112 | } 113 | if self.header.needs_redraw { 114 | let _ = self.handle.clear_line(0); 115 | let _ = self.handle.write_header(0, self.header.content.as_str()); 116 | self.header.needs_redraw = false; 117 | } 118 | if self.scan_loop_header.needs_redraw { 119 | let _ = self.handle.clear_line(12); 120 | let _ = self 121 | .handle 122 | .write_header(12, self.scan_loop_header.content.as_str()); 123 | self.scan_loop_header.needs_redraw = false; 124 | } 125 | if self.scan_loop_content.needs_redraw { 126 | let _ = self.handle.clear_line(20); 127 | let _ = self 128 | .handle 129 | .write_header(20, self.scan_loop_content.content.as_str()); 130 | self.scan_loop_content.needs_redraw = false; 131 | } 132 | if self.press_loop_content.needs_redraw { 133 | let _ = self.handle.clear_line(28); 134 | let _ = self 135 | .handle 136 | .write_header(28, self.press_loop_content.content.as_str()); 137 | self.press_loop_content.needs_redraw = false; 138 | } 139 | if self.dbg_header.needs_redraw { 140 | let _ = self.handle.clear_line(40); 141 | let _ = self 142 | .handle 143 | .write_header(40, self.dbg_header.content.as_str()); 144 | self.dbg_header.needs_redraw = false; 145 | } 146 | if self.dbg_tx.needs_redraw { 147 | let _ = self.handle.clear_line(48); 148 | let _ = self.handle.write_header(48, self.dbg_tx.content.as_str()); 149 | self.dbg_tx.needs_redraw = false; 150 | } 151 | if self.dbg_queue.needs_redraw { 152 | let _ = self.handle.clear_line(56); 153 | let _ = self 154 | .handle 155 | .write_header(56, self.dbg_queue.content.as_str()); 156 | self.dbg_queue.needs_redraw = false; 157 | } 158 | if self.clk_header.needs_redraw { 159 | let _ = self.handle.clear_line(68); 160 | let _ = self 161 | .handle 162 | .write_header(68, self.clk_header.content.as_str()); 163 | self.clk_header.needs_redraw = false; 164 | } 165 | if self.clk_freq.needs_redraw { 166 | let _ = self.handle.clear_line(76); 167 | let _ = self.handle.write_header(76, self.clk_freq.content.as_str()); 168 | self.clk_freq.needs_redraw = false; 169 | } 170 | if self.underscores_need_redraw { 171 | // Header 172 | let _ = self.handle.write_underscored_at(8); 173 | // Perf 174 | let _ = self.handle.write_underscored_at(36); 175 | // Dbg 176 | let _ = self.handle.write_underscored_at(64); 177 | // Clock 178 | let _ = self.handle.write_underscored_at(84); 179 | self.underscores_need_redraw = false; 180 | } 181 | } 182 | 183 | pub fn render_boot_msg(&mut self) { 184 | self.handle.clear(); 185 | let _ = self.handle.write(0, "RIGHT"); 186 | let _ = self.handle.write(9, "SIDE"); 187 | let _ = self.handle.write(18, "ENTER"); 188 | let _ = self.handle.write(27, "USB"); 189 | let _ = self.handle.write(36, "BOOT"); 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/oled/left.rs: -------------------------------------------------------------------------------- 1 | use crate::keyboard::oled::{DrawUnit, OledHandle, OledLineString}; 2 | use crate::static_draw_unit_string; 3 | use core::fmt::Write; 4 | use rp2040_hal::fugit::HertzU32; 5 | 6 | pub struct LeftOledDrawer { 7 | handle: OledHandle, 8 | hidden: bool, 9 | header: DrawUnit, 10 | scan_loop_header: DrawUnit, 11 | scan_loop_content: DrawUnit, 12 | press_left_loop_content: DrawUnit, 13 | press_right_loop_content: DrawUnit, 14 | dbg_header: DrawUnit, 15 | dbg_rx: DrawUnit, 16 | dbg_queue: DrawUnit, 17 | clk_header: DrawUnit, 18 | clk_freq: DrawUnit, 19 | layer_header: DrawUnit, 20 | perm_layer: DrawUnit, 21 | underscores_need_redraw: bool, 22 | } 23 | 24 | impl LeftOledDrawer { 25 | pub fn new(handle: OledHandle) -> Self { 26 | let header_content = static_draw_unit_string!("LEFT"); 27 | let scan_loop_header_content = static_draw_unit_string!("PERF"); 28 | let scan_loop_content = static_draw_unit_string!("S ..."); 29 | let press_left_loop_content = static_draw_unit_string!("L ..."); 30 | let press_right_loop_content = static_draw_unit_string!("R ..."); 31 | let dbg_header = static_draw_unit_string!("DEBUG"); 32 | let dbg_rx = static_draw_unit_string!("R ..."); 33 | let dbg_queue = static_draw_unit_string!("Q ..."); 34 | let clk_header = static_draw_unit_string!("CLOCK"); 35 | let clk_freq = static_draw_unit_string!("..."); 36 | let layer_header = static_draw_unit_string!("LAYER"); 37 | Self { 38 | handle, 39 | hidden: false, 40 | header: DrawUnit::new(header_content, true), 41 | scan_loop_header: DrawUnit::new(scan_loop_header_content, true), 42 | scan_loop_content: DrawUnit::new(scan_loop_content, true), 43 | press_left_loop_content: DrawUnit::new(press_left_loop_content, true), 44 | press_right_loop_content: DrawUnit::new(press_right_loop_content, true), 45 | dbg_header: DrawUnit::new(dbg_header, true), 46 | dbg_rx: DrawUnit::new(dbg_rx, true), 47 | dbg_queue: DrawUnit::new(dbg_queue, true), 48 | clk_header: DrawUnit::new(clk_header, true), 49 | clk_freq: DrawUnit::new(clk_freq, true), 50 | layer_header: DrawUnit::new(layer_header, true), 51 | perm_layer: DrawUnit::new(static_draw_unit_string!("..."), true), 52 | underscores_need_redraw: true, 53 | } 54 | } 55 | 56 | pub fn hide(&mut self) { 57 | self.handle.clear(); 58 | self.hidden = true; 59 | } 60 | 61 | pub fn show(&mut self) { 62 | if self.hidden { 63 | self.header.needs_redraw = true; 64 | self.scan_loop_header.needs_redraw = true; 65 | self.scan_loop_content.needs_redraw = true; 66 | self.press_left_loop_content.needs_redraw = true; 67 | self.press_right_loop_content.needs_redraw = true; 68 | self.dbg_header.needs_redraw = true; 69 | self.dbg_rx.needs_redraw = true; 70 | self.dbg_queue.needs_redraw = true; 71 | self.clk_header.needs_redraw = true; 72 | self.clk_freq.needs_redraw = true; 73 | self.layer_header.needs_redraw = true; 74 | self.perm_layer.needs_redraw = true; 75 | self.underscores_need_redraw = true; 76 | } 77 | self.hidden = false; 78 | } 79 | 80 | pub fn update_scan_loop(&mut self, avg_scan_latency: f32) { 81 | self.scan_loop_content.content.clear(); 82 | let _ = self 83 | .scan_loop_content 84 | .content 85 | .write_fmt(format_args!("S {avg_scan_latency:.1}")); 86 | self.scan_loop_content.needs_redraw = true; 87 | } 88 | 89 | pub fn update_left_counter(&mut self, avg_latency: f32) { 90 | self.press_left_loop_content.content.clear(); 91 | let _ = self 92 | .press_left_loop_content 93 | .content 94 | .write_fmt(format_args!("L {avg_latency:.1}")); 95 | self.press_left_loop_content.needs_redraw = true; 96 | } 97 | 98 | pub fn update_right_counter(&mut self, avg_latency: f32) { 99 | self.press_right_loop_content.content.clear(); 100 | let _ = self 101 | .press_right_loop_content 102 | .content 103 | .write_fmt(format_args!("R {avg_latency:.1}")); 104 | self.press_right_loop_content.needs_redraw = true; 105 | } 106 | 107 | pub fn update_layer(&mut self, default_layer: OledLineString) { 108 | self.perm_layer.content = default_layer; 109 | self.perm_layer.needs_redraw = true; 110 | } 111 | 112 | pub fn update_rx(&mut self, count: u16) { 113 | self.dbg_rx.content.clear(); 114 | let _ = self.dbg_rx.content.write_fmt(format_args!("R {count}")); 115 | self.dbg_rx.needs_redraw = true; 116 | } 117 | 118 | pub fn update_queue(&mut self, count: usize) { 119 | self.dbg_queue.content.clear(); 120 | let _ = self.dbg_queue.content.write_fmt(format_args!("Q {count}")); 121 | self.dbg_queue.needs_redraw = true; 122 | } 123 | 124 | pub fn set_clock(&mut self, freq: HertzU32) { 125 | self.clk_freq.content.clear(); 126 | let _ = self 127 | .clk_freq 128 | .content 129 | .write_fmt(format_args!("{}Mhz", freq.to_MHz())); 130 | } 131 | 132 | pub fn render(&mut self) { 133 | if self.hidden { 134 | return; 135 | } 136 | if self.header.needs_redraw { 137 | let _ = self.handle.clear_line(0); 138 | let _ = self.handle.write_header(0, self.header.content.as_str()); 139 | self.header.needs_redraw = false; 140 | } 141 | if self.scan_loop_header.needs_redraw { 142 | let _ = self.handle.clear_line(12); 143 | let _ = self 144 | .handle 145 | .write_header(12, self.scan_loop_header.content.as_str()); 146 | self.scan_loop_header.needs_redraw = false; 147 | } 148 | if self.scan_loop_content.needs_redraw { 149 | let _ = self.handle.clear_line(20); 150 | let _ = self 151 | .handle 152 | .write_header(20, self.scan_loop_content.content.as_str()); 153 | self.scan_loop_content.needs_redraw = false; 154 | } 155 | if self.press_left_loop_content.needs_redraw { 156 | let _ = self.handle.clear_line(28); 157 | let _ = self 158 | .handle 159 | .write_header(28, self.press_left_loop_content.content.as_str()); 160 | self.press_left_loop_content.needs_redraw = false; 161 | } 162 | if self.press_right_loop_content.needs_redraw { 163 | let _ = self.handle.clear_line(36); 164 | let _ = self 165 | .handle 166 | .write_header(36, self.press_right_loop_content.content.as_str()); 167 | self.press_right_loop_content.needs_redraw = false; 168 | } 169 | if self.dbg_header.needs_redraw { 170 | let _ = self.handle.clear_line(48); 171 | let _ = self 172 | .handle 173 | .write_header(48, self.dbg_header.content.as_str()); 174 | self.dbg_header.needs_redraw = false; 175 | } 176 | if self.dbg_rx.needs_redraw { 177 | let _ = self.handle.clear_line(56); 178 | let _ = self.handle.write_header(56, self.dbg_rx.content.as_str()); 179 | self.dbg_rx.needs_redraw = false; 180 | } 181 | if self.dbg_queue.needs_redraw { 182 | let _ = self.handle.clear_line(64); 183 | let _ = self 184 | .handle 185 | .write_header(64, self.dbg_queue.content.as_str()); 186 | self.dbg_queue.needs_redraw = false; 187 | } 188 | if self.clk_header.needs_redraw { 189 | let _ = self.handle.clear_line(76); 190 | let _ = self 191 | .handle 192 | .write_header(76, self.clk_header.content.as_str()); 193 | self.clk_header.needs_redraw = false; 194 | } 195 | if self.clk_freq.needs_redraw { 196 | let _ = self.handle.clear_line(84); 197 | let _ = self.handle.write_header(84, self.clk_freq.content.as_str()); 198 | self.clk_freq.needs_redraw = false; 199 | } 200 | if self.layer_header.needs_redraw { 201 | let _ = self.handle.clear_line(96); 202 | let _ = self 203 | .handle 204 | .write_header(96, self.layer_header.content.as_str()); 205 | self.layer_header.needs_redraw = false; 206 | } 207 | if self.perm_layer.needs_redraw { 208 | let _ = self.handle.clear_line(104); 209 | let _ = self 210 | .handle 211 | .write_header(104, self.perm_layer.content.as_str()); 212 | self.perm_layer.needs_redraw = false; 213 | } 214 | if self.underscores_need_redraw { 215 | // Header 216 | let _ = self.handle.write_underscored_at(8); 217 | // Perf 218 | let _ = self.handle.write_underscored_at(44); 219 | // Clock 220 | let _ = self.handle.write_underscored_at(72); 221 | // Dbg 222 | let _ = self.handle.write_underscored_at(92); 223 | // Layer 224 | let _ = self.handle.write_underscored_at(112); 225 | self.underscores_need_redraw = false; 226 | } 227 | } 228 | 229 | pub fn render_boot_msg(&mut self) { 230 | self.handle.clear(); 231 | let _ = self.handle.write_header(0, "LEFT"); 232 | let _ = self.handle.write_header(9, "SIDE"); 233 | let _ = self.handle.write_header(18, "ENTER"); 234 | let _ = self.handle.write_header(27, "USB"); 235 | let _ = self.handle.write_header(36, "BOOT"); 236 | } 237 | } 238 | 239 | pub fn layer_to_string(keymap_layer: crate::keymap::KeymapLayer) -> OledLineString { 240 | let mut s = heapless::String::new(); 241 | match keymap_layer { 242 | crate::keymap::KeymapLayer::DvorakSe => { 243 | let _ = s.push_str("DV-SE"); 244 | } 245 | crate::keymap::KeymapLayer::DvorakAnsi => { 246 | let _ = s.push_str("DV-AN"); 247 | } 248 | crate::keymap::KeymapLayer::QwertyGaming => { 249 | let _ = s.push_str("QW-GM"); 250 | } 251 | crate::keymap::KeymapLayer::Lower => { 252 | let _ = s.push_str("LO"); 253 | } 254 | crate::keymap::KeymapLayer::LowerAnsi => { 255 | let _ = s.push_str("LO-AN"); 256 | } 257 | crate::keymap::KeymapLayer::Raise => { 258 | let _ = s.push_str("RA"); 259 | } 260 | crate::keymap::KeymapLayer::Num => { 261 | let _ = s.push_str("NUM"); 262 | } 263 | crate::keymap::KeymapLayer::Settings => { 264 | let _ = s.push_str("SET"); 265 | } 266 | } 267 | s 268 | } 269 | -------------------------------------------------------------------------------- /rp2040-kbd/src/runtime/left.rs: -------------------------------------------------------------------------------- 1 | use crate::keyboard::left::message_receiver::MessageReceiver; 2 | use crate::keyboard::left::LeftButtons; 3 | use crate::keyboard::oled::left::{layer_to_string, LeftOledDrawer}; 4 | use crate::keyboard::oled::OledHandle; 5 | use crate::keyboard::power_led::PowerLed; 6 | use crate::keyboard::split_serial::UartLeft; 7 | use crate::keymap::{KeyboardReportState, KeymapLayer}; 8 | use crate::runtime::shared::cores_left::{ 9 | new_shared_queue, pop_message, push_loop_to_admin, push_rx_change, push_touch_left_to_admin, 10 | push_touch_right_to_admin, Consumer, KeycoreToAdminMessage, Producer, 11 | }; 12 | use crate::runtime::shared::loop_counter::LoopCounter; 13 | use crate::runtime::shared::press_latency_counter::PressLatencyCounter; 14 | use crate::runtime::shared::sleep::SleepCountdown; 15 | #[cfg(feature = "serial")] 16 | use crate::runtime::shared::usb::init_usb; 17 | #[cfg(feature = "serial")] 18 | use core::fmt::Write; 19 | #[cfg(feature = "hiddev")] 20 | use liatris::pac::interrupt; 21 | use rp2040_hal::clocks::SystemClock; 22 | use rp2040_hal::multicore::{Multicore, Stack}; 23 | use rp2040_hal::rom_data::reset_to_usb_boot; 24 | use rp2040_hal::{Clock, Timer}; 25 | use usb_device::bus::UsbBusAllocator; 26 | 27 | static CORE_1_STACK: Stack<{ 1024 * 8 }> = Stack::new(); 28 | 29 | #[inline(never)] 30 | pub fn run_left<'a>( 31 | mc: &'a mut Multicore<'a>, 32 | usb_bus: UsbBusAllocator, 33 | mut oled_handle: OledHandle, 34 | uart_driver: UartLeft, 35 | left_buttons: LeftButtons, 36 | power_led_pin: PowerLed, 37 | timer: Timer, 38 | system_clock: &SystemClock, 39 | ) -> ! { 40 | #[cfg(feature = "serial")] 41 | unsafe { 42 | init_usb(usb_bus); 43 | } 44 | let receiver = MessageReceiver::new(uart_driver); 45 | let (producer, consumer) = new_shared_queue(); 46 | if let Err(_e) = mc.cores()[1].spawn(CORE_1_STACK.take().unwrap(), move || { 47 | run_key_processsing_core( 48 | receiver, 49 | left_buttons, 50 | timer, 51 | producer, 52 | #[cfg(feature = "hiddev")] 53 | usb_bus, 54 | ) 55 | }) { 56 | oled_handle.clear(); 57 | oled_handle.write(0, "ERROR"); 58 | oled_handle.write(9, "SPAWN"); 59 | oled_handle.write(18, "CORE1"); 60 | oled_handle.write(27, "FAIL"); 61 | oled_handle.write(36, "BOOT"); 62 | reset_to_usb_boot(0, 0); 63 | panic!(); 64 | } 65 | run_admin_core(oled_handle, consumer, timer, power_led_pin, system_clock) 66 | } 67 | 68 | #[expect(clippy::needless_pass_by_value)] 69 | pub fn run_admin_core( 70 | oled_handle: OledHandle, 71 | consumer: Consumer, 72 | timer: Timer, 73 | mut power_led_pin: PowerLed, 74 | sys_clock: &SystemClock, 75 | ) -> ! { 76 | let mut oled_left = LeftOledDrawer::new(oled_handle); 77 | #[cfg(feature = "serial")] 78 | let mut last_chars = [0u8; 128]; 79 | #[cfg(feature = "serial")] 80 | let mut output_all = false; 81 | #[cfg(feature = "serial")] 82 | let mut has_dumped = false; 83 | let mut sleep = SleepCountdown::new(); 84 | let mut rx: u16 = 0; 85 | let mut left_counter: PressLatencyCounter = PressLatencyCounter::new(); 86 | let mut right_counter: PressLatencyCounter = PressLatencyCounter::new(); 87 | let mut last_avail = 0; 88 | oled_left.update_layer(layer_to_string(KeymapLayer::DvorakSe)); 89 | oled_left.set_clock(sys_clock.freq()); 90 | loop { 91 | let avail = consumer.available(); 92 | let now = timer.get_counter(); 93 | match pop_message(&consumer) { 94 | Some(KeycoreToAdminMessage::TouchLeft(micros)) => { 95 | oled_left.update_left_counter(left_counter.increment_get_avg(micros)); 96 | sleep.touch(now); 97 | power_led_pin.turn_on(); 98 | oled_left.show(); 99 | } 100 | Some(KeycoreToAdminMessage::TouchRight(micros)) => { 101 | oled_left.update_right_counter(right_counter.increment_get_avg(micros)); 102 | sleep.touch(now); 103 | power_led_pin.turn_on(); 104 | oled_left.show(); 105 | } 106 | Some(KeycoreToAdminMessage::Loop(lc)) => { 107 | if sleep.is_awake() { 108 | oled_left.update_scan_loop(lc.as_micros_fraction()); 109 | } 110 | } 111 | Some(KeycoreToAdminMessage::LayerChange(default)) => { 112 | let dfl_out = layer_to_string(default); 113 | oled_left.update_layer(dfl_out); 114 | } 115 | Some(KeycoreToAdminMessage::Rx(incr)) => { 116 | rx += incr; 117 | if rx > 9999 { 118 | rx = incr; 119 | } 120 | sleep.touch(now); 121 | oled_left.update_rx(rx); 122 | } 123 | Some(KeycoreToAdminMessage::Reboot) => { 124 | oled_left.render_boot_msg(); 125 | reset_to_usb_boot(0, 0); 126 | panic!("HALT POST RESET"); 127 | } 128 | _ => {} 129 | } 130 | if avail != last_avail { 131 | oled_left.update_queue(avail); 132 | last_avail = avail; 133 | } 134 | if sleep.should_sleep(now) { 135 | oled_left.hide(); 136 | power_led_pin.turn_off(); 137 | sleep.set_sleeping(); 138 | } 139 | oled_left.render(); 140 | #[cfg(feature = "serial")] 141 | { 142 | handle_usb( 143 | &mut power_led_pin, 144 | &mut last_chars, 145 | &mut output_all, 146 | sys_clock, 147 | ); 148 | if output_all && !has_dumped { 149 | let _ = 150 | crate::runtime::shared::usb::acquire_usb().write_str("Left side running\r\n"); 151 | has_dumped = true; 152 | } 153 | } 154 | } 155 | } 156 | 157 | #[cfg(feature = "serial")] 158 | fn handle_usb( 159 | power_led: &mut PowerLed, 160 | last_chars: &mut [u8], 161 | output_all: &mut bool, 162 | clocks: &SystemClock, 163 | ) -> Option<()> { 164 | let usb = crate::runtime::shared::usb::acquire_usb(); 165 | let serial = usb.serial?; 166 | let dev = usb.dev?; 167 | if dev.inner.poll(&mut [&mut serial.inner]) { 168 | let last_chars_len = last_chars.len(); 169 | let mut buf = [0u8; 64]; 170 | match serial.inner.read(&mut buf) { 171 | Err(_e) => { 172 | // Do nothing 173 | } 174 | Ok(0) => { 175 | // Do nothing 176 | } 177 | Ok(count) => { 178 | for byte in &buf[..count] { 179 | last_chars.copy_within(1..last_chars_len, 0); 180 | last_chars[last_chars.len() - 1] = *byte; 181 | if last_chars.ends_with(b"boot") { 182 | let _ = serial.write_str("BOOT\r\n"); 183 | reset_to_usb_boot(0, 0); 184 | } else if last_chars.ends_with(b"output") { 185 | *usb.output = true; 186 | let _ = serial.write_str("OUTPUT ON\r\n"); 187 | *output_all = true; 188 | } else if last_chars.ends_with(b"led") { 189 | if power_led.is_on() { 190 | power_led.turn_off(); 191 | } else { 192 | power_led.turn_on(); 193 | } 194 | } else if last_chars.ends_with(b"CLOCK") { 195 | let _ = 196 | serial.write_fmt(format_args!("SYS={}\r\n", clocks.freq().to_MHz(),)); 197 | } 198 | } 199 | } 200 | } 201 | } 202 | Some(()) 203 | } 204 | 205 | #[expect(clippy::needless_pass_by_value)] 206 | pub fn run_key_processsing_core( 207 | mut receiver: MessageReceiver, 208 | mut left_buttons: LeftButtons, 209 | timer: Timer, 210 | producer: Producer, 211 | #[cfg(feature = "hiddev")] allocator: usb_device::bus::UsbBusAllocator< 212 | liatris::hal::usb::UsbBus, 213 | >, 214 | ) -> ! { 215 | #[cfg(feature = "hiddev")] 216 | unsafe { 217 | crate::runtime::shared::usb::init_usb_hiddev(allocator); 218 | } 219 | let mut kbd = crate::keymap::KeyboardState::new(); 220 | let mut report_state = KeyboardReportState::new(); 221 | let mut loop_count: LoopCounter<10_000> = LoopCounter::new(timer.get_counter()); 222 | #[cfg(feature = "hiddev")] 223 | unsafe { 224 | liatris::hal::pac::NVIC::unmask(liatris::pac::Interrupt::USBCTRL_IRQ); 225 | } 226 | let mut rx = 0; 227 | loop { 228 | let loop_timer = timer.get_counter(); 229 | let mut changed_left = false; 230 | let mut changed_right = false; 231 | if let Some(update) = receiver.try_read() { 232 | // Right side sent an update 233 | rx += 1; 234 | // Update report state 235 | kbd.update_right(update, &mut report_state, &producer); 236 | changed_right = true; 237 | } 238 | // Check left side gpio and update report state 239 | if kbd.scan_left(&mut left_buttons, &mut report_state, timer, &producer) { 240 | changed_left = true; 241 | } 242 | 243 | #[cfg(feature = "hiddev")] 244 | { 245 | let mut pop = false; 246 | if let Some(next_update) = report_state.report() { 247 | // Published the next update on queue if present 248 | unsafe { 249 | pop = crate::runtime::shared::usb::try_push_report(next_update); 250 | } 251 | } 252 | if pop { 253 | // Remove the sent report (it's down here because of the borrow checker) 254 | report_state.accept(); 255 | } 256 | } 257 | if rx > 0 && push_rx_change(&producer, rx) { 258 | rx = 0; 259 | } 260 | if loop_count.increment() { 261 | let now = timer.get_counter(); 262 | let lc = loop_count.value(now); 263 | if push_loop_to_admin(&producer, lc) { 264 | loop_count.reset(now); 265 | } 266 | } 267 | if let Some(dur) = timer.get_counter().checked_duration_since(loop_timer) { 268 | if changed_left { 269 | push_touch_left_to_admin(&producer, dur); 270 | } 271 | if changed_right { 272 | push_touch_right_to_admin(&producer, dur); 273 | } 274 | } 275 | } 276 | } 277 | 278 | /// Todo: Change to 'expect' after [this PR](https://github.com/rust-embedded/cortex-m/pull/557) 279 | /// Safety: Called from the same core that publishes 280 | #[interrupt] 281 | #[allow(clippy::allow_attributes, non_snake_case)] 282 | #[cfg(feature = "hiddev")] 283 | unsafe fn USBCTRL_IRQ() { 284 | crate::runtime::shared::usb::hiddev_interrupt_poll(); 285 | } 286 | -------------------------------------------------------------------------------- /rp2040-kbd/src/main.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(not(test), no_std)] 2 | #![no_main] 3 | 4 | mod hid; 5 | pub(crate) mod keyboard; 6 | #[cfg(feature = "left")] 7 | mod keymap; 8 | pub(crate) mod runtime; 9 | mod timer; 10 | 11 | use core::ops::Div; 12 | use embedded_graphics::draw_target::DrawTarget; 13 | use embedded_graphics::pixelcolor::BinaryColor; 14 | // The macro for our start-up function 15 | use liatris::{entry, Pins}; 16 | 17 | // Ensure we halt the program on panic (if we don't mention this crate it won't 18 | // be linked) 19 | #[cfg(not(test))] 20 | // A shorter alias for the Peripheral Access Crate, which provides low-level 21 | // register access 22 | use liatris::hal::pac; 23 | 24 | // A shorter alias for the Hardware Abstraction Layer, which provides 25 | // higher-level drivers. 26 | use liatris::hal; 27 | 28 | use crate::keyboard::oled::OledHandle; 29 | use crate::keyboard::power_led::PowerLed; 30 | use embedded_hal::digital::InputPin; 31 | use liatris::pac::vreg_and_chip_reset::vreg::VSEL_A; 32 | use liatris::pac::I2C1; 33 | use rp2040_hal::clocks::{ClocksManager, PeripheralClock}; 34 | use rp2040_hal::fugit::{HertzU32, RateExtU32}; 35 | use rp2040_hal::gpio::bank0::{Gpio2, Gpio3}; 36 | use rp2040_hal::gpio::{FunctionI2C, Pin, PullDown}; 37 | use rp2040_hal::multicore::Multicore; 38 | use rp2040_hal::pll::common_configs::PLL_USB_48MHZ; 39 | use rp2040_hal::pll::{setup_pll_blocking, PLLConfig}; 40 | use rp2040_hal::vreg::{get_voltage, set_voltage}; 41 | use rp2040_hal::xosc::setup_xosc_blocking; 42 | use rp2040_hal::Clock; 43 | use ssd1306::mode::DisplayConfig; 44 | use ssd1306::prelude::DisplayRotation; 45 | use ssd1306::size::DisplaySize128x32; 46 | use ssd1306::Ssd1306; 47 | 48 | #[cfg(all(feature = "serial", feature = "hiddev"))] 49 | const _ILLEGAL_FEATURES: () = assert!(false, "Can't compile as both serial and hiddev"); 50 | 51 | #[cfg(all(feature = "left", feature = "right"))] 52 | const _ILLEGAL_SIDES: () = assert!(false, "Can't compile as both right and left"); 53 | 54 | #[cfg(all(feature = "hiddev", feature = "right"))] 55 | const _RIGHT_HIDDEN: () = assert!(false, "Can't compile right as hiddev"); 56 | 57 | /// FREF is the xosc crystal freq (12Mhz) 58 | /// POSTDIV(both) 1 -7 59 | /// If postdiv has different values, POSTDIV1 should be higher 60 | /// for energy efficiency 61 | /// Refdiv recommended to be 1 62 | /// MAX VCO = 1600Mhz 63 | /// Docs says FBDIV which is, but that can be replaced with VCO since it's a part of it 64 | /// Calculate by (FREF / REFDIV) * FBDIV / (POSTDIV1 * POSTDIV2) 65 | /// Where VCO = FREF * FBDIV => FBDIV = VCO / FREF 66 | /// Ex: (12 / 1) * 133 / (6 * 2) => VCO = 12 * 133 = 1596Mhz 67 | /// There's a script for finding your optimal clock frequency here: 68 | /// 69 | /// Ex legal config for 200Mhz 70 | /// `VCO_FREQ` = 1200Mhz 71 | /// refdiv = 1 72 | /// postdiv1 = 6, postdiv2 = 1 73 | /// Higher VCO-freq decreases jitter but increases power consumption, 74 | /// The only way to increase VCO is to compromize on output frequency 75 | /// Below is a Legal config for 199.5Mhz 76 | /// `VCO_FREQ` = 1596 77 | /// REFDIV = 1 78 | /// FBDIV = 133 79 | /// POSTDIV1 = 4 80 | /// POSTDIV2 = 2 81 | const PLL_1995_MHZ: PLLConfig = PLLConfig { 82 | vco_freq: HertzU32::MHz(1596), 83 | refdiv: 1, 84 | post_div1: 4, 85 | post_div2: 2, 86 | }; 87 | 88 | /*/// Example 133Mhz config 89 | const PLL_133_MHZ: PLLConfig = PLLConfig { 90 | vco_freq: HertzU32::MHz(1596), 91 | refdiv: 1, 92 | post_div1: 6, 93 | post_div2: 2, 94 | };*/ 95 | 96 | /// Entry point to our bare-metal application. 97 | /// 98 | /// The `#[entry]` macro ensures the Cortex-M start-up code calls this function 99 | /// as soon as all global variables are initialised. 100 | /// 101 | /// The function configures the RP2040 peripherals, then echoes any characters 102 | /// received over USB Serial. 103 | #[entry] 104 | fn main() -> ! { 105 | setup_kbd() 106 | } 107 | 108 | #[expect(clippy::too_many_lines, clippy::cast_possible_truncation)] 109 | fn setup_kbd() -> ! { 110 | // Grab our singleton objects 111 | let mut pac = pac::Peripherals::take().unwrap(); 112 | 113 | // Up voltage if necessary for 200Mhz clock 114 | if get_voltage(&pac.VREG_AND_CHIP_RESET) != Some(VSEL_A::VOLTAGE1_15) { 115 | set_voltage(&mut pac.VREG_AND_CHIP_RESET, VSEL_A::VOLTAGE1_15); 116 | } 117 | 118 | // Set up the watchdog driver - needed by the clock setup code 119 | let mut watchdog = hal::Watchdog::new(pac.WATCHDOG); 120 | 121 | let xosc = setup_xosc_blocking(pac.XOSC, liatris::XOSC_CRYSTAL_FREQ.Hz()).unwrap(); 122 | watchdog.enable_tick_generation((liatris::XOSC_CRYSTAL_FREQ / 1_000_000) as u8); 123 | 124 | let mut clocks = ClocksManager::new(pac.CLOCKS); 125 | let pll_sys = setup_pll_blocking( 126 | pac.PLL_SYS, 127 | xosc.operating_frequency(), 128 | PLL_1995_MHZ, 129 | &mut clocks, 130 | &mut pac.RESETS, 131 | ) 132 | .unwrap(); 133 | let pll_usb = setup_pll_blocking( 134 | pac.PLL_USB, 135 | xosc.operating_frequency(), 136 | PLL_USB_48MHZ, 137 | &mut clocks, 138 | &mut pac.RESETS, 139 | ) 140 | .unwrap(); 141 | clocks.init_default(&xosc, &pll_sys, &pll_usb).unwrap(); 142 | // I want this high, but also as a clean divisor of the system clock 143 | // I'm using some weird protocol now with a header and footer on the message, 144 | // stretching it to 16 bits, to account for connects/disconnects of the right side 145 | // producing faulty messages. 146 | // The 'fake-uart' clock divisor is the baud-rate * 16, and can at most be 1, 147 | // I'm putting it at 1, so that's `199_500_000 / 16 => 12_468_750`. 148 | // Todo: Maybe check that this is a clean divisor 149 | let uart_baud = clocks.system_clock.freq().div(16); 150 | 151 | let timer = hal::Timer::new(pac.TIMER, &mut pac.RESETS, &clocks); 152 | let mut sio = hal::Sio::new(pac.SIO); 153 | let pins = Pins::new( 154 | pac.IO_BANK0, 155 | pac.PADS_BANK0, 156 | sio.gpio_bank0, 157 | &mut pac.RESETS, 158 | ); 159 | 160 | let sda_pin = pins.gpio2.into_function::(); 161 | let scl_pin = pins.gpio3.into_function::(); 162 | let mut oled = setup_oled( 163 | pac.I2C1, 164 | &mut pac.RESETS, 165 | sda_pin, 166 | scl_pin, 167 | &clocks.peripheral_clock, 168 | ); 169 | 170 | // Set up the USB driver 171 | #[cfg(any(feature = "serial", feature = "left"))] 172 | let usb_bus = usb_device::bus::UsbBusAllocator::new(hal::usb::UsbBus::new( 173 | pac.USBCTRL_REGS, 174 | pac.USBCTRL_DPRAM, 175 | clocks.usb_clock, 176 | true, 177 | &mut pac.RESETS, 178 | )); 179 | 180 | let mut side_check_pin = pins.gpio28.into_pull_up_input(); 181 | 182 | let power_led_pin = pins.power_led.into_push_pull_output(); 183 | let pl = PowerLed::new(power_led_pin); 184 | let is_left = side_check_pin.is_high().unwrap(); 185 | let mut mc = Multicore::new(&mut pac.PSM, &mut pac.PPB, &mut sio.fifo); 186 | if is_left { 187 | #[cfg(feature = "left")] 188 | { 189 | // Left side flips tx/rx, check qmk for proton-c in kyria for reference 190 | let uart = keyboard::split_serial::UartLeft::new( 191 | pins.gpio1, 192 | uart_baud, 193 | clocks.system_clock.freq(), 194 | pac.PIO0, 195 | &mut pac.RESETS, 196 | ); 197 | let left = crate::keyboard::left::LeftButtons::new( 198 | ( 199 | pins.gpio29.into_pull_up_input(), 200 | pins.gpio27.into_pull_up_input(), 201 | pins.gpio6.into_pull_up_input(), 202 | pins.gpio7.into_pull_up_input(), 203 | pins.gpio8.into_pull_up_input(), 204 | ), 205 | ( 206 | Some(pins.gpio9.into_pull_up_input()), 207 | Some(pins.gpio26.into_pull_up_input()), 208 | Some(pins.gpio22.into_pull_up_input()), 209 | Some(pins.gpio20.into_pull_up_input()), 210 | Some(pins.gpio23.into_pull_up_input()), 211 | Some(pins.gpio21.into_pull_up_input()), 212 | ), 213 | ); 214 | runtime::left::run_left( 215 | &mut mc, 216 | usb_bus, 217 | oled, 218 | uart, 219 | left, 220 | pl, 221 | timer, 222 | &clocks.system_clock, 223 | ); 224 | } 225 | #[cfg(not(feature = "left"))] 226 | { 227 | // Hard error, needs new firmware loaded 228 | oled.write_bad_boot_msg(); 229 | rp2040_hal::rom_data::reset_to_usb_boot(0, 0); 230 | unreachable!("Should have gone into boot"); 231 | } 232 | } else { 233 | #[cfg(feature = "right")] 234 | { 235 | let uart = keyboard::split_serial::UartRight::new( 236 | pins.gpio1.reconfigure(), 237 | uart_baud, 238 | clocks.system_clock.freq(), 239 | pac.PIO0, 240 | &mut pac.RESETS, 241 | ); 242 | let right = crate::keyboard::right::RightButtons::new( 243 | ( 244 | pins.gpio29.into_pull_up_input(), 245 | pins.gpio4.into_pull_up_input(), 246 | pins.gpio20.into_pull_up_input(), 247 | pins.gpio23.into_pull_up_input(), 248 | pins.gpio21.into_pull_up_input(), 249 | ), 250 | ( 251 | pins.gpio22.into_pull_up_input(), 252 | pins.gpio5.into_pull_up_input(), 253 | pins.gpio6.into_pull_up_input(), 254 | pins.gpio7.into_pull_up_input(), 255 | pins.gpio8.into_pull_up_input(), 256 | pins.gpio9.into_pull_up_input(), 257 | ), 258 | crate::keyboard::right::RotaryEncoder::new( 259 | pins.gpio26.into_pull_up_input(), 260 | pins.gpio27.into_pull_up_input(), 261 | ), 262 | ); 263 | runtime::right::run_right( 264 | &mut mc, 265 | #[cfg(feature = "serial")] 266 | usb_bus, 267 | oled, 268 | uart, 269 | right, 270 | pl, 271 | timer, 272 | &clocks.system_clock, 273 | ); 274 | } 275 | #[cfg(not(feature = "right"))] 276 | { 277 | // Hard error, needs new firmware loaded 278 | oled.write_bad_boot_msg(); 279 | rp2040_hal::rom_data::reset_to_usb_boot(0, 0); 280 | unreachable!("Should have gone into boot"); 281 | } 282 | } 283 | } 284 | 285 | fn setup_oled( 286 | i2c: I2C1, 287 | r: &mut pac::RESETS, 288 | sda: Pin, 289 | scl: Pin, 290 | clock: &PeripheralClock, 291 | ) -> OledHandle { 292 | let i2c = hal::I2C::i2c1( 293 | i2c, 294 | sda.reconfigure(), 295 | scl.reconfigure(), 296 | 400.kHz(), 297 | r, 298 | clock, 299 | ); 300 | 301 | let interface = ssd1306::I2CDisplayInterface::new(i2c); 302 | let mut display = Ssd1306::new(interface, DisplaySize128x32, DisplayRotation::Rotate90) 303 | .into_buffered_graphics_mode(); 304 | display.init().unwrap(); 305 | let _ = display.clear(BinaryColor::Off); 306 | let _ = display.flush(); 307 | OledHandle::new(display) 308 | } 309 | 310 | #[panic_handler] 311 | #[inline(never)] 312 | fn halt(_info: &core::panic::PanicInfo) -> ! { 313 | loop { 314 | core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst); 315 | } 316 | } 317 | -------------------------------------------------------------------------------- /rp2040-kbd-lib/src/queue.rs: -------------------------------------------------------------------------------- 1 | use core::mem::MaybeUninit; 2 | use core::sync::atomic::{AtomicUsize, Ordering}; 3 | 4 | pub struct Queue { 5 | buffer: [MaybeUninit; N], 6 | head: usize, 7 | tail: usize, 8 | } 9 | 10 | impl Queue { 11 | const NULL: MaybeUninit = MaybeUninit::uninit(); 12 | 13 | #[inline] 14 | fn rem(&self) -> usize { 15 | if self.head > self.tail { 16 | self.head - self.tail 17 | } else { 18 | N - self.tail + self.head 19 | } 20 | } 21 | 22 | #[inline] 23 | pub fn push_back(&mut self, val: T) -> bool { 24 | if self.rem() == 0 { 25 | return false; 26 | } 27 | if self.tail == N { 28 | self.tail = 0; 29 | } 30 | // Safety: Tail always in range and points to initialized memory 31 | unsafe { 32 | #[cfg(test)] 33 | { 34 | self.buffer.get(self.tail).unwrap(); 35 | } 36 | let cur = self.buffer.get_unchecked_mut(self.tail); 37 | cur.as_mut_ptr().write(val); 38 | } 39 | self.tail += 1; 40 | true 41 | } 42 | 43 | #[inline] 44 | pub fn peek(&self) -> Option<&T> { 45 | if self.head == self.tail { 46 | return None; 47 | }; 48 | // Safety: Head always in range (always moves after tail) and points to initialized memory 49 | let val = unsafe { 50 | #[cfg(test)] 51 | { 52 | self.buffer.get(self.head).unwrap(); 53 | } 54 | let cur = self.buffer.get_unchecked(self.head); 55 | cur.as_ptr().as_ref() 56 | }; 57 | val 58 | } 59 | 60 | #[inline] 61 | pub fn pop_front(&mut self) -> Option { 62 | if self.head == self.tail { 63 | return None; 64 | }; 65 | // Safety: Head always in range (always moves after tail) and points to initialized memory 66 | let val = unsafe { 67 | #[cfg(test)] 68 | { 69 | self.buffer.get(self.head).unwrap(); 70 | } 71 | let cur = self.buffer.get_unchecked_mut(self.head); 72 | cur.as_ptr().read() 73 | }; 74 | if self.head >= N - 1 { 75 | self.head = 0; 76 | if self.tail == N { 77 | self.tail = 0; 78 | } 79 | } else { 80 | self.head += 1; 81 | } 82 | Some(val) 83 | } 84 | 85 | #[must_use] 86 | pub const fn new() -> Self { 87 | Self { 88 | buffer: [Self::NULL; N], 89 | head: 0, 90 | tail: 0, 91 | } 92 | } 93 | } 94 | 95 | /// Retrofitted the above queue into something atomic, [looked to heapless](https://github.com/rust-embedded/heapless/blob/7bb2f71/src/spsc.rs#L3) 96 | /// for inspiration, largely a subset of that implementation, although I don't think 97 | /// any atomics are required except Load/Store which exists, gotta ask. 98 | /// 99 | /// [According to the docs, the original idea came from here](https://www.codeproject.com/Articles/43510/Lock-Free-Single-Producer-Single-Consumer-Circular). 100 | pub struct AtomicQueueProducer<'a, T, const N: usize> { 101 | buffer: *mut T, // Length N 102 | head: &'a AtomicUsize, 103 | tail: &'a AtomicUsize, 104 | } 105 | 106 | unsafe impl Send for AtomicQueueProducer<'_, T, N> {} 107 | 108 | impl AtomicQueueProducer<'_, T, N> { 109 | pub fn push_back(&self, val: T) -> bool { 110 | let tail = self.tail.load(Ordering::Relaxed); 111 | let next = (tail + 1) % N; 112 | let head = self.head.load(Ordering::Acquire); 113 | if next == head { 114 | #[cfg(test)] 115 | { 116 | eprintln!("bail head={head}, tail={tail}"); 117 | } 118 | return false; 119 | } 120 | unsafe { 121 | let cur = self.buffer.add(tail); 122 | cur.write(val); 123 | } 124 | self.tail.store(next, Ordering::Release); 125 | true 126 | } 127 | } 128 | 129 | pub struct AtomicQueueConsumer<'a, T, const N: usize> { 130 | buffer: *mut T, // Length N 131 | head: &'a AtomicUsize, 132 | tail: &'a AtomicUsize, 133 | } 134 | impl AtomicQueueConsumer<'_, T, N> { 135 | #[must_use] 136 | pub fn available(&self) -> usize { 137 | let head = self.head.load(Ordering::Relaxed); 138 | let tail = self.tail.load(Ordering::Relaxed); 139 | tail.wrapping_sub(head).wrapping_add(N) % N 140 | } 141 | #[inline] 142 | #[must_use] 143 | pub fn peek(&self) -> Option<&T> { 144 | let head = self.head.load(Ordering::Relaxed); 145 | let tail = self.tail.load(Ordering::Acquire); 146 | #[cfg(test)] 147 | { 148 | eprintln!("peek head={head}, tail={tail}"); 149 | } 150 | if head == tail { 151 | return None; 152 | }; 153 | // Safety: Head always in range (always moves after tail) and points to initialized memory 154 | let val = unsafe { 155 | let cur = self.buffer.add(head); 156 | cur.as_ref() 157 | }; 158 | val 159 | } 160 | 161 | #[inline] 162 | #[must_use] 163 | pub fn pop_front(&self) -> Option { 164 | let head = self.head.load(Ordering::Relaxed); 165 | let tail = self.tail.load(Ordering::Acquire); 166 | #[cfg(test)] 167 | { 168 | eprintln!("pop head={head}, tail={tail}"); 169 | } 170 | if head == tail { 171 | return None; 172 | }; 173 | // Safety: Head always in range (always moves after tail) and points to initialized memory 174 | let val = unsafe { 175 | let cur = self.buffer.add(head); 176 | cur.read() 177 | }; 178 | let next_head = (head + 1) % N; 179 | self.head.store(next_head, Ordering::Release); 180 | Some(val) 181 | } 182 | } 183 | 184 | #[must_use] 185 | pub fn new_atomic_producer_consumer<'a, T, const N: usize>( 186 | mem_area: &'a mut [T; N], 187 | head: &'a mut AtomicUsize, 188 | tail: &'a mut AtomicUsize, 189 | ) -> (AtomicQueueProducer<'a, T, N>, AtomicQueueConsumer<'a, T, N>) { 190 | let buf = mem_area.as_mut_ptr(); 191 | head.store(0, Ordering::Release); 192 | tail.store(0, Ordering::Release); 193 | ( 194 | AtomicQueueProducer { 195 | buffer: buf, 196 | head, 197 | tail, 198 | }, 199 | AtomicQueueConsumer { 200 | buffer: buf, 201 | head, 202 | tail, 203 | }, 204 | ) 205 | } 206 | 207 | #[cfg(test)] 208 | mod tests { 209 | use crate::queue::{new_atomic_producer_consumer, Queue}; 210 | use core::sync::atomic::AtomicUsize; 211 | 212 | #[test] 213 | fn push_to_cap() { 214 | let mut queue: Queue = Queue::new(); 215 | assert!(queue.pop_front().is_none()); 216 | for i in 0..u8::MAX { 217 | queue.push_back(i); 218 | let val = queue.pop_front(); 219 | assert_eq!(Some(i), val); 220 | } 221 | assert!(queue.pop_front().is_none()); 222 | } 223 | 224 | #[test] 225 | fn fill_clear() { 226 | let mut queue: Queue = Queue::new(); 227 | assert!(queue.pop_front().is_none()); 228 | for i in 0..128 { 229 | queue.push_back(i); 230 | } 231 | for i in 0..128 { 232 | assert_eq!(Some(&i), queue.peek()); 233 | assert_eq!(Some(i), queue.pop_front()); 234 | } 235 | assert!(queue.pop_front().is_none()); 236 | for i in 0..128 { 237 | queue.push_back(i); 238 | } 239 | for i in 0..128 { 240 | assert_eq!(Some(&i), queue.peek()); 241 | assert_eq!(Some(i), queue.pop_front()); 242 | } 243 | assert!(queue.pop_front().is_none()); 244 | } 245 | 246 | #[test] 247 | fn wrap() { 248 | let mut queue: Queue = Queue::new(); 249 | assert!(queue.peek().is_none()); 250 | assert!(queue.pop_front().is_none()); 251 | queue.push_back(1); 252 | queue.push_back(2); 253 | queue.push_back(3); 254 | assert_eq!(&1, queue.peek().unwrap()); 255 | assert_eq!(1, queue.pop_front().unwrap()); 256 | assert_eq!(&2, queue.peek().unwrap()); 257 | assert_eq!(2, queue.pop_front().unwrap()); 258 | assert_eq!(&3, queue.peek().unwrap()); 259 | assert_eq!(3, queue.pop_front().unwrap()); 260 | assert!(queue.pop_front().is_none()); 261 | for i in 27..27 + 64 { 262 | queue.push_back(i); 263 | assert_eq!(Some(&i), queue.peek()); 264 | assert_eq!(Some(i), queue.pop_front()); 265 | assert!(queue.peek().is_none()); 266 | assert!(queue.pop_front().is_none()); 267 | } 268 | assert!(queue.peek().is_none()); 269 | assert!(queue.pop_front().is_none()); 270 | } 271 | 272 | #[test] 273 | fn wrap_chunks() { 274 | let mut queue: Queue = Queue::new(); 275 | assert!(queue.pop_front().is_none()); 276 | for i in 0..128 { 277 | for j in 0..i { 278 | queue.push_back(j); 279 | } 280 | for j in 0..i { 281 | let val = queue.pop_front(); 282 | assert_eq!(Some(j), val); 283 | } 284 | assert!(queue.pop_front().is_none()); 285 | } 286 | } 287 | #[test] 288 | fn atomic_push_to_cap() { 289 | let mut area = [0u8; 128]; 290 | let mut head = AtomicUsize::new(999); 291 | let mut tail = AtomicUsize::new(1527); 292 | let (producer, consumer) = new_atomic_producer_consumer(&mut area, &mut head, &mut tail); 293 | assert!(consumer.pop_front().is_none()); 294 | for i in 0..u8::MAX { 295 | producer.push_back(i); 296 | let val = consumer.pop_front(); 297 | assert_eq!(Some(i), val); 298 | } 299 | assert!(consumer.pop_front().is_none()); 300 | } 301 | 302 | #[test] 303 | fn atomic_fill_clear() { 304 | let mut area = [0u8; 8]; 305 | let mut head = AtomicUsize::new(999); 306 | let mut tail = AtomicUsize::new(1527); 307 | let (producer, consumer) = new_atomic_producer_consumer(&mut area, &mut head, &mut tail); 308 | assert!(consumer.pop_front().is_none()); 309 | for i in 0..7 { 310 | producer.push_back(i); 311 | } 312 | for i in 0..7 { 313 | assert_eq!(Some(&i), consumer.peek()); 314 | assert_eq!(Some(i), consumer.pop_front()); 315 | } 316 | assert!(consumer.pop_front().is_none()); 317 | for i in 0..7 { 318 | producer.push_back(i); 319 | } 320 | for i in 0..7 { 321 | assert_eq!(Some(&i), consumer.peek()); 322 | assert_eq!(Some(i), consumer.pop_front()); 323 | } 324 | assert!(consumer.pop_front().is_none()); 325 | } 326 | 327 | #[test] 328 | fn atomic_wrap() { 329 | let mut area = [0u8; 128]; 330 | let mut head = AtomicUsize::new(999); 331 | let mut tail = AtomicUsize::new(1527); 332 | let (producer, consumer) = new_atomic_producer_consumer(&mut area, &mut head, &mut tail); 333 | assert!(consumer.peek().is_none()); 334 | assert!(consumer.pop_front().is_none()); 335 | producer.push_back(1); 336 | producer.push_back(2); 337 | producer.push_back(3); 338 | assert_eq!(&1, consumer.peek().unwrap()); 339 | assert_eq!(1, consumer.pop_front().unwrap()); 340 | assert_eq!(&2, consumer.peek().unwrap()); 341 | assert_eq!(2, consumer.pop_front().unwrap()); 342 | assert_eq!(&3, consumer.peek().unwrap()); 343 | assert_eq!(3, consumer.pop_front().unwrap()); 344 | assert!(consumer.pop_front().is_none()); 345 | for i in 27..27 + 64 { 346 | producer.push_back(i); 347 | assert_eq!(Some(&i), consumer.peek()); 348 | assert_eq!(Some(i), consumer.pop_front()); 349 | assert!(consumer.peek().is_none()); 350 | assert!(consumer.pop_front().is_none()); 351 | } 352 | assert!(consumer.peek().is_none()); 353 | assert!(consumer.pop_front().is_none()); 354 | } 355 | 356 | #[test] 357 | fn atomic_wrap_chunks() { 358 | let mut area = [0i32; 1024]; 359 | let mut head = AtomicUsize::new(999); 360 | let mut tail = AtomicUsize::new(1527); 361 | let (producer, consumer) = new_atomic_producer_consumer(&mut area, &mut head, &mut tail); 362 | assert!(consumer.pop_front().is_none()); 363 | for i in 0..1024 { 364 | for j in 0..i { 365 | producer.push_back(j); 366 | } 367 | for j in 0..i { 368 | let val = consumer.pop_front(); 369 | assert_eq!(Some(j), val, "{i}"); 370 | } 371 | assert!(consumer.pop_front().is_none()); 372 | } 373 | } 374 | } 375 | -------------------------------------------------------------------------------- /rp2040-kbd/src/keyboard/right.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod message_serializer; 2 | 3 | use crate::keyboard::debounce::PinDebouncer; 4 | use crate::keyboard::right::message_serializer::MessageSerializer; 5 | use crate::keyboard::ButtonPin; 6 | use crate::runtime::shared::cores_right::{push_reboot_and_halt, Producer}; 7 | #[cfg(feature = "serial")] 8 | use core::fmt::Write; 9 | use embedded_hal::digital::InputPin; 10 | use rp2040_hal::gpio::bank0::{ 11 | Gpio20, Gpio21, Gpio22, Gpio23, Gpio26, Gpio27, Gpio29, Gpio4, Gpio5, Gpio6, Gpio7, Gpio8, 12 | Gpio9, 13 | }; 14 | use rp2040_hal::gpio::{FunctionSio, Pin, PinState, PullUp, SioInput}; 15 | use rp2040_hal::Timer; 16 | use rp2040_kbd_lib::matrix::{ColIndex, MatrixIndex, MatrixUpdate, RowIndex}; 17 | 18 | const ROW0: u32 = 1 << 29; 19 | const ROW1: u32 = 1 << 4; 20 | const ROW2: u32 = 1 << 20; 21 | const ROW3: u32 = 1 << 23; 22 | const ROW4: u32 = 1 << 21; 23 | const ROW_MASK: u32 = ROW0 | ROW1 | ROW2 | ROW3 | ROW4; 24 | 25 | struct PinStructState { 26 | pressed: bool, 27 | debounce: PinDebouncer, 28 | } 29 | 30 | impl PinStructState { 31 | const fn new() -> Self { 32 | Self { 33 | pressed: false, 34 | debounce: PinDebouncer::new(), 35 | } 36 | } 37 | } 38 | 39 | macro_rules! pins_container { 40 | ($($row: tt, $col: tt),*,) => { 41 | paste::paste! { 42 | #[expect(clippy::struct_field_names)] 43 | struct RightPinsContainer { 44 | $( 45 | [] : PinStructState, 46 | )* 47 | } 48 | 49 | impl RightPinsContainer { 50 | const fn new() -> Self { 51 | Self { 52 | $( 53 | [] : PinStructState::new(), 54 | )* 55 | } 56 | } 57 | } 58 | } 59 | 60 | }; 61 | } 62 | 63 | pins_container!( 64 | 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 2, 0, 2, 1, 2, 2, 2, 3, 65 | 2, 4, 2, 5, 3, 0, 3, 1, 3, 2, 3, 3, 3, 4, 3, 5, // 4, 0, Does not exist 66 | 4, 1, 4, 2, 4, 3, 4, 4, 67 | // 4, 5, Has a rotary encoder on it 68 | ); 69 | 70 | macro_rules! impl_check_rows_by_column { 71 | ($($structure: expr, $row: tt,)*, $col: tt) => { 72 | paste::paste! { 73 | #[inline] 74 | pub fn [](right_buttons: &mut RightButtons, serializer: &mut MessageSerializer, timer: Timer, changes: &mut u16, producer: &Producer) { 75 | 76 | // Safety: Make sure this is properly initialized and restored 77 | // at the end of this function, makes a noticeable difference in performance 78 | let col = unsafe {right_buttons.cols.$col.0.take().unwrap_unchecked()}; 79 | let col = col.into_push_pull_output_in_state(PinState::Low); 80 | // Just pulling chibios defaults of 0.25 micros, could probably be 0 81 | crate::timer::wait_nanos(timer, 250); 82 | let bank = rp2040_hal::Sio::read_bank0(); 83 | right_buttons.cols.$col.0 = Some(col.into_pull_up_input()); 84 | $( 85 | { 86 | const PRESSED: MatrixUpdate = MatrixUpdate::from_key_update(MatrixIndex::from_row_col(RowIndex::from_value($row), ColIndex::from_value($col)), true); 87 | const RELEASED: MatrixUpdate = MatrixUpdate::from_key_update(MatrixIndex::from_row_col(RowIndex::from_value($row), ColIndex::from_value($col)), false); 88 | let pressed = bank & [] == 0; 89 | #[cfg(feature = "serial")] 90 | { 91 | if right_buttons.pin_states.[< $structure:snake >].pressed != pressed { 92 | let _ = crate::runtime::shared::usb::acquire_usb().write_fmt(format_args!( 93 | "M{}, R{}, C{} -> {} {:?}\r\n", 94 | MatrixIndex::from_row_col(RowIndex::from_value($row), ColIndex::from_value($col)).byte(), 95 | $row, 96 | $col, 97 | u8::from(pressed), 98 | right_buttons.pin_states.[< $structure:snake >].debounce.diff_last(timer.get_counter()), 99 | )); 100 | } 101 | 102 | } 103 | if right_buttons.pin_states.[< $structure:snake >].pressed != pressed && right_buttons.pin_states.[< $structure:snake >].debounce.try_submit(timer.get_counter(), pressed) { 104 | 105 | serializer.serialize_matrix_state(if pressed {PRESSED} else {RELEASED}); 106 | right_buttons.pin_states.[< $structure:snake >].pressed = pressed; 107 | *changes += 1; 108 | if $row == 4 && $col == 2 { 109 | push_reboot_and_halt(producer); 110 | } 111 | } 112 | } 113 | )* 114 | while rp2040_hal::Sio::read_bank0() & ROW_MASK != ROW_MASK {} 115 | } 116 | } 117 | }; 118 | } 119 | 120 | impl_check_rows_by_column!( 121 | row_0_col_0_state, 0, 122 | row_1_col_0_state, 1, 123 | row_2_col_0_state, 2, 124 | row_3_col_0_state, 3, 125 | ,0 126 | ); 127 | 128 | impl_check_rows_by_column!( 129 | row_0_col_1_state, 0, 130 | row_1_col_1_state, 1, 131 | row_2_col_1_state, 2, 132 | row_3_col_1_state, 3, 133 | row_4_col_1_state, 4, 134 | ,1 135 | ); 136 | 137 | impl_check_rows_by_column!( 138 | row_0_col_2_state, 0, 139 | row_1_col_2_state, 1, 140 | row_2_col_2_state, 2, 141 | row_3_col_2_state, 3, 142 | row_4_col_2_state, 4, 143 | ,2 144 | ); 145 | 146 | impl_check_rows_by_column!( 147 | row_0_col_3_state, 0, 148 | row_1_col_3_state, 1, 149 | row_2_col_3_state, 2, 150 | row_3_col_3_state, 3, 151 | row_4_col_3_state, 4, 152 | ,3 153 | ); 154 | 155 | impl_check_rows_by_column!( 156 | row_0_col_4_state, 0, 157 | row_1_col_4_state, 1, 158 | row_2_col_4_state, 2, 159 | row_3_col_4_state, 3, 160 | row_4_col_4_state, 4, 161 | ,4 162 | ); 163 | 164 | impl_check_rows_by_column!( 165 | row_0_col_5_state, 0, 166 | row_1_col_5_state, 1, 167 | row_2_col_5_state, 2, 168 | row_3_col_5_state, 3, 169 | ,5 170 | ); 171 | 172 | pub struct RightButtons { 173 | pin_states: RightPinsContainer, 174 | _rows: ( 175 | ButtonPin, 176 | ButtonPin, 177 | ButtonPin, 178 | ButtonPin, 179 | ButtonPin, 180 | ), 181 | cols: ( 182 | (Option>, ColIndex), 183 | (Option>, ColIndex), 184 | (Option>, ColIndex), 185 | (Option>, ColIndex), 186 | (Option>, ColIndex), 187 | (Option>, ColIndex), 188 | ), 189 | encoder: RotaryEncoder, 190 | } 191 | impl RightButtons { 192 | pub fn new( 193 | // Want this supplied owned and in the correct state 194 | #[expect(clippy::used_underscore_binding)] _rows: ( 195 | ButtonPin, 196 | ButtonPin, 197 | ButtonPin, 198 | ButtonPin, 199 | ButtonPin, 200 | ), 201 | cols: ( 202 | ButtonPin, 203 | ButtonPin, 204 | ButtonPin, 205 | ButtonPin, 206 | ButtonPin, 207 | ButtonPin, 208 | ), 209 | rotary_encoder: RotaryEncoder, 210 | ) -> Self { 211 | Self { 212 | pin_states: RightPinsContainer::new(), 213 | _rows, 214 | cols: ( 215 | ( 216 | Some( 217 | cols.0 218 | .into_push_pull_output_in_state(PinState::High) 219 | .into_function(), 220 | ), 221 | ColIndex::from_value(0), 222 | ), 223 | ( 224 | Some( 225 | cols.1 226 | .into_push_pull_output_in_state(PinState::High) 227 | .into_function(), 228 | ), 229 | ColIndex::from_value(1), 230 | ), 231 | ( 232 | Some( 233 | cols.2 234 | .into_push_pull_output_in_state(PinState::High) 235 | .into_function(), 236 | ), 237 | ColIndex::from_value(2), 238 | ), 239 | ( 240 | Some( 241 | cols.3 242 | .into_push_pull_output_in_state(PinState::High) 243 | .into_function(), 244 | ), 245 | ColIndex::from_value(3), 246 | ), 247 | ( 248 | Some( 249 | cols.4 250 | .into_push_pull_output_in_state(PinState::High) 251 | .into_function(), 252 | ), 253 | ColIndex::from_value(4), 254 | ), 255 | ( 256 | Some( 257 | cols.5 258 | .into_push_pull_output_in_state(PinState::High) 259 | .into_function(), 260 | ), 261 | ColIndex::from_value(5), 262 | ), 263 | ), 264 | encoder: rotary_encoder, 265 | } 266 | } 267 | 268 | pub fn scan_matrix( 269 | &mut self, 270 | serializer: &mut MessageSerializer, 271 | timer: Timer, 272 | producer: &Producer, 273 | ) -> u16 { 274 | let mut changes = 0; 275 | read_col_0_pins(self, serializer, timer, &mut changes, producer); 276 | read_col_1_pins(self, serializer, timer, &mut changes, producer); 277 | read_col_2_pins(self, serializer, timer, &mut changes, producer); 278 | read_col_3_pins(self, serializer, timer, &mut changes, producer); 279 | read_col_4_pins(self, serializer, timer, &mut changes, producer); 280 | read_col_5_pins(self, serializer, timer, &mut changes, producer); 281 | changes 282 | } 283 | 284 | #[inline] 285 | pub fn scan_encoder(&mut self, serializer: &mut MessageSerializer) -> bool { 286 | if let Some(dir) = self.encoder.scan_debounced() { 287 | #[cfg(feature = "serial")] 288 | { 289 | let _ = crate::runtime::shared::usb::acquire_usb().write_fmt(format_args!( 290 | "Encoder clockwise: Pos: {:?} clockwise={:?}\r\n", 291 | self.encoder.last_position, dir 292 | )); 293 | } 294 | serializer.serialize_matrix_state(MatrixUpdate::from_rotary_change(dir)); 295 | true 296 | } else { 297 | false 298 | } 299 | } 300 | } 301 | 302 | #[derive(Copy, Clone, Debug)] 303 | enum RotaryPosition { 304 | North, 305 | East, 306 | South, 307 | West, 308 | } 309 | 310 | impl RotaryPosition { 311 | fn from_state(a: bool, b: bool) -> Self { 312 | match (a, b) { 313 | (true, true) => RotaryPosition::South, 314 | (false, true) => RotaryPosition::West, 315 | (false, false) => RotaryPosition::North, 316 | (true, false) => RotaryPosition::East, 317 | } 318 | } 319 | } 320 | 321 | pub struct RotaryEncoder { 322 | dt_pin: Pin, PullUp>, 323 | clk_pin: Pin, PullUp>, 324 | last_position: Option, 325 | last_clockwise: Option, 326 | cached: Option, 327 | } 328 | 329 | impl RotaryEncoder { 330 | pub fn new( 331 | dt_pin: Pin, PullUp>, 332 | clk_pin: Pin, PullUp>, 333 | ) -> Self { 334 | Self { 335 | dt_pin, 336 | clk_pin, 337 | last_position: None, 338 | last_clockwise: None, 339 | cached: None, 340 | } 341 | } 342 | 343 | #[inline] 344 | fn read_position(&mut self) -> RotaryPosition { 345 | RotaryPosition::from_state( 346 | matches!(self.dt_pin.is_high(), Ok(true)), 347 | matches!(self.clk_pin.is_high(), Ok(true)), 348 | ) 349 | } 350 | 351 | // Dirty, but works for debouncing the encoder 352 | #[inline] 353 | pub fn scan_debounced(&mut self) -> Option { 354 | let current = self.read_position(); 355 | let Some(old) = self.last_position else { 356 | self.last_position = Some(current); 357 | return None; 358 | }; 359 | let dir = match (old, current) { 360 | (RotaryPosition::North, RotaryPosition::East) 361 | | (RotaryPosition::East, RotaryPosition::South) 362 | | (RotaryPosition::South, RotaryPosition::West) 363 | | (RotaryPosition::West, RotaryPosition::North) => true, 364 | (RotaryPosition::North, RotaryPosition::West) 365 | | (RotaryPosition::West, RotaryPosition::South) 366 | | (RotaryPosition::South, RotaryPosition::East) 367 | | (RotaryPosition::East, RotaryPosition::North) => false, 368 | (_, _) => { 369 | self.last_position = Some(current); 370 | return None; 371 | } 372 | }; 373 | self.last_position = Some(current); 374 | let Some(last) = self.last_clockwise else { 375 | self.last_clockwise = Some(dir); 376 | return None; 377 | }; 378 | self.last_clockwise = Some(dir); 379 | if last == dir { 380 | if let Some(prev) = self.cached { 381 | if prev == last { 382 | return self.cached.take(); 383 | } 384 | } 385 | self.cached = Some(dir); 386 | } 387 | None 388 | } 389 | } 390 | -------------------------------------------------------------------------------- /rp2040-kbd-lib/src/keycodes.rs: -------------------------------------------------------------------------------- 1 | #[repr(transparent)] 2 | #[derive(Copy, Clone, Debug, Eq, PartialEq)] 3 | pub struct KeyCode(pub u8); 4 | 5 | impl KeyCode { 6 | //Keyboard = 0x01; //ErrorRollOver1 Sel N/A 3 3 3 4/101/104 7 | //Keyboard = 0x02; //POSTFail1 Sel N/A 3 3 3 4/101/104 8 | //Keyboard = 0x03; //ErrorUndefined1 Sel N/A 3 3 3 4/101/104 9 | pub const A: Self = Self(0x04); //a and A2 Sel 31 3 3 3 4/101/104 10 | pub const B: Self = Self(0x05); //b and B Sel 50 3 3 3 4/101/104 11 | pub const C: Self = Self(0x06); //c and C2 Sel 48 3 3 3 4/101/104 12 | pub const D: Self = Self(0x07); //d and D Sel 33 3 3 3 4/101/104 13 | pub const E: Self = Self(0x08); //e and E Sel 19 3 3 3 4/101/104 14 | pub const F: Self = Self(0x09); //f and F Sel 34 3 3 3 4/101/104 15 | pub const G: Self = Self(0x0A); //g and G Sel 35 3 3 3 4/101/104 16 | pub const H: Self = Self(0x0B); //h and H Sel 36 3 3 3 4/101/104 17 | pub const I: Self = Self(0x0C); //i and I Sel 24 3 3 3 4/101/104 18 | pub const J: Self = Self(0x0D); //j and J Sel 37 3 3 3 4/101/104 19 | pub const K: Self = Self(0x0E); //k and K Sel 38 3 3 3 4/101/104 20 | pub const L: Self = Self(0x0F); //l and L Sel 39 3 3 3 4/101/104 21 | pub const M: Self = Self(0x10); //m and M2 Sel 52 3 3 3 4/101/104 22 | pub const N: Self = Self(0x11); //n and N Sel 51 3 3 3 4/101/104 23 | pub const O: Self = Self(0x12); //o and O2 Sel 25 3 3 3 4/101/104 24 | pub const P: Self = Self(0x13); //p and P2 Sel 26 3 3 3 4/101/104 25 | pub const Q: Self = Self(0x14); //q and Q2 Sel 17 3 3 3 4/101/104 26 | pub const R: Self = Self(0x15); //r and R Sel 20 3 3 3 4/101/104 27 | pub const S: Self = Self(0x16); //s and S Sel 32 3 3 3 4/101/104 28 | pub const T: Self = Self(0x17); //t and T Sel 21 3 3 3 4/101/104 29 | pub const U: Self = Self(0x18); //u and U Sel 23 3 3 3 4/101/104 30 | pub const V: Self = Self(0x19); //v and V Sel 49 3 3 3 4/101/104 31 | pub const W: Self = Self(0x1A); //w and W2 Sel 18 3 3 3 4/101/104 32 | pub const X: Self = Self(0x1B); //x and X2 Sel 47 3 3 3 4/101/104 33 | pub const Y: Self = Self(0x1C); //y and Y2 Sel 22 3 3 3 4/101/104 34 | pub const Z: Self = Self(0x1D); //z and Z2 Sel 46 3 3 3 4/101/104 35 | pub const N1: Self = Self(0x1E); //1 and !2 Sel 2 3 3 3 4/101/104 36 | pub const N2: Self = Self(0x1F); //2 and @2 Sel 3 3 3 3 4/101/104 37 | pub const N3: Self = Self(0x20); //3 and #2 Sel 4 3 3 3 4/101/104 38 | pub const N4: Self = Self(0x21); //4 and $2 Sel 5 3 3 3 4/101/104 39 | pub const N5: Self = Self(0x22); //5 and %2 Sel 6 3 3 3 4/101/104 40 | pub const N6: Self = Self(0x23); //6 and ∧2 Sel 7 3 3 3 4/101/104 41 | pub const N7: Self = Self(0x24); //7 and &2 Sel 8 3 3 3 4/101/104 42 | pub const N8: Self = Self(0x25); //8 and *2 Sel 9 3 3 3 4/101/104 43 | pub const N9: Self = Self(0x26); //9 and (2 Sel 10 3 3 3 4/101/104 44 | pub const N0: Self = Self(0x27); //0 and )2 Sel 11 3 3 3 4/101/104 45 | pub const ENTER: Self = Self(0x28); //Return (ENTER)3 Sel 43 3 3 3 4/101/104 46 | pub const ESCAPE: Self = Self(0x29); //ESCAPE Sel 110 3 3 3 4/101/104 47 | pub const BACKSPACE: Self = Self(0x2A); //DELETE (Backspace)4 Sel 15 3 3 3 4/101/104 48 | pub const TAB: Self = Self(0x2B); //Tab Sel 16 3 3 3 4/101/104 49 | pub const SPACE: Self = Self(0x2C); //Spacebar Sel 61 3 3 3 4/101/104 50 | pub const DASH: Self = Self(0x2D); //- and (underscore)2 Sel 12 3 3 3 4/101/104 51 | pub const EQUALS: Self = Self(0x2E); //= and +2 Sel 13 3 3 3 4/101/104 52 | pub const LEFT_BRACKET: Self = Self(0x2F); //[ and {2 Sel 27 3 3 3 4/101/104 53 | pub const RIGHT_BRACKET: Self = Self(0x30); //] and }2 Sel 28 3 3 3 4/101/104 54 | pub const BACKSLASH: Self = Self(0x31); //\and | Sel 29 3 3 3 4/101/104 55 | pub const KC_PND: Self = Self(0x32); //Non-US # and ˜5 Sel 42 3 3 3 4/101/104 56 | pub const SEMICOLON: Self = Self(0x33); //; and :2 Sel 40 3 3 3 4/101/104 57 | pub const QUOTE: Self = Self(0x34); //‘ and “2 Sel 41 3 3 3 4/101/104 58 | pub const GRAVE: Self = Self(0x35); //Grave Accent and Tilde2 Sel 1 3 3 3 4/101/104 59 | pub const COMMA: Self = Self(0x36); //, and <2 Sel 53 3 3 3 4/101/104 60 | pub const DOT: Self = Self(0x37); //. and >2 Sel 54 3 3 3 4/101/104 61 | pub const SLASH: Self = Self(0x38); 62 | /// and ?2 Sel 55 3 3 3 4/101/104 63 | pub const KC_CAPS: Self = Self(0x39); //Caps Lock6 Sel 30 3 3 3 4/101/104 64 | pub const F1: Self = Self(0x3A); //F1 Sel 112 3 3 3 4/101/104 65 | pub const F2: Self = Self(0x3B); //F2 Sel 113 3 3 3 4/101/104 66 | pub const F3: Self = Self(0x3C); //F3 Sel 114 3 3 3 4/101/104 67 | pub const F4: Self = Self(0x3D); //F4 Sel 115 3 3 3 4/101/104 68 | pub const KC_F5: Self = Self(0x3E); //F5 Sel 116 3 3 3 4/101/104 69 | pub const F6: Self = Self(0x3F); //F6 Sel 117 3 3 3 4/101/104 70 | pub const F7: Self = Self(0x40); //F7 Sel 118 3 3 3 4/101/104 71 | pub const F8: Self = Self(0x41); //F8 Sel 119 3 3 3 4/101/104 72 | pub const F9: Self = Self(0x42); //F9 Sel 120 3 3 3 4/101/104 73 | pub const F10: Self = Self(0x43); //F10 Sel 121 3 3 3 4/101/104 74 | pub const F11: Self = Self(0x44); //F11 Sel 122 3 3 3 4/101/104 75 | pub const F12: Self = Self(0x45); //F12 Sel 123 3 3 3 4/101/104 76 | pub const PRINT_SCREEN: Self = Self(0x46); //PrintScreen7 Sel 124 3 3 3 4/101/104 77 | pub const KC_SCLK: Self = Self(0x47); //Scroll Lock6 Sel 125 3 3 3 4/101/104 78 | pub const KC_PAUS: Self = Self(0x48); //Pause7 Sel 126 3 3 3 4/101/104 79 | pub const INSERT: Self = Self(0x49); //Insert7 Sel 75 3 3 3 4/101/104 80 | pub const HOME: Self = Self(0x4A); //Home7 Sel 80 3 3 3 4/101/104 81 | pub const PAGE_UP: Self = Self(0x4B); //PageUp7 Sel 85 3 3 3 4/101/104 82 | pub const KC_DELF: Self = Self(0x4C); //Delete Forward7,8 Sel 76 3 3 3 4/101/104 83 | pub const END: Self = Self(0x4D); //End7 Sel 81 3 3 3 4/101/104 84 | pub const PAGE_DOWN: Self = Self(0x4E); //PageDown7 Sel 86 3 3 3 4/101/104 85 | pub const RIGHT_ARROW: Self = Self(0x4F); //RightArrow7 Sel 89 3 3 3 4/101/104 86 | pub const LEFT_ARROW: Self = Self(0x50); //LeftArrow7 Sel 79 3 3 3 4/101/104 87 | pub const DOWN_ARROW: Self = Self(0x51); //DownArrow7 Sel 84 3 3 3 4/101/104 88 | pub const UP_ARROW: Self = Self(0x52); //UpArrow7 Sel 83 3 3 3 4/101/104 89 | pub const KP_NUML: Self = Self(0x53); //Num Lock and Clear6 Sel 90 3 3 3 4/101/104 90 | pub const KP_7: Self = Self(0x54); 91 | ///7 Sel 95 3 3 3 4/101/104 92 | pub const KP_ASTR: Self = Self(0x55); //* Sel 100 3 3 3 4/101/104 93 | pub const KP_MINS: Self = Self(0x56); //- Sel 105 3 3 3 4/101/104 94 | pub const KP_PLUS: Self = Self(0x57); //+ Sel 106 3 3 3 4/101/104 95 | pub const KP_ENT: Self = Self(0x58); //ENTER3 Sel 108 3 3 3 4/101/104 96 | pub const KP_1: Self = Self(0x59); //1 and End Sel 93 3 3 3 4/101/104 97 | pub const KP_2: Self = Self(0x5A); //2 and Down Arrow Sel 98 3 3 3 4/101/104 98 | pub const KP_3: Self = Self(0x5B); //3 and PageDn Sel 103 3 3 3 4/101/104 99 | pub const KP_4: Self = Self(0x5C); //4 and Left Arrow Sel 92 3 3 3 4/101/104 100 | pub const KP_5: Self = Self(0x5D); //5 Sel 97 3 3 3 4/101/104 101 | pub const KP_6: Self = Self(0x5E); //6 and Right Arrow Sel 102 3 3 3 4/101/104 102 | pub const KP_7HME: Self = Self(0x5F); //7 and Home Sel 91 3 3 3 4/101/104 103 | pub const KP_8: Self = Self(0x60); //8 and Up Arrow Sel 96 3 3 3 4/101/104 104 | pub const KP_9: Self = Self(0x61); //9 and PageUp Sel 101 3 3 3 4/101/104 105 | pub const KP_0: Self = Self(0x62); //0 and Insert Sel 99 3 3 3 4/101/104 106 | pub const KP_DOT: Self = Self(0x63); //. and Delete Sel 104 3 3 3 4/101/104 107 | pub const NON_US_BACKSLASH: Self = Self(0x64); //Non-US \and |9,10 Sel 45 3 3 3 4/101/104 108 | pub const KC_AP11: Self = Self(0x65); //Application11 Sel 129 3 3 104 109 | pub const KC_POW1: Self = Self(0x66); //Power1 Sel 3 3 110 | pub const KP_EQ: Self = Self(0x67); //= Sel 3 111 | pub const KC_F13: Self = Self(0x68); //F13 Sel 3 112 | pub const KC_F14: Self = Self(0x69); //F14 Sel 3 113 | pub const KC_F15: Self = Self(0x6A); //F15 Sel 3 114 | pub const KC_F16: Self = Self(0x6B); //F16 Sel 115 | pub const KC_F17: Self = Self(0x6C); //F17 Sel 116 | pub const KC_F18: Self = Self(0x6D); //F18 Sel 117 | pub const KC_F19: Self = Self(0x6E); //F19 Sel 118 | pub const KC_F20: Self = Self(0x6F); //F20 Sel 119 | pub const KC_F21: Self = Self(0x70); //F21 Sel 120 | pub const KC_F22: Self = Self(0x71); //F22 Sel 121 | pub const KC_F23: Self = Self(0x72); //F23 Sel 122 | pub const KC_F24: Self = Self(0x73); //F24 Sel 123 | pub const KC_EXECUTE: Self = Self(0x74); //Execute Sel 3 124 | pub const KC_HELP: Self = Self(0x75); //Help Sel 3 125 | pub const KC_MENU: Self = Self(0x76); //Menu Sel 3 126 | pub const KC_SELECT: Self = Self(0x77); //Select Sel 3 127 | pub const KC_STOP: Self = Self(0x78); //Stop Sel 3 128 | pub const KC_AGAIN: Self = Self(0x79); //Again Sel 3 129 | pub const KC_UNDO: Self = Self(0x7A); //Undo Sel 3 130 | pub const KC_CUT: Self = Self(0x7B); //Cut Sel 3 131 | pub const KC_COPY: Self = Self(0x7C); //Copy Sel 3 132 | pub const KC_PAST: Self = Self(0x7D); //Paste Sel 3 133 | pub const KC_FIND: Self = Self(0x7E); //Find Sel 3 134 | pub const KC_MUTE: Self = Self(0x7F); //Mute Sel 3 135 | pub const KC_VOUP: Self = Self(0x80); //Volume Up Sel 3 136 | pub const KC_VODN: Self = Self(0x81); //Volume Down Sel 3 137 | pub const KC_LOCKING_CAPS: Self = Self(0x82); //Locking Caps Lock12 Sel 3 138 | pub const KC_LOCKING_NUM: Self = Self(0x83); //Locking Num Lock12 Sel 3 139 | pub const KC_LOCKING_SCROLL: Self = Self(0x84); //Locking Scroll Lock12 Sel 3 140 | pub const KP_COMMA13: Self = Self(0x85); //Comma13 Sel 107 141 | pub const KP_EQUAL: Self = Self(0x86); //Equal Sign14 Sel 3 142 | pub const KC_INTERNATIONAL115: Self = Self(0x87); //International115,16 Sel 56 143 | pub const KC_INTERNATIONAL217: Self = Self(0x88); //International217 Sel 144 | pub const KC_INTERNATIONAL318: Self = Self(0x89); //International318 Sel 145 | pub const KC_INTERNATIONAL419: Self = Self(0x8A); //International419 Sel 146 | pub const KC_INTERNATIONAL520: Self = Self(0x8B); //International520 Sel 147 | pub const KC_INTERNATIONAL621: Self = Self(0x8C); //International621 Sel 148 | pub const KC_INTERNATIONAL722: Self = Self(0x8D); //International722 Sel 149 | pub const KC_INTERNATIONAL823: Self = Self(0x8E); //International823 Sel 150 | pub const KC_INTERNATIONAL923: Self = Self(0x8F); //International923 Sel 151 | pub const KC_LANG124: Self = Self(0x90); //LANG124 Sel 152 | pub const KC_LANG225: Self = Self(0x91); //LANG225 Sel 153 | pub const KC_LANG326: Self = Self(0x92); //LANG326 Sel 154 | pub const KC_LANG427: Self = Self(0x93); //LANG427 Sel 155 | pub const KC_LANG528: Self = Self(0x94); //LANG528 Sel 156 | pub const KC_LANG629: Self = Self(0x95); //LANG629 Sel 157 | pub const KC_LANG729: Self = Self(0x96); //LANG729 Sel 158 | pub const KC_LANG829: Self = Self(0x97); //LANG829 Sel 159 | pub const KC_LANG929: Self = Self(0x98); //LANG929 Sel 160 | pub const KC_ALTERNATE_ERASE_30: Self = Self(0x99); //Alternate Erase30 Sel 161 | pub const KC_SYSREQ: Self = Self(0x9A); //SysReq/Attention7 Sel 162 | pub const KC_CANCEL: Self = Self(0x9B); //Cancel Sel 163 | pub const KC_CLEAR: Self = Self(0x9C); //Clear Sel 164 | pub const KC_PRIOR: Self = Self(0x9D); //Prior Sel 165 | pub const KC_RETURN: Self = Self(0x9E); //Return Sel 166 | pub const KC_SEPARATOR: Self = Self(0x9F); //Separator Sel 167 | pub const KC_OUT: Self = Self(0xA0); //Out Sel 168 | pub const KC_OPER: Self = Self(0xA1); //Oper Sel 169 | pub const KC_CLEAR_AGAIN: Self = Self(0xA2); //Clear/Again Sel 170 | pub const KC_CRSEL: Self = Self(0xA3); //CrSel/Props Sel 171 | pub const KC_EXSEL: Self = Self(0xA4); //ExSel Sel 172 | pub const KP_00: Self = Self(0xB0); //00 Sel 173 | pub const KP_000: Self = Self(0xB1); //000 Sel 174 | pub const SP_THOUSANDS: Self = Self(0xB2); //Separator31 Sel 175 | pub const SP_DECIMAL: Self = Self(0xB3); //Separator31 Sel 176 | pub const UN_CURRENCY: Self = Self(0xB4); //Unit32 Sel 177 | pub const UN_CURRENCY_SUB: Self = Self(0xB5); //Sub-unit32 Sel 178 | pub const KP_LEFT_PARENS: Self = Self(0xB6); //( Sel 179 | pub const KP_RIGHT_PARENS: Self = Self(0xB7); //) Sel 180 | pub const KP_LEFT_CURLY_BRACKET: Self = Self(0xB8); //{ Sel 181 | pub const KP_RIGHT_CURLY_BRACKET: Self = Self(0xB9); //} Sel 182 | pub const KP_TAB: Self = Self(0xBA); //Tab Sel 183 | pub const KP_BACKSPACE: Self = Self(0xBB); //Backspace Sel 184 | pub const KP_A: Self = Self(0xBC); //A Sel 185 | pub const KP_B: Self = Self(0xBD); //B Sel 186 | pub const KP_C: Self = Self(0xBE); //C Sel 187 | pub const KP_D: Self = Self(0xBF); //D Sel 188 | pub const KP_E: Self = Self(0xC0); //E Sel 189 | pub const KP_F: Self = Self(0xC1); //F Sel 190 | pub const KP_XOR: Self = Self(0xC2); //XOR Sel 191 | pub const KP_CIRCUMFLEX: Self = Self(0xC3); //∧ Sel 192 | pub const KP_PERCENTAGE: Self = Self(0xC4); //% Sel 193 | pub const KP_LEFT_ANGLE_BRACKET: Self = Self(0xC5); //< Sel 194 | pub const KP_RIGHT_ANGLE_BRACKET: Self = Self(0xC6); //> Sel 195 | pub const KP_AMPERSAND: Self = Self(0xC7); //& Sel 196 | pub const KP_DOUBLE_AMPERSAND: Self = Self(0xC8); //&& Sel 197 | pub const PIPE: Self = Self(0xC9); //| Sel 198 | pub const KP_DOUBLE_PIPE: Self = Self(0xCA); //|| Sel 199 | pub const KP_COLON: Self = Self(0xCB); //: Sel 200 | pub const KP_POUND: Self = Self(0xCC); //# Sel 201 | pub const KP_SPACE: Self = Self(0xCD); //Space Sel 202 | pub const KP_AT: Self = Self(0xCE); //@ Sel 203 | pub const KP_EXCLAMATION_MARK: Self = Self(0xCF); // ! Sel 204 | pub const KP_MEM_STORE: Self = Self(0xD0); //Memory Store Sel 205 | pub const KP_MEM_RECALL: Self = Self(0xD1); //Memory Recall Sel 206 | pub const KP_MEM_CLEAR: Self = Self(0xD2); //Memory Clear Sel 207 | pub const KP_MEM_ADD: Self = Self(0xD3); //Memory Add Sel 208 | pub const KP_MEM_SUB: Self = Self(0xD4); //Memory Subtract Sel 209 | pub const KP_MEM_MULT: Self = Self(0xD5); //Memory Multiply Sel 210 | pub const KP_MEM_DIV: Self = Self(0xD6); //Memory Divide Sel 211 | pub const KP_PLUS_MINS: Self = Self(0xD7); //+/- Sel 212 | pub const KP_CLEAR: Self = Self(0xD8); //Clear Sel 213 | pub const KP_CLEAR_ENTRY: Self = Self(0xD9); //Clear Entry Sel 214 | pub const KP_BINARY: Self = Self(0xDA); //Binary Sel 215 | pub const KP_OCTAL: Self = Self(0xDB); //Octal Sel 216 | pub const KP_DECIMAL: Self = Self(0xDC); //Decimal Sel 217 | pub const KP_HEXADECIMAL: Self = Self(0xDD); //Hexadecimal Sel 218 | } 219 | 220 | #[repr(transparent)] 221 | #[derive(Copy, Clone, Debug)] 222 | pub struct Modifier(pub u8); 223 | 224 | impl Modifier { 225 | pub const LEFT_CONTROL: Self = Self(0b0000_0001); //LeftControl DV 58 3 3 3 4/101/104 226 | pub const LEFT_SHIFT: Self = Self(0b0000_0010); //LeftShift DV 44 3 3 3 4/101/104 227 | pub const LEFT_ALT: Self = Self(0b0000_0100); //LeftAlt DV 60 3 3 3 4/101/104 228 | pub const LEFT_GUI: Self = Self(0b0000_1000); //Left GUI11,33 DV 127 3 3 3 104 229 | pub const RIGHT_CONTROL: Self = Self(0b0001_0000); //RightControl DV 64 3 3 3 101/104 230 | pub const KC_RSHIFT: Self = Self(0b0010_0000); //RightShift DV 57 3 3 3 4/101/104 231 | pub const RIGHT_ALT: Self = Self(0b0100_0000); //RightAlt DV 62 3 3 3 101/104 232 | pub const KC_RGUI: Self = Self(0b1000_0000); //Right GUI11,34 DV 128 3 3 3 104 233 | 234 | pub const ANY_SHIFT: Self = Self(Self::KC_RSHIFT.0 | Self::LEFT_SHIFT.0); 235 | } 236 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "ahash" 7 | version = "0.8.11" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" 10 | dependencies = [ 11 | "cfg-if", 12 | "once_cell", 13 | "version_check", 14 | "zerocopy", 15 | ] 16 | 17 | [[package]] 18 | name = "aho-corasick" 19 | version = "1.1.3" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 22 | dependencies = [ 23 | "memchr", 24 | ] 25 | 26 | [[package]] 27 | name = "arrayvec" 28 | version = "0.7.6" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" 31 | 32 | [[package]] 33 | name = "ascii-canvas" 34 | version = "4.0.0" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "ef1e3e699d84ab1b0911a1010c5c106aa34ae89aeac103be5ce0c3859db1e891" 37 | dependencies = [ 38 | "term", 39 | ] 40 | 41 | [[package]] 42 | name = "autocfg" 43 | version = "1.4.0" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 46 | 47 | [[package]] 48 | name = "az" 49 | version = "1.2.1" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" 52 | 53 | [[package]] 54 | name = "bare-metal" 55 | version = "0.2.5" 56 | source = "registry+https://github.com/rust-lang/crates.io-index" 57 | checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" 58 | dependencies = [ 59 | "rustc_version", 60 | ] 61 | 62 | [[package]] 63 | name = "bit-set" 64 | version = "0.8.0" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" 67 | dependencies = [ 68 | "bit-vec", 69 | ] 70 | 71 | [[package]] 72 | name = "bit-vec" 73 | version = "0.8.0" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" 76 | 77 | [[package]] 78 | name = "bitfield" 79 | version = "0.13.2" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" 82 | 83 | [[package]] 84 | name = "bitfield" 85 | version = "0.14.0" 86 | source = "registry+https://github.com/rust-lang/crates.io-index" 87 | checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" 88 | 89 | [[package]] 90 | name = "bitfield" 91 | version = "0.19.0" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | checksum = "786e53b0c071573a28956cec19a92653e42de34c683e2f6e86c197a349fba318" 94 | dependencies = [ 95 | "bitfield-macros", 96 | ] 97 | 98 | [[package]] 99 | name = "bitfield-macros" 100 | version = "0.19.0" 101 | source = "registry+https://github.com/rust-lang/crates.io-index" 102 | checksum = "07805405d3f1f3a55aab895718b488821d40458f9188059909091ae0935c344a" 103 | dependencies = [ 104 | "proc-macro2", 105 | "quote", 106 | "syn 2.0.100", 107 | ] 108 | 109 | [[package]] 110 | name = "bitflags" 111 | version = "2.9.0" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" 114 | 115 | [[package]] 116 | name = "block-buffer" 117 | version = "0.10.4" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 120 | dependencies = [ 121 | "generic-array", 122 | ] 123 | 124 | [[package]] 125 | name = "byte-slice-cast" 126 | version = "1.2.3" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" 129 | 130 | [[package]] 131 | name = "byteorder" 132 | version = "1.5.0" 133 | source = "registry+https://github.com/rust-lang/crates.io-index" 134 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 135 | 136 | [[package]] 137 | name = "cfg-if" 138 | version = "1.0.0" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 141 | 142 | [[package]] 143 | name = "codespan-reporting" 144 | version = "0.11.1" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" 147 | dependencies = [ 148 | "termcolor", 149 | "unicode-width", 150 | ] 151 | 152 | [[package]] 153 | name = "cortex-m" 154 | version = "0.7.7" 155 | source = "registry+https://github.com/rust-lang/crates.io-index" 156 | checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" 157 | dependencies = [ 158 | "bare-metal", 159 | "bitfield 0.13.2", 160 | "embedded-hal 0.2.7", 161 | "volatile-register", 162 | ] 163 | 164 | [[package]] 165 | name = "cortex-m-rt" 166 | version = "0.7.5" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "801d4dec46b34c299ccf6b036717ae0fce602faa4f4fe816d9013b9a7c9f5ba6" 169 | dependencies = [ 170 | "cortex-m-rt-macros", 171 | ] 172 | 173 | [[package]] 174 | name = "cortex-m-rt-macros" 175 | version = "0.7.5" 176 | source = "registry+https://github.com/rust-lang/crates.io-index" 177 | checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" 178 | dependencies = [ 179 | "proc-macro2", 180 | "quote", 181 | "syn 2.0.100", 182 | ] 183 | 184 | [[package]] 185 | name = "cpufeatures" 186 | version = "0.2.17" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" 189 | dependencies = [ 190 | "libc", 191 | ] 192 | 193 | [[package]] 194 | name = "crc-any" 195 | version = "2.5.0" 196 | source = "registry+https://github.com/rust-lang/crates.io-index" 197 | checksum = "a62ec9ff5f7965e4d7280bd5482acd20aadb50d632cf6c1d74493856b011fa73" 198 | dependencies = [ 199 | "debug-helper", 200 | ] 201 | 202 | [[package]] 203 | name = "critical-section" 204 | version = "1.2.0" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" 207 | 208 | [[package]] 209 | name = "crypto-common" 210 | version = "0.1.6" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 213 | dependencies = [ 214 | "generic-array", 215 | "typenum", 216 | ] 217 | 218 | [[package]] 219 | name = "debug-helper" 220 | version = "0.3.13" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e" 223 | 224 | [[package]] 225 | name = "digest" 226 | version = "0.10.7" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" 229 | dependencies = [ 230 | "block-buffer", 231 | "crypto-common", 232 | ] 233 | 234 | [[package]] 235 | name = "display-interface" 236 | version = "0.5.0" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | checksum = "7ba2aab1ef3793e6f7804162debb5ac5edb93b3d650fbcc5aeb72fcd0e6c03a0" 239 | 240 | [[package]] 241 | name = "display-interface-i2c" 242 | version = "0.5.0" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "0d964fa85bbbb5a6ecd06e58699407ac5dc3e3ad72dac0ab7e6b0d00a1cd262d" 245 | dependencies = [ 246 | "display-interface", 247 | "embedded-hal 1.0.0", 248 | "embedded-hal-async", 249 | ] 250 | 251 | [[package]] 252 | name = "display-interface-spi" 253 | version = "0.5.0" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "f86b9ec30048b1955da2038fcc3c017f419ab21bb0001879d16c0a3749dc6b7a" 256 | dependencies = [ 257 | "byte-slice-cast", 258 | "display-interface", 259 | "embedded-hal 1.0.0", 260 | "embedded-hal-async", 261 | ] 262 | 263 | [[package]] 264 | name = "either" 265 | version = "1.15.0" 266 | source = "registry+https://github.com/rust-lang/crates.io-index" 267 | checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" 268 | 269 | [[package]] 270 | name = "embedded-dma" 271 | version = "0.2.0" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "994f7e5b5cb23521c22304927195f236813053eb9c065dd2226a32ba64695446" 274 | dependencies = [ 275 | "stable_deref_trait", 276 | ] 277 | 278 | [[package]] 279 | name = "embedded-graphics" 280 | version = "0.8.1" 281 | source = "registry+https://github.com/rust-lang/crates.io-index" 282 | checksum = "0649998afacf6d575d126d83e68b78c0ab0e00ca2ac7e9b3db11b4cbe8274ef0" 283 | dependencies = [ 284 | "az", 285 | "byteorder", 286 | "embedded-graphics-core", 287 | "float-cmp", 288 | "micromath", 289 | ] 290 | 291 | [[package]] 292 | name = "embedded-graphics-core" 293 | version = "0.4.0" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "ba9ecd261f991856250d2207f6d8376946cd9f412a2165d3b75bc87a0bc7a044" 296 | dependencies = [ 297 | "az", 298 | "byteorder", 299 | ] 300 | 301 | [[package]] 302 | name = "embedded-hal" 303 | version = "0.2.7" 304 | source = "registry+https://github.com/rust-lang/crates.io-index" 305 | checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" 306 | dependencies = [ 307 | "nb 0.1.3", 308 | "void", 309 | ] 310 | 311 | [[package]] 312 | name = "embedded-hal" 313 | version = "1.0.0" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" 316 | 317 | [[package]] 318 | name = "embedded-hal-async" 319 | version = "1.0.0" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "0c4c685bbef7fe13c3c6dd4da26841ed3980ef33e841cddfa15ce8a8fb3f1884" 322 | dependencies = [ 323 | "embedded-hal 1.0.0", 324 | ] 325 | 326 | [[package]] 327 | name = "embedded-hal-nb" 328 | version = "1.0.0" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "fba4268c14288c828995299e59b12babdbe170f6c6d73731af1b4648142e8605" 331 | dependencies = [ 332 | "embedded-hal 1.0.0", 333 | "nb 1.1.0", 334 | ] 335 | 336 | [[package]] 337 | name = "embedded-io" 338 | version = "0.6.1" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" 341 | 342 | [[package]] 343 | name = "ena" 344 | version = "0.14.3" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" 347 | dependencies = [ 348 | "log", 349 | ] 350 | 351 | [[package]] 352 | name = "encode_unicode" 353 | version = "0.3.6" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" 356 | 357 | [[package]] 358 | name = "equivalent" 359 | version = "1.0.2" 360 | source = "registry+https://github.com/rust-lang/crates.io-index" 361 | checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 362 | 363 | [[package]] 364 | name = "fixedbitset" 365 | version = "0.5.7" 366 | source = "registry+https://github.com/rust-lang/crates.io-index" 367 | checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" 368 | 369 | [[package]] 370 | name = "float-cmp" 371 | version = "0.9.0" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" 374 | dependencies = [ 375 | "num-traits", 376 | ] 377 | 378 | [[package]] 379 | name = "frunk" 380 | version = "0.4.3" 381 | source = "registry+https://github.com/rust-lang/crates.io-index" 382 | checksum = "874b6a17738fc273ec753618bac60ddaeac48cb1d7684c3e7bd472e57a28b817" 383 | dependencies = [ 384 | "frunk_core", 385 | "frunk_derives", 386 | ] 387 | 388 | [[package]] 389 | name = "frunk_core" 390 | version = "0.4.3" 391 | source = "registry+https://github.com/rust-lang/crates.io-index" 392 | checksum = "3529a07095650187788833d585c219761114005d5976185760cf794d265b6a5c" 393 | 394 | [[package]] 395 | name = "frunk_derives" 396 | version = "0.4.3" 397 | source = "registry+https://github.com/rust-lang/crates.io-index" 398 | checksum = "e99b8b3c28ae0e84b604c75f721c21dc77afb3706076af5e8216d15fd1deaae3" 399 | dependencies = [ 400 | "frunk_proc_macro_helpers", 401 | "quote", 402 | "syn 2.0.100", 403 | ] 404 | 405 | [[package]] 406 | name = "frunk_proc_macro_helpers" 407 | version = "0.1.3" 408 | source = "registry+https://github.com/rust-lang/crates.io-index" 409 | checksum = "05a956ef36c377977e512e227dcad20f68c2786ac7a54dacece3746046fea5ce" 410 | dependencies = [ 411 | "frunk_core", 412 | "proc-macro2", 413 | "quote", 414 | "syn 2.0.100", 415 | ] 416 | 417 | [[package]] 418 | name = "fugit" 419 | version = "0.3.7" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "17186ad64927d5ac8f02c1e77ccefa08ccd9eaa314d5a4772278aa204a22f7e7" 422 | dependencies = [ 423 | "gcd", 424 | ] 425 | 426 | [[package]] 427 | name = "gcd" 428 | version = "2.3.0" 429 | source = "registry+https://github.com/rust-lang/crates.io-index" 430 | checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" 431 | 432 | [[package]] 433 | name = "generic-array" 434 | version = "0.14.7" 435 | source = "registry+https://github.com/rust-lang/crates.io-index" 436 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" 437 | dependencies = [ 438 | "typenum", 439 | "version_check", 440 | ] 441 | 442 | [[package]] 443 | name = "hash32" 444 | version = "0.3.1" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" 447 | dependencies = [ 448 | "byteorder", 449 | ] 450 | 451 | [[package]] 452 | name = "hashbrown" 453 | version = "0.13.2" 454 | source = "registry+https://github.com/rust-lang/crates.io-index" 455 | checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" 456 | dependencies = [ 457 | "ahash", 458 | ] 459 | 460 | [[package]] 461 | name = "hashbrown" 462 | version = "0.15.2" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" 465 | 466 | [[package]] 467 | name = "heapless" 468 | version = "0.8.0" 469 | source = "registry+https://github.com/rust-lang/crates.io-index" 470 | checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" 471 | dependencies = [ 472 | "hash32", 473 | "stable_deref_trait", 474 | ] 475 | 476 | [[package]] 477 | name = "home" 478 | version = "0.5.11" 479 | source = "registry+https://github.com/rust-lang/crates.io-index" 480 | checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" 481 | dependencies = [ 482 | "windows-sys 0.59.0", 483 | ] 484 | 485 | [[package]] 486 | name = "indexmap" 487 | version = "2.8.0" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" 490 | dependencies = [ 491 | "equivalent", 492 | "hashbrown 0.15.2", 493 | ] 494 | 495 | [[package]] 496 | name = "itertools" 497 | version = "0.14.0" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" 500 | dependencies = [ 501 | "either", 502 | ] 503 | 504 | [[package]] 505 | name = "keccak" 506 | version = "0.1.5" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" 509 | dependencies = [ 510 | "cpufeatures", 511 | ] 512 | 513 | [[package]] 514 | name = "lalrpop" 515 | version = "0.22.1" 516 | source = "registry+https://github.com/rust-lang/crates.io-index" 517 | checksum = "7047a26de42016abf8f181b46b398aef0b77ad46711df41847f6ed869a2a1d5b" 518 | dependencies = [ 519 | "ascii-canvas", 520 | "bit-set", 521 | "ena", 522 | "itertools", 523 | "lalrpop-util", 524 | "petgraph", 525 | "pico-args", 526 | "regex", 527 | "regex-syntax", 528 | "sha3", 529 | "string_cache", 530 | "term", 531 | "unicode-xid", 532 | "walkdir", 533 | ] 534 | 535 | [[package]] 536 | name = "lalrpop-util" 537 | version = "0.22.1" 538 | source = "registry+https://github.com/rust-lang/crates.io-index" 539 | checksum = "e8d05b3fe34b8bd562c338db725dfa9beb9451a48f65f129ccb9538b48d2c93b" 540 | dependencies = [ 541 | "regex-automata", 542 | "rustversion", 543 | ] 544 | 545 | [[package]] 546 | name = "liatris" 547 | version = "0.1.0" 548 | source = "git+https://github.com/MarcusGrass/rp-hal-boards?rev=748c497ce5f423599e168ca17d2f8017533c0afb#748c497ce5f423599e168ca17d2f8017533c0afb" 549 | dependencies = [ 550 | "cortex-m-rt", 551 | "fugit", 552 | "rp2040-boot2", 553 | "rp2040-hal", 554 | "usb-device", 555 | ] 556 | 557 | [[package]] 558 | name = "libc" 559 | version = "0.2.171" 560 | source = "registry+https://github.com/rust-lang/crates.io-index" 561 | checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" 562 | 563 | [[package]] 564 | name = "lock_api" 565 | version = "0.4.12" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" 568 | dependencies = [ 569 | "autocfg", 570 | "scopeguard", 571 | ] 572 | 573 | [[package]] 574 | name = "log" 575 | version = "0.4.27" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" 578 | 579 | [[package]] 580 | name = "maybe-async-cfg" 581 | version = "0.2.4" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "a1e083394889336bc66a4eaf1011ffbfa74893e910f902a9f271fa624c61e1b2" 584 | dependencies = [ 585 | "proc-macro-error", 586 | "proc-macro2", 587 | "pulldown-cmark", 588 | "quote", 589 | "syn 1.0.109", 590 | ] 591 | 592 | [[package]] 593 | name = "memchr" 594 | version = "2.7.4" 595 | source = "registry+https://github.com/rust-lang/crates.io-index" 596 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 597 | 598 | [[package]] 599 | name = "micromath" 600 | version = "2.1.0" 601 | source = "registry+https://github.com/rust-lang/crates.io-index" 602 | checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" 603 | 604 | [[package]] 605 | name = "nb" 606 | version = "0.1.3" 607 | source = "registry+https://github.com/rust-lang/crates.io-index" 608 | checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" 609 | dependencies = [ 610 | "nb 1.1.0", 611 | ] 612 | 613 | [[package]] 614 | name = "nb" 615 | version = "1.1.0" 616 | source = "registry+https://github.com/rust-lang/crates.io-index" 617 | checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" 618 | 619 | [[package]] 620 | name = "new_debug_unreachable" 621 | version = "1.0.6" 622 | source = "registry+https://github.com/rust-lang/crates.io-index" 623 | checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" 624 | 625 | [[package]] 626 | name = "num-traits" 627 | version = "0.2.19" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 630 | dependencies = [ 631 | "autocfg", 632 | ] 633 | 634 | [[package]] 635 | name = "num_enum" 636 | version = "0.7.3" 637 | source = "registry+https://github.com/rust-lang/crates.io-index" 638 | checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" 639 | dependencies = [ 640 | "num_enum_derive", 641 | ] 642 | 643 | [[package]] 644 | name = "num_enum_derive" 645 | version = "0.7.3" 646 | source = "registry+https://github.com/rust-lang/crates.io-index" 647 | checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" 648 | dependencies = [ 649 | "proc-macro2", 650 | "quote", 651 | "syn 2.0.100", 652 | ] 653 | 654 | [[package]] 655 | name = "once_cell" 656 | version = "1.21.2" 657 | source = "registry+https://github.com/rust-lang/crates.io-index" 658 | checksum = "c2806eaa3524762875e21c3dcd057bc4b7bfa01ce4da8d46be1cd43649e1cc6b" 659 | 660 | [[package]] 661 | name = "parking_lot" 662 | version = "0.12.3" 663 | source = "registry+https://github.com/rust-lang/crates.io-index" 664 | checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" 665 | dependencies = [ 666 | "lock_api", 667 | "parking_lot_core", 668 | ] 669 | 670 | [[package]] 671 | name = "parking_lot_core" 672 | version = "0.9.10" 673 | source = "registry+https://github.com/rust-lang/crates.io-index" 674 | checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" 675 | dependencies = [ 676 | "cfg-if", 677 | "libc", 678 | "redox_syscall", 679 | "smallvec", 680 | "windows-targets", 681 | ] 682 | 683 | [[package]] 684 | name = "paste" 685 | version = "1.0.15" 686 | source = "registry+https://github.com/rust-lang/crates.io-index" 687 | checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" 688 | 689 | [[package]] 690 | name = "petgraph" 691 | version = "0.7.1" 692 | source = "registry+https://github.com/rust-lang/crates.io-index" 693 | checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" 694 | dependencies = [ 695 | "fixedbitset", 696 | "indexmap", 697 | ] 698 | 699 | [[package]] 700 | name = "phf_shared" 701 | version = "0.11.3" 702 | source = "registry+https://github.com/rust-lang/crates.io-index" 703 | checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" 704 | dependencies = [ 705 | "siphasher", 706 | ] 707 | 708 | [[package]] 709 | name = "pico-args" 710 | version = "0.5.0" 711 | source = "registry+https://github.com/rust-lang/crates.io-index" 712 | checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" 713 | 714 | [[package]] 715 | name = "pio" 716 | version = "0.3.0" 717 | source = "registry+https://github.com/rust-lang/crates.io-index" 718 | checksum = "d0ba4153cee9585abc451271aa437d9e8defdea8b468d48ba6b8f098cbe03d7f" 719 | dependencies = [ 720 | "pio-core", 721 | "pio-proc", 722 | ] 723 | 724 | [[package]] 725 | name = "pio-core" 726 | version = "0.3.0" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "61d90fddc3d67f21bbf93683bc461b05d6a29c708caf3ffb79947d7ff7095406" 729 | dependencies = [ 730 | "arrayvec", 731 | "num_enum", 732 | "paste", 733 | ] 734 | 735 | [[package]] 736 | name = "pio-parser" 737 | version = "0.3.0" 738 | source = "registry+https://github.com/rust-lang/crates.io-index" 739 | checksum = "825266c1eaddf54f636d06eefa4bf3c99d774c14ec46a4a6c6e5128a0f10d205" 740 | dependencies = [ 741 | "lalrpop", 742 | "lalrpop-util", 743 | "pio-core", 744 | ] 745 | 746 | [[package]] 747 | name = "pio-proc" 748 | version = "0.3.0" 749 | source = "registry+https://github.com/rust-lang/crates.io-index" 750 | checksum = "ed4a76571f5fe51af43cc80ac870fe0c79cc0cdd686b9002a6c4c84bfdd0176b" 751 | dependencies = [ 752 | "codespan-reporting", 753 | "lalrpop-util", 754 | "pio-core", 755 | "pio-parser", 756 | "proc-macro-error2", 757 | "proc-macro2", 758 | "quote", 759 | "syn 2.0.100", 760 | ] 761 | 762 | [[package]] 763 | name = "pio-uart" 764 | version = "0.2.1" 765 | source = "git+https://github.com/MarcusGrass/pio-uart?rev=80f5fdbdbfb56e456ece97bdb7c8aebe18d10042#80f5fdbdbfb56e456ece97bdb7c8aebe18d10042" 766 | dependencies = [ 767 | "cortex-m", 768 | "embedded-io", 769 | "fugit", 770 | "pio", 771 | "rp2040-hal", 772 | ] 773 | 774 | [[package]] 775 | name = "precomputed-hash" 776 | version = "0.1.1" 777 | source = "registry+https://github.com/rust-lang/crates.io-index" 778 | checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" 779 | 780 | [[package]] 781 | name = "proc-macro-error" 782 | version = "1.0.4" 783 | source = "registry+https://github.com/rust-lang/crates.io-index" 784 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 785 | dependencies = [ 786 | "proc-macro-error-attr", 787 | "proc-macro2", 788 | "quote", 789 | "syn 1.0.109", 790 | "version_check", 791 | ] 792 | 793 | [[package]] 794 | name = "proc-macro-error-attr" 795 | version = "1.0.4" 796 | source = "registry+https://github.com/rust-lang/crates.io-index" 797 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 798 | dependencies = [ 799 | "proc-macro2", 800 | "quote", 801 | "version_check", 802 | ] 803 | 804 | [[package]] 805 | name = "proc-macro-error-attr2" 806 | version = "2.0.0" 807 | source = "registry+https://github.com/rust-lang/crates.io-index" 808 | checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" 809 | dependencies = [ 810 | "proc-macro2", 811 | "quote", 812 | ] 813 | 814 | [[package]] 815 | name = "proc-macro-error2" 816 | version = "2.0.1" 817 | source = "registry+https://github.com/rust-lang/crates.io-index" 818 | checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" 819 | dependencies = [ 820 | "proc-macro-error-attr2", 821 | "proc-macro2", 822 | "quote", 823 | "syn 2.0.100", 824 | ] 825 | 826 | [[package]] 827 | name = "proc-macro2" 828 | version = "1.0.94" 829 | source = "registry+https://github.com/rust-lang/crates.io-index" 830 | checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" 831 | dependencies = [ 832 | "unicode-ident", 833 | ] 834 | 835 | [[package]] 836 | name = "pulldown-cmark" 837 | version = "0.11.3" 838 | source = "registry+https://github.com/rust-lang/crates.io-index" 839 | checksum = "679341d22c78c6c649893cbd6c3278dcbe9fc4faa62fea3a9296ae2b50c14625" 840 | dependencies = [ 841 | "bitflags", 842 | "memchr", 843 | "unicase", 844 | ] 845 | 846 | [[package]] 847 | name = "quote" 848 | version = "1.0.40" 849 | source = "registry+https://github.com/rust-lang/crates.io-index" 850 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 851 | dependencies = [ 852 | "proc-macro2", 853 | ] 854 | 855 | [[package]] 856 | name = "rand_core" 857 | version = "0.9.3" 858 | source = "registry+https://github.com/rust-lang/crates.io-index" 859 | checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" 860 | 861 | [[package]] 862 | name = "redox_syscall" 863 | version = "0.5.10" 864 | source = "registry+https://github.com/rust-lang/crates.io-index" 865 | checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" 866 | dependencies = [ 867 | "bitflags", 868 | ] 869 | 870 | [[package]] 871 | name = "regex" 872 | version = "1.11.1" 873 | source = "registry+https://github.com/rust-lang/crates.io-index" 874 | checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" 875 | dependencies = [ 876 | "aho-corasick", 877 | "memchr", 878 | "regex-automata", 879 | "regex-syntax", 880 | ] 881 | 882 | [[package]] 883 | name = "regex-automata" 884 | version = "0.4.9" 885 | source = "registry+https://github.com/rust-lang/crates.io-index" 886 | checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" 887 | dependencies = [ 888 | "aho-corasick", 889 | "memchr", 890 | "regex-syntax", 891 | ] 892 | 893 | [[package]] 894 | name = "regex-syntax" 895 | version = "0.8.5" 896 | source = "registry+https://github.com/rust-lang/crates.io-index" 897 | checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" 898 | 899 | [[package]] 900 | name = "rp-binary-info" 901 | version = "0.1.1" 902 | source = "git+https://github.com/MarcusGrass/rp-hal?rev=79e022ddc15377c155682db15138b623212b978d#79e022ddc15377c155682db15138b623212b978d" 903 | 904 | [[package]] 905 | name = "rp-hal-common" 906 | version = "0.1.0" 907 | source = "git+https://github.com/MarcusGrass/rp-hal?rev=79e022ddc15377c155682db15138b623212b978d#79e022ddc15377c155682db15138b623212b978d" 908 | dependencies = [ 909 | "fugit", 910 | ] 911 | 912 | [[package]] 913 | name = "rp2040-boot2" 914 | version = "0.3.0" 915 | source = "registry+https://github.com/rust-lang/crates.io-index" 916 | checksum = "7c92f344f63f950ee36cf4080050e4dce850839b9175da38f9d2ffb69b4dbb21" 917 | dependencies = [ 918 | "crc-any", 919 | ] 920 | 921 | [[package]] 922 | name = "rp2040-hal" 923 | version = "0.11.0" 924 | source = "git+https://github.com/MarcusGrass/rp-hal?rev=79e022ddc15377c155682db15138b623212b978d#79e022ddc15377c155682db15138b623212b978d" 925 | dependencies = [ 926 | "bitfield 0.19.0", 927 | "cortex-m", 928 | "critical-section", 929 | "embedded-dma", 930 | "embedded-hal 0.2.7", 931 | "embedded-hal 1.0.0", 932 | "embedded-hal-async", 933 | "embedded-hal-nb", 934 | "embedded-io", 935 | "frunk", 936 | "fugit", 937 | "itertools", 938 | "nb 1.1.0", 939 | "paste", 940 | "pio", 941 | "rand_core", 942 | "rp-binary-info", 943 | "rp-hal-common", 944 | "rp2040-hal-macros", 945 | "rp2040-pac", 946 | "usb-device", 947 | "vcell", 948 | "void", 949 | ] 950 | 951 | [[package]] 952 | name = "rp2040-hal-macros" 953 | version = "0.1.0" 954 | source = "git+https://github.com/MarcusGrass/rp-hal?rev=79e022ddc15377c155682db15138b623212b978d#79e022ddc15377c155682db15138b623212b978d" 955 | dependencies = [ 956 | "proc-macro2", 957 | "quote", 958 | "syn 2.0.100", 959 | ] 960 | 961 | [[package]] 962 | name = "rp2040-kbd" 963 | version = "0.1.0" 964 | dependencies = [ 965 | "cortex-m-rt", 966 | "critical-section", 967 | "embedded-graphics", 968 | "embedded-hal 1.0.0", 969 | "heapless", 970 | "liatris", 971 | "paste", 972 | "pio-uart", 973 | "rp2040-hal", 974 | "rp2040-kbd-lib", 975 | "ssd1306", 976 | "usb-device", 977 | "usbd-hid", 978 | "usbd-serial", 979 | ] 980 | 981 | [[package]] 982 | name = "rp2040-kbd-lib" 983 | version = "0.1.0" 984 | 985 | [[package]] 986 | name = "rp2040-pac" 987 | version = "0.6.0" 988 | source = "registry+https://github.com/rust-lang/crates.io-index" 989 | checksum = "83cbcd3f7a0ca7bbe61dc4eb7e202842bee4e27b769a7bf3a4a72fa399d6e404" 990 | dependencies = [ 991 | "cortex-m", 992 | "cortex-m-rt", 993 | "critical-section", 994 | "vcell", 995 | ] 996 | 997 | [[package]] 998 | name = "rustc_version" 999 | version = "0.2.3" 1000 | source = "registry+https://github.com/rust-lang/crates.io-index" 1001 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 1002 | dependencies = [ 1003 | "semver", 1004 | ] 1005 | 1006 | [[package]] 1007 | name = "rustversion" 1008 | version = "1.0.20" 1009 | source = "registry+https://github.com/rust-lang/crates.io-index" 1010 | checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" 1011 | 1012 | [[package]] 1013 | name = "same-file" 1014 | version = "1.0.6" 1015 | source = "registry+https://github.com/rust-lang/crates.io-index" 1016 | checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 1017 | dependencies = [ 1018 | "winapi-util", 1019 | ] 1020 | 1021 | [[package]] 1022 | name = "scopeguard" 1023 | version = "1.2.0" 1024 | source = "registry+https://github.com/rust-lang/crates.io-index" 1025 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 1026 | 1027 | [[package]] 1028 | name = "semver" 1029 | version = "0.9.0" 1030 | source = "registry+https://github.com/rust-lang/crates.io-index" 1031 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1032 | dependencies = [ 1033 | "semver-parser", 1034 | ] 1035 | 1036 | [[package]] 1037 | name = "semver-parser" 1038 | version = "0.7.0" 1039 | source = "registry+https://github.com/rust-lang/crates.io-index" 1040 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 1041 | 1042 | [[package]] 1043 | name = "serde" 1044 | version = "1.0.219" 1045 | source = "registry+https://github.com/rust-lang/crates.io-index" 1046 | checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" 1047 | dependencies = [ 1048 | "serde_derive", 1049 | ] 1050 | 1051 | [[package]] 1052 | name = "serde_derive" 1053 | version = "1.0.219" 1054 | source = "registry+https://github.com/rust-lang/crates.io-index" 1055 | checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" 1056 | dependencies = [ 1057 | "proc-macro2", 1058 | "quote", 1059 | "syn 2.0.100", 1060 | ] 1061 | 1062 | [[package]] 1063 | name = "sha3" 1064 | version = "0.10.8" 1065 | source = "registry+https://github.com/rust-lang/crates.io-index" 1066 | checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" 1067 | dependencies = [ 1068 | "digest", 1069 | "keccak", 1070 | ] 1071 | 1072 | [[package]] 1073 | name = "siphasher" 1074 | version = "1.0.1" 1075 | source = "registry+https://github.com/rust-lang/crates.io-index" 1076 | checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" 1077 | 1078 | [[package]] 1079 | name = "smallvec" 1080 | version = "1.14.0" 1081 | source = "registry+https://github.com/rust-lang/crates.io-index" 1082 | checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" 1083 | 1084 | [[package]] 1085 | name = "ssd1306" 1086 | version = "0.10.0" 1087 | source = "registry+https://github.com/rust-lang/crates.io-index" 1088 | checksum = "3ea6aac2d078bbc71d9b8ac3f657335311f3b6625e9a1a96ccc29f5abfa77c56" 1089 | dependencies = [ 1090 | "display-interface", 1091 | "display-interface-i2c", 1092 | "display-interface-spi", 1093 | "embedded-graphics-core", 1094 | "embedded-hal 1.0.0", 1095 | "maybe-async-cfg", 1096 | ] 1097 | 1098 | [[package]] 1099 | name = "ssmarshal" 1100 | version = "1.0.0" 1101 | source = "registry+https://github.com/rust-lang/crates.io-index" 1102 | checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" 1103 | dependencies = [ 1104 | "encode_unicode", 1105 | "serde", 1106 | ] 1107 | 1108 | [[package]] 1109 | name = "stable_deref_trait" 1110 | version = "1.2.0" 1111 | source = "registry+https://github.com/rust-lang/crates.io-index" 1112 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" 1113 | 1114 | [[package]] 1115 | name = "string_cache" 1116 | version = "0.8.8" 1117 | source = "registry+https://github.com/rust-lang/crates.io-index" 1118 | checksum = "938d512196766101d333398efde81bc1f37b00cb42c2f8350e5df639f040bbbe" 1119 | dependencies = [ 1120 | "new_debug_unreachable", 1121 | "parking_lot", 1122 | "phf_shared", 1123 | "precomputed-hash", 1124 | ] 1125 | 1126 | [[package]] 1127 | name = "syn" 1128 | version = "1.0.109" 1129 | source = "registry+https://github.com/rust-lang/crates.io-index" 1130 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1131 | dependencies = [ 1132 | "proc-macro2", 1133 | "quote", 1134 | "unicode-ident", 1135 | ] 1136 | 1137 | [[package]] 1138 | name = "syn" 1139 | version = "2.0.100" 1140 | source = "registry+https://github.com/rust-lang/crates.io-index" 1141 | checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" 1142 | dependencies = [ 1143 | "proc-macro2", 1144 | "quote", 1145 | "unicode-ident", 1146 | ] 1147 | 1148 | [[package]] 1149 | name = "term" 1150 | version = "1.0.1" 1151 | source = "registry+https://github.com/rust-lang/crates.io-index" 1152 | checksum = "a3bb6001afcea98122260987f8b7b5da969ecad46dbf0b5453702f776b491a41" 1153 | dependencies = [ 1154 | "home", 1155 | "windows-sys 0.52.0", 1156 | ] 1157 | 1158 | [[package]] 1159 | name = "termcolor" 1160 | version = "1.4.1" 1161 | source = "registry+https://github.com/rust-lang/crates.io-index" 1162 | checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" 1163 | dependencies = [ 1164 | "winapi-util", 1165 | ] 1166 | 1167 | [[package]] 1168 | name = "typenum" 1169 | version = "1.18.0" 1170 | source = "registry+https://github.com/rust-lang/crates.io-index" 1171 | checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" 1172 | 1173 | [[package]] 1174 | name = "unicase" 1175 | version = "2.8.1" 1176 | source = "registry+https://github.com/rust-lang/crates.io-index" 1177 | checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" 1178 | 1179 | [[package]] 1180 | name = "unicode-ident" 1181 | version = "1.0.18" 1182 | source = "registry+https://github.com/rust-lang/crates.io-index" 1183 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 1184 | 1185 | [[package]] 1186 | name = "unicode-width" 1187 | version = "0.1.14" 1188 | source = "registry+https://github.com/rust-lang/crates.io-index" 1189 | checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" 1190 | 1191 | [[package]] 1192 | name = "unicode-xid" 1193 | version = "0.2.6" 1194 | source = "registry+https://github.com/rust-lang/crates.io-index" 1195 | checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" 1196 | 1197 | [[package]] 1198 | name = "usb-device" 1199 | version = "0.3.2" 1200 | source = "git+https://github.com/MarcusGrass/usb-device?rev=b0b066059065db55fc9991f18f5de755f1accd7f#b0b066059065db55fc9991f18f5de755f1accd7f" 1201 | dependencies = [ 1202 | "heapless", 1203 | ] 1204 | 1205 | [[package]] 1206 | name = "usbd-hid" 1207 | version = "0.8.2" 1208 | source = "registry+https://github.com/rust-lang/crates.io-index" 1209 | checksum = "e6f291ab53d428685cc780f08a2eb9d5d6ff58622db2b36e239a4f715f1e184c" 1210 | dependencies = [ 1211 | "serde", 1212 | "ssmarshal", 1213 | "usb-device", 1214 | "usbd-hid-macros", 1215 | ] 1216 | 1217 | [[package]] 1218 | name = "usbd-hid-descriptors" 1219 | version = "0.8.2" 1220 | source = "registry+https://github.com/rust-lang/crates.io-index" 1221 | checksum = "0eee54712c5d778d2fb2da43b1ce5a7b5060886ef7b09891baeb4bf36910a3ed" 1222 | dependencies = [ 1223 | "bitfield 0.14.0", 1224 | ] 1225 | 1226 | [[package]] 1227 | name = "usbd-hid-macros" 1228 | version = "0.8.2" 1229 | source = "registry+https://github.com/rust-lang/crates.io-index" 1230 | checksum = "bb573c76e7884035ac5e1ab4a81234c187a82b6100140af0ab45757650ccda38" 1231 | dependencies = [ 1232 | "byteorder", 1233 | "hashbrown 0.13.2", 1234 | "log", 1235 | "proc-macro2", 1236 | "quote", 1237 | "serde", 1238 | "syn 1.0.109", 1239 | "usbd-hid-descriptors", 1240 | ] 1241 | 1242 | [[package]] 1243 | name = "usbd-serial" 1244 | version = "0.2.2" 1245 | source = "registry+https://github.com/rust-lang/crates.io-index" 1246 | checksum = "065e4eaf93db81d5adac82d9cef8f8da314cb640fa7f89534b972383f1cf80fc" 1247 | dependencies = [ 1248 | "embedded-hal 0.2.7", 1249 | "embedded-io", 1250 | "nb 1.1.0", 1251 | "usb-device", 1252 | ] 1253 | 1254 | [[package]] 1255 | name = "vcell" 1256 | version = "0.1.3" 1257 | source = "registry+https://github.com/rust-lang/crates.io-index" 1258 | checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" 1259 | 1260 | [[package]] 1261 | name = "version_check" 1262 | version = "0.9.5" 1263 | source = "registry+https://github.com/rust-lang/crates.io-index" 1264 | checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" 1265 | 1266 | [[package]] 1267 | name = "void" 1268 | version = "1.0.2" 1269 | source = "registry+https://github.com/rust-lang/crates.io-index" 1270 | checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 1271 | 1272 | [[package]] 1273 | name = "volatile-register" 1274 | version = "0.2.2" 1275 | source = "registry+https://github.com/rust-lang/crates.io-index" 1276 | checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" 1277 | dependencies = [ 1278 | "vcell", 1279 | ] 1280 | 1281 | [[package]] 1282 | name = "walkdir" 1283 | version = "2.5.0" 1284 | source = "registry+https://github.com/rust-lang/crates.io-index" 1285 | checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" 1286 | dependencies = [ 1287 | "same-file", 1288 | "winapi-util", 1289 | ] 1290 | 1291 | [[package]] 1292 | name = "winapi-util" 1293 | version = "0.1.9" 1294 | source = "registry+https://github.com/rust-lang/crates.io-index" 1295 | checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" 1296 | dependencies = [ 1297 | "windows-sys 0.59.0", 1298 | ] 1299 | 1300 | [[package]] 1301 | name = "windows-sys" 1302 | version = "0.52.0" 1303 | source = "registry+https://github.com/rust-lang/crates.io-index" 1304 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 1305 | dependencies = [ 1306 | "windows-targets", 1307 | ] 1308 | 1309 | [[package]] 1310 | name = "windows-sys" 1311 | version = "0.59.0" 1312 | source = "registry+https://github.com/rust-lang/crates.io-index" 1313 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 1314 | dependencies = [ 1315 | "windows-targets", 1316 | ] 1317 | 1318 | [[package]] 1319 | name = "windows-targets" 1320 | version = "0.52.6" 1321 | source = "registry+https://github.com/rust-lang/crates.io-index" 1322 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1323 | dependencies = [ 1324 | "windows_aarch64_gnullvm", 1325 | "windows_aarch64_msvc", 1326 | "windows_i686_gnu", 1327 | "windows_i686_gnullvm", 1328 | "windows_i686_msvc", 1329 | "windows_x86_64_gnu", 1330 | "windows_x86_64_gnullvm", 1331 | "windows_x86_64_msvc", 1332 | ] 1333 | 1334 | [[package]] 1335 | name = "windows_aarch64_gnullvm" 1336 | version = "0.52.6" 1337 | source = "registry+https://github.com/rust-lang/crates.io-index" 1338 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1339 | 1340 | [[package]] 1341 | name = "windows_aarch64_msvc" 1342 | version = "0.52.6" 1343 | source = "registry+https://github.com/rust-lang/crates.io-index" 1344 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1345 | 1346 | [[package]] 1347 | name = "windows_i686_gnu" 1348 | version = "0.52.6" 1349 | source = "registry+https://github.com/rust-lang/crates.io-index" 1350 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1351 | 1352 | [[package]] 1353 | name = "windows_i686_gnullvm" 1354 | version = "0.52.6" 1355 | source = "registry+https://github.com/rust-lang/crates.io-index" 1356 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1357 | 1358 | [[package]] 1359 | name = "windows_i686_msvc" 1360 | version = "0.52.6" 1361 | source = "registry+https://github.com/rust-lang/crates.io-index" 1362 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1363 | 1364 | [[package]] 1365 | name = "windows_x86_64_gnu" 1366 | version = "0.52.6" 1367 | source = "registry+https://github.com/rust-lang/crates.io-index" 1368 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1369 | 1370 | [[package]] 1371 | name = "windows_x86_64_gnullvm" 1372 | version = "0.52.6" 1373 | source = "registry+https://github.com/rust-lang/crates.io-index" 1374 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1375 | 1376 | [[package]] 1377 | name = "windows_x86_64_msvc" 1378 | version = "0.52.6" 1379 | source = "registry+https://github.com/rust-lang/crates.io-index" 1380 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1381 | 1382 | [[package]] 1383 | name = "zerocopy" 1384 | version = "0.7.35" 1385 | source = "registry+https://github.com/rust-lang/crates.io-index" 1386 | checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" 1387 | dependencies = [ 1388 | "zerocopy-derive", 1389 | ] 1390 | 1391 | [[package]] 1392 | name = "zerocopy-derive" 1393 | version = "0.7.35" 1394 | source = "registry+https://github.com/rust-lang/crates.io-index" 1395 | checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" 1396 | dependencies = [ 1397 | "proc-macro2", 1398 | "quote", 1399 | "syn 2.0.100", 1400 | ] 1401 | --------------------------------------------------------------------------------