Here’s the code I use for programming the chip. You’ll need to fill in some details but this’ll give you the idea. there’s a distinction between the code for the version 3 drivers and the version 4 drivers.
if this.okVersion == 3
% for OK front panel version 3.0.11:
addpath([paths.opalKelly '\FrontPanel\API']); % The actual DLL is here
addpath([paths.opalKelly '\FrontPanel\API\Matlab']); % The DLL header file and all the matlab object definitions are here
elseif this.okVersion == 3.1 || this.okVersion == 4
% for OK front panel 3.1.5 onwards:
addpath([paths.opalKelly '\FrontPanelUSB\API']); % The actual DLL is here
addpath([paths.opalKelly '\FrontPanelUSB\API\Matlab']); % The DLL header file and all the matlab object definitions are here
end
addpath([paths.chipTest '\Code_Xilinx']);
if ~libisloaded('okFrontPanel')
if this.okVersion == 3.1 || this.okVersion == 4
loadlibrary('okFrontPanel', 'okFrontPanelDLL.h');
else
loadlibrary('okFrontPanel', 'okFrontPanelDLL.h');
end
end
if this.okVersion == 3
this.xPointer = calllib(‘okFrontPanel’, ‘okUsbFrontPanel_Construct’);
NumDevices = calllib(‘okFrontPanel’, ‘okUsbFrontPanel_GetDeviceCount’, this.xPointer);
else
this.xPointer = calllib(‘okFrontPanel’, ‘okFrontPanel_Construct’);
NumDevices = calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceCount’, this.xPointer);
end
if NumDevices == 0
error(‘error: there are no devices connected’);
elseif NumDevices > 1
error(‘error: there is more than one device connected’);
else
if this.verbose(1), disp(‘There is one device connected’), end
end
if this.okVersion == 3
if this.verbose(1), disp('Device model: ’ calllib(‘okFrontPanel’, ‘okUsbFrontPanel_GetDeviceListModel’, this.xPointer, 0)]), end;
serialNumber = calllib(‘okFrontPanel’, ‘okUsbFrontPanel_GetDeviceListSerial’, this.xPointer, 0, ’ ', 10);
else
if this.verbose(1), disp('Device model: ’ calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceListModel’, this.xPointer, 0)]), end;
serialNumber = calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceListSerial’, this.xPointer, 0, ’ ', 10);
end
%[ptr SerialNumber] = calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceListSerial’, XPointer, 0, ’ ');
%if this.verbose(1), disp('Device serial number: ’ SerialNumber]), end;
this.xem = okusbfrontpanel(this.xPointer);
if isopen(this.xem)
if this.verbose(1), disp(‘The FPGA is already open.’), end;
else
if this.verbose(1), disp(‘Attempting to open the FPGA.’), end
resultOfAttemptingToOpenFpga = openbyserial(this.xem,serialNumber);
end
resultOfAttemptingToConfigureFpga = configurefpga(this.xem, ‘…\Code_Xilinx.bit’);
if this.verbose(1), disp('Result of attempting to configure the FPGA: ’ resultOfAttemptingToConfigureFpga]), end;
if ~strcmp(resultOfAttemptingToConfigureFpga,‘ok_NoError’)
disp(‘Attempting to reopen FPGA’)
this.xem = ];
this.OpenFpga;
resultOfAttemptingToConfigureFpga = configurefpga(this.xem, ‘…\Code_Xilinx\renachip.bit’);
if this.verbose(1), disp('Result of second attempt to configure the FPGA: ’ resultOfAttemptingToConfigureFpga]), end;
if ~strcmp(resultOfAttemptingToConfigureFpga,‘ok_NoError’)
error(resultOfAttemptingToConfigureFpga)
end
end