From 9f17335c19a6ae91a450e267b5313148644a7a14 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 16 Nov 2020 18:20:32 -0700 Subject: Add DMA header file which defines the DMA registers and add testing_harness with fake environment to allow testing on x86 development machines. --- 02-usart/tests/test_dma.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 02-usart/tests/test_dma.c (limited to '02-usart/tests/test_dma.c') diff --git a/02-usart/tests/test_dma.c b/02-usart/tests/test_dma.c new file mode 100644 index 0000000..7c2127a --- /dev/null +++ b/02-usart/tests/test_dma.c @@ -0,0 +1,27 @@ +#include "test_harness.h" +#include "dma.h" + +#include +#include +#include + +TEST(dma, smoke) { + dma_t* dma = &DMA1; + memset(dma, sizeof(dma), 0); + + dma->is_bf.tcif1 = 1; + ASSERT_EQ(dma->is_r, 2); + + dma->is_bf.htif7 = 1; + ASSERT_EQ(dma->is_r, 67108866); +} + +TEST(dma, correct_align) +{ + dma_t dma; + + // Assert the DMA registers are aligned with what the spec says. + ASSERT_EQ((long)(&dma.csel_r) - (long)(&dma), 0xA8); + + return 0; +} -- cgit