1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016, 2021 NXP
4  * All rights reserved.
5  *
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  */
9 #include "fsl_common.h"
10 #include "fsl_power.h"
11 /* Component ID definition, used by tools. */
12 #ifndef FSL_COMPONENT_ID
13 #define FSL_COMPONENT_ID "platform.drivers.power"
14 #endif
15 
16 /*******************************************************************************
17  * Code
18  ******************************************************************************/
19 
POWER_InitBod(const power_bod_config_t * bodConfig)20 void POWER_InitBod(const power_bod_config_t *bodConfig)
21 {
22     assert(bodConfig != NULL);
23 
24     uint32_t tmp32 = 0UL;
25 
26     tmp32 = SYSCON->BODCTRL;
27     tmp32 &= ~(SYSCON_BODCTRL_BODRSTLEV_MASK | SYSCON_BODCTRL_BODRSTENA_MASK | SYSCON_BODCTRL_BODINTLEV_MASK |
28                SYSCON_BODCTRL_BODINTENA_MASK | SYSCON_BODCTRL_BODRSTSTAT_MASK | SYSCON_BODCTRL_BODINTSTAT_MASK);
29     tmp32 |= SYSCON_BODCTRL_BODRSTLEV(bodConfig->resetLevel) | SYSCON_BODCTRL_BODRSTENA(bodConfig->enableReset) |
30              SYSCON_BODCTRL_BODINTLEV(bodConfig->interruptLevel) | SYSCON_BODCTRL_BODINTENA(bodConfig->enableInterrupt);
31     SYSCON->BODCTRL = tmp32;
32 }
33 
POWER_GetDefaultBodConfig(power_bod_config_t * bodConfig)34 void POWER_GetDefaultBodConfig(power_bod_config_t *bodConfig)
35 {
36     assert(bodConfig != NULL);
37 
38     bodConfig->enableReset     = true;
39     bodConfig->resetLevel      = kBod_ResetLevel0;
40     bodConfig->enableInterrupt = false;
41     bodConfig->interruptLevel  = kBod_InterruptLevel0;
42 }
43