[STM32F0] add support of autotrimming HSI to USB SOF frames

Signed-off-by: Frantisek Burian <BuFran@seznam.cz>
This commit is contained in:
Kuldeep Singh Dhaka
2014-03-20 22:55:31 +01:00
committed by Frantisek Burian
parent 3974e5f48d
commit 331acce4fc
3 changed files with 18 additions and 1 deletions

View File

@@ -29,4 +29,19 @@
*/
#include <libopencm3/stm32/crs.h>
#include <libopencm3/stm32/rcc.h>
/**
* This function enables autonatic trimming of internal RC oscillator by USB SOF
* frames
*/
void crs_autotrim_usb_enable(void)
{
rcc_periph_clock_enable(RCC_CRS);
CRS_CFGR &= ~CRS_CFGR_SYNCSRC;
CRS_CFGR |= CRS_CFGR_SYNCSRC_USB_SOF;
CRS_CR |= CRS_CR_AUTOTRIMEN;
CRS_CR |= CRS_CR_CEN;
}