stm32f4xx_dbgmcu.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_dbgmcu.c
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 30-September-2011
  7. * @brief This file provides all the DBGMCU firmware functions.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17. *
  18. * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  19. ******************************************************************************
  20. */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "stm32f4xx_dbgmcu.h"
  23. /** @addtogroup STM32F4xx_StdPeriph_Driver
  24. * @{
  25. */
  26. /** @defgroup DBGMCU
  27. * @brief DBGMCU driver modules
  28. * @{
  29. */
  30. /* Private typedef -----------------------------------------------------------*/
  31. /* Private define ------------------------------------------------------------*/
  32. #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
  33. /* Private macro -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private function prototypes -----------------------------------------------*/
  36. /* Private functions ---------------------------------------------------------*/
  37. /** @defgroup DBGMCU_Private_Functions
  38. * @{
  39. */
  40. /**
  41. * @brief Returns the device revision identifier.
  42. * @param None
  43. * @retval Device revision identifier
  44. */
  45. uint32_t DBGMCU_GetREVID(void)
  46. {
  47. return(DBGMCU->IDCODE >> 16);
  48. }
  49. /**
  50. * @brief Returns the device identifier.
  51. * @param None
  52. * @retval Device identifier
  53. */
  54. uint32_t DBGMCU_GetDEVID(void)
  55. {
  56. return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
  57. }
  58. /**
  59. * @brief Configures low power mode behavior when the MCU is in Debug mode.
  60. * @param DBGMCU_Periph: specifies the low power mode.
  61. * This parameter can be any combination of the following values:
  62. * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode
  63. * @arg DBGMCU_STOP: Keep debugger connection during STOP mode
  64. * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode
  65. * @param NewState: new state of the specified low power mode in Debug mode.
  66. * This parameter can be: ENABLE or DISABLE.
  67. * @retval None
  68. */
  69. void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
  70. {
  71. /* Check the parameters */
  72. assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
  73. assert_param(IS_FUNCTIONAL_STATE(NewState));
  74. if (NewState != DISABLE)
  75. {
  76. DBGMCU->CR |= DBGMCU_Periph;
  77. }
  78. else
  79. {
  80. DBGMCU->CR &= ~DBGMCU_Periph;
  81. }
  82. }
  83. /**
  84. * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode.
  85. * @param DBGMCU_Periph: specifies the APB1 peripheral.
  86. * This parameter can be any combination of the following values:
  87. * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted
  88. * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted
  89. * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted
  90. * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted
  91. * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted
  92. * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted
  93. * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted
  94. * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted
  95. * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted
  96. * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter stopped when Core is halted.
  97. * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted
  98. * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted
  99. * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
  100. * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
  101. * @arg DBGMCU_I2C3_SMBUS_TIMEOUT: I2C3 SMBUS timeout mode stopped when Core is halted
  102. * @arg DBGMCU_CAN2_STOP: Debug CAN1 stopped when Core is halted
  103. * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted
  104. * This parameter can be: ENABLE or DISABLE.
  105. * @retval None
  106. */
  107. void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
  108. {
  109. /* Check the parameters */
  110. assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));
  111. assert_param(IS_FUNCTIONAL_STATE(NewState));
  112. if (NewState != DISABLE)
  113. {
  114. DBGMCU->APB1FZ |= DBGMCU_Periph;
  115. }
  116. else
  117. {
  118. DBGMCU->APB1FZ &= ~DBGMCU_Periph;
  119. }
  120. }
  121. /**
  122. * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode.
  123. * @param DBGMCU_Periph: specifies the APB2 peripheral.
  124. * This parameter can be any combination of the following values:
  125. * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted
  126. * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted
  127. * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted
  128. * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted
  129. * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted
  130. * @param NewState: new state of the specified peripheral in Debug mode.
  131. * This parameter can be: ENABLE or DISABLE.
  132. * @retval None
  133. */
  134. void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
  135. {
  136. /* Check the parameters */
  137. assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));
  138. assert_param(IS_FUNCTIONAL_STATE(NewState));
  139. if (NewState != DISABLE)
  140. {
  141. DBGMCU->APB2FZ |= DBGMCU_Periph;
  142. }
  143. else
  144. {
  145. DBGMCU->APB2FZ &= ~DBGMCU_Periph;
  146. }
  147. }
  148. /**
  149. * @}
  150. */
  151. /**
  152. * @}
  153. */
  154. /**
  155. * @}
  156. */
  157. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/