Enable DMTimer PWM pins on BBB and PB #340
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scope of Change
As referenced in #229, there are additional PWM pins available for use on the BeagleBoard. These pins take advantage of the DMTimer to create PWM signals. The current version of
Adafruit_BBIO.PWM
does not have support for these pins. This PR adds support for these pins without change the structure ofAdafruit_BBIO.PWM
from the user's perspective (see the "Tests/Examples" section of this PR).To add support for these pins, a different PWM path is used when accessing the DMTimer pins. To elaborate, when a DMTimer pin is accessed, its properties can be changed in
/sys/devices/platform/dmtimer-pwm-*/pwm/pwmchip*/pwm0/
(after exporting the pin within the pwmchip directory). This is different from the ocp path used for the standard PWM pins.Fortunately, because of the structure of this library -- especially the
pwm_exp
struct (which stores the PWM config files) -- the majority of the changes are localized within thepwm_setup
function ofc_pwm.c
. Minor modifications were also made to the tables found incommon.c
.Limitations
The current changes are meant to support the PocketBeagle and BeagleBone Black. The code has only been tested on a PocketBeagle (see the "Tests/Examples" section). See #229 for a list of kernels that support PWM output from the DMTimer pins. In order to use these pins, the proper device tree overlays must be loaded (these for PocketBeagle and these for BeagleBone Black)
Tests/Examples
This feature has only been tested on a PocketBeagle (due to the availability of resources), but should also work on the BeagleBone Black. To test the functionality, I loaded
PB-PWM-TIMER-P1.20.dtbo,
connected an LED to P1_20, and ran the following in my Python shell:I repeated this for the other four DMTimer pins on the PocketBeagle.
This example illustrates how the library itself has not changed from the user's perspective (this is the same code that would be used for any PWM pin). I've run this test on the currently recommended Buster IoT image ("AM3358 Debian 10.3 2020-04-06 4GB SD IoT"), as well as the 2020-07-13, Buster IoT testing image "bone-debian-10.4-iot-armhf-2020-07-13-4gb.img.xz".