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.
main.cpp
- Committer:
- CSTritt
- Date:
- 2017-10-27
- Revision:
- 0:1917e5873a6e
- Child:
- 1:7ae3a9b9b2b0
File content as of revision 0:1917e5873a6e:
/*
Project: WaitTest
File: main.cpp
Modified by by: Dr. C. S. Tritt
Last revision on: 9/27/17 (v. 1.0)
Demonstrate/confirm wait function behaivor
*/
#include "mbed.h"
Ticker myTicker; // My ticker object. Used to generate output.
// Declare my ticker callback function. Sends text to serial.
void tick_Callback(void);
int main() {
// Setup to call to_Callback once a second.
myTicker.attach(&tick_Callback, 1.0);
wait(0.5); // Offset main loop calls by half a second.
int mainCount = 0; // Main loop counter.
while (true) {
// Tested a wait of 0. It was not taken as infinity.
wait(1.0); // Cycle this loop once a second.
mainCount++; // Increment mainCount.
if (mainCount == 11) mainCount = 1; // Reset every 10 times.
printf("In main loop. Count = %d.\n", mainCount);
}
}
// Define my ticker callback function. Sends text to serial.
void tick_Callback(void) {
static int cbCount = 0; // Initialized on load. Remembered between calls.
cbCount++; // Increment call back counter.
if (cbCount == 11) cbCount = 1; // Reset every 10 times.
printf("In ticker callback loop. Count = %d.\n", cbCount);
}