aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-27 12:51:24 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-11-27 13:04:00 -0700
commitfcb936b4ea13841e8c4f87648182b20a194413f2 (patch)
tree11ba2cf223e2efe5c5f2b4c4f1192560631ddf89 /src/main.c
parent22c5b3e1dc4e3cf7de3f73ebbf5b59542f207f4b (diff)
downloadch573-fcb936b4ea13841e8c4f87648182b20a194413f2.tar.gz
ch573-fcb936b4ea13841e8c4f87648182b20a194413f2.tar.bz2
ch573-fcb936b4ea13841e8c4f87648182b20a194413f2.zip
Some SPI is working, a bit. Still no clock, but I'm about to give up on that.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/main.c b/src/main.c
index f06a775..8bf8e15 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,6 +5,7 @@
#include "ch573/pwr.h"
#include "ch573/uart.h"
#include "clock.h"
+#include "spi.h"
#include "system.h"
#define GPIO_PORT_A ch573_gpio__gpio_port_a
@@ -124,28 +125,34 @@ static void fast_delay()
*/
int main(void)
{
- GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 8);
- GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 8);
- GPIO_PORT.out.set(GPIO_PORT_A, OFF, 8);
+ printf("Running SPI.\n");
- GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 11);
- GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 11);
+ enable_spi();
- GPIO_PORT.dir.set(GPIO_PORT_A, DIR_IN, 10);
- GPIO_PORT.pd_drv.set(GPIO_PORT_A, PD_DRV_OPEN_DRAIN, 11);
+ run_spi();
- set_system_clock_6Mhz();
- uint32_t reg = (*(uint32_t*)0x40001008);
- reg &= ~0x1f;
- reg |= 10;
- enter_safe_mode();
- (*(uint32_t*)0x40001008) = reg;
+ // GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 8);
+ // GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 8);
+ // GPIO_PORT.out.set(GPIO_PORT_A, OFF, 8);
+ // GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 11);
+ // GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 11);
- for (int i = 0;; ++i) {
- GPIO_PORT.out.set(GPIO_PORT_A, ON, 8);
- GPIO_PORT.out.set(GPIO_PORT_A, OFF, 8);
- }
+ // GPIO_PORT.dir.set(GPIO_PORT_A, DIR_IN, 10);
+ // GPIO_PORT.pd_drv.set(GPIO_PORT_A, PD_DRV_OPEN_DRAIN, 11);
+
+ // set_system_clock_6Mhz();
+ // uint32_t reg = (*(uint32_t*)0x40001008);
+ // reg &= ~0x1f;
+ // reg |= 10;
+ // enter_safe_mode();
+ // (*(uint32_t*)0x40001008) = reg;
+
+
+ // for (int i = 0;; ++i) {
+ // GPIO_PORT.out.set(GPIO_PORT_A, ON, 8);
+ // GPIO_PORT.out.set(GPIO_PORT_A, OFF, 8);
+ // }
// clock_cfg_t cfg;
// for (int i = 0;; ++i) {