diff --git a/cpu/atmega_common/periph/adc.c b/cpu/atmega_common/periph/adc.c index 81bc224c9f7347a833de5c2e5d6c06c820ef470d..db6fd7950242810f8f49a327240228f0c857eb5b 100644 --- a/cpu/atmega_common/periph/adc.c +++ b/cpu/atmega_common/periph/adc.c @@ -67,6 +67,9 @@ int adc_init(adc_t line) #if defined(CPU_ATMEGA328P) DDRC &= ~(1 << line); PORTC &= ~(1 << line); +#elif defined(CPU_ATMEGA1284P) + DDRA &= ~(1 << line); + PORTA &= ~(1 << line); #elif defined(CPU_ATMEGA2560) || defined(CPU_ATMEGA1281) if (line < 8) { DDRF &= ~(1 << line); @@ -108,7 +111,7 @@ int adc_sample(adc_t line, adc_res_t res) _prep(); /* set conversion channel */ -#if defined(CPU_ATMEGA328P) || defined(CPU_ATMEGA1281) +#if defined(CPU_ATMEGA328P) || defined(CPU_ATMEGA1281) || defined(CPU_ATMEGA1284P) ADMUX &= 0xf0; ADMUX |= line; #elif defined(CPU_ATMEGA2560) || defined(CPU_ATMEGA256RFR2) diff --git a/cpu/atmega_common/periph/gpio.c b/cpu/atmega_common/periph/gpio.c index 28d48bd7b78b1fd1148cdbad7ac51f79eaf1b5d5..4d61c08e58670651b0e94d560a2031627cc7ab50 100644 --- a/cpu/atmega_common/periph/gpio.c +++ b/cpu/atmega_common/periph/gpio.c @@ -140,6 +140,10 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, || (_port_num(pin) != PORT_D && _port_num(pin) != PORT_E) #elif defined(CPU_ATMEGA328P) || (pin_num < 2) || (_port_num(pin) != PORT_D) +#elif defined(CPU_ATMEGA1284P) + || (_port_num(pin) == PORT_B && pin_num != 2) + || (_port_num(pin) == PORT_D && pin_num < 2) + || (_port_num(pin) != PORT_D && _port_num(pin) != PORT_D) #endif || ((mode != GPIO_IN) && (mode != GPIO_IN_PU))) { return -1; @@ -153,6 +157,11 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, #if defined(CPU_ATMEGA328P) /* INT pins start at PD2 instead of at PD0 */ pin_num -= 2; +#elif defined(CPU_ATMEGA1284P) + /* INT pins start at PD2 instead of at PD0 on PORT_D */ + if (_port_num(pin) == PORT_D) { + pin_num -= 2; + } #endif EIMSK |= (1 << pin_num); @@ -186,6 +195,14 @@ void gpio_irq_enable(gpio_t pin) #if defined(CPU_ATMEGA328P) /* INT pins start at PD2 instead of at PD0 */ EIMSK |= (1 << (_pin_num(pin) - 2)); +#elif defined(CPU_ATMEGA1284P) + /* INT pins start at PD2 instead of at PD0 on PORT_D */ + if (_port_num(pin) == PORT_D) { + EIMSK |= (1 << (_pin_num(pin) - 2)); + } + else { + EIMSK |= (1 << _pin_num(pin)); + } #else EIMSK |= (1 << _pin_num(pin)); #endif @@ -196,6 +213,14 @@ void gpio_irq_disable(gpio_t pin) #if defined(CPU_ATMEGA328P) /* INT pins start at PD2 instead of at PD0 */ EIMSK &= ~(1 << (_pin_num(pin) - 2)); +#elif defined (CPU_ATMEGA1284P) + /* INT pins start at PD2 instead of at PD0 on PORT_D */ + if (_port_num(pin) == PORT_D) { + EIMSK &= ~(1 << (_pin_num(pin) - 2)); + } + else { + EIMSK &= ~(1 << _pin_num(pin)); + } #else EIMSK &= ~(1 << _pin_num(pin)); #endif diff --git a/cpu/atmega_common/periph/spi.c b/cpu/atmega_common/periph/spi.c index fb2fcd2e40452bbcb98f0f0a707ea3ae474211e3..de4ac97cfc8a8203ee9c4566cc719e22f3047816 100644 --- a/cpu/atmega_common/periph/spi.c +++ b/cpu/atmega_common/periph/spi.c @@ -57,6 +57,9 @@ void spi_init_pins(spi_t bus) #if defined (CPU_ATMEGA328P) DDRB |= ((1 << DDB2) | (1 << DDB3) | (1 << DDB5)); #endif +#if defined (CPU_ATMEGA1284P) + DDRB |= ((1 << DDB4) | (1 << DDB5) | (1 << DDB7)); +#endif #if defined (CPU_ATMEGA256RFR2) /* Master: PB3 MISO set to out * PB2 MOSI set to input by hardware diff --git a/cpu/atmega_common/periph/timer.c b/cpu/atmega_common/periph/timer.c index 5a463e22fe328e9d43ddb584e2c5d12c976befa9..9eb2b1a87feefbc5324fdcb84d25f8786c8f4e4d 100644 --- a/cpu/atmega_common/periph/timer.c +++ b/cpu/atmega_common/periph/timer.c @@ -212,10 +212,12 @@ ISR(TIMER_1_ISRB, ISR_BLOCK) _isr(1, 1); } +#ifdef TIMER_1_ISRC ISR(TIMER_1_ISRC, ISR_BLOCK) { _isr(1, 2); } +#endif /* TIMER_1_ISRC */ #endif /* TIMER_1 */ #ifdef TIMER_2