antmerlino commented on a change in pull request #3488:
URL: https://github.com/apache/incubator-nuttx/pull/3488#discussion_r835726071
##########
File path: arch/arm/src/stm32h7/stm32_tim.c
##########
@@ -487,6 +500,64 @@ static void stm32_tim_disable(FAR struct stm32_tim_dev_s
*dev)
stm32_putreg16(dev, STM32_GTIM_CR1_OFFSET, val);
}
+/****************************************************************************
+ * Name: stm32_tim_getwidth
+ ****************************************************************************/
+
+static int stm32_tim_getwidth(FAR struct stm32_tim_dev_s *dev)
+{
+ /* Only TIM2 and TIM5 timers may be 32-bits in width */
+
+ switch (((struct stm32_tim_priv_s *)dev)->base)
+ {
+#if defined(CONFIG_STM32H7_TIM2)
+ case STM32_TIM2_BASE:
+ return 32;
+#endif
+
+#if defined(CONFIG_STM32H7_TIM5)
+ case STM32_TIM5_BASE:
+ return 32;
+#endif
+
+ /* All others are 16-bit times */
+
+ default:
+ return 16;
+ }
+}
+
+/****************************************************************************
+ * Name: stm32_tim_getcounter
+ ****************************************************************************/
+
+static uint32_t stm32_tim_getcounter(FAR struct stm32_tim_dev_s *dev)
+{
+ DEBUGASSERT(dev != NULL);
+ return stm32_tim_getwidth(dev) > 16 ?
+ stm32_getreg32(dev, STM32_BTIM_CNT_OFFSET) :
+ (uint32_t)stm32_getreg16(dev, STM32_BTIM_CNT_OFFSET);
Review comment:
I didn't write this, it existed before, and I don't want to mess with
it, so I'm going to leave it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]