Loading...
Searching...
No Matches
L4::Poll_timeout_counter Class Reference

Evaluate an expression for a maximum number of times. More...

`#include <poll_timeout_counter.h>`

Collaboration diagram for L4::Poll_timeout_counter:

## Public Member Functions

| Poll_timeout_counter (unsigned counter_val)
| Constructor.
void | set (unsigned counter_val)
| Set the counter to a certain value.
bool | test (bool expression=true)
| Evaluate the expression for a maximum number of times.
bool | timed_out () const
| Indicator if the maximum number of tests was required.

## Detailed Description

Evaluate an expression for a maximum number of times.

A typical use case is testing for a bit change in a hardware register for a maximum number of times (polling). For example:

Mmio_register_block regs;
Poll_timeout_counter i(3000000);
while (i.test(!(regs.read<l4_uint32_t>(0x04) & 1)))
;
L4::Poll_timeout_counter::Poll_timeout_counter
Poll_timeout_counter(unsigned counter_val)
Constructor.
Definition poll_timeout_counter.h:42
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29

The following usage is wrong:

...
Poll_timeout_counter i(3000000);
while (!i.test((regs.read<l4_uint32_t>(0x04) & 1)))
;

This loop would never terminate if the hardware register doesn't change!

Definition at line 34 of file poll_timeout_counter.h.

## Constructor & Destructor Documentation

## Poll_timeout_counter()

L4::Poll_timeout_counter::Poll_timeout_counter | ( | unsigned | counter_val | ) |

inline

Constructor.

Parameters

  counter_val | Maximum number of times to repeat the test.

Definition at line 42 of file poll_timeout_counter.h.

References set().

Here is the call graph for this function:

## Member Function Documentation

## set()

void L4::Poll_timeout_counter::set | ( | unsigned | counter_val | ) |

inline

Set the counter to a certain value.

Parameters

  counter_val | New counter value for maximum number of times to repeat the test.

Definition at line 53 of file poll_timeout_counter.h.

Referenced by Poll_timeout_counter().

Here is the caller graph for this function:

## timed_out()

bool L4::Poll_timeout_counter::timed_out | ( |  | ) | const

inline

Indicator if the maximum number of tests was required.

Return values

  true,if | the maximum number of tests was required or if the counter was initialized to zero.

Definition at line 81 of file poll_timeout_counter.h.

The documentation for this class was generated from the following file:

- pkg/drivers-frst/include/poll_timeout_counter.h