diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-11-16 18:20:32 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-11-16 18:20:32 -0700 |
commit | 9f17335c19a6ae91a450e267b5313148644a7a14 (patch) | |
tree | f1ae946ada62148913a8cc10bc985f8de926a4a0 /02-usart/test_harness/fake_env.c | |
parent | 4767c73fb2e1f96469fe24a83b443c1774b01d86 (diff) | |
download | stm32l4-9f17335c19a6ae91a450e267b5313148644a7a14.tar.gz stm32l4-9f17335c19a6ae91a450e267b5313148644a7a14.tar.bz2 stm32l4-9f17335c19a6ae91a450e267b5313148644a7a14.zip |
Add DMA header file which defines the DMA registers and add
testing_harness with fake environment to allow testing on x86
development machines.
Diffstat (limited to '02-usart/test_harness/fake_env.c')
-rw-r--r-- | 02-usart/test_harness/fake_env.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/02-usart/test_harness/fake_env.c b/02-usart/test_harness/fake_env.c new file mode 100644 index 0000000..45cb1e9 --- /dev/null +++ b/02-usart/test_harness/fake_env.c @@ -0,0 +1,25 @@ +#include "fake_env.h" + +#include <stdlib.h> +#include <assert.h> + +#define DEFINE_MEMORY_SEGMENT(name, start_addr, end_addr) \ + static void* fake_##name = NULL; \ + void* load_fake_##name##__ () \ + { \ + if (fake_##name == NULL) { \ + fake_##name = malloc((end_addr) - (start_addr)); \ + assert(fake_##name != NULL); \ + } \ + return fake_##name; \ + } + +/* Peripheral buses */ +DEFINE_MEMORY_SEGMENT(apb1, 0x40000000, 0x40010000) +DEFINE_MEMORY_SEGMENT(apb2, 0x40010000, 0x40020000) +DEFINE_MEMORY_SEGMENT(ahb1, 0x40020000, 0x40024400) +DEFINE_MEMORY_SEGMENT(ahb2, 0x48000000, 0x50060C00) + +/* SRAM */ +DEFINE_MEMORY_SEGMENT(sram1, 0x20000000, 0x2000C000) +DEFINE_MEMORY_SEGMENT(sram2, 0x2000C000, 0x20018000) |