2020-2021 Sunseeker Telemetry and Lighting System
wdt_a.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // wdt_a.c - Driver for the wdt_a Module.
4 //
5 //*****************************************************************************
6 
7 //*****************************************************************************
8 //
11 //
12 //*****************************************************************************
13 
14 #include "inc/hw_memmap.h"
15 
16 #ifdef __MSP430_HAS_WDT_A__
17 #include "wdt_a.h"
18 
19 #include <assert.h>
20 
21 void WDT_A_hold (uint16_t baseAddress)
22 {
23  // Set Hold bit
24  uint8_t newWDTStatus =
25  ((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) | WDTHOLD);
26 
27  HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;
28 }
29 
30 void WDT_A_start (uint16_t baseAddress)
31 {
32  // Reset Hold bit
33  uint8_t newWDTStatus =
34  ((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) & ~(WDTHOLD));
35 
36  HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;
37 }
38 
39 void WDT_A_resetTimer (uint16_t baseAddress)
40 {
41  // Set Counter Clear bit
42  uint8_t newWDTStatus =
43  ((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) | WDTCNTCL);
44 
45  HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;
46 }
47 
48 void WDT_A_initWatchdogTimer (uint16_t baseAddress,
49  uint8_t clockSelect,
50  uint8_t clockDivider)
51 {
52  HWREG16(baseAddress + OFS_WDTCTL) =
53  WDTPW + WDTCNTCL + WDTHOLD + clockSelect + clockDivider;
54 }
55 
56 void WDT_A_initIntervalTimer (uint16_t baseAddress,
57  uint8_t clockSelect,
58  uint8_t clockDivider)
59 {
60  HWREG16(baseAddress + OFS_WDTCTL) =
61  WDTPW + WDTCNTCL + WDTHOLD + WDTTMSEL + clockSelect + clockDivider;
62 }
63 
64 
65 #endif
66 //*****************************************************************************
67 //
70 //
71 //*****************************************************************************
#define HWREG16(x)
Definition: hw_memmap.h:39