CC26xx Driver Library
aon_batmon.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aon_batmon.h
3 * Revised: 2016-06-30 09:21:03 +0200 (Thu, 30 Jun 2016)
4 * Revision: 46799
5 *
6 * Description: Defines and prototypes for the AON Battery and Temperature
7 * Monitor
8 *
9 * Copyright (c) 2015 - 2016, Texas Instruments Incorporated
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 *
15 * 1) Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 *
18 * 2) Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 *
22 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
23 * be used to endorse or promote products derived from this software without
24 * specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 *
38 ******************************************************************************/
39 
40 //*****************************************************************************
41 //
46 //
47 //*****************************************************************************
48 
49 #ifndef __AON_BATMON_H__
50 #define __AON_BATMON_H__
51 
52 //*****************************************************************************
53 //
54 // If building with a C++ compiler, make all of the definitions in this header
55 // have a C binding.
56 //
57 //*****************************************************************************
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63 #include <stdbool.h>
64 #include <stdint.h>
65 #include <inc/hw_types.h>
66 #include <inc/hw_memmap.h>
67 #include <inc/hw_aon_batmon.h>
68 #include <driverlib/debug.h>
69 
70 //*****************************************************************************
71 //
72 // Support for DriverLib in ROM:
73 // This section renames all functions that are not "static inline", so that
74 // calling these functions will default to implementation in flash. At the end
75 // of this file a second renaming will change the defaults to implementation in
76 // ROM for available functions.
77 //
78 // To force use of the implementation in flash, e.g. for debugging:
79 // - Globally: Define DRIVERLIB_NOROM at project level
80 // - Per function: Use prefix "NOROM_" when calling the function
81 //
82 //*****************************************************************************
83 #if !defined(DOXYGEN)
84  #define AONBatMonTemperatureGetDegC NOROM_AONBatMonTemperatureGetDegC
85 #endif
86 
87 
88 //*****************************************************************************
89 //
90 // API Functions and prototypes
91 //
92 //*****************************************************************************
93 
94 //*****************************************************************************
95 //
120 //
121 //*****************************************************************************
122 __STATIC_INLINE void
124 {
125  //
126  // Enable the measurements.
127  //
131 }
132 
133 //*****************************************************************************
134 //
141 //
142 //*****************************************************************************
143 __STATIC_INLINE void
145 {
146  //
147  // Disable the measurements.
148  //
149  HWREG(AON_BATMON_BASE + AON_BATMON_O_CTL) = 0;
150 }
151 
152 
153 //*****************************************************************************
154 //
168 //
169 //*****************************************************************************
170 extern int32_t AONBatMonTemperatureGetDegC( void );
171 
172 //*****************************************************************************
173 //
188 //
189 //*****************************************************************************
190 __STATIC_INLINE uint32_t
192 {
193  uint32_t ui32CurrentBattery;
194 
195  ui32CurrentBattery = HWREG(AON_BATMON_BASE + AON_BATMON_O_BAT);
196 
197  //
198  // Return the current battery voltage measurement.
199  //
200  return (ui32CurrentBattery >> AON_BATMON_BAT_FRAC_S);
201 }
202 
203 //*****************************************************************************
204 //
221 //
222 //*****************************************************************************
223 __STATIC_INLINE bool
225 {
226  bool bStatus;
227 
228  //
229  // Check the status bit.
230  //
231  bStatus = HWREG(AON_BATMON_BASE + AON_BATMON_O_BATUPD) &
232  AON_BATMON_BATUPD_STAT ? true : false;
233 
234  //
235  // Clear status bit if set.
236  //
237  if(bStatus)
238  {
240  }
241 
242  //
243  // Return status.
244  //
245  return (bStatus);
246 }
247 
248 //*****************************************************************************
249 //
266 //
267 //*****************************************************************************
268 __STATIC_INLINE bool
270 {
271  bool bStatus;
272 
273  //
274  // Check the status bit.
275  //
276  bStatus = HWREG(AON_BATMON_BASE + AON_BATMON_O_TEMPUPD) &
277  AON_BATMON_TEMPUPD_STAT ? true : false;
278 
279  //
280  // Clear status bit if set.
281  //
282  if(bStatus)
283  {
285  }
286 
287  //
288  // Return status.
289  //
290  return (bStatus);
291 }
292 
293 //*****************************************************************************
294 //
295 // Support for DriverLib in ROM:
296 // Redirect to implementation in ROM when available.
297 //
298 //*****************************************************************************
299 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
300  #include <driverlib/rom.h>
301  #ifdef ROM_AONBatMonTemperatureGetDegC
302  #undef AONBatMonTemperatureGetDegC
303  #define AONBatMonTemperatureGetDegC ROM_AONBatMonTemperatureGetDegC
304  #endif
305 #endif
306 
307 //*****************************************************************************
308 //
309 // Mark the end of the C bindings section for C++ compilers.
310 //
311 //*****************************************************************************
312 #ifdef __cplusplus
313 }
314 #endif
315 
316 #endif // __AON_BATMON_H__
317 
318 //*****************************************************************************
319 //
323 //
324 //*****************************************************************************
static void AONBatMonEnable(void)
Enable the temperature and battery monitoring.
Definition: aon_batmon.h:123
static bool AONBatMonNewBatteryMeasureReady(void)
Check if battery monitor measurement has changed.
Definition: aon_batmon.h:224
static void AONBatMonDisable(void)
Disable the temperature and battery monitoring.
Definition: aon_batmon.h:144
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
Definition: aon_batmon.c:60
static uint32_t AONBatMonBatteryVoltageGet(void)
Get the battery monitor measurement.
Definition: aon_batmon.h:191
static bool AONBatMonNewTempMeasureReady(void)
Check if temperature monitor measurement has changed.
Definition: aon_batmon.h:269