-
Notifications
You must be signed in to change notification settings - Fork 214
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
Added active high polarity option for CS and ability to work with bi-… #86
base: master
Are you sure you want to change the base?
Conversation
…directional data for MicroWire support
I may merge this improved implementation, but I think there are a couple of issues to address first:
|
Very good points. I will take a look at it and improve things. |
I added a test to tests/spi.py. I will address the other points and test against my new test. |
…want to run the SPI tests, which use a different configuration, at the same time as the microwire test; Also fixed how cs_bits was being passed to SpiPort; Also changed cs_pol to a boolean with a better name, cs_act_hi
|
… MicroWire EEPROM.
spi.rst updated with MicroWire example using active high CS and bi-directional data |
I am open to suggestions on how to handle |
I'm not sure how to understand how the microwire works, so it is hard to give a valid answer to this question, I first need to read some docs, I believe :-) |
Just to be sure on how you have connected the EEPROM to the FTDI: you went for the same connection kludge as with I2C: MOSI & MISO are connected together on FTDI side, and connected to SISO on EEPROM side? You also need to disable MOSI as an output, so when you need to read from the EEPROM, FTDI/MOSI does not force a level on the bi-directional line? If this is the case, and the FTDI is always the master - therefore the slave cannot send data on the bi-dir line without a clock cycle from the master - is it not possible to only force FTDI/MOSI as input (e.g. hi-z) on a read sequence (EEPROM --> FTDI/MISO), read out the values, then revert back to FTDI/MOSI as output as soon as the read sequence is over - i.e. leave the FTDI device in its default setup (MOSI: out, MISO: in) except during the read sequence? I guess I missed something at some point :P |
You have it exactly right. During a read when the slave (EEPROM) is expected to drive the data line, the MOSI line is changed to be an input so that the MISO line can receive from the slave. This is exactly what my code does. The problem is that I cannot find a way to tell the FTDI to change direction of the MOSI line without also having to tell it what state ALL of the outputs must be in. So in order to change the direction of the MOSI line, I must know what value was last sent with the command SET_BITS_LOW so that I do not cause an output to change state while trying to make MOSI an input. So I use |
…tate; fixed bug in read_word() in tests/microwire.py
Updating the upstream before updating the pull-request.
Nevertheless, the SCLK state is known (as it only depends on CPOL/CPHA), the MOSI/MISO should be don't care are both are to be set as inputs. Do you have to preserve the state between two write to the EEPROM - just asking, I'm not sure to get it? |
Sorry for the delay in responding.
You make a very good point. MOSI/MISO does not matter then since they will both be set to inputs, CS must remain active and SCLK can be known through CPOL/CPHA. There is also the GPIO, but I believe I know how to handle that.
…--
Stephen Goadhouse
Electronics Engineer
University of Virginia
Physics Department
office: room 265
434-982-5594
[email protected]<mailto:[email protected]>
http://faculty.virginia.edu/phys-electronics<http://faculty.virginia.edu/phys-electronics/>
For any Electronics Shop requests, please email the team at [email protected]<mailto:[email protected]>
or feel free to come see Larry St. John in the Electronics Shop in Physics Rm 115
On Feb 23, 2018, at 06:54, Emmanuel Blot <[email protected]<mailto:[email protected]>> wrote:
I must know what value was last sent with the command SET_BITS_LOW so that I do not cause an output to change state while trying to make MOSI an input.
This is true the FTDI lacks several useful feature (such as precise clocking without altering the clock output to generate proper delays, and SET/GET of bits instead of bytes...)
Nevertheless, the SCLK state is known (as it only depends on CPOL/CPHA), the MOSI/MISO should be don't care are both are to be set as inputs. Do you have to preserve the state between two write to the EEPROM - just asking, I'm not sure to get it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#86 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAfWSvRl4NZJgiFqxGbevadoqBAkqt1Zks5tXqb9gaJpZM4SLC6F>.
|
Just to let you know, I've committed some fixes with SPI & GPIO earlier today. I do not think you need to rebase your code on this new version (v0.28.7), but you might be bitten with the issues I just fixed - if you test GPIO access. |
Thanks for the heads up. I made the code changes to eliminate the state with _last_prolog_ctrl and I also found a bug in my test case (tests/microwire.py) and fixed it. I rebased and just submitted the changes. Hopefully these can meet approval. Thanks for helping me to improve this code and being willing to work with me until I got it right. |
Thanks. I need to set up a working SPI/µWire environment to run the tests. I will merge you work once it's done, and keep you posted. |
…directional data for MicroWire support. These code changes were specifically done so that I could use a FTDI device to directly write and read a 93LC56 MicroWire EEPROM used by another FTDI device (yea, I bricked my FT4232 and used pyftdi to fix it). The MicroWire protocol is similar enough to SPI that spi mode can be used but MicroWire has an active high chip select (CS) instead of the active low CS of SPI. Also, in the case of fixing the EEPROM of a FT4232H-56Q Mini Module, I also needed bi-directional data support, which MicroWire can handle. These code changes were done so that they should not negatively impact code not using active high CS nor bi-directional data but these features can be extended to new users.