1 /*!
2 * @file apm32e10x_dbgmcu.c
3 *
4 * @brief This file provides all the DEBUG firmware functions
5 *
6 * @version V1.0.2
7 *
8 * @date 2022-12-31
9 *
10 * @attention
11 *
12 * Copyright (C) 2021-2023 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 #include "apm32e10x_dbgmcu.h"
26
27 /** @addtogroup APM32E10x_StdPeriphDriver
28 @{
29 */
30
31 /** @addtogroup DBGMCU_Driver
32 * @brief DBGMCU driver modules
33 @{
34 */
35
36 /** @defgroup DBGMCU_Functions Functions
37 @{
38 */
39
40 /*!
41 * @brief Returns the device identifier.
42 *
43 * @param None
44 *
45 * @retval Device identifier
46 */
DBGMCU_ReadDEVID(void)47 uint32_t DBGMCU_ReadDEVID(void)
48 {
49 return(DBGMCU->IDCODE_B.EQR);
50 }
51
52 /*!
53 * @brief Returns the device revision identifier.
54 *
55 * @param None
56 *
57 * @retval Device revision identifier
58 */
DBGMCU_ReadREVID(void)59 uint32_t DBGMCU_ReadREVID(void)
60 {
61 return(DBGMCU->IDCODE_B.WVR);
62 }
63
64 /*!
65 * @brief Enable the specified peripheral and low power mode behavior
66 * when the MCU under Debug mode
67 *
68 * @param periph: Specifies the peripheral and low power mode
69 * This parameter can be any combination of the following values:
70 * @arg DBGMCU_SLEEP : Keep debugger connection during SLEEP mode
71 * @arg DBGMCU_STOP : Keep debugger connection during STOP mode
72 * @arg DBGMCU_STANDBY : Keep debugger connection during STANDBY mode
73 * @arg DBGMCU_IWDT_STOP : Debug IWDT stopped when Core is halted
74 * @arg DBGMCU_WWDT_STOP : Debug WWDT stopped when Core is halted
75 * @arg DBGMCU_TMR1_STOP : TMR1 counter stopped when Core is halted
76 * @arg DBGMCU_TMR2_STOP : TMR2 counter stopped when Core is halted
77 * @arg DBGMCU_TMR3_STOP : TMR3 counter stopped when Core is halted
78 * @arg DBGMCU_TMR4_STOP : TMR4 counter stopped when Core is halted
79 * @arg DBGMCU_CAN1_STOP : Debug CAN1 stopped when Core is halted
80 * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
81 * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
82 * @arg DBGMCU_TMR5_STOP : TMR5 counter stopped when Core is halted
83 * @arg DBGMCU_TMR6_STOP : TMR6 counter stopped when Core is halted
84 * @arg DBGMCU_TMR7_STOP : TMR7 counter stopped when Core is halted
85 * @arg DBGMCU_TMR8_STOP : TMR8 counter stopped when Core is halted
86 * @arg DBGMCU_CAN2_STOP : Debug CAN2 stopped when Core is halted
87 * @arg DBGMCU_TMR15_STOP : TMR15 counter stopped when Core is halted
88 * @arg DBGMCU_TMR16_STOP : TMR16 counter stopped when Core is halted
89 * @arg DBGMCU_TMR17_STOP : TMR17 counter stopped when Core is halted
90 * @arg DBGMCU_TMR9_STOP : TMR9 counter stopped when Core is halted
91 * @arg DBGMCU_TMR10_STOP : TMR10 counter stopped when Core is halted
92 * @arg DBGMCU_TMR11_STOP : TMR11 counter stopped when Core is halted
93 * @arg DBGMCU_TMR12_STOP : TMR12 counter stopped when Core is halted
94 * @arg DBGMCU_TMR13_STOP : TMR13 counter stopped when Core is halted
95 * @arg DBGMCU_TMR14_STOP : TMR14 counter stopped when Core is halted
96 *
97 * @retval None
98 */
DBGMCU_Enable(uint32_t periph)99 void DBGMCU_Enable(uint32_t periph)
100 {
101 DBGMCU->CFG |= periph;
102 }
103
104 /*!
105 * @brief Enable the specified peripheral and low power mode behavior
106 * when the MCU under Debug mode
107 *
108 * @param periph: Specifies the peripheral and low power mode
109 * This parameter can be any combination of the following values:
110 * @arg DBGMCU_SLEEP : Keep debugger connection during SLEEP mode
111 * @arg DBGMCU_STOP : Keep debugger connection during STOP mode
112 * @arg DBGMCU_STANDBY : Keep debugger connection during STANDBY mode
113 * @arg DBGMCU_IWDT_STOP : Debug IWDT stopped when Core is halted
114 * @arg DBGMCU_WWDT_STOP : Debug WWDT stopped when Core is halted
115 * @arg DBGMCU_TMR1_STOP : TMR1 counter stopped when Core is halted
116 * @arg DBGMCU_TMR2_STOP : TMR2 counter stopped when Core is halted
117 * @arg DBGMCU_TMR3_STOP : TMR3 counter stopped when Core is halted
118 * @arg DBGMCU_TMR4_STOP : TMR4 counter stopped when Core is halted
119 * @arg DBGMCU_CAN1_STOP : Debug CAN1 stopped when Core is halted
120 * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
121 * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
122 * @arg DBGMCU_TMR5_STOP : TMR5 counter stopped when Core is halted
123 * @arg DBGMCU_TMR6_STOP : TMR6 counter stopped when Core is halted
124 * @arg DBGMCU_TMR7_STOP : TMR7 counter stopped when Core is halted
125 * @arg DBGMCU_TMR8_STOP : TMR8 counter stopped when Core is halted
126 * @arg DBGMCU_CAN2_STOP : Debug CAN2 stopped when Core is halted
127 * @arg DBGMCU_TMR15_STOP : TMR15 counter stopped when Core is halted
128 * @arg DBGMCU_TMR16_STOP : TMR16 counter stopped when Core is halted
129 * @arg DBGMCU_TMR17_STOP : TMR17 counter stopped when Core is halted
130 * @arg DBGMCU_TMR9_STOP : TMR9 counter stopped when Core is halted
131 * @arg DBGMCU_TMR10_STOP : TMR10 counter stopped when Core is halted
132 * @arg DBGMCU_TMR11_STOP : TMR11 counter stopped when Core is halted
133 * @arg DBGMCU_TMR12_STOP : TMR12 counter stopped when Core is halted
134 * @arg DBGMCU_TMR13_STOP : TMR13 counter stopped when Core is halted
135 * @arg DBGMCU_TMR14_STOP : TMR14 counter stopped when Core is halted
136 *
137 * @retval None
138 */
DBGMCU_Disable(uint32_t periph)139 void DBGMCU_Disable(uint32_t periph)
140 {
141 DBGMCU->CFG &= ~periph;
142 }
143
144 /**@} end of group DBGMCU_Functions */
145 /**@} end of group DBGMCU_Driver */
146 /**@} end of group APM32E10x_StdPeriphDriver */
147