From fd6842752f69a412d86acb51ff70823eca1a06b7 Mon Sep 17 00:00:00 2001
From: Steven Honson <steven@honson.id.au>
Date: Tue, 14 Dec 2021 11:50:37 +1100
Subject: [PATCH] atmega2560 support

---
 Config.h | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/Config.h b/Config.h
index 179ead6..116ade9 100644
--- a/Config.h
+++ b/Config.h
@@ -7,6 +7,7 @@
 	#define MIN_VERS  0x11
 
 	#define MCU_1284P 0x91
+	#define MCU_2560  0x92
 
 	#define MODE_HOST 0x11
 	#define MODE_TNC  0x12
@@ -14,6 +15,9 @@
 	#if defined(__AVR_ATmega1284P__)
 		#define MCU_VARIANT MCU_1284P
 		#warning "Firmware is being compiled for atmega1284p based boards"
+	#elif defined(__AVR_ATmega2560__)
+		#define MCU_VARIANT MCU_2560
+		#warning "Firmware is being compiled for atmega2560 based boards"
 	#else
 		#error "The firmware cannot be compiled for the selected MCU variant"
 	#endif
@@ -43,6 +47,22 @@
 		#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED
 	#endif
 
+	#if MCU_VARIANT == MCU_2560
+		const int pin_cs = 10;
+		const int pin_reset = 9;
+		const int pin_dio = 2;
+		const int pin_led_rx = 12;
+		const int pin_led_tx = 13;
+
+		// TODO: Reset
+		#define CONFIG_UART_BUFFER_SIZE 2048
+		#define CONFIG_QUEUE_SIZE 2048
+		#define CONFIG_QUEUE_MAX_LENGTH 250
+
+		#define EEPROM_SIZE 4096
+		#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED
+	#endif
+
 	#define eeprom_addr(a) (a+EEPROM_OFFSET)
 
 	// MCU independent configuration parameters
@@ -71,13 +91,13 @@
 	uint8_t op_mode   = MODE_HOST;
 	uint8_t model     = 0x00;
 	uint8_t hwrev     = 0x00;
-	
+
 	int		last_rssi		= -292;
 	uint8_t last_rssi_raw   = 0x00;
 	uint8_t last_snr_raw	= 0x00;
 	size_t	read_len		= 0;
 	uint8_t seq				= 0xFF;
-	
+
 	// Incoming packet buffer
 	uint8_t pbuf[MTU];
 
@@ -107,4 +127,4 @@
 	const uint8_t SIG_SYNCED = 0x02;
 	const uint8_t RX_ONGOING = 0x04;
 
-#endif
\ No newline at end of file
+#endif