dcl_wdt.h
11.5 KB
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* dcl_wdt.h
*
* Project:
* --------
* Maui
*
* Description:
* ------------
* Header file of DCL (Driver Common Layer) for WDT.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifdef DCL_DEFINITION_STRUCT
#ifndef __DCL_WDT_H_STRUCT__
#define __DCL_WDT_H_STRUCT__
#define DCL_WDT_RSTINTERVAL_VALUE 0xffa
/*******************************************************************************
* DCL_OPTIONS for WDT
*******************************************************************************/
#define WDT_OPTIONS
/*******************************************************************************
* DCL_CONFIGURE_T for WDT
*******************************************************************************/
#define WDT_CONFIGS
/*******************************************************************************
* DCL_EVENT for WDT
*******************************************************************************/
#ifdef __BUILD_DOM__
/*The WDT EVENT is part of DCL_EVENT_T Enum of dcl.h*/
/*WDT_EVENTS_T Define the event type that wdt support to register a callback function*/
typedef enum
{
EVENT_WDT_TIMEOUT = 0x00000001
}DCL_EVENT_T;
#else
#define WDT_EVENTS \
EVENT_WDT_TIMEOUT = 0x00000001,
#endif
/*******************************************************************************
* DCL_CTRL_CMD for WDT
*******************************************************************************/
#ifdef __BUILD_DOM__
/*The WDT Command values is part of DCL_CTRL_CMD_T Enum of dcl.h*/
/*DCL_CTRL_DATA_T Define the Control data structure for each module's command*/
typedef enum
{
WDT_CMD_ENABLE , /*to enable/disable WDT*/
WDT_CMD_SET_EXT_POL, /*to set ploarity of external pin when WDT expired */
WDT_CMD_SET_EXT_RESET, /*to generate an external watchdog reset signal when WDT expired*/
WDT_CMD_SET_VALUE, /*to set WDT count value*/
WDT_CMD_RESTART, /*to restart counter*/
WDT_CMD_DRV_RESET, /*to reset device*/
WDT_CMD_ABN_RESET, /*to reset device with abnormal flag set to indicate it is a abnormal reset*/
WDT_CMD_IRQ, /*to generate interrupt instead of resetting device*/
WDT_CMD_ENABLE_DEBUG,
}DCL_CTRL_CMD_T;
#else
#define WDT_CMDS \
WDT_CMD_ENABLE , \
WDT_CMD_SET_EXT_POL, \
WDT_CMD_SET_EXT_RESET, \
WDT_CMD_SET_VALUE, \
WDT_CMD_RESTART, \
WDT_CMD_DRV_RESET, \
WDT_CMD_ABN_RESET, \
WDT_CMD_IRQ, \
WDT_CMD_GET_RSTINTERVAL, \
WDT_CMD_ENABLE_DEBUG,
#endif
/*******************************************************************************
* DCL_CTRL_DATA_T: Define the Control data structure for each module's command
*******************************************************************************/
typedef struct
{
DCL_UINT16 rstInterval;
}WDT_CTRL_GET_RSTINTERVAL_T;
/* For WDT_CMD_ENABLE command. */
typedef struct
{
DCL_BOOL fgEnable; // TRUE: Enable WDT, FALSE: Disable WDT
} WDT_CTRL_ENABLE_T;
/* For WDT_CMD_SET_EXT_POL command. */
typedef struct
{
DCL_BOOL fgIOHigh; // TRUE: IO high, FALSE: IO low
} WDT_CTRL_SET_EXT_POL_T;
/* For WDT_CMD_SET_EXT_RESET command. */
typedef struct
{
DCL_BOOL fgEnable; // TRUE: Generate reset signal, FALSE: Do NOT generate reset signal
} WDT_CTRL_SET_EXT_RESET_T;
/* For WDT_CMD_SET_VALUE command. */
typedef struct
{
DCL_UINT16 u2Value; // Set WDT count down value, the unit is 15.6ms
} WDT_CTRL_SET_VALUE_T;
/* For WDT_CMD_RESTART command. */
// WDT_CMD_RESTART does NOT need parameters
/* For WDT_CMD_DRV_RESET command. */
// WDT_CMD_DRV_RESET does NOT need parameters
/* For WDT_CMD_ABN_RESET command. */
// WDT_CMD_ABN_RESET does NOT need parameters
/* For WDT_CMD_IRQ command. */
typedef struct
{
DCL_BOOL fgEnable; // TRUE: Enable interrupt instread of generating reset, FALSE: Do NOT enable interrupt
} WDT_CTRL_IRQ_T;
/*For WDT_CMD_ENABLE_DEBUG command*/
typedef struct
{
DCL_BOOL fgEnable; //enable or disable debug
}WDT_CTRL_DEBUG_T;
#ifdef __BUILD_DOM__
/*The GPIO command prarmeter data structure for each command. that's enum in in DCL_CTRL_DATA_T*/
typedef struct
{
WDT_CTRL_ENABLE_T rWDTEnable; /*data structure for WDT_CMD_ENABLE control command */
WDT_CTRL_SET_EXT_POL_T rWDTSetExtPol; /*data structure for WDT_CMD_SET_EXT_POL control command */
WDT_CTRL_SET_EXT_RESET_T rWDTSetExtReset; /*data structure for WDT_CMD_SET_EXT_RESET control command */
WDT_CTRL_SET_VALUE_T rWDTSetValue; /*data structure for WDT_CMD_SET_VALUE control command */
WDT_CTRL_IRQ_T rWDTIRQ; /*data structure for WDT_CMD_IRQ control command */
WDT_CTRL_DEBUG_T rWDTDebug; /*data structure for WDT_CMD_ENABLE_DEBUG control command */
}DCL_CTRL_DATA_T;
#else
#define WDT_CTRLS \
WDT_CTRL_ENABLE_T rWDTEnable; \
WDT_CTRL_SET_EXT_POL_T rWDTSetExtPol; \
WDT_CTRL_SET_EXT_RESET_T rWDTSetExtReset; \
WDT_CTRL_SET_VALUE_T rWDTSetValue; \
WDT_CTRL_IRQ_T rWDTIRQ; \
WDT_CTRL_DEBUG_T rWDTDebug; \
WDT_CTRL_GET_RSTINTERVAL_T rRstValue;
#endif
#endif // #ifndef __DCL_I2C_H_STRUCT__
#endif // #ifdef DCL_DEFINITION_STRUCT
#ifdef DCL_DEFINITION_PROTOTYPE
#ifndef __DCL_WDT_H_PROTOTYPE__
#define __DCL_WDT_H_PROTOTYPE__
/*************************************************************************
* FUNCTION
* DclWDT_Initialize
*
* DESCRIPTION
* This function is to initialize WDT module
*
* PARAMETERS
* None
*
* RETURN VALUES
* STATUS_OK
*
*************************************************************************/
extern DCL_STATUS DclWDT_Initialize(void);
/*************************************************************************
* FUNCTION
* DclWDT_Open
*
* DESCRIPTION
* This function is to open the WDT module and return a handle
*
* PARAMETERS
* dev: only valid for DCL_WDT
* flags: no sepcial flags is needed. Please use FLAGS_NONE
*
* RETURN VALUES
* DCL_HANDLE_INVALID: Open failed.
* other value: a valid handle
*
*************************************************************************/
extern DCL_HANDLE DclWDT_Open(DCL_DEV dev, DCL_FLAGS flags);
/*************************************************************************
* FUNCTION
* DclWDT_ReadData
*
* DESCRIPTION
* This function is not supported for the WDT module now.
*
* PARAMETERS
* N/A
*
* RETURN VALUES
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclWDT_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
/*************************************************************************
* FUNCTION
* DclWDT_WriteData
*
* DESCRIPTION
* This function is not supported for the WDT module now.
*
* PARAMETERS
* N/A
*
* RETURN VALUES
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclWDT_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
/*************************************************************************
* FUNCTION
* DclWDT_Configure
*
* DESCRIPTION
* This function is not supported for the WDT module now.
*
* PARAMETERS
* N/A
*
* RETURN VALUES
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclWDT_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
/*************************************************************************
* FUNCTION
* DclWDT_RegisterCallback
*
* DESCRIPTION
* This function is to set callback function for the WDT module.
*
* PARAMETERS
* handle: the returned handle value of DclWDT_Open
* event: Supported events:
* EVENT_WDT_TIMEOUT: Watch dog time out interrupt
* callback: the callback function for registered events
*
* RETURN VALUES
* STATUS_OK: Successfully register the callback function.
* STATUS_INVALID_DCL_HANDLE: It's a invalid handle.
* STATUS_NOT_OPENED: The module has not been opened.
* STATUS_INVALID_EVENT: The event parameter is invalid.
*
*************************************************************************/
extern DCL_STATUS DclWDT_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
/*************************************************************************
* FUNCTION
* DclWDT_Control
*
* DESCRIPTION
* This function is to send command to control the WDT module.
*
* PARAMETERS
* handle: The handle value returned from DclWDT_Open
* cmd: a control command for WDT module
* 1. WDT_CMD_ENABLE: to enable/disable WDT
* 2. WDT_CMD_SET_EXT_POL: to set ploarity of external pin when WDT expired
* 3. WDT_CMD_SET_EXT_RESET: to generate an external watchdog reset signal when WDT expired
* 4. WDT_CMD_SET_VALUE: to set WDT count value
* 5 WDT_CMD_RESTART: to restart counter
* 6. WDT_CMD_DRV_RESET: to reset device
* 7. WDT_CMD_ABN_RESET: to reset device with abnormal flag set to indicate it is a abnormal reset
* 8. WDT_CMD_IRQ: to generate interrupt instead of reseting device
* data: The data of the control command
* 1. WDT_CMD_ENABLE: pointer to a WDT_CTRL_ENABLE_T structure
* 2. WDT_CMD_SET_EXT_POL: pointer to a WDT_CTRL_SET_EXT_POL_T structure
* 3. WDT_CMD_SET_EXT_RESET: pointer to a WDT_CTRL_SET_EXT_RESET_T structure
* 4. WDT_CMD_SET_VALUE: pointer to a WDT_CTRL_SET_VALUE_T structure
* 5 WDT_CMD_RESTART: A null pointer
* 6. WDT_CMD_DRV_RESET: A null pointer
* 7. WDT_CMD_ABN_RESET: A null pointer
* 8. WDT_CMD_IRQ: pointer to a WDT_CTRL_IRQ_T structure
*
* RETURN VALUES
* STATUS_OK: command is executed successfully.
* STATUS_FAIL: command is failed.
* STATUS_INVALID_CMD: It's a invalid command.
*
*************************************************************************/
extern DCL_STATUS DclWDT_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
/*************************************************************************
* FUNCTION
* DclWDT_Close
*
* DESCRIPTION
* This function is to close the WDT module.
*
* PARAMETERS
* handle: the returned handle value of DclWDT_Open
*
* RETURNS
* STATUS_OK
*
*************************************************************************/
extern DCL_STATUS DclWDT_Close(DCL_HANDLE handle);
#endif // #ifndef __DCL_WDT_H_PROTOTYPE__
#endif // #ifdef DCL_DEFINITION_PROTOTYPE