Update MCDU firmware for new PCB revision
Signed-off-by: fly <merspieler@alwaysdata.net>
This commit is contained in:
parent
66550ed861
commit
57f589f9a6
2 changed files with 91 additions and 91 deletions
|
@ -4,13 +4,13 @@
|
|||
2 Byte output, consisting of
|
||||
* 1 Byte for the reportId (always value 1)
|
||||
* 1 Byte for indicator LEDs, each bit controls one item:
|
||||
* 0x01: FM
|
||||
* 0x02: FAIL
|
||||
* 0x04: FM2
|
||||
* 0x08: RDY
|
||||
* 0x10: MENU
|
||||
* 0x20: IND
|
||||
* 0x40: FM1
|
||||
* 0x01: MENU
|
||||
* 0x02: FM2
|
||||
* 0x04: RDY
|
||||
* 0x08: FM1
|
||||
* 0x10: FM
|
||||
* 0x20: FAIL
|
||||
* 0x40: IND
|
||||
|
||||
## Firmware
|
||||
use the `--features FO` and `--features third` flags to compile for the FO and 3rd occupant MCDUs
|
||||
|
|
|
@ -41,44 +41,44 @@ macro_rules! define_output_states {
|
|||
|
||||
struct MyPins {
|
||||
// Input Col select
|
||||
pa4: Pin<'A', 4, Output<PushPull>>,
|
||||
pa5: Pin<'A', 5, Output<PushPull>>,
|
||||
pa15: Pin<'A', 15, Output<PushPull>>,
|
||||
pa1: Pin<'A', 1, Output<PushPull>>,
|
||||
pb5: Pin<'B', 5, Output<PushPull>>,
|
||||
pb6: Pin<'B', 6, Output<PushPull>>,
|
||||
pb7: Pin<'B', 7, Output<PushPull>>,
|
||||
pb15: Pin<'B', 15, Output<PushPull>>,
|
||||
pb11: Pin<'B', 11, Output<PushPull>>,
|
||||
pc2: Pin<'C', 2, Output<PushPull>>,
|
||||
pc3: Pin<'C', 3, Output<PushPull>>,
|
||||
pc5: Pin<'C', 5, Output<PushPull>>,
|
||||
pc6: Pin<'C', 6, Output<PushPull>>,
|
||||
pc7: Pin<'C', 7, Output<PushPull>>,
|
||||
pc8: Pin<'C', 8, Output<PushPull>>,
|
||||
pc10: Pin<'C', 10, Output<PushPull>>,
|
||||
pc11: Pin<'C', 11, Output<PushPull>>,
|
||||
pc15: Pin<'C', 15, Output<PushPull>>,
|
||||
pc12: Pin<'C', 12, Output<PushPull>>,
|
||||
|
||||
// Input read row
|
||||
pa0: Pin<'A', 0, Input<PullDown>>,
|
||||
pa1: Pin<'A', 1, Input<PullDown>>,
|
||||
pa2: Pin<'A', 2, Input<PullDown>>,
|
||||
pa3: Pin<'A', 3, Input<PullDown>>,
|
||||
pa7: Pin<'A', 7, Input<PullDown>>,
|
||||
pb0: Pin<'B', 0, Input<PullDown>>,
|
||||
pb1: Pin<'B', 1, Input<PullDown>>,
|
||||
pb2: Pin<'B', 2, Input<PullDown>>,
|
||||
pb4: Pin<'B', 4, Input<PullDown>>,
|
||||
pb5: Pin<'B', 5, Input<PullDown>>,
|
||||
pa8: Pin<'A', 8, Input<PullDown>>,
|
||||
pb10: Pin<'B', 10, Input<PullDown>>,
|
||||
pb12: Pin<'B', 12, Input<PullDown>>,
|
||||
pb13: Pin<'B', 13, Input<PullDown>>,
|
||||
pb14: Pin<'B', 14, Input<PullDown>>,
|
||||
pc0: Pin<'C', 0, Input<PullDown>>,
|
||||
pc1: Pin<'C', 1, Input<PullDown>>,
|
||||
pc2: Pin<'C', 2, Input<PullDown>>,
|
||||
pc3: Pin<'C', 3, Input<PullDown>>,
|
||||
pc9: Pin<'C', 9, Input<PullDown>>,
|
||||
pb15: Pin<'B', 15, Input<PullDown>>,
|
||||
pc4: Pin<'C', 4, Input<PullDown>>,
|
||||
pc11: Pin<'C', 11, Input<PullDown>>,
|
||||
pd2: Pin<'D', 2, Input<PullDown>>,
|
||||
|
||||
// Outputs
|
||||
pa9: Pin<'A', 9, Output<PushPull>>,
|
||||
pa10: Pin<'A', 10, Output<PushPull>>,
|
||||
pa15: Pin<'A', 15, Output<PushPull>>,
|
||||
pb8: Pin<'B', 8, Output<PushPull>>,
|
||||
pb9: Pin<'B', 9, Output<PushPull>>,
|
||||
pc12: Pin<'C', 12, Output<PushPull>>,
|
||||
pc1: Pin<'C', 1, Output<PushPull>>,
|
||||
pc8: Pin<'C', 8, Output<PushPull>>,
|
||||
pc9: Pin<'C', 9, Output<PushPull>>,
|
||||
pc13: Pin<'C', 13, Output<PushPull>>,
|
||||
pc14: Pin<'C', 14, Output<PushPull>>,
|
||||
}
|
||||
|
||||
#[entry]
|
||||
|
@ -148,44 +148,44 @@ fn main() -> ! {
|
|||
// ====================== Pin setup =================
|
||||
let mut io_pins = MyPins {
|
||||
// Inputs Col Select
|
||||
pa4: gpioa.pa4.into_push_pull_output(&mut gpioa.crl),
|
||||
pa5: gpioa.pa5.into_push_pull_output(&mut gpioa.crl),
|
||||
pa15: pa15.into_push_pull_output(&mut gpioa.crh),
|
||||
pa1: gpioa.pa1.into_push_pull_output(&mut gpioa.crl),
|
||||
pb5: gpiob.pb5.into_push_pull_output(&mut gpiob.crl),
|
||||
pb6: gpiob.pb6.into_push_pull_output(&mut gpiob.crl),
|
||||
pb7: gpiob.pb7.into_push_pull_output(&mut gpiob.crl),
|
||||
pb15: gpiob.pb15.into_push_pull_output(&mut gpiob.crh),
|
||||
pb11: gpiob.pb11.into_push_pull_output(&mut gpiob.crh),
|
||||
pc2: gpioc.pc2.into_push_pull_output(&mut gpioc.crl),
|
||||
pc3: gpioc.pc3.into_push_pull_output(&mut gpioc.crl),
|
||||
pc5: gpioc.pc5.into_push_pull_output(&mut gpioc.crl),
|
||||
pc6: gpioc.pc6.into_push_pull_output(&mut gpioc.crl),
|
||||
pc7: gpioc.pc7.into_push_pull_output(&mut gpioc.crl),
|
||||
pc8: gpioc.pc8.into_push_pull_output(&mut gpioc.crh),
|
||||
pc10: gpioc.pc10.into_push_pull_output(&mut gpioc.crh),
|
||||
pc11: gpioc.pc11.into_push_pull_output(&mut gpioc.crh),
|
||||
pc15: gpioc.pc15.into_push_pull_output(&mut gpioc.crh),
|
||||
pc12: gpioc.pc12.into_push_pull_output(&mut gpioc.crh),
|
||||
|
||||
// Inputs Row Read
|
||||
pa0: gpioa.pa0.into_pull_down_input(&mut gpioa.crl),
|
||||
pa1: gpioa.pa1.into_pull_down_input(&mut gpioa.crl),
|
||||
pa2: gpioa.pa2.into_pull_down_input(&mut gpioa.crl),
|
||||
pa3: gpioa.pa3.into_pull_down_input(&mut gpioa.crl),
|
||||
pa7: gpioa.pa7.into_pull_down_input(&mut gpioa.crl),
|
||||
pb0: gpiob.pb0.into_pull_down_input(&mut gpiob.crl),
|
||||
pb1: gpiob.pb1.into_pull_down_input(&mut gpiob.crl),
|
||||
pb2: gpiob.pb2.into_pull_down_input(&mut gpiob.crl),
|
||||
pb4: pb4.into_pull_down_input(&mut gpiob.crl),
|
||||
pb5: gpiob.pb5.into_pull_down_input(&mut gpiob.crl),
|
||||
pa8: gpioa.pa8.into_pull_down_input(&mut gpioa.crh),
|
||||
pb10: gpiob.pb10.into_pull_down_input(&mut gpiob.crh),
|
||||
pb12: gpiob.pb12.into_pull_down_input(&mut gpiob.crh),
|
||||
pb13: gpiob.pb13.into_pull_down_input(&mut gpiob.crh),
|
||||
pb14: gpiob.pb14.into_pull_down_input(&mut gpiob.crh),
|
||||
pc0: gpioc.pc0.into_pull_down_input(&mut gpioc.crl),
|
||||
pc1: gpioc.pc1.into_pull_down_input(&mut gpioc.crl),
|
||||
pc2: gpioc.pc2.into_pull_down_input(&mut gpioc.crl),
|
||||
pc3: gpioc.pc3.into_pull_down_input(&mut gpioc.crl),
|
||||
pc9: gpioc.pc9.into_pull_down_input(&mut gpioc.crh),
|
||||
pb15: gpiob.pb15.into_pull_down_input(&mut gpiob.crh),
|
||||
pc4: gpioc.pc4.into_pull_down_input(&mut gpioc.crl),
|
||||
pc11: gpioc.pc11.into_pull_down_input(&mut gpioc.crh),
|
||||
pd2: gpiod.pd2.into_pull_down_input(&mut gpiod.crl),
|
||||
|
||||
// Outputs
|
||||
pa9: gpioa.pa9.into_push_pull_output(&mut gpioa.crh), // FM
|
||||
pa10: gpioa.pa10.into_push_pull_output(&mut gpioa.crh), // FAIL
|
||||
pa15: pa15.into_push_pull_output(&mut gpioa.crh), // MENU
|
||||
pb8: gpiob.pb8.into_push_pull_output(&mut gpiob.crh), // FM2
|
||||
pb9: gpiob.pb9.into_push_pull_output(&mut gpiob.crh), // RDY
|
||||
pc12: gpioc.pc12.into_push_pull_output(&mut gpioc.crh), // MENU
|
||||
pc1: gpioc.pc1.into_push_pull_output(&mut gpioc.crl), // FM1
|
||||
pc8: gpioc.pc8.into_push_pull_output(&mut gpioc.crh), // FM
|
||||
pc9: gpioc.pc9.into_push_pull_output(&mut gpioc.crh), // FAIL
|
||||
pc13: gpioc.pc13.into_push_pull_output(&mut gpioc.crh), // IND
|
||||
pc14: gpioc.pc14.into_push_pull_output(&mut gpioc.crh), // FM1
|
||||
};
|
||||
|
||||
// ====================== Timer setup ===============
|
||||
|
@ -205,12 +205,12 @@ fn main() -> ! {
|
|||
// LSK Matirx
|
||||
let mut lsk_buttons_read: u32 = 0;
|
||||
|
||||
if io_pins.pc0.is_high() { lsk_buttons_read += 0x1; }
|
||||
if io_pins.pc1.is_high() { lsk_buttons_read += 0x2; }
|
||||
if io_pins.pc2.is_high() { lsk_buttons_read += 0x4; }
|
||||
if io_pins.pd2.is_high() { lsk_buttons_read += 0x40; }
|
||||
if io_pins.pb4.is_high() { lsk_buttons_read += 0x80; }
|
||||
if io_pins.pb5.is_high() { lsk_buttons_read += 0x100; }
|
||||
if io_pins.pa7.is_high() { lsk_buttons_read += 0x1; }
|
||||
if io_pins.pa3.is_high() { lsk_buttons_read += 0x2; }
|
||||
if io_pins.pa2.is_high() { lsk_buttons_read += 0x4; }
|
||||
if io_pins.pc11.is_high() { lsk_buttons_read += 0x40; }
|
||||
if io_pins.pd2.is_high() { lsk_buttons_read += 0x80; }
|
||||
if io_pins.pb4.is_high() { lsk_buttons_read += 0x100; }
|
||||
|
||||
buttons2 = buttons2 & (0xFFFFFFFF - (0x1CF << (lsk_col_select * 3)));
|
||||
buttons2 += lsk_buttons_read << (lsk_col_select * 3);
|
||||
|
@ -218,29 +218,29 @@ fn main() -> ! {
|
|||
// Main Matrix
|
||||
let mut buttons_read: u64 = 0;
|
||||
|
||||
if io_pins.pc3.is_high() { buttons_read += 0x1; }
|
||||
if io_pins.pa0.is_high() { buttons_read += 0x2; }
|
||||
if io_pins.pa1.is_high() { buttons_read += 0x4; }
|
||||
if io_pins.pa2.is_high() { buttons_read += 0x8; }
|
||||
if io_pins.pb12.is_high() { buttons_read += 0x10; }
|
||||
if io_pins.pc4.is_high() { buttons_read += 0x1; }
|
||||
if io_pins.pb0.is_high() { buttons_read += 0x2; }
|
||||
if io_pins.pb1.is_high() { buttons_read += 0x4; }
|
||||
if io_pins.pb2.is_high() { buttons_read += 0x8; }
|
||||
if io_pins.pb10.is_high() { buttons_read += 0x10; }
|
||||
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.pb12.is_high() { buttons_read += 0x40; }
|
||||
if io_pins.pb14.is_high() { buttons_read += 0x80; }
|
||||
|
||||
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; }
|
||||
if io_pins.pb15.is_high() { buttons2 = (buttons2 & 0xFFFFEFFF) + 0x1000; }
|
||||
else { buttons2 = buttons2 & 0xFFFFEFFF; }
|
||||
}
|
||||
if col_select == 2 {
|
||||
if io_pins.pa8.is_high() { buttons2 = (buttons2 & 0xFFFFDFFF) + 0x2000; }
|
||||
if io_pins.pb15.is_high() { buttons2 = (buttons2 & 0xFFFFDFFF) + 0x2000; }
|
||||
else { buttons2 = buttons2 & 0xFFFFDFFF; }
|
||||
}
|
||||
if col_select == 3 {
|
||||
if io_pins.pa8.is_high() { buttons2 = (buttons2 & 0xFFFFBFFF) + 0x4000; }
|
||||
if io_pins.pb15.is_high() { buttons2 = (buttons2 & 0xFFFFBFFF) + 0x4000; }
|
||||
else { buttons2 = buttons2 & 0xFFFFBFFF; }
|
||||
}
|
||||
|
||||
|
@ -252,50 +252,50 @@ fn main() -> ! {
|
|||
};
|
||||
// Pull the next LSK column high for next time coming through in the main loop ~1ms
|
||||
if lsk_col_select <= 0 {
|
||||
io_pins.pc15.set_high();
|
||||
io_pins.pa5.set_low();
|
||||
io_pins.pb6.set_high();
|
||||
io_pins.pb7.set_low();
|
||||
io_pins.pc2.set_high();
|
||||
io_pins.pc3.set_low();
|
||||
io_pins.pb5.set_high();
|
||||
io_pins.pb6.set_low();
|
||||
}
|
||||
else {
|
||||
io_pins.pc15.set_low();
|
||||
io_pins.pa5.set_high();
|
||||
io_pins.pb6.set_low();
|
||||
io_pins.pb7.set_high();
|
||||
io_pins.pc2.set_low();
|
||||
io_pins.pc3.set_high();
|
||||
io_pins.pb5.set_low();
|
||||
io_pins.pb6.set_high();
|
||||
}
|
||||
|
||||
// Pull the next main column high for next time coming through in the main loop ~1ms
|
||||
if col_select <= 0 {
|
||||
io_pins.pb15.set_high();
|
||||
io_pins.pc7.set_high();
|
||||
io_pins.pc10.set_low();
|
||||
}
|
||||
else if col_select == 1 {
|
||||
io_pins.pc6.set_high();
|
||||
io_pins.pb15.set_low();
|
||||
io_pins.pc7.set_low();
|
||||
}
|
||||
else if col_select == 2 {
|
||||
io_pins.pc7.set_high();
|
||||
io_pins.pb11.set_high();
|
||||
io_pins.pc6.set_low();
|
||||
}
|
||||
else if col_select == 3 {
|
||||
io_pins.pc8.set_high();
|
||||
io_pins.pc7.set_low();
|
||||
io_pins.pc5.set_high();
|
||||
io_pins.pb11.set_low();
|
||||
}
|
||||
else if col_select == 4 {
|
||||
io_pins.pa4.set_high();
|
||||
io_pins.pc8.set_low();
|
||||
io_pins.pa1.set_high();
|
||||
io_pins.pc5.set_low();
|
||||
}
|
||||
else if col_select == 5 {
|
||||
io_pins.pc11.set_high();
|
||||
io_pins.pa4.set_low();
|
||||
io_pins.pb7.set_high();
|
||||
io_pins.pa1.set_low();
|
||||
}
|
||||
else if col_select == 6 {
|
||||
io_pins.pa15.set_high();
|
||||
io_pins.pc11.set_low();
|
||||
io_pins.pc12.set_high();
|
||||
io_pins.pb7.set_low();
|
||||
}
|
||||
else if col_select == 7 {
|
||||
io_pins.pc10.set_high();
|
||||
io_pins.pa15.set_low();
|
||||
io_pins.pc12.set_low();
|
||||
}
|
||||
|
||||
|
||||
|
@ -317,7 +317,7 @@ fn main() -> ! {
|
|||
Ok(_) => {
|
||||
}
|
||||
Err(e) => {
|
||||
io_pins.pa10.set_high(); // set as indicator that this has happened
|
||||
io_pins.pc9.set_high(); // set as indicator that this has happened
|
||||
core::panic!("Failed to write consumer report: {:?}", e)
|
||||
}
|
||||
}
|
||||
|
@ -327,13 +327,13 @@ fn main() -> ! {
|
|||
Err(UsbHidError::WouldBlock) => { }
|
||||
Ok(output) => {
|
||||
// LED outputs
|
||||
define_output_states!(0x1, pa9, output, io_pins); // FM
|
||||
define_output_states!(0x2, pa10, output, io_pins); // FAIL
|
||||
define_output_states!(0x4, pb8, output, io_pins); // FM2
|
||||
define_output_states!(0x8, pb9, output, io_pins); // RDY
|
||||
define_output_states!(0x10, pc12, output, io_pins); // MENU
|
||||
define_output_states!(0x20, pc13, output, io_pins); // IND
|
||||
define_output_states!(0x40, pc14, output, io_pins); // FM1
|
||||
define_output_states!(0x1, pa15, output, io_pins); // MENU
|
||||
define_output_states!(0x2, pb8, output, io_pins); // FM2
|
||||
define_output_states!(0x4, pb9, output, io_pins); // RDY
|
||||
define_output_states!(0x8, pc1, output, io_pins); // FM1
|
||||
define_output_states!(0x10, pc8, output, io_pins); // FM
|
||||
define_output_states!(0x20, pc9, output, io_pins); // FAIL
|
||||
define_output_states!(0x40, pc13, output, io_pins); // IND
|
||||
}
|
||||
Err(e) => {
|
||||
core::panic!("Failed to write consumer report: {:?}", e)
|
||||
|
|
Loading…
Add table
Reference in a new issue