Created
March 23, 2019 05:00
-
-
Save patocarr/fbefbc74b5f724e89a50caf469fa93c4 to your computer and use it in GitHub Desktop.
C Macros for field addressing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MACB_RMII_OFFSET 0 | |
#define MACB_RMII_SIZE 1 | |
#define GEM_RGMII_OFFSET 0 /* GEM gigabit mode */ | |
#define GEM_RGMII_SIZE 1 | |
#define MACB_CLKEN_OFFSET 1 | |
#define MACB_CLKEN_SIZE 1 | |
<...> | |
/* Bit manipulation macros */ | |
#define MACB_BIT(name) \ | |
(1 << MACB_##name##_OFFSET) | |
#define MACB_BF(name,value) \ | |
(((value) & ((1 << MACB_##name##_SIZE) - 1)) \ | |
<< MACB_##name##_OFFSET) | |
#define MACB_BFEXT(name,value)\ | |
(((value) >> MACB_##name##_OFFSET) \ | |
& ((1 << MACB_##name##_SIZE) - 1)) | |
#define MACB_BFINS(name,value,old) \ | |
(((old) & ~(((1 << MACB_##name##_SIZE) - 1) \ | |
<< MACB_##name##_OFFSET)) \ | |
| MACB_BF(name,value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment