aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-27 17:56:47 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-11-27 17:56:47 -0700
commit281672d418bdc093716b069198c8852ad87eabb2 (patch)
tree37edd78f8395390d7fdbe342a604d11060bda1f7 /src/main.c
parent74ea2acc63e7716f1e6bd24ee8a0cac3c0dbb819 (diff)
downloadch573-281672d418bdc093716b069198c8852ad87eabb2.tar.gz
ch573-281672d418bdc093716b069198c8852ad87eabb2.tar.bz2
ch573-281672d418bdc093716b069198c8852ad87eabb2.zip
Got the DMA to work! (That was surprisingly easy).
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 8bf8e15..5f883f9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,7 @@
#include <stdint.h>
#include <stdio.h>
+#include "string.h"
#include "ch573/gpio.h"
#include "ch573/pwr.h"
#include "ch573/uart.h"
@@ -127,9 +128,24 @@ int main(void)
{
printf("Running SPI.\n");
+ set_system_clock_60Mhz();
+
enable_spi();
- run_spi();
+ char buf[1024];
+ memset(buf, 0xf0, sizeof(buf));
+ for (int i = 0; i < 50; ++ i) {
+ buf[i] = 0xaa;
+ buf[sizeof(buf) - i] = 0xaa;
+ }
+
+ while (1) {
+ printf("Xfer.\n");
+ dma_transfer(buf, sizeof(buf));
+ wait_for_dma();
+ }
+
+ // run_spi();
// GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 8);
// GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 8);