Line | |
---|
1 | #ifndef __MACROS_H
|
---|
2 | #define __MACROS_H
|
---|
3 | //-----------------------------------------------------------------------------
|
---|
4 |
|
---|
5 | #define SET_BIT(byte,bit) (byte |= (1 << bit)) // Set bit in byte
|
---|
6 | #define CLR_BIT(byte,bit) (byte &= ~(1 << bit)) // Clear bit in byte
|
---|
7 | #define TGL_BIT(byte,bit) (byte ^= (1 << bit)) // Toggle bit in byte
|
---|
8 |
|
---|
9 | #define IS_SET(reg,bit) (reg & bit) // TRUE if bit = 1
|
---|
10 | #define IS_CLR(reg,bit) !(reg & bit) // TRUE if bit = 0
|
---|
11 |
|
---|
12 | #define BIT(x) (1 << (x)) // Define bit value
|
---|
13 | #define HI(x) ((x) >> 8) // Highbyte of 16-bit value
|
---|
14 |
|
---|
15 |
|
---|
16 | #define ABS(x) ((x >= 0) ? x : -x) // Absolute value of x
|
---|
17 |
|
---|
18 | #define HI_HEX(x) ("0123456789ABCDEF" [x >> 4]) // Create hex of high nibble
|
---|
19 | #define LO_HEX(x) ("0123456789ABCDEF" [x & 0x0F]) // Create hex of low nibble
|
---|
20 | //-----------------------------------------------------------------------------
|
---|
21 |
|
---|
22 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.