* @brief Writes a byte to an i2c slave * * @param data Data to write * @return uint8_t Write status. 0 = success, 2 = NACK */
| 35 | * @return uint8_t Write status. 0 = success, 2 = NACK |
| 36 | */ |
| 37 | uint8_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 |
nothing calls this directly
no outgoing calls
no test coverage detected