You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
incubator_embeded/HARDWARE/OSC.c

41 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "stm32f10x.h" // Device header
#include "USART.h"
#include "SysTick.h"
//GPIO4->PD1 GPIO5->PD0
//PD0->OSC_IN,只能配置为输入PD1->OSC_OUT,只能配置为输出;
void OSC_Init(void)
{
// GPIO_InitTypeDef GPIO_InitStructure;
//
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE); /*开启时钟*/
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);/*开启复用的外设时钟使能*/
// GPIO_PinRemapConfig(GPIO_Remap_PD01,ENABLE);/*映射PD01的使能*/
//GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);//关闭jtag使能SWD可以用SWD模式调试
//
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; /*浮空输入*/
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
// GPIO_Init(GPIOD, &GPIO_InitStructure);
//
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE); /*开启时钟*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);/*开启复用的外设时钟使能*/
GPIO_PinRemapConfig(GPIO_Remap_PD01,ENABLE);/*映射PD01的使能*/
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);//关闭jtag使能SWD可以用SWD模式调试
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_ResetBits(GPIOD,GPIO_Pin_0);
GPIO_ResetBits(GPIOD,GPIO_Pin_1);
}