simple.c

Description | Download | Table of Contents | Modules | Compound List | File List | Functions


Overview
Compiler
Documentation
Examples
Misc
Help
IDE & Tools

Download
Install

Links
Projects






00001 /* Small test/example program
00002    Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
00003    Written by Stephane Carrez (stcarrez@worldnet.fr)    
00004 
00005 This file is free software; you can redistribute it and/or modify it
00006 under the terms of the GNU General Public License as published by the
00007 Free Software Foundation; either version 2, or (at your option) any
00008 later version.
00009 
00010 In addition to the permissions in the GNU General Public License, the
00011 Free Software Foundation gives you unlimited permission to link the
00012 compiled version of this file with other programs, and to distribute
00013 those programs without any restriction coming from the use of this
00014 file.  (The General Public License restrictions do apply in other
00015 respects; for example, they cover modification of the file, and
00016 distribution when not linked into another program.)
00017 
00018 This file is distributed in the hope that it will be useful, but
00019 WITHOUT ANY WARRANTY; without even the implied warranty of
00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 General Public License for more details.
00022 
00023 You should have received a copy of the GNU General Public License
00024 along with this program; see the file COPYING.  If not, write to
00025 the Free Software Foundation, 59 Temple Place - Suite 330,
00026 Boston, MA 02111-1307, USA.  */
00027 
00039 #include <sys/sio.h>
00040 
00041 /* Prints "Hello %d\n" on the serial device.  */
00042 void
00043 print_hello (unsigned i)
00044 {
00045   char buf[15];
00046   char* p;
00047   unsigned char c;
00048   unsigned int value;
00049   
00050   p = &buf[15];
00051   *--p = 0;
00052   value = i;
00053   
00054   do {
00055     c = value % 10;
00056     value = value / 10;
00057     *--p = c + '0';
00058   } while (value != 0);
00059   
00060   serial_print ("Hello ");
00061   serial_print (p);
00062   serial_print ("\n");
00063 }
00064 
00065 int
00066 main ()
00067 {
00068   unsigned i;
00069 
00070   for (i = 0; i < 1000; i++)
00071     {
00072       print_hello (i);
00073     }
00074   return 0;
00075 }

Description | Download | Table of Contents | Modules | Compound List | File List | Functions

    Last modified,
    Apr 16, 2001
[ Copying ]     [ Feedback to Stephane.Carrez@worldnet.fr ]