VSF Documented
vsf_template_wdt.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_TEMPLATE_WDT_H__
19#define __VSF_TEMPLATE_WDT_H__
20
21/*============================ INCLUDES ======================================*/
22
24#include "hal/arch/vsf_arch.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ MACROS ========================================*/
31
39#ifndef VSF_WDT_CFG_MULTI_CLASS
40# define VSF_WDT_CFG_MULTI_CLASS ENABLED
41#endif
42
43#if defined(VSF_HW_WDT_COUNT) && !defined(VSF_HW_WDT_MASK)
51# define VSF_HW_WDT_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_WDT_COUNT)
52#endif
53
54#if defined(VSF_HW_WDT_MASK) && !defined(VSF_HW_WDT_COUNT)
62# define VSF_HW_WDT_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_WDT_MASK)
63#endif
64
86#ifndef VSF_WDT_CFG_PREFIX
87# if (VSF_WDT_CFG_MULTI_CLASS == DISABLED) && defined(VSF_HW_WDT_COUNT) && (VSF_HW_WDT_COUNT != 0)
88# define VSF_WDT_CFG_PREFIX vsf_hw
89# else
90# define VSF_WDT_CFG_PREFIX vsf
91# endif
92#endif
93
104#ifndef VSF_WDT_CFG_FUNCTION_RENAME
105# define VSF_WDT_CFG_FUNCTION_RENAME ENABLED
106#endif
107
117#ifndef VSF_WDT_CFG_REIMPLEMENT_TYPE_MODE
118# define VSF_WDT_CFG_REIMPLEMENT_TYPE_MODE DISABLED
119#endif
120
133#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
134# define VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG DISABLED
135#endif
136
149#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
150# define VSF_WDT_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
151#endif
152
163#ifndef VSF_WDT_CFG_INHERIT_HAL_CAPABILITY
164# define VSF_WDT_CFG_INHERIT_HAL_CAPABILITY ENABLED
165#endif
166
167/*============================ MACROFIED FUNCTIONS ===========================*/
168
178#define VSF_WDT_APIS(__prefix) \
179 __VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, wdt, init, VSF_MCONNECT(__prefix, _wdt_t) *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr) \
180 __VSF_HAL_TEMPLATE_API(__prefix, void, wdt, fini, VSF_MCONNECT(__prefix, _wdt_t) *wdt_ptr) \
181 __VSF_HAL_TEMPLATE_API(__prefix, fsm_rt_t, wdt, enable, VSF_MCONNECT(__prefix, _wdt_t) *wdt_ptr) \
182 __VSF_HAL_TEMPLATE_API(__prefix, fsm_rt_t, wdt, disable, VSF_MCONNECT(__prefix, _wdt_t) *wdt_ptr) \
183 __VSF_HAL_TEMPLATE_API(__prefix, vsf_wdt_capability_t, wdt, capability, VSF_MCONNECT(__prefix, _wdt_t) *wdt_ptr) \
184 __VSF_HAL_TEMPLATE_API(__prefix, void, wdt, feed, VSF_MCONNECT(__prefix, _wdt_t) *wdt_ptr)
185
186/*============================ TYPES =========================================*/
187
188#if VSF_WDT_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
224typedef enum vsf_wdt_mode_t {
227
231
232 /*
235 VSF_WDT_MODE_PRESCALER_1 = (0 << 2),
236 VSF_WDT_MODE_PRESCALER_2 = (1 << 2),
237 VSF_WDT_MODE_PRESCALER_4 = (2 << 2),
238 #define VSF_WDT_MODE_PRESCALER_8 VSF_WDT_MODE_PRESCALER_8
239 #define VSF_WDT_MODE_PRESCALER_1 VSF_WDT_MODE_PRESCALER_1
240 #define VSF_WDT_MODE_PRESCALER_2 VSF_WDT_MODE_PRESCALER_2
241 #define VSF_WDT_MODE_PRESCALER_4 VSF_WDT_MODE_PRESCALER_4
242 #define VSF_WDT_MODE_PRESCALER_MASK (0x03 << 2)
243 */
245#endif
246
253enum {
258
259#ifndef VSF_WDT_MODE_RESET_MASK
265#endif
266
267#ifndef VSF_WDT_MODE_ALL_BITS_MASK
270#ifdef VSF_WDT_MODE_PRESCALER_MASK
271 | VSF_WDT_MODE_PRESCALER_MASK
272#endif
273#endif
275
276#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
281typedef struct vsf_wdt_t vsf_wdt_t;
282
291typedef void vsf_wdt_isr_handler_t(void *target_ptr, vsf_wdt_t *wdt_ptr);
292
297typedef struct vsf_wdt_isr_t {
302
310typedef struct vsf_wdt_cfg_t {
316#endif
317
318#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
329typedef struct vsf_wdt_capability_t {
330#if VSF_WDT_CFG_INHERIT_HAL_CAPABILITY == ENABLED
332#endif
333
342#endif
343
348typedef struct vsf_wdt_op_t {
350#undef __VSF_HAL_TEMPLATE_API
351#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
353
354 VSF_WDT_APIS(vsf)
356
357#if VSF_WDT_CFG_MULTI_CLASS == ENABLED
362struct vsf_wdt_t {
364};
365#endif
366
367/*============================ PROTOTYPES ====================================*/
368
388extern vsf_err_t vsf_wdt_init(vsf_wdt_t *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr);
389
401extern void vsf_wdt_fini(vsf_wdt_t *wdt_ptr);
402
414extern fsm_rt_t vsf_wdt_enable(vsf_wdt_t *wdt_ptr);
415
427extern fsm_rt_t vsf_wdt_disable(vsf_wdt_t *wdt_ptr);
428
441
451extern void vsf_wdt_feed(vsf_wdt_t *wdt_ptr);
452
453/*============================ MACROFIED FUNCTIONS ===========================*/
454
456#if VSF_WDT_CFG_FUNCTION_RENAME == ENABLED
457# define __vsf_wdt_t VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_t)
458# define vsf_wdt_init(__WDT, ...) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_init) ((__vsf_wdt_t *)(__WDT), ##__VA_ARGS__)
459# define vsf_wdt_fini(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_fini) ((__vsf_wdt_t *)(__WDT))
460# define vsf_wdt_enable(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_enable) ((__vsf_wdt_t *)(__WDT))
461# define vsf_wdt_disable(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_disable) ((__vsf_wdt_t *)(__WDT))
462# define vsf_wdt_capability(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_capability) ((__vsf_wdt_t *)(__WDT))
463# define vsf_wdt_feed(__WDT, ...) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_feed) ((__vsf_wdt_t *)(__WDT))
464#endif
466
467#ifdef __cplusplus
468}
469#endif
470
471#endif /*__VSF_TEMPLATE_WDT_H__*/
vsf_err_t
Definition __type.h:42
vsf_wdt_mode_t
Definition wdt.h:31
vsf_arch_prio_t
Definition cortex_a_generic.h:88
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_hal_driver.h:203
Predefined VSF WDT capability that can be reimplemented in specific hal drivers. The vsf_wdt_capabili...
Definition vsf_template_wdt.h:329
uint8_t support_reset_soc
Indicates if SoC reset mode is supported.
Definition vsf_template_wdt.h:337
uint8_t support_disable
Indicates if WDT can be disabled after startup.
Definition vsf_template_wdt.h:338
uint8_t support_early_wakeup
Definition wdt.h:160
uint8_t support_reset_cpu
Indicates if core reset mode is supported.
Definition vsf_template_wdt.h:336
uint32_t max_timeout_ms
Maximum timeout in milliseconds.
Definition vsf_template_wdt.h:340
inherit(vsf_peripheral_capability_t) uint8_t support_early_wakeup uint8_t support_reset_none
< Indicates if early wakeup is supported
Definition vsf_template_wdt.h:331
uint8_t support_min_timeout
Indicates if minimum timeout is supported.
Definition vsf_template_wdt.h:339
WDT configuration structure.
Definition vsf_template_wdt.h:310
vsf_wdt_mode_t mode
WDT mode, refer to vsf_wdt_mode_t.
Definition vsf_template_wdt.h:311
uint32_t min_ms
Minimum timeout in milliseconds.
Definition vsf_template_wdt.h:313
uint32_t max_ms
Maximum timeout in milliseconds.
Definition vsf_template_wdt.h:312
vsf_wdt_isr_t isr
WDT interrupt configuration, refer to vsf_wdt_isr_t.
Definition vsf_template_wdt.h:314
WDT interrupt configuration structure.
Definition vsf_template_wdt.h:297
vsf_wdt_isr_handler_t * handler_fn
Interrupt handler function pointer.
Definition vsf_template_wdt.h:298
void * target_ptr
User-defined target pointer.
Definition vsf_template_wdt.h:299
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_wdt.h:300
WDT operation function pointer type, used for WDT Multi Class support.
Definition vsf_template_wdt.h:348
WDT instance structure, used for WDT Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_wdt.h:362
const vsf_wdt_op_t * op
Definition vsf_template_wdt.h:363
vsf_wdt_mode_t
Definition wdt.h:115
void vsf_wdt_isr_handler_t(void *target_ptr, vsf_wdt_t *wdt_ptr)
Definition wdt.h:144
fsm_rt_t
Definition vsf_fsm.h:315
@ VSF_WDT_MODE_RESET_MASK
Definition vsf_template_wdt.h:262
@ VSF_WDT_MODE_EARLY_WAKEUP_MASK
Definition vsf_template_wdt.h:256
@ VSF_WDT_MODE_ALL_BITS_MASK
Definition vsf_template_wdt.h:268
vsf_err_t vsf_wdt_init(vsf_wdt_t *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr)
Initialize a WDT instance.
Definition wdt_common.c:38
fsm_rt_t vsf_wdt_enable(vsf_wdt_t *wdt_ptr)
Enable a WDT instance.
Definition wdt_common.c:56
vsf_wdt_mode_t
Predefined VSF WDT modes that can be reimplemented in specific HAL drivers.The following modes must b...
Definition vsf_template_wdt.h:224
@ VSF_WDT_MODE_RESET_SOC
Reset SOC when timeout.
Definition vsf_template_wdt.h:230
@ VSF_WDT_MODE_NO_EARLY_WAKEUP
No early wakeup.
Definition vsf_template_wdt.h:225
@ VSF_WDT_MODE_RESET_CPU
Reset CPU when timeout.
Definition vsf_template_wdt.h:229
@ VSF_WDT_MODE_RESET_NONE
No reset when timeout.
Definition vsf_template_wdt.h:228
@ VSF_WDT_MODE_EARLY_WAKEUP
Early wakeup.
Definition vsf_template_wdt.h:226
void vsf_wdt_isr_handler_t(void *target_ptr, vsf_wdt_t *wdt_ptr)
WDT interrupt handler type declaration.
Definition vsf_template_wdt.h:291
struct vsf_wdt_capability_t vsf_wdt_capability_t
Predefined VSF WDT capability that can be reimplemented in specific hal drivers. The vsf_wdt_capabili...
void vsf_wdt_feed(vsf_wdt_t *wdt_ptr)
WDT feed operation.
Definition wdt_common.c:83
struct vsf_wdt_isr_t vsf_wdt_isr_t
WDT interrupt configuration structure.
#define VSF_WDT_APIS(__prefix)
WDT API template, used to generate WDT type, specific prefix function declarations,...
Definition vsf_template_wdt.h:178
fsm_rt_t vsf_wdt_disable(vsf_wdt_t *wdt_ptr)
Disable a WDT instance.
Definition wdt_common.c:65
void vsf_wdt_fini(vsf_wdt_t *wdt_ptr)
Finalize a WDT instance.
Definition wdt_common.c:47
vsf_wdt_capability_t vsf_wdt_capability(vsf_wdt_t *wdt_ptr)
Get the capability of WDT instance.
Definition wdt_common.c:74
struct vsf_wdt_cfg_t vsf_wdt_cfg_t
WDT configuration structure.
Generated from commit: vsfteam/vsf@2b286be