diff options
Diffstat (limited to 'libhw/rp2040_dma.h')
-rw-r--r-- | libhw/rp2040_dma.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/libhw/rp2040_dma.h b/libhw/rp2040_dma.h index e4b44ff..c8d69b1 100644 --- a/libhw/rp2040_dma.h +++ b/libhw/rp2040_dma.h @@ -31,13 +31,26 @@ enum dma_channel_transfer_size { DMA_SIZE_32 = 2 ///< Word transfer (32 bits) }; -static inline bool dma_channel_is_busy(uint channel) { - assert(channel < NUM_DMA_CHANNELS); - return dma_hw->ch[channel].al1_ctrl & DMA_CH0_CTRL_TRIG_BUSY_BITS; -} - /* Our own code ***************************************************************/ +enum dmairq { + DMAIRQ_0 = DMA_IRQ_0, + DMAIRQ_1 = DMA_IRQ_1, +}; + +typedef void (*dmairq_handler_t)(void *arg, enum dmairq irq, uint channel); + +/** + * Register `fn(arg, ...)` to be called when `channel` completes or + * has a NULL trigger (depending on the channel's configuration). + * + * Your handler does not need to acknowledge the IRQ; that will be + * done for you after your handler is called. + * + * It is illegal to enable the same channel on more than one IRQ. + */ +void dmairq_set_and_enable_exclusive_handler(enum dmairq irq, uint channel, dmairq_handler_t fn, void *arg); + #define DMA_CTRL_ENABLE (1<<0) #define DMA_CTRL_HI_PRIO (1<<1) #define DMA_CTRL_DATA_SIZE(sz) ((sz)<<2) |