mirror of
https://github.com/IcedRooibos/py32f0-template.git
synced 2025-10-29 00:42:06 -07:00
89 lines
2.5 KiB
C
89 lines
2.5 KiB
C
/**
|
|
******************************************************************************
|
|
* @file main.c
|
|
* @author MCU Application Team
|
|
* @brief Main program body
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
|
* All rights reserved.</center></h2>
|
|
*
|
|
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
* All rights reserved.</center></h2>
|
|
*
|
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
* the "License"; You may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at:
|
|
* opensource.org/licenses/BSD-3-Clause
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "main.h"
|
|
#include "py32f0xx_bsp_button.h"
|
|
#include "py32f0xx_bsp_led.h"
|
|
#include "py32f0xx_bsp_printf.h"
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
/* Private variables ---------------------------------------------------------*/
|
|
/* Private user code ---------------------------------------------------------*/
|
|
/* Private macro -------------------------------------------------------------*/
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
static void APP_SystemClockConfig(void);
|
|
static void APP_GpioConfig(void);
|
|
|
|
|
|
int main(void)
|
|
{
|
|
APP_SystemClockConfig();
|
|
|
|
APP_GpioConfig();
|
|
|
|
while (1)
|
|
{
|
|
LL_mDelay(500);
|
|
LL_GPIO_TogglePin(GPIOB,LL_GPIO_PIN_5);
|
|
}
|
|
}
|
|
|
|
static void APP_SystemClockConfig(void)
|
|
{
|
|
LL_RCC_HSI_Enable();
|
|
while(LL_RCC_HSI_IsReady() != 1);
|
|
|
|
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
|
|
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSISYS);
|
|
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSISYS);
|
|
|
|
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
|
|
LL_Init1msTick(8000000);
|
|
LL_SetSystemCoreClock(8000000);
|
|
}
|
|
|
|
/**
|
|
* @brief 配置GPIO
|
|
* @param 无
|
|
* @retval 无
|
|
*/
|
|
static void APP_GpioConfig(void)
|
|
{
|
|
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
|
|
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_5, LL_GPIO_MODE_OUTPUT);
|
|
}
|
|
|
|
void APP_ErrorHandler(void)
|
|
{
|
|
while (1);
|
|
}
|
|
|
|
#ifdef USE_FULL_ASSERT
|
|
void assert_failed(uint8_t *file, uint32_t line)
|
|
{
|
|
while (1);
|
|
}
|
|
#endif /* USE_FULL_ASSERT */
|
|
|
|
/************************ (C) COPYRIGHT Puya *****END OF FILE******************/
|