1 /*!
2 * @file apm32f4xx_dbgmcu.c
3 *
4 * @brief This file provides all the DEBUG firmware functions
5 *
6 * @version V1.0.2
7 *
8 * @date 2022-06-23
9 *
10 * @attention
11 *
12 * Copyright (C) 2021-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 usefull 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 "apm32f4xx_dbgmcu.h"
27
28 /** @addtogroup APM32F4xx_StdPeriphDriver
29 @{
30 */
31
32 /** @defgroup DBGMCU_Driver
33 * @brief DBGMCU driver modules
34 @{
35 */
36
37 /** @defgroup DBGMCU_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 *
75 * @retval None
76 */
DBGMCU_Enable(uint32_t periph)77 void DBGMCU_Enable(uint32_t periph)
78 {
79 DBGMCU->CFG |= periph;
80 }
81
82 /*!
83 * @brief DBGMCU_Disable the specified peripheral and low power mode behavior
84 * when the MCU under Debug mode
85 *
86 * @param periph: Specifies the peripheral and low power mode
87 * This parameter can be any combination of the following values:
88 * @arg DBGMCU_SLEEP : Keep debugger connection during SLEEP mode
89 * @arg DBGMCU_STOP : Keep debugger connection during STOP mode
90 * @arg DBGMCU_STANDBY : Keep debugger connection during STANDBY mode
91 *
92 * @retval None
93 */
DBGMCU_Disable(uint32_t periph)94 void DBGMCU_Disable(uint32_t periph)
95 {
96 DBGMCU->CFG &= ~periph;
97 }
98
99 /*!
100 * @brief Enable APB1 peripheral behavior when the MCU is in Debug mode.
101 *
102 * @param periph: specifies the APB1 peripheral.
103 * This parameter can be any combination of the following values:
104 * @arg DBGMCU_TMR2_STOP : TMR2 counter stopped when Core is halted
105 * @arg DBGMCU_TMR3_STOP : TMR3 counter stopped when Core is halted
106 * @arg DBGMCU_TMR4_STOP : TMR4 counter stopped when Core is halted
107 * @arg DBGMCU_TMR5_STOP : TMR5 counter stopped when Core is halted
108 * @arg DBGMCU_TMR6_STOP : TMR6 counter stopped when Core is halted
109 * @arg DBGMCU_TMR7_STOP : TMR7 counter stopped when Core is halted
110 * @arg DBGMCU_TMR12_STOP : TMR12 counter stopped when Core is halted
111 * @arg DBGMCU_TMR13_STOP : TMR13 counter stopped when Core is halted
112 * @arg DBGMCU_TMR14_STOP : TMR14 counter stopped when Core is halted
113 * @arg DBGMCU_RTC_STOP : RTC Calendar and Wakeup counter stopped when Core is halted.
114 * @arg DBGMCU_WWDT_STOP : Debug WWDG stopped when Core is halted
115 * @arg DBGMCU_IWDT_STOP : Debug IWDG stopped when Core is halted
116 * @arg DBGMCU_I2C1_SMBUS_TIMEOUT : I2C1 SMBUS timeout mode stopped when Core is halted
117 * @arg DBGMCU_I2C2_SMBUS_TIMEOUT : I2C2 SMBUS timeout mode stopped when Core is halted
118 * @arg DBGMCU_I2C3_SMBUS_TIMEOUT : I2C3 SMBUS timeout mode stopped when Core is halted
119 * @arg DBGMCU_CAN1_STOP : Debug CAN1 stopped when Core is halted
120 * @arg DBGMCU_CAN2_STOP : Debug CAN2 stopped when Core is halted
121 *
122 * @retval None
123 */
DBGMCU_EnableAPB1Periph(uint32_t periph)124 void DBGMCU_EnableAPB1Periph(uint32_t periph)
125 {
126 DBGMCU->APB1F |= periph;
127 }
128
129 /*!
130 * @brief Disable APB1 peripheral behavior when the MCU is in Debug mode.
131 *
132 * @param periph: specifies the APB1 peripheral.
133 * This parameter can be any combination of the following values:
134 * @arg DBGMCU_TMR2_STOP : TMR2 counter stopped when Core is halted
135 * @arg DBGMCU_TMR3_STOP : TMR3 counter stopped when Core is halted
136 * @arg DBGMCU_TMR4_STOP : TMR4 counter stopped when Core is halted
137 * @arg DBGMCU_TMR5_STOP : TMR5 counter stopped when Core is halted
138 * @arg DBGMCU_TMR6_STOP : TMR6 counter stopped when Core is halted
139 * @arg DBGMCU_TMR7_STOP : TMR7 counter stopped when Core is halted
140 * @arg DBGMCU_TMR12_STOP : TMR12 counter stopped when Core is halted
141 * @arg DBGMCU_TMR13_STOP : TMR13 counter stopped when Core is halted
142 * @arg DBGMCU_TMR14_STOP : TMR14 counter stopped when Core is halted
143 * @arg DBGMCU_RTC_STOP : RTC Calendar and Wakeup counter stopped when Core is halted.
144 * @arg DBGMCU_WWDT_STOP : Debug WWDG stopped when Core is halted
145 * @arg DBGMCU_IWDT_STOP : Debug IWDG stopped when Core is halted
146 * @arg DBGMCU_I2C1_SMBUS_TIMEOUT : I2C1 SMBUS timeout mode stopped when Core is halted
147 * @arg DBGMCU_I2C2_SMBUS_TIMEOUT : I2C2 SMBUS timeout mode stopped when Core is halted
148 * @arg DBGMCU_I2C3_SMBUS_TIMEOUT : I2C3 SMBUS timeout mode stopped when Core is halted
149 * @arg DBGMCU_CAN1_STOP : Debug CAN1 stopped when Core is halted
150 * @arg DBGMCU_CAN1_STOP : Debug CAN2 stopped when Core is halted
151 *
152 * @retval None
153 */
DBGMCU_DisableAPB1Periph(uint32_t periph)154 void DBGMCU_DisableAPB1Periph(uint32_t periph)
155 {
156 DBGMCU->APB1F &= ~periph;
157 }
158
159 /*!
160 * @brief Enable APB2 peripheral behavior when the MCU is in Debug mode.
161 *
162 * @param periph: specifies the APB2 peripheral.
163 * This parameter can be any combination of the following values:
164 * @arg DBGMCU_TMR1_STOP : TMR1 counter stopped when Core is halted
165 * @arg DBGMCU_TMR8_STOP : TMR8 counter stopped when Core is halted
166 * @arg DBGMCU_TMR9_STOP : TMR9 counter stopped when Core is halted
167 * @arg DBGMCU_TMR10_STOP : TMR10 counter stopped when Core is halted
168 * @arg DBGMCU_TMR11_STOP : TMR11 counter stopped when Core is halted
169 *
170 * @retval None
171 */
DBGMCU_EnableAPB2Periph(uint32_t periph)172 void DBGMCU_EnableAPB2Periph(uint32_t periph)
173 {
174 DBGMCU->APB2F |= periph;
175 }
176
177 /*!
178 * @brief Disable APB2 peripheral behavior when the MCU is in Debug mode.
179 *
180 * @param periph: specifies the APB2 peripheral.
181 * This parameter can be any combination of the following values:
182 * @arg DBGMCU_TMR1_STOP : TMR1 counter stopped when Core is halted
183 * @arg DBGMCU_TMR8_STOP : TMR8 counter stopped when Core is halted
184 * @arg DBGMCU_TMR9_STOP : TMR9 counter stopped when Core is halted
185 * @arg DBGMCU_TMR10_STOP : TMR10 counter stopped when Core is halted
186 * @arg DBGMCU_TMR11_STOP : TMR11 counter stopped when Core is halted
187 *
188 * @retval None
189 */
DBGMCU_DisableAPB2Periph(uint32_t periph)190 void DBGMCU_DisableAPB2Periph(uint32_t periph)
191 {
192 DBGMCU->APB2F &= ~periph;
193 }
194
195 /**@} end of group DBGMCU_Functions */
196 /**@} end of group DBGMCU_Driver */
197 /**@} end of group APM32F4xx_StdPeriphDriver */
198