2024-04-27 12:17:32 +08:00
|
|
|
#include "stm32f4xx_rcc.h"
|
|
|
|
|
#include "led.h"
|
2024-04-27 21:38:35 +08:00
|
|
|
#include "lcd.h"
|
2024-04-27 12:17:32 +08:00
|
|
|
|
|
|
|
|
volatile uint32_t system_tick_cnt;
|
|
|
|
|
|
|
|
|
|
void system_tick_init(void)
|
|
|
|
|
{
|
|
|
|
|
RCC_ClocksTypeDef rcc_clocks;
|
|
|
|
|
|
|
|
|
|
system_tick_cnt = 0;
|
|
|
|
|
RCC_GetClocksFreq(&rcc_clocks);
|
|
|
|
|
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
|
|
|
|
|
SysTick_Config(rcc_clocks.HCLK_Frequency / 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void led_loop(void)
|
|
|
|
|
{
|
|
|
|
|
static uint32_t tick = 0;
|
|
|
|
|
|
|
|
|
|
if (system_tick_cnt - tick > 500) {
|
|
|
|
|
led_toggle();
|
|
|
|
|
tick = system_tick_cnt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void system_init(void)
|
|
|
|
|
{
|
|
|
|
|
led_init();
|
|
|
|
|
system_tick_init();
|
2024-04-27 21:38:35 +08:00
|
|
|
lcd_init();
|
2024-04-27 12:17:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
|
{
|
|
|
|
|
system_init();
|
|
|
|
|
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
|
|
|
|
|
SCB->VTOR = 0x08000000;
|
|
|
|
|
__enable_irq();
|
|
|
|
|
while (1) {
|
|
|
|
|
led_loop();
|
2024-04-27 21:38:35 +08:00
|
|
|
lcd_loop();
|
2024-04-27 12:17:32 +08:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SysTick_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
system_tick_cnt++;
|
|
|
|
|
}
|