From 84de029e74859d98c82047b04b62d87a35d12a27 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 10 Jun 2017 19:14:18 +0200 Subject: fw working commit --- fw/main.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 fw/main.c (limited to 'fw/main.c') diff --git a/fw/main.c b/fw/main.c new file mode 100644 index 0000000..d29ef9e --- /dev/null +++ b/fw/main.c @@ -0,0 +1,98 @@ + +#include +#include +#include +#include +#include +#include +/* + * Part number: STM32F030F4C6 + */ + +void tick(void) { + for(int i=0; i<50; i++) + __asm__("nop"); +} + +int main(void) { + RCC->CR |= RCC_CR_HSEON; + while (!(RCC->CR&RCC_CR_HSERDY)); + RCC->CFGR &= ~RCC_CFGR_PLLMUL_Msk & ~RCC_CFGR_SW_Msk; + RCC->CFGR |= (2<CFGR2 &= ~RCC_CFGR2_PREDIV_Msk; /* PREDIV=0 */ + RCC->CR |= RCC_CR_PLLON; + while (!(RCC->CR&RCC_CR_PLLRDY)); + RCC->CFGR |= (2<AHBENR |= RCC_AHBENR_GPIOAEN; + RCC->APB2ENR |= RCC_APB2ENR_SPI1EN; + + GPIOA->MODER |= + (2<OSPEEDR |= + (3<AFR[0] |= + (0<CR1 = SPI_CR1_SSM | SPI_CR1_SSI | SPI_CR1_SPE | (7<CR2 = (7<DR = 1<DR = 0; + } + while (SPI1->SR & SPI_SR_BSY); + tick(); + } + pos2 += 1; + if (pos2 == 8) { + pos2 = 0; + pos1 += 1; + if (pos1 == 6) + pos1 = 0; + } + /* Strobe both LED drivers and aux regs */ + GPIOA->BSRR = GPIO_BSRR_BS_9 | GPIO_BSRR_BS_10; + tick(); + GPIOA->BSRR = GPIO_BSRR_BR_9 | GPIO_BSRR_BR_10; + LL_mDelay(1); + } +} + +void NMI_Handler(void) { +} + +void HardFault_Handler(void) { + for(;;); +} + +void SVC_Handler(void) { +} + + +void PendSV_Handler(void) { +} + +void SysTick_Handler(void) { +} + -- cgit