summaryrefslogtreecommitdiffstats
path: root/drivers/staging/wilc1000/wilc_event.h
blob: 94e0f7c0bed5db64430c62a95df277bc1620d634 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef __WILC_EVENT_H__
#define __WILC_EVENT_H__

/*!
 *  @file	wilc_event.h
 *  @brief	Event OS wrapper functionality
 *  @author	syounan
 *  @sa		wilc_oswrapper.h top level OS wrapper file
 *  @date	10 Oct 2010
 *  @version	1.0
 */

#ifndef CONFIG_WILC_EVENT_FEATURE
#error the feature CONFIG_WILC_EVENT_FEATURE must be supported to include this file
#endif


/*!
 *  @struct             tstrWILC_TimerAttrs
 *  @brief		Timer API options
 *  @author		syounan
 *  @date		10 Oct 2010
 *  @version		1.0
 */
typedef struct {
	/* a dummy member to avoid compiler errors*/
	WILC_Uint8 dummy;

	#ifdef CONFIG_WILC_EVENT_TIMEOUT
	/*!<
	 * Timeout for use with WILC_EventWait, 0 to return immediately and
	 * WILC_OS_INFINITY to wait forever. default is WILC_OS_INFINITY
	 */
	WILC_Uint32 u32TimeOut;
	#endif

} tstrWILC_EventAttrs;

/*!
 *  @brief	Fills the WILC_TimerAttrs with default parameters
 *  @param[out]	pstrAttrs structure to be filled
 *  @sa		WILC_TimerAttrs
 *  @author	syounan
 *  @date	10 Oct 2010
 *  @version	1.0
 */
static void WILC_EventFillDefault(tstrWILC_EventAttrs *pstrAttrs)
{
	#ifdef CONFIG_WILC_EVENT_TIMEOUT
	pstrAttrs->u32TimeOut = WILC_OS_INFINITY;
	#endif
}

/*!
 *  @brief	Creates a new Event
 *  @details	the Event is an object that allows a thread to wait until an external
 *                      event occuers, Event objects have 2 states, either TRIGGERED or
 *                      UNTRIGGERED
 *  @param[out]	pHandle handle to the newly created event object
 *  @param[in]	pstrAttrs Optional attributes, NULL for default
 *  @return	Error code indicating sucess/failure
 *  @sa		tstrWILC_EventAttrs
 *  @author	syounan
 *  @date	10 Oct 2010
 *  @version	1.0
 */
WILC_ErrNo WILC_EventCreate(WILC_EventHandle *pHandle, tstrWILC_EventAttrs *pstrAttrs);


/*!
 *  @brief	Destroys a given event
 *  @details	This will destroy a given event freeing any resources used by it
 *              if there are any thread blocked by the WILC_EventWait call the the
 *              behaviour is undefined
 *  @param[in]	pHandle handle to the event object
 *  @param[in]	pstrAttrs Optional attributes, NULL for default
 *  @return	Error code indicating sucess/failure
 *  @sa		tstrWILC_EventAttrs
 *  @author	syounan
 *  @date	10 Oct 2010
 *  @version	1.0
 */
WILC_ErrNo WILC_EventDestroy(WILC_EventHandle *pHandle,
			     tstrWILC_EventAttrs *pstrAttrs);

/*!
 *  @brief	Triggers a given event
 *  @details	This function will set the given event into the TRIGGERED state,
 *                      if the event is already in TRIGGERED, this function will have no
 *                      effect
 *  @param[in]	pHandle handle to the event object
 *  @param[in]	pstrAttrs Optional attributes, NULL for default
 *  @return	Error code indicating sucess/failure
 *  @sa		tstrWILC_EventAttrs
 *  @author	syounan
 *  @date	10 Oct 2010
 *  @version	1.0
 */
WILC_ErrNo WILC_EventTrigger(WILC_EventHandle *pHandle,
			     tstrWILC_EventAttrs *pstrAttrs);


/*!
 *  @brief	waits until a given event is triggered
 *  @details	This function will block the calling thread until the event becomes
 *                      in the TRIGGERED state. the call will retun the event into the
 *                      UNTRIGGERED	state upon completion
 *                      if multible threads are waiting on the same event at the same time,
 *                      behaviour is undefined
 *  @param[in]	pHandle handle to the event object
 *  @param[in]	pstrAttrs Optional attributes, NULL for default
 *  @return	Error code indicating sucess/failure
 *  @sa		tstrWILC_EventAttrs
 *  @author	syounan
 *  @date	10 Oct 2010
 *  @version	1.0
 */
WILC_ErrNo WILC_EventWait(WILC_EventHandle *pHandle,
			  tstrWILC_EventAttrs *pstrAttrs);



#endif