-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2251 from particle-iot/bug/ch68808/low-level-inpu…
…t-output-slow-on-os-2-0-0-rc4 Always inline fastPinGetPinmap to speed pin sets
- Loading branch information
Showing
2 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
#include "application.h" | ||
#include "unit-test/unit-test.h" | ||
|
||
|
||
|
||
test(FASTPIN_01_MaxDuration_PinSet) { | ||
// Attempt pinSetFast and pinResetFast numerous times and check speed. | ||
// Duration went from about 62 -> 24 ticks per set on Gen2 with this change list | ||
|
||
#if HAL_PLATFORM_GEN == 3 | ||
// expected max ticks of pinSetFast / pinResetFast on Gen3 | ||
const uint32_t MAX_DURATION_PINSET_TICKS = 61; | ||
#elif HAL_PLATFORM_GEN == 2 | ||
// expected max ticks of pinSetFast / pinResetFast on Gen2 | ||
const uint32_t MAX_DURATION_PINSET_TICKS = 24; | ||
#else | ||
#error "No gpio fastpin timing benchmark yet measured for this platform" | ||
#endif | ||
|
||
const uint32_t NUM_ITERATIONS = 100; | ||
uint32_t start, finish; | ||
|
||
ATOMIC_BLOCK() { | ||
start = System.ticks(); | ||
for (uint32_t i = 0; i < NUM_ITERATIONS; i++) { | ||
pinSetFast(D7); | ||
//pinResetFast(D7); | ||
} | ||
finish = System.ticks(); | ||
} | ||
uint32_t duration = finish - start; | ||
// Serial.print("Set duration:"); | ||
// Serial.println(duration); | ||
assertLessOrEqual(duration, NUM_ITERATIONS*MAX_DURATION_PINSET_TICKS); | ||
} | ||
|
||
test(FASTPIN_02_MaxDuration_PinReset) { | ||
// Attempt pinResetFast numerous times and check speed. | ||
|
||
#if HAL_PLATFORM_GEN == 3 | ||
// expected max ticks of pinResetFast on Gen3 | ||
const uint32_t MAX_DURATION_PINRESET_TICKS = 60; | ||
#elif HAL_PLATFORM_GEN == 2 | ||
// expected max ticks of pinResetFast on Gen2 | ||
const uint32_t MAX_DURATION_PINRESET_TICKS = 25; | ||
#else | ||
#error "No gpio fastpin timing benchmark yet measured for this platform" | ||
#endif | ||
|
||
const uint32_t NUM_ITERATIONS = 100; | ||
uint32_t start, finish; | ||
|
||
ATOMIC_BLOCK() { | ||
start = System.ticks(); | ||
for (uint32_t i = 0; i < NUM_ITERATIONS; i++) { | ||
pinResetFast(D7); | ||
} | ||
finish = System.ticks(); | ||
} | ||
uint32_t duration = finish - start; | ||
// Serial.print("Reset duration:"); | ||
// Serial.println(duration); | ||
assertLessOrEqual(duration, NUM_ITERATIONS*MAX_DURATION_PINRESET_TICKS); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters