From f5ea9d822d0693d9829b609e3270ab03df47c216 Mon Sep 17 00:00:00 2001 From: leomar75 Date: Sat, 9 Nov 2024 06:19:16 +1100 Subject: [PATCH] #38 ATmega32U4, ATmega2560, ATmega1280 supported as a RS485 Slave --- src/DcsBios.h | 9 +++++++-- src/internal/UART.Mod/DcsBiosNgRS485Slave.cpp.inc | 8 ++++---- src/internal/UART.Mod/DcsBiosNgRS485Slave.h | 10 ++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/DcsBios.h b/src/DcsBios.h index da48e5f..6b7ed76 100644 --- a/src/DcsBios.h +++ b/src/DcsBios.h @@ -44,8 +44,13 @@ do not come with their own build system, we are just putting everything into the #include "internal/DcsBiosNgRS485Master.cpp.inc" #endif #ifdef DCSBIOS_RS485_SLAVE - #include "internal/DcsBiosNgRS485Slave.h" - #include "internal/DcsBiosNgRS485Slave.cpp.inc" + #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) + #include "internal/UART.Mod/DcsBiosNgRS485Slave.h" + #include "internal/UART.Mod/DcsBiosNgRS485Slave.cpp.inc" + #else + #include "internal/DcsBiosNgRS485Slave.h" + #include "internal/DcsBiosNgRS485Slave.cpp.inc" + #endif #endif #ifdef DCSBIOS_IRQ_SERIAL diff --git a/src/internal/UART.Mod/DcsBiosNgRS485Slave.cpp.inc b/src/internal/UART.Mod/DcsBiosNgRS485Slave.cpp.inc index 5dab1a5..26a8234 100644 --- a/src/internal/UART.Mod/DcsBiosNgRS485Slave.cpp.inc +++ b/src/internal/UART.Mod/DcsBiosNgRS485Slave.cpp.inc @@ -172,8 +172,8 @@ namespace DcsBios { } - // Arduino Mega UART 1 - #ifdef UART1_SELECT + // Arduino Mega UART 1 or Arduino ProMicro + #if defined(UART1_SELECT) || defined(__AVR_ATmega32U4__) RS485Slave rs485slave(&UDR1, &UCSR1A, &UCSR1B, &UCSR1C, TXENABLE_PIN); ISR(USART1_RX_vect) { rs485slave.rxISR(); } ISR(USART1_TX_vect) { rs485slave.txcISR(); } @@ -204,8 +204,8 @@ namespace DcsBios { void setup() { - // Arduino Mega UART 1 - #ifdef UART1_SELECT + // Arduino Mega UART 1 or Arduino ProMicro + #if defined(UART1_SELECT) || defined(__AVR_ATmega32U4__) PRR1 &= ~(0<