SemiDrive SSDK Appication Program Interface PTG3.0
sdrv_watchdog.h
Go to the documentation of this file.
1
9#ifndef SDRV_WATCHDOG_DRV_H_
10#define SDRV_WATCHDOG_DRV_H_
11
12#include <types.h>
13#include <regs_base.h>
14#include "sdrv_common.h"
15
16#undef __I
17#undef __O
18#undef __IO
19
20
21#ifdef __cplusplus
22 #define __I volatile
23#else
24 #define __I volatile const
25#endif
26#define __O volatile
27#define __IO volatile
33{
34 SDRV_STATUS_TIMEOUT_FAILED = SDRV_ERROR_STATUS(SDRV_STATUS_GROUP_WATCHDOG, 0), /* watchdog status for timeout failed. */
35 SDRV_STATUS_DELTA_FAILED = SDRV_ERROR_STATUS(SDRV_STATUS_GROUP_WATCHDOG,1), /* watchdog status for delta failed. */
36 SDRV_STATUS_WINDOW_LOW_FAILED= SDRV_ERROR_STATUS(SDRV_STATUS_GROUP_WATCHDOG, 2), /* watchdog status for window_low failed. */
37 SDRV_STATUS_INTR_UNCLEARED = SDRV_ERROR_STATUS(SDRV_STATUS_GROUP_WATCHDOG, 3), /* watchdog status for interrupt not cleared. */
38};
39
43typedef struct sdrv_wdt {
44 __IO uint32_t ctrl;
45 __IO uint32_t wtc;
46 __IO uint32_t wrc_ctrl;
47 __IO uint32_t wrc_val;
48 __IO uint32_t wrc_seq;
49 __IO uint32_t rst_ctl;
50 __IO uint32_t ext_rst_ctl;
51 __I uint32_t cnt;
52 __O uint32_t tsw;
53 __IO uint32_t intr;
54 __IO uint32_t rst_req_mon;
55 __IO uint32_t dummy_res;
57 uint32_t reserved1[4];
58
59 __IO uint32_t lock;
61
65typedef enum sdrv_wdt_clock {
72
76typedef enum sdrv_wdt_refresh {
84
88typedef enum sdrv_wdt_intr {
91 WDT_OVERFLOW = 0X4U,
93
98 bool reset_en;
99 uint8_t reset_mode;
100 uint8_t reset_win;
101 uint16_t reset_cnt;
104
109 bool reset_en;
110 uint8_t reset_mode;
111 uint8_t reset_pol;
112 uint8_t reset_win;
113 uint16_t reset_cnt;
115
119typedef struct sdrv_wdt_config {
121 uint16_t pre_divide;
123 uint8_t wdt_en_src;
124 uint8_t wtc_src;
129 uint32_t timeout;
130 uint32_t window_low;
131 uint32_t seq_delta;
133 uint32_t intr_bitmap;
138
149
160
172
182
192
204status_t sdrv_wdt_set_timeout(sdrv_wdt_t *base, uint32_t timeout);
205
217status_t sdrv_wdt_set_window_low(sdrv_wdt_t *base, uint32_t low_limit);
218
231
241
253
265
276
285
286#endif /* SDRV_WATCHDOG_DRV_H_ */
SemiDrive driver common header file.
@ SDRV_STATUS_GROUP_WATCHDOG
Definition: sdrv_common.h:31
int32_t status_t
Type used for all status and error return values.
Definition: sdrv_common.h:82
#define SDRV_ERROR_STATUS(group, code)
Construct a status code value from a group and code number. All the error statuses are negetive numbe...
Definition: sdrv_common.h:17
enum sdrv_wdt_refresh sdrv_wdt_refresh_e
Definition for watchdog refresh type.
struct sdrv_wdt sdrv_wdt_t
Definition for sdrv watchdog register.
status_t sdrv_wdt_disable(sdrv_wdt_t *base)
Disable watchdog.
status_t sdrv_wdt_get_intr_status(sdrv_wdt_t *base, sdrv_wdt_intr_e intr)
Get watchdog interrupt status of specific type.
status_t sdrv_wdt_set_timeout(sdrv_wdt_t *base, uint32_t timeout)
Set watchdog timeout value.
struct sdrv_wdt_internal_reset sdrv_wdt_internal_reset_t
Definition for watchdog internal reset config.
sdrv_wdt_clock
Definition for watchdog clock source.
Definition: sdrv_watchdog.h:65
@ WDT_LP_CLOCK
Definition: sdrv_watchdog.h:70
@ WDT_BUS_CLOCK
Definition: sdrv_watchdog.h:67
@ WDT_MAIN_CLOCK
Definition: sdrv_watchdog.h:66
@ WDT_TIE_OFF
Definition: sdrv_watchdog.h:69
@ WDT_EXT_CLOCK
Definition: sdrv_watchdog.h:68
sdrv_watchdog_error
watchdog status error code.
Definition: sdrv_watchdog.h:33
@ SDRV_STATUS_INTR_UNCLEARED
Definition: sdrv_watchdog.h:37
@ SDRV_STATUS_TIMEOUT_FAILED
Definition: sdrv_watchdog.h:34
@ SDRV_STATUS_WINDOW_LOW_FAILED
Definition: sdrv_watchdog.h:36
@ SDRV_STATUS_DELTA_FAILED
Definition: sdrv_watchdog.h:35
status_t sdrv_wdt_enable(sdrv_wdt_t *base)
Enable watchdog.
status_t sdrv_wdt_init(sdrv_wdt_t *base, sdrv_wdt_config_t *config)
Initialize watchdog with config parameters.
status_t sdrv_wdt_set_sequence_delta(sdrv_wdt_t *base, uint32_t delta)
Set watchdog sequence delta value.
status_t sdrv_wdt_set_window_low(sdrv_wdt_t *base, uint32_t low_limit)
Set watchdog time window low limit value.
sdrv_wdt_refresh
Definition for watchdog refresh type.
Definition: sdrv_watchdog.h:76
@ WDT_DIRECT_REFRESH
Definition: sdrv_watchdog.h:77
@ WDT_DIRECT_SEQUENCE_REFRESH
Definition: sdrv_watchdog.h:81
@ WDT_WINDOW_REFRESH
Definition: sdrv_watchdog.h:78
@ WDT_SEQUENCE_REFRESH
Definition: sdrv_watchdog.h:79
@ WDT_WINDOW_SEQUENCE_REFRESH
Definition: sdrv_watchdog.h:82
struct sdrv_wdt_config sdrv_wdt_config_t
Definition for watchdog initialize config.
#define __O
Definition: sdrv_watchdog.h:26
status_t sdrv_wdt_get_default_config(sdrv_wdt_config_t *config)
Get the default configuration for watchdog.
status_t sdrv_wdt_clear_intr_status(sdrv_wdt_t *base, sdrv_wdt_intr_e intr)
Clear watchdog interrupt status of specific type.
enum sdrv_wdt_intr sdrv_wdt_intr_e
Definition for watchdog interrupt type.
status_t sdrv_wdt_write_timestamp(sdrv_wdt_t *base, uint32_t timestamp)
Write watchdog counter to TSW register.
enum sdrv_wdt_clock sdrv_wdt_clock_e
Definition for watchdog clock source.
uint32_t sdrv_wdt_read_timestamp(sdrv_wdt_t *base)
Read watchdog current counter.
status_t sdrv_wdt_deinit(sdrv_wdt_t *base)
De-Initialize watchdog.
sdrv_wdt_intr
Definition for watchdog interrupt type.
Definition: sdrv_watchdog.h:88
@ WDT_ILL_SEQUENCE_RESRESH
Definition: sdrv_watchdog.h:90
@ WDT_OVERFLOW
Definition: sdrv_watchdog.h:91
@ WDT_ILL_WINDOW_REFRESH
Definition: sdrv_watchdog.h:89
#define __IO
Definition: sdrv_watchdog.h:27
struct sdrv_wdt_external_reset sdrv_wdt_external_reset_t
Definition for watchdog external reset config.
#define __I
Definition: sdrv_watchdog.h:24
Definition for watchdog initialize config.
Definition: sdrv_watchdog.h:119
uint32_t window_low
Definition: sdrv_watchdog.h:130
uint16_t pre_divide
Definition: sdrv_watchdog.h:121
bool auto_restart
Definition: sdrv_watchdog.h:126
uint8_t wdt_en_src
Definition: sdrv_watchdog.h:123
sdrv_wdt_internal_reset_t int_rst
Definition: sdrv_watchdog.h:135
sdrv_wdt_external_reset_t ext_rst
Definition: sdrv_watchdog.h:136
uint32_t seq_delta
Definition: sdrv_watchdog.h:131
uint8_t wtc_src
Definition: sdrv_watchdog.h:124
uint32_t timeout
Definition: sdrv_watchdog.h:129
sdrv_wdt_refresh_e refresh
Definition: sdrv_watchdog.h:128
sdrv_wdt_clock_e clk_src
Definition: sdrv_watchdog.h:120
uint32_t intr_bitmap
Definition: sdrv_watchdog.h:133
Definition for watchdog external reset config.
Definition: sdrv_watchdog.h:108
uint8_t reset_pol
Definition: sdrv_watchdog.h:111
uint8_t reset_win
Definition: sdrv_watchdog.h:112
uint8_t reset_mode
Definition: sdrv_watchdog.h:110
uint16_t reset_cnt
Definition: sdrv_watchdog.h:113
bool reset_en
Definition: sdrv_watchdog.h:109
Definition for watchdog internal reset config.
Definition: sdrv_watchdog.h:97
uint8_t reset_win
Definition: sdrv_watchdog.h:100
uint8_t reset_mode
Definition: sdrv_watchdog.h:99
bool wdt_reset_en
Definition: sdrv_watchdog.h:102
uint16_t reset_cnt
Definition: sdrv_watchdog.h:101
bool reset_en
Definition: sdrv_watchdog.h:98
Definition for sdrv watchdog register.
Definition: sdrv_watchdog.h:43
uint32_t reserved1[4]
Definition: sdrv_watchdog.h:57
__I uint32_t cnt
Definition: sdrv_watchdog.h:51
__IO uint32_t wrc_val
Definition: sdrv_watchdog.h:47
__IO uint32_t rst_req_mon
Definition: sdrv_watchdog.h:54
__IO uint32_t rst_ctl
Definition: sdrv_watchdog.h:49
__IO uint32_t ctrl
Definition: sdrv_watchdog.h:44
__IO uint32_t dummy_res
Definition: sdrv_watchdog.h:55
__IO uint32_t lock
Definition: sdrv_watchdog.h:59
__IO uint32_t intr
Definition: sdrv_watchdog.h:53
__IO uint32_t wrc_seq
Definition: sdrv_watchdog.h:48
__O uint32_t tsw
Definition: sdrv_watchdog.h:52
__IO uint32_t wrc_ctrl
Definition: sdrv_watchdog.h:46
__IO uint32_t ext_rst_ctl
Definition: sdrv_watchdog.h:50
__IO uint32_t wtc
Definition: sdrv_watchdog.h:45