@@ -25,23 +25,23 @@
|
||||
*/
|
||||
|
||||
/* Get register content. */
|
||||
#define GET_REG(REG) ((uint16_t) *REG)
|
||||
#define GET_REG(REG) ((uint16_t) *(REG))
|
||||
|
||||
/* Set register content. */
|
||||
#define SET_REG(REG, VAL) (*REG = (uint16_t)VAL)
|
||||
#define SET_REG(REG, VAL) (*(REG) = (uint16_t)(VAL))
|
||||
|
||||
/* Clear register bit. */
|
||||
#define CLR_REG_BIT(REG, BIT) SET_REG(REG, (~BIT))
|
||||
#define CLR_REG_BIT(REG, BIT) SET_REG((REG), (~(BIT)))
|
||||
|
||||
/* Clear register bit masking out some bits that must not be touched. */
|
||||
#define CLR_REG_BIT_MSK_AND_SET(REG, MSK, BIT, EXTRA_BITS) \
|
||||
SET_REG(REG, (GET_REG(REG) & MSK & (~BIT)) | (EXTRA_BITS))
|
||||
SET_REG((REG), (GET_REG((REG)) & (MSK) & (~(BIT))) | (EXTRA_BITS))
|
||||
|
||||
#define CLR_REG_BIT_MSK(REG, MSK, BIT) \
|
||||
CLR_REG_BIT_MSK_AND_SET(REG, MSK, BIT, 0)
|
||||
CLR_REG_BIT_MSK_AND_SET((REG), (MSK), (BIT), 0)
|
||||
|
||||
/* Get masked out bit value. */
|
||||
#define GET_REG_BIT(REG, BIT) (GET_REG(REG) & BIT)
|
||||
#define GET_REG_BIT(REG, BIT) (GET_REG(REG) & (BIT))
|
||||
|
||||
/*
|
||||
* Set/reset a bit in a masked window by using toggle mechanism.
|
||||
@@ -62,10 +62,10 @@ do { \
|
||||
toggle_mask ^= bit_selector; \
|
||||
} \
|
||||
} \
|
||||
SET_REG(REG, toggle_mask | (EXTRA_BITS)); \
|
||||
SET_REG((REG), toggle_mask | (EXTRA_BITS)); \
|
||||
} while (0)
|
||||
|
||||
#define TOG_SET_REG_BIT_MSK(REG, MSK, BIT) \
|
||||
TOG_SET_REG_BIT_MSK_AND_SET(REG, MSK, BIT, 0)
|
||||
TOG_SET_REG_BIT_MSK_AND_SET((REG), (MSK), (BIT), 0)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user