33 uint32_t detectionThreshold,
37 auto result = callbacks.insert({pin,
38 {callback, detectionThreshold, 0, 0,
39 pin.value() != reverted, 0, reverted}});
45 std::bind(&PinObserver::periodicPinValueCheck,
this, pin),
63 callbacks[pin].changesCount = 0;
66void PinObserver::periodicPinValueCheck(miosix::GpioPin pin)
69 if (callbacks.find(pin) == callbacks.end())
72 auto& pinData = callbacks[pin];
75 uint32_t& count = pinData.periodCount;
78 const bool newState = pin.value() != pinData.reverted;
81 if (pinData.lastState != newState)
88 if (count > pinData.threshold)
91 pinData.changesCount++;
95 pinData.lastState = newState;
std::function< void(PinTransition)> PinCallback
void resetPinChangesCount(miosix::GpioPin pin)
Resets the changes counter for the specified pin.
bool registerPinCallback(miosix::GpioPin pin, PinCallback callback, uint32_t detectionThreshold=1, bool reverted=false)
PinData getPinData(miosix::GpioPin pin)
Returns the information for the specified pin.
@ RECOVER
Prioritize the number of executions over the period.
size_t addTask(function_t function, uint32_t periodMs, Policy policy=Policy::RECOVER, int64_t startTick=Kernel::getOldTick())
Add a millisecond-period task function to the scheduler with an auto generated ID.
uint64_t getTimestamp()
Returns the current timer value in microseconds.
This file includes all the types the logdecoder script will decode.
PinTransition
Pin transition.
@ FALLING_EDGE
The pin goes from high to low.
@ RISING_EDGE
The pin goes from low to high.