~aleteoryx/muditaos

ref: 3a5f668c981db13ba5e31cabb528c43728a8bf2e muditaos/module-bsp/board/rt1051/bsp/lpm/ClockState.cpp -rw-r--r-- 700 bytes
3a5f668c — Lefucjusz [BH-1583] Fix SNVS LP lockup after debugging 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ClockState.hpp"

namespace bsp
{
    inline constexpr uint8_t CCM_TupleShift{8};
    inline constexpr uint8_t CCM_TupleMask{0x1F};
    inline constexpr uint32_t ClockNeededRunWaitMode{kCLOCK_ClockNeededRunWait};

    bool IsClockEnabled(clock_ip_name_t name)
    {
        const auto index = static_cast<uint32_t>(name) >> CCM_TupleShift;
        const auto shift = static_cast<uint32_t>(name) & CCM_TupleMask;

        return ((*reinterpret_cast<volatile uint32_t *>(&CCM->CCGR0 + index)) & (ClockNeededRunWaitMode << shift));
    }
}; // namespace bsp