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
32// multi-class support enabled by default for maximum availability.
33#ifndef VSF_WDT_CFG_MULTI_CLASS
34# define VSF_WDT_CFG_MULTI_CLASS ENABLED
35#endif
36
37#if defined(VSF_HW_WDT_COUNT) && !defined(VSF_HW_WDT_MASK)
38# define VSF_HW_WDT_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_WDT_COUNT)
39#endif
40
41#if defined(VSF_HW_WDT_MASK) && !defined(VSF_HW_WDT_COUNT)
42# define VSF_HW_WDT_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_WDT_MASK)
43#endif
44
45// application code can redefine it
46#ifndef VSF_WDT_CFG_PREFIX
47# if VSF_WDT_CFG_MULTI_CLASS == ENABLED
48# define VSF_WDT_CFG_PREFIX vsf
49# elif defined(VSF_HW_WDT_COUNT) && (VSF_HW_WDT_COUNT != 0)
50# define VSF_WDT_CFG_PREFIX vsf_hw
51# else
52# define VSF_WDT_CFG_PREFIX vsf
53# endif
54#endif
55
56#ifndef VSF_WDT_CFG_FUNCTION_RENAME
57# define VSF_WDT_CFG_FUNCTION_RENAME ENABLED
58#endif
59
60#ifndef VSF_WDT_CFG_REIMPLEMENT_TYPE_MODE
61# define VSF_WDT_CFG_REIMPLEMENT_TYPE_MODE DISABLED
62#endif
63
64#ifndef VSF_WDT_CFG_REIMPLEMENT_TYPE_IRQ_MASK
65# define VSF_WDT_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
66#endif
67
71#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
72# define VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG DISABLED
73#endif
74
78#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
79# define VSF_WDT_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
80#endif
81
82#ifndef VSF_WDT_CFG_INHERT_HAL_CAPABILITY
83# define VSF_WDT_CFG_INHERT_HAL_CAPABILITY ENABLED
84#endif
85
86/*============================ MACROFIED FUNCTIONS ===========================*/
87
88#define VSF_WDT_APIS(__prefix_name) \
89 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, wdt, init, VSF_MCONNECT(__prefix_name, _wdt_t) *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr) \
90 __VSF_HAL_TEMPLATE_API(__prefix_name, void, wdt, fini, VSF_MCONNECT(__prefix_name, _wdt_t) *wdt_ptr) \
91 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, wdt, enable, VSF_MCONNECT(__prefix_name, _wdt_t) *wdt_ptr) \
92 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, wdt, disable, VSF_MCONNECT(__prefix_name, _wdt_t) *wdt_ptr) \
93 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_wdt_capability_t, wdt, capability, VSF_MCONNECT(__prefix_name, _wdt_t) *wdt_ptr) \
94 __VSF_HAL_TEMPLATE_API(__prefix_name, void, wdt, feed, VSF_MCONNECT(__prefix_name, _wdt_t) *wdt_ptr)
95
96/*============================ TYPES =========================================*/
97
98#if VSF_WDT_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
99typedef enum vsf_wdt_mode_t {
102
107#endif
108
109enum {
113
118
122};
123
124#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
125typedef struct vsf_wdt_t vsf_wdt_t;
126typedef void vsf_wdt_isr_handler_t(void *target_ptr, vsf_wdt_t *wdt_ptr);
127typedef struct vsf_wdt_isr_t {
132
134typedef struct vsf_wdt_cfg_t {
137 uint32_t min_ms; //The window watchdog supports a timeout range
140#endif
141
142#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
143typedef struct vsf_wdt_capability_t {
144#if VSF_WDT_CFG_INHERT_HAL_CAPABILITY == ENABLED
146#endif
147
148 uint8_t support_early_wakeup : 1;
155#endif
156
157typedef struct vsf_wdt_op_t {
158#undef __VSF_HAL_TEMPLATE_API
159#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
160
161 VSF_WDT_APIS(vsf)
163
164#if VSF_WDT_CFG_MULTI_CLASS == ENABLED
165struct vsf_wdt_t {
167};
168#endif
169
170/*============================ PROTOTYPES ====================================*/
171
191extern vsf_err_t vsf_wdt_init(vsf_wdt_t *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr);
192
205extern void vsf_wdt_fini(vsf_wdt_t *wdt_ptr);
206
220extern fsm_rt_t vsf_wdt_enable(vsf_wdt_t *wdt_ptr);
221
235extern fsm_rt_t vsf_wdt_disable(vsf_wdt_t *wdt_ptr);
236
249
259extern void vsf_wdt_feed(vsf_wdt_t *wdt_ptr);
260
261/*============================ MACROFIED FUNCTIONS ===========================*/
262
263#if VSF_WDT_CFG_FUNCTION_RENAME == ENABLED
264# define __vsf_wdt_t VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_t)
265# define vsf_wdt_init(__WDT, ...) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_init) ((__vsf_wdt_t *)(__WDT), ##__VA_ARGS__)
266# define vsf_wdt_fini(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_fini) ((__vsf_wdt_t *)(__WDT))
267# define vsf_wdt_enable(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_enable) ((__vsf_wdt_t *)(__WDT))
268# define vsf_wdt_disable(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_disable) ((__vsf_wdt_t *)(__WDT))
269# define vsf_wdt_capability(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_capability) ((__vsf_wdt_t *)(__WDT))
270# define vsf_wdt_feed(__WDT, ...) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_feed) ((__vsf_wdt_t *)(__WDT))
271#endif
272
273#ifdef __cplusplus
274}
275#endif
276
277#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
Definition vsf_template_wdt.h:143
uint8_t support_reset_soc
Definition vsf_template_wdt.h:151
uint8_t support_reset_core
Definition vsf_template_wdt.h:150
uint8_t support_disable
Definition vsf_template_wdt.h:152
uint32_t max_timeout_ms
Definition vsf_template_wdt.h:153
inherit(vsf_peripheral_capability_t) uint8_t support_early_wakeup uint8_t support_reset_none
Definition vsf_template_wdt.h:145
wdt configuration
Definition vsf_template_wdt.h:134
vsf_wdt_mode_t mode
Definition vsf_template_wdt.h:135
uint32_t min_ms
Definition vsf_template_wdt.h:137
uint32_t max_ms
Definition vsf_template_wdt.h:136
vsf_wdt_isr_t isr
Definition vsf_template_wdt.h:138
Definition vsf_template_wdt.h:127
vsf_wdt_isr_handler_t * handler_fn
Definition vsf_template_wdt.h:128
void * target_ptr
Definition vsf_template_wdt.h:129
vsf_arch_prio_t prio
Definition vsf_template_wdt.h:130
Definition vsf_template_wdt.h:157
Definition vsf_template_wdt.h:165
const vsf_wdt_op_t * op
Definition vsf_template_wdt.h:166
fsm_rt_t
Definition vsf_fsm.h:315
#define vsf_wdt_init(__WDT,...)
Definition vsf_template_wdt.h:265
#define vsf_wdt_enable(__WDT)
Definition vsf_template_wdt.h:267
#define VSF_WDT_APIS(__prefix_name)
Definition vsf_template_wdt.h:88
#define vsf_wdt_feed(__WDT,...)
Definition vsf_template_wdt.h:270
vsf_wdt_mode_t
Definition vsf_template_wdt.h:99
@ VSF_WDT_MODE_RESET_SOC
Definition vsf_template_wdt.h:105
@ VSF_WDT_MODE_NO_EARLY_WAKEUP
Definition vsf_template_wdt.h:100
@ VSF_WDT_MODE_RESET_CPU
Definition vsf_template_wdt.h:104
@ VSF_WDT_MODE_RESET_NONE
Definition vsf_template_wdt.h:103
@ VSF_WDT_MODE_EARLY_WAKEUP
Definition vsf_template_wdt.h:101
#define vsf_wdt_disable(__WDT)
Definition vsf_template_wdt.h:268
@ VSF_WDT_MODE_RESET_MASK
Definition vsf_template_wdt.h:115
@ VSF_WDT_MODE_RESET_COUNT
Definition vsf_template_wdt.h:114
@ VSF_WDT_MODE_EARLY_WAKEUP_MASK
Definition vsf_template_wdt.h:111
@ VSF_WDT_MODE_ALL_BITS_MASK
Definition vsf_template_wdt.h:120
@ VSF_WDT_MODE_MASK_COUNT
Definition vsf_template_wdt.h:119
@ VSF_WDT_MODE_EARLY_WAKEUP_COUNT
Definition vsf_template_wdt.h:110
#define vsf_wdt_fini(__WDT)
Definition vsf_template_wdt.h:266
void vsf_wdt_isr_handler_t(void *target_ptr, vsf_wdt_t *wdt_ptr)
Definition vsf_template_wdt.h:126
#define vsf_wdt_capability(__WDT)
Definition vsf_template_wdt.h:269