basic application
git-svn-id: svn+ssh://en.codiert.org/home/staff/ben/dev/misc.svn/projects/fpgafs@400 766a2236-cff9-0310-b0c0-a81a5f92509a
This commit is contained in:
		
							parent
							
								
									96948e503d
								
							
						
					
					
						commit
						0ae8873d37
					
				
							
								
								
									
										15
									
								
								app/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
#/*********************************************
 | 
			
		||||
# * Benjamin Krill <ben@codiert.org>
 | 
			
		||||
# *********************************************/
 | 
			
		||||
CFLAGS= -c -I../libfpga
 | 
			
		||||
 | 
			
		||||
CC = gcc
 | 
			
		||||
 | 
			
		||||
SRCS = fifo_shift.c
 | 
			
		||||
OBJS = $(SRCS:%.c=%.o)
 | 
			
		||||
 | 
			
		||||
fifo_shift: ${OBJS}
 | 
			
		||||
	${CC} $^ -o $@ -lfpga 
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	rm *.o *.so.*
 | 
			
		||||
							
								
								
									
										46
									
								
								app/fifo_shift.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								app/fifo_shift.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
			
		||||
/*********************************************
 | 
			
		||||
 * Benjamin Krill <ben@codiert.org>
 | 
			
		||||
 *********************************************/
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <libfpga.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
main(int argv, char **argc)
 | 
			
		||||
{
 | 
			
		||||
	int fd, sta, rnd, i;
 | 
			
		||||
	char *c, buf[4];
 | 
			
		||||
 | 
			
		||||
	if ((fd = open("tdat", O_RDONLY, 0)) == -1 ) {
 | 
			
		||||
		printf("ERROR-1: %s\n", strerror(errno));
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (fpgafs_create_context(fd, "dbg") == -1) {
 | 
			
		||||
		printf("ERROR-2: Cannot create fpgafs context\n");
 | 
			
		||||
		close(fd);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
//	while (fpgafs_get_stat() < 0x10) {
 | 
			
		||||
	for(i=0; i < 10; i++) {
 | 
			
		||||
		rnd = rand();
 | 
			
		||||
		c = (char *)&rnd;
 | 
			
		||||
		printf("write data: %x\n",c[0], c[1], c[2], c[3]);
 | 
			
		||||
		if ((sta=fpgafs_send_data(&c[0], 4)) != 4) {
 | 
			
		||||
			printf("ERROR-3: Cannot send specified length (%d)\n", sta);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ((sta=fpgafs_recv_data(&c[0], 4)) != 4) {
 | 
			
		||||
			printf("ERROR-3: Cannot send specified length (%d)\n", sta);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
		printf("read data: %x\n",buf[0], buf[1], buf[2], buf[3]);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@ -1,4 +1,6 @@
 | 
			
		||||
 | 
			
		||||
#/*********************************************
 | 
			
		||||
# * Benjamin Krill <ben@codiert.org>
 | 
			
		||||
# *********************************************/
 | 
			
		||||
CFLAGS=-c -fPIC
 | 
			
		||||
 | 
			
		||||
CC = gcc
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
/*********************************************
 | 
			
		||||
 * Benjamin Krill <ben@codiert.org>
 | 
			
		||||
 *********************************************/
 | 
			
		||||
int fpgafs_create_context(int fd, const char *name)
 | 
			
		||||
int fpgafs_send_data(const void *buf, size_t count);
 | 
			
		||||
int fpgafs_recv_data(void *buf, size_t count);
 | 
			
		||||
int fpgafs_create_context(int fd, const char *name);
 | 
			
		||||
int fpgafs_send_data(const void *buf, int count);
 | 
			
		||||
int fpgafs_recv_data(void *buf, int count);
 | 
			
		||||
int fpgafs_send_cmd(unsigned int cmd);
 | 
			
		||||
int fpgafs_get_stat();
 | 
			
		||||
int fpgafs_set_lldrv(const char* name);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user