text: /*!
      \file  systick.c
      \brief the systick configuration file
  */
  
  /*
      Copyright (C) 2017 GigaDevice
  
      2014-12-26, V1.0.0, platform GD32F1x0(x=3,5)
      2016-01-15, V2.0.0, platform GD32F1x0(x=3,5,7,9)
      2016-04-30, V3.0.0, firmware update for GD32F1x0(x=3,5,7,9)
      2017-06-19, V3.1.0, firmware update for GD32F1x0(x=3,5,7,9)
  */
  
  #include "gd32f1x0.h"
  #include "systick.h"
  
  static volatile 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 / 1000)){
          /* capture error */
          while (1);
      }
      /* configure the systick handler priority */
      NVIC_SetPriority(SysTick_IRQn, 0x00);
  }
  
  /*!
      \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(0 != delay);
  }
  
  /*!
      \brief      delay decrement
      \param[in]  none
      \param[out] none
      \retval     none
  */
  void delay_decrement(void)
  {
      if (0 != delay){ 
          delay--;
      }
  }
  