mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-15 06:59:22 +08:00
ea6d73f140
1. Upgrade Cortex driver library (CMSIS -> CMSIS & Device): version 2.3.2 -> 3.0.1 & 3.0.0 - Remove "bsp/efm32/Libraries/CMSIS/Lib/ARM", "bsp/efm32/Libraries/CMSIS/Lib/G++" and "bsp/efm32/Libraries/CMSIS/SVD" to save space 2. Upgrade EFM32 driver libraries (efm32lib -> emlib): version 2.3.2 -> 3.0.0 - Remove "bsp/efm32/Libraries/Device/EnergyMicro/EFM32LG" and "bsp/efm32/Libraries/Device/EnergyMicro/EFM32TG" to save space 3. Upgrade EFM32GG_DK3750 development kit driver library: version 1.2.2 -> 2.0.1 4. Upgrade EFM32_Gxxx_DK development kit driver library: version 1.7.3 -> 2.0.1 5. Add energy management unit driver and test code 6. Modify linker script and related code to compatible with new version of libraries 7. Change EFM32 branch version number to 1.0 8. Add photo frame demo application git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2122 bbd45198-f89e-11dd-88c7-29a3b14d5316
112 lines
4.0 KiB
C
112 lines
4.0 KiB
C
/**************************************************************************//**
|
|
* @file
|
|
* @brief SWO Trace API (for eAProfiler)
|
|
* @author Energy Micro AS
|
|
* @version 2.0.1
|
|
******************************************************************************
|
|
* @section License
|
|
* <b>(C) Copyright 2012 Energy Micro AS, http://www.energymicro.com</b>
|
|
*******************************************************************************
|
|
*
|
|
* Permission is granted to anyone to use this software for any purpose,
|
|
* including commercial applications, and to alter it and redistribute it
|
|
* freely, subject to the following restrictions:
|
|
*
|
|
* 1. The origin of this software must not be misrepresented; you must not
|
|
* claim that you wrote the original software.
|
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
* misrepresented as being the original software.
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
|
|
* microcontrollers and "EFR4" radios.
|
|
*
|
|
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
|
|
* obligation to support this Software. Energy Micro AS is providing the
|
|
* Software "AS IS", with no express or implied warranties of any kind,
|
|
* including, but not limited to, any implied warranties of merchantability
|
|
* or fitness for any particular purpose or warranties against infringement
|
|
* of any proprietary rights of a third party.
|
|
*
|
|
* Energy Micro AS will not be liable for any consequential, incidental, or
|
|
* special damages, or any other relief, or for any claim by any third party,
|
|
* arising from your use of this Software.
|
|
*
|
|
*****************************************************************************/
|
|
#include <stdbool.h>
|
|
#include "efm32.h"
|
|
#include "trace.h"
|
|
|
|
/***************************************************************************//**
|
|
* @addtogroup BSP
|
|
* @{
|
|
******************************************************************************/
|
|
|
|
/**************************************************************************//**
|
|
* @brief Configure trace output for energyAware Profiler
|
|
*****************************************************************************/
|
|
void TRACE_SWOSetup(void)
|
|
{
|
|
uint32_t *dwt_ctrl = (uint32_t *) 0xE0001000;
|
|
uint32_t *tpiu_prescaler = (uint32_t *) 0xE0040010;
|
|
uint32_t *tpiu_protocol = (uint32_t *) 0xE00400F0;
|
|
|
|
/* Enable GPIO clock */
|
|
CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
|
|
|
|
/* Enable Serial wire output pin */
|
|
GPIO->ROUTE |= GPIO_ROUTE_SWOPEN;
|
|
|
|
/* Set location 1 */
|
|
GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC1;
|
|
|
|
/* Enable output on pin */
|
|
GPIO->P[2].MODEH &= ~(_GPIO_P_MODEH_MODE15_MASK);
|
|
GPIO->P[2].MODEH |= GPIO_P_MODEH_MODE15_PUSHPULL;
|
|
|
|
/* Enable debug clock AUXHFRCO */
|
|
CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
|
|
|
|
/* Wait until clock is ready */
|
|
while(!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY));
|
|
|
|
/* Enable trace in core debug */
|
|
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
|
|
|
/* Enable PC and IRQ sampling output */
|
|
*dwt_ctrl = 0x400113FF;
|
|
|
|
/* Set TPIU prescaler to 16. */
|
|
*tpiu_prescaler = 0xf;
|
|
|
|
/* Set protocol to NRZ */
|
|
*tpiu_protocol = 2;
|
|
|
|
/* Unlock ITM and output data */
|
|
ITM->LAR = 0xC5ACCE55;
|
|
ITM->TCR = 0x10009;
|
|
}
|
|
|
|
/**************************************************************************//**
|
|
* @brief Profiler configuration
|
|
* @return true if energyAware Profiler/SWO is enabled, false if not
|
|
* @note If first word of the user page is zero, this will not
|
|
* enable SWO profiler output, see trace.h
|
|
*****************************************************************************/
|
|
bool TRACE_ProfilerSetup(void)
|
|
{
|
|
volatile uint32_t *userData = (uint32_t *) USER_PAGE;
|
|
|
|
/* Check magic "trace" word in user page */
|
|
if(*userData == 0x00000000UL)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
TRACE_SWOSetup();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/** @} (end group BSP) */
|