tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

gpio(4) and pulsing pins in software

I recently added code to gpio(4) on jak's request to pulse a pin in
software.  The idea is, that when the hardware supports it, a pin is
pulsed by the hardware, if the underlying hardware has no pulsate
support, it can be done in software.  While the current code works, I
think it is done wrong, or at the wrong level, and I'd like to change
that. Comments welcome.

I think gpio(4) should only be used to configure and control pins, but
not to do any magic with them, like pulsing in software.  We have the
possibility to attach device drivers to individual pins which can then
do the "magic".  So I am suggesting removing the software pulsing
support in gpio(4) and replacing it by a gpiopwm(4) driver that can be
attached to an individual pin.  gpioctl(8) will keep the pulse keyword,
as this is needed for hardware pulsating devices.  The interface to the
gpiopwm(4) driver could be realized using three sysctl variables:

hw.gpiopwm0.running=0 # Set to 1 to start pwm
hw.gpiopwm0.ticks_on=n1 # Number of ticks the pin is 1
hw.gpiopwm0.ticks_off=n2 # Number of ticks the pin is 0

The current implementation is kind of a hack, since I need a callout_t
and two integers per pin, if they pulse or not.  Memory is certainly not
the problem, but I think it's gross nonetheless.


Home | Main Index | Thread Index | Old Index