📄 main.c
字号:
#include "stm32f10x_lib.h"
#include "LCD12864.h"
#include "SPI1.h"
void RCC_Config(void);
void NVIC_Config(void);
int main(void)
{
RCC_Config();
NVIC_Config();
SPI1_Config();
LCD12864_Init();
LCD12864_PutString(1,0, "Hello");
while(1){
}
}
//******************************************************************************
// Function Name : RCC_Configuration
// Description : Reset and Clock Control configuration
// Input : None
// Output : None
// Return : None
//******************************************************************************
void RCC_Config(void)
{
ErrorStatus HSEStartUpStatus;
// Reset the RCC clock configuration to default reset state
RCC_DeInit();
// Configures the High Speed External oscillator
RCC_HSEConfig(RCC_HSE_ON);
// Waits for HSE start-up
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
// Enable Prefetch Buffer
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
// Sets the code latency value: FLASH Two Latency cycles
FLASH_SetLatency(FLASH_Latency_2);
// Configures the AHB clock(HCLK): HCLK = SYSCLK
RCC_HCLKConfig(RCC_SYSCLK_Div1);
// Configures the High Speed APB clcok(PCLK2): PCLK2 = HCLK
RCC_PCLK2Config(RCC_HCLK_Div1);
// Configures the Low Speed APB clock(PCLK1): PCLK1 = HCLK/2
RCC_PCLK1Config(RCC_HCLK_Div2);
// Configures the PLL clock source and multiplication factor
// PLLCLK = HSE*PLLMul = 8*9 = 72MHz
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
// Enable PLL
RCC_PLLCmd(ENABLE);
// Checks whether the specified RCC flag is set or not
// Wait till PLL is ready
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
// Select PLL as system clock source
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
// Get System Clock Source
// Wait till PLL is used as system clock source
while(RCC_GetSYSCLKSource() != 0x08);
}
}
//******************************************************************************
// Function Name : NVIC_Configuration
// Description : Nested Vectored Interrupt Controller configuration
// Input : None
// Output : None
// Return : None
//******************************************************************************
void NVIC_Config(void)
{
#ifdef VECT_TAB_RAM
// Set the Vector Tab base at location at 0x20000000
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else
// Set the Vector Tab base at location at 0x80000000
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -