Commit 9a5ea80c authored by TMRh20's avatar TMRh20

Bugfix: Deadlocks due to RPi SPI mutex code

- SPI transfern function calls transfernb function so a deadlock was
occurring when a lock was attempted prior to the call
- Thread should be unlocked before returning if bcm2835_init() fails
parent 243e25f2
...@@ -10,6 +10,7 @@ SPI::SPI() { ...@@ -10,6 +10,7 @@ SPI::SPI() {
void SPI::begin( int busNo ) { void SPI::begin( int busNo ) {
spiNoInterrupts(); spiNoInterrupts();
if (!bcm2835_init()){ if (!bcm2835_init()){
spiInterrupts();
return; return;
} }
......
...@@ -50,9 +50,7 @@ void SPI::transfernb(char* tbuf, char* rbuf, uint32_t len){ ...@@ -50,9 +50,7 @@ void SPI::transfernb(char* tbuf, char* rbuf, uint32_t len){
void SPI::transfern(char* buf, uint32_t len) void SPI::transfern(char* buf, uint32_t len)
{ {
spiNoInterrupts();
transfernb(buf, buf, len); transfernb(buf, buf, len);
spiInterrupts();
} }
/** /**
* \endcond * \endcond
......
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