Adds a lot of code, makes IRQs a bit less efficient, but is very useful
for debugging. Usage: pyb.irq_stats() returns a memory view that can be
read and written, eg:
list(pyb.irq_stats())
pyb.irq_stats()[0]
pyb.irq_stats()[0] = 0
The patch provides general IRQ_ENTER() and IRQ_EXIT() macros that can be
modified to provide further IRQ statistics if desired.
Turning on each DMA block increases the current consumption
by about 8 mA. This code adds an idle timer for each DMA
block and turns off the clocks when no streams are in use
for 128 msec. Having a small timeout allows for improved
performance when back-to-back transfers are being performed.
The 128 msec is basically a guess.
This removes hard-coded DMA init params from dma_init(), instead defining
these parameters in a DMA_InitTypeDef struct that gets passed as an
argument to dma_init()
This makes dma_init more generic so it can be used for I2S and SD Card,
which require different initialization parameters.