Loading...
Searching...
No Matches
irq.hpp
Go to the documentation of this file.
1/*
2* Copyright (C) 2021 Jens Wetterich <jens@wetterich-net.de>
3*
4* This file is subject to the terms and conditions of the GNU Lesser
5* General Public License v2.1. See the file LICENSE in the top level
6* directory for more details.
7*/
16#ifndef IRQ_HPP
17#define IRQ_HPP
18#include "irq.h"
19
20namespace riot {
26class irq_lock {
27public:
32 static inline bool is_locked() noexcept {
33 return irq_is_enabled() == 0;
34 }
35
40 static inline bool is_isr() noexcept {
41 return irq_is_in() != 0;
42 }
43
47 inline irq_lock() : state(irq_disable()) {
48 }
49
55 inline ~irq_lock() {
56 irq_restore(state);
57 }
58
59 irq_lock(irq_lock const& irq) = delete;
60 irq_lock(irq_lock const&& irq) = delete;
61
62private:
63 unsigned int state;
64};
65}// namespace riot
66#endif /* IRQ_HPP */
RAII based IRQ lock.
Definition irq.hpp:26
~irq_lock()
This restores the IRQ disable bit in the status register to the value saved during construction of th...
Definition irq.hpp:55
static bool is_locked() noexcept
Test whether IRQs are currently enabled.
Definition irq.hpp:32
static bool is_isr() noexcept
Check whether called from interrupt service routine.
Definition irq.hpp:40
irq_lock()
This sets the IRQ disable bit in the status register.
Definition irq.hpp:47
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_enabled(void)
Test if IRQs are currently enabled.
MAYBE_INLINE bool irq_is_in(void)
Check whether called from interrupt service routine.
IRQ driver interface.
RIOT C++ namespace.
Definition chrono.hpp:35