Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OrangePi Zero] Chip enable not working on GPIO10 + workaround #903

Closed
fertinator opened this issue Mar 27, 2023 · 3 comments
Closed

[OrangePi Zero] Chip enable not working on GPIO10 + workaround #903

fertinator opened this issue Mar 27, 2023 · 3 comments
Labels

Comments

@fertinator
Copy link
Contributor

I am using the gettingstarted.cpp to test the library. I use the following declaration:
RF24 radio(10, 10, 1000000).
So chip enable on GPIO10, Spi on 1.0 as 0.0 is used by flash. And speed for testing, I could probably ramp it up.
For a few days struggling to find out why the gettingstarted program failed with a "hardware fault". With a logic analyzer I saw the SPI is transmitting OK, but the CE pin never got high.
It seems the following code is prohibiting the CE pin to go high:
RF24.cpp from line 103
void RF24::ce(bool level) { //Allow for 3-pin use on ATTiny if (ce_pin != csn_pin) { digitalWrite(ce_pin, level); } }
Because I use the 10,10 declaration it read as if both pins are the same. Except the Orange Pi Zero CS pin is GPIO13. See pinout: https://linux-sunxi.org/Xunlong_Orange_Pi_Zero#Expansion_Port
I got it to work by just commenting the if statement and only leaving the digitalWrite there.
It might be a possible bug, but depends on the platform and gpio used

@2bndy5 2bndy5 added the bug label Mar 27, 2023
@2bndy5
Copy link
Member

2bndy5 commented Mar 27, 2023

Thank you for testing and reporting this! I don't have a OrangePi, so I can't reproduce this. But your diagnosis is sound.

RF24/RF24.cpp

Lines 103 to 109 in 6ad390f

void RF24::ce(bool level)
{
//Allow for 3-pin use on ATTiny
if (ce_pin != csn_pin) {
digitalWrite(ce_pin, level);
}
}

We should wrap the conditional statement with #ifndef RF24_LINUX:

void RF24::ce(bool level) 
{ 
#ifndef RF24_LINUX
    //Allow for 3-pin use on ATTiny 
    if (ce_pin != csn_pin) { 
#endif
        digitalWrite(ce_pin, level); 
#ifndef RF24_LINUX
    } 
#endif
} 

@fertinator I assume you built/installed RF24 lib with the SPIDEV driver. Is that correct?

@fertinator
Copy link
Contributor Author

Correct. I built it with the SPIDEV driver

@2bndy5
Copy link
Member

2bndy5 commented Mar 27, 2023

@fertinator If you could test this fix to make sure it works on your OrangePi, we can move forward with this fix (a PR would be welcome if the fix works).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants