applicfg.h

Go to the documentation of this file.
00001 /*
00002 This file is part of CanFestival, a library implementing CanOpen Stack. 
00003 
00004 Copyright (C): Edouard TISSERANT and Francis DUPIN
00005 
00006 See COPYING file for copyrights details.
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Lesser General Public
00010 License as published by the Free Software Foundation; either
00011 version 2.1 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Lesser General Public License for more details.
00017 
00018 You should have received a copy of the GNU Lesser General Public
00019 License along with this library; if not, write to the Free Software
00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef __APPLICFG_HC12__
00024 #define __APPLICFG_HC12__
00025 
00026 #include <string.h>
00027 #include <stdio.h>
00028 
00029 #include <../include/hcs12/asm-m68hc12/portsaccess.h>
00030 #include <../include/hcs12/asm-m68hc12/ports_def.h>
00031 #include <../include/hcs12/asm-m68hc12/ports.h>
00032 #include <../include/hcs12/interrupt.h>
00033 
00034 
00036 // -----------------------------------------------------
00037 // Test :
00038 // UNS32 v = 0x1234ABCD;
00039 // char *data = &v;
00040 //
00041 // Result for a little_endian architecture :
00042 // data[0] = 0xCD;
00043 // data[1] = 0xAB;
00044 // data[2] = 0x34;
00045 // data[3] = 0x12;
00046 //
00047 // Result for a big_endian architecture :
00048 // data[0] = 0x12;
00049 // data[1] = 0x34;
00050 // data[2] = 0xAB;
00051 // data[3] = 0xCD;
00052 
00053 /* CANOPEN_BIG_ENDIAN now defined in config.h*/
00054 #ifndef CANOPEN_BIG_ENDIAN
00055 #  define CANOPEN_BIG_ENDIAN 1
00056 #endif
00057 
00058 
00059 // Use or not the PLL
00060 //#define USE_PLL
00061 
00062 #ifdef USE_PLL
00063 #  define BUS_CLOCK 24 // If the quartz on the board is 16 MHz. If different, change this value
00064 #else 
00065 #  define BUS_CLOCK 8  // If the quartz on the board is 16 MHz. If different, change this value
00066 #endif
00067 
00069 // Tested : 
00070 //   SERIAL_SCI0_BAUD_RATE 9600      BUS_CLOCK 8   Send OK      Receive not tested
00071 //   SERIAL_SCI0_BAUD_RATE 19200     BUS_CLOCK 8   Send OK      Receive not tested
00072 //   SERIAL_SCI0_BAUD_RATE 38400     BUS_CLOCK 8   Send OK      Receive not tested
00073 //   SERIAL_SCI0_BAUD_RATE 57600     BUS_CLOCK 8   Send Failed  Receive not tested
00074 //   SERIAL_SCI0_BAUD_RATE 115200    BUS_CLOCK 8   Send Failed  Receive not tested
00075 
00076 //   SERIAL_SCI0_BAUD_RATE 9600      BUS_CLOCK 24  Send OK      Receive not tested
00077 //   SERIAL_SCI0_BAUD_RATE 19200     BUS_CLOCK 24  Send OK      Receive not tested
00078 //   SERIAL_SCI0_BAUD_RATE 38400     BUS_CLOCK 24  Send OK but init problems     Receive not tested
00079 //   SERIAL_SCI0_BAUD_RATE 57600     BUS_CLOCK 24  Send Failed  Receive not tested
00080 //   SERIAL_SCI0_BAUD_RATE 115200    BUS_CLOCK 24  Send Failed  Receive not tested
00081 
00082 #define SERIAL_SCI0_BAUD_RATE 38400
00083 #define SERIAL_SCI1_BAUD_RATE 9600
00084 
00085 
00086 
00087 
00088 
00089 
00090 // Several hardware definitions functions
00091 // --------------------------------------
00092 
00093 
00095 extern void initSCI_0 (void);
00096 
00098 extern void initSCI_1 (void);
00099 
00110 extern char *
00111 hex_convert (char *buf, unsigned long value, char lastCar);
00112 
00115 extern void printSCI_str (char sci, const char * str); 
00116 
00119 extern void printSCI_nbr (char sci, unsigned long nbr, char lastCar);
00120 
00123 extern void initPLL (void);
00124 
00126 extern void initHCS12 (void);
00127 
00128 // Integers
00129 #define INTEGER8 signed char
00130 #define INTEGER16 short
00131 #define INTEGER24
00132 #define INTEGER32 long
00133 #define INTEGER40
00134 #define INTEGER48
00135 #define INTEGER56
00136 #define INTEGER64
00137  
00138 // Unsigned integers
00139 #define UNS8   unsigned char
00140 #define UNS16  unsigned short
00141 #define UNS32  unsigned long
00142 #define UNS24
00143 #define UNS40
00144 #define UNS48
00145 #define UNS56
00146 #define UNS64 
00147 
00148 // Whatever your microcontroller, the timer wont work if 
00149 // TIMEVAL is not at least on 32 bits
00150 #define TIMEVAL UNS32 
00151 
00152 // The timer of the hcs12 counts from 0000 to 0xFFFF
00153 #define TIMEVAL_MAX 0xFFFF
00154 
00155 // The timer is incrementing every 4 us.
00156 #define MS_TO_TIMEVAL(ms) (ms * 250)
00157 #define US_TO_TIMEVAL(us) (us>>2)
00158 
00159 
00160 // Reals
00161 #define REAL32  float
00162 #define REAL64 double
00163 
00164 #include "can.h"
00165 
00166 
00168 // ---------------------
00169 #ifdef DEBUG_ERR_CONSOLE_ON
00170 #    define MSG_ERR(num, str, val)            \
00171           initSCI_0();                        \
00172           printSCI_nbr(SCI0, num, ' ');       \
00173           /* large printing on console  */    \
00174           printSCI_str(SCI0, str);            \
00175           printSCI_nbr(SCI0, val, '\n');      
00176 #else
00177 #    define MSG_ERR(num, str, val)
00178 #endif
00179 
00181 // ---------------------
00182 #ifdef DEBUG_WAR_CONSOLE_ON
00183 #    define MSG_WAR(num, str, val)          \
00184         initSCI_0();                        \
00185         printSCI_nbr(SCI0, num, ' ');       \
00186         /* large printing on console  */    \
00187         printSCI_str(SCI0, str);            \
00188         printSCI_nbr(SCI0, val, '\n');      
00189 #else
00190 #    define MSG_WAR(num, str, val)
00191 #endif
00192 
00193 
00194 #endif
00195 
00196 

Generated on Mon Jul 2 19:10:16 2007 for CanFestival by  doxygen 1.5.1