This shows you the differences between two versions of the page.
| de:examples:define [2009/04/08 17:21] – angelegt nierhoff | de:examples:define [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Nützliche Definitionen ====== | ||
| + | |||
| + | ===== Bit Manipulationen ===== | ||
| + | |||
| + | <code c> | ||
| + | |||
| + | |||
| + | #define BIT(x) (1 << (x)) // Bit index to bit mask | ||
| + | #define SET(x) |= BIT(x) // Bit setting | ||
| + | #define CLR(x) &= ~BIT(x) // Bit clearing | ||
| + | #define INV(x) ^= BIT(x) // Bit inversion | ||
| + | |||
| + | // Setzen oder loeschen des angegebenen Bits im angegebenen Byte | ||
| + | #define SETTO(value, | ||
| + | |||
| + | // Ueberpruefen ob angegebenes Bit im angegebenen Byte gesetzt ist | ||
| + | #define ISSET(value, | ||
| + | |||
| + | // avrlibc deprecated macros | ||
| + | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) // Setze Bit in Byte | ||
| + | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) // Lösche Bit in Byte | ||
| + | |||
| + | #define MAX(a, b) ((a) > (b)) ? (a):(b) // | ||
| + | </ | ||
| + | |||
| + | Digi i/o board (Study Board) | ||
| + | |||
| + | <code c> | ||
| + | #define LED1 PORTC, 3 | ||
| + | #define LED2 PORTC, 4 | ||
| + | #define LED3 PORTC, 5 | ||
| + | |||
| + | #define S1 PORTC, 0 | ||
| + | #define S2 PORTC, 1 | ||
| + | #define S3 PORTC, 2 | ||
| + | </ | ||