2020-2021 Sunseeker Telemetry and Lighting System
ldopwr.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // ldopwr.c - Driver for the ldopwr Module.
4 //
5 //*****************************************************************************
6 
7 //*****************************************************************************
8 //
11 //
12 //*****************************************************************************
13 
14 #include "inc/hw_memmap.h"
15 
16 #ifdef __MSP430_HAS_PU__
17 #include "ldopwr.h"
18 
19 #include <assert.h>
20 
21 void LDOPWR_unLockConfiguration ( uint16_t baseAddress )
22 {
23  HWREG16(baseAddress + OFS_LDOKEYPID) = 0x9628;
24 }
25 
26 void LDOPWR_lockConfiguration ( uint16_t baseAddress )
27 {
28  HWREG16(baseAddress + OFS_LDOKEYPID) = 0x0000;
29 }
30 
31 void LDOPWR_enablePort_U_inputs (uint16_t baseAddress )
32 {
33  HWREG8(baseAddress + OFS_PUCTL_H) |= PUIPE_H;
34 }
35 
36 void LDOPWR_disablePort_U_inputs (uint16_t baseAddress )
37 {
38  HWREG8(baseAddress + OFS_PUCTL_H) &= ~PUIPE_H;
39 }
40 
41 void LDOPWR_enablePort_U_outputs (uint16_t baseAddress )
42 {
43  HWREG8(baseAddress + OFS_PUCTL_L) |= PUOPE;
44 }
45 
46 void LDOPWR_disablePort_U_outputs (uint16_t baseAddress )
47 {
48  HWREG8(baseAddress + OFS_PUCTL_L) &= ~PUOPE;
49 }
50 
51 uint8_t LDOPWR_getPort_U1_inputData (uint16_t baseAddress )
52 {
53  return ((HWREG8(baseAddress + OFS_PUCTL_L) & PUIN1) >> 3 );
54 }
55 
56 uint8_t LDOPWR_getPort_U0_inputData (uint16_t baseAddress )
57 {
58  return ((HWREG8(baseAddress + OFS_PUCTL_L) & PUIN0) >> 2 );
59 }
60 
61 uint8_t LDOPWR_getPort_U1_outputData (uint16_t baseAddress )
62 {
63  return ((HWREG8(baseAddress + OFS_PUCTL_L) & PUOUT1) >> 1 );
64 }
65 
66 uint8_t LDOPWR_getPort_U0_outputData (uint16_t baseAddress )
67 {
68  return (HWREG8(baseAddress + OFS_PUCTL_L) & PUOUT0);
69 }
70 
71 void LDOPWR_setPort_U1_outputData (uint16_t baseAddress,
72  uint8_t value
73  )
74 {
75  if (LDOPWR_PORTU_PIN_HIGH == value){
76  HWREG8(baseAddress + OFS_PUCTL_L) |= PUOUT1;
77  } else {
78  HWREG8(baseAddress + OFS_PUCTL_L) &= ~PUOUT1;
79  }
80 }
81 
82 void LDOPWR_setPort_U0_outputData (uint16_t baseAddress,
83  uint8_t value
84  )
85 {
86  if (LDOPWR_PORTU_PIN_HIGH == value){
87  HWREG8(baseAddress + OFS_PUCTL_L) |= PUOUT0;
88  } else {
89  HWREG8(baseAddress + OFS_PUCTL_L) &= ~PUOUT0;
90  }
91 }
92 
93 void LDOPWR_togglePort_U1_outputData (uint16_t baseAddress)
94 {
95  HWREG8(baseAddress + OFS_PUCTL_L) ^= PUOUT1;
96 }
97 
98 void LDOPWR_togglePort_U0_outputData (uint16_t baseAddress)
99 {
100  HWREG8(baseAddress + OFS_PUCTL_L) ^= PUOUT0;
101 }
102 
103 void LDOPWR_enableInterrupt (uint16_t baseAddress,
104  uint16_t mask
105  )
106 {
107  HWREG8(baseAddress + OFS_LDOPWRCTL_H) |= mask;
108 }
109 
110 void LDOPWR_disableInterrupt (uint16_t baseAddress,
111  uint16_t mask
112  )
113 {
114  HWREG8(baseAddress + OFS_LDOPWRCTL_H) &= ~mask;
115 }
116 
117 void LDOPWR_enable (uint16_t baseAddress)
118 {
119  HWREG8(baseAddress + OFS_LDOPWRCTL_H) |= LDOOEN_H;
120 }
121 
122 void LDOPWR_disable (uint16_t baseAddress)
123 {
124  HWREG8(baseAddress + OFS_LDOPWRCTL_H) &= ~LDOOEN_H;
125 }
126 
127 uint8_t LDOPWR_getInterruptStatus (uint16_t baseAddress,
128  uint16_t mask
129  )
130 {
131  return (HWREG8(baseAddress + OFS_LDOPWRCTL_L) & mask);
132 }
133 
134 void LDOPWR_clearInterrupt (uint16_t baseAddress,
135  uint16_t mask
136  )
137 {
138  HWREG8(baseAddress + OFS_LDOPWRCTL_L) &= ~mask;
139 }
140 
141 uint8_t LDOPWR_isLDOInputValid (uint16_t baseAddress)
142 {
143  return (HWREG8(baseAddress + OFS_LDOPWRCTL_L) & LDOBGVBV);
144 }
145 
146 void LDOPWR_enableOverloadAutoOff (uint16_t baseAddress)
147 {
148  HWREG8(baseAddress + OFS_LDOPWRCTL_L) |= OVLAOFF_L;
149 }
150 
151 void LDOPWR_disableOverloadAutoOff (uint16_t baseAddress)
152 {
153  HWREG8(baseAddress + OFS_LDOPWRCTL_L) &= ~OVLAOFF_L;
154 }
155 
156 uint8_t LDOPWR_getOverloadAutoOffStatus (uint16_t baseAddress)
157 {
158  return (HWREG8(baseAddress + OFS_LDOPWRCTL_L) & OVLAOFF_L);
159 }
160 
161 #endif
162 //*****************************************************************************
163 //
166 //
167 //*****************************************************************************
#define HWREG8(x)
Definition: hw_memmap.h:41
#define HWREG16(x)
Definition: hw_memmap.h:39