~aleteoryx/muditaos

ref: ec56afc93393af6c84ba69a2cf9c5ca5d0b83cf2 muditaos/module-bsp/board/rt1051/bsp/lpm/ClockState.cpp -rw-r--r-- 700 bytes
ec56afc9 — Maciej-Mudita [EGD-5381] Add Low Power Drivers 5 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