summaryrefslogtreecommitdiffstats
blob: cda0bb5f9bc952148fb2207798618247b4a7fbdc (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
 * Copyright (c) 2018, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  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.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * 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.
 */
/** ============================================================================
 *  @file       EventP.h
 *
 *  @brief      Event module for the RTOS Porting Interface
 *
 *
 *  ============================================================================
 */

#ifndef ti_osal_EventP__include
#define ti_osal_EventP__include

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <ti/sysbios/knl/Event.h>

/*
 * Pre-defined Event Ids. Event_Ids are provided to simplify the specification
 * of andMasks and orMasks arguments to Event_pend().
 * Since each Event_Id is a bitmask composed of only a single bit,
 * a group of Event_Ids within an andMask or orMask can be indicated by simply adding them together.
 */

/*!
*  @brief    Event ID 0
*/
#define EventP_ID_NONE     Event_Id_NONE
/*!
 *  @brief    Event ID 0
 */
#define EventP_ID_00        Event_Id_00
/*!
 *  @brief    Event ID 1
 */
#define EventP_ID_01        Event_Id_01
/*!
 *  @brief    Event ID 2
 */
#define EventP_ID_02        Event_Id_02
/*!
 *  @brief    Event ID 3
 */
#define EventP_ID_03        Event_Id_03
/*!
 *  @brief    Event ID 4
 */
#define EventP_ID_04        Event_Id_04
/*!
 *  @brief    Event ID 5
 */
#define EventP_ID_05        Event_Id_05
/*!
 *  @brief    Event ID 6
 */
#define EventP_ID_06        Event_Id_06
/*!
 *  @brief    Event ID 7
 */
#define EventP_ID_07        Event_Id_07
/*!
 *  @brief    Event ID 8
 */
#define EventP_ID_08        Event_Id_08
/*!
 *  @brief    Event ID 9
 */
#define EventP_ID_09        Event_Id_09
/*!
 *  @brief    Event ID 10
 */
#define EventP_ID_10        Event_Id_10

/*!
 *  @brief    Status codes for EventP APIs
 */
typedef enum EventP_Status_e
{
    /*! API completed successfully */
    EventP_OK         = 0,
    /*! API failed */
    EventP_FAILURE    = (-(int32_t)1)
} EventP_Status;

/*!
 *  @brief    Wait forever define
 */
#define EventP_WAIT_FOREVER (~((uint32_t)0U))

/*!
 *  @brief    No wait define
 */
#define EventP_NO_WAIT       ((uint32_t)0U)


/*!
 *  @brief    Opaque client reference to an instance of a EventP
 *
 *  A EventP_Handle returned from the ::EventP_create represents that
 *  instance and  is used in the other instance based functions
 */
typedef  void *EventP_Handle;

/*!
 *  @brief    Basic EventP Parameters
 *
 *  Structure that contains the parameters are passed into ::EventP_create
 *  when creating a EventP instance.
 */
typedef struct EventP_Params_s
{
    void *instance;          /*!< Name of the task instance.                  */
} EventP_Params;

/*!
 *  @brief  Function to create an event.
 *
 *  @param  params  Pointer to the instance configuration parameters.
 *
 *  @return A EventP_Handle on success or a NULL on an error
 */
extern EventP_Handle EventP_create(EventP_Params *params);

/*!
 *  @brief  Function to delete an event.
 *
 *  @param  handle  A EventP_Handle returned from EventP_create
 */
extern void EventP_delete(EventP_Handle *handle);

/*!
 *  @brief  Initialize params structure to default values.
 *
 *  @param params  Pointer to the instance configuration parameters.
 */
extern void EventP_Params_init(EventP_Params *params);

/*!
 *  @brief  Function for Event Pend
 *
 *  @param handle  EventP handle.created via EventP_create API
 *  @param andMask return from pend() when ALL of these events have occurred
 *  @param orMask  return from pend() when ANY of these events have occurred
 *  @param timeout return from pend() after this many system time units
 *  @return All consumed events or zero if timeout
 */
extern uint32_t EventP_pend(EventP_Handle handle, uint32_t andMask,
                            uint32_t orMask, uint32_t timeout);

/*!
 *  @brief  Function for Event Post.
 *
 *  @param handle  A EventP_Handle returned from EventP_create.
 *  @param eventMask  mask of eventIds to post (must be non-zero)
 */
extern void EventP_post(EventP_Handle handle, uint32_t eventMask);

/*!
 *  @brief  Function for Event Post.
 *
 *  @param handle  A EventP_Handle returned from EventP_create.
 *  @return All un-consumed events posted to the event
 */
extern uint32_t EventP_getPostedEvents(EventP_Handle handle);

#ifdef __cplusplus
}
#endif

#endif /* ti_osal_EventP__include */