mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
samv7/pwm: add support for PWMIOC_FAULTS_FETCH_AND_CLEAR ioctl
Build Documentation / build-html (push) Waiting to run
Build Documentation / build-html (push) Waiting to run
This ioctl fetches and clears PWM faults. Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
committed by
Alan C. Assis
parent
86917b4777
commit
4e70cc1e69
@@ -1118,7 +1118,43 @@ static int pwm_stop(struct pwm_lowerhalf_s *dev)
|
|||||||
static int pwm_ioctl(struct pwm_lowerhalf_s *dev, int cmd,
|
static int pwm_ioctl(struct pwm_lowerhalf_s *dev, int cmd,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
return -ENOTTY;
|
struct sam_pwm_s *priv = (struct sam_pwm_s *)dev;
|
||||||
|
uint32_t regval;
|
||||||
|
int ret = OK;
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case PWMIOC_FAULTS_FETCH_AND_CLEAR:
|
||||||
|
{
|
||||||
|
unsigned long clear = arg != 0 ?
|
||||||
|
*(unsigned long *)(uintptr_t)arg : FCR_FCLR_MASK;
|
||||||
|
|
||||||
|
/* Get current faults. */
|
||||||
|
|
||||||
|
regval = pwm_getreg(priv, SAMV7_PWM_FSR);
|
||||||
|
|
||||||
|
/* Clear the faults. */
|
||||||
|
|
||||||
|
clear &= ((regval & FSR_FS_MASK) >> FSR_FS_SHIFT);
|
||||||
|
pwm_putreg(priv, SAMV7_PWM_FCR, FCR_FCLR_SEL(clear));
|
||||||
|
|
||||||
|
/* And return the previously read faults. */
|
||||||
|
|
||||||
|
if (arg != 0)
|
||||||
|
{
|
||||||
|
*(unsigned long *)(uintptr_t)arg =
|
||||||
|
(regval & FSR_FS_MASK) >> FSR_FS_SHIFT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
pwmerr("ERROR: Unknown cmd: %d\n", cmd);
|
||||||
|
ret = -ENOTTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user