diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-01-24 17:28:06 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-01-24 17:28:06 +0200 |
| commit | d1807ee5a17bada69c8062d7e218c006fe654a24 (patch) | |
| tree | a8e9a403e8cffda687b60f1d9ff8530b43c68e56 | |
| parent | 036d435688ff04e0cb89ad8c099d27ec71c0dc8b (diff) | |
| download | Tango-d1807ee5a17bada69c8062d7e218c006fe654a24.tar.gz Tango-d1807ee5a17bada69c8062d7e218c006fe654a24.zip | |
update fpga programing full vme logic
19 files changed, 187 insertions, 2437 deletions
diff --git a/Software/Embedded_SW/.jxbrowser-data/Cache/data_0 b/Software/Embedded_SW/.jxbrowser-data/Cache/data_0 Binary files differindex ba8683cee..43bc4dd30 100644 --- a/Software/Embedded_SW/.jxbrowser-data/Cache/data_0 +++ b/Software/Embedded_SW/.jxbrowser-data/Cache/data_0 diff --git a/Software/Embedded_SW/.jxbrowser-data/Cache/data_1 b/Software/Embedded_SW/.jxbrowser-data/Cache/data_1 Binary files differindex 22a0c48b7..98e1cbae6 100644 --- a/Software/Embedded_SW/.jxbrowser-data/Cache/data_1 +++ b/Software/Embedded_SW/.jxbrowser-data/Cache/data_1 diff --git a/Software/Embedded_SW/.jxbrowser-data/Cache/data_2 b/Software/Embedded_SW/.jxbrowser-data/Cache/data_2 Binary files differindex 67e0f8604..616f7914e 100644 --- a/Software/Embedded_SW/.jxbrowser-data/Cache/data_2 +++ b/Software/Embedded_SW/.jxbrowser-data/Cache/data_2 diff --git a/Software/Embedded_SW/.jxbrowser-data/Cache/data_3 b/Software/Embedded_SW/.jxbrowser-data/Cache/data_3 Binary files differindex 2ad14fe07..af4db3b45 100644 --- a/Software/Embedded_SW/.jxbrowser-data/Cache/data_3 +++ b/Software/Embedded_SW/.jxbrowser-data/Cache/data_3 diff --git a/Software/Embedded_SW/.jxbrowser-data/GPUCache/data_1 b/Software/Embedded_SW/.jxbrowser-data/GPUCache/data_1 Binary files differindex 735175301..33c2cc543 100644 --- a/Software/Embedded_SW/.jxbrowser-data/GPUCache/data_1 +++ b/Software/Embedded_SW/.jxbrowser-data/GPUCache/data_1 diff --git a/Software/Embedded_SW/.jxbrowser-data/History b/Software/Embedded_SW/.jxbrowser-data/History Binary files differindex af92dd0a9..56cc9160c 100644 --- a/Software/Embedded_SW/.jxbrowser-data/History +++ b/Software/Embedded_SW/.jxbrowser-data/History diff --git a/Software/Embedded_SW/.jxbrowser-data/History-journal b/Software/Embedded_SW/.jxbrowser-data/History-journal Binary files differindex 5f18e7c06..e69de29bb 100644 --- a/Software/Embedded_SW/.jxbrowser-data/History-journal +++ b/Software/Embedded_SW/.jxbrowser-data/History-journal diff --git a/Software/Embedded_SW/.jxbrowser-data/Local Storage - EXT/http_127.0.0.1.localstorage b/Software/Embedded_SW/.jxbrowser-data/Local Storage - EXT/http_127.0.0.1.localstorage index 420ed969f..fec0901b2 100644 --- a/Software/Embedded_SW/.jxbrowser-data/Local Storage - EXT/http_127.0.0.1.localstorage +++ b/Software/Embedded_SW/.jxbrowser-data/Local Storage - EXT/http_127.0.0.1.localstorage @@ -1,4 +1,4 @@ -#Tue Dec 18 13:18:39 IST 2018 +#Wed Jan 23 14:51:29 IST 2019 viewsData-storage={"ti.sysbios.knl.Task.Basic"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"label","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"priority","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"mode","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"fxn","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"arg0","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"arg1","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"stackSize","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"stackBase","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"curCoreId","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"affinity","checked"\:true,"hasFormat"\:false,"format"\:null}],"hasFormats"\:true},"ti.sysbios.knl.Task"\:{"defaultViewName"\:"CallStacks"},"ti.sysbios.family.arm.m3.Hwi.Basic"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"halHwiHandle","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"label","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"type","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"intNum","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"priority","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"group","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"subPriority","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"fxn","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"arg","checked"\:true,"hasFormat"\:true,"format"\:"Hex"}],"hasFormats"\:true},"ti.sysbios.family.arm.m3.Hwi"\:{"defaultViewName"\:"Exception"},"ti.sysbios.knl.Task.Detailed"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"label","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"priority","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"mode","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"fxn","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"arg0","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"arg1","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"stackPeak","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"stackSize","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"stackBase","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"curCoreId","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"affinity","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"blockedOn","checked"\:true,"hasFormat"\:false,"format"\:null}],"hasFormats"\:true},"ti.sysbios.family.arm.m3.Hwi.Detailed"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"halHwiHandle","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"label","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"type","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"intNum","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"priority","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"group","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"subPriority","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"fxn","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"arg","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"irp","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"status","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"coreId","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"}],"hasFormats"\:true},"ti.sysbios.heaps.HeapMem.Basic"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"label","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"buf","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"minBlockAlign","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"sectionName","checked"\:true,"hasFormat"\:false,"format"\:null}],"hasFormats"\:true},"ti.sysbios.knl.Event"\:{"defaultViewName"\:"Basic"},"ti.sysbios.knl.Event.Raw"\:{},"ti.catalog.arm.cortexm4.tiva.ce.Boot.Module"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"configureClock","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"sysClockDivEnable","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"sysClockDiv","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"pwmClockDivEnable","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"pwmClockDiv","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"xtal","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"oscSrc","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"pllBypass","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"pllOutEnable","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"ioscDisable","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"moscDisable","checked"\:true,"hasFormat"\:false,"format"\:null}],"hasFormats"\:false},"ti.sysbios.knl.Swi.Basic"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"label","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"state","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"priority","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"fxn","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"arg0","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"arg1","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"initTrigger","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"curTrigger","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"}],"hasFormats"\:true},"xdc.runtime.System.XDCROOT"\:{"columnStates"\:[{"name"\:"entry","checked"\:true,"hasFormat"\:false,"format"\:null}],"hasFormats"\:false},"xdc.runtime.System"\:{"defaultViewName"\:"Raw"},"xdc.runtime.System.Raw"\:{},"ti.sysbios.family.arm.m3.Hwi.Raw"\:{},"xdc.runtime.Startup.Module"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"rtsStartupDone","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"startupBegun","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"resetFxn","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"firstFxns","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"lastFxns","checked"\:true,"hasFormat"\:false,"format"\:null}],"hasFormats"\:true},"ti.sysbios.knl.Semaphore.Basic"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"label","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"event","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"eventId","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"mode","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"count","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"pendedTasks","checked"\:true,"hasFormat"\:false,"format"\:null}],"hasFormats"\:true},"ti.sysbios.family.arm.lm4.Timer.Basic"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"halTimerHandle","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"label","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"id","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"device","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"startMode","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"runMode","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"period","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"periodType","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"intNum","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"tickFxn","checked"\:true,"hasFormat"\:false,"format"\:null},{"name"\:"arg","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"extFreq","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"hwiHandle","checked"\:true,"hasFormat"\:true,"format"\:"Hex"}],"hasFormats"\:true},"xdc.runtime.SysMin.Module"\:{"columnStates"\:[{"name"\:"address","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"outBuf","checked"\:true,"hasFormat"\:true,"format"\:"Hex"},{"name"\:"outBufIndex","checked"\:true,"hasFormat"\:true,"format"\:"Decimal"},{"name"\:"wrapped","checked"\:true,"hasFormat"\:false,"format"\:null}],"hasFormats"\:true}} rovSettings-storage={"exeMrus"\:["C\:/Tango/Software/Embedded_SW/Embedded/Debug/Embedded.out","C\:/Tango/Software/Embedded_SW/Embedded/debug_w_pmr/Embedded.out"]} rovInit-storage={"progressInfo"\:{"min"\:0,"max"\:7,"step"\:1,"notifyCount"\:6,"average"\:6,"numLoads"\:20},"autoConnectChecked"\:false,"exe"\:"C\:/Tango/Software/Embedded_SW/Embedded/Debug/Embedded.out","commLink"\:"Debugger","autoConnect"\:false,"noExe"\:false,"showIntro"\:true} diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject index 55d917f2a..d85df2927 100644 --- a/Software/Embedded_SW/Embedded/.cproject +++ b/Software/Embedded_SW/Embedded/.cproject @@ -167,7 +167,7 @@ </toolChain> </folderInfo> <sourceEntries> - <entry excluding="Drivers/FPGA/Full_Vme/ispvme/FPGA1_Full_vme.c|Drivers/FPGA/JTAG_VME|Common/protobuf-c/person-pb-c.c|JigCommands.c|PWM.c|USBCDCD.c|Message.c|Pin_config.c|src|Configuration.c|SlowMotors.c|Timer.c|Communication.c|FastMotors.c|ADCUtils.c|Drivers/I2C_Communication/Previous_Code|Drivers/L6470|Pin.c|ADCLogger.c|Drivers/I2C_Communication/Previous_Code/TestI2C|Flashstore.c|Profile.c|Drivers/I2C_Communication/I2C_Switch" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> + <entry excluding="Drivers/FPGA/Full_Vme/Handle_vme_file.c|Common/protobuf-c/person-pb-c.c|JigCommands.c|PWM.c|USBCDCD.c|Message.c|Pin_config.c|src|Configuration.c|SlowMotors.c|Timer.c|Communication.c|FastMotors.c|ADCUtils.c|Drivers/I2C_Communication/Previous_Code|Drivers/L6470|Pin.c|ADCLogger.c|Drivers/I2C_Communication/Previous_Code/TestI2C|Flashstore.c|Profile.c|Drivers/I2C_Communication/I2C_Switch" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> </sourceEntries> </configuration> </storageModule> diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index bb9119372..b87544341 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -298,6 +298,27 @@ typedef struct //S_SPI }SPI;//SPI +typedef enum +{ + FPGA1 = 0, + FPGA2 = 1, + FPGA3 = 2, +}FPGA_ID; + +typedef struct +{ + uint32_t Port; + uint8_t Pin; +}GPIO; + +typedef struct +{ + GPIO GPO_TCK; //GPO MCU->FPGA + GPIO GPO_TDI; //GPO MCU->FPGA + GPIO GPO_TMS; //GPO MCU->FPGA + GPIO GPI_TDO; //GPI FPGA->MCU +}FPGA_JTAG_GPIO; + #define SSI_SPI_TIMEOUT 1000 extern void *my_malloc(size_t _size); diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c new file mode 100644 index 000000000..dfe3d919a --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c @@ -0,0 +1,89 @@ +/* + * FPGA_Programming_Up.c + * + * Created on: Jan 23, 2019 + * Author: avi + */ + +#include "include.h" +#include <DataDef.h> +#include <driverlib/gpio.h> +#include <Drivers/Flash_Memory/FATFS/ff.h> +#include <Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h> +#include <inc/hw_memmap.h> + +extern short int main_vme(); + +FPGA_JTAG_GPIO FPGA_JTAG; + +FIL *FileHandlevme = 0; + +FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot) +{ + FRESULT fresult = FR_OK; + + switch(FPGA_Id) + { + case FPGA1: + FPGA_JTAG.GPO_TCK.Port = GPIO_PORTQ_BASE; + FPGA_JTAG.GPO_TCK.Pin = GPIO_PIN_6; + + FPGA_JTAG.GPO_TDI.Port = GPIO_PORTS_BASE; + FPGA_JTAG.GPO_TDI.Pin = GPIO_PIN_7; + + FPGA_JTAG.GPO_TMS.Port = GPIO_PORTS_BASE; + FPGA_JTAG.GPO_TMS.Pin = GPIO_PIN_5; + + FPGA_JTAG.GPI_TDO.Port = GPIO_PORTN_BASE; + FPGA_JTAG.GPI_TDO.Pin = GPIO_PIN_7; + break; + case FPGA2: + FPGA_JTAG.GPO_TCK.Port = GPIO_PORTS_BASE; + FPGA_JTAG.GPO_TCK.Pin = GPIO_PIN_6; + + FPGA_JTAG.GPO_TDI.Port = GPIO_PORTT_BASE; + FPGA_JTAG.GPO_TDI.Pin = GPIO_PIN_0; + + FPGA_JTAG.GPO_TMS.Port = GPIO_PORTT_BASE; + FPGA_JTAG.GPO_TMS.Pin = GPIO_PIN_1; + + FPGA_JTAG.GPI_TDO.Port = GPIO_PORTS_BASE; + FPGA_JTAG.GPI_TDO.Pin = GPIO_PIN_4; + break; + case FPGA3: + FPGA_JTAG.GPO_TCK.Port = GPIO_PORTH_BASE; + FPGA_JTAG.GPO_TCK.Pin = GPIO_PIN_7; + + FPGA_JTAG.GPO_TDI.Port = GPIO_PORTH_BASE; + FPGA_JTAG.GPO_TDI.Pin = GPIO_PIN_5; + + FPGA_JTAG.GPO_TMS.Port = GPIO_PORTH_BASE; + FPGA_JTAG.GPO_TMS.Pin = GPIO_PIN_6; + + FPGA_JTAG.GPI_TDO.Port = GPIO_PORTQ_BASE; + FPGA_JTAG.GPI_TDO.Pin = GPIO_PIN_7; + break; + default: + //return error + break; + } + + FileHandlevme = malloc(sizeof(FIL)); + fresult |= f_open(FileHandlevme, FullPath, FA_READ); + if(fresult != FR_OK) + { + return(fresult); + } + main_vme(); + + + + if(IncludeReboot) + { + Power_Reset();// Resets the MCU (include FPGA reset + init) + } + + return fresult; +} + + diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h new file mode 100644 index 000000000..c1b2b29ce --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h @@ -0,0 +1,15 @@ +/* + * FPGA_Programming_Up.h + * + * Created on: Jan 23, 2019 + * Author: avi + */ + +#ifndef DRIVERS_FPGA_FULL_VME_FPGA_PROGRAMMING_UP_H_ +#define DRIVERS_FPGA_FULL_VME_FPGA_PROGRAMMING_UP_H_ + +FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot); + + + +#endif /* DRIVERS_FPGA_FULL_VME_FPGA_PROGRAMMING_UP_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/hardware.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/hardware.c index 71a4d68d6..2000df29c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/hardware.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/hardware.c @@ -125,7 +125,7 @@ void calibration(void); // _outp( g_usOutPort, g_siIspPins ); // */ //} - +/* void writePort( unsigned char a_ucPins, unsigned char a_ucValue ) { uint8_t PinId = 0; @@ -159,6 +159,38 @@ void writePort( unsigned char a_ucPins, unsigned char a_ucValue ) else ROM_GPIOPinWrite(PortId, PinId, 0); //Turn OFF the requested GPIO } +*/ +extern FPGA_JTAG_GPIO FPGA_JTAG; + +void writePort( unsigned char a_ucPins, unsigned char a_ucValue ) +{ + GPIO Gpio; + + switch(a_ucPins) + { + case pinTCK: + Gpio.Port = FPGA_JTAG.GPO_TCK.Port; + Gpio.Pin = FPGA_JTAG.GPO_TCK.Pin; + break; + case pinTDI: + Gpio.Port = FPGA_JTAG.GPO_TDI.Port; + Gpio.Pin = FPGA_JTAG.GPO_TDI.Pin; + break; + case pinTMS: + Gpio.Port = FPGA_JTAG.GPO_TMS.Port; + Gpio.Pin = FPGA_JTAG.GPO_TMS.Pin; + break; + case pinENABLE: //always enabled + case pinTRST: //N/A + default: + return; + } + + if(a_ucValue) + ROM_GPIOPinWrite(Gpio.Port, Gpio.Pin, Gpio.Pin); //Turn ON the requested GPIO + else + ROM_GPIOPinWrite(Gpio.Port, Gpio.Pin, 0); //Turn OFF the requested GPIO +} /********************************************************************************* * @@ -167,18 +199,19 @@ void writePort( unsigned char a_ucPins, unsigned char a_ucValue ) * Returns the value of the TDO from the device. * **********************************************************************************/ +/* unsigned char readPort() { unsigned char ucRet = 0x00; - /* This is a sample code for Windows/DOS - if ( _inp( g_usInPort ) & g_ucPinTDO ) { - ucRet = 0x01; - } - else { - ucRet = 0x00; - } - */ +// This is a sample code for Windows/DOS +// if ( _inp( g_usInPort ) & g_ucPinTDO ) { +// ucRet = 0x01; +// } +// else { +// ucRet = 0x00; +// } +// //return ( ucRet ); //FPGA 1: if(ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_7)) @@ -187,6 +220,16 @@ unsigned char readPort() return ( ucRet ); } +*/ +unsigned char readPort() +{ + unsigned char ucRet = 0x00; + + if(ROM_GPIOPinRead(FPGA_JTAG.GPI_TDO.Port, FPGA_JTAG.GPI_TDO.Pin)) + ucRet = 0x01; + + return ( ucRet ); +} /********************************************************************************* * sclock diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/Handle_vme_file.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/Handle_vme_file.c deleted file mode 100644 index a3d8ebbcb..000000000 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/Handle_vme_file.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Handle_vme_file.c - * - * Created on: Dec 13, 2018 - * Author: avi - */ -#include "include.h" -#include "Communication/CommunicationTask.h" -#include <DataDef.h> - - -#include "third_party/fatfs/src/ffconf.h" -#include "third_party/fatfs/src/diskio.h" -#include "drivers/Flash_Memory/Flash_Memory.h" -#include "drivers/Flash_Memory/fatfs/ff.h" - -#include "third_party/fatfs/src/ffconf.h" - -#include <Communication/PMR/IO/FileInfo.pb-c.h> - -extern unsigned char g_pucAlgoArray[]; - -//FIL *FileHandle = 0; //the system supports a single active file -char FileHandleChar[5]; -char ErrorMsg[100]; -#define MAX_CHUNK_LENGTH 2000 -//int FileLength = 0; -//int FileReceivedLength = 0; -static char g_cCwdBuf[50] = "/"; -//uint32_t WrittenBytes = 0; - -int Vme1_index = -1; - -uint32_t Read_vme_from_flash() -{ - //fs.Read(chunk,0,chunk.Length); - - return 0; -} - -FileInfo Data[10]; -extern int g_iAlgoSize; - -uint32_t GetFiles() -{ - //uint32_t status = OK; - - //MessageContainer responseContainer; - - //GetFilesRequest* request = get_files_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); - - //GetFilesResponse response = GET_FILES_RESPONSE__INIT; - char *path; - FIL* Fo; - - path = "0://Shlomo"; - - #define MAX_NUM_OF_FILES 5 - DIR dir; - FILINFO* fno[MAX_NUM_OF_FILES]; - int i,NumOfFiles = 0; - FRESULT Fresult = FR_OK; - - Fresult |= f_opendir(&dir, path); - if(Fresult != FR_OK) - { - return(Fresult); - } - - memset (fno,0,sizeof(fno)); - FileInfo **FilesInfo = (FileInfo**)my_malloc(sizeof(FileInfo *)*(MAX_NUM_OF_FILES)); - //FileInfo Data[MAX_NUM_OF_FILES]; - memset(fno,0,sizeof(fno)); - fno[0] = my_malloc(sizeof(FILINFO)); - memset (fno[0],0,sizeof(FILINFO)); - - Fresult = f_stat(path,fno[0]); - if (Fresult == FR_OK) - { - if (isDirectory(fno[0]->fattrib)) - { - NumOfFiles++; - //============================ - Fresult = f_opendir(&dir, path); /* Open the directory */ - if (Fresult == FR_OK) - { - for (NumOfFiles = 1;NumOfFiles < MAX_NUM_OF_FILES;NumOfFiles++) - { - fno[NumOfFiles] = my_malloc(sizeof(FILINFO)); - memset (fno[NumOfFiles],0,sizeof(FILINFO)); - Fresult = f_readdir(&dir, fno[NumOfFiles]); /* Read a directory item */ - if (Fresult == FR_OK) - { - if(fno[NumOfFiles]->fname[0] ==0) - { - break; - } - } - } - } - } - else - { - Fresult = FR_DENIED; - } - } - - if ((Fresult == FR_OK)&&(NumOfFiles)) - { - for (i = 0;i < NumOfFiles;i++) - { - file_info__init(&Data[i]); - FilesInfo[i] = &Data[i]; - Data[i].has_attribute = true; - Data[i].attribute = fno[i]->fattrib; - Data[i].has_length = true; - Data[i].name = fno[i]->fname; - Data[i].has_length = true; - Data[i].length = fno[i]->fsize; - Data[i].lastmodifieddate = fno[i]->fdate; - Data[i].lastmodifiedtime = fno[i]->ftime; - - char str[] = "F1_TANGO.VME"; - if( strcmp(Data[i].name,str) == 0) - { - Vme1_index = i; - - g_iAlgoSize = Data[i].length; - //memset ((char)g_pucAlgoArray,0xAA,sizeof(g_pucAlgoArray)); - int j = 0; - for(j=0;j<1000;j++) - g_pucAlgoArray[j] = 0xAA; -// Fresult |= f_open(&Fo, "0://Shlomo//F1_Tango.vme", FA_READ); -// if(Fresult != FR_OK) -// { -// //return(fresult); -// while(1); -// } - - GetVmeByte(); - break; - } - - - } - //response.n_items = NumOfFiles; - //response.items = FilesInfo; - } - else - { - //response.n_items = 0; - //response.items = NULL; - } - //responseContainer = createContainer(MESSAGE_TYPE__GetFilesResponse, requestContainer->token, false, &response, &get_files_response__pack, &get_files_response__get_packed_size); - - if (Fresult!= OK) - { - //responseContainer.error = getErrorCode(Fresult); - //responseContainer.errormessage = "File operation error"; - } - //responseContainer.continuous = false; - //uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - //size_t container_size = message_container__pack(&responseContainer, container_buffer); - //my_free(responseContainer.data.data); - //my_free(FilesInfo); - //get_files_request__free_unpacked(request,NULL); - //SendChars(container_buffer, container_size); - for (i = 0;i < NumOfFiles;i++) - { - if (fno[i]) - my_free (fno[i]); - } - return Fresult; -} - - -uint32_t ReadIndex = 0; -unsigned char Read_buf[10000]; - -FIL *FileHandlevme = 0; //the system supports a single active file - -void GetVmeByte() -{ - uint8_t no_butes= 2000,i; - BYTE s[no_butes]; - - memset(s,0,sizeof(s)); - - - - UINT rc; - - - FileHandlevme = malloc(sizeof(FIL)); - - char *path; - - - //path = "0://Shlomo"; - - DIR dir; - - FRESULT fresult = FR_OK; - -// fresult |= f_opendir(&dir, path); -// if(fresult != FR_OK) -// { -// while(1); -// } - - if(Vme1_index != -1) - { - fresult |= f_open(FileHandlevme, "0://Shlomo//F1_Tango.vme", FA_READ); - if(fresult != FR_OK) - { - //return(fresult); - while(1); - } -/* - while(1) - { - do - { - - rc = 0; - f_read(FileHandle, s, no_butes, &rc); - - for(i=0;i<no_butes;i++) - { - Read_buf[ReadIndex + i] = s[i]; - } - - ReadIndex += no_butes; - - } while((ReadIndex<10000) && (rc != 0));//EOF or error - -// if(rc !=0) -// { -// while(1); -// } - for(i=0;i<sizeof(Read_buf);i++) - g_pucAlgoArray[i] = Read_buf[i]; - - main_vme(); - - memset(Read_buf,0,sizeof(Read_buf)); - ReadIndex = 0; - - if((rc == 0)) - break; - } - */ - main_vme(); - } - -} - -// call unsigned char GetByte(int a_iCurrentIndex, char a_cAlgo) - -/* - xdata const unsigned char g_pucAlgoArray[]= {0}; - xdata const int g_iAlgoSize = 0; -*/ - -//C:\\FileSystemTests\\F1_Tango_fpga.vme diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/hardware.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/hardware.c deleted file mode 100644 index 0f96cda30..000000000 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/hardware.c +++ /dev/null @@ -1,329 +0,0 @@ -/************************************************************** -* -* Lattice Semiconductor Corp. Copyright 2008 -* -* -***************************************************************/ - - -/************************************************************** -* -* Revision History of hardware.c -* -* -* 09/11/07 NN type cast all the mismatch variables -***************************************************************/ - - -#include "opcode.h" - -#include <DataDef.h> -#include "include.h" -#include <stdbool.h> -#include <stdlib.h> -#include <stdio.h> -#include <stdint.h> -#include <string.h> -#include "inc/hw_memmap.h" -#include "inc/hw_types.h" -#include "driverlib/gpio.h" - -#include "delay.h" - - -/************************************************************* -* * -* EXTERNAL VARIABLE * -* * -*************************************************************/ - -extern short int g_siIspPins; - -/************************************************************* -* * -* EXTERNAL FUNCTION * -* * -*************************************************************/ - -extern void ispVMStateMachine( char a_cNextState ); - -/************************************************************* -* * -* READPORT * -* * -* INPUT: * -* None. * -* * -* RETURN: * -* Returns the bit read back from the device. * -* * -* DESCRIPTION: * -* This function is used to read the TDO pin from the * -* input port. * -* * -* NOTE: This function should be modified in an embedded * -* system! * -* * -*************************************************************/ - -unsigned char readPort() -{ - /* - // unsigned char ucRet = 0; - // This is a sample code for Windows/DOS - // if ( _inp( 0x379 ) & g_ucPinTDO ) { - // ucRet = 0x01; - // } - // else { - // ucRet = 0x00; - // } - - return ( ucRet ); - */ - - //FPGA 1: - if(ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_7)) - return 0x01; - else - return 0x00; -} - -/************************************************************* -* * -* WRITEPORT * -* * -* INPUT: * -* a_ucPins: a byte to indicate which pin will be * -* depending on the value. * -* * -* a_ucValue: the value to determine of the pin above * -* will be written out or not. * -* * -* RETURN: * -* None. * -* * -* DESCRIPTION: * -* To apply the specified value to the pins indicated. * -* This routine will likely be modified for specific * -* systems. As an example, this code is for the PC, as * -* described below. * -* * -* This routine uses the IBM-PC standard Parallel port, * -* along with the schematic shown in Lattice * -* documentation, to apply the signals to the programming * -* loop. * -* * -* NOTE: This function should be modified in an embedded * -* system! * -* * -*************************************************************/ - -//void writePort( unsigned char a_ucPins, unsigned char a_ucValue ) -//{ -// if ( a_ucValue ) { -// g_siIspPins = (short int) ((short int)a_ucPins | g_siIspPins); -// } -// else { -// g_siIspPins = (short int) ((short int)~a_ucPins & g_siIspPins); -// } -// /* This is a sample code for Windows/DOS without Windows Driver. -// _outp( 0x378, g_siIspPins ); -// */ -//} - - -void writePort( unsigned char a_ucPins, unsigned char a_ucValue ) -{ - uint8_t PinId = 0; - uint32_t PortId = 0; - - switch(a_ucPins) - { - case pinTCK: - //FPGA 1: - PortId = GPIO_PORTQ_BASE; - PinId = GPIO_PIN_6; - break; - case pinTDI: - //FPGA 1: - PortId = GPIO_PORTS_BASE; - PinId = GPIO_PIN_7; - break; - case pinTMS: - //FPGA 1: - PortId = GPIO_PORTS_BASE; - PinId = GPIO_PIN_5; - break; - case pinENABLE: //always enabled - case pinTRST: //N/A - default: - return; - } - - if(a_ucValue) - ROM_GPIOPinWrite(PortId, PinId, PinId); //Turn ON the requested GPIO - else - ROM_GPIOPinWrite(PortId, PinId, 0); //Turn OFF the requested GPIO -} - -/************************************************************* -* * -* ISPVMDELAY * -* * -* INPUT: * -* a_uiDelay: delay in milliseconds * -* * -* RETURN: * -* None. * -* * -* DESCRIPTION: * -* The user must implement a delay to observe a_uiDelay, * -* where a_uiDelay is the number of milliseconds that must * -* pass before data is read from in_port. Since platforms and* -* processor speeds vary greatly, this task is left to the * -* user. This subroutine is called upon to provide a delay * -* from 1 millisecond to a few hundreds milliseconds each time* -* That is the reason behind using unsigned long integer in * -* this subroutine. It is OK to provide longer delay than * -* required. It is not acceptable if the delay is shorter than* -* required. * -* * -* Note: user must re - implement to target specific hardware.* -* * -* Example: Use the for loop to create the microsecond delay. * -* Loop 1K times to produce the milliseconds delay. * -* * -* Let the CPU clock (system clock) be F Mhz. * -* * -* Let the for loop represented by the 2 lines of * -* machine code: * -* LOOP: DEC RA; * -* JNZ LOOP; * -* Let the for loop number for one microsecond be L. * -* Lets assume 4 system clocks for each line of * -* machine code. * -* Then 1 us = 1/F (microseconds per clock) * -* x (2 lines) x (4 clocks per line) x L* -* = 8L/F * -* Or L = F/8; * -* * -* Convert the unit in microseconds to * -* milliseconds. * -* L = F/8 x 1000; * -* Lets assume the CPU clock is set to 48MHZ. The C * -* code then is: * -* * -* unsigned int F = 48; //MHZ. * -* unsigned int L = F/8; //microseconds. * -* unsigned int index, m; * -* * -* * -* if (L < 1) L = 1; //minimum is i microsecond. * -* for (index=0; index < a_uiDelay * L; index++) * -* { * -* //loop 1K times to produce milliseconds delay * -* for (m=0; m<1000; m++); //milliseconds * -* } * -* return 0; * -* * -* * -*************************************************************/ - -/* the unit of a_uiDelay is milliseconds */ -void ispVMDelay( unsigned int a_uiDelay ) -{ - delayms(a_uiDelay); -} - -/************************************************************* -* * -* ENABLEHARDWARE * -* * -* INPUT: * -* None. * -* * -* RETURN: * -* None. * -* * -* DESCRIPTION: * -* This function is called to enable the hardware. * -* * -* NOTE: This function should be modified in an embedded * -* system! * -* * -*************************************************************/ - -void EnableHardware() -{ - ispVMStateMachine(RESET); -} - -/************************************************************* -* * -* DISABLEHARDWARE * -* * -* INPUT: * -* None. * -* * -* RETURN: * -* None. * -* * -* DESCRIPTION: * -* This function is called to disable the hardware. * -* * -* NOTE: This function should be modified in an embedded * -* system! * -* * -*************************************************************/ - -void DisableHardware() -{ - ispVMStateMachine(RESET); -} - - - -/********************************************************************************* -* -* calibration -* -* It is important to confirm if the delay function is indeed providing -* the accuracy required. Also one other important parameter needed -* checking is the clock frequency. -* Calibration will help to determine the system clock frequency -* and the loop_per_micro value for one micro-second delay of the target -* specific hardware. -* -**********************************************************************************/ -void calibration(void) -{ -/* - //Apply 2 pulses to TCK. - writePort( pinTCK, 0x00 ); - writePort( pinTCK, 0x01 ); - writePort( pinTCK, 0x00 ); - writePort( pinTCK, 0x01 ); - writePort( pinTCK, 0x00 ); - - //Delay for 1 millisecond. Pass on 1000 or 0x8001 both = 1ms delay. - ispVMDelay(1); - - //Apply 2 pulses to TCK - writePort( pinTCK, 0x01 ); - writePort( pinTCK, 0x00 ); - writePort( pinTCK, 0x01 ); - writePort( pinTCK, 0x00 ); -*/ - //Test pinTDI pinTMS - //writePort( pinTDI, 0x01 ); - //writePort( pinTMS, 0x01 ); - //writePort( pinTMS, 0x00 ); - -// - //writePort( pinTDI, 0x00 ); -// writePort( pinTMS, 0x00 ); - - unsigned char temp = 0; - temp = readPort(); -} - diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/opcode.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/opcode.h deleted file mode 100644 index 296ca0290..000000000 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/opcode.h +++ /dev/null @@ -1,136 +0,0 @@ - -/************************************************************** -* -* Revision History of opcode.h -* -* -* 09/11/07 NN Updated to support version 1.3 -* This version supported new POLING STATUS LOOP opcodes -* for Flash programming of the Lattice FPGA devices -* #define LOOP = 0x58 -* #define ENDLOOP = 0x59 -***************************************************************/ - - -/************************************************************* -* * -* LATTICE CABLE DEFINTIONS. * -* * -* Define these only if the lattice cable is being used. * -* * -*************************************************************/ - -#define pinTDI 1 -#define pinTCK 2 -#define pinTMS 4 -#define pinENABLE 8 -#define pinTRST 16 -#define pinCE 32 -#define pinTDO 64 - -/************************************************************* -* * -* ERROR DEFINITIONS * -* * -*************************************************************/ - -#define ERR_VERIFY_FAIL -1 //NA -#define ERR_FIND_ALGO_FILE -2 //NA -#define ERR_FIND_DATA_FILE -3 //NA -#define ERR_WRONG_VERSION -4 -#define ERR_ALGO_FILE_ERROR -5 -#define ERR_DATA_FILE_ERROR -6 -#define ERR_OUT_OF_MEMORY -7 //NA - -/************************************************************* -* * -* DATA TYPE REGISTER BIT DEFINITIONS * -* * -*************************************************************/ - -#define SIR_DATA 0x0001 /*** Current command is SIR ***/ -#define SDR_DATA 0x0002 /*** Current command is SDR ***/ -#define TDI_DATA 0x0004 /*** Command contains TDI ***/ -#define TDO_DATA 0x0008 /*** Command contains TDO ***/ -#define MASK_DATA 0x0010 /*** Command contains MASK ***/ -#define DTDI_DATA 0x0020 /*** Verification flow ***/ -#define DTDO_DATA 0x0040 /*** Verification flow ***/ -#define COMPRESS 0x0080 /*** Compressed data file ***/ -#define COMPRESS_FRAME 0x0100 /*** Compressed data frame ***/ - -/************************************************************* -* * -* USED JTAG STATE * -* * -*************************************************************/ - -#define RESET 0x00 -#define IDLE 0x01 -#define IRPAUSE 0x02 -#define DRPAUSE 0x03 -#define SHIFTIR 0x04 -#define SHIFTDR 0x05 -#define DRCAPTURE 0x06 - -/************************************************************* -* * -* VME OPCODE DEFINITIONS * -* * -* These are the opcodes found in the VME file. Although * -* most of them are similar to SVF commands, a few opcodes * -* are available only in VME format. * -* * -*************************************************************/ - -#define STATE 0x10 -#define SIR 0x11 -#define SDR 0x12 -#define TCK 0x1B -#define WAIT_FOR 0x1A -#define ENDDR 0x02 -#define ENDIR 0x03 -#define HIR 0x06 -#define TIR 0x07 -#define HDR 0x08 -#define TDR 0x09 -#define TDI 0x13 -#define CONTINUE_FOR 0x70 -#define TDO 0x14 -#define MASK 0x15 -#define LOOP 0x58 -#define ENDLOOP 0x59 -#define LCOUNT 0x66 -#define LDELAY 0x67 -#define LSDR 0x68 -#define ENDSTATE 0x69 -#define ENDVME 0x7F - -/************************************************************* -* * -* Begin future opcodes at 0xA0 to avoid conflict with Full * -* VME opcodes. * -* * -*************************************************************/ - -#define BEGIN_REPEAT 0xA0 -#define END_REPEAT 0xA1 -#define END_FRAME 0xA2 -#define DATA 0xA3 -#define PROGRAM 0xA4 -#define VERIFY 0xA5 -#define DTDI 0xA6 -#define DTDO 0xA7 - -/************************************************************* -* * -* Opcode for discrete pins toggling * -* * -*************************************************************/ -#define signalENABLE 0x1C /*assert the ispEN pin*/ -#define signalTMS 0x1D /*assert the MODE or TMS pin*/ -#define signalTCK 0x1E /*assert the SCLK or TCK pin*/ -#define signalTDI 0x1F /*assert the SDI or TDI pin*/ -#define signalTRST 0x20 /*assert the RESET or TRST pin*/ -#define signalTDO 0x21 /*assert the RESET or TDO pin*/ -#define signalCableEN 0x22 /*assert the RESET or CableEN pin*/ - diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/slim_pro.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/slim_pro.c deleted file mode 100644 index 8812003ab..000000000 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/slim_pro.c +++ /dev/null @@ -1,1483 +0,0 @@ -/************************************************************** -* -* Lattice Semiconductor Corp. Copyright 2008 -* -* -***************************************************************/ - - -/************************************************************** -* -* Revision History of slim_pro.c -* -* -* 09/11/07 NN Updated to support version 1.3 -* This version supported new POLING STATUS LOOP opcodes (LOOP and ENDLOOP) -* for Flash programming of the Lattice FPGA devices -* 09/11/07 NN type cast all the mismatch variables -***************************************************************/ - - -#include <stdio.h> -#include "opcode.h" -#include "include.h" -/************************************************************* -* * -* PROTOTYPES * -* * -*************************************************************/ - -unsigned int ispVMDataSize(); -short int ispVMShiftExec(unsigned int a_uiDataSize); -short int ispVMShift(char a_cCommand); -unsigned char GetByte(int a_iCurrentIndex, char a_cAlgo); -void ispVMStateMachine(char a_cNextState); -void ispVMClocks(unsigned int a_usClocks); -void ispVMBypass(unsigned int a_siLength); -void sclock(); -short int ispVMRead(unsigned int a_uiDataSize); -void ispVMSend(unsigned int a_uiDataSize); -void ispVMLCOUNT(unsigned short a_usCountSize); -void ispVMLDELAY(); - -#include "drivers/Flash_Memory/fatfs/ff.h" -/************************************************************* -* * -* EXTERNAL FUNCTION * -* * -*************************************************************/ - -extern void ispVMDelay(unsigned int a_usDelay); -extern unsigned char readPort(); -extern void writePort(unsigned char a_ucPins, unsigned char a_ucValue); - -/************************************************************* -* * -* GLOBAL VARIABLES * -* * -*************************************************************/ -int g_iMovingAlgoIndex = 0; /*** variable to hold the current index in the algo array ***/ -int g_iMovingDataIndex = 0; /*** variable to hold the current index in the data array ***/ -unsigned short g_usDataType = 0x0000; /*** data type register used to hold information *** - **** about the algorithm and data ***/ -unsigned char g_cEndDR = 0; /*** used to hold the ENDDR state. ***/ -unsigned char g_cEndIR = 0; /*** used to hold the ENDIR state. ***/ -short int g_siHeadDR = 0; /*** used to hold the header data register ***/ -short int g_siHeadIR = 0; /*** used to hold the header instruction register ***/ -short int g_siTailDR = 0; /*** used to hold the trailer data register ***/ -short int g_siTailIR = 0; /*** used to hold the trailer instruction register ***/ - -int g_iMainDataIndex = 0; /*** forward - only index used as a placed holder in the data array ***/ -int g_iRepeatIndex = 0; /*** Used to point to the location of REPEAT data ***/ -int g_iTDIIndex = 0; /*** Used to point to the location of TDI data ***/ -int g_iTDOIndex = 0; /*** Used to point to the location of TDO data ***/ -int g_iMASKIndex = 0; /*** Used to point to the location of MASK data ***/ -unsigned char g_ucCompressCounter = 0; /*** used to indicate how many times 0xFF is repeated ***/ - -short int g_siIspPins = 0x00; /*** holds the current byte to be sent to the hardware ***/ -char g_cCurrentJTAGState = 0; /*** holds the current state of JTAG state machine ***/ - -int g_iLoopIndex = 0; -int g_iLoopMovingIndex = 0; /*** Used to point to the location of LOOP data ***/ -int g_iLoopDataMovingIndex = 0; - -unsigned short g_usLCOUNTSize = 0; -unsigned char g_ucLDELAYState = IDLE; -unsigned short int g_ucLDELAYTCK = 0; -unsigned short int g_ucLDELAYDelay = 0; -unsigned short int m_loopState = 0; - -/************************************************************* -* * -* EXTERNAL VARIABLES * -* * -* If the algorithm does not require the data, then * -* declare the variables g_pucDataArray and g_iDataSize * -* as local variables and set them to NULL and 0, * -* respectively. * -* * -* Example: * -* xdata unsigned char * g_pucDataArray = NULL; * -* xdata int g_iDataSize = 0; * -* * -*************************************************************/ -#define max_index 10000 -/*xdata const */ unsigned char g_pucAlgoArray[max_index]; -/*xdata const *//*unsigned char g_pucDataArray[]= {0};*/const unsigned char * g_pucDataArray = NULL; //AVI+ -/*xdata const*/ int g_iAlgoSize = 0; -/*xdata*/ const int g_iDataSize = 0; - -/*xdata*/ const struct iState -{ - /*** JTAG state machine transistion table ***/ - unsigned char CurState; /*** From this state ***/ - unsigned char NextState; /*** Step to this state ***/ - unsigned char Pattern; /*** The pattern of TMS ***/ - unsigned char Pulses; /*** The number of steps ***/ -} iStates[25] = -{ - { DRPAUSE, SHIFTDR, 0x80, 2 }, - { IRPAUSE, SHIFTIR, 0x80, 2 }, - { SHIFTIR, IRPAUSE, 0x80, 2 }, - { SHIFTDR, DRPAUSE, 0x80, 2 }, - { DRPAUSE, IDLE, 0xC0, 3 }, - { IRPAUSE, IDLE, 0xC0, 3 }, - { RESET, IDLE, 0x00, 1 }, - { RESET, DRPAUSE, 0x50, 5 }, - { RESET, IRPAUSE, 0x68, 6 }, - { IDLE, RESET, 0xE0, 3 }, - { IDLE, DRPAUSE, 0xA0, 4 }, - { IDLE, IRPAUSE, 0xD0, 5 }, - { DRPAUSE, RESET, 0xF8, 5 }, - { DRPAUSE, IRPAUSE, 0xF4, 7 }, - { DRPAUSE, DRPAUSE, 0xE8, 6 }, /* 06/14/06 Support POLING STATUS LOOP*/ - { IRPAUSE, RESET, 0xF8, 5 }, - { IRPAUSE, DRPAUSE, 0xE8, 6 }, - { IRPAUSE, SHIFTDR, 0xE0, 5 }, - { SHIFTIR, IDLE, 0xC0, 3 }, - { SHIFTDR, IDLE, 0xC0, 3 }, - { RESET, RESET, 0xFC, 6 }, - { DRPAUSE, DRCAPTURE, 0xE0, 4 }, /* 11/15/05 Support DRCAPTURE*/ - { DRCAPTURE, DRPAUSE, 0x80, 2 }, - { IDLE, DRCAPTURE, 0x80, 2 }, - { IRPAUSE, DRCAPTURE, 0xE0, 4 } -}; -/************************************************************* -* * -* ISPPROCESSVME * -* * -* INPUT: * -* None. * -* * -* RETURN: * -* The return value indicates whether the vme was * -* processed successfully or not. A return value equal * -* to or greater than 0 is passing, and less than 0 is * -* failing. * -* * -* DESCRIPTION: * -* This function is the core of the embedded processor. * -* It extracts the VME file for the high - level tokens * -* such as SIR, SDR, STATE, etc, and calls the * -* appropriate functions to process them. * -* * -*************************************************************/ -unsigned char EOF_Flag = 0; // AVI + - -unsigned char nop = 0; // AVI + - -short int ispProcessVME() //reentrant -{ - unsigned char ucOpcode = 0; - unsigned char ucState = 0; - short int siRetCode = 0; - static char cProgram = 0; - unsigned int uiDataSize = 0; - int iLoopCount = 0; - unsigned int iMovingAlgoIndex = 0; - - /************************************************************* - * * - * Begin processing the vme algorithm and data files. * - * * - *************************************************************/ - //while (ucOpcode = GetByte(g_iMovingAlgoIndex++, 1) != 0xFF) - //while (EOF_Flag==0) // AVI + - while(1) // AVI + - { - ucOpcode = GetByte(g_iMovingAlgoIndex++, 1); // AVI + - /************************************************************* - * * - * This switch statement is the main switch that represents * - * the core of the embedded processor. * - * * - *************************************************************/ - - switch (ucOpcode) - { - case STATE: - /************************************************************* - * * - * Move the state. * - * * - *************************************************************/ - ispVMStateMachine(GetByte(g_iMovingAlgoIndex++, 1)); - break; - case SIR: - /************************************************************* - * * - * Execute SIR/SDR command. * - * * - *************************************************************/ - siRetCode = ispVMShift(ucOpcode); - if (siRetCode < 0) - { - while(1);//avi+ - } - break; - case SDR: - /************************************************************* - * * - * Execute SIR/SDR command. * - * * - *************************************************************/ - siRetCode = ispVMShift(ucOpcode); - if (siRetCode < 0) - { - while(1);//avi+ - } - break; - case TCK: - /************************************************************* - * * - * Pulse TCK signal the specified time. * - * * - *************************************************************/ - ispVMClocks(ispVMDataSize()); - break; - case WAIT_FOR: - /************************************************************* - * * - * Issue delay in specified time. * - * * - *************************************************************/ - ispVMDelay(ispVMDataSize()); - break; - case ENDDR: - /************************************************************* - * * - * Get the ENDDR state and store in global variable. * - * * - *************************************************************/ - g_cEndDR = GetByte(g_iMovingAlgoIndex++, 1); - break; - case ENDIR: - /************************************************************* - * * - * Get the ENDIR state and store in global variable. * - * * - *************************************************************/ - g_cEndIR = GetByte(g_iMovingAlgoIndex++, 1); - break; - case HIR: - g_siHeadIR = (short int) ispVMDataSize(); - break; - case TIR: - g_siTailIR = (short int) ispVMDataSize(); - break; - case HDR: - g_siHeadDR = (short int) ispVMDataSize(); - - break; - case TDR: - g_siTailDR = (short int) ispVMDataSize(); - - break; - case BEGIN_REPEAT: - /************************************************************* - * * - * Execute repeat loop. * - * * - *************************************************************/ - - uiDataSize = ispVMDataSize(); - - switch (GetByte(g_iMovingAlgoIndex++, 1)) - { - case PROGRAM: - /************************************************************* - * * - * Set the main data index to the moving data index. This * - * allows the processor to remember the beginning of the * - * data. Set the cProgram variable to true to indicate to * - * the verify flow later that a programming flow has been * - * completed so the moving data index must return to the * - * main data index. * - * * - *************************************************************/ - g_iMainDataIndex = g_iMovingDataIndex; - cProgram = 1; - break; - case VERIFY: - /************************************************************* - * * - * If the static variable cProgram has been set, then return * - * the moving data index to the main data index because this * - * is a erase, program, verify operation. If the programming * - * flag is not set, then this is a verify only operation thus * - * no need to return the moving data index. * - * * - *************************************************************/ - if (cProgram) - { - g_iMovingDataIndex = g_iMainDataIndex; - cProgram = 0; - } - break; - } - - /************************************************************* - * * - * Set the repeat index to the first byte in the repeat loop. * - * * - *************************************************************/ - - g_iRepeatIndex = g_iMovingAlgoIndex; - - for (; uiDataSize > 0; uiDataSize--) - { - /************************************************************* - * * - * Initialize the current algorithm index to the beginning of * - * the repeat index before each repeat loop. * - * * - *************************************************************/ - - g_iMovingAlgoIndex = g_iRepeatIndex; - - /************************************************************* - * * - * Make recursive call. * - * * - *************************************************************/ - - siRetCode = ispProcessVME(); - if (siRetCode < 0) - { - while(1);//avi+ - break; - } - } - break; - case END_REPEAT: - /************************************************************* - * * - * Exit the current repeat frame. * - * * - *************************************************************/ - while(1);//avi+ - return siRetCode; - //break; - case LOOP: - /************************************************************* - * * - * Execute repeat loop. * - * * - *************************************************************/ - - g_usLCOUNTSize = (short int)ispVMDataSize(); - -#ifdef VME_DEBUG - printf( "MaxLoopCount %d\n", g_usLCOUNTSize ); -#endif - /************************************************************* - * * - * Set the repeat index to the first byte in the repeat loop. * - * * - *************************************************************/ - - g_iLoopMovingIndex = g_iMovingAlgoIndex; - g_iLoopDataMovingIndex = g_iMovingDataIndex; - - - for ( g_iLoopIndex = 0 ; g_iLoopIndex < g_usLCOUNTSize; g_iLoopIndex++ ) { - m_loopState = 1; - /************************************************************* - * * - * Initialize the current algorithm index to the beginning of * - * the repeat index before each repeat loop. * - * * - *************************************************************/ - - g_iMovingAlgoIndex = g_iLoopMovingIndex; - g_iMovingDataIndex = g_iLoopDataMovingIndex; - - - /************************************************************* - * * - * Make recursive call. * - * * - *************************************************************/ - - siRetCode = ispProcessVME(); - if ( !siRetCode ) { - /************************************************************* - * * - * Stop if the complete status matched. * - * * - *************************************************************/ - //while(1);//avi+ - break; - } - } - m_loopState = 0; - - if (siRetCode != 0) { - /************************************************************* - * * - * Return if the complete status error. * - * * - *************************************************************/ - while(1);//avi+ - return (siRetCode); - } - break; - case ENDLOOP: - /************************************************************* - * * - * End the current loop. * - * * - *************************************************************/ - if(m_loopState) - { - //while(1);//avi+ - return siRetCode; - } - break; - case ENDVME: - /************************************************************* - * * - * If the ENDVME token is found and g_iMovingAlgoIndex is * - * greater than or equal to g_iAlgoSize, then that indicates * - * the end of the chain. If g_iMovingAlgoIndex is less than * - * g_iAlgoSize, then that indicates that there are still more * - * devices to be processed. * - * * - *************************************************************/ - if (g_iMovingAlgoIndex >= g_iAlgoSize) - { - while(1);//avi+ - return siRetCode; - } - break; - case LCOUNT: - /************************************************************* - * * - * Get the Maximum LoopCount and store in global variable. * - * * - *************************************************************/ - ispVMLCOUNT((unsigned short) ispVMDataSize()); - break; - case LDELAY: - /************************************************************* - * * - * Get the State,TCK number and Delay time for the poling loop* - * and store in global variable. * - * * - *************************************************************/ - ispVMLDELAY(); - break; - case LSDR: - /************************************************************* - * * - * Execute repeat poling status loop. * - * * - *************************************************************/ - iMovingAlgoIndex = g_iMovingAlgoIndex; - for (iLoopCount = 0; iLoopCount < g_usLCOUNTSize; iLoopCount++) - { - siRetCode = ispVMShift(SDR); - if (!siRetCode) - { - while(1);//avi+ - break; - } - /************************************************************* - * * - * If the status is not done, then move to the setting State * - * execute the delay and come back and do the checking again * - * * - *************************************************************/ - g_iMovingAlgoIndex = iMovingAlgoIndex; - ispVMStateMachine(DRPAUSE); - m_loopState = 1; - ispVMStateMachine(g_ucLDELAYState); - m_loopState = 0; - ispVMClocks(g_ucLDELAYTCK); - ispVMDelay(g_ucLDELAYDelay); - } - if (siRetCode != 0) - { - while(1);//avi+ - return (siRetCode); - } - break; - case signalENABLE: - /****************************************************************** - * Toggle ispENABLE signal * - * * - ******************************************************************/ - ucState = GetByte(g_iMovingAlgoIndex++, 1); - if (ucState == 0x01) - writePort(pinENABLE, 0x01); - else - writePort(pinENABLE, 0x00); - ispVMDelay(1); - break; - case signalTRST: - /****************************************************************** - * Toggle TRST signal * - * * - ******************************************************************/ - ucState = GetByte(g_iMovingAlgoIndex++, 1); - if (ucState == 0x01) - writePort(pinTRST, 0x01); - else - writePort(pinTRST, 0x00); - ispVMDelay(1); - break; - default: - /************************************************************* - * * - * Unrecognized opcode. Return with file error. * - * * - *************************************************************/ - while(1);//avi+ - return ERR_ALGO_FILE_ERROR; - //if((ucOpcode == 0x32) || (ucOpcode == 0x2E) || (ucOpcode == 0x31))///avi+ - // { - - //} - // else - //{ - // while(1);//avi+ - // return ERR_ALGO_FILE_ERROR;////avi- - // } - // nop++; - - } - - if (siRetCode < 0) - { - while(1);//avi+ - return siRetCode; - } - } - while(1);//avi+ - return ERR_ALGO_FILE_ERROR;//avi- -} - -/************************************************************* -* * -* ISPVMDATASIZE * -* * -* INPUT: * -* None. * -* * -* RETURN: * -* This function returns a number indicating the size of * -* the instruction. * -* * -* DESCRIPTION: * -* This function returns a number. The number is the * -* value found in SVF commands such as SDR, SIR, HIR, and * -* etc. For example: * -* SDR 200 TDI(FFF..F); * -* The return value would be 200. * -* * -*************************************************************/ - -unsigned int ispVMDataSize() -{ - unsigned int uiSize = 0; - unsigned char ucCurrentByte = 0; - unsigned char ucIndex = 0; - - while ((ucCurrentByte = GetByte(g_iMovingAlgoIndex++, 1)) & 0x80) - { - uiSize |=((unsigned int)(ucCurrentByte & 0x7F)) << ucIndex; - ucIndex += 7; - } - uiSize |=((unsigned int)(ucCurrentByte & 0x7F)) << ucIndex; - return uiSize; -} - -/************************************************************* -* * -* ISPVMSHIFTEXEC * -* * -* INPUT: * -* a_uiDataSize: this holds the size of the command. * -* * -* RETURN: * -* Returns 0 if passing, -1 if failing. * -* * -* DESCRIPTION: * -* This function handles the data in the SIR/SDR commands * -* by either decompressing the data or setting the * -* respective indexes to point to the appropriate * -* location in the algo or data array. Note that data * -* only comes after TDI, DTDI, TDO, DTDO, and MASK. * -* * -*************************************************************/ - -short int ispVMShiftExec(unsigned int a_uiDataSize) -{ - unsigned char ucDataByte = 0; - - /************************************************************* - * * - * Reset the data type register. * - * * - *************************************************************/ - - g_usDataType &= ~(TDI_DATA + TDO_DATA + MASK_DATA + DTDI_DATA + DTDO_DATA + COMPRESS_FRAME); - - /************************************************************* - * * - * Convert the size from bits to byte. * - * * - *************************************************************/ - - if (a_uiDataSize % 8) - { - a_uiDataSize = a_uiDataSize / 8 + 1; - } - else - { - a_uiDataSize = a_uiDataSize / 8; - } - - /************************************************************* - * * - * Begin extracting the command. * - * * - *************************************************************/ - - while ((ucDataByte = GetByte(g_iMovingAlgoIndex++, 1)) != CONTINUE_FOR) - { - switch (ucDataByte) - { - case TDI: - /************************************************************* - * * - * Set data type register to indicate TDI data and set TDI * - * index to the current algorithm location. * - * * - *************************************************************/ - g_usDataType |= TDI_DATA; - g_iTDIIndex = g_iMovingAlgoIndex; - g_iMovingAlgoIndex += a_uiDataSize; - break; - case DTDI: - /************************************************************* - * * - * Set data type register to indicate DTDI data and check the * - * next byte to make sure it's the DATA byte. DTDI indicates * - * that the data should be read from the data array, not the * - * algo array. * - * * - *************************************************************/ - g_usDataType |= DTDI_DATA; - if (GetByte(g_iMovingAlgoIndex++, 1) != DATA) - { - while(1);//avi+ - return ERR_ALGO_FILE_ERROR; - } - - /************************************************************* - * * - * If the COMPRESS flag is set, read the next byte from the * - * data file array. If the byte is true, then that indicates * - * the frame was compressable. Note that even though the * - * overall data file was compressed, certain frames may not * - * be compressable that is why this byte must be checked. * - * * - *************************************************************/ - if (g_usDataType & COMPRESS) - { - if (GetByte(g_iMovingDataIndex++, 0)) - { - g_usDataType |= COMPRESS_FRAME; - } - } - break; - case TDO: - /************************************************************* - * * - * Set data type register to indicate TDO data and set TDO * - * index to the current algorithm location. * - * * - *************************************************************/ - g_usDataType |= TDO_DATA; - g_iTDOIndex = g_iMovingAlgoIndex; - g_iMovingAlgoIndex += a_uiDataSize; - break; - case DTDO: - /************************************************************* - * * - * Set data type register to indicate DTDO data and check the * - * next byte to make sure it's the DATA byte. DTDO indicates * - * that the data should be read from the data array, not the * - * algo array. * - * * - *************************************************************/ - g_usDataType |= DTDO_DATA; - if (GetByte(g_iMovingAlgoIndex++, 1) != DATA) //avi- - { - while(1);//avi+ - return ERR_ALGO_FILE_ERROR; - } - - /************************************************************* - * * - * If the COMPRESS flag is set, read the next byte from the * - * data file array. If the byte is true, then that indicates * - * the frame was compressable. Note that even though the * - * overall data file was compressed, certain frames may not * - * be compressable that is why this byte must be checked. * - * * - *************************************************************/ - if (g_usDataType & COMPRESS) - { - if (GetByte(g_iMovingDataIndex++, 0)) - { - g_usDataType |= COMPRESS_FRAME; - } - } - break; - case MASK: - /************************************************************* - * * - * Set data type register to indicate MASK data. Set MASK * - * location index to current algorithm array position. * - * * - *************************************************************/ - g_usDataType |= MASK_DATA; - g_iMASKIndex = g_iMovingAlgoIndex; - g_iMovingAlgoIndex += a_uiDataSize; - break; - default: - /************************************************************* - * * - * Unrecognized or misplaced opcode. Return error. * - * * - *************************************************************/ - - while(1);////avi+ - return ERR_ALGO_FILE_ERROR; - } - } - - /************************************************************* - * * - * Reached the end of the instruction. Return passing. * - * * - *************************************************************/ - - return 0; -} - -/************************************************************* -* * -* ISPVMSHIFT * -* * -* INPUT: * -* a_cCommand: this argument specifies either the SIR or * -* SDR command. * -* * -* RETURN: * -* The return value indicates whether the SIR/SDR was * -* processed successfully or not. A return value equal * -* to or greater than 0 is passing, and less than 0 is * -* failing. * -* * -* DESCRIPTION: * -* This function is the entry point to execute an SIR or * -* SDR command to the device. * -* * -*************************************************************/ - -short int ispVMShift(char a_cCommand) -{ - short int siRetCode = 0; - unsigned int uiDataSize = ispVMDataSize(); - - /************************************************************* - * * - * Clear any existing SIR/SDR instructions from the data type * - * register. * - * * - *************************************************************/ - - g_usDataType &= ~(SIR_DATA + SDR_DATA); - - /************************************************************* - * * - * Move state machine to appropriate state depending on the * - * command. Issue bypass if needed. * - * * - *************************************************************/ - - switch (a_cCommand) - { - case SIR: - /************************************************************* - * * - * Set the data type register to indicate that it's executing * - * an SIR instruction. Move state machine to IRPAUSE, * - * SHIFTIR. If header instruction register exists, then * - * issue bypass. * - * * - *************************************************************/ - g_usDataType |= SIR_DATA; - ispVMStateMachine(IRPAUSE); - ispVMStateMachine(SHIFTIR); - if (g_siHeadIR > 0) - { - ispVMBypass(g_siHeadIR); - sclock(); - } - break; - case SDR: - /************************************************************* - * * - * Set the data type register to indicate that it's executing * - * an SDR instruction. Move state machine to DRPAUSE, * - * SHIFTDR. If header data register exists, then issue * - * bypass. * - * * - *************************************************************/ - g_usDataType |= SDR_DATA; - ispVMStateMachine(DRPAUSE); - ispVMStateMachine(SHIFTDR); - if (g_siHeadDR > 0) - { - ispVMBypass(g_siHeadDR); - sclock(); - } - break; - }//switch (a_cCommand) - - /************************************************************* - * * - * Set the appropriate index locations. If error then return * - * error code immediately. * - * * - *************************************************************/ - - siRetCode = ispVMShiftExec(uiDataSize); - - if (siRetCode < 0) - { - while(1);//avi+ - return siRetCode; - } - - /************************************************************* - * * - * Execute the command to the device. If TDO exists, then * - * read from the device and verify. Else only TDI exists * - * which must send data to the device only. * - * * - *************************************************************/ - - if ((g_usDataType & TDO_DATA) ||(g_usDataType & DTDO_DATA)) - { - siRetCode = ispVMRead(uiDataSize); -// if (siRetCode < 0) -// { -// while(1);//avi+ -// } - - /************************************************************* - * * - * A frame of data has just been read and verified. If the * - * DTDO_DATA flag is set, then check to make sure the next * - * byte in the data array, which is the last byte of the * - * frame, is the END_FRAME byte. * - * * - *************************************************************/ - if (g_usDataType & DTDO_DATA) - { - if (GetByte(g_iMovingDataIndex++, 0) != END_FRAME) - { - while(1);//avi+ - siRetCode = ERR_DATA_FILE_ERROR; - } - } - } - else - { - ispVMSend(uiDataSize); - /************************************************************* - * * - * A frame of data has just been sent. If the DTDI_DATA flag * - * is set, then check to make sure the next byte in the data * - * array, which is the last byte of the frame, is the * - * END_FRAME byte. * - * * - *************************************************************/ - if (g_usDataType & DTDI_DATA) - { - if (GetByte(g_iMovingDataIndex++, 0) != END_FRAME) - { - while(1);//avi+ - siRetCode = ERR_DATA_FILE_ERROR; - } - } - } - - /************************************************************* - * * - * Bypass trailer if it exists. Move state machine to * - * ENDIR/ENDDR state. * - * * - *************************************************************/ - - switch (a_cCommand) - { - case SIR: - if (g_siTailIR > 0) - { - sclock(); - ispVMBypass(g_siTailIR); - } - ispVMStateMachine(g_cEndIR); - break; - case SDR: - if (g_siTailDR > 0) - { - sclock(); - ispVMBypass(g_siTailDR); - } - ispVMStateMachine(g_cEndDR); - break; - } - - return siRetCode; -} - -/************************************************************* -* * -* GETBYTE * -* * -* INPUT: * -* a_iCurrentIndex: the current index to access. * -* * -* a_cAlgo: 1 if the return byte is to be retrieved from * -* the algorithm array, 0 if the byte is to be retrieved * -* from the data array. * -* * -* RETURN: * -* This function returns a byte of data from either the * -* algorithm or data array. It returns -1 if out of * -* bounds. * -* * -*************************************************************/ -extern FIL *FileHandlevme; - -unsigned char debug_temp_buf[max_index] ; - -unsigned char GetByte(int a_iCurrentIndex, char a_cAlgo) -{ - unsigned char ucData = 0; - UINT rc; - BYTE s[1]; - static unsigned char comments = 0; - - if (a_cAlgo) - { - /************************************************************* - * * - * If the current index is still within range, then return * - * the next byte. If it is out of range, then return -1. * - * * - *************************************************************/ - /* - if (a_iCurrentIndex >= g_iAlgoSize) - { - return (unsigned char) 0xFF; - } - ucData = (unsigned char) g_pucAlgoArray[a_iCurrentIndex]; - */ - //AVI - /* f_read(FileHandlevme, s, 1, &rc); - - while(comments == 0) // read until the first command (HDR 0 ;) - { - if (s[0] !=0x10) - { - f_read(FileHandlevme, s, 1, &rc); - } - else - { - comments = 1; - } - } - - - if(rc == 0) - { - - EOF_Flag =1; - return (unsigned char) 0xFF; - } - else - { - ucData = s[0]; - g_pucAlgoArray[a_iCurrentIndex] = s[0];// in order to check how many bytes I read - }*/ - - /* while(comments == 0) // read until the first command (HDR 0 ;) - { - if (s[0] !=0x10) - { - f_read(FileHandlevme, s, 1, &rc); - } - else - { - comments = 1; - g_pucAlgoArray[0] = 0x10; - return g_pucAlgoArray[0]; - } - }*/ - - static unsigned int counter = 0,local_index; - - if(counter == 0) //first time or read all - { - memset(g_pucAlgoArray,0xFF,sizeof(g_pucAlgoArray)); - memset(debug_temp_buf,0xFF,sizeof(debug_temp_buf)); - //g_pucAlgoArray[0] = 0x10; - f_read(FileHandlevme, g_pucAlgoArray,max_index , &rc); - counter = max_index; - } - - local_index = a_iCurrentIndex % max_index; - ucData = (unsigned char) g_pucAlgoArray[local_index]; - counter -=1; - - debug_temp_buf[local_index] = ucData; - - } - else - { - /************************************************************* - * * - * If the current index is still within range, then return * - * the next byte. If it is out of range, then return -1. * - * * - *************************************************************/ - if (a_iCurrentIndex >= g_iDataSize) - { - return (unsigned char) 0xFF; - } - ucData = (unsigned char) g_pucDataArray[a_iCurrentIndex]; - } - - return ucData; -} - -/************************************************************* -* * -* SCLOCK * -* * -* INPUT: * -* None. * -* * -* RETURN: * -* None. * -* * -* DESCRIPTION: * -* This function applies a HLL pulse to TCK. * -* * -*************************************************************/ - -void sclock() -{ -/************************************************************* -* * -* Set TCK to HIGH, LOW, LOW. * -* * -*************************************************************/ - - writePort(pinTCK, 0x01); - writePort(pinTCK, 0x00); - writePort(pinTCK, 0x00); -} - -/************************************************************* -* * -* ISPVMREAD * -* * -* INPUT: * -* a_uiDataSize: this argument is the size of the * -* command. * -* * -* RETURN: * -* The return value is 0 if passing, and -1 if failing. * -* * -* DESCRIPTION: * -* This function reads a data stream from the device and * -* compares it to the expected TDO. * -* * -*************************************************************/ - -short int ispVMRead(unsigned int a_uiDataSize) -{ - unsigned int uiIndex = 0; - unsigned short usErrorCount = 0; - unsigned char ucTDIByte = 0; - unsigned char ucTDOByte = 0; - unsigned char ucMaskByte = 0; - unsigned char ucCurBit = 0; - - for (uiIndex = 0;uiIndex < a_uiDataSize; uiIndex++) - { - if (uiIndex % 8 == 0) - { - if ( g_usDataType & TDI_DATA ) { - /************************************************************* - * * - * If the TDI_DATA flag is set, then grab the next byte from * - * the algo array and increment the TDI index. * - * * - *************************************************************/ - ucTDIByte = GetByte( g_iTDIIndex++, 1 ); - } - else - { - ucTDIByte = 0xFF; - } - if (g_usDataType & TDO_DATA) - { - /************************************************************* - * * - * If the TDO_DATA flag is set, then grab the next byte from * - * the algo array and increment the TDO index. * - * * - *************************************************************/ - ucTDOByte = GetByte(g_iTDOIndex++, 1); - } - else - { - /************************************************************* - * * - * If TDO_DATA is not set, then DTDO_DATA must be set. If * - * the compression counter exists, then the next TDO byte * - * must be 0xFF. If it doesn't exist, then get next byte * - * from data file array. * - * * - *************************************************************/ - if (g_ucCompressCounter) - { - g_ucCompressCounter--; - ucTDOByte =(unsigned char) 0xFF; - } - else - { - ucTDOByte = GetByte(g_iMovingDataIndex++, 0); - - /************************************************************* - * * - * If the frame is compressed and the byte is 0xFF, then the * - * next couple bytes must be read to determine how many * - * repetitions of 0xFF are there. That value will be stored * - * in the variable g_ucCompressCounter. * - * * - *************************************************************/ - if ((g_usDataType & COMPRESS_FRAME) &&(ucTDOByte ==(unsigned char) 0xFF)) - { - g_ucCompressCounter = GetByte(g_iMovingDataIndex++, 0); - g_ucCompressCounter--; - } - } - } - - if (g_usDataType & MASK_DATA) - { - ucMaskByte = GetByte(g_iMASKIndex++, 1); - } - else - { - ucMaskByte =(unsigned char) 0xFF; - } - } - - ucCurBit = readPort(); - - if ((((ucMaskByte << uiIndex % 8) & 0x80) ? 0x01 : 0x00)) - { - if (ucCurBit !=(unsigned char)(((ucTDOByte << uiIndex % 8) & 0x80) ? 0x01 : 0x00)) - { - usErrorCount++; - } - } - - /************************************************************* - * * - * Always shift 0x01 into TDI pin when reading. * - * * - *************************************************************/ - - writePort(pinTDI, (unsigned char) (((ucTDIByte << uiIndex % 8) & 0x80) ? 0x01 : 0x00)); - - if (uiIndex < a_uiDataSize - 1) - { - sclock(); - } - } - - if (usErrorCount > 0) - { - return -1; - } - - return 0; -} - -/************************************************************* -* * -* ISPVMSEND * -* * -* INPUT: * -* a_uiDataSize: this argument is the size of the * -* command. * -* * -* RETURN: * -* None. * -* * -* DESCRIPTION: * -* This function sends a data stream to the device. * -* * -*************************************************************/ - -void ispVMSend(unsigned int a_uiDataSize) -{ - unsigned int iIndex; - unsigned char ucCurByte = 0; - unsigned char ucBitState = 0; - - /************************************************************* - * * - * Begin processing the data to the device. * - * * - *************************************************************/ - - for (iIndex = 0;iIndex < a_uiDataSize; iIndex++) - { - if (iIndex % 8 == 0) - { - if (g_usDataType & TDI_DATA) - { - /************************************************************* - * * - * If the TDI_DATA flag is set, then grab the next byte from * - * the algo array and increment the TDI index. * - * * - *************************************************************/ - ucCurByte = GetByte(g_iTDIIndex++, 1); - } - else - { - /************************************************************* - * * - * If TDI_DATA flag is not set, then DTDI_DATA flag must have * - * already been set. If the compression counter exists, then * - * the next TDI byte must be 0xFF. If it doesn't exist, then * - * get next byte from data file array. * - * * - *************************************************************/ - if (g_ucCompressCounter) - { - g_ucCompressCounter--; - ucCurByte =(unsigned char) 0xFF; - } - else - { - ucCurByte = GetByte(g_iMovingDataIndex++, 0); - - /************************************************************* - * * - * If the frame is compressed and the byte is 0xFF, then the * - * next couple bytes must be read to determine how many * - * repetitions of 0xFF are there. That value will be stored * - * in the variable g_ucCompressCounter. * - * * - *************************************************************/ - - if ((g_usDataType & COMPRESS_FRAME) &&(ucCurByte ==(unsigned char) 0xFF)) - { - g_ucCompressCounter = GetByte(g_iMovingDataIndex++, 0); - g_ucCompressCounter--; - } - } - } - } - - ucBitState =(unsigned char)(((ucCurByte << iIndex % 8) & 0x80) ? 0x01 : 0x00); - writePort(pinTDI, ucBitState); - - if (iIndex < a_uiDataSize - 1) - { - sclock(); - } - } -} - -/************************************************************* -* * -* ISPVMSTATEMACHINE * -* * -* INPUT: * -* a_cNextState: this is the opcode of the next JTAG * -* state. * -* * -* RETURN: * -* This functions returns 0 when passing, and -1 when * -* failure occurs. * -* * -* DESCRIPTION: * -* This function is called to move the device into * -* different JTAG states. * -* * -*************************************************************/ - -void ispVMStateMachine(char a_cNextState) -{ - char cPathIndex, cStateIndex; - if ((g_cCurrentJTAGState == DRPAUSE) &&(a_cNextState== DRPAUSE) && m_loopState) - { - } - else if ((g_cCurrentJTAGState == a_cNextState) &&(g_cCurrentJTAGState != RESET)) - { - return; - } - - for (cStateIndex = 0;cStateIndex < 25; cStateIndex++) - { - if ((g_cCurrentJTAGState == iStates[cStateIndex].CurState) &&(a_cNextState == iStates[cStateIndex].NextState)) - { - break; - } - } - g_cCurrentJTAGState = a_cNextState; - for (cPathIndex = 0;cPathIndex < iStates[cStateIndex].Pulses; cPathIndex++) - { - if ((iStates[cStateIndex].Pattern << cPathIndex) & 0x80) - { - writePort(pinTMS, (unsigned char) 0x01); - } - else - { - writePort(pinTMS, (unsigned char) 0x00); - } - sclock(); - } - - writePort(pinTDI, 0x00); - writePort(pinTMS, 0x00); -} - -/************************************************************* -* * -* ISPVMCLOCKS * -* * -* INPUT: * -* a_usClocks: number of clocks to apply. * -* * -* RETURN: * -* None. * -* * -* DESCRIPTION: * -* This procedure applies the specified number of pulses * -* to TCK. * -* * -*************************************************************/ - -void ispVMClocks(unsigned int a_uiClocks) -{ - for (; a_uiClocks > 0; a_uiClocks--) - { - sclock(); - } -} - -/************************************************************* -* * -* ISPVMBYPASS * -* * -* INPUT: * -* a_siLength: this argument is the length of the * -* command. * -* * -* RETURN: * -* None. * -* * -* DESCRIPTION: * -* This function takes care of the HIR, HDR, TIR, and TDR * -* for the purpose of putting the other devices into * -* bypass mode. * -* * -*************************************************************/ - -void ispVMBypass(unsigned int a_uiLength) -{ -/************************************************************* -* * -* Issue a_siLength number of 0x01 to the TDI pin to bypass. * -* * -*************************************************************/ - - for (; a_uiLength > 1; a_uiLength--) - { - writePort(pinTDI, (char) 0x01); - sclock(); - } - - writePort(pinTDI, (char) 0x01); -} -/************************************************************* -* * -* ispVMLCOUNT * -* * -* INPUT: * -* a_usCountSize: The maximum number of loop required to * -* poling the status * -* * -* * -* DESCRIPTION: * -* This function is set the maximum loop count * -* * -*************************************************************/ - -void ispVMLCOUNT(unsigned short a_usCountSize) -{ - g_usLCOUNTSize = a_usCountSize; -} -/************************************************************* -* * -* ispVMLDELAY * -* * -* * -* DESCRIPTION: * -* This function is set the delay state, number of TCK and* -* the delay time for poling the status * -* * -*************************************************************/ -void ispVMLDELAY() -{ - g_ucLDELAYState = IDLE; - g_ucLDELAYDelay = 0; - g_ucLDELAYTCK = 0; - while (1) - { - unsigned char bytedata = GetByte(g_iMovingAlgoIndex++, 1); - switch (bytedata) - { - case STATE: /*step BSCAN state machine to specified state*/ - g_ucLDELAYState = GetByte(g_iMovingAlgoIndex++, 1); - break; - case WAIT_FOR: /*opcode to wait for specified time in us or ms*/ - g_ucLDELAYDelay = (short int) ispVMDataSize(); - break; - case TCK: /*pulse TCK signal the specified time*/ - g_ucLDELAYTCK = (short int) ispVMDataSize(); - break; - case ENDSTATE: - return; - //break; - } - } -} diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/slim_vme.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/slim_vme.c deleted file mode 100644 index e6acfbd1d..000000000 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/JTAG_VME/slim_vme_8051/slim_vme.c +++ /dev/null @@ -1,213 +0,0 @@ -/************************************************************** -* -* Lattice Semiconductor Corp. Copyright 2008 -* -* -***************************************************************/ - - -/************************************************************** -* -* Revision History of slim_vme.c -* -* -* 09/11/07 NN Updated to support version 1.3 -* This version supported new POLING STATUS LOOP opcodes (LOOP and ENDLOOP) -* for Flash programming of the Lattice FPGA devices -* 09/11/07 NN Added Global variables initialization -* 09/11/07 NN type cast all mismatch variables -***************************************************************/ - - -#include <stdlib.h> -#include "opcode.h" - -/************************************************************* -* * -* EXTERNAL FUNCTIONS * -* * -*************************************************************/ - -extern unsigned char GetByte( int a_iCurrentIndex, char a_cAlgo ); -extern short ispProcessVME(); -extern void EnableHardware(); -extern void DisableHardware(); - -/*************************************************************** -* -* Supported VME versions. -* -***************************************************************/ -char *g_szSupportedVersions[] = { "_SVME1.1", "_SVME1.2", "_SVME1.3", 0 }; - -/************************************************************* -* * -* EXTERNAL VARIABLES * -* * -* If the algorithm does not require the data, then * -* declare the variables g_pucDataArray and g_iDataSize * -* as local variables and set them to NULL and 0, * -* respectively. * -* * -* Example: * -* xdata unsigned char * g_pucDataArray = NULL; * -* xdata int g_iDataSize = 0; * -* * -*************************************************************/ - -extern int g_iMovingAlgoIndex; -extern int g_iMovingDataIndex; -extern unsigned short g_usDataType; -extern /*xdata*/ const int g_iDataSize; - - -/************************************************************* -* * -* ISPVMENTRYPOINT * -* * -* INPUT: * -* a_pszAlgoFile: this is the name of the algorithm file. * -* * -* a_pszDataFile: this is the name of the data file. * -* Note that this argument may be empty if the algorithm * -* does not require a data file. * -* * -* RETURN: * -* The return value will be a negative number if an error * -* occurred, or 0 if everything was successful * -* * -* DESCRIPTION: * -* This function opens the file pointers to the algo and * -* data file. It intializes global variables to their * -* default values and enters the processor. * -* * -*************************************************************/ - -short int ispEntryPoint() -{ - char szFileVersion[ 9 ] = { 0 }; - short int siRetCode = 0; - short int iIndex = 0; - short int cVersionIndex = 0; - - /************************************************************* - * * - * VARIABLES INITIALIZATION * - * * - *************************************************************/ - - g_usDataType = 0; - g_iMovingAlgoIndex = 0; - g_iMovingDataIndex = 0; - - if ( g_iDataSize ) { - if ( GetByte( g_iMovingDataIndex++, 0 ) ) { - g_usDataType |= COMPRESS; - } - } - /*************************************************************** - * - * Read and store the version of the VME file. - * - ***************************************************************/ - - for ( iIndex = 0; iIndex < 8; iIndex++ ) { - szFileVersion[ iIndex ] = GetByte( g_iMovingAlgoIndex++, 1 ); - } - - /*************************************************************** - * - * Compare the VME file version against the supported version. - * - ***************************************************************/ - - for ( cVersionIndex = 0; g_szSupportedVersions[ cVersionIndex ] != 0; cVersionIndex++ ) { - for ( iIndex = 0; iIndex < 8; iIndex++ ) { - if ( szFileVersion[ iIndex ] != g_szSupportedVersions[ cVersionIndex ][ iIndex ] ) { - //siRetCode = ERR_WRONG_VERSION; AVI- - //break; AVI- - } - siRetCode = 0; - } - - if ( siRetCode == 0 ) { - - /*************************************************************** - * - * Found matching version, break. - * - ***************************************************************/ - - break; - } - } - - if ( siRetCode < 0 ) { - - /*************************************************************** - * - * VME file version failed to match the supported versions. - * - ***************************************************************/ - while(1);//avi+ - return ERR_WRONG_VERSION; - } - - - /************************************************************* - * * - * Start the hardware. * - * * - *************************************************************/ - - EnableHardware(); - - /************************************************************* - * * - * Begin processing algorithm and data file. * - * * - *************************************************************/ - - siRetCode = ispProcessVME(); - - /************************************************************* - * * - * Stop the hardware. * - * * - *************************************************************/ - - DisableHardware(); - - /************************************************************* - * * - * Return the return code. * - * * - *************************************************************/ - - return ( siRetCode ); -} -/************************************************************* -* * -* MAIN * -* * -*************************************************************/ - -short int main_vme() -{ - /************************************************************* - * * - * LOCAL VARIABLES: * - * siRetCode: this variable holds the return. * - * * - *************************************************************/ - - short int siRetCode = 0; - /************************************************************* - * * - * Pass in the command line arguments to the entry point. * - * * - *************************************************************/ - - siRetCode = ispEntryPoint(); - return( siRetCode ); -} diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 4ffa76fa4..0d57d6bd8 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -194,6 +194,14 @@ int main(void) //GetFiles(); //- to start jtag //GetVmeByte(); + //char FullPath[] = "0://FPGAJTAG//F1TangoF.vme"; + //FPGA_Programming_Up(FPGA1, FullPath, FALSE); + + //char FullPath[] = "0://FPGAJTAG//F2TangoF.vme"; + //FPGA_Programming_Up(FPGA2, FullPath, FALSE); + + //char FullPath[] = "0://FPGAJTAG//F3TangoF.vme"; + //FPGA_Programming_Up(FPGA3, FullPath, FALSE); //////////////////////////// // Enable interrupts to the processor. |
