Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
GpioInitializer.hxx
Go to the documentation of this file.
1
35#ifndef _UTILS_GPIOINITIALIZER_HXX_
36#define _UTILS_GPIOINITIALIZER_HXX_
37
39template <class T> struct GpioInitHelper;
40
42template <> struct GpioInitHelper<std::tuple<>>
43{
45 static void hw_init()
46 {
47 }
49 static void hw_set_to_safe()
50 {
51 }
53 static void set(bool value)
54 {
55 }
56};
57
60template <typename Head, typename... Tail>
61struct GpioInitHelper<std::tuple<Head, Tail...>>
62{
64 static void hw_init()
65 {
66 Head::hw_init();
67 GpioInitHelper<std::tuple<Tail...>>::hw_init();
68 }
70 static void hw_set_to_safe()
71 {
72 Head::hw_set_to_safe();
73 GpioInitHelper<std::tuple<Tail...>>::hw_set_to_safe();
74 }
76 static void set(bool value)
77 {
78 Head::set(value);
79 GpioInitHelper<std::tuple<Tail...>>::set(value);
80 }
81};
82
99template <typename... Args> struct GpioInitializer
100{
101public:
103 static void hw_init()
104 {
105 GpioInitHelper<std::tuple<Args...>>::hw_init();
106 }
108 static void hw_set_to_safe()
109 {
110 GpioInitHelper<std::tuple<Args...>>::hw_set_to_safe();
111 }
113 static void set(bool value)
114 {
115 GpioInitHelper<std::tuple<Args...>>::set(value);
116 }
117};
118
119#endif // _UTILS_GPIOINITIALIZER_HXX_
static void hw_set_to_safe()
Middle step of the recursion for an individual pin.
static void set(bool value)
Middle step of the recursion for an individual pin.
static void hw_init()
Middle step of the recursion for an individual pin.
static void hw_set_to_safe()
hw_set_to_safe part of the end of the recursion.
static void hw_init()
hw_init part of the end of the recursion.
static void set(bool value)
set part of the end of the recursion.
Forward declaration to make the template matcher happy.
Class collecting a bunch of GPIO pins and allowing them to be initialized in one go.
static void hw_init()
Calls the hw_init() function for all declared pins.
static void set(bool value)
Calls the set() function for all declared pins.
static void hw_set_to_safe()
Calls the hw_set_to_safe() function for all declared pins.