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-11-26 01:48:12 -05:00
|
|
|
|
2023-01-22 14:31:21 -05:00
|
|
|
|
|
|
|
/*********************************************************************
|
2023-11-26 01:48:12 -05:00
|
|
|
* @fn GPIO_Toggle_INIT
|
2023-01-22 14:31:21 -05:00
|
|
|
*
|
2023-11-26 01:48:12 -05:00
|
|
|
* @brief Initializes GPIOD.4
|
2023-01-22 14:31:21 -05:00
|
|
|
*
|
|
|
|
* @return none
|
|
|
|
*/
|
2023-11-26 01:48:12 -05:00
|
|
|
void GPIO_LED_Init(void) {
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure = {0};
|
2023-01-22 14:31:21 -05:00
|
|
|
|
2023-11-26 01:48:12 -05:00
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
|
|
|
|
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
|
|
|
|
*/
|
2023-11-26 01:48:12 -05:00
|
|
|
int main(void) {
|
2023-01-22 14:31:21 -05:00
|
|
|
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
2023-11-26 01:48:12 -05:00
|
|
|
SystemCoreClockUpdate();
|
2023-01-22 14:31:21 -05:00
|
|
|
Delay_Init();
|
2023-11-26 01:48:12 -05:00
|
|
|
#if (SDI_PRINT == SDI_PR_OPEN)
|
|
|
|
SDI_Printf_Enable();
|
|
|
|
#else
|
2023-01-22 14:31:21 -05:00
|
|
|
USART_Printf_Init(115200);
|
2023-11-26 01:48:12 -05:00
|
|
|
#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());
|
2023-11-26 01:48:12 -05:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|