@@ -166,15 +166,15 @@ def read_register(self, register):
166
166
def _read_u8 (self , address ):
167
167
with self ._device as i2c :
168
168
self ._BUFFER [0 ] = address & 0xFF
169
- i2c .write (self ._BUFFER , end = 1 , stop = False )
170
- i2c . readinto ( self . _BUFFER , end = 1 )
169
+ i2c .write_then_readinto (self ._BUFFER , self . _BUFFER ,
170
+ out_end = 1 , in_end = 1 )
171
171
return self ._BUFFER [0 ]
172
172
173
173
def _read_u16 (self , address ):
174
174
with self ._device as i2c :
175
175
self ._BUFFER [0 ] = address & 0xFF
176
- i2c .write (self ._BUFFER , end = 1 , stop = False )
177
- i2c . readinto ( self . _BUFFER , end = 2 )
176
+ i2c .write_then_readinto (self ._BUFFER , self . _BUFFER ,
177
+ out_end = 1 , in_end = 2 )
178
178
return self ._BUFFER [0 ]<< 8 | self ._BUFFER [1 ]
179
179
180
180
def _write_u8 (self , address , val ):
@@ -194,5 +194,4 @@ def _write_u16(self, address, val):
194
194
def _read_bytes (device , address , count , buf ):
195
195
with device as i2c :
196
196
buf [0 ] = address & 0xFF
197
- i2c .write (buf , end = 1 , stop = False )
198
- i2c .readinto (buf , end = count )
197
+ i2c .write_then_readinto (buf , buf , out_end = 1 , in_end = count )
0 commit comments