123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- // /* include path: ..../A2F/root/usr/include */
- // #include <stdio.h>
- // #include <fcntl.h>
- // #include <linux/types.h>
- // //#include <linux/jiffies.h>
- // #include <unistd.h>
- // typedef unsigned char uint8_t;
- // typedef unsigned long uint32_t;
- // typedef struct {
- // uint32_t address;
- // uint8_t data;
- // } cpld_t;
- // typedef struct {
- // uint32_t clockspeed;
- // uint32_t ownAddr;
- // uint8_t DevAddr;
- // uint8_t buf[100];
- // uint8_t Size;
- // } i2c_arg_t;
- // #define GENERATE_CMD(__MAGIC__, __MAJOR__, __CMD__) \
- // ((0x3<<30) | (__MAJOR__<<16) | (__MAGIC__<<8) | __CMD__)
- // #define SET_ADDR GENERATE_CMD('x', 101, 2)
- // #define TRANSFER GENERATE_CMD('x', 101, 4)
- // #define MASTER_RCV GENERATE_CMD('x', 101, 5)
- // #define SLAVE_RCV GENERATE_CMD('x', 101, 6)
- // int main()
- // {
- // /* //FMC test app
- // cpld_t cpld_arg;
- // printf("This is test app!\n");
- // int fd;
- // fd = open("/dev/fmc_cpld", O_RDWR);
- // if(fd == NULL)
- // printf("Open failed\n");
- // cpld_arg.address = 0x64000000;
- // cpld_arg.data = 0x55;
- // ioctl(fd, 0, &cpld_arg);
- // cpld_arg.data = 0;
- // ioctl(fd, 1, &cpld_arg);
- // printf("Read from cpld: %#x\n", cpld_arg.data);
- // close(fd);
- // */
-
- // /* //gpio interrup test app
- // int fd;
- // uint8_t buf;
- // int ret = 0;
- // fd = open("/dev/test_module", O_RDWR);
- // if(fd == NULL)
- // printf("open failed\n");
- // while(1)
- // {
- // ret = read(fd, &buf, 1);
- // printf("test app read %#x\n", buf);
- // }
- // close(fd);*/
- // int fd;
- // int i;
- // i2c_arg_t i2c_arg;
- // fd = open("/dev/i2c1", O_RDWR);
- // if(fd == NULL)
- // printf("open failed\n");
- // i2c_arg.ownAddr = 0;
- // i2c_arg.DevAddr = 0x92;
- // i2c_arg.buf[0] = 1;
- // i2c_arg.buf[1] = 2;
- // i2c_arg.buf[2] = 3;
- // i2c_arg.Size = 0;
- // while(1)
- // {
- // // ioctl(fd, 1, &i2c_arg); //get speed
- // // printf("speed: %d\n", i2c_arg.clockspeed);
- // // sleep(1);
- // //
- // // i2c_arg.clockspeed = 400000;
- // // ioctl(fd, 0, &i2c_arg); //set speed
- // // sleep(1);
- // //
- // // ioctl(fd, 3, &i2c_arg); //get addr
- // // printf("addr: %#x\n", i2c_arg.ownAddr);
- // // sleep(1);
-
- // // i2c_arg.ownAddr = 0x42;
- // // ioctl(fd, SET_ADDR, &i2c_arg); //set addr
- // // sleep(1);
- // // ioctl(fd, MASTER_RCV, &i2c_arg);
- // // printf("Read: %#x, %#x\n", i2c_arg.buf[0], i2c_arg.buf[1]);
- // // sleep(1);
-
- // ioctl(fd, SLAVE_RCV, &i2c_arg);
- // printf("\ni2c1 rec: ");
- // for(i=0;i<i2c_arg.Size;i++)
- // printf("%#x ", i2c_arg.buf[i]);
- // printf("\n");
- // }
-
- // close(fd);
-
-
-
- // return 0;
- // }
|