em_dbg.c

Go to the documentation of this file.
00001 /***************************************************************************/
00033 #include "em_dbg.h"
00034 
00035 #if defined ( CoreDebug_DHCSR_C_DEBUGEN_Msk )
00036 
00037 #include "em_assert.h"
00038 #include "em_cmu.h"
00039 #include "em_gpio.h"
00040 
00041 /***************************************************************************/
00046 /***************************************************************************/
00052 /*******************************************************************************
00053  **************************   GLOBAL FUNCTIONS   *******************************
00054  ******************************************************************************/
00055 
00056 #if defined( GPIO_ROUTE_SWOPEN )
00057 /***************************************************************************/
00088 void DBG_SWOEnable(unsigned int location)
00089 {
00090   int port;
00091   int pin;
00092 
00093   EFM_ASSERT(location < AFCHANLOC_MAX);
00094 
00095   port = AF_DBG_SWO_PORT(location);
00096   pin  = AF_DBG_SWO_PIN(location);
00097 
00098   /* Port/pin location not defined for device? */
00099   if ((pin < 0) || (port < 0))
00100   {
00101     EFM_ASSERT(0);
00102     return;
00103   }
00104 
00105   /* Ensure auxiliary clock going to the Cortex debug trace module is enabled */
00106   CMU_OscillatorEnable(cmuOsc_AUXHFRCO, true, false);
00107 
00108   /* Set selected pin location for SWO pin and enable it */
00109   GPIO_DbgLocationSet(location);
00110   GPIO_DbgSWOEnable(true);
00111 
00112   /* Configure SWO pin for output */
00113   GPIO_PinModeSet((GPIO_Port_TypeDef)port, pin, gpioModePushPull, 0);
00114 }
00115 #endif
00116 
00119 #endif /* defined ( CoreDebug_DHCSR_C_DEBUGEN_Msk ) */