36 #pragma GCC optimize ("O2") 69 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) 70 SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));
92 volatile unsigned *dest = &
_sccm;
94 #if 0 // no support for initialized data in CCM 96 while (dest < &_eccm) {
100 while (dest < &_eccm) {
109 asm volatile (
"mov %0, sp\n\t" :
"=rm" (sp) );
111 #if 0 // memset is much faster but uses too much stack for own needs 112 memset((
void *)dest,0x55, (sp-(uint32_t)dest) -128);
114 while ((uint32_t)dest < (sp-8)) {
115 *dest++ = 0x55555555;
126 NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4);
143 PWR->CR |= PWR_CR_DBP;
145 RTC_WriteBackupRegister(reg, sig);
147 PWR->CR &= ~PWR_CR_DBP;
154 PWR->CR |= PWR_CR_DBP;
156 uint32_t ret = RTC_ReadBackupRegister(reg);
158 PWR->CR &= ~PWR_CR_DBP;
170 RCC->APB1ENR |= RCC_APB1ENR_PWREN;
171 RCC->AHB1ENR |= RCC_AHB1ENR_BKPSRAMEN;
172 PWR_BackupAccessCmd(ENABLE);
174 RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
175 RCC_RTCCLKCmd(ENABLE);
178 RCC->BDCR |= RCC_BDCR_RTCEN;
180 RTC_WriteProtectionCmd(DISABLE);
181 for(
volatile int i=0; i<50; i++);
185 for(
volatile int i=0; i<50; i++);
193 bool overclock_failed =
false;
199 overclock_failed =
true;
201 overclock_failed =
true;
230 DBGMCU->CR |= DBGMCU_STANDBY | DBGMCU_STOP | DBGMCU_SLEEP;
231 DBGMCU->APB1FZ |= DBGMCU_TIM4_STOP | DBGMCU_TIM5_STOP | DBGMCU_TIM7_STOP;
232 DBGMCU->APB2FZ |= DBGMCU_TIM10_STOP | DBGMCU_TIM11_STOP;
242 if(!overclock_failed) {
261 for (i=4000; i!=0; i--) {
262 asm volatile(
"nop \n");
272 RCC->CIR |= RCC_CIR_CSSC;
279 RCC_HSEConfig(RCC_HSE_ON);
283 if (RCC_WaitForHSEStartUp() == SUCCESS){
302 RCC->APB1ENR |= RCC_APB1ENR_PWREN;
303 PWR->CR |= PWR_CR_PMODE;
306 RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
309 RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
312 RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
315 RCC->PLLCFGR =
PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
316 (RCC_PLLCFGR_PLLSRC_HSI) | (
PLL_Q << 24);
319 RCC->CR |= RCC_CR_PLLON;
322 while((RCC->CR & RCC_CR_PLLRDY) == 0) { }
325 RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
326 RCC->CFGR |= RCC_CFGR_SW_PLL;
#define OV_GUARD_FAIL_SIGNATURE
int usb_configure(usb_attr_t *attr)
void SystemCoreClockUpdate(void)
Update SystemCoreClock variable according to Clock Register Values. The SystemCoreClock variable cont...
static INLINE void interrupts()
void init(void)
Generic board initialization function.
void emerg_delay(uint32_t n)
void stopwatch_init(void)
#define RTC_OVERCLOCK_REG
#define OVERCLOCK_SIG_MASK
const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS]
#define OV_GUARD_SIGNATURE
static void setupCCM(void)
#define SYSTICK_RELOAD_VAL
void SetSysClock(uint8_t oc)
Configures the System clock source, PLL Multiplier and Divider factors, AHB/APBx prescalers and Flash...
static usb_attr_t * usb_attr
Board-specific pin information.
void boardInit(void)
Board-specific initialization code.
static void setupNVIC(void)
Generic board initialization routines.
const gpio_dev * present_port
uint32_t board_get_rtc_register(uint16_t reg)
void board_set_rtc_register(uint32_t sig, uint16_t reg)
#define DFU_RTC_SIGNATURE
static void enableFPU(void)
#define RTC_SIGNATURE_REG
#define OVERCLOCK_SIGNATURE
void systemInit(uint8_t oc)
Setup the microcontroller system Initialize the Embedded Flash Interface, the PLL and update the Syst...
void usb_default_attr(usb_attr_t *attr)
const gpio_dev *const gpio_device
void systick_init(uint32_t reload_val)
Initialize and enable SysTick.