MCPcopy Create free account
hub / github.com/SmingHub/Sming / twi_writeTo

Method twi_writeTo

Sming/Core/Wire.cpp:320–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320TwoWire::Error TwoWire::twi_writeTo(uint8_t address, const uint8_t* buf, size_t len, bool sendStop)
321{
322 if(!twi_write_start()) {
323 return I2C_ERR_LINE_BUSY;
324 }
325 if(!twi_write_byte(((address << 1) | 0) & 0xFF)) {
326 if(sendStop) {
327 twi_write_stop();
328 }
329 return I2C_ERR_ADDR_NACK;
330 }
331 for(unsigned i = 0; i < len; i++) {
332 if(!twi_write_byte(buf[i])) {
333 if(sendStop) {
334 twi_write_stop();
335 }
336 return I2C_ERR_DATA_NACK;
337 }
338 }
339 if(sendStop) {
340 twi_write_stop();
341 }
342 for(unsigned i = 0; SDA_READ() == 0 && i++ < 10;) {
343 SCL_LOW();
344 twi_delay(twi_dcount);
345 SCL_HIGH();
346 twi_delay(twi_dcount);
347 }
348 return I2C_ERR_SUCCESS;
349}
350
351TwoWire::Error TwoWire::twi_readFrom(uint8_t address, uint8_t* buf, size_t len, bool sendStop)
352{

Callers

nothing calls this directly

Calls 4

twi_write_startFunction · 0.85
twi_write_byteFunction · 0.85
twi_write_stopFunction · 0.85
twi_delayFunction · 0.85

Tested by

no test coverage detected