SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
Events
cy_rslt_t cy_rtos_event_init (cy_event_t *event)
cy_rslt_t cy_rtos_event_setbits (const cy_event_t *event, uint32_t bits)
cy_rslt_t cy_rtos_event_clearbits (const cy_event_t *event, uint32_t bits)
cy_rslt_t cy_rtos_event_getbits (const cy_event_t *event, uint32_t *bits)
cy_rslt_t cy_rtos_event_waitbits (const cy_event_t *event, uint32_t *bits, bool clear, bool all, cy_time_t timeout_ms)
cy_rslt_t cy_rtos_event_deinit (cy_event_t *event)
#define cy_rtos_init_event(event)
#define cy_rtos_setbits_event(event, bits, in_isr)
#define cy_rtos_clearbits_event(event, bits, in_isr)
#define cy_rtos_getbits_event(event, bits)
#define cy_rtos_waitbits_event(event, bits, clear, all, timeout_ms)
#define cy_rtos_deinit_event(event)

Detailed Description

APIs for acquiring and working with Events.

Macro Definition Documentation

◆ cy_rtos_clearbits_event

#define cy_rtos_clearbits_event ( event,
bits,
in_isr )
Value:
cy_rslt_t cy_rtos_event_clearbits(const cy_event_t *event, uint32_t bits)

Clear the event flag bits

This function clears bits in the event.

Parameters
[in]eventPointer to the event handle
[in]bitsAny bits set in this value, will be cleared in the event.
[in]in_isrif true, this is called from an ISR, otherwise from a thread
Returns
The status of the clear flags request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM, CY_RTOS_GENERAL_ERROR].
Specific for kernel:

Definition at line 1382 of file cyabs_rtos.h.

◆ cy_rtos_deinit_event

#define cy_rtos_deinit_event ( event)
Value:
cy_rslt_t cy_rtos_event_deinit(cy_event_t *event)

Deinitialize a event.

This function frees the resources associated with an event.

Parameters
[in]eventPointer to the event handle
Returns
The status of the deletion request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM].
Specific for kernel:

Definition at line 1434 of file cyabs_rtos.h.

◆ cy_rtos_getbits_event

#define cy_rtos_getbits_event ( event,
bits )
Value:
cy_rslt_t cy_rtos_event_getbits(const cy_event_t *event, uint32_t *bits)

Get the event bits.

Returns the current bits for the event.

Parameters
[in]eventPointer to the event handle
[out]bitspointer to receive the value of the event flags
Returns
The status of the get request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM].
Specific for kernel:

Definition at line 1396 of file cyabs_rtos.h.

◆ cy_rtos_init_event

#define cy_rtos_init_event ( event)
Value:
cy_rslt_t cy_rtos_event_init(cy_event_t *event)

Create an event.

This is an event which can be used to signal a set of threads with a 32 bit data element.

Parameters
[in,out]eventPointer to the event handle to be initialized
Returns
The status of the event initialization request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM].
Specific for kernel:

Definition at line 1349 of file cyabs_rtos.h.

◆ cy_rtos_setbits_event

#define cy_rtos_setbits_event ( event,
bits,
in_isr )
Value:
cy_rslt_t cy_rtos_event_setbits(const cy_event_t *event, uint32_t bits)

Set the event flag bits.

This is an event which can be used to signal a set of threads with a 32 bit data element. Any threads waiting on this event are released

Parameters
[in]eventPointer to the event handle
[in]bitsThe value of the 32 bit flags
[in]in_isrIf true, this is called from an ISR, otherwise from a thread
Returns
The status of the set request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM, CY_RTOS_GENERAL_ERROR].
Specific for kernel:

Definition at line 1365 of file cyabs_rtos.h.

◆ cy_rtos_waitbits_event

#define cy_rtos_waitbits_event ( event,
bits,
clear,
all,
timeout_ms )
Value:
cy_rtos_event_waitbits(event, bits, clear, all, timeout_ms)
cy_rslt_t cy_rtos_event_waitbits(const cy_event_t *event, uint32_t *bits, bool clear, bool all, cy_time_t timeout_ms)

