BatMonSupportLPF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!****************************************************************************
33  * @file BatMonSupportLPF3.h
34  *
35  * @brief BatMon Support layer
36  *
37  * @anchor ti_drivers_batterymonitor_BatMonSupportLPF3_Overview
38  * # Overview #
39  * The purpose of the BatMon Support layer is to provide a way for multiple
40  * drivers to share the the BATMON hardware resource. The BATMON provides both
41  * temperature and supply voltage measurements. For this reason, both the
42  * Temperature driver and the Battery Monitor driver depends on the BATMON
43  * module.
44  *
45  * Only a combined interrupt request for BATMON exists, and this needs to be
46  * shared by multiple drivers.
47  *
48  * The two main services provided are:
49  * - Initializing the BATMON module
50  * - Dispatching the combined BATMON interrupt (AON_PMU_COMB) to registered
51  * callback functions
52  *
53  * @note The BatMon Support layer is not intended to be used by the application.
54  * It is only intended to be used by TI drivers.
55  *
56  * @anchor ti_drivers_batterymonitor_BatMonSupportLPF3_Usage
57  * # Usage #
58  *
59  * ## Initialisation #
60  * The BatMon Support layer needs to be initialized by calling
61  * #BatMonSupportLPF3_init().
62  * #BatMonSupportLPF3_init() should be called once before using other BatMon
63  * Support APIs. Subsequent #BatMonSupportLPF3_init() calls will have no
64  * effect.
65  *
66  * ## BATMON Event Callbacks #
67  * The main function of the BatMon Support layer is to dispatch the combined
68  * BATMON interrupt to registered callback functions when certain event flags
69  * are set.
70  *
71  * ### Registering Event Callbacks
72  * There are two functions that register an event callback:
73  * - #BatMonSupportLPF3_registerTemperatureCb()
74  * - #BatMonSupportLPF3_registerBatteryCb()
75  *
76  * Only one Temperature Callback and one Battery Callback can be registered,
77  * and registered callbacks cannot be unregistered.
78  *
79  * @anchor ti_drivers_batterymonitor_BatMonSupportLPF3_Synopsis
80  * # Synopsis #
81  * @anchor ti_drivers_batterymonitor_BatMonSupportLPF3_Code
82  * @code
83  * #include <ti/drivers/BatMonSupportLPF3.h>
84  *
85  * BatMonSupportLPF3_init();
86  *
87  * BatMonSupportLPF3_registerTemperatureCb(PMUD_EVENT_TEMP_BELOW_LL | PMUD_EVENT_TEMP_OVER_UL, myTempCb);
88  * BatMonSupportLPF3_registerBatteryCb(PMUD_EVENT_BATT_BELOW_LL | PMUD_EVENT_BATT_OVER_UL, myBattCb);
89  * @endcode
90  */
91 #ifndef ti_drivers_batterymonitor_BatMonSupportLPF3__include
92 #define ti_drivers_batterymonitor_BatMonSupportLPF3__include
93 
94 #include <stdbool.h>
95 #include <stddef.h>
96 #include <stdint.h>
97 
98 #include <ti/drivers/utils/List.h>
99 
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
103 
116 typedef struct
117 {
118  uint32_t intNum;
119  uint32_t intPriority;
120  uint32_t intMux;
122 
135 typedef void (*BatMonSupportLPF3_EventCb)(uint32_t eventFlags);
136 
144 extern void BatMonSupportLPF3_init(void);
145 
165 extern void BatMonSupportLPF3_registerTemperatureCb(uint32_t eventMask, BatMonSupportLPF3_EventCb callback);
166 
187 extern void BatMonSupportLPF3_registerBatteryCb(uint32_t eventMask, BatMonSupportLPF3_EventCb callback);
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* ti_drivers_batterymonitor_BatMonSupportLPF3__include */
uint32_t intPriority
Definition: BatMonSupportLPF3.h:119
void BatMonSupportLPF3_registerTemperatureCb(uint32_t eventMask, BatMonSupportLPF3_EventCb callback)
This function registers a callback dedicated for the Temperature driver.
void BatMonSupportLPF3_init(void)
This function initializes the BatMon Support layer.
BatMon Support Configuration.
Definition: BatMonSupportLPF3.h:116
void(* BatMonSupportLPF3_EventCb)(uint32_t eventFlags)
Function prototype for an event callback.
Definition: BatMonSupportLPF3.h:135
uint32_t intMux
Definition: BatMonSupportLPF3.h:120
uint32_t intNum
Definition: BatMonSupportLPF3.h:118
void BatMonSupportLPF3_registerBatteryCb(uint32_t eventMask, BatMonSupportLPF3_EventCb callback)
This function registers a callback dedicated for the Battery Monitor driver.
Linked List interface for use in drivers.
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale