twi.h(3)

πŸ“¦ version 2.2.1, in fedora 43, fedora 44, opensuse-leap 16.0

πŸ¦‹ 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 that TW_MT_ARB_LOST and TW_MR_ARB_LOST are literally the same value 0x38. 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