Skip to content

Commit

Permalink
[RSDK-2734] turn off PWM signals when closing a board (#2224)
Browse files Browse the repository at this point in the history
Tried on an Orin: if you set a pin to high or turn on a PWM signal, and then hit control-C to kill the RDK server, the pin goes low again and stays there.

If you set a pin high or turn on a PWM signal, and then change the board config, the pin goes low again and stays there (until you set it to something else afterwards on the new board component). Is that the right choice? I think it might be, but would like a second opinion.
  • Loading branch information
penguinland authored Apr 17, 2023
1 parent 39e9f1c commit 19079d2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions components/board/genericlinux/gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,10 @@ func (pin *gpioPin) Close() error {
pin.mu.Lock()
defer pin.mu.Unlock()

if pin.hwPwm != nil {
// Make sure to unexport the sysfs device for hardware PWM on this pin, if it's in use.
if err := pin.hwPwm.Close(); err != nil {
return err
}
// If the entire server is shutting down, it's important to turn off all pins so they don't
// continue outputting signals we can no longer control.
if err := pin.setInternal(false); err != nil {
return err
}
return pin.closeGpioFd()
}
Expand Down

0 comments on commit 19079d2

Please sign in to comment.