diff --git a/include/mdu/utility.hpp b/include/mdu/utility.hpp index adc7d5b..44cab07 100644 --- a/include/mdu/utility.hpp +++ b/include/mdu/utility.hpp @@ -41,4 +41,17 @@ constexpr auto data2uint64(uint8_t const* data) { return static_cast(upper) << 32u | lower; } +/// uint32_t to data +/// +/// \param word Word to convert +/// \param data Pointer to write to +/// \return Pointer after last element +constexpr auto uint32_2data(uint32_t word, uint8_t* data) { + *data++ = static_cast((word & 0xFF00'0000u) >> 24u); + *data++ = static_cast((word & 0x00FF'0000u) >> 16u); + *data++ = static_cast((word & 0x0000'FF00u) >> 8u); + *data++ = static_cast((word & 0x0000'00FFu) >> 0u); + return data; +} + } // namespace mdu \ No newline at end of file