summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile_op24
-rw-r--r--Makefile_opgui32
-rw-r--r--common.h1
-rw-r--r--progAVR.c22
-rw-r--r--progEEPROM.c8
-rw-r--r--progP16.c44
-rw-r--r--progP18.c18
-rw-r--r--progP24.c13
-rw-r--r--progP32.c7
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 <ctype.h>
#include <getopt.h>
#include <string.h>
+#include <stdbool.h>
#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<sizeof(AVRLIST)/sizeof(AVRLIST[0]);i++){
@@ -122,9 +122,13 @@ void AtmelID(BYTE id[])
strcat(str," 128KB Flash");
break;
}
- if(i!=1001) strcat(str,strings[S_nodev]); //"Unknown device\r\n");
- else strcat(str,"\r\n");
+ if(i!=1001) {
+ PrintMessage(strings[S_nodev]); //"Unknown device\r\n");
+ return false;
+ }
+ strcat(str,"\r\n");
PrintMessage(str);
+ return true;
}
void DisplayCODEAVR(int dim){
@@ -582,7 +586,7 @@ void ReadAT(int dim, int dim2, int options)
for(z+=3;z<DIMBUF-2&&bufferI[z]!=SPI_READ;z++);
signature[2]=bufferI[z+2];
PrintMessage3("CHIP ID:%02X%02X%02X\r\n",signature[0],signature[1],signature[2]);
- AtmelID(signature);
+ if (!AtmelID(signature)) return;
if(options&LOCK){ //LOCK byte
for(z+=3;z<DIMBUF-2&&bufferI[z]!=SPI_READ;z++);
PrintMessage1("LOCK bits:\t 0x%02X\r\n",bufferI[z+2]);
@@ -908,7 +912,7 @@ void ReadAT_HV(int dim, int dim2, int options)
for(z+=2;z<DIMBUF-1&&bufferI[z]!=AT_HV_RTX;z++);
signature[2]=bufferI[z+1];
PrintMessage3("CHIP ID:%02X%02X%02X\r\n",signature[0],signature[1],signature[2]);
- AtmelID(signature);
+ if (!AtmelID(signature)) return;
if(options&LOCK){ //LOCK byte
for(z+=2;z<DIMBUF-1&&bufferI[z]!=AT_HV_RTX;z++);
PrintMessage1("LOCK byte:\t 0x%02X\r\n",bufferI[z+1]);
@@ -1258,7 +1262,7 @@ void WriteAT(int dim, int dim2, int dummy1, int dummy2)
for(z+=3;z<DIMBUF-2&&bufferI[z]!=SPI_READ;z++);
signature[2]=bufferI[z+2];
PrintMessage3("CHIP ID:%02X%02X%02X\r\n",signature[0],signature[1],signature[2]);
- AtmelID(signature);
+ if (!AtmelID(signature)) return;
//****************** erase memory ********************
PrintMessage(strings[S_StartErase]); //"Erase ... "
if(saveLog) fprintf(logfile,"%s\n",strings[S_StartErase]);
@@ -1492,7 +1496,7 @@ void WriteATmega(int dim, int dim2, int page, int options)
for(z+=3;z<DIMBUF-2&&bufferI[z]!=SPI_READ;z++);
signature[2]=bufferI[z+2];
PrintMessage3("CHIP ID:%02X%02X%02X\r\n",signature[0],signature[1],signature[2]);
- AtmelID(signature);
+ if (!AtmelID(signature)) return;
//****************** erase memory ********************
PrintMessage(strings[S_StartErase]); //"Erase ... "
if(saveLog) fprintf(logfile,"%s\n",strings[S_StartErase]);
@@ -1896,7 +1900,7 @@ void WriteAT_HV(int dim, int dim2, int page, int options)
for(z+=2;z<DIMBUF-1&&bufferI[z]!=AT_HV_RTX;z++);
signature[2]=bufferI[z+1];
PrintMessage3("CHIP ID:%02X%02X%02X\r\n",signature[0],signature[1],signature[2]);
- AtmelID(signature);
+ if (!AtmelID(signature)) return;
//****************** erase memory ********************
if(saveLog)fprintf(logfile,"CHIP ERASE\n");
j=0;
diff --git a/progEEPROM.c b/progEEPROM.c
index f0e8259..fa6d138 100644
--- a/progEEPROM.c
+++ b/progEEPROM.c
@@ -1555,7 +1555,7 @@ struct ID_OW{
{0x43,"DS28EC20\r\n"},
};
-void OW_ID(int id)
+static bool OW_ID(int id)
{
char s[64];
int i;
@@ -1563,11 +1563,11 @@ void OW_ID(int id)
if(id==OW_LIST[i].id){
sprintf(s,OW_LIST[i].device,id);
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;
}
#define READ_ROM 0x33
diff --git a/progP16.c b/progP16.c
index 54d6727..be9f5a0 100644
--- a/progP16.c
+++ b/progP16.c
@@ -419,7 +419,7 @@ struct ID16{
{0x3106,"16F17176\r\n",0},
};
-void PIC16_ID(int id)
+static bool PIC16_ID(int id)
{
char s[64];
int i;
@@ -427,16 +427,16 @@ void PIC16_ID(int id)
if(PIC16LIST[i].revmask&&(id>>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<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
calib1=(bufferI[z+1]<<8)+bufferI[z+2];
if(calib1<0x3fff){
@@ -1930,7 +1930,7 @@ void Write16F8x (int dim,int dim2)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
config=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_ConfigWord],config); //"Config word: 0x%04X\r\n"
@@ -2294,7 +2294,7 @@ void Write16F62x (int dim,int dim2)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
config=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_ConfigWord],config); //"Config word: 0x%04X\r\n"
@@ -2629,7 +2629,7 @@ void Write12F62x(int dim,int dim2)
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
config=(bufferI[z+1]<<8)+bufferI[z+1];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
//****************** erase memory ********************
PrintMessage(strings[S_StartErase]); //"Erase ... "
j=0;
@@ -2940,7 +2940,7 @@ void Write16F87x (int dim,int dim2)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
config=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_ConfigWord],config); //"Config word: 0x%04X\r\n"
@@ -3324,7 +3324,7 @@ void Write16F87xA (int dim,int dim2,int seq)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
config=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_ConfigWord],config); //"Config word: 0x%04X\r\n"
@@ -3666,7 +3666,7 @@ void Write16F81x (int dim,int dim2)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
config=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_ConfigWord],config); //"Config word: 0x%04X\r\n"
@@ -4037,7 +4037,7 @@ void Write12F61x(int dim, int d, int d2)
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
if(devREV<0x3FFF) PrintMessage1(strings[S_DevREV],devREV); //"DevREV: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
calib1=(bufferI[z+1]<<8)+bufferI[z+2];
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
@@ -4321,7 +4321,7 @@ void Write16F88x(int dim,int dim2)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
calib1=(bufferI[z+1]<<8)+bufferI[z+2];
if(calib1<0x3fff){
@@ -4672,7 +4672,7 @@ void Write16F7x(int dim,int vdd)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
//****************** erase memory ********************
PrintMessage(strings[S_StartErase]); //"Erase ... "
j=0;
@@ -4936,7 +4936,7 @@ void Write16F71x(int dim,int vdd)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
//****************** erase memory ********************
PrintMessage(strings[S_StartErase]); //"Erase ... "
j=0;
@@ -5203,7 +5203,7 @@ void Write16F72x(int dim, int d, int d2)
for(z=0;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
//****************** erase memory ********************
PrintMessage(strings[S_StartErase]); //"Erase ... "
j=0;
@@ -5526,7 +5526,7 @@ void Write16F1xxx(int dim,int dim2,int options)
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
if(devREV<0x3FFF) PrintMessage1(strings[S_DevREV],devREV); //"DevREV: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
if(memCODE_W[0x8006]<0x3FFF&&devID!=memCODE_W[0x8006]) PrintMessage(strings[S_DevMismatch]); //"Warning: the device is different from what specified in source data"
if(!F18x){ //16F1xxx
for(z+=3;z<DIMBUF-2&&bufferI[z]!=READ_DATA_PROG;z++);
@@ -6153,7 +6153,7 @@ void Write16F18xxx(int dim,int dim2,int options)
devID=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage1(strings[S_DevID],devID); //"DevID: 0x%04X\r\n"
if(devREV<0x3FFF) PrintMessage1(strings[S_DevREV],devREV); //"DevREV: 0x%04X\r\n"
- PIC16_ID(devID);
+ if (!PIC16_ID(devID)) return;
if(memCODE_W[0x8006]<0x3FFF&&devID!=memCODE_W[0x8006]) PrintMessage(strings[S_DevMismatch]); //"Warning: the device is different from what specified in source data"
//****************** DIA-DCI ********************
if(useDCI){ //if not disabled
diff --git a/progP18.c b/progP18.c
index 4d888f0..de77e99 100644
--- a/progP18.c
+++ b/progP18.c
@@ -324,7 +324,7 @@ struct ID18{
{0x990B,"18F57Q83 rev%c%d\r\n",0xFFFF},
};
-void PIC18_ID(int id)
+static bool PIC18_ID(int id)
{
char s[128];
int i;
@@ -332,18 +332,18 @@ void PIC18_ID(int id)
if(PIC18LIST[i].revmask!=0xFFFF&&PIC18LIST[i].id==(id&~PIC18LIST[i].revmask)){
sprintf(s,PIC18LIST[i].device,id&PIC18LIST[i].revmask);
PrintMessage(s);
- return;
+ return true;
}
else if(PIC18LIST[i].revmask==0xFFFF&&PIC18LIST[i].id==(id&0xFFFF)){
int MJrev=(id>>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<DIMBUF;z++);
if(z<DIMBUF-3){
PrintMessage2(strings[S_DevID2],bufferI[z+3],bufferI[z+2]); //"DevID: 0x%02X%02X\r\n"
- PIC18_ID(bufferI[z+2]+(bufferI[z+3]<<8));
+ if (!PIC18_ID(bufferI[z+2]+(bufferI[z+3]<<8))) return;
}
//****************** read code ********************
PrintMessage(strings[S_CodeReading1]); //code read ...
@@ -792,7 +792,7 @@ void Write18Fx(int dim,int dim2,int wbuf,int eraseW1,int eraseW2,int options)
for(z=0;bufferI[z]!=TBLR_INC_N&&z<DIMBUF;z++);
if(z<DIMBUF-3){
PrintMessage2(strings[S_DevID2],bufferI[z+3],bufferI[z+2]); //"DevID: 0x%02X%02X\r\n"
- PIC18_ID(bufferI[z+2]+(bufferI[z+3]<<8));
+ if (!PIC18_ID(bufferI[z+2]+(bufferI[z+3]<<8))) return;
}
j=0;
//****************** erase memory ********************
@@ -1758,7 +1758,7 @@ void Read18FKx(int dim,int dim2,int options)
}
PrintMessage1("DevID: 0x%04X\r\n",devID);
PrintMessage1("RevID: 0x%04X\r\n",devREV);
- PIC18_ID(devID+(devREV<<16));
+ if(!PIC18_ID(devID+(devREV<<16))) return;
PrintMessage("Device Configuration Information:\r\n");
for(z+=3;bufferI[z]!=ICSP8_READ&&z<DIMBUF;z++);
if(z<DIMBUF-2){
@@ -2139,7 +2139,7 @@ void Write18FKx(int dim,int dim2,int options,int nu1,int nu2, int nu3)
}
PrintMessage1("DevID: 0x%04X\r\n",devID);
PrintMessage1("RevID: 0x%04X\r\n",devREV);
- PIC18_ID(devID+(devREV<<16));
+ if(!PIC18_ID(devID+(devREV<<16))) return;
PrintMessage("Device Configuration Information:\r\n");
for(z+=3;bufferI[z]!=ICSP8_READ&&z<DIMBUF;z++);
if(z<DIMBUF-2){
diff --git a/progP24.c b/progP24.c
index 435b931..d6e86b5 100644
--- a/progP24.c
+++ b/progP24.c
@@ -346,7 +346,7 @@ struct ID24{
{0x488B,"24FJ128GC008"},
};
-void PIC24_ID(int id)
+static bool PIC24_ID(int id)
{
char s[64];
int i;
@@ -355,10 +355,11 @@ void PIC24_ID(int id)
strcpy(s,PIC24LIST[i].device);
strcat(s,"\r\n");
PrintMessage(s);
- return;
+ return true;
}
}
PrintMessage(strings[S_nodev]); //"Unknown device\r\n");
+ return false;
}
void DisplayCODE24F(int dim){
@@ -644,7 +645,7 @@ void Read24Fx(int dim,int dim2,int options,int appIDaddr,int executiveArea){
for(z+=3;bufferI[z]!=REGOUT&&z<DIMBUF;z++);
if(z<DIMBUF-2) w1=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage2("DevID: 0x%04X\r\nDevRev: 0x%04X\r\n",w0,w1);
- PIC24_ID(w0);
+ if(!PIC24_ID(w0)) return;
//Read ApplicationID @ appIDaddr
bufferU[j++]=SIX_N;
bufferU[j++]=0x44; //append 1 NOP
@@ -1409,7 +1410,7 @@ void Read24Ex(int dim,int dim2,int options,int appIDaddr,int executiveArea){
for(z+=3;bufferI[z]!=REGOUT&&z<DIMBUF;z++);
if(z<DIMBUF-2) w1=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage2("DevID: 0x%04X\r\nDevRev: 0x%04X\r\n",w0,w1);
- PIC24_ID(w0);
+ if(!PIC24_ID(w0)) return;
//Read ApplicationID @ appIDaddr
bufferU[j++]=SIX_N;
bufferU[j++]=0x4;
@@ -2157,7 +2158,7 @@ void Write24Fx(int dim,int dim2,int options,int appIDaddr,int rowSize, double wa
for(z+=3;bufferI[z]!=REGOUT&&z<DIMBUF;z++);
if(z<DIMBUF-2) w1=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage2("DevID: 0x%04X\r\nDevRev: 0x%04X\r\n",w0,w1);
- PIC24_ID(w0);
+ if(!PIC24_ID(w0)) return;
//Read ApplicationID @ appIDaddr
bufferU[j++]=SIX_N;
bufferU[j++]=0x44; //append 1 NOP
@@ -3495,7 +3496,7 @@ void Write24Ex(int dim,int dim2,int options,int appIDaddr,int rowSize, double wa
for(z+=3;bufferI[z]!=REGOUT&&z<DIMBUF;z++);
if(z<DIMBUF-2) w1=(bufferI[z+1]<<8)+bufferI[z+2];
PrintMessage2("DevID: 0x%04X\r\nDevRev: 0x%04X\r\n",w0,w1);
- PIC24_ID(w0);
+ if(!PIC24_ID(w0)) return;
//Read ApplicationID @ appIDaddr
bufferU[j++]=SIX_N;
bufferU[j++]=0x44; //append 1 NOP
diff --git a/progP32.c b/progP32.c
index 9416eed..7c68287 100644
--- a/progP32.c
+++ b/progP32.c
@@ -298,7 +298,7 @@ struct ID32{
{0x06201053,"PIC32MK1024MCF100"},
};
-void PIC32_ID(int id)
+static bool PIC32_ID(int id)
{
char s[64];
int i;
@@ -307,10 +307,11 @@ void PIC32_ID(int id)
strcpy(s,PIC32LIST[i].device);
strcat(s,"\r\n");
PrintMessage(s);
- return;
+ return true;
}
}
PrintMessage(strings[S_nodev]); //"Unknown device\r\n");
+ return false;
}
/*#ifdef _MSC_VER
@@ -540,7 +541,7 @@ void Read32x(int dim,int options){
for(z=0;bufferI[z]!=JTAG_XFER_DATA&&z<DIMBUF;z++);
if(z<DIMBUF-4) w0=(bufferI[z+1]<<24)+(bufferI[z+2]<<16)+(bufferI[z+3]<<8)+bufferI[z+4];
PrintMessage1("IDCODE=0x%08X\r\n",w0);
- PIC32_ID(w0);
+ if(!PIC32_ID(w0)) return;
//enable serial execution mode
bufferU[j++]=JTAG_SEND_CMD;
bufferU[j++]=MTAP_SW_MTAP;