Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions | Static Public Member Functions
Timeout Class Reference

A Timeout is used to call a function at a point in the future. More...

#include <Timeout.h>

Inheritance diagram for Timeout:
Ticker NonCopyable< Timeout > TimerEvent NonCopyable< Ticker > NonCopyable< TimerEvent >

Public Member Functions

void attach (Callback< void()> func, float t)
 Attach a function to be called by the Ticker, specifying the interval in seconds. More...
 
template<typename T , typename M >
void attach (T *obj, M method, float t)
 Attach a member function to be called by the Ticker, specifying the interval in seconds. More...
 
void attach_us (Callback< void()> func, us_timestamp_t t)
 Attach a function to be called by the Ticker, specifying the interval in microseconds. More...
 
template<typename T , typename M >
void attach_us (T *obj, M method, us_timestamp_t t)
 Attach a member function to be called by the Ticker, specifying the interval in microseconds. More...
 
void detach ()
 Detach the function. More...
 

Static Public Member Functions

static void irq (uint32_t id)
 The handler registered with the underlying timer interrupt. More...
 

Detailed Description

A Timeout is used to call a function at a point in the future.

You can use as many separate Timeout objects as you require.

Note
Synchronization level: Interrupt safe

Example:

// Blink until timeout.
#include "mbed.h"
Timeout timeout;
DigitalOut led(LED1);
int on = 1;
void attimeout() {
on = 0;
}
int main() {
timeout.attach(&attimeout, 5);
while(on) {
led = !led;
wait(0.2);
}
}

Definition at line 58 of file Timeout.h.

Member Function Documentation

void attach ( Callback< void()>  func,
float  t 
)
inherited

Attach a function to be called by the Ticker, specifying the interval in seconds.

Parameters
funcpointer to the function to be called
tthe time between calls in seconds

Definition at line 87 of file Ticker.h.

void attach ( T *  obj,
method,
float  t 
)
inherited

Attach a member function to be called by the Ticker, specifying the interval in seconds.

Parameters
objpointer to the object to call the member function on
methodpointer to the member function to be called
tthe time between calls in seconds
Deprecated:
The attach function does not support cv-qualifiers. Replaced by attach(callback(obj, method), t).

Definition at line 105 of file Ticker.h.

void attach_us ( Callback< void()>  func,
us_timestamp_t  t 
)
inherited

Attach a function to be called by the Ticker, specifying the interval in microseconds.

Parameters
funcpointer to the function to be called
tthe time between calls in micro-seconds
Note
setting t to a value shorter than it takes to process the ticker callback causes the system to hang. Ticker callback is called constantly with no time for threads scheduling.
void attach_us ( T *  obj,
method,
us_timestamp_t  t 
)
inherited

Attach a member function to be called by the Ticker, specifying the interval in microseconds.

Parameters
objpointer to the object to call the member function on
methodpointer to the member function to be called
tthe time between calls in microseconds
Deprecated:
The attach_us function does not support cv-qualifiers. Replaced by attach_us(callback(obj, method), t).

Definition at line 135 of file Ticker.h.

void detach ( )
inherited

Detach the function.

static void irq ( uint32_t  id)
staticinherited

The handler registered with the underlying timer interrupt.

Parameters
idTimer Event ID
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.