1 /*!
2  * @file        apm32s10x_dbgmcu.c
3  *
4  * @brief       This file provides all the DEBUG firmware functions
5  *
6  * @version     V1.0.1
7  *
8  * @date        2022-12-31
9  *
10  * @attention
11  *
12  *  Copyright (C) 2022-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 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 /* Includes */
27 #include "apm32s10x_dbgmcu.h"
28 
29 /** @addtogroup APM32S10x_StdPeriphDriver
30   @{
31 */
32 
33 /** @addtogroup DBGMCU_Driver DBGMCU Driver
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_IOEN              : Trace Debug Pin Enable
75  *                      @arg DBGMCU_IOMODE0           : Trace Debug Pin Mode Configure Asynchronization
76  *                      @arg DBGMCU_IOMODE1           : Trace Debug Pin Mode Configure Synchronizer data size one
77  *                      @arg DBGMCU_IOMODE2           : Trace Debug Pin Mode Configure Synchronizer data size two
78  *                      @arg DBGMCU_IOMODE3           : Trace Debug Pin Mode Configure Synchronizer data size four
79  *                      @arg DBGMCU_IWDT_STOP         : Debug IWDT stopped when Core is halted
80  *                      @arg DBGMCU_WWDT_STOP         : Debug WWDT stopped when Core is halted
81  *                      @arg DBGMCU_TMR1_STOP         : TMR1 counter stopped when Core is halted
82  *                      @arg DBGMCU_TMR2_STOP         : TMR2 counter stopped when Core is halted
83  *                      @arg DBGMCU_TMR3_STOP         : TMR3 counter stopped when Core is halted
84  *                      @arg DBGMCU_TMR4_STOP         : TMR4 counter stopped when Core is halted
85  *                      @arg DBGMCU_CAN1_STOP         : Debug CAN1 stopped when Core is halted
86  *                      @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
87  *                      @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
88  *                      @arg DBGMCU_CAN2_STOP         : Debug CAN2 stopped when Core is halted
89  *
90  * @retval      None
91  */
DBGMCU_Enable(uint32_t periph)92 void DBGMCU_Enable(uint32_t periph)
93 {
94     DBGMCU->CFG |= periph;
95 }
96 
97 /*!
98  * @brief       Enable the specified peripheral and low power mode behavior
99  *              when the MCU under Debug mode
100  *
101  * @param       periph: Specifies the peripheral and low power mode
102  *                      This parameter can be any combination of the following values:
103  *                      @arg DBGMCU_SLEEP             : Keep debugger connection during SLEEP mode
104  *                      @arg DBGMCU_STOP              : Keep debugger connection during STOP mode
105  *                      @arg DBGMCU_STANDBY           : Keep debugger connection during STANDBY mode
106  *                      @arg DBGMCU_IOEN              : Trace Debug Pin Enable
107  *                      @arg DBGMCU_IOMODE0           : Trace Debug Pin Mode Configure Asynchronization
108  *                      @arg DBGMCU_IOMODE1           : Trace Debug Pin Mode Configure Synchronizer data size one
109  *                      @arg DBGMCU_IOMODE2           : Trace Debug Pin Mode Configure Synchronizer data size two
110  *                      @arg DBGMCU_IOMODE3           : Trace Debug Pin Mode Configure Synchronizer data size four
111  *                      @arg DBGMCU_IWDT_STOP         : Debug IWDT stopped when Core is halted
112  *                      @arg DBGMCU_WWDT_STOP         : Debug WWDT stopped when Core is halted
113  *                      @arg DBGMCU_TMR1_STOP         : TMR1 counter stopped when Core is halted
114  *                      @arg DBGMCU_TMR2_STOP         : TMR2 counter stopped when Core is halted
115  *                      @arg DBGMCU_TMR3_STOP         : TMR3 counter stopped when Core is halted
116  *                      @arg DBGMCU_TMR4_STOP         : TMR4 counter stopped when Core is halted
117  *                      @arg DBGMCU_CAN1_STOP         : Debug CAN1 stopped when Core is halted
118  *                      @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
119  *                      @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
120  *                      @arg DBGMCU_CAN2_STOP         : Debug CAN2 stopped when Core is halted
121  *
122  * @retval      None
123  */
DBGMCU_Disable(uint32_t periph)124 void DBGMCU_Disable(uint32_t periph)
125 {
126     DBGMCU->CFG &= ~periph;
127 }
128 
129 /**@} end of group DBGMCU_Functions */
130 /**@} end of group DBGMCU_Driver */
131 /**@} end of group APM32S10x_StdPeriphDriver */
132