~aleteoryx/muditaos

ref: 3e1170daf75b79d6ef461b3b38e5d96683047c7d muditaos/module-bsp/board/rt1051/drivers/RT1051DriverSEMC.cpp -rw-r--r-- 1.1 KiB
3e1170da — Lefucjusz [BH-1673] Harmony random resets fixes 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
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "RT1051DriverSEMC.hpp"
#include "critical.hpp"
#include "board/clock_config.h"

namespace drivers
{

    RT1051DriverSEMC::RT1051DriverSEMC(std::string name) : DriverSEMC(std::move(name))
    {
        SwitchToPLL2ClockSource();
    }

    void RT1051DriverSEMC::Enable()
    {}

    void RT1051DriverSEMC::Disable()
    {}

    void RT1051DriverSEMC::SwitchToPLL2ClockSource()
    {
        cpp_freertos::CriticalSection::Enter();
        if (pll2Driver == nullptr) {
            pll2Driver = std::make_shared<RT1051DriverPLL2>();
        }
        CLOCK_SetMux(kCLOCK_SemcMux, SemcMuxPLL2Clock);
        cpp_freertos::CriticalSection::Exit();
    }

    void RT1051DriverSEMC::SwitchToPeripheralClockSource()
    {
        cpp_freertos::CriticalSection::Enter();
        CLOCK_SetMux(kCLOCK_SemcMux, SemcMuxPeripheralClock);
        pll2Driver.reset();
        cpp_freertos::CriticalSection::Exit();
    }

} // namespace drivers