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