mirror of
https://github.com/sergeyyarkov/ch32v00x-template-mk.git
synced 2026-10-11 10:19:07 +03:00
blink prog
This commit is contained in:
parent
857d690136
commit
9a319bf9a5
25
src/main.c
25
src/main.c
@ -1,29 +1,24 @@
|
||||
#include "../platform/ch32v00x/debug.h"
|
||||
#include "ch32v00x_gpio.h"
|
||||
|
||||
int main(void) {
|
||||
SystemInit();
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure = {0};
|
||||
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||
|
||||
Delay_Init();
|
||||
Delay_Ms(1000);
|
||||
Delay_Ms(1000);
|
||||
#if (SDI_PRINT == SDI_PR_OPEN)
|
||||
SDI_Printf_Enable();
|
||||
#else
|
||||
USART_Printf_Init(115200);
|
||||
#endif
|
||||
printf("SystemClk:%d\r\n", SystemCoreClock);
|
||||
printf("ChipID:%08x\r\n", DBGMCU_GetCHIPID());
|
||||
|
||||
|
||||
while (1) {
|
||||
Delay_Ms(1000);
|
||||
GPIOA->OUTDR ^= GPIO_Pin_1;
|
||||
GPIO_ResetBits(GPIOD, GPIO_Pin_4);
|
||||
Delay_Ms(500);
|
||||
GPIO_SetBits(GPIOD, GPIO_Pin_4);
|
||||
Delay_Ms(500);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user