-
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
Can we have some usage examples for initialization? #7
Comments
Hi Neil, spi_init is just a default routine to setup the SPI @ 4MHz (dividers are defined in spi.h). It also sets up some standard SPI module settings (cs hold/setup which brings the CS pin up and down a bit earlier before data is sent and a bit later after data is done.) Pretty much a one-liner for the most common use case for SPI master. If you want to run the SPI at the cpu clock frequency (ie 80Mhz) there's a few things that need to happen. Sysclock as SPI clock needs to be set in the gpio init routine which handles the PERIPHS_IO_MUX register. Then you need to set the dividers to 0 in spi_clock. I doubt this would get much use in practice but its there if needed. There's a whole bunch more info on my blog from when I was testing all the SPI stuff when writing this. If you have a read through that some of it might make a bit more sense (it was a bit different to SPI on PICs as I'm used to). http://d.av.id.au/blog/tag/spi/ You can see some example use cases in my other driver libraries on github (ie ESP8266_MCP23S17). As for setting the spi_clock, there's a few ways to handle it (perhaps with a wrapper function using a predefined list of common SPI frequencies?). For a lot of values, there are multiple combinations of pre-divider and post-divider that will work. Doing more division in pre vs post doesn't seem to make any difference. More than happy for you to use this code in your Espruino project (if the MIT licence doesn't work for you for some reason let me know). I'm on IRC Afternet / #eevblog most of the time if you want to chat more. Git pull requests with any fixes or features are welcomed :) |
Thank you David ... everything is working splendidly using your hardware libraries. We'd like to include your code in the Espruino distribution which means that it would be compiled into the Espruino firmware and also found in the Espruino github source. We would like to use the Mozilla Public License v2.0 ... here is your file with that license included ... can you take a look and let us know if this is acceptable to you? https://github.com/nkolban/Espruino/blob/master/targets/esp8266/spi.h Many thanks my friend ... and again, your work on hardware SPI is fantastic. |
Yep Mozilla is fine. I just used MIT because it's fairly open. I have no issues with people using the code for whatever purpose as long as they don't claim it as their own :) |
I am having trouble changing the SPI phase for when it latches on the rising or falling edge. I believe right now data is being latched on the falling edge. Is there a way to change that so that? |
Your library looks to be exactly what we need for the Espruino port to ESP8266 project (see www.espruino.com). I'm hoping that we can have your permission to use your library in our project?
As we study your library, we are a little confused on the initialization functions. Specifically the semantics and relationships between:
spi_init
spi_init_gpio
spi_clock
Some additional documentation and/or examples of these would be fantastic.
I am wondering if we can also work together on a recipe or algorithm that would convert a desired SPI clock rate into the correct set of parameters to be passed into
spi_clock
?The text was updated successfully, but these errors were encountered: