|
|
#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);
|
|
|
|
|
|
}
|