📄 main.c
字号:
/************************************************* by zou jian guo<zounix@126.com> * 2004.9.27 14:30 * * the driver is s3c2410_da_max504.c in drivers/char*************************************************/#include <stdio.h>#include <fcntl.h>#include <string.h>#include <sys/ioctl.h>#define Max504_FULL 4.096fstatic int da_fd = -1;void Delay(int t){ int i; for(;t>0;t--) for(i=0;i<400;i++);}/****************************************************************/int main(int argc, char **argv){ float v; unsigned int value; char *DA_DEV="/dev/da/0"; if(argc < 2){ printf("Error parameter\n"); return 1; } sscanf(argv[1], "%f",&v); if(v<0 || v>Max504_FULL){ printf("DA out must between: 0 to %f\n", Max504_FULL); return 1; } if(argc==3)DA_DEV="/dev/da/1"; if((da_fd=open(DA_DEV, O_WRONLY))<0){ printf("Error opening %s spi device\n", DA_DEV); return 1; } value=(unsigned int)((v*1024.0f)/Max504_FULL); write(da_fd,&value,4); close(da_fd); printf("Current Voltage is %f V\n", v); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -