24 CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
27 GPIO->ROUTE |= GPIO_ROUTE_SWOPEN;
29 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_LEOPARD_FAMILY) || defined(_EFM32_WONDER_FAMILY) 31 GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC0;
34 GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK);
35 GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL;
38 GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK))
39 | GPIO_ROUTE_SWLOCATION_LOC1;
41 GPIO->P[2].MODEH &= ~(_GPIO_P_MODEH_MODE15_MASK);
42 GPIO->P[2].MODEH |= GPIO_P_MODEH_MODE15_PUSHPULL;
46 CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
49 while (!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY))
53 CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
54 ITM->LAR = 0xC5ACCE55;
60 DWT->CTRL = 0x400003FE;
61 ITM->TCR = 0x0001000D;
62 TPI->FFCR = 0x00000100;
69 int _write(
int file,
const char *ptr,
int len) {
71 for (x = 0; x < len; x++) {
81 CMU_ClockEnable(cmuClock_GPIO,
true);
82 GPIO_PinModeSet(gpioPortD, 7, gpioModePushPullDrive, 0);
86 GPIO_PinOutSet(gpioPortD, 7);
90 GPIO_PinOutClear(gpioPortD, 7);
94 GPIO_PinOutToggle(gpioPortD, 7);
103 CMU_ClockEnable(cmuClock_GPIO,
true);
104 GPIO_PinModeSet(gpioPortD, 8, gpioModeInput, 0);
105 GPIO_PinModeSet(gpioPortB, 11, gpioModeInput, 0);
116 TIMER_InitCC_TypeDef timerCCInit = {
117 .eventCtrl = timerEventEveryEdge,
118 .edge = timerEdgeNone,
119 .prsSel = timerPRSSELCh0,
120 .cufoa = timerOutputActionNone,
121 .cofoa = timerOutputActionSet,
122 .cmoa = timerOutputActionClear,
123 .mode = timerCCModePWM,
130 TIMER_Init_TypeDef timerInit = {
133 .prescale = timerPrescale256,
134 .clkSel = timerClkSelHFPerClk,
135 .fallAction = timerInputActionNone,
136 .riseAction = timerInputActionNone,
146 CMU_ClockEnable(cmuClock_TIMER1,
true);
149 SLEEP_SleepBlockBegin(sleepEM2);
151 TIMER_InitCC(TIMER1, 1, &timerCCInit);
152 TIMER1->ROUTE |= (TIMER_ROUTE_CC1PEN | TIMER_ROUTE_LOCATION_LOC4);
155 TIMER_CompareBufSet(TIMER1, 1,
pwm_value);
156 TIMER_Init(TIMER1, &timerInit);
160 ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
161 ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
164 CMU_ClockEnable(cmuClock_ADC0,
true);
167 SLEEP_SleepBlockBegin(sleepEM2);
170 ADC_Init(ADC0, &init);
173 singleInit.reference = adcRefVDD;
174 singleInit.input = adcSingleInpCh6;
176 ADC_InitSingle(ADC0, &singleInit);
static void BSP_LedInit(void)
Init LED GPIO.
static void setupSWOForPrint(void)
Initialize SWO to be used by printf.
void LedOff(void)
Switch off LED.
void BSP_Init(void)
Init all BSP functions.
int _write(int file, const char *ptr, int len)
write function to be used by printf
void ADCConfig(void)
ADC init.
void PWMConfig(void)
PWM (Timer) init.
void LedToggle(void)
Switch off LED.
void LedOn(void)
Switch on LED.
Basic BSP enabling printf.
static void BSP_ButtonsInit()
Init buttons GPIOs.
volatile uint32_t pwm_value