/* * Copyright (C) 2018 SoloKeys, Inc. * * This file is part of Solo. * * Solo is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Solo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Solo. If not, see * * This code is available under licenses for commercial use. * Please contact SoloKeys for more information. */ #include "em_chip.h" #include "em_cmu.h" #include "em_emu.h" #include "em_core.h" #include "em_usart.h" #include "em_gpio.h" #include #include #include "app.h" #ifndef PRINTING_USE_VCOM int RETARGET_WriteChar(char c) { return ITM_SendChar(c); } int RETARGET_ReadChar(void) { return 0; } void setupSWOForPrint(void) { /* Enable GPIO clock. */ CMU_ClockEnable(cmuClock_GPIO, true); /* Enable Serial wire output pin */ GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN; /* Set location 0 */ GPIO->ROUTELOC0 = GPIO_ROUTELOC0_SWVLOC_LOC0; /* 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; /* Enable debug clock AUXHFRCO */ CMU_OscillatorEnable(cmuOsc_AUXHFRCO, true, true); 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; ITM->LAR = 0xC5ACCE55; ITM->TER = 0x0; ITM->TCR = 0x0; TPI->SPPR = 2; TPI->ACPR = 0x15; // changed from 0x0F on Giant, etc. to account for 19 MHz default AUXHFRCO frequency ITM->TPR = 0x0; DWT->CTRL = 0x400003FE; ITM->TCR = 0x0001000D; TPI->FFCR = 0x00000100; ITM->TER = 0x1; } void printing_init() { setupSWOForPrint(); } #else int RETARGET_WriteChar(char c) { USART_Tx(USART0,c); return 0; } int RETARGET_ReadChar(void) { return 0; } void printing_init() { #ifdef USING_DEV_BOARD // GPIO_PinModeSet(gpioPortA,5,gpioModePushPull,1); // VCOM enable #endif } #endif