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
u_int32_t testFifos(void) {
int testFifos(void) {
printf("Fifo test not implemented!\n");
bus_w(CONTROL_REG, START_FIFOTEST_BIT);
bus_w(CONTROL_REG, 0x0);
bus_w16(CONTROL_REG, START_FIFOTEST_BIT);
bus_w16(CONTROL_REG, 0x0);
return OK;
}
@ -1537,7 +1537,7 @@ u_int32_t runState(void) {
// State Machine
u_int32_t startStateMachine(){
int startStateMachine(){
//#ifdef VERBOSE
printf("Starting State Machine\n");
//#endif
@ -1554,15 +1554,16 @@ u_int32_t startStateMachine(){
#endif
*/
//putout("0000000000000000",ALLMOD);
bus_w(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
bus_w(CONTROL_REG, 0x0);
bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
bus_w16(CONTROL_REG, 0x0);
printf("statusreg=%08x\n",bus_r(STATUS_REG));
return OK;
}
u_int32_t stopStateMachine(){
int stopStateMachine(){
#ifdef VERBOSE
printf("Stopping State Machine\n");
@ -1571,8 +1572,8 @@ u_int32_t stopStateMachine(){
write_stop_sm(1);
write_status_sm("Stopped");
#endif
bus_w(CONTROL_REG, STOP_ACQ_BIT);
bus_w(CONTROL_REG, 0x0);
bus_w16(CONTROL_REG, STOP_ACQ_BIT);
bus_w16(CONTROL_REG, 0x0);
usleep(500);
// if (!runBusy())
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;
#ifdef VERBOSE
printf("Starting State Machine Readout\n");
@ -1591,8 +1592,8 @@ u_int32_t startReadOut(){
#ifdef DEBUG
printf("State machine status is %08x\n",bus_r(STATUS_REG));
#endif
bus_w(CONTROL_REG, START_ACQ_BIT |START_READOUT_BIT); // start readout
bus_w(CONTROL_REG, 0x0);
bus_w16(CONTROL_REG, START_ACQ_BIT |START_READOUT_BIT); // start readout
bus_w16(CONTROL_REG, 0x0);
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_int32_t getMcsVersion();
u_int32_t testFifos(void);
int testFifos(void);
u_int32_t testFpga(void);
u_int32_t testRAM(void);
int testBus(void);
@ -106,9 +106,9 @@ u_int32_t runState(void);
u_int32_t dataPresent(void);
u_int32_t startStateMachine();
u_int32_t stopStateMachine();
u_int32_t startReadOut();
int startStateMachine();
int stopStateMachine();
int startReadOut();
u_int32_t fifoReset(void);
u_int32_t fifoReadCounter(int fifonum);
u_int32_t fifoReadStatus();

View File

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