mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
1280 -> 1280/2560.
This commit is contained in:
parent
6fbfb713ee
commit
27cfd22066
@ -42,7 +42,7 @@ struct ring_buffer {
|
|||||||
|
|
||||||
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
|
ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
|
||||||
ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
|
ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
|
||||||
ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
|
ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
|
||||||
@ -62,7 +62,7 @@ inline void store_char(unsigned char c, ring_buffer *rx_buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
|
||||||
SIGNAL(SIG_USART0_RECV)
|
SIGNAL(SIG_USART0_RECV)
|
||||||
{
|
{
|
||||||
@ -229,7 +229,7 @@ HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TX
|
|||||||
HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
|
HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
|
HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
|
||||||
HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
|
HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
|
||||||
HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
|
HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
|
||||||
|
@ -58,7 +58,7 @@ class HardwareSerial : public Stream
|
|||||||
|
|
||||||
extern HardwareSerial Serial;
|
extern HardwareSerial Serial;
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
extern HardwareSerial Serial1;
|
extern HardwareSerial Serial1;
|
||||||
extern HardwareSerial Serial2;
|
extern HardwareSerial Serial2;
|
||||||
extern HardwareSerial Serial3;
|
extern HardwareSerial Serial3;
|
||||||
|
@ -66,7 +66,7 @@ volatile long timer2_toggle_count;
|
|||||||
volatile uint8_t *timer2_pin_port;
|
volatile uint8_t *timer2_pin_port;
|
||||||
volatile uint8_t timer2_pin_mask;
|
volatile uint8_t timer2_pin_mask;
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
volatile long timer3_toggle_count;
|
volatile long timer3_toggle_count;
|
||||||
volatile uint8_t *timer3_pin_port;
|
volatile uint8_t *timer3_pin_port;
|
||||||
volatile uint8_t timer3_pin_mask;
|
volatile uint8_t timer3_pin_mask;
|
||||||
@ -79,7 +79,7 @@ volatile uint8_t timer5_pin_mask;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
|
||||||
#define AVAILABLE_TONE_PINS 1
|
#define AVAILABLE_TONE_PINS 1
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ static int8_t toneBegin(uint8_t _pin)
|
|||||||
timer2_pin_mask = digitalPinToBitMask(_pin);
|
timer2_pin_mask = digitalPinToBitMask(_pin);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
case 3:
|
case 3:
|
||||||
// 16 bit timer
|
// 16 bit timer
|
||||||
TCCR3A = 0;
|
TCCR3A = 0;
|
||||||
@ -279,7 +279,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|||||||
|
|
||||||
if (_timer == 1)
|
if (_timer == 1)
|
||||||
TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
|
TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
else if (_timer == 3)
|
else if (_timer == 3)
|
||||||
TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
|
TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
|
||||||
else if (_timer == 4)
|
else if (_timer == 4)
|
||||||
@ -326,7 +326,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|||||||
bitWrite(TIMSK2, OCIE2A, 1);
|
bitWrite(TIMSK2, OCIE2A, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
case 3:
|
case 3:
|
||||||
OCR3A = ocr;
|
OCR3A = ocr;
|
||||||
timer3_toggle_count = toggle_count;
|
timer3_toggle_count = toggle_count;
|
||||||
@ -370,7 +370,7 @@ void disableTimer(uint8_t _timer)
|
|||||||
TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
|
TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
|
||||||
OCR2A = 0;
|
OCR2A = 0;
|
||||||
break;
|
break;
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
case 3:
|
case 3:
|
||||||
TIMSK3 = 0;
|
TIMSK3 = 0;
|
||||||
break;
|
break;
|
||||||
@ -461,7 +461,7 @@ ISR(TIMER2_COMPA_vect)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#if defined(__AVR_ATmega1280__)
|
//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
ISR(TIMER3_COMPA_vect)
|
ISR(TIMER3_COMPA_vect)
|
||||||
|
@ -52,7 +52,7 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
|
|||||||
// Enable the interrupt.
|
// Enable the interrupt.
|
||||||
|
|
||||||
switch (interruptNum) {
|
switch (interruptNum) {
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
case 2:
|
case 2:
|
||||||
EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
|
EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
|
||||||
EIMSK |= (1 << INT0);
|
EIMSK |= (1 << INT0);
|
||||||
@ -105,7 +105,7 @@ void detachInterrupt(uint8_t interruptNum) {
|
|||||||
// to the number of the EIMSK bit to clear, as this isn't true on the
|
// to the number of the EIMSK bit to clear, as this isn't true on the
|
||||||
// ATmega8. There, INT0 is 6 and INT1 is 7.)
|
// ATmega8. There, INT0 is 6 and INT1 is 7.)
|
||||||
switch (interruptNum) {
|
switch (interruptNum) {
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
case 2:
|
case 2:
|
||||||
EIMSK &= ~(1 << INT0);
|
EIMSK &= ~(1 << INT0);
|
||||||
break;
|
break;
|
||||||
@ -150,7 +150,7 @@ void attachInterruptTwi(void (*userFunc)(void) ) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
|
||||||
SIGNAL(INT0_vect) {
|
SIGNAL(INT0_vect) {
|
||||||
if(intFunc[EXTERNAL_INT_2])
|
if(intFunc[EXTERNAL_INT_2])
|
||||||
|
@ -29,7 +29,7 @@ long random(long, long);
|
|||||||
void randomSeed(unsigned int);
|
void randomSeed(unsigned int);
|
||||||
long map(long, long, long, long, long);
|
long map(long, long, long, long, long);
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
const static uint8_t A0 = 54;
|
const static uint8_t A0 = 54;
|
||||||
const static uint8_t A1 = 55;
|
const static uint8_t A1 = 55;
|
||||||
const static uint8_t A2 = 56;
|
const static uint8_t A2 = 56;
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
#define PL 12
|
#define PL 12
|
||||||
|
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
||||||
NOT_A_PORT,
|
NOT_A_PORT,
|
||||||
&DDRA,
|
&DDRA,
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#define TIMER5B 15
|
#define TIMER5B 15
|
||||||
#define TIMER5C 16
|
#define TIMER5C 16
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
const static uint8_t SS = 53;
|
const static uint8_t SS = 53;
|
||||||
const static uint8_t MOSI = 51;
|
const static uint8_t MOSI = 51;
|
||||||
const static uint8_t MISO = 50;
|
const static uint8_t MISO = 50;
|
||||||
|
@ -209,7 +209,7 @@ void init()
|
|||||||
sbi(TCCR2A, WGM20);
|
sbi(TCCR2A, WGM20);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
// set timer 3, 4, 5 prescale factor to 64
|
// set timer 3, 4, 5 prescale factor to 64
|
||||||
sbi(TCCR3B, CS31); sbi(TCCR3B, CS30);
|
sbi(TCCR3B, CS31); sbi(TCCR3B, CS30);
|
||||||
sbi(TCCR4B, CS41); sbi(TCCR4B, CS40);
|
sbi(TCCR4B, CS41); sbi(TCCR4B, CS40);
|
||||||
|
@ -58,7 +58,7 @@ extern "C"{
|
|||||||
#define FALLING 2
|
#define FALLING 2
|
||||||
#define RISING 3
|
#define RISING 3
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
#define INTERNAL1V1 2
|
#define INTERNAL1V1 2
|
||||||
#define INTERNAL2V56 3
|
#define INTERNAL2V56 3
|
||||||
#else
|
#else
|
||||||
|
@ -39,7 +39,7 @@ int analogRead(uint8_t pin)
|
|||||||
{
|
{
|
||||||
uint8_t low, high;
|
uint8_t low, high;
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
|
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
|
||||||
|
|
||||||
// the MUX5 bit of ADCSRB selects whether we're reading from channels
|
// the MUX5 bit of ADCSRB selects whether we're reading from channels
|
||||||
@ -133,7 +133,7 @@ void analogWrite(uint8_t pin, int val)
|
|||||||
// set pwm duty
|
// set pwm duty
|
||||||
OCR2B = val;
|
OCR2B = val;
|
||||||
#endif
|
#endif
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
// XXX: need to handle other timers here
|
// XXX: need to handle other timers here
|
||||||
} else if (digitalPinToTimer(pin) == TIMER3A) {
|
} else if (digitalPinToTimer(pin) == TIMER3A) {
|
||||||
// connect pwm to pin on timer 3, channel A
|
// connect pwm to pin on timer 3, channel A
|
||||||
|
@ -71,7 +71,7 @@ static inline void turnOffPWM(uint8_t timer)
|
|||||||
if (timer == TIMER2B) cbi(TCCR2A, COM2B1);
|
if (timer == TIMER2B) cbi(TCCR2A, COM2B1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
if (timer == TIMER3A) cbi(TCCR3A, COM3A1);
|
if (timer == TIMER3A) cbi(TCCR3A, COM3A1);
|
||||||
if (timer == TIMER3B) cbi(TCCR3A, COM3B1);
|
if (timer == TIMER3B) cbi(TCCR3A, COM3B1);
|
||||||
if (timer == TIMER3C) cbi(TCCR3A, COM3C1);
|
if (timer == TIMER3C) cbi(TCCR3A, COM3C1);
|
||||||
|
@ -53,7 +53,7 @@ extern "C"{
|
|||||||
#define EXTERNAL_INT_6 6
|
#define EXTERNAL_INT_6 6
|
||||||
#define EXTERNAL_INT_7 7
|
#define EXTERNAL_INT_7 7
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
#define EXTERNAL_NUM_INTERRUPTS 8
|
#define EXTERNAL_NUM_INTERRUPTS 8
|
||||||
#else
|
#else
|
||||||
#define EXTERNAL_NUM_INTERRUPTS 2
|
#define EXTERNAL_NUM_INTERRUPTS 2
|
||||||
|
@ -308,7 +308,7 @@ private:
|
|||||||
uint16_t RBASE[SOCKETS]; // Rx buffer base address
|
uint16_t RBASE[SOCKETS]; // Rx buffer base address
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
inline static void initSS() { DDRB |= _BV(4); };
|
inline static void initSS() { DDRB |= _BV(4); };
|
||||||
inline static void setSS() { PORTB &= ~_BV(4); };
|
inline static void setSS() { PORTB &= ~_BV(4); };
|
||||||
inline static void resetSS() { PORTB |= _BV(4); };
|
inline static void resetSS() { PORTB |= _BV(4); };
|
||||||
|
@ -153,7 +153,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
|
|||||||
|
|
||||||
|
|
||||||
// Arduino Mega
|
// Arduino Mega
|
||||||
#elif defined(__AVR_ATmega1280__)
|
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
#define TOTAL_ANALOG_PINS 16
|
#define TOTAL_ANALOG_PINS 16
|
||||||
#define TOTAL_PINS 70 // 54 digital + 16 analog
|
#define TOTAL_PINS 70 // 54 digital + 16 analog
|
||||||
#define VERSION_BLINK_PIN 13
|
#define VERSION_BLINK_PIN 13
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Say which 16 bit timers can be used and in what order
|
// Say which 16 bit timers can be used and in what order
|
||||||
#if defined(__AVR_ATmega1280__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
#define _useTimer5
|
#define _useTimer5
|
||||||
#define _useTimer1
|
#define _useTimer1
|
||||||
#define _useTimer3
|
#define _useTimer3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user