From b12629e93f75e4d8d0d750452d96d803f54489be Mon Sep 17 00:00:00 2001 From: arighi Date: Mon, 27 Sep 2010 09:35:22 +0000 Subject: [PATCH] STM32: USB: endpoint buffer must be 4-bytes aligned git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4309 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/cortex-m3/drv/usb_stm32.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bertos/cpu/cortex-m3/drv/usb_stm32.c b/bertos/cpu/cortex-m3/drv/usb_stm32.c index e1fa5fbd..752b8e2d 100644 --- a/bertos/cpu/cortex-m3/drv/usb_stm32.c +++ b/bertos/cpu/cortex-m3/drv/usb_stm32.c @@ -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) { -- 2.25.1