1 /*******************************************************************************
\r
2 * (c) Copyright 2008 Actel Corporation. All rights reserved.
\r
4 * SmartFusion microcontroller subsystem Peripheral DMA bare metal software
\r
7 * SVN $Revision: 2110 $
\r
8 * SVN $Date: 2010-02-05 15:24:19 +0000 (Fri, 05 Feb 2010) $
\r
10 /*=========================================================================*//**
\r
11 @mainpage SmartFusion MSS GPIO Bare Metal Driver.
\r
13 @section intro_sec Introduction
\r
14 The SmartFusion Microcontroller Subsystem (MSS) includes an 8 channel
\r
15 Peripheral DMA (PDMA) controller.
\r
16 This software driver provides a set of functions for controlling the MSS PDMA
\r
17 controller as part of a bare metal system where no operating system is available.
\r
18 This driver can be adapted for use as part of an operating system but the
\r
19 implementation of the adaptation layer between this driver and the operating
\r
20 system's driver model is outside the scope of this driver.
\r
22 @section theory_op Theory of Operation
\r
23 The MSS PDMA driver uses the SmartFusion "Cortex Microcontroler Software
\r
24 Interface Standard - Peripheral Access Layer" (CMSIS-PAL) to access MSS hardware
\r
25 registers. You must ensure that the SmartFusion CMSIS-PAL is either included
\r
26 in the software toolchain used to build your project or is included in your
\r
27 project. The most up-to-date SmartFusion CMSIS-PAL files can be obtained using
\r
28 the Actel Firmware Catalog.
\r
30 The MSS PDMA driver functions are grouped into the following categories:
\r
33 - DMA transfer control
\r
36 The MSS PDMA driver is initialized through a call to the PDMA_init() function.
\r
37 The PDMA_init() function must be called before any other PDMA driver functions
\r
40 Each PDMA channel is individually configured through a call to the PDMA_configure()
\r
41 function. Configuration includes:
\r
44 - source and/or destination address increment
\r
45 - source or destination of the DMA transfer
\r
46 PDMA channels can be divided into high and low priority channels. High priority
\r
47 channels are given more opportunities to perform transfers than low priority
\r
48 channels when there are continuous high priority channels requests. The ratio
\r
49 of high priority to low priority PDMA transfers is configurable through the
\r
50 PDMA_set_priority() function.
\r
51 PDMA channels can be configured to perform byte (8 bits), half-word (16 bits)
\r
52 or word (32 bits) transfers.
\r
53 The source and destination address of a PDMA channel
\92s transfers can be
\r
54 independently configured to increment by 0, 1, 2 or 4 bytes. For example, the
\r
55 content of a byte buffer located in RAM can be transferred into a peripheral
\92s
\r
56 transmit register by configuring the source address increment to one byte and
\r
57 no increment of the destination address.
\r
58 The source or destination of a PDMA channel
\92s transfers can be configured to
\r
59 be one of the MSS peripherals. This allows the PDMA controller to use some
\r
60 hardware flow control signaling with the peripheral to avoid overrunning the
\r
61 peripheral
\92s data buffer when the peripheral is the destination of the DMA
\r
62 transfer, or attempting to read data from the peripheral while it is not ready
\r
63 when the peripheral is the source of the transfer.
\r
64 A PDMA channel can also be configured to transfer data between two memory
\r
65 mapped locations (memory to memory). No hardware flow control is used by the
\r
66 PDMA controller for data transfer in this configuration.
\r
68 A DMA transfer can be initiated by a call to the PDMA_start() function after a
\r
69 PDMA channel has been configured. Once started, further data can be pushed
\r
70 through the PDMA channel by calling the PDMA_load_next_buffer() function. The
\r
71 PDMA_load_next_buffer() function can be called every time a call to the
\r
72 PDMA_status() function indicates that the PDMA channel used for the transfer
\r
73 has a free buffer or it can be called as a result of a PDMA interrupt.
\r
75 A DMA transfer can be paused and resumed through calls to functions PDMA_pause()
\r
78 Your application can manage DMA transfers using interrupts through the use of
\r
79 the following functions:
\r
80 - PDMA_set_irq_handler()
\r
83 - PDMA_disable_irq()
\r
84 The PDMA_set_irq_handler() function is used to register PDMA channel interrupt
\r
85 handler functions with the driver. You must create and register an interrupt
\r
86 handler function for each interrupt driven PDMA channel used by the application.
\r
87 Use the PDMA_enable_irq() function to enable interrupts for the PDMA channels.
\r
88 Every time a PDMA channel completes the transfer of a buffer it causes a PDMA
\r
89 interrupt to occur and the PDMA driver will call the interrupt handler
\r
90 registered by the application for that PDMA channel.
\r
92 *//*=========================================================================*/
\r
93 #ifndef __MSS_PERIPHERAL_DMA_H_
\r
94 #define __MSS_PERIPHERAL_DMA_H_
\r
100 #include "../../CMSIS/a2fxxxm3.h"
\r
102 /***************************************************************************//**
\r
103 The pdma_channel_id_t enumeration is used to identify peripheral DMA channels.
\r
104 It is used as function parameter to specify the PDMA channel used.
\r
106 typedef enum __pdma_channel_id
\r
108 PDMA_CHANNEL_0 = 0,
\r
116 } pdma_channel_id_t;
\r
118 /***************************************************************************//**
\r
119 The pdma_src_dest_t enumeration is used to specify the source or destination
\r
120 of transfers on a PDMA channel. It specifies which hardware peripheral will be
\r
121 the source or destination of DMA transfers. This allows the PDMA controller
\r
122 to use hardware flow control signals to avoid overrunning a
\r
123 destination peripheral with data it is not ready to receive, or attempting to
\r
124 transfer data from a peripheral while it has no data ready to transfer.
\r
125 The pdma_src_dest_t enumeration can also be used to specify that a PDMA channel
\r
126 is configured to transfer data between two memory mapped locations
\r
127 (memory to memory). No hardware data flow control is used by the PDMA
\r
128 controller in this configuration.
\r
129 This enumeration is used as parameter to function PDMA_configure().
\r
131 typedef enum __pdma_src_dest
\r
133 PDMA_FROM_UART_0 = 0,
\r
150 /***************************************************************************//**
\r
151 The pdma_priority_ratio_t enumeration is used to configure the ratio of high
\r
152 priority to low priority PDMA channels. This ratio specifies how many DMA
\r
153 transfer opportunities will be given to high priority channels before a DMA
\r
154 transfer opportunity is given to a low priority channel when there are
\r
155 continuous requests from high priority channels. This enumeration is used as
\r
156 parameter to function PDMA_set_priority_ratio().
\r
158 typedef enum __pdma_priority_ratio_t
\r
160 PDMA_ROUND_ROBIN = 0,
\r
161 PDMA_RATIO_HIGH_LOW_1_TO_1 = 1,
\r
162 PDMA_RATIO_HIGH_LOW_3_TO_1 = 3,
\r
163 PDMA_RATIO_HIGH_LOW_7_TO_1 = 7,
\r
164 PDMA_RATIO_HIGH_LOW_15_TO_1 = 15,
\r
165 PDMA_RATIO_HIGH_LOW_31_TO_1 = 31,
\r
166 PDMA_RATIO_HIGH_LOW_63_TO_1 = 63,
\r
167 PDMA_RATIO_HIGH_LOW_127_TO_1 = 127,
\r
168 PDMA_RATIO_HIGH_LOW_255_TO_1 = 255
\r
169 } pdma_priority_ratio_t;
\r
172 /***************************************************************************//**
\r
173 The pdma_channel_isr_t type is a pointer to a PDMA channel interrupt handler
\r
174 function. It specifies the function prototype of functions that can be
\r
175 registered as PDMA channel interrupt handlers. It is used as parameter to
\r
176 function PDMA_set_irq_handler().
\r
178 typedef void (*pdma_channel_isr_t)( void );
\r
179 /***************************************************************************//**
\r
180 These constants are used to build the channel_cfg parameter of the
\r
181 PDMA_configure() function. They specify whether a channel is a high or low
\r
184 #define PDMA_LOW_PRIORITY 0x0000
\r
185 #define PDMA_HIGH_PRIORITY 0x0200
\r
187 /***************************************************************************//**
\r
188 These constants are used to build the channel_cfg parameter of the
\r
189 PDMA_configure() function. They specify the data width of the transfers
\r
190 performed by a PDMA channel.
\r
192 #define PDMA_BYTE_TRANSFER 0x0000 /* Byte transfers (8 bits) */
\r
193 #define PDMA_HALFWORD_TRANSFER 0x0004 /* Half-word transfers (16 bits) */
\r
194 #define PDMA_WORD_TRANSFER 0x0008 /* Word transfers (32 bits) */
\r
196 /***************************************************************************//**
\r
197 These constants are used to build the channel_cfg parameter of the
\r
198 PDMA_configure() function. They specify the PDMA channel
\92s source and
\r
199 destination address increment.
\r
201 #define PDMA_NO_INC 0
\r
202 #define PDMA_INC_SRC_ONE_BYTE 0x0400
\r
203 #define PDMA_INC_SRC_TWO_BYTES 0x0800
\r
204 #define PDMA_INC_SRC_FOUR_BYTES 0x0C00
\r
205 #define PDMA_INC_DEST_ONE_BYTE 0x1000
\r
206 #define PDMA_INC_DEST_TWO_BYTES 0x2000
\r
207 #define PDMA_INC_DEST_FOUR_BYTES 0x3000
\r
209 /***************************************************************************//**
\r
210 * Mask for various control register bits.
\r
212 #define PDMA_IRQ_ENABLE_MASK (uint32_t)0x00000040
\r
213 #define PDMA_PAUSE_MASK (uint32_t)0x00000010
\r
215 /***************************************************************************//**
\r
216 These constants are used to specify the src_addr parameter to the PDMA_start()
\r
217 and PDMA_load_next_buffer() functions. They specify the receive register
\r
218 address of peripherals that can be the source of a DMA transfer.
\r
219 When a PDMA channel is configured for DMA transfers from a peripheral to memory,
\r
220 the constant specifying that peripheral
\92s receive register address must be used
\r
221 as the src_addr parameter.
\r
223 #define PDMA_SPI0_RX_REGISTER 0x40001010uL
\r
224 #define PDMA_SPI1_RX_REGISTER 0x40011010uL
\r
225 #define PDMA_UART0_RX_REGISTER 0x40000000uL
\r
226 #define PDMA_UART1_RX_REGISTER 0x40010000uL
\r
227 #define PDMA_ACE_PPE_DATAOUT 0x40021308uL
\r
229 /***************************************************************************//**
\r
230 These constants are used to specify the dest_addr parameter to the PDMA_start()
\r
231 and PDMA_load_next_buffer() functions. They specify the transmit register
\r
232 address of peripherals that can be the destination of a DMA transfer.
\r
233 When a PDMA channel is configured for DMA transfers from memory to a peripheral,
\r
234 the constant specifying that peripheral
\92s transmit register address must be used
\r
235 as the dest_addr parameter.
\r
237 #define PDMA_SPI0_TX_REGISTER 0x40001014uL
\r
238 #define PDMA_SPI1_TX_REGISTER 0x40011014uL
\r
239 #define PDMA_UART0_TX_REGISTER 0x40000000uL
\r
240 #define PDMA_UART1_TX_REGISTER 0x40010000uL
\r
241 #define PDMA_ACE_SSE_DATAIN 0x40020700uL
\r
243 /***************************************************************************//**
\r
244 The PDMA_DEFAULT_WRITE_ADJ constant provides a suitable default value for the
\r
245 PDMA_configure() function write_adjust parameter.
\r
247 #define PDMA_DEFAULT_WRITE_ADJ 10u
\r
249 /***************************************************************************//**
\r
250 The PDMA_init() function initializes the peripheral DMA hardware and driver
\r
251 internal data. It resets the PDMA and it also clears any pending PDMA
\r
252 interrupts in the Cortex-M3 interrupt controller. When the function exits, it
\r
253 takes the PDMA block out of reset.
\r
255 void PDMA_init( void );
\r
257 /***************************************************************************//**
\r
258 The PDMA_configure() function configures a PDMA channel.
\r
260 - The peripheral which will be the source or destination of the DMA transfer.
\r
261 - Whether the DMA channel will be a high or low priority channel
\r
262 - The source and destination address increment that will take place after
\r
266 The channel_id parameter identifies the PDMA channel used by the function.
\r
269 The src_dest parameter specifies the source or destination of the DMA
\r
270 transfers that will be performed. It can be one of the following:
\r
288 The channel_cfg parameter specifies the configuration of the PDMA channel.
\r
289 The configuration includes:
\r
292 - source and/or destination address increment
\r
293 The channel_cfg parameter value is a logical OR of:
\r
294 One of the following to specify the channel priority:
\r
295 - PDMA_LOW_PRIORITY
\r
296 - PDMA_HIGH_PRIORITY
\r
297 One of the following to specify the transfer size:
\r
298 - PDMA_BYTE_TRANSFER
\r
299 - PDMA_HALFWORD_TRANSFER
\r
300 - PDMA_WORD_TRANSFER
\r
301 One or two of the following to specify the source and/or destination address
\r
304 - PDMA_INC_SRC_ONE_BYTE
\r
305 - PDMA_INC_SRC_TWO_BYTES
\r
306 - PDMA_INC_SRC_FOUR_BYTES
\r
307 - PDMA_INC_DEST_ONE_BYTE
\r
308 - PDMA_INC_DEST_TWO_BYTES
\r
309 - PDMA_INC_DEST_FOUR_BYTES
\r
311 @param write_adjust
\r
312 The write_adjust parameter specifies the number of Cortex-M3 clock cycles
\r
313 the PDMA controller will wait before attempting another transfer cycle. This
\r
314 delay is necessary when peripherals are used as destination of a DMA transfer
\r
315 to ensure the DMA controller interprets the state of the peripheral
\92s ready
\r
316 signal only after data has actually been written to the peripheral. This delay
\r
317 accounts for posted writes (dump and run) for write accesses to peripherals.
\r
318 The effect of posted writes is that if the PDMA performs a write operation to
\r
319 a peripheral, the data is not actually written into the peripheral until
\r
320 sometime after the PDMA controller thinks it is written.
\r
321 A suitable value for write_adjust depends on the target of the DMA transfer.
\r
322 Guidelines for choosing this value are as follows:
\r
323 \95 The PDMA_DEFAULT_WRITE_ADJ constant provides a suitable default value
\r
324 for the write_adjust parameter when the PDMA channel is configured for
\r
325 transfers with MSS peripherals.
\r
326 \95 The PDMA_DEFAULT_WRITE_ADJ constant can also be used for DMA transfers
\r
327 with FPGA fabric implemented peripherals making use of the DMAREADY0 or
\r
328 DMAREADY1fabric interface signal to indicate that the peripheral is
\r
329 ready for another DMA transfer.
\r
330 \95 The write_adjust parameter can be set to zero to achieve maximum transfer
\r
331 speed for genuine memory to memory transfers.
\r
332 \95 The internal latency of FPGA implemented peripherals will decide the
\r
333 write_adjust value for fabric peripherals that do not use the DMAREADY0
\r
334 or DMAREADY1 fabric interface signals. You need to check the fabric
\r
335 peripheral documentation for the value to use.
\r
343 PDMA_LOW_PRIORITY | PDMA_BYTE_TRANSFER | PDMA_INC_SRC_ONE_BYTE,
\r
344 PDMA_DEFAULT_WRITE_ADJ
\r
348 void PDMA_configure
\r
350 pdma_channel_id_t channel_id,
\r
351 pdma_src_dest_t src_dest,
\r
352 uint32_t channel_cfg,
\r
353 uint8_t write_adjust
\r
357 /***************************************************************************//**
\r
358 The PDMA_set_priority_ratio() function sets the ratio of high priority to low
\r
359 priority DMA access opportunities. This ratio is used by the PDMA controller
\r
360 arbiter to decide which PDMA channel will be given the opportunity to perform
\r
361 a transfer when multiple PDMA channels are requesting to transfer data at the
\r
362 same time. The priority ratio specifies how many DMA transfer opportunities
\r
363 will be given to high priority channels before a DMA transfer opportunity is
\r
364 given to a low priority channel when there are continuous requests from high
\r
367 @param priority_ratio
\r
368 The priority_ratio parameter specifies the ratio of DMA access opportunities
\r
369 given to high priority channels versus low priority channels.
\r
370 Allowed values for this parameter are:
\r
372 - PDMA_RATIO_HIGH_LOW_1_TO_1
\r
373 - PDMA_RATIO_HIGH_LOW_3_TO_1
\r
374 - PDMA_RATIO_HIGH_LOW_7_TO_1
\r
375 - PDMA_RATIO_HIGH_LOW_15_TO_1
\r
376 - PDMA_RATIO_HIGH_LOW_31_TO_1
\r
377 - PDMA_RATIO_HIGH_LOW_63_TO_1
\r
378 - PDMA_RATIO_HIGH_LOW_127_TO_1
\r
379 - PDMA_RATIO_HIGH_LOW_255_TO_1
\r
383 PDMA_set_priority_ratio( PDMA_ROUND_ROBIN );
\r
386 static __INLINE void PDMA_set_priority_ratio
\r
388 pdma_priority_ratio_t priority_ratio
\r
391 PDMA->RATIO_HIGH_LOW = (uint32_t)priority_ratio;
\r
394 /***************************************************************************//**
\r
395 The PDMA_start() function initiates a DMA transfer. It specifies the source
\r
396 and destination address of the transfer as well as the number of transfers
\r
397 that must take place. The source and destination addresses can be the address
\r
398 of peripheral registers.
\r
401 The channel_id parameter identifies the PDMA channel used by the function.
\r
404 The src_addr parameter specifies the address location of the data to be
\r
405 transferred. You must ensure that this source address is consistent with the
\r
406 DMA source configured for the selected channel using the PDMA_configure()
\r
408 For DMA transfers from MSS peripheral to memory, the following src_addr
\r
409 parameter values are allowed:
\r
410 \95 PDMA_SPI0_RX_REGISTER
\r
411 \95 PDMA_SPI1_RX_REGISTER
\r
412 \95 PDMA_UART0_RX_REGISTER
\r
413 \95 PDMA_UART1_RX_REGISTER
\r
414 \95 PDMA_ACE_PPE_DATAOUT
\r
415 For DMA transfers from FPGA fabric peripheral to memory, the following
\r
416 src_addr parameter values are allowed:
\r
417 \95 An address in the FPGA fabric address space (0x40050000-0x400FFFFF)
\r
418 For DMA transfers from memory to MSS peripheral, or from memory to FPGA
\r
419 fabric peripheral, or from memory to memory, the following src_addr
\r
420 parameter values are allowed:
\r
421 \95 Any memory mapped address.
\r
424 The dest_addr parameter specifies the destination address of the PDMA
\r
425 transfer. You must ensure that this matches with the DMA destination
\r
426 configured for the selected channel.
\r
427 For DMA transfers from memory to MSS peripheral, the following dest_addr parameter values are allowed:
\r
428 \95 PDMA_SPI0_TX_REGISTER
\r
429 \95 PDMA_SPI1_TX_REGISTER
\r
430 \95 PDMA_UART0_TX_REGISTER
\r
431 \95 PDMA_UART1_TX_REGISTER
\r
432 \95 PDMA_ACE_SSE_DATAIN
\r
433 For DMA transfers from memory to FPGA fabric peripheral, the following
\r
434 dest_addr parameter values are allowed:
\r
435 \95 An address in the FPGA fabric address space (0x40050000-0x400FFFFF)
\r
436 For DMA transfers from MSS peripheral to memory, or from FPGA fabric
\r
437 peripheral to memory, or from memory to memory, the following dest_addr
\r
438 parameter values are allowed:
\r
439 \95 Any memory mapped address.
\r
441 @param transfer_count
\r
442 The transfer_count parameter specifies the number of transfers to be
\r
443 performed. It is the number of bytes to transfer if the PDMA channel is
\r
444 configured for byte transfer, the number of half-words to transfer if the
\r
445 PDMA channel is configured for half-word transfer, or the number of words
\r
446 to transfer if the PDMA channel is configured for word transfer.
\r
453 PDMA_SPI1_RX_REGISTER,
\r
454 (uint32_t)slave_rx_buffer,
\r
455 sizeof(slave_rx_buffer)
\r
461 pdma_channel_id_t channel_id,
\r
463 uint32_t dest_addr,
\r
464 uint16_t transfer_count
\r
467 /***************************************************************************//**
\r
468 The PDMA_load_next_buffer() function sets the next buffer to be transferred.
\r
469 This function is called after a transfer has been initiated using the
\r
470 PDMA_start() function. Its purpose is to keep feeding a PDMA channel with data
\r
474 The channel_id parameter identifies the PDMA channel used by the function.
\r
477 The src_addr parameter specifies the address location of the data to be
\r
478 transferred. You must ensure that this source address is consistent with the
\r
479 DMA source configured for the selected channel using the PDMA_configure()
\r
481 For DMA transfers from MSS peripheral to memory, the following src_addr parameter values are allowed:
\r
482 \95 PDMA_SPI0_RX_REGISTER
\r
483 \95 PDMA_SPI1_RX_REGISTER
\r
484 \95 PDMA_UART0_RX_REGISTER
\r
485 \95 PDMA_UART1_RX_REGISTER
\r
486 \95 PDMA_ACE_PPE_DATAOUT
\r
487 For DMA transfers from FPGA fabric peripheral to memory, the following src_addr parameter values are allowed:
\r
488 \95 An address in the FPGA fabric address space (0x40050000-0x400FFFFF)
\r
489 For DMA transfers from memory to MSS peripheral, or from memory to FPGA fabric peripheral, or from memory to memory, the following src_addr parameter values are allowed:
\r
490 \95 Any memory mapped address.
\r
493 The dest_addr parameter specifies the destination address of the PDMA
\r
494 transfer. You must ensure that this matches with the DMA destination
\r
495 configured for the selected channel.
\r
496 For DMA transfers from memory to MSS peripheral, the following dest_addr parameter values are allowed:
\r
497 \95 PDMA_SPI0_TX_REGISTER
\r
498 \95 PDMA_SPI1_TX_REGISTER
\r
499 \95 PDMA_UART0_TX_REGISTER
\r
500 \95 PDMA_UART1_TX_REGISTER
\r
501 \95 PDMA_ACE_SSE_DATAIN
\r
502 For DMA transfers from memory to FPGA fabric peripheral, the following dest_addr parameter values are allowed:
\r
503 \95 An address in the FPGA fabric address space (0x40050000-0x400FFFFF)
\r
504 For DMA transfers from MSS peripheral to memory, or from FPGA fabric peripheral to memory, or from memory to memory, the following dest_addr parameter values are allowed:
\r
505 \95 Any memory mapped address.
\r
507 @param transfer_count
\r
508 The transfer_count parameter specifies the number of transfers to be
\r
509 performed. It is the number of bytes to transfer if the PDMA channel is
\r
510 configured for byte transfer, the number of half-words to transfer if the
\r
511 PDMA channel is configured for half-word transfer or the number of words to
\r
512 transfer if the PDMA channel is configured for word transfer.
\r
516 void write_cmd_data
\r
518 mss_spi_instance_t * this_spi,
\r
519 const uint8_t * cmd_buffer,
\r
520 uint16_t cmd_byte_size,
\r
521 uint8_t * data_buffer,
\r
522 uint16_t data_byte_size
\r
525 uint32_t transfer_size;
\r
527 transfer_size = cmd_byte_size + data_byte_size;
\r
529 MSS_SPI_disable( this_spi );
\r
530 MSS_SPI_set_transfer_byte_count( this_spi, transfer_size );
\r
535 (uint32_t)cmd_buffer,
\r
536 PDMA_SPI1_TX_REGISTER,
\r
540 PDMA_load_next_buffer
\r
543 (uint32_t)data_buffer,
\r
544 PDMA_SPI1_TX_REGISTER,
\r
548 MSS_SPI_enable( this_spi );
\r
550 while ( !MSS_SPI_tx_done(this_spi) )
\r
557 void PDMA_load_next_buffer
\r
559 pdma_channel_id_t channel_id,
\r
561 uint32_t dest_addr,
\r
562 uint16_t transfer_count
\r
565 /***************************************************************************//**
\r
566 The PDMA_status() function returns the status of a DMA channel.
\r
567 The returned value indicates if transfers have been completed using buffer A
\r
568 or buffer B of the PDMA hardware block.
\r
571 The channel_id parameter identifies the PDMA channel used by the function.
\r
574 bit 0 of the return value indicates if buffer A has been trasnfered. It is
\r
575 set to 1 if the transfer has completed.
\r
576 bit 1 of the return value indicates if buffer B has been transfered. It is
\r
577 set to 1 if the transfer has completed.
\r
579 uint32_t PDMA_status
\r
581 pdma_channel_id_t channel_id
\r
584 /***************************************************************************//**
\r
585 The PDMA_pause() function temporarily pauses a PDMA transfer taking place on
\r
586 the specified PDMA channel. The transfer can later be resumed by using the
\r
587 PDMA_resume() function.
\r
590 The channel_id parameter identifies the PDMA channel used by the function.
\r
592 static __INLINE void PDMA_pause( pdma_channel_id_t channel_id )
\r
594 PDMA->CHANNEL[channel_id].CRTL |= PDMA_PAUSE_MASK;
\r
597 /***************************************************************************//**
\r
598 The PDMA_resume() function resumes a transfer previously paused using the
\r
599 PDMA_pause() function.
\r
601 @param channel_id The channel_id parameter identifies the PDMA channel
\r
602 used by the function.
\r
604 static __INLINE void PDMA_resume( pdma_channel_id_t channel_id )
\r
606 PDMA->CHANNEL[channel_id].CRTL &= ~PDMA_PAUSE_MASK;
\r
609 /***************************************************************************//**
\r
610 The PDMA_enable_irq() enables the PDMA hardware to generate an interrupt when
\r
611 a DMA transfer completes on the specified PDMA channel. This function also
\r
612 enables the PDMA interrupt in the Cortex-M3 interrupt controller.
\r
615 The channel_id parameter identifies the PDMA channel used by the function.
\r
617 void PDMA_enable_irq( pdma_channel_id_t channel_id );
\r
619 /***************************************************************************//**
\r
620 The PDMA_disable_irq() disables interrupts for a specific PDMA channel.
\r
623 The channel_id parameter identifies the PDMA channel used by the function.
\r
625 static __INLINE void PDMA_disable_irq( pdma_channel_id_t channel_id )
\r
627 PDMA->CHANNEL[channel_id].CRTL &= ~PDMA_IRQ_ENABLE_MASK;
\r
630 /***************************************************************************//**
\r
631 The PDMA_set_irq_handler() function registers a handler function for
\r
632 interrupts generated on the completion of a transfer on a specific PDMA
\r
633 channel. This function also enables the PDMA interrupt both in the PDMA
\r
634 controller and in the Cortex-M3 interrupt controller.
\r
637 The channel_id parameter identifies the PDMA channel used by the function.
\r
640 The handler parameter is a pointer to the function that will be called when
\r
641 a transfer completes on the PDMA channel identified by channel_id and the
\r
642 interrupt is enabled for that channel.
\r
646 void slave_dma_irq_handler( void )
\r
648 if ( g_spi1_rx_buffer[2] == 0x99 )
\r
650 PDMA_load_next_buffer
\r
653 (uint32_t)g_spi1_tx_buffer_b,
\r
654 PDMA_SPI1_TX_REGISTER,
\r
655 sizeof(g_spi1_tx_buffer_b)
\r
658 PDMA_disable_irq( PDMA_CHANNEL_3 );
\r
661 void setup_dma( void )
\r
668 PDMA_LOW_PRIORITY | PDMA_BYTE_TRANSFER | PDMA_INC_SRC_ONE_BYTE
\r
674 PDMA_HIGH_PRIORITY | PDMA_BYTE_TRANSFER | PDMA_INC_DEST_ONE_BYTE
\r
676 PDMA_set_irq_handler( PDMA_CHANNEL_3, slave_dma_irq_handler );
\r
677 PDMA_start( PDMA_CHANNEL_3, PDMA_SPI1_RX_REGISTER, (uint32_t)g_spi1_rx_buffer, 3 );
\r
681 void PDMA_set_irq_handler
\r
683 pdma_channel_id_t channel_id,
\r
684 pdma_channel_isr_t handler
\r
687 /***************************************************************************//**
\r
688 The PDMA_clear_irq() function clears interrupts for a specific PDMA channel.
\r
689 This function also clears the PDMA interrupt in the Cortex-M3 NVIC.
\r
692 The channel_id parameter identifies the PDMA channel used by the function.
\r
694 void PDMA_clear_irq
\r
696 pdma_channel_id_t channel_id
\r
703 #endif /* __MSS_PERIPHERAL_DMA_H_ */
\r