Skip to content

Commit

Permalink
fix timeout assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Paciente8159 committed Feb 23, 2024
1 parent 65cbea1 commit e7bea90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions uCNC/src/modules/softuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int16_t softuart_getc(softuart_port_t *port, uint32_t ms_timeout)
return 0;
}

return mcu_uart2_getc();
val = mcu_uart2_getc();
#endif
}
else
Expand All @@ -82,6 +82,11 @@ int16_t softuart_getc(softuart_port_t *port, uint32_t ms_timeout)
}
}

__TIMEOUT_ASSERT__(ms_timeout)
{
return 0;
}

port->waithalf();

uint8_t bits = 8;
Expand All @@ -99,10 +104,5 @@ int16_t softuart_getc(softuart_port_t *port, uint32_t ms_timeout)
port->waithalf();
}

__TIMEOUT_ASSERT__(ms_timeout)
{
return 0;
}

return (int16_t)val;
}
2 changes: 1 addition & 1 deletion uCNC/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ extern "C"

#define __TIMEOUT_US__(timeout) for (int32_t elap_us_##timeout, curr_us_##timeout = mcu_free_micros(); ((int32_t)timeout) >= 0; elap_us_##timeout = mcu_free_micros() - curr_us_##timeout, timeout -= ABS(elap_us_##timeout), curr_us_##timeout = mcu_free_micros())
#define __TIMEOUT_MS__(timeout) timeout*=1000; __TIMEOUT_US__(timeout)
#define __TIMEOUT_ASSERT__(timeout) if(timeout < 0)
#define __TIMEOUT_ASSERT__(timeout) if(((int32_t)timeout) < 0)

#if defined(__GNUC__) && __GNUC__ >= 7
#define __FALL_THROUGH__ __attribute__ ((fallthrough));
Expand Down

0 comments on commit e7bea90

Please sign in to comment.