cpu/atmega_common: prepare for atmega328p inclusion

use generic avr/libc definition for conditionnal compilation.
eg: use #ifdef(PORTG) or #ifdef(TIMER_0_ISRC) instead of #ifdef(Atmega328p)
This is more generic and simplify future boards support.
pr/spi.typo
Laurent Navet 7 years ago
parent 2cd918a07a
commit eed73beaa1

@ -17,6 +17,7 @@
*
* @author René Herthel <rene-herthel@outlook.de>
* @author Francisco Acosta <francisco.acosta@inria.fr>
* @author Laurent Navet <laurent.navet@gmail.com>
*
* @}
*/
@ -84,10 +85,11 @@ static inline uint16_t _port_addr(gpio_t pin)
port_addr += GPIO_BASE_PORT_A;
port_addr += GPIO_OFFSET_PIN_PORT;
#if defined (PORTG)
if (port_num > PORT_G) {
port_addr += GPIO_OFFSET_PORT_H;
}
#endif
return port_addr;
}
@ -153,25 +155,31 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
if (pin_num < 4) {
EICRA |= (3 << pin_num * 2);
}
#if defined(EICRB)
else {
EICRB |= (3 << (pin_num * 2) % 4);
}
#endif
break;
case GPIO_FALLING:
if (pin_num < 4) {
EICRA |= (2 << pin_num * 2);
}
#if defined(EICRB)
else {
EICRB |= (2 << (pin_num * 2) % 4);
}
#endif
break;
case GPIO_BOTH:
if (pin_num < 4) {
EICRA |= (1 << pin_num * 2);
}
#if defined(EICRB)
else {
EICRB |= (1 << (pin_num * 2) % 4);
}
#endif
break;
default:
return -1;

@ -208,10 +208,12 @@ ISR(TIMER_0_ISRB, ISR_BLOCK)
_isr(0, 1);
}
#ifdef TIMER_0_ISRC
ISR(TIMER_0_ISRC, ISR_BLOCK)
{
_isr(0, 2);
}
#endif /* TIMER_0_ISRC */
#endif /* TIMER_0 */
#ifdef TIMER_1

Loading…
Cancel
Save