Skip to content

Commit

Permalink
cpu/atmega_common: implements pseudomodule-based pin change interrupts
Browse files Browse the repository at this point in the history
  • Loading branch information
roberthartung committed Aug 1, 2019
1 parent 8c4cc54 commit 7bca1cc
Show file tree
Hide file tree
Showing 5 changed files with 324 additions and 4 deletions.
17 changes: 17 additions & 0 deletions boards/common/atmega/doc.txt
@@ -0,0 +1,17 @@
/**
@defgroup boards_common_atmega ATmega common
@ingroup boards
@brief Shared files and configuration for ATmega-based boards

### Pin Change Interrupts

Pin Change Interrupts (PCINTs) can be enabled using pseudo modules. To provide
a low-memory overhead implementation, the PCINTs are grouped into **banks**.
Each banks corresponds to one PCINT on the ATmega (PCINT0, ..., PCINT3).

To enable only a specific bank, simply add `USEMODULE += atmega_pcintN` to your
Makefile. To enable all interrupts you can use `USEMODULE += atmega_pcint`.

In case you want to add a new CPU, simply provide an `atmega_pcint.h` with your
CPU and adapt your Makefile.dep and Makefile.featues files.
*/
24 changes: 24 additions & 0 deletions cpu/atmega_common/Makefile.dep
@@ -0,0 +1,24 @@
# expand atmega_pcint module
ifneq (,$(filter atmega_pcint,$(USEMODULE)))
USEMODULE += atmega_pcint0
endif

# feature for atmega_pcint0 module
ifneq (,$(filter atmega_pcint0,$(USEMODULE)))
FEATURES_REQUIRED += atmega_pcint0
endif

# feature for atmega_pcint1 module
ifneq (,$(filter atmega_pcint1,$(USEMODULE)))
FEATURES_REQUIRED += atmega_pcint1
endif

# feature for atmega_pcint2 module
ifneq (,$(filter atmega_pcint2,$(USEMODULE)))
FEATURES_REQUIRED += atmega_pcint2
endif

# feature for atmega_pcint3 module
ifneq (,$(filter atmega_pcint3,$(USEMODULE)))
FEATURES_REQUIRED += atmega_pcint3
endif
2 changes: 2 additions & 0 deletions cpu/atmega_common/Makefile.features
@@ -1,2 +1,4 @@
FEATURES_PROVIDED += periph_eeprom
FEATURES_PROVIDED += periph_pm

FEATURES_PROVIDED += atmega_pcint0
30 changes: 30 additions & 0 deletions cpu/atmega_common/Makefile.include
Expand Up @@ -6,4 +6,34 @@ export INCLUDES += -I$(RIOTCPU)/atmega_common/include \
# avr libc needs some RIOT-specific support code
USEMODULE += avr_libc_extra

PSEUDOMODULES += atmega_pcint
PSEUDOMODULES += atmega_pcint%

# expand atmega_pcint module
# atmega16u4 only features atmega_pcint0, therefore additional pseudomodules
# are activated in each CPU's Makefile.include
ifneq (,$(filter atmega_pcint,$(USEMODULE)))
USEMODULE += atmega_pcint0
endif

# feature for atmega_pcint0 module
ifneq (,$(filter atmega_pcint0,$(USEMODULE)))
FEATURES_REQUIRED += atmega_pcint0
endif

# feature for atmega_pcint1 module
ifneq (,$(filter atmega_pcint1,$(USEMODULE)))
FEATURES_REQUIRED += atmega_pcint1
endif

# feature for atmega_pcint2 module
ifneq (,$(filter atmega_pcint2,$(USEMODULE)))
FEATURES_REQUIRED += atmega_pcint2
endif

# feature for atmega_pcint3 module
ifneq (,$(filter atmega_pcint3,$(USEMODULE)))
FEATURES_REQUIRED += atmega_pcint3
endif

include $(RIOTMAKE)/arch/atmega.inc.mk

0 comments on commit 7bca1cc

Please sign in to comment.