gd32f10x_mcudbg.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. ******************************************************************************
  3. * @brief MCUDBG functions of the firmware library.
  4. ******************************************************************************
  5. */
  6. /* Includes ------------------------------------------------------------------*/
  7. #include "gd32f10x_mcudbg.h"
  8. /** @addtogroup GD32F10x_Firmware
  9. * @{
  10. */
  11. /** @defgroup MCUDBG
  12. * @brief MCUDBG driver modules
  13. * @{
  14. */
  15. /** @defgroup MCUDBG_Private_Defines
  16. * @{
  17. */
  18. #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
  19. /**
  20. * @}
  21. */
  22. /** @defgroup MCUDBG_Private_Functions
  23. * @{
  24. */
  25. /**
  26. * @brief Returns the device revision identifier.
  27. * @param None
  28. * @retval Device revision identifier
  29. */
  30. uint32_t MCUDBG_GetREVID(void)
  31. {
  32. return (MCUDBG->IDR >> 16);
  33. }
  34. /**
  35. * @brief Returns the device identifier.
  36. * @param None
  37. * @retval Device identifier
  38. */
  39. uint32_t MCUDBG_GetDEVID(void)
  40. {
  41. return (MCUDBG->IDR & IDCODE_DEVID_MASK);
  42. }
  43. /**
  44. * @brief Configure the specified peripheral and low power mode behavior
  45. * when the MCU under Debug mode.
  46. * @param MCUDBG_Periph: specifies the peripheral and low power mode.
  47. * This parameter can be any combination of the following values:
  48. * @arg MCUDBG_SLEEP_HOLD: Keep debugger connection during SLEEP mode
  49. * @arg MCUDBG_DEEPSLEEP_HOLD: Keep debugger connection during DEEPSLEEP mode
  50. * @arg MCUDBG_STDBY_HOLD: Keep debugger connection during STANDBY mode
  51. * @arg MCUDBG_IWDG_HOLD: Debug IWDG hold when Core is halted
  52. * @arg MCUDBG_WWDG_HOLD: Debug WWDG hold when Core is halted
  53. * @arg MCUDBG_TIMER1_HOLD: TIMER1 counter hold when Core is halted
  54. * @arg MCUDBG_TIMER2_HOLD: TIMER2 counter hold when Core is halted
  55. * @arg MCUDBG_TIMER3_HOLD: TIMER3 counter hold when Core is halted
  56. * @arg MCUDBG_TIMER4_HOLD: TIMER4 counter hold when Core is halted
  57. * @arg MCUDBG_CAN1_HOLD: Debug CAN1 hold when Core is halted
  58. * @arg MCUDBG_I2C1_HOLD: I2C1 SMBUS timeout mode hold when Core is halted
  59. * @arg MCUDBG_I2C2_HOLD: I2C2 SMBUS timeout mode hold when Core is halted
  60. * @arg MCUDBG_TIMER5_HOLD: TIMER5 counter hold when Core is halted
  61. * @arg MCUDBG_TIMER6_HOLD: TIMER6 counter hold when Core is halted
  62. * @arg MCUDBG_TIMER7_HOLD: TIMER7 counter hold when Core is halted
  63. * @arg MCUDBG_TIMER8_HOLD: TIMER8 counter hold when Core is halted
  64. * @arg MCUDBG_CAN2_HOLD: Debug CAN2 hold when Core is halted
  65. * @arg MCUDBG_TIMER12_HOLD: TIMER12 counter hold when Core is halted
  66. * @arg MCUDBG_TIMER13_HOLD: TIMER13 counter hold when Core is halted
  67. * @arg MCUDBG_TIMER14_HOLD: TIMER14 counter hold when Core is halted
  68. * @arg MCUDBG_TIMER9_HOLD: TIMER9 counter hold when Core is halted
  69. * @arg MCUDBG_TIMER10_HOLD: TIMER10 counter hold when Core is halted
  70. * @arg MCUDBG_TIMER11_HOLD: TIMER11 counter hold when Core is halted
  71. * @param NewState: new state of the specified peripheral in Debug mode.
  72. * This parameter can be: ENABLE or DISABLE.
  73. * @retval None
  74. */
  75. void MCUDBG_PeriphConfig(uint32_t MCUDBG_Periph, TypeState NewValue)
  76. {
  77. if (NewValue != DISABLE) {
  78. MCUDBG->CTLR |= MCUDBG_Periph;
  79. } else {
  80. MCUDBG->CTLR &= ~MCUDBG_Periph;
  81. }
  82. }
  83. /**
  84. * @}
  85. */
  86. /**
  87. * @}
  88. */
  89. /**
  90. * @}
  91. */