MIP_SDK  v3.0.0-187-g93c7302
MicroStrain Communications Library for embedded systems
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
microstrain::BitfieldMemberN< T, BitI, Nbits > Struct Template Reference

A class which represents part of a bitfield. More...

#include <bits.hpp>

Public Types

using Type = T
 
using BaseType = typename detail::BaseIntegerType< T >::type
 

Static Public Member Functions

template<typename RegType >
static constexpr T get (RegType reg)
 
template<typename RegType >
static constexpr void set (RegType &reg, Type value)
 
template<typename RegType >
static constexpr void clear (RegType &reg)
 

Static Public Attributes

static constexpr unsigned int bitI = BitI
 
static constexpr unsigned int nbits = Nbits
 

Detailed Description

template<class T, unsigned int BitI, unsigned int Nbits>
struct microstrain::BitfieldMemberN< T, BitI, Nbits >

A class which represents part of a bitfield.

This is used to store the range of bits, to avoid repeating them in get/set function implementations and other situations.

Usage would typically be like this:

using Part1Bits = BitfieldMemberItoJ<uint16_t, 0, 12>; // First 12 bits, holding a u16
using Part2Bits = BitfieldMemberItoJ<uint8_t, 12, 16>; // Last 4 bits as a u8
uint16_t getPart1() const { return Part1Bits::get(m_value); }
uint16_t getPart2() const { return Part2Bits::get(m_value); }
void setPart1(uint16_t p1) { Part1Bits::set(m_value, p1); }
void setPart2(uint16_t p2) { Part2Bits::set(m_value, p2); }
uint16_t m_value;
Template Parameters
TType of the bitfield member. Must be integral or a non-scoped enum.
BitIThe 0-based index of the first bit used to represent this value.
NbitsNumber of bits in the field used to represent this value.

Member Typedef Documentation

◆ BaseType

template<class T , unsigned int BitI, unsigned int Nbits>
using microstrain::BitfieldMemberN< T, BitI, Nbits >::BaseType = typename detail::BaseIntegerType<T>::type

◆ Type

template<class T , unsigned int BitI, unsigned int Nbits>
using microstrain::BitfieldMemberN< T, BitI, Nbits >::Type = T

Member Function Documentation

◆ clear()

template<class T , unsigned int BitI, unsigned int Nbits>
template<typename RegType >
static constexpr void microstrain::BitfieldMemberN< T, BitI, Nbits >::clear ( RegType &  reg)
inlinestaticconstexpr

◆ get()

template<class T , unsigned int BitI, unsigned int Nbits>
template<typename RegType >
static constexpr T microstrain::BitfieldMemberN< T, BitI, Nbits >::get ( RegType  reg)
inlinestaticconstexpr

◆ set()

template<class T , unsigned int BitI, unsigned int Nbits>
template<typename RegType >
static constexpr void microstrain::BitfieldMemberN< T, BitI, Nbits >::set ( RegType &  reg,
Type  value 
)
inlinestaticconstexpr

Member Data Documentation

◆ bitI

template<class T , unsigned int BitI, unsigned int Nbits>
constexpr unsigned int microstrain::BitfieldMemberN< T, BitI, Nbits >::bitI = BitI
inlinestaticconstexpr

◆ nbits

template<class T , unsigned int BitI, unsigned int Nbits>
constexpr unsigned int microstrain::BitfieldMemberN< T, BitI, Nbits >::nbits = Nbits
inlinestaticconstexpr

The documentation for this struct was generated from the following file:
mip::metadata::get
auto & get(typename EnableForFieldTypes< FieldType >::type &field)
Gets a reference to parameter 'I' in the struct for the given field.
Definition: mip_metadata.hpp:67