systick.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. volatile 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. }
  26. /* configure the systick handler priority */
  27. NVIC_SetPriority(SysTick_IRQn, 0x00U);
  28. }
  29. /*!
  30. \brief delay a time in milliseconds
  31. \param[in] count: count in milliseconds
  32. \param[out] none
  33. \retval none
  34. */
  35. void delay_1ms(uint32_t count)
  36. {
  37. delay = count;
  38. while(0U != delay){
  39. }
  40. }
  41. /*!
  42. \brief delay decrement
  43. \param[in] none
  44. \param[out] none
  45. \retval none
  46. */
  47. void delay_decrement(void)
  48. {
  49. if (0U != delay){
  50. delay--;
  51. }
  52. }