Hardware Reference
In-Depth Information
144 * Queue up a command for the controller thread :
145 */
146 static void
147 queue_cmd( char new_cmd) {
148
149 pthread_mutex_lock(&mutex); /* Gain exclusive access */
150
151 /* Wait until controller grabs and zeros cmd */
152 while ( cmd )
153 pthread_cond_wait(&cond ,&mutex);
154
155 cmd = new_cmd; /* Deposit new command */
156
157 pthread_mutex_unlock(&mutex); /* Unlock */
158 pthread_cond_signal(&cond); /* Signal that cmd is there */
159 }
160
161 /*
162 * Stop the current operation :
163 */
164 static void
165 stop_cmd(void) {
166 for ( stop = 1; !stopped; stop = 1 )
167 await(0.100);
168 }
169
170 /*
171 * Provide usage info :
172 */
173 static void
174 help(void) {
175 puts("Enter :\n"
176 " 1 − One phase mode\n"
177 " 2 − Two phase mode\n"
178 " 3 − Half step mode\n"
179 " R − Toggle Reverse (counter−clockwise)\n"
180 " F − Toggle Forward (clockwise)\n"
181 " S − Stop motor\n"
182 " + − Step forward\n"
183 " − − Step backwards\n"
184 " > − Faster step times \n"
185 " < − Slower step times \n"
186 " ? − Help\n"
187 " Q − Quit\n " ) ;
188 }
189
190 /*
Search WWH ::




Custom Search