util_twi(3avr)
β¨ util_twi β the TWI bit mask glow-up β¨
okay bestie, listen. this is util_twi from AVR-LibC, manual page util_twi(3avr), and it's literally the header <util/twi.h> that holds all the TWI bit mask definitions. no cap, it's giving "small file, huge main character energy". π
π NAME
util_twi β <util/twi.h>: TWI bit mask definitions
πΈ SYNOPSIS
β¨ TWSR values β¨
the mnemonics, so you know who's who at the party:
TW_MT_xxxβ master transmitter πTW_MR_xxxβ master receiver π«ΆTW_ST_xxxβ slave transmitterTW_SR_xxxβ slave receiver
and now the actual defines, verbatim, no edits, periodt:
#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)
π¦ R/~W bit in SLA+R/W address field π¦
just the two, and they're iconic:
#define TW_READ 1
#define TW_WRITE 0
π Detailed Description π
first thing, the include. it's:
#include <util/twi.h>
and what IS this header, you ask? it contains bit mask definitions for use with the AVR TWI interface. that's it. that's the whole vibe. π₯
π Macro Definition Documentation π
alphabetical order, the way the compiler gods intended. every single one, bestie, i'm not skipping a crumb:
#define TW_BUS_ERROR 0x00β illegal start or stop condition π#define TW_MR_ARB_LOST 0x38β arbitration lost in SLA+R or NACK#define TW_MR_DATA_ACK 0x50β data received, ACK returned#define TW_MR_DATA_NACK 0x58β data received, NACK returned#define TW_MR_SLA_ACK 0x40β SLA+R transmitted, ACK received π«Ά#define TW_MR_SLA_NACK 0x48β SLA+R transmitted, NACK received#define TW_MT_ARB_LOST 0x38β arbitration lost in SLA+W or data#define TW_MT_DATA_ACK 0x28β data transmitted, ACK received#define TW_MT_DATA_NACK 0x30β data transmitted, NACK received#define TW_MT_SLA_ACK 0x18β SLA+W transmitted, ACK received#define TW_MT_SLA_NACK 0x20β SLA+W transmitted, NACK received#define TW_NO_INFO 0xF8β no state information available π#define TW_READ 1β SLA+R address#define TW_REP_START 0x10β repeated start condition transmitted#define TW_SR_ARB_LOST_GCALL_ACK 0x78β arbitration lost in SLA+RW, general call received, ACK returned#define TW_SR_ARB_LOST_SLA_ACK 0x68β arbitration lost in SLA+RW, SLA+W received, ACK returned#define TW_SR_DATA_ACK 0x80β data received, ACK returned#define TW_SR_DATA_NACK 0x88β data received, NACK returned#define TW_SR_GCALL_ACK 0x70β general call received, ACK returned#define TW_SR_GCALL_DATA_ACK 0x90β general call data received, ACK returned#define TW_SR_GCALL_DATA_NACK 0x98β general call data received, NACK returned#define TW_SR_SLA_ACK 0x60β SLA+W received, ACK returned#define TW_SR_STOP 0xA0β stop or repeated start condition received while selected#define TW_ST_ARB_LOST_SLA_ACK 0xB0β arbitration lost in SLA+RW, SLA+R received, ACK returned#define TW_ST_DATA_ACK 0xB8β data transmitted, ACK received#define TW_ST_DATA_NACK 0xC0β data transmitted, NACK received#define TW_ST_LAST_DATA 0xC8β last data byte transmitted, ACK received#define TW_ST_SLA_ACK 0xA8β SLA+R received, ACK returned#define TW_START 0x08β start condition transmitted#define TW_STATUS (TWSR & TW_STATUS_MASK)β TWSR, masked byTW_STATUS_MASK#define TW_STATUS_MASKβ value:
(_BV(TWS7)|_BV(TWS6)|_BV(TWS5)|_BV(TWS4)|\
_BV(TWS3))
β οΈ okay important lore, don't skip this: the lower 3 bits of TWSR are reserved on the ATmega163. and the 2 LSB carry the prescaler bits on the newer ATmegas. so like... know your chip, fr fr. π₯
#define TW_WRITE 0β SLA+W address
π Author π
Generated automatically by Doxygen for AVR-LibC from the source code.
and that's the whole page, bestie!! go forth and bit-mask with confidence π β¨
this lil beauty is from AVR-LibC, Version 2.2.1, and it's page util_twi(3avr) β mwah, no notes, obsessed π«Άπ
π¦ where this page comes from
- ubuntu resolute: avr-libc 1:2.2.1-1build1 Β· BSD-3-Clause
- ubuntu stonking: avr-libc 1:2.2.1-1build1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms