| 318 | } |
| 319 | |
| 320 | TwoWire::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 | |
| 351 | TwoWire::Error TwoWire::twi_readFrom(uint8_t address, uint8_t* buf, size_t len, bool sendStop) |
| 352 | { |
nothing calls this directly
no test coverage detected