Add init state before entering state machine loop.
This commit is contained in:
parent
3be047d2e4
commit
76ac461516
18
src/bridge.c
18
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 */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user