This guide covers the basics of adding a board that can support GPIO, I2C, SPI, and UART Serial. However, Blinka supports other features such as PWM Output using the pulseio module, NeoPixel Support, and Analog Support using the analogio module.

Since each of these is implemented differently for each board, we don't have a specific set of steps to follow. However, the separate files for each supported module should be stored in the same folder as your Chip file.

PWM Output

There are a couple of ways that you can add PWM support to your board. Either you can use built-in PWM support and use the sysfs PWM library, or you can use a custom driver such as one provided by the manufacturer. Custom manufacturer drivers vary widely and is beyond the scope of this guide. Additionally, not all boards support PWM. You could check that it is supported natively by running the command:

ls /sys/class/pwm

The check if anything shows up. There was nothing for the Pine64, but there was when we added the Coral:

If you do find something, you can get some more information by typing:

sudo cat /sys/kernel/debug/pwm

None of these PWMs in the example photo are in use. You can tell by the (null) and that the period and duty cycle are 0. If they were in use, you couldn't use them. Also, sometimes the pwm chips can control more than 1 pin.

To add natively supported PWM, you'll first need to add pwmOuts to your Chip file such as:

pwmOuts = (
  ((0, 0), PWM1),
  ((1, 0), PWM2),
  ((2, 0), PWM3),
)

The first parameter is a tuple and consists of the PWM chip number and the PWM channel of that chip.

The second parameter is the PWM pin and can be found by either a web search or referring to the manufacturer data.

Don't forget to add the pins to the Board file as well in the same way as the GPIO.

Regardless of whether you are using a manufacturer driver or adding it natively, you will also want to add your board to Adafruit_Blinka/src/pulseio.py.

NeoPixel Support

To add NeoPixel support, you will need a driver that is capable of running the NeoPixels at a rate of 800Hz since they run at a fixed frequency. If you are able to find or write a driver for the board, you will want to be sure to add your board to Adafruit_Blinka/src/neopixel_write.py.

Analog Support

For adding Analog Support, your board will first need to have PINs that have either an ADC or Analog-to-Digital Converter, or a DAC, which is the opposite of an ADC. You will most likely need to create a custom Pin file for your board that adds support for those pins and you will want to add your board to Adafruit_Blinka/src/analogio.py.

This guide was first published on Apr 01, 2020. It was last updated on Mar 28, 2024.

This page (Adding More Features) was last updated on Mar 08, 2024.

Text editor powered by tinymce.