mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
sys/bitfield: add bf_clear_all()
This commit is contained in:
parent
9b09f673fd
commit
7ed0f7355f
@ -32,6 +32,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "irq.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -358,6 +359,30 @@ static inline void bf_set_all_atomic(uint8_t field[], size_t size)
|
||||
irq_restore(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear all bits in the bitfield to 0
|
||||
*
|
||||
* @param[in] field The bitfield
|
||||
* @param[in] size The size of the bitfield
|
||||
*/
|
||||
static inline void bf_clear_all(uint8_t field[], size_t size)
|
||||
{
|
||||
memset(field, 0, (size + 7) / 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Atomically clear all bits in the bitfield to 0
|
||||
*
|
||||
* @param[in] field The bitfield
|
||||
* @param[in] size The size of the bitfield
|
||||
*/
|
||||
static inline void bf_clear_all_atomic(uint8_t field[], size_t size)
|
||||
{
|
||||
unsigned state = irq_disable();
|
||||
bf_clear_all(field, size);
|
||||
irq_restore(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Count set bits in the bitfield
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user