mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
I'm worried about the stm32_tim_getcounter funtion. It returns always 32 bits. But major stm32 timers have 16 bits counters. I think, it's not a good idea to return the memory behind the TIMx_CNT register. This changes adds the register size checking.
This commit is contained in:
committed by
Gregory Nutt
parent
a7fd8eb203
commit
795650a2fb
@@ -903,7 +903,9 @@ static void stm32_tim_setperiod(FAR struct stm32_tim_dev_s *dev,
|
||||
static uint32_t stm32_tim_getcounter(FAR struct stm32_tim_dev_s *dev)
|
||||
{
|
||||
DEBUGASSERT(dev != NULL);
|
||||
return stm32_getreg32(dev, STM32_BTIM_CNT_OFFSET);
|
||||
return stm32_tim_getwidth(dev) > 16 ?
|
||||
stm32_getreg32(dev, STM32_BTIM_CNT_OFFSET) :
|
||||
(uint32_t)stm32_getreg16(dev, STM32_BTIM_CNT_OFFSET);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user