From cddcaef9cf26d24264169a5da158380189dac970 Mon Sep 17 00:00:00 2001 From: fly Date: Tue, 3 Dec 2024 00:18:50 +0100 Subject: [PATCH] Fix row 9 issue Signed-off-by: fly --- Pedestal/MCDU/firmware/src/main.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Pedestal/MCDU/firmware/src/main.rs b/Pedestal/MCDU/firmware/src/main.rs index a97aa5b..28a5adc 100644 --- a/Pedestal/MCDU/firmware/src/main.rs +++ b/Pedestal/MCDU/firmware/src/main.rs @@ -105,7 +105,7 @@ fn main() -> ! { .freeze(&mut flash.acr); let mut afio = p.AFIO.constrain(); - let (pa15, pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4); // To allow us to use pa15 and pb4 + let (pa15, _pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4); // To allow us to use pa15 and pb4 // ====================== USB setup ================= assert!(clocks.usbclk_valid()); @@ -226,11 +226,24 @@ fn main() -> ! { if io_pins.pb13.is_high() { buttons_read += 0x20; } if io_pins.pb14.is_high() { buttons_read += 0x40; } if io_pins.pc9.is_high() { buttons_read += 0x80; } -// if io_pins.pa8.is_high() { buttons_read += 0x100; } buttons1 = buttons1 & (0xFFFFFFFFFFFFFFFF - (0xFF << (col_select * 8))); buttons1 += buttons_read << (col_select * 8); + // Treat row 9 special so it fits into the 64 bit block + if col_select == 1 { + if io_pins.pa8.is_high() { buttons2 = (buttons2 & 0xFFFFEFFF) + 0x1000; } + else { buttons2 = buttons2 & 0xFFFFEFFF; } + } + if col_select == 2 { + if io_pins.pa8.is_high() { buttons2 = (buttons2 & 0xFFFFDFFF) + 0x2000; } + else { buttons2 = buttons2 & 0xFFFFDFFF; } + } + if col_select == 3 { + if io_pins.pa8.is_high() { buttons2 = (buttons2 & 0xFFFFBFFF) + 0x4000; } + else { buttons2 = buttons2 & 0xFFFFBFFF; } + } + let report = CustomInputReport { report_id: 1, buttons1, @@ -244,7 +257,7 @@ fn main() -> ! { io_pins.pb6.set_high(); io_pins.pb7.set_low(); } - else if lsk_col_select == 1 { + else { io_pins.pc15.set_low(); io_pins.pa5.set_high(); io_pins.pb6.set_low();