vsergeev / python-periphery

A pure Python 2/3 library for peripheral I/O (GPIO, LED, PWM, SPI, I2C, MMIO, Serial) in Linux.
MIT License
529 stars 139 forks source link

Can you please explain more regarding I2C? #18

Closed ishahak closed 4 years ago

ishahak commented 5 years ago

Hello, your library looks really cool. However I was trying to use it for I2C and could not understand the logic behind that code. There are 3 entities involved in I2C operations: the device address, the register within that device, and the value that we want to write or read to the register.

How do you accomplish a writing of value into a register? and how do you read the value from a register?

Thank you! -Itay

vsergeev commented 4 years ago

Register reads and writes are implemented using a small subset of the more general I2C protocol, which consists of an arbitrary number of multi-byte read and/or write messages in a single transaction to one device. python-periphery supports I2C in this sense, which allows interfacing with a wider variety of I2C devices than just the ones that implement a register map. For example, you may want to read/write multiple bytes from an EEPROM in one transaction.

It would be possible to add convenience read()/write() wrapper functions, though.

ishahak commented 4 years ago

Thank you very much for responding!

‫בתאריך יום ד׳, 23 באוק׳ 2019 ב-7:08 מאת ‪Vanya Sergeev‬‏ <‪ notifications@github.com‬‏>:‬

Register reads and writes are implemented using a small subset of the more general I2C protocol, which consists generally of an arbitrary number of multi-byte read and/or write messages in under a single transaction to one device. python-periphery supports I2C in this sense, which allows interfacing with a wider variety of I2C devices than just the ones that implement a register map. For example, you may want to read/write multiple bytes from an EEPROM in one transaction.

It would be possible to add convenience read()/write() wrapper functions, though.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vsergeev/python-periphery/issues/18?email_source=notifications&email_token=ACEK7YBKEANGXHK5OE2ZZPTQP7E5LA5CNFSM4F23WNFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB77KQQ#issuecomment-545256770, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACEK7YFSR6EENJKGO77XKDTQP7E5LANCNFSM4F23WNFA .