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 /02-usart/src | |
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.)
Diffstat (limited to '02-usart/src')
-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 |
14 files changed, 54 insertions, 43 deletions
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 |