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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
/*
* CmdQueue_api.h
*
* Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
* 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 Texas Instruments 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 CmdQueue_api.h
* \brief CmdQueue api
*
* \see CmdQueue.c
*/
#ifndef _CMDQUEUE_API_H_
#define _CMDQUEUE_API_H_
#include "public_commands.h"
/*****************************************************************************
** Structures **
*****************************************************************************/
/* User Callback for Queue */
typedef void (*TCmdQueueInterrogateCb) (TI_HANDLE handle, TI_UINT16 status, void *pItrBuf);
/*****************************************************************************
** APIs definitions **
*****************************************************************************/
/*
* \brief Create the TCmdQueue object
*
* \param hOs - OS module object handle
* \return Handle to the created object
*
* \par Description
* Calling this function creates a CmdQueue object
*
* \sa cmdQueue_Destroy
*/
TI_HANDLE cmdQueue_Create (TI_HANDLE hOS);
/*
* \brief Destroys the cmdQueue object
*
* \param hCmdMbox - The object to free
* \return TI_OK
*
* \par Description
* Calling this function destroys the cmdQueue object
*
* \sa cmdQueue_Create
*/
TI_STATUS cmdQueue_Destroy (TI_HANDLE hCmdQueue);
/*
* \brief Configure the CmdQueue object
*
* \param hCmdQueue - Handle to CmdQueue
* \param hCmdMbox - Handle to CmdMbox
* \param hReport - Handle to report module
* \param hTwIf - Handle to TwIf
* \param hTimer - Handle to os timer
* \return TI_OK on success or TI_NOK on failure
*
* \par Description
*
* \sa
*/
TI_STATUS cmdQueue_Init (TI_HANDLE hCmdQueue,
TI_HANDLE hCmdMbox,
TI_HANDLE hReport,
TI_HANDLE hTwIf,
TI_HANDLE hTimer);
/*
* \brief Prepere the command queue for recovery.
*
* \param hCmdQueue - Handle to CmdQueue
* \return TI_OK
*
* \par Description
* Copy the queue nodes to a recovery list, in order handle
* the commands CB's after recovery has finished
*
* \sa cmdQueue_EndReconfig
*/
TI_STATUS cmdQueue_Restart (TI_HANDLE hCmdQueue);
/*
* \brief Call the stored CB to end the recovery of the MBox queue
*
* \param hCmdQueue - Handle to CmdQueue
* \return TI_OK
*
* \par Description
* Call the stored CB's with an error status
*
* \sa cmdQueue_StartReconfig
*/
TI_STATUS cmdQueue_EndReconfig (TI_HANDLE hCmdQueue);
/*
* \brief Register for a call back to be called when Command Complete occured and the CmdMboxCB was NULL
*
* \param hCmdQueue - Handle to CmdQueue
* \param fCb - The command's Cb function
* \param hCb - The command's Cb handle
* \return TI_OK
*
* \par Description
*
* \sa
*/
TI_STATUS cmdQueue_RegisterCmdCompleteGenericCb (TI_HANDLE hCmdQueue, void *fCb, TI_HANDLE hCb);
/*
* \brief Register for a call back to be called when an Error (Timeout) occurs
*
* \param hCmdQueue - Handle to CmdQueue
* \param fCb - The command's Cb function
* \param hCb - The command's Cb handle
* \return TI_OK
*
* \par Description
*
* \sa
*/
TI_STATUS cmdQueue_RegisterForErrorCb (TI_HANDLE hCmdQueue, void *fCb, TI_HANDLE hCb);
/*
* \brief Sends the command to the cmdMbox
*
* \param hCmdQueue - Handle to CmdQueue
* \param eMboxCmdType - The command type
* \param pMboxBuf - The command itself (parameters)
* \param uParamsLen - The command's length
* \param fCb - The command's Cb function
* \param hCb - The command's Cb handle
* \param pCb - Pointer to the results buffer (for interrogate commands)
* \return TI_OK on success or TI_NOK on failure
*
* \par Description
* Pushes the command to the command queue, which triggers the
* CmdQueue SM.
*
* \sa cmdQueue_Push
*/
TI_STATUS cmdQueue_SendCommand (TI_HANDLE hCmdQueue,
Command_e eMboxCmdType,
void *pMboxBuf,
TI_UINT32 uParamsLen,
void *fCb,
TI_HANDLE hCb,
void *pCb);
/*
* \brief Notify the CmdQueue SM on the result received.
*
* \param hCmdQueue - Handle to CmdQueue
* \return TI_OK on success or TI_NOK on failure
*
* \par Description
* Call the CmdQueue SM with CMDQUEUE_EVENT_COMPLETE
*
* \sa cmdQueue_SM
*/
TI_STATUS cmdQueue_ResultReceived (TI_HANDLE hCmdQueue);
/*
* \brief Returns maximum number of commands (ever) in TCmdQueue queue
*
* \param hCmdQueue - Handle to CmdQueue
* \return maximum number of commands (ever) in mailbox queue
*
* \par Description
* Used for debugging purposes
*
* \sa cmdQueue_Error
*/
TI_UINT32 cmdQueue_GetMaxNumberOfCommands (TI_HANDLE hCmdQueue);
/*
* \brief Enables the CmdMbox (on exit from init mode)
*
* \param hCmdQueue - Handle to CmdQueue
* \return TI_OK
*
* \par Description
*
* \sa cmdQueue_DisableMbox
*/
TI_STATUS cmdQueue_EnableMbox (TI_HANDLE hCmdQueue);
/*
* \brief Disables the CmdMbox (when stopping the driver)
*
* \param hCmdQueue - Handle to CmdQueue
* \return TI_OK
*
* \par Description
*
* \sa cmdQueue_EnableMbox
*/
TI_STATUS cmdQueue_DisableMbox (TI_HANDLE hCmdQueue);
/*
* \brief Called when a command timeout occur
*
* \param hCmdQueue - Handle to CmdQueue
* \return TI_OK
*
* \par Description
*
* \sa cmdQueue_Init, cmdMbox_TimeOut
*/
TI_STATUS cmdQueue_Error (TI_HANDLE hCmdQueue, TI_UINT32 command, TI_UINT32 status, void *param);
#ifdef TI_DBG
/*
* \brief Print the command queue & statistics
*
* \param hCmdQueue - Handle to CmdQueue
* \return void
*
* \par Description
* Used for debugging purposes
*
* \sa cmdQueue_PrintQueue
*/
void cmdQueue_Print (TI_HANDLE hCmdQueue);
/*
* \brief print the last uNumOfCmd commands
*
* \param hCmdQueue - Handle to CmdQueue
* \param uNumOfCmd - Number of commands to print
* \return void
*
* \par Description
* Used for debugging purposes
*
* \sa cmdQueue_Error
*/
void cmdQueue_PrintHistory (TI_HANDLE hCmdQueue, TI_UINT32 uNumOfCmd);
#endif /* TI_DBG */
#endif /* _CMDQUEUE_API_H_ */
|