libopencm3-examples
libopencm3-examples copied to clipboard
stm32F070 USB
Not sure if I'll have time to make a PR. Leaving this as a reminder and to share my findings. Actually a PR is probably not even the right thing to do anyway, since there is not really a devkit or popular hardware with an F070 ?
The F070 is a bit special in not having USB clock recovery , unlike the F072.
I essentially took examples/stm32/f4/stm32f4-discovery/usb_cdcacm/cdcacm.c and modified main.c thus :
// F070 can't do USB clock recovery , needs an external clock + PLL to derive the 48MHz ! Here using a 8M xtal
rcc_clock_setup_in_hse_8mhz_out_48mhz();
rcc_periph_clock_enable(RCC_USB);
rcc_set_usbclk_source(RCC_PLL);
rcc_periph_clock_enable(RCC_GPIOA);
//( Do not set USB pins to Alternate functions)
usbd_dev = usbd_init(&st_usbfs_v2_usb_driver, &dev, &config,
usb_strings, 3,
usbd_control_buffer, sizeof(usbd_control_buffer));