Skip to content

Commit

Permalink
README: update
Browse files Browse the repository at this point in the history
  • Loading branch information
m-laniakea committed Mar 21, 2020
1 parent beadcf1 commit 95c3f9d
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ A Python library for interfacing with [ST Spin Family devices](https://www.digik
specifically the ST Micro **L6470**, **L6472**, **L6474**, and **L6480** ICs.
Can be used nearly without modification with similar ICs.

Currently this project relies on [spidev's](https://pypi.org/project/spidev/ "spidev") SPI transfer function.
If you do not specify your own spi_transfer function when creating a SpinChain, this project relies on [spidev's](https://pypi.org/project/spidev/ "spidev") SPI transfer function.

Meant for use in embedded Linux applictions.
Python 3.6 or greater recommended.

## Getting Started
`pip install st-spin`
`pip install spidev` (if you intend to use /dev/spi and spidev's spi transfer function)

**Add imports**
```python
Expand Down Expand Up @@ -77,8 +77,27 @@ motorMain.hiZHard()
```
### More details
For details on the SPI setup, see [create()](https://github.com/m-laniakea/st_spin/blob/dev/stspin/spin_chain.py#L47) in spin_chain.py.
See [example.py](https://github.com/m-laniakea/st_spin/blob/dev/example.py "example.py")
See [example.py](https://github.com/m-laniakea/st_spin/blob/dev/example.py "example.py").

**Creating your own spi_transfer function**
You may use your own spi transfer function in place of spidev's xfer2.
```
def custom_spi_transfer(buffer: List[int]) -> List[int]:
# TODO: Implement me
pass
stChain = SpinChain(
total_devices=2,
spi_transfer=custom_spi_transfer,
)
```
`custom_spi_transfer()` must take a list of bytes as int,
and return a same-length list of bytes as int from the MISO pin.

It should handle latching using the Chip Select pin, and transfer data with MSB first in
SPI Mode 3 (sample on rising edge, shift out on falling edge).

On these devices, Chip Select is active low.
### Troubleshooting
getStatus() is your friend. Feel free to use getPrettyStatus() under utility.py.
The manual is also your friend.
Expand Down

0 comments on commit 95c3f9d

Please sign in to comment.