mirror of
https://github.com/apache/nuttx.git
synced 2026-09-30 19:06:22 +00:00
arm/nrf52,nrf53,nrf91: fix TIMER driver bugs
- setcc/getcc accepted channel index equal to the channel count - init never marked the instance as in use - TIM_PRESCALER_MASK used the maximum value as the mask Assisted-by: Claude Code Signed-off-by: raiden00pl <raiden00@railab.me>
This commit is contained in:
parent
a315d19fac
commit
d490c80df2
6 changed files with 21 additions and 9 deletions
|
|
@ -103,6 +103,6 @@
|
|||
|
||||
#define TIM_PRESCALER_SHIFT (0) /* Bits 0-3: Prescaler value */
|
||||
#define TIM_PRESCALER_MAX (9)
|
||||
#define TIM_PRESCALER_MASK (TIM_PRESCALER_MAX << TIM_PRESCALER_SHIFT)
|
||||
#define TIM_PRESCALER_MASK (0xf << TIM_PRESCALER_SHIFT)
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_NRF52_HARDWARE_NRF52_TIM_H */
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ static int nrf52_tim_setcc(struct nrf52_tim_dev_s *dev, uint8_t i,
|
|||
|
||||
/* Is the channel supported? */
|
||||
|
||||
if (i > tim->chan)
|
||||
if (i >= tim->chan)
|
||||
{
|
||||
tmrerr("ERROR: unsupported TIMER channel %d\n", i);
|
||||
ret = -EINVAL;
|
||||
|
|
@ -518,7 +518,7 @@ static int nrf52_tim_getcc(struct nrf52_tim_dev_s *dev, uint8_t i,
|
|||
|
||||
/* Is the channel supported? */
|
||||
|
||||
if (i > tim->chan)
|
||||
if (i >= tim->chan)
|
||||
{
|
||||
tmrerr("ERROR: unsupported TIMER channel %d\n", i);
|
||||
ret = -EINVAL;
|
||||
|
|
@ -832,6 +832,10 @@ struct nrf52_tim_dev_s *nrf52_tim_init(int timer)
|
|||
|
||||
tim = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
tim->inuse = true;
|
||||
}
|
||||
|
||||
errout:
|
||||
return (struct nrf52_tim_dev_s *)tim;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@
|
|||
|
||||
#define TIM_PRESCALER_SHIFT (0) /* Bits 0-3: Prescaler value */
|
||||
#define TIM_PRESCALER_MAX (9)
|
||||
#define TIM_PRESCALER_MASK (TIM_PRESCALER_MAX << TIM_PRESCALER_SHIFT)
|
||||
#define TIM_PRESCALER_MASK (0xf << TIM_PRESCALER_SHIFT)
|
||||
|
||||
/* ONESHOT Register */
|
||||
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ static int nrf53_tim_setcc(struct nrf53_tim_dev_s *dev, uint8_t i,
|
|||
|
||||
/* Is the channel supported? */
|
||||
|
||||
if (i > tim->chan)
|
||||
if (i >= tim->chan)
|
||||
{
|
||||
tmrerr("ERROR: unsupported TIMER channel %d\n", i);
|
||||
ret = -EINVAL;
|
||||
|
|
@ -518,7 +518,7 @@ static int nrf53_tim_getcc(struct nrf53_tim_dev_s *dev, uint8_t i,
|
|||
|
||||
/* Is the channel supported? */
|
||||
|
||||
if (i > tim->chan)
|
||||
if (i >= tim->chan)
|
||||
{
|
||||
tmrerr("ERROR: unsupported TIMER channel %d\n", i);
|
||||
ret = -EINVAL;
|
||||
|
|
@ -832,6 +832,10 @@ struct nrf53_tim_dev_s *nrf53_tim_init(int timer)
|
|||
|
||||
tim = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
tim->inuse = true;
|
||||
}
|
||||
|
||||
errout:
|
||||
return (struct nrf53_tim_dev_s *)tim;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@
|
|||
|
||||
#define TIM_PRESCALER_SHIFT (0) /* Bits 0-3: Prescaler value */
|
||||
#define TIM_PRESCALER_MAX (9)
|
||||
#define TIM_PRESCALER_MASK (TIM_PRESCALER_MAX << TIM_PRESCALER_SHIFT)
|
||||
#define TIM_PRESCALER_MASK (0xf << TIM_PRESCALER_SHIFT)
|
||||
|
||||
/* ONESHOT Register */
|
||||
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ static int nrf91_tim_setcc(struct nrf91_tim_dev_s *dev, uint8_t i,
|
|||
|
||||
/* Is the channel supported? */
|
||||
|
||||
if (i > tim->chan)
|
||||
if (i >= tim->chan)
|
||||
{
|
||||
tmrerr("ERROR: unsupported TIMER channel %d\n", i);
|
||||
ret = -EINVAL;
|
||||
|
|
@ -518,7 +518,7 @@ static int nrf91_tim_getcc(struct nrf91_tim_dev_s *dev, uint8_t i,
|
|||
|
||||
/* Is the channel supported? */
|
||||
|
||||
if (i > tim->chan)
|
||||
if (i >= tim->chan)
|
||||
{
|
||||
tmrerr("ERROR: unsupported TIMER channel %d\n", i);
|
||||
ret = -EINVAL;
|
||||
|
|
@ -832,6 +832,10 @@ struct nrf91_tim_dev_s *nrf91_tim_init(int timer)
|
|||
|
||||
tim = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
tim->inuse = true;
|
||||
}
|
||||
|
||||
errout:
|
||||
return (struct nrf91_tim_dev_s *)tim;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue