9.7. Using the mbed Timeout

Program Example 9.4 showed the mbed timer being used to trigger time-based events in an effective way. However, we needed to poll the timer value to know when the event should be triggered. The timeout allows an event to be triggered by an interrupt, with no polling needed. Timeout sets up an interrupt to call a function after a specified delay. There is no limit on the number of timeouts created. The API summary is shown in Table 9.4.

9.7.1. A Simple Timeout Application

A simple first example of Timeout is shown in Program Example 9.6. This causes an action to be triggered a fixed period after an external event. This simple program is made up of the main( ) function and a blink( ) function. A Timeout object is created, ...

Get Fast and Effective Embedded Systems Design, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.