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#ifndef VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG
134# define VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG DISABLED
135#endif
136
149#ifndef VSF_WDT_CFG_REIMPLEMENT_TYPE_CAPABILITY
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_name) \
179 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, wdt, init, VSF_MCONNECT(__prefix_name, _t) *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr) \
180 __VSF_HAL_TEMPLATE_API(__prefix_name, void, wdt, fini, VSF_MCONNECT(__prefix_name, _t) *wdt_ptr) \
181 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, wdt, get_configuration, VSF_MCONNECT(__prefix_name, _t) *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr) \
182 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, wdt, enable, VSF_MCONNECT(__prefix_name, _t) *wdt_ptr) \
183 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, wdt, disable, VSF_MCONNECT(__prefix_name, _t) *wdt_ptr) \
184 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_wdt_capability_t, wdt, capability, VSF_MCONNECT(__prefix_name, _t) *wdt_ptr) \
185 __VSF_HAL_TEMPLATE_API(__prefix_name, void, wdt, feed, VSF_MCONNECT(__prefix_name, _t) *wdt_ptr)
186
187/*============================ TYPES =========================================*/
188
189#if VSF_WDT_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
225typedef enum vsf_wdt_mode_t {
228
232
233 /*
236 VSF_WDT_MODE_PRESCALER_1 = (0 << 2),
237 VSF_WDT_MODE_PRESCALER_2 = (1 << 2),
238 VSF_WDT_MODE_PRESCALER_4 = (2 << 2),
239 #define VSF_WDT_MODE_PRESCALER_8 VSF_WDT_MODE_PRESCALER_8
240 #define VSF_WDT_MODE_PRESCALER_1 VSF_WDT_MODE_PRESCALER_1
241 #define VSF_WDT_MODE_PRESCALER_2 VSF_WDT_MODE_PRESCALER_2
242 #define VSF_WDT_MODE_PRESCALER_4 VSF_WDT_MODE_PRESCALER_4
243 #define VSF_WDT_MODE_PRESCALER_MASK (0x03 << 2)
244 */
246#endif
247
254enum {
259
260#ifndef VSF_WDT_MODE_RESET_MASK
266#endif
267
268#ifndef VSF_WDT_MODE_ALL_BITS_MASK
271#ifdef VSF_WDT_MODE_PRESCALER_MASK
272 | VSF_WDT_MODE_PRESCALER_MASK
273#endif
274#endif
276
277#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
282typedef struct vsf_wdt_t vsf_wdt_t;
283
292typedef void vsf_wdt_isr_handler_t(void *target_ptr, vsf_wdt_t *wdt_ptr);
293
298typedef struct vsf_wdt_isr_t {
303
311typedef struct vsf_wdt_cfg_t {
317#endif
318
319#if VSF_WDT_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
330typedef struct vsf_wdt_capability_t {
331#if VSF_WDT_CFG_INHERIT_HAL_CAPABILITY == ENABLED
333#endif
334
343#endif
344
349typedef struct vsf_wdt_op_t {
351#undef __VSF_HAL_TEMPLATE_API
352#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
354
355 VSF_WDT_APIS(vsf_wdt)
357
358#if VSF_WDT_CFG_MULTI_CLASS == ENABLED
363struct vsf_wdt_t {
365};
366#endif
367
368/*============================ PROTOTYPES ====================================*/
369
389extern vsf_err_t vsf_wdt_init(vsf_wdt_t *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr);
390
402extern void vsf_wdt_fini(vsf_wdt_t *wdt_ptr);
403
415extern fsm_rt_t vsf_wdt_enable(vsf_wdt_t *wdt_ptr);
416
428extern fsm_rt_t vsf_wdt_disable(vsf_wdt_t *wdt_ptr);
429
442
463
473extern void vsf_wdt_feed(vsf_wdt_t *wdt_ptr);
474
475/*============================ MACROFIED FUNCTIONS ===========================*/
476
478#if VSF_WDT_CFG_FUNCTION_RENAME == ENABLED
479# define __vsf_wdt_t VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_t)
480# define vsf_wdt_init(__WDT, ...) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_init) ((__vsf_wdt_t *)(__WDT), ##__VA_ARGS__)
481# define vsf_wdt_fini(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_fini) ((__vsf_wdt_t *)(__WDT))
482# define vsf_wdt_enable(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_enable) ((__vsf_wdt_t *)(__WDT))
483# define vsf_wdt_disable(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_disable) ((__vsf_wdt_t *)(__WDT))
484# define vsf_wdt_capability(__WDT) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_capability) ((__vsf_wdt_t *)(__WDT))
485# define vsf_wdt_get_configuration(__WDT, ...) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_get_configuration) ((__vsf_wdt_t *)(__WDT), ##__VA_ARGS__)
486# define vsf_wdt_feed(__WDT, ...) VSF_MCONNECT(VSF_WDT_CFG_PREFIX, _wdt_feed) ((__vsf_wdt_t *)(__WDT))
487#endif
489
490#ifdef __cplusplus
491}
492#endif
493
494#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:330
uint8_t support_reset_soc
Indicates if SoC reset mode is supported.
Definition vsf_template_wdt.h:338
uint8_t support_disable
Indicates if WDT can be disabled after startup.
Definition vsf_template_wdt.h:339
uint8_t support_early_wakeup
Definition wdt.h:158
uint8_t support_reset_cpu
Indicates if core reset mode is supported.
Definition vsf_template_wdt.h:337
uint32_t max_timeout_ms
Maximum timeout in milliseconds.
Definition vsf_template_wdt.h:341
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:332
uint8_t support_min_timeout
Indicates if minimum timeout is supported.
Definition vsf_template_wdt.h:340
WDT configuration structure.
Definition vsf_template_wdt.h:311
vsf_wdt_mode_t mode
WDT mode, refer to vsf_wdt_mode_t.
Definition vsf_template_wdt.h:312
uint32_t min_ms
Minimum timeout in milliseconds.
Definition vsf_template_wdt.h:314
uint32_t max_ms
Maximum timeout in milliseconds.
Definition vsf_template_wdt.h:313
vsf_wdt_isr_t isr
WDT interrupt configuration, refer to vsf_wdt_isr_t.
Definition vsf_template_wdt.h:315
WDT interrupt configuration structure.
Definition vsf_template_wdt.h:298
vsf_wdt_isr_handler_t * handler_fn
Interrupt handler function pointer.
Definition vsf_template_wdt.h:299
void * target_ptr
User-defined target pointer.
Definition vsf_template_wdt.h:300
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_wdt.h:301
WDT operation function pointer type, used for WDT Multi Class support.
Definition vsf_template_wdt.h:349
WDT instance structure, used for WDT Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_wdt.h:363
const vsf_wdt_op_t * op
Definition vsf_template_wdt.h:364
vsf_wdt_mode_t
Definition wdt.h:113
void vsf_wdt_isr_handler_t(void *target_ptr, vsf_wdt_t *wdt_ptr)
Definition wdt.h:142
fsm_rt_t
Definition vsf_fsm.h:315
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
#define VSF_WDT_APIS(__prefix_name)
WDT API template, used to generate WDT type, specific prefix function declarations,...
Definition vsf_template_wdt.h:178
fsm_rt_t vsf_wdt_enable(vsf_wdt_t *wdt_ptr)
Enable a WDT instance.
Definition wdt_common.c:66
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:225
@ VSF_WDT_MODE_RESET_SOC
Reset SOC when timeout.
Definition vsf_template_wdt.h:231
@ VSF_WDT_MODE_NO_EARLY_WAKEUP
No early wakeup.
Definition vsf_template_wdt.h:226
@ VSF_WDT_MODE_RESET_CPU
Reset CPU when timeout.
Definition vsf_template_wdt.h:230
@ VSF_WDT_MODE_RESET_NONE
No reset when timeout.
Definition vsf_template_wdt.h:229
@ VSF_WDT_MODE_EARLY_WAKEUP
Early wakeup.
Definition vsf_template_wdt.h:227
void vsf_wdt_isr_handler_t(void *target_ptr, vsf_wdt_t *wdt_ptr)
WDT interrupt handler type declaration.
Definition vsf_template_wdt.h:292
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:93
struct vsf_wdt_isr_t vsf_wdt_isr_t
WDT interrupt configuration structure.
vsf_err_t vsf_wdt_get_configuration(vsf_wdt_t *wdt_ptr, vsf_wdt_cfg_t *cfg_ptr)
Get the current configuration of a WDT instance.
Definition wdt_common.c:56
fsm_rt_t vsf_wdt_disable(vsf_wdt_t *wdt_ptr)
Disable a WDT instance.
Definition wdt_common.c:75
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:84
struct vsf_wdt_cfg_t vsf_wdt_cfg_t
WDT configuration structure.
@ VSF_WDT_MODE_RESET_MASK
Definition vsf_template_wdt.h:263
@ VSF_WDT_MODE_EARLY_WAKEUP_MASK
Definition vsf_template_wdt.h:257
@ VSF_WDT_MODE_ALL_BITS_MASK
Definition vsf_template_wdt.h:269
Generated from commit: vsfteam/vsf@74aa6ce