AM62x MCU+ SDK  10.01.00
watchdog_rti.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
48 #ifndef WATCHDOG_RTI_H_
49 #define WATCHDOG_RTI_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #include <string.h>
60 #include <stdbool.h>
61 #include <drivers/hw_include/cslr_watchdog.h>
62 
63 /* ========================================================================== */
64 /* Macros & Typedefs */
65 /* ========================================================================== */
66 
70 #define WATCHDOG_CLEAR_STATUS (0xFFU)
71 
72 /* ========================================================================== */
73 /* Structures */
74 /* ========================================================================== */
75 
84 typedef struct Watchdog_HwAttrs_s
85 {
90  uint8_t instance;
94  uintptr_t baseAddr;
95 
99  uint32_t wdtClkFrequency;
101 
110 typedef enum Watchdog_DebugMode_e {
114 
122 typedef enum Watchdog_ResetMode_e {
124  Watchdog_RESET_ON = 0x5U
126 
132 typedef enum Watchdog_WindowSize_e {
133  Watchdog_WINDOW_100_PERCENT = CSL_RTI_RTIWWDSIZECTRL_WWDSIZE_100_PERCENT,
134  Watchdog_WINDOW_50_PERCENT = CSL_RTI_RTIWWDSIZECTRL_WWDSIZE_50_PERCENT,
135  Watchdog_WINDOW_25_PERCENT = CSL_RTI_RTIWWDSIZECTRL_WWDSIZE_25_PERCENT,
136  Watchdog_WINDOW_12_5_PERCENT = CSL_RTI_RTIWWDSIZECTRL_WWDSIZE_12_5_PERCENT,
137  Watchdog_WINDOW_6_25_PERCENT = CSL_RTI_RTIWWDSIZECTRL_WWDSIZE_6_25_PERCENT,
138  Watchdog_WINDOW_3_125_PERCENT = CSL_RTI_RTIWWDSIZECTRL_WWDSIZE_3_125_PERCENT
140 
144 typedef struct Watchdog_Config_s *Watchdog_Handle;
145 
154 typedef void (*Watchdog_Callback)(Watchdog_Handle handle, void *callbackFxnArgs);
155 
163 typedef struct Watchdog_Params_t {
169  uint32_t expirationTime;
171 
183 typedef struct Watchdog_Config_s {
184 
186  void *object;
187 
189  void const *hwAttrs;
190 
192 
200 typedef enum Watchdog_DriverState_e
201 {
206 
212 
221 typedef struct Watchdog_MCB_t
222 {
227 
232 
236  uint32_t interruptsRxed;
237 
241  uint32_t watchdogCleared;
242 } Watchdog_MCB;
243 
244 
245 /* ========================================================================== */
246 /* Function Declarations */
247 /* ========================================================================== */
248 
267 void Watchdog_setReaction(Watchdog_Handle handle, uint32_t dwwdReaction);
268 
279 
298 void Watchdog_setWindowSize(Watchdog_Handle handle, uint32_t dwwdWindowSize);
299 
309 
318 
319 
329 
335 void Watchdog_init(void);
336 
342 void Watchdog_deinit(void);
343 
358 
365 
366 #ifdef __cplusplus
367 }
368 #endif
369 
370 #endif /* WATCHDOG_RTI_H_ */
371 
Watchdog_WINDOW_100_PERCENT
@ Watchdog_WINDOW_100_PERCENT
Definition: watchdog_rti.h:133
Watchdog_paramsInit
void Watchdog_paramsInit(Watchdog_Params *params)
Function to set default values of Watchdog_Params in params.
Watchdog_WINDOW_50_PERCENT
@ Watchdog_WINDOW_50_PERCENT
Definition: watchdog_rti.h:134
Watchdog_DriverState_OPERATIONAL
@ Watchdog_DriverState_OPERATIONAL
Driver is operational.
Definition: watchdog_rti.h:210
Watchdog_setReaction
void Watchdog_setReaction(Watchdog_Handle handle, uint32_t dwwdReaction)
Set DWWD reaction.
Watchdog_DEBUG_STALL_ON
@ Watchdog_DEBUG_STALL_ON
Definition: watchdog_rti.h:111
Watchdog_WINDOW_25_PERCENT
@ Watchdog_WINDOW_25_PERCENT
Definition: watchdog_rti.h:135
index
uint16_t index
Definition: tisci_rm_proxy.h:3
Watchdog_getWindowSize
uint32_t Watchdog_getWindowSize(Watchdog_Handle handle)
Get DWWD Window Size.
Watchdog_Config
Watchdog Global configuration.
Definition: watchdog_rti.h:183
Watchdog_DebugMode
Watchdog_DebugMode
Watchdog debug stall settings.
Definition: watchdog_rti.h:110
Watchdog_Callback
void(* Watchdog_Callback)(Watchdog_Handle handle, void *callbackFxnArgs)
Watchdog callback pointer.
Definition: watchdog_rti.h:154
Watchdog_open
Watchdog_Handle Watchdog_open(uint8_t index, Watchdog_Params *params)
Opens a Watchdog object with the index and parameters specified, and returns a Watchdog_Handle.
Watchdog_Handle
struct Watchdog_Config_s * Watchdog_Handle
Watchdog Handle.
Definition: watchdog_rti.h:144
Watchdog_WINDOW_3_125_PERCENT
@ Watchdog_WINDOW_3_125_PERCENT
Definition: watchdog_rti.h:138
Watchdog_MCB::interruptsRxed
uint32_t interruptsRxed
Number of interrupts received. Valid only when resetMode = Watchdog_RESET_OFF.
Definition: watchdog_rti.h:236
Watchdog_MCB::watchdogCleared
uint32_t watchdogCleared
Number of times watchdog was serviced.
Definition: watchdog_rti.h:241
Watchdog_setWindowSize
void Watchdog_setWindowSize(Watchdog_Handle handle, uint32_t dwwdWindowSize)
Set DWWD Window Size.
Watchdog_Params::callbackFxnArgs
void * callbackFxnArgs
Definition: watchdog_rti.h:165
Watchdog_Config::hwAttrs
void const * hwAttrs
Definition: watchdog_rti.h:189
Watchdog_Config::object
void * object
Definition: watchdog_rti.h:186
Watchdog_WINDOW_6_25_PERCENT
@ Watchdog_WINDOW_6_25_PERCENT
Definition: watchdog_rti.h:137
Watchdog_Params
Watchdog Parameters.
Definition: watchdog_rti.h:163
Watchdog_RESET_OFF
@ Watchdog_RESET_OFF
Definition: watchdog_rti.h:123
Watchdog_WindowSize
Watchdog_WindowSize
Watchdog Window Size settings.
Definition: watchdog_rti.h:132
Watchdog_ResetMode
Watchdog_ResetMode
Watchdog reset mode settings.
Definition: watchdog_rti.h:122
Watchdog_init
void Watchdog_init(void)
The functions initializes the Watchdog module.
Watchdog_Params::callbackFxn
Watchdog_Callback callbackFxn
Definition: watchdog_rti.h:164
Watchdog_isClosedWindow
bool Watchdog_isClosedWindow(Watchdog_Handle handle)
The function checks for Closed Window.
Watchdog_DriverState
Watchdog_DriverState
Watchdog Driver Status.
Definition: watchdog_rti.h:201
Watchdog_close
void Watchdog_close(Watchdog_Handle handle)
The function closes a Watchdog peripheral specified by the Watchdog handle. It stops (holds) the Watc...
Watchdog_DEBUG_STALL_OFF
@ Watchdog_DEBUG_STALL_OFF
Definition: watchdog_rti.h:112
Watchdog_MCB::state
Watchdog_DriverState state
Watchdog driver internal state.
Definition: watchdog_rti.h:226
Watchdog_WINDOW_12_5_PERCENT
@ Watchdog_WINDOW_12_5_PERCENT
Definition: watchdog_rti.h:136
Watchdog_HwAttrs::wdtClkFrequency
uint32_t wdtClkFrequency
WDT clock frequency.
Definition: watchdog_rti.h:99
Watchdog_Params::debugStallMode
Watchdog_DebugMode debugStallMode
Definition: watchdog_rti.h:167
Watchdog_Params::resetMode
Watchdog_ResetMode resetMode
Definition: watchdog_rti.h:166
Watchdog_RESET_ON
@ Watchdog_RESET_ON
Definition: watchdog_rti.h:124
Watchdog_MCB
Watchdog Driver Master Control Block.
Definition: watchdog_rti.h:222
Watchdog_HwAttrs::instance
uint8_t instance
Instance of the Watchdog to be used.
Definition: watchdog_rti.h:90
Watchdog_HwAttrs
Watchdog Driver HW configuration.
Definition: watchdog_rti.h:85
Watchdog_HwAttrs::baseAddr
uintptr_t baseAddr
Base address of the Watchdog address space to be used.
Definition: watchdog_rti.h:94
Watchdog_Params::windowSize
Watchdog_WindowSize windowSize
Definition: watchdog_rti.h:168
Watchdog_MCB::params
Watchdog_Params params
Watchdog Parameters which were used to initialize the driver instance.
Definition: watchdog_rti.h:231
Watchdog_clear
void Watchdog_clear(Watchdog_Handle handle)
The function clears the Watchdog to prevent a reset signal from being generated if the module is in W...
Watchdog_deinit
void Watchdog_deinit(void)
The functions de-initializes the Watchdog module.
Watchdog_Params::expirationTime
uint32_t expirationTime
Definition: watchdog_rti.h:169
Watchdog_DriverState_UNINIT
@ Watchdog_DriverState_UNINIT
Driver is uninitialized.
Definition: watchdog_rti.h:205