AVR Static Libraries Demystified: Example I2C/TWI

Опубликовано: 04 Август 2026
на канале: Arduino under the Hood
14
1

🧑‍🏫 PREVIOUS SESSION
   • I2C/TWI: Multi-Device Bus Communication in...  

📥 RESOURCES & DOWNLOADS
• Datasheets: https://drive.google.com/drive/folder...
• Common DS3231 RTC Module: https://components101.com/modules/ds3...
• Common BH1750 Module: https://components101.com/sensors/bh1...
• Practical Example Source: https://drive.google.com/drive/folder...
• AVR I2C Slave Library: https://github.com/thegouger/avr-i2c-...
• TWI bit mask definitions (TWSR values): https://www.nongnu.org/avr-libc/user-...
• AVR-GCC Source Examples: http://www.peterfleury.epizy.com/avr-...

This section demonstrates how to build a static library for AVR: creating separate .c/.h files for related functions, compiling them into object files, archiving with avr-ar, and linking with -l and -L flags. Best practices are covered, including one function per file for optimal dead code elimination, combining related functions (init/start/stop), and ensuring ISRs are paired with always-called functions to prevent linker removal.

Chapters:
0:00 Introduction: What did we write in the previous lecture?
3:28 Writing the Library
6:12 The header file
10:40 The Makefile
16:03 Using the new Library