?? lib_def.h
字號:
#error " [See 'cpu.h CONFIGURATION ERRORS']"
#endif
/*$PAGE*/
/* ------------------- TIME DEFINES ------------------- */
#define DEF_TIME_NBR_HR_PER_DAY 24uL
#define DEF_TIME_NBR_MIN_PER_HR 60uL
#define DEF_TIME_NBR_MIN_PER_DAY (DEF_TIME_NBR_MIN_PER_HR * DEF_TIME_NBR_HR_PER_DAY)
#define DEF_TIME_NBR_SEC_PER_MIN 60uL
#define DEF_TIME_NBR_SEC_PER_HR (DEF_TIME_NBR_SEC_PER_MIN * DEF_TIME_NBR_MIN_PER_HR)
#define DEF_TIME_NBR_SEC_PER_DAY (DEF_TIME_NBR_SEC_PER_HR * DEF_TIME_NBR_HR_PER_DAY)
#define DEF_TIME_NBR_mS_PER_SEC 1000uL
#define DEF_TIME_NBR_uS_PER_SEC 1000000uL
#define DEF_TIME_NBR_nS_PER_SEC 1000000000uL
/*$PAGE*/
/*
*********************************************************************************************************
* BIT MACRO'S
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* DEF_BIT()
*
* Description : Create bit mask with single, specified bit set.
*
* Argument(s) : bit Bit number of bit to set.
*
* Return(s) : Bit mask with single, specified bit set.
*
* Caller(s) : various.
*
* Note(s) : (1) 'bit' values that overflow the target CPU &/or compiler environment (e.g. negative
* or greater-than-CPU-data-size values) MAY generate compiler warnings &/or errors.
*********************************************************************************************************
*/
#define DEF_BIT(bit) (1u << (bit))
/*$PAGE*/
/*
*********************************************************************************************************
* DEF_BIT_MASK()
*
* Description : Shift a bit mask.
*
* Argument(s) : bit_mask Bit mask to shift.
*
* bit_shift Number of bit positions to left-shift bit mask.
*
* Return(s) : Shifted bit mask.
*
* Caller(s) : various.
*
* Note(s) : (1) 'bit_shift' values that overflow the target CPU &/or compiler environment (e.g. negative
* or greater-than-CPU-data-size values) MAY generate compiler warnings &/or errors.
*********************************************************************************************************
*/
#define DEF_BIT_MASK(bit_mask, bit_shift) ((bit_mask) << (bit_shift))
/*
*********************************************************************************************************
* DEF_BIT_FIELD()
*
* Description : Create & shift a contiguous bit field.
*
* Argument(s) : bit_field Number of contiguous bits to set in the bit field.
*
* bit_shift Number of bit positions to left-shift bit field.
*
* Return(s) : Shifted bit field.
*
* Caller(s) : various.
*
* Note(s) : (1) 'bit_field'/'bit_shift' values that overflow the target CPU &/or compiler environment
* (e.g. negative or greater-than-CPU-data-size values) MAY generate compiler warnings
* &/or errors.
*********************************************************************************************************
*/
#define DEF_BIT_FIELD(bit_field, bit_shift) ((((bit_field) >= DEF_INT_CPU_NBR_BITS) ? (DEF_INT_CPU_U_MAX_VAL) \
: (DEF_BIT(bit_field) - 1)) \
<< (bit_shift))
/*$PAGE*/
/*
*********************************************************************************************************
* DEF_BIT_SET()
*
* Description : Set specified bit(s) in a value.
*
* Argument(s) : val Value to modify by setting specified bit(s).
*
* mask Mask of bits to set.
*
* Return(s) : Modified value with specified bit(s) set.
*
* Caller(s) : various.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_BIT_SET(val, mask) { (val) |= (mask); }
/*
*********************************************************************************************************
* DEF_BIT_CLR()
*
* Description : Clear specified bit(s) in a value.
*
* Argument(s) : val Value to modify by clearing specified bit(s).
*
* mask Mask of bits to clear.
*
* Return(s) : Modified value with specified bit(s) clear.
*
* Caller(s) : various.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_BIT_CLR(val, mask) { (val) &= ~(mask); }
/*$PAGE*/
/*
*********************************************************************************************************
* DEF_BIT_IS_SET()
*
* Description : Determine if specified bit(s) in a value are set.
*
* Argument(s) : val Value to check for specified bit(s) set.
*
* mask Mask of bits to check if set.
*
* Return(s) : DEF_YES, if ALL specified bit(s) are set in value.
*
* DEF_NO, if ALL specified bit(s) are NOT set in value.
*
* Caller(s) : various.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_BIT_IS_SET(val, mask) ((((val) & (mask)) == (mask)) ? (DEF_YES) : (DEF_NO ))
/*
*********************************************************************************************************
* DEF_BIT_IS_CLR()
*
* Description : Determine if specified bit(s) in a value are clear.
*
* Argument(s) : val Value to check for specified bit(s) clear.
*
* mask Mask of bits to check if clear.
*
* Return(s) : DEF_YES, if ALL specified bit(s) are clear in value.
*
* DEF_NO, if ALL specified bit(s) are NOT clear in value.
*
* Caller(s) : various.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_BIT_IS_CLR(val, mask) (((val) & (mask)) ? (DEF_NO ) : (DEF_YES))
/*$PAGE*/
/*
*********************************************************************************************************
* DEF_BIT_IS_SET_ANY()
*
* Description : Determine if any specified bit(s) in a value are set.
*
* Argument(s) : val Value to check for specified bit(s) set.
*
* mask Mask of bits to check if set.
*
* Return(s) : DEF_YES, if ANY specified bit(s) are set in value.
*
* DEF_NO, if ALL specified bit(s) are NOT set in value.
*
* Caller(s) : various.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_BIT_IS_SET_ANY(val, mask) (((val) & (mask)) ? (DEF_YES) : (DEF_NO ))
/*
*********************************************************************************************************
* DEF_BIT_IS_CLR_ANY()
*
* Description : Determine if any specified bit(s) in a value are clear.
*
* Argument(s) : val Value to check for specified bit(s) clear.
*
* mask Mask of bits to check if clear.
*
* Return(s) : DEF_YES, if ANY specified bit(s) are clear in value.
*
* DEF_NO, if ALL specified bit(s) are NOT clear in value.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_BIT_IS_CLR_ANY(val, mask) ((((val) & (mask)) != (mask)) ? (DEF_YES) : (DEF_NO ))
/*$PAGE*/
/*
*********************************************************************************************************
* MATH MACRO'S
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* DEF_MIN()
*
* Description : Determine the minimum of two values.
*
* Argument(s) : a First value.
*
* b Second value.
*
* Return(s) : Minimum of the two values.
*
* Caller(s) : various.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_MIN(a, b) (((a) < (b)) ? (a) : (b))
/*
*********************************************************************************************************
* DEF_MAX()
*
* Description : Determine the maximum of two values.
*
* Argument(s) : a First value.
*
* b Second value.
*
* Return(s) : Maximum of the two values.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_MAX(a, b) (((a) > (b)) ? (a) : (b))
/*$PAGE*/
/*
*********************************************************************************************************
* DEF_ABS()
*
* Description : Determine the absolute value of a value.
*
* Argument(s) : a Value to calculate absolute value.
*
* Return(s) : Absolute value of the value.
*
* Caller(s) : various.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define DEF_ABS(a) (((a) < 0) ? (-(a)) : (a))
/*$PAGE*/
/*
*********************************************************************************************************
* MODULE END
*********************************************************************************************************
*/
#endif /* End of lib def module include. */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -