Skip to content

Commit f28dc09

Browse files
committed
HardwareTimer: Add API to get configured mode
1 parent 89e08d2 commit f28dc09

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

cores/arduino/HardwareTimer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,20 @@ void HardwareTimer::setMode(uint32_t channel, TimerModes_t mode, PinName pin)
690690
}
691691
}
692692

693+
/**
694+
* @brief Retrieves channel mode configured
695+
* @param channel: Arduino channel [1..4]
696+
* @retval returns configured mode
697+
*/
698+
TimerModes_t HardwareTimer::getMode(uint32_t channel)
699+
{
700+
if ((1 <= channel) && (channel <= TIMER_CHANNELS)) {
701+
return _ChannelMode[channel - 1];
702+
} else {
703+
return TIMER_DISABLED;
704+
}
705+
}
706+
693707
/**
694708
* @brief Enable or disable preloading for overflow value
695709
* When disabled, changes to the overflow value take effect

cores/arduino/HardwareTimer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class HardwareTimer {
118118
void setMode(uint32_t channel, TimerModes_t mode, PinName pin = NC); // Configure timer channel with specified mode on specified pin if available
119119
void setMode(uint32_t channel, TimerModes_t mode, uint32_t pin);
120120

121+
TimerModes_t getMode(uint32_t channel); // Retrieve configured mode
122+
121123
void setPreloadEnable(bool value); // Configure overflow preload enable setting
122124

123125
uint32_t getCaptureCompare(uint32_t channel, TimerCompareFormat_t format = TICK_COMPARE_FORMAT); // return Capture/Compare register value of specified channel depending on format provided

0 commit comments

Comments
 (0)