CC13xx Driver Library
aon_batmon.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aon_batmon.h
3 * Revised: 2015-07-16 12:12:04 +0200 (Thu, 16 Jul 2015)
4 * Revision: 44151
5 *
6 * Description: Defines and prototypes for the AON Battery and Temperature
7 * Monitor
8 *
9 * Copyright (c) 2015, 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 //
73 // API Functions and prototypes
74 //
75 //*****************************************************************************
76 
77 //*****************************************************************************
78 //
103 //
104 //*****************************************************************************
105 __STATIC_INLINE void
107 {
108  //
109  // Enable the measurements.
110  //
114 }
115 
116 //*****************************************************************************
117 //
124 //
125 //*****************************************************************************
126 __STATIC_INLINE void
128 {
129  //
130  // Disable the measurements.
131  //
132  HWREG(AON_BATMON_BASE + AON_BATMON_O_CTL) = 0;
133 }
134 
135 
136 //*****************************************************************************
137 //
151 //
152 //*****************************************************************************
153 int32_t
155 
156 //*****************************************************************************
157 //
172 //
173 //*****************************************************************************
174 __STATIC_INLINE uint32_t
176 {
177  uint32_t ui32CurrentBattery;
178 
179  ui32CurrentBattery = HWREG(AON_BATMON_BASE + AON_BATMON_O_BAT);
180 
181  //
182  // Return the current battery voltage measurement.
183  //
184  return (ui32CurrentBattery >> AON_BATMON_BAT_FRAC_S);
185 }
186 
187 //*****************************************************************************
188 //
205 //
206 //*****************************************************************************
207 __STATIC_INLINE bool
209 {
210  bool bStatus;
211 
212  //
213  // Check the status bit.
214  //
215  bStatus = HWREG(AON_BATMON_BASE + AON_BATMON_O_BATUPD) &
216  AON_BATMON_BATUPD_STAT ? true : false;
217 
218  //
219  // Clear status bit if set.
220  //
221  if(bStatus)
222  {
224  }
225 
226  //
227  // Return status.
228  //
229  return (bStatus);
230 }
231 
232 //*****************************************************************************
233 //
250 //
251 //*****************************************************************************
252 __STATIC_INLINE bool
254 {
255  bool bStatus;
256 
257  //
258  // Check the status bit.
259  //
260  bStatus = HWREG(AON_BATMON_BASE + AON_BATMON_O_TEMPUPD) &
261  AON_BATMON_TEMPUPD_STAT ? true : false;
262 
263  //
264  // Clear status bit if set.
265  //
266  if(bStatus)
267  {
269  }
270 
271  //
272  // Return status.
273  //
274  return (bStatus);
275 }
276 
277 //*****************************************************************************
278 //
279 // Mark the end of the C bindings section for C++ compilers.
280 //
281 //*****************************************************************************
282 #ifdef __cplusplus
283 }
284 #endif
285 
286 #endif // __AON_BATMON_H__
287 
288 //*****************************************************************************
289 //
293 //
294 //*****************************************************************************
static void AONBatMonEnable(void)
Enable the temperature and battery monitoring.
Definition: aon_batmon.h:106
static bool AONBatMonNewBatteryMeasureReady(void)
Check if battery monitor measurement has changed.
Definition: aon_batmon.h:208
static void AONBatMonDisable(void)
Disable the temperature and battery monitoring.
Definition: aon_batmon.h:127
int32_t AONBatMonTemperatureGetDegC(void)
Get the current temperature measurement as a signed value in Deg Celsius.
Definition: aon_batmon.c:49
static uint32_t AONBatMonBatteryVoltageGet(void)
Get the battery monitor measurement.
Definition: aon_batmon.h:175
static bool AONBatMonNewTempMeasureReady(void)
Check if temperature monitor measurement has changed.
Definition: aon_batmon.h:253