aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-12-04 00:20:36 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-12-04 00:20:36 -0700
commitd6d04862de9126d0930ae1f4b95ff6077c6eda63 (patch)
treee5266c4017d41b1e77be8bbefa8abafb90fa1504 /src/main.c
parent47885d62b689bececb58b7bf9479a5c1ff1c9b5c (diff)
downloadch573-d6d04862de9126d0930ae1f4b95ff6077c6eda63.tar.gz
ch573-d6d04862de9126d0930ae1f4b95ff6077c6eda63.tar.bz2
ch573-d6d04862de9126d0930ae1f4b95ff6077c6eda63.zip
Basic interrupts are working.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 2bbd0b3..9f5808b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,10 +1,10 @@
#include <math.h>
#include <stdint.h>
#include <stdio.h>
-#include "string.h"
#include "byte_math.h"
#include "ch573/gpio.h"
+#include "ch573/pfic.h"
#include "ch573/pwr.h"
#include "ch573/uart.h"
#include "clock.h"
@@ -13,8 +13,12 @@
#include "string.h"
#include "sysled.h"
#include "system.h"
+#include "systick.h"
#include "ws2812b.h"
+#define PFIC_I CH573_PFIC__PFIC_T_INTF
+#define PFIC ch573_pfic__pfic
+
#define GPIO_PORT_A ch573_gpio__gpio_port_a
#define GPIO_PORT_B ch573_gpio__gpio_port_b
#define GPIO_PORT CH573_GPIO__GPIO_PORT_T_INTF
@@ -203,14 +207,25 @@ int main(void)
{
char buf[N_LEDS * TOTAL_BYTES_PER_LED];
+ PFIC_I.vector_table_control.set(PFIC, 1);
+ PFIC->interrupt_priority_threshold = 0x10;
+ PFIC->interrupt_enable |= IRQ_SysTick;
+
+ printf(
+ "PFIC enable status 1: %08x\n",
+ (uint32_t)(PFIC->interrupt_enable_status));
+
set_system_clock_60Mhz();
+
+ set_systick(250000);
+
enable_sysled();
enable_spi();
size_t n = sizeof(buf);
struct ws2812b_buf ws_buf;
make_wsb2812b(&ws_buf, buf, n);
- ws_buf.byte_order = BYTE_ORDER_RGB;
+ ws_buf.byte_order = BYTE_ORDER_GRB;
rgb_t color;
uint32_t time = 0;