Emilio Monti
/
test_wait
"wait_us" example
main.cpp
- Committer:
- emilmont
- Date:
- 2013-03-21
- Revision:
- 1:09163b143242
- Parent:
- 0:453461456608
File content as of revision 1:09163b143242:
#include "mbed.h" int main() { volatile int us = 100; volatile uint32_t start = 0xFFFFFFF0; volatile uint32_t us_ticker = 100; // void wait_us(int us) { // uint32_t start = us_ticker_read(); // while ((us_ticker_read() - start) < us); // } if ((us_ticker - start) < us) { printf("while(True): Failed to detect that the interval is expired, still in the loop \n"); } else { printf("while(False): Got out of the wait loop\n"); } printf("%d\n", (us_ticker - start)); DigitalOut led(LED1); while (1) { led = !led; wait(0.5); } }