Commit graph

129 commits

Author SHA1 Message Date
Limor "Ladyada" Fried
a12fee3983
Update README.md 2019-09-29 22:44:33 -04:00
Limor "Ladyada" Fried
72a7e96125
Update README.md 2019-07-18 16:05:02 -04:00
Limor "Ladyada" Fried
5b7b116ef0
Merge pull request #106 from vestom/py3
FTH232H: Make compatible with Python3
2019-05-26 17:00:45 -04:00
Tommy Vestermark
521309de57 FTH232H: Make compatible with Python3
- Fix some indentations
- Convert use of str() to bytes()
- Append b' to byte literals
- Fix some integer divisions / -> //
2019-04-27 09:55:00 +10:00
Limor "Ladyada" Fried
a92a23d6b5
Merge pull request #105 from gizmohd/master
Adding support for the Nvidia Jetson Nano Board
2019-04-10 08:24:34 -04:00
Darren McDaniel
7b8e666e84
Fix indent issue 2019-04-10 00:09:12 -04:00
Darren McDaniel
3ab79950de
Added Jetson functionality to GPIO 2019-04-10 00:05:38 -04:00
Darren McDaniel
74365514d1
Added Detection of Jetson Nano Board 2019-04-10 00:02:08 -04:00
Limor "Ladyada" Fried
2e84c14e22
Merge pull request #53 from frankalicious/fix-SPI-cs-assert-during-startup
fix unwanted SPI cs assert during startup
2019-04-04 17:53:50 -04:00
Limor "Ladyada" Fried
93e8ac6f0e
Merge pull request #104 from mpratt14/patch-10
FT232H.py: make print statements compatible with python 3
2019-04-04 15:29:22 -04:00
mpratt14
687adfb76b
FT232H.py: make print statements compatible with python 3
Similar to #102 

In the future consider more print statements for where and when errors would appear in code
2019-04-04 15:20:19 -04:00
Limor "Ladyada" Fried
498d8a1b9f
Merge pull request #102 from mpratt14/patch-7
setup.py: make print statements compatible with both Python 2 and 3
2019-04-02 21:00:11 -04:00
mpratt14
fcf67c0209
setup.py: make print statements compatible with both Python 2 and 3 2019-04-02 20:37:50 -04:00
Limor "Ladyada" Fried
d232fce7b2
Merge pull request #100 from mpratt14/patch-5
Fix mistakes from previous pull request for SPI methods
2019-04-02 00:46:04 -04:00
Limor "Ladyada" Fried
6fb18c6e37
Merge pull request #101 from mpratt14/patch-6
Fix previous pull request for setup.py
2019-04-02 00:45:48 -04:00
mpratt14
d943526240
Fix previous pull request for setup.py
doing a better job than #96 

prints possible requirement for root or admin privileges
tries to import pip before calling ensurepip (which isnt needed for python 3)

this time, don't even keep the method from ez_setup.py, there's no point...
commenting it out with ''' ''' gave me an IOError

bump version because why not?
2019-04-02 00:22:52 -04:00
mpratt14
9f9f23204e
Removed line with tab 2019-04-02 00:16:00 -04:00
mpratt14
aba58cb25f
Formatting and Indentation fix 2019-04-02 00:10:43 -04:00
mpratt14
63df8b9fb2
Fix mistakes in SPI method from previous pull request
Fix mistakes from #98 
This time, extensively tested

Also added support for read requests of odd length, read requests of length 1 working
Also applied same ideas to write requests
2019-04-02 00:03:19 -04:00
Limor "Ladyada" Fried
377c684950
Merge pull request #98 from mpratt14/patch-4
SPI Methods: Prevention of hardware limit errors and data corruption
2019-03-30 01:33:07 -04:00
mpratt14
57adb1e500
Merge branch 'master' into patch-4 2019-03-30 00:18:21 -04:00
Limor "Ladyada" Fried
96651c95fe
Merge pull request #97 from mpratt14/patch-3
setup.py: use the routine modern method for initial install ensuring of setuptools
2019-03-28 23:59:06 -04:00
Limor "Ladyada" Fried
0ec1977df2
Merge pull request #95 from mpratt14/patch-2
Add SPI method: bulkread
2019-03-28 23:58:46 -04:00
mpratt14
8a10df5416
Applying Hardware limit and data error prevention fixes
Applying fixes described here:
#94 
#95 

