diff --git a/ports/ARMCM3-STM32F103/pal_lld.h b/ports/ARMCM3-STM32F103/pal_lld.h index 7c1bb4399..33e6f959a 100644 --- a/ports/ARMCM3-STM32F103/pal_lld.h +++ b/ports/ARMCM3-STM32F103/pal_lld.h @@ -198,8 +198,8 @@ typedef GPIO_TypeDef * ioportid_t; * code. */ #define pal_lld_writegroup(port, mask, offset, bits) { \ - (bus)->bus_portid->BSRR = ((~(bits) & (mask)) << (16 + (offset))) | \ - ((bits) & (mask)) << (offset); \ + (port)->BSRR = ((~(bits) & (mask)) << (16 + (offset))) | \ + (((bits) & (mask)) << (offset)); \ } /** @@ -207,15 +207,12 @@ typedef GPIO_TypeDef * ioportid_t; * * @param[in] port the port identifier * @param[in] pad the pad number within the port - * @param[out] value the logical value, the value must be @p 0 or @p 1 + * @param[out] bit the logical value, the value must be @p 0 or @p 1 * * @note This function is not meant to be invoked directly by the application * code. */ -#define pal_lld_writepad(port, pad, value) { \ - (bus)->bus_portid->BSRR = (((~(value) & 1) << ((pad) + 16)) | \ - ((((value) & 1) << (pad))); \ -} +#define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit) /** * @brief GPIO port setup. diff --git a/src/lib/pal.h b/src/lib/pal.h index 11137c6cb..cac306c43 100644 --- a/src/lib/pal.h +++ b/src/lib/pal.h @@ -31,6 +31,16 @@ #include "pal_lld.h" #endif +/** + * @brief Logical low state. + */ +#define PAL_LOW 0 + +/** + * @brief Logical high state. + */ +#define PAL_HIGH 1 + /** * @brief Port bit helper macro. * @details This macro calculates the mask of a bit within a port. @@ -241,7 +251,7 @@ typedef struct { * * @param[in] port the port identifier * @param[in] pad the pad number within the port - * @param[out] value the logical value, the value must be @p 0 or @p 1 + * @param[out] bit the logical value, the value must be @p 0 or @p 1 * * @note The operation is not guaranteed to be atomic on all the architectures, * for atomicity and/or portability reasons you may need to enclose port @@ -253,12 +263,12 @@ typedef struct { * @p palWritePort(). */ #if !defined(pal_lld_writepad) || defined(__DOXYGEN__) -#define palWritePad(port, pad, value) { \ +#define palWritePad(port, pad, bit) { \ palWritePort(port, (palReadLatch(port) & ~PAL_PORT_BIT(pad)) | \ - (((value) & 1) << pad)); \ + (((bit) & 1) << pad)); \ } #else -#define palWritePad(port, pad, value) pal_lld_writepad(port, pad, value) +#define palWritePad(port, pad, bit) pal_lld_writepad(port, pad, bit) #endif /**