Skip to content

Commit 74c513d

Browse files
committed
Fix nasty bug in word and bytewise register access
1 parent 3b07d24 commit 74c513d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

hw/arm/prusa/stm32f407/stm32f2xx_flashint.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void
5353
stm32f2xx_fint_write(void *arg, hwaddr addr, uint64_t data, unsigned int size)
5454
{
5555
stm32f2xx_fint *s = arg;
56-
int offset = addr % 3;
56+
int offset = addr & 0x03;
5757

5858
addr >>= 2;
5959
if (addr > STM32_FINT_MAX) {

hw/arm/prusa/stm32f407/stm32f2xx_gpio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static void
9696
stm32f2xx_gpio_write(void *arg, hwaddr addr, uint64_t data, unsigned int size)
9797
{
9898
stm32f2xx_gpio *s = arg;
99-
int offset = addr % 3;
99+
int offset = addr & 0x03;
100100

101101
addr >>= 2;
102102
if (addr > STM32_GPIO_MAX) {

hw/arm/prusa/stm32f407/stm32f4xx_itm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void
5353
stm32f4xx_itm_write(void *arg, hwaddr addr, uint64_t data, unsigned int size)
5454
{
5555
stm32f4xx_itm *s = arg;
56-
int offset = addr % 3;
56+
int offset = addr & 0x03;
5757

5858
addr >>= 2;
5959
if (addr > R_ITM_MAX) {

0 commit comments

Comments
 (0)