In order to:
Prevent a data stream larger than 64 KB from passing per command and warn the user
Fix the weird data corruption error that may or may not occur from full hardware limit length reads
2019-03-28 23:42:28 -04:00
mpratt14
662d0d9d31
setup.py: use the routine modern method for installing setuptools
My suggestion for fixing the deprecated method for installing or updating setuptools using ez_setup.py
Also ensures that both pip and setuptools are 'bootstrapped' to the python environment, which does not always happen on a fresh install in Windows.

Fixes #96 

This can be made more robust by detecting if pip or setuptools is installed with `pip --version`, etc...
2019-03-28 23:15:44 -04:00
mpratt14
268cd87672
Update FT232H.py 2019-03-26 00:45:02 -04:00
mpratt14
1f974c7744
Add SPI method: bulkread
Designed for communication with SPI Flash memory chips.

Single-use or combinations of the existing methods are not efficient or functional for the use case of NOR/NAND flash chip reading and writing. It is essential that between reading and writing the Chip Select remains asserted (High) for the entire period. Usage of the `write` and `read` methods is therefore not possible in combination because each of them de-asserts CS at the end of the method. There is no need for that behavior to change though.

The `transfer` method is inefficient because it sends a command to the FT232H that not only allows Full-Duplex but actually REQUIRES it for a command to complete. This is due to the design of the MPSSE. If I use the same FT232H command and attempt to read more than I am writing, a timeout occurs. In other words, the FT232H only allows communication at all during a Full-duplex command when there is data to be handled in Full-duplex, the amount you read MUST BE equal to the amount you write.

For example, an SPI read of a NOR flash chip: After instructing the FT232H to open the connection to the flash chip, you write the command to the slave as 1 byte, then the address as 3 bytes and the chip responds AFTER the write, not DURING, for as long as CS is asserted. In order to read only 1 of the 64 blocks of a 4 MB flash chip using the `transfer` method, I would have to append 65,532 zeros to the array that I am writing to the chip to keep the connection alive for each iteration of the loop, which is mandated both by the slave (NOR Flash) with CS, and by the master (FT232H) with the full-duplex command. Again, half-duplex read then write is a very simple matter, as with any SPI slave, that would be treated as two separate commands, `read` and then `write`. But on many SPI slaves, half-duplex write then read is almost always in the same instruction, where CS assertion must not be interrupted between commands of the master (FT232H), and this is a very popular implementation.

I have also designed this method to solve the issue #94 that I posted






For a while, I thought it should work with a single write command and two poll reads
...not true...


in parallel order, double read still doesnt fix it:
```
spi._ft232h._write(str(bytearray((commandR, len_lowR, len_highR))))
spi._ft232h._write(str(bytearray((commandR, len_lowR, len_highR))))
payload1 = spi._ft232h._poll_read(lengthR)
payload2 = spi._ft232h._poll_read(lengthR)
```

but in series order, double read does give clean output:
```
spi._ft232h._write(str(bytearray((commandR, len_lowR, len_highR))))
payload1 = spi._ft232h._poll_read(lengthR)
spi._ft232h._write(str(bytearray((commandR, len_lowR, len_highR))))
payload2 = spi._ft232h._poll_read(lengthR)
```





This is tested both in situations where the expected output is all ff, the expected output is all 00, or the expected output is real life data, confirmed with CRC32.

My take on this is basically sacrificing a little more python environment memory, to save the chips buffer from suffering. I am convinced that the problem is NOT with the poll_read function.
I am not sure if it is just my chip with this problem or many more, but this surely prevents it from appearing during heavy use, at practically any frequency. I have tried setting my clock as low as 1 MHz.







