From 557d5dfa75c8c7e72d5e884d7733a3f0feb686f9 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sat, 21 Dec 2024 23:05:42 +0000 Subject: [PATCH] Allow writing uint32_t to UART --- src/vm.cpp | 8 ++++++++ src/vm.hpp | 1 + 2 files changed, 9 insertions(+) diff --git a/src/vm.cpp b/src/vm.cpp index 9b8b10f..5644d1d 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -58,6 +58,14 @@ void UART::write_mem_u8(uint8_t* src, size_t addr) { } } +void UART::write_mem_u32(uint32_t* src, size_t addr) { + uint8_t* s = (uint8_t*)src; + + for (size_t i = 0; i < 4; i++) { + write_mem_u8(s + i, addr + i); + } +} + void Timer::update() { using Clock = std::chrono::high_resolution_clock; constexpr auto den = Clock::period::den; diff --git a/src/vm.hpp b/src/vm.hpp index 0e5f0b8..478f8a7 100644 --- a/src/vm.hpp +++ b/src/vm.hpp @@ -75,6 +75,7 @@ class UART final : public Device { UART() : Device(UART_ADDR, 8) {} virtual void write_mem_u8(uint8_t *src, size_t addr); + virtual void write_mem_u32(uint32_t *src, size_t addr); virtual void read_mem_u8(uint8_t *dst, size_t addr);