Skip to content

Commit 480c534

Browse files
authored
Merge pull request #2 from peterdmr/wait_sof_fix
Fix listening for a Start-Of-Frame byte
2 parents fc7c1c8 + 8f932be commit 480c534

File tree

1 file changed

+6
-10
lines changed
  • first-steps/3-simple-uart-protocol/mcu

1 file changed

+6
-10
lines changed

first-steps/3-simple-uart-protocol/mcu/sup.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,15 @@ void sup_handle_rx_byte(const uint8_t byte)
119119
return;
120120
}
121121

122-
// Always listen for a Start-Of-Frame byte, which can reset a broken frame transmission.
123-
if (byte == SUP_SOF)
124-
{
125-
reset_rx_frame_state();
126-
rx_frame_state->parsing_state = SUP_STATE_WAIT_ID;
127-
return;
128-
}
129-
130122
switch (rx_frame_state->parsing_state)
131123
{
132124
case SUP_STATE_WAIT_SOF:
133-
// This state is effectively handled by the check above,
134-
// but we keep the case for clarity. Any byte other than SOF is ignored.
125+
// Listen for a Start-Of-Frame byte. Any byte other than SOF is ignored.
126+
if (byte == SUP_SOF)
127+
{
128+
reset_rx_frame_state();
129+
rx_frame_state->parsing_state = SUP_STATE_WAIT_ID;
130+
}
135131
break;
136132

137133
case SUP_STATE_WAIT_ID:

0 commit comments

Comments
 (0)