Hardware Reference
In-Depth Information
191 * Main program
192 */
193 int
194 main(int argc,char **argv) {
195 pthread_t tid; /* Thread id */
196 int tty = 0; /* Use stdin */
197 struct termios sv_ios, ios;
198 int rc, quit;
199 char ch, lcmd = 0;
200
201 rc = tcgetattr (tty,&sv_ios); /* Save current settings */
202 assert(!rc);
203 ios = sv_ios;
204 cfmakeraw(&ios); /* Make into a raw config */
205 ios.c_oflag = OPOST | ONLCR; /* Keep output editing */
206 rc = tcsetattr(tty,TCSAFLUSH,&ios); /* Put into raw mode */
207 assert(!rc);
208
209 /*
210 * Initialize and configure GPIO pins :
211 */
212 gpio_init();
213 gpio_config(g_enable,Output);
214 gpio_config(g_in1,Output);
215 gpio_config(g_in2,Output);
216 gpio_config(g_in3,Output);
217 gpio_config(g_in4, Output);
218
219 enable(0); /* Turn off output */
220 set_mode(0); /* Default is one phase mode */
221
222 help();
223
224 pthread_mutex_init(&mutex,0); /* Mutex for inter−thread
locking */
225 pthread_cond_init(&cond,0); /* For inter−thread signaling */
226 pthread_create(&tid,0,controller,0); /* The thread itself */
227
228 /*
229 * Process single-character commands :
230 */
231 for ( quit=0; !quit; ) {
232 /*
233 * Prompt and read input char :
234 */
235 write(1,": ",2);
 
Search WWH ::




Custom Search