Dawn Framework 1.0
Universal data acquisition framework for embedded systems
descswitch.cxx
1// dawn/src/dev/descswitch.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/dev/descswitch.hxx"
7
8#include <atomic>
9
10using namespace dawn;
11
12namespace
13{
14std::atomic_bool g_switchRequested(false);
15std::atomic_uint8_t g_switchSlot(0);
16std::atomic_uint8_t g_activeSlot(0);
17}
18
20{
21 g_switchSlot = slot;
22 g_switchRequested = true;
23}
24
26{
27 g_switchRequested = false;
28}
29
31{
32 return g_switchRequested.load();
33}
34
36{
37 return g_switchSlot.load();
38}
39
41{
42 return g_activeSlot.load();
43}
44
46{
47 g_activeSlot = slot;
48}
static uint8_t getActiveSlot()
Get currently active descriptor slot.
static void setActiveSlot(uint8_t slot)
Set currently active descriptor slot.
static void clear()
Clear pending switch request.
static uint8_t getSwitchSlot()
Get pending switch target slot.
static bool isSwitchRequested()
Check if descriptor switch is pending.
static void requestSwitch(uint8_t slot)
Request descriptor switch to a slot.
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13