Merge pull request #12043 from petroborys/master

Modify itm_api.c for EFM32 targets
pull/12027/head
Martin Kojtal 2019-12-10 09:48:46 +01:00 committed by GitHub
commit b7c3b35d65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 80 additions and 17 deletions

View File

@ -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

View File

@ -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 \

View File

@ -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

View File

@ -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 \

View File

@ -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 \

View File

@ -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

View File

@ -19,6 +19,7 @@
#include "hal/itm_api.h"
#include "cmsis.h"
#include "em_cmu.h"
#include "device_peripherals.h"
#include <stdbool.h>
@ -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;
#if defined(_GPIO_ROUTE_MASK)
#define SWO_ROUTE ROUTE
#endif
#if defined(_GPIO_ROUTELOC0_MASK)
#define SWO_ROUTE ROUTELOC0
#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;
// 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;

View File

@ -6951,6 +6951,7 @@
"I2CSLAVE",
"I2C_ASYNCH",
"INTERRUPTIN",
"ITM",
"LPTICKER",
"PORTIN",
"PORTINOUT",