From dde82c6051089a009dd6ca5e440dcfafd33991f0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Oct 2018 11:37:59 +0000 Subject: Improved type robustness of STM32 GPIO PAL drivers. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12393 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'os/hal/ports/STM32/LLD/GPIOv2') diff --git a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h index 5aaa0bf28..1d9033753 100644 --- a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h +++ b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h @@ -328,7 +328,7 @@ typedef uint32_t iopadid_t; * * @notapi */ -#define pal_lld_readport(port) ((port)->IDR) +#define pal_lld_readport(port) ((ioportmask_t)((port)->IDR)) /** * @brief Reads the output latch. @@ -342,7 +342,7 @@ typedef uint32_t iopadid_t; * * @notapi */ -#define pal_lld_readlatch(port) ((port)->ODR) +#define pal_lld_readlatch(port) ((ioportmask_t)((port)->ODR)) /** * @brief Writes on a I/O port. @@ -354,7 +354,7 @@ typedef uint32_t iopadid_t; * * @notapi */ -#define pal_lld_writeport(port, bits) ((port)->ODR = (bits)) +#define pal_lld_writeport(port, bits) ((port)->ODR = (uint32_t)(bits)) /** * @brief Sets a bits mask on a I/O port. @@ -393,9 +393,11 @@ typedef uint32_t iopadid_t; * * @notapi */ -#define pal_lld_writegroup(port, mask, offset, bits) \ - ((port)->BSRR.W = ((~(bits) & (mask)) << (16U + (offset))) | \ - (((bits) & (mask)) << (offset))) +#define pal_lld_writegroup(port, mask, offset, bits) { \ + uint32_t w = ((~(uint32_t)(bits) & (uint32_t)(mask)) << (16U + (offset))) | \ + ((uint32_t)(bits) & (uint32_t)(mask)) << (offset); \ + (port)->BSRR.W = w; \ +} /** * @brief Pads group mode setup. -- cgit v1.2.3