nRF5 SDK v17.0.2
Data Structures | Macros | Typedefs | Functions

Module for writing and reading flags that are associated with keys. More...

Data Structures

struct  sdk_mapped_flags_key_list_t
 Type used to present a subset of the registered keys. More...
 

Macros

#define SDK_MAPPED_FLAGS_N_KEYS   32
 
#define SDK_MAPPED_FLAGS_N_KEYS_PER_BYTE   8
 
#define SDK_MAPPED_FLAGS_INVALID_INDEX   0xFFFF
 

Typedefs

typedef uint32_t sdk_mapped_flags_t
 

Functions

uint16_t sdk_mapped_flags_first_key_index_get (sdk_mapped_flags_t flags)
 Function for getting the first index at which the flag is true in the provided collection. More...
 
void sdk_mapped_flags_update_by_key (uint16_t *p_keys, sdk_mapped_flags_t *p_flags, uint16_t key, bool value)
 Function for updating the state of a flag. More...
 
void sdk_mapped_flags_bulk_update_by_key (uint16_t *p_keys, sdk_mapped_flags_t *p_flags, uint32_t n_flag_collections, uint16_t key, bool value)
 Function for updating the state of the same flag in multiple flag collections. More...
 
bool sdk_mapped_flags_get_by_key (uint16_t *p_keys, sdk_mapped_flags_t flags, uint16_t key)
 Function for getting the state of a specific flag. More...
 
bool sdk_mapped_flags_get_by_key_w_idx (uint16_t *p_keys, sdk_mapped_flags_t flags, uint16_t key, uint8_t *p_index)
 Function for getting the state of a specific flag. More...
 
sdk_mapped_flags_key_list_t sdk_mapped_flags_key_list_get (uint16_t *p_keys, sdk_mapped_flags_t flags)
 Function for getting a list of all keys that have a specific flag set to true. More...
 
uint32_t sdk_mapped_flags_n_flags_set (sdk_mapped_flags_t flags)
 Function for getting the number of keys that have a specific flag set to true. More...
 
static __INLINE bool sdk_mapped_flags_any_set (sdk_mapped_flags_t flags)
 Function for querying whether any flags in the collection are set. More...
 

Detailed Description

Module for writing and reading flags that are associated with keys.

The flags are represented as bits in a bitmap called a flag collection. The keys are uint16_t. Each flag collection contains all flags of the same type, one flag for each key.

The mapped flags module does not keep the flag states, nor the list of keys. These are provided in the API calls. A key's index in the key list determines which bit in the flag collection is associated with it. This module does not ever edit the key list, and does not edit flags except in function calls that take the flag collection as a pointer.

Macro Definition Documentation

#define SDK_MAPPED_FLAGS_INVALID_INDEX   0xFFFF

A flag index guaranteed to be invalid.

#define SDK_MAPPED_FLAGS_N_KEYS   32

The number of keys to keep flags for. This is also the number of flags in a flag collection. If changing this value, you might also need change the width of the sdk_mapped_flags_t type.

#define SDK_MAPPED_FLAGS_N_KEYS_PER_BYTE   8

The number of flags that fit in one byte.

Typedef Documentation

typedef uint32_t sdk_mapped_flags_t

The bitmap to hold flags. Each flag is one bit, and each bit represents the flag state associated with one key.

Function Documentation

static __INLINE bool sdk_mapped_flags_any_set ( sdk_mapped_flags_t  flags)
static

Function for querying whether any flags in the collection are set.

Parameters
[in]flagsThe flag collection to query.
Return values
trueIf one or more flags are set to true.
falseOtherwise.
void sdk_mapped_flags_bulk_update_by_key ( uint16_t *  p_keys,
sdk_mapped_flags_t p_flags,
uint32_t  n_flag_collections,
uint16_t  key,
bool  value 
)

Function for updating the state of the same flag in multiple flag collections.

The key and value are the same for all flag collections in the p_flags array.

Parameters
[in]p_keysThe list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
[out]p_flagsThe flag collections to modify.
[out]n_flag_collectionsThe number of flag collections in p_flags.
[in]keyThe key to modify the flag of.
[in]valueThe state to set the flag to.
uint16_t sdk_mapped_flags_first_key_index_get ( sdk_mapped_flags_t  flags)

Function for getting the first index at which the flag is true in the provided collection.

Parameters
[in]flagsThe flag collection to search for a flag set to true.
Returns
The first index that has its flag set to true. If none were found, the function returns SDK_MAPPED_FLAGS_INVALID_INDEX.
bool sdk_mapped_flags_get_by_key ( uint16_t *  p_keys,
sdk_mapped_flags_t  flags,
uint16_t  key 
)

Function for getting the state of a specific flag.

Parameters
[in]p_keysThe list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
[in]flagsThe flag collection to read from.
[in]keyThe key to get the flag for.
Returns
The state of the flag.
bool sdk_mapped_flags_get_by_key_w_idx ( uint16_t *  p_keys,
sdk_mapped_flags_t  flags,
uint16_t  key,
uint8_t *  p_index 
)

Function for getting the state of a specific flag.

Parameters
[in]p_keysThe list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
[in]flagsThe flag collection from which to read.
[in]keyThe key for which to get the flag.
[out]p_indexIf not NULL, the index of the key.
Returns
The state of the flag.
sdk_mapped_flags_key_list_t sdk_mapped_flags_key_list_get ( uint16_t *  p_keys,
sdk_mapped_flags_t  flags 
)

Function for getting a list of all keys that have a specific flag set to true.

Parameters
[in]p_keysThe list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
[in]flagsThe flag collection to search.
Returns
The list of keys.
uint32_t sdk_mapped_flags_n_flags_set ( sdk_mapped_flags_t  flags)

Function for getting the number of keys that have a specific flag set to true.

Parameters
[in]flagsThe flag collection to search.
Returns
The number of keys.
void sdk_mapped_flags_update_by_key ( uint16_t *  p_keys,
sdk_mapped_flags_t p_flags,
uint16_t  key,
bool  value 
)

Function for updating the state of a flag.

Parameters
[in]p_keysThe list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
[out]p_flagsThe flag collection to modify.
[in]keyThe key to modify the flag of.
[in]valueThe state to set the flag to.

Documentation feedback | Developer Zone | Subscribe | Updated