2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * o Redistributions of source code must retain the above copyright notice, this list
9 * of conditions and the following disclaimer.
11 * o Redistributions in binary form must reproduce the above copyright notice, this
12 * list of conditions and the following disclaimer in the documentation and/or
13 * other materials provided with the distribution.
15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #if !defined(__FSL_PMC_HAL_H__)
31 #define __FSL_PMC_HAL_H__
36 #include "fsl_device_registers.h"
37 #include "fsl_pmc_features.h"
39 /*! @addtogroup pmc_hal*/
42 /*! @file fsl_pmc_hal.h */
44 /*******************************************************************************
46 ******************************************************************************/
48 /*! @brief Low-Voltage Warning Voltage Select*/
49 typedef enum _pmc_low_volt_warn_volt_select {
50 kPmcLowVoltWarnVoltLowTrip, /*!< Low trip point selected (VLVW = VLVW1)*/
51 kPmcLowVoltWarnVoltMid1Trip, /*!< Mid 1 trip point selected (VLVW = VLVW2)*/
52 kPmcLowVoltWarnVoltMid2Trip, /*!< Mid 2 trip point selected (VLVW = VLVW3)*/
53 kPmcLowVoltWarnVoltHighTrip /*!< High trip point selected (VLVW = VLVW4)*/
54 } pmc_low_volt_warn_volt_select_t;
56 /*! @brief Low-Voltage Detect Voltage Select*/
57 typedef enum _pmc_low_volt_detect_volt_select {
58 kPmcLowVoltDetectVoltLowTrip, /*!< Low trip point selected (V LVD = V LVDL )*/
59 kPmcLowVoltDetectVoltHighTrip, /*!< High trip point selected (V LVD = V LVDH )*/
60 } pmc_low_volt_detect_volt_select_t;
62 /*! @brief interrupt control*/
63 typedef enum _pmc_int_select {
64 kPmcIntLowVoltDetect, /*!< Low Voltage Detect Interrupt */
65 kPmcIntLowVoltWarn, /*!< Low Voltage Warning Interrupt */
68 /*******************************************************************************
70 ******************************************************************************/
72 #if defined(__cplusplus)
74 #endif /* __cplusplus*/
76 /*! @name Power Management Controller Control APIs*/
81 * @brief Enables/Disables low voltage-related interrupts.
83 * This function enables the interrupt for the low voltage detection, warning,
84 * etc. When enabled, if the LVDF (Low Voltage Detect Flag) is set, a hardware
87 * @param baseAddr Base address for current PMC instance.
88 * @param intSelect interrut select
89 * @param enable enable/disable the interrupt
91 void PMC_HAL_SetLowVoltIntCmd(uint32_t baseAddr, pmc_int_select_t intSelect, bool enable);
94 * @brief Low-Voltage Detect Hardware Reset Enable/Disable (write once)
96 * This function enables/disables the hardware reset for the low voltage
97 * detection. When enabled, if the LVDF (Low Voltage Detect Flag) is set, a
98 * hardware reset occurs. This setting is a write-once-only. Any additional writes
101 * @param baseAddr Base address for current PMC instance.
102 * @param enable enable/disable the LVD hardware reset
104 static inline void PMC_HAL_SetLowVoltDetectResetCmd(uint32_t baseAddr, bool enable)
106 BW_PMC_LVDSC1_LVDRE(baseAddr, (uint8_t)enable);
110 * @brief Low-Voltage Detect Acknowledge
112 * This function acknowledges the low voltage detection errors (write 1 to
115 * @param baseAddr Base address for current PMC instance.
117 static inline void PMC_HAL_SetLowVoltDetectAck(uint32_t baseAddr)
119 BW_PMC_LVDSC1_LVDACK(baseAddr, 1);
123 * @brief Low-Voltage Detect Flag Read
125 * This function reads the current LVDF status. If it returns 1, a low
126 * voltage event is detected.
128 * @param baseAddr Base address for current PMC instance.
129 * @return status Current low voltage detect flag
130 * - true: Low-Voltage detected
131 * - false: Low-Voltage not detected
133 static inline bool PMC_HAL_GetLowVoltDetectFlag(uint32_t baseAddr)
135 return BR_PMC_LVDSC1_LVDF(baseAddr);
139 * @brief Sets the Low-Voltage Detect Voltage Mode
141 * This function sets the low voltage detect voltage select. It sets
142 * the low voltage detect trip point voltage (Vlvd). An application can select
143 * either a low-trip or a high-trip point. See a chip reference manual for details.
145 * @param baseAddr Base address for current PMC instance.
146 * @param select Voltage select setting defined in pmc_lvdv_select_t
148 static inline void PMC_HAL_SetLowVoltDetectVoltMode(uint32_t baseAddr, pmc_low_volt_detect_volt_select_t select)
150 BW_PMC_LVDSC1_LVDV(baseAddr, select);
154 * @brief Gets the Low-Voltage Detect Voltage Mode
156 * This function gets the low voltage detect voltage select. It gets
157 * the low voltage detect trip point voltage (Vlvd). An application can select
158 * either a low-trip or a high-trip point. See a chip reference manual for details.
160 * @param baseAddr Base address for current PMC instance.
161 * @return select Current voltage select setting
163 static inline pmc_low_volt_detect_volt_select_t PMC_HAL_GetLowVoltDetectVoltMode(uint32_t baseAddr)
165 return (pmc_low_volt_detect_volt_select_t)BR_PMC_LVDSC1_LVDV(baseAddr);
169 * @brief Low-Voltage Warning Acknowledge
171 * This function acknowledges the low voltage warning errors (write 1 to
174 * @param baseAddr Base address for current PMC instance.
176 static inline void PMC_HAL_SetLowVoltWarnAck(uint32_t baseAddr)
178 BW_PMC_LVDSC2_LVWACK(baseAddr, 1);
182 * @brief Low-Voltage Warning Flag Read
184 * This function polls the current LVWF status. When 1 is returned, it
185 * indicates a low-voltage warning event. LVWF is set when V Supply transitions
186 * below the trip point or after reset and V Supply is already below the V LVW.
188 * @param baseAddr Base address for current PMC instance.
189 * @return status Current LVWF status
190 * - true: Low-Voltage Warning Flag is set.
191 * - false: the Low-Voltage Warning does not happen.
193 static inline bool PMC_HAL_GetLowVoltWarnFlag(uint32_t baseAddr)
195 return BR_PMC_LVDSC2_LVWF(baseAddr);
199 * @brief Sets the Low-Voltage Warning Voltage Mode.
201 * This function sets the low voltage warning voltage select. It sets
202 * the low voltage warning trip point voltage (Vlvw). An application can select
203 * either a low, mid1, mid2 and a high-trip point. See a chip reference manual for
204 * details and the pmc_lvwv_select_t for supported settings.
206 * @param baseAddr Base address for current PMC instance.
207 * @param select Low voltage warning select setting
209 static inline void PMC_HAL_SetLowVoltWarnVoltMode(uint32_t baseAddr, pmc_low_volt_warn_volt_select_t select)
211 BW_PMC_LVDSC2_LVWV(baseAddr, select);
215 * @brief Gets the Low-Voltage Warning Voltage Mode.
217 * This function gets the low voltage warning voltage select. It gets
218 * the low voltage warning trip point voltage (Vlvw). See the pmc_lvwv_select_t
219 * for supported settings.
221 * @param baseAddr Base address for current PMC instance.
222 * @return select Current low voltage warning select setting
224 static inline pmc_low_volt_warn_volt_select_t PMC_HAL_GetLowVoltWarnVoltMode(uint32_t baseAddr)
226 return (pmc_low_volt_warn_volt_select_t)BR_PMC_LVDSC2_LVWV(baseAddr);
229 #if FSL_FEATURE_PMC_HAS_BGEN
231 * @brief Enables the Bandgap in the VLPx Operation.
233 * This function enables/disables the bandgap in lower power modes
234 * (VLPx, * LLS, and VLLSx). When on-chip peripherals require the bandgap voltage
235 * reference in low power modes, set the BGEN to continue to enable
236 * the bandgap operation.
238 * @param baseAddr Base address for current PMC instance.
239 * @param enable enable/disable the Bangap.
241 static inline void PMC_HAL_SetBandgapInLowPowerModeCmd(uint32_t baseAddr, bool enable)
243 BW_PMC_REGSC_BGEN(baseAddr, enable);
248 * @brief Enables/Disables the Bandgap Buffer.
250 * This function enables/disables the Bandgap buffer.
252 * @param baseAddr Base address for current PMC instance.
253 * @param enable enable/disable the Bangap Buffer.
255 static inline void PMC_HAL_SetBandgapBufferCmd(uint32_t baseAddr, bool enable)
257 BW_PMC_REGSC_BGBE(baseAddr, enable);
261 * @brief Gets the acknowledge isolation value.
263 * This function reads the Acknowledge Isolation setting that indicates
264 * whether certain peripherals and the I/O pads are in a latched state as
265 * a result of having been in the VLLS mode.
267 * @param baseAddr Base address for current PMC instance.
268 * @return value ACK isolation
269 * 0 - Peripherals and I/O pads are in a normal run state.
270 * 1 - Certain peripherals and I/O pads are in an isolated and
273 static inline uint8_t PMC_HAL_GetAckIsolation(uint32_t baseAddr)
275 return BR_PMC_REGSC_ACKISO(baseAddr);
279 * @brief Clears an acknowledge isolation.
281 * This function clears the ACK Isolation flag. Writing one to this setting
282 * when it is set releases the I/O pads and certain peripherals to their normal
285 * @param baseAddr Base address for current PMC instance.
287 static inline void PMC_HAL_SetClearAckIsolation(uint32_t baseAddr)
289 BW_PMC_REGSC_ACKISO(baseAddr, 1);
293 * @brief Gets the Regulator regulation status.
295 * This function returns the regulator to a run regulation status. It provides
296 * the current status of the internal voltage regulator.
298 * @param baseAddr Base address for current PMC instance.
299 * @return value Regulation status
300 * 0 - Regulator is in a stop regulation or in transition to/from it.
301 * 1 - Regulator is in a run regulation.
304 static inline uint8_t PMC_HAL_GetRegulatorStatus(uint32_t baseAddr)
306 return BR_PMC_REGSC_REGONS(baseAddr);
311 #if defined(__cplusplus)
313 #endif /* __cplusplus*/
317 #endif /* __FSL_PMC_HAL_H__*/
318 /*******************************************************************************
320 ******************************************************************************/