cocoOS  5.0.1
os_event.c File Reference
#include "cocoos.h"
#include "stdarg.h"

Data Structures

struct  Event_t
 

Functions

void os_event_init (void)
 
Evt_t event_create (void)
 
uint8_t event_signaling_taskId_get (Evt_t ev)
 
Evt_t event_last_signaled_get (void)
 
void os_wait_event (uint8_t tid, Evt_t ev, uint8_t waitSingleEvent, uint16_t timeout)
 
void os_signal_event (Evt_t ev)
 
void os_event_set_signaling_tid (Evt_t ev, uint8_t tid)
 
void os_wait_multiple (uint8_t waitAll,...)
 

Detailed Description

Copyright (c) 2012 Peter Eckstrand

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file is part of the cocoOS operating system. Author: Peter Eckstrand info@.nosp@m.coco.nosp@m.os.ne.nosp@m.t Event source file

Function Documentation

Evt_t event_create ( void  )

Creates an event.

Returns
Returns an event.
Remarks
Usage:
An event is created by declaring a variable of type Evt_t and then assigning the event_create() return value to that variable.
1 Evt_t myEvent;
2 myEvent = event_create();
Evt_t event_last_signaled_get ( void  )

Gets the last signaled event

Returns
Last signaled event
Remarks
Usage:
Used when waiting for multiple events, to find out which event was signaled.
1 event_wait_multiple(0, event1, event2);
2 Evt_t lastEvt = event_last_signaled_get();
3 if ( lastEvt == event1 ) {
4  ...
5 }
uint8_t event_signaling_taskId_get ( Evt_t  ev)

Gets the Task Id of the task that signaled the event.

Parameters
evevent
Returns
Id of task that signaled the event.
NO_TID if a timeout occurred before the event was signaled.
Remarks
Usage:
A task can make a call to this function when it has resumed execution after waiting for an event to find out which other task signaled the event.
1 event_wait(event);
2 signalingTask = event_signaling_taskId_get(event);
3 if ( signalingTask == Task2_id ) {
4  ...
5 }