apm32f4xx_dbgmcu.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*!
  2. * @file apm32f4xx_dbgmcu.c
  3. *
  4. * @brief This file provides all the DEBUG firmware functions
  5. *
  6. * @version V1.0.2
  7. *
  8. * @date 2022-06-23
  9. *
  10. * @attention
  11. *
  12. * Copyright (C) 2021-2022 Geehy Semiconductor
  13. *
  14. * You may not use this file except in compliance with the
  15. * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
  16. *
  17. * The program is only for reference, which is distributed in the hope
  18. * that it will be usefull and instructional for customers to develop
  19. * their software. Unless required by applicable law or agreed to in
  20. * writing, the program is distributed on an "AS IS" BASIS, WITHOUT
  21. * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
  23. * and limitations under the License.
  24. */
  25. #include "apm32f4xx_dbgmcu.h"
  26. /** @addtogroup APM32F4xx_StdPeriphDriver
  27. @{
  28. */
  29. /** @defgroup DBGMCU_Driver
  30. * @brief DBGMCU driver modules
  31. @{
  32. */
  33. /** @defgroup DBGMCU_Functions
  34. @{
  35. */
  36. /*!
  37. * @brief Returns the device identifier.
  38. *
  39. * @param None
  40. *
  41. * @retval Device identifier
  42. */
  43. uint32_t DBGMCU_ReadDEVID(void)
  44. {
  45. return (DBGMCU->IDCODE_B.EQR);
  46. }
  47. /*!
  48. * @brief Returns the device revision identifier.
  49. *
  50. * @param None
  51. *
  52. * @retval Device revision identifier
  53. */
  54. uint32_t DBGMCU_ReadREVID(void)
  55. {
  56. return (DBGMCU->IDCODE_B.WVR);
  57. }
  58. /*!
  59. * @brief Enable the specified peripheral and low power mode behavior
  60. * when the MCU under Debug mode
  61. *
  62. * @param periph: Specifies the peripheral and low power mode
  63. * This parameter can be any combination of the following values:
  64. * @arg DBGMCU_SLEEP : Keep debugger connection during SLEEP mode
  65. * @arg DBGMCU_STOP : Keep debugger connection during STOP mode
  66. * @arg DBGMCU_STANDBY : Keep debugger connection during STANDBY mode
  67. *
  68. * @retval None
  69. */
  70. void DBGMCU_Enable(uint32_t periph)
  71. {
  72. DBGMCU->CFG |= periph;
  73. }
  74. /*!
  75. * @brief DBGMCU_Disable the specified peripheral and low power mode behavior
  76. * when the MCU under Debug mode
  77. *
  78. * @param periph: Specifies the peripheral and low power mode
  79. * This parameter can be any combination of the following values:
  80. * @arg DBGMCU_SLEEP : Keep debugger connection during SLEEP mode
  81. * @arg DBGMCU_STOP : Keep debugger connection during STOP mode
  82. * @arg DBGMCU_STANDBY : Keep debugger connection during STANDBY mode
  83. *
  84. * @retval None
  85. */
  86. void DBGMCU_Disable(uint32_t periph)
  87. {
  88. DBGMCU->CFG &= ~periph;
  89. }
  90. /*!
  91. * @brief Enable APB1 peripheral behavior when the MCU is in Debug mode.
  92. *
  93. * @param periph: specifies the APB1 peripheral.
  94. * This parameter can be any combination of the following values:
  95. * @arg DBGMCU_TMR2_STOP : TMR2 counter stopped when Core is halted
  96. * @arg DBGMCU_TMR3_STOP : TMR3 counter stopped when Core is halted
  97. * @arg DBGMCU_TMR4_STOP : TMR4 counter stopped when Core is halted
  98. * @arg DBGMCU_TMR5_STOP : TMR5 counter stopped when Core is halted
  99. * @arg DBGMCU_TMR6_STOP : TMR6 counter stopped when Core is halted
  100. * @arg DBGMCU_TMR7_STOP : TMR7 counter stopped when Core is halted
  101. * @arg DBGMCU_TMR12_STOP : TMR12 counter stopped when Core is halted
  102. * @arg DBGMCU_TMR13_STOP : TMR13 counter stopped when Core is halted
  103. * @arg DBGMCU_TMR14_STOP : TMR14 counter stopped when Core is halted
  104. * @arg DBGMCU_RTC_STOP : RTC Calendar and Wakeup counter stopped when Core is halted.
  105. * @arg DBGMCU_WWDT_STOP : Debug WWDG stopped when Core is halted
  106. * @arg DBGMCU_IWDT_STOP : Debug IWDG stopped when Core is halted
  107. * @arg DBGMCU_I2C1_SMBUS_TIMEOUT : I2C1 SMBUS timeout mode stopped when Core is halted
  108. * @arg DBGMCU_I2C2_SMBUS_TIMEOUT : I2C2 SMBUS timeout mode stopped when Core is halted
  109. * @arg DBGMCU_I2C3_SMBUS_TIMEOUT : I2C3 SMBUS timeout mode stopped when Core is halted
  110. * @arg DBGMCU_CAN1_STOP : Debug CAN1 stopped when Core is halted
  111. * @arg DBGMCU_CAN2_STOP : Debug CAN2 stopped when Core is halted
  112. *
  113. * @retval None
  114. */
  115. void DBGMCU_EnableAPB1Periph(uint32_t periph)
  116. {
  117. DBGMCU->APB1F |= periph;
  118. }
  119. /*!
  120. * @brief Disable APB1 peripheral behavior when the MCU is in Debug mode.
  121. *
  122. * @param periph: specifies the APB1 peripheral.
  123. * This parameter can be any combination of the following values:
  124. * @arg DBGMCU_TMR2_STOP : TMR2 counter stopped when Core is halted
  125. * @arg DBGMCU_TMR3_STOP : TMR3 counter stopped when Core is halted
  126. * @arg DBGMCU_TMR4_STOP : TMR4 counter stopped when Core is halted
  127. * @arg DBGMCU_TMR5_STOP : TMR5 counter stopped when Core is halted
  128. * @arg DBGMCU_TMR6_STOP : TMR6 counter stopped when Core is halted
  129. * @arg DBGMCU_TMR7_STOP : TMR7 counter stopped when Core is halted
  130. * @arg DBGMCU_TMR12_STOP : TMR12 counter stopped when Core is halted
  131. * @arg DBGMCU_TMR13_STOP : TMR13 counter stopped when Core is halted
  132. * @arg DBGMCU_TMR14_STOP : TMR14 counter stopped when Core is halted
  133. * @arg DBGMCU_RTC_STOP : RTC Calendar and Wakeup counter stopped when Core is halted.
  134. * @arg DBGMCU_WWDT_STOP : Debug WWDG stopped when Core is halted
  135. * @arg DBGMCU_IWDT_STOP : Debug IWDG stopped when Core is halted
  136. * @arg DBGMCU_I2C1_SMBUS_TIMEOUT : I2C1 SMBUS timeout mode stopped when Core is halted
  137. * @arg DBGMCU_I2C2_SMBUS_TIMEOUT : I2C2 SMBUS timeout mode stopped when Core is halted
  138. * @arg DBGMCU_I2C3_SMBUS_TIMEOUT : I2C3 SMBUS timeout mode stopped when Core is halted
  139. * @arg DBGMCU_CAN1_STOP : Debug CAN1 stopped when Core is halted
  140. * @arg DBGMCU_CAN1_STOP : Debug CAN2 stopped when Core is halted
  141. *
  142. * @retval None
  143. */
  144. void DBGMCU_DisableAPB1Periph(uint32_t periph)
  145. {
  146. DBGMCU->APB1F &= ~periph;
  147. }
  148. /*!
  149. * @brief Enable APB2 peripheral behavior when the MCU is in Debug mode.
  150. *
  151. * @param periph: specifies the APB2 peripheral.
  152. * This parameter can be any combination of the following values:
  153. * @arg DBGMCU_TMR1_STOP : TMR1 counter stopped when Core is halted
  154. * @arg DBGMCU_TMR8_STOP : TMR8 counter stopped when Core is halted
  155. * @arg DBGMCU_TMR9_STOP : TMR9 counter stopped when Core is halted
  156. * @arg DBGMCU_TMR10_STOP : TMR10 counter stopped when Core is halted
  157. * @arg DBGMCU_TMR11_STOP : TMR11 counter stopped when Core is halted
  158. *
  159. * @retval None
  160. */
  161. void DBGMCU_EnableAPB2Periph(uint32_t periph)
  162. {
  163. DBGMCU->APB2F |= periph;
  164. }
  165. /*!
  166. * @brief Disable APB2 peripheral behavior when the MCU is in Debug mode.
  167. *
  168. * @param periph: specifies the APB2 peripheral.
  169. * This parameter can be any combination of the following values:
  170. * @arg DBGMCU_TMR1_STOP : TMR1 counter stopped when Core is halted
  171. * @arg DBGMCU_TMR8_STOP : TMR8 counter stopped when Core is halted
  172. * @arg DBGMCU_TMR9_STOP : TMR9 counter stopped when Core is halted
  173. * @arg DBGMCU_TMR10_STOP : TMR10 counter stopped when Core is halted
  174. * @arg DBGMCU_TMR11_STOP : TMR11 counter stopped when Core is halted
  175. *
  176. * @retval None
  177. */
  178. void DBGMCU_DisableAPB2Periph(uint32_t periph)
  179. {
  180. DBGMCU->APB2F &= ~periph;
  181. }
  182. /**@} end of group DBGMCU_Functions */
  183. /**@} end of group DBGMCU_Driver */
  184. /**@} end of group APM32F4xx_StdPeriphDriver */