C API timer definitions.
More...
- For the complete definition, see
- RTOS C++ API
- Examples
void
tmfunc (void* args
{
printf ("%s\n", __func__);
}
int
{
{
assert(strcmp (name, "tm1") == 0);
}
{
assert(strcmp (name, "tm2") == 0);
}
}
os_result_t os_sysclock_sleep_for(os_clock_duration_t duration)
Sleep for a relative duration.
const char * os_timer_get_name(os_timer_t *timer)
Get the timer name.
os_result_t os_timer_stop(os_timer_t *timer)
Stop the timer.
void os_timer_destruct(os_timer_t *timer)
Destruct the statically allocated timer object instance.
os_result_t os_timer_start(os_timer_t *timer, os_clock_duration_t period)
Start or restart the timer.
void os_timer_construct(os_timer_t *timer, const char *name, os_timer_func_t function, os_timer_func_args_t args, const os_timer_attr_t *attr)
Construct a statically allocated timer object instance.
const os_timer_attr_t * os_timer_attr_get_periodic(void)
Get a periodic timer attributes object instance.
int os_main(int argc, char *argv[])
Application entry point, running on the main thread context.
◆ os_timer_create
◆ os_timer_destroy
◆ os_timer_attr_t
◆ os_timer_func_args_t
◆ os_timer_func_t
◆ os_timer_state_t
◆ os_timer_t
This C structure has the same size as the C++ os::rtos::timer object and must be initialised with os_timer_create().
Later on a pointer to it can be used both in C and C++ to refer to the timer object instance.
The members of this structure are hidden and should not be used directly, but only through specific functions.
- See also
- os::rtos::timer
◆ os_timer_type_t
◆ anonymous enum
| Enumerator |
|---|
| os_timer_once | |
| os_timer_periodic | |
Definition at line 694 of file os-c-decls.h.
◆ os_timer_attr_get_periodic()
◆ os_timer_attr_init()
- Parameters
-
| [in] | attr | Pointer to timer attributes object instance. |
- Returns
- Nothing.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer::attributes
Definition at line 1460 of file os-c-wrapper.cpp.
1461{
1462 assert (attr != nullptr);
1464}
◆ os_timer_attr_periodic_init()
- Parameters
-
| [in] | attr | Pointer to timer attributes object instance. |
- Returns
- Nothing.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer::attributes_periodic
Definition at line 1473 of file os-c-wrapper.cpp.
1474{
1475 assert (attr != nullptr);
1477}
Periodic timer attributes.
◆ os_timer_construct()
- Parameters
-
| [in] | timer | Pointer to timer object instance storage. |
| [in] | name | Pointer to name (may be NULL). |
| [in] | function | Pointer to timer function. |
| [in] | args | Pointer to timer function arguments (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
- Returns
- Nothing.
- Note
- Must be paired with
os_timer_destruct().
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer
Definition at line 1500 of file os-c-wrapper.cpp.
1503{
1504 assert (
timer !=
nullptr);
1505 if (attr == nullptr)
1506 {
1508 }
1512}
User single-shot or periodic timer.
void * func_args_t
Timer call back function arguments.
void(*)(func_args_t args) func_t
Entry point of a timer call back function.
References os::rtos::timer::periodic_initializer.
◆ os_timer_delete()
- Parameters
-
| [in] | timer | Pointer to dynamically allocated timer object instance. |
- Returns
- Nothing.
Destruct the timer and deallocate the dynamically allocated space using the RTOS system allocator.
- Note
- Equivalent of C++
delete ptr_timer.
-
Must be paired with
os_timer_new().
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer
Definition at line 1569 of file os-c-wrapper.cpp.
1570{
1571 assert (
timer !=
nullptr);
1573}
◆ os_timer_destruct()
- Parameters
-
| [in] | timer | Pointer to timer object instance. |
- Returns
- Nothing.
- Note
- Must be paired with
os_timer_construct().
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer
Definition at line 1523 of file os-c-wrapper.cpp.
1524{
1525 assert (
timer !=
nullptr);
1527}
◆ os_timer_get_name()
| const char * os_timer_get_name |
( |
os_timer_t * |
timer | ) |
|
- Parameters
-
| [in] | timer | Pointer to timer object instance. |
- Returns
- Null terminated string.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer::name()
Definition at line 1582 of file os-c-wrapper.cpp.
1583{
1584 assert (
timer !=
nullptr);
1586}
◆ os_timer_new()
- Parameters
-
| [in] | name | Pointer to name (may be NULL). |
| [in] | function | Pointer to timer function. |
| [in] | args | Pointer to timer function arguments (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
- Returns
- Pointer to new timer object instance.
Dynamically allocate the timer object instance using the RTOS system allocator and construct it.
- Note
- Equivalent of C++
new timer(...).
-
Must be paired with
os_timer_delete().
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer
Definition at line 1543 of file os-c-wrapper.cpp.
1545{
1546 if (attr == nullptr)
1547 {
1549 }
1553}
References os::rtos::timer::periodic_initializer.
◆ os_timer_start()
- Parameters
-
| [in] | timer | Pointer to timer object instance. |
| [in] | period | Timer period, in clock units (ticks or seconds). |
- Return values
-
| os_ok | The timer has been started or restarted. |
| ENOTRECOVERABLE | Timer could not be started. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer::start()
Definition at line 1595 of file os-c-wrapper.cpp.
1596{
1597 assert (
timer !=
nullptr);
1599}
uint32_t os_result_t
Type of values returned by RTOS functions.
◆ os_timer_stop()
- Parameters
-
| [in] | timer | Pointer to timer object instance. |
- Return values
-
| os_ok | The timer has been stopped. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
| EAGAIN | The timer is not yet started. |
| ENOTRECOVERABLE | Timer could not be stopped. |
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::timer::stop()
Definition at line 1608 of file os-c-wrapper.cpp.
1609{
1610 assert (
timer !=
nullptr);
1612}