MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / Swo_Configuration

Function Swo_Configuration

bsp/efm32/board.c:200–241  ·  view source on GitHub ↗

/ * @brief * Enable SWO. * * @details * * @note * ******************************************************************************/

Source from the content-addressed store, hash-verified

198 *
199 ******************************************************************************/
200void Swo_Configuration(void)
201{
202 rt_uint32_t *dwt_ctrl = (rt_uint32_t *) 0xE0001000;
203 rt_uint32_t *tpiu_prescaler = (rt_uint32_t *) 0xE0040010;
204 rt_uint32_t *tpiu_protocol = (rt_uint32_t *) 0xE00400F0;
205
206 CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
207 /* Enable Serial wire output pin */
208 GPIO->ROUTE |= GPIO_ROUTE_SWOPEN;
209#if defined(_EFM32_GIANT_FAMILY)
210 /* Set location 0 */
211 GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC0;
212
213 /* Enable output on pin - GPIO Port F, Pin 2 */
214 GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK);
215 GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL;
216 #else
217 /* Set location 1 */
218 GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC1;
219 /* Enable output on pin */
220 GPIO->P[2].MODEH &= ~(_GPIO_P_MODEH_MODE15_MASK);
221 GPIO->P[2].MODEH |= GPIO_P_MODEH_MODE15_PUSHPULL;
222#endif
223 /* Enable debug clock AUXHFRCO */
224 CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
225
226 while(!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY));
227
228 /* Enable trace in core debug */
229 CoreDebug->DHCSR |= 1;
230 CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
231
232 /* Enable PC and IRQ sampling output */
233 *dwt_ctrl = 0x400113FF;
234 /* Set TPIU prescaler to 16. */
235 *tpiu_prescaler = 0xf;
236 /* Set protocol to NRZ */
237 *tpiu_protocol = 2;
238 /* Unlock ITM and output data */
239 ITM->LAR = 0xC5ACCE55;
240 ITM->TCR = 0x10009;
241}
242
243/***************************************************************************//**
244 * @brief

Callers 1

rt_hw_board_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected