1.\" $NetBSD: gpiopwm.4,v 1.5 2014/03/18 18:20:39 riastradh Exp $ 2.\" 3.\" Copyright (c) 2011 Marc Balmer <marc@msys.ch> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd November 13, 2011 18.Dt GPIOPWM 4 19.Os 20.Sh NAME 21.Nm gpiopwm 22.Nd support for pulsing GPIO pins in software 23.Sh SYNOPSIS 24.Cd "gpiopwm* at gpio? offset ? mask 1" 25.Cd "gpiopwm* at gpio?" 26.Sh DESCRIPTION 27The 28.Nm 29driver allows for pulsing GPIO pins in software using the 30.Xr callout 9 31facility. 32The pulse frequency and duty cycle are specified indirectly by setting an 33.Dq on 34and 35.Dq off 36period, in ticks. 37Both values are accessible as 38.Xr sysctl 3 39variables. 40.Sh SYSCTL VARIABLES 41The following 42.Xr sysctl 3 43variables are used to define the pulsing: 44.Bl -tag -width hw.gpiopwmN.off 45.It hw.gpiopwmN.off 46Define the 47.Dq off 48period in ticks. 49.It hw.gpiopwmN.on 50Define the 51.Dq on 52period in ticks. 53.El 54.Pp 55Only when both the 56.Dq on 57and the 58.Dq off 59period are set to values higher than zero pulsing will start. 60To stop the pulsing, set either value to zero. 61.Sh EXAMPLES 62To pulse a pin on a machine with 100 ticks/second with a frequency of 1Hz and a 63duty cycle of 20%, the 64.Dq on 65period must be set to 20 and the 66.Dq off 67period must be set to 80. 68The following example will pulse the error LED of a Soekris net4801 69with a frequency of 1 Hz and a duty cycle of 20%: 70.Bd -literal 71# gpioctl gpio0 20 set pp 72# gpioctl gpio0 attach gpiopwm 20 1 73# sysctl -w hw.gpiopwm0.off=80 74# sysctl -w hw.gpiopwm0.on=20 75.Ed 76.Sh SEE ALSO 77.Xr gpio 4 , 78.\" .Xr gpioattach 4 , 79.Xr intro 4 , 80.Xr gpioctl 8 , 81.Xr sysctl 8 82.Sh HISTORY 83The 84.Nm 85driver first appeared in 86.Nx 6.0 . 87.Sh AUTHORS 88.An -nosplit 89The 90.Nm 91driver was written by 92.An Marc Balmer Aq Mt marc@msys.ch . 93