From 6e95ba4bbc200b13c9411204557f794eaf78e96b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 8 Aug 2018 21:56:37 +0100 Subject: [PATCH] Fixed unaligned access --- test/test_io_port.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/test_io_port.cpp b/test/test_io_port.cpp index 88223339..4634e8da 100644 --- a/test/test_io_port.cpp +++ b/test/test_io_port.cpp @@ -95,7 +95,14 @@ namespace //************************************************************************* TEST(test_dynamic_io_port) { - uint8_t memory[7]; + union U + { + uint16_t dummy; + uint8_t memory[7]; + } u; + + uint8_t* memory = &u.memory[0]; + memory[0] = 0x12; memory[1] = 0x00; memory[2] = 0x00; @@ -104,7 +111,7 @@ namespace memory[5] = 0x9A; memory[6] = 0x00; - dynamic_serial_port port(memory); + dynamic_serial_port port(&u.memory[0]); uint8_t rxdata = port.rxdata; CHECK_EQUAL(memory[0], rxdata);