From b79621076080ee1518189aa9f8788780f618aa21 Mon Sep 17 00:00:00 2001 From: Marc Poulhiès Date: Fri, 25 Feb 2022 22:39:32 +0100 Subject: Update some dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc Poulhiès --- firmware/Cargo.toml | 7 ++-- firmware/src/main.rs | 114 ++++++++++++++++++--------------------------------- 2 files changed, 43 insertions(+), 78 deletions(-) (limited to 'firmware') diff --git a/firmware/Cargo.toml b/firmware/Cargo.toml index b93b6f3..5cc1170 100644 --- a/firmware/Cargo.toml +++ b/firmware/Cargo.toml @@ -6,17 +6,16 @@ edition = "2018" [dependencies] stm32f0xx-hal = { git = "https://github.com/dkm/stm32f0xx-hal/", features = ["rt", "stm32f072", "stm32-usbd"] } -##{ version = "0.17.0", features = ["rt", "stm32f072", "stm32-usbd"] } +##stm32f0xx-hal = { version = "0.17.0", features = ["rt", "stm32f072", "stm32-usbd"] } cortex-m = "0.6" cortex-m-rt = { version = "0.6", features = ["device"] } panic-halt = "0.2" keyberon = { git = "https://github.com/TeXiToi/keyberon" } -cortex-m-rtic = "0.5" -generic-array = "0.13" +cortex-m-rtic = { version = "0.5.8", default-features = false, features = ["cortex-m-7"] } embedded-hal = "0.2" usb-device = "0.2" nb = "1.0" -ws2812-spi = "0.3" +ws2812-spi = "0.4" smart-leds = "0.3" [profile.release] diff --git a/firmware/src/main.rs b/firmware/src/main.rs index 2806262..c07a1c1 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -4,21 +4,30 @@ // set the panic handler use panic_halt as _; +use core::convert::Infallible; + +use hal::prelude::*; +use hal::serial; +//use hal::usb; +use keyberon::layout::{CustomEvent, Event, Layout}; +use keyberon::matrix::{Matrix, PressedKeys}; +use nb::block; +use rtic::app; +use stm32f0xx_hal as hal; +use usb_device::bus::UsbBusAllocator; +use usb_device::class::UsbClass as _; +use usb_device::device::UsbDeviceState; + extern crate smart_leds; extern crate ws2812_spi; - use smart_leds::{brightness, colors, SmartLedsWrite, RGB8}; use ws2812_spi as ws2812; -use core::convert::Infallible; - use embedded_hal::digital::v2::{InputPin, OutputPin}; -use generic_array::typenum::{U12, U5}; - use hal::delay::Delay; -use hal::gpio::{gpioa, gpiob, Alternate, Input, Output, PullUp, PushPull, AF0}; +use hal::gpio::{gpioa, gpiob, Alternate, Input, Output, Pin, PullUp, PushPull, AF0}; use hal::prelude::*; use embedded_hal::spi::FullDuplex; @@ -31,17 +40,9 @@ use hal::{ use keyberon::action::Action; use keyberon::debounce::Debouncer; -use keyberon::impl_heterogenous_array; use keyberon::key_code::KbHidReport; use keyberon::key_code::KeyCode; -use keyberon::layout::Layout; -use keyberon::matrix::{Matrix, PressedKeys}; - -use rtic::app; -use stm32f0xx_hal as hal; - -use usb_device::bus::UsbBusAllocator; use usb_device::class::UsbClass as _; type Spi = hal::spi::Spi< stm32::SPI1, @@ -67,41 +68,6 @@ impl ResultExt for Result { } } -pub struct Cols( - gpioa::PA0>, // 12 - gpioa::PA1>, // 11 - gpiob::PB13>, // 10 - gpiob::PB12>, // 9 - gpiob::PB14>, // 8 - gpiob::PB15>, // 7 - gpioa::PA15>, // 6 - gpiob::PB3>, // 5 - gpiob::PB4>, // 4 - gpiob::PB5>, // 3 - gpiob::PB8>, // 2 - gpiob::PB9>, // 1 -); -impl_heterogenous_array! { - Cols, - dyn InputPin, - U12, - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] -} - -pub struct Rows( - gpiob::PB0>, - gpiob::PB1>, - gpiob::PB2>, - gpiob::PB10>, - gpiob::PB11>, -); -impl_heterogenous_array! { - Rows, - dyn OutputPin, - U5, - [0, 1, 2, 3, 4] -} - #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum CustomActions { LightUp, @@ -375,8 +341,8 @@ const APP: () = { struct Resources { usb_dev: UsbDevice, usb_class: UsbClass, - matrix: Matrix, - debouncer: Debouncer>, + matrix: Matrix>, Pin>, 12, 5>, + debouncer: Debouncer>, layout: Layout, timer: timers::Timer, @@ -464,29 +430,29 @@ const APP: () = { let matrix = cortex_m::interrupt::free(move |cs| { Matrix::new( - Cols( - pa0.into_pull_up_input(cs), - pa1.into_pull_up_input(cs), - gpiob.pb13.into_pull_up_input(cs), - gpiob.pb12.into_pull_up_input(cs), - gpiob.pb14.into_pull_up_input(cs), - gpiob.pb15.into_pull_up_input(cs), - pa15.into_pull_up_input(cs), - gpiob.pb3.into_pull_up_input(cs), - gpiob.pb4.into_pull_up_input(cs), - gpiob.pb5.into_pull_up_input(cs), - gpiob.pb8.into_pull_up_input(cs), - gpiob.pb9.into_pull_up_input(cs), - ), - Rows( - gpiob.pb0.into_push_pull_output(cs), - gpiob.pb1.into_push_pull_output(cs), - gpiob.pb2.into_push_pull_output(cs), - gpiob.pb10.into_push_pull_output(cs), - gpiob.pb11.into_push_pull_output(cs), - ), - ) - }); + [ + pa0.into_pull_up_input(cs).downgrade(), + pa1.into_pull_up_input(cs).downgrade(), + gpiob.pb13.into_pull_up_input(cs).downgrade(), + gpiob.pb12.into_pull_up_input(cs).downgrade(), + gpiob.pb14.into_pull_up_input(cs).downgrade(), + gpiob.pb15.into_pull_up_input(cs).downgrade(), + pa15.into_pull_up_input(cs).downgrade(), + gpiob.pb3.into_pull_up_input(cs).downgrade(), + gpiob.pb4.into_pull_up_input(cs).downgrade(), + gpiob.pb5.into_pull_up_input(cs).downgrade(), + gpiob.pb8.into_pull_up_input(cs).downgrade(), + gpiob.pb9.into_pull_up_input(cs).downgrade(), + ], + [ + gpiob.pb0.into_push_pull_output(cs).downgrade(), + gpiob.pb1.into_push_pull_output(cs).downgrade(), + gpiob.pb2.into_push_pull_output(cs).downgrade(), + gpiob.pb10.into_push_pull_output(cs).downgrade(), + gpiob.pb11.into_push_pull_output(cs).downgrade(), + + ], + )}); init::LateResources { usb_dev, -- cgit v1.2.3