File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -1158,6 +1158,42 @@ void HardwareTimer::captureCompareCallback(TIM_HandleTypeDef *htim)
1158
1158
}
1159
1159
}
1160
1160
1161
+ /* *
1162
+ * @brief Checks whether HardwareTimer is running (paused or resumed).
1163
+ * @retval returns true if the HardwareTimer is running
1164
+ */
1165
+ bool HardwareTimer::isRunning ()
1166
+ {
1167
+ return LL_TIM_IsEnabledCounter (_timerObj.handle .Instance );
1168
+ }
1169
+
1170
+ /* *
1171
+ * @brief Checks whether channel is running (paused or resumed).
1172
+ * @param channel: Arduino channel [1..4]
1173
+ * @retval returns true if HardwareTimer is running and the channel is enabled
1174
+ */
1175
+ bool HardwareTimer::isRunningChannel (uint32_t channel)
1176
+ {
1177
+ int timAssociatedInputChannel;
1178
+ int LLChannel = getLLChannel (channel);
1179
+ int interrupt = getIT (channel);
1180
+ bool ret;
1181
+
1182
+ if (LLChannel == -1 ) {
1183
+ Error_Handler ();
1184
+ }
1185
+
1186
+ if (interrupt == -1 ) {
1187
+ Error_Handler ();
1188
+ }
1189
+
1190
+ // channel is runnning if: timer is running, and either output channel is
1191
+ // enabled or interrupt is set
1192
+ ret = LL_TIM_CC_IsEnabledChannel (_timerObj.handle .Instance , LLChannel)
1193
+ || (__HAL_TIM_GET_IT_SOURCE (&(_timerObj.handle ), interrupt) == SET);
1194
+ return (isRunning () && ret);
1195
+ }
1196
+
1161
1197
/* *
1162
1198
* @brief HardwareTimer destructor
1163
1199
* @retval None
Original file line number Diff line number Diff line change @@ -148,9 +148,12 @@ class HardwareTimer {
148
148
149
149
uint32_t getTimerClkFreq (); // return timer clock frequency in Hz.
150
150
151
- static void captureCompareCallback (TIM_HandleTypeDef *htim); // Generic Caputre and Compare callback which will call user callback
151
+ static void captureCompareCallback (TIM_HandleTypeDef *htim); // Generic Capture and Compare callback which will call user callback
152
152
static void updateCallback (TIM_HandleTypeDef *htim); // Generic Update (rollover) callback which will call user callback
153
153
154
+ bool isRunning (); // returns true if HardwareTimer is running
155
+ bool isRunningChannel (uint32_t channel); // returns true if channel is running
156
+
154
157
// The following function(s) are available for more advanced timer options
155
158
TIM_HandleTypeDef *getHandle (); // return the handle address for HAL related configuration
156
159
int getChannel (uint32_t channel);
You can’t perform that action at this time.
0 commit comments