adds support for the atmega328 (#9043)
Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
committed by
Drashna Jael're
parent
d26bb7e403
commit
7d8930c805
@@ -38,7 +38,7 @@ int16_t analogRead(uint8_t pin) {
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
if (pin >= 12) return 0;
|
if (pin >= 12) return 0;
|
||||||
return adc_read(pgm_read_byte(pin_to_mux + pin));
|
return adc_read(pgm_read_byte(pin_to_mux + pin));
|
||||||
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
if (pin >= 8) return 0;
|
if (pin >= 8) return 0;
|
||||||
return adc_read(pin);
|
return adc_read(pin);
|
||||||
#else
|
#else
|
||||||
@@ -85,7 +85,7 @@ uint8_t pinToMux(pin_t pin) {
|
|||||||
case A6: return _BV(MUX2) | _BV(MUX1); // ADC6
|
case A6: return _BV(MUX2) | _BV(MUX1); // ADC6
|
||||||
case A7: return _BV(MUX2) | _BV(MUX1) | _BV(MUX0); // ADC7
|
case A7: return _BV(MUX2) | _BV(MUX1) | _BV(MUX0); // ADC7
|
||||||
default: return _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1) | _BV(MUX0); // 0V
|
default: return _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1) | _BV(MUX0); // 0V
|
||||||
#elif defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
case C0: return 0; // ADC0
|
case C0: return 0; // ADC0
|
||||||
case C1: return _BV(MUX0); // ADC1
|
case C1: return _BV(MUX0); // ADC1
|
||||||
case C2: return _BV(MUX1); // ADC2
|
case C2: return _BV(MUX1); // ADC2
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
# define SPI_SCK_PIN B7
|
# define SPI_SCK_PIN B7
|
||||||
# define SPI_MOSI_PIN B5
|
# define SPI_MOSI_PIN B5
|
||||||
# define SPI_MISO_PIN B6
|
# define SPI_MISO_PIN B6
|
||||||
#elif defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
# define SPI_SCK_PIN B5
|
# define SPI_SCK_PIN B5
|
||||||
# define SPI_MOSI_PIN B3
|
# define SPI_MOSI_PIN B3
|
||||||
# define SPI_MISO_PIN B4
|
# define SPI_MISO_PIN B4
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ typedef int16_t spi_status_t;
|
|||||||
# define SPI_SS_PIN B0
|
# define SPI_SS_PIN B0
|
||||||
#elif defined(__AVR_ATmega32A__)
|
#elif defined(__AVR_ATmega32A__)
|
||||||
# define SPI_SS_PIN B4
|
# define SPI_SS_PIN B4
|
||||||
#elif defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
# define SPI_SS_PIN B2
|
# define SPI_SS_PIN B2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
# define COMxx1 COM1A1
|
# define COMxx1 COM1A1
|
||||||
# define OCRxx OCR1A
|
# define OCRxx OCR1A
|
||||||
# endif
|
# 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 HARDWARE_PWM
|
||||||
# define ICRx ICR1
|
# define ICRx ICR1
|
||||||
# define TCCRxA TCCR1A
|
# define TCCRxA TCCR1A
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
# define PINC_ADDRESS 0x3
|
# define PINC_ADDRESS 0x3
|
||||||
# define PINB_ADDRESS 0x6
|
# define PINB_ADDRESS 0x6
|
||||||
# define PINA_ADDRESS 0x9
|
# define PINA_ADDRESS 0x9
|
||||||
# elif defined(__AVR_ATmega328P__)
|
# elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
# define ADDRESS_BASE 0x00
|
# define ADDRESS_BASE 0x00
|
||||||
# define PINB_ADDRESS 0x3
|
# define PINB_ADDRESS 0x3
|
||||||
# define PINC_ADDRESS 0x6
|
# define PINC_ADDRESS 0x6
|
||||||
|
|||||||
@@ -291,6 +291,24 @@ ifneq (,$(filter $(MCU),atmega328p))
|
|||||||
NO_SUSPEND_POWER_DOWN ?= yes
|
NO_SUSPEND_POWER_DOWN ?= yes
|
||||||
endif
|
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))
|
ifneq (,$(filter $(MCU),attiny85))
|
||||||
PROTOCOL = VUSB
|
PROTOCOL = VUSB
|
||||||
|
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ void bootloader_jump(void) {
|
|||||||
|
|
||||||
#else // Assume remaining boards are DFU, even if the flag isn't set
|
#else // Assume remaining boards are DFU, even if the flag isn't set
|
||||||
|
|
||||||
# if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATtiny85__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though?
|
# if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATtiny85__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though?
|
||||||
UDCON = 1;
|
UDCON = 1;
|
||||||
USBCON = (1 << FRZCLK); // disable USB
|
USBCON = (1 << FRZCLK); // disable USB
|
||||||
UCSR1B = 0;
|
UCSR1B = 0;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
|
||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
||||||
# define UDRn UDR0
|
# define UDRn UDR0
|
||||||
# define UBRRnL UBRR0L
|
# define UBRRnL UBRR0L
|
||||||
# define UCSRnA UCSR0A
|
# define UCSRnA UCSR0A
|
||||||
|
|||||||
Reference in New Issue
Block a user