This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| et:examples:define [2009/08/17 20:12] – mikk.leini | et:examples:define [2009/08/17 21:14] (current) – eemaldatud raivo.sell | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Erinevad kasulikud definitsioonid ====== | ||
| - | |||
| - | ===== biti manipulatsioonid ===== | ||
| - | |||
| - | <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 | ||
| - | |||
| - | // Setting or clearing specified bit in specified byte | ||
| - | #define SETTO(value, | ||
| - | |||
| - | // Checking whether the specified bit is set in specified byte | ||
| - | #define ISSET(value, | ||
| - | |||
| - | // avrlibc deprecated macros | ||
| - | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) // Set bit in byte | ||
| - | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) // Clear bit in byte | ||
| - | |||
| - | #define MAX(a, b) ((a) > (b)) ? (a):(b) | ||
| - | </ | ||