modm API documentation
modm::Register< T > Struct Template Reference

#include <modm/architecture/interface/register.hpp>

Inheritance diagram for modm::Register< T >:
modm::FlagsOperators< Abandonment, T > modm::FlagsOperators< Pin, T > modm::FlagsOperators< Enum, T > modm::Flags< Abandonment > modm::Flags< Pin > modm::Flags< Enum, T >

Public Typedefs

typedef T UnderlyingType
 The integer type internally used to represent the register.
 

Public Member Functions

constexpr Register ()
 Default constructor initializes value to zero.
 
constexpr operator bool () const
 
constexpr bool operator! () const
 Returns true if value is zero.
 

Public Attributes

UnderlyingType value
 The underlying integer value.
 

Protected Member Functions

constexpr Register (UnderlyingType initialValue)
 This class is meant to be subclassed.
 

Friends

IOStreamoperator<< (IOStream &s, const Register< T > &m)
 Printing a register will output its numeric value.
 

Detailed Description

template<typename T>
struct modm::Register< T >

Class for holding a register value.

You can cast any Flags, Configuration or Value type into the approprate Register type.

Control_t control = Control::EN;
Register8 base = control;
// functions can also be overloaded to accept *any* register of x bits
void function(Register8 arg);
function(control);

Apart from the boolean operators, this base class deletes all other implicit operator overloadings. Since any type information is lost during casting, you should not be able to use any operations involving specific flags, configurations or values.

Instead you have to explicitly use the integral value to perform your potentially unsafe operations.

This class makes heavy use of constexpr, so that as many values and operation can take place at compile time for efficiency.

Template Parameters
Tthe (unsigned) underlying integer type: uint8_t, uint16_t, uint32_t
See also
Register8, Register16, Register32
Author
Niklas Hauser

Member Function Documentation

template<typename T >
constexpr modm::Register< T >::operator bool ( ) const
inlineexplicitconstexpr

Returns true if value is non-zero

The compiler will allow implicit conversions to bool in the following contexts:

  • conditions of if, while, for, do-while statements
  • logical operators (&&, ||)
  • negation (operator !)
  • static_assert

The documentation for this struct was generated from the following file: