diff options
author | Damien George <damien.p.george@gmail.com> | 2015-11-24 15:06:14 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-11-24 15:44:16 +0000 |
commit | 522d454e34e2132dc19ba929d9c92f511e9b1cd3 (patch) | |
tree | 11c823da977d19cc6f1df020906fbe2153bf6f27 | |
parent | 3baf6b531990dda109b9af065c94cf9eb9c0aac6 (diff) |
stmhal: Small simplification of code to tickle DMA idle counter.
-rw-r--r-- | stmhal/dma.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/stmhal/dma.c b/stmhal/dma.c index 2ecee7afc..7abd521be 100644 --- a/stmhal/dma.c +++ b/stmhal/dma.c @@ -33,7 +33,8 @@ #include "py/obj.h" #include "irq.h" -#define NSTREAMS_PER_CONTROLLER (8) +#define NSTREAMS_PER_CONTROLLER_LOG2 (3) +#define NSTREAMS_PER_CONTROLLER (1 << NSTREAMS_PER_CONTROLLER_LOG2) #define NCONTROLLERS (2) #define NSTREAM (NCONTROLLERS * NSTREAMS_PER_CONTROLLER) @@ -117,11 +118,7 @@ static int get_dma_id(DMA_Stream_TypeDef *dma_stream) { // Resets the idle counter for the DMA controller associated with dma_id. static void dma_tickle(int dma_id) { - if (dma_id < NSTREAMS_PER_CONTROLLER) { - dma_idle.counter[0] = 1; - } else { - dma_idle.counter[1] = 1; - } + dma_idle.counter[(dma_id >> NSTREAMS_PER_CONTROLLER_LOG2) & 1] = 1; } static void dma_enable_clock(int dma_id) { |