Skip to content

Commit

Permalink
Added CH347 frequency menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nofeletru committed Sep 7, 2024
1 parent 29d9745 commit 8da57fa
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 6 deletions.
7 changes: 4 additions & 3 deletions software/ch347hw.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
interface

uses
Classes, SysUtils, basehw, msgstr, ch347dll, ch341dll, utilfunc;
Classes, SysUtils, basehw, msgstr, ch347dll, ch341dll;

type

Expand Down Expand Up @@ -117,7 +117,7 @@ function TCH347Hardware.SPIInit(speed: integer): boolean;
with FDevSPIConfig do
begin
iMode:= 0;
iClock:= 0;
iClock:= speed;
iByteOrder:= 1;
iSpiWriteReadInterval:= 0;
iSpiOutDefaultData:= 0;
Expand Down Expand Up @@ -267,7 +267,8 @@ function TCH347Hardware.I2CWriteByte(data: byte): boolean;
function TCH347Hardware.MWInit(speed: integer): boolean;
begin
if not FDevOpened then Exit(false);

main.LogPrint('MICROWIRE not supported');
Exit(false);
end;

procedure TCH347Hardware.MWDeInit;
Expand Down
54 changes: 52 additions & 2 deletions software/main.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,8 @@ object MainForm: TMainForm
Width = 853
Align = alBottom
Lines.Strings = (
'AsProgrammer v2.0.2'
'AsProgrammer v2.1.0'
'https://github.com/nofeletru/UsbAsp-flash'
'asprogrammer@inbox.ru'
)
ParentFont = False
PopupMenu = LogPopupMenu
Expand Down Expand Up @@ -749,6 +748,57 @@ object MainForm: TMainForm
end
object MenuSPI: TMenuItem
Caption = 'SPI'
object MenuCH347SPIClock: TMenuItem
Caption = 'Частота'
object MenuCH347SPIClock60MHz: TMenuItem
AutoCheck = True
Caption = '60 MHz'
Checked = True
RadioItem = True
end
object MenuCH347SPIClock30MHz: TMenuItem
Tag = 1
AutoCheck = True
Caption = '30 MHz'
RadioItem = True
end
object MenuCH347SPIClock15MHz: TMenuItem
Tag = 2
AutoCheck = True
Caption = '15 MHz'
RadioItem = True
end
object MenuCH347SPIClock7_5MHz: TMenuItem
Tag = 3
AutoCheck = True
Caption = '7.5 MHz'
RadioItem = True
end
object MenuCH347SPIClock3_75MHz: TMenuItem
Tag = 4
AutoCheck = True
Caption = '3.75 MHz'
RadioItem = True
end
object MenuCH347SPIClock1_875MHz: TMenuItem
Tag = 5
AutoCheck = True
Caption = '1.875 MHz'
RadioItem = True
end
object MenuCH347SPIClock937_5KHz: TMenuItem
Tag = 6
AutoCheck = True
Caption = '937.5 KHz'
RadioItem = True
end
object MenuCH347SPIClock468_75KHz: TMenuItem
Tag = 7
AutoCheck = True
Caption = '468.75 KHz'
RadioItem = True
end
end
object MenuArduinoSPIClock: TMenuItem
Caption = 'Частота'
object MenuArduinoISP8MHz: TMenuItem
Expand Down
29 changes: 28 additions & 1 deletion software/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ TMainForm = class(TForm)
MenuFT232SPI30Mhz: TMenuItem;
MenuFT232SPI6Mhz: TMenuItem;
MenuHWCH347: TMenuItem;
MenuCH347SPIClock: TMenuItem;
MenuCH347SPIClock468_75KHz: TMenuItem;
MenuCH347SPIClock60MHz: TMenuItem;
MenuCH347SPIClock30MHz: TMenuItem;
MenuCH347SPIClock15MHz: TMenuItem;
MenuCH347SPIClock7_5MHz: TMenuItem;
MenuCH347SPIClock3_75MHz: TMenuItem;
MenuCH347SPIClock1_875MHz: TMenuItem;
MenuCH347SPIClock937_5KHz: TMenuItem;
MenuSendAB: TMenuItem;
StartAddressEdit: TEdit;
GroupChipSettings: TGroupBox;
Expand Down Expand Up @@ -514,6 +523,18 @@ function SetSPISpeed(OverrideSpeed: byte): integer;
if MainForm.MenuFT232SPI6Mhz.Checked then Speed := MainForm.MenuFT232SPI6Mhz.Tag;
end;

