|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Named Bit Positions and Masks for Register Manipulation. More...
#include <stdint.h>Go to the source code of this file.
Named Bit Positions and Masks for Register Manipulation.
Central home for bit-position constants used when poking hardware registers. Every bit shift and mask in the firmware should be expressed in terms of one of these enums rather than a raw integer literal. The clang-tidy rule readability-magic-numbers enforces this at commit time.
Without named constants, register writes look like:
With this header, they look like:
The second version is searchable (grep k_ra8_bit_7 tells you every place bit 7 is touched), self-documenting, and compile-time type-safe.
Definition in file ra8_bit_constants.h.
| enum ra8_be_byte_idx_t : uint8_t |
Byte indices when packing big-endian multi-byte values.
Use in place of raw literals when splitting a uint16_t or uint32_t into a byte buffer. Keeps code self-documenting and greppable.
Definition at line 144 of file ra8_bit_constants.h.
| enum ra8_bit_position_t : uint8_t |
Bit positions 0..31 as typed constants.
Use these with the shift operator to construct masks:
Every position is a distinct enumerator so the compiler's switch analysis and clang-tidy's naming rules both see them.
Definition at line 58 of file ra8_bit_constants.h.
| enum ra8_byte_count_t : uint8_t |
Bit counts per integral type.
| Enumerator | |
|---|---|
| k_ra8_bits_per_byte | Bits in a byte. |
| k_ra8_bits_per_u16 | Bits in a uint16_t. |
| k_ra8_bits_per_u32 | Bits in a uint32_t. |
| k_ra8_bits_per_u64 | Bits in a uint64_t. |
Definition at line 119 of file ra8_bit_constants.h.
| enum ra8_byte_mask_t : uint16_t |
Byte-wide bit masks and positions for byte packing/unpacking.
Definition at line 102 of file ra8_bit_constants.h.