diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-02-26 13:40:37 +0100 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-02-26 13:40:37 +0100 |
commit | fcbdab4ab27e83acf0ed721583db4ddbf6222341 (patch) | |
tree | 4961086fc593dd734619ebd4a3ad79b005dca934 /controller/fw/main.c | |
parent | 2964bda23c98b81b6853f542e98fb3d55dafa14c (diff) | |
download | master-thesis-fcbdab4ab27e83acf0ed721583db4ddbf6222341.tar.gz master-thesis-fcbdab4ab27e83acf0ed721583db4ddbf6222341.tar.bz2 master-thesis-fcbdab4ab27e83acf0ed721583db4ddbf6222341.zip |
demo: SPI Flash interface working
Diffstat (limited to 'controller/fw/main.c')
-rw-r--r-- | controller/fw/main.c | 24 |
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) { |