@@ -118,7 +118,6 @@ bool dma_channel_is_claimed(uint channel);
118
118
*
119
119
* A DMA channel needs to be configured, these functions provide handy helpers to set up configuration
120
120
* structures. See \ref dma_channel_config
121
- *
122
121
*/
123
122
124
123
/*! \brief Enumeration of available DMA channel transfer sizes.
@@ -136,21 +135,21 @@ typedef struct {
136
135
uint32_t ctrl ;
137
136
} dma_channel_config ;
138
137
139
- /*! \brief Set DMA channel read increment
138
+ /*! \brief Set DMA channel read increment in a channel configuration object
140
139
* \ingroup channel_config
141
140
*
142
- * \param c Pointer to channel configuration data
141
+ * \param c Pointer to channel configuration object
143
142
* \param incr True to enable read address increments, if false, each read will be from the same address
144
143
* Usually disabled for peripheral to memory transfers
145
144
*/
146
145
static inline void channel_config_set_read_increment (dma_channel_config * c , bool incr ) {
147
146
c -> ctrl = incr ? (c -> ctrl | DMA_CH0_CTRL_TRIG_INCR_READ_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_INCR_READ_BITS );
148
147
}
149
148
150
- /*! \brief Set DMA channel write increment
149
+ /*! \brief Set DMA channel write increment in a channel configuration object
151
150
* \ingroup channel_config
152
151
*
153
- * \param c Pointer to channel configuration data
152
+ * \param c Pointer to channel configuration object
154
153
* \param incr True to enable write address increments, if false, each write will be to the same address
155
154
* Usually disabled for memory to peripheral transfers
156
155
* Usually disabled for memory to peripheral transfers
@@ -159,7 +158,7 @@ static inline void channel_config_set_write_increment(dma_channel_config *c, boo
159
158
c -> ctrl = incr ? (c -> ctrl | DMA_CH0_CTRL_TRIG_INCR_WRITE_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_INCR_WRITE_BITS );
160
159
}
161
160
162
- /*! \brief Select a transfer request signal
161
+ /*! \brief Select a transfer request signal in a channel configuration object
163
162
* \ingroup channel_config
164
163
*
165
164
* 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) {
179
178
c -> ctrl = (c -> ctrl & ~DMA_CH0_CTRL_TRIG_TREQ_SEL_BITS ) | (dreq << DMA_CH0_CTRL_TRIG_TREQ_SEL_LSB );
180
179
}
181
180
182
- /*! \brief Set DMA channel completion channel
181
+ /*! \brief Set DMA channel chain_to channel in a channel configuration object
183
182
* \ingroup channel_config
184
183
*
185
184
* When this channel completes, it will trigger the channel indicated by chain_to. Disable by
186
185
* setting chain_to to itself (the same channel)
187
186
*
188
- * \param c Pointer to channel configuration data
187
+ * \param c Pointer to channel configuration object
189
188
* \param chain_to Channel to trigger when this channel completes.
190
189
*/
191
190
static inline void channel_config_set_chain_to (dma_channel_config * c , uint chain_to ) {
192
191
assert (chain_to <= NUM_DMA_CHANNELS );
193
192
c -> ctrl = (c -> ctrl & ~DMA_CH0_CTRL_TRIG_CHAIN_TO_BITS ) | (chain_to << DMA_CH0_CTRL_TRIG_CHAIN_TO_LSB );
194
193
}
195
194
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
197
196
* \ingroup channel_config
198
197
*
199
198
* Set the size of each bus transfer (byte/halfword/word). The read and write addresses
200
199
* advance by the specific amount (1/2/4 bytes) with each transfer.
201
200
*
202
- * \param c Pointer to channel configuration data
201
+ * \param c Pointer to channel configuration object
203
202
* \param size See enum for possible values.
204
203
*/
205
204
static inline void channel_config_set_transfer_data_size (dma_channel_config * c , enum dma_channel_transfer_size size ) {
206
205
assert (size == DMA_SIZE_8 || size == DMA_SIZE_16 || size == DMA_SIZE_32 );
207
206
c -> ctrl = (c -> ctrl & ~DMA_CH0_CTRL_TRIG_DATA_SIZE_BITS ) | (((uint )size ) << DMA_CH0_CTRL_TRIG_DATA_SIZE_LSB );
208
207
}
209
208
210
- /*! \brief Set address wrapping parameters
209
+ /*! \brief Set address wrapping parameters in a channel configuration object
211
210
* \ingroup channel_config
212
211
*
213
212
* 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,
217
216
*
218
217
* 0x0 -> No wrapping.
219
218
*
220
- * \param c Pointer to channel configuration data
219
+ * \param c Pointer to channel configuration object
221
220
* \param write True to apply to write addresses, false to apply to read addresses
222
221
* \param size_bits 0 to disable wrapping. Otherwise the size in bits of the changing part of the address.
223
222
* 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
229
228
(write ? DMA_CH0_CTRL_TRIG_RING_SEL_BITS : 0 );
230
229
}
231
230
232
- /*! \brief Set DMA byte swapping
231
+ /*! \brief Set DMA byte swapping config in a channel configuration object
233
232
* \ingroup channel_config
234
233
*
235
234
* No effect for byte data, for halfword data, the two bytes of each halfword are
236
235
* swapped. For word data, the four bytes of each word are swapped to reverse their order.
237
236
*
238
- * \param c Pointer to channel configuration data
237
+ * \param c Pointer to channel configuration object
239
238
* \param bswap True to enable byte swapping
240
239
*/
241
240
static inline void channel_config_set_bswap (dma_channel_config * c , bool bswap ) {
242
241
c -> ctrl = bswap ? (c -> ctrl | DMA_CH0_CTRL_TRIG_BSWAP_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_BSWAP_BITS );
243
242
}
244
243
245
- /*! \brief Set IRQ quiet mode
244
+ /*! \brief Set IRQ quiet mode in a channel configuration object
246
245
* \ingroup channel_config
247
246
*
248
247
* In QUIET mode, the channel does not generate IRQs at the end of every transfer block. Instead,
249
248
* an IRQ is raised when NULL is written to a trigger register, indicating the end of a control
250
249
* block chain.
251
250
*
252
- * \param c Pointer to channel configuration data
251
+ * \param c Pointer to channel configuration object
253
252
* \param irq_quiet True to enable quiet mode, false to disable.
254
253
*/
255
254
static inline void channel_config_set_irq_quiet (dma_channel_config * c , bool irq_quiet ) {
256
255
c -> ctrl = irq_quiet ? (c -> ctrl | DMA_CH0_CTRL_TRIG_IRQ_QUIET_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_IRQ_QUIET_BITS );
257
256
}
258
257
259
258
/*!
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
261
278
* \ingroup channel_config
262
279
*
263
280
* When false, the channel will ignore triggers, stop issuing transfers, and pause the current transfer sequence (i.e. BUSY will
264
281
* remain high if already high)
265
282
*
266
- * \param c Pointer to channel configuration data
283
+ * \param c Pointer to channel configuration object
267
284
* \param enable True to enable the DMA channel. When enabled, the channel will respond to triggering events, and start transferring data.
268
285
*
269
286
*/
270
287
static inline void channel_config_set_enable (dma_channel_config * c , bool enable ) {
271
288
c -> ctrl = enable ? (c -> ctrl | DMA_CH0_CTRL_TRIG_EN_BITS ) : (c -> ctrl & ~DMA_CH0_CTRL_TRIG_EN_BITS );
272
289
}
273
290
274
- /*! \brief Enable access to channel by sniff hardware.
291
+ /*! \brief Enable access to channel by sniff hardware in a channel configuration object
275
292
* \ingroup channel_config
276
293
*
277
294
* Sniff HW must be enabled and have this channel selected.
278
295
*
279
- * \param c Pointer to channel configuration data
296
+ * \param c Pointer to channel configuration object
280
297
* \param sniff_enable True to enable the Sniff HW access to this DMA channel.
281
298
*/
282
299
static 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
297
314
* Ring | write=false, size=0 (i.e. off)
298
315
* Byte Swap | false
299
316
* Quiet IRQs | false
317
+ * High Priority | false
300
318
* Channel Enable | true
301
319
* Sniff Enable | false
302
320
*
@@ -315,6 +333,7 @@ static inline dma_channel_config dma_channel_get_default_config(uint channel) {
315
333
channel_config_set_irq_quiet (& c , false);
316
334
channel_config_set_enable (& c , true);
317
335
channel_config_set_sniff_enable (& c , false);
336
+ channel_config_set_high_priority ( & c , false);
318
337
return c ;
319
338
}
320
339
0 commit comments