#include #include "dio32rlp.h" #include "licel_re.h" void mDelay(int Milliseconds) { delay(Milliseconds); } /* Setup of the DIO card*/ int Initialize_Board(short int iBoard) { if(Setup_PNP_Board()!=0) exit(1); DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER1_1,0x00); /*Reset Run Mode for Group 1 */ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER1_2,0x00); /* Reset Run Mode for Group 2*/ DAQ_DIO_Windowed_Mode_Write8(DATA_PATH_1,0x03); /* Group 1 FIFO Enable A and FIFO Enable B no Funneling input*/ DAQ_DIO_Windowed_Mode_Write8(DATA_PATH_2,0x84); /* Group 2 FIFO Enable C no funneling output*/ DAQ_DIO_Windowed_Mode_Write8(PORTA_POLARITY,0x00); DAQ_DIO_Windowed_Mode_Write8(PORTB_POLARITY,0x00); DAQ_DIO_Windowed_Mode_Write8(PORTC_POLARITY,0x00); DAQ_DIO_Windowed_Mode_Write8(PORTD_POLARITY,0x00); /*Dont invert the polarites of the port data*/ DAQ_DIO_Windowed_Mode_Write8(PORTC_MASK,0x00); DAQ_DIO_Windowed_Mode_Write8(PORTD_MASK,0x00); /* Configuring Port C and D to use standard and not wired or driving mechanism while they are marked as inputs*/ DAQ_DIO_Windowed_Mode_Write8(PORTA_DIRECTION,0x00); DAQ_DIO_Windowed_Mode_Write8(PORTB_DIRECTION,0x00); /* Configuring Port A and B as inputs*/ DAQ_DIO_Windowed_Mode_Write8(PORTC_DIRECTION,0xFF); DAQ_DIO_Windowed_Mode_Write8(PORTD_DIRECTION,0xFF); /* Configuring C and D as outputs*/ DAQ_DIO_Windowed_Mode_Write8(TRANSFER_SIZE_CONTROL_1,0x03); DAQ_DIO_Windowed_Mode_Write8(TRANSFER_SIZE_CONTROL_2,0x02); /* Set the transfer size to two bytes for group 1 and one byte for group2*/ /* Handshaking protocol*/ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER1_1,0x00); /* Stop the run Mode for group 1*/ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER2_1,0x60); /* bit 5 0 Tristate the PCLK line 1 Use the PCLK bit 6 as an extra output line. Drive the value of Invert Clock onto the line. bit 7 1 - hardware stop trigger active low */ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER3_1,0x00); /* set the sequence register */ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER4_1,0x08); DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER5_1,0x04); DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER6_1,0x00); /* normal polarites*/ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER7_1,0x60); /* Serial Mode & Ack = 96 */ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER8_1,0x01); /* 0 ns delay */ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER1_2,0x00); /*stop the run mode*/ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER2_2,0x10); DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER3_2,0x00); DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER4_2,0x20); DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER5_2,0x04); DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER6_2,0x00); /*normal polarities of handshake lines*/ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER7_2,0x60); /*serial Mode & Ack 96*/ DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER8_2,0x01); /* 0ns delay */ DAQ_DIO_Windowed_Mode_Write8(FIFO_CONTROL_1,0x00); /* stop FIFO1*/ DAQ_DIO_Windowed_Mode_Write8(FIFO_CONTROL_2,0x00); /* stop FIFO2*/ DAQ_DIO_Windowed_Mode_Write16(CLOCK_SPEED_LSB_1,0x00); /* Dont use Clock?*/ DAQ_DIO_Windowed_Mode_Write16(CLOCK_SPEED_LSB_2,0x00); /* Dont Use Clock*/ return 0; } /* Writing the commands to the TR*/ int WriteCommand(short int iBoard, short iCommand) { int TransferReady2Flag,CountExpiredFlag; int i; TransferReady2Flag=0x00; i=0; while(TransferReady2Flag==0x00 && i =WRITE_RETRY) return(-10080); /* Timeout*/ Board_Write8(GROUP2_FIRST_FIFO,iCommand); DAQ_DIO_Windowed_Mode_Write32(GROUP2_TRANSFER_COUNT_0,0x01); DAQ_DIO_Windowed_Mode_Write8(PROTOCOL_REGISTER1_2,0x0F); CountExpiredFlag=0x00; i=0; while(CountExpiredFlag==0x00 && i