target/unix/asuro_unix_decode.c

Go to the documentation of this file.
00001 /**@file 
00002  * 
00003  * Decode simulated IO vector.
00004  * 
00005  * @author Denis Martin
00006  * 
00007  * This program is free software; you can redistribute it and/or modify it under
00008  * the terms of the GNU General Public License as published by the Free Software
00009  * Foundation; either version 2 of the License, or (at your option) any later
00010  * version.
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
00014  * details. You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation, Inc.,
00016  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018  
00019 #include "asuro_defs.h"
00020 #include "asuro_unix.h"
00021 #include "asuro_unix_decode.h"
00022 
00023 #include "stdio.h"
00024 
00025 extern volatile double AS_unix_simTime;
00026 
00027 /**
00028  * Evaluate state of IO vector
00029  */
00030 void AS_unix_decode() {
00031     char leds[8];
00032     
00033     // status LED
00034     if (PORTB & AS_PB_LED_GREEN) {
00035         if (PORTD & AS_PD_LED_RED) {
00036             leds[0] = 'Y'; // yellow
00037             
00038         } else {
00039             leds[0] = 'G'; // green
00040             
00041         }
00042         
00043     } else if (PORTD & AS_PD_LED_RED) {
00044         leds[0] = 'R'; // red
00045         
00046     } else {
00047         leds[0] = '0'; // off
00048         
00049     }
00050     
00051     // front and back LEDs
00052     leds[1] = PORTD & AS_PD_LED_FRONT ? '1' : '0';
00053     leds[2] = PORTC & AS_PC_LED_LBACK ? '1' : '0';
00054     leds[3] = PORTC & AS_PC_LED_RBACK ? '1' : '0';
00055     leds[4] = '-';
00056     
00057     // odometry and IR LEDs
00058     leds[5] = PORTD & AS_PD_LED_ODO ? '1' : '0';
00059     leds[6] = PORTB & AS_PB_LED_IRTX ? '1' : '0';
00060     
00061     leds[7] = '\0';
00062     
00063     fprintf(stderr, "%6.2f LD %s\r", AS_unix_simTime, leds);
00064     
00065 }

Generated on Fri May 12 10:11:15 2006 for simsuro by  doxygen 1.4.6