This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| en:examples:define [2009/03/05 10:36] – raivo.sell | en:examples:define [2010/02/04 12:34] (current) – removed mikk.leini | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Useful definitions ====== | ||
| - | |||
| - | ===== bit manipulations ===== | ||
| - | |||
| - | <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) | ||
| - | </ | ||
| - | |||
| - | Digi i/o board (Studyboard) | ||
| - | |||
| - | <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 | ||
| - | </ | ||