diff options
-rw-r--r-- | Makefile | 61 | ||||
-rw-r--r-- | Makefile_opgui | 2 | ||||
-rw-r--r-- | deviceRW.c | 2 | ||||
-rw-r--r-- | op.c | 3 | ||||
-rw-r--r-- | opgui.c | 50 | ||||
-rw-r--r-- | opgui.glade | 4 | ||||
-rw-r--r-- | progP16.c | 6 | ||||
-rw-r--r-- | progP18.c | 4 | ||||
-rw-r--r-- | readme | 4 | ||||
-rw-r--r-- | strings.c | 12 | ||||
-rw-r--r-- | strings.h | 4 |
11 files changed, 66 insertions, 86 deletions
diff --git a/Makefile b/Makefile deleted file mode 100644 index 2abc748..0000000 --- a/Makefile +++ /dev/null @@ -1,61 +0,0 @@ -OP_PROGRAM := op -OPGUI_PROGRAM := opgui - -VERSION = 0.12.1 - -CFLAGS := '-DVERSION="$(VERSION)"' -CFLAGS += -Os -s #size -CFLAGSGUI := -DOPGUI `pkg-config --cflags gtk+-3.0` - -OBJECTS := \ - progP12.o \ - progP16.o \ - progP18.o \ - progP24.o \ - progEEPROM.o \ - progAVR.o \ - fileIO.o \ - deviceRW.o \ - I2CSPI.o \ - strings.o \ - -OP_OBJ := \ - op.o \ - -OPGUI_OBJ := \ - opgui.o \ - coff.o \ - icd.o \ - resources.o \ - -LDFLAGS := -lrt -LDFLAGSGTK := `pkg-config --libs gtk+-3.0` - -all: $(OP_PROGRAM) $(OPGUI_PROGRAM) - -# https://stackoverflow.com/a/1305879 - -$(OPGUI_PROGRAM): EXTRA_FLAGS := $(CFLAGSGUI) - -%.o: %.c - @echo "\tCC $@" - $(CC) $(CFLAGS) $(EXTRA_FLAGS) -c $^ -o $@ - -resources.c: resources.xml opgui.glade - @glib-compile-resources resources.xml --target=resources.c --generate-source - -$(OPGUI_PROGRAM): $(OBJECTS) $(OPGUI_OBJ) - @echo "\tLD $@" - $(CC) $^ -o $@ $(LDFLAGS) $(LDFLAGSGTK) - @rm -f *.o resources.c - -$(OP_PROGRAM): $(OBJECTS) $(OP_OBJ) - @echo "\tLD $@" - $(CC) $^ -o $@ $(LDFLAGS) - @rm -f *.o - -clean: - @echo "\tCLEAN .o" - @rm -f *.o - -.PHONY: all clean diff --git a/Makefile_opgui b/Makefile_opgui index 7ac6624..bdde783 100644 --- a/Makefile_opgui +++ b/Makefile_opgui @@ -1,5 +1,5 @@ # equivalent to #define in c code -VERSION = 0.12.1 +VERSION = 0.12.2 CC = gcc PREFIX = /usr/local @@ -1201,6 +1201,8 @@ void populateDevInfo(struct DevInfo *info, const struct DEVICES *devlistEntry) { if(info->size<1024) sprintf(str2,"%s, %dB",strings[I_UNIOMEM],info->size); //UNI/O Memory else sprintf(str2,"%s, %sKB",strings[I_UNIOMEM],strF); break; + default: + sprintf(str2,"!!unknown family!!"); } if(info->HV>0){ sprintf(str3,", %.1fV",info->HV); @@ -349,6 +349,7 @@ int main (int argc, char **argv) { strncpy(LogFileName,strings[S_LogFile],sizeof(LogFileName)); if(argc==1){ + printf("OP v%s\n",VERSION); printf(strings[L_HELP]); exit(1); } @@ -361,7 +362,7 @@ int main (int argc, char **argv) { if(langfile) GenerateLangFile(langid,"languages.rc"); if (ver){ - printf("OP v%s\nCopyright (C) Alberto Maccioni 2009-2022\ + printf("OP v%s\nCopyright (C) Alberto Maccioni 2009-2023\ \n For detailed info see http://openprog.altervista.org/\ \nThis program is free software; you can redistribute it and/or modify it under \ the terms of the GNU General Public License as published by the Free Software \ @@ -252,7 +252,7 @@ void info(GtkWidget *widget,GtkWidget *window) //"authors","Alberto Maccioni",NULL, "comments", "A graphical interface for the Open Programmer", "copyright", - "Copyright (C) Alberto Maccioni 2009-2022\n\n" + "Copyright (C) Alberto Maccioni 2009-2023\n\n" "This program is free software; you can \n" "redistribute it and/or modify it under \n" "the terms of the GNU General Public License \n" @@ -649,8 +649,6 @@ void WriteATfuseLowLF(GtkWidget *widget,GtkWidget *window){ void onDevSel_Changed(GtkWidget *widget,GtkWidget *window) { struct DevInfo info; - char str2[256],str3[64],strF[32]; - double x; GetSelectedDevice(); if (strlen(dev) == 0) return; // None selected info=GetDevInfo(dev); @@ -764,6 +762,16 @@ int sortIterCompareFunc(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpo } return ret; } + + +#ifndef strupr +char* strupr( char* s ){ + char* p = s; + while (*p = toupper( *p )) p++; + return s; +} +#endif + /// ///Add devices to the device ListStore (which may not have been created) ///groupFilter: add devices in this group (-1 for all) @@ -790,6 +798,8 @@ void AddDevices(enum group_t groupFilter, const char *textFilter) { else gtk_list_store_clear(devStore); int i,j=0; char *devices=0,*tok; + char textFilterU[32]; + strupr(strncpy(textFilterU,textFilter,32)); for(i=0;i<NDEVLIST;i++) { if(devices) free(devices); devices=malloc(strlen(DEVLIST[i].device)+1); @@ -800,7 +810,7 @@ void AddDevices(enum group_t groupFilter, const char *textFilter) { //info.device=malloc(strlen(tok)+1); //strcpy(info.device,tok); info.group=nameToGroup(tok); - if(info.group!=-1&&(!textFilter || strlen(textFilter) == 0 || strstr(tok, textFilter)) && + if(info.group!=-1&&(!textFilter || strlen(textFilter) == 0 || strstr(strupr(tok), textFilterU)) && (groupFilter == -1 || info.group == groupFilter)) { gtk_list_store_insert_with_values(devStore, NULL, -1, DEVICE_ID_COLUMN, j++, @@ -856,8 +866,6 @@ void IOchanged(GtkWidget *widget,GtkWidget *window) int i,j=0; int trisa=1,trisb=0,trisc=0x30,latac=0,latb=0; int port=0,z; - //char str[128]="IO:"; - char s2[64]; str[0]=0; for(i=0;i<sizeof(ioButtons)/sizeof(ioButtons[0]);i++){ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ioButtons[i].r_0))){ @@ -1375,7 +1383,11 @@ void ProgID() else if(HwID==2) PrintMessage(" (18F2450)\r\n\r\n"); else if(HwID==3) PrintMessage(" (18F2458/2553)\r\n\r\n"); else if(HwID==4) PrintMessage(" (18F25K50)\r\n\r\n"); + else if(HwID==5) PrintMessage(" (18F25K50 all-in-one variant)\r\n\r\n"); else PrintMessage(" (?)\r\n\r\n"); + // Disable 3.3V check and hide the option for all-in-one board. Enable and show for others + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b_V33check), HwID==5 ? TRUE : FALSE); + gtk_widget_set_visible(GTK_WIDGET(b_V33check), HwID==5 ? FALSE : TRUE); } /// ///Check if a 3.3V regulator is present @@ -1418,13 +1430,24 @@ int CheckS1() int i,j=0; bufferU[j++]=READ_RAM; bufferU[j++]=0x0F; + if (HwID==5) { //all-in-one board + bufferU[j++]=0x80; // Read PORTA + } + else { //std board bufferU[j++]=0x84; //READ PORTE + } bufferU[j++]=FLUSH; for(;j<DIMBUF;j++) bufferU[j]=0x0; PacketIO(5); for(j=0;j<DIMBUF-3&&bufferI[j]!=READ_RAM;j++); + if (HwID==5) { //all-in-one board + i=bufferI[j+3]&0x80; //i=A7 + return i?1:0; //A7=1 when switch pressed (active high) + } + else { //std board i=bufferI[j+3]&0x8; //i=E3 - return i?0:1; //S1 open -> E3=1 + return i?0:1; //S1 open -> E3=1 (active low) + } } /// ///Execute hardware test @@ -1679,7 +1702,6 @@ void PacketIO(double delay){ int main( int argc, char *argv[]) { //int langID=GetUserDefaultLangID(); - DWORD t0=GetTickCount(); FILE *f; gchar *homedir,*config_dir,*fname=0; char lang[32]=""; @@ -1724,7 +1746,6 @@ int main( int argc, char *argv[]) opterr = 0; int option_index = 0; int help=0,command=0,i,j; - char c; struct option long_options[] = { {"?", no_argument, &help, 1}, @@ -1747,7 +1768,7 @@ int main( int argc, char *argv[]) char* langid=0; i=0; if(lang[0]){ //explicit language selection - if(lang[0]=='i'&&langid[1]=='t'){ //built-in + if(lang[0]=='i'&&lang[1]=='t'){ //built-in strings=strings_it; i=1; } @@ -1852,7 +1873,8 @@ int main( int argc, char *argv[]) dataBuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(data)); //------device tab------------- gtk_label_set_text(GTK_LABEL(GTK_WIDGET(gtk_builder_get_object(builder,"DEVICE_L"))),strings[I_Dev]); //"Device" - gtk_label_set_text(GTK_LABEL(GTK_WIDGET(gtk_builder_get_object(builder,"TYPE_L"))),strings[I_Type]); //"Type" + gtk_label_set_text(GTK_LABEL(GTK_WIDGET(gtk_builder_get_object(builder,"TYPE_L"))),strings[I_TypeFilt]); //"Filter by type" + gtk_label_set_text(GTK_LABEL(GTK_WIDGET(gtk_builder_get_object(builder,"DEV_SRC_L"))),strings[I_Filt]); //"Filter" devTypeCombo=GTK_WIDGET(gtk_builder_get_object(builder,"TYPE_C")); g_signal_connect(G_OBJECT(devTypeCombo),"changed",G_CALLBACK(FilterDevType),NULL); devFiltEntry=GTK_WIDGET(gtk_builder_get_object(builder,"DEV_SRC_E")); @@ -1861,7 +1883,9 @@ int main( int argc, char *argv[]) gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(devTree), -1, strings[I_Dev], gtk_cell_renderer_text_new(), "text", DEVICE_NAME_COLUMN, NULL); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(devTree), - -1, strings[I_Type], gtk_cell_renderer_text_new(), "text", DEVICE_GROUP_COLUMN, NULL); + -1, strings[I_Type], gtk_cell_renderer_text_new(), "text", DEVICE_GROUP_COLUMN, NULL); //"Type" + gtk_tree_view_column_set_fixed_width(gtk_tree_view_get_column(GTK_TREE_VIEW(devTree),0),125); + gtk_tree_view_column_set_fixed_width(gtk_tree_view_get_column(GTK_TREE_VIEW(devTree),1),125); // AddDevices() gets called when an entry in devTypeCombo is selected during init devFrame = GTK_WIDGET(gtk_builder_get_object(builder,"DEVICE_NAME")); devinfo = GTK_WIDGET(gtk_builder_get_object(builder,"DEV_INFO")); @@ -2291,7 +2315,7 @@ int FindDevice(int vid,int pid){ typedef BOOLEAN (__stdcall*SETREPORT) (IN HANDLE HidDeviceObject, IN PVOID ReportBuffer, IN ULONG ReportBufferLength); typedef BOOLEAN (__stdcall*GETMANUFACTURERSTRING) (IN HANDLE HidDeviceObject, OUT PVOID ReportBuffer, IN ULONG ReportBufferLength); typedef BOOLEAN (__stdcall*GETPRODUCTSTRING) (IN HANDLE HidDeviceObject, OUT PVOID ReportBuffer, IN ULONG ReportBufferLength); - typedef BOOLEAN (__stdcall*GETINDEXEDSTRING) (IN HANDLE HidDeviceObject, IN ULONG StringIndex, OUT PVOID ReportBuffer, IN ULONG ReportBufferLength); +// typedef BOOLEAN (__stdcall*GETINDEXEDSTRING) (IN HANDLE HidDeviceObject, IN ULONG StringIndex, OUT PVOID ReportBuffer, IN ULONG ReportBufferLength); HIDD_ATTRIBUTES Attributes; SP_DEVICE_INTERFACE_DATA devInfoData; int LastDevice = FALSE; diff --git a/opgui.glade b/opgui.glade index 60b9c1a..194e5ac 100644 --- a/opgui.glade +++ b/opgui.glade @@ -228,6 +228,7 @@ <property name="spacing">5</property> <child> <object class="GtkBox"> + <property name="width-request">250</property> <property name="visible">True</property> <property name="can-focus">False</property> <property name="orientation">vertical</property> @@ -240,6 +241,7 @@ <object class="GtkLabel" id="TYPE_L"> <property name="visible">True</property> <property name="can-focus">False</property> + <property name="margin-end">3</property> <property name="label" translatable="yes">_tipo</property> </object> <packing> @@ -270,10 +272,12 @@ <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> + <property name="margin-start">5</property> <child> <object class="GtkLabel" id="DEV_SRC_L"> <property name="visible">True</property> <property name="can-focus">False</property> + <property name="margin-end">3</property> <property name="label" translatable="yes">label</property> </object> <packing> @@ -1,6 +1,6 @@ /** * \file progP16.c - algorithms to program the PIC16 (14 bit word) family of microcontrollers - * Copyright (C) 2009-2022 Alberto Maccioni + * Copyright (C) 2009-2023 Alberto Maccioni * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1146,7 +1146,7 @@ void Read16F18xxx(int dim,int dim2,int dim3,int options) PrintMessage(strings[S_noV33reg]); //Can't find 3.3V expansion board return; } - char s[256],t[256],*aux; + char s[256],t[256]; if(dim>0x8000||dim<0){ PrintMessage(strings[S_CodeLim]); //"Code size exceeds limits\r\n" return; @@ -6280,7 +6280,7 @@ void Write16F18xxx(int dim,int dim2,int options) PrintStatusSetup(); if(saveLog) fprintf(logfile,"%s\n",strings[S_StartCodeProg]); fflush(logfile); - int valid,inc; + int valid; for(;dim>0&&memCODE_W[dim-1]>=0x3fff;dim--); //skip empty space at end if(dim%rowN) dim+=rowN-dim%rowN; //grow to 32 word multiple for(i=k=0,j=0;i<dim;i+=rowN){ @@ -1,6 +1,6 @@ /** * \file progP18F.c - algorithms to program the PIC18 family of microcontrollers - * Copyright (C) 2009-2022 Alberto Maccioni + * Copyright (C) 2009-2023 Alberto Maccioni * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2015,7 +2015,7 @@ void Write18FKx(int dim,int dim2,int options,int nu1,int nu2, int nu3) // 1 10 0x380000 0x3C0000 0x2C0000 Q40-43 one-word 11 0.075 11 // 2 35 0x380000 0x3C0000 0x2C0000 Q83-84 one-word 11 0.075 11 { - int k=0,k2,z=0,i,j,x=0,w=0; + int k=0,z=0,i,j,x=0,w=0; int err=0; int devID=0,devREV=0; int MemAddr,rowN=0; @@ -5,7 +5,9 @@ Website: http://openprog.altervista.org These sources are given free of charge under the GNU General Public License version 2 Changelog (to use new features the corresponding firmware is required): -V 0.12.1 february 2023: fixed crash when filtering with "*" while some devices were selected +V 0.12.2 december 2023: fixed config write on 16F18456; support all-in-one board + +V 0.12.1 february 2023: fixed crash when selecting "*" filter; V 0.12.0 october 2022: port to GTK3; device selected via tree; added possibility to send manual commands; added 16F15213-14-23-24-25-43-44-45-54-55-56-74-75-76, @@ -1,4 +1,4 @@ -// Strings.c v0.12.0 +// Strings.c v0.12.2 #include "common.h" #define NL "\n" @@ -260,6 +260,8 @@ void strinit() STR_ID[I_Opt]="I_Opt"; STR_ID[I_Dev]="I_Dev"; STR_ID[I_Type]="I_Type"; + STR_ID[I_TypeFilt]="I_TypeFilt"; + STR_ID[I_Filt]="I_Filt"; STR_ID[I_Speed]="I_Speed"; STR_ID[I_ReadRes]="I_ReadRes"; STR_ID[I_ID_BKo_W]="I_ID_BKo_W"; @@ -537,7 +539,9 @@ void strinit() strings_it[I_Data]="Dati"; strings_it[I_Opt]="Opzioni"; strings_it[I_Dev]="Dispositivo"; - strings_it[I_Type]="Filtra per tipo"; + strings_it[I_Type]="Tipo"; + strings_it[I_TypeFilt]="Filtra per tipo"; + strings_it[I_Filt]="Filtro"; strings_it[I_Speed]="Velocità"; strings_it[I_ReadRes]="Leggi area riservata"; strings_it[I_ID_BKo_W]="Programma ID e BKosccal"; @@ -904,7 +908,9 @@ void strinit() strings_en[I_Data]="Data"; strings_en[I_Opt]="Options"; strings_en[I_Dev]="Device"; - strings_en[I_Type]="Filter by type"; + strings_en[I_Type]="Type"; + strings_en[I_TypeFilt]="Filter by type"; + strings_en[I_Filt]="Filter"; strings_en[I_Speed]="Speed"; strings_en[I_ReadRes]="Read reserved area"; strings_en[I_ID_BKo_W]="Write ID and BKosccal"; @@ -1,4 +1,4 @@ -// Strings.h v0.12.0 +// Strings.h v0.12.2 enum S { S_NL, @@ -195,6 +195,8 @@ enum S { I_Opt, I_Dev, I_Type, + I_TypeFilt, + I_Filt, I_Speed, I_ReadRes, I_ID_BKo_W, |