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

Committer:
rebonatto
Date:
Wed Jul 09 21:16:23 2014 +0000
Revision:
0:c64e1194230b
Vers?o do Protegemed com calculo de tempo de fuga, overflow, underflow e novo valor m?dio (manual).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rebonatto 0:c64e1194230b 1 /*
rebonatto 0:c64e1194230b 2 * adc.h
rebonatto 0:c64e1194230b 3 *
rebonatto 0:c64e1194230b 4 * Created on: 02/07/2011
rebonatto 0:c64e1194230b 5 * Author: francisco
rebonatto 0:c64e1194230b 6 */
rebonatto 0:c64e1194230b 7
rebonatto 0:c64e1194230b 8 #ifndef ADC_H_
rebonatto 0:c64e1194230b 9 #define ADC_H_
rebonatto 0:c64e1194230b 10
rebonatto 0:c64e1194230b 11
rebonatto 0:c64e1194230b 12 #define PCADC (1U<<12)
rebonatto 0:c64e1194230b 13
rebonatto 0:c64e1194230b 14 #define ADC_CCLK_4 0U
rebonatto 0:c64e1194230b 15 #define ADC_CCLK 1U
rebonatto 0:c64e1194230b 16 #define ADC_CCLK_2 2U
rebonatto 0:c64e1194230b 17 #define ADC_CCLK_8 3U
rebonatto 0:c64e1194230b 18
rebonatto 0:c64e1194230b 19 #define PCLK_ADC 24U
rebonatto 0:c64e1194230b 20
rebonatto 0:c64e1194230b 21 #define ADC_CH_0 (1U<<0)
rebonatto 0:c64e1194230b 22 #define ADC_CH_1 (1U<<1)
rebonatto 0:c64e1194230b 23 #define ADC_CH_2 (1U<<2)
rebonatto 0:c64e1194230b 24 #define ADC_CH_3 (1U<<3)
rebonatto 0:c64e1194230b 25 #define ADC_CH_4 (1U<<4)
rebonatto 0:c64e1194230b 26 #define ADC_CH_5 (1U<<5)
rebonatto 0:c64e1194230b 27 #define ADC_CH_6 (1U<<6)
rebonatto 0:c64e1194230b 28 #define ADC_CH_7 (1U<<7)
rebonatto 0:c64e1194230b 29 #define ADC_CLKDIV(val) ((val)<<8)
rebonatto 0:c64e1194230b 30 #define ADC_MODE_BURST (1U<<16)
rebonatto 0:c64e1194230b 31 #define ADC_OPERATIONAL (1U<< 21)
rebonatto 0:c64e1194230b 32 #define ADC_NO_START ~(7U<<24)
rebonatto 0:c64e1194230b 33 #define ADC_START_NOW (1U<<24)
rebonatto 0:c64e1194230b 34 #define ADC_START_ON_PIO2_10 (2U<<24)
rebonatto 0:c64e1194230b 35 #define ADC_START_ON_PIO1_27 (3U<<24)
rebonatto 0:c64e1194230b 36 #define ADC_START_ON_MAT0_1 (4U<<24)
rebonatto 0:c64e1194230b 37 #define ADC_START_ON_MAT0_3 (5U<<24)
rebonatto 0:c64e1194230b 38 #define ADC_START_ON_MAT1_0 (6U<<24)
rebonatto 0:c64e1194230b 39 #define ADC_START_ON_MAT1_1 (7U<<24)
rebonatto 0:c64e1194230b 40 #define ADC_EDGE_FALLING (1U<<27)
rebonatto 0:c64e1194230b 41 #define ADC_EDGE_RAISING ~(1U<<27)
rebonatto 0:c64e1194230b 42
rebonatto 0:c64e1194230b 43 #define ADC_GLOBAL_INT (1U<<8)
rebonatto 0:c64e1194230b 44 #define ADC_INT_CH_0 (1U<<0)
rebonatto 0:c64e1194230b 45 #define ADC_INT_CH_1 (1U<<1)
rebonatto 0:c64e1194230b 46 #define ADC_INT_CH_2 (1U<<2)
rebonatto 0:c64e1194230b 47 #define ADC_INT_CH_3 (1U<<3)
rebonatto 0:c64e1194230b 48 #define ADC_INT_CH_4 (1U<<4)
rebonatto 0:c64e1194230b 49 #define ADC_INT_CH_5 (1U<<5)
rebonatto 0:c64e1194230b 50 #define ADC_INT_CH_6 (1U<<6)
rebonatto 0:c64e1194230b 51 #define ADC_INT_CH_7 (1U<<7)
rebonatto 0:c64e1194230b 52
rebonatto 0:c64e1194230b 53 #define ADC_LAST_CONVERSION() ((LPC_ADC->ADGDR&(0xFFFU<<4))>>4)
rebonatto 0:c64e1194230b 54 #define ADC_LAST_CONVERSION_CHANNEL() ((LPC_ADC->ADGDR&(7U<<24))>>24)
rebonatto 0:c64e1194230b 55 #define ADC_LAST_CONVERSION_DONE() (LPC_ADC->ADGDR&(1U<<31))
rebonatto 0:c64e1194230b 56 #define ADC_LAST_CONVERSION_OVERUN() (LPC_ADC->ADGDR&(1U<<30))
rebonatto 0:c64e1194230b 57 #define ADC_CONVERSION_CH(ch) ((LPC_ADC->ADDR[ch]&(0xFFFU<<4))>>4)
rebonatto 0:c64e1194230b 58 #define ADC_CONVERSION_DONE_CH(ch) (LPC_ADC->ADDR[ch]&(1U<<31))
rebonatto 0:c64e1194230b 59 #define ADC_CONVERSION_OVERUN_CH(ch) (LPC_ADC->ADDR[ch]&(1U<<30))
rebonatto 0:c64e1194230b 60
rebonatto 0:c64e1194230b 61 #define ADC_CONVERT(val) ((val&(0xFFFU<<4))>>4)
rebonatto 0:c64e1194230b 62 #define ADC_CHANNEL(val) ((val&(7U<<24))>>24)
rebonatto 0:c64e1194230b 63
rebonatto 0:c64e1194230b 64 #ifdef __cplusplus
rebonatto 0:c64e1194230b 65 extern "C" {
rebonatto 0:c64e1194230b 66 #endif
rebonatto 0:c64e1194230b 67
rebonatto 0:c64e1194230b 68 extern void init_adc(int adc_clk);
rebonatto 0:c64e1194230b 69 extern void setup_start(int mode,int edge);
rebonatto 0:c64e1194230b 70 extern void select_channels(int adc_ch);
rebonatto 0:c64e1194230b 71
rebonatto 0:c64e1194230b 72 #ifdef __cplusplus
rebonatto 0:c64e1194230b 73 }
rebonatto 0:c64e1194230b 74 #endif
rebonatto 0:c64e1194230b 75
rebonatto 0:c64e1194230b 76 #endif /* ADC_H_ */