File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 2222 */
2323
2424#include <stdint.h>
25+ #include <stdbool.h>
2526
2627#ifdef __cplusplus
2728extern "C"
@@ -246,6 +247,58 @@ static inline void bit_clear8(volatile uint8_t *ptr, uint8_t bit)
246247 * ((volatile uint8_t * )(((uintptr_t )ptr ) | BME_AND_MASK )) = (uint8_t )(~(1ul << bit ));
247248}
248249
250+ /**
251+ * @brief Checks if a single bit in the 32 bit word pointed to by @p ptr is set.
252+ *
253+ * The effect is the same as for the following snippet:
254+ *
255+ * @code{c}
256+ * *ptr & (1 << bit);
257+ * @endcode
258+ *
259+ * @param[in] ptr Pointer to target word.
260+ * @param[in] bit Bit number within the word.
261+ */
262+ static inline bool bit_check32 (volatile uint32_t * ptr , uint8_t bit )
263+ {
264+ return * ((volatile uint32_t * )(((uintptr_t )ptr ) | BME_AND_MASK )) & (uint32_t )(1ul << bit );
265+ }
266+
267+ /**
268+ * @brief Checks if a single bit in the 16 bit word pointed to by @p ptr is set.
269+ *
270+ * The effect is the same as for the following snippet:
271+ *
272+ * @code{c}
273+ * *ptr & (1 << bit);
274+ * @endcode
275+ *
276+ * @param[in] ptr Pointer to target word.
277+ * @param[in] bit Bit number within the word.
278+ */
279+ static inline bool bit_check16 (volatile uint16_t * ptr , uint8_t bit )
280+ {
281+ return * ((volatile uint16_t * )(((uintptr_t )ptr ) | BME_AND_MASK )) & (uint16_t )(1ul << bit );
282+ }
283+
284+ /**
285+ * @brief Checks if a single bit in the 8 bit byte pointed to by @p ptr is set.
286+ *
287+ * The effect is the same as for the following snippet:
288+ *
289+ * @code{c}
290+ * *ptr & (1 << bit);
291+ * @endcode
292+ *
293+ * @param[in] ptr Pointer to target byte.
294+ * @param[in] bit Bit number within the byte.
295+ */
296+ static inline bool bit_check8 (volatile uint8_t * ptr , uint8_t bit )
297+ {
298+ return * ((volatile uint8_t * )(((uintptr_t )ptr ) | BME_AND_MASK )) & (uint8_t )(1ul << bit );
299+ }
300+
301+
249302#ifdef __cplusplus
250303}
251304#endif
You can’t perform that action at this time.
0 commit comments