author | Christian Taedcke <Christian.Taedcke@ica-traffic.de> |
Fri, 19 Feb 2010 15:51:40 +0100 | |
changeset 643 | 8b67ee3f5363 |
parent 315 | 1d3bf87b8658 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
This file is part of CanFestival, a library implementing CanOpen Stack. |
|
3 |
||
4 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
5 |
||
6 |
See COPYING file for copyrights details. |
|
7 |
||
8 |
This library is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU Lesser General Public |
|
10 |
License as published by the Free Software Foundation; either |
|
11 |
version 2.1 of the License, or (at your option) any later version. |
|
12 |
||
13 |
This library is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
Lesser General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU Lesser General Public |
|
19 |
License along with this library; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
*/ |
|
22 |
||
23 |
#ifndef __APPLICFG_HC12__ |
|
24 |
#define __APPLICFG_HC12__ |
|
25 |
||
26 |
#include <string.h> |
|
27 |
#include <stdio.h> |
|
28 |
||
29 |
#include <../include/hcs12/asm-m68hc12/portsaccess.h> |
|
30 |
#include <../include/hcs12/asm-m68hc12/ports_def.h> |
|
31 |
#include <../include/hcs12/asm-m68hc12/ports.h> |
|
32 |
#include <../include/hcs12/interrupt.h> |
|
33 |
||
34 |
||
35 |
/// Define the architecture : little_endian or big_endian |
|
36 |
// ----------------------------------------------------- |
|
37 |
// Test : |
|
38 |
// UNS32 v = 0x1234ABCD; |
|
39 |
// char *data = &v; |
|
40 |
// |
|
41 |
// Result for a little_endian architecture : |
|
42 |
// data[0] = 0xCD; |
|
43 |
// data[1] = 0xAB; |
|
44 |
// data[2] = 0x34; |
|
45 |
// data[3] = 0x12; |
|
46 |
// |
|
47 |
// Result for a big_endian architecture : |
|
48 |
// data[0] = 0x12; |
|
49 |
// data[1] = 0x34; |
|
50 |
// data[2] = 0xAB; |
|
51 |
// data[3] = 0xCD; |
|
52 |
||
83 | 53 |
/* CANOPEN_BIG_ENDIAN now defined in config.h*/ |
54 |
#ifndef CANOPEN_BIG_ENDIAN |
|
55 |
# define CANOPEN_BIG_ENDIAN 1 |
|
56 |
#endif |
|
0 | 57 |
|
58 |
||
59 |
// Use or not the PLL |
|
60 |
//#define USE_PLL |
|
61 |
||
62 |
#ifdef USE_PLL |
|
63 |
# define BUS_CLOCK 24 // If the quartz on the board is 16 MHz. If different, change this value |
|
64 |
#else |
|
65 |
# define BUS_CLOCK 8 // If the quartz on the board is 16 MHz. If different, change this value |
|
66 |
#endif |
|
67 |
||
68 |
/// Configuration of the serials port SCI0 and SCI1 |
|
69 |
// Tested : |
|
70 |
// SERIAL_SCI0_BAUD_RATE 9600 BUS_CLOCK 8 Send OK Receive not tested |
|
71 |
// SERIAL_SCI0_BAUD_RATE 19200 BUS_CLOCK 8 Send OK Receive not tested |
|
72 |
// SERIAL_SCI0_BAUD_RATE 38400 BUS_CLOCK 8 Send OK Receive not tested |
|
73 |
// SERIAL_SCI0_BAUD_RATE 57600 BUS_CLOCK 8 Send Failed Receive not tested |
|
74 |
// SERIAL_SCI0_BAUD_RATE 115200 BUS_CLOCK 8 Send Failed Receive not tested |
|
75 |
||
76 |
// SERIAL_SCI0_BAUD_RATE 9600 BUS_CLOCK 24 Send OK Receive not tested |
|
77 |
// SERIAL_SCI0_BAUD_RATE 19200 BUS_CLOCK 24 Send OK Receive not tested |
|
78 |
// SERIAL_SCI0_BAUD_RATE 38400 BUS_CLOCK 24 Send OK but init problems Receive not tested |
|
79 |
// SERIAL_SCI0_BAUD_RATE 57600 BUS_CLOCK 24 Send Failed Receive not tested |
|
80 |
// SERIAL_SCI0_BAUD_RATE 115200 BUS_CLOCK 24 Send Failed Receive not tested |
|
81 |
||
13 | 82 |
#define SERIAL_SCI0_BAUD_RATE 38400 |
0 | 83 |
#define SERIAL_SCI1_BAUD_RATE 9600 |
84 |
||
85 |
||
86 |
||
87 |
||
88 |
||
89 |
||
90 |
// Several hardware definitions functions |
|
91 |
// -------------------------------------- |
|
92 |
||
93 |
||
94 |
/// Initialisation of the serial port 0 |
|
95 |
extern void initSCI_0 (void); |
|
96 |
||
97 |
/// Initialisation of the serial port 1 |
|
98 |
extern void initSCI_1 (void); |
|
99 |
||
100 |
/// Convert an integer to a string in hexadecimal format |
|
101 |
/// If you do not wants to use a lastCar, put lastCar = '\0' (end of string) |
|
102 |
/// ex : value = 0XABCDEF and lastCar = '\n' |
|
103 |
/// buf[0] = '0' |
|
104 |
/// buf[1] = 'X' |
|
105 |
/// buf[2] = 'A' |
|
106 |
/// .... |
|
107 |
/// buf[7] = 'F' |
|
108 |
/// buf[8] = '\n' |
|
109 |
/// buf[9] = '\0' |
|
110 |
extern char * |
|
111 |
hex_convert (char *buf, unsigned long value, char lastCar); |
|
112 |
||
113 |
/// Print the string to the serial port sci |
|
114 |
/// (sci takes the values SCI0 or SCI1) |
|
115 |
extern void printSCI_str (char sci, const char * str); |
|
116 |
||
117 |
/// Print the number in hexadecimal to the serial port sci |
|
118 |
/// (sci takes the values SCI0 or SCI1) |
|
119 |
extern void printSCI_nbr (char sci, unsigned long nbr, char lastCar); |
|
120 |
||
121 |
/// to start using the PLL. Bus clock becomes 24 MHz if the quartz |
|
122 |
/// on the board is at 16 MHz |
|
123 |
extern void initPLL (void); |
|
124 |
||
125 |
/// Put here all the code to init the HCS12 |
|
126 |
extern void initHCS12 (void); |
|
127 |
||
128 |
// Integers |
|
129 |
#define INTEGER8 signed char |
|
130 |
#define INTEGER16 short |
|
131 |
#define INTEGER24 |
|
132 |
#define INTEGER32 long |
|
133 |
#define INTEGER40 |
|
134 |
#define INTEGER48 |
|
135 |
#define INTEGER56 |
|
136 |
#define INTEGER64 |
|
137 |
||
138 |
// Unsigned integers |
|
139 |
#define UNS8 unsigned char |
|
140 |
#define UNS16 unsigned short |
|
141 |
#define UNS32 unsigned long |
|
315
1d3bf87b8658
Workaround for unsupported UNS64 on some compiler.
etisserant
parents:
83
diff
changeset
|
142 |
/* |
0 | 143 |
#define UNS24 |
144 |
#define UNS40 |
|
145 |
#define UNS48 |
|
146 |
#define UNS56 |
|
315
1d3bf87b8658
Workaround for unsupported UNS64 on some compiler.
etisserant
parents:
83
diff
changeset
|
147 |
#define UNS64 |
1d3bf87b8658
Workaround for unsupported UNS64 on some compiler.
etisserant
parents:
83
diff
changeset
|
148 |
*/ |
0 | 149 |
|
150 |
// Whatever your microcontroller, the timer wont work if |
|
151 |
// TIMEVAL is not at least on 32 bits |
|
152 |
#define TIMEVAL UNS32 |
|
153 |
||
154 |
// The timer of the hcs12 counts from 0000 to 0xFFFF |
|
155 |
#define TIMEVAL_MAX 0xFFFF |
|
156 |
||
157 |
// The timer is incrementing every 4 us. |
|
158 |
#define MS_TO_TIMEVAL(ms) (ms * 250) |
|
159 |
#define US_TO_TIMEVAL(us) (us>>2) |
|
160 |
||
161 |
||
162 |
// Reals |
|
163 |
#define REAL32 float |
|
164 |
#define REAL64 double |
|
165 |
||
166 |
#include "can.h" |
|
167 |
||
168 |
||
169 |
/// Definition of MSG_ERR |
|
170 |
// --------------------- |
|
171 |
#ifdef DEBUG_ERR_CONSOLE_ON |
|
172 |
# define MSG_ERR(num, str, val) \ |
|
173 |
initSCI_0(); \ |
|
174 |
printSCI_nbr(SCI0, num, ' '); \ |
|
175 |
/* large printing on console */ \ |
|
176 |
printSCI_str(SCI0, str); \ |
|
177 |
printSCI_nbr(SCI0, val, '\n'); |
|
178 |
#else |
|
179 |
# define MSG_ERR(num, str, val) |
|
180 |
#endif |
|
181 |
||
182 |
/// Definition of MSG_WAR |
|
183 |
// --------------------- |
|
184 |
#ifdef DEBUG_WAR_CONSOLE_ON |
|
185 |
# define MSG_WAR(num, str, val) \ |
|
186 |
initSCI_0(); \ |
|
187 |
printSCI_nbr(SCI0, num, ' '); \ |
|
188 |
/* large printing on console */ \ |
|
189 |
printSCI_str(SCI0, str); \ |
|
190 |
printSCI_nbr(SCI0, val, '\n'); |
|
191 |
#else |
|
192 |
# define MSG_WAR(num, str, val) |
|
193 |
#endif |
|
194 |
||
195 |
||
196 |
#endif |
|
197 |
||
198 |