Skip to content

Commit

Permalink
Merge pull request #2527 from particle-iot/fix/trackerm_interrupt_tests
Browse files Browse the repository at this point in the history
[tests] fix pins for interrupt tests on trackerm
  • Loading branch information
keeramis committed Aug 30, 2022
2 parents 1bf0fc2 + 7ed9a28 commit 37900a4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
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)
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;
#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

0 comments on commit 37900a4

Please sign in to comment.