works but usleep required

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@115 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2012-02-14 10:39:37 +00:00
parent ba833233b9
commit 2e15e9c2db
5 changed files with 80 additions and 39 deletions

View File

@ -6,7 +6,7 @@
CROSS = bfin-uclinux- CROSS = bfin-uclinux-
CC = $(CROSS)gcc CC = $(CROSS)gcc
CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE #-DVERY_VERBOSE #-DVIRTUAL CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE #-DVERY_VERBOSE #-DVIRTUAL
#INCLUDES= /usr/src/kernels/2.6.18-238.12.1.el5-i686/include #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 #/home/l_maliakal_d/bfin/blackfin-linux-dist/linux-2.6.x/include

View File

@ -96,8 +96,7 @@ int acceptConnection(int socketDescriptor) {
// if(file_des>0) return file_des; // if(file_des>0) return file_des;
//next 3 lines commented out by dhanya //#ifndef C_ONLY
//#ifndef C_ONLY
// if(is_a_server){ //server; the server will wait for the clients connection // if(is_a_server){ //server; the server will wait for the clients connection
//#endif //#endif

View File

@ -15,6 +15,9 @@
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
#include <sys/stat.h> #include <sys/stat.h>
#include </opt/uClinux/bfin-linux-uclibc/bfin-linux-uclibc/runtime/usr/include/bfin_sram.h>
//for memory mapping //for memory mapping
@ -171,8 +174,8 @@ int mapCSP0(void) {
u_int32_t address; u_int32_t address;
address = FIFO_DATA_REG_OFF; address = FIFO_DATA_REG_OFF;
values=(u_int16_t*)(CSP0BASE+address*2); values=(u_int32_t*)(CSP0BASE+address*2);
printf("values=%04x\n",values); printf("values=%08x\n",values);
//printf("values=%08x\n",((u_int32_t*)(CSP0BASE+FIFO_DATA_REG_OFF*2))); //printf("values=%08x\n",((u_int32_t*)(CSP0BASE+FIFO_DATA_REG_OFF*2)));
/* must b uncommentedlater//////////////////////////////////////////////////////// /* must b uncommentedlater////////////////////////////////////////////////////////
@ -1263,7 +1266,7 @@ u_int32_t runState(void) {
write_status_sm("Stopped"); write_status_sm("Stopped");
#endif #endif
#ifdef VERBOSE #ifdef VERBOSE
printf("status %08x\n",s); printf("status %04x\n",s);
#endif #endif
return s; return s;
} }
@ -1272,9 +1275,9 @@ u_int32_t runState(void) {
// State Machine // State Machine
u_int32_t startStateMachine(){ u_int32_t startStateMachine(){
#ifdef VERBOSE //#ifdef VERBOSE
printf("Starting State Machine\n"); printf("Starting State Machine\n");
#endif //#endif
// fifoReset(); printf("Starting State Machine\n"); // fifoReset(); printf("Starting State Machine\n");
now_ptr=(char*)ram_values; now_ptr=(char*)ram_values;
#ifdef SHAREDMEMORY #ifdef SHAREDMEMORY
@ -1442,7 +1445,35 @@ u_int32_t* fifo_read_event()
printf("FIFO %d contains %d words\n",ichip,(fifoReadCounter(ichip)&FIFO_COUNTER_MASK)); printf("FIFO %d contains %d words\n",ichip,(fifoReadCounter(ichip)&FIFO_COUNTER_MASK));
} }
#endif #endif
memcpy(now_ptr, values, dataBytes);
//unsigned long flags;
// register int ihalf;
// save_flags(flags);
// cli(); /* This code runs with interrupts disabled */
/* for (ihalf=0;ihalf<dataBytes/sizeof(int); ihalf++){
ram_values[ihalf]=*values;
}*/
// restore_flags(flags);
/*
for (ihalf=0;ihalf<dataBytes/sizeof(int); ihalf++)
printf("\n%d: 0x%0x 0x%0x",ihalf,ram_values[ihalf]&0xffff,(ram_values[ihalf]>>16)&0xffff);
*/
/* for (ichip=0;ichip<dataBytes/2; ichip++)
printf("\n%d: %08x",ichip,*values);*/
//sram_free(now_ptr);
memcpy(now_ptr, values, dataBytes);
/* /*
#ifdef VERBOSE #ifdef VERBOSE
for (ichip=0;ichip<dataBytes/4; ichip++) { for (ichip=0;ichip<dataBytes/4; ichip++) {

View File

@ -52,45 +52,45 @@
//FIFO //FIFO
#define LOOK_AT_ME_REG 0x28<<11 #define LOOK_AT_ME_REG 0x28<<11
#define COUNTER_REG_OFF 0x29<<11
#define FIFO_DATA_REG_OFF 0x80<<11 /////// #define FIFO_DATA_REG_OFF 0x80<<11 ///////
//to read back dac registers //to read back dac registers
#define MOD_DACS1_REG 0x2a<<11 #define MOD_DACS1_REG 0x65<<11
#define MOD_DACS2_REG 0x2b<<11 #define MOD_DACS2_REG 0x66<<11
#define MOD_DACS3_REG 0x2c<<11 #define MOD_DACS3_REG 0x67<<11
//user entered //user entered
#define SET_DELAY_LSB_REG 0x2d<<11 #define SET_DELAY_LSB_REG 0x68<<11
#define SET_DELAY_MSB_REG 0x2e<<11 #define SET_DELAY_MSB_REG 0x69<<11
#define GET_DELAY_LSB_REG 0x2f<<11 #define GET_DELAY_LSB_REG 0x6a<<11
#define GET_DELAY_MSB_REG 0x30<<11 #define GET_DELAY_MSB_REG 0x6b<<11
#define SET_TRAINS_LSB_REG 0x31<<11 #define SET_TRAINS_LSB_REG 0x6c<<11
#define SET_TRAINS_MSB_REG 0x32<<11 #define SET_TRAINS_MSB_REG 0x6d<<11
#define GET_TRAINS_LSB_REG 0x33<<11 #define GET_TRAINS_LSB_REG 0x6e<<11
#define GET_TRAINS_MSB_REG 0x34<<11 #define GET_TRAINS_MSB_REG 0x6f<<11
#define SET_FRAMES_LSB_REG 0x35<<11 #define SET_FRAMES_LSB_REG 0x70<<11
#define SET_FRAMES_MSB_REG 0x36<<11 #define SET_FRAMES_MSB_REG 0x71<<11
#define GET_FRAMES_LSB_REG 0x37<<11 #define GET_FRAMES_LSB_REG 0x72<<11
#define GET_FRAMES_MSB_REG 0x38<<11 #define GET_FRAMES_MSB_REG 0x73<<11
#define SET_PERIOD_LSB_REG 0x39<<11 #define SET_PERIOD_LSB_REG 0x74<<11
#define SET_PERIOD_MSB_REG 0x3a<<11 #define SET_PERIOD_MSB_REG 0x75<<11
#define GET_PERIOD_LSB_REG 0x3b<<11 #define GET_PERIOD_LSB_REG 0x76<<11
#define GET_PERIOD_MSB_REG 0x3c<<11 #define GET_PERIOD_MSB_REG 0x77<<11
#define SET_EXPTIME_LSB_REG 0x3d<<11 #define SET_EXPTIME_LSB_REG 0x78<<11
#define SET_EXPTIME_MSB_REG 0x3e<<11 #define SET_EXPTIME_MSB_REG 0x79<<11
#define GET_EXPTIME_LSB_REG 0x3f<<11 #define GET_EXPTIME_LSB_REG 0x7a<<11
#define GET_EXPTIME_MSB_REG 0x40<<11 #define GET_EXPTIME_MSB_REG 0x7b<<11
#define SET_GATES_LSB_REG 0x41<<11 #define SET_GATES_LSB_REG 0x7c<<11
#define SET_GATES_MSB_REG 0x42<<11 #define SET_GATES_MSB_REG 0x7d<<11
#define GET_GATES_LSB_REG 0x43<<11 #define GET_GATES_LSB_REG 0x7e<<11
#define GET_GATES_MSB_REG 0x44<<11 #define GET_GATES_MSB_REG 0x7f<<11

View File

@ -94,7 +94,7 @@ int decode_function(int file_des) {
#endif #endif
n = receiveDataOnly(file_des,&fnum,sizeof(fnum)); n = receiveDataOnly(file_des,&fnum,sizeof(fnum));
if (n <= 0) { if (n <= 0) {
printf("ERROR reading from socket %d, %d %d\n", n, fnum, file_des); //printf("ERROR reading from socket %d, %d %d\n", n, fnum, file_des);
return FAIL; return FAIL;
} }
#ifdef VERBOSE #ifdef VERBOSE
@ -1853,6 +1853,16 @@ int get_run_status(int file_des) {
retval= runState(); retval= runState();
printf("\n\nSTATUS=%x\n",retval); printf("\n\nSTATUS=%x\n",retval);
if (retval&0x00000001){
printf("-----------------------------------RUNNING-----------------------------------\n");
s=RUNNING;
}
else{
printf("-----------------------------------IDLE----------------------------------\n");
s=IDLE;
}
/*
if (retval&0x8000) if (retval&0x8000)
s=ERROR; s=ERROR;
else if (retval&0x00000001) else if (retval&0x00000001)
@ -1867,7 +1877,7 @@ int get_run_status(int file_des) {
s=WAITING; s=WAITING;
else else
s=IDLE; s=IDLE;
*/
if (ret!=OK) { if (ret!=OK) {
@ -1995,6 +2005,7 @@ int read_all(int file_des) {
while(read_frame(file_des)==OK) { while(read_frame(file_des)==OK) {
//usleep(0);
#ifdef VERBOSE #ifdef VERBOSE
printf("frame read\n"); printf("frame read\n");
#endif #endif