STM32: USB: endpoint buffer must be 4-bytes aligned
authorarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 27 Sep 2010 09:35:22 +0000 (09:35 +0000)
committerarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 27 Sep 2010 09:35:22 +0000 (09:35 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4309 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/cortex-m3/drv/usb_stm32.c

index e1fa5fbd48a90cc242e10554983fd394d326e312..752b8e2d35868d5ff845944690ecaeabac87c8c1 100644 (file)
@@ -1096,6 +1096,12 @@ ssize_t usb_endpointRead(int ep, void *buffer, ssize_t size)
 {
        int ep_num = usb_ep_logical_to_hw(ep);
 
+       if (UNLIKELY((size_t)buffer & 0x03))
+       {
+               LOG_ERR("unaligned buffer @ %p\n", buffer);
+               ASSERT(0);
+       }
+
        /* Non-blocking read for EP0 */
        if (ep_num == CTRL_ENP_OUT)
        {
@@ -1141,6 +1147,12 @@ ssize_t usb_endpointWrite(int ep, const void *buffer, ssize_t size)
 {
        int ep_num = usb_ep_logical_to_hw(ep);
 
+       if (UNLIKELY((size_t)buffer & 0x03))
+       {
+               LOG_ERR("unaligned buffer @ %p\n", buffer);
+               ASSERT(0);
+       }
+
        /* Non-blocking write for EP0 */
        if (ep_num == CTRL_ENP_IN)
        {