MotorWare f2806x Driver API Documentation
wdog.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2015, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 #ifndef _WDOG_H_
33 #define _WDOG_H_
34 
41 
42 
43 // **************************************************************************
44 // the includes
45 
46 #include "sw/modules/types/src/types.h"
47 
49 
50 
55 
56 
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 
63 // **************************************************************************
64 // the defines
65 
66 
69 #define WDOG_BASE_ADDR (0x00007022)
70 
71 
74 #define WDOG_SCSR_WDOVERRIDE_BITS (1 << 0)
75 
78 #define WDOG_SCSR_WDENINT_BITS (1 << 1)
79 
82 #define WDOG_SCSR_WDINTS_BITS (1 << 2)
83 
84 
87 #define WDOG_WDCNTR_BITS (255 << 0)
88 
89 
92 #define WDOG_WDKEY_BITS (255 << 0)
93 
94 
97 #define WDOG_WDCR_WDPS_BITS (7 << 0)
98 
101 #define WDOG_WDCR_WDCHK_BITS (7 << 3)
102 
105 #define WDOG_WDCR_WDDIS_BITS (1 << 6)
106 
109 #define WDOG_WDCR_WDFLAG_BITS (1 << 7)
110 
111 
114 #define WDOG_WDCR_WRITE_ENABLE (5 << 3)
115 
116 
117 // **************************************************************************
118 // the typedefs
119 
120 
123 typedef enum
124 {
125  WDOG_IntStatus_Active=(0 << 2), // Denotes an active interrupt status
126  WDOG_IntStatus_InActive=(1 << 2) // Denotes an in-active interrupt status
128 
129 
132 typedef enum
133 {
142 
143 
146 typedef struct _WDOG_Obj_
147 {
148  volatile uint16_t SCSR;
149  volatile uint16_t WDCNTR;
150  volatile uint16_t rsvd_1;
151  volatile uint16_t WDKEY;
152  volatile uint16_t rsvd_2[3];
153  volatile uint16_t WDCR;
154 } WDOG_Obj;
155 
156 
159 typedef struct _WDOG_Obj_ *WDOG_Handle;
160 
161 
162 // **************************************************************************
163 // the globals
164 
165 
166 // **************************************************************************
167 // the function prototypes
168 
171 extern void WDOG_clearCounter(WDOG_Handle wdogHandle);
172 
173 
176 extern void WDOG_disable(WDOG_Handle wdogHandle);
177 
178 
181 extern void WDOG_disableInt(WDOG_Handle wdogHandle);
182 
183 
186 extern void WDOG_disableOverRide(WDOG_Handle wdogHandle);
187 
188 
191 extern void WDOG_enable(WDOG_Handle wdogHandle);
192 
193 
196 extern void WDOG_enableInt(WDOG_Handle wdogHandle);
197 
198 
201 extern void WDOG_enableOverRide(WDOG_Handle wdogHandle);
202 
203 
207 extern WDOG_IntStatus_e WDOG_getIntStatus(WDOG_Handle wdogHandle);
208 
209 
214 extern WDOG_Handle WDOG_init(void *pMemory,const size_t numBytes);
215 
216 
220 extern void WDOG_setCount(WDOG_Handle wdogHandle,const uint_least8_t count);
221 
222 
226 extern void WDOG_setPreScaler(WDOG_Handle wdogHandle,const WDOG_PreScaler_e preScaler);
227 
228 
229 #ifdef __cplusplus
230 }
231 #endif // extern "C"
232 
234 #endif // end of _WDOG_H_ definition
235 
WDOG_Handle WDOG_init(void *pMemory, const size_t numBytes)
Initializes the watchdog (WDOG) object handle.
Definition: wdog.c:192
Denotes WDCLK = OSCCLK/512/16.
Definition: wdog.h:138
Defines the watchdog (WDOG) object.
Definition: wdog.h:146
void WDOG_enable(WDOG_Handle wdogHandle)
Enables the watchdog (WDOG) timer.
Definition: wdog.c:128
Denotes WDCLK = OSCCLK/512/64.
Definition: wdog.h:140
struct _WDOG_Obj_ * WDOG_Handle
Defines the watchdog (WDOG) handle.
Definition: wdog.h:159
void WDOG_setCount(WDOG_Handle wdogHandle, const uint_least8_t count)
Sets the watchdog (WDOG) counter.
Definition: wdog.c:207
volatile uint16_t rsvd_2[3]
Reserved.
Definition: wdog.h:152
Denotes WDCLK = OSCCLK/512/32.
Definition: wdog.h:139
void WDOG_disableInt(WDOG_Handle wdogHandle)
Disables the watchdog (WDOG) timer interrupt.
Definition: wdog.c:96
volatile uint16_t rsvd_1
Reserved.
Definition: wdog.h:150
volatile uint16_t WDCR
Watchdog Control Register.
Definition: wdog.h:153
Denotes WDCLK = OSCCLK/512/4.
Definition: wdog.h:136
void WDOG_setPreScaler(WDOG_Handle wdogHandle, const WDOG_PreScaler_e preScaler)
Sets the watchdog (WDOG) timer clock prescaler.
Definition: wdog.c:219
void WDOG_enableInt(WDOG_Handle wdogHandle)
Enables the watchdog (WDOG) timer interrupt.
Definition: wdog.c:148
volatile uint16_t WDCNTR
Watchdog Counter Register.
Definition: wdog.h:149
struct _WDOG_Obj_ WDOG_Obj
Defines the watchdog (WDOG) object.
volatile uint16_t SCSR
System Control & Status Register.
Definition: wdog.h:148
Contains public interface to various functions related to the central processing unit (CPU) object...
void WDOG_clearCounter(WDOG_Handle wdogHandle)
Clears the watchdog (WDOG) counter.
Definition: wdog.c:57
WDOG_IntStatus_e WDOG_getIntStatus(WDOG_Handle wdogHandle)
Gets the watchdog (WDOG) interrupt status.
Definition: wdog.c:180
void WDOG_enableOverRide(WDOG_Handle wdogHandle)
Enables the watchdog (WDOG) timer override.
Definition: wdog.c:164
void WDOG_disable(WDOG_Handle wdogHandle)
Disables the watchdog (WDOG) timer.
Definition: wdog.c:76
volatile uint16_t WDKEY
Watchdog Reset Key Register.
Definition: wdog.h:151
WDOG_PreScaler_e
Enumeration to define the watchdog (WDOG) timer clock prescaler, which sets the clock frequency...
Definition: wdog.h:132
void WDOG_disableOverRide(WDOG_Handle wdogHandle)
Disables the timer override.
Definition: wdog.c:112
Denotes WDCLK = OSCCLK/512/1.
Definition: wdog.h:134
WDOG_IntStatus_e
Enumeration to define the watchdog (WDOG) interrupt status.
Definition: wdog.h:123
Denotes WDCLK = OSCCLK/512/8.
Definition: wdog.h:137
Denotes WDCLK = OSCCLK/512/2.
Definition: wdog.h:135