~aleteoryx/muditaos

1134a38584f2e84d7eb2a2de3fcc11ee2f280df5 — Maciej Gibowicz 4 years ago 8b50f65
[EGD-4875] Add internal load resistor switching

To reduce the power consumption, we disconnect
internal load resistor
M module-bsp/board/linux/lpm/LinuxLPM.cpp => module-bsp/board/linux/lpm/LinuxLPM.cpp +6 -0
@@ 45,4 45,10 @@ namespace bsp
    void LinuxLPM::DisableDcdcPowerSaveMode()
    {}

    void LinuxLPM::DisconnectInternalLoadResistor()
    {}

    void LinuxLPM::ConnectInternalLoadResistor()
    {}

} // namespace bsp

M module-bsp/board/linux/lpm/LinuxLPM.h => module-bsp/board/linux/lpm/LinuxLPM.h +3 -0
@@ 22,6 22,9 @@ namespace bsp

        void EnableDcdcPowerSaveMode() final;
        void DisableDcdcPowerSaveMode() final;

        void DisconnectInternalLoadResistor() final;
        void ConnectInternalLoadResistor() final;
    };

} // namespace bsp

M module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp => module-bsp/board/rt1051/bsp/lpm/RT1051LPM.cpp +10 -0
@@ 133,4 133,14 @@ namespace bsp
        gpio_2->WritePin(static_cast<uint32_t>(BoardDefinitions::DCDC_INVERTER_MODE_PIN), 1);
    }

    void RT1051LPM::DisconnectInternalLoadResistor()
    {
        DCDC->REG1 &= ~DCDC_REG1_REG_RLOAD_SW_MASK;
    }

    void RT1051LPM::ConnectInternalLoadResistor()
    {
        DCDC->REG1 |= DCDC_REG1_REG_RLOAD_SW_MASK;
    }

} // namespace bsp

M module-bsp/board/rt1051/bsp/lpm/RT1051LPM.hpp => module-bsp/board/rt1051/bsp/lpm/RT1051LPM.hpp +3 -0
@@ 25,6 25,9 @@ namespace bsp
        void EnableDcdcPowerSaveMode() final;
        void DisableDcdcPowerSaveMode() final;

        void DisconnectInternalLoadResistor() final;
        void ConnectInternalLoadResistor() final;

      private:
        std::shared_ptr<drivers::DriverGPIO> gpio_1;
        std::shared_ptr<drivers::DriverGPIO> gpio_2;

M module-bsp/bsp/lpm/bsp_lpm.hpp => module-bsp/bsp/lpm/bsp_lpm.hpp +3 -0
@@ 45,6 45,9 @@ namespace bsp
        virtual void EnableDcdcPowerSaveMode()  = 0;
        virtual void DisableDcdcPowerSaveMode() = 0;

        virtual void DisconnectInternalLoadResistor()  = 0;
        virtual void ConnectInternalLoadResistor() = 0;

      protected:
        CpuFrequencyHz currentFrequency = CpuFrequencyHz::Level_6;
    };

M module-sys/SystemManager/PowerManager.cpp => module-sys/SystemManager/PowerManager.cpp +5 -0
@@ 120,6 120,8 @@ namespace sys
        const auto freq = lowPowerControl->GetCurrentFrequencyLevel();

        if (freq == bsp::CpuFrequencyHz::Level_1) {
            // connect internal the load resistor
            lowPowerControl->ConnectInternalLoadResistor();
            // turn off power save mode for DCDC inverter
            lowPowerControl->DisableDcdcPowerSaveMode();
            // Switch DCDC to full throttle during oscillator switch


@@ 182,6 184,9 @@ namespace sys

            // turn on power save mode for DCDC inverter
            lowPowerControl->EnableDcdcPowerSaveMode();

            // disconnect internal the load resistor
            lowPowerControl->DisconnectInternalLoadResistor();
        }

        isFrequencyLoweringInProgress = true;