Skip to content

cpu/atmega_common: pseudomodule-based pin change interrupt implementation#11122

Merged
maribu merged 8 commits intoRIOT-OS:masterfrom
ibr-cm:hartung/atmega-pin-change-interrupt-pseudomodules
Aug 2, 2019
Merged

cpu/atmega_common: pseudomodule-based pin change interrupt implementation#11122
maribu merged 8 commits intoRIOT-OS:masterfrom
ibr-cm:hartung/atmega-pin-change-interrupt-pseudomodules

Conversation

@roberthartung
Copy link
Copy Markdown
Member

@roberthartung roberthartung commented Mar 7, 2019

Contribution description

This is pseudomodule-based version of pin change interrupts for the atmega common platform. Challenge was, that each bank of pin change interrupts (PCINT0, ..., PCINT3) mixes ports. Therefore some magic has to happen.

The memory consumption is: (1 byte (state) + 8 byte (mapping) + 8*6 (config)) per used bank. This means if a single PCINT is used on a pin we need 57 bytes of additional memory.

Additionally, each cpu needs an atmega_pcint.h for the specific PCINT mapping.

Issues/PRs references

See also #7610, #8993, #9159. This is an follow up PR for #11114

Testing

  • ATmega1281 (board(s): waspmote-pro) @maribu double checked config against the data sheet (no one has the board)
  • ATmega1284p (board(s): mega-xplained) @TorbenPetersen tested with the INGA board
  • ATmega2560 (boards(s): arduino-mega2560) PCINT9 and PCINT10 are not working yet
  • ATmega256RFR2 (boards(s): jiminy-mega256rfr2) @maribu double checked config against the data sheet
  • ATmega328P (boards(s): arduino-uno) @maribu tested, works as expected

Testing for non-Arduino boards

  1. Flash tests/periph_gpio on your avr board
  2. Enable a pcint bank with USEMODULE += atmega_pcint0, or USEMODULE += atmega_pcint.
  3. Using the shell commands init_int and enable_int test if interrupts are correctly fired for a couple of pins.
    • Please test both pins with their own interrupt vector (to rule out regressions) and pins that rely on the "Pin Change Interrupt" vector shared by multiple GPIOs
    • Please test with at least one pin per interrupt bank

Testing for Arduino Uno and Arduino Mega2560

Flash and run the test added in this PR.


Update 1: Added TODO for testing
Update 2: Elaborated on testing
Update 3: Added instructions for testing on Arduino boards, added test results

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: AVR Platform: This PR/issue effects AVR-based platforms Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants