From 7aa4cc9603b8cdb0ea3ede753eff7d07a86a18b0 Mon Sep 17 00:00:00 2001
From: itsnoteasy <pyrosoma1@yahoo.ie>
Date: Wed, 10 Jun 2020 22:23:11 +0100
Subject: adds support for the atmega328 (#9043)

Co-authored-by: Ryan <fauxpark@gmail.com>
---
 quantum/backlight/backlight_avr.c |  2 +-
 quantum/config_common.h           |  2 +-
 quantum/mcu_selection.mk          | 18 ++++++++++++++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

(limited to 'quantum')

diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c
index ce13f1118..b3e882ffe 100644
--- a/quantum/backlight/backlight_avr.c
+++ b/quantum/backlight/backlight_avr.c
@@ -103,7 +103,7 @@
 #        define COMxx1 COM1A1
 #        define OCRxx OCR1A
 #    endif
-#elif defined(__AVR_ATmega328P__) && (BACKLIGHT_PIN == B1 || BACKLIGHT_PIN == B2)
+#elif (defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)) && (BACKLIGHT_PIN == B1 || BACKLIGHT_PIN == B2)
 #    define HARDWARE_PWM
 #    define ICRx ICR1
 #    define TCCRxA TCCR1A
diff --git a/quantum/config_common.h b/quantum/config_common.h
index 9861c8678..9b28e8d63 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -58,7 +58,7 @@
 #        define PINC_ADDRESS 0x3
 #        define PINB_ADDRESS 0x6
 #        define PINA_ADDRESS 0x9
-#    elif defined(__AVR_ATmega328P__)
+#    elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
 #        define ADDRESS_BASE 0x00
 #        define PINB_ADDRESS 0x3
 #        define PINC_ADDRESS 0x6
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk
index 33de162bb..a1d2c5fbf 100644
--- a/quantum/mcu_selection.mk
+++ b/quantum/mcu_selection.mk
@@ -288,6 +288,24 @@ ifneq (,$(filter $(MCU),atmega328p))
   NO_SUSPEND_POWER_DOWN ?= yes
 endif
 
+ifneq (,$(filter $(MCU),atmega328))
+  # MCU name for avrdude
+  AVRDUDE_MCU = m328
+
+  PROTOCOL = VUSB
+
+  # Processor frequency.
+  #     This will define a symbol, F_CPU, in all source code files equal to the
+  #     processor frequency in Hz. You can then use this symbol in your source code to
+  #     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+  #     automatically to create a 32-bit value in your source code.
+  F_CPU ?= 16000000
+
+  # unsupported features for now
+  NO_UART ?= yes
+  NO_SUSPEND_POWER_DOWN ?= yes
+endif
+
 ifneq (,$(filter $(MCU),attiny85))
   PROTOCOL = VUSB
 
-- 
cgit v1.2.3