Skip to content

Commit c8754d6

Browse files
committed
added helpful bit macros
1 parent 97dd5c6 commit c8754d6

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/sfTk/sfToolkit.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,26 @@ int32_t sftk_byte_swap(int32_t i);
4747
void sftk_delay_ms(uint32_t ms);
4848

4949
// ticks in milliseconds
50-
uint32_t sftk_ticks_ms(void);
50+
uint32_t sftk_ticks_ms(void);
51+
52+
/**
53+
* @brief Check if specific bits are set in a value.
54+
*
55+
* This macro checks if the bits specified by the bitmask are set in the given value.
56+
*
57+
* @param __value__ The value to check.
58+
* @param __bitmask__ The bitmask specifying which bits to check.
59+
* @return True if all bits specified by the bitmask are set, false otherwise.
60+
*/.
61+
#define SFTK_CHECK_BITS_SET(__value__, __bitmask__) (((__value__) & (__bitmask__)) == __bitmask__)
62+
63+
/**
64+
* @brief Check if specific bits are cleared in a value.
65+
*
66+
* This macro checks if the bits specified by the bitmask are cleared in the given value.
67+
*
68+
* @param __value__ The value to check.
69+
* @param __bitmask__ The bitmask specifying which bits to check.
70+
* @return True if all bits specified by the bitmask are cleared, false otherwise.
71+
*/
72+
#define SFTK_CHECK_BITS_CLEARED(__value__, __bitmask__) (((__value__) & (__bitmask__)) == 0)

0 commit comments

Comments
 (0)