1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/nrf5x: use IS_ACTIVE to enable the DCDC conv

This commit is contained in:
Hauke Petersen 2021-02-12 10:57:19 +01:00
parent f69fcc162b
commit cc2df0c508
2 changed files with 23 additions and 12 deletions

View File

@ -3,3 +3,10 @@ USEMODULE += nrf5x_common_periph
# link common cpu code
USEMODULE += cpu_common
# per default, enable DCDC converter if an external LC filter is provided
# reg1 feature denotes state 1 on two-stage regulator models or the single
# state in single-regulator models
FEATURES_OPTIONAL += vdd_lc_filter_reg1
# reg0 feature denotes stage 0 two-stage regulator models
FEATURES_OPTIONAL += vdd_lc_filter_reg0

View File

@ -32,26 +32,30 @@ extern "C" {
/**
* @brief Enable the internal DC/DC power converter for the NRF5x MCU.
*
* The internal DC/DC converter is more efficient compared to the LDO regulator.
* The downside of the DC/DC converter is that it requires an external inductor
* to be present on the board. Enabling the DC/DC converter is guarded with
* NRF5X_ENABLE_DCDC, this macro must be defined if the DC/DC converter is to be
* enabled.
* In most cases, the internal DC/DC converter is more efficient compared to the
* LDO regulator. The downside of the DC/DC converter is that it requires an
* external LC filter to be present on the board. Per default, the DC/DC
* converter is enabled if an LC filter is present (VDD_LC_FILTER_REGx feature).
*
* Independent of the presence of the LC filter, the DC/DC converter(s) can be
* disabled by blacklisting the VDD_LC_FILTER_REGx feature, e.g. build using
* `FEATURES_BLACKLIST=VDD_LC_FILTER_REG1 make all`.
*/
static inline void nrfx_dcdc_init(void)
{
#ifdef NRF5X_ENABLE_DCDC
NRF_POWER->DCDCEN = 1;
if (IS_ACTIVE(MODULE_VDD_LC_FILTER_REG1)) {
NRF_POWER->DCDCEN = 1;
}
/* on CPUs that support high voltage power supply via VDDH and thus use a
* two stage regulator, we also enable the DC/DC converter for the first
* state. */
#ifdef POWER_DCDCEN0_DCDCEN_Msk
if (NRF_POWER->MAINREGSTATUS == POWER_MAINREGSTATUS_MAINREGSTATUS_High) {
/* on CPUs that support high voltage power supply via VDDH and thus use a
* two stage regulator, we also try to enable the DC/DC converter for the
* first stage */
if (IS_ACTIVE(MODULE_VDD_LC_FILTER_REG0) &&
(NRF_POWER->MAINREGSTATUS == POWER_MAINREGSTATUS_MAINREGSTATUS_High)) {
NRF_POWER->DCDCEN0 = 1;
}
#endif
#endif
}
#ifdef __cplusplus