Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
LoggingGPIO.hxx
Go to the documentation of this file.
1
35#ifndef _FREERTOS_DRIVERS_COMMON_LOGGINGGPIO_HXX_
36#define _FREERTOS_DRIVERS_COMMON_LOGGINGGPIO_HXX_
37
38#include "GpioWrapper.hxx"
39
42template<const char* message>
44{
46 static void hw_init()
47 {
48 }
50 static void hw_set_to_safe()
51 {
52 }
55 static void set(bool value)
56 {
57 if (lastValue_ == value) return;
58 LOG(INFO, "Logging pin %s = %s", message, value ? "ON" : "OFF");
59 lastValue_ = value;
60 }
62 static void toggle()
63 {
65 LOG(INFO, "Logging pin %s: TOGGLE", message);
66 }
67
69 static bool is_output()
70 {
71 return true;
72 }
73
74protected:
76 static bool lastValue_;
77};
78
79template<const char* message>
81
84template<const char* message>
85struct LoggingPinWithRead : public LoggingPin<message>
86{
88 static bool get()
89 {
91 }
92
94 static bool is_output()
95 {
96 return false;
97 }
98
100 static constexpr const Gpio *instance()
101 {
103 }
104};
105
106#endif // _FREERTOS_DRIVERS_COMMON_LOGGINGGPIO_HXX_
static constexpr const Gpio * instance()
OS-independent abstraction for GPIO.
Definition Gpio.hxx:43
#define LOG(level, message...)
Conditionally write a message to the logging output.
Definition logging.h:99
static const int INFO
Loglevel that is printed by default, reporting some status information.
Definition logging.h:57
GPIO Pin definition structure with no actual pin behind it.
static constexpr const Gpio * instance()
static bool get()
Returns the input pin level.
static bool is_output()
Returns whether this is an output pin or not.
GPIO Pin definition structure with no actual pin behind it.
static void set(bool value)
Sets the output pin level (generating a log output).
static void hw_init()
Empty. No initialization needed.
static bool is_output()
Returns whether this is an output pin or not.
static void toggle()
Toggles the output pin level.
static void hw_set_to_safe()
Empty. No initialization needed.
static bool lastValue_
Last output value.