if (MainForm.RadioSPI.Checked) and (AsProgrammer.Current_HW = CHW_CH347) then
begin
if MainForm.MenuCH347SPIClock60MHz.Checked then Speed := MainForm.MenuCH347SPIClock60MHz.Tag;
if MainForm.MenuCH347SPIClock30MHz.Checked then Speed := MainForm.MenuCH347SPIClock30MHz.Tag;
if MainForm.MenuCH347SPIClock15MHz.Checked then Speed := MainForm.MenuCH347SPIClock15MHz.Tag;
if MainForm.MenuCH347SPIClock7_5MHz.Checked then Speed := MainForm.MenuCH347SPIClock7_5MHz.Tag;
if MainForm.MenuCH347SPIClock3_75MHz.Checked then Speed := MainForm.MenuCH347SPIClock3_75MHz.Tag;
if MainForm.MenuCH347SPIClock1_875MHz.Checked then Speed := MainForm.MenuCH347SPIClock1_875MHz.Tag;
if MainForm.MenuCH347SPIClock937_5KHz.Checked then Speed := MainForm.MenuCH347SPIClock937_5KHz.Tag;
if MainForm.MenuCH347SPIClock468_75KHz.Checked then Speed := MainForm.MenuCH347SPIClock468_75KHz.Tag;
end;

if OverrideSpeed <> 0 then Speed := OverrideSpeed;

result := speed;
Expand Down Expand Up @@ -1730,6 +1751,7 @@ procedure SelectHW(programmer: THardwareList);
if programmer = CHW_USBASP then
begin
MainForm.MenuSPIClock.Visible:= true;
MainForm.MenuCH347SPIClock.Visible:= false;
MainForm.MenuAVRISPSPIClock.Visible:= false;
MainForm.MenuArduinoSPIClock.Visible:= false;
MainForm.MenuFT232SPIClock.Visible:= false;
Expand All @@ -1740,6 +1762,7 @@ procedure SelectHW(programmer: THardwareList);
if programmer = CHW_CH341 then
begin
MainForm.MenuSPIClock.Visible:= false;
MainForm.MenuCH347SPIClock.Visible:= false;
MainForm.MenuAVRISPSPIClock.Visible:= false;
MainForm.MenuArduinoSPIClock.Visible:= false;
MainForm.MenuFT232SPIClock.Visible:= false;
Expand All @@ -1749,6 +1772,7 @@ procedure SelectHW(programmer: THardwareList);

if programmer = CHW_CH347 then
begin
MainForm.MenuCH347SPIClock.Visible:= true;
MainForm.MenuSPIClock.Visible:= false;
MainForm.MenuAVRISPSPIClock.Visible:= false;
MainForm.MenuArduinoSPIClock.Visible:= false;
Expand All @@ -1760,6 +1784,7 @@ procedure SelectHW(programmer: THardwareList);
if programmer = CHW_AVRISP then
begin
MainForm.MenuSPIClock.Visible:= false;
MainForm.MenuCH347SPIClock.Visible:= false;
MainForm.MenuAVRISPSPIClock.Visible:= true;
MainForm.MenuArduinoSPIClock.Visible:= false;
MainForm.MenuFT232SPIClock.Visible:= false;
Expand All @@ -1770,6 +1795,7 @@ procedure SelectHW(programmer: THardwareList);
if programmer = CHW_ARDUINO then
begin
MainForm.MenuSPIClock.Visible:= false;
MainForm.MenuCH347SPIClock.Visible:= false;
MainForm.MenuAVRISPSPIClock.Visible:= false;
MainForm.MenuArduinoSPIClock.Visible:= true;
MainForm.MenuFT232SPIClock.Visible:= false;
Expand All @@ -1780,6 +1806,7 @@ procedure SelectHW(programmer: THardwareList);
if programmer = CHW_FT232H then
begin
MainForm.MenuFT232SPIClock.Visible:= true;
MainForm.MenuCH347SPIClock.Visible:= false;
MainForm.MenuSPIClock.Visible:= false;
MainForm.MenuAVRISPSPIClock.Visible:= false;
MainForm.MenuArduinoSPIClock.Visible:= false;
Expand Down Expand Up @@ -2908,7 +2935,7 @@ procedure TMainForm.ButtonReadClick(Sender: TObject);
Exit;
end;

AsProgrammer.Programmer.MWInit(SetSPISpeed(0));
if not AsProgrammer.Programmer.MWInit(SetSPISpeed(0)) then Exit;
TimeCounter := Time();
ReadFlashMW(RomF, StrToInt(ComboMWBitLen.Text), 0, StrToInt(ComboChipSize.Text));

Expand Down

0 comments on commit 8da57fa

Please sign in to comment.