Created
October 24, 2017 02:50
-
-
Save greenbreakfast/e634201bf1f363ff927b871195069259 to your computer and use it in GitHub Desktop.
Script to configure a software bit-banged SPI interface on the Omega2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## insmod spi-gpio-custom bus%d=%d,%d,%d,%d,%d,%d,%d | |
## From OnionIoT/spi-gpio-driver: | |
## | |
# sprintf(cmd, SPI_DEV_INSMOD_TEMPLATE, params->busNum, params->deviceId, | |
# params->sckGpio, | |
# params->mosiGpio, | |
# params->misoGpio, | |
# params->mode, | |
# params->speedInHz, | |
# params->csGpio | |
# ); | |
# since gpios 4 and 5 are used: | |
omega2-ctrl gpiomux set i2c gpio | |
busNum=0 | |
deviceId=1 | |
sckGpio=4 | |
mosiGpio=19 | |
misoGpio=18 | |
mode=0 | |
speedInHz=25000000 | |
csGpio=5 | |
echo "> Registering SPI bitbang interface.." | |
echo " /dev/spi${busNum}.${deviceId}" | |
echo " CLK = GPIO${sckGpio}" | |
echo " MOSI = GPIO${mosiGpio}" | |
echo " MISO = GPIO${misoGpio}" | |
echo " CS = GPIO${csGpio}" | |
cmd="insmod spi-gpio-custom bus${busNum}=${deviceId},${sckGpio},${mosiGpio},${misoGpio},${mode},${speedInHz},${csGpio}" | |
echo "$cmd" | |
$cmd | |
echo "> Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment