dma.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _HARDWARE_DMA_H
8 #define _HARDWARE_DMA_H
9 
10 #include "pico.h"
11 #include "hardware/structs/dma.h"
12 #include "hardware/regs/dreq.h"
13 #include "pico/assert.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
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
43 
44 // PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_DMA, Enable/disable DMA assertions, type=bool, default=0, group=hardware_dma
45 #ifndef PARAM_ASSERTIONS_ENABLED_DMA
46 #define PARAM_ASSERTIONS_ENABLED_DMA 0
47 #endif
48 
49 static inline void check_dma_channel_param(__unused uint channel) {
50 #if PARAM_ASSERTIONS_ENABLED(DMA)
51  // this method is used a lot by inline functions so avoid code bloat by deferring to function
52  extern void check_dma_channel_param_impl(uint channel);
53  check_dma_channel_param_impl(channel);
54 #endif
55 }
56 
57 static inline void check_dma_timer_param(__unused uint timer_num) {
58  valid_params_if(DMA, timer_num < NUM_DMA_TIMERS);
59 }
60 
61 inline static dma_channel_hw_t *dma_channel_hw_addr(uint channel) {
62  check_dma_channel_param(channel);
63  return &dma_hw->ch[channel];
64 }
65 
75 void dma_channel_claim(uint channel);
76 
86 void dma_claim_mask(uint32_t channel_mask);
87 
93 void dma_channel_unclaim(uint channel);
94 
100 void dma_unclaim_mask(uint32_t channel_mask);
101 
108 int dma_claim_unused_channel(bool required);
109 
118 bool dma_channel_is_claimed(uint channel);
119 
137 };
138 
139 typedef struct {
140  uint32_t ctrl;
142 
150 static inline void channel_config_set_read_increment(dma_channel_config *c, bool incr) {
151  c->ctrl = incr ? (c->ctrl | DMA_CH0_CTRL_TRIG_INCR_READ_BITS) : (c->ctrl & ~DMA_CH0_CTRL_TRIG_INCR_READ_BITS);
152 }
153 
161 static inline void channel_config_set_write_increment(dma_channel_config *c, bool incr) {
162  c->ctrl = incr ? (c->ctrl | DMA_CH0_CTRL_TRIG_INCR_WRITE_BITS) : (c->ctrl & ~DMA_CH0_CTRL_TRIG_INCR_WRITE_BITS);
163 }
164 
180 static inline void channel_config_set_dreq(dma_channel_config *c, uint dreq) {
181  assert(dreq <= DREQ_FORCE);
182  c->ctrl = (c->ctrl & ~DMA_CH0_CTRL_TRIG_TREQ_SEL_BITS) | (dreq << DMA_CH0_CTRL_TRIG_TREQ_SEL_LSB);
183 }
184 
194 static inline void channel_config_set_chain_to(dma_channel_config *c, uint chain_to) {
195  assert(chain_to <= NUM_DMA_CHANNELS);
196  c->ctrl = (c->ctrl & ~DMA_CH0_CTRL_TRIG_CHAIN_TO_BITS) | (chain_to << DMA_CH0_CTRL_TRIG_CHAIN_TO_LSB);
197 }
198 
209  assert(size == DMA_SIZE_8 || size == DMA_SIZE_16 || size == DMA_SIZE_32);
210  c->ctrl = (c->ctrl & ~DMA_CH0_CTRL_TRIG_DATA_SIZE_BITS) | (((uint)size) << DMA_CH0_CTRL_TRIG_DATA_SIZE_LSB);
211 }
212 
228 static inline void channel_config_set_ring(dma_channel_config *c, bool write, uint size_bits) {
229  assert(size_bits < 32);
230  c->ctrl = (c->ctrl & ~(DMA_CH0_CTRL_TRIG_RING_SIZE_BITS | DMA_CH0_CTRL_TRIG_RING_SEL_BITS)) |
231  (size_bits << DMA_CH0_CTRL_TRIG_RING_SIZE_LSB) |
232  (write ? DMA_CH0_CTRL_TRIG_RING_SEL_BITS : 0);
233 }
234 
244 static inline void channel_config_set_bswap(dma_channel_config *c, bool bswap) {
245  c->ctrl = bswap ? (c->ctrl | DMA_CH0_CTRL_TRIG_BSWAP_BITS) : (c->ctrl & ~DMA_CH0_CTRL_TRIG_BSWAP_BITS);
246 }
247 
258 static inline void channel_config_set_irq_quiet(dma_channel_config *c, bool irq_quiet) {
259  c->ctrl = irq_quiet ? (c->ctrl | DMA_CH0_CTRL_TRIG_IRQ_QUIET_BITS) : (c->ctrl & ~DMA_CH0_CTRL_TRIG_IRQ_QUIET_BITS);
260 }
261 
276 static inline void channel_config_set_high_priority(dma_channel_config *c, bool high_priority) {
277  c->ctrl = high_priority ? (c->ctrl | DMA_CH0_CTRL_TRIG_HIGH_PRIORITY_BITS) : (c->ctrl & ~DMA_CH0_CTRL_TRIG_HIGH_PRIORITY_BITS);
278 }
279 
291 static inline void channel_config_set_enable(dma_channel_config *c, bool enable) {
292  c->ctrl = enable ? (c->ctrl | DMA_CH0_CTRL_TRIG_EN_BITS) : (c->ctrl & ~DMA_CH0_CTRL_TRIG_EN_BITS);
293 }
294 
303 static inline void channel_config_set_sniff_enable(dma_channel_config *c, bool sniff_enable) {
304  c->ctrl = sniff_enable ? (c->ctrl | DMA_CH0_CTRL_TRIG_SNIFF_EN_BITS) : (c->ctrl &
305  ~DMA_CH0_CTRL_TRIG_SNIFF_EN_BITS);
306 }
307 
329  dma_channel_config c = {0};
332  channel_config_set_dreq(&c, DREQ_FORCE);
333  channel_config_set_chain_to(&c, channel);
335  channel_config_set_ring(&c, false, 0);
336  channel_config_set_bswap(&c, false);
337  channel_config_set_irq_quiet(&c, false);
338  channel_config_set_enable(&c, true);
341  return c;
342 }
343 
350 static inline dma_channel_config dma_get_channel_config(uint channel) {
352  c.ctrl = dma_channel_hw_addr(channel)->ctrl_trig;
353  return c;
354 }
355 
362 static inline uint32_t channel_config_get_ctrl_value(const dma_channel_config *config) {
363  return config->ctrl;
364 }
365 
373 static inline void dma_channel_set_config(uint channel, const dma_channel_config *config, bool trigger) {
374  // Don't use CTRL_TRIG since we don't want to start a transfer
375  if (!trigger) {
376  dma_channel_hw_addr(channel)->al1_ctrl = channel_config_get_ctrl_value(config);
377  } else {
378  dma_channel_hw_addr(channel)->ctrl_trig = channel_config_get_ctrl_value(config);
379  }
380 }
381 
389 static inline void dma_channel_set_read_addr(uint channel, const volatile void *read_addr, bool trigger) {
390  if (!trigger) {
391  dma_channel_hw_addr(channel)->read_addr = (uintptr_t) read_addr;
392  } else {
393  dma_channel_hw_addr(channel)->al3_read_addr_trig = (uintptr_t) read_addr;
394  }
395 }
396 
404 static inline void dma_channel_set_write_addr(uint channel, volatile void *write_addr, bool trigger) {
405  if (!trigger) {
406  dma_channel_hw_addr(channel)->write_addr = (uintptr_t) write_addr;
407  } else {
408  dma_channel_hw_addr(channel)->al2_write_addr_trig = (uintptr_t) write_addr;
409  }
410 }
411 
419 static inline void dma_channel_set_trans_count(uint channel, uint32_t trans_count, bool trigger) {
420  if (!trigger) {
421  dma_channel_hw_addr(channel)->transfer_count = trans_count;
422  } else {
423  dma_channel_hw_addr(channel)->al1_transfer_count_trig = trans_count;
424  }
425 }
426 
437 static inline void dma_channel_configure(uint channel, const dma_channel_config *config, volatile void *write_addr,
438  const volatile void *read_addr,
439  uint transfer_count, bool trigger) {
440  dma_channel_set_read_addr(channel, read_addr, false);
441  dma_channel_set_write_addr(channel, write_addr, false);
442  dma_channel_set_trans_count(channel, transfer_count, false);
443  dma_channel_set_config(channel, config, trigger);
444 }
445 
453 inline static void __attribute__((always_inline)) dma_channel_transfer_from_buffer_now(uint channel,
454  const volatile void *read_addr,
455  uint32_t transfer_count) {
456 // check_dma_channel_param(channel);
457  dma_channel_hw_t *hw = dma_channel_hw_addr(channel);
458  hw->read_addr = (uintptr_t) read_addr;
459  hw->al1_transfer_count_trig = transfer_count;
460 }
461 
469 inline static void dma_channel_transfer_to_buffer_now(uint channel, volatile void *write_addr, uint32_t transfer_count) {
470  dma_channel_hw_t *hw = dma_channel_hw_addr(channel);
471  hw->write_addr = (uintptr_t) write_addr;
472  hw->al1_transfer_count_trig = transfer_count;
473 }
474 
480 static inline void dma_start_channel_mask(uint32_t chan_mask) {
481  valid_params_if(DMA, chan_mask && chan_mask < (1u << NUM_DMA_CHANNELS));
482  dma_hw->multi_channel_trigger = chan_mask;
483 }
484 
490 static inline void dma_channel_start(uint channel) {
491  dma_start_channel_mask(1u << channel);
492 }
493 
527 static inline void dma_channel_abort(uint channel) {
528  check_dma_channel_param(channel);
529  dma_hw->abort = 1u << channel;
530  // Bit will go 0 once channel has reached safe state
531  // (i.e. any in-flight transfers have retired)
532  while (dma_hw->ch[channel].ctrl_trig & DMA_CH0_CTRL_TRIG_BUSY_BITS) tight_loop_contents();
533 }
534 
541 static inline void dma_channel_set_irq0_enabled(uint channel, bool enabled) {
542  check_dma_channel_param(channel);
543  check_hw_layout(dma_hw_t, inte0, DMA_INTE0_OFFSET);
544  if (enabled)
545  hw_set_bits(&dma_hw->inte0, 1u << channel);
546  else
547  hw_clear_bits(&dma_hw->inte0, 1u << channel);
548 }
549 
556 static inline void dma_set_irq0_channel_mask_enabled(uint32_t channel_mask, bool enabled) {
557  if (enabled) {
558  hw_set_bits(&dma_hw->inte0, channel_mask);
559  } else {
560  hw_clear_bits(&dma_hw->inte0, channel_mask);
561  }
562 }
563 
570 static inline void dma_channel_set_irq1_enabled(uint channel, bool enabled) {
571  check_dma_channel_param(channel);
572  check_hw_layout(dma_hw_t, inte1, DMA_INTE1_OFFSET);
573  if (enabled)
574  hw_set_bits(&dma_hw->inte1, 1u << channel);
575  else
576  hw_clear_bits(&dma_hw->inte1, 1u << channel);
577 }
578 
585 static inline void dma_set_irq1_channel_mask_enabled(uint32_t channel_mask, bool enabled) {
586  if (enabled) {
587  hw_set_bits(&dma_hw->inte1, channel_mask);
588  } else {
589  hw_clear_bits(&dma_hw->inte1, channel_mask);
590  }
591 }
592 
600 static inline void dma_irqn_set_channel_enabled(uint irq_index, uint channel, bool enabled) {
601  invalid_params_if(DMA, irq_index > 1);
602  if (irq_index) {
603  dma_channel_set_irq1_enabled(channel, enabled);
604  } else {
605  dma_channel_set_irq0_enabled(channel, enabled);
606  }
607 }
608 
616 static inline void dma_irqn_set_channel_mask_enabled(uint irq_index, uint32_t channel_mask, bool enabled) {
617  invalid_params_if(DMA, irq_index > 1);
618  if (irq_index) {
619  dma_set_irq1_channel_mask_enabled(channel_mask, enabled);
620  } else {
621  dma_set_irq0_channel_mask_enabled(channel_mask, enabled);
622  }
623 }
624 
631 static inline bool dma_channel_get_irq0_status(uint channel) {
632  check_dma_channel_param(channel);
633  return dma_hw->ints0 & (1u << channel);
634 }
635 
642 static inline bool dma_channel_get_irq1_status(uint channel) {
643  check_dma_channel_param(channel);
644  return dma_hw->ints1 & (1u << channel);
645 }
646 
654 static inline bool dma_irqn_get_channel_status(uint irq_index, uint channel) {
655  invalid_params_if(DMA, irq_index > 1);
656  check_dma_channel_param(channel);
657  return (irq_index ? dma_hw->ints1 : dma_hw->ints0) & (1u << channel);
658 }
659 
665 static inline void dma_channel_acknowledge_irq0(uint channel) {
666  check_dma_channel_param(channel);
667  dma_hw->ints0 = 1u << channel;
668 }
669 
675 static inline void dma_channel_acknowledge_irq1(uint channel) {
676  check_dma_channel_param(channel);
677  dma_hw->ints1 = 1u << channel;
678 }
679 
686 static inline void dma_irqn_acknowledge_channel(uint irq_index, uint channel) {
687  invalid_params_if(DMA, irq_index > 1);
688  check_dma_channel_param(channel);
689  if (irq_index)
690  dma_hw->ints1 = 1u << channel;
691  else
692  dma_hw->ints0 = 1u << channel;
693 }
694 
701 inline static bool dma_channel_is_busy(uint channel) {
702  check_dma_channel_param(channel);
703  return !!(dma_hw->ch[channel].al1_ctrl & DMA_CH0_CTRL_TRIG_BUSY_BITS);
704 }
705 
711 inline static void dma_channel_wait_for_finish_blocking(uint channel) {
712  while (dma_channel_is_busy(channel)) tight_loop_contents();
713  // stop the compiler hoisting a non volatile buffer access above the DMA completion.
715 }
716 
737 inline static void dma_sniffer_enable(uint channel, uint mode, bool force_channel_enable) {
738  check_dma_channel_param(channel);
739  check_hw_layout(dma_hw_t, sniff_ctrl, DMA_SNIFF_CTRL_OFFSET);
740  if (force_channel_enable) {
741  hw_set_bits(&dma_hw->ch[channel].al1_ctrl, DMA_CH0_CTRL_TRIG_SNIFF_EN_BITS);
742  }
743  hw_write_masked(&dma_hw->sniff_ctrl,
744  (((channel << DMA_SNIFF_CTRL_DMACH_LSB) & DMA_SNIFF_CTRL_DMACH_BITS) |
745  ((mode << DMA_SNIFF_CTRL_CALC_LSB) & DMA_SNIFF_CTRL_CALC_BITS) |
746  DMA_SNIFF_CTRL_EN_BITS),
747  (DMA_SNIFF_CTRL_DMACH_BITS |
748  DMA_SNIFF_CTRL_CALC_BITS |
749  DMA_SNIFF_CTRL_EN_BITS));
750 }
751 
763 inline static void dma_sniffer_set_byte_swap_enabled(bool swap) {
764  if (swap)
765  hw_set_bits(&dma_hw->sniff_ctrl, DMA_SNIFF_CTRL_BSWAP_BITS);
766  else
767  hw_clear_bits(&dma_hw->sniff_ctrl, DMA_SNIFF_CTRL_BSWAP_BITS);
768 }
769 
778 inline static void dma_sniffer_set_output_invert_enabled(bool invert) {
779  if (invert)
780  hw_set_bits(&dma_hw->sniff_ctrl, DMA_SNIFF_CTRL_OUT_INV_BITS);
781  else
782  hw_clear_bits(&dma_hw->sniff_ctrl, DMA_SNIFF_CTRL_OUT_INV_BITS);
783 }
784 
793 inline static void dma_sniffer_set_output_reverse_enabled(bool reverse) {
794  if (reverse)
795  hw_set_bits(&dma_hw->sniff_ctrl, DMA_SNIFF_CTRL_OUT_REV_BITS);
796  else
797  hw_clear_bits(&dma_hw->sniff_ctrl, DMA_SNIFF_CTRL_OUT_REV_BITS);
798 }
799 
804 inline static void dma_sniffer_disable(void) {
805  dma_hw->sniff_ctrl = 0;
806 }
807 
816 inline static void dma_sniffer_set_data_accumulator(uint32_t seed_value) {
817  dma_hw->sniff_data = seed_value;
818 }
819 
825 inline static uint32_t dma_sniffer_get_data_accumulator(void) {
826  return dma_hw->sniff_data;
827 }
828 
838 void dma_timer_claim(uint timer);
839 
847 void dma_timer_unclaim(uint timer);
848 
855 int dma_claim_unused_timer(bool required);
856 
864 bool dma_timer_is_claimed(uint timer);
865 
876 static inline void dma_timer_set_fraction(uint timer, uint16_t numerator, uint16_t denominator) {
877  check_dma_timer_param(timer);
878  dma_hw->timer[timer] = (((uint32_t)numerator) << DMA_TIMER0_X_LSB) | (((uint32_t)denominator) << DMA_TIMER0_Y_LSB);
879 }
880 
886 static inline uint dma_get_timer_dreq(uint timer_num) {
887  static_assert(DREQ_DMA_TIMER1 == DREQ_DMA_TIMER0 + 1, "");
888  static_assert(DREQ_DMA_TIMER2 == DREQ_DMA_TIMER0 + 2, "");
889  static_assert(DREQ_DMA_TIMER3 == DREQ_DMA_TIMER0 + 3, "");
890  check_dma_timer_param(timer_num);
891  return DREQ_DMA_TIMER0 + timer_num;
892 }
893 
894 #ifndef NDEBUG
895 void print_dma_ctrl(dma_channel_hw_t *channel);
896 #endif
897 
898 #ifdef __cplusplus
899 }
900 #endif
901 
902 #endif
dma_claim_unused_channel
int dma_claim_unused_channel(bool required)
Claim a free dma channel.
Definition: dma.c:45
dma_sniffer_enable
static void dma_sniffer_enable(uint channel, uint mode, bool force_channel_enable)
Enable the DMA sniffing targeting the specified channel.
Definition: dma.h:737
hw_clear_bits
static __force_inline void hw_clear_bits(io_rw_32 *addr, uint32_t mask)
Atomically clear the specified bits to 0 in a HW register.
Definition: address_mapped.h:131
dma_channel_set_write_addr
static void dma_channel_set_write_addr(uint channel, volatile void *write_addr, bool trigger)
Set the DMA initial write address.
Definition: dma.h:404
dma_set_irq1_channel_mask_enabled
static void dma_set_irq1_channel_mask_enabled(uint32_t channel_mask, bool enabled)
Enable multiple DMA channels' interrupts via DMA_IRQ_1.
Definition: dma.h:585
dma_channel_is_busy
static bool dma_channel_is_busy(uint channel)
Check if DMA channel is busy.
Definition: dma.h:701
dma_irqn_set_channel_enabled
static void dma_irqn_set_channel_enabled(uint irq_index, uint channel, bool enabled)
Enable single DMA channel interrupt on either DMA_IRQ_0 or DMA_IRQ_1.
Definition: dma.h:600
dma_channel_transfer_size
dma_channel_transfer_size
Enumeration of available DMA channel transfer sizes.
Definition: dma.h:133
dma_channel_transfer_to_buffer_now
static void dma_channel_transfer_to_buffer_now(uint channel, volatile void *write_addr, uint32_t transfer_count)
Start a DMA transfer to a buffer immediately.
Definition: dma.h:469
dma_channel_set_irq1_enabled
static void dma_channel_set_irq1_enabled(uint channel, bool enabled)
Enable single DMA channel's interrupt via DMA_IRQ_1.
Definition: dma.h:570
dma_start_channel_mask
static void dma_start_channel_mask(uint32_t chan_mask)
Start one or more channels simultaneously.
Definition: dma.h:480
dma_hw_t
Definition: dma.h:105
dma_channel_acknowledge_irq1
static void dma_channel_acknowledge_irq1(uint channel)
Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_1.
Definition: dma.h:675
dma_channel_set_read_addr
static void dma_channel_set_read_addr(uint channel, const volatile void *read_addr, bool trigger)
Set the DMA initial read address.
Definition: dma.h:389
dma_sniffer_get_data_accumulator
static uint32_t dma_sniffer_get_data_accumulator(void)
Get the sniffer's data accumulator value.
Definition: dma.h:825
channel_config_set_high_priority
static void channel_config_set_high_priority(dma_channel_config *c, bool high_priority)
Set the channel priority in a channel configuration object.
Definition: dma.h:276
dma_set_irq0_channel_mask_enabled
static void dma_set_irq0_channel_mask_enabled(uint32_t channel_mask, bool enabled)
Enable multiple DMA channels' interrupts via DMA_IRQ_0.
Definition: dma.h:556
dma_sniffer_set_output_invert_enabled
static void dma_sniffer_set_output_invert_enabled(bool invert)
Enable the Sniffer output invert function.
Definition: dma.h:778
dma_channel_configure
static void dma_channel_configure(uint channel, const dma_channel_config *config, volatile void *write_addr, const volatile void *read_addr, uint transfer_count, bool trigger)
Configure all DMA parameters and optionally start transfer.
Definition: dma.h:437
dma_channel_config
Definition: dma.h:139
hw_write_masked
static __force_inline void hw_write_masked(io_rw_32 *addr, uint32_t values, uint32_t write_mask)
Set new values for a sub-set of the bits in a HW register.
Definition: address_mapped.h:157
dma_channel_claim
void dma_channel_claim(uint channel)
Mark a dma channel as used.
Definition: dma.c:23
dma_sniffer_set_byte_swap_enabled
static void dma_sniffer_set_byte_swap_enabled(bool swap)
Enable the Sniffer byte swap function.
Definition: dma.h:763
dma_claim_unused_timer
int dma_claim_unused_timer(bool required)
Claim a free dma timer.
Definition: dma.c:64
dma_sniffer_set_data_accumulator
static void dma_sniffer_set_data_accumulator(uint32_t seed_value)
Set the sniffer's data accumulator with initial value.
Definition: dma.h:816
DMA_SIZE_8
@ DMA_SIZE_8
Byte transfer (8 bits)
Definition: dma.h:134
dma_irqn_get_channel_status
static bool dma_irqn_get_channel_status(uint irq_index, uint channel)
Determine if a particular channel is a cause of DMA_IRQ_N.
Definition: dma.h:654
channel_config_set_irq_quiet
static void channel_config_set_irq_quiet(dma_channel_config *c, bool irq_quiet)
Set IRQ quiet mode in a channel configuration object.
Definition: dma.h:258
dma_channel_wait_for_finish_blocking
static void dma_channel_wait_for_finish_blocking(uint channel)
Wait for a DMA channel transfer to complete.
Definition: dma.h:711
channel_config_set_sniff_enable
static void channel_config_set_sniff_enable(dma_channel_config *c, bool sniff_enable)
Enable access to channel by sniff hardware in a channel configuration object.
Definition: dma.h:303
channel_config_set_bswap
static void channel_config_set_bswap(dma_channel_config *c, bool bswap)
Set DMA byte swapping config in a channel configuration object.
Definition: dma.h:244
hw_set_bits
static __force_inline void hw_set_bits(io_rw_32 *addr, uint32_t mask)
Atomically set the specified bits to 1 in a HW register.
Definition: address_mapped.h:121
channel_config_set_dreq
static void channel_config_set_dreq(dma_channel_config *c, uint dreq)
Select a transfer request signal in a channel configuration object.
Definition: dma.h:180
dma_unclaim_mask
void dma_unclaim_mask(uint32_t channel_mask)
Mark multiple dma channels as no longer used.
Definition: dma.c:39
dma_sniffer_set_output_reverse_enabled
static void dma_sniffer_set_output_reverse_enabled(bool reverse)
Enable the Sniffer output bit reversal function.
Definition: dma.h:793
dma_channel_start
static void dma_channel_start(uint channel)
Start a single DMA channel.
Definition: dma.h:490
channel_config_set_write_increment
static void channel_config_set_write_increment(dma_channel_config *c, bool incr)
Set DMA channel write increment in a channel configuration object.
Definition: dma.h:161
dma_channel_is_claimed
bool dma_channel_is_claimed(uint channel)
Determine if a dma channel is claimed.
Definition: dma.c:49
dma_channel_unclaim
void dma_channel_unclaim(uint channel)
Mark a dma channel as no longer used.
Definition: dma.c:34
dma_channel_set_trans_count
static void dma_channel_set_trans_count(uint channel, uint32_t trans_count, bool trigger)
Set the number of bus transfers the channel will do.
Definition: dma.h:419
channel_config_set_ring
static void channel_config_set_ring(dma_channel_config *c, bool write, uint size_bits)
Set address wrapping parameters in a channel configuration object.
Definition: dma.h:228
dma_irqn_acknowledge_channel
static void dma_irqn_acknowledge_channel(uint irq_index, uint channel)
Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_N.
Definition: dma.h:686
dma_channel_abort
static void dma_channel_abort(uint channel)
Stop a DMA transfer.
Definition: dma.h:527
channel_config_set_read_increment
static void channel_config_set_read_increment(dma_channel_config *c, bool incr)
Set DMA channel read increment in a channel configuration object.
Definition: dma.h:150
tight_loop_contents
static __always_inline void tight_loop_contents(void)
No-op function for the body of tight loops.
Definition: platform.h:358
dma_channel_get_default_config
static dma_channel_config dma_channel_get_default_config(uint channel)
Get the default channel configuration for a given channel.
Definition: dma.h:328
dma_get_channel_config
static dma_channel_config dma_get_channel_config(uint channel)
Get the current configuration for the specified channel.
Definition: dma.h:350
dma_channel_hw_t
Definition: dma.h:23
dma_timer_is_claimed
bool dma_timer_is_claimed(uint timer)
Determine if a dma timer is claimed.
Definition: dma.c:68
pico.h
dma_channel_set_irq0_enabled
static void dma_channel_set_irq0_enabled(uint channel, bool enabled)
Enable single DMA channel's interrupt via DMA_IRQ_0.
Definition: dma.h:541
dma_channel_get_irq1_status
static bool dma_channel_get_irq1_status(uint channel)
Determine if a particular channel is a cause of DMA_IRQ_1.
Definition: dma.h:642
DMA_SIZE_32
@ DMA_SIZE_32
Word transfer (32 bits)
Definition: dma.h:136
dma_channel_transfer_from_buffer_now
static void dma_channel_transfer_from_buffer_now(uint channel, const volatile void *read_addr, uint32_t transfer_count)
Start a DMA transfer from a buffer immediately.
Definition: dma.h:453
dma_timer_set_fraction
static void dma_timer_set_fraction(uint timer, uint16_t numerator, uint16_t denominator)
Set the divider for the given DMA timer.
Definition: dma.h:876
__compiler_memory_barrier
static __always_inline void __compiler_memory_barrier(void)
Ensure that the compiler does not move memory access across this method call.
Definition: platform.h:284
dma_irqn_set_channel_mask_enabled
static void dma_irqn_set_channel_mask_enabled(uint irq_index, uint32_t channel_mask, bool enabled)
Enable multiple DMA channels' interrupt via either DMA_IRQ_0 or DMA_IRQ_1.
Definition: dma.h:616
dma_channel_get_irq0_status
static bool dma_channel_get_irq0_status(uint channel)
Determine if a particular channel is a cause of DMA_IRQ_0.
Definition: dma.h:631
dma_sniffer_disable
static void dma_sniffer_disable(void)
Disable the DMA sniffer.
Definition: dma.h:804
DMA_SIZE_16
@ DMA_SIZE_16
Half word transfer (16 bits)
Definition: dma.h:135
dma_timer_claim
void dma_timer_claim(uint timer)
Mark a dma timer as used.
Definition: dma.c:54
dma_channel_set_config
static void dma_channel_set_config(uint channel, const dma_channel_config *config, bool trigger)
Set a channel configuration.
Definition: dma.h:373
channel_config_set_transfer_data_size
static void channel_config_set_transfer_data_size(dma_channel_config *c, enum dma_channel_transfer_size size)
Set the size of each DMA bus transfer in a channel configuration object.
Definition: dma.h:208
channel_config_get_ctrl_value
static uint32_t channel_config_get_ctrl_value(const dma_channel_config *config)
Get the raw configuration register from a channel configuration.
Definition: dma.h:362
channel_config_set_chain_to
static void channel_config_set_chain_to(dma_channel_config *c, uint chain_to)
Set DMA channel chain_to channel in a channel configuration object.
Definition: dma.h:194
channel_config_set_enable
static void channel_config_set_enable(dma_channel_config *c, bool enable)
Enable/Disable the DMA channel in a channel configuration object.
Definition: dma.h:291
dma_timer_unclaim
void dma_timer_unclaim(uint timer)
Mark a dma timer as no longer used.
Definition: dma.c:59
dma_get_timer_dreq
static uint dma_get_timer_dreq(uint timer_num)
Return the DREQ number for a given DMA timer.
Definition: dma.h:886
dma_channel_acknowledge_irq0
static void dma_channel_acknowledge_irq0(uint channel)
Acknowledge a channel IRQ, resetting it as the cause of DMA_IRQ_0.
Definition: dma.h:665
dma_claim_mask
void dma_claim_mask(uint32_t channel_mask)
Mark multiple dma channels as used.
Definition: dma.c:28