Make the ECAM page lights work
Signed-off-by: fly <merspieler@alwaysdata.net>
This commit is contained in:
parent
14bb51d128
commit
2ad43d73af
1 changed files with 19 additions and 15 deletions
|
@ -17,7 +17,7 @@ use cortex_m::asm::delay;
|
|||
use cortex_m_rt::entry;
|
||||
use stm32f1xx_hal::{
|
||||
adc,
|
||||
gpio::{Pin, Input, Analog, PullDown, Output, PushPull},
|
||||
gpio::{Pin, Input, Analog, PullDown, Output, PushPull, Dynamic},
|
||||
pac,
|
||||
prelude::*,
|
||||
timer::{Tim2FullRemap, Timer},
|
||||
|
@ -48,12 +48,12 @@ macro_rules! define_output_states {
|
|||
}
|
||||
|
||||
macro_rules! define_ecam_output_states_row {
|
||||
($index:literal, $pin:ident, $ecam_row:ident, $io_pins:ident) => {
|
||||
($index:literal, $pin:ident, $ecam_row:ident, $io_pins:ident, &mut $cr_base:ident, &mut $cr_part:ident) => {
|
||||
if $ecam_row[$index] == 1 {
|
||||
$io_pins.$pin.set_high();
|
||||
$io_pins.$pin.make_push_pull_output(&mut $cr_base.$cr_part);
|
||||
}
|
||||
else {
|
||||
$io_pins.$pin.set_low();
|
||||
$io_pins.$pin.make_pull_down_input(&mut $cr_base.$cr_part);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -118,7 +118,6 @@ struct MyPins {
|
|||
pb6: Pin<'B', 6, Output<PushPull>>, // Door Fault Light
|
||||
pb7: Pin<'B', 7, Output<PushPull>>, // Door Open Light
|
||||
pb11: Pin<'B', 11, Output<PushPull>>, // ECAM LEDs Column 6
|
||||
pb12: Pin<'B', 12, Output<PushPull>>, // ECAM LEDs Row 1
|
||||
pc7: Pin<'C', 7, Output<PushPull>>, // ECAM LEDs Column 2
|
||||
pc8: Pin<'C', 8, Output<PushPull>>, // ECAM LEDs Column 3
|
||||
pd8: Pin<'D', 8, Output<PushPull>>, // ECAM LEDs Column 5
|
||||
|
@ -128,8 +127,11 @@ struct MyPins {
|
|||
pe2: Pin<'E', 2, Output<PushPull>>, // Engine 1 Fault
|
||||
pe3: Pin<'E', 3, Output<PushPull>>, // Engine 2 Fault
|
||||
pe4: Pin<'E', 4, Output<PushPull>>, // Engine 2 Fire
|
||||
pe9: Pin<'E', 9, Output<PushPull>>, // ECAM LEDs Row 3
|
||||
pe13: Pin<'E', 13, Output<PushPull>>, // ECAM LEDs Row 2
|
||||
|
||||
// ECAM LEDs row select
|
||||
pb12: Pin<'B', 12, Dynamic>, // ECAM LEDs Row 1
|
||||
pe9: Pin<'E', 9, Dynamic>, // ECAM LEDs Row 3
|
||||
pe13: Pin<'E', 13, Dynamic>, // ECAM LEDs Row 2
|
||||
|
||||
// ECAM matrix read row
|
||||
pe12: Pin<'E', 12, Input<PullDown>>, // ECAM Keys Row 1
|
||||
|
@ -296,7 +298,6 @@ fn main() -> ! {
|
|||
pb6: gpiob.pb6.into_push_pull_output(&mut gpiob.crl),
|
||||
pb7: gpiob.pb7.into_push_pull_output(&mut gpiob.crl),
|
||||
pb11: gpiob.pb11.into_push_pull_output(&mut gpiob.crh),
|
||||
pb12: gpiob.pb12.into_push_pull_output(&mut gpiob.crh),
|
||||
pc7: gpioc.pc7.into_push_pull_output(&mut gpioc.crl),
|
||||
pc8: gpioc.pc8.into_push_pull_output(&mut gpioc.crh),
|
||||
pd8: gpiod.pd8.into_push_pull_output(&mut gpiod.crh),
|
||||
|
@ -306,8 +307,11 @@ fn main() -> ! {
|
|||
pe2: gpioe.pe2.into_push_pull_output(&mut gpioe.crl),
|
||||
pe3: gpioe.pe3.into_push_pull_output(&mut gpioe.crl),
|
||||
pe4: gpioe.pe4.into_push_pull_output(&mut gpioe.crl),
|
||||
pe9: gpioe.pe9.into_push_pull_output(&mut gpioe.crh),
|
||||
pe13: gpioe.pe13.into_push_pull_output(&mut gpioe.crh),
|
||||
|
||||
// ECAM LEDs row select
|
||||
pb12: gpiob.pb12.into_dynamic(&mut gpiob.crh),
|
||||
pe9: gpioe.pe9.into_dynamic(&mut gpioe.crh),
|
||||
pe13: gpioe.pe13.into_dynamic(&mut gpioe.crh),
|
||||
|
||||
// ECAM matrix read row
|
||||
pe12: gpioe.pe12.into_pull_down_input(&mut gpioe.crh),
|
||||
|
@ -494,8 +498,8 @@ fn main() -> ! {
|
|||
let mut ecam_row = [0; 3];
|
||||
let mut ecam_col = [0; 6];
|
||||
// Match row and col
|
||||
if output.leds_ecam & 0x54A != 0 { ecam_row[0] = 1; }
|
||||
if output.leds_ecam & 0x1A94 != 0 { ecam_row[1] = 1; }
|
||||
if output.leds_ecam & 0x1A94 != 0 { ecam_row[0] = 1; }
|
||||
if output.leds_ecam & 0x54A != 0 { ecam_row[1] = 1; }
|
||||
if output.leds_ecam & 0x21 != 0 { ecam_row[2] = 1; }
|
||||
if output.leds_ecam & 0x6 != 0 { ecam_col[0] = 1; }
|
||||
if output.leds_ecam & 0x18 != 0 { ecam_col[1] = 1; }
|
||||
|
@ -504,9 +508,9 @@ fn main() -> ! {
|
|||
if output.leds_ecam & 0xC00 != 0 { ecam_col[4] = 1; }
|
||||
if output.leds_ecam & 0x1001 != 0 { ecam_col[5] = 1; }
|
||||
// Set ECAM Out
|
||||
define_ecam_output_states_row!(0, pb12, ecam_row, io_pins); // Row 1
|
||||
define_ecam_output_states_row!(1, pe13, ecam_row, io_pins); // Row 2
|
||||
define_ecam_output_states_row!(2, pe9, ecam_row, io_pins); // Row 3
|
||||
define_ecam_output_states_row!(0, pb12, ecam_row, io_pins, &mut gpiob, &mut crh); // Row 1
|
||||
define_ecam_output_states_row!(1, pe13, ecam_row, io_pins, &mut gpioe, &mut crh); // Row 2
|
||||
define_ecam_output_states_row!(2, pe9, ecam_row, io_pins, &mut gpioe, &mut crh); // Row 3
|
||||
define_ecam_output_states_col!(0, pd9, ecam_col, io_pins); // Col 1
|
||||
define_ecam_output_states_col!(1, pc7, ecam_col, io_pins); // Col 2
|
||||
define_ecam_output_states_col!(2, pc8, ecam_col, io_pins); // Col 3
|
||||
|
|
Loading…
Reference in a new issue