R1 code for micro:bit based train controller code, requires second micro:bit running rx code to operate - see https://meanderingpi.wordpress.com/ for more information
Fork of nrf51-sdk by
Mapped flags
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... | |
Typedefs | |
typedef uint8_t | sdk_mapped_flags_t |
The bitmap to hold flags. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
static __INLINE bool | sdk_mapped_flags_any_set (sdk_mapped_flags_t flags) |
Function for querying whether any flags in the collection are set. |
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.
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.
Definition at line 64 of file sdk_mapped_flags.h.
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.
Definition at line 165 of file sdk_mapped_flags.h.
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.
Definition at line 102 of file sdk_mapped_flags.c.
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.
Definition at line 80 of file sdk_mapped_flags.c.
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.
Definition at line 132 of file sdk_mapped_flags.c.
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.
Definition at line 148 of file sdk_mapped_flags.c.
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.
Definition at line 169 of file sdk_mapped_flags.c.
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.
Definition at line 93 of file sdk_mapped_flags.c.
Generated on Tue Jul 12 2022 19:00:13 by 1.7.2