Fill bridge's state machine function with IO logic.

This commit is contained in:
Marco 2022-06-28 03:48:40 +02:00
parent 5114887f1c
commit 3be047d2e4

View File

@ -46,80 +46,37 @@ sm_t bridge_statemachine = {
.transitions = bridge_sm_transitions
};
void adsf()
{
switch (bridge_state)
{
case HB1_GND_ON:
setPin(&PORTB, PB6);
unsetPin(&PORTB, PB4);
_delay_us(10);
bridge_state = HB1_PWR_ON;
break;
case HB1_PWR_ON:
setPin(&PORTB, PB7);
_delay_us(9980);
bridge_state = HB1_PWR_OFF;
break;
case HB1_PWR_OFF:
unsetPin(&PORTB, PB7);
_delay_us(100);
bridge_state = HB2_GND_ON;
break;
case HB2_GND_ON:
setPin(&PORTB, PB4);
unsetPin(&PORTB, PB6);
_delay_us(10);
bridge_state = HB2_PWR_ON;
break;
case HB2_PWR_ON:
setPin(&PORTB, PB5);
_delay_us(9980);
bridge_state = HB2_PWR_OFF;
break;
case HB2_PWR_OFF:
unsetPin(&PORTB, PB5);
_delay_us(100);
bridge_state = HB1_GND_ON;
break;
default:
break;
}
}
void brdg_Hb1GndOn(void)
{
/* We turn GND of half-bridge 1 on */
setPin(&PORTB, PB6);
/* And then we turn GND of half-bridge 2 off */
unsetPin(&PORTB, PB4);
}
void brdg_Hb1PowerOn(void)
{
setPin(&PORTB, PB7);
}
void brdg_Hb1PowerOff(void)
{
unsetPin(&PORTB, PB7);
}
void brdg_Hb2GndOn(void)
{
setPin(&PORTB, PB4);
unsetPin(&PORTB, PB6);
}
void brdg_Hb2PowerOn(void)
{
setPin(&PORTB, PB5);
}
void brdg_Hb2PowerOff(void)
{
unsetPin(&PORTB, PB5);
}