aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/usbfs.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-10-13 14:24:50 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-10-13 14:33:23 -0400
commit1e8582e3f6cb13d85f06c740d7f79824c15a88be (patch)
tree2254827e1883ac296ca25ab76512262d7d2dd1de /src/stm32/usbfs.c
parent789659599cc711d9b45adf73dbd0cd66731a045c (diff)
downloadkutter-1e8582e3f6cb13d85f06c740d7f79824c15a88be.tar.gz
kutter-1e8582e3f6cb13d85f06c740d7f79824c15a88be.tar.xz
kutter-1e8582e3f6cb13d85f06c740d7f79824c15a88be.zip
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>
Diffstat (limited to 'src/stm32/usbfs.c')
-rw-r--r--src/stm32/usbfs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/stm32/usbfs.c b/src/stm32/usbfs.c
index a7a20548..ca66f513 100644
--- a/src/stm32/usbfs.c
+++ b/src/stm32/usbfs.c
@@ -34,7 +34,7 @@ struct ep_mem {
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_SIZE(s) ((s) > 32 ? (DIV_ROUND_UP((s), 32) << 10) | 0x8000 \
@@ -268,12 +268,12 @@ usb_init(void)
udelay(5000);
gpio_in_setup(GPIO('A', 12), 0);
- // Setup USB packet memory
- btable_configure();
-
// Enable USB clock
enable_pclock(USB_BASE);
+ // Setup USB packet memory
+ btable_configure();
+
// Reset usb controller and enable interrupts
USB->CNTR = USB_CNTR_FRES;
USB->BTABLE = 0;