?? rw_addr.c
字號:
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#define DEVICE "/dev/phyaddrtest"
int main()
{
int fd,ret;
unsigned short val[4]={0x0028,0x0029,0x002A,0x002B};
unsigned short read_val=0;
if((fd=open(DEVICE,O_RDWR | O_NONBLOCK))<0)
{
printf("open device: %s\n",DEVICE);
perror("can not open device");
exit(1);
}
ret=write(fd,&val[0],2);
read(fd,&read_val,2);
printf("read1=0x%02x\n",(unsigned char)(read_val&0xff));
ret=write(fd,&val[1],2);
read(fd,&read_val,2);
printf("read2=0x%02x\n",(unsigned char)(read_val&0xff));
ret=write(fd,&val[2],2);
read(fd,&read_val,2);
printf("read2=0x%02x\n",(unsigned char)(read_val&0xff));
ret=write(fd,&val[3],2);
read(fd,&read_val,2);
printf("read3=0x%02x\n",(unsigned char)(read_val&0xff));
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -