Commit ded2157c authored by TMRh20's avatar TMRh20

RPI: Fix for SPIDEV on 4.1.7+

Per #138 n8henrie - SPIDEV not working with newest firmware.
parent 14ed8638
...@@ -18,18 +18,18 @@ void SPI::begin(int busNo){ ...@@ -18,18 +18,18 @@ void SPI::begin(int busNo){
//BBB: //BBB:
if(!busNo){ /*if(!busNo){
this->device = "/dev/spidev1.0";; this->device = "/dev/spidev1.0";;
}else{ }else{
this->device = "/dev/spidev1.1";; this->device = "/dev/spidev1.1";;
} }*/
//RPi: //RPi:
/* if(!busNo){ if(!busNo){
this->device = "/dev/spidev0.0";; this->device = "/dev/spidev0.0";;
}else{ }else{
this->device = "/dev/spidev0.1";; this->device = "/dev/spidev0.1";;
}*/ }
this->bits = 8; this->bits = 8;
...@@ -111,6 +111,7 @@ uint8_t SPI::transfer(uint8_t tx_) ...@@ -111,6 +111,7 @@ uint8_t SPI::transfer(uint8_t tx_)
uint8_t tx[1] = {tx_}; uint8_t tx[1] = {tx_};
uint8_t rx[1]; uint8_t rx[1];
this->init();
struct spi_ioc_transfer tr = { struct spi_ioc_transfer tr = {
tr.tx_buf = (unsigned long)&tx[0], tr.tx_buf = (unsigned long)&tx[0],
tr.rx_buf = (unsigned long)&rx[0], tr.rx_buf = (unsigned long)&rx[0],
...@@ -151,7 +152,7 @@ void SPI::transfernb(char* tbuf, char* rbuf, uint32_t len) ...@@ -151,7 +152,7 @@ void SPI::transfernb(char* tbuf, char* rbuf, uint32_t len)
{ {
int ret; int ret;
this->init();
struct spi_ioc_transfer tr = { struct spi_ioc_transfer tr = {
tr.tx_buf = (unsigned long)tbuf, tr.tx_buf = (unsigned long)tbuf,
tr.rx_buf = (unsigned long)rbuf, tr.rx_buf = (unsigned long)rbuf,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment