template.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 16.04.2004 by                                           *
00003  *   Matthias Kranz (matthias.kranz@ifi.lmu.de)                            *
00004  *   Paul Holleis (paul.holleis@ifi.lmu.de)                                *
00005  *                                                                         *
00006  *   Last modified 19.10.2004                                              *
00007  *                                                                         *
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  *   This program is distributed in the hope that it will be useful,       *
00015  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017  *   GNU General Public License for more details.                          *
00018  *                                                                         *
00019  *   You should have received a copy of the GNU General Public License     *
00020  *   along with this program; if not, write to the                         *
00021  *   Free Software Foundation, Inc.,                                       *
00022  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00023  **************************************************************************/
00024 
00025 //********* GENERAL SETUP ****************************************************/
00027 #include <18f452.h>
00029 #device *=16 ADC=10
00030 // delay must be defined before first use of
00031 // #use rs232 (see compiler manual); 20MHz crystal used
00032 #define CLOCKCYCLE 20000000
00033 #use delay(clock=CLOCKCYCLE)
00034 // no watchdogtimer (wdt), no low-voltage programming (lvp)
00035 // oscillator = hs, no brownout, no code protect
00036 #fuses NOWDT, HS, NOBROWNOUT, NOPROTECT, NOLVP
00037 
00038 #include <std.h>
00039 //********* PROGRAMMING STYLE ************************************************/
00040 // case sensitive programming
00041 #CASE
00042 // see compiler handbook for description of warnings.
00043 // we are glad with ignoring the following warnings.
00044 #ignore_warnings 201,202,203,205,207,208,216
00045 
00046 //********* ADDITIONAL INCLUDES **********************************************/
00047 // (un)comment the following to (un)define the standard spm pins
00048 //#define SPM_USED
00049 #ifdef SPM_USED
00050         #include "spm2-433-28.h"        
00051 #endif
00052 
00053 // (un)comment the following to (un)define the standard i2c pins
00054 //#define USE_I2C
00055 #ifdef USE_I2C
00056         #include <i2c.h>
00057 #endif
00058 
00059 // (un)comment the following to (un)define the standard rf43392 pins
00060 //#define RF43392
00061 #ifdef RF43392
00062         #include <rf43392.h>
00063 #endif
00064 
00066 #ifndef USE_PORT_A_ANALOG
00067         #define USE_PORT_A_ANALOG
00068 #endif
00069 
00070 //********* COMMUNICATION SETUP **********************************************/
00071 #ifdef __STD
00072   // serial line setup (STDSTREAM) & stdout (no stream)
00073   #use rs232(baud=STDSTREAM_SPEED,xmit=PIC_TX_PIN,rcv=PIC_RX_PIN,STREAM=STDSTREAM)
00074   #use rs232(baud=STDSTREAM_SPEED,xmit=PIC_TX_PIN,rcv=PIC_RX_PIN)
00075 #else
00076   // stdout/sdtin (no stream)
00077   #use rs232(baud=STDOUT_SPEED,xmit=PIN_C6,rcv=PIN_C7)
00078 #endif
00079 #ifdef __SPM243328
00080   // spm out/in (SPMSTREAM)
00081   #use rs232(baud=SPM_SPEED, xmit=SPM_TX_PIN, rcv=SPM_RX_PIN,STREAM=SPMSTREAM)
00082 #endif
00083 #ifdef __RF43392
00084   // rf out/in (SPMSTREAM)
00085   #use rs232(baud=SPM_SPEED, xmit=RF433_TX_PIN, rcv=RF433_RX_PIN,STREAM=RF43392STREAM)
00086 #endif
00087 
00088 //********* MISCELLANEOUS ****************************************************/
00089 // use fast io if it works for you (which is very rare...).
00090 //#use fast_io(A)
00091 //#use fast_io(B)
00092 
00093 /******************************************************************************
00094  * defines
00095  *****************************************************************************/
00096 
00097 /******************************************************************************
00098  * includes
00099  *****************************************************************************/
00100 // use warnings only to translate compiler error codes to text.
00101 // not needed during normal operation.
00102 //#include <warnings.h>
00103 
00104 // for atoi or similar stuff, include the next line:
00105 //#include <stdlib.h>
00106 // for malloc, free or similar stuff, include the next line:
00107 //#include <stdlibm.h>
00108 // for max and mix sizes of data types!
00109 //#include <limits.h>
00110 
00111 /******************************************************************************
00112  * structs
00113  *****************************************************************************/
00114 
00115 /******************************************************************************
00116  * global variables
00117  *****************************************************************************/
00118 
00119 /******************************************************************************
00120  * function signatures
00121  *****************************************************************************/
00122 void main();
00123 
00124 /******************************************************************************
00125  * Code
00126  *****************************************************************************/
00127 void main()
00128 {
00129   // variables come first
00130         
00131   // pre-main, doing some general setup for the program
00132   #ifdef USE_PORT_A_ANALOG
00133     // if analog sensors are to be used
00134     setup_port_a( ALL_ANALOG );    
00135     // general analog/digital converter setup
00136     setup_adc( ADC_CLOCK_INTERNAL );
00137   #endif
00138   // spm setup
00139   #ifdef SPM_USED
00140     spm_init();
00141     // wait a little to let the spm init happen!
00142     delay_ms(50);
00143   #endif
00144 
00145   // your code below
00146   for (;;)
00147   {
00148           fprintf(STDSTREAM, "hello world\n\r");
00149           delay_ms(100);
00150           
00151   }
00152 }

Generated on Tue Nov 30 09:16:48 2004 for Smart-Its Headers by  doxygen 1.3.9.1