L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
sys_debug.c
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4 * @file sys_debug.c
5 * @author MCD Application Team
6 * @brief Configure probes pins RealTime debugging and JTAG/SerialWires for LowPower
7 ******************************************************************************
8 * @attention
9 *
10 * Copyright (c) 2026 STMicroelectronics.
11 * All rights reserved.
12 *
13 * This software is licensed under terms that can be found in the LICENSE file
14 * in the root directory of this software component.
15 * If no LICENSE file comes with this software, it is provided AS-IS.
16 *
17 ******************************************************************************
18 */
19/* USER CODE END Header */
20
21/* Includes ------------------------------------------------------------------*/
22#include "platform.h"
23#include "sys_debug.h"
24
25/* USER CODE BEGIN Includes */
26
27/* USER CODE END Includes */
28
29/* External variables ---------------------------------------------------------*/
30/* USER CODE BEGIN EV */
31
32/* USER CODE END EV */
33
34/* Private typedef -----------------------------------------------------------*/
35/* USER CODE BEGIN PTD */
36
37/* USER CODE END PTD */
38
39/* Private define ------------------------------------------------------------*/
40/* USER CODE BEGIN PD */
41
42/* USER CODE END PD */
43
44/* Private macro -------------------------------------------------------------*/
45/* USER CODE BEGIN PM */
46
47/* USER CODE END PM */
48
49/* Private variables ---------------------------------------------------------*/
50/* USER CODE BEGIN PV */
51
52/* USER CODE END PV */
53
54/* Private function prototypes -----------------------------------------------*/
55/* USER CODE BEGIN PFP */
56
57/* USER CODE END PFP */
58
59/* Exported functions --------------------------------------------------------*/
60
61/**
62 * @brief Initializes the SW probes pins and the monitor RF pins via Alternate Function
63 */
64void DBG_Init(void)
65{
66 /* USER CODE BEGIN DBG_Init_1 */
67
68 /* USER CODE END DBG_Init_1 */
69
70 /* SW probes */
71#if defined (DEBUGGER_ENABLED) && ( DEBUGGER_ENABLED == 0 )
72 HAL_DBGMCU_DisableDBGSleepMode();
73 HAL_DBGMCU_DisableDBGStopMode();
74 HAL_DBGMCU_DisableDBGStandbyMode();
75#elif defined (DEBUGGER_ENABLED) && ( DEBUGGER_ENABLED == 1 )
76 /*Debug power up request wakeup CBDGPWRUPREQ*/
77 LL_EXTI_EnableIT_32_63(LL_EXTI_LINE_46);
78 /* Disabled HAL_DBGMCU_ */
79 HAL_DBGMCU_EnableDBGSleepMode();
80 HAL_DBGMCU_EnableDBGStopMode();
81 HAL_DBGMCU_EnableDBGStandbyMode();
82#elif !defined (DEBUGGER_ENABLED)
83#error "DEBUGGER_ENABLED not defined or out of range <0,1>"
84#endif /* DEBUGGER_OFF */
85
86#if (DEBUG_SUBGHZSPI_MONITORING_ENABLED == 1) || \
87 (DEBUG_RF_NRESET_ENABLED == 1) || \
88 (DEBUG_RF_HSE32RDY_ENABLED == 1) || \
89 (DEBUG_RF_SMPSRDY_ENABLED == 1) || \
90 (DEBUG_RF_LDORDY_ENABLED == 1) || \
91 (DEBUG_RF_DTB1_ENABLED == 1) || \
92 (DEBUG_RF_BUSY_ENABLED == 1)
93 GPIO_InitTypeDef GPIO_InitStruct = {0};
94#endif
95
96 /* USER CODE BEGIN DBG_Init_2 */
97
98 /* USER CODE END DBG_Init_2 */
99
100 /* HW alternate functions for monitoring RF */
101
102#if (DEBUG_SUBGHZSPI_MONITORING_ENABLED == 1)
103 /*spi dbg*/
104 GPIO_InitStruct.Pin = (GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
105 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
106 GPIO_InitStruct.Pull = GPIO_NOPULL;
107 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
108 GPIO_InitStruct.Alternate = GPIO_AF13_DEBUG_SUBGHZSPI;
109 __HAL_RCC_GPIOA_CLK_ENABLE();
110 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
111#endif /* DEBUG_SUBGHZSPI_MONITORING_ENABLED */
112
113#if (DEBUG_RF_NRESET_ENABLED == 1)
114 GPIO_InitStruct.Pin = GPIO_PIN_11;
115 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
116 GPIO_InitStruct.Pull = GPIO_NOPULL;
117 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
118 GPIO_InitStruct.Alternate = GPIO_AF13_DEBUG_RF;
119 __HAL_RCC_GPIOA_CLK_ENABLE();
120 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
121#endif /* DEBUG_RF_NRESET_ENABLED */
122
123#if (DEBUG_RF_HSE32RDY_ENABLED == 1)
124 GPIO_InitStruct.Pin = GPIO_PIN_10;
125 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
126 GPIO_InitStruct.Pull = GPIO_NOPULL;
127 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
128 GPIO_InitStruct.Alternate = GPIO_AF13_DEBUG_RF;
129 __HAL_RCC_GPIOA_CLK_ENABLE();
130 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
131#endif /* DEBUG_RF_HSE32RDY_ENABLED */
132
133#if (DEBUG_RF_SMPSRDY_ENABLED == 1)
134 GPIO_InitStruct.Pin = (GPIO_PIN_2);
135 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
136 GPIO_InitStruct.Pull = GPIO_NOPULL;
137 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
138 GPIO_InitStruct.Alternate = GPIO_AF13_DEBUG_RF;
139 __HAL_RCC_GPIOB_CLK_ENABLE();
140 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
141#endif /* DEBUG_RF_SMPSRDY_ENABLED */
142
143#if (DEBUG_RF_LDORDY_ENABLED == 1)
144 GPIO_InitStruct.Pin = (GPIO_PIN_4);
145 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
146 GPIO_InitStruct.Pull = GPIO_NOPULL;
147 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
148 GPIO_InitStruct.Alternate = GPIO_AF13_DEBUG_RF;
149 __HAL_RCC_GPIOB_CLK_ENABLE();
150 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
151#endif /* DEBUG_RF_LDORDY_ENABLED */
152
153#if (DEBUG_RF_DTB1_ENABLED == 1)
154 GPIO_InitStruct.Pin = GPIO_PIN_3;
155 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
156 GPIO_InitStruct.Pull = GPIO_NOPULL;
157 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
158 GPIO_InitStruct.Alternate = GPIO_AF13_DEBUG_RF;
159 __HAL_RCC_GPIOB_CLK_ENABLE();
160 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
161#endif /* DEBUG_RF_DTB1_ENABLED */
162
163#if (DEBUG_RF_BUSY_ENABLED == 1)
164 /* Busy */
165 GPIO_InitStruct.Pin = (GPIO_PIN_12);
166 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
167 GPIO_InitStruct.Pull = GPIO_NOPULL;
168 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
169 GPIO_InitStruct.Alternate = GPIO_AF6_RF_BUSY;
170 __HAL_RCC_GPIOA_CLK_ENABLE() ;
171 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
172#endif /* DEBUG_RF_BUSY_ENABLED */
173
174 /* USER CODE BEGIN DBG_Init_3 */
175
176 /* USER CODE END DBG_Init_3 */
177}
178
179/* USER CODE BEGIN EF */
180
181/* USER CODE END EF */
182
183/* Private Functions Definition -----------------------------------------------*/
184
185/* USER CODE BEGIN PrFD */
186
187/* USER CODE END PrFD */
Header for General HW instances configuration.
void DBG_Init(void)
Initializes the SW probes pins and the monitor RF pins via Alternate Function.
Definition sys_debug.c:64
Configuration of the debug.c instances.