stm32f0xx_dbgmcu.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_dbgmcu.c
  4. * @author MCD Application Team
  5. * @version V1.5.0
  6. * @date 05-December-2014
  7. * @brief This file provides firmware functions to manage the following
  8. * functionalities of the Debug MCU (DBGMCU) peripheral:
  9. * + Device and Revision ID management
  10. * + Peripherals Configuration
  11. * @verbatim
  12. * @endverbatim
  13. *
  14. ******************************************************************************
  15. * @attention
  16. *
  17. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  18. *
  19. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  20. * You may not use this file except in compliance with the License.
  21. * You may obtain a copy of the License at:
  22. *
  23. * http://www.st.com/software_license_agreement_liberty_v2
  24. *
  25. * Unless required by applicable law or agreed to in writing, software
  26. * distributed under the License is distributed on an "AS IS" BASIS,
  27. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. * See the License for the specific language governing permissions and
  29. * limitations under the License.
  30. *
  31. ******************************************************************************
  32. */
  33. /* Includes ------------------------------------------------------------------*/
  34. #include "stm32f0xx_dbgmcu.h"
  35. /** @addtogroup STM32F0xx_StdPeriph_Driver
  36. * @{
  37. */
  38. /** @defgroup DBGMCU
  39. * @brief DBGMCU driver modules
  40. * @{
  41. */
  42. /* Private typedef -----------------------------------------------------------*/
  43. /* Private define ------------------------------------------------------------*/
  44. #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
  45. /* Private macro -------------------------------------------------------------*/
  46. /* Private variables ---------------------------------------------------------*/
  47. /* Private function prototypes -----------------------------------------------*/
  48. /* Private functions ---------------------------------------------------------*/
  49. /** @defgroup DBGMCU_Private_Functions
  50. * @{
  51. */
  52. /** @defgroup DBGMCU_Group1 Device and Revision ID management functions
  53. * @brief Device and Revision ID management functions
  54. *
  55. @verbatim
  56. ==============================================================================
  57. ##### Device and Revision ID management functions #####
  58. ==============================================================================
  59. @endverbatim
  60. * @{
  61. */
  62. /**
  63. * @brief Returns the device revision identifier.
  64. * @param None
  65. * @retval Device revision identifier
  66. */
  67. uint32_t DBGMCU_GetREVID(void)
  68. {
  69. return(DBGMCU->IDCODE >> 16);
  70. }
  71. /**
  72. * @brief Returns the device identifier.
  73. * @param None
  74. * @retval Device identifier
  75. */
  76. uint32_t DBGMCU_GetDEVID(void)
  77. {
  78. return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
  79. }
  80. /**
  81. * @}
  82. */
  83. /** @defgroup DBGMCU_Group2 Peripherals Configuration functions
  84. * @brief Peripherals Configuration
  85. *
  86. @verbatim
  87. ==============================================================================
  88. ##### Peripherals Configuration functions #####
  89. ==============================================================================
  90. @endverbatim
  91. * @{
  92. */
  93. /**
  94. * @brief Configures low power mode behavior when the MCU is in Debug mode.
  95. * @param DBGMCU_Periph: specifies the low power mode.
  96. * This parameter can be any combination of the following values:
  97. * @arg DBGMCU_STOP: Keep debugger connection during STOP mode
  98. * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode
  99. * @param NewState: new state of the specified low power mode in Debug mode.
  100. * This parameter can be: ENABLE or DISABLE.
  101. * @retval None
  102. */
  103. void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
  104. {
  105. /* Check the parameters */
  106. assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
  107. assert_param(IS_FUNCTIONAL_STATE(NewState));
  108. if (NewState != DISABLE)
  109. {
  110. DBGMCU->CR |= DBGMCU_Periph;
  111. }
  112. else
  113. {
  114. DBGMCU->CR &= ~DBGMCU_Periph;
  115. }
  116. }
  117. /**
  118. * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode.
  119. * @param DBGMCU_Periph: specifies the APB1 peripheral.
  120. * This parameter can be any combination of the following values:
  121. * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted,
  122. * not applicable for STM32F030 devices
  123. * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted
  124. * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted
  125. * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted,
  126. * applicable only for STM32F072 devices
  127. * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted
  128. * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter stopped
  129. * when Core is halted.
  130. * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted
  131. * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted
  132. * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped
  133. * when Core is halted
  134. * @arg DBGMCU_CAN1_STOP: Debug CAN1 stopped when Core is halted,
  135. * applicable only for STM32F042 and STM32F072 devices
  136. * @param NewState: new state of the specified APB1 peripheral in Debug mode.
  137. * This parameter can be: ENABLE or DISABLE.
  138. * @retval None
  139. */
  140. void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
  141. {
  142. /* Check the parameters */
  143. assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));
  144. assert_param(IS_FUNCTIONAL_STATE(NewState));
  145. if (NewState != DISABLE)
  146. {
  147. DBGMCU->APB1FZ |= DBGMCU_Periph;
  148. }
  149. else
  150. {
  151. DBGMCU->APB1FZ &= ~DBGMCU_Periph;
  152. }
  153. }
  154. /**
  155. * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode.
  156. * @param DBGMCU_Periph: specifies the APB2 peripheral.
  157. * This parameter can be any combination of the following values:
  158. * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted
  159. * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted
  160. * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted
  161. * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted
  162. * @param NewState: new state of the specified APB2 peripheral in Debug mode.
  163. * This parameter can be: ENABLE or DISABLE.
  164. * @retval None
  165. */
  166. void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
  167. {
  168. /* Check the parameters */
  169. assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));
  170. assert_param(IS_FUNCTIONAL_STATE(NewState));
  171. if (NewState != DISABLE)
  172. {
  173. DBGMCU->APB2FZ |= DBGMCU_Periph;
  174. }
  175. else
  176. {
  177. DBGMCU->APB2FZ &= ~DBGMCU_Periph;
  178. }
  179. }
  180. /**
  181. * @}
  182. */
  183. /**
  184. * @}
  185. */
  186. /**
  187. * @}
  188. */
  189. /**
  190. * @}
  191. */
  192. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/