Had to go back...
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2416 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
2018975c3e
commit
955425572d
|
@ -82,7 +82,7 @@ typedef enum {
|
|||
* @iclass
|
||||
*/
|
||||
#define pwmEnableChannelI(pwmp, channel, width) \
|
||||
pwm_lld_set_channel(pwmp, channel, width)
|
||||
pwm_lld_enable_channel(pwmp, channel, width)
|
||||
|
||||
/**
|
||||
* @brief Disables a PWM channel.
|
||||
|
@ -96,7 +96,7 @@ typedef enum {
|
|||
* @iclass
|
||||
*/
|
||||
#define pwmDisableChannelI(pwmp, channel) \
|
||||
pwm_lld_set_channel(pwmp, channel, 0)
|
||||
pwm_lld_disable_channel(pwmp, channel)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
|
|
|
@ -87,9 +87,8 @@ static void stop_channels(PWMDriver *pwmp) {
|
|||
pwmp->pd_tim->CCR2 = 0; /* Comparator 2 disabled. */
|
||||
pwmp->pd_tim->CCR3 = 0; /* Comparator 3 disabled. */
|
||||
pwmp->pd_tim->CCR4 = 0; /* Comparator 4 disabled. */
|
||||
/* Channels forced to idle.*/
|
||||
pwmp->pd_tim->CCMR1 = TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC2M_2;
|
||||
pwmp->pd_tim->CCMR2 = TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC4M_2;
|
||||
pwmp->pd_tim->CCMR1 = 0; /* Channels 1 and 2 frozen. */
|
||||
pwmp->pd_tim->CCMR2 = 0; /* Channels 3 and 4 frozen. */
|
||||
}
|
||||
|
||||
#if STM32_PWM_USE_TIM2 || STM32_PWM_USE_TIM3 || STM32_PWM_USE_TIM4 || \
|
||||
|
@ -414,48 +413,18 @@ void pwm_lld_stop(PWMDriver *pwmp) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Disables, enables or reprograms a PWM channel.
|
||||
* @brief Enables a PWM channel.
|
||||
*
|
||||
* @param[in] pwmp pointer to a @p PWMDriver object
|
||||
* @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
|
||||
* @param[in] width PWM pulse width as clock pulses number, note that
|
||||
* specifying zero disables the channel and enforces
|
||||
* the output to the idle state.
|
||||
* @param[in] width PWM pulse width as clock pulses number
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
void pwm_lld_set_channel(PWMDriver *pwmp,
|
||||
void pwm_lld_enable_channel(PWMDriver *pwmp,
|
||||
pwmchannel_t channel,
|
||||
pwmcnt_t width) {
|
||||
|
||||
if (width == 0) {
|
||||
/* Channel disable mode.*/
|
||||
pwmp->pd_enabled_channels &= ~(1 << channel);
|
||||
switch (channel) {
|
||||
case 0:
|
||||
pwmp->pd_tim->CCR1 = 0;
|
||||
pwmp->pd_tim->CCMR1 = (pwmp->pd_tim->CCMR1 & 0xFF00) | TIM_CCMR1_OC1M_2;
|
||||
pwmp->pd_tim->DIER &= ~TIM_DIER_CC1IE;
|
||||
break;
|
||||
case 1:
|
||||
pwmp->pd_tim->CCR2 = 0;
|
||||
pwmp->pd_tim->CCMR1 = (pwmp->pd_tim->CCMR1 & 0x00FF) | TIM_CCMR1_OC2M_2;
|
||||
pwmp->pd_tim->DIER &= ~TIM_DIER_CC2IE;
|
||||
break;
|
||||
case 2:
|
||||
pwmp->pd_tim->CCR3 = 0;
|
||||
pwmp->pd_tim->CCMR2 = (pwmp->pd_tim->CCMR2 & 0xFF00) | TIM_CCMR2_OC3M_2;
|
||||
pwmp->pd_tim->DIER &= ~TIM_DIER_CC3IE;
|
||||
break;
|
||||
case 3:
|
||||
pwmp->pd_tim->CCR4 = 0;
|
||||
pwmp->pd_tim->CCMR2 = (pwmp->pd_tim->CCMR2 & 0x00FF) | TIM_CCMR2_OC4M_2;
|
||||
pwmp->pd_tim->DIER &= ~TIM_DIER_CC4IE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Channel enable or reprogram mode.*/
|
||||
switch (channel) {
|
||||
case 0:
|
||||
pwmp->pd_tim->CCR1 = width;
|
||||
|
@ -510,6 +479,40 @@ void pwm_lld_set_channel(PWMDriver *pwmp,
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disables a PWM channel.
|
||||
* @details The channel is disabled and its output line returned to the
|
||||
* idle state.
|
||||
*
|
||||
* @param[in] pwmp pointer to a @p PWMDriver object
|
||||
* @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
|
||||
*/
|
||||
void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel) {
|
||||
|
||||
pwmp->pd_enabled_channels &= ~(1 << channel);
|
||||
switch (channel) {
|
||||
case 0:
|
||||
pwmp->pd_tim->CCR1 = 0;
|
||||
pwmp->pd_tim->CCMR1 = pwmp->pd_tim->CCMR1 & 0xFF00;
|
||||
pwmp->pd_tim->DIER &= ~TIM_DIER_CC1IE;
|
||||
break;
|
||||
case 1:
|
||||
pwmp->pd_tim->CCR2 = 0;
|
||||
pwmp->pd_tim->CCMR1 = pwmp->pd_tim->CCMR1 & 0x00FF;
|
||||
pwmp->pd_tim->DIER &= ~TIM_DIER_CC2IE;
|
||||
break;
|
||||
case 2:
|
||||
pwmp->pd_tim->CCR3 = 0;
|
||||
pwmp->pd_tim->CCMR2 = pwmp->pd_tim->CCMR2 & 0xFF00;
|
||||
pwmp->pd_tim->DIER &= ~TIM_DIER_CC3IE;
|
||||
break;
|
||||
case 3:
|
||||
pwmp->pd_tim->CCR4 = 0;
|
||||
pwmp->pd_tim->CCMR2 = pwmp->pd_tim->CCMR2 & 0x00FF;
|
||||
pwmp->pd_tim->DIER &= ~TIM_DIER_CC4IE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -344,9 +344,10 @@ extern "C" {
|
|||
void pwm_lld_init(void);
|
||||
void pwm_lld_start(PWMDriver *pwmp);
|
||||
void pwm_lld_stop(PWMDriver *pwmp);
|
||||
void pwm_lld_set_channel(PWMDriver *pwmp,
|
||||
void pwm_lld_enable_channel(PWMDriver *pwmp,
|
||||
pwmchannel_t channel,
|
||||
pwmcnt_t width);
|
||||
void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -118,8 +118,7 @@ void pwmStop(PWMDriver *pwmp) {
|
|||
*
|
||||
* @param[in] pwmp pointer to a @p PWMDriver object
|
||||
* @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
|
||||
* @param[in] width PWM pulse width as clock pulses number, setting the
|
||||
* width at zero is equivalent to disabling the channel
|
||||
* @param[in] width PWM pulse width as clock pulses number
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -133,7 +132,7 @@ void pwmEnableChannel(PWMDriver *pwmp,
|
|||
chSysLock();
|
||||
chDbgAssert(pwmp->pd_state == PWM_READY,
|
||||
"pwmEnableChannel(), #1", "not ready");
|
||||
pwm_lld_set_channel(pwmp, channel, width);
|
||||
pwm_lld_enable_channel(pwmp, channel, width);
|
||||
chSysUnlock();
|
||||
}
|
||||
|
||||
|
@ -155,7 +154,7 @@ void pwmDisableChannel(PWMDriver *pwmp, pwmchannel_t channel) {
|
|||
chSysLock();
|
||||
chDbgAssert(pwmp->pd_state == PWM_READY,
|
||||
"pwmDisableChannel(), #1", "not ready");
|
||||
pwm_lld_set_channel(pwmp, channel, 0);
|
||||
pwm_lld_disable_channel(pwmp, channel);
|
||||
chSysUnlock();
|
||||
}
|
||||
|
||||
|
|
|
@ -102,22 +102,32 @@ bool_t pwm_lld_is_enabled(PWMDriver *pwmp, pwmchannel_t channel) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Disables, enables or reprograms a PWM channel.
|
||||
* @brief Enables a PWM channel.
|
||||
*
|
||||
* @param[in] pwmp pointer to a @p PWMDriver object
|
||||
* @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
|
||||
* @param[in] width PWM pulse width as clock pulses number, note that
|
||||
* specifying zero disables the channel and enforces
|
||||
* the output to the idle state.
|
||||
* @param[in] width PWM pulse width as clock pulses number
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
void pwm_lld_set_channel(PWMDriver *pwmp,
|
||||
void pwm_lld_enable_channel(PWMDriver *pwmp,
|
||||
pwmchannel_t channel,
|
||||
pwmcnt_t width) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disables a PWM channel.
|
||||
* @details The channel is disabled and its output line returned to the
|
||||
* idle state.
|
||||
*
|
||||
* @param[in] pwmp pointer to a @p PWMDriver object
|
||||
* @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
|
||||
*/
|
||||
void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel) {
|
||||
|
||||
}
|
||||
|
||||
#endif /* HAL_USE_PWM */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -195,9 +195,10 @@ extern "C" {
|
|||
void pwm_lld_start(PWMDriver *pwmp);
|
||||
void pwm_lld_stop(PWMDriver *pwmp);
|
||||
bool_t pwm_lld_is_enabled(PWMDriver *pwmp, pwmchannel_t channel);
|
||||
void pwm_lld_set_channel(PWMDriver *pwmp,
|
||||
void pwm_lld_enable_channel(PWMDriver *pwmp,
|
||||
pwmchannel_t channel,
|
||||
pwmcnt_t width);
|
||||
void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -85,8 +85,6 @@
|
|||
- NEW: Added demo for the ST STM8L-Discovery kit.
|
||||
- NEW: Added support for the STM32 Value Line to the HAL.
|
||||
- NEW: Added demo for the ST STM32VL-Discovery kit.
|
||||
- NEW: Simplified the interface between the PWM high level driver and the
|
||||
low level driver, now there is a single channels-interacting function.
|
||||
- CHANGE: Improved the STM32 HAL to support multiple sub-families, at compile
|
||||
time now it is possible to test the presence of any single peripheral into
|
||||
the specified STM32 device.
|
||||
|
|
Loading…
Reference in New Issue