ft32f0xx_debug.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. ******************************************************************************
  3. * @file ft32f0xx_debug.c
  4. * @author FMD AE
  5. * @brief This file provides firmware functions to manage the following
  6. * functionalities of the Debug MCU (DBGMCU) peripheral:
  7. * + Device and Revision ID management
  8. * + Peripherals Configuration
  9. * @version V1.0.0
  10. * @data 2021-07-01
  11. ******************************************************************************
  12. */
  13. /* Includes ------------------------------------------------------------------*/
  14. #include "ft32f0xx_debug.h"
  15. #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
  16. /**
  17. * @brief Returns the device revision identifier.
  18. * @param None
  19. * @retval Device revision identifier
  20. */
  21. uint32_t DBGMCU_GetREVID(void)
  22. {
  23. return(DBGMCU->IDCODE >> 16);
  24. }
  25. /**
  26. * @brief Returns the device identifier.
  27. * @param None
  28. * @retval Device identifier
  29. */
  30. uint32_t DBGMCU_GetDEVID(void)
  31. {
  32. return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
  33. }
  34. /**
  35. * @}
  36. */
  37. /**
  38. * @brief Configures low power mode behavior when the MCU is in Debug mode.
  39. * @param DBGMCU_Periph: specifies the low power mode.
  40. * This parameter can be any combination of the following values:
  41. * @arg DBGMCU_STOP: Keep debugger connection during STOP mode
  42. * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode
  43. * @param NewState: new state of the specified low power mode in Debug mode.
  44. * This parameter can be: ENABLE or DISABLE.
  45. * @retval None
  46. */
  47. void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
  48. {
  49. /* Check the parameters */
  50. assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
  51. assert_param(IS_FUNCTIONAL_STATE(NewState));
  52. if (NewState != DISABLE)
  53. {
  54. DBGMCU->CR |= DBGMCU_Periph;
  55. }
  56. else
  57. {
  58. DBGMCU->CR &= ~DBGMCU_Periph;
  59. }
  60. }
  61. /**
  62. * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode.
  63. * @param DBGMCU_Periph: specifies the APB1 peripheral.
  64. * This parameter can be any combination of the following values:
  65. * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted
  66. * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted
  67. * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted
  68. * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted
  69. * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted
  70. * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter stopped
  71. * when Core is halted.
  72. * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted
  73. * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted
  74. * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped
  75. * when Core is halted
  76. * @arg DBGMCU_CAN1_STOP: Debug CAN1 stopped when Core is halted
  77. * @param NewState: new state of the specified APB1 peripheral in Debug mode.
  78. * This parameter can be: ENABLE or DISABLE.
  79. * @retval None
  80. */
  81. void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
  82. {
  83. /* Check the parameters */
  84. assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));
  85. assert_param(IS_FUNCTIONAL_STATE(NewState));
  86. if (NewState != DISABLE)
  87. {
  88. DBGMCU->APB1FZ |= DBGMCU_Periph;
  89. }
  90. else
  91. {
  92. DBGMCU->APB1FZ &= ~DBGMCU_Periph;
  93. }
  94. }
  95. /**
  96. * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode.
  97. * @param DBGMCU_Periph: specifies the APB2 peripheral.
  98. * This parameter can be any combination of the following values:
  99. * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted
  100. * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted
  101. * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted
  102. * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted
  103. * @param NewState: new state of the specified APB2 peripheral in Debug mode.
  104. * This parameter can be: ENABLE or DISABLE.
  105. * @retval None
  106. */
  107. void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
  108. {
  109. /* Check the parameters */
  110. assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));
  111. assert_param(IS_FUNCTIONAL_STATE(NewState));
  112. if (NewState != DISABLE)
  113. {
  114. DBGMCU->APB2FZ |= DBGMCU_Periph;
  115. }
  116. else
  117. {
  118. DBGMCU->APB2FZ &= ~DBGMCU_Periph;
  119. }
  120. }
  121. /**
  122. * @}
  123. */
  124. /**
  125. * @}
  126. */
  127. /**
  128. * @}
  129. */
  130. /**
  131. * @}
  132. */
  133. /************************ (C) COPYRIGHT FMD *****END OF FILE****/