Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] fix pins for interrupt tests on trackerm #2527

Merged
merged 1 commit into from Aug 30, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion user/tests/app/input_pinmode/input_pinmode.cpp
Expand Up @@ -14,7 +14,7 @@ InterruptMode intType = CHANGE;
// We will set most pins to INPUT_x modes, but only test the first 7
// since PM_INT takes up one of the 8, and after that RISING and CHANGE pending interrupt tests will fail.
//
#if (PLATFORM_ID == PLATFORM_P2)
#if (PLATFORM_ID == PLATFORM_P2) || (PLATFORM_ID == PLATFORM_TRACKERM)
technobly marked this conversation as resolved.
Show resolved Hide resolved
const int PIN_MAX = D6; // TEST: D0 ~ D6 (however all will work on P2)
#elif (PLATFORM_ID == PLATFORM_ARGON) || (PLATFORM_ID == PLATFORM_BORON)
const int PIN_MAX = D6; // TEST: D0 ~ D6
Expand Down
12 changes: 9 additions & 3 deletions user/tests/app/interrupts/interrupts.cpp
Expand Up @@ -13,8 +13,14 @@ InterruptMode intType = RISING;
// We will set most pins to INPUT_x modes, but only test the first 7
// since PM_INT takes up one of the 8, and after that RISING and CHANGE pending interrupt tests will fail.
//

// Most of the tests start with D0
const int START_PIN = D0;
#if (PLATFORM_ID == PLATFORM_P2)
const int PIN_MAX = S6; // TEST: D0 ~ D6 (however all will work on P2)
#elif (PLATFORM_ID == PLATFORM_TRACKERM)
START_PIN = D8; // Overwrite start pin for trackerm
const int PIN_MAX = D9; // TEST: D8,D9
#elif (PLATFORM_ID == PLATFORM_ARGON) || (PLATFORM_ID == PLATFORM_BORON)
const int PIN_MAX = A0; // TEST: D0 ~ D6
#elif (PLATFORM_ID == PLATFORM_B5SOM)
Expand Down Expand Up @@ -51,7 +57,7 @@ void gimmeFivePulses() {
}

void teardownTest() {
for (int i = 0; i <= PIN_MAX; i++) {
for (int i = START_PIN; i <= PIN_MAX; i++) {
if (i == PULSE_PIN) continue;
if (i >= D7) continue;
#if (PLATFORM_ID == PLATFORM_BSOM)
Expand All @@ -65,7 +71,7 @@ void teardownTest() {

void setupTest(InterruptMode type) {
Log.info("TEST (%s) START", type==RISING?"RISING":type==FALLING?"FALLING":"CHANGE");
for (int i = 0; i <= PIN_MAX; i++) {
for (int i = START_PIN; i <= PIN_MAX; i++) {
if (i == PULSE_PIN) continue;
if (type == RISING) {
pinMode(i, INPUT_PULLDOWN);
Expand All @@ -75,7 +81,7 @@ void setupTest(InterruptMode type) {
pinMode(i, INPUT_PULLUP); // change
}
}
for (int i = 0; i <= PIN_MAX; i++) {
for (int i = START_PIN; i <= PIN_MAX; i++) {
if (i == PULSE_PIN) continue;
if (i >= D7) continue;
#if (PLATFORM_ID == PLATFORM_BSOM)
Expand Down
9 changes: 9 additions & 0 deletions user/tests/wiring/no_fixture/interrupts.cpp
Expand Up @@ -68,6 +68,9 @@ test(INTERRUPTS_02_attachintterupt_does_not_affect_pullup_pulldown_nopull)
#if PLATFORM_ID == PLATFORM_ESOMX
const pin_t START_PIN = D0;
const pin_t END_PIN = D2;
#elif PLATFORM_ID == PLATFORM_TRACKERM
const pin_t START_PIN = D8;
const pin_t END_PIN = D9;
technobly marked this conversation as resolved.
Show resolved Hide resolved
#else
// Every other platform has D2 ~ D3 available.
const pin_t START_PIN = D2;
Expand All @@ -80,6 +83,8 @@ test(INTERRUPTS_02_attachintterupt_does_not_affect_pullup_pulldown_nopull)
});
for (int i = START_PIN; i <= END_PIN; i++) {
pinMode(i, INPUT_PULLUP);
delay(100);
assertTrue(digitalRead(i) == HIGH); // INPUT_PULLUP should be set
}
for (int i = START_PIN; i <= END_PIN; i++) {
attachInterrupt(i, attach_interrupt_handler, RISING); // used to set PULLDOWN before sc-107554
Expand All @@ -92,6 +97,8 @@ test(INTERRUPTS_02_attachintterupt_does_not_affect_pullup_pulldown_nopull)

for (int i = START_PIN; i <= END_PIN; i++) {
pinMode(i, INPUT_PULLDOWN);
delay(100);
assertTrue(digitalRead(i) == LOW); // INPUT_PULLUP should be set
}
for (int i = START_PIN; i <= END_PIN; i++) {
attachInterrupt(i, attach_interrupt_handler, FALLING); // used to set PULLUP before sc-107554
Expand All @@ -100,6 +107,8 @@ test(INTERRUPTS_02_attachintterupt_does_not_affect_pullup_pulldown_nopull)
}
for (int i = START_PIN; i <= END_PIN; i++) {
detachInterrupt(i);
delay(100);
assertTrue(digitalRead(i) == LOW); // INPUT_PULLDOWN should be set
}
for (int i = START_PIN; i <= END_PIN; i++) {
attachInterrupt(i, attach_interrupt_handler, CHANGE); // used to set PULLUP before sc-107554
Expand Down