Skip to content

Commit

Permalink
updated ESP32
Browse files Browse the repository at this point in the history
  • Loading branch information
Paciente8159 committed Oct 10, 2023
1 parent 44797bd commit b509e55
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 77 deletions.
34 changes: 31 additions & 3 deletions uCNC/src/hal/mcus/avr/mcu_avr.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ ISR(COM_RX_vect, ISR_BLOCK)
{
#if !defined(DETACH_UART_FROM_MAIN_PROTOCOL)
uint8_t c = COM_INREG;
if (mcu_com_rx_cb(COM_INREG))
if (mcu_com_rx_cb(c))
{
if (BUFFER_FULL(uart_rx))
{
Expand Down Expand Up @@ -411,12 +411,23 @@ ISR(COM_TX_vect, ISR_BLOCK)
#endif

#if defined(MCU_HAS_UART2)
DECL_BUFFER(uint8_t, uart2_rx, RX_BUFFER_SIZE);
ISR(COM2_RX_vect, ISR_BLOCK)
{
#if !defined(DETACH_UART2_FROM_MAIN_PROTOCOL)
mcu_com_rx_cb(COM2_INREG);
uint8_t c = COM2_INREG;
if (mcu_com_rx_cb(c))
{
if (BUFFER_FULL(uart2_rx))
{
c = OVF;
}

*(BUFFER_NEXT_FREE(uart2_rx)) = c;
BUFFER_STORE(uart2_rx);
}
#else
mcu_uart2_rx_cb(COM2_INREG);
mcu_uart_rx_cb(COM2_INREG);
#endif
}

Expand Down Expand Up @@ -621,6 +632,23 @@ void mcu_uart_flush(void)
#endif

#ifdef MCU_HAS_UART2
uint8_t mcu_uart2_getc(void)
{
uint8_t c = 0;
BUFFER_DEQUEUE(uart2_rx, &c);
return c;
}

uint8_t mcu_uart2_available(void)
{
return BUFFER_READ_AVAILABLE(uart2_rx);
}

void mcu_uart2_clear(void)
{
BUFFER_CLEAR(uart2_rx);
}

void mcu_uart2_putc(uint8_t c)
{
while (BUFFER_FULL(uart2))
Expand Down
Loading

0 comments on commit b509e55

Please sign in to comment.