mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 01:00:02 +02:00
changed fifo_data address, made fifo related stuff volatile, changed makefile to incorporate compiling image and program simultaneously
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@138 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
7c07ae5a5a
commit
c2846e72e7
@ -5,16 +5,10 @@
|
||||
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
|
||||
CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE -DVERYVERBOSE #-DVIRTUAL
|
||||
|
||||
#INCLUDES= /usr/src/kernels/2.6.18-238.12.1.el5-i686/include
|
||||
#/home/l_maliakal_d/bfin/blackfin-linux-dist/linux-2.6.x/include
|
||||
#/usr/include/asm/page.h
|
||||
|
||||
|
||||
PROGS= gotthardDetectorServer
|
||||
|
||||
INSTDIR= /tftpboot
|
||||
INSTMODE= 0777
|
||||
|
||||
@ -25,9 +19,6 @@ SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.
|
||||
OBJS = $(SRCS:%.c=%.o)
|
||||
|
||||
|
||||
#LDLIBS+= -lm
|
||||
|
||||
|
||||
|
||||
all: clean $(PROGS)
|
||||
|
||||
@ -35,7 +26,7 @@ boot: $(OBJS)
|
||||
|
||||
$(PROGS): $(OBJS)
|
||||
echo $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
||||
|
||||
|
||||
install: $(PROGS)
|
||||
@ -43,14 +34,11 @@ install: $(PROGS)
|
||||
$(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
|
||||
|
||||
|
||||
#CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS
|
||||
#-DVERBOSE
|
||||
#-DVERYVERBOSE
|
||||
#-Werror
|
||||
|
||||
romfs:
|
||||
$(ROMFSINST) /bin/$(PROGS)
|
||||
|
||||
clean:
|
||||
rm -rf $(PROGS) *.o
|
||||
rm -rf $(PROGS) *.o *.gdb
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
#include "communication_funcs.h"
|
||||
//#include <sys/socket.h>
|
||||
//#include <sys/socket.h>
|
||||
#include <netinet/tcp.h> /* for TCP_NODELAY */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -209,7 +209,7 @@ void exitServer(int socketDescriptor) {
|
||||
int sendDataOnly(int file_des, void* buf,int length) {
|
||||
|
||||
|
||||
return write(file_des, buf, length);
|
||||
return write(file_des, buf, length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
#include </opt/uClinux/bfin-linux-uclibc/bfin-linux-uclibc/runtime/usr/include/bfin_sram.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
|
||||
|
||||
|
||||
@ -28,7 +29,7 @@ FILE *debugfp, *datafp;
|
||||
int fr;
|
||||
int wait_time;
|
||||
int *fifocntrl;
|
||||
int *values;
|
||||
volatile const u_int16_t *values;
|
||||
//int *statusreg; commented out by dhanya
|
||||
const int nModY=1;
|
||||
int nModBoard;
|
||||
@ -36,8 +37,8 @@ int nModX=NMAXMOD;
|
||||
int dynamicRange=16;//32;
|
||||
int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
||||
int storeInRAM=0;
|
||||
int *ram_values=NULL;
|
||||
char *now_ptr=NULL;
|
||||
volatile u_int32_t *ram_values=NULL;
|
||||
volatile char *now_ptr=NULL;
|
||||
int ram_size=0;
|
||||
|
||||
int64_t totalTime=1;
|
||||
@ -190,13 +191,13 @@ int mapCSP0(void) {
|
||||
}
|
||||
|
||||
u_int16_t bus_r16(u_int32_t offset){
|
||||
u_int16_t *ptr1;
|
||||
volatile u_int16_t *ptr1;
|
||||
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
||||
return *ptr1;
|
||||
}
|
||||
//aldos function volatile (not needed)
|
||||
u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
|
||||
u_int16_t *ptr1;
|
||||
volatile u_int16_t *ptr1;
|
||||
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
||||
// printf("writing at 0x%x data 0x%x %d%d%d\n",CSP0BASE+offset*2,data, (data>>2)&0x1,(data>>1)&0x1 ,(data>>0)&0x1);
|
||||
|
||||
@ -206,7 +207,7 @@ u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
|
||||
|
||||
|
||||
u_int32_t bus_w(u_int32_t offset, u_int32_t data) {
|
||||
u_int32_t *ptr1;
|
||||
volatile u_int32_t *ptr1;
|
||||
|
||||
ptr1=(u_int32_t*)(CSP0BASE+offset*2);
|
||||
*ptr1=data;
|
||||
@ -216,7 +217,7 @@ u_int32_t bus_w(u_int32_t offset, u_int32_t data) {
|
||||
|
||||
|
||||
u_int32_t bus_r(u_int32_t offset) {
|
||||
u_int32_t *ptr1;
|
||||
volatile u_int32_t *ptr1;
|
||||
|
||||
ptr1=(u_int32_t*)(CSP0BASE+offset*2);
|
||||
return *ptr1;
|
||||
@ -525,7 +526,7 @@ u_int32_t getMcsVersion() {
|
||||
// for fpga test
|
||||
u_int32_t testFpga(void) {
|
||||
printf("Test FPGA:\n");
|
||||
u_int32_t val,addr;
|
||||
volatile u_int32_t val,addr,val2;
|
||||
int result=OK,i;
|
||||
//fixed pattern
|
||||
val=bus_r(FIX_PATT_REG);
|
||||
@ -543,9 +544,12 @@ u_int32_t testFpga(void) {
|
||||
printf("FPGA version too old! %06x\n",val);
|
||||
result= FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//dummy register
|
||||
addr = DUMMY_REG;
|
||||
for(i=0;i<100;i++)
|
||||
for(i=0;i<1000000;i++)
|
||||
{
|
||||
val=0x5A5A5A5A-i;
|
||||
bus_w(addr, val);
|
||||
@ -554,6 +558,13 @@ u_int32_t testFpga(void) {
|
||||
printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of %x \n",i,val,0x5A5A5A5A-i);
|
||||
result=FAIL;
|
||||
}
|
||||
val=(i+(i<<10)+(i<<20));
|
||||
bus_w(addr, val);
|
||||
val2=bus_r(addr);
|
||||
if (val2!=val) {
|
||||
printf("ATTEMPT:%d:\tFPGA dummy register wrong!! read %x instead of %x.\n",i,val2,val);
|
||||
result=FAIL;
|
||||
}
|
||||
val=0x0F0F0F0F;
|
||||
bus_w(addr, val);
|
||||
val=bus_r(addr);
|
||||
@ -562,8 +573,8 @@ u_int32_t testFpga(void) {
|
||||
result=FAIL;
|
||||
}
|
||||
val=0xF0F0F0F0;
|
||||
bus_w(DUMMY_REG, val);
|
||||
val=bus_r(DUMMY_REG);
|
||||
bus_w(addr, val);
|
||||
val=bus_r(addr);
|
||||
if (val!=0xF0F0F0F0) {
|
||||
printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of 0xF0F0F0F0 \n\n",i,val);
|
||||
result=FAIL;
|
||||
@ -572,7 +583,7 @@ u_int32_t testFpga(void) {
|
||||
if(result==OK)
|
||||
{
|
||||
printf("----------------------------------------------------------------------------------------------");
|
||||
printf("\nATTEMPT 100: FPGA DUMMY REGISTER OK!!\n");
|
||||
printf("\nATTEMPT 1000000: FPGA DUMMY REGISTER OK!!!\n");
|
||||
printf("----------------------------------------------------------------------------------------------\n");
|
||||
}
|
||||
return result;
|
||||
@ -1451,12 +1462,31 @@ u_int32_t* fifo_read_event()
|
||||
#endif
|
||||
dma_memcpy(now_ptr,values ,dataBytes);
|
||||
|
||||
//memcpy(now_ptr,values ,dataBytes);
|
||||
/* struct timeval t1,t2;
|
||||
long long t;
|
||||
gettimeofday(&t1,NULL);
|
||||
if(geteuid()==0){
|
||||
struct sched_param sp;
|
||||
memset(&sp,0,sizeof(sp));
|
||||
sp.sched_priority= sched_get_priority_max(SCHED_FIFO);
|
||||
sched_setscheduler(0,SCHED_FIFO,&sp);
|
||||
mlockall(MCL_CURRENT | MCL_FUTURE);
|
||||
}
|
||||
gettimeofday(&t2,NULL);
|
||||
memmove(now_ptr,values ,dataBytes);
|
||||
t = ((t2.tv_sec * 1000000) + t2.tv_usec) - ((t1.tv_sec * 1000000) + t1.tv_usec);
|
||||
printf("\n*********Call took %lld us*******\n", t);
|
||||
*/
|
||||
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
printf("\n x%08x\n",now_ptr);
|
||||
int a;
|
||||
for (a=0;a<10; a=a+2)
|
||||
printf("\n%d: x%04x",a,now_ptr[a]);
|
||||
printf("\n");
|
||||
for (a=0;a<8; a=a+2)
|
||||
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
|
||||
for (a=2554;a<2560; a=a+2)
|
||||
printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
|
||||
printf("********\n");
|
||||
//memcpy(now_ptr, values, dataBytes);
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
|
@ -53,7 +53,7 @@
|
||||
//FIFO
|
||||
#define LOOK_AT_ME_REG 0x28<<11
|
||||
|
||||
#define FIFO_DATA_REG_OFF 0x80<<11 ///////
|
||||
#define FIFO_DATA_REG_OFF 0x50<<11 ///////
|
||||
|
||||
|
||||
//to read back dac registers
|
||||
|
@ -10,12 +10,13 @@
|
||||
#include "trimming_funcs.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Global variables
|
||||
|
||||
int (*flist[256])(int);
|
||||
|
||||
|
||||
|
||||
#ifdef MCB_FUNCS
|
||||
extern const enum detectorType myDetectorType;
|
||||
#endif
|
||||
@ -34,7 +35,7 @@ extern char thisClientIP[INET_ADDRSTRLEN];
|
||||
extern int differentClients;
|
||||
|
||||
/* global variables for optimized readout */
|
||||
extern int *ram_values;
|
||||
extern unsigned int *ram_values;
|
||||
char *dataretval=NULL;
|
||||
int nframes, iframes, dataret;
|
||||
char mess[1000];
|
||||
@ -68,7 +69,7 @@ int init_detector( int b) {
|
||||
#ifdef MCB_FUNCS
|
||||
if (b) {
|
||||
initDetector();
|
||||
printf("\ninitdetector done! \n");
|
||||
printf("\n----initdetector done! new serverRdRR\n\n");
|
||||
testFpga();
|
||||
testRAM();
|
||||
|
||||
@ -846,7 +847,7 @@ int read_register(int file_des) {
|
||||
|
||||
if(ret!=FAIL){
|
||||
address=(addr<<11);
|
||||
if(addr==0x80)
|
||||
if(addr==0x50)
|
||||
retval=bus_r16(address);
|
||||
else
|
||||
retval=bus_r(address);
|
||||
@ -1931,7 +1932,7 @@ int read_frame(int file_des) {
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,dataretval,dataBytes);
|
||||
#ifdef VERBOSE
|
||||
printf("sent %d bytes\n",dataBytes);
|
||||
printf("sent %d bytes \n",dataBytes);
|
||||
#endif
|
||||
printf("dataret OK\n");
|
||||
return OK;
|
||||
@ -2007,15 +2008,13 @@ int read_frame(int file_des) {
|
||||
|
||||
int read_all(int file_des) {
|
||||
|
||||
|
||||
while(read_frame(file_des)==OK) {
|
||||
//usleep(0);
|
||||
while(read_frame(file_des)==OK) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("frame read\n");
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Frames finished\n");
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user