示例#1
0
int main (int argc, char *argv[])
{
        int ret = 0;
        int fd;

        parse_opts (argc, argv);

        fd = open (device, O_RDWR);
        if (fd < 0)
                pabort ("can't open device");

        /*
         * spi mode
         */
        ret = ioctl (fd, SPI_IOC_WR_MODE, &mode);
        if (ret == -1)
                pabort ("can't set spi mode");

        ret = ioctl (fd, SPI_IOC_RD_MODE, &mode);
        if (ret == -1)
                pabort ("can't get spi mode");

        /*
         * bits per word
         */
        ret = ioctl (fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
        if (ret == -1)
                pabort ("can't set bits per word");

        ret = ioctl (fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
        if (ret == -1)
                pabort ("can't get bits per word");

        /*
         * max speed hz
         */
        ret = ioctl (fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
        if (ret == -1)
                pabort ("can't set max speed hz");

        ret = ioctl (fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
        if (ret == -1)
                pabort ("can't get max speed hz");

        printf ("spi mode: %d\n", mode);
        printf ("bits per word: %d\n", bits);
        printf ("max speed: %d Hz (%d KHz)\n", speed, speed / 1000);

        transfer2 (fd);

        close (fd);

        return ret;
}
示例#2
0
int main(int argv,char **argc){
	int d,y;
	char months[10];
	int t =0;
	scanf("%d",&t);
	printf("%d\n",t);
	while(t-->0){
		scanf("%d. %s %d",&d,months,&y);
		int date = transfer1(d,months,y);
		transfer2(date);
//		printf("%d %s %d\n",d,months,y);
	}
	return 0;
}