Allow writing uint32_t to UART

This commit is contained in:
Konstantin Nazarov 2024-12-21 23:05:42 +00:00
parent 2e9bb3fd76
commit 557d5dfa75
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
2 changed files with 9 additions and 0 deletions

View file

@ -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() { void Timer::update() {
using Clock = std::chrono::high_resolution_clock; using Clock = std::chrono::high_resolution_clock;
constexpr auto den = Clock::period::den; constexpr auto den = Clock::period::den;

View file

@ -75,6 +75,7 @@ class UART final : public Device {
UART() : Device(UART_ADDR, 8) {} UART() : Device(UART_ADDR, 8) {}
virtual void write_mem_u8(uint8_t *src, size_t addr); 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); virtual void read_mem_u8(uint8_t *dst, size_t addr);