systick.c 1007 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*!
  2. \file systick.c
  3. \brief the systick configuration file
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #include "gd32f3x0.h"
  10. #include "systick.h"
  11. static uint32_t delay;
  12. /*!
  13. \brief configure systick
  14. \param[in] none
  15. \param[out] none
  16. \retval none
  17. */
  18. void systick_config(void)
  19. {
  20. /* setup systick timer for 1000Hz interrupts */
  21. if (SysTick_Config(SystemCoreClock / 1000U)){
  22. /* capture error */
  23. while (1);
  24. }
  25. /* configure the systick handler priority */
  26. NVIC_SetPriority(SysTick_IRQn, 0x00U);
  27. }
  28. /*!
  29. \brief delay a time in milliseconds
  30. \param[in] count: count in milliseconds
  31. \param[out] none
  32. \retval none
  33. */
  34. void delay_1ms(uint32_t count)
  35. {
  36. delay = count;
  37. while(0U != delay);
  38. }
  39. /*!
  40. \brief delay decrement
  41. \param[in] none
  42. \param[out] none
  43. \retval none
  44. */
  45. void delay_decrement(void)
  46. {
  47. if (0U != delay){
  48. delay--;
  49. }
  50. }