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
Headers/Capture.h@0:c64e1194230b, 2014-07-09 (annotated)
- Committer:
- rebonatto
- Date:
- Wed Jul 09 21:16:23 2014 +0000
- Revision:
- 0:c64e1194230b
- Child:
- 1:917ca6b5d9d9
Vers?o do Protegemed com calculo de tempo de fuga, overflow, underflow e novo valor m?dio (manual).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rebonatto | 0:c64e1194230b | 1 | /* |
rebonatto | 0:c64e1194230b | 2 | * capture.h |
rebonatto | 0:c64e1194230b | 3 | * |
rebonatto | 0:c64e1194230b | 4 | * Created on: |
rebonatto | 0:c64e1194230b | 5 | * Author: |
rebonatto | 0:c64e1194230b | 6 | */ |
rebonatto | 0:c64e1194230b | 7 | |
rebonatto | 0:c64e1194230b | 8 | #ifndef CAPTURE_H |
rebonatto | 0:c64e1194230b | 9 | #define CAPTURE_H |
rebonatto | 0:c64e1194230b | 10 | |
rebonatto | 0:c64e1194230b | 11 | #include <stdio.h> |
rebonatto | 0:c64e1194230b | 12 | #include <string.h> |
rebonatto | 0:c64e1194230b | 13 | #include <math.h> |
rebonatto | 0:c64e1194230b | 14 | |
rebonatto | 0:c64e1194230b | 15 | #include "mbed.h" |
rebonatto | 0:c64e1194230b | 16 | #include "rtos.h" |
rebonatto | 0:c64e1194230b | 17 | #include "dma.h" |
rebonatto | 0:c64e1194230b | 18 | #include "adc.h" |
rebonatto | 0:c64e1194230b | 19 | |
rebonatto | 0:c64e1194230b | 20 | #include "Settings.h" |
rebonatto | 0:c64e1194230b | 21 | |
rebonatto | 0:c64e1194230b | 22 | // MTR: Estes defines nao deveriam estar no arquivo de configuraçeos? |
rebonatto | 0:c64e1194230b | 23 | //#define SAMPLE_RATE 256U |
rebonatto | 0:c64e1194230b | 24 | |
rebonatto | 0:c64e1194230b | 25 | class Capture |
rebonatto | 0:c64e1194230b | 26 | { |
rebonatto | 0:c64e1194230b | 27 | protected: |
rebonatto | 0:c64e1194230b | 28 | |
rebonatto | 0:c64e1194230b | 29 | static Semaphore m_CaptureSemaphore; //used to alert the capture thread about a ready capture |
rebonatto | 0:c64e1194230b | 30 | static int m_BufferIndex; |
rebonatto | 0:c64e1194230b | 31 | |
rebonatto | 0:c64e1194230b | 32 | static dmaLinkedListNode m_Nodes[2]; //this list holds the buffer configuration for the DMA peripheral |
rebonatto | 0:c64e1194230b | 33 | public: |
rebonatto | 0:c64e1194230b | 34 | static unsigned short int m_AdcBuffers[2][NUMBER_OF_SAMPLES][NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 35 | |
rebonatto | 0:c64e1194230b | 36 | public: |
rebonatto | 0:c64e1194230b | 37 | |
rebonatto | 0:c64e1194230b | 38 | static unsigned short int GetValue(int nsamples, int nchannel); |
rebonatto | 0:c64e1194230b | 39 | static void CopyBuffer(int channel, unsigned short int *dest); |
rebonatto | 0:c64e1194230b | 40 | |
rebonatto | 0:c64e1194230b | 41 | static void ISRHandler(); |
rebonatto | 0:c64e1194230b | 42 | |
rebonatto | 0:c64e1194230b | 43 | static void Initialize(); |
rebonatto | 0:c64e1194230b | 44 | static void Start(); |
rebonatto | 0:c64e1194230b | 45 | static void Stop(); |
rebonatto | 0:c64e1194230b | 46 | static void Wait(); |
rebonatto | 0:c64e1194230b | 47 | |
rebonatto | 0:c64e1194230b | 48 | }; |
rebonatto | 0:c64e1194230b | 49 | |
rebonatto | 0:c64e1194230b | 50 | #endif |