GPIOPWM(4)

GPIOPWM(4) | Device Drivers Manual | GPIOPWM(4)

# NAME

`gpiopwm` — support for pulsing GPIO pins in software

# SYNOPSIS

`gpiopwm* at gpio? offset ? mask 1`
`gpiopwm* at gpio?`

# DESCRIPTION

The `gpiopwm` driver allows for pulsing GPIO pins in software using the callout(9) facility. The pulse frequency and duty cycle are specified indirectly by setting an “on” and “off” period, in ticks. Both values are accessible as sysctl(3) variables.

# SYSCTL VARIABLES

The following sysctl(3) variables are used to define the pulsing:

hw.gpiopwmN.off
  Define the “off” period in ticks.
hw.gpiopwmN.on
  Define the “on” period in ticks.

Only when both the “on” and the “off” period are set to values higher than zero pulsing will start. To stop the pulsing, set either value to zero.

# EXAMPLES

To pulse a pin on a machine with 100 ticks/second with a frequency of 1Hz and a duty cycle of 20%, the “on” period must be set to 20 and the “off” period must be set to 80. The following example will pulse the error LED of a Soekris net4801 with a frequency of 1 Hz and a duty cycle of 20%:

    # gpioctl gpio0 20 set pp
    # gpioctl gpio0 attach gpiopwm 20 1
    # sysctl -w hw.gpiopwm0.off=80
    # sysctl -w hw.gpiopwm0.on=20

# SEE ALSO

gpio(4), intro(4), gpioctl(8), sysctl(8)

# HISTORY

The `gpiopwm` driver first appeared in NetBSD 6.0.

# AUTHORS

The `gpiopwm` driver was written by Marc Balmer <marc@msys.ch>.

November 13, 2011 | NetBSD 11.0