Emilio Monti / Mbed 2 deprecated test_wait

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 int main() {
00004     volatile int us = 100;
00005     volatile uint32_t start = 0xFFFFFFF0;
00006     volatile uint32_t us_ticker  = 100;
00007     
00008     // void wait_us(int us) {
00009     //     uint32_t start = us_ticker_read();
00010     //     while ((us_ticker_read() - start) < us);
00011     // }
00012     if ((us_ticker - start) < us) {
00013         printf("while(True): Failed to detect that the interval is expired, still in the loop \n");
00014     } else {
00015         printf("while(False): Got out of the wait loop\n");
00016     }
00017     printf("%d\n", (us_ticker - start));
00018 
00019     DigitalOut led(LED1);
00020     while (1) {
00021         led = !led;
00022         wait(0.5);
00023     }
00024 }