-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_macros.h
31 lines (23 loc) · 1.45 KB
/
common_macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*******************************************************************************************************
* [FILE NAME] : <common_macros.h> *
* [AUTHOR] : <Eslam EL-Naggar> *
* [DATE CREATED]: <Oct 4, 2019> *
* [Description] : <header file contain common macros that used frequently> *
******************************************************************************************************/
#ifndef COMMON_MACROS_H_
#define COMMON_MACROS_H_
/* Set a certain bit in any register */
#define SET_BIT(REG,BIT) (REG|=(1<<BIT))
/* Clear a certain bit in any register */
#define CLEAR_BIT(REG,BIT) (REG&=(~(1<<BIT)))
/* Toggle a certain bit in any register */
#define TOGGLE_BIT(REG,BIT) (REG^=(1<<BIT))
/* Rotate right the register value with specific number of rotates */
#define ROR(REG,num) ( REG= (REG>>num) | (REG<<(8-num)) )
/* Rotate left the register value with specific number of rotates */
#define ROL(REG,num) ( REG= (REG<<num) | (REG>>(8-num)) )
/* Check if a specific bit is set in any register and return true if yes */
#define BIT_IS_SET(REG,BIT) ( REG & (1<<BIT) )
/* Check if a specific bit is cleared in any register and return true if yes */
#define BIT_IS_CLEAR(REG,BIT) ( !(REG & (1<<BIT)) )
#endif /* COMMON_MACROS_H_ */