Merged in raiden00/nuttx_pe (pull request #822)
Improvements for STM32 PWM arch/arm/src/stm32/stm32_pwm: fix polarity and IDLE state configuration for advanced timer PWM include/dsp.h: raise error if math.h not present Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
parent
f546801fb3
commit
f841175540
@ -315,31 +315,6 @@
|
|||||||
# define HAVE_TRGO
|
# define HAVE_TRGO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Complementary outputs support */
|
|
||||||
|
|
||||||
#if defined(CONFIG_STM32_TIM1_CH1NOUT) || defined(CONFIG_STM32_TIM1_CH2NOUT) || \
|
|
||||||
defined(CONFIG_STM32_TIM1_CH3NOUT)
|
|
||||||
# define HAVE_TIM1_COMPLEMENTARY
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_STM32_TIM8_CH1NOUT) || defined(CONFIG_STM32_TIM8_CH2NOUT) || \
|
|
||||||
defined(CONFIG_STM32_TIM8_CH3NOUT)
|
|
||||||
# define HAVE_TIM8_COMPLEMENTARY
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_STM32_TIM15_CH1NOUT)
|
|
||||||
# define HAVE_TIM15_COMPLEMENTARY
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_STM32_TIM16_CH1NOUT)
|
|
||||||
# define HAVE_TIM16_COMPLEMENTARY
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_STM32_TIM17_CH1NOUT)
|
|
||||||
# define HAVE_TIM17_COMPLEMENTARY
|
|
||||||
#endif
|
|
||||||
#if defined(HAVE_TIM1_COMPLEMENTARY) || defined(HAVE_TIM8_COMPLEMENTARY) || \
|
|
||||||
defined(HAVE_TIM15_COMPLEMENTARY) || defined(HAVE_TIM16_COMPLEMENTARY) || \
|
|
||||||
defined(HAVE_TIM17_COMPLEMENTARY)
|
|
||||||
# define HAVE_COMPLEMENTARY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Break support */
|
/* Break support */
|
||||||
|
|
||||||
#if defined(CONFIG_STM32_TIM1_BREAK1) || defined(CONFIG_STM32_TIM1_BREAK2) || \
|
#if defined(CONFIG_STM32_TIM1_BREAK1) || defined(CONFIG_STM32_TIM1_BREAK2) || \
|
||||||
@ -397,7 +372,7 @@ struct stm32_pwmchan_s
|
|||||||
#ifdef HAVE_BREAK
|
#ifdef HAVE_BREAK
|
||||||
struct stm32_pwm_break_s brk; /* PWM break configuration */
|
struct stm32_pwm_break_s brk; /* PWM break configuration */
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
struct stm32_pwm_out_s out2; /* PWM complementary output configuration */
|
struct stm32_pwm_out_s out2; /* PWM complementary output configuration */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -418,7 +393,7 @@ struct stm32_pwmtimer_s
|
|||||||
uint8_t lock:2; /* TODO: Lock configuration */
|
uint8_t lock:2; /* TODO: Lock configuration */
|
||||||
uint8_t t_dts:3; /* Clock division for t_DTS */
|
uint8_t t_dts:3; /* Clock division for t_DTS */
|
||||||
uint8_t _res:5; /* Reserved */
|
uint8_t _res:5; /* Reserved */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
uint8_t deadtime; /* Dead-time value */
|
uint8_t deadtime; /* Dead-time value */
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_TRGO
|
#ifdef HAVE_TRGO
|
||||||
@ -486,7 +461,7 @@ static int pwm_break_dt_configure(FAR struct stm32_pwmtimer_s *priv);
|
|||||||
#ifdef HAVE_TRGO
|
#ifdef HAVE_TRGO
|
||||||
static int pwm_sync_configure(FAR struct stm32_pwmtimer_s *priv, uint8_t trgo);
|
static int pwm_sync_configure(FAR struct stm32_pwmtimer_s *priv, uint8_t trgo);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_COMPLEMENTARY) && defined(CONFIG_STM32_PWM_LL_OPS)
|
#if defined(HAVE_PWM_COMPLEMENTARY) && defined(CONFIG_STM32_PWM_LL_OPS)
|
||||||
static int pwm_deadtime_update(FAR struct pwm_lowerhalf_s *dev, uint8_t dt);
|
static int pwm_deadtime_update(FAR struct pwm_lowerhalf_s *dev, uint8_t dt);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_STM32_PWM_LL_OPS
|
#ifdef CONFIG_STM32_PWM_LL_OPS
|
||||||
@ -567,7 +542,7 @@ static const struct stm32_pwm_ops_s g_llpwmops =
|
|||||||
# ifdef CONFIG_DEBUG_PWM_INFO
|
# ifdef CONFIG_DEBUG_PWM_INFO
|
||||||
.dump_regs = pwm_dumpregs,
|
.dump_regs = pwm_dumpregs,
|
||||||
# endif
|
# endif
|
||||||
# ifdef HAVE_COMPLEMENTARY
|
# ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.dt_update = pwm_deadtime_update,
|
.dt_update = pwm_deadtime_update,
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
@ -695,7 +670,7 @@ static struct stm32_pwmtimer_s g_pwm1dev =
|
|||||||
.mode = CONFIG_STM32_TIM1_MODE,
|
.mode = CONFIG_STM32_TIM1_MODE,
|
||||||
.lock = CONFIG_STM32_TIM1_LOCK,
|
.lock = CONFIG_STM32_TIM1_LOCK,
|
||||||
.t_dts = CONFIG_STM32_TIM1_TDTS,
|
.t_dts = CONFIG_STM32_TIM1_TDTS,
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = CONFIG_STM32_TIM1_DEADTIME,
|
.deadtime = CONFIG_STM32_TIM1_DEADTIME,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO) && defined(STM32_TIM1_TRGO)
|
#if defined(HAVE_TRGO) && defined(STM32_TIM1_TRGO)
|
||||||
@ -794,7 +769,7 @@ static struct stm32_pwmtimer_s g_pwm2dev =
|
|||||||
.mode = CONFIG_STM32_TIM2_MODE,
|
.mode = CONFIG_STM32_TIM2_MODE,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO) && defined(STM32_TIM2_TRGO)
|
#if defined(HAVE_TRGO) && defined(STM32_TIM2_TRGO)
|
||||||
@ -893,7 +868,7 @@ static struct stm32_pwmtimer_s g_pwm3dev =
|
|||||||
.mode = CONFIG_STM32_TIM3_MODE,
|
.mode = CONFIG_STM32_TIM3_MODE,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO) && defined(STM32_TIM3_TRGO)
|
#if defined(HAVE_TRGO) && defined(STM32_TIM3_TRGO)
|
||||||
@ -992,7 +967,7 @@ static struct stm32_pwmtimer_s g_pwm4dev =
|
|||||||
.mode = CONFIG_STM32_TIM4_MODE,
|
.mode = CONFIG_STM32_TIM4_MODE,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO) && defined(STM32_TIM4_TRGO)
|
#if defined(HAVE_TRGO) && defined(STM32_TIM4_TRGO)
|
||||||
@ -1089,7 +1064,7 @@ static struct stm32_pwmtimer_s g_pwm5dev =
|
|||||||
.mode = CONFIG_STM32_TIM5_MODE,
|
.mode = CONFIG_STM32_TIM5_MODE,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO) && defined(STM32_TIM5_TRGO)
|
#if defined(HAVE_TRGO) && defined(STM32_TIM5_TRGO)
|
||||||
@ -1225,7 +1200,7 @@ static struct stm32_pwmtimer_s g_pwm8dev =
|
|||||||
.mode = CONFIG_STM32_TIM8_MODE,
|
.mode = CONFIG_STM32_TIM8_MODE,
|
||||||
.lock = CONFIG_STM32_TIM8_LOCK,
|
.lock = CONFIG_STM32_TIM8_LOCK,
|
||||||
.t_dts = CONFIG_STM32_TIM8_TDTS,
|
.t_dts = CONFIG_STM32_TIM8_TDTS,
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = CONFIG_STM32_TIM8_DEADTIME,
|
.deadtime = CONFIG_STM32_TIM8_DEADTIME,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO) && defined(STM32_TIM8_TRGO)
|
#if defined(HAVE_TRGO) && defined(STM32_TIM8_TRGO)
|
||||||
@ -1292,7 +1267,7 @@ static struct stm32_pwmtimer_s g_pwm9dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO)
|
#if defined(HAVE_TRGO)
|
||||||
@ -1343,7 +1318,7 @@ static struct stm32_pwmtimer_s g_pwm10dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO)
|
#if defined(HAVE_TRGO)
|
||||||
@ -1394,7 +1369,7 @@ static struct stm32_pwmtimer_s g_pwm11dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO)
|
#if defined(HAVE_TRGO)
|
||||||
@ -1461,7 +1436,7 @@ static struct stm32_pwmtimer_s g_pwm12dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO)
|
#if defined(HAVE_TRGO)
|
||||||
@ -1512,7 +1487,7 @@ static struct stm32_pwmtimer_s g_pwm13dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO)
|
#if defined(HAVE_TRGO)
|
||||||
@ -1563,7 +1538,7 @@ static struct stm32_pwmtimer_s g_pwm14dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = 0, /* No lock */
|
.lock = 0, /* No lock */
|
||||||
.t_dts = 0, /* No t_dts */
|
.t_dts = 0, /* No t_dts */
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = 0, /* No deadtime */
|
.deadtime = 0, /* No deadtime */
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO)
|
#if defined(HAVE_TRGO)
|
||||||
@ -1648,7 +1623,7 @@ static struct stm32_pwmtimer_s g_pwm15dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = CONFIG_STM32_TIM15_LOCK,
|
.lock = CONFIG_STM32_TIM15_LOCK,
|
||||||
.t_dts = CONFIG_STM32_TIM15_TDTS,
|
.t_dts = CONFIG_STM32_TIM15_TDTS,
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = CONFIG_STM32_TIM15_DEADTIME,
|
.deadtime = CONFIG_STM32_TIM15_DEADTIME,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO) && defined(STM32_TIM15_TRGO)
|
#if defined(HAVE_TRGO) && defined(STM32_TIM15_TRGO)
|
||||||
@ -1717,7 +1692,7 @@ static struct stm32_pwmtimer_s g_pwm16dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = CONFIG_STM32_TIM16_LOCK,
|
.lock = CONFIG_STM32_TIM16_LOCK,
|
||||||
.t_dts = CONFIG_STM32_TIM16_TDTS,
|
.t_dts = CONFIG_STM32_TIM16_TDTS,
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = CONFIG_STM32_TIM16_DEADTIME,
|
.deadtime = CONFIG_STM32_TIM16_DEADTIME,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO)
|
#if defined(HAVE_TRGO)
|
||||||
@ -1786,7 +1761,7 @@ static struct stm32_pwmtimer_s g_pwm17dev =
|
|||||||
.mode = STM32_TIMMODE_COUNTUP,
|
.mode = STM32_TIMMODE_COUNTUP,
|
||||||
.lock = CONFIG_STM32_TIM17_LOCK,
|
.lock = CONFIG_STM32_TIM17_LOCK,
|
||||||
.t_dts = CONFIG_STM32_TIM17_TDTS,
|
.t_dts = CONFIG_STM32_TIM17_TDTS,
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
.deadtime = CONFIG_STM32_TIM17_DEADTIME,
|
.deadtime = CONFIG_STM32_TIM17_DEADTIME,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_TRGO)
|
#if defined(HAVE_TRGO)
|
||||||
@ -2742,7 +2717,7 @@ static int pwm_output_configure(FAR struct stm32_pwmtimer_s *priv,
|
|||||||
|
|
||||||
/* Configure output polarity (all PWM timers) */
|
/* Configure output polarity (all PWM timers) */
|
||||||
|
|
||||||
if (priv->channels[channel-1].out1.pol & STM32_POL_POS)
|
if (priv->channels[channel-1].out1.pol == STM32_POL_POS)
|
||||||
{
|
{
|
||||||
ccer |= (GTIM_CCER_CC1P << ((channel-1)*4));
|
ccer |= (GTIM_CCER_CC1P << ((channel-1)*4));
|
||||||
}
|
}
|
||||||
@ -2757,7 +2732,7 @@ static int pwm_output_configure(FAR struct stm32_pwmtimer_s *priv,
|
|||||||
{
|
{
|
||||||
/* Configure output IDLE State */
|
/* Configure output IDLE State */
|
||||||
|
|
||||||
if (priv->channels[channel-1].out1.idle & STM32_IDLE_ACTIVE)
|
if (priv->channels[channel-1].out1.idle == STM32_IDLE_ACTIVE)
|
||||||
{
|
{
|
||||||
cr2 |= (ATIM_CR2_OIS1 << ((channel-1)*2));
|
cr2 |= (ATIM_CR2_OIS1 << ((channel-1)*2));
|
||||||
}
|
}
|
||||||
@ -2766,10 +2741,10 @@ static int pwm_output_configure(FAR struct stm32_pwmtimer_s *priv,
|
|||||||
cr2 &= ~(ATIM_CR2_OIS1 << ((channel-1)*2));
|
cr2 &= ~(ATIM_CR2_OIS1 << ((channel-1)*2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
/* Configure complementary output IDLE state */
|
/* Configure complementary output IDLE state */
|
||||||
|
|
||||||
if (priv->channels[channel-1].out2.idle & STM32_IDLE_ACTIVE)
|
if (priv->channels[channel-1].out2.idle == STM32_IDLE_ACTIVE)
|
||||||
{
|
{
|
||||||
cr2 |= (ATIM_CR2_OIS1N << ((channel-1)*2));
|
cr2 |= (ATIM_CR2_OIS1N << ((channel-1)*2));
|
||||||
}
|
}
|
||||||
@ -2780,7 +2755,7 @@ static int pwm_output_configure(FAR struct stm32_pwmtimer_s *priv,
|
|||||||
|
|
||||||
/* Configure complementary output polarity */
|
/* Configure complementary output polarity */
|
||||||
|
|
||||||
if (priv->channels[channel-1].out2.pol & STM32_POL_POS)
|
if (priv->channels[channel-1].out2.pol == STM32_POL_POS)
|
||||||
{
|
{
|
||||||
ccer |= (ATIM_CCER_CC1NP << ((channel-1)*4));
|
ccer |= (ATIM_CCER_CC1NP << ((channel-1)*4));
|
||||||
}
|
}
|
||||||
@ -2788,7 +2763,7 @@ static int pwm_output_configure(FAR struct stm32_pwmtimer_s *priv,
|
|||||||
{
|
{
|
||||||
ccer &= ~(ATIM_CCER_CC1NP << ((channel-1)*4));
|
ccer &= ~(ATIM_CCER_CC1NP << ((channel-1)*4));
|
||||||
}
|
}
|
||||||
#endif /* HAVE_COMPLEMENTARY */
|
#endif /* HAVE_PWM_COMPLEMENTARY */
|
||||||
|
|
||||||
#ifdef HAVE_IP_TIMERS_V2
|
#ifdef HAVE_IP_TIMERS_V2
|
||||||
/* TODO: OIS5 and OIS6 */
|
/* TODO: OIS5 and OIS6 */
|
||||||
@ -2888,7 +2863,7 @@ static int pwm_outputs_enable(FAR struct pwm_lowerhalf_s *dev,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_COMPLEMENTARY) && defined(CONFIG_STM32_PWM_LL_OPS)
|
#if defined(HAVE_PWM_COMPLEMENTARY) && defined(CONFIG_STM32_PWM_LL_OPS)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: pwm_deadtime_update
|
* Name: pwm_deadtime_update
|
||||||
@ -2896,6 +2871,7 @@ static int pwm_outputs_enable(FAR struct pwm_lowerhalf_s *dev,
|
|||||||
|
|
||||||
static int pwm_deadtime_update(FAR struct pwm_lowerhalf_s *dev, uint8_t dt)
|
static int pwm_deadtime_update(FAR struct pwm_lowerhalf_s *dev, uint8_t dt)
|
||||||
{
|
{
|
||||||
|
FAR struct stm32_pwmtimer_s *priv = (FAR struct stm32_pwmtimer_s *)dev;
|
||||||
uint32_t bdtr = 0;
|
uint32_t bdtr = 0;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
@ -3041,7 +3017,7 @@ static uint16_t pwm_outputs_from_channels(FAR struct stm32_pwmtimer_s *priv)
|
|||||||
outputs |= (STM32_CHAN1 << ((channel-1)*2));
|
outputs |= (STM32_CHAN1 << ((channel-1)*2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
/* Enable complementary output if configured */
|
/* Enable complementary output if configured */
|
||||||
|
|
||||||
if (priv->channels[i].out2.in_use == 1)
|
if (priv->channels[i].out2.in_use == 1)
|
||||||
@ -3079,7 +3055,7 @@ static int pwm_break_dt_configure(FAR struct stm32_pwmtimer_s *priv)
|
|||||||
pwm_modifyreg(priv, STM32_GTIM_CR1_OFFSET, GTIM_CR1_CKD_MASK,
|
pwm_modifyreg(priv, STM32_GTIM_CR1_OFFSET, GTIM_CR1_CKD_MASK,
|
||||||
priv->t_dts<<GTIM_CR1_CKD_SHIFT);
|
priv->t_dts<<GTIM_CR1_CKD_SHIFT);
|
||||||
|
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
/* Initialize deadtime */
|
/* Initialize deadtime */
|
||||||
|
|
||||||
bdtr |= (priv->deadtime << ATIM_BDTR_DTG_SHIFT);
|
bdtr |= (priv->deadtime << ATIM_BDTR_DTG_SHIFT);
|
||||||
@ -4075,7 +4051,7 @@ static int pwm_setup(FAR struct pwm_lowerhalf_s *dev)
|
|||||||
pwm_dumpgpio(pincfg, "PWM setup");
|
pwm_dumpgpio(pincfg, "PWM setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
if (priv->channels[i].out2.in_use == 1)
|
if (priv->channels[i].out2.in_use == 1)
|
||||||
{
|
{
|
||||||
pincfg = priv->channels[i].out2.pincfg;
|
pincfg = priv->channels[i].out2.pincfg;
|
||||||
@ -4161,7 +4137,7 @@ static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev)
|
|||||||
stm32_configgpio(pincfg);
|
stm32_configgpio(pincfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
pincfg = priv->channels[i].out2.pincfg;
|
pincfg = priv->channels[i].out2.pincfg;
|
||||||
if (pincfg != 0)
|
if (pincfg != 0)
|
||||||
{
|
{
|
||||||
|
@ -849,6 +849,31 @@
|
|||||||
# define PWM_TIM17_CH1NCFG 0
|
# define PWM_TIM17_CH1NCFG 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Complementary outputs support */
|
||||||
|
|
||||||
|
#if defined(CONFIG_STM32_TIM1_CH1NOUT) || defined(CONFIG_STM32_TIM1_CH2NOUT) || \
|
||||||
|
defined(CONFIG_STM32_TIM1_CH3NOUT)
|
||||||
|
# define HAVE_TIM1_COMPLEMENTARY
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_STM32_TIM8_CH1NOUT) || defined(CONFIG_STM32_TIM8_CH2NOUT) || \
|
||||||
|
defined(CONFIG_STM32_TIM8_CH3NOUT)
|
||||||
|
# define HAVE_TIM8_COMPLEMENTARY
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_STM32_TIM15_CH1NOUT)
|
||||||
|
# define HAVE_TIM15_COMPLEMENTARY
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_STM32_TIM16_CH1NOUT)
|
||||||
|
# define HAVE_TIM16_COMPLEMENTARY
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_STM32_TIM17_CH1NOUT)
|
||||||
|
# define HAVE_TIM17_COMPLEMENTARY
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_TIM1_COMPLEMENTARY) || defined(HAVE_TIM8_COMPLEMENTARY) || \
|
||||||
|
defined(HAVE_TIM15_COMPLEMENTARY) || defined(HAVE_TIM16_COMPLEMENTARY) || \
|
||||||
|
defined(HAVE_TIM17_COMPLEMENTARY)
|
||||||
|
# define HAVE_PWM_COMPLEMENTARY
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Low-level ops helpers ************************************************************/
|
/* Low-level ops helpers ************************************************************/
|
||||||
|
|
||||||
/* NOTE: low-level ops accept pwm_lowerhalf_s as first argument, but llops access
|
/* NOTE: low-level ops accept pwm_lowerhalf_s as first argument, but llops access
|
||||||
@ -1027,7 +1052,7 @@ struct stm32_pwm_ops_s
|
|||||||
int (*dump_regs)(FAR struct pwm_lowerhalf_s *dev);
|
int (*dump_regs)(FAR struct pwm_lowerhalf_s *dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_COMPLEMENTARY
|
#ifdef HAVE_PWM_COMPLEMENTARY
|
||||||
/* Deadtime update */
|
/* Deadtime update */
|
||||||
|
|
||||||
int (*dt_update)(FAR struct pwm_lowerhalf_s *dev, uint8_t dt);
|
int (*dt_update)(FAR struct pwm_lowerhalf_s *dev, uint8_t dt);
|
||||||
|
@ -72,6 +72,10 @@
|
|||||||
# define CONFIG_LIBDSP_PRECISION 0
|
# define CONFIG_LIBDSP_PRECISION 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CONFIG_LIBM) && !defined(CONFIG_ARCH_MATH_H)
|
||||||
|
# error math.h not defined!
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Phase rotation direction */
|
/* Phase rotation direction */
|
||||||
|
|
||||||
#define DIR_CW (1.0f)
|
#define DIR_CW (1.0f)
|
||||||
|
Loading…
Reference in New Issue
Block a user