NULL
This commit is contained in:
82
user/MCU/lhl_systemclock.c
Executable file
82
user/MCU/lhl_systemclock.c
Executable file
@@ -0,0 +1,82 @@
|
||||
#include "../main/SystemInclude.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief ϵͳʱ<CDB3>ӳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @note <20><><EFBFBD><EFBFBD>оƬʱ<C6AC><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>(HSI) 16MHz <20><>Ϊϵͳʱ<CDB3><CAB1>Դ<EFBFBD><D4B4>
|
||||
* HCLK = 4MHz<48><7A>APB1/APB2 ʱ<>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD> HCLK<4C><4B>
|
||||
* @param <20><>
|
||||
* @example SystemClockConfiguration();
|
||||
*/
|
||||
void SystemClockConfiguration(void)
|
||||
{
|
||||
RCC_ClockInitTypeDef Clock_InitStructure;
|
||||
Clock_InitStructure.SYSCLKSource = RCC_SYSCLK_SRC_HSI_DIV2; // SYSCLK = 32M/2 = 16MHz
|
||||
Clock_InitStructure.AHBCLKDivider = RCC_SYSCLK_DIV4; // PCLK = SYSCLK/4 = 4MHz
|
||||
Clock_InitStructure.APB1CLKDivider = RCC_HCLK_DIV1; // PCLK1 = HCLK
|
||||
Clock_InitStructure.APB2CLKDivider = RCC_HCLK_DIV1; // PCKL2 = HCLK
|
||||
if (LHL_RCC_ClockConfig(&Clock_InitStructure, LHL_NRM_TIMEOUT) != LHL_OK)
|
||||
{
|
||||
while(1); // Error Handler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(MCO)<29><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @note <20><><EFBFBD><EFBFBD> P0.4 <20><><EFBFBD><EFBFBD>Ϊ ECLKOUT <20><><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡʱ<D1A1><CAB1>Դ<EFBFBD>źţ<C5BA>
|
||||
* <20><>ǰʹ<C7B0><CAB9> PCLK1 <20><>Ϊ MCO <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>
|
||||
* @param <20><>
|
||||
* @example System_MCO_Config();
|
||||
*/
|
||||
void System_MCO_Config(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
#if 0 //set p2.2 is MCO
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Current = GPIO_CURRENT_16mA;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.SchmittTrigger = ENABLE;
|
||||
GPIO_InitStruct.Alternate = GPIO2_2_AF_ECLKOUT; // AFΪ
|
||||
LHL_GPIO_Init(pGPIO2, &GPIO_InitStruct);
|
||||
|
||||
#endif
|
||||
#if 1 //set p0.4 is ECLKOUT
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Current = GPIO_CURRENT_16mA;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.SchmittTrigger = ENABLE;
|
||||
GPIO_InitStruct.Alternate = GPIO0_4_AF_ECLKOUT; // AFΪ
|
||||
LHL_GPIO_Init(pGPIO0, &GPIO_InitStruct);
|
||||
#endif
|
||||
|
||||
|
||||
/** RCC_MCOSOURCE_LSI
|
||||
* RCC_MCOSOURCE_SYSCLK
|
||||
* RCC_MCOSOURCE_HSI
|
||||
* RCC_MCOSOURCE_HSE
|
||||
* RCC_MCOSOURCE_PLL_DIV2
|
||||
* RCC_MCOSOURCE_PCLK1
|
||||
* RCC_MCOSOURCE_PCLK2
|
||||
* RCC_MCOSOURCE_HCLK */
|
||||
LHL_RCC_MCOConfig(RCC_MCOSOURCE_PCLK1);//ѡ<><D1A1><EFBFBD><EFBFBD>ʼʱ<CABC><CAB1>Դ
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void disable_interrupts(void)
|
||||
{
|
||||
// __disable_irq();
|
||||
}
|
||||
|
||||
void enable_interrupts(void)
|
||||
{
|
||||
// __enable_irq();
|
||||
}
|
||||
|
||||
void ResetSystem(void)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user