73 lines
2 KiB
C
73 lines
2 KiB
C
/* Megumin LED display firmware
|
|
* Copyright (C) 2018 Sebastian Götte <code@jaseg.net>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "global.h"
|
|
|
|
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_PPRE_Msk & ~RCC_CFGR_HPRE_Msk;
|
|
RCC->CFGR |= ((12-2)<<RCC_CFGR_PLLMUL_Pos); /* PLL / 2 * 12 -> 48.0MHz */
|
|
RCC->CR |= RCC_CR_PLLON;
|
|
while (!(RCC->CR&RCC_CR_PLLRDY));
|
|
RCC->CFGR |= (2<<RCC_CFGR_SW_Pos);
|
|
SystemCoreClockUpdate();
|
|
|
|
/* Turn on lots of neat things */
|
|
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
|
|
|
|
GPIOA->MODER |=
|
|
(1<<GPIO_MODER_MODER0_Pos)
|
|
| (1<<GPIO_MODER_MODER1_Pos);
|
|
|
|
int cnt = 0;
|
|
int ph = 0;
|
|
while (42) {
|
|
if (cnt > 5000) {
|
|
cnt = 0;
|
|
ph += 1;
|
|
ph %= 4;
|
|
} else {
|
|
cnt = cnt+1;
|
|
}
|
|
switch (ph) {
|
|
case 0: GPIOA->ODR = 1; break;
|
|
case 1: GPIOA->ODR = 3; break;
|
|
case 2: GPIOA->ODR = 2; break;
|
|
case 3: GPIOA->ODR = 0; break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void NMI_Handler(void) {
|
|
asm volatile ("bkpt");
|
|
}
|
|
|
|
void HardFault_Handler(void) __attribute__((naked));
|
|
void HardFault_Handler() {
|
|
asm volatile ("bkpt");
|
|
}
|
|
|
|
void SVC_Handler(void) {
|
|
asm volatile ("bkpt");
|
|
}
|
|
|
|
|
|
void PendSV_Handler(void) {
|
|
asm volatile ("bkpt");
|
|
}
|
|
|