MSP430 DriverLib for MSP430F5xx_6xx Devices  2.80.00.01
 All Data Structures Functions Variables Modules Pages
battbak.h
1 //*****************************************************************************
2 //
3 // battbak.h - Driver for the BATTBAK Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_BATTBAK_H__
8 #define __MSP430WARE_BATTBAK_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_BATTERY_CHARGER__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 //*****************************************************************************
26 //
27 // The following are values that can be passed toThe following are values that
28 // can be returned by the BattBak_unlockBackupSubSystem() function.
29 //
30 //*****************************************************************************
31 #define BATTBAK_UNLOCKFAILURE (LOCKBAK)
32 #define BATTBAK_UNLOCKSUCCESS (0x0)
33 
34 //*****************************************************************************
35 //
36 // The following are values that can be passed to the chargerEndVoltage
37 // parameter for functions: BattBak_initAndEnableCharger().
38 //
39 //*****************************************************************************
40 #define BATTBAK_CHARGERENDVOLTAGE_VCC (BAKCHV0)
41 #define BATTBAK_CHARGERENDVOLTAGE2_7V (BAKCHV1)
42 
43 //*****************************************************************************
44 //
45 // The following are values that can be passed to the chargeCurrent parameter
46 // for functions: BattBak_initAndEnableCharger().
47 //
48 //*****************************************************************************
49 #define BATTBAK_CHARGECURRENT_5KOHM (BAKCHC0)
50 #define BATTBAK_CHARGECURRENT_10KOHM (BAKCHC1)
51 #define BATTBAK_CHARGECURRENT_20KOHM (BAKCHC0 + BAKCHC1)
52 
53 //*****************************************************************************
54 //
55 // The following are values that can be passed to the backupRAMSelect parameter
56 // for functions: BattBak_setBackupRAMData(), and BattBak_getBackupRAMData().
57 //
58 //*****************************************************************************
59 #define BATTBAK_RAMSELECT_0 (0x0000)
60 #define BATTBAK_RAMSELECT_1 (0x0002)
61 #define BATTBAK_RAMSELECT_2 (0x0004)
62 #define BATTBAK_RAMSELECT_3 (0x0006)
63 
64 //*****************************************************************************
65 //
66 // Prototypes for the APIs.
67 //
68 //*****************************************************************************
69 
70 //*****************************************************************************
71 //
72 //! \brief Unlocks any pending backup input pins and RTC_B interrupts to be
73 //! serviced.
74 //!
75 //! This function unlocks the ability to view and service any pending backup
76 //! input pin interrupts, as well as pending RTC_B interrupts. The backup sub-
77 //! system can only be unlocked when the backup domain has settled, so this
78 //! function returns the status of the unlock bit after it has been to be
79 //! verified by user code. Please note, the backup sub-system should only be
80 //! unlocked after modifying the RTC_B registers.
81 //!
82 //! \param baseAddress is the base address of the BATTBAK module.
83 //!
84 //! \return One of the following:
85 //! - \b BattBak_UNLOCKFAILURE backup system has not yet settled
86 //! - \b BattBak_UNLOCKSUCCESS successfully unlocked
87 //! \n indicating if the backup system has been successfully unlocked
88 //
89 //*****************************************************************************
90 extern uint16_t BattBak_unlockBackupSubSystem(uint16_t baseAddress);
91 
92 //*****************************************************************************
93 //
94 //! \brief Enables the backup supply to be measured by the ADC battery monitor
95 //! input.
96 //!
97 //! This function enables the backup supply signal to be monitored by the ADC
98 //! battery supply monitor input, to allow a measurement of the voltage from
99 //! the backup battery.
100 //!
101 //! \param baseAddress is the base address of the BATTBAK module.
102 //!
103 //! \return None
104 //
105 //*****************************************************************************
106 extern void BattBak_enableBackupSupplyToADC(uint16_t baseAddress);
107 
108 //*****************************************************************************
109 //
110 //! \brief Disables the backup supply input to the ADC module.
111 //!
112 //! This function disables the ability to monitor the backup supply voltage
113 //! from the ADC battery monitor input.
114 //!
115 //! \param baseAddress is the base address of the BATTBAK module.
116 //!
117 //! \return None
118 //
119 //*****************************************************************************
120 extern void BattBak_disableBackupSupplyToADC(uint16_t baseAddress);
121 
122 //*****************************************************************************
123 //
124 //! \brief Manually switches to backup supply.
125 //!
126 //! This function uses software to manually switch to the backup battery
127 //! supply. Once this bit is set, it will be automatically reset by a POR and
128 //! the system returns to an automatic switch to backup supply.
129 //!
130 //! \param baseAddress is the base address of the BATTBAK module.
131 //!
132 //! \return None
133 //
134 //*****************************************************************************
135 extern void BattBak_switchToBackupSupplyManually(uint16_t baseAddress);
136 
137 //*****************************************************************************
138 //
139 //! \brief Disables backup battery system.
140 //!
141 //! This function disables the battery backup system from being used. The
142 //! battery backup system is re-enabled after a power cycle.
143 //!
144 //! \param baseAddress is the base address of the BATTBAK module.
145 //!
146 //! \return None
147 //
148 //*****************************************************************************
149 extern void BattBak_disable(uint16_t baseAddress);
150 
151 //*****************************************************************************
152 //
153 //! \brief Initializes and enables the backup battery charger.
154 //!
155 //! This function initializes the backup battery charger with the selected
156 //! settings.
157 //!
158 //! \param baseAddress is the base address of the BATTBAK module.
159 //! \param chargerEndVoltage is the maximum voltage to charge the backup
160 //! battery to.
161 //! Valid values are:
162 //! - \b BATTBAK_CHARGERENDVOLTAGE_VCC - charges backup battery up to
163 //! Vcc
164 //! - \b BATTBAK_CHARGERENDVOLTAGE2_7V - charges backup battery up to
165 //! 2.7V OR up to Vcc if Vcc is less than 2.7V.
166 //! \n Modified bits are \b BAKCHVx of \b BAKCHCTL register.
167 //! \param chargeCurrent is the maximum current to charge the backup battery
168 //! at.
169 //! Valid values are:
170 //! - \b BATTBAK_CHARGECURRENT_5KOHM
171 //! - \b BATTBAK_CHARGECURRENT_10KOHM
172 //! - \b BATTBAK_CHARGECURRENT_20KOHM
173 //! \n Modified bits are \b BAKCHCx of \b BAKCHCTL register.
174 //!
175 //! \return None
176 //
177 //*****************************************************************************
178 extern void BattBak_initAndEnableCharger(uint16_t baseAddress,
179  uint8_t chargerEndVoltage,
180  uint8_t chargeCurrent);
181 
182 //*****************************************************************************
183 //
184 //! \brief Disables and resets backup battery charger settings.
185 //!
186 //! This function clears all backup battery charger settings and disables it.
187 //! To re-enable the charger, a call to BattBak_initAndEnableCharger() is
188 //! required.
189 //!
190 //! \param baseAddress is the base address of the BATTBAK module.
191 //!
192 //! \return None
193 //
194 //*****************************************************************************
195 extern void BattBak_disableCharger(uint16_t baseAddress);
196 
197 //*****************************************************************************
198 //
199 //! \brief Sets data into the selected backup RAM space.
200 //!
201 //! This function sets the given 16-bit data into the selected backup RAM
202 //! space.
203 //!
204 //! \param baseAddress is the base address of the BATTBAK module.
205 //! \param backupRAMSelect is the backup RAM space to set data into.
206 //! Valid values are:
207 //! - \b BATTBAK_RAMSELECT_0
208 //! - \b BATTBAK_RAMSELECT_1
209 //! - \b BATTBAK_RAMSELECT_2
210 //! - \b BATTBAK_RAMSELECT_3
211 //! \param data is the data to set into the selected backup RAM space.
212 //!
213 //! \return None
214 //
215 //*****************************************************************************
216 extern void BattBak_setBackupRAMData(uint16_t baseAddress,
217  uint8_t backupRAMSelect,
218  uint16_t data);
219 
220 //*****************************************************************************
221 //
222 //! \brief Returns the data from the selected backup RAM space.
223 //!
224 //! This function returns the 16-bit data currently residing in the selected
225 //! backup RAM space.
226 //!
227 //! \param baseAddress is the base address of the BATTBAK module.
228 //! \param backupRAMSelect is the backup RAM space to read out from.
229 //! Valid values are:
230 //! - \b BATTBAK_RAMSELECT_0
231 //! - \b BATTBAK_RAMSELECT_1
232 //! - \b BATTBAK_RAMSELECT_2
233 //! - \b BATTBAK_RAMSELECT_3
234 //!
235 //! \return Data residing in the selected backup RAM space.
236 //
237 //*****************************************************************************
238 extern uint16_t BattBak_getBackupRAMData(uint16_t baseAddress,
239  uint8_t backupRAMSelect);
240 
241 //*****************************************************************************
242 //
243 // Mark the end of the C bindings section for C++ compilers.
244 //
245 //*****************************************************************************
246 #ifdef __cplusplus
247 }
248 #endif
249 
250 #endif
251 #endif // __MSP430WARE_BATTBAK_H__
void BattBak_disableBackupSupplyToADC(uint16_t baseAddress)
Disables the backup supply input to the ADC module.
Definition: battbak.c:32
void BattBak_disableCharger(uint16_t baseAddress)
Disables and resets backup battery charger settings.
Definition: battbak.c:55
void BattBak_disable(uint16_t baseAddress)
Disables backup battery system.
Definition: battbak.c:42
void BattBak_enableBackupSupplyToADC(uint16_t baseAddress)
Enables the backup supply to be measured by the ADC battery monitor input.
Definition: battbak.c:27
uint16_t BattBak_getBackupRAMData(uint16_t baseAddress, uint8_t backupRAMSelect)
Returns the data from the selected backup RAM space.
Definition: battbak.c:67
void BattBak_switchToBackupSupplyManually(uint16_t baseAddress)
Manually switches to backup supply.
Definition: battbak.c:37
uint16_t BattBak_unlockBackupSubSystem(uint16_t baseAddress)
Unlocks any pending backup input pins and RTC_B interrupts to be serviced.
Definition: battbak.c:21
void BattBak_initAndEnableCharger(uint16_t baseAddress, uint8_t chargerEndVoltage, uint8_t chargeCurrent)
Initializes and enables the backup battery charger.
Definition: battbak.c:47
void BattBak_setBackupRAMData(uint16_t baseAddress, uint8_t backupRAMSelect, uint16_t data)
Sets data into the selected backup RAM space.
Definition: battbak.c:60

Copyright 2016, Texas Instruments Incorporated