AM62x MCU+ SDK  10.01.00
Event

Features Supported

  • APIs to construct and destruct Events
  • APIs to set, get or clear bits and wait for bits

Features NOT Supported

  • These APIs are not implemented for no-RTOS. Error will be returned if these APIs called using no-RTOS.

Important Usage Guidelines

  • EventP_waitBits should not be called within ISR context. It can be called from task context.
  • Setting or clearing the Event bits is a non-deterministic operation and FreeRTOS does not allow non-deterministic operations to be performed in interrupts or from critical sections. If EventP_setBits or EventP_clearBits is called from an ISR, a message is sent to RTOS daemon task to perform the operation in the context of daemon task. If the set or clear operation is required to be completed immediately, then the priority of RTOS daemon task must be higher than the priority of task waiting for the Event bits. The priority of RTOS daemon task is set by the configTIMER_TASK_PRIORITY in FreeRTOSConfig.h file.
  • The actual current value of Event bits returned from EventP_waitBits and EventP_getBits can be different from returned value if an interrupt or a higher priority task modifies the value between the calling task leaving blocked state and exiting this API.

Example Usage

Include the below file to access the APIs

Example usage to define an Event

/* Event objects, typically these are global's */
EventP_Object gMyEvent;
/* Event bits */
/* Event bit mask upto 24 bits */
#define EVENT_BIT_PING (0x000001u)
#define EVENT_BIT_PONG (0x000002u)

Example usage to create an Event

Example usage to set and wait for bits across two tasks

void task1(void *args)
{
int32_t status;
uint32_t eventBits;
/* Set PING bit from task1 */
status = EventP_setBits(&gMyEvent, EVENT_BIT_PING);
/* Reading the Event Bits */
status = EventP_getBits(&gMyEvent, &eventBits);
/* Wait for PONG but to be set from task2. PING bit was already set */
status = EventP_waitBits(&gMyEvent, (EVENT_BIT_PING | EVENT_BIT_PONG), 0, 1, SystemP_WAIT_FOREVER, &eventBits);
/* Clearing the PING and PONG bits */
status = EventP_clearBits(&gMyEvent, (EVENT_BIT_PING | EVENT_BIT_PONG));
}
void task2(void *args)
{
int32_t status;
uint32_t eventBits;
/* Wait for PING but to be set from task1*/
status = EventP_waitBits(&gMyEvent, EVENT_BIT_PING, 0, 1, SystemP_WAIT_FOREVER, &eventBits);
/* Set PONG bit from task2 */
status = EventP_setBits(&gMyEvent, EVENT_BIT_PONG);
}

API

APIs for Event

EventP_clearBits
int32_t EventP_clearBits(EventP_Object *obj, uint32_t bitsToClear)
Clear a bit or multiple bits in the Event bits.
status
uint32_t status
Definition: tisci_lpm.h:1
EventP_waitBits
int32_t EventP_waitBits(EventP_Object *obj, uint32_t bitsToWaitFor, uint8_t clearOnExit, uint8_t waitForAll, uint32_t timeToWaitInTicks, uint32_t *eventBits)
Read the Event bits, after optionally waiting for a bit or multiple bits to be set.
SystemP_WAIT_FOREVER
#define SystemP_WAIT_FOREVER
Value to use when needing a timeout of infinity or wait forver until resource is available.
Definition: SystemP.h:83
EventP_getBits
int32_t EventP_getBits(EventP_Object *obj, uint32_t *eventBits)
Getting the current value of Event bits.
EventP_Object
Opaque Event object used with the Event APIs.
Definition: EventP.h:60
SystemP_SUCCESS
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
EventP_construct
int32_t EventP_construct(EventP_Object *obj)
Create an Event object.
EventP_setBits
int32_t EventP_setBits(EventP_Object *obj, uint32_t bitsToSet)
Setting a bit or multiple bits in the Event bits.
DebugP.h
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:175
EventP.h