N-sim
Emulation and simulation of
Wireless Sensor Networks



   Home


   Project Page


   Download


   CVS



   Installation


   Configuration


   Plug-ins




 Hosted by
SourceForge.net Logo

/home/brennan/n-sim/OrbisQuartus/server/l4/ituner_lcd.c

Go to the documentation of this file.
00001 
00014 /*
00015  * Copyright 2007. Los Alamos National Security, LLC. This material
00016  * was produced under U.S. Government contract DE-AC52-06NA25396 for
00017  * Los Alamos National Laboratory (LANL), which is operated by Los
00018  * Alamos National Security, LLC, for the Department of Energy. The
00019  * U.S. Government has rights to use, reproduce, and distribute this
00020  * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY,
00021  * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
00022  * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to
00023  * produce derivative works, such modified software should be clearly
00024  * marked, so as not to confuse it with the version available from LANL.
00025  *
00026  * Additionally, this program is free software; you can redistribute
00027  * it and/or modify it under the terms of the GNU General Public
00028  * License as published by the Free Software Foundation; version 2 of
00029  * the License. Accordingly, this program is distributed in the hope
00030  * it will be useful, but WITHOUT ANY WARRANTY; without even the
00031  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00032  * PURPOSE. See the GNU General Public License for more details.
00033  */
00034 
00035 
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <string.h>
00039 #include <stdarg.h>
00040 #include <l4/sys/kdebug.h>
00041 #include <l4/rmgr/librmgr.h>
00042 #include <l4/util/reboot.h>
00043 #include <l4/serial/serial.h>
00044 #include "ituner_lcd.h"
00045 
00046 #define LCD_DEVICE 1  // "/dev/ttyS1"
00047 
00048 static int initialized = 0;
00049 
00050 
00051 int ituner_lcd_init(void)
00052 {
00053         int err;
00054 
00055         rmgr_init();
00056 
00057         if ((err = l4serial_init(5, LCD_DEVICE)) != 0) {
00058                 printf("l4serial_init(5,%d): %d\n\r", LCD_DEVICE, err);
00059                 return err;
00060         }
00061 
00062         /* hide cursor/wrap=off/scroll=off */
00063         l4serial_outstring("\004\024\030", 3);
00064 
00065         initialized = 1;
00066         return 0;
00067 }
00068 
00069 
00070 int ituner_lcd_print(int line, const char *format, ...)
00071 {
00072         int err;
00073         va_list list;
00074         char string[128];
00075         unsigned char buf[2];
00076 
00077         if (!initialized) {
00078                 if ((err = ituner_lcd_init()) != 0)
00079                         return err;
00080         }
00081 
00082         memset(string, 0, sizeof(string));
00083         va_start(list, format);
00084         vsnprintf(string, sizeof(string), format, list);
00085         va_end(list);
00086 
00087         buf[0] = (unsigned char)254;
00088         buf[1] = (unsigned char)1;
00089         l4serial_outstring((char*)buf, 2);
00090 
00091         buf[0] = (unsigned char)254;
00092         if (line == 1)
00093                 buf[1] = (unsigned char)128;
00094         else
00095                 buf[1] = (unsigned char)192;
00096         l4serial_outstring((char*)buf, 2);
00097 
00098         l4serial_outstring((char*)(string), strlen(string));
00099 
00100         return 0;
00101 }


© 2007, Los Alamos National Security, LLC.