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

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

Public Member Functions

 unaligned_t (T value)
 
 operator T () const
 

Protected Member Functions

void write (T &value)
 
void read (T &value) const
 

Detailed Description

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

Accesses a type using byte-wise copy.

This wrapper manages unaligned access to memory, by copying the memory to and from the stack, which is always correctly aligned. Use this with the asUnaligned helper:

uint8_t *buffer;
// `u32` is a pointer to a unaligned_t<uint32_t*> !
auto *u32 = modm::asUnaligned<uint32_t*>(buffer);
// write to the unaligned location
*u32 = input;
// read from the unaligned location
output = *u32;
Author
Niklas Hauser

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