mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-16 14:57:13 +02:00
reset fpga implemented, changed receiver configuration warning prints, powerchip implemented
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include "firmware_funcs.h"
|
||||
#include "mcb_funcs.h"
|
||||
#include "registers_m.h"
|
||||
#include "gitInfoJungfrau.h"
|
||||
|
||||
//#define VERBOSE
|
||||
//#define VERYVERBOSE
|
||||
@ -116,7 +117,7 @@ char mtdvalue[10];
|
||||
|
||||
|
||||
int mapCSP0(void) {
|
||||
//printf("Mapping memory\n");
|
||||
printf("Mapping memory\n");
|
||||
#ifndef VIRTUAL
|
||||
int fd;
|
||||
fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
@ -163,6 +164,7 @@ void defineGPIOpins(){
|
||||
}
|
||||
|
||||
void resetFPGA(){
|
||||
cprintf(BLUE,"\n*** Reseting FPGA ***\n");
|
||||
FPGAdontTouchFlash();
|
||||
FPGATouchFlash();
|
||||
}
|
||||
@ -177,18 +179,143 @@ void FPGATouchFlash(){
|
||||
system("echo 1 > /sys/class/gpio/gpio9/value");
|
||||
}
|
||||
|
||||
void powerChip (int on){
|
||||
if(on){
|
||||
printf("\nPowering on the chip\n");
|
||||
bus_w(POWER_ON_REG,0x1);
|
||||
}
|
||||
else{
|
||||
printf("\nPowering off the chip\n");
|
||||
bus_w(POWER_ON_REG,0x0);
|
||||
int powerChip (int on){
|
||||
if(on != -1){
|
||||
if(on){
|
||||
printf("\nPowering on the chip\n");
|
||||
bus_w(POWER_ON_REG,0x1);
|
||||
}
|
||||
else{
|
||||
printf("\nPowering off the chip\n");
|
||||
bus_w(POWER_ON_REG,0x0);
|
||||
}
|
||||
}
|
||||
|
||||
return bus_r(POWER_ON_REG);
|
||||
}
|
||||
|
||||
|
||||
void initializeDetector(){
|
||||
printf("Initializing Detector\n");
|
||||
|
||||
int i;
|
||||
//printf("Bus test... ");
|
||||
for (i=0; i<1000000; i++) {
|
||||
bus_w(SET_DELAY_LSB_REG, i*100);
|
||||
bus_r(FPGA_VERSION_REG);
|
||||
if (i*100!=bus_r(SET_DELAY_LSB_REG))
|
||||
cprintf(RED,"Bus Test ERROR: wrote 0x%x, read 0x%x\n",i*100,bus_r(SET_DELAY_LSB_REG));
|
||||
}
|
||||
//printf("Finished\n");
|
||||
|
||||
//confirm the detector type
|
||||
if (((bus_r(PCB_REV_REG) & DETECTOR_TYPE_MASK)>>DETECTOR_TYPE_OFFSET) != JUNGFRAU_MODULE_ID){
|
||||
cprintf(BG_RED,"This is not a Jungfrau Server (enum:%d)\n",myDetectorType);
|
||||
exit(-1);
|
||||
}
|
||||
cprintf(BLUE,"\n\n********************************************************\n"
|
||||
"*********************Jungfrau Server********************\n"
|
||||
"********************************************************\n");
|
||||
|
||||
//print version
|
||||
cprintf(BLUE,"\n"
|
||||
"Firmware Version:\t 0x%x\n"
|
||||
"Software Version:\t %llx\n"
|
||||
//"F/w-S/w API Version:\t\t %lld\n"
|
||||
//"Required Firmware Version:\t %d\n"
|
||||
"Fixed Pattern:\t\t 0x%x\n"
|
||||
"Board Revision:\t\t 0x%x\n"
|
||||
"\n********************************************************\n",
|
||||
bus_r(FPGA_VERSION_REG),(long long unsigned int)(((int64_t)SVNREV <<32) | (int64_t)SVNDATE)
|
||||
//,sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION
|
||||
,bus_r(FIX_PATT_REG),(bus_r(PCB_REV_REG)&BOARD_REVISION_MASK)
|
||||
);
|
||||
|
||||
|
||||
printf("Resetting PLL\n");
|
||||
resetPLL();
|
||||
bus_w16(CONTROL_REG, SYNC_RESET);
|
||||
bus_w16(CONTROL_REG, 0);
|
||||
bus_w16(CONTROL_REG, GB10_RESET_BIT);
|
||||
bus_w16(CONTROL_REG, 0);
|
||||
|
||||
#ifdef MCB_FUNCS
|
||||
initDetector();
|
||||
#endif
|
||||
/*some registers set, which is in common with jungfrau, please check */
|
||||
prepareADC();
|
||||
/*some registers set, which is in common with jungfrau, please check */
|
||||
initDac(0); initDac(8); //initializes the two dacs
|
||||
|
||||
|
||||
//set dacs
|
||||
printf("Setting Default Dac values\n");
|
||||
enum dacNames{VB_COMP,VDD_PROT,VIN_COM,VREF_PRECH,VB_PIXBUF,VB_DS,VREF_DS,VREF_COMP};
|
||||
int retval = -1;
|
||||
int dacvalues[8][2]={
|
||||
{VB_COMP, 1220},
|
||||
{VDD_PROT, 3000},
|
||||
{VIN_COM, 1053},
|
||||
{VREF_PRECH,1450},
|
||||
{VB_PIXBUF, 750},
|
||||
{VB_DS, 1000},
|
||||
{VREF_DS, 480},
|
||||
{VREF_COMP, 420},
|
||||
};
|
||||
for(i=0;i<8;++i){
|
||||
retval=setDac(dacvalues[i][0], dacvalues[i][1]);
|
||||
if(retval!=dacvalues[i][1])
|
||||
printf("Error: Setting dac %d failed, wrote %d, read %d\n",dacvalues[i][0],dacvalues[i][1],retval);
|
||||
}
|
||||
|
||||
|
||||
//done from config file
|
||||
//printf("\nPowering on the chip\n");
|
||||
//bus_w(POWER_ON_REG,0x1);
|
||||
|
||||
/* Only once */
|
||||
bus_w(CONFGAIN_REG,0x0);
|
||||
|
||||
printf("Resetting ADC\n");
|
||||
writeADC(ADCREG1,0x3); writeADC(ADCREG1,0x0);
|
||||
writeADC(ADCREG2,0x40);
|
||||
writeADC(ADCREG3,0xf);
|
||||
writeADC(ADCREG4,0x3f);
|
||||
printf("Configuring Vrefs\n");
|
||||
writeADC(ADCREG_VREFS,0x2);
|
||||
printf("Setting ADC Inversion\n");// (by trial and error)
|
||||
bus_w(ADC_INVERSION_REG,0x453b2a9c);
|
||||
|
||||
adcPipeline(HALFSPEED_ADC_PIPELINE);
|
||||
dbitPipeline(HALFSPEED_DBIT_PIPELINE);
|
||||
adcPhase(HALFSPEED_ADC_PHASE); //set adc_clock_phase in unit of 1/(52) clock period (by trial and error)
|
||||
|
||||
printf("Reset mem machine fifos\n");
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x4000);
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0);
|
||||
printf("Reset run control\n");
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0400);
|
||||
bus_w(MEM_MACHINE_FIFOS_REG,0x0);
|
||||
initSpeedConfGain(HALFSPEED_CONF);
|
||||
setSettings(DYNAMICGAIN,-1);
|
||||
|
||||
|
||||
|
||||
//Initialization of acquistion parameters
|
||||
setFrames(1*1000*1000);
|
||||
setTrains(-1);
|
||||
setExposureTime(10*1000);
|
||||
setPeriod(2*1000*1000);
|
||||
setDelay(0);
|
||||
setGates(0);
|
||||
|
||||
|
||||
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||
setMaster(GET_MASTER);
|
||||
setSynchronization(GET_SYNCHRONIZATION_MODE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
u_int16_t bus_r16(u_int32_t offset){
|
||||
volatile u_int16_t *ptr1;
|
||||
|
Reference in New Issue
Block a user