~aleteoryx/muditaos

muditaos/module-bsp/board/rt1051/bsp/lpm/DCDC.cpp -rw-r--r-- 1.4 KiB
a405cad6Aleteoryx trim readme 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#include "DCDC.hpp"
#include "CpuFreqLPM.hpp"
#include <fsl_dcdc.h>

namespace bsp::dcdc
{
    void SwitchToOverdriveConfig()
    {
        /* Switch to CCM mode for improved stability */
        DCDC_BootIntoCCM(DCDC);

        /* Connect internal DCDC load resistor */
        DCDC->REG1 |= DCDC_REG1_REG_RLOAD_SW_MASK;

        /* Adjust target voltage to 1.275V */
        DCDC_AdjustTargetVoltage(DCDC, VDDRun_1275_mV, VDDStandby_925_mV);

        /* Disable FET ODRIVE */
        PMU->REG_CORE_CLR = PMU_REG_CORE_FET_ODRIVE_MASK;
    }

    void SwitchToRegularConfig()
    {
        /* Adjust target voltage to 1.15V */
        DCDC_AdjustTargetVoltage(DCDC, VDDRun_1150_mV, VDDStandby_925_mV);
    }

    void SwitchToLowPowerConfig()
    {
        /* Adjust target voltage to nominal 0.95V */
        DCDC_AdjustTargetVoltage(DCDC, VDDRun_950_mV, VDDStandby_925_mV);

        /* Switch to DCM mode to reduce current consumption */
        DCDC_BootIntoDCM(DCDC);

        /* Disconnect internal DCDC load resistor */
        DCDC->REG1 &= ~DCDC_REG1_REG_RLOAD_SW_MASK;

        /* Power down output range comparator */
        DCDC->REG0 |= DCDC_REG0_PWD_CMP_OFFSET_MASK;

        /* Enable FET ODRIVE */
        PMU->REG_CORE_SET = PMU_REG_CORE_FET_ODRIVE_MASK;
    }
} // namespace bsp::dcdc