etisserant@0: /* etisserant@0: This file is part of CanFestival, a library implementing CanOpen Stack. etisserant@0: etisserant@0: Copyright (C): Edouard TISSERANT and Francis DUPIN etisserant@0: etisserant@0: See COPYING file for copyrights details. etisserant@0: etisserant@0: This library is free software; you can redistribute it and/or etisserant@0: modify it under the terms of the GNU Lesser General Public etisserant@0: License as published by the Free Software Foundation; either etisserant@0: version 2.1 of the License, or (at your option) any later version. etisserant@0: etisserant@0: This library is distributed in the hope that it will be useful, etisserant@0: but WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU etisserant@0: Lesser General Public License for more details. etisserant@0: etisserant@0: You should have received a copy of the GNU Lesser General Public etisserant@0: License along with this library; if not, write to the Free Software etisserant@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA etisserant@0: */ etisserant@0: etisserant@0: #ifndef __APPLICFG_HC12__ etisserant@0: #define __APPLICFG_HC12__ etisserant@0: etisserant@0: #include etisserant@0: #include etisserant@0: etisserant@0: #include <../include/hcs12/asm-m68hc12/portsaccess.h> etisserant@0: #include <../include/hcs12/asm-m68hc12/ports_def.h> etisserant@0: #include <../include/hcs12/asm-m68hc12/ports.h> etisserant@0: #include <../include/hcs12/interrupt.h> etisserant@0: etisserant@0: etisserant@0: /// Define the architecture : little_endian or big_endian etisserant@0: // ----------------------------------------------------- etisserant@0: // Test : etisserant@0: // UNS32 v = 0x1234ABCD; etisserant@0: // char *data = &v; etisserant@0: // etisserant@0: // Result for a little_endian architecture : etisserant@0: // data[0] = 0xCD; etisserant@0: // data[1] = 0xAB; etisserant@0: // data[2] = 0x34; etisserant@0: // data[3] = 0x12; etisserant@0: // etisserant@0: // Result for a big_endian architecture : etisserant@0: // data[0] = 0x12; etisserant@0: // data[1] = 0x34; etisserant@0: // data[2] = 0xAB; etisserant@0: // data[3] = 0xCD; etisserant@0: frdupin@83: /* CANOPEN_BIG_ENDIAN now defined in config.h*/ frdupin@83: #ifndef CANOPEN_BIG_ENDIAN frdupin@83: # define CANOPEN_BIG_ENDIAN 1 frdupin@83: #endif etisserant@0: etisserant@0: etisserant@0: // Use or not the PLL etisserant@0: //#define USE_PLL etisserant@0: etisserant@0: #ifdef USE_PLL etisserant@0: # define BUS_CLOCK 24 // If the quartz on the board is 16 MHz. If different, change this value etisserant@0: #else etisserant@0: # define BUS_CLOCK 8 // If the quartz on the board is 16 MHz. If different, change this value etisserant@0: #endif etisserant@0: etisserant@0: /// Configuration of the serials port SCI0 and SCI1 etisserant@0: // Tested : etisserant@0: // SERIAL_SCI0_BAUD_RATE 9600 BUS_CLOCK 8 Send OK Receive not tested etisserant@0: // SERIAL_SCI0_BAUD_RATE 19200 BUS_CLOCK 8 Send OK Receive not tested etisserant@0: // SERIAL_SCI0_BAUD_RATE 38400 BUS_CLOCK 8 Send OK Receive not tested etisserant@0: // SERIAL_SCI0_BAUD_RATE 57600 BUS_CLOCK 8 Send Failed Receive not tested etisserant@0: // SERIAL_SCI0_BAUD_RATE 115200 BUS_CLOCK 8 Send Failed Receive not tested etisserant@0: etisserant@0: // SERIAL_SCI0_BAUD_RATE 9600 BUS_CLOCK 24 Send OK Receive not tested etisserant@0: // SERIAL_SCI0_BAUD_RATE 19200 BUS_CLOCK 24 Send OK Receive not tested etisserant@0: // SERIAL_SCI0_BAUD_RATE 38400 BUS_CLOCK 24 Send OK but init problems Receive not tested etisserant@0: // SERIAL_SCI0_BAUD_RATE 57600 BUS_CLOCK 24 Send Failed Receive not tested etisserant@0: // SERIAL_SCI0_BAUD_RATE 115200 BUS_CLOCK 24 Send Failed Receive not tested etisserant@0: dejoigny@13: #define SERIAL_SCI0_BAUD_RATE 38400 etisserant@0: #define SERIAL_SCI1_BAUD_RATE 9600 etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: // Several hardware definitions functions etisserant@0: // -------------------------------------- etisserant@0: etisserant@0: etisserant@0: /// Initialisation of the serial port 0 etisserant@0: extern void initSCI_0 (void); etisserant@0: etisserant@0: /// Initialisation of the serial port 1 etisserant@0: extern void initSCI_1 (void); etisserant@0: etisserant@0: /// Convert an integer to a string in hexadecimal format etisserant@0: /// If you do not wants to use a lastCar, put lastCar = '\0' (end of string) etisserant@0: /// ex : value = 0XABCDEF and lastCar = '\n' etisserant@0: /// buf[0] = '0' etisserant@0: /// buf[1] = 'X' etisserant@0: /// buf[2] = 'A' etisserant@0: /// .... etisserant@0: /// buf[7] = 'F' etisserant@0: /// buf[8] = '\n' etisserant@0: /// buf[9] = '\0' etisserant@0: extern char * etisserant@0: hex_convert (char *buf, unsigned long value, char lastCar); etisserant@0: etisserant@0: /// Print the string to the serial port sci etisserant@0: /// (sci takes the values SCI0 or SCI1) etisserant@0: extern void printSCI_str (char sci, const char * str); etisserant@0: etisserant@0: /// Print the number in hexadecimal to the serial port sci etisserant@0: /// (sci takes the values SCI0 or SCI1) etisserant@0: extern void printSCI_nbr (char sci, unsigned long nbr, char lastCar); etisserant@0: etisserant@0: /// to start using the PLL. Bus clock becomes 24 MHz if the quartz etisserant@0: /// on the board is at 16 MHz etisserant@0: extern void initPLL (void); etisserant@0: etisserant@0: /// Put here all the code to init the HCS12 etisserant@0: extern void initHCS12 (void); etisserant@0: etisserant@0: // Integers etisserant@0: #define INTEGER8 signed char etisserant@0: #define INTEGER16 short etisserant@0: #define INTEGER24 etisserant@0: #define INTEGER32 long etisserant@0: #define INTEGER40 etisserant@0: #define INTEGER48 etisserant@0: #define INTEGER56 etisserant@0: #define INTEGER64 etisserant@0: etisserant@0: // Unsigned integers etisserant@0: #define UNS8 unsigned char etisserant@0: #define UNS16 unsigned short etisserant@0: #define UNS32 unsigned long etisserant@0: #define UNS24 etisserant@0: #define UNS40 etisserant@0: #define UNS48 etisserant@0: #define UNS56 etisserant@0: #define UNS64 etisserant@0: etisserant@0: // Whatever your microcontroller, the timer wont work if etisserant@0: // TIMEVAL is not at least on 32 bits etisserant@0: #define TIMEVAL UNS32 etisserant@0: etisserant@0: // The timer of the hcs12 counts from 0000 to 0xFFFF etisserant@0: #define TIMEVAL_MAX 0xFFFF etisserant@0: etisserant@0: // The timer is incrementing every 4 us. etisserant@0: #define MS_TO_TIMEVAL(ms) (ms * 250) etisserant@0: #define US_TO_TIMEVAL(us) (us>>2) etisserant@0: etisserant@0: etisserant@0: // Reals etisserant@0: #define REAL32 float etisserant@0: #define REAL64 double etisserant@0: etisserant@0: #include "can.h" etisserant@0: etisserant@0: etisserant@0: /// Definition of MSG_ERR etisserant@0: // --------------------- etisserant@0: #ifdef DEBUG_ERR_CONSOLE_ON etisserant@0: # define MSG_ERR(num, str, val) \ etisserant@0: initSCI_0(); \ etisserant@0: printSCI_nbr(SCI0, num, ' '); \ etisserant@0: /* large printing on console */ \ etisserant@0: printSCI_str(SCI0, str); \ etisserant@0: printSCI_nbr(SCI0, val, '\n'); etisserant@0: #else etisserant@0: # define MSG_ERR(num, str, val) etisserant@0: #endif etisserant@0: etisserant@0: /// Definition of MSG_WAR etisserant@0: // --------------------- etisserant@0: #ifdef DEBUG_WAR_CONSOLE_ON etisserant@0: # define MSG_WAR(num, str, val) \ etisserant@0: initSCI_0(); \ etisserant@0: printSCI_nbr(SCI0, num, ' '); \ etisserant@0: /* large printing on console */ \ etisserant@0: printSCI_str(SCI0, str); \ etisserant@0: printSCI_nbr(SCI0, val, '\n'); etisserant@0: #else etisserant@0: # define MSG_WAR(num, str, val) etisserant@0: #endif etisserant@0: etisserant@0: etisserant@0: #endif etisserant@0: etisserant@0: