2014-03-18 22:20:35 +04:00
|
|
|
.\" $NetBSD: gpiopwm.4,v 1.5 2014/03/18 18:20:39 riastradh Exp $
|
2011-11-13 16:35:40 +04:00
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
2011-11-13 23:31:05 +04:00
|
|
|
.Dd November 13, 2011
|
2011-11-13 16:35:40 +04:00
|
|
|
.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.
|
2011-11-13 23:31:05 +04:00
|
|
|
The pulse frequency and duty cycle are specified indirectly by setting an
|
|
|
|
.Dq on
|
|
|
|
and
|
|
|
|
.Dq off
|
|
|
|
period, in ticks.
|
2011-11-13 16:35:40 +04:00
|
|
|
Both values are accessible as
|
2011-11-13 23:31:05 +04:00
|
|
|
.Xr sysctl 3
|
2011-11-13 16:35:40 +04:00
|
|
|
variables.
|
|
|
|
.Sh SYSCTL VARIABLES
|
|
|
|
The following
|
2011-11-13 23:31:05 +04:00
|
|
|
.Xr sysctl 3
|
2011-11-13 16:35:40 +04:00
|
|
|
variables are used to define the pulsing:
|
2013-06-04 16:11:12 +04:00
|
|
|
.Bl -tag -width hw.gpiopwmN.off
|
2011-11-13 16:35:40 +04:00
|
|
|
.It hw.gpiopwmN.off
|
2011-11-13 23:31:05 +04:00
|
|
|
Define the
|
|
|
|
.Dq off
|
|
|
|
period in ticks.
|
2011-11-13 16:35:40 +04:00
|
|
|
.It hw.gpiopwmN.on
|
2011-11-13 23:31:05 +04:00
|
|
|
Define the
|
|
|
|
.Dq on
|
|
|
|
period in ticks.
|
2011-11-13 16:35:40 +04:00
|
|
|
.El
|
|
|
|
.Pp
|
2011-11-13 23:31:05 +04:00
|
|
|
Only when both the
|
|
|
|
.Dq on
|
|
|
|
and the
|
|
|
|
.Dq off
|
|
|
|
period are set to values higher than zero pulsing will start.
|
2011-11-13 16:35:40 +04:00
|
|
|
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
|
2011-11-13 23:31:05 +04:00
|
|
|
duty cycle of 20%, the
|
|
|
|
.Dq on
|
|
|
|
period must be set to 20 and the
|
|
|
|
.Dq off
|
|
|
|
period must be set to 80.
|
2011-11-13 16:35:40 +04:00
|
|
|
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 ,
|
2011-11-13 23:31:05 +04:00
|
|
|
.\" .Xr gpioattach 4 ,
|
|
|
|
.Xr intro 4 ,
|
2011-11-13 16:35:40 +04:00
|
|
|
.Xr gpioctl 8 ,
|
2011-11-13 23:31:05 +04:00
|
|
|
.Xr sysctl 8
|
2011-11-13 16:35:40 +04:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver first appeared in
|
|
|
|
.Nx 6.0 .
|
|
|
|
.Sh AUTHORS
|
|
|
|
.An -nosplit
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver was written by
|
2013-07-21 01:39:55 +04:00
|
|
|
.An Marc Balmer Aq Mt marc@msys.ch .
|