Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Blinky_Tests by
Revision 4:09af3b2d723e, committed 2016-11-08
- Comitter:
- mbed_demo
- Date:
- Tue Nov 08 22:12:16 2016 +0000
- Parent:
- 3:4432e591b5ef
- Child:
- 5:4f1e6b065e6b
- Commit message:
- Tests use blinky method instead of InterruptIn
Changed in this revision
| Blinky.lib | Show annotated file Show diff for this revision Revisions of this file |
| TESTS/Blinky/5_Blinks/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Blinky.lib Tue Nov 08 18:51:34 2016 +0000 +++ b/Blinky.lib Tue Nov 08 22:12:16 2016 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/sarahmarshy/code/Blinky/#5b51a271d47e +https://developer.mbed.org/users/mbed_demo/code/Blinky/#256c8d48f5e7
--- a/TESTS/Blinky/5_Blinks/main.cpp Tue Nov 08 18:51:34 2016 +0000
+++ b/TESTS/Blinky/5_Blinks/main.cpp Tue Nov 08 22:12:16 2016 +0000
@@ -10,35 +10,25 @@
//All tests will blink the LED 5 times
const int expected_blinks = 5;
//To be set by interrupt handler
-int measured_blinks = 0;
-
-//To be called by interrupt, increases the number of measured rising edges
-void count_blinks(){
- measured_blinks++;
-}
//Generic blink test
//interval => the the amount of time between blinks
//led => PinName of LED to blink
void test_blinks(PinName led, int interval){
- //reset the measured blinks to 0 for each case
- measured_blinks = 0;
//Set an appropriate wait time to measure exactly expected_blinks
//with the given interval
float wait_time = 2*interval*expected_blinks;
- //Create an interrupt that calls count_blinks on rising edge of LED pin
- InterruptIn blink_counter(led);
//Create Blinky
Blinky blinker(led, interval);
- //Attach interrupt
- blink_counter.rise(&count_blinks);
//start blinky
blinker.start();
//Wait the appropriate amount of time for expected_blinks
Thread::wait(wait_time);
blinker.stop();
+
+ float measured_blinks = blinker.times_blinked();
//Only assert if failure
- TEST_ASSERT(measured_blinks != expected_blinks);
+ TEST_ASSERT(measured_blinks == (float)expected_blinks);
}
void blink_500(){
