diff --git a/src/bridge.c b/src/bridge.c index 013a98c..948d134 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -9,6 +9,16 @@ bdg_sm_state_t bridge_state; sm_trans_t bridge_sm_transitions[] = { + { + .from_state = BRIDGE_SM_START, + .to_state = BRIDGE_SM_INIT_IO, + .trans_fct = brdg_BothGndOn + }, + { + .from_state = BRIDGE_SM_INIT_IO, + .to_state = HB1_PWR_ON, + .trans_fct = brdg_Hb1PowerOn + }, { .from_state = HB1_GND_ON, .to_state = HB1_PWR_ON, @@ -42,10 +52,16 @@ sm_trans_t bridge_sm_transitions[] = }; sm_t bridge_statemachine = { - .current_state = HB1_PWR_OFF, + .current_state = BRIDGE_SM_START, .transitions = bridge_sm_transitions }; +void brdg_BothGndOn(void) +{ + setPin(&PORTB, PB6); + setPin(&PORTB, PB4); +} + void brdg_Hb1GndOn(void) { /* We turn GND of half-bridge 1 on */ diff --git a/src/include/bridge.h b/src/include/bridge.h index 52f1d7c..dfa4a03 100644 --- a/src/include/bridge.h +++ b/src/include/bridge.h @@ -1,5 +1,7 @@ typedef enum { + BRIDGE_SM_START, + BRIDGE_SM_INIT_IO, HB1_GND_ON, HB1_PWR_ON, HB1_PWR_OFF, @@ -9,6 +11,8 @@ typedef enum } bdg_sm_state_t; +void brdg_BothGndOn(void); + void brdg_Hb1GndOn(void); void brdg_Hb1PowerOn(void); void brdg_Hb1PowerOff(void);