?? adctest.c
字號:
#define IN_TGPIO
#include "config.h"
int main()
{
int fd;
volatile uint16 ad_data;
uint32 volt;
uint32 fadc = 4500000;
fd = open("/dev/ADC0.0", O_RDONLY);
if(fd == -1)
{
printf("\nCan't open ADC0.0!\n");
exit(-1);
}
ioctl(fd, ADC_SET_CLKDIV, (Fpclk + fadc - 1) / fadc - 1);
ioctl(fd, ADC_SET_BITS, 10);
while(1)
{
ad_data = 0;
read(fd, &ad_data, sizeof(ad_data));
volt = (3300*(ad_data>>6));
volt = volt/1024;
printf("VIN1's voltage is: %d mV\n", volt);
sleep(1);
}
return 0;
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -