From 1ccc15cc408e8a24976a5bebff0bb04862cdd0c9 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Mon, 11 Apr 2022 17:13:16 +0200 Subject: [PATCH] Add type size assertions --- src/hal/spi.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hal/spi.cpp b/src/hal/spi.cpp index 0fcf150..9411bef 100644 --- a/src/hal/spi.cpp +++ b/src/hal/spi.cpp @@ -28,6 +28,8 @@ namespace sta void HalSpiInterface::transfer16(uint16_t value) { + static_assert(sizeof(uint16_t) == 2); + HAL_SPI_Transmit(handle_, reinterpret_cast(&value), 2, HAL_MAX_DELAY); } @@ -42,6 +44,8 @@ namespace sta void HalSpiInterface::fill32(uint32_t value, size_t count) { + static_assert(sizeof(uint32_t) == 4); + for (size_t i = 0; i < count; ++i) { HAL_SPI_Transmit(handle_, reinterpret_cast(&value), 4, HAL_MAX_DELAY);