twi.h(3avr)

πŸ“¦
version 2.2.1 Β· 3 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

twi.h β€” that's it, that's the whole name, bestie πŸ’… it's a header file and it lives in section 3avr of the manual, so when you see twi.h(3avr) floating around you already know what time it is.


πŸŽ€ SYNOPSIS πŸŽ€

Macros

TWSR values

okay so this is the part where we get into the actual content, and ngl it's a lot of little #defines, but every single one of them is a mood and a half 🌈

Mnemonics:

the naming scheme is lowkey iconic once you clock it β€” each family of values tells you who's doing the talking and what just happened:

  • TW_MT_xxx β€” master transmitter 🫢
  • TW_MR_xxx β€” master receiver
  • TW_ST_xxx β€” slave transmitter
  • TW_SR_xxx β€” slave receiver

and here's the full lineup, character for character, no cap:

#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 noticing TW_MT_ARB_LOST and TW_MR_ARB_LOST are literally the same value, 0x38 β€” twins, obviously, they ate πŸ’€

R/~W bit in SLA+R/W address field.

this is the little bit that decides which direction the conversation is going, and it only has two settings, which honestly? main character energy:

#define TW_READ   1
#define TW_WRITE   0

πŸ‘‘ Author πŸ‘‘

generated automatically by Doxygen for AVR-LibC from the source code. so like, nobody wrote this page by hand, it manifested, and we respect that 🧚


okay bye bestie β€” this was twi.h from AVR-LibC, Version 2.2.1, page twi.h(3avr). go forth and slay those TWI status codes βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from