嵌入式系统设计AD转换器 - 图文

发布时间 : 星期四 文章嵌入式系统设计AD转换器 - 图文更新完毕开始阅读

#define I_PMST REGL(0x200014) #define I_CSLV

REGL(0x200018) #define I_CMST REGL(0x20001c) #define I_ISPR REGL(0x200020) #define I_ISPC REGL(0x200024) #define F_ISPR REGL(0x200038) #define F_ISPC

REGL(0x20003c)

/********************************/ /* LCD Controller Registers */ /********************************/ #define LCDCON1 REGL(0x300000) #define LCDCON2

REGL(0x300004)

#define LCDSADDR1 REGL(0x300008) #define LCDSADDR2 REGL(0x30000c) #define LCDSADDR3 REGL(0x300010) #define REDLUT REGL(0x300014) #define GREENLUT REGL(0x300018) #define BLUELUT REGL(0x30001c) #define DP1_2 REGL(0x300020) #define DP4_7 REGL(0x300024) #define DP3_5 REGL(0x300028) #define DP2_3 REGL(0x30002c) #define DP5_7 REGL(0x300030) #define DP3_4 REGL(0x300034) #define DP4_5 REGL(0x300038) #define DP6_7

REGL(0x30003c) #define LCDCON3 REGL(0x300040) #define DITHMODE

REGL(0x300044)

/*********************/ /* DMA Registers */

20

/*********************/ #define ZDCON0 #define ZDISRC0 #define ZDIDES0 #define ZDICNT0 #define ZDCSRC0 #define ZDCDES0 #define ZDCCNT0 #define ZDCON1 #define ZDISRC1 #define ZDIDES1 #define ZDICNT1 #define ZDCSRC1 #define ZDCDES1 #define ZDCCNT1 #define BDCON0 #define BDISRC0 #define BDIDES0 #define BDICNT0 #define BDCSRC0 #define BDCDES0 #define BDCCNT0 #define BDCON1 #define BDISRC1 #define BDIDES1 #define BDICNT1 #define BDCSRC1 #define BDCDES1 #define BDCCNT1

REGL(0x280000) REGL(0x280004) REGL(0x280008) REGL(0x28000c) REGL(0x280010) REGL(0x280014) REGL(0x280018) REGL(0x280020) REGL(0x280024) REGL(0x280028) REGL(0x28002c) REGL(0x280030) REGL(0x280034) REGL(0x280038) REGL(0x380000) REGL(0x380004) REGL(0x380008) REGL(0x38000c) REGL(0x380010) REGL(0x380014) REGL(0x380018) REGL(0x380020) REGL(0x380024) REGL(0x380028) REGL(0x38002c) REGL(0x380030) REGL(0x380034) REGL(0x380038)

#define CLEAR_PEND_INT(n) I_ISPC = (1<<(n))

21

#define INT_ENABLE(n) INTMSK &= ~(1<<(n)) INTMSK |= (1<<(n))

#define INT_DISABLE(n) #define HARD_RESET_NOW()

#endif /* __ASM_ARCH_HARDWARE_H */

Main.c

#include #include #include #include #include #include #include #include \#define ADC_DEV static int adc_fd = -1; static int init_ADdevice(void) { }

static int GetADresult(int channel) {

int PRESCALE=0XFF;

int data=ADC_WRITE(channel, PRESCALE); write(adc_fd, &data, sizeof(data)); read(adc_fd, &data, sizeof(data)); return data;

if((adc_fd=open(ADC_DEV, O_RDWR))<0){ }

printf(\return -1;

\

22

}

static int stop=0;

static void* comMonitor(void* data) { }

int main(void) {

int i; float d;

pthread_t th_com; void * retval;

//set s3c44b0 AD register and start AD if(init_ADdevice()<0)

return -1; getchar(); stop=1; return NULL;

/* Create the threads */

pthread_create(&th_com, NULL, comMonitor, 0); printf(\while( stop==0 ){ }

/* Wait until producer and consumer finish. */ pthread_join(th_com, &retval);

for(i=0; i<=2; i++){//采样0~2路A/D值 } usleep(1); printf(\

d=((float)GetADresult(i)*3.3)/1024.0; printf(\

23

联系合同范文客服:xxxxx#qq.com(#替换为@)