-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
The arduino interface is documented here:
- https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/I2Cdev
- http://arduino.cc/en/reference/wire (Wire)
keywords in here:
It uses a different set of function names than micro python currently does.
There is a small reason (existing users) to follow their lead, or to make similar wrapped interfaces to help migrating users from Arduino.
Although we clearly do not want to slavish about this. The pythonic approach suits us better but for low lying interfaces there is the advantage of familiarity where applicable.
What do we want to do ? Here and in general ?
(We could also make an arduino module which wrapped micropython calls to look similar to existing arduino libraries ?)
Notes:
Specifically micropython (current) vs arduino i2cdevlib:
(note that i2cdevlib also wraps the Wire library which inherits from Stream)
pyb_I2C
i2c_obj_print
i2c_obj_start
i2c_obj_write
i2c_obj_read
i2c_obj_readAndStop
i2c_obj_stop
vs:
from Wire:
begin([addr])
requestFrom(address, quantity, [stop])
beginTransmission(address)
endTransmission([stop])
write(value, [stop]) (where value may be byte, str, array)
available()
read()
onReceive(handler)
onRequest(handler)
From I2Cdev
readBit
readBitW
readBits
readBitsW
readByte
readBytes
readWord
readWords
writeBit
writeBitW
writeBits
writeBitsW
writeByte
writeBytes
writeWord
writeWords
Where - for example - readWords supports timeouts
int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout)
The arduino lib uses its Wire and Fastwire libraries for also supporting one wire and twowire devices and deals with requests for reads longer than the inbuilt buffer...
Limitations in Wire include only allowing 7bit i2c addresses.
Extra info - maybe I should put this on a wikipage ?
One-wire on Arduino:
Stream lib
- http://arduino.cc/en/Reference/Stream
- used in arduino by Serial library.
SPI lib