twi.h(3)
π¦ NAME π¦
twi.h β bestie, this is the header that holds all the TWI (that's Two-Wire Interface, aka IΒ²C, iykyk) status codes from avr-libc. It's section 3 of the manual, so it's a library header situation. π
β¨ SYNOPSIS β¨
π Macros
π TWSR values
Okay so these are all the values that live in TWSR, and they're grouped by mnemonic prefix, so here's the vibe check on which is which:
TW_MT_xxxβ master transmitter πTW_MR_xxxβ master receiver π¦TW_ST_xxxβ slave transmitter πΈTW_SR_xxxβ slave receiver β
And here's every single one, no cap, exactly as defined:
#define TW_START 0x08
#define TW_REP_START 0x10
#define TW_MT_SLA_ACK 0x18
#define TW_MT_SLA_NACK 0x20
#define TW_MT_DATA_ACK 0x28
#define TW_MT_DATA_NACK 0x30
#define TW_MT_ARB_LOST 0x38
#define TW_MR_ARB_LOST 0x38
#define TW_MR_SLA_ACK 0x40
#define TW_MR_SLA_NACK 0x48
#define TW_MR_DATA_ACK 0x50
#define TW_MR_DATA_NACK 0x58
#define TW_ST_SLA_ACK 0xA8
#define TW_ST_ARB_LOST_SLA_ACK 0xB0
#define TW_ST_DATA_ACK 0xB8
#define TW_ST_DATA_NACK 0xC0
#define TW_ST_LAST_DATA 0xC8
#define TW_SR_SLA_ACK 0x60
#define TW_SR_ARB_LOST_SLA_ACK 0x68
#define TW_SR_GCALL_ACK 0x70
#define TW_SR_ARB_LOST_GCALL_ACK 0x78
#define TW_SR_DATA_ACK 0x80
#define TW_SR_DATA_NACK 0x88
#define TW_SR_GCALL_DATA_ACK 0x90
#define TW_SR_GCALL_DATA_NACK 0x98
#define TW_SR_STOP 0xA0
#define TW_NO_INFO 0xF8
#define TW_BUS_ERROR 0x00
#define TW_STATUS_MASK
#define TW_STATUS (TWSR & TW_STATUS_MASK)
Not me pointing out thatTW_MT_ARB_LOSTandTW_MR_ARB_LOSTare literally the same value0x38. That's not a typo bestie, that's just how the silicon works. π
π R/~W bit in SLA+R/W address field.
The read/write bit, in its little address-field era:
#define TW_READ 1
#define TW_WRITE 0
π Author
Generated automatically by Doxygen for avr-libc from the source code. (Yes, a robot wrote it. Iconic behaviour honestly. π€β¨)
Okay that's the whole page bestie, you ate it. This one's from avr-libc version 2.1.0, dated Sat Jan 29 2022 β so if you're out here debugging your IΒ²C status codes at 3am, know that this header has been holding it down since then. πππ¦ Slay, go read TWSR, periodt. π
π¦ where this page comes from
- fedora 43: avr-libc 2.2.1-3.fc43 Β· BSD-3-Clause
- fedora 44: avr-libc 2.2.1-5.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: avr-libc 2.1.0-bp160.1.33 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms