For usage examples, see the
https://python-periphery.readthedocs.io/en/latest/pwm.html
I2C
The following code shows how to instantiate each of the I2C ports with Periphery:
i2c2 = I2C(
"/dev/i2c-1"
)
i2c3 = I2C(
"/dev/i2c-2"
)
For usage examples, see the
https://python-periphery.readthedocs.io/en/latest/i2c.html
SPI
The following code shows how to instantiate each of the SPI ports with Periphery:
# SPI1, SS0, Mode 0, 10MHz
spi1_0 = SPI(
"/dev/spidev32766.0"
,
0
,
10000000
)
# SPI1, SS1, Mode 0, 10MHz
spi1_1 = SPI(
"/dev/spidev32766.1"
,
0
,
10000000
)
For usage examples, see the
https://python-periphery.readthedocs.io/en/latest/spi.html
UART
The following code shows how to instantiate each of the UART ports with Periphery:
# UART1, 115200 baud
uart1 = Serial(
"/dev/ttymxc0"
,
115200
)
# UART3, 9600 baud
uart3 = Serial(
"/dev/ttymxc2"
,
9600
)
Caution:
UART1 is shared with the Linux serial console. To use the UART1 port in your application, you
must disable the serial console with the following command:
systemctl stop [email protected]
Note: UART3 is not enabled by default in Mendel 3.0 (Chef), but we've released a package update to
enable it. First check to see if it's available on your board:
ls
/dev |
grep
ttymxc
If you see
ttymxc2
listed, then you're all good. If not, then you need to update as follows:
sudo
apt-get
update
sudo
apt-get
dist-upgrade
sudo
reboot
now
For usage examples, see the
https://python-periphery.readthedocs.io/en/latest/serial.html