diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-11-22 01:06:30 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-11-22 01:06:30 -0700 |
commit | 9f28e53c71d28d04e2775c59944d2887a99f1e86 (patch) | |
tree | c0ecb2872c6d27acf08aa73919d709f949200de5 | |
parent | ebb9123c00d1e9629376b6f0a2f1f4e7e550c2af (diff) | |
download | stm32l4-9f28e53c71d28d04e2775c59944d2887a99f1e86.tar.gz stm32l4-9f28e53c71d28d04e2775c59944d2887a99f1e86.tar.bz2 stm32l4-9f28e53c71d28d04e2775c59944d2887a99f1e86.zip |
Large reorganization.
What was in core/ is now moved to arch/stm34l4xxx/peripherals. This new
directory is *supposed to* to contain raw header files defining just the
pertinent register structures for the various peripherals. Peripheral
management belongs somewhere in the new `kern/..` directories. This is
not completely the case at the moment, so more refactoring needs to be
done.
What was sitting in the root has now been moved into the kern/
directory. The kern/ directory is to contain everything else
other than raw device register definitions. The root of the kern/
tree is reserved for standard library-esque headers.
The kern/<peripheral> directory contains management systems for that
peripheral. (At the moment DMA is the only peripheral with a decent
management system.) Preferably these peripheral systems should only
include their correlating header in arch/stm34l4xxx/peripherals, and
use other management systems for handling other peripherals rather
than manipulating their raw registers directly. (Though this ideal
will require much more critical mass of management systems.)
-rwxr-xr-x | 02-usart/genmake.pl | 9 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/apb.h (renamed from 02-usart/include/core/apb.h) | 0 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/clock.h (renamed from 02-usart/include/core/clock.h) | 2 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/dma.h (renamed from 02-usart/include/core/dma.h) | 2 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/flash.h (renamed from 02-usart/include/core/flash.h) | 2 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/gpio.h (renamed from 02-usart/include/core/gpio.h) | 4 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/irq.h (renamed from 02-usart/include/core/irq.h) | 2 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/isrs.inc (renamed from 02-usart/include/core/isrs.inc) | 0 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/nvic.h (renamed from 02-usart/include/core/nvic.h) | 2 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/rcc.h (renamed from 02-usart/include/core/rcc.h) | 2 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/spi.h (renamed from 02-usart/include/core/spi.h) | 2 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/system.h (renamed from 02-usart/include/core/system.h) | 2 | ||||
-rw-r--r-- | 02-usart/include/arch/stm32l4xxx/peripherals/usart.h (renamed from 02-usart/include/core/usart.h) | 4 | ||||
-rw-r--r-- | 02-usart/include/kern/common.h (renamed from 02-usart/include/common.h) | 0 | ||||
-rw-r--r-- | 02-usart/include/kern/delay.h (renamed from 02-usart/include/delay.h) | 0 | ||||
-rw-r--r-- | 02-usart/include/kern/dma/dma_manager.h (renamed from 02-usart/include/peri/dma.h) | 6 | ||||
-rw-r--r-- | 02-usart/include/kern/lib.h (renamed from 02-usart/include/lib.h) | 0 | ||||
-rw-r--r-- | 02-usart/include/kern/mem.h (renamed from 02-usart/include/mem.h) | 0 | ||||
-rw-r--r-- | 02-usart/include/kern/spin.h (renamed from 02-usart/include/spin.h) | 0 | ||||
-rw-r--r-- | 02-usart/include/kern/string.h | 6 | ||||
-rw-r--r-- | 02-usart/src/arch/stm32l4xxx/peripherals/clock.c (renamed from 02-usart/src/core/clock.c) | 6 | ||||
-rw-r--r-- | 02-usart/src/arch/stm32l4xxx/peripherals/gpio.c (renamed from 02-usart/src/core/gpio.c) | 4 | ||||
-rw-r--r-- | 02-usart/src/arch/stm32l4xxx/peripherals/init.c (renamed from 02-usart/src/core/init.c) | 2 | ||||
-rw-r--r-- | 02-usart/src/arch/stm32l4xxx/peripherals/irq.c (renamed from 02-usart/src/core/irq.c) | 12 | ||||
-rw-r--r-- | 02-usart/src/arch/stm32l4xxx/peripherals/usart.c (renamed from 02-usart/src/core/usart.c) | 6 | ||||
-rw-r--r-- | 02-usart/src/kern/delay.c (renamed from 02-usart/src/delay.c) | 2 | ||||
-rw-r--r-- | 02-usart/src/kern/dma/dma_manager.c (renamed from 02-usart/src/peri/dma.c) | 8 | ||||
-rw-r--r-- | 02-usart/src/kern/lib.c (renamed from 02-usart/src/lib.c) | 2 | ||||
-rw-r--r-- | 02-usart/src/kern/main.c (renamed from 02-usart/src/main.c) | 36 | ||||
-rw-r--r-- | 02-usart/src/kern/mem.c (renamed from 02-usart/src/mem.c) | 4 | ||||
-rw-r--r-- | 02-usart/src/kern/spin.c (renamed from 02-usart/src/spin.c) | 6 | ||||
-rw-r--r-- | 02-usart/src/kern/stdlibrepl.c (renamed from 02-usart/src/stdlibrepl.c) | 0 | ||||
-rw-r--r-- | 02-usart/src/kern/string.c | 9 | ||||
-rw-r--r-- | 02-usart/src/kern/vector.c (renamed from 02-usart/src/vector.c) | 0 | ||||
-rw-r--r-- | 02-usart/tests/test_dma.c | 15 | ||||
-rw-r--r-- | 02-usart/tests/test_irq.c | 10 | ||||
-rw-r--r-- | 02-usart/tests/test_lib.c | 4 | ||||
-rw-r--r-- | 02-usart/tests/test_memory.c | 4 | ||||
-rw-r--r-- | 02-usart/tests/test_spi.c | 2 | ||||
-rw-r--r-- | 02-usart/tests/test_usart.c | 4 |
40 files changed, 112 insertions, 69 deletions
diff --git a/02-usart/genmake.pl b/02-usart/genmake.pl index 89403ce..c4165a6 100755 --- a/02-usart/genmake.pl +++ b/02-usart/genmake.pl @@ -87,6 +87,7 @@ foreach $file (@files) { my $obj_files_deps = join(' ', @obj_files); +my @tests_tgts; foreach $file (@test_files) { my $c_file = $file; @@ -98,6 +99,7 @@ foreach $file (@test_files) { my @deps = header_deps($c_file); my $deps_as_join = join(" ", @deps); + push (@test_tgts, "${outbinary}"); print "${outbinary}: $deps_as_join $obj_files_deps test_harness/test_harness.a\n\t"; print "mkdir -p " . dirname($outbinary) . "\n\t"; print '$(CC) $(CFLAGS) -o' . ${outbinary} . ' ' . $c_file . ' ' . $obj_files_deps . " test_harness/test_harness.a\n\n"; @@ -111,6 +113,13 @@ foreach $file (@test_files) { print "test_harness/test_harness.a: test_harness/test_harness.h test_harness/test_harness.c\n\t"; print 'cd test_harness; $(MAKE) test_harness.a; cd ..' . "\n\n"; +print "tests_: " . join(" ", @test_tgts) . "\n\t"; +print "" . join("\n\t", @test_tgts) . "\n\n"; + +print ".PHONY: tests\n"; +print "tests:\n\t"; +print 'PREFIX=$(TEST_PREFIX) CFLAGS="$(TEST_CFLAGS)" $(MAKE) tests_' . "\n\n"; + print "FORCE:\n\t\n\n"; print "$arch_obs_dir/main.elf: FORCE $obj_files_deps linker/linker_script.ld\n\t"; print "([ \"\$\$($idempotency_cmd_make)\" != \"\$(IDEMPOTENCY_HASH)\" ] " diff --git a/02-usart/include/core/apb.h b/02-usart/include/arch/stm32l4xxx/peripherals/apb.h index 11fa7ab..11fa7ab 100644 --- a/02-usart/include/core/apb.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/apb.h diff --git a/02-usart/include/core/clock.h b/02-usart/include/arch/stm32l4xxx/peripherals/clock.h index c3c58d7..6e461de 100644 --- a/02-usart/include/core/clock.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/clock.h @@ -2,7 +2,7 @@ #define CORE_CLOCK_H__ #include <stdint.h> -#include "rcc.h" +#include "arch/stm32l4xxx/peripherals/rcc.h" #define PERIPH_BASE ((uint32_t)0x40000000) #define AHBPERIPH_BASE (PERIPH_BASE + 0x00020000) diff --git a/02-usart/include/core/dma.h b/02-usart/include/arch/stm32l4xxx/peripherals/dma.h index 8e4896d..f62a92b 100644 --- a/02-usart/include/core/dma.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/dma.h @@ -10,7 +10,7 @@ * There are 2 DMA's on the chip. Each with 7 channels. */ -#include "common.h" +#include "kern/common.h" #include <arch.h> #include <stdint.h> diff --git a/02-usart/include/core/flash.h b/02-usart/include/arch/stm32l4xxx/peripherals/flash.h index a163a25..28a3d6c 100644 --- a/02-usart/include/core/flash.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/flash.h @@ -1,7 +1,7 @@ #ifndef H__FLASH_ #define H__FLASH_ -#include "common.h" +#include "kern/common.h" /* * Header file for dealing with flash. diff --git a/02-usart/include/core/gpio.h b/02-usart/include/arch/stm32l4xxx/peripherals/gpio.h index 54963b1..20acf71 100644 --- a/02-usart/include/core/gpio.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/gpio.h @@ -1,8 +1,8 @@ #ifndef CORE_GPIO_H__ #define CORE_GPIO_H__ -#include "common.h" -#include "rcc.h" +#include "kern/common.h" +#include "arch/stm32l4xxx/peripherals/rcc.h" #include <stdint.h> diff --git a/02-usart/include/core/irq.h b/02-usart/include/arch/stm32l4xxx/peripherals/irq.h index f2fe8d9..52878ca 100644 --- a/02-usart/include/core/irq.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/irq.h @@ -11,7 +11,7 @@ typedef enum { #define IRQ_RESERVED(n) #define IRQ(name_, uname, num) \ IRQ_##uname = num, -#include "core/isrs.inc" +#include "arch/stm32l4xxx/peripherals//isrs.inc" #undef IRQ #undef IRQ_RESERVED } interrupt_t; diff --git a/02-usart/include/core/isrs.inc b/02-usart/include/arch/stm32l4xxx/peripherals/isrs.inc index 0682238..0682238 100644 --- a/02-usart/include/core/isrs.inc +++ b/02-usart/include/arch/stm32l4xxx/peripherals/isrs.inc diff --git a/02-usart/include/core/nvic.h b/02-usart/include/arch/stm32l4xxx/peripherals/nvic.h index c761574..1645a2d 100644 --- a/02-usart/include/core/nvic.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/nvic.h @@ -2,7 +2,7 @@ #define NVIC_H_ #include "arch.h" -#include "common.h" +#include "kern/common.h" typedef __IO struct { #define nvic_intlinesnum (0x0F << 0) diff --git a/02-usart/include/core/rcc.h b/02-usart/include/arch/stm32l4xxx/peripherals/rcc.h index 45f64b5..861504e 100644 --- a/02-usart/include/core/rcc.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/rcc.h @@ -2,7 +2,7 @@ #define H__RCC_ #include "arch.h" -#include "common.h" +#include "kern/common.h" #include <stdint.h> typedef struct { diff --git a/02-usart/include/core/spi.h b/02-usart/include/arch/stm32l4xxx/peripherals/spi.h index 77cd61e..a39a0bb 100644 --- a/02-usart/include/core/spi.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/spi.h @@ -1,7 +1,7 @@ #ifndef CORE_SPI_H_ #define CORE_SPI_H_ -#include "common.h" +#include "kern/common.h" #include "arch.h" #define SPI1 (*((spi_t*)(SPI1_BASE))) diff --git a/02-usart/include/core/system.h b/02-usart/include/arch/stm32l4xxx/peripherals/system.h index a636729..b6ff0a6 100644 --- a/02-usart/include/core/system.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/system.h @@ -2,7 +2,7 @@ #define CORE_SYSTEM_H_ #include <stdint.h> -#include "common.h" +#include "kern/common.h" typedef __IO struct { uint32_t actl_r; /* Auxiliary Control Register, ACTLR on page 4-5 */ diff --git a/02-usart/include/core/usart.h b/02-usart/include/arch/stm32l4xxx/peripherals/usart.h index 8d841df..e42e31e 100644 --- a/02-usart/include/core/usart.h +++ b/02-usart/include/arch/stm32l4xxx/peripherals/usart.h @@ -4,8 +4,8 @@ #include <arch.h> #include <stdint.h> -#include "common.h" -#include "rcc.h" +#include "kern/common.h" +#include "arch/stm32l4xxx/peripherals/rcc.h" #include <assert.h> #define USART1 (* (usart_t*) USART1_BASE) diff --git a/02-usart/include/common.h b/02-usart/include/kern/common.h index 653279e..653279e 100644 --- a/02-usart/include/common.h +++ b/02-usart/include/kern/common.h diff --git a/02-usart/include/delay.h b/02-usart/include/kern/delay.h index 65a26d6..65a26d6 100644 --- a/02-usart/include/delay.h +++ b/02-usart/include/kern/delay.h diff --git a/02-usart/include/peri/dma.h b/02-usart/include/kern/dma/dma_manager.h index d3cac4b..0d17bd5 100644 --- a/02-usart/include/peri/dma.h +++ b/02-usart/include/kern/dma/dma_manager.h @@ -1,9 +1,9 @@ #ifndef PERI_DMA_H_ #define PERI_DMA_H_ -#include "common.h" -#include "core/dma.h" /* Access to the DMA registers. */ -#include "core/irq.h" +#include "kern/common.h" +#include "arch/stm32l4xxx/peripherals/dma.h" /* Access to the DMA registers. */ +#include "arch/stm32l4xxx/peripherals/irq.h" #define DMA_ERROR_CHANNEL_IN_USE 1 diff --git a/02-usart/include/lib.h b/02-usart/include/kern/lib.h index be0e8e9..be0e8e9 100644 --- a/02-usart/include/lib.h +++ b/02-usart/include/kern/lib.h diff --git a/02-usart/include/mem.h b/02-usart/include/kern/mem.h index d150744..d150744 100644 --- a/02-usart/include/mem.h +++ b/02-usart/include/kern/mem.h diff --git a/02-usart/include/spin.h b/02-usart/include/kern/spin.h index a23d25b..a23d25b 100644 --- a/02-usart/include/spin.h +++ b/02-usart/include/kern/spin.h diff --git a/02-usart/include/kern/string.h b/02-usart/include/kern/string.h new file mode 100644 index 0000000..3c9f0b4 --- /dev/null +++ b/02-usart/include/kern/string.h @@ -0,0 +1,6 @@ +#ifndef STRING_H_ +#define STRING_H_ + +void kstrcpy(char* into, const char* from); + +#endif /* STRING_H_ */ diff --git a/02-usart/src/core/clock.c b/02-usart/src/arch/stm32l4xxx/peripherals/clock.c index f32cb4e..ba127a9 100644 --- a/02-usart/src/core/clock.c +++ b/02-usart/src/arch/stm32l4xxx/peripherals/clock.c @@ -2,11 +2,11 @@ * This file sets the system clock to its full glory of 80Mhz */ -#include "core/clock.h" -#include "core/flash.h" +#include "arch/stm32l4xxx/peripherals/clock.h" +#include "arch/stm32l4xxx/peripherals/flash.h" #include <stdint.h> -#include "spin.h" +#include "kern/spin.h" #define TIMEOUT 10000 diff --git a/02-usart/src/core/gpio.c b/02-usart/src/arch/stm32l4xxx/peripherals/gpio.c index c46b1ff..a1e82c7 100644 --- a/02-usart/src/core/gpio.c +++ b/02-usart/src/arch/stm32l4xxx/peripherals/gpio.c @@ -1,5 +1,5 @@ -#include "core/gpio.h" -#include "core/rcc.h" +#include "arch/stm32l4xxx/peripherals/gpio.h" +#include "arch/stm32l4xxx/peripherals/rcc.h" /* * Sets the mode of a pin on a gpio por. diff --git a/02-usart/src/core/init.c b/02-usart/src/arch/stm32l4xxx/peripherals/init.c index 0a7cb7f..47bfaa5 100644 --- a/02-usart/src/core/init.c +++ b/02-usart/src/arch/stm32l4xxx/peripherals/init.c @@ -1,5 +1,5 @@ #include "arch.h" -#include "core/system.h" +#include "arch/stm32l4xxx/peripherals/system.h" /* Forward-declare the main function. This is implemented in main.c. */ void main(); diff --git a/02-usart/src/core/irq.c b/02-usart/src/arch/stm32l4xxx/peripherals/irq.c index 47ad924..8fb3e49 100644 --- a/02-usart/src/core/irq.c +++ b/02-usart/src/arch/stm32l4xxx/peripherals/irq.c @@ -1,16 +1,16 @@ -#include "core/irq.h" -#include "core/gpio.h" -#include "core/nvic.h" +#include "arch/stm32l4xxx/peripherals/irq.h" +#include "arch/stm32l4xxx/peripherals/gpio.h" +#include "arch/stm32l4xxx/peripherals/nvic.h" #include "arch.h" -#include "delay.h" +#include "kern/delay.h" #define IRQ_RESERVED(n) #define IRQ(name, uname_, n) \ void WEAK name () { \ unhandled_isr(n); \ } -#include "core/isrs.inc" +#include "arch/stm32l4xxx/peripherals/isrs.inc" #undef IRQ_RESERVED #undef IRQ @@ -26,7 +26,7 @@ void isr_simple_pin_on() #define IRQ(name, uname_, n) name, const void* vectors[] __attribute__((section(".vectors"))) = { (void*)0x2000c000, /* Top of stack at top of sram1. 48k */ -#include "core/isrs.inc" +#include "arch/stm32l4xxx/peripherals/isrs.inc" }; #undef IRQ_RESERVED #undef IRQ diff --git a/02-usart/src/core/usart.c b/02-usart/src/arch/stm32l4xxx/peripherals/usart.c index 19d982e..d37eee2 100644 --- a/02-usart/src/core/usart.c +++ b/02-usart/src/arch/stm32l4xxx/peripherals/usart.c @@ -1,6 +1,6 @@ -#include "core/usart.h" -#include "delay.h" -#include "lib.h" +#include "arch/stm32l4xxx/peripherals/usart.h" +#include "kern/delay.h" +#include "kern/lib.h" #include <stdarg.h> void set_usart1_clock_src(__IO rcc_t* rcc, usart_clk_src_t usart_clk_src) diff --git a/02-usart/src/delay.c b/02-usart/src/kern/delay.c index 2a16d47..28ef710 100644 --- a/02-usart/src/delay.c +++ b/02-usart/src/kern/delay.c @@ -1,4 +1,4 @@ -#include "delay.h" +#include "kern/delay.h" void delay(uint32_t delay) { diff --git a/02-usart/src/peri/dma.c b/02-usart/src/kern/dma/dma_manager.c index ceae2e6..4336496 100644 --- a/02-usart/src/peri/dma.c +++ b/02-usart/src/kern/dma/dma_manager.c @@ -1,7 +1,7 @@ -#include "peri/dma.h" -#include "core/dma.h" -#include "core/usart.h" -#include "core/rcc.h" +#include "kern/dma/dma_manager.h" +#include "arch/stm32l4xxx/peripherals/dma.h" +#include "arch/stm32l4xxx/peripherals/usart.h" +#include "arch/stm32l4xxx/peripherals/rcc.h" /* Bitmask of DMA2 channels in use. */ diff --git a/02-usart/src/lib.c b/02-usart/src/kern/lib.c index d5d81da..88188cc 100644 --- a/02-usart/src/lib.c +++ b/02-usart/src/kern/lib.c @@ -1,4 +1,4 @@ -#include "lib.h" +#include "kern/lib.h" #define nybble_to_hex(n) \ ((n) < 10 ? 0x30 + (n) : ('A' + ((n) - 10))) diff --git a/02-usart/src/main.c b/02-usart/src/kern/main.c index b050d3e..0e0c89c 100644 --- a/02-usart/src/main.c +++ b/02-usart/src/kern/main.c @@ -1,18 +1,20 @@ #include "arch.h" -#include "core/clock.h" -#include "core/dma.h" -#include "core/gpio.h" -#include "core/system.h" -#include "core/usart.h" -#include "core/nvic.h" -#include "core/irq.h" - -#include "peri/dma.h" -#include "delay.h" -#include "mem.h" -#include "spin.h" -#include "string.h" + +#include "arch/stm32l4xxx/peripherals/clock.h" +#include "arch/stm32l4xxx/peripherals/dma.h" +#include "arch/stm32l4xxx/peripherals/gpio.h" +#include "arch/stm32l4xxx/peripherals/system.h" +#include "arch/stm32l4xxx/peripherals/usart.h" +#include "arch/stm32l4xxx/peripherals/nvic.h" +#include "arch/stm32l4xxx/peripherals/irq.h" + +#include "kern/dma/dma_manager.h" + +#include "kern/delay.h" +#include "kern/mem.h" +#include "kern/spin.h" +#include "kern/string.h" /** Overrides the default systick irq handler. */ void on_systick() @@ -84,7 +86,7 @@ int main() // const char* thing = "Good Thing This Works!"; char* str = halloc(128); - strcpy(str, "Hello, Heap!"); + kstrcpy(str, "Hello, Heap!"); usart_printf(&USART2, "DATA_SEGMENT_START %p\n", &DATA_SEGMENT_START); usart_printf(&USART2, "DATA_SEGMENT_STOP: %p\n", &DATA_SEGMENT_STOP); @@ -101,13 +103,13 @@ int main() // usart_printf(&USART2, "Start Configuring Countdown!\n"); /* Set the countdown to start from 1,000,0000. */ - // SCB.strv_r = 10000000; + SCB.strv_r = 10000000; /* Enable interrupts. */ - // regset(SCB.stcs_r, scb_tickint, 1); + regset(SCB.stcs_r, scb_tickint, 1); /* Start the systick. */ - // regset(SCB.stcs_r, scb_enable, 1); + regset(SCB.stcs_r, scb_enable, 1); // usart_printf(&USART2, "Start Countdown Started!\n"); } diff --git a/02-usart/src/mem.c b/02-usart/src/kern/mem.c index 27e0fc2..79bcabf 100644 --- a/02-usart/src/mem.c +++ b/02-usart/src/kern/mem.c @@ -1,6 +1,6 @@ #include "arch.h" -#include "mem.h" -#include "common.h" +#include "kern/mem.h" +#include "kern/common.h" #ifdef ARCH_STM32L4 /* Provide a definition for memset() when not provided for the diff --git a/02-usart/src/spin.c b/02-usart/src/kern/spin.c index 4d1aede..7c4f6eb 100644 --- a/02-usart/src/spin.c +++ b/02-usart/src/kern/spin.c @@ -1,6 +1,6 @@ -#include "spin.h" -#include "delay.h" -#include "core/gpio.h" +#include "kern/spin.h" +#include "kern/delay.h" +#include "arch/stm32l4xxx/peripherals/gpio.h" #define SHORT_DELAY 200000 #define LONG_DELAY (SHORT_DELAY * 2) diff --git a/02-usart/src/stdlibrepl.c b/02-usart/src/kern/stdlibrepl.c index 2d9d839..2d9d839 100644 --- a/02-usart/src/stdlibrepl.c +++ b/02-usart/src/kern/stdlibrepl.c diff --git a/02-usart/src/kern/string.c b/02-usart/src/kern/string.c new file mode 100644 index 0000000..4afa228 --- /dev/null +++ b/02-usart/src/kern/string.c @@ -0,0 +1,9 @@ +#include "kern/string.h" + +void kstrcpy(char* into, const char* from) +{ + while(*from) { + *(into ++) = *(from ++); + } + *into = 0; +} diff --git a/02-usart/src/vector.c b/02-usart/src/kern/vector.c index e69de29..e69de29 100644 --- a/02-usart/src/vector.c +++ b/02-usart/src/kern/vector.c diff --git a/02-usart/tests/test_dma.c b/02-usart/tests/test_dma.c index ce0c4ba..50cdb5b 100644 --- a/02-usart/tests/test_dma.c +++ b/02-usart/tests/test_dma.c @@ -1,8 +1,8 @@ #include "test_harness.h" -#include "core/dma.h" -#include "core/rcc.h" -#include "core/usart.h" -#include "peri/dma.h" +#include "arch/stm32l4xxx/peripherals/dma.h" +#include "arch/stm32l4xxx/peripherals/rcc.h" +#include "arch/stm32l4xxx/peripherals/usart.h" +#include "kern/dma/dma_manager.h" #include <stdio.h> #include <stdlib.h> @@ -18,6 +18,7 @@ TEST(dma, smoke) regset(dma->is_r, dma_htif7, 1); ASSERT_EQ(dma->is_r, 67108866); + return 0; } TEST(dma, cc_regset) @@ -29,6 +30,7 @@ TEST(dma, cc_regset) regset(channel_config->cc_r, dma_cc_msize, DMA_SIZE_32_BITS); ASSERT_EQ(channel_config->cc_r, 1 << 11); + return 0; } TEST(dma, correct_align) @@ -52,6 +54,7 @@ TEST(dma, regset_pl) ASSERT_EQ( regget(reg, dma_cc_pl), DMA_PRIORITY_LEVEL_MEDIUM); + return 0; } TEST(dma_peri, select_peripheral) @@ -86,6 +89,7 @@ TEST(dma_peri, select_peripheral) release_dma_channel(chan.c_); ASSERT_EQ(regget(RCC.ahb1en_r, rcc_dma1en), 0); + return 0; } TEST(dma_peri, unable_to_realloc) @@ -119,6 +123,7 @@ TEST(dma_peri, unable_to_realloc) ASSERT_EQ(ec, 0); release_dma_channel(chan.c_); + return 0; } TEST(dma_peri, select_mem2mem) @@ -151,6 +156,7 @@ TEST(dma_peri, select_mem2mem) release_dma_channel(chan2.c_); release_dma_channel(chan3.c_); + return 0; } TEST(dma_peri, select_mem2mem_2) @@ -179,4 +185,5 @@ TEST(dma_peri, select_mem2mem_2) } release_dma_channel(chans[i].c_); } + return 0; } diff --git a/02-usart/tests/test_irq.c b/02-usart/tests/test_irq.c index 89eea11..3c4ee9c 100644 --- a/02-usart/tests/test_irq.c +++ b/02-usart/tests/test_irq.c @@ -1,7 +1,7 @@ #include "test_harness.h" -#include "core/irq.h" -#include "core/nvic.h" +#include "arch/stm32l4xxx/peripherals/irq.h" +#include "arch/stm32l4xxx/peripherals/nvic.h" TEST(irq, nvic) { @@ -14,6 +14,8 @@ TEST(irq, nvic) ASSERT_EQ(is.irqs[1], 0xC0); ASSERT_EQ(NVIC.ise_r[1], 0xC0); + + return 0; } TEST(irq, nvic_edgecase) @@ -28,10 +30,14 @@ TEST(irq, nvic_edgecase) ASSERT_EQ(NVIC.ise_r[0], 1); ASSERT_EQ(is.irqs[1], 1); ASSERT_EQ(NVIC.ise_r[1], 1); + + return 0; } TEST(irq, enable_single_interrupt) { enable_interrupt(IRQ_USART2); ASSERT_EQ(NVIC.ise_r[1], 0x40); + + return 0; } diff --git a/02-usart/tests/test_lib.c b/02-usart/tests/test_lib.c index 8d63577..33076c2 100644 --- a/02-usart/tests/test_lib.c +++ b/02-usart/tests/test_lib.c @@ -1,5 +1,5 @@ #include "test_harness.h" -#include "lib.h" +#include "kern/lib.h" TEST(lib, hexify) { @@ -16,4 +16,6 @@ TEST(lib, hexify) hexify(0xdeadbeef, buf); ASSERT_EQ_STR(buf, "DEADBEEF"); + + return 0; } diff --git a/02-usart/tests/test_memory.c b/02-usart/tests/test_memory.c index 1b88ad1..2272f20 100644 --- a/02-usart/tests/test_memory.c +++ b/02-usart/tests/test_memory.c @@ -6,8 +6,8 @@ #include "arch.h" #include "test_harness.c" -#include "common.h" -#include "mem.h" +#include "kern/common.h" +#include "kern/mem.h" extern uint32_t* halloc_start; static void wipeout_halloc() diff --git a/02-usart/tests/test_spi.c b/02-usart/tests/test_spi.c index d6cc24e..cc25d6e 100644 --- a/02-usart/tests/test_spi.c +++ b/02-usart/tests/test_spi.c @@ -1,6 +1,6 @@ #include "test_harness.h" -#include "core/spi.h" +#include "arch/stm32l4xxx/peripherals/spi.h" TEST(spi, smoke) { diff --git a/02-usart/tests/test_usart.c b/02-usart/tests/test_usart.c index e2cfdf8..b19d687 100644 --- a/02-usart/tests/test_usart.c +++ b/02-usart/tests/test_usart.c @@ -1,5 +1,5 @@ #include "test_harness.h" -#include "core/usart.h" +#include "arch/stm32l4xxx/peripherals/usart.h" #include <stdlib.h> @@ -17,4 +17,6 @@ TEST(usart, enable_dma) usart_enable_dma(usart, USART_ENABLE_DISABLED); ASSERT_EQ(usart->c_r3, 0); + + return 0; } |