Skip to content

explicit 'write-then-read' function for repeated start #19

Closed
@ladyada

Description

@ladyada

exciting news - while microcontrollers let you not-send a STOP, linux doesn't allow it explicitly. instead, we must use a single call that does reads and writes

e.g. here's the pure smbus example:

import datetime
import Adafruit_PureIO.smbus as smbus
import time

bus=smbus.SMBus(1)

# how busdevice works now, we write the register, then read separetly. great on micros, bad on linux.
bus.write_byte(0x21, 0x0C)
print(hex(bus.read_byte(0x21)))

# works correctly on linux, single ioctl reads 1 byte from register 0x0C on addr 0x21
print([hex(i) for i in bus.read_i2c_block_data(0x21, 0x0C, 1)])

but, right now, bus device only has read and write. i'd basically like to add a function called write_readinto, we'll also need a matching function in the busio, but for microcontrollers it'd just call the two functions immediately one after the other. in blinka linux i'd call the special block_data command

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions