/* Includes ------------------------------------------------------------------*/
#include "gd32f1x0.h"
#include <stdio.h>
#include "systick.h"
/* Private functions ---------------------------------------------------------*/
/**
* @brief Configure the GPIO ports.
* @param None
* @retval None
*/
void delay(int x)
{
int i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void LED_config(void)
{
GPIO_InitPara GPIO_InitStructure;
RCC_APB2PeriphClock_Enable(RCC_APB2Periph_GPIOC,ENABLE);
//RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_GPIOB,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_6;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_2MHZ;
GPIO_InitStructure.GPIO_OType = GPIO_OTYPE_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PUPD_NOPULL;
GPIO_Init(GPIOC,&GPIO_InitStructure);
}
/**
* @brief Toggle the LED every 500ms.
* @param None
* @retval None
*/
void LED_Spark(void)
{
/* static __IO uint32_t TimingDelayLocal = 0;
if (TimingDelayLocal != 0x00)
{
if(TimingDelayLocal < 500)
{
GPIO_ResetBits(GPIOB, GPIO_PIN_9);
}
else
{
GPIO_SetBits(GPIOB,GPIO_PIN_9);
}
TimingDelayLocal--;
}
else
{
TimingDelayLocal = 1000;
}
//GPIO_SetBits(GPIOB,GPIO_PIN_15);*/
}
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
LED_config();
GPIO_SetBits(GPIOC,GPIO_PIN_6);
delay(500);
GPIO_ResetBits(GPIOC,GPIO_PIN_6);
//LED_Spark();
SysTick_Configuration();
while (1)
{
}
}
由于文件太大,沾不上来,我就把主函数拿出来,各位大神帮我看看为什么驱动不了LED,用的是GD32F103RCT6芯片,程序编译时没有问题,程序是以前用ST时的程序改的,在ST板子上能正常运行,谢谢各位大神,求指教
|