aboutsummaryrefslogtreecommitdiff
path: root/src/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.c')
-rw-r--r--src/init.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/init.c b/src/init.c
index 3aacc66..5f276cb 100644
--- a/src/init.c
+++ b/src/init.c
@@ -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();