diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-02-27 14:39:18 +0100 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-02-27 14:39:18 +0100 |
commit | b489a1b12f2f574ed24237601b3797b58d302196 (patch) | |
tree | fe9bbd687c6ea9d3fe4f453f3419810f3c7e9ad4 /controller/fw/main.c | |
parent | fcbdab4ab27e83acf0ed721583db4ddbf6222341 (diff) | |
download | master-thesis-b489a1b12f2f574ed24237601b3797b58d302196.tar.gz master-thesis-b489a1b12f2f574ed24237601b3797b58d302196.tar.bz2 master-thesis-b489a1b12f2f574ed24237601b3797b58d302196.zip |
Add a bunch of deps
Diffstat (limited to 'controller/fw/main.c')
-rw-r--r-- | controller/fw/main.c | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/controller/fw/main.c b/controller/fw/main.c deleted file mode 100644 index 3131df1..0000000 --- a/controller/fw/main.c +++ /dev/null @@ -1,76 +0,0 @@ - -#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) -{ - rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); - rcc_periph_clock_enable(RCC_GPIOA); - rcc_periph_clock_enable(RCC_GPIOB); - rcc_periph_clock_enable(RCC_SPI1); -} - -static void led_setup(void) -{ - gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO6 | GPIO7); -} - -static void spi_flash_if_set_cs(bool val) { - if (val) - gpio_set(GPIOB, GPIO0); - else - gpio_clear(GPIOB, GPIO0); -} - -static void spi_flash_setup(void) -{ - gpio_mode_setup(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO3 | GPIO4 | GPIO5); /* SPI flash SCK/MISO/MOSI */ - gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO0); /* SPI flash CS */ - gpio_set_output_options(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO0 | GPIO3 | GPIO4 | GPIO5); - gpio_set_af(GPIOB, 5, GPIO3 | GPIO4 | GPIO5); - - 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) -{ - clock_setup(); - led_setup(); - spi_flash_setup(); - - gpio_set(GPIOA, GPIO6); - - while (1) { - gpio_toggle(GPIOA, GPIO6 | GPIO7); - for (int i = 0; i < 6000000; i++) - __asm__("nop"); - } - - return 0; -} |