blob: 0110d503c4bcef7530e6e11cd2f6d35e98fdfb63 (
plain)
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
|
#ifndef _BFLB_WDG_H
#define _BFLB_WDG_H
#include "bflb_core.h"
/** @addtogroup LHAL
* @{
*/
/** @addtogroup WDG
* @{
*/
#if !defined(BL702L)
#define WDG_CLKSRC_BCLK 0
#endif
#define WDG_CLKSRC_32K 1
#define WDG_CLKSRC_1K 2
#define WDG_CLKSRC_XTAL 3
#if !defined(BL702) && !defined(BL602)
#define WDG_CLKSRC_GPIO 4
#endif
#define WDG_CLKSRC_NO 5
/** @defgroup WDG_MODE Watch-dog reset/interrupt mode definition
* @{
*/
#define WDG_MODE_INTERRUPT 0
#define WDG_MODE_RESET 1
/**
* @}
*/
/**
* @brief WDG configuration structure
*
* @param clock_source Wdg clock source, use BFLB_SYSTEM_* definition
* @param clock_div Wdg clock divison value, from 0 to 255
* @param comp_val Wdg compare value
* @param mode Wdg reset/interrupt mode
*/
struct bflb_wdg_config_s {
uint8_t clock_source;
uint8_t clock_div;
uint16_t comp_val;
uint8_t mode;
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize watchdog.
*
* @param [in] dev device handle
* @param [in] config pointer to save watchdog config
*/
void bflb_wdg_init(struct bflb_device_s *dev, const struct bflb_wdg_config_s *config);
/**
* @brief Start watchdog.
*
* @param [in] dev device handle
*/
void bflb_wdg_start(struct bflb_device_s *dev);
/**
* @brief Stop watchdog.
*
* @param [in] dev device handle
*/
void bflb_wdg_stop(struct bflb_device_s *dev);
/**
* @brief Get watchdog counter value.
*
* @param [in] dev device handle
* @return counter value
*/
uint16_t bflb_wdg_get_countervalue(struct bflb_device_s *dev);
/**
* @brief Set watchdog counter value.
*
* @param [in] dev device handle
* @param [in] counter value
*/
void bflb_wdg_set_countervalue(struct bflb_device_s *dev, uint16_t value);
/**
* @brief Reset watchdog counter value.
*
* @param [in] dev device handle
*/
void bflb_wdg_reset_countervalue(struct bflb_device_s *dev);
/**
* @brief Clear watchdog compare interrupt status.
*
* @param [in] dev device handle
*/
void bflb_wdg_compint_clear(struct bflb_device_s *dev);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
/**
* @}
*/
#endif
|