X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm32f1%2Fao_dma_stm.c;h=45bb88f31609c882487ac2e2eb0219ecbe9b6480;hb=HEAD;hp=d3162d5ba85c163261e4e3bc815cf4f02398c496;hpb=a080a564b9b54e6b3495d30703c45ba2850b1703;p=fw%2Faltos diff --git a/src/stm32f1/ao_dma_stm.c b/src/stm32f1/ao_dma_stm.c index d3162d5b..45bb88f3 100644 --- a/src/stm32f1/ao_dma_stm.c +++ b/src/stm32f1/ao_dma_stm.c @@ -66,6 +66,27 @@ void stm_dma1_channel7_isr(void) { ao_dma_isr(STM_DMA_INDEX(7)); } static uint8_t ao_dma_active; #endif +void +ao_dma_mutex_get(uint8_t index) +{ + if (ao_dma_allocated[index]) { + if (ao_dma_mutex[index]) + ao_panic(AO_PANIC_DMA); + ao_dma_mutex[index] = 0xff; + } else + ao_mutex_get(&ao_dma_mutex[index]); +} + +void +ao_dma_mutex_put(uint8_t index) +{ + if (ao_dma_allocated[index]) + ao_dma_mutex[index] = 0; + else + ao_mutex_put(&ao_dma_mutex[index]); +} + + void ao_dma_set_transfer(uint8_t index, volatile void *peripheral,