update firmware + sender

This commit is contained in:
Brian Peek 2022-09-27 23:35:26 -07:00
parent 8fc3c4ba03
commit 63befcb95f
4 changed files with 29 additions and 40 deletions

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="port" value="COM3"/>
<add key="baud" value="115200"/>
</appSettings>
</configuration>

View File

@ -1,34 +1,39 @@
using System.IO.Ports; using System.IO.Ports;
using System.Configuration; using System.CommandLine;
namespace SendEPROM namespace SendEPROM
{ {
public class Program public class Program
{ {
public static int Main(string[] args) public static async Task<int> Main(string[] args)
{ {
if(args.Length != 3 && args.Length != 2) var rootCmd = new RootCommand("Send a binary image to the EPROM emulator");
return Usage();
string port = ConfigurationManager.AppSettings["port"]; var portOption = new Option<string> (new string[] {"--port", "-p" }, description: "COM port on which to send the file", getDefaultValue: () => "COM3");
int baud = int.Parse(ConfigurationManager.AppSettings["baud"]); var baudOption = new Option<int> (new string[] {"--baud", "-b" }, description: "Baud rate at which to send", getDefaultValue: () => 115200);
string file = string.Empty; var modeOption = new Option<byte> (new string[] {"--mode", "-m" }, description: "EPROM mode (1 = 27C256, 2 = 27C020)", getDefaultValue: () => 2);
byte mode = 0;
if(args.Length == 2) var fileArgument = new Argument<FileInfo>("file", description: "File to send");
rootCmd.AddOption(portOption);
rootCmd.AddOption(baudOption);
rootCmd.AddOption(modeOption);
rootCmd.AddArgument(fileArgument);
rootCmd.SetHandler((port, baud, mode, file) =>
{ {
mode = byte.Parse(args[0]); SendData(port, baud, mode, file);
file = args[1]; },
} portOption, baudOption, modeOption, fileArgument);
else if(args.Length == 3)
{
port = args[0];
baud = int.Parse(args[1]);
file = args[2];
}
Console.WriteLine($"Reading {file}"); return await rootCmd.InvokeAsync(args);
byte[] buff = File.ReadAllBytes(file); }
static void SendData(string port, int baud, byte mode, FileInfo file)
{
Console.WriteLine($"Reading {file.Name}");
byte[] buff = File.ReadAllBytes(file.Name);
Console.WriteLine($"Opening {port} at {baud}"); Console.WriteLine($"Opening {port} at {baud}");
var sp = new SerialPort(port) var sp = new SerialPort(port)
@ -48,14 +53,6 @@ namespace SendEPROM
sp.Write(buff, 0, buff.Length); sp.Write(buff, 0, buff.Length);
sp.Close(); sp.Close();
Console.WriteLine("Done!"); Console.WriteLine("Done!");
return 0;
}
private static int Usage()
{
Console.WriteLine("Usage: SendEPROM [COMX] [baud] [EPROM mode] filename");
return -1;
} }
} }
} }

View File

@ -8,7 +8,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> <PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
<PackageReference Include="System.IO.Ports" Version="6.0.0" /> <PackageReference Include="System.IO.Ports" Version="6.0.0" />
</ItemGroup> </ItemGroup>

View File

@ -96,17 +96,15 @@ void loop()
switch(mode) switch(mode)
{ {
// 32Kbit, 8KB, 0x0000-0x7FFF // 256Kbit, 32KB, 0x0000-0x7FFF
case m27C256: case m27C256:
addr = ((io6 >> 16) & 0x7FFF); addr = ((io6 >> 16) & 0x7FFF);
break; break;
// 2Mbit, 256KB, 0x00000-0x3FFFF // 2Mbit, 256KB, 0x00000-0x3FFFF
case m27C020: case m27C020:
addr = ((io6 >> 16) & 0xFFFF) | ((io6 & 0x3000) << 4);
break;
default: default:
addr = ((io6 >> 16) & 0xFFFF) | ((io6 & 0x3000) << 4);
break; break;
} }