Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cpu/atmega1281/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ enum {
GPIO_PIN(PORT_E, 6), \
GPIO_PIN(PORT_E, 7) }

/**
* @brief Get the interrupt vector number of the given GPIO pin
*/
static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
{
(void)port_num;
return pin_num;
}

/**
* @brief Check if the given pin can be used as external interrupt
*/
static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
{
if (pin_num < 4) {
return port_num == PORT_D;
}

return port_num == PORT_E;
}

/**
* @name Defines for the I2C interface
* @{
Expand Down
27 changes: 27 additions & 0 deletions cpu/atmega1284p/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,33 @@ enum {
GPIO_PIN(PORT_D, 3), \
GPIO_PIN(PORT_B, 2) }

/**
* @brief Get the interrupt vector number of the given GPIO pin
*/
static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
{
if (port_num == PORT_B) {
return 2;
}

return pin_num - 2;
}

/**
* @brief Check if the given pin can be used as external interrupt
*/
static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
{
switch (port_num) {
default:
return false;
case PORT_D:
return ((pin_num == 2) || (pin_num == 3));
case PORT_B:
return pin_num == 2;
}
}

/**
* @name Defines for the I2C interface
* @{
Expand Down
21 changes: 21 additions & 0 deletions cpu/atmega128rfa1/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ enum {
GPIO_PIN(PORT_E, 6), \
GPIO_PIN(PORT_E, 7) }

/**
* @brief Get the interrupt vector number of the given GPIO pin
*/
static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
{
(void)port_num;
return pin_num;
}

/**
* @brief Check if the given pin can be used as external interrupt
*/
static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
{
if (pin_num < 4) {
return port_num == PORT_D;
}

return port_num == PORT_E;
}

/**
* @name Defines for the I2C interface
* @{
Expand Down
21 changes: 21 additions & 0 deletions cpu/atmega2560/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ enum {
GPIO_PIN(PORT_E, 6), \
GPIO_PIN(PORT_E, 7) }

/**
* @brief Get the interrupt vector number of the given GPIO pin
*/
static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
{
(void)port_num;
return pin_num;
}

/**
* @brief Check if the given pin can be used as external interrupt
*/
static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
{
if (pin_num < 4) {
return port_num == PORT_D;
}

return port_num == PORT_E;
}

/**
* @name Defines for the I2C interface
* @{
Expand Down
21 changes: 21 additions & 0 deletions cpu/atmega256rfr2/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ enum {
GPIO_PIN(PORT_E, 6), \
GPIO_PIN(PORT_E, 7) }

/**
* @brief Get the interrupt vector number of the given GPIO pin
*/
static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
{
(void)port_num;
return pin_num;
}

/**
* @brief Check if the given pin can be used as external interrupt
*/
static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
{
if (pin_num < 4) {
return port_num == PORT_D;
}

return port_num == PORT_E;
}

/**
* @name Defines for the I2C interface
* @{
Expand Down
21 changes: 21 additions & 0 deletions cpu/atmega328p/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ enum {
#define CPU_ATMEGA_EXT_INTS { GPIO_PIN(PORT_D, 2), \
GPIO_PIN(PORT_D, 3) }

/**
* @brief Get the interrupt vector number of the given GPIO pin
*/
static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
{
(void)port_num;
return pin_num - 2;
}

/**
* @brief Check if the given pin can be used as external interrupt
*/
static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
{
if (port_num == PORT_D) {
return ((pin_num == 2) || (pin_num == 3));
}

return false;
}

/**
* @name Defines for the I2C interface
* @{
Expand Down
17 changes: 17 additions & 0 deletions cpu/atmega32u4/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ enum {
GPIO_PIN(PORT_D, 2), \
GPIO_PIN(PORT_D, 3) }

/**
* @brief Get the interrupt vector number of the given GPIO pin
*/
static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
{
(void)port_num;
return pin_num;
}

/**
* @brief Check if the given pin can be used as external interrupt
*/
static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
{
return ((pin_num < 4) && (port_num == PORT_D));
}

/**
* @name Defines for the I2C interface
* @{
Expand Down
4 changes: 4 additions & 0 deletions cpu/atmega_common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ config CPU_COMMON_ATMEGA
select HAS_PERIPH_EEPROM
select HAS_PERIPH_GPIO
select HAS_PERIPH_GPIO_IRQ
select HAS_PERIPH_GPIO_LL
select HAS_PERIPH_GPIO_LL_IRQ
select HAS_PERIPH_GPIO_LL_IRQ_LEVEL_TRIGGERED_LOW
select HAS_PERIPH_GPIO_LL_IRQ_UNMASK
select HAS_PERIPH_PM
select HAS_PERIPH_RTC_MS
select HAS_PERIPH_RTT_SET_COUNTER
Expand Down
4 changes: 4 additions & 0 deletions cpu/atmega_common/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ FEATURES_PROVIDED += dbgpin
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_eeprom
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_gpio_ll
FEATURES_PROVIDED += periph_gpio_ll_irq
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_low
FEATURES_PROVIDED += periph_gpio_ll_irq_unmask
FEATURES_PROVIDED += periph_pm
FEATURES_PROVIDED += periph_rtc_ms
FEATURES_PROVIDED += periph_rtt_set_counter
Expand Down
18 changes: 1 addition & 17 deletions cpu/atmega_common/include/atmega_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
extern "C" {
#endif

#define ATMEGA_GPIO_BASE_PORT_A (0x20)
#define ATMEGA_GPIO_OFFSET_PORT_H (0xCB)
#define ATMEGA_GPIO_OFFSET_PIN_PORT (0x02)
#define ATMEGA_GPIO_OFFSET_PIN_PIN (0x03)

/**
* @brief Extract the pin number of the given pin
*/
Expand All @@ -64,18 +59,7 @@ static inline uint8_t atmega_port_num(gpio_t pin)
*/
static inline uint16_t atmega_port_addr(gpio_t pin)
{
uint8_t port_num = atmega_port_num(pin);
uint16_t port_addr = port_num * ATMEGA_GPIO_OFFSET_PIN_PIN;

port_addr += ATMEGA_GPIO_BASE_PORT_A;
port_addr += ATMEGA_GPIO_OFFSET_PIN_PORT;

#if defined (PORTG)
if (port_num > PORT_G) {
port_addr += ATMEGA_GPIO_OFFSET_PORT_H;
}
#endif
return port_addr;
return (uintptr_t)(&atmega_gpio_port(pin)->port);
}

/**
Expand Down
Loading