From 5f686d5179d6a23a37378550b8c1122453d240c1 Mon Sep 17 00:00:00 2001 From: Attila Veghelyi Date: Tue, 25 Jun 2024 20:25:31 +0200 Subject: Stop the process when device ID is unknown --- Makefile_op | 24 +++++++++++++----------- Makefile_opgui | 32 +++++++++++++++++--------------- common.h | 1 + progAVR.c | 22 +++++++++++++--------- progEEPROM.c | 8 ++++---- progP16.c | 44 ++++++++++++++++++++++---------------------- progP18.c | 18 +++++++++--------- progP24.c | 13 +++++++------ progP32.c | 7 ++++--- 9 files changed, 90 insertions(+), 79 deletions(-) diff --git a/Makefile_op b/Makefile_op index 6d34e67..5fff89a 100644 --- a/Makefile_op +++ b/Makefile_op @@ -4,17 +4,19 @@ CC = gcc CFLAGS = '-DVERSION="$(VERSION)"' -w -Os -s #size #CFLAGS = -w -O3 -s #CFLAGS = -w -g #debug -OBJECTS = op.o \ - progP12.o \ - progP16.o \ - progP18.o \ - progP24.o \ - progEEPROM.o \ - progAVR.o \ - fileIO.o \ - deviceRW.o \ - I2CSPI.o \ - strings.o +SOURCES = op.c \ + progP12.c \ + progP16.c \ + progP18.c \ + progP24.c \ + progEEPROM.c \ + progAVR.c \ + fileIO.c \ + deviceRW.c \ + I2CSPI.c \ + strings.c + +OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) LDFLAG = -lrt diff --git a/Makefile_opgui b/Makefile_opgui index bdde783..cd0f5a3 100644 --- a/Makefile_opgui +++ b/Makefile_opgui @@ -11,21 +11,23 @@ CFLAGS += -Os -s #size LDLAGS = `pkg-config --libs gtk+-3.0` -OBJECTS = opgui.o \ - deviceRW.o \ - progP12.o \ - progP16.o \ - progP18.o \ - progP24.o \ - progEEPROM.o \ - progAVR.o \ - fileIO.o \ - I2CSPI.o \ - coff.o \ - icd.o \ - strings.o \ - resources.o -# progP32.o \ +SOURCES = opgui.c \ + deviceRW.c \ + progP12.c \ + progP16.c \ + progP18.c \ + progP24.c \ + progEEPROM.c \ + progAVR.c \ + fileIO.c \ + I2CSPI.c \ + coff.c \ + icd.c \ + strings.c \ + resources.c +# progP32.c \ + +OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) # Check if we are running on windows UNAME := $(shell uname) diff --git a/common.h b/common.h index 8573b08..ba105e7 100644 --- a/common.h +++ b/common.h @@ -32,6 +32,7 @@ #include #include #include +#include #include "strings.h" #include "instructions.h" diff --git a/progAVR.c b/progAVR.c index 47fdcc4..839e1f6 100644 --- a/progAVR.c +++ b/progAVR.c @@ -81,13 +81,13 @@ struct AVRID{ {0x9706,"ATmega1284"}, }; -void AtmelID(BYTE id[]) +static bool AtmelID(BYTE id[]) { char str[128]=""; int i,idw=(id[1]<<8)+id[2]; if(id[0]==0&&id[1]==1&&id[2]==2){ PrintMessage(strings[S_Protected]); //"Device protected" - return; + return false; } if(id[0]==0x1E) strcat(str,"Atmel "); for(i=0;i>5)==PIC16LIST[i].id){ //id + rev in same location sprintf(s,PIC16LIST[i].device,id&PIC16LIST[i].revmask); PrintMessage(s); - return; + return true; } else if(!PIC16LIST[i].revmask&&id==PIC16LIST[i].id){ //id separate from rev sprintf(s,PIC16LIST[i].device); PrintMessage(s); - return; + return true; } } - sprintf(s,"%s",strings[S_nodev]); //"Unknown device\r\n"); - PrintMessage(s); + PrintMessage(strings[S_nodev]); //"Unknown device\r\n"); + return false; } void DisplayCODE16F(int size){ @@ -716,7 +716,7 @@ void Read16Fxxx(int dim,int dim2,int dim3,int vdd) } PrintMessage1(strings[S_DevID],memCODE_W[0x2006]); //"DevID: 0x%04X\r\n" if(memCODE_W[0x2005]<0x3FFF) PrintMessage1(strings[S_DevREV],memCODE_W[0x2005]); //"DevREV: 0x%04X\r\n" - PIC16_ID(memCODE_W[0x2006]); + if (!PIC16_ID(memCODE_W[0x2006])) return; PrintMessage1(strings[S_ConfigWord],memCODE_W[0x2007]); //"Configuration word: 0x%04X\r\n" if(dim3>8){ PrintMessage1(strings[S_Config2Cal1],memCODE_W[0x2008]); //"Config2 or Cal1: 0x%04X\r\n" @@ -1048,7 +1048,7 @@ void Read16F1xxx(int dim,int dim2,int dim3,int options) } PrintMessage1(strings[S_DevID],memCODE_W[0x8006]); //"DevID: 0x%04X\r\n" if(memCODE_W[0x8005]<0x3FFF) PrintMessage1(strings[S_DevREV],memCODE_W[0x8005]); //"DevREV: 0x%04X\r\n" - PIC16_ID(memCODE_W[0x8006]); + if (!PIC16_ID(memCODE_W[0x8006])) return; PrintMessage2(strings[S_ConfigWordX],1,memCODE_W[0x8007]); //"Configuration word %d: 0x%04X\r\n" PrintMessage2(strings[S_ConfigWordX],2,memCODE_W[0x8008]); //"Configuration word %d: 0x%04X\r\n" if((options&0xC)==0&&F18x==0){ //2 config + 2/3 calib words @@ -1404,7 +1404,7 @@ void Read16F18xxx(int dim,int dim2,int dim3,int options) } PrintMessage1(strings[S_DevID],memCODE_W[0x8006]); //"DevID: 0x%04X\r\n" if(memCODE_W[0x8005]<0x3FFF) PrintMessage1(strings[S_DevREV],memCODE_W[0x8005]); //"DevREV: 0x%04X\r\n" - PIC16_ID(memCODE_W[0x8006]); + if (!PIC16_ID(memCODE_W[0x8006])) return; for(i=0;i<5;i++){ PrintMessage2(strings[S_ConfigWordX],i+1,memCODE_W[0x8007+i]); //"Configuration word %d: 0x%04X\r\n" } @@ -1538,7 +1538,7 @@ void Write12F6xx(int dim,int dim2) for(z=0;z>22)&0x3F; int MNrev=(id>>16)&0x3F; sprintf(s,PIC18LIST[i].device,MJrev+'A',MNrev); PrintMessage(s); - return; + return true; } } - sprintf(s,"%s",strings[S_nodev]); //"Unknown device\r\n"); - PrintMessage(s); + PrintMessage(strings[S_nodev]); //"Unknown device\r\n"); + return false; } void DisplayCODE18F(int dim){ @@ -496,7 +496,7 @@ void Read18Fx(int dim,int dim2,int options) for(z=0;bufferI[z]!=TBLR_INC_N&&z