From c86a5d888757ac3c861e0cf6d28671ea97bddc98 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 30 Nov 2013 09:14:06 +0000 Subject: Fixed bug #434. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6517 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/OTGv1/usb_lld.c | 6 +++--- os/ports/GCC/ARMCMx/chtypes.h | 5 +++++ os/ports/IAR/ARMCMx/chtypes.h | 5 +++++ os/ports/RVCT/ARMCMx/chtypes.h | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) (limited to 'os') diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.c b/os/hal/platforms/STM32/OTGv1/usb_lld.c index 4af75ccd2..35b5335e5 100644 --- a/os/hal/platforms/STM32/OTGv1/usb_lld.c +++ b/os/hal/platforms/STM32/OTGv1/usb_lld.c @@ -246,7 +246,7 @@ static uint8_t *otg_do_push(volatile uint32_t *fifop, uint8_t *buf, size_t n) { while (n > 0) { /* Note, this line relies on the Cortex-M3/M4 ability to perform unaligned word accesses and on the LSB-first memory organization.*/ - *fifop = *((uint32_t *)buf); + *fifop = *((PACKED_VAR uint32_t *)buf); buf += 4; n--; } @@ -345,7 +345,7 @@ static uint8_t *otg_do_pop(volatile uint32_t *fifop, uint8_t *buf, size_t n) { uint32_t w = *fifop; /* Note, this line relies on the Cortex-M3/M4 ability to perform unaligned word accesses and on the LSB-first memory organization.*/ - *((uint32_t *)buf) = w; + *((PACKED_VAR uint32_t *)buf) = w; buf += 4; n--; } @@ -374,7 +374,7 @@ static void otg_fifo_read_to_buffer(volatile uint32_t *fifop, if (max) { /* Note, this line relies on the Cortex-M3/M4 ability to perform unaligned word accesses and on the LSB-first memory organization.*/ - *((uint32_t *)buf) = w; + *((PACKED_VAR uint32_t *)buf) = w; buf += 4; max--; } diff --git a/os/ports/GCC/ARMCMx/chtypes.h b/os/ports/GCC/ARMCMx/chtypes.h index a94ae24ae..5116a79a7 100644 --- a/os/ports/GCC/ARMCMx/chtypes.h +++ b/os/ports/GCC/ARMCMx/chtypes.h @@ -75,6 +75,11 @@ typedef int32_t cnt_t; /**< Resources counter. */ */ #define PACK_STRUCT_END +/** + * @brief Packed variable specifier. + */ +#define PACKED_VAR __attribute__((packed)) + #endif /* _CHTYPES_H_ */ /** @} */ diff --git a/os/ports/IAR/ARMCMx/chtypes.h b/os/ports/IAR/ARMCMx/chtypes.h index 9855c4e00..d2a55bbfe 100644 --- a/os/ports/IAR/ARMCMx/chtypes.h +++ b/os/ports/IAR/ARMCMx/chtypes.h @@ -74,6 +74,11 @@ typedef int32_t cnt_t; /**< Resources counter. */ */ #define PACK_STRUCT_END +/** + * @brief Packed variable specifier. + */ +#define PACKED_VAR __packed + #endif /* _CHTYPES_H_ */ /** @} */ diff --git a/os/ports/RVCT/ARMCMx/chtypes.h b/os/ports/RVCT/ARMCMx/chtypes.h index b3f19f674..ec76fd523 100644 --- a/os/ports/RVCT/ARMCMx/chtypes.h +++ b/os/ports/RVCT/ARMCMx/chtypes.h @@ -74,6 +74,11 @@ typedef int32_t cnt_t; /**< Resources counter. */ */ #define PACK_STRUCT_END +/** + * @brief Packed variable specifier. + */ +#define PACKED_VAR __packed + #endif /* _CHTYPES_H_ */ /** @} */ -- cgit v1.2.3