Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SAM3A/3N/3S/3U/3X/4E/4N/4S/G Peripheral DMA Controller (PDC) Driver

This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the the Peripheral Direct Memory Access (DMA) Controller (PDC) module.

The PDC transfers data between on-chip serial peripherals and the on and/or off-chip memories. The link between the PDC and a serial peripheral is operated by the AHB to ABP bridge.

This module:

Devices from the following series can use this module:

The outline of this documentation is as follows:

Prerequisites

There are no prerequisites for this module.

Module Overview

The user interface of each PDC channel is integrated into the user interface of the peripheral it serves. The user interface of unidirectional channels (receive only or transmit only), contains two 32-bit memory pointers and two 16-bit counters, one set (pointer, counter) for current transfer and one set (pointer, counter) for next transfer. The bidirectional channel user interface contains four 32-bit memory pointers and four 16-bit counters. Each set (pointer, counter) is used by current transmit, next transmit, current receive and next receive. Using the PDC removes processor overhead by reducing its intervention during the transfer. This significantly reduces the number of clock cycles required for a data transfer, which improves microcontroller performance. To launch a transfer, the peripheral triggers its associated PDC channels by using transmit and receive signals. When the programmed data is transferred, an end of transfer interrupt is generated by the peripheral itself.

Special Considerations

There are no special considerations for this module.

Extra Information

For extra information, see Extra Information for Peripheral DMA Controller. This includes:

Examples

For a list of examples related to this driver, see Examples for Peripheral DMA Controller.

API Overview

Data Structures

struct  pdc_packet
 PDC data packet for transfer. More...
 

Typedefs

typedef struct pdc_packet pdc_packet_t
 PDC data packet for transfer. More...
 

Functions

void pdc_disable_transfer (Pdc *p_pdc, uint32_t ul_controls)
 Disable PDC transfers (TX and/or RX). More...
 
void pdc_enable_transfer (Pdc *p_pdc, uint32_t ul_controls)
 Enable PDC transfers (TX and/or RX). More...
 
uint32_t pdc_read_rx_counter (Pdc *p_pdc)
 Return Receive Counter Register (RCR) value. More...
 
uint32_t pdc_read_rx_next_counter (Pdc *p_pdc)
 Return Receive Next Counter Register (RNCR) value. More...
 
uint32_t pdc_read_rx_next_ptr (Pdc *p_pdc)
 Return Receive Next Pointer Register (RNPR) value. More...
 
uint32_t pdc_read_rx_ptr (Pdc *p_pdc)
 Return Receive Pointer Register (RPR) value. More...
 
uint32_t pdc_read_status (Pdc *p_pdc)
 Read PDC status. More...
 
uint32_t pdc_read_tx_counter (Pdc *p_pdc)
 Return Transmit Counter Register (TCR) value. More...
 
uint32_t pdc_read_tx_next_counter (Pdc *p_pdc)
 Return Transmit Next Counter Register (TNCR) value. More...
 
uint32_t pdc_read_tx_next_ptr (Pdc *p_pdc)
 Return Transmit Next Pointer Register (TNPR) value. More...
 
uint32_t pdc_read_tx_ptr (Pdc *p_pdc)
 Return Transmit Pointer Register (TPR) value. More...
 
void pdc_rx_clear_cnt (Pdc *p_pdc)
 Clear PDC buffer receive counter. More...
 
void pdc_rx_init (Pdc *p_pdc, pdc_packet_t *p_packet, pdc_packet_t *p_next_packet)
 Configure PDC for data receive. More...
 
void pdc_tx_init (Pdc *p_pdc, pdc_packet_t *p_packet, pdc_packet_t *p_next_packet)
 Configure PDC for data transmit. More...
 

typedef struct pdc_packet pdc_packet_t

PDC data packet for transfer.

void pdc_disable_transfer ( Pdc *  p_pdc,
uint32_t  ul_controls 
)

Disable PDC transfers (TX and/or RX).

Parameters
[out]p_pdcDevice structure pointer
[in]ul_controlsTransfer directions (bit PERIPH_PTCR_TXTDIS, bit PERIPH_PTCR_TXTDIS)

