@@ -118,7 +118,6 @@ bool dma_channel_is_claimed(uint channel);
118118 *
119119 * A DMA channel needs to be configured, these functions provide handy helpers to set up configuration
120120 * structures. See \ref dma_channel_config
121- *
122121 */
123122
124123/*! \brief Enumeration of available DMA channel transfer sizes.
@@ -136,21 +135,21 @@ typedef struct {
136135 uint32_t ctrl ;
137136} dma_channel_config ;
138137
139- /*! \brief Set DMA channel read increment
138+ /*! \brief Set DMA channel read increment in a channel configuration object
140139 * \ingroup channel_config
141140 *
142- * \param c Pointer to channel configuration data
141+ * \param c Pointer to channel configuration object
143142 * \param incr True to enable read address increments, if false, each read will be from the same address
144143 * Usually disabled for peripheral to memory transfers
145144 */
146145static inline void channel_config_set_read_increment (dma_channel_config * c , bool incr ) {
147146 c -> ctrl = incr ? (c -> ctrl | DMA_CH0_CTRL_TRIG_INCR_READ_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_INCR_READ_BITS );
148147}
149148
150- /*! \brief Set DMA channel write increment
149+ /*! \brief Set DMA channel write increment in a channel configuration object
151150 * \ingroup channel_config
152151 *
153- * \param c Pointer to channel configuration data
152+ * \param c Pointer to channel configuration object
154153 * \param incr True to enable write address increments, if false, each write will be to the same address
155154 * Usually disabled for memory to peripheral transfers
156155 * Usually disabled for memory to peripheral transfers
@@ -159,7 +158,7 @@ static inline void channel_config_set_write_increment(dma_channel_config *c, boo
159158 c -> ctrl = incr ? (c -> ctrl | DMA_CH0_CTRL_TRIG_INCR_WRITE_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_INCR_WRITE_BITS );
160159}
161160
162- /*! \brief Select a transfer request signal
161+ /*! \brief Select a transfer request signal in a channel configuration object
163162 * \ingroup channel_config
164163 *
165164 * The channel uses the transfer request signal to pace its data transfer rate.
@@ -179,35 +178,35 @@ static inline void channel_config_set_dreq(dma_channel_config *c, uint dreq) {
179178 c -> ctrl = (c -> ctrl & ~DMA_CH0_CTRL_TRIG_TREQ_SEL_BITS ) | (dreq << DMA_CH0_CTRL_TRIG_TREQ_SEL_LSB );
180179}
181180
182- /*! \brief Set DMA channel completion channel
181+ /*! \brief Set DMA channel chain_to channel in a channel configuration object
183182 * \ingroup channel_config
184183 *
185184 * When this channel completes, it will trigger the channel indicated by chain_to. Disable by
186185 * setting chain_to to itself (the same channel)
187186 *
188- * \param c Pointer to channel configuration data
187+ * \param c Pointer to channel configuration object
189188 * \param chain_to Channel to trigger when this channel completes.
190189 */
191190static inline void channel_config_set_chain_to (dma_channel_config * c , uint chain_to ) {
192191 assert (chain_to <= NUM_DMA_CHANNELS );
193192 c -> ctrl = (c -> ctrl & ~DMA_CH0_CTRL_TRIG_CHAIN_TO_BITS ) | (chain_to << DMA_CH0_CTRL_TRIG_CHAIN_TO_LSB );
194193}
195194
196- /*! \brief Set the size of each DMA bus transfer
195+ /*! \brief Set the size of each DMA bus transfer in a channel configuration object
197196 * \ingroup channel_config
198197 *
199198 * Set the size of each bus transfer (byte/halfword/word). The read and write addresses
200199 * advance by the specific amount (1/2/4 bytes) with each transfer.
201200 *
202- * \param c Pointer to channel configuration data
201+ * \param c Pointer to channel configuration object
203202 * \param size See enum for possible values.
204203 */
205204static inline void channel_config_set_transfer_data_size (dma_channel_config * c , enum dma_channel_transfer_size size ) {
206205 assert (size == DMA_SIZE_8 || size == DMA_SIZE_16 || size == DMA_SIZE_32 );
207206 c -> ctrl = (c -> ctrl & ~DMA_CH0_CTRL_TRIG_DATA_SIZE_BITS ) | (((uint )size ) << DMA_CH0_CTRL_TRIG_DATA_SIZE_LSB );
208207}
209208
210- /*! \brief Set address wrapping parameters
209+ /*! \brief Set address wrapping parameters in a channel configuration object
211210 * \ingroup channel_config
212211 *
213212 * Size of address wrap region. If 0, don’t wrap. For values n > 0, only the lower n bits of the address
@@ -217,7 +216,7 @@ static inline void channel_config_set_transfer_data_size(dma_channel_config *c,
217216 *
218217 * 0x0 -> No wrapping.
219218 *
220- * \param c Pointer to channel configuration data
219+ * \param c Pointer to channel configuration object
221220 * \param write True to apply to write addresses, false to apply to read addresses
222221 * \param size_bits 0 to disable wrapping. Otherwise the size in bits of the changing part of the address.
223222 * Effectively wraps the address on a (1 << size_bits) byte boundary.
@@ -229,54 +228,72 @@ static inline void channel_config_set_ring(dma_channel_config *c, bool write, ui
229228 (write ? DMA_CH0_CTRL_TRIG_RING_SEL_BITS : 0 );
230229}
231230
232- /*! \brief Set DMA byte swapping
231+ /*! \brief Set DMA byte swapping config in a channel configuration object
233232 * \ingroup channel_config
234233 *
235234 * No effect for byte data, for halfword data, the two bytes of each halfword are
236235 * swapped. For word data, the four bytes of each word are swapped to reverse their order.
237236 *
238- * \param c Pointer to channel configuration data
237+ * \param c Pointer to channel configuration object
239238 * \param bswap True to enable byte swapping
240239 */
241240static inline void channel_config_set_bswap (dma_channel_config * c , bool bswap ) {
242241 c -> ctrl = bswap ? (c -> ctrl | DMA_CH0_CTRL_TRIG_BSWAP_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_BSWAP_BITS );
243242}
244243
245- /*! \brief Set IRQ quiet mode
244+ /*! \brief Set IRQ quiet mode in a channel configuration object
246245 * \ingroup channel_config
247246 *
248247 * In QUIET mode, the channel does not generate IRQs at the end of every transfer block. Instead,
249248 * an IRQ is raised when NULL is written to a trigger register, indicating the end of a control
250249 * block chain.
251250 *
252- * \param c Pointer to channel configuration data
251+ * \param c Pointer to channel configuration object
253252 * \param irq_quiet True to enable quiet mode, false to disable.
254253 */
255254static inline void channel_config_set_irq_quiet (dma_channel_config * c , bool irq_quiet ) {
256255 c -> ctrl = irq_quiet ? (c -> ctrl | DMA_CH0_CTRL_TRIG_IRQ_QUIET_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_IRQ_QUIET_BITS );
257256}
258257
259258/*!
260- * \brief Enable/Disable the DMA channel
259+ * \brief Set the channel priority in a channel configuration object
260+ * \ingroup channel_config
261+ *
262+ * When true, gives a channel preferential treatment in issue scheduling: in each scheduling round,
263+ * all high priority channels are considered first, and then only a single low
264+ * priority channel, before returning to the high priority channels.
265+ *
266+ * This only affects the order in which the DMA schedules channels. The DMA's bus priority is not changed.
267+ * If the DMA is not saturated then a low priority channel will see no loss of throughput.
268+ *
269+ * \param c Pointer to channel configuration object
270+ * \param high_priority True to enable high priority
271+ */
272+ static inline void channel_config_set_high_priority (dma_channel_config * c , bool high_priority ) {
273+ c -> ctrl = high_priority ? (c -> ctrl | DMA_CH0_CTRL_TRIG_HIGH_PRIORITY_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_HIGH_PRIORITY_BITS );
274+ }
275+
276+ /*!
277+ * \brief Enable/Disable the DMA channel in a channel configuration object
261278 * \ingroup channel_config
262279 *
263280 * When false, the channel will ignore triggers, stop issuing transfers, and pause the current transfer sequence (i.e. BUSY will
264281 * remain high if already high)
265282 *
266- * \param c Pointer to channel configuration data
283+ * \param c Pointer to channel configuration object
267284 * \param enable True to enable the DMA channel. When enabled, the channel will respond to triggering events, and start transferring data.
268285 *
269286 */
270287static inline void channel_config_set_enable (dma_channel_config * c , bool enable ) {
271288 c -> ctrl = enable ? (c -> ctrl | DMA_CH0_CTRL_TRIG_EN_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_EN_BITS );
272289}
273290
274- /*! \brief Enable access to channel by sniff hardware.
291+ /*! \brief Enable access to channel by sniff hardware in a channel configuration object
275292 * \ingroup channel_config
276293 *
277294 * Sniff HW must be enabled and have this channel selected.
278295 *
279- * \param c Pointer to channel configuration data
296+ * \param c Pointer to channel configuration object
280297 * \param sniff_enable True to enable the Sniff HW access to this DMA channel.
281298 */
282299static inline void channel_config_set_sniff_enable (dma_channel_config * c , bool sniff_enable ) {
@@ -297,6 +314,7 @@ static inline void channel_config_set_sniff_enable(dma_channel_config *c, bool s
297314 * Ring | write=false, size=0 (i.e. off)
298315 * Byte Swap | false
299316 * Quiet IRQs | false
317+ * High Priority | false
300318 * Channel Enable | true
301319 * Sniff Enable | false
302320 *
@@ -315,6 +333,7 @@ static inline dma_channel_config dma_channel_get_default_config(uint channel) {
315333 channel_config_set_irq_quiet (& c , false);
316334 channel_config_set_enable (& c , true);
317335 channel_config_set_sniff_enable (& c , false);
336+ channel_config_set_high_priority ( & c , false);
318337 return c ;
319338}
320339
0 commit comments