stm32: Make sure to turn on the usb clock before writing to the packet memory

The USB clock needs to be enabled prior to writing to the USB packet
memory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-10-13 14:24:50 -04:00
parent 789659599c
commit 1e8582e3f6
1 changed files with 4 additions and 4 deletions

View File

@ -34,7 +34,7 @@ struct ep_mem {
uint32_t ep_bulk_in_tx[USB_CDC_EP_BULK_IN_SIZE / 2]; uint32_t ep_bulk_in_tx[USB_CDC_EP_BULK_IN_SIZE / 2];
}; };
#define EPM ((struct ep_mem *)(USB_BASE + 0x400)) #define EPM ((struct ep_mem *)USB_PMAADDR)
#define CALC_ADDR(p) (((void*)(p) - (void*)EPM) / 2) #define CALC_ADDR(p) (((void*)(p) - (void*)EPM) / 2)
#define CALC_SIZE(s) ((s) > 32 ? (DIV_ROUND_UP((s), 32) << 10) | 0x8000 \ #define CALC_SIZE(s) ((s) > 32 ? (DIV_ROUND_UP((s), 32) << 10) | 0x8000 \
@ -268,12 +268,12 @@ usb_init(void)
udelay(5000); udelay(5000);
gpio_in_setup(GPIO('A', 12), 0); gpio_in_setup(GPIO('A', 12), 0);
// Setup USB packet memory
btable_configure();
// Enable USB clock // Enable USB clock
enable_pclock(USB_BASE); enable_pclock(USB_BASE);
// Setup USB packet memory
btable_configure();
// Reset usb controller and enable interrupts // Reset usb controller and enable interrupts
USB->CNTR = USB_CNTR_FRES; USB->CNTR = USB_CNTR_FRES;
USB->BTABLE = 0; USB->BTABLE = 0;