-
Notifications
You must be signed in to change notification settings - Fork 1
/
ADSEQ1.C
208 lines (187 loc) · 4.78 KB
/
ADSEQ1.C
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include "adext.h"
void BlockSeqOn(void)
{
/*
** start acquisition
*/
EventString("BLOCKON");
/*
** activate sequence to start acq
*/
sysinfo.seq[STIMSEQON].active = 1;
sysinfo.seq[STIMSEQON].time = 0;
sysinfo.seq[BLOCKSEQOFF].active = 1;
sysinfo.seq[BLOCKSEQOFF].time = ReadTS();
}
void BlockSeqOff(void)
{
/*
** stop acquisition
*/
EventString("BLOCKOFF");
/*
** activate sequence to start acq
*/
sysinfo.seq[BLOCKSEQOFF].active = 0;
sysinfo.seq[STIMSEQON].active = 0;
}
void StartStimAcq(void)
{
/*
** start acquisition
*/
StartAcq();
EventString("STIMON");
/*
** stimulate
*/
Stimulate();
/*
** activate sequence to stop acq
*/
sysinfo.seq[STIMSEQOFF].active = 1;
sysinfo.seq[STIMSEQOFF].time = ReadTS();
}
void EndStimAcq(void)
{
EventString("STIMOFF");
/*
** stop acquisition
*/
TestAndStopAcq();
/*
** shut off sequence
*/
sysinfo.seq[STIMSEQOFF].active = 0;
}
void CheckBar(void)
{
/*
** check the pio status for a bar press
*/
if(ReadPIO2() == 2){
EventString("BARPRESS");
} else {
EventString("NO PRESS");
}
}
void StartLight(void)
{
EventString("LIGHTON");
/*
** turn on the LED1
*/
RaisePIO2(2);
/*
** activate sequence to turn off the light. This will control
** the duration of the LED on period
*/
sysinfo.seq[LIGHTSEQOFF].active = 1;
sysinfo.seq[LIGHTSEQOFF].time = ReadTS();
/*
** activate wait sequence to end trial and begin
** intertrial delta. This controls length of trial
*/
sysinfo.seq[DELTASEQ].active = 1;
sysinfo.seq[DELTASEQ].time = ReadTS();
}
void EndLight(void)
{
EventString("LIGHTOFF");
/*
** turn off light
*/
WritePIO2(0x00);
/*
** inactivate the sequence to turn off the light.
** note that the light-on sequence will continue to run
*/
sysinfo.seq[LIGHTSEQOFF].active = 0;
/*
** activate the sequence to check lever and operate feeder
*/
sysinfo.seq[FEEDERSEQON].active = 1;
sysinfo.seq[FEEDERSEQON].time = ReadTS();
}
void StartDeltaWait(void)
{
EventString("END TIME TRIAL");
/*
** inactivate sequence that marks trial
*/
sysinfo.seq[DELTASEQ].active = 0;
/*
** inactivate feeder control sequences
/*
sysinfo.seq[FEEDERSEQON].active = 0;
sysinfo.seq[FEEDERSEQOFF].active = 0;
}
void TurnFeederOn(void)
{
if(ReadPIO2() == 2){
EventString("FEEDER ON");
/*
** if bar press detected operate feeder, turn on seq to
** stop feeder, and turn off feeder check/operate seq
*/
RaiseBitPIO2(1);
sysinfo.seq[FEEDERSEQOFF].active = 1;
sysinfo.seq[FFEDERSEQOFF].time = ReadTS();
sysinfo.seq[FEEDERSEQON].active = 0;
}
}
void TurnFeederOff(void)
{
EventString("FEEDER OFF");
/*
** turns off the feeder and reactivates the seq to
** check/operate the feeder
*/
LowerBitPIO2(1);
sysinfo.seq[FEEDERSEQON].active = 1;
sysinfo.seq[FEEDERSEQON].time = ReadTS();
}
void SetupSequences(void)
{
sysinfo.seq[BLOCKSEQOFF].id = BLOCKSEQ;
sysinfo.seq[BLOCKSEQOFF].interval = 0;
sysinfo.seq[BLOCKSEQOFF].func = BlockSeqOff;
sysinfo.seq[BLOCKSEQOFF].active = 0;
sysinfo.seq[BLOCKSEQ].id = BLOCKSEQ;
sysinfo.seq[BLOCKSEQ].interval = 0;
sysinfo.seq[BLOCKSEQ].func = BlockSeqOn;
sysinfo.seq[BLOCKSEQ].active = 0;
sysinfo.seq[STIMSEQON].id = STIMSEQON;
sysinfo.seq[STIMSEQON].interval = 0;
sysinfo.seq[STIMSEQON].func = StartStimAcq;
sysinfo.seq[STIMSEQON].active = 0;
sysinfo.seq[STIMSEQOFF].id = STIMSEQOFF;
sysinfo.seq[STIMSEQOFF].interval = 0;
sysinfo.seq[STIMSEQOFF].func = EndStimAcq;
sysinfo.seq[STIMSEQOFF].active = 0;
sysinfo.seq[LIGHTSEQON].id = LIGHTSEQON;
sysinfo.seq[LIGHTSEQON].interval = 0;
sysinfo.seq[LIGHTSEQON].func = StartLight;
sysinfo.seq[LIGHTSEQON].active = 0;
sysinfo.seq[LIGHTSEQOFF].id = LIGHTSEQOFF;
sysinfo.seq[LIGHTSEQOFF].interval = 20000; /* default 2 sec */
sysinfo.seq[LIGHTSEQOFF].func = EndLight;
sysinfo.seq[LIGHTSEQOFF].active = 0;
sysinfo.seq[CHECKBARSEQ].id = CHECKBARSEQ;
sysinfo.seq[CHECKBARSEQ].interval = 1000; /* check every 100 msec */
sysinfo.seq[CHECKBARSEQ].func = CheckBar;
sysinfo.seq[CHECKBARSEQ].active = 0;
sysinfo.seq[FEEDERSEQON].id = FEEDERSEQON;
sysinfo.seq[FEEDERSEQON].interval = 1000; /* check every 100 msec */
sysinfo.seq[FEEDERSEQON].func = TurnFeederOn;
sysinfo.seq[FEEDERSEQON].active = 0;
sysinfo.seq[FEEDERSEQOFF].id = FEEDERSEQOFF;
sysinfo.seq[FEEDERSEQOFF].interval = 200; /* 2 msec feeder pulse */
sysinfo.seq[FEEDERSEQOFF].func = TurnFeederOff;
sysinfo.seq[FEEDERSEQOFF].active = 0;
sysinfo.seq[DELTASEQ].id = DELTASEQ;
sysinfo.seq[DELTASEQ].interval = 100; /* check every 100 msec */
sysinfo.seq[DELTASEQ].func = StartDeltaWait;
sysinfo.seq[DELTASEQ].active = 0;
sysinfo.nseq = 10;
}