Skip to content

Modify itm_api.c for EFM32 targets #12043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
#define PWM_TIMER_CLOCK cmuClock_TIMER2
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1

/* Set SWO location */
#if DEVICE_ITM
/* Set location 0 */
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTE_SWLOCATION_MASK) | GPIO_ROUTE_SWLOCATION_LOC0
/* Enable output on pin */
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
#define SWO_MODE MODEL
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
#endif

/* USB */
#define USB_TIMER USB_TIMER1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@
#define PWM_TIMER_CLOCK cmuClock_TIMER1
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1

/* Set SWO location */
#if DEVICE_ITM
/* Set location 0 */
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTELOC0_SWVLOC_MASK) | GPIO_ROUTELOC0_SWVLOC_LOC0
/* Enable output on pin */
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
#define SWO_MODE MODEL
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL

/* Set location 1 */
/*
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTELOC0_SWVLOC_MASK) | GPIO_ROUTELOC0_SWVLOC_LOC1
// Enable output on pin
#define GPIO_PORT 2 // GPIO port number (A = 0, B = 1, ...)
#define SWO_MODE MODEH
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEH_MODE15_MASK) | GPIO_P_MODEH_MODE15_PUSHPULL
*/
#endif

/* Crystal calibration */
#if !defined(CMU_HFXOINIT_STK_DEFAULT)
#define CMU_HFXOINIT_STK_DEFAULT \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
#define PWM_TIMER_CLOCK cmuClock_TIMER2
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1

/* Set SWO location */
#if DEVICE_ITM
/* Set location 0 */
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTE_SWLOCATION_MASK) | GPIO_ROUTE_SWLOCATION_LOC0
/* Enable output on pin */
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
#define SWO_MODE MODEL
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
#endif

/* USB */
#define USB_TIMER USB_TIMER1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
#define PWM_TIMER_CLOCK cmuClock_TIMER1
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1

/* Set SWO location */
#if DEVICE_ITM
/* Set location 0 */
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTELOC0_SWVLOC_MASK) | GPIO_ROUTELOC0_SWVLOC_LOC0
/* Enable output on pin */
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
#define SWO_MODE MODEL
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
#endif

/* Crystal Calibration */
#if !defined(CMU_HFXOINIT_STK_DEFAULT)
#define CMU_HFXOINIT_STK_DEFAULT \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
#define PWM_TIMER_CLOCK cmuClock_TIMER1
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1

/* Set SWO location */
#if DEVICE_ITM
/* Set location 0 */
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTELOC0_SWVLOC_MASK) | GPIO_ROUTELOC0_SWVLOC_LOC0
/* Enable output on pin */
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
#define SWO_MODE MODEL
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
#endif

/* Crystal calibration */
#if !defined(CMU_HFXOINIT_STK_DEFAULT)
#define CMU_HFXOINIT_STK_DEFAULT \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
#define PWM_TIMER_CLOCK cmuClock_TIMER2
#define PWM_ROUTE TIMER_ROUTE_LOCATION_LOC1

/* Set SWO location */
#if DEVICE_ITM
/* Set location 0 */
#define SWO_LOCATION (GPIO->SWO_ROUTE & ~_GPIO_ROUTE_SWLOCATION_MASK) | GPIO_ROUTE_SWLOCATION_LOC0
/* Enable output on pin */
#define GPIO_PORT 5 // GPIO port number (A = 0, B = 1, ...)
#define SWO_MODE MODEL
#define SWO_ENABLE_OUTPUT_PIN (GPIO->P[GPIO_PORT].SWO_MODE & ~_GPIO_P_MODEL_MODE2_MASK) | GPIO_P_MODEL_MODE2_PUSHPULL
#endif

/* USB */
#define USB_TIMER USB_TIMER1

Expand Down
27 changes: 10 additions & 17 deletions targets/TARGET_Silicon_Labs/TARGET_EFM32/itm_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "hal/itm_api.h"
#include "cmsis.h"
#include "em_cmu.h"
#include "device_peripherals.h"

#include <stdbool.h>

Expand All @@ -40,26 +41,18 @@ static void setupSWOForPrint(void)
GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN;
#endif
#endif

#if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_LEOPARD_FAMILY) || defined(_EFM32_WONDER_FAMILY) || defined(_EFM32_PEARL_FAMILY)
// Set location 0
#if defined( _GPIO_ROUTE_SWOPEN_MASK )
GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC0;
#elif defined( _GPIO_ROUTEPEN_SWVPEN_MASK )
GPIO->ROUTELOC0 = (GPIO->ROUTELOC0 & ~(_GPIO_ROUTELOC0_SWVLOC_MASK)) | GPIO_ROUTELOC0_SWVLOC_LOC0;
#endif

// Enable output on pin - GPIO Port F, Pin 2
GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK);
GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL;
#else
// Set location 1
GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC1;
#if defined(_GPIO_ROUTE_MASK)
#define SWO_ROUTE ROUTE
#endif
#if defined(_GPIO_ROUTELOC0_MASK)
#define SWO_ROUTE ROUTELOC0
#endif

// Set SWO location
GPIO->SWO_ROUTE = SWO_LOCATION;
// Enable output on pin
GPIO->P[2].MODEH &= ~(_GPIO_P_MODEH_MODE15_MASK);
GPIO->P[2].MODEH |= GPIO_P_MODEH_MODE15_PUSHPULL;
#endif
GPIO->P[GPIO_PORT].SWO_MODE = SWO_ENABLE_OUTPUT_PIN;

// Enable debug clock AUXHFRCO
CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
Expand Down
4 changes: 3 additions & 1 deletion targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6953,6 +6953,7 @@
"I2CSLAVE",
"I2C_ASYNCH",
"INTERRUPTIN",
"ITM",
"LPTICKER",
"PORTIN",
"PORTINOUT",
Expand All @@ -6970,7 +6971,8 @@
"USTICKER",
"TRNG",
"FLASH",
"MPU"
"MPU",
"WATCHDOG"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this watchdog change, is it just reorg or was watchdog actually added ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just reorg to fix the conflict.

],
"forced_reset_timeout": 5,
"config": {
Expand Down