summaryrefslogtreecommitdiff
path: root/controller/fw/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'controller/fw/main.c')
-rw-r--r--controller/fw/main.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/controller/fw/main.c b/controller/fw/main.c
index 846aa8c..3131df1 100644
--- a/controller/fw/main.c
+++ b/controller/fw/main.c
@@ -2,8 +2,11 @@
#include <stdbool.h>
#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/spi.h>
#include <libopencm3/stm32/gpio.h>
+#include "spi_flash.h"
+
static struct spi_flash_if spif;
static void clock_setup(void)
@@ -33,8 +36,27 @@ static void spi_flash_setup(void)
gpio_set_output_options(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO0 | GPIO3 | GPIO4 | GPIO5);
gpio_set_af(GPIOB, 5, GPIO3 | GPIO4 | GPIO5);
- spi_init(&spif, SPI1, &spi_flash_if_set_cs);
+ spif_init(&spif, 256, SPI1, &spi_flash_if_set_cs);
+}
+
+/*
+void spi_flash_test(void) {
+ spif_clear_mem(&spif);
+
+ uint32_t buf[1024];
+ for (size_t addr=0; addr<0x10000; addr += sizeof(buf)) {
+ for (size_t i=0; i<sizeof(buf); i+= sizeof(buf[0]))
+ buf[i/sizeof(buf[0])] = addr + i;
+
+ spif_write(&spif, addr, sizeof(buf), (char *)buf);
+ }
+
+ for (size_t i=0; i<sizeof(buf)/sizeof(buf[0]); i++)
+ buf[i] = 0;
+ spif_read(&spif, 0x1030, sizeof(buf), (char *)buf);
+ asm volatile ("bkpt");
}
+*/
int main(void)
{