source: firmware/FSC/usb_src/macros.h@ 18715

Last change on this file since 18715 was 10094, checked in by neise, 14 years ago
initial commit of FSC firmware - use for FSC testing only -
File size: 859 bytes
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#define ABS(x) ((x >= 0) ? x : -x) // Absolute value of x
16
17#define HI_HEX(x) ("0123456789ABCDEF" [x >> 4]) // Create hex of high nibble
18#define LO_HEX(x) ("0123456789ABCDEF" [x & 0x0F]) // Create hex of low nibble
19//-----------------------------------------------------------------------------
20
21#endif
Note: See TracBrowser for help on using the repository browser.