53#include "interrupts.h"
56#define NVIC_EnableIRQ(_x) interrupt_enable(_x + 16)
57#define NVIC_DisableIRQ(_x) interrupt_disable(_x + 16)
58#define power_set() ( USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_PWRDWN )
59#ifdef USB_OTG_GCCFG_VBUSASEN
60#define vbus_enable() ( USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSASEN )
62#define vbus_enable() ( USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN )
86static inline void usb_hw_init(
void) {
87 uint16_t timeout = 10000;
89 RCC->IOPENR |= RCC_IOPENR_GPIOAEN;
91 RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
93 RCC->APB1ENR |= RCC_APB1ENR_USBEN;
95 RCC->CRRCR |= RCC_CRRCR_HSI48ON;
99 }
while(!(RCC->CRRCR & RCC_CRRCR_HSI48RDY) || (0 == timeout));
102 SYSCFG->CFGR3 = SYSCFG_CFGR3_ENREF_HSI48;
104 RCC->CCIPR |= RCC_CCIPR_HSI48SEL;