#include "main.h"
#include "gpio.h"
#define led0on HAL_GPIO_WritePin(GPIOC,GPIO_PIN_0, GPIO_PIN_RESET)
#define led1on HAL_GPIO_WritePin(GPIOC,GPIO_PIN_1, GPIO_PIN_RESET)
#define led2on HAL_GPIO_WritePin(GPIOC,GPIO_PIN_2, GPIO_PIN_RESET)
#define led3on HAL_GPIO_WritePin(GPIOC,GPIO_PIN_3, GPIO_PIN_RESET)
#define led4on HAL_GPIO_WritePin(GPIOC,GPIO_PIN_4, GPIO_PIN_RESET)
#define led5on HAL_GPIO_WritePin(GPIOC,GPIO_PIN_5, GPIO_PIN_RESET)
#define led6on HAL_GPIO_WritePin(GPIOC,GPIO_PIN_6, GPIO_PIN_RESET)
#define led7on HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7, GPIO_PIN_RESET)
#define led0off HAL_GPIO_WritePin(GPIOC,GPIO_PIN_0, GPIO_PIN_SET)
#define led1off HAL_GPIO_WritePin(GPIOC,GPIO_PIN_1, GPIO_PIN_SET)
#define led2off HAL_GPIO_WritePin(GPIOC,GPIO_PIN_2, GPIO_PIN_SET)
#define led3off HAL_GPIO_WritePin(GPIOC,GPIO_PIN_3, GPIO_PIN_SET)
#define led4off HAL_GPIO_WritePin(GPIOC,GPIO_PIN_4, GPIO_PIN_SET)
#define led5off HAL_GPIO_WritePin(GPIOC,GPIO_PIN_5, GPIO_PIN_SET)
#define led6off HAL_GPIO_WritePin(GPIOC,GPIO_PIN_6, GPIO_PIN_SET)
#define led7off HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7, GPIO_PIN_SET)
#define ledaoff HAL_GPIO_WritePin(GPIOC,GPIO_PIN_All,GPIO_PIN_SET)
#define time 100
void gd()
{
ledaoff;
}
void lsd()
{
led0on;
HAL_Delay(time);
led0off;
HAL_Delay(time);
led1on;
HAL_Delay(time);
led1off;
HAL_Delay(time);
led2on;
HAL_Delay(time);
led2off;
HAL_Delay(time);
led3on;
HAL_Delay(time);
led3off;
HAL_Delay(time);
led4on;
HAL_Delay(time);
led4off;
HAL_Delay(time);
led5on;
HAL_Delay(time);
led5off;
HAL_Delay(time);
led6on;
HAL_Delay(time);
led6off;
HAL_Delay(time);
led7on;
HAL_Delay(time);
led7off;
HAL_Delay(time);
}
void SystemClock_Config(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
gd();
while (1)
{
lsd();
}
}
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
void Error_Handler(void)
{
__disable_irq();
while (1)
{
}
}
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t *file, uint32_t line)
{
}
#endif
|