@@ -34,8 +34,12 @@ extern "C" {
34
34
* * Memory to memory
35
35
*/
36
36
37
- // this is not defined in generated dreq.h
38
- #define DREQ_FORCE 63
37
+ // these are not defined in generated dreq.h
38
+ #define DREQ_DMA_TIMER0 DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_TIMER0
39
+ #define DREQ_DMA_TIMER1 DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_TIMER1
40
+ #define DREQ_DMA_TIMER2 DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_TIMER2
41
+ #define DREQ_DMA_TIMER3 DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_TIMER3
42
+ #define DREQ_FORCE DMA_CH0_CTRL_TRIG_TREQ_SEL_VALUE_PERMANENT
39
43
40
44
// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_DMA, Enable/disable DMA assertions, type=bool, default=0, group=hardware_dma
41
45
#ifndef PARAM_ASSERTIONS_ENABLED_DMA
@@ -94,6 +98,16 @@ void dma_channel_unclaim(uint channel);
94
98
*/
95
99
int dma_claim_unused_channel (bool required );
96
100
101
+ /*! \brief Determine if a dma channel is claimed
102
+ * \ingroup hardware_dma
103
+ *
104
+ * \param channel the dma channel
105
+ * \return true if the channel is claimed, false otherwise
106
+ * \see dma_channel_claim
107
+ * \see dma_channel_claim_mask
108
+ */
109
+ bool dma_channel_is_claimed (uint channel );
110
+
97
111
/** \brief DMA channel configuration
98
112
* \defgroup channel_config channel_config
99
113
* \ingroup hardware_dma
@@ -465,7 +479,7 @@ static inline void dma_channel_abort(uint channel) {
465
479
while (dma_hw -> abort & (1ul << channel )) tight_loop_contents ();
466
480
}
467
481
468
- /*! \brief Enable single DMA channel interrupt 0
482
+ /*! \brief Enable single DMA channel's interrupt via DMA_IRQ_0
469
483
* \ingroup hardware_dma
470
484
*
471
485
* \param channel DMA channel
@@ -480,7 +494,7 @@ static inline void dma_channel_set_irq0_enabled(uint channel, bool enabled) {
480
494
hw_clear_bits (& dma_hw -> inte0 , 1u << channel );
481
495
}
482
496
483
- /*! \brief Enable multiple DMA channels interrupt 0
497
+ /*! \brief Enable multiple DMA channels' interrupts via DMA_IRQ_0
484
498
* \ingroup hardware_dma
485
499
*
486
500
* \param channel_mask Bitmask of all the channels to enable/disable. Channel 0 = bit 0, channel 1 = bit 1 etc.
@@ -494,7 +508,7 @@ static inline void dma_set_irq0_channel_mask_enabled(uint32_t channel_mask, bool
494
508
}
495
509
}
496
510
497
- /*! \brief Enable single DMA channel interrupt 1
511
+ /*! \brief Enable single DMA channel's interrupt via DMA_IRQ_1
498
512
* \ingroup hardware_dma
499
513
*
500
514
* \param channel DMA channel
@@ -509,7 +523,7 @@ static inline void dma_channel_set_irq1_enabled(uint channel, bool enabled) {
509
523
hw_clear_bits (& dma_hw -> inte1 , 1u << channel );
510
524
}
511
525
512
- /*! \brief Enable multiple DMA channels interrupt 0
526
+ /*! \brief Enable multiple DMA channels' interrupts via DMA_IRQ_1
513
527
* \ingroup hardware_dma
514
528
*
515
529
* \param channel_mask Bitmask of all the channels to enable/disable. Channel 0 = bit 0, channel 1 = bit 1 etc.
@@ -523,6 +537,105 @@ static inline void dma_set_irq1_channel_mask_enabled(uint32_t channel_mask, bool
523
537
}
524
538
}
525
539
540
+ /*! \brief Enable single DMA channel interrupt on either DMA_IRQ_0 or DMA_IRQ_1
541
+ * \ingroup hardware_dma
542
+ *
543
+ * \param irq_index the IRQ index; either 0 or 1 for DMA_IRQ_0 or DMA_IRQ_1
544
+ * \param channel DMA channel
545
+ * \param enabled true to enable interrupt via irq_index for specified channel, false to disable.
546
+ */
547
+ static inline void dma_irqn_set_channel_enabled (uint irq_index , uint channel , bool enabled ) {
548
+ invalid_params_if (DMA , irq_index > 1 );
549
+ if (irq_index ) {
550
+ dma_channel_set_irq1_enabled (channel , enabled );
551
+ } else {
552
+ dma_channel_set_irq0_enabled (channel , enabled );
553
+ }
554
+ }
555
+
556
+ /*! \brief Enable multiple DMA channels' interrupt via either DMA_IRQ_0 or DMA_IRQ_1
557
+ * \ingroup hardware_dma
558
+ *
559
+ * \param irq_index the IRQ index; either 0 or 1 for DMA_IRQ_0 or DMA_IRQ_1
560
+ * \param channel_mask Bitmask of all the channels to enable/disable. Channel 0 = bit 0, channel 1 = bit 1 etc.
561
+ * \param enabled true to enable all the interrupts specified in the mask, false to disable all the interrupts specified in the mask.
562
+ */
563
+ static inline void dma_irqn_set_channel_mask_enabled (uint irq_index , uint32_t channel_mask , bool enabled ) {
564
+ invalid_params_if (DMA , irq_index > 1 );
565
+ if (irq_index ) {
566
+ dma_set_irq1_channel_mask_enabled (channel_mask , enabled );
567
+ } else {
568
+ dma_set_irq0_channel_mask_enabled (channel_mask , enabled );
569
+ }
570
+ }
571
+
572
+ /*! \brief Determine if a particular channel is a cause of DMA_IRQ_0
573
+ * \ingroup hardware_dma
574
+ *
575
+ * \param channel DMA channel
576
+ * \return true if the channel is a cause of DMA_IRQ_0, false otherwise
577
+ */
578
+ static inline bool dma_channel_get_irq0_status (uint channel ) {
579
+ check_dma_channel_param (channel );
580
+ return dma_hw -> ints0 & (1u << channel );
581
+ }
582
+
583
+ /*! \brief Determine if a particular channel is a cause of DMA_IRQ_1
584
+ * \ingroup hardware_dma
585
+ *
586
+ * \param channel DMA channel
587
+ * \return true if the channel is a cause of DMA_IRQ_1, false otherwise
588
+ */
589
+ static inline bool dma_channel_get_irq1_status (uint channel ) {
590
+ check_dma_channel_param (channel );
591
+ return dma_hw -> ints1 & (1u << channel );
592
+ }
593
+
594
+ /*! \brief Determine if a particular channel is a cause of DMA_IRQ_N
595
+ * \ingroup hardware_dma
596
+ *
597
+ * \param irq_index the IRQ index; either 0 or 1 for DMA_IRQ_0 or DMA_IRQ_1
598
+ * \param channel DMA channel
599
+ * \return true if the channel is a cause of the DMA_IRQ_N, false otherwise
600
+ */
601
+ static inline bool dma_irqn_get_channel_status (uint irq_index , uint channel ) {
602
+ invalid_params_if (DMA , irq_index > 1 );
603
+ check_dma_channel_param (channel );
604
+ return (irq_index ? dma_hw -> ints1 : dma_hw -> ints0 ) & (1u << channel );
605
+ }
606
+
607
+ /*! \brief Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_0
608
+ * \ingroup hardware_dma
609
+ *
610
+ * \param channel DMA channel
611
+ */
612
+ static inline void dma_channel_acknowledge_irq0 (uint channel ) {
613
+ check_dma_channel_param (channel );
614
+ hw_set_bits (& dma_hw -> ints0 , (1u << channel ));
615
+ }
616
+
617
+ /*! \brief Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_1
618
+ * \ingroup hardware_dma
619
+ *
620
+ * \param channel DMA channel
621
+ */
622
+ static inline void dma_channel_acknowledge_irq1 (uint channel ) {
623
+ check_dma_channel_param (channel );
624
+ hw_set_bits (& dma_hw -> ints1 , (1u << channel ));
625
+ }
626
+
627
+ /*! \brief Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_N
628
+ * \ingroup hardware_dma
629
+ *
630
+ * \param irq_index the IRQ index; either 0 or 1 for DMA_IRQ_0 or DMA_IRQ_1
631
+ * \param channel DMA channel
632
+ */
633
+ static inline void dma_irqn_acknowledge_channel (uint irq_index , uint channel ) {
634
+ invalid_params_if (DMA , irq_index > 1 );
635
+ check_dma_channel_param (channel );
636
+ hw_set_bits (irq_index ? & dma_hw -> ints1 : & dma_hw -> ints0 , (1u << channel ));
637
+ }
638
+
526
639
/*! \brief Check if DMA channel is busy
527
640
* \ingroup hardware_dma
528
641
*
0 commit comments