graycatlabs / PyBBIO

A Python library for Arduino-style hardware IO support on the Beaglebone
https://github.com/graycatlabs/PyBBIO/wiki
MIT License
251 stars 89 forks source link

Compatibility in libraries for SPI and I2C devices #83

Open alexanderhiam opened 8 years ago

alexanderhiam commented 8 years ago

The device driver libraries shouldn't initialize the SPI and I2C buses, that should be up to the user code to do before instantiating or initializing them. Otherwise using multiple devices on the same bus will result in multiple calls to the buses' open() methods.

For I2C devices that just means the open() calls need to be removed.

For SPI, the open() calls need to be removed from class init() methods, and any clock mode or frequency settings need to be moved to the data transfer methods so those settings are always applied before transferring data. (Note: SPI devices won't be thread safe because those settings could be changed by another thread before data is sent; is there a good way to implement a mutex for that?)