MIP_SDK  v3.0.0-187-g93c7302
MicroStrain Communications Library for embedded systems
Classes | Namespaces | Functions
bits.hpp File Reference
#include <type_traits>
#include <limits>
#include <stdint.h>
#include <assert.h>

Go to the source code of this file.

Classes

struct  microstrain::detail::BaseIntegerType< TestType, IsEnum >
 
struct  microstrain::detail::BaseIntegerType< TestType, true >
 
struct  microstrain::BitfieldMemberN< T, BitI, Nbits >
 A class which represents part of a bitfield. More...
 
struct  microstrain::BitfieldMemberItoJ< T, BitI, BitJ >
 A class which represents part of a bitfield (see BitfieldMemberN) More...
 
struct  microstrain::BitfieldMemberIthruJ< T, BitI, BitJ >
 A class which represents part of a bitfield (see BitfieldMemberN) More...
 
struct  microstrain::IntegerWithBytes< nbytes >
 Helper type to get an integer of at least N bytes in size. More...
 
struct  microstrain::IntegerWithBytes< 8 >
 
struct  microstrain::IntegerWithBytes< 7 >
 
struct  microstrain::IntegerWithBytes< 6 >
 
struct  microstrain::IntegerWithBytes< 5 >
 
struct  microstrain::IntegerWithBytes< 4 >
 
struct  microstrain::IntegerWithBytes< 3 >
 
struct  microstrain::IntegerWithBytes< 2 >
 
struct  microstrain::IntegerWithBytes< 1 >
 
struct  microstrain::IntegerWithBits< nbits >
 Helper type to get an integer of at least N bits in size. More...
 

Namespaces

 microstrain
 
 microstrain::detail
 

Functions

template<typename T >
constexpr T microstrain::bitmaskFirstN (unsigned int nbits)
 Creates a bitmask with 1s in the first N bits, i.e. bits [0..N). More...
 
template<typename T >
constexpr T microstrain::bitmaskN (unsigned int bitI, unsigned int nbits)
 Creates a bitmask with N '1' bits starting at bit I. More...
 
template<typename T >
constexpr T microstrain::bitmaskItoJ (unsigned int bitI, unsigned int bitJ)
 Creates a bitmask with bits [bitI..bitJ) set to 1 (excludes bit J). More...
 
template<typename T >
constexpr T microstrain::bitmaskIthruJ (unsigned int bitI, unsigned int bitJ)
 Creates a bitmask with bits [bitI..bitJ] set to 1 (includes bit J). More...
 
template<typename RegType >
constexpr bool microstrain::testBit (RegType reg, unsigned int bit)
 Checks if a specific bit in a value is set. More...
 
template<typename RegType >
constexpr void microstrain::setBit (RegType &reg, unsigned int bit, bool value=true)
 Sets a specific bit in a variable to a specified value. More...
 
template<typename RegType >
constexpr RegType microstrain::getBitsN (RegType reg, unsigned int bitI, unsigned int nbits)
 Extracts a bitfield from a variable value. More...
 
template<typename RegType >
constexpr RegType microstrain::getBitsItoJ (RegType reg, unsigned int bitI, unsigned int bitJ)
 Extracts a bitfield from a variable value. More...
 
template<typename RegType >
constexpr RegType microstrain::getBitsIthruJ (RegType reg, unsigned int bitI, unsigned int bitJ)
 Extracts a bitfield from a variable value. More...
 
template<typename RegType >
constexpr void microstrain::setBitsN (RegType &reg, unsigned int bitI, unsigned int nbits)
 Sets a series of consecutive bits in a variable to 1. More...
 
template<typename RegType >
constexpr void microstrain::setBitsItoJ (RegType &reg, unsigned int bitI, unsigned int bitJ)
 Sets a series of consecutive bits in a variable to 1. More...
 
template<typename RegType >
constexpr void microstrain::setBitsIthruJ (RegType &reg, unsigned int bitI, unsigned int bitJ)
 Sets a series of consecutive bits in a variable to 1. More...
 
template<typename RegType >
constexpr void microstrain::clearBitsN (RegType &reg, unsigned int bitI, unsigned int nbits)
 Sets a series of consecutive bits in a variable to 0. More...
 
template<typename RegType >
constexpr void microstrain::clearBitsItoJ (RegType &reg, unsigned int bitI, unsigned int bitJ)
 Sets a series of consecutive bits in a variable to 0. More...
 
template<typename RegType >
constexpr void microstrain::clearBitsIthruJ (RegType &reg, unsigned int bitI, unsigned int bitJ)
 Sets a series of consecutive bits in a variable to 0. More...
 
template<typename RegType , typename ValType >
constexpr void microstrain::setBitsN (RegType &reg, unsigned int bitI, unsigned int nbits, ValType value)
 Writes a value to a specific set of bits in a variable as if it were a bitfield. More...
 
template<typename RegType , typename ValType >
constexpr void microstrain::setBitsItoJ (RegType &reg, unsigned int bitI, unsigned int bitJ, ValType value)
 Writes a value to a specific set of bits in a variable as if it were a bitfield. More...
 
template<typename RegType , typename ValType >
constexpr void microstrain::modifyBitsIthruJ (RegType &reg, unsigned int bitI, unsigned int bitJ, ValType value)
 Writes a value to a specific set of bits in a variable as if it were a bitfield. More...