Rename MCU
This commit is contained in:
parent
ed2925a961
commit
64a01bef05
75 changed files with 4 additions and 4 deletions
56
stm32f103t8u6/src/main.c
Normal file
56
stm32f103t8u6/src/main.c
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include "main.h"
|
||||
|
||||
static void Clock_Init(void)
|
||||
{
|
||||
// Activate HSE and wait for it to be ready
|
||||
RCC->CR = RCC_CR_HSEON;
|
||||
while(!(RCC->CR & RCC_CR_HSERDY));
|
||||
|
||||
RCC->CFGR = RCC_CFGR_SW_0;
|
||||
while((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_0);
|
||||
|
||||
FLASH->ACR |= FLASH_ACR_LATENCY_1;
|
||||
|
||||
// Set PLL to x9 (-> 72MHz system clock)
|
||||
RCC->CFGR |= RCC_CFGR_PLLMULL9 | RCC_CFGR_PLLSRC | RCC_CFGR_PPRE1_2;
|
||||
|
||||
// Activate PLL and wait
|
||||
RCC->CR |= RCC_CR_PLLON;
|
||||
while(!(RCC->CR & RCC_CR_PLLRDY));
|
||||
|
||||
// Select PLL as clock source
|
||||
RCC->CFGR = (RCC->CFGR & ~RCC_CFGR_SW) | RCC_CFGR_SW_1;
|
||||
|
||||
// Resulting clocks:
|
||||
// SYSCLK, AHB, APB2 72 Mhz
|
||||
// APB1, ADC 36 MHz
|
||||
#if (CLOCK_SYSCLK != 72000000) || (CLOCK_AHB != 72000000) \
|
||||
|| (CLOCK_APB1 != 36000000) || (CLOCK_APB2 != 72000000)
|
||||
#error Clock initialisation does not match definitions in clock.h.
|
||||
#endif
|
||||
|
||||
// Disable all interrupts
|
||||
RCC->CIR = 0x00000000;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Clock_Init();
|
||||
LED_Init();
|
||||
USB_Init();
|
||||
Output_Init();
|
||||
|
||||
LED_ON();
|
||||
|
||||
// uint8_t buffer[32];
|
||||
for(;;)
|
||||
{
|
||||
// int length = USBCDC_ReceiveData(buffer, sizeof(buffer));
|
||||
// if(length)
|
||||
// {
|
||||
// USBCDC_SendData(buffer, length);
|
||||
// }
|
||||
// __WFI();
|
||||
HPGL_Poll();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue