-
Notifications
You must be signed in to change notification settings - Fork 4
/
OX-Only_SMD
145 lines (122 loc) · 4.61 KB
/
OX-Only_SMD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/python3
# Python wrapper for Xenium programming using Pi-ZeroW PC-Board
#
# Copyright (C) 2019 Koos du Preez (kdupreez@hotmail.com)
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
import subprocess
import RPi.GPIO as GPIO
import time
print("▒██ ██▒▓█████ ███▄ █ ██▓ █ ██ ███▄ ▄███▓")
print("▒▒ █ █ ▒░▓█ ▀ ██ ▀█ █ ▓██▒ ██ ▓██▒▓██▒▀█▀ ██▒")
print("░░ █ ░▒███ ▓██ ▀█ ██▒▒██▒▓██ ▒██░▓██ ▓██░")
print(" ░ █ █ ▒ ▒▓█ ▄ ▓██▒ ▐▌██▒░██░▓▓█ ░██░▒██ ▒██ ")
print("▒██▒ ▒██▒░▒████▒▒██░ ▓██░░██░▒▒█████▓ ▒██▒ ░██▒")
print("▒▒ ░ ░▓ ░░░ ▒░ ░░ ▒░ ▒ ▒ ░▓ ░▒▓▒ ▒ ▒ ░ ▒░ ░ ░")
print("░░ ░▒ ░ ░ ░ ░░ ░░ ░ ▒░ ▒ ░░░▒Programmer░ ░")
print(" ░ ░ ░ ░ ░ ░ ▒kooscode@github ░ ")
print(" ░ ░ ░ ░ ░ ░ ░ ░ ", flush=True)
# git root folder.
programmer_root = os.getcwd()
# Commands
cmd_jtag = os.path.join(programmer_root, "xenium-flash/bin/xenium-jtag")
cmd_jflash = os.path.join(programmer_root, "xenium-flash/bin/xenium-flash-smd")
cmd_jverify = os.path.join(programmer_root, "xenium-flash/bin/xenium-verify-smd")
# Data Files
flash_jed = os.path.join(programmer_root, "xenium-bin/xeniumflash.jed")
xenium_os = os.path.join(programmer_root, "xenium-bin/xenium_blue.bin")
xenium_jed= os.path.join(programmer_root, "xenium-bin/openxenium.jed")
# LED Pins
led1 = 19
led2 = 6
led3 = 7
S1led = 10
S2led = 9
S3led = 11
S4led = 26
def set_ok():
GPIO.output(led1, GPIO.HIGH)
GPIO.output(led2, GPIO.LOW)
GPIO.output(led3, GPIO.LOW)
def set_busy():
GPIO.output(led1, GPIO.LOW)
GPIO.output(led2, GPIO.HIGH)
GPIO.output(led3, GPIO.LOW)
def set_error():
GPIO.output(led1, GPIO.LOW)
GPIO.output(led2, GPIO.LOW)
GPIO.output(led3, GPIO.HIGH)
def S1():
GPIO.output(S1led, GPIO.HIGH)
GPIO.output(S2led, GPIO.LOW)
GPIO.output(S3led, GPIO.LOW)
GPIO.output(S4led, GPIO.LOW)
def S2():
GPIO.output(S1led, GPIO.LOW)
GPIO.output(S2led, GPIO.HIGH)
GPIO.output(S3led, GPIO.LOW)
GPIO.output(S4led, GPIO.LOW)
def S3():
GPIO.output(S1led, GPIO.LOW)
GPIO.output(S2led, GPIO.LOW)
GPIO.output(S3led, GPIO.HIGH)
GPIO.output(S4led, GPIO.LOW)
def S4():
GPIO.output(S1led, GPIO.LOW)
GPIO.output(S2led, GPIO.LOW)
GPIO.output(S3led, GPIO.LOW)
GPIO.output(S4led, GPIO.HIGH)
def set_init():
GPIO.output(led1, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(led2, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(led3, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(S1led, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(S2led, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(S3led, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(S4led, GPIO.HIGH)
time.sleep(0.1)
#using Broadcom pin numbering.
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
#setup pin as output
GPIO.setup(led1, GPIO.OUT)
GPIO.setup(led2, GPIO.OUT)
GPIO.setup(led3, GPIO.OUT)
GPIO.setup(S1led, GPIO.OUT)
GPIO.setup(S2led, GPIO.OUT)
GPIO.setup(S3led, GPIO.OUT)
GPIO.setup(S4led, GPIO.OUT)
set_init()
set_busy()
S4()
# Program CPLD with OpenXenium Firmware.
print("---------------------------------------------")
print("PROGRAMMING XILINX CPLD: OPEN XENIUM FIRMWARE")
print("---------------------------------------------", flush=True)
sub_proc = subprocess.run([cmd_jtag, xenium_jed])
if sub_proc.returncode == 0:
set_ok()
GPIO.output(S4led, GPIO.LOW)
else:
print("ERROR Programming the Xilinx CPLD!")
print("Please double check your JTAG connection and wires!", flush=True)
set_error()