| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
Mapped flags
SDK common libraries

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 8
#define | SDK_MAPPED_FLAGS_N_KEYS_PER_BYTE 8
#define | SDK_MAPPED_FLAGS_INVALID_INDEX 0xFFFF

## Typedefs
typedef uint8_t | sdk_mapped_flags_t

## Enumerations
enum | { assert_line___LINE__ = 1 / (!!( ( sizeof(sdk_mapped_flags_t) * 8 ) >= 8 )) }

## 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...
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 8

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 uint8_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] | flags | The flag collection to query.

Return values

  true | If one or more flags are set to true.
  false | Otherwise.

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_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
  [out] | p_flags | The flag collections to modify.
  [out] | n_flag_collections | The number of flag collections in p_flags.
  [in] | key | The key to modify the flag of.
  [in] | value | The 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] | flags | The 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_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
  [in] | flags | The flag collection to read from.
  [in] | key | The key to get the flag for.

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_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
  [in] | flags | The 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] | flags | The 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_keys | The list of associated keys (assumed to have a length of SDK_MAPPED_FLAGS_N_KEYS).
  [out] | p_flags | The flag collection to modify.
  [in] | key | The key to modify the flag of.
  [in] | value | The state to set the flag to.