Skip to content
This repository was archived by the owner on Jan 7, 2019. It is now read-only.

Commit 6328b4a

Browse files
committed
[stm32] Fix GpioPort mask for 32-bit registers
GpioPort::setOutput(), setInput() as well as configure() function access registers GPIOx->MODER, GPIOx->OSPEEDR and GPIOx->PUPDR, which contain 16x 2-bit values for each port, which are masked by `portMask2`. Even though `portMask2` had the correct width, its offset was wrong and therefore configured the wrong pins as output.
1 parent 857e514 commit 6328b4a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • src/xpcc/architecture/platform/driver/gpio/stm32

src/xpcc/architecture/platform/driver/gpio/stm32/gpio.hpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ class GpioPortBase<Gpio::Port::{{port.name}}, StartPin, Width, PortOrder> : publ
580580
static constexpr uint8_t StartPinReversed = (8 - StartPin - Width) + 8;
581581
static constexpr uint16_t dataMask = (1 << Width) - 1;
582582
static constexpr uint16_t portMask = dataMask << StartPin;
583-
static constexpr uint32_t portMask2 = portMask | (portMask << Width);
583+
static constexpr uint32_t portMask2 = (portMask | (portMask << Width)) << StartPin;
584584
static constexpr uint32_t port01 = 0x55555555 & portMask2;
585585
static constexpr uint32_t port10 = 0xAAAAAAAA & portMask2;
586586

0 commit comments

Comments
 (0)