MCPcopy Create free account
hub / github.com/MCUdude/MicroCore / write

Method write

avr/libraries/TinyWire/src/TinyWire.cpp:37–49  ·  view source on GitHub ↗

* @brief Writes a byte to an i2c slave * * @param data Data to write * @return uint8_t Write status. 0 = success, 2 = NACK */

Source from the content-addressed store, hash-verified

35 * @return uint8_t Write status. 0 = success, 2 = NACK
36 */
37uint8_t TinyWire::write(uint8_t data)
38{
39 rw(data);
40 scl_hi();
41
42 uint8_t err = SUCCESS;
43 asm volatile ("clr %0" : "=r" (err)); // Optimization trick saves 4 bytes w/ avr-gcc
44 if (I2C_PIN & (1 << SDA)) // NACK = SDA high
45 err = ADDR_NAK;
46 I2C_DDR |= (1 << SCL); // SCL low
47
48 return err;
49}
50
51/**
52 * @brief Request to read N bytes from i2c slave

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected