-
Notifications
You must be signed in to change notification settings - Fork 91
/
JTAGulatorUtil.spin
executable file
·80 lines (53 loc) · 2.14 KB
/
JTAGulatorUtil.spin
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
{{
+-------------------------------------------------+
| JTAGulator |
| Utility Object |
| |
| Author: Joe Grand |
| Copyright (c) 2013-2021 Grand Idea Studio, Inc. |
| Web: http://www.grandideastudio.com |
| |
| Distributed under a Creative Commons |
| Attribution 3.0 United States license |
| http://creativecommons.org/licenses/by/3.0/us/ |
+-------------------------------------------------+
Program Description:
This object provides the general purpose utility
methods for the JTAGulator.
}}
CON
TXS_ENABLE_DELAY = 10 ' Settling time (ms) after enabling level translators
' (must wait > 200nS for TXS0108E one-shot circuitry to become operational)
OBJ
g : "JTAGulatorCon" ' JTAGulator global constants
PUB LedOff
outa[g#LED_R] := 0
outa[g#LED_G] := 0
PUB LedGreen
outa[g#LED_R] := 0
outa[g#LED_G] := 1
PUB LedRed
outa[g#LED_R] := 1
outa[g#LED_G] := 0
PUB LedYellow
outa[g#LED_R] := 1
outa[g#LED_G] := 1
PUB TXSEnable ' Enable level shifter outputs
dira[g#MAX_CHAN-1..0]~ ' Set all channels as inputs to avoid contention when driver is enabled. Pin directions will be configured by other methods as needed.
outa[g#TXS_OE] := 1
Pause(TXS_ENABLE_DELAY)
PUB TXSDisable ' Disable level shifter outputs (high impedance)
outa[g#TXS_OE] := 0
PUB Set_Pins_High(start_ch, end_ch) | i ' Set range of channels to output HIGH
repeat i from start_ch to end_ch
dira[i] := 1
outa[i] := 1
PUB Set_Pins_Low(start_ch, end_ch) | i ' Set range of channels to output LOW
repeat i from start_ch to end_ch
dira[i] := 1
outa[i] := 0
PUB Set_Pins_Input(start_ch, end_ch) | i ' Set range of channels to input
repeat i from start_ch to end_ch
dira[i] := 0
PUB Pause(ms)
waitcnt(clkfreq / 1000 * ms + cnt)