CH32V00x/User/main.c

69 lines
1.8 KiB
C
Raw Normal View History

2023-01-22 14:31:21 -05:00
/********************************** (C) COPYRIGHT *******************************
* File Name : main.c
* Author : WCH
* Version : V1.0.0
* Date : 2022/08/08
* Description : Main program body.
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
#include "debug.h"
/* Global define */
/* Global Variable */
2023-01-22 14:31:21 -05:00
/*********************************************************************
* @fn GPIO_Toggle_INIT
2023-01-22 14:31:21 -05:00
*
* @brief Initializes GPIOD.4
2023-01-22 14:31:21 -05:00
*
* @return none
*/
void GPIO_LED_Init(void) {
GPIO_InitTypeDef GPIO_InitStructure = {0};
2023-01-22 14:31:21 -05:00
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
2024-01-05 06:18:32 -05:00
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
2023-01-22 14:31:21 -05:00
GPIO_Init(GPIOD, &GPIO_InitStructure);
}
/*********************************************************************
* @fn main
*
* @brief Main program.
*
* @return none
*/
int main(void) {
2024-03-20 23:18:08 -04:00
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
SystemCoreClockUpdate();
2023-01-22 14:31:21 -05:00
Delay_Init();
#if (SDI_PRINT == SDI_PR_OPEN)
SDI_Printf_Enable();
#else
2023-01-22 14:31:21 -05:00
USART_Printf_Init(115200);
#endif
printf("SystemClk: %ld\r\n", SystemCoreClock);
2023-11-26 04:52:09 -05:00
printf("DeviceID: %08lx\r\n", DBGMCU_GetDEVID());
printf("ChipID: %08lx\r\n", DBGMCU_GetCHIPID());
GPIO_LED_Init();
while(1) {
Delay_Ms(1000);
printf("On\r\n");
GPIO_WriteBit(GPIOD, GPIO_Pin_4, Bit_SET);
Delay_Ms(1000);
printf("Off\r\n");
GPIO_WriteBit(GPIOD, GPIO_Pin_4, Bit_RESET);
2023-01-22 14:31:21 -05:00
}
}