PWM generator using AR9331 hardware timer.
gpio-pwm-ar9331 is an OpenWRT kernel module which provides PWM output on any AR9331 SoC GPIO pin with up to 125 kHz frequency.
##Intallation
- Build it using OpenWRT Buildroot.
- Upload package to device using your favorite method.
- Run
opkg install kmod-gpio-pwm-ar9331_<version>.ipk
where<version>
is version of a package.
##Building
- Clone this repository to buildrootdir/package (i.e.
cd /path/to/buildroot/
thencd package/
andgit clone https://github.com/ASMfreaK/gpio-pwm-ar9331.git
) - Run
make menuconfig
and selectKernel modules --->
thenOther modules --->
and finallykmod-gpio-pwm-ar9331
. Select other packages if needed and exit the dialog. - Run
make
- Install the freshly built firmware to BlackSwift.
##Initialisation
insmod gpio-pwm-ar9331
Default is timer 3
##Usage
Start: echo "+ <timer> <GPIO> <freq> <pos>" > /sys/kernel/debug/pwm-ar9331
timer
is timer number (one of 0, 1, 2, 3), GPIO
is GPIO number, freq
is square wave frequency in Hz, pos
is a number between 0 and 65536 representing duty cycle. At different frequencies it can generate up to 16 bit PWM Maximum frequency with 200 MHz system bus (default clock) is 125 kHz; high settings may result in performance penalty or watchdog reset.
Example: to blink Black Swift's system LED with 1 Hz frequency at around 1/2 duty cycle using timer 0: echo "+ 0 27 1 3000" > /sys/kernel/debug/pwm-ar9331
Stop: echo - > /sys/kernel/debug/pwm-ar9331
Status: echo ? > /sys/kernel/debug/pwm-ar9331