Skip to content

Commit

Permalink
fix DMA resource tracking by properly masking off the channel index
Browse files Browse the repository at this point in the history
  • Loading branch information
GrumpyOldPizza committed Jun 13, 2016
1 parent ea0dcb3 commit b26526f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions system/libstm32l4_dragonfly/stm32l4_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,19 @@ static void stm32l4_dma_track(uint32_t channel, uint32_t address)
{
if (address < 0x40000000)
{
uint32_t mask = (1ul << (channel & 15));

if (address >= 0x20000000)
{
stm32l4_system_periph_cond_wake(SYSTEM_PERIPH_SRAM1, &stm32l4_dma_driver.sram1, (1ul << channel));
stm32l4_system_periph_cond_wake(SYSTEM_PERIPH_SRAM1, &stm32l4_dma_driver.sram1, mask);
}
else if (address >= 0x10000000)
{
stm32l4_system_periph_cond_wake(SYSTEM_PERIPH_SRAM2, &stm32l4_dma_driver.sram2, (1ul << channel));
stm32l4_system_periph_cond_wake(SYSTEM_PERIPH_SRAM2, &stm32l4_dma_driver.sram2, mask);
}
else
{
stm32l4_system_periph_cond_wake(SYSTEM_PERIPH_FLASH, &stm32l4_dma_driver.flash, (1ul << channel));
stm32l4_system_periph_cond_wake(SYSTEM_PERIPH_FLASH, &stm32l4_dma_driver.flash, mask);
}
}
}
Expand All @@ -108,17 +110,19 @@ static void stm32l4_dma_untrack(uint32_t channel, uint32_t address)
{
if (address < 0x40000000)
{
uint32_t mask = (1ul << (channel & 15));

if (address >= 0x20000000)
{
stm32l4_system_periph_cond_sleep(SYSTEM_PERIPH_SRAM1, &stm32l4_dma_driver.sram1, (1ul << channel));
stm32l4_system_periph_cond_sleep(SYSTEM_PERIPH_SRAM1, &stm32l4_dma_driver.sram1, mask);
}
else if (address >= 0x10000000)
{
stm32l4_system_periph_cond_sleep(SYSTEM_PERIPH_SRAM2, &stm32l4_dma_driver.sram2, (1ul << channel));
stm32l4_system_periph_cond_sleep(SYSTEM_PERIPH_SRAM2, &stm32l4_dma_driver.sram2, mask);
}
else
{
stm32l4_system_periph_cond_sleep(SYSTEM_PERIPH_FLASH, &stm32l4_dma_driver.flash, (1ul << channel));
stm32l4_system_periph_cond_sleep(SYSTEM_PERIPH_FLASH, &stm32l4_dma_driver.flash, mask);
}
}
}
Expand Down
Binary file modified variants/dragonfly/libstm32l4_dragonfly.a
Binary file not shown.

0 comments on commit b26526f

Please sign in to comment.