-
Notifications
You must be signed in to change notification settings - Fork 58
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
Support gpio CS? #2
Comments
It's an idea I've thought about a while back when writing this, but haven't gotten around to implementing it. If I get some time over the next couple of weeks I'll take a look at doing it. I'm sure I'll need to do it at some point in the future for one of my projects anyway! :) |
I second this! Is there a register for setting which GPIO is used for CS? |
I removed the line
The hardware SPI block can only use GPIO15 as CS. Note that in SPI the CS signal is active when low. |
Great that works pretty well. Thanks. |
@kanflo @elmorejd You had any problems with software CS? I'm trying to use GPIO4 as CS.
This is what I get with the code above: (only CS and CLK lines) I'm a bit lucky because first 4 bits of data for MAX7219 doesn't matter so this is working. Also last transaction is skipped. If I switch CS to hardware mode everything works like a charm. Unfortunately I have boards manufactered and CS is wired to GPIO4 |
You need to wait for the hardware spi buffer to write out before bring cs pin low again. Add something after spi_tx16 to check the status. Spi_tx16 is non blocking.
…Sent from my iPhone
On 8 Oct 2017, at 9:48 pm, Karol ***@***.***> wrote:
@kanflo @elmorejd You had any problems with software CS? I'm trying to use GPIO4 as CS.
void max7219_write(uint8 reg, uint8 value){
uint16_t data = (reg << 8) | value;
GPIO_OUTPUT_SET(4, 0); // cs low
spi_tx16(HSPI, data);
GPIO_OUTPUT_SET(4, 1); // cs high
}
This is what I get with the code above: (only CS and CLK lines)
I'm a bit lucky because first 4 bits of data for MAX7219 doesn't matter so this is working. Also last transaction is skipped. If I switch CS to hardware mode everything works like a charm. Unfortunately I have boards manufactered and CS is wired to GPIO4
Any ideas what could go wrong? I know it's a bit old issue :P
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Thanks for very fast reply! I'm checking if spi is busy like you said and now everything is OK Working code:
|
Your driver seems like a nice fit for my project but I will have more than one SPI device leading to the need for GPIO chip selects. Of course the pin toggling could be made outside of the SPI driver but imho it would be nicer to have it inside the driver as it belongs to "the SPI domain". What do you think?
The text was updated successfully, but these errors were encountered: