EFR32 Blue Gecko 1 Software Documentation  efr32bg1-doc-5.1.2
bsp_trace.h
Go to the documentation of this file.
1 /**************************************************************************/
16 #ifndef __BSP_TRACE_H
17 #define __BSP_TRACE_H
18 
19 #include "em_device.h"
20 #if (defined( BSP_ETM_TRACE ) && defined( ETM_PRESENT )) || \
21  defined( GPIO_ROUTE_SWOPEN ) || \
22  defined( GPIO_ROUTEPEN_SWVPEN )
23 
24 #include <stdint.h>
25 #include <stdbool.h>
26 #include "em_msc.h"
27 #include "traceconfig.h"
28 
29 /***************************************************************************/
33 /***************************************************************************/
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #if defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )
43 void BSP_TraceEtmSetup(void);
44 #endif
45 
46 #if defined( GPIO_ROUTE_SWOPEN ) || defined( _GPIO_ROUTEPEN_SWVPEN_MASK )
47 bool BSP_TraceProfilerSetup(void);
48 void BSP_TraceSwoSetup(void);
49 #endif
50 
52 #define USER_PAGE 0x0FE00000UL /* Address to flash memory */
53 
55 /**************************************************************************/
62 __STATIC_INLINE void BSP_TraceProfilerEnable(bool enable)
63 {
64  uint32_t data;
65  volatile uint32_t *userpage = (uint32_t *) USER_PAGE;
66 
67  /* Check that configuration needs to change */
68  data = *userpage;
69  if (enable)
70  {
71  if (data == 0xFFFFFFFF)
72  {
73  return;
74  }
75  }
76  else
77  {
78  if (data == 0x00000000)
79  {
80  return;
81  }
82  }
83 
84  /* Initialize MSC */
85  MSC_Init();
86 
87  /* Write enable or disable trigger word into flash */
88  if (enable)
89  {
90  data = 0xFFFFFFFF;
91  MSC_ErasePage((uint32_t *) USER_PAGE);
92  MSC_WriteWord((uint32_t *) USER_PAGE, (void *) &data, 4);
93  }
94  else
95  {
96  data = 0x00000000;
97  MSC_ErasePage((uint32_t *) USER_PAGE);
98  MSC_WriteWord((uint32_t *) USER_PAGE, (void *) &data, 4);
99  }
100 }
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
109 #endif /* (defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )) || defined( GPIO_ROUTE_SWOPEN ) */
110 #endif /* __BSP_TRACE_H */
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
void MSC_Init(void)
Enables the flash controller for writing.
Definition: em_msc.c:157
bool BSP_TraceProfilerSetup(void)
Profiler configuration.
Definition: bsp_trace.c:169
Flash controller (MSC) peripheral API.
__STATIC_INLINE void BSP_TraceProfilerEnable(bool enable)
Set or clear word in user page which enables or disables SWO in BSP_TraceProfilerSetup. If BSP_TraceProfilerEnable(false) has been run, no example project will enable SWO trace.
Definition: bsp_trace.h:62
void BSP_TraceSwoSetup(void)
Configure trace output for energyAware Profiler.
Definition: bsp_trace.c:98
MSC_RAMFUNC_DECLARATOR MSC_Status_TypeDef MSC_WriteWord(uint32_t *address, void const *data, uint32_t numBytes)
Writes data to flash memory. This function is interrupt safe, but slower than MSC_WriteWordFast(), which writes to flash with interrupts disabled. Write data must be aligned to words and contain a number of bytes that is divisable by four.
Definition: em_msc.c:839
MSC_RAMFUNC_DECLARATOR MSC_Status_TypeDef MSC_ErasePage(uint32_t *startAddress)
Erases a page in flash memory.
Definition: em_msc.c:748