61 lines
1.0 KiB
C
61 lines
1.0 KiB
C
/*!
|
|
\file systick.c
|
|
\brief the systick configuration file
|
|
*/
|
|
|
|
/*
|
|
Copyright (C) 2016 GigaDevice
|
|
|
|
2016-08-15, V1.0.0, firmware for GD32F4xx
|
|
*/
|
|
|
|
#include "gd32f4xx.h"
|
|
#include "systick.h"
|
|
|
|
volatile static uint32_t delay;
|
|
|
|
/*!
|
|
\brief configure systick
|
|
\param[in] none
|
|
\param[out] none
|
|
\retval none
|
|
*/
|
|
void systick_config(void)
|
|
{
|
|
/* setup systick timer for 1000Hz interrupts */
|
|
if (SysTick_Config(SystemCoreClock / 1000U)){
|
|
/* capture error */
|
|
while (1){
|
|
}
|
|
}
|
|
/* configure the systick handler priority */
|
|
NVIC_SetPriority(SysTick_IRQn, 0x00U);
|
|
}
|
|
|
|
/*!
|
|
\brief delay a time in milliseconds
|
|
\param[in] count: count in milliseconds
|
|
\param[out] none
|
|
\retval none
|
|
*/
|
|
void delay_1ms(uint32_t count)
|
|
{
|
|
delay = count;
|
|
|
|
while(0U != delay){
|
|
}
|
|
}
|
|
|
|
/*!
|
|
\brief delay decrement
|
|
\param[in] none
|
|
\param[out] none
|
|
\retval none
|
|
*/
|
|
void delay_decrement(void)
|
|
{
|
|
if (0U != delay){
|
|
delay--;
|
|
}
|
|
}
|