+
+/**
+ * Check if given numeric value has it's given bit number set.
+ *
+ * @param[in] value The numeric variable to which bit check.
+ * @param[in] bit Which bit number to check, starting at 0 for the
+ * least-significant (rightmost) bit.
+ *
+ * @return TRUE if bit is set, FALSE if not.
+ */
+#define is_bit_set(value, bit) (bit_read(value, bit) == 1)
+
+
+/**
+ * Check if given numeric value has it's given bit number clear.
+ *
+ * @param[in] value The numeric variable to which bit check.
+ * @param[in] bit Which bit number to check, starting at 0 for the
+ * least-significant (rightmost) bit.
+ *
+ * @return TRUE if bit is clear, FALSE if not.
+ */
+#define is_bit_clear(value, bit) (bit_read(value, bit) == 0)
+
+
+/**
+ * @brief Set value at position specified by mask.
+ *
+ * Macro for value setting into mask position.
+ * For example we want to get value 0x0040. We can use
+ * this macro with parameters: __val2mfld(0x00F0, 4)
+ */
+#define __val2mfld(mask,val) (((mask)&~((mask)<<1))*(val)&(mask))
+
+
+/**
+ * @brief Get value from position specified by mask.
+ *
+ * Macro for getting value from mask position.
+ * For example we have a value 0x1234 and we want get
+ * the second number value from the right. This macro
+ * can be used for this with parameters: __mfld2val(0x00F0, 0x1234)
+ * which will return 0x0030.
+ */
+#define __mfld2val(mask,val) (((val)&(mask))/((mask)&~((mask)<<1)))
+
+/**
+ * @brief Clear bits in mask position
+ *
+ * This macro clears all bits specified by the mask.
+ * For example the call __clrvalmsk(0x00F0, 0x1234) will
+ * return 0x1204.
+ */
+#define __clrvalmsk(mask, val) ((val) & ~(mask))
+
+/**
+ * @brief Insert value into mask position
+ *
+ * This macro inserts value into position specified by mask.
+ * All others bits are preserved, only masked bits are changed.
+ * For example:
+ * int value = 0X1234;
+ * int mask = 0x00F0;
+ * value = __insval2mfld(mask, value, 4);
+ * will change value into 0x1244;
+ */
+#define __insval2mfld(mask, value, val) (__clrvalmsk(mask, value) | \
+ __val2mfld(mask,val))
+