-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
32u4-ATL3_interface.ino
148 lines (121 loc) · 3.1 KB
/
32u4-ATL3_interface.ino
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
146
147
/*
The clock signal goes to pinClock (11) and each Top from the probe goes to pinTop.
Both are recorded on track GPIO21 and PWM (GPIO6) from the Raspberry pi, using the ADC code.
test1 and test2 do not have the nop instructions between pin11 output
test3 and test4 have.
#define SAMPLE_SIZE 1000000 (both in scope.c -- the module, and in read.cpp)
*/
int pos = 0;
int pinClock = 11; //analog pin 12
int pinTop = 12; //analog pin 12
int pinLED = 13;
int pinLEDSD = 8;
int LEDStatus = 0;
int LEDStatusSD = 0;
void setup() {
pinMode(pinLED, OUTPUT);
pinMode(pinLEDSD, OUTPUT);
pinMode(pinClock, OUTPUT);
pinMode(pinTop, OUTPUT);
digitalWrite(pinLEDSD, LEDStatusSD);
digitalWrite(pinLED, LEDStatus);
attachInterrupt(2, updatePos, RISING);
}
void loop() {
// put your main code here, to run repeatedly:
StreamPos();
}
void updatePos() {
pos = 0;
digitalWrite(pinTop, HIGH);
LEDStatus = !LEDStatus;
digitalWrite(pinLED, LEDStatus);
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinTop, LOW);
}
void StreamPos() {
pos = pos + 1;
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, HIGH && (pos & B00100000));
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, LOW);
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, HIGH && (pos & B00010000));
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, LOW);
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, HIGH && (pos & B00001000));
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, LOW);
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, HIGH && (pos & B00000100));
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, LOW);
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, HIGH && (pos & B00000010));
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, LOW);
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, HIGH && (pos & B00000001));
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
digitalWrite(pinClock, LOW);
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
}