This file gives an example of using the PDC to burst data on the USART. With and without the use of interrupts.
Definition in file pdc.h.
#include <avr32/io.h>
Include dependency graph for pdc.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| void | pdc_disable (void *dev) |
| Disable the PDC for the given peripheral device. | |
| void | pdc_disableRx (void *dev) |
| Disable the PDC receiver. | |
| void | pdc_disableTx (void *dev) |
| Disable the PDC transmitter. | |
| void | pdc_enable (void *dev) |
| Enable the PDC for the given peripheral device. | |
| void | pdc_enableRx (void *dev) |
| Enable the PDC receiver, the buffers will remain the same as they were before PDC got disabled (ie. the PDC continues were it left of. | |
| void | pdc_enableTx (void *dev) |
| Enable the PDC transmitter, the buffers will remain the same as they were before PDC got disabled (ie. the PDC continues were it left of). | |
| void | pdc_flushCache (void *buffer, unsigned short size) |
| Flush the cache at a given address. | |
| int | pdc_getRcr (void *dev) |
| Check remaining size of current receive buffer. | |
| int | pdc_getTcr (void *dev) |
| Check remaining size of current transmit buffer. | |
| int | pdc_rxBytesLeft (void *dev) |
| Check total remaining size of the receive buffers. | |
| void | pdc_setRxBuf (void *dev, void *rp, unsigned short rc, void *rnp, unsigned short rnc) |
| Give pointers and size of receive buffers to the PDC (Peripheral DMA Controller), and enables the receiver. | |
| void | pdc_setRxNextBuf (void *dev, void *rnp, unsigned short rnc) |
| Give pointers and size of the next receive buffers to the PDC (Peripheral DMA Controller). | |
| void | pdc_setTxBuf (void *dev, void *tp, unsigned short tc, void *tnp, unsigned short tnc) |
| Give pointers and size of transmit buffers to the PDC (Peripheral DMA Controller), and enables the transmitter. | |
| void | pdc_setTxNextBuf (void *dev, void *tnp, unsigned short tnc) |
| Give pointers and size of the next transmit buffers to add to the PDC (Peripheral DMA Controller). | |
| void * | pdc_translatePtr (void *pointerAddr) |
| Translates memory addresses from P1, P2, P3 and P4 memory space to the P0 memory space. This function is only valid if the MMU is not used. | |
| int | pdc_txBytesLeft (void *dev) |
| Check total remaining size of the transmit buffers. | |
|
|
Disable the PDC for the given peripheral device.
Definition at line 90 of file pdc.c. References PDC_RXTDIS_OFFSET, and PDC_TXTDIS_OFFSET. Referenced by start_interrupts(), and stop_interrupts(). 00091 { 00092 /* Disable RX and TX */ 00093 ((struct peripheral_t *)dev)->ptcr = 00094 (1<<PDC_RXTDIS_OFFSET)|(1<<PDC_TXTDIS_OFFSET); 00095 }
|
|
|
Disable the PDC receiver.
Definition at line 114 of file pdc.c. References PDC_RXTDIS_OFFSET. Referenced by pdc_setRxBuf(). 00115 { 00116 /* Disable RX */ 00117 ((struct peripheral_t *)dev)->ptcr = (1<<PDC_RXTDIS_OFFSET); 00118 }
|
|
|
Disable the PDC transmitter.
Definition at line 125 of file pdc.c. References PDC_TXTDIS_OFFSET. Referenced by pdc_setTxBuf(). 00126 { 00127 /* Disable TX */ 00128 ((struct peripheral_t *)dev)->ptcr = (1<<PDC_TXTDIS_OFFSET); 00129 }
|
|
|
Enable the PDC for the given peripheral device.
Definition at line 102 of file pdc.c. References PDC_RXTEN_OFFSET, and PDC_TXTEN_OFFSET. Referenced by start_interrupts(). 00103 { 00104 /* Enable RX and TX */ 00105 ((struct peripheral_t *)dev)->ptcr = 00106 (1<<PDC_RXTEN_OFFSET)|(1<<PDC_TXTEN_OFFSET); 00107 }
|
|
|
Enable the PDC receiver, the buffers will remain the same as they were before PDC got disabled (ie. the PDC continues were it left of.
Definition at line 138 of file pdc.c. References PDC_RXTEN_OFFSET. Referenced by pdc_setRxBuf(). 00139 { 00140 /* Enable RX */ 00141 ((struct peripheral_t *)dev)->ptcr = (1<<PDC_RXTEN_OFFSET); 00142 }
|
|
|
Enable the PDC transmitter, the buffers will remain the same as they were before PDC got disabled (ie. the PDC continues were it left of).
Definition at line 151 of file pdc.c. References PDC_TXTEN_OFFSET. Referenced by pdc_setTxBuf(). 00152 { 00153 ((struct peripheral_t *)dev)->ptcr = (1<<PDC_TXTEN_OFFSET); 00154 }
|
|
||||||||||||
|
Flush the cache at a given address.
Definition at line 338 of file pdc.c. Referenced by main(), and start_interrupts(). 00339 { 00340 unsigned int i; 00341 long memoryAddress = (long) buffer; 00342 00343 for (i = 0; i < size; ++i) { 00344 #ifdef __GNUC__ 00345 __builtin_cache((void *)memoryAddress, 0x0C); 00346 #elif __ICCAVR32__ 00347 __cache_control((void *)memoryAddress, 0x0C); 00348 #else 00349 #error No valid compiler for pdc_flushCache() function 00350 #endif 00351 00352 memoryAddress += 32; 00353 } 00354 }
|
|
|
Check remaining size of current receive buffer.
Definition at line 277 of file pdc.c. 00278 { 00279 int bytes = 0; 00280 bytes += ((struct peripheral_t *)dev)->rcr; 00281 00282 return bytes; 00283 }
|
|
|
Check remaining size of current transmit buffer.
Definition at line 308 of file pdc.c. 00309 { 00310 int bytes = 0; 00311 bytes += ((struct peripheral_t *)dev)->tcr; 00312 00313 return bytes; 00314 }
|
|
|
Check total remaining size of the receive buffers.
Definition at line 292 of file pdc.c. 00293 { 00294 int bytes = 0; 00295 bytes += ((struct peripheral_t *)dev)->rcr; 00296 bytes += ((struct peripheral_t *)dev)->rncr; 00297 00298 return bytes; 00299 }
|
|
||||||||||||||||||||||||
|
Give pointers and size of receive buffers to the PDC (Peripheral DMA Controller), and enables the receiver.
Definition at line 166 of file pdc.c. References pdc_disableRx(), and pdc_enableRx(). 00171 { 00172 pdc_disableRx(dev); 00173 00174 if (rp == 0 || rc == 0) { 00175 return; 00176 } 00177 00178 ((struct peripheral_t *)dev)->rpr = (long)rp; 00179 ((struct peripheral_t *)dev)->rcr = rc; 00180 00181 if (rnp != 0) { 00182 ((struct peripheral_t *)dev)->rnpr = (long)rnp; 00183 ((struct peripheral_t *)dev)->rncr = rnc; 00184 } 00185 00186 pdc_enableRx(dev); 00187 00188 return; 00189 }
Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
Give pointers and size of the next receive buffers to the PDC (Peripheral DMA Controller).
Definition at line 199 of file pdc.c. 00202 { 00203 if (rnp == 0 || rnc == 0) { 00204 return; 00205 } 00206 00207 ((struct peripheral_t *)dev)->rnpr = (long)rnp; 00208 ((struct peripheral_t *)dev)->rncr = rnc; 00209 00210 return; 00211 }
|
|
||||||||||||||||||||||||
|
Give pointers and size of transmit buffers to the PDC (Peripheral DMA Controller), and enables the transmitter.
Definition at line 223 of file pdc.c. References pdc_disableTx(), and pdc_enableTx(). Referenced by start_interrupts(). 00228 { 00229 pdc_disableTx(dev); 00230 00231 if (tp == 0 || tc == 0) { 00232 return; 00233 } 00234 00235 ((struct peripheral_t *)dev)->tpr = (long)tp; 00236 ((struct peripheral_t *)dev)->tcr = tc; 00237 00238 if (tnp != 0) { 00239 ((struct peripheral_t *)dev)->tnpr = (long)tnp; 00240 ((struct peripheral_t *)dev)->tncr = tnc; 00241 } 00242 00243 pdc_enableTx(dev); 00244 00245 return; 00246 }
Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
Give pointers and size of the next transmit buffers to add to the PDC (Peripheral DMA Controller).
Definition at line 256 of file pdc.c. Referenced by pdc_interrupt_handler(). 00259 { 00260 if (tnp == 0 || tnc == 0) { 00261 return; 00262 } 00263 00264 ((struct peripheral_t *)dev)->tnpr = (long)tnp; 00265 ((struct peripheral_t *)dev)->tncr = tnc; 00266 00267 return; 00268 }
|
|
|
Translates memory addresses from P1, P2, P3 and P4 memory space to the P0 memory space. This function is only valid if the MMU is not used.
Definition at line 365 of file pdc.c. Referenced by pdc_interrupt_handler(), and start_interrupts(). 00366 { 00367 unsigned long returnAddress = (unsigned long) pointerAddr; 00368 00369 /* Mapping between virtual address and physical address when the 00370 * MCU has been reset, and the MMU is not being used, is done by 00371 * clearing MSB in the memory address. 00372 * 00373 * For more details conserning the MMU see application note 00374 * AVR32113 Configuration and Use of the Memory Managment Unit. 00375 */ 00376 returnAddress &= ~(0x80000000); 00377 00378 return (void *) returnAddress; 00379 }
|
|
|
Check total remaining size of the transmit buffers.
Definition at line 323 of file pdc.c. Referenced by stop_interrupts(). 00324 { 00325 int bytes = 0; 00326 bytes += ((struct peripheral_t *)dev)->tcr; 00327 bytes += ((struct peripheral_t *)dev)->tncr; 00328 00329 return bytes; 00330 }
|
1.4.6-NO