added reset for control reg and changed teh read and write register functions in server_funcs.c

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@168 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2012-04-03 09:35:23 +00:00
parent ee36cdf9e4
commit d8e03f80e4
3 changed files with 37 additions and 23 deletions

View File

@ -949,10 +949,10 @@ int setNMod(int n) {
// fifo test // fifo test
u_int32_t testFifos(void) { int testFifos(void) {
printf("Fifo test not implemented!\n"); printf("Fifo test not implemented!\n");
bus_w(CONTROL_REG, START_FIFOTEST_BIT); bus_w16(CONTROL_REG, START_FIFOTEST_BIT);
bus_w(CONTROL_REG, 0x0); bus_w16(CONTROL_REG, 0x0);
return OK; return OK;
} }
@ -1537,7 +1537,7 @@ u_int32_t runState(void) {
// State Machine // State Machine
u_int32_t startStateMachine(){ int startStateMachine(){
//#ifdef VERBOSE //#ifdef VERBOSE
printf("Starting State Machine\n"); printf("Starting State Machine\n");
//#endif //#endif
@ -1554,15 +1554,16 @@ u_int32_t startStateMachine(){
#endif #endif
*/ */
//putout("0000000000000000",ALLMOD); //putout("0000000000000000",ALLMOD);
bus_w(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT); bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
bus_w(CONTROL_REG, 0x0); bus_w16(CONTROL_REG, 0x0);
printf("statusreg=%08x\n",bus_r(STATUS_REG));
return OK; return OK;
} }
u_int32_t stopStateMachine(){ int stopStateMachine(){
#ifdef VERBOSE #ifdef VERBOSE
printf("Stopping State Machine\n"); printf("Stopping State Machine\n");
@ -1571,8 +1572,8 @@ u_int32_t stopStateMachine(){
write_stop_sm(1); write_stop_sm(1);
write_status_sm("Stopped"); write_status_sm("Stopped");
#endif #endif
bus_w(CONTROL_REG, STOP_ACQ_BIT); bus_w16(CONTROL_REG, STOP_ACQ_BIT);
bus_w(CONTROL_REG, 0x0); bus_w16(CONTROL_REG, 0x0);
usleep(500); usleep(500);
// if (!runBusy()) // if (!runBusy())
if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT)) if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT))
@ -1582,7 +1583,7 @@ u_int32_t stopStateMachine(){
} }
u_int32_t startReadOut(){ int startReadOut(){
u_int32_t status; u_int32_t status;
#ifdef VERBOSE #ifdef VERBOSE
printf("Starting State Machine Readout\n"); printf("Starting State Machine Readout\n");
@ -1591,8 +1592,8 @@ u_int32_t startReadOut(){
#ifdef DEBUG #ifdef DEBUG
printf("State machine status is %08x\n",bus_r(STATUS_REG)); printf("State machine status is %08x\n",bus_r(STATUS_REG));
#endif #endif
bus_w(CONTROL_REG, START_ACQ_BIT |START_READOUT_BIT); // start readout bus_w16(CONTROL_REG, START_ACQ_BIT |START_READOUT_BIT); // start readout
bus_w(CONTROL_REG, 0x0); bus_w16(CONTROL_REG, 0x0);
return OK; return OK;
} }

View File

@ -64,7 +64,7 @@ int configureMAC(int ipad, long long int macad, long long int servermacad, int i
u_int64_t getMcsNumber(); u_int64_t getMcsNumber();
u_int32_t getMcsVersion(); u_int32_t getMcsVersion();
u_int32_t testFifos(void); int testFifos(void);
u_int32_t testFpga(void); u_int32_t testFpga(void);
u_int32_t testRAM(void); u_int32_t testRAM(void);
int testBus(void); int testBus(void);
@ -106,9 +106,9 @@ u_int32_t runState(void);
u_int32_t dataPresent(void); u_int32_t dataPresent(void);
u_int32_t startStateMachine(); int startStateMachine();
u_int32_t stopStateMachine(); int stopStateMachine();
u_int32_t startReadOut(); int startReadOut();
u_int32_t fifoReset(void); u_int32_t fifoReset(void);
u_int32_t fifoReadCounter(int fifonum); u_int32_t fifoReadCounter(int fifonum);
u_int32_t fifoReadStatus(); u_int32_t fifoReadStatus();

View File

@ -9,7 +9,8 @@
#include "mcb_funcs.h" #include "mcb_funcs.h"
#include "trimming_funcs.h" #include "trimming_funcs.h"
#define FIFO_DATA_REG_OFF 0x50<<11
#define CONTROL_REG 0x24<<11
// Global variables // Global variables
int (*flist[256])(int); int (*flist[256])(int);
@ -790,9 +791,16 @@ int write_register(int file_des) {
if(ret!=FAIL){ if(ret!=FAIL){
address=(addr<<11); address=(addr<<11);
ret=bus_w(address,val); if((address==FIFO_DATA_REG_OFF)||(address==CONTROL_REG))
if(ret==OK) ret = bus_w16(address,val);
retval=bus_r(address); else
ret=bus_w(address,val);
if(ret==OK){
if((address==FIFO_DATA_REG_OFF)||(address==CONTROL_REG))
retval=bus_r16(address);
else
retval=bus_r(address);
}
} }
@ -849,7 +857,7 @@ int read_register(int file_des) {
if(ret!=FAIL){ if(ret!=FAIL){
address=(addr<<11); address=(addr<<11);
if(addr==0x50) if((address==FIFO_DATA_REG_OFF)||(address==CONTROL_REG))
retval=bus_r16(address); retval=bus_r16(address);
else else
retval=bus_r(address); retval=bus_r(address);
@ -1855,10 +1863,15 @@ int get_run_status(int file_des) {
s=TRANSMITTING; s=TRANSMITTING;
} }
//and readbusy=0,idle //and readbusy=0,idle
if(!(retval&0x00000001)){ else if(!(retval&0x000FFFFF)){
//if(!(retval&0x00000001)){
printf("-----------------------------------IDLE--------------------------------------\n"); printf("-----------------------------------IDLE--------------------------------------\n");
s=IDLE; s=IDLE;
} }
else {
printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval);
s=ERROR;
}
} }
//if runbusy=1 //if runbusy=1
else { else {
@ -2008,7 +2021,7 @@ int read_frame(int file_des) {
int read_all(int file_des) { int read_all(int file_des) {
while(read_frame(file_des)==OK) { while(read_frame(file_des)==OK) {
#ifdef VERBOSE #ifdef VERBOSE
printf("frame read\n"); printf("frame read\n");