8000 stmhal: Small simplification of code to tickle DMA idle counter. · micropython/micropython@522d454 · GitHub
[go: up one dir, main page]

Skip to content

Commit 522d454

Browse files
committed
stmhal: Small simplification of code to tickle DMA idle counter.
1 parent 3baf6b5 commit 522d454

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

stmhal/dma.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
#include "py/obj.h"
3434
#include "irq.h"
3535

36-
#define NSTREAMS_PER_CONTROLLER (8)
36+
#define NSTREAMS_PER_CONTROLLER_LOG2 (3)
37+
#define NSTREAMS_PER_CONTROLLER (1 << NSTREAMS_PER_CONTROLLER_LOG2)
3738
#define NCONTROLLERS (2)
3839
#define NSTREAM (NCONTROLLERS * NSTREAMS_PER_CONTROLLER)
3940

@@ -117,11 +118,7 @@ static int get_dma_id(DMA_Stream_TypeDef *dma_stream) {
117118

118119
// Resets the idle counter for the DMA controller associated with dma_id.
119120
static void dma_tickle(int dma_id) {
120-
if (dma_id < NSTREAMS_PER_CONTROLLER) {
121-
dma_idle.counter[0] = 1;
122-
} else {
123-
dma_idle.counter[1] = 1;
124-
}
121+
dma_idle.counter[(dma_id >> NSTREAMS_PER_CONTROLLER_LOG2) & 1] = 1;
125122
}
126123

127124
static void dma_enable_clock(int dma_id) {

0 commit comments

Comments
 (0)
0