References Assert.

Referenced by nm_bus_init().

void pdc_enable_transfer ( Pdc *  p_pdc,
uint32_t  ul_controls 
)

Enable PDC transfers (TX and/or RX).

Note
It is forbidden to set both TXTEN and RXTEN for a half duplex peripheral.
Parameters
[out]p_pdcDevice structure pointer
[in]ul_controlsTransfer directions (bit PERIPH_PTCR_RXTEN and bit PERIPH_PTCR_TXTEN)

References Assert.

uint32_t pdc_read_rx_counter ( Pdc *  p_pdc)

Return Receive Counter Register (RCR) value.

Parameters
[in]p_pdcDevice structure pointer
Returns
Receive Counter Register value.

References Assert.

uint32_t pdc_read_rx_next_counter ( Pdc *  p_pdc)

Return Receive Next Counter Register (RNCR) value.

Parameters
[in]p_pdcDevice structure pointer
Returns
Receive Next Counter Register value.

References Assert.

uint32_t pdc_read_rx_next_ptr ( Pdc *  p_pdc)

Return Receive Next Pointer Register (RNPR) value.

Parameters
[in]p_pdcDevice structure pointer
Returns
Receive Next Pointer Register value.

References Assert.

uint32_t pdc_read_rx_ptr ( Pdc *  p_pdc)

Return Receive Pointer Register (RPR) value.

Parameters
[in]p_pdcDevice structure pointer
Returns
Receive Pointer Register value.

References Assert.

uint32_t pdc_read_status ( Pdc *  p_pdc)

Read PDC status.

Parameters
[in]p_pdcDevice structure pointer
Returns
PDC status register bit map.
Name Description Bit
RXTEN Receiver Transfer Enabled 8
TXTEN Transmitter Transfer Enabled 1

References Assert.

uint32_t pdc_read_tx_counter ( Pdc *  p_pdc)

Return Transmit Counter Register (TCR) value.

Parameters
[in]p_pdcDevice structure pointer
Returns
Transmit Counter Register value.

References Assert.

uint32_t pdc_read_tx_next_counter ( Pdc *  p_pdc)

Return Transmit Next Counter Register (TNCR) value.

Parameters
[in]p_pdcDevice structure pointer
Returns
Transmit Next Counter Register value.

References Assert.

uint32_t pdc_read_tx_next_ptr ( Pdc *  p_pdc)

Return Transmit Next Pointer Register (TNPR) value.

Parameters
[in]p_pdcDevice structure pointer
Returns
Transmit Next Pointer Register value.

References Assert.

uint32_t pdc_read_tx_ptr ( Pdc *  p_pdc)

Return Transmit Pointer Register (TPR) value.

Parameters
[in]p_pdcDevice structure pointer
Returns
Transmit Pointer Register value.

References Assert.

void pdc_rx_clear_cnt ( Pdc *  p_pdc)

Clear PDC buffer receive counter.

Parameters
[out]p_pdcDevice structure pointer

References Assert.

void pdc_rx_init ( Pdc *  p_pdc,
pdc_packet_t p_packet,
pdc_packet_t p_next_packet 
)

Configure PDC for data receive.

Parameters
[out]p_pdcDevice structure pointer
[in]p_packetPointer to packet information for current buffer register set. Use NULL to leave unaltered.
[in]p_next_packetPointer to packet information for next buffer register set. Use NULL to leave unaltered.

References Assert, pdc_packet::ul_addr, and pdc_packet::ul_size.

Referenced by nm_spi_rw().

void pdc_tx_init ( Pdc *  p_pdc,
pdc_packet_t p_packet,
pdc_packet_t p_next_packet 
)

Configure PDC for data transmit.

Parameters
[out]p_pdcDevice structure pointer
[in]p_packetPointer to packet information for current buffer register set. Use NULL to leave unaltered.
[in]p_next_packetPointer to packet information for next buffer register set. Use NULL to leave unaltered.

References Assert, pdc_packet::ul_addr, and pdc_packet::ul_size.

Referenced by nm_spi_rw().