]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MSP430FR5969_LaunchPad/driverlib/MSP430FR5xx_6xx/wdt_a.c
bba45df8ccb63f84eac64ef4feafb0c641e0ef2b
[freertos] / FreeRTOS / Demo / MSP430FR5969_LaunchPad / driverlib / MSP430FR5xx_6xx / wdt_a.c
1 /* --COPYRIGHT--,BSD\r
2  * Copyright (c) 2014, Texas Instruments Incorporated\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  *\r
9  * *  Redistributions of source code must retain the above copyright\r
10  *    notice, this list of conditions and the following disclaimer.\r
11  *\r
12  * *  Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the distribution.\r
15  *\r
16  * *  Neither the name of Texas Instruments Incorporated nor the names of\r
17  *    its contributors may be used to endorse or promote products derived\r
18  *    from this software without specific prior written permission.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31  * --/COPYRIGHT--*/\r
32 //*****************************************************************************\r
33 //\r
34 // wdt_a.c - Driver for the wdt_a Module.\r
35 //\r
36 //*****************************************************************************\r
37 \r
38 //*****************************************************************************\r
39 //\r
40 //! \addtogroup wdt_a_api wdt_a\r
41 //! @{\r
42 //\r
43 //*****************************************************************************\r
44 \r
45 #include "inc/hw_regaccess.h"\r
46 #include "inc/hw_memmap.h"\r
47 \r
48 #ifdef __MSP430_HAS_WDT_A__\r
49 #include "wdt_a.h"\r
50 \r
51 #include <assert.h>\r
52 \r
53 void WDT_A_hold(uint16_t baseAddress)\r
54 {\r
55     // Set Hold bit\r
56     uint8_t newWDTStatus =\r
57         ((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) | WDTHOLD);\r
58 \r
59     HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;\r
60 }\r
61 \r
62 void WDT_A_start(uint16_t baseAddress)\r
63 {\r
64     // Reset Hold bit\r
65     uint8_t newWDTStatus =\r
66         ((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) & ~(WDTHOLD));\r
67 \r
68     HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;\r
69 }\r
70 \r
71 void WDT_A_resetTimer(uint16_t baseAddress)\r
72 {\r
73     // Set Counter Clear bit\r
74     uint8_t newWDTStatus =\r
75         ((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) | WDTCNTCL);\r
76 \r
77     HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;\r
78 }\r
79 \r
80 void WDT_A_initWatchdogTimer(uint16_t baseAddress,\r
81                              uint8_t clockSelect,\r
82                              uint8_t clockDivider)\r
83 {\r
84     HWREG16(baseAddress + OFS_WDTCTL) =\r
85         WDTPW + WDTCNTCL + WDTHOLD + clockSelect + clockDivider;\r
86 }\r
87 \r
88 void WDT_A_initIntervalTimer(uint16_t baseAddress,\r
89                              uint8_t clockSelect,\r
90                              uint8_t clockDivider)\r
91 {\r
92     HWREG16(baseAddress + OFS_WDTCTL) =\r
93         WDTPW + WDTCNTCL + WDTHOLD + WDTTMSEL + clockSelect + clockDivider;\r
94 }\r
95 \r
96 #endif\r
97 //*****************************************************************************\r
98 //\r
99 //! Close the doxygen group for wdt_a_api\r
100 //! @}\r
101 //\r
102 //*****************************************************************************\r