~aleteoryx/muditaos

ref: 79b3c32842459fa72db6357e20ff7e892cc365f6 muditaos/module-bsp/drivers/pll/DriverPLL.hpp -rw-r--r-- 1.0 KiB
79b3c328 — Maciej Gibowicz [BH-1757] Fix Hard Fault handling 2 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
42
43
44
45
46
47
48
49
50
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <memory>
#include <cstdint>

namespace drivers
{

    enum class PLLInstances
    {
        OSC_24M,
        PLL1_ARM,
        PLL2_PFD2,
        PLL3,
        PLL3_PFD0,
        PLL3_PFD1,
        PLL3_PFD2,
        PLL4_Audio,
        COUNT
    };

    struct DriverPLLParams
    {
        std::uint32_t loopDivider;
        std::uint32_t postDivider;
        std::uint32_t numerator;
        std::uint32_t denominator;
        std::uint32_t src;
    };

    class DriverPLL
    {
      public:
        static std::shared_ptr<DriverPLL> Create(PLLInstances inst, const DriverPLLParams &params);

        explicit DriverPLL(const DriverPLLParams &params) : parameters(params)
        {}

      protected:
        const DriverPLLParams parameters;

      private:
        static std::weak_ptr<DriverPLL> singleton[static_cast<std::uint32_t>(PLLInstances::COUNT)];
    };

} // namespace drivers