|
|
|
|
@@ -546,22 +546,22 @@ int Beb_SetUpTransferParameters(short the_bit_mode){
|
|
|
|
|
int Beb_StopAcquisition()
|
|
|
|
|
{
|
|
|
|
|
u_int32_t baseaddr;
|
|
|
|
|
u_int32_t valuel,valuer;
|
|
|
|
|
volatile u_int32_t valuel,valuer;
|
|
|
|
|
//open file pointer
|
|
|
|
|
int fd = Beb_open(XPAR_STOP_ACQUISITION,&baseaddr);
|
|
|
|
|
int fd = Beb_open(XPAR_CMD_GENERATOR,&baseaddr);
|
|
|
|
|
if(fd < 0){
|
|
|
|
|
cprintf(RED,"Beb Stop Acquisition FAIL\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}else{
|
|
|
|
|
//find value
|
|
|
|
|
valuel = Beb_Read32(baseaddr, STOP_ACQUISITION_LEFT_OFFSET);
|
|
|
|
|
valuer = Beb_Read32(baseaddr, STOP_ACQUISITION_RIGHT_OFFSET);
|
|
|
|
|
valuel = Beb_Read32(baseaddr, (LEFT_OFFSET+STOP_ACQ_OFFSET));
|
|
|
|
|
valuer = Beb_Read32(baseaddr, (RIGHT_OFFSET+STOP_ACQ_OFFSET));
|
|
|
|
|
//high
|
|
|
|
|
Beb_Write32(baseaddr, STOP_ACQUISITION_LEFT_OFFSET,(valuel|STOP_ACQUISITION_BIT));
|
|
|
|
|
Beb_Write32(baseaddr, STOP_ACQUISITION_RIGHT_OFFSET,(valuer|STOP_ACQUISITION_BIT));
|
|
|
|
|
Beb_Write32(baseaddr, (LEFT_OFFSET + STOP_ACQ_OFFSET),(valuel|STOP_ACQ_BIT));
|
|
|
|
|
Beb_Write32(baseaddr, (RIGHT_OFFSET + STOP_ACQ_OFFSET),(valuer|STOP_ACQ_BIT));
|
|
|
|
|
//low
|
|
|
|
|
Beb_Write32(baseaddr, STOP_ACQUISITION_LEFT_OFFSET,(valuel&(~STOP_ACQUISITION_BIT)));
|
|
|
|
|
Beb_Write32(baseaddr, STOP_ACQUISITION_RIGHT_OFFSET,(valuer&(~STOP_ACQUISITION_BIT)));
|
|
|
|
|
Beb_Write32(baseaddr, (LEFT_OFFSET + STOP_ACQ_OFFSET),(valuel&(~STOP_ACQ_BIT)));
|
|
|
|
|
Beb_Write32(baseaddr, (RIGHT_OFFSET + STOP_ACQ_OFFSET),(valuer&(~STOP_ACQ_BIT)));
|
|
|
|
|
|
|
|
|
|
printf("Beb Stop Acquisition OK\n");
|
|
|
|
|
//close file pointer
|
|
|
|
|
@@ -571,124 +571,117 @@ int Beb_StopAcquisition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait){
|
|
|
|
|
if(dst_number>64) return 0;
|
|
|
|
|
if(dst_number>64) return 0;
|
|
|
|
|
|
|
|
|
|
unsigned int header_size = 4; //4*64 bits
|
|
|
|
|
unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets
|
|
|
|
|
unsigned int npackets = ten_gig ? Beb_bit_mode*4 : Beb_bit_mode*16;
|
|
|
|
|
int in_two_requests = (!ten_gig&&Beb_bit_mode==32);
|
|
|
|
|
unsigned int header_size = 4; //4*64 bits
|
|
|
|
|
unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets
|
|
|
|
|
unsigned int npackets = ten_gig ? Beb_bit_mode*4 : Beb_bit_mode*16;
|
|
|
|
|
int in_two_requests = (!ten_gig&&Beb_bit_mode==32);
|
|
|
|
|
|
|
|
|
|
volatile u_int32_t* ptrl;
|
|
|
|
|
volatile u_int32_t* ptrr;
|
|
|
|
|
u_int32_t send_header_command;
|
|
|
|
|
u_int32_t send_frame_command;
|
|
|
|
|
// volatile u_int32_t* ptrl;
|
|
|
|
|
// volatile u_int32_t* ptrr;
|
|
|
|
|
u_int32_t send_header_command;
|
|
|
|
|
u_int32_t send_frame_command;
|
|
|
|
|
|
|
|
|
|
if(in_two_requests) npackets/=2;
|
|
|
|
|
if(in_two_requests) npackets/=2;
|
|
|
|
|
|
|
|
|
|
#ifdef MARTIN
|
|
|
|
|
cprintf(RED, "----Beb_RequestNImages Start----\n");
|
|
|
|
|
cprintf(RED, "beb_number:%X, ten_gig:%X,dst_number:%X,npackets:%X,Beb_bit_mode:%X,header_size:%X,nimages:%d,test_just_send_out_packets_no_wait:%X\n",beb_number,ten_gig,dst_number,npackets,Beb_bit_mode,header_size,nimages,test_just_send_out_packets_no_wait);
|
|
|
|
|
cprintf(RED, "----Beb_RequestNImages Start----\n");
|
|
|
|
|
cprintf(RED, "beb_number:%X, ten_gig:%X,dst_number:%X,npackets:%X,Beb_bit_mode:%X,header_size:%X,nimages:%d,test_just_send_out_packets_no_wait:%X\n",beb_number,ten_gig,dst_number,npackets,Beb_bit_mode,header_size,nimages,test_just_send_out_packets_no_wait);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// CMD_GEN core registers
|
|
|
|
|
//
|
|
|
|
|
// base for left feb fpga + 0x000
|
|
|
|
|
// base for right feb fpga + 0x100 Bytes
|
|
|
|
|
//
|
|
|
|
|
// OFFSETs given in Bytes
|
|
|
|
|
// base+00 0xC0DE0001 (static r/o)
|
|
|
|
|
// base+04 0x636D6467 (static r/o, ASCII for "CMDG")
|
|
|
|
|
//
|
|
|
|
|
// base+08 1st 32bits of 1st command
|
|
|
|
|
// base+0c 2nd 32bits of 1st command
|
|
|
|
|
//
|
|
|
|
|
// base+10 1st 32bits of 2nd command
|
|
|
|
|
// base+14 2nd 32bits of 2nd command
|
|
|
|
|
//
|
|
|
|
|
// base+1c command counter (sends n commands)
|
|
|
|
|
// <32 Bit mode : 2 commands for 1 frame neccessary (header + frame) (10 frames = 20 commands)
|
|
|
|
|
// 32 Bit mode : 3 commands for 1 frame neccessary (header + 1st halfframe + 2nd halfframe) (10 frames = 30 commands)
|
|
|
|
|
// if > 0 core starts operation
|
|
|
|
|
//
|
|
|
|
|
// base+20 command mode (for 32 bit mode)
|
|
|
|
|
// 0 for 2 command mode (send 1st command and 2nd command) (header + frame)
|
|
|
|
|
// 1 on bit 31 for 3 command mode (send 1st command, 2nd command, and 2nd command) (header + 1st halfframe + 2nd halfframe)
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// Warning: Hard coded base address 0xc5000000 (TBD)
|
|
|
|
|
//
|
|
|
|
|
// CMD_GEN core registers
|
|
|
|
|
//
|
|
|
|
|
// base for left feb fpga + 0x000
|
|
|
|
|
// base for right feb fpga + 0x100 Bytes
|
|
|
|
|
//
|
|
|
|
|
// OFFSETs given in Bytes
|
|
|
|
|
// base+00 0xC0DE0001 (static r/o)
|
|
|
|
|
// base+04 0x636D6467 (static r/o, ASCII for "CMDG")
|
|
|
|
|
//
|
|
|
|
|
// base+08 1st 32bits of 1st command
|
|
|
|
|
// base+0c 2nd 32bits of 1st command
|
|
|
|
|
//
|
|
|
|
|
// base+10 1st 32bits of 2nd command
|
|
|
|
|
// base+14 2nd 32bits of 2nd command
|
|
|
|
|
//
|
|
|
|
|
// base+18 command counter (sends n commands)
|
|
|
|
|
// <32 Bit mode : 2 commands for 1 frame neccessary (header + frame) (10 frames = 20 commands)
|
|
|
|
|
// 32 Bit mode : 3 commands for 1 frame neccessary (header + 1st halfframe + 2nd halfframe) (10 frames = 30 commands)
|
|
|
|
|
// if > 0 core starts operation
|
|
|
|
|
//
|
|
|
|
|
// base+1c command mode (for 32 bit mode)
|
|
|
|
|
// 0 for 2 command mode (send 1st command and 2nd command) (header + frame)
|
|
|
|
|
// 1 on bit 31 for 3 command mode (send 1st command, 2nd command, and 2nd command) (header + 1st halfframe + 2nd halfframe)
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// Warning: Hard coded base address 0xc5000000 (TBD)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Mapping
|
|
|
|
|
int fd;
|
|
|
|
|
fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
|
|
|
|
if (fd == -1)
|
|
|
|
|
{
|
|
|
|
|
printf("\nCan't find /dev/mem!\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
u_int32_t CSP0BASE = (u_int32_t)mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, 0xC5000000 );
|
|
|
|
|
if (CSP0BASE == (u_int32_t)MAP_FAILED)
|
|
|
|
|
{
|
|
|
|
|
printf("\nCan't map memmory area!!\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ptrl = (u_int32_t*)(CSP0BASE);
|
|
|
|
|
ptrr = (u_int32_t*)(CSP0BASE+0x100);
|
|
|
|
|
u_int32_t right_port_value = 0x2000;
|
|
|
|
|
u_int32_t baseaddr;
|
|
|
|
|
volatile u_int32_t value;
|
|
|
|
|
//open file pointer
|
|
|
|
|
int fd = Beb_open(XPAR_CMD_GENERATOR,&baseaddr);
|
|
|
|
|
if(fd < 0){
|
|
|
|
|
cprintf(RED,"Beb Request N Images FAIL\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
#ifdef MARTIN
|
|
|
|
|
int i;
|
|
|
|
|
for (i=0; i < 10; i++)
|
|
|
|
|
printf("%X\n",*(ptrl+i));
|
|
|
|
|
int i;
|
|
|
|
|
for (i=0; i < 10; i++)
|
|
|
|
|
printf("%X\n",Beb_Read32(baseaddr, (LEFT_OFFSET + i*4)));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Generating commands
|
|
|
|
|
send_header_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | header_size << 14 | 0;
|
|
|
|
|
send_frame_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | packet_size << 14 | (npackets-1);
|
|
|
|
|
// Generating commands
|
|
|
|
|
send_header_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | header_size << 14 | 0;
|
|
|
|
|
send_frame_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | packet_size << 14 | (npackets-1);
|
|
|
|
|
|
|
|
|
|
#ifdef MARTIN
|
|
|
|
|
for (i=0; i < 10; i++)
|
|
|
|
|
printf("%X\n",*(ptrl+i));
|
|
|
|
|
printf("%d\n",in_two_requests);
|
|
|
|
|
for (i=0; i < 10; i++)
|
|
|
|
|
printf("%X\n",Beb_Read32(baseaddr, (LEFT_OFFSET + i*4)));
|
|
|
|
|
printf("%d\n",in_two_requests);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Wait until last command was send successfully
|
|
|
|
|
// while (*(ptrl+6) != 0);
|
|
|
|
|
// while (*(ptrr+6) != 0);
|
|
|
|
|
//"0x20 << 8" is dst_number (0x00 for left, 0x20 for right)
|
|
|
|
|
//Left
|
|
|
|
|
Beb_Write32(baseaddr, (LEFT_OFFSET + FIRST_CMD_PART1_OFFSET),0);
|
|
|
|
|
Beb_Write32(baseaddr, (LEFT_OFFSET + FIRST_CMD_PART2_OFFSET),send_header_command);
|
|
|
|
|
Beb_Write32(baseaddr, (LEFT_OFFSET + SECOND_CMD_PART1_OFFSET),0);
|
|
|
|
|
Beb_Write32(baseaddr, (LEFT_OFFSET + SECOND_CMD_PART2_OFFSET),send_frame_command);
|
|
|
|
|
value = Beb_Read32(baseaddr,(LEFT_OFFSET + TWO_REQUESTS_OFFSET));
|
|
|
|
|
if(in_two_requests) Beb_Write32(baseaddr, (LEFT_OFFSET + TWO_REQUESTS_OFFSET),(value | TWO_REQUESTS_BIT));
|
|
|
|
|
else Beb_Write32(baseaddr, (LEFT_OFFSET + TWO_REQUESTS_OFFSET),(value &~(TWO_REQUESTS_BIT)));
|
|
|
|
|
|
|
|
|
|
//"0x20 << 8" is dst_number (0x00 for left, 0x20 for right)
|
|
|
|
|
//Left
|
|
|
|
|
*(ptrl+2) = 0;
|
|
|
|
|
*(ptrl+3) = send_header_command;
|
|
|
|
|
*(ptrl+4) = 0;
|
|
|
|
|
*(ptrl+5) = send_frame_command;
|
|
|
|
|
*(ptrl+7) = in_two_requests << 31;
|
|
|
|
|
// Right
|
|
|
|
|
Beb_Write32(baseaddr, (RIGHT_OFFSET + FIRST_CMD_PART1_OFFSET),0);
|
|
|
|
|
Beb_Write32(baseaddr, (RIGHT_OFFSET + FIRST_CMD_PART2_OFFSET),send_header_command | right_port_value);
|
|
|
|
|
Beb_Write32(baseaddr, (RIGHT_OFFSET + SECOND_CMD_PART1_OFFSET),0);
|
|
|
|
|
Beb_Write32(baseaddr, (RIGHT_OFFSET + SECOND_CMD_PART2_OFFSET),send_frame_command | right_port_value);
|
|
|
|
|
value = Beb_Read32(baseaddr,(RIGHT_OFFSET + TWO_REQUESTS_OFFSET));
|
|
|
|
|
if(in_two_requests) Beb_Write32(baseaddr, (RIGHT_OFFSET + TWO_REQUESTS_OFFSET),(value | TWO_REQUESTS_BIT));
|
|
|
|
|
else Beb_Write32(baseaddr, (RIGHT_OFFSET + TWO_REQUESTS_OFFSET),(value &~(TWO_REQUESTS_BIT)));
|
|
|
|
|
|
|
|
|
|
// Right
|
|
|
|
|
*(ptrr+2) = 0;
|
|
|
|
|
*(ptrr+3) = send_header_command | 0x2000;
|
|
|
|
|
*(ptrr+4) = 0;
|
|
|
|
|
*(ptrr+5) = send_frame_command | 0x2000;
|
|
|
|
|
*(ptrr+7) = in_two_requests | (in_two_requests << 31);
|
|
|
|
|
|
|
|
|
|
// Set number of frames
|
|
|
|
|
*(ptrl+6) = nimages*(2+in_two_requests);
|
|
|
|
|
*(ptrr+6) = nimages*(2+in_two_requests);
|
|
|
|
|
// Set number of frames
|
|
|
|
|
Beb_Write32(baseaddr, (LEFT_OFFSET + COMMAND_COUNTER_OFFSET), nimages*(2+in_two_requests));
|
|
|
|
|
Beb_Write32(baseaddr, (RIGHT_OFFSET + COMMAND_COUNTER_OFFSET), nimages*(2+in_two_requests));
|
|
|
|
|
|
|
|
|
|
#ifdef MARTIN
|
|
|
|
|
for (i=0; i < 10; i++)
|
|
|
|
|
printf("%X\n",*(ptrl+i));
|
|
|
|
|
printf("%d\n",in_two_requests);
|
|
|
|
|
for (i=0; i < 10; i++)
|
|
|
|
|
printf("%X\n",Beb_Read32(baseaddr, (LEFT_OFFSET + i*4))); //*(ptrl+i));
|
|
|
|
|
printf("%d\n",in_two_requests);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
Beb_close(fd);
|
|
|
|
|
|
|
|
|
|
#ifdef MARTIN
|
|
|
|
|
cprintf(RED, "----Beb_RequestNImages----\n");
|
|
|
|
|
printf("----Beb_RequestNImages----\n");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|