1 /*!
2  * @file        apm32f10x_dbgmcu.c
3  *
4  * @brief       This file provides all the DEBUG firmware functions
5  *
6  * @version     V1.0.4
7  *
8  * @date        2022-12-01
9  *
10  * @attention
11  *
12  *  Copyright (C) 2020-2022 Geehy Semiconductor
13  *
14  *  You may not use this file except in compliance with the
15  *  GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
16  *
17  *  The program is only for reference, which is distributed in the hope
18  *  that it will be useful and instructional for customers to develop
19  *  their software. Unless required by applicable law or agreed to in
20  *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
21  *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
22  *  See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
23  *  and limitations under the License.
24  */
25 
26 #include "apm32f10x_dbgmcu.h"
27 
28 /** @addtogroup APM32F10x_StdPeriphDriver
29   @{
30 */
31 
32 /** @addtogroup DBGMCU_Driver DBGMCU Driver
33   * @brief DBGMCU driver modules
34   @{
35 */
36 
37 /** @defgroup DBGMCU_Functions Functions
38   @{
39 */
40 
41 /*!
42  * @brief  Returns the device identifier.
43  *
44  * @param  None
45  *
46  * @retval Device identifier
47  */
DBGMCU_ReadDEVID(void)48 uint32_t DBGMCU_ReadDEVID(void)
49 {
50     return (DBGMCU->IDCODE_B.EQR);
51 }
52 
53 /*!
54  * @brief  Returns the device revision identifier.
55  *
56  * @param  None
57  *
58  * @retval Device revision identifier
59  */
DBGMCU_ReadREVID(void)60 uint32_t DBGMCU_ReadREVID(void)
61 {
62     return (DBGMCU->IDCODE_B.WVR);
63 }
64 
65 /*!
66  * @brief       Enable the specified peripheral and low power mode behavior
67  *              when the MCU under Debug mode
68  *
69  * @param       periph: Specifies the peripheral and low power mode
70  *                      This parameter can be any combination of the following values:
71  *                      @arg DBGMCU_SLEEP             : Keep debugger connection during SLEEP mode
72  *                      @arg DBGMCU_STOP              : Keep debugger connection during STOP mode
73  *                      @arg DBGMCU_STANDBY           : Keep debugger connection during STANDBY mode
74  *                      @arg DBGMCU_IWDT_STOP         : Debug IWDT stopped when Core is halted
75  *                      @arg DBGMCU_WWDT_STOP         : Debug WWDT stopped when Core is halted
76  *                      @arg DBGMCU_TMR1_STOP         : TMR1 counter stopped when Core is halted
77  *                      @arg DBGMCU_TMR2_STOP         : TMR2 counter stopped when Core is halted
78  *                      @arg DBGMCU_TMR3_STOP         : TMR3 counter stopped when Core is halted
79  *                      @arg DBGMCU_TMR4_STOP         : TMR4 counter stopped when Core is halted
80  *                      @arg DBGMCU_CAN1_STOP         : Debug CAN1 stopped when Core is halted
81  *                      @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
82  *                      @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
83  *                      @arg DBGMCU_TMR5_STOP         : TMR5 counter stopped when Core is halted
84  *                      @arg DBGMCU_TMR6_STOP         : TMR6 counter stopped when Core is halted
85  *                      @arg DBGMCU_TMR7_STOP         : TMR7 counter stopped when Core is halted
86  *                      @arg DBGMCU_TMR8_STOP         : TMR8 counter stopped when Core is halted
87  *                      @arg DBGMCU_CAN2_STOP         : Debug CAN2 stopped when Core is halted
88  *                      @arg DBGMCU_TMR15_STOP        : TMR15 counter stopped when Core is halted
89  *                      @arg DBGMCU_TMR16_STOP        : TMR16 counter stopped when Core is halted
90  *                      @arg DBGMCU_TMR17_STOP        : TMR17 counter stopped when Core is halted
91  *                      @arg DBGMCU_TMR9_STOP         : TMR9 counter stopped when Core is halted
92  *                      @arg DBGMCU_TMR10_STOP        : TMR10 counter stopped when Core is halted
93  *                      @arg DBGMCU_TMR11_STOP        : TMR11 counter stopped when Core is halted
94  *                      @arg DBGMCU_TMR12_STOP        : TMR12 counter stopped when Core is halted
95  *                      @arg DBGMCU_TMR13_STOP        : TMR13 counter stopped when Core is halted
96  *                      @arg DBGMCU_TMR14_STOP        : TMR14 counter stopped when Core is halted
97  *
98  * @retval      None
99  */
DBGMCU_Enable(uint32_t periph)100 void DBGMCU_Enable(uint32_t periph)
101 {
102     DBGMCU->CFG |= periph;
103 }
104 
105 /*!
106  * @brief       Enable the specified peripheral and low power mode behavior
107  *              when the MCU under Debug mode
108  *
109  * @param       periph: Specifies the peripheral and low power mode
110  *                      This parameter can be any combination of the following values:
111  *                      @arg DBGMCU_SLEEP             : Keep debugger connection during SLEEP mode
112  *                      @arg DBGMCU_STOP              : Keep debugger connection during STOP mode
113  *                      @arg DBGMCU_STANDBY           : Keep debugger connection during STANDBY mode
114  *                      @arg DBGMCU_IWDT_STOP         : Debug IWDT stopped when Core is halted
115  *                      @arg DBGMCU_WWDT_STOP         : Debug WWDT stopped when Core is halted
116  *                      @arg DBGMCU_TMR1_STOP         : TMR1 counter stopped when Core is halted
117  *                      @arg DBGMCU_TMR2_STOP         : TMR2 counter stopped when Core is halted
118  *                      @arg DBGMCU_TMR3_STOP         : TMR3 counter stopped when Core is halted
119  *                      @arg DBGMCU_TMR4_STOP         : TMR4 counter stopped when Core is halted
120  *                      @arg DBGMCU_CAN1_STOP         : Debug CAN1 stopped when Core is halted
121  *                      @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
122  *                      @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
123  *                      @arg DBGMCU_TMR5_STOP         : TMR5 counter stopped when Core is halted
124  *                      @arg DBGMCU_TMR6_STOP         : TMR6 counter stopped when Core is halted
125  *                      @arg DBGMCU_TMR7_STOP         : TMR7 counter stopped when Core is halted
126  *                      @arg DBGMCU_TMR8_STOP         : TMR8 counter stopped when Core is halted
127  *                      @arg DBGMCU_CAN2_STOP         : Debug CAN2 stopped when Core is halted
128  *                      @arg DBGMCU_TMR15_STOP        : TMR15 counter stopped when Core is halted
129  *                      @arg DBGMCU_TMR16_STOP        : TMR16 counter stopped when Core is halted
130  *                      @arg DBGMCU_TMR17_STOP        : TMR17 counter stopped when Core is halted
131  *                      @arg DBGMCU_TMR9_STOP         : TMR9 counter stopped when Core is halted
132  *                      @arg DBGMCU_TMR10_STOP        : TMR10 counter stopped when Core is halted
133  *                      @arg DBGMCU_TMR11_STOP        : TMR11 counter stopped when Core is halted
134  *                      @arg DBGMCU_TMR12_STOP        : TMR12 counter stopped when Core is halted
135  *                      @arg DBGMCU_TMR13_STOP        : TMR13 counter stopped when Core is halted
136  *                      @arg DBGMCU_TMR14_STOP        : TMR14 counter stopped when Core is halted
137  *
138  * @retval      None
139  */
DBGMCU_Disable(uint32_t periph)140 void DBGMCU_Disable(uint32_t periph)
141 {
142     DBGMCU->CFG &= ~periph;
143 }
144 
145 /**@} end of group DBGMCU_Functions*/
146 /**@} end of group DBGMCU_Driver */
147 /**@} end of group APM32F10x_StdPeriphDriver */
148