Initial commit
This commit is contained in:
commit
dbd0be1188
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
bin/
|
||||
obj/
|
||||
.vs/
|
6
App.config
Normal file
6
App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
22
Program.cs
Normal file
22
Program.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TinyFPGA_VisualProgrammer
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Point d'entrée principal de l'application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Programmer());
|
||||
}
|
||||
}
|
||||
}
|
181
Programmer.Designer.cs
generated
Normal file
181
Programmer.Designer.cs
generated
Normal file
@ -0,0 +1,181 @@
|
||||
|
||||
namespace TinyFPGA_VisualProgrammer
|
||||
{
|
||||
partial class Programmer
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable nécessaire au concepteur.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Nettoyage des ressources utilisées.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Code généré par le Concepteur Windows Form
|
||||
|
||||
/// <summary>
|
||||
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
|
||||
/// le contenu de cette méthode avec l'éditeur de code.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Programmer));
|
||||
this.serialPortList = new System.Windows.Forms.ComboBox();
|
||||
this.fileExpSelect = new System.Windows.Forms.Button();
|
||||
this.launchProgramBtn = new System.Windows.Forms.Button();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.fileLocationTextBox = new System.Windows.Forms.TextBox();
|
||||
this.programStatusBar = new System.Windows.Forms.ProgressBar();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.statusLabel = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.bgWorker = new System.ComponentModel.BackgroundWorker();
|
||||
this.fileSelectDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.connectBtn = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// serialPortList
|
||||
//
|
||||
this.serialPortList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.serialPortList.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.serialPortList, "serialPortList");
|
||||
this.serialPortList.Name = "serialPortList";
|
||||
this.serialPortList.SelectedIndexChanged += new System.EventHandler(this.serialPortList_SelectedIndexChanged);
|
||||
//
|
||||
// fileExpSelect
|
||||
//
|
||||
resources.ApplyResources(this.fileExpSelect, "fileExpSelect");
|
||||
this.fileExpSelect.Name = "fileExpSelect";
|
||||
this.fileExpSelect.UseVisualStyleBackColor = true;
|
||||
this.fileExpSelect.Click += new System.EventHandler(this.fileExpSelect_Click);
|
||||
//
|
||||
// launchProgramBtn
|
||||
//
|
||||
resources.ApplyResources(this.launchProgramBtn, "launchProgramBtn");
|
||||
this.launchProgramBtn.Name = "launchProgramBtn";
|
||||
this.launchProgramBtn.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
resources.ApplyResources(this.button3, "button3");
|
||||
this.button3.Name = "button3";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// fileLocationTextBox
|
||||
//
|
||||
resources.ApplyResources(this.fileLocationTextBox, "fileLocationTextBox");
|
||||
this.fileLocationTextBox.Name = "fileLocationTextBox";
|
||||
this.fileLocationTextBox.ReadOnly = true;
|
||||
//
|
||||
// programStatusBar
|
||||
//
|
||||
resources.ApplyResources(this.programStatusBar, "programStatusBar");
|
||||
this.programStatusBar.Name = "programStatusBar";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.statusLabel);
|
||||
resources.ApplyResources(this.groupBox1, "groupBox1");
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// statusLabel
|
||||
//
|
||||
resources.ApplyResources(this.statusLabel, "statusLabel");
|
||||
this.statusLabel.Name = "statusLabel";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
resources.ApplyResources(this.label1, "label1");
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Image = global::TinyFPGA_VisualProgrammer.Properties.Resources.softBanner;
|
||||
this.pictureBox1.InitialImage = global::TinyFPGA_VisualProgrammer.Properties.Resources.softBanner;
|
||||
resources.ApplyResources(this.pictureBox1, "pictureBox1");
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
resources.ApplyResources(this.label2, "label2");
|
||||
this.label2.Name = "label2";
|
||||
//
|
||||
// bgWorker
|
||||
//
|
||||
this.bgWorker.WorkerReportsProgress = true;
|
||||
//
|
||||
// fileSelectDialog
|
||||
//
|
||||
this.fileSelectDialog.DefaultExt = "hex";
|
||||
this.fileSelectDialog.FileName = "bitmap.hex";
|
||||
resources.ApplyResources(this.fileSelectDialog, "fileSelectDialog");
|
||||
this.fileSelectDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.fileSelectDialog_FileOk);
|
||||
//
|
||||
// connectBtn
|
||||
//
|
||||
resources.ApplyResources(this.connectBtn, "connectBtn");
|
||||
this.connectBtn.Name = "connectBtn";
|
||||
this.connectBtn.UseVisualStyleBackColor = true;
|
||||
this.connectBtn.Click += new System.EventHandler(this.connectBtn_Click);
|
||||
//
|
||||
// Programmer
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.connectBtn);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.fileLocationTextBox);
|
||||
this.Controls.Add(this.serialPortList);
|
||||
this.Controls.Add(this.button3);
|
||||
this.Controls.Add(this.fileExpSelect);
|
||||
this.Controls.Add(this.programStatusBar);
|
||||
this.Controls.Add(this.launchProgramBtn);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "Programmer";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox serialPortList;
|
||||
private System.Windows.Forms.Button fileExpSelect;
|
||||
private System.Windows.Forms.Button launchProgramBtn;
|
||||
private System.Windows.Forms.Button button3;
|
||||
private System.Windows.Forms.TextBox fileLocationTextBox;
|
||||
private System.Windows.Forms.ProgressBar programStatusBar;
|
||||
private System.ComponentModel.BackgroundWorker bgWorker;
|
||||
private System.Windows.Forms.OpenFileDialog fileSelectDialog;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label statusLabel;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Button connectBtn;
|
||||
}
|
||||
}
|
||||
|
98
Programmer.cs
Normal file
98
Programmer.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.IO.Ports;
|
||||
|
||||
namespace TinyFPGA_VisualProgrammer
|
||||
{
|
||||
public partial class Programmer : Form
|
||||
{
|
||||
SerialController sController = null;
|
||||
TinyProg TProg = null;
|
||||
|
||||
public Programmer()
|
||||
{
|
||||
InitializeComponent();
|
||||
fileSelectDialog.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath);
|
||||
this.AllowDrop = true;
|
||||
this.DragEnter += new DragEventHandler(Programmer_DragEnter);
|
||||
this.DragDrop += new DragEventHandler(Programmer_DragDrop);
|
||||
|
||||
sController = new SerialController();
|
||||
TProg = new TinyProg(sController);
|
||||
if (sController.sPortsList != null && sController.sPortsList.Count > 0)
|
||||
{
|
||||
foreach (string s in sController.sPortsList)
|
||||
serialPortList.Items.Add(s);
|
||||
|
||||
serialPortList.SelectedIndex = serialPortList.Items.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Programmer_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
|
||||
void Programmer_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
//if(Path.GetExtension(files.First()) == "hex")
|
||||
fileLocationTextBox.Text = files.First();
|
||||
fileSelectDialog.FileName = files.First();
|
||||
launchProgramBtn.Enabled = true;
|
||||
}
|
||||
|
||||
private void fileExpSelect_Click(object sender, EventArgs e)
|
||||
{
|
||||
fileSelectDialog.ShowDialog();
|
||||
}
|
||||
|
||||
private void fileSelectDialog_FileOk(object sender, CancelEventArgs e)
|
||||
{
|
||||
fileLocationTextBox.Text = fileSelectDialog.FileName;
|
||||
launchProgramBtn.Enabled = true;
|
||||
}
|
||||
|
||||
private void connectBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
connectBtn.Enabled = false;
|
||||
|
||||
if (sController.GetPortOpened())
|
||||
{
|
||||
sController.ClosePort();
|
||||
connectBtn.Text = "Connect";
|
||||
statusLabel.Text = "--";
|
||||
}
|
||||
else
|
||||
{
|
||||
sController.comPortName = serialPortList.SelectedItem.ToString();
|
||||
sController.OpenPort();
|
||||
if (sController.GetPortOpened())
|
||||
TProg.CheckTinyPresence();
|
||||
if (TProg.TinyFPGAIsConnected)
|
||||
statusLabel.Text = "XXXX found.";
|
||||
else
|
||||
statusLabel.Text = "No TinyFPGA found.";
|
||||
connectBtn.Text = "Disconnect";
|
||||
}
|
||||
|
||||
connectBtn.Enabled = true;
|
||||
}
|
||||
|
||||
private void serialPortList_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (serialPortList.SelectedItem.ToString().Length > 0)
|
||||
connectBtn.Enabled = true;
|
||||
else
|
||||
connectBtn.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
2270
Programmer.resx
Normal file
2270
Programmer.resx
Normal file
File diff suppressed because it is too large
Load Diff
36
Properties/AssemblyInfo.cs
Normal file
36
Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Les informations générales relatives à un assembly dépendent de
|
||||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
|
||||
// associées à un assembly.
|
||||
[assembly: AssemblyTitle("TinyFPGA-VisualProgrammer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TinyFPGA-VisualProgrammer")]
|
||||
[assembly: AssemblyCopyright("GPL v3")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
|
||||
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
|
||||
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
|
||||
[assembly: Guid("6917bc1d-eb8a-4dcd-89af-be183a82ba39")]
|
||||
|
||||
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
|
||||
//
|
||||
// Version principale
|
||||
// Version secondaire
|
||||
// Numéro de build
|
||||
// Révision
|
||||
//
|
||||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
|
||||
// en utilisant '*', comme indiqué ci-dessous :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
83
Properties/Resources.Designer.cs
generated
Normal file
83
Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,83 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Ce code a été généré par un outil.
|
||||
// Version du runtime :4.0.30319.42000
|
||||
//
|
||||
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
|
||||
// le code est régénéré.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TinyFPGA_VisualProgrammer.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
|
||||
/// </summary>
|
||||
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
|
||||
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
|
||||
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
|
||||
// avec l'option /str ou régénérez votre projet VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TinyFPGA_VisualProgrammer.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
|
||||
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap softBanner {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("softBanner", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Icon semblable à (Icône).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon tinyfpga_icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("tinyfpga_icon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
127
Properties/Resources.resx
Normal file
127
Properties/Resources.resx
Normal file
@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="softBanner" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\softBanner.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="tinyfpga_icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\tinyfpga-icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
29
Properties/Settings.Designer.cs
generated
Normal file
29
Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace TinyFPGA_VisualProgrammer.Properties
|
||||
{
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
Properties/Settings.settings
Normal file
7
Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
BIN
Resources/softBanner.png
Normal file
BIN
Resources/softBanner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
Resources/tinyfpga-icon.ico
Normal file
BIN
Resources/tinyfpga-icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
118
SerialController.cs
Normal file
118
SerialController.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO.Ports;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace TinyFPGA_VisualProgrammer
|
||||
{
|
||||
public class SerialController
|
||||
{
|
||||
SerialPort mainSerial = new SerialPort();
|
||||
public List<string> sPortsList { get; private set; }
|
||||
public string comPortName { get; set; }
|
||||
|
||||
public SerialController()
|
||||
{
|
||||
mainSerial.BaudRate = 9600;
|
||||
List<string> usbPorts = ComPortNames("1D50", "6130");
|
||||
if (usbPorts.Count > 0)
|
||||
{
|
||||
sPortsList = new List<string>();
|
||||
foreach (string s in SerialPort.GetPortNames())
|
||||
{
|
||||
if (usbPorts.Contains(s))
|
||||
sPortsList.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenPort()
|
||||
{
|
||||
mainSerial.PortName = comPortName;
|
||||
mainSerial.ReadTimeout = 2000;
|
||||
mainSerial.WriteTimeout = 5000;
|
||||
try
|
||||
{
|
||||
mainSerial.Open();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public void ClosePort()
|
||||
{
|
||||
try
|
||||
{
|
||||
mainSerial.Close();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public bool GetPortOpened()
|
||||
{
|
||||
return mainSerial.IsOpen;
|
||||
}
|
||||
|
||||
public void SendBytes(byte[] db, int dc)
|
||||
{
|
||||
mainSerial.WriteTimeout = 5000;
|
||||
|
||||
try
|
||||
{
|
||||
mainSerial.Write(db, 0, dc);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public byte[] WaitForBytes(int dc)
|
||||
{
|
||||
byte[] result = new byte[dc];
|
||||
|
||||
mainSerial.ReadTimeout = 2000;
|
||||
|
||||
try
|
||||
{
|
||||
mainSerial.Read(result, 0, dc);
|
||||
}
|
||||
catch { }
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compile an array of COM port names associated with given VID and PID
|
||||
/// </summary>
|
||||
/// <param name="VID"></param>
|
||||
/// <param name="PID"></param>
|
||||
/// <returns></returns>
|
||||
List<string> ComPortNames(String VID, String PID)
|
||||
{
|
||||
String pattern = String.Format("^VID_{0}.PID_{1}", VID, PID);
|
||||
Regex _rx = new Regex(pattern, RegexOptions.IgnoreCase);
|
||||
List<string> comports = new List<string>();
|
||||
RegistryKey rk1 = Registry.LocalMachine;
|
||||
RegistryKey rk2 = rk1.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum");
|
||||
foreach (String s3 in rk2.GetSubKeyNames())
|
||||
{
|
||||
RegistryKey rk3 = rk2.OpenSubKey(s3);
|
||||
foreach (String s in rk3.GetSubKeyNames())
|
||||
{
|
||||
if (_rx.Match(s).Success)
|
||||
{
|
||||
RegistryKey rk4 = rk3.OpenSubKey(s);
|
||||
foreach (String s2 in rk4.GetSubKeyNames())
|
||||
{
|
||||
RegistryKey rk5 = rk4.OpenSubKey(s2);
|
||||
RegistryKey rk6 = rk5.OpenSubKey("Device Parameters");
|
||||
comports.Add((string)rk6.GetValue("PortName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return comports;
|
||||
}
|
||||
}
|
||||
}
|
98
TinyFPGA-VisualProgrammer.csproj
Normal file
98
TinyFPGA-VisualProgrammer.csproj
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6917BC1D-EB8A-4DCD-89AF-BE183A82BA39}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>TinyFPGA_VisualProgrammer</RootNamespace>
|
||||
<AssemblyName>TinyFPGA-VisualProgrammer</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\tinyfpga-icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>TinyFPGA_VisualProgrammer.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Programmer.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Programmer.Designer.cs">
|
||||
<DependentUpon>Programmer.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SerialController.cs" />
|
||||
<Compile Include="TinyProg.cs" />
|
||||
<EmbeddedResource Include="Programmer.resx">
|
||||
<DependentUpon>Programmer.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\softBanner.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\tinyfpga-icon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
25
TinyFPGA-VisualProgrammer.sln
Normal file
25
TinyFPGA-VisualProgrammer.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30907.101
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinyFPGA-VisualProgrammer", "TinyFPGA-VisualProgrammer.csproj", "{6917BC1D-EB8A-4DCD-89AF-BE183A82BA39}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6917BC1D-EB8A-4DCD-89AF-BE183A82BA39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6917BC1D-EB8A-4DCD-89AF-BE183A82BA39}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6917BC1D-EB8A-4DCD-89AF-BE183A82BA39}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6917BC1D-EB8A-4DCD-89AF-BE183A82BA39}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8FF556F6-777A-4303-BD2F-6C9543C14057}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
169
TinyProg.cs
Normal file
169
TinyProg.cs
Normal file
@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TinyFPGA_VisualProgrammer
|
||||
{
|
||||
public class TinyProg
|
||||
{
|
||||
SerialController pPort = null;
|
||||
byte SecurePage_bitOffset = 0x00;
|
||||
byte SecurePage_writeCmd = 0x00;
|
||||
byte SecurePage_readCmd = 0x00;
|
||||
byte SecurePage_eraseCmd = 0x00;
|
||||
|
||||
public bool TinyFPGAIsConnected { get; private set; }
|
||||
|
||||
public TinyProg(SerialController p)
|
||||
{
|
||||
TinyFPGAIsConnected = false;
|
||||
if (p != null)
|
||||
pPort = p;
|
||||
}
|
||||
|
||||
|
||||
public void CheckTinyPresence()
|
||||
{
|
||||
WakeCmd();
|
||||
byte[] flash_id = RetrieveFlashID();
|
||||
if (flash_id.Length >= 3)
|
||||
{
|
||||
if (flash_id[0] == 0x9D && flash_id[2] == 0x60)
|
||||
{
|
||||
// ISSI
|
||||
SecurePage_bitOffset = 4;
|
||||
SecurePage_writeCmd = 0x62;
|
||||
SecurePage_readCmd = 0x68;
|
||||
SecurePage_eraseCmd = 0x64;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Adesto
|
||||
SecurePage_bitOffset = 0;
|
||||
SecurePage_writeCmd = 0x42;
|
||||
SecurePage_readCmd = 0x48;
|
||||
SecurePage_eraseCmd = 0x44;
|
||||
}
|
||||
|
||||
TinyFPGAIsConnected = true;
|
||||
}
|
||||
|
||||
//@TODO: Add json security parser
|
||||
}
|
||||
|
||||
byte[] SendCommand(byte opcode, byte[] addr, byte[] datas, uint read_len = 0)
|
||||
{
|
||||
if (addr == null)
|
||||
addr = new byte[] { };
|
||||
if (datas == null)
|
||||
datas = new byte[] { };
|
||||
|
||||
byte[] _ret = new byte[read_len];
|
||||
byte[] cmdSequence = new byte[sizeof(byte) + sizeof(ushort) + sizeof(ushort) + sizeof(byte) + addr.Length + datas.Length];
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Prepare datas container
|
||||
*/
|
||||
cmdSequence[0] = 0x01;
|
||||
|
||||
ushort seqSize = (ushort)(1 + addr.Length + datas.Length);
|
||||
cmdSequence[1] = (byte)(seqSize & 0xFF); // LSB
|
||||
cmdSequence[2] = (byte)((seqSize >> 8) & 0xFF);
|
||||
|
||||
cmdSequence[3] = (byte)(read_len & 0xFF); // LSB
|
||||
cmdSequence[4] = (byte)((read_len >> 8) & 0xFF);
|
||||
|
||||
cmdSequence[5] = opcode;
|
||||
i = 6;
|
||||
foreach (byte ab in addr)
|
||||
cmdSequence[i++] = ab;
|
||||
i = 6 + addr.Length;
|
||||
foreach (byte d in datas)
|
||||
cmdSequence[i++] = d;
|
||||
|
||||
/*
|
||||
* Send datas container through serial line
|
||||
*/
|
||||
pPort.SendBytes(cmdSequence, cmdSequence.Length);
|
||||
|
||||
if (read_len > 0)
|
||||
{
|
||||
_ret = pPort.WaitForBytes((int)read_len);
|
||||
}
|
||||
|
||||
return _ret;
|
||||
}
|
||||
|
||||
public void WakeCmd()
|
||||
{
|
||||
SendCommand(0xab, null, null);
|
||||
}
|
||||
|
||||
byte[] RetrieveFlashID()
|
||||
{
|
||||
return SendCommand(0x9f, null, null, 3);
|
||||
}
|
||||
|
||||
void FlashWriteEnable()
|
||||
{
|
||||
SendCommand(0x06, null, null);
|
||||
}
|
||||
|
||||
void FlashWriteDisable()
|
||||
{
|
||||
SendCommand(0x04, null, null);
|
||||
}
|
||||
|
||||
byte RetrieveStatus()
|
||||
{
|
||||
return SendCommand(0x05, null, null, 1)[0];
|
||||
}
|
||||
|
||||
void WaitWhileBusy()
|
||||
{
|
||||
while ((RetrieveStatus() & 1) == 1) { }
|
||||
}
|
||||
|
||||
void EraseSecureRegPage(uint page)
|
||||
{
|
||||
FlashWriteEnable();
|
||||
SendCommand(SecurePage_eraseCmd, BitConverter.GetBytes(page << 8 + SecurePage_bitOffset), null);
|
||||
WaitWhileBusy();
|
||||
}
|
||||
|
||||
void ProgramSecureRegPage(uint page, byte[] data)
|
||||
{
|
||||
FlashWriteEnable();
|
||||
SendCommand(SecurePage_writeCmd, BitConverter.GetBytes(page << 8 + SecurePage_bitOffset), data);
|
||||
WaitWhileBusy();
|
||||
}
|
||||
|
||||
byte[] ReadSecureRegPage(uint page)
|
||||
{
|
||||
return SendCommand(SecurePage_readCmd, BitConverter.GetBytes(page << 8 + SecurePage_bitOffset), new byte[] { 0x00 }, 255);
|
||||
}
|
||||
}
|
||||
|
||||
public class TinyMeta
|
||||
{
|
||||
TinyProg tProg;
|
||||
//JSONRoot root;
|
||||
|
||||
public TinyMeta(TinyProg tProg)
|
||||
{
|
||||
this.tProg = tProg;
|
||||
tProg.WakeCmd();
|
||||
//this.root = ReadMetadata();
|
||||
}
|
||||
|
||||
|
||||
void ParseJSON()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user