Skip to content

Commit b7c3b35

Browse files
authored
Merge pull request #12043 from petroborys/master
Modify itm_api.c for EFM32 targets
2 parents 09a2db0 + 8bee5f3 commit b7c3b35

File tree

8 files changed

+80
-17
lines changed

8 files changed

+80
-17
lines changed

targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/TARGET_EFM32GG_STK3700/device_peripherals.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
#define PWM_TIMER_CLOCK cmuClock_TIMER2
3434
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1
3535

36+
/* Set SWO location */
37+
#if DEVICE_ITM
38+
/* Set location 0 */
39+
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTE_SWLOCATION_MASK) | GPIO_ROUTE_SWLOCATION_LOC0
40+
/* Enable output on pin */
41+
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
42+
#define SWO_MODE MODEL
43+
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
44+
#endif
45+
3646
/* USB */
3747
#define USB_TIMER USB_TIMER1
3848

targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG11/TARGET_EFM32GG11_STK3701/device_peripherals.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@
3333
#define PWM_TIMER_CLOCK cmuClock_TIMER1
3434
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1
3535

36+
/* Set SWO location */
37+
#if DEVICE_ITM
38+
/* Set location 0 */
39+
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTELOC0_SWVLOC_MASK) | GPIO_ROUTELOC0_SWVLOC_LOC0
40+
/* Enable output on pin */
41+
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
42+
#define SWO_MODE MODEL
43+
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
44+
45+
/* Set location 1 */
46+
/*
47+
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTELOC0_SWVLOC_MASK) | GPIO_ROUTELOC0_SWVLOC_LOC1
48+
// Enable output on pin
49+
#define GPIO_PORT 2 // GPIO port number (A = 0, B = 1, ...)
50+
#define SWO_MODE MODEH
51+
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEH_MODE15_MASK) | GPIO_P_MODEH_MODE15_PUSHPULL
52+
*/
53+
#endif
54+
3655
/* Crystal calibration */
3756
#if !defined(CMU_HFXOINIT_STK_DEFAULT)
3857
#define CMU_HFXOINIT_STK_DEFAULT \

targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32LG/TARGET_EFM32LG_STK3600/device_peripherals.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
#define PWM_TIMER_CLOCK cmuClock_TIMER2
3434
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1
3535

36+
/* Set SWO location */
37+
#if DEVICE_ITM
38+
/* Set location 0 */
39+
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTE_SWLOCATION_MASK) | GPIO_ROUTE_SWLOCATION_LOC0
40+
/* Enable output on pin */
41+
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
42+
#define SWO_MODE MODEL
43+
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
44+
#endif
45+
3646
/* USB */
3747
#define USB_TIMER USB_TIMER1
3848

targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32PG/TARGET_EFM32PG_STK3401/device_peripherals.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
#define PWM_TIMER_CLOCK cmuClock_TIMER1
3434
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1
3535

36+
/* Set SWO location */
37+
#if DEVICE_ITM
38+
/* Set location 0 */
39+
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTELOC0_SWVLOC_MASK) | GPIO_ROUTELOC0_SWVLOC_LOC0
40+
/* Enable output on pin */
41+
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
42+
#define SWO_MODE MODEL
43+
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
44+
#endif
45+
3646
/* Crystal Calibration */
3747
#if !defined(CMU_HFXOINIT_STK_DEFAULT)
3848
#define CMU_HFXOINIT_STK_DEFAULT \

targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32PG12/TARGET_EFM32PG12_STK3402/device_peripherals.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
#define PWM_TIMER_CLOCK cmuClock_TIMER1
3434
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1
3535

36+
/* Set SWO location */
37+
#if DEVICE_ITM
38+
/* Set location 0 */
39+
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTELOC0_SWVLOC_MASK) | GPIO_ROUTELOC0_SWVLOC_LOC0
40+
/* Enable output on pin */
41+
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
42+
#define SWO_MODE MODEL
43+
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
44+
#endif
45+
3646
/* Crystal calibration */
3747
#if !defined(CMU_HFXOINIT_STK_DEFAULT)
3848
#define CMU_HFXOINIT_STK_DEFAULT \

targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32WG/TARGET_EFM32WG_STK3800/device_peripherals.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
#define PWM_TIMER_CLOCK cmuClock_TIMER2
3434
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1
3535

36+
/* Set SWO location */
37+
#if DEVICE_ITM
38+
/* Set location 0 */
39+
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTE_SWLOCATION_MASK) | GPIO_ROUTE_SWLOCATION_LOC0
40+
/* Enable output on pin */
41+
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
42+
#define SWO_MODE MODEL
43+
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
44+
#endif
45+
3646
/* USB */
3747
#define USB_TIMER USB_TIMER1
3848

targets/TARGET_Silicon_Labs/TARGET_EFM32/itm_api.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "hal/itm_api.h"
2020
#include "cmsis.h"
2121
#include "em_cmu.h"
22+
#include "device_peripherals.h"
2223

2324
#include <stdbool.h>
2425

@@ -40,26 +41,18 @@ static void setupSWOForPrint(void)
4041
GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN;
4142
#endif
4243
#endif
43-
44-
#if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_LEOPARD_FAMILY) || defined(_EFM32_WONDER_FAMILY) || defined(_EFM32_PEARL_FAMILY)
45-
// Set location 0
46-
#if defined( _GPIO_ROUTE_SWOPEN_MASK )
47-
GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC0;
48-
#elif defined( _GPIO_ROUTEPEN_SWVPEN_MASK )
49-
GPIO->ROUTELOC0 = (GPIO->ROUTELOC0 & ~(_GPIO_ROUTELOC0_SWVLOC_MASK)) | GPIO_ROUTELOC0_SWVLOC_LOC0;
50-
#endif
5144

52-
// Enable output on pin - GPIO Port F, Pin 2
53-
GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK);
54-
GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL;
55-
#else
56-
// Set location 1
57-
GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC1;
45+
#if defined(_GPIO_ROUTE_MASK)
46+
#define SWO_ROUTE ROUTE
47+
#endif
48+
#if defined(_GPIO_ROUTELOC0_MASK)
49+
#define SWO_ROUTE ROUTELOC0
50+
#endif
5851

52+
// Set SWO location
53+
GPIO->SWO_ROUTE = SWO_LOCATION;
5954
// Enable output on pin
60-
GPIO->P[2].MODEH &= ~(_GPIO_P_MODEH_MODE15_MASK);
61-
GPIO->P[2].MODEH |= GPIO_P_MODEH_MODE15_PUSHPULL;
62-
#endif
55+
GPIO->P[GPIO_PORT].SWO_MODE = SWO_ENABLE_OUTPUT_PIN;
6356

6457
// Enable debug clock AUXHFRCO
6558
CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;

targets/targets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6951,6 +6951,7 @@
69516951
"I2CSLAVE",
69526952
"I2C_ASYNCH",
69536953
"INTERRUPTIN",
6954+
"ITM",
69546955
"LPTICKER",
69556956
"PORTIN",
69566957
"PORTINOUT",

0 commit comments

Comments
 (0)