diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2025-09-30 13:06:16 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2025-09-30 13:06:16 -0600 |
commit | 290d784950b6248782b049cd9831bd6e034fd538 (patch) | |
tree | c231c02e92ed83a02b234a85b3c07bcc5e44b168 /src/init.c | |
parent | f89f75b5616de99865448f41b068a2783cd3648e (diff) | |
download | ch573-290d784950b6248782b049cd9831bd6e034fd538.tar.gz ch573-290d784950b6248782b049cd9831bd6e034fd538.tar.bz2 ch573-290d784950b6248782b049cd9831bd6e034fd538.zip |
Add many different patterns, and organize it.
Add a voltage discovery subsystem to allow the ch573 to detect if it's
on 12v or 5v lights.
Diffstat (limited to 'src/init.c')
-rw-r--r-- | src/init.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -1,11 +1,11 @@ #include <stddef.h> #include <stdint.h> -#include <stdio.h> #include "ch573/systick.h" -#include "clock.h" +#include "gpio.h" #include "io.h" #include "isr_vector.h" +#include "risc-v.h" void on_reset(void); @@ -67,13 +67,6 @@ extern uint32_t DATA_SEGMENT_STOP; extern uint32_t BSS_START; extern uint32_t BSS_STOP; -static inline void set_mtvec(void* vector_table) -{ - uint32_t mtvec = (uint32_t)vector_table; - mtvec |= 1; // Set interrupt table mode to "VECTORED" - asm volatile("csrw mtvec, %0" : : "r"(mtvec)); -} - /* * Initialize the data segment and the bss segment. * @@ -115,9 +108,12 @@ static __attribute((__section__(".sinit.1"))) void start(void) /* Initialize the data segments. */ init_data_segments(); /* Set the mtvec to the isr_vector. */ - set_mtvec(&isr_vector); + set_mtvec(&isr_vector, MODE_VECTORED); enable_interrupts(); + /* Initialize GPIO pins so they don't create unnecessary electrical noise. */ + gpio_init(); + /* Initialize stdout. */ init_uart1_for_stdout(); |