Nur zur Sicherheit:
1 | #define STR_HELPER(x) #x
|
2 | #define STR(x) STR_HELPER(x)
|
3 |
|
4 | #define TWI_TWBR ((F_CPU/SCL_CLOCK)-16)/2
|
5 |
|
6 | #if TWI_TWBR <= 10 /* must be > 10 for stable operation */
|
7 | #error TWBR to small
|
8 | #endif
|
9 |
|
10 | #if TWI_TWBR > 255
|
11 | #error TWBR is 8Bit
|
12 | #else
|
13 | #pragma message "TWI Bit rate Register:" STR(TWI_TWBR)
|
14 | #endif
|
Wird mir nie ein Rechenergebnis mitteilen, weil der Preprozessor stehts
Ersetzt und erst zur Laufzeit ein printf(%d, TWI_TWBR) möglich wäre (was
ich auf einem AVR jedoch nicht gebrauchen kann), richtig?
Ausgabe de Build:
1 | Anmerkung: #pragma message: TWI Bit rate Register:((8000000UL/100000L)-16)/2
|
2 | #pragma message "TWI Bit rate Register:" STR(TWI_TWBR)
|
Grüße David