First Version

Dependencies:   EthernetInterface mbed-rtos mbed

Committer:
rebonatto
Date:
Mon Mar 07 19:20:49 2016 +0000
Revision:
3:94a128e0f316
Parent:
0:9df41090ba33
Vers?o est?vel com nova forma de aquisi??o de valores e limpeza de c?digo desnecess?rio.

Who changed what in which revision?

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