Skip to content

Commit

Permalink
- Fix a bug where DMA IRQ failed to lower
Browse files Browse the repository at this point in the history
- Fix output breaking test
  • Loading branch information
vintagepc committed Nov 4, 2023
1 parent e653e28 commit 3fb8734
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions hw/arm/prusa/stm32_common/stm32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ static bool create_if_not_exist(const char* default_name, uint32_t file_size)
bool exists = true;
if (access(default_name, R_OK | W_OK) == -1)
{
#ifndef CONFIG_GCOV
printf("%s not found - creating it.\n",default_name);
#endif
// Create it.
int fd = creat(default_name, S_IRUSR | S_IWUSR);
exists = (ftruncate(fd, file_size) != -1);
Expand Down
12 changes: 5 additions & 7 deletions hw/arm/prusa/stm32_common/stm32_f2xx_f4xx_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ enum interrupt_bits
INT_HTIF = 0b010000,
INT_TCIF = 0b100000,
INT_ALL = 0b111101,
INT_SxCR_MASK = 0b111100,
INT_SxCR_MASK = 0b111110,
INT_BLKSIZE = 6,
};

Expand Down Expand Up @@ -200,12 +200,10 @@ static void stm32_f2xx_f4xx_update_irqs(STM32F2XX_STRUCT_NAME(Dma) *s, uint8_t c

sr &= INT_ALL;

if (sr != 0)
if (sr != 0 && (sr & int_en))
{
if (sr & int_en) {
qemu_irq_raise(s->irq[channel]);
}
}
qemu_irq_raise(s->irq[channel]);
}
else
{
qemu_irq_lower(s->irq[channel]);
Expand Down Expand Up @@ -323,7 +321,7 @@ static void stm32_f2xx_f4xx_dma_do_xfer(STM32F2XX_STRUCT_NAME(Dma) *s, hwaddr ch
*dest += dest_inc;
*src += src_inc;

if (cr->HTIE && *ndtr == (s->original_ndtrs[channel]>>1U) )
if (*ndtr == (s->original_ndtrs[channel]>>1U) )
{
stm32_f2xx_f4xx_set_int_flag(s, channel, INT_HTIF);
}
Expand Down

0 comments on commit 3fb8734

Please sign in to comment.