建立完工程各项准备终于可以开始项目了,首先准备熟悉一下开发板按列子实现LED和按键功能,
1。分别修改编写2个功能文件,需要配置好SysTick及相关文件按开发板修改调用这些初始化文件
/* ÅäÖÃconfigure systick */
systick_config();
EvbLedConfig();
EvbKeyConfigPoll();
- #include "350dx_led.h"
- #include "350dx_uart.h"
- #include "350dx_key.h"
- #include "systick.h"
- #include "main.h"
- #include <stdio.h>
- #include "gd32f3x0_rcu.h"
- //#include "gd32f3x0.h"
- //#include "gd32f3x0_it.h"
- void led_spark(void)
- { //呼吸灯
- static __IO uint32_t timingdelaylocal = 0U;
- if(timingdelaylocal){
- if(timingdelaylocal < 500U){
- EvbLedControl(LED1, LED_ON);
- EvbLedControl(LED2, LED_ON);
- EvbLedControl(LED3, LED_ON);
- }else{
- EvbLedControl(LED1, LED_OFF);
- EvbLedControl(LED2, LED_OFF);
- EvbLedControl(LED3, LED_OFF);
- }
- timingdelaylocal--;
- }else{
- timingdelaylocal = 1000U;
- }
- } // */
- int main(void)
- {
- int i;
- /* 配置configure systick */
- systick_config();
- EvbLedConfig(); //初始化LED
- EvbKeyConfigPoll(); //初始化按键
-
-
- rcu_ckout_config(RCU_CKOUTSRC_CKSYS, RCU_CKOUT_DIV1);
- while(1)
- {
- delay_1ms(500); //500 X 1ms=500ms,1000u时
- //for (i =0; i<0xffffff; i++); //延时
- EvbLedControl(LED1, LED_ON);
- EvbLedControl(LED2, LED_ON);
- EvbLedControl(LED3, LED_ON);
-
- delay_1ms(500);
- // for (i =0; i<0xffffff; i++); //延时
- EvbLedControl(LED1, LED_OFF);
- EvbLedControl(LED2, LED_OFF);
- EvbLedControl(LED3, LED_OFF);
-
- //EvbUart1WriteStr("Hello ZhanglinGD32F\r");
- if (EvbKeyScanPoll() == 1) //按键是否按下
- {
- EvbLedControl(LED1, LED_ON);
- EvbLedControl(LED2, LED_ON);
- EvbLedControl(LED3, LED_ON);
- }
- //else
- }
- // return 1;
- }