Wait for the event and return bits.

Waits for the event to be set and then returns the bits associated with the event, or waits for the given timeout period.

Note
This function returns if any bit in the set is set.
Parameters
[in]eventPointer to the event handle
[in,out]bitspointer to receive the value of the event flags
[in]clearif true, clear any bits set that cause the wait to return if false, do not clear bits
[in]allif true, all bits in the initial bits value must be set to return if false, any one bit in the initial bits value must be set to return
[in]timeout_msThe amount of time to wait in milliseconds
Returns
The status of the wait for event request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM, CY_RTOS_TIMEOUT].
Specific for kernel:

Definition at line 1418 of file cyabs_rtos.h.

Function Documentation

◆ cy_rtos_event_clearbits()

cy_rslt_t cy_rtos_event_clearbits ( const cy_event_t * event,
uint32_t bits )

Clear the event flag bits

This function clears bits in the event.

Parameters
[in]eventPointer to the event handle
[in]bitsAny bits set in this value, will be cleared in the event.
Returns
The status of the clear flags request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM, CY_RTOS_GENERAL_ERROR].
Specific for kernel:

Definition at line 1104 of file cyabs_rtos_stk.cpp.

1105{
1106 if (!IsValid(event))
1107 {
1108 return CY_RTOS_BAD_PARAM;
1109 }
1110
1111 if (bits != 0U)
1112 {
1113 (void)EventOf(event)->Clear(static_cast<uint64_t>(bits));
1114 }
1115
1116 return CY_RSLT_SUCCESS;
1117}
#define CY_RTOS_BAD_PARAM
Definition cyabs_rtos.h:96

References CY_RTOS_BAD_PARAM.

◆ cy_rtos_event_deinit()

cy_rslt_t cy_rtos_event_deinit ( cy_event_t * event)

Deinitialize a event.

This function frees the resources associated with an event.

Parameters
[in]eventPointer to the event handle
Returns
The status of the deletion request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM].
Specific for kernel:

Definition at line 1167 of file cyabs_rtos_stk.cpp.

1168{
1169 if (!IsValid(event))
1170 {
1171 return CY_RTOS_BAD_PARAM;
1172 }
1173
1174 event->id = 0U;
1175 EventOf(event)->~EventFlags(); // STK contract: no thread may be waiting on it
1176
1177 return CY_RSLT_SUCCESS;
1178}

References CY_RTOS_BAD_PARAM.

◆ cy_rtos_event_getbits()

cy_rslt_t cy_rtos_event_getbits ( const cy_event_t * event,
uint32_t * bits )

Get the event bits.

Returns the current bits for the event.

Parameters
[in]eventPointer to the event handle
[out]bitspointer to receive the value of the event flags
Returns
The status of the get request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM].
Specific for kernel:

Definition at line 1119 of file cyabs_rtos_stk.cpp.

1120{
1121 if (!IsValid(event) || (bits == nullptr))
1122 {
1123 return CY_RTOS_BAD_PARAM;
1124 }
1125
1126 *bits = static_cast<uint32_t>(EventOf(event)->Get());
1127
1128 return CY_RSLT_SUCCESS;
1129}

References CY_RTOS_BAD_PARAM.

◆ cy_rtos_event_init()

cy_rslt_t cy_rtos_event_init ( cy_event_t * event)

Create an event.

This is an event which can be used to signal a set of threads with a 32 bit data element.

Parameters
[in,out]eventPointer to the event handle to be initialized
Returns
The status of the event initialization request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM].
Specific for kernel:
Examples
blinky_c-cyabs_rtos/example.c.

Definition at line 1076 of file cyabs_rtos_stk.cpp.

1077{
1078 if (event == nullptr)
1079 {
1080 return CY_RTOS_BAD_PARAM;
1081 }
1082
1083 (void)new (static_cast<void *>(event->storage)) EventFlags(0U);
1084 event->id = ID_EVENT;
1085
1086 return CY_RSLT_SUCCESS;
1087}
EventFlagsT< uint32_t > EventFlags
Default event flags group with a 32-bit flags word (31 usable flags, bit 31 reserved).
uint64_t storage[(9U)]

