~aleteoryx/muditaos

ref: 2b754af627a1d4d93fdbf28c79eab64db5ea72cd muditaos/module-bsp/bsp/lpm/bsp_lpm.hpp -rw-r--r-- 913 bytes
2b754af6 — Piotr Leniec [DW-31] Add a condition that prohibits checks to be run on draft PRs 5 years 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
#ifndef PUREPHONE_BSP_LPM_HPP
#define PUREPHONE_BSP_LPM_HPP

#include <optional>
#include <memory>

namespace bsp {

    class LowPowerMode
    {
      public:
        enum class CpuFrequency
        {
            Level_1, // 12 MHz
            Level_2, // 24 MHz
            Level_3, // 66 MHz
            Level_4, // 132 MHz
            Level_5, // 264 MHz
            Level_6  // 528 MHz
        };

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

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

        virtual int32_t PowerOff() = 0;
        virtual int32_t Reboot() = 0;
        virtual void SetCpuFrequency(CpuFrequency freq) = 0;
        [[nodiscard]] CpuFrequency GetCurrentFrequency() const noexcept;

    protected:
        CpuFrequency currentFrequency = CpuFrequency::Level_6;
    };
} // namespace bsp

#endif //PUREPHONE_BSP_LPM_HPP