1 /********************************** (C) COPYRIGHT *******************************
2 * File Name : ch32v10x_dbgmcu.c
3 * Author : WCH
4 * Version : V1.0.0
5 * Date : 2020/04/30
6 * Description : This file provides all the DBGMCU firmware functions.
7 * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
8 * SPDX-License-Identifier: Apache-2.0
9 ****************************************************************************************/
10 #include "ch32v10x_dbgmcu.h"
11
12 /*********************************************************************
13 * @fn DBGMCU_Config
14 *
15 * @brief Configures the specified peripheral and low power mode behavior
16 * when the MCU under Debug mode.
17 *
18 * @param DBGMCU_Periph - specifies the peripheral and low power mode.
19 * DBGMCU_IWDG_STOP - Debug IWDG stopped when Core is halted
20 * DBGMCU_WWDG_STOP - Debug WWDG stopped when Core is halted
21 * DBGMCU_I2C1_SMBUS_TIMEOUT - I2C1 SMBUS timeout mode stopped when Core is halted
22 * DBGMCU_I2C2_SMBUS_TIMEOUT - I2C2 SMBUS timeout mode stopped when Core is halted
23 * DBGMCU_TIM1_STOP - TIM1 counter stopped when Core is halted
24 * DBGMCU_TIM2_STOP - TIM2 counter stopped when Core is halted
25 * DBGMCU_TIM3_STOP - TIM3 counter stopped when Core is halted
26 * DBGMCU_TIM4_STOP - TIM4 counter stopped when Core is halted
27 * DBGMCU_SLEEP - Keep debugger connection during SLEEP mode
28 * DBGMCU_STOP - Keep debugger connection during STOP mode
29 * DBGMCU_STANDBY - Keep debugger connection during STANDBY mode
30 * NewState - ENABLE or DISABLE.
31 *
32 * @return none
33 */
DBGMCU_Config(uint32_t DBGMCU_Periph,FunctionalState NewState)34 void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
35 {
36 if((DBGMCU_Periph == DBGMCU_SLEEP) || (DBGMCU_Periph == DBGMCU_STOP) || (DBGMCU_Periph == DBGMCU_STANDBY))
37 {
38 if(NewState != DISABLE)
39 {
40 DBGMCU->CFGR1 |= DBGMCU_Periph;
41 }
42 else
43 {
44 DBGMCU->CFGR1 &= ~DBGMCU_Periph;
45 }
46 }
47 else
48 {
49 if(NewState != DISABLE)
50 {
51 DBGMCU->CFGR0 |= DBGMCU_Periph;
52 }
53 else
54 {
55 DBGMCU->CFGR0 &= ~DBGMCU_Periph;
56 }
57 }
58
59
60
61
62
63
64 }
65