at32f423_debug.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. **************************************************************************
  3. * @file at32f423_mcudbg.c
  4. * @brief contains all the functions for the mcudbg firmware library
  5. **************************************************************************
  6. * Copyright notice & Disclaimer
  7. *
  8. * The software Board Support Package (BSP) that is made available to
  9. * download from Artery official website is the copyrighted work of Artery.
  10. * Artery authorizes customers to use, copy, and distribute the BSP
  11. * software and its related documentation for the purpose of design and
  12. * development in conjunction with Artery microcontrollers. Use of the
  13. * software is governed by this copyright notice and the following disclaimer.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  16. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  17. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  18. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  19. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  21. *
  22. **************************************************************************
  23. */
  24. #include "at32f423_conf.h"
  25. /** @addtogroup AT32F423_periph_driver
  26. * @{
  27. */
  28. /** @defgroup DEBUG
  29. * @brief DEBUG driver modules
  30. * @{
  31. */
  32. #ifdef DEBUG_MODULE_ENABLED
  33. /** @defgroup DEBUG_private_functions
  34. * @{
  35. */
  36. /**
  37. * @brief get debug device id
  38. * @param none
  39. * @retval the debug device id
  40. */
  41. uint32_t debug_device_id_get(void)
  42. {
  43. return DEBUGMCU->pid;
  44. }
  45. /**
  46. * @brief set periph debug mode
  47. * @param periph_debug_mode
  48. * this parameter can be one of the following values:
  49. * - DEBUG_SLEEP
  50. * - DEBUG_DEEPSLEEP
  51. * - DEBUG_STANDBY
  52. * @param new_state (TRUE or FALSE)
  53. * @retval none
  54. */
  55. void debug_low_power_mode_set(uint32_t low_power_mode, confirm_state new_state)
  56. {
  57. if(new_state != FALSE)
  58. {
  59. DEBUGMCU->ctrl |= low_power_mode;
  60. }
  61. else
  62. {
  63. DEBUGMCU->ctrl &= ~low_power_mode;
  64. }
  65. }
  66. /**
  67. * @brief set apb1 periph debug mode
  68. * @param periph_debug_mode
  69. * this parameter can be any combination of the following values:
  70. * - DEBUG_TMR2_PAUSE - DEBUG_TMR3_PAUSE
  71. * - DEBUG_TMR6_PAUSE - DEBUG_TMR7_PAUSE
  72. * - DEBUG_TMR12_PAUSE - DEBUG_TMR13_PAUSE
  73. * - DEBUG_TMR14_PAUSE - DEBUG_ERTC_PAUSE
  74. * - DEBUG_WWDT_PAUSE - DEBUG_WDT_PAUSE
  75. * - DEBUG_ERTC_512_PAUSE - DEBUG_I2C1_SMBUS_TIMEOUT
  76. * - DEBUG_I2C2_SMBUS_TIMEOUT - DEBUG_I2C3_SMBUS_TIMEOUT
  77. * - DEBUG_CAN1_PAUSE - DEBUG_CAN2_PAUSE
  78. * - DEBUG_TMR4_PAUSE
  79. * @param new_state (TRUE or FALSE)
  80. * @retval none
  81. */
  82. void debug_apb1_periph_mode_set(uint32_t apb1_periph, confirm_state new_state)
  83. {
  84. if(new_state != FALSE)
  85. {
  86. DEBUGMCU->apb1_frz |= apb1_periph;
  87. }
  88. else
  89. {
  90. DEBUGMCU->apb1_frz &= ~apb1_periph;
  91. }
  92. }
  93. /**
  94. * @brief set apb2 periph debug mode
  95. * @param periph_debug_mode
  96. * this parameter can be any combination of the following values:
  97. * - DEBUG_TMR1_PAUSE - DEBUG_TMR9_PAUSE
  98. * - DEBUG_TMR10_PAUSE - DEBUG_TMR11_PAUSE
  99. * @param new_state (TRUE or FALSE)
  100. * @retval none
  101. */
  102. void debug_apb2_periph_mode_set(uint32_t apb2_periph, confirm_state new_state)
  103. {
  104. if(new_state != FALSE)
  105. {
  106. DEBUGMCU->apb2_frz |= apb2_periph;
  107. }
  108. else
  109. {
  110. DEBUGMCU->apb2_frz &= ~apb2_periph;
  111. }
  112. }
  113. /**
  114. * @}
  115. */
  116. #endif
  117. /**
  118. * @}
  119. */
  120. /**
  121. * @}
  122. */