aboutsummaryrefslogtreecommitdiff
path: root/src/spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/spi.c')
-rw-r--r--src/spi.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/spi.c b/src/spi.c
index 6d9fb2a..5c84b77 100644
--- a/src/spi.c
+++ b/src/spi.c
@@ -7,9 +7,6 @@
#define MAX_SPI_FIFO 8
-#define SPI CH573_SPI__SPI_T_INTF
-#define SPI0 ch573_spi__spi0
-
#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
@@ -19,7 +16,7 @@
void enable_spi(void)
{
- GPIO_I.pin_alternate.pin_spi0.set(GPIO, OFF);
+ GPIO_I.pin_alternate.pin_spi0.set(GPIO, ON);
GPIO_PORT.out.set(GPIO_PORT_A, ON, 12);
GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 12);
@@ -34,6 +31,8 @@ void enable_spi(void)
GPIO_PORT.out.set(GPIO_PORT_B, OFF, 14);
GPIO_PORT.out.set(GPIO_PORT_B, ON, 12);
+ GPIO_PORT.pu.set(GPIO_PORT_B, ENABLED, 14);
+
GPIO_PORT.dir.set(GPIO_PORT_B, DIR_IN, 13);
GPIO_PORT.dir.set(GPIO_PORT_B, DIR_IN, 15);
GPIO_PORT.dir.set(GPIO_PORT_A, DIR_IN, 13);
@@ -44,7 +43,7 @@ void enable_spi(void)
// SPI.ctrl_mod.set(SPI0, 0xe0); // Set mosi and sck
SPI.ctrl_mod.all_clear.set(SPI0, 0);
- SPI.ctrl_mod.pin_enable.set(SPI0, 0x7); // Set mosi and sck
+ SPI.ctrl_mod.pin_enable.set(SPI0, 0x2); // Set mosi and sck
SPI.ctrl_cfg.auto_if.set(SPI0, 1);
SPI.ctrl_cfg.dma_enable.set(SPI0, OFF);
}
@@ -62,8 +61,11 @@ void enable_spi(void)
void dma_transfer(void* output_buffer, size_t len)
{
// Clear everything.
- SPI.ctrl_mod.all_clear.set(SPI0, 1);
- SPI.ctrl_mod.all_clear.set(SPI0, 0);
+ // SPI.ctrl_mod.all_clear.set(SPI0, 1);
+ // SPI.ctrl_mod.all_clear.set(SPI0, 0);
+ // SPI.ctrl_cfg.dma_enable.set(SPI0, OFF);
+
+ // printf("Start DMA: %p, %zu\n", output_buffer, len);
SPI.ctrl_mod.fifo_dir.set(SPI0, FIFO_DIR_OUTPUT);
SPI.dma_beg.set(SPI0, (uint32_t)output_buffer);