Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Softuart fix and onewire #600

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions uCNC/src/modules/softuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

void softuart_putc(softuart_port_t *port, char c)
{
cnc_dotasks();
if (!port)
{
#if (defined(MCU_HAS_UART2) && defined(DETACH_UART2_FROM_MAIN_PROTOCOL))
Expand Down Expand Up @@ -59,14 +58,13 @@ int16_t softuart_getc(softuart_port_t *port, uint32_t ms_timeout)
}
else
{
ms_timeout *= 1000;
ms_timeout += mcu_millis();
while (port->rx())
{
if (!ms_timeout--)
if (ms_timeout < mcu_millis())
{
return -1;
}
cnc_dotasks();
}
port->waithalf();

Expand Down
28 changes: 25 additions & 3 deletions uCNC/src/modules/softuart.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,38 @@ extern "C"
{ \
if (state) \
{ \
io_set_output(TXPIN); \
io_set_output(TXPIN); \
} \
else \
{ \
io_clear_output(TXPIN); \
io_clear_output(TXPIN); \
} \
} \
bool NAME##_rx(void) \
{ \
return io_get_input(RXPIN); \
return io_get_input(RXPIN); \
} \
void NAME##_wait(void) { mcu_delay_cycles(F_CPU / BAUD); } \
void NAME##_waithalf(void) { mcu_delay_cycles(F_CPU / 2 / BAUD); } \
__attribute__((used)) softuart_port_t NAME = {.wait = &NAME##_wait, .waithalf = &NAME##_waithalf, .tx = &NAME##_tx, .rx = &NAME##_rx};

#define ONEWIRE(NAME, BAUD, TRXPIN) \
void NAME##_tx(bool state) \
{ \
if (state) \
{ \
io_config_input(TRXPIN); \
io_config_pullup(TRXPIN); \
} \
else \
{ \
io_clear_output(TRXPIN); \
io_config_output(TRXPIN); \
} \
} \
bool NAME##_rx(void) \
{ \
return io_get_input(RXPIN); \
} \
void NAME##_wait(void) { mcu_delay_cycles(F_CPU / BAUD); } \
void NAME##_waithalf(void) { mcu_delay_cycles(F_CPU / 2 / BAUD); } \
Expand Down
16 changes: 8 additions & 8 deletions uCNC/src/modules/tmcdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,56 +318,56 @@ bool m350_exec(void *args)
#ifdef STEPPER0_HAS_TMC
val = tmc_get_microstep(&tmc0_driver);
#endif
serial_print_flt(val);
serial_print_int(val);
serial_putc(',');
val = 0;
serial_putc('Y');
#ifdef STEPPER1_HAS_TMC
val = tmc_get_microstep(&tmc1_driver);
#endif
serial_print_flt(val);
serial_print_int(val);
serial_putc(',');
val = 0;
serial_putc('Z');
#ifdef STEPPER2_HAS_TMC
val = tmc_get_microstep(&tmc2_driver);
#endif
serial_print_flt(val);
serial_print_int(val);
serial_putc(',');
val = 0;
serial_putc('A');
#ifdef STEPPER3_HAS_TMC
val = tmc_get_microstep(&tmc3_driver);
#endif
serial_print_flt(val);
serial_print_int(val);
serial_putc(',');
val = 0;
serial_putc('B');
#ifdef STEPPER4_HAS_TMC
val = tmc_get_microstep(&tmc4_driver);
#endif
serial_print_flt(val);
serial_print_int(val);
serial_putc(',');
val = 0;
serial_putc('C');
#ifdef STEPPER5_HAS_TMC
val = tmc_get_microstep(&tmc5_driver);
#endif
serial_print_flt(val);
serial_print_int(val);
serial_putc(',');
val = 0;
serial_putc('I');
#ifdef STEPPER6_HAS_TMC
val = tmc_get_microstep(&tmc6_driver);
#endif
serial_print_flt(val);
serial_print_int(val);
serial_putc(',');
val = 0;
serial_putc('J');
#ifdef STEPPER7_HAS_TMC
val = tmc_get_microstep(&tmc7_driver);
#endif
serial_print_flt(val);
serial_print_int(val);
serial_putc(']');
protocol_send_string(MSG_EOL);
}
Expand Down
Loading