gd32f1x0_misc.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*!
  2. \file gd32f1x0_misc.h
  3. \brief definitions for the MISC
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2014-12-26, V1.0.0, platform GD32F1x0(x=3,5)
  8. 2016-01-15, V2.0.0, platform GD32F1x0(x=3,5,7,9)
  9. 2016-04-30, V3.0.0, firmware update for GD32F1x0(x=3,5,7,9)
  10. 2017-06-19, V3.1.0, firmware update for GD32F1x0(x=3,5,7,9)
  11. */
  12. #ifndef GD32F1X0_MISC_H
  13. #define GD32F1X0_MISC_H
  14. #include "gd32f1x0.h"
  15. /* constants definitions */
  16. /* set the RAM and FLASH base address */
  17. #define NVIC_VECTTAB_RAM ((uint32_t)0x20000000U) /*!< RAM base address */
  18. #define NVIC_VECTTAB_FLASH ((uint32_t)0x08000000U) /*!< Flash base address */
  19. /* set the NVIC vector table offset mask */
  20. #define NVIC_VECTTAB_OFFSET_MASK ((uint32_t)0x1FFFFF80U)
  21. /* the register key mask, if you want to do the write operation, you should write 0x5FA to VECTKEY bits */
  22. #define NVIC_AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000U)
  23. /* priority group - define the pre-emption priority and the subpriority */
  24. #define NVIC_PRIGROUP_PRE0_SUB4 ((uint32_t)0x700U) /*!< 0 bits for pre-emption priority 4 bits for subpriority */
  25. #define NVIC_PRIGROUP_PRE1_SUB3 ((uint32_t)0x600U) /*!< 1 bits for pre-emption priority 3 bits for subpriority */
  26. #define NVIC_PRIGROUP_PRE2_SUB2 ((uint32_t)0x500U) /*!< 2 bits for pre-emption priority 2 bits for subpriority */
  27. #define NVIC_PRIGROUP_PRE3_SUB1 ((uint32_t)0x400U) /*!< 3 bits for pre-emption priority 1 bits for subpriority */
  28. #define NVIC_PRIGROUP_PRE4_SUB0 ((uint32_t)0x300U) /*!< 4 bits for pre-emption priority 0 bits for subpriority */
  29. /* choose the method to enter or exit the lowpower mode */
  30. #define SCB_SCR_SLEEPONEXIT ((uint8_t)0x02U) /*!< choose the the system whether enter low power mode by exiting from ISR */
  31. #define SCB_SCR_SLEEPDEEP ((uint8_t)0x04U) /*!< choose the the system enter the DEEPSLEEP mode or SLEEP mode */
  32. #define SCB_SCR_SEVONPEND ((uint8_t)0x10U) /*!< choose the interrupt source that can wake up the lowpower mode */
  33. #define SCB_LPM_SLEEP_EXIT_ISR SCB_SCR_SLEEPONEXIT
  34. #define SCB_LPM_DEEPSLEEP SCB_SCR_SLEEPDEEP
  35. #define SCB_LPM_WAKE_BY_ALL_INT SCB_SCR_SEVONPEND
  36. /* choose the systick clock source */
  37. #define SYSTICK_CLKSOURCE_HCLK_DIV8 ((uint32_t)0xFFFFFFFBU) /*!< systick clock source is from HCLK/8 */
  38. #define SYSTICK_CLKSOURCE_HCLK ((uint32_t)0x00000004U) /*!< systick clock source is from HCLK */
  39. /* function declarations */
  40. /* set the priority group */
  41. void nvic_priority_group_set(uint32_t nvic_prigroup);
  42. /* enable NVIC request */
  43. void nvic_irq_enable(uint8_t nvic_irq, uint8_t nvic_irq_pre_priority, uint8_t nvic_irq_sub_priority);
  44. /* disable NVIC request */
  45. void nvic_irq_disable(uint8_t nvic_irq);
  46. /* set the NVIC vector table base address */
  47. void nvic_vector_table_set(uint32_t nvic_vict_tab, uint32_t offset);
  48. /* set the state of the low power mode */
  49. void system_lowpower_set(uint8_t lowpower_mode);
  50. /* reset the state of the low power mode */
  51. void system_lowpower_reset(uint8_t lowpower_mode);
  52. /* set the systick clock source */
  53. void systick_clksource_set(uint32_t systick_clksource);
  54. #endif /* GD32F1X0_MISC_H */