Merged in raiden00/nuttx (pull request #606)

stm32_hrtim: add repetition support and fix enum overflow

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Mateusz Szafoni 2018-02-27 18:53:08 +00:00 committed by Gregory Nutt
parent 8fe9e81183
commit 2e5bef89b8
2 changed files with 34 additions and 2 deletions

View File

@ -729,6 +729,8 @@ static int hrtim_cmp_update(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint8_t index, uint16_t cmp);
static int hrtim_per_update(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint16_t per);
static int hrtim_rep_update(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint8_t rep);
static uint16_t hrtim_per_get(FAR struct hrtim_dev_s *dev, uint8_t timer);
static uint16_t hrtim_cmp_get(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint8_t index);
@ -1538,6 +1540,7 @@ static const struct stm32_hrtim_ops_s g_hrtim1ops =
{
.cmp_update = hrtim_cmp_update,
.per_update = hrtim_per_update,
.rep_update = hrtim_rep_update,
.per_get = hrtim_per_get,
.cmp_get = hrtim_cmp_get,
.fclk_get = hrtim_fclk_get,
@ -4897,6 +4900,31 @@ static uint16_t hrtim_per_get(FAR struct hrtim_dev_s *dev, uint8_t timer)
return (uint16_t)hrtim_tim_getreg(priv, timer, STM32_HRTIM_TIM_PER_OFFSET);
}
/****************************************************************************
* Name: hrtim_rep_update
*
* Description:
* Try update HRTIM Timer repetition register.
*
* Input Parameters:
* dev - HRTIM device structure
* timer - HRTIM Timer index
* rep - New repetition register value
*
* Returned Value:
* 0 on success; a negated errno value on failure
*
****************************************************************************/
static int hrtim_rep_update(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint8_t rep)
{
FAR struct stm32_hrtim_s *priv = (FAR struct stm32_hrtim_s *)dev->hd_priv;
hrtim_tim_putreg(priv, timer, STM32_HRTIM_TIM_REPR_OFFSET, rep);
return OK;
}
/****************************************************************************
* Name: hrtim_cmp_update
*

View File

@ -397,10 +397,13 @@ enum stm32_hrtim_tim_rst_e
HRTIM_RST_TDCMP2 = (1<<29),
HRTIM_RST_TDCMP4 = (1<<30),
HRTIM_RST_TECMP1 = (1<<31),
HRTIM_RST_TECMP2 = (1<<32),
HRTIM_RST_TECMP4 = (1<<33),
};
/* This definitions does not fit to the above 32 bit enum */
#define HRTIM_RST_TECMP2 (1ull<<32)
#define HRTIM_RST_TECMP4 (1ull<<33)
/* HRTIM Timer X prescaler */
enum stm32_hrtim_tim_prescaler_e
@ -1000,6 +1003,7 @@ struct stm32_hrtim_ops_s
int (*cmp_update)(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint8_t index, uint16_t cmp);
int (*per_update)(FAR struct hrtim_dev_s *dev, uint8_t timer, uint16_t per);
int (*rep_update)(FAR struct hrtim_dev_s *dev, uint8_t timer, uint8_t rep);
uint16_t (*per_get)(FAR struct hrtim_dev_s *dev, uint8_t timer);
uint16_t (*cmp_get)(FAR struct hrtim_dev_s *dev, uint8_t timer,
uint8_t index);