![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Versão do protegemed que calcula o tempo em ms da fuga, calcula o numero de onverflow (valores muito baixo) e underflow (valores muito altos). Além disso, calcula um valor médio a partir dos valores capturados e não apenas pela fft.
Dependencies: EthernetInterface mbed-rtos mbed
Drivers/dma.c@2:86c3cb25577b, 2014-07-21 (annotated)
- Committer:
- rebonatto
- Date:
- Mon Jul 21 00:58:34 2014 +0000
- Revision:
- 2:86c3cb25577b
- Parent:
- 0:c64e1194230b
Problemas com objeto para aquisi??o da rfid (serial)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rebonatto | 0:c64e1194230b | 1 | /* |
rebonatto | 0:c64e1194230b | 2 | * dma.c |
rebonatto | 0:c64e1194230b | 3 | * |
rebonatto | 0:c64e1194230b | 4 | * Created on: 03/07/2011 |
rebonatto | 0:c64e1194230b | 5 | * Author: francisco |
rebonatto | 0:c64e1194230b | 6 | */ |
rebonatto | 0:c64e1194230b | 7 | #include <LPC17xx.h> |
rebonatto | 0:c64e1194230b | 8 | #include "dma.h" |
rebonatto | 0:c64e1194230b | 9 | |
rebonatto | 0:c64e1194230b | 10 | #define LPC_GPDMACH ((LPC_GPDMACH_TypeDef **) LPC_GPDMACH0_BASE ) |
rebonatto | 0:c64e1194230b | 11 | |
rebonatto | 0:c64e1194230b | 12 | void init_dma() |
rebonatto | 0:c64e1194230b | 13 | { |
rebonatto | 0:c64e1194230b | 14 | LPC_SC->PCONP |= 1<<29; //Power GPDMA module |
rebonatto | 0:c64e1194230b | 15 | |
rebonatto | 0:c64e1194230b | 16 | LPC_GPDMA->DMACConfig = 1; //Enable GPDMA |
rebonatto | 0:c64e1194230b | 17 | |
rebonatto | 0:c64e1194230b | 18 | //Clear any previous interrupts |
rebonatto | 0:c64e1194230b | 19 | LPC_GPDMA->DMACIntTCClear = 0xFF; |
rebonatto | 0:c64e1194230b | 20 | LPC_GPDMA->DMACIntErrClr = 0xFF; |
rebonatto | 0:c64e1194230b | 21 | |
rebonatto | 0:c64e1194230b | 22 | NVIC_SetPriority(DMA_IRQn,(1<<__NVIC_PRIO_BITS) - 1); |
rebonatto | 0:c64e1194230b | 23 | NVIC_EnableIRQ(DMA_IRQn); |
rebonatto | 0:c64e1194230b | 24 | } |
rebonatto | 0:c64e1194230b | 25 | |
rebonatto | 0:c64e1194230b | 26 | void setup_channel(dmaLinkedListNode* pList,int ch,int src,int dst) |
rebonatto | 0:c64e1194230b | 27 | { |
rebonatto | 0:c64e1194230b | 28 | //Initialize the channel with previously configured LL; |
rebonatto | 0:c64e1194230b | 29 | LPC_GPDMACH0->DMACCSrcAddr = pList->sourceAddr; |
rebonatto | 0:c64e1194230b | 30 | LPC_GPDMACH0->DMACCDestAddr = pList->destAddr; |
rebonatto | 0:c64e1194230b | 31 | LPC_GPDMACH0->DMACCControl = pList->dmaControl; |
rebonatto | 0:c64e1194230b | 32 | LPC_GPDMACH0->DMACCLLI = (unsigned long int) pList & 0xFFFFFFFC; //Lower bits must be 0 |
rebonatto | 0:c64e1194230b | 33 | |
rebonatto | 0:c64e1194230b | 34 | int transfer_type; |
rebonatto | 0:c64e1194230b | 35 | if(src == DMA_MEMORY && dst != DMA_MEMORY) |
rebonatto | 0:c64e1194230b | 36 | { |
rebonatto | 0:c64e1194230b | 37 | transfer_type = DMA_MEMORY_TO_PERIPHERAL; |
rebonatto | 0:c64e1194230b | 38 | src = 0; |
rebonatto | 0:c64e1194230b | 39 | } |
rebonatto | 0:c64e1194230b | 40 | else if(src != DMA_MEMORY && dst == DMA_MEMORY) |
rebonatto | 0:c64e1194230b | 41 | { |
rebonatto | 0:c64e1194230b | 42 | transfer_type = DMA_PERIPHERAL_TO_MEMORY; |
rebonatto | 0:c64e1194230b | 43 | dst = 0; |
rebonatto | 0:c64e1194230b | 44 | } |
rebonatto | 0:c64e1194230b | 45 | else if(src == DMA_MEMORY && dst == DMA_MEMORY) |
rebonatto | 0:c64e1194230b | 46 | { |
rebonatto | 0:c64e1194230b | 47 | transfer_type = DMA_MEMORY_TO_MEMORY; |
rebonatto | 0:c64e1194230b | 48 | src=dst = 0; |
rebonatto | 0:c64e1194230b | 49 | } |
rebonatto | 0:c64e1194230b | 50 | else if(src != DMA_MEMORY && dst != DMA_MEMORY) |
rebonatto | 0:c64e1194230b | 51 | transfer_type = DMA_PERIPHERAL_TO_PERIPHERAL; |
rebonatto | 0:c64e1194230b | 52 | |
rebonatto | 0:c64e1194230b | 53 | //Set up all relevant bits |
rebonatto | 0:c64e1194230b | 54 | LPC_GPDMACH0->DMACCConfig = (src<<1) | (dst<<5) | (transfer_type<<11) | (1<<15); |
rebonatto | 0:c64e1194230b | 55 | |
rebonatto | 0:c64e1194230b | 56 | //Finally, enable the channel - |
rebonatto | 0:c64e1194230b | 57 | LPC_GPDMACH0->DMACCConfig |= 1<<0; |
rebonatto | 0:c64e1194230b | 58 | } |
rebonatto | 0:c64e1194230b | 59 | |
rebonatto | 0:c64e1194230b | 60 | void stop_channel() |
rebonatto | 0:c64e1194230b | 61 | { |
rebonatto | 0:c64e1194230b | 62 | LPC_GPDMACH0->DMACCConfig &= ~(1<<0); |
rebonatto | 0:c64e1194230b | 63 | } |