tests: Added tests for gpio_init_int() on ATmega boards#11923
tests: Added tests for gpio_init_int() on ATmega boards#11923maribu wants to merge 7 commits intoRIOT-OS:masterfrom
Conversation
This test is written to allow testing and debugging of the interrupt facilities of ATmega MCUs. Some ATmegas (e.g. the ATmega328P used on the Arduino Uno / Arduino Nano) have so limited RAM and flash, that using standard tests cannot be compiled. This test is written with the low resources in mind and also takes the pin changed features of the ATmega MCUs into account.
Somehow Makefile.dep was missing on the Arduino Leonardo. This commit adds it.
Currently the configuration claims that external interrupt INT4 is present on pin PE7. However, the ATmega32U4 datasheet (section 10.3.4 page 81) contains the following remark to pin PE7: "Not present on pin-out". This commit removes the PE7 from the interrupt config.
Pins PD2 and PD3 can be used as both external interrupt and as pin changed interrupt. (PD2: INT0/PCINT18, PD3: INT1/PCINT19.) This commit removes support for the pin changed interrupt PCINT18 and PCINT19 on the ATmega328P MCU in order to reflect that GPIO PD2 and PD3 cannot be set up as port changed interrupt, as RIOT will always use the external interrupt of the pin changed interrupt if both are available.
|
OK. I tested this on the Ardunino Lenoardo, Uno, Nano, and Mega2560. I had to add board specific pin change interrupt configurations to take unconnected or unusable GPIOs into account. I also updated the ATmega328P pin change interrupt configuration, as two pins can be used as both external interrupt and as pin changed interrupt. I disabled those as pin changed interrupts to make it more obvious that RIOT will never configure them that was, as external interrupts take preference in the implementation (which makes sense). @roberthartung: The PR is now ready to be reviewed |
|
@roberthartung: Have you found time to give it a look? |
|
Works for me so far. :) However is it good to 'randomly' attach flanks? e.g. if pull ups/downs are attached, this might cause an issue? |
|
I think that the flanks should not be an issue if external pull downs are present: One would need to use a second jumper wire connected to VDD to generate the edge for those pins. But enabling the internal pull up will be problematic with an external pull down present. I think that the combined resistance of both pull resistors should be high enough to limit the current to a safe value, as they will be in series (and not in parallel), right? But the logical value at the pin could be "jumpy", if both pull resistors pull are similar "strong". But this should not be an issue on the boards we currently have in RIOT, as they do not use external pull downs on the relevant pins as far as I know. A better approach for testing would be to provide a shell and let the user pick the pins to test. But using the shell is not possible on the ATmega328P based boards due to memory constrains; and new boards having external pull downs might be using the ATmega328P. So this is not viable, sadly. I think in case new boards are added that do have external pull downs, those pins could be added conditionally ( |
Well we also have to think about the future I guess. Just wanted to make a hint about that. Maybe we should add a README.md to the test so we mention that we assign the flanks "randomly" (round robin manner) and one needs to be careful, when using the test, if external pull downs are present? |
Contribution description
This PR adds a test that tests
gpio_init_int()on ATmega boards, which differs in two major points from the existing test forgpio_init_int():Testing procedure
Build, flash and run the provided test on a couple of ATmega based boards
arduino-leonardo)[ ] ATmega256RF2 based board ((Board support dropped in RIOT)jiminy-mega256rf2)arduino-unoorarduino-nano)waspmote-pro)mega-xplainedor the not yet mainlined INGA board)arduino-mega2560)Issues/PRs references
Depends on and includes #11122(merged)Depends on and includes #11927(merged)