Therefore I propose this method, bulkread (I can't think of a better name, maybe readblock) with the following features...

  - both the array to write and the length to read back are optional (one or the other), configurable, and with defaults
  - allows a read up to the limit of the FT232H capabilities, both hard limit in the datasheet (64 KB) by ensuring input is within the range...
  - and soft limit handling from data corruption issue observed in my real life testing by simply performing two separate poll reads (see #94)
  - Warning the user about the data length limits
  - Deasserting CS is the VERY LAST action sent to the FT232H
  - the buffer flush command (0x87) is not used, in my testing, it makes no difference, less talking to the master means more talking to the slave.
  - a very simple mode setting, to allow writing only with the same method, not having to change methods by setting readmode to 0
  - all math is moved to the top, before anything is pushed to the device


Similar logic should be applied to every other method in the library, to inform the user before errors occur, and prevent errors due to (most likely) hardware defects.


@ladyada @tdicola Please help me out with the logger.debug line...I'm not sure about the syntax or purpose or usage of it
2019-03-26 00:35:32 -04:00
Limor "Ladyada" Fried
ede3d7d2be
Merge pull request #93 from mpratt14/patch-1
Allow basic support for libFTDI1.3
2019-03-22 16:34:13 -04:00
mpratt14
8c3bdde5be
Allow basic support for libFTDI1.3
Between libFTDI versions 1.2 and 1.3. The largest difference is a simple syntax difference on one function, where they removed one of the three arguments. Simply try the one for <=1.2, and if that throws a TypeError, try the syntax for 1.3+

here is a screenshot:
https://www.dropbox.com/s/m7a1ybx3ss2jotg/Screenshot%202019-03-11%2021.30.17.png?dl=0

This change is present in another commit, but with other changes. I am hoping that this simpler commit can be accepted easily...

Signed-off-by: Michael Pratt <mpratt51@gmail.com>
2019-03-22 16:24:22 -04:00
Limor "Ladyada" Fried
0528fe164e
Merge pull request #88 from abhinuvpitale/patch-1
update _mosi typo as per #83
2018-10-02 08:50:18 -07:00
Abhinuv Nitin Pitale
67de20d275
update _mosi typo as per #83 2018-10-02 00:58:53 -07:00
Tony DiCola
c543d1df9c
Check for older BCM2708 combined mode path before attempting to set. 2018-02-26 17:58:56 -08:00
Tony DiCola
f17faeeac8
Merge pull request #71 from lsellens/master
duplicate function
2018-02-26 17:43:57 -08:00
Tony DiCola
35a6a9ca58
Fix previous commit to correctly set SpiDev device cshigh property. 2018-02-26 17:40:44 -08:00
Tony DiCola
145b1d3eaa
Merge pull request #52 from mrnuke/cs-high-fix
SPI: Make sure CS line is active-low
2018-02-26 17:37:43 -08:00
Tony DiCola
bde795a635
Merge pull request #37 from Pelado-Mat/master
Add a GPIO class to support PCA9555 chips
2018-02-26 17:33:09 -08:00
Tony DiCola
2cea57917d
Explicitly set internal MCP23017 GPIO state on input_pins read, fix #70. 2018-02-26 17:27:17 -08:00
Tony DiCola
f300bddc6c
Default MCP230xx direction to input, fix #44. 2018-02-26 17:18:18 -08:00
Tony DiCola
8042997714
Swap to Python 2 and 3 compatible items() call vs. iteritems(), fix #43. 2018-02-26 17:15:14 -08:00
Tony DiCola
22a1ff4f54 Deprecate I2C reverseByteOrder function.
Throwing an error now based on deprecation from: https://github.com/adafruit/Adafruit_Python_GPIO/issues/48
2017-08-23 00:43:28 -07:00
lsellens
88273cd27a duplicate function 2017-07-11 07:23:24 -05:00
Tony DiCola
060f6d6782 Minor bump for Pi 3 on 4.9.x kernel detection. 2017-03-06 22:44:49 -08:00
Tony DiCola
37e55de593 Add Pi 3 4.9 kernel detection 2017-03-06 22:41:59 -08:00
Tony DiCola
f9a870f6bf Don't throw errors when enumerating multiple devices.
Workaround for issue seen with: https://forums.adafruit.com/viewtopic.php?f=19&t=112200
2017-02-28 00:55:44 -08:00
Tony DiCola
bd058f7d2e Minor version bump for python 3 FT232H fix. 2017-02-06 23:43:48 -08:00
Tony DiCola
b0d68e0f9e Python 3 fix for FT232H import. 2017-02-06 23:43:17 -08:00
Alexander Frank
8cf257fbf8 fix unwanted SPI cs assert during startup
First set the chipselect to high then change the pin to output.
By fixing the order the pin does not go low and then high for a short
time.
2016-11-24 09:28:31 +01:00
Tony DiCola
5abc5d276e Fix python 3 pip install issue with ez_setup relative import. 2016-10-20 03:06:46 +00:00
Alexandru Gagniuc
d70b111058 SPI: Make sure CS line is active-low
If another user configures the SPI bus as CS active-high, the setting
will stick. It is thus possible to end up in a situation where CS is
forced high during SPI transactions. The solution is to explicitly
disable 'cshigh' before using the SpiDev object.
2016-10-15 14:06:20 -07:00
Tony DiCola
38cd1bb542 Add GitHub pull request template 2016-05-27 13:23:50 -07:00