References CY_RTOS_BAD_PARAM, and cy_event_t::storage.

Referenced by app_init().

Here is the caller graph for this function:

◆ cy_rtos_event_setbits()

cy_rslt_t cy_rtos_event_setbits ( const cy_event_t * event,
uint32_t bits )

Set the event flag bits.

This is an event which can be used to signal a set of threads with a 32 bit data element. Any threads waiting on this event are released

Parameters
[in]eventPointer to the event handle
[in]bitsThe value of the 32 bit flags
Returns
The status of the set request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM, CY_RTOS_GENERAL_ERROR].
Specific for kernel:
Examples
blinky_c-cyabs_rtos/example.c.

Definition at line 1089 of file cyabs_rtos_stk.cpp.

1090{
1091 if (!IsValid(event))
1092 {
1093 return CY_RTOS_BAD_PARAM;
1094 }
1095
1096 if (bits != 0U)
1097 {
1098 (void)EventOf(event)->Set(static_cast<uint64_t>(bits)); // ISR-safe, wakes the waiters
1099 }
1100
1101 return CY_RSLT_SUCCESS;
1102}

References CY_RTOS_BAD_PARAM.

Referenced by app_main(), and signal_func().

Here is the caller graph for this function:

◆ cy_rtos_event_waitbits()

cy_rslt_t cy_rtos_event_waitbits ( const cy_event_t * event,
uint32_t * bits,
bool clear,
bool all,
cy_time_t timeout_ms )

Wait for the event and return bits.

Waits for the event to be set and then returns the bits associated with the event, or waits for the given timeout period.

Note
This function returns if any bit in the set is set.
Parameters
[in]eventPointer to the event handle
[in,out]bitspointer to receive the value of the event flags
[in]clearif true, clear any bits set that cause the wait to return if false, do not clear bits
[in]allif true, all bits in the initial bits value must be set to return if false, any one bit in the initial bits value must be set to return
[in]timeout_msThe amount of time to wait in milliseconds
Returns
The status of the wait for event request. Same across all RTOS kernels [CY_RSLT_SUCCESS, CY_RTOS_BAD_PARAM, CY_RTOS_TIMEOUT].
Specific for kernel:
Examples
blinky_c-cyabs_rtos/example.c.

Definition at line 1131 of file cyabs_rtos_stk.cpp.

1133{
1134 if (!IsValid(event) || (bits == nullptr) || (*bits == 0U))
1135 {
1136 return CY_RTOS_BAD_PARAM;
1137 }
1138
1139 stk::Timeout timeout;
1140 cy_rslt_t error = CY_RSLT_SUCCESS;
1141
1142 if (!PrepareTimeout(timeout_ms, timeout, error))
1143 {
1144 return error;
1145 }
1146
1147 uint32_t options = (all ? EventFlags::OPT_WAIT_ALL : EventFlags::OPT_WAIT_ANY);
1148 if (!clear)
1149 {
1150 options |= EventFlags::OPT_NO_CLEAR;
1151 }
1152
1153 uint64_t actual = 0U;
1154
1155 const cy_rslt_t result = WaitResultToCy(
1156 EventOf(event)->WaitEx(static_cast<uint64_t>(*bits), options, timeout, actual), CY_RTOS_TIMEOUT);
1157
1158 if (result == CY_RSLT_SUCCESS)
1159 {
1160 // the whole flags word at the moment the request was satisfied (before auto-clear)
1161 *bits = static_cast<uint32_t>(actual);
1162 }
1163
1164 return result;
1165}
#define CY_RTOS_TIMEOUT
Definition cyabs_rtos.h:87
int32_t Timeout
Timeout time (ticks).
Definition stk_common.h:216

References CY_RTOS_BAD_PARAM, and CY_RTOS_TIMEOUT.

Referenced by wait_flag().

Here is the caller graph for this function: