Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

.\"	$NetBSD: gpiopwm.4,v 1.5 2014/03/18 18:20:39 riastradh Exp $
.\"
.\" Copyright (c) 2011 Marc Balmer <marc@msys.ch>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd November 13, 2011
.Dt GPIOPWM 4
.Os
.Sh NAME
.Nm gpiopwm
.Nd support for pulsing GPIO pins in software
.Sh SYNOPSIS
.Cd "gpiopwm* at gpio? offset ? mask 1"
.Cd "gpiopwm* at gpio?"
.Sh DESCRIPTION
The
.Nm
driver allows for pulsing GPIO pins in software using the
.Xr callout 9
facility.
The pulse frequency and duty cycle are specified indirectly by setting an
.Dq on
and
.Dq off
period, in ticks.
Both values are accessible as
.Xr sysctl 3
variables.
.Sh SYSCTL VARIABLES
The following
.Xr sysctl 3
variables are used to define the pulsing:
.Bl -tag -width hw.gpiopwmN.off
.It hw.gpiopwmN.off
Define the
.Dq off
period in ticks.
.It hw.gpiopwmN.on
Define the
.Dq on
period in ticks.
.El
.Pp
Only when both the
.Dq on
and the
.Dq off
period are set to values higher than zero pulsing will start.
To stop the pulsing, set either value to zero.
.Sh EXAMPLES
To pulse a pin on a machine with 100 ticks/second with a frequency of 1Hz and a
duty cycle of 20%, the
.Dq on
period must be set to 20 and the
.Dq 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%:
.Bd -literal
# gpioctl gpio0 20 set pp
# gpioctl gpio0 attach gpiopwm 20 1
# sysctl -w hw.gpiopwm0.off=80
# sysctl -w hw.gpiopwm0.on=20
.Ed
.Sh SEE ALSO
.Xr gpio 4 ,
.\" .Xr gpioattach 4 ,
.Xr intro 4 ,
.Xr gpioctl 8 ,
.Xr sysctl 8
.Sh HISTORY
The
.Nm
driver first appeared in
.Nx 6.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An Marc Balmer Aq Mt marc@msys.ch .