Skip to content

Commit dfbb462

Browse files
committed
Add fault and chassis LED handling
1 parent 71922f8 commit dfbb462

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

drv/cosmo-seq-server/src/main.rs

+28-4
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ task_slot!(SPI_FRONT, spi_front);
5656
task_slot!(AUXFLASH, auxflash);
5757

5858
const SP_TO_SP5_NMI_SYNC_FLOOD_L: sys_api::PinSet = sys_api::Port::J.pin(2);
59+
const SP_TO_IGN_TRGT_FPGA_FAULT_L: sys_api::PinSet = sys_api::Port::B.pin(7);
60+
const SP_CHASSIS_STATUS_LED: sys_api::PinSet = sys_api::Port::C.pin(6);
5961

6062
#[export_name = "main"]
6163
fn main() -> ! {
6264
// XXX set up fault pin
6365
match init() {
6466
// Set up everything nicely, time to start serving incoming messages.
6567
Ok(mut server) => {
68+
// Mark that we've reached A2, and turn on the chassis LED
6669
server.set_state_impl(PowerState::A2);
70+
server.sys.gpio_set(SP_CHASSIS_STATUS_LED);
6771

6872
let mut buffer = [0; idl::INCOMING_SIZE];
6973
loop {
@@ -93,9 +97,27 @@ fn main() -> ! {
9397
}
9498

9599
fn init() -> Result<ServerImpl, SeqError> {
96-
// XXX initialize fault pin
97-
98100
let sys = sys_api::Sys::from(SYS.get_task_id());
101+
102+
// Pull the fault line low while we're loading
103+
sys.gpio_configure_output(
104+
SP_TO_IGN_TRGT_FPGA_FAULT_L,
105+
sys_api::OutputType::OpenDrain,
106+
sys_api::Speed::Low,
107+
sys_api::Pull::None,
108+
);
109+
sys.gpio_reset(SP_TO_IGN_TRGT_FPGA_FAULT_L);
110+
111+
// Turn off the chassis LED, in case this is a task restart (and not a
112+
// full chip restart, which would leave the GPIO unconfigured).
113+
sys.gpio_configure_output(
114+
SP_CHASSIS_STATUS_LED,
115+
sys_api::OutputType::PushPull,
116+
sys_api::Speed::Low,
117+
sys_api::Pull::None,
118+
);
119+
sys.gpio_reset(SP_CHASSIS_STATUS_LED);
120+
99121
let spi_front = drv_spi_api::Spi::from(SPI_FRONT.get_task_id());
100122
let aux = drv_auxflash_api::AuxFlash::from(AUXFLASH.get_task_id());
101123

@@ -113,7 +135,7 @@ fn init() -> Result<ServerImpl, SeqError> {
113135
let loader = Spartan7Loader::from(LOADER.get_task_id());
114136
loader.ping();
115137

116-
// Bring up the fault / NMI pin
138+
// Bring up the SP5 NMI pin
117139
sys.gpio_set(SP_TO_SP5_NMI_SYNC_FLOOD_L);
118140
sys.gpio_configure_output(
119141
SP_TO_SP5_NMI_SYNC_FLOOD_L,
@@ -122,7 +144,9 @@ fn init() -> Result<ServerImpl, SeqError> {
122144
sys_api::Pull::None,
123145
);
124146

125-
// XXX fix fault pin
147+
// Clear the fault pin
148+
sys.gpio_set(SP_TO_IGN_TRGT_FPGA_FAULT_L);
149+
126150
Ok(ServerImpl {
127151
jefe: Jefe::from(JEFE.get_task_id()),
128152
sys,

drv/user-leds/src/main.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ cfg_if::cfg_if! {
5151
if #[cfg(target_board = "cosmo-a")] {
5252
#[derive(enum_map::Enum, Copy, Clone, FromPrimitive)]
5353
enum Led {
54-
Chassis = 0,
55-
DebugWhite = 1,
56-
DebugRed = 2,
57-
DebugGreen = 3,
58-
DebugBlue = 4,
54+
// chassis LED is controlled by cosmo-seq
55+
DebugWhite = 0,
56+
DebugRed = 1,
57+
DebugGreen = 2,
58+
DebugBlue = 3,
5959
}
6060
}
6161
// Target boards with 4 leds
@@ -493,7 +493,6 @@ cfg_if::cfg_if! {
493493
];
494494
} else if #[cfg(target_board = "cosmo-a")] {
495495
const LEDS: &[(drv_stm32xx_sys_api::PinSet, bool)] = &[
496-
(drv_stm32xx_sys_api::Port::C.pin(6), false), // chassis
497496
(drv_stm32xx_sys_api::Port::H.pin(6), false), // debug W
498497
(drv_stm32xx_sys_api::Port::H.pin(10), false), // debug R
499498
(drv_stm32xx_sys_api::Port::H.pin(11), false), // debug G

0 commit comments

Comments
 (0)