From 95c3f9d887f18698bea11477a89e6513d7f161ae Mon Sep 17 00:00:00 2001 From: eir Date: Sat, 21 Mar 2020 13:29:09 -0700 Subject: [PATCH] README: update --- README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9ae9994..e51fdf5 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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.