cpuinit.c
57 lines
| 1.4 KiB
| text/x-c
|
CLexer
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
|
r18 | #include "stm32f4xx.h" | ||
#include <stdint.h> | ||||
#include <stdlib.h> | ||||
#include <stdio.h> | ||||
#include <bsp.h> | ||||
#include <stm32f4xx_rcc.h> | ||||
jeandet@PC-DE-JEANDET.lab-lpp.local
|
r22 | #include <core.h> | ||
extern int main(); | ||||
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
|
r18 | |||
void cpu_init() | ||||
{ | ||||
extern uint32_t currentCpuFreq; | ||||
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
|
r37 | currentCpuFreq = 160000000; | ||
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
|
r18 | enable_FPU(); | ||
RCC->CR |= (uint32_t)0x00000001; | ||||
FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS; | ||||
reset_AHB1(); | ||||
reset_AHB2(); | ||||
reset_APB1(); | ||||
reset_APB2(); | ||||
RCC->CR |= (uint32_t)0x00000001; | ||||
FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS; | ||||
RCC->CFGR = 0x00000000; | ||||
RCC->CIR = 0x00000000; | ||||
SCB->VTOR = FLASH_BASE; | ||||
RCC->APB1ENR |= RCC_APB1ENR_PWREN; | ||||
PWR->CR |= PWR_CR_PMODE; | ||||
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
|
r23 | currentCpuFreq=setCpuFreq(currentCpuFreq); | ||
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
|
r18 | bsp_init(); | ||
RCC_ClocksTypeDef RCC_ClocksStatus; | ||||
RCC_GetClocksFreq(&RCC_ClocksStatus); | ||||
printf("PLL Configured got:\n\r SYS=%uHz\n\r CPU=%uHz\n\r APB1=%uHz\n\r APB2=%uHz\n\r",(unsigned int)RCC_ClocksStatus.SYSCLK_Frequency,(unsigned int)RCC_ClocksStatus.HCLK_Frequency,(unsigned int)RCC_ClocksStatus.PCLK1_Frequency,(unsigned int)RCC_ClocksStatus.PCLK2_Frequency); | ||||
printf("Enter Main\n\r"); | ||||
int res=main(); | ||||
printf("\n\rprogram exited with code "); | ||||
printf("%u",res); | ||||
printf("\n\r"); | ||||
while(1) | ||||
{ | ||||
for(volatile int i=0;i<1024*64;i++); | ||||
gpioset(PD14); | ||||
for(volatile int i=0;i<1024*64;i++); | ||||
gpioclr(PD14); | ||||
} | ||||
} | ||||