~aleteoryx/muditaos

ref: f9703ad5c17f4bff299bb6f5bfc65dbb13a44232 muditaos/module-bsp/bsp/lpm/bsp_lpm.hpp -rw-r--r-- 1.1 KiB
f9703ad5 — Lucjan Bryndza [EGD-6097] Remove script for restore FAT layout 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
38
39
40
41
// 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 bsp {

    class LowPowerMode
    {
      public:
        enum class OscillatorSource
        {
            External,
            Internal
        };

        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(CpuFrequencyHz freq) = 0;
        [[nodiscard]] CpuFrequencyHz GetCurrentFrequencyLevel() const noexcept;
        [[nodiscard]] virtual uint32_t GetCpuFrequency() const noexcept = 0;

        virtual void SwitchOscillatorSource(OscillatorSource source) = 0;
        [[nodiscard]] OscillatorSource GetCurrentOscillatorSource() const noexcept;

    protected:
        CpuFrequencyHz currentFrequency = CpuFrequencyHz::Level_6;
        OscillatorSource currentOscSource = OscillatorSource::External;
    };
} // namespace bsp