mirror of
https://github.com/jhbruhn/eurorack.git
synced 2025-03-15 11:05:49 +00:00
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
|
#include <stm32f0xx_hal.h>
|
||
|
#include <stm32f0xx_ll_bus.h>
|
||
|
#include <stm32f0xx_ll_system.h>
|
||
|
|
||
|
#include "stmlib/system/bootloader_utils.h"
|
||
|
#include "stmlib/system/system_clock.h"
|
||
|
|
||
|
using namespace stmlib;
|
||
|
|
||
|
extern "C" void __cxa_pure_virtual()
|
||
|
{
|
||
|
while (1)
|
||
|
;
|
||
|
}
|
||
|
|
||
|
extern "C" {
|
||
|
void Error_Handler(void)
|
||
|
{
|
||
|
while (1)
|
||
|
;
|
||
|
}
|
||
|
void SysTick_Handler()
|
||
|
{
|
||
|
system_clock.Tick();
|
||
|
}
|
||
|
void SystemClock_Config(void)
|
||
|
{
|
||
|
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
|
||
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
|
||
|
|
||
|
/** Initializes the CPU, AHB and APB busses clocks
|
||
|
*/
|
||
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI14 | RCC_OSCILLATORTYPE_HSE;
|
||
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||
|
RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
|
||
|
RCC_OscInitStruct.HSI14CalibrationValue = 16;
|
||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
|
||
|
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
|
||
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||
|
Error_Handler();
|
||
|
}
|
||
|
/** Initializes the CPU, AHB and APB busses clocks
|
||
|
*/
|
||
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
|
||
|
| RCC_CLOCKTYPE_PCLK1;
|
||
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||
|
|
||
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
|
||
|
Error_Handler();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
const uint32_t kStartAddress = 0x08002000;
|
||
|
int main(void)
|
||
|
{
|
||
|
HAL_Init();
|
||
|
SystemClock_Config();
|
||
|
|
||
|
// todo: do bootloader things
|
||
|
HAL_DeInit();
|
||
|
Uninitialize();
|
||
|
__disable_irq();
|
||
|
JumpTo(kStartAddress);
|
||
|
}
|