stm32,stm32f7/foc: support for pwm_off()
This commit is contained in:
parent
30015b862c
commit
bd6a0b08db
@ -766,6 +766,7 @@ static int stm32_foc_shutdown(struct foc_dev_s *dev);
|
||||
static int stm32_foc_start(struct foc_dev_s *dev, bool state);
|
||||
static int stm32_foc_pwm_duty_set(struct foc_dev_s *dev,
|
||||
foc_duty_t *duty);
|
||||
static int stm32_foc_pwm_off(struct foc_dev_s *dev, bool off);
|
||||
static int stm32_foc_ioctl(struct foc_dev_s *dev, int cmd,
|
||||
unsigned long arg);
|
||||
static int stm32_foc_bind(struct foc_dev_s *dev,
|
||||
@ -857,6 +858,7 @@ static struct foc_lower_ops_s g_stm32_foc_ops =
|
||||
.shutdown = stm32_foc_shutdown,
|
||||
.start = stm32_foc_start,
|
||||
.pwm_duty_set = stm32_foc_pwm_duty_set,
|
||||
.pwm_off = stm32_foc_pwm_off,
|
||||
.ioctl = stm32_foc_ioctl,
|
||||
.bind = stm32_foc_bind,
|
||||
.fault_clear = stm32_foc_fault_clear,
|
||||
@ -1914,6 +1916,48 @@ static int stm32_foc_pwm_duty_set(struct foc_dev_s *dev,
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_foc_pwm_off
|
||||
*
|
||||
* Description:
|
||||
* Set the 3-phase bridge switches in off state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_foc_pwm_off(struct foc_dev_s *dev, bool off)
|
||||
{
|
||||
struct stm32_pwm_dev_s *pwm = PWM_FROM_FOC_DEV_GET(dev);
|
||||
|
||||
if (off)
|
||||
{
|
||||
/* Force all transistors to low state */
|
||||
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN1, PWM_MODE_HIZ);
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN2, PWM_MODE_HIZ);
|
||||
#if CONFIG_MOTOR_FOC_PHASES > 2
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN3, PWM_MODE_HIZ);
|
||||
#endif
|
||||
#if CONFIG_MOTOR_FOC_PHASES > 3
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN4, PWM_MODE_HIZ);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Restore FOC operation modes */
|
||||
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN1, PWM_MODE_FOC);
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN2, PWM_MODE_FOC);
|
||||
#if CONFIG_MOTOR_FOC_PHASES > 2
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN3, PWM_MODE_FOC);
|
||||
#endif
|
||||
#if CONFIG_MOTOR_FOC_PHASES > 3
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN4, PWM_MODE_FOC);
|
||||
#endif
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_foc_hw_config_get
|
||||
*
|
||||
|
@ -591,6 +591,7 @@ static int stm32_foc_shutdown(struct foc_dev_s *dev);
|
||||
static int stm32_foc_start(struct foc_dev_s *dev, bool state);
|
||||
static int stm32_foc_pwm_duty_set(struct foc_dev_s *dev,
|
||||
foc_duty_t *duty);
|
||||
static int stm32_foc_pwm_off(struct foc_dev_s *dev, bool off);
|
||||
static int stm32_foc_ioctl(struct foc_dev_s *dev, int cmd,
|
||||
unsigned long arg);
|
||||
static int stm32_foc_bind(struct foc_dev_s *dev,
|
||||
@ -657,6 +658,7 @@ static struct foc_lower_ops_s g_stm32_foc_ops =
|
||||
.shutdown = stm32_foc_shutdown,
|
||||
.start = stm32_foc_start,
|
||||
.pwm_duty_set = stm32_foc_pwm_duty_set,
|
||||
.pwm_off = stm32_foc_pwm_off,
|
||||
.ioctl = stm32_foc_ioctl,
|
||||
.bind = stm32_foc_bind,
|
||||
.fault_clear = stm32_foc_fault_clear,
|
||||
@ -1704,6 +1706,48 @@ static int stm32_foc_pwm_duty_set(struct foc_dev_s *dev,
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_foc_pwm_off
|
||||
*
|
||||
* Description:
|
||||
* Set the 3-phase bridge switches in off state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm32_foc_pwm_off(struct foc_dev_s *dev, bool off)
|
||||
{
|
||||
struct stm32_pwm_dev_s *pwm = PWM_FROM_FOC_DEV_GET(dev);
|
||||
|
||||
if (off)
|
||||
{
|
||||
/* Force all transistors to low state */
|
||||
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN1, PWM_MODE_HIZ);
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN2, PWM_MODE_HIZ);
|
||||
#if CONFIG_MOTOR_FOC_PHASES > 2
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN3, PWM_MODE_HIZ);
|
||||
#endif
|
||||
#if CONFIG_MOTOR_FOC_PHASES > 3
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN4, PWM_MODE_HIZ);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Restore FOC operation modes */
|
||||
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN1, PWM_MODE_FOC);
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN2, PWM_MODE_FOC);
|
||||
#if CONFIG_MOTOR_FOC_PHASES > 2
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN3, PWM_MODE_FOC);
|
||||
#endif
|
||||
#if CONFIG_MOTOR_FOC_PHASES > 3
|
||||
PWM_MODE_UPDATE(pwm, STM32_PWM_CHAN4, PWM_MODE_FOC);
|
||||
#endif
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_foc_hw_config_get
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user