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