stm32f4xx_dbgmcu.c 6.5 KB

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