📄 main.c
字号:
//#include"../ucos-ii/includes.h" /* uC/OS interface */
//#include "../ucos-ii/add/osaddition.h"
#include "../inc/drivers.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "../inc/lib.h"
//#include "../src/gui/gui.h"
#include <string.h>
#include <stdio.h>
#include "../inc/reg2410.h"
#include "../inc/serial.h"
//#include "../inc/io.h"
#include "../inc/lib.h"
#include "inc/bitfield.h"
/* Externl clock frequency used by CPU */
#define FIN 12000000
#pragma import(__use_no_semihosting_swi) // ensure no functions that use semihosting
#define ADCCON_FLAG (0x1<<15)
#define ADCCON_ENABLE_START_BYREAD (0x1<<1)
#define rADCCON (*(volatile unsigned *)0x58000000)
#define rADCCON (*(volatile unsigned *)0x58000000)
#define rADCDAT0 (*(volatile unsigned *)0x5800000C)
#define PRSCVL (49<<6)
#define ADCCON_ENABLE_START (0x1)
#define STDBM (0x0<<2)
#define PRSCEN (0x1<<14)
void ARMTargetInit();
void init_ADdevice()
{//初始化
rADCCON=(PRSCVL|ADCCON_ENABLE_START|STDBM|PRSCEN);
}
int GetADresult(int channel)
{
rADCCON=ADCCON_ENABLE_START_BYREAD|(channel<<3)|PRSCEN|PRSCVL;
hudelay(10);
while(!(rADCCON&ADCCON_FLAG));//转换结束
return (0x3ff&rADCDAT0);//返回采样值
}
int main(void)
{
int i,j=0,k=0,l=0,m=0,n=0;
int d;
int a[1023];
ARMTargetInit(); // do target (uHAL based ARM system) initialisation //
init_ADdevice();
//printf("\n");
Uart_Printf(0,"\n");
s3c2410_get_cpu_clk();
while(1)
{
for(l=6;l<=100;l++)
{
d=GetADresult(1); // 数据 采集,处理
k=a[d];
k=k+1;
a[d]=k;
Uart_Printf(0,"a%d=%d\t",0,d);
hudelay(1000);
}
a[0]=a[0]++;
for(m=0;m<=1023;m++)
{
n=a[m];
if(a[m]!=0)
{
Uart_Printf(0,"a%d=%d\t",m,n);
Uart_Printf(0,"\r");
a[m]=0;
}
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -