RTE RBC 2oo2 Reference Application 0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Loading...
Searching...
No Matches
ab_gp_cycle_ticks.c File Reference

See ab_gp_cycle_ticks.h. More...

#include "ab_gp_cycle_ticks.h"
#include <stddef.h>
Include dependency graph for ab_gp_cycle_ticks.c:

Go to the source code of this file.

Functions

rte_status_t ab_gp_cycle_ticks_setup (ab_gp_cycle_ticks_t *ticks)
 Creates the mutex and clears the count. Setup phase only (rte_mutex_create() is a setup-only resource, ADR-026); call before the timer that posts is created. Does not check for an earlier setup of ticks.
rte_status_t ab_gp_cycle_ticks_post (ab_gp_cycle_ticks_t *ticks)
 Adds one tick (timer callback side). The count saturates at UINT32_MAX.
rte_status_t ab_gp_cycle_ticks_take (ab_gp_cycle_ticks_t *ticks, uint32_t *out_pending)
 Returns every pending tick and clears the count, as one critical section (cycle thread side).
rte_status_t ab_gp_cycle_ticks_teardown (ab_gp_cycle_ticks_t *ticks)
 Destroys the mutex. Call only when no other task can post or take any more (the posting timer is destroyed). The instance is not set up afterwards, whatever the result.

Detailed Description

See ab_gp_cycle_ticks.h.

Definition in file ab_gp_cycle_ticks.c.

Function Documentation

◆ ab_gp_cycle_ticks_setup()

rte_status_t ab_gp_cycle_ticks_setup ( ab_gp_cycle_ticks_t * ticks)

Creates the mutex and clears the count. Setup phase only (rte_mutex_create() is a setup-only resource, ADR-026); call before the timer that posts is created. Does not check for an earlier setup of ticks.

Parameters
ticksinstance to set up, all-zero or torn down
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM when ticks is NULL; otherwise the status of rte_mutex_create() (the instance then stays not set up)

Definition at line 9 of file ab_gp_cycle_ticks.c.

◆ ab_gp_cycle_ticks_post()

rte_status_t ab_gp_cycle_ticks_post ( ab_gp_cycle_ticks_t * ticks)

Adds one tick (timer callback side). The count saturates at UINT32_MAX.

Parameters
ticksinstance to post to
Returns
RTE_STATUS_OK when the tick was counted; RTE_STATUS_INVALID_PARAM when ticks is NULL; RTE_STATUS_INVALID_STATE before setup or after teardown; otherwise the status of the failed rte_mutex_lock_timed() (RTE_STATUS_TIMEOUT after AB_GP_CYCLE_TICKS_LOCK_TIMEOUT_MS; the tick is then not counted) or of the failed rte_mutex_unlock() (the tick is then counted)

Definition at line 30 of file ab_gp_cycle_ticks.c.

◆ ab_gp_cycle_ticks_take()

rte_status_t ab_gp_cycle_ticks_take ( ab_gp_cycle_ticks_t * ticks,
uint32_t * out_pending )

Returns every pending tick and clears the count, as one critical section (cycle thread side).

Parameters
ticksinstance to take from
out_pendingreceives the number of ticks posted since the previous take; 0 when none. Written only when the lock was acquired.
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM when ticks or out_pending is NULL; RTE_STATUS_INVALID_STATE before setup or after teardown; otherwise the status of the failed rte_mutex_lock_timed() (the count is then unchanged) or of the failed rte_mutex_unlock() (the count is then already taken and cleared)

Definition at line 57 of file ab_gp_cycle_ticks.c.

◆ ab_gp_cycle_ticks_teardown()

rte_status_t ab_gp_cycle_ticks_teardown ( ab_gp_cycle_ticks_t * ticks)

Destroys the mutex. Call only when no other task can post or take any more (the posting timer is destroyed). The instance is not set up afterwards, whatever the result.

Parameters
ticksinstance to tear down
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM when ticks is NULL; RTE_STATUS_INVALID_STATE when it is not set up; otherwise the status of rte_mutex_destroy()

Definition at line 83 of file ab_gp_cycle_ticks.c.