Skip to content

Commit

Permalink
Merge pull request #2231 from particle-iot/fix/sleep_pin_array
Browse files Browse the repository at this point in the history
[wiring] system: minor fix for sleep configuration method
  • Loading branch information
XuGuohui authored Nov 3, 2020
2 parents 070621c + 6088ea1 commit c21d5b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion system/inc/system_sleep_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class SystemSleepConfiguration: protected SystemSleepConfigurationHelper {
return *this;
}

SystemSleepConfiguration& gpios(const uint8_t* pins, size_t count, InterruptMode mode) {
SystemSleepConfiguration& gpios(const pin_t* pins, size_t count, InterruptMode mode) {
for (size_t i = 0; i < count; i++) {
gpio(pins[i], mode);
}
Expand Down
8 changes: 5 additions & 3 deletions user/tests/wiring/api/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ test(system_api) {

test(system_sleep)
{
const pin_t pins_array[] = {D0, D1};
const InterruptMode mode_array[] = {RISING, FALLING};

// All sleep methods should return System.sleep()
API_COMPILE({ SleepResult r = System.sleep(60); (void)r; });
Expand Down Expand Up @@ -103,9 +105,6 @@ test(system_sleep)
*/
API_COMPILE({ SleepResult r = System.sleep({D0, D1}, {RISING, FALLING}); (void)r; });

const pin_t pins_array[] = {D0, D1};
const InterruptMode mode_array[] = {RISING, FALLING};

/*
* wakeup pins: pin_t* + size_t
* trigger mode: single InterruptMode
Expand Down Expand Up @@ -169,6 +168,9 @@ test(system_sleep)
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().gpio(WKP, RISING)); (void)r; });
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().gpio(WKP, FALLING)); (void)r; });
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().gpio(WKP, CHANGE)); (void)r; });
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().gpios(Vector<std::pair<pin_t, InterruptMode>>())); (void)r; });
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().gpios(Vector<pin_t>(), RISING)); (void)r; });
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().gpios(pins_array, sizeof(pins_array)/sizeof(*pins_array), RISING)); (void)r; });
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().duration(1000)); (void)r; });
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().duration(1000ms)); (void)r; });
API_COMPILE({ SystemSleepResult r = System.sleep(SystemSleepConfiguration().duration(1s)); (void)r; });
Expand Down

0 comments on commit c21d5b8

Please sign in to comment.