timer_enable_counter(TIM1);// enable timer to start blinking
}
}
voidled_blue(void)
{
timer_disable_counter(TIM1);// disable timer for PWM
gpio_set_mode(GPIO(LED_PORT),GPIO_MODE_OUTPUT_2_MHZ,GPIO_CNF_OUTPUT_PUSHPULL,GPIO(LED_PIN));// set LED pin to 'output push-pull'
gpio_set(GPIO(LED_PORT),GPIO(LED_PIN));
}
voidled_red(void)
{
timer_disable_counter(TIM1);// disable timer for PWM
gpio_set_mode(GPIO(LED_PORT),GPIO_MODE_OUTPUT_2_MHZ,GPIO_CNF_OUTPUT_PUSHPULL,GPIO(LED_PIN));// set LED pin to 'output push-pull'
gpio_clear(GPIO(LED_PORT),GPIO(LED_PIN));
}
#endif
voidsleep_us(uint32_tduration)
{
systick_counter_disable();// disable SysTick to reconfigure it
@ -213,16 +171,9 @@ void board_setup(void)
// setup LED
rcc_periph_clock_enable(RCC_GPIO(LED_PORT));// enable clock for LED
#if defined(BUSVOODOO)
// LED is connected to TIM1_CH1, allowing to used the PWM output so to display patterns
rcc_periph_clock_enable(RCC_TIM1);// enable clock for timer domain
timer_reset(TIM1);// reset timer configuration
timer_set_mode(TIM1,TIM_CR1_CKD_CK_INT,TIM_CR1_CMS_CENTER_1,TIM_CR1_DIR_UP);// configure timer to up counting mode (center aligned for more precise duty cycle control)
timer_set_oc_mode(TIM1,TIM_OC1,TIM_OCM_PWM1);// use PWM output compare mode