~aleteoryx/muditaos

ref: sign_test muditaos/module-bsp/bsp/lpm/bsp_lpm.hpp -rw-r--r-- 2.0 KiB
a217eeb3 — Dawid Wojtas [BH-2024] Fix lack of alarm directory after updating software 1 year, 5 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <optional>
#include <memory>
#include <bsp/common.hpp>

namespace drivers
{
    class DriverSEMC;
}

namespace bsp
{
    class LowPowerMode
    {
      public:
        enum class OscillatorSource
        {
            External,
            Internal
        };
        
        enum class RebootType
        {
            NormalRestart,
            GoToRecoveryUpdate,       //! Goto recovery into the update mode
            GoToRecoveryFactoryReset, //! GOto recovery into the factory reset mode
            GoToRecoveryRecovery,     //! Goto to recovery into recovery mode
            GoToRecoveryBackup,       //! Goto to recovery into backup mode
            GoToRecoveryRestore,      //! Goto to recovery into restore mode
            GoToMSC                   //! Goto msc mode 
        };

        LowPowerMode()          = default;
        virtual ~LowPowerMode() = default;

        static std::optional<std::unique_ptr<LowPowerMode>> Create();

        virtual std::int32_t PowerOff()                = 0;
        virtual std::int32_t Reboot(RebootType reason) = 0;

        virtual void SetCpuFrequency(CpuFrequencyMHz freq) = 0;
        [[nodiscard]] CpuFrequencyMHz GetCurrentFrequencyLevel() const noexcept;
        [[nodiscard]] virtual std::uint32_t GetCpuFrequency() const noexcept = 0;

        virtual void SwitchOscillatorSource(OscillatorSource source) = 0;

        virtual void EnableDcdcPowerSaveMode()  = 0;
        virtual void DisableDcdcPowerSaveMode() = 0;

        virtual void AllowEnteringWfiMode() = 0;
        virtual void BlockEnteringWfiMode() = 0;
        virtual std::uint32_t EnterWfiModeIfAllowed() = 0;
        virtual std::uint32_t GetLastTimeSpentInWfi() = 0;

        virtual void DisableSysTick() = 0;
        virtual void EnableSysTick() = 0;
      protected:
        CpuFrequencyMHz currentFrequency = CpuFrequencyMHz::Level_6;
    };
} // namespace bsp