-
Notifications
You must be signed in to change notification settings - Fork 4
XWire 2 wire library
Bob Frazier edited this page Dec 23, 2016
·
6 revisions
Low-level API functions:
void twi_init(TWI_t *); void twi_shutdown(TWI_t *); void twi_setAddress(TWI_t *, uint8_t); uint8_t twi_readFrom(TWI_t *, uint8_t, uint8_t*, uint8_t, uint16_t); uint8_t twi_writeTo(TWI_t *, uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t); uint8_t twi_transmit(TWI_t *, const uint8_t*, uint8_t); void twi_attachSlaveRxEvent(TWI_t *, void (*)(TWI_t *, uint8_t*, int) ); void twi_attachSlaveTxEvent(TWI_t *, void (*)(TWI_t *) ); void twi_reply(TWI_t *, uint8_t); void twi_stop(TWI_t *); void twi_releaseBus(TWI_t *);
Note that parameters differ from Arduino 'reference' implementation, specifically the addition of the first parameter, the 'TWI_t *', that indicates which of the TWI interfaces you use. As an example, you would initialize 'TWIE' by calling the 'twi_init' function, passing the address of the TWIE interface:
twi_init(&(TWIE));
You can use multiple TWI interfaces at the same time this way, in either master or slave mode.
[note that slave mode is not currently implemented]