]> cloudbase.mooo.com Git - avrcpm.git/blob - avr/config.inc
3d63410cde7512a24184f1cdae17b7e5aee44047
[avrcpm.git] / avr / config.inc
1 ; Configuration, hardware definition, ...
2 ;
3 ; Copyright (C) 2010 Sprite_tm
4 ; Copyright (C) 2010 Leo C.
5 ;
6 ; This file is part of avrcpm.
7 ;
8 ; avrcpm is free software: you can redistribute it and/or modify it
9 ; under the terms of the GNU General Public License as published by
10 ; the Free Software Foundation, either version 3 of the License, or
11 ; (at your option) any later version.
12 ;
13 ; avrcpm 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
16 ; GNU General Public License for more details.
17 ;
18 ; You should have received a copy of the GNU General Public License
19 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
20 ;
21 ; $Id$
22 ;
23
24
25 #define VMAJOR 3 /* Version number */
26 #define VMINOR 1
27
28 #ifndef DRAM_8BIT
29 #define DRAM_8BIT 1 /* 1 = 8bit wide DRAM */
30 #endif
31 #ifndef F_CPU
32 #define F_CPU 20000000 /* system clock in Hz; defaults to 20MHz */
33 #endif
34 #ifndef BAUD
35 #define BAUD 38400 /* console baud rate */
36 #endif
37 #ifndef I2C
38 #define I2C DRAM_8BIT /* I2C requires 8 bit DRAM */
39 #endif
40 #if I2C && !DRAM_8BIT
41 #error "I2C requires 8 bit DRAM (DRAM_8BIT=1)!"
42 #endif
43
44 #define EM_Z80 1 /* Emulate Z80 if true, else 8080 */
45
46 #ifndef FAT16_SUPPORT
47 #define FAT16_SUPPORT 1 /* Include Support for FAT16 Partitions */
48 #endif /* which may contain CP/M image files. */
49 #define RAMDISKCNT 4 /* Number of RAM disks */
50 #define RAMDISKNR 'I'-'A' /* Drive "letter" for first RAM disk */
51
52 #define PARTID 0x52 /* Partition table id */
53 /* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */
54 #define IPLADDR 0x2000 /* Bootloader load address */
55
56 #define DRAM_WAITSTATES 1 /* Number of additional clock cycles for dram read access */
57 #define REFR_RATE 64000 /* dram refresh rate in cycles/s. */
58 /* Most drams need 1/15.6µs. */
59 #define RXBUFSIZE 128 /* USART recieve buffer size. Must be power of 2 */
60 #define TXBUFSIZE 128 /* USART transmit buffer size. Must be power of 2 */
61
62 #define I2C_CLOCK 100000 /* 100kHz */
63 #define I2C_BUFSIZE 17 /* largest message size including address byte (SLA) */
64
65
66 .equ BOOTWAIT = 1
67 .equ MEMTEST = 1
68 .equ MEMFILL = 1
69 .equ MMC_DEBUG = 0 /* Increase for more debugging */
70 .equ FAT16_DEBUG = 0
71 .equ FAT16_RWDEBUG = 0
72 .equ FAT16_DBG_FAT = 0
73 .equ DISK_DEBUG = 0 /* Increase for more debugging */
74 .equ HOSTRW_DEBUG = 0
75 .equ HEAP_DEBUG = 0
76 .equ PORT_DEBUG = 0
77 .equ INS_DEBUG = 0
78 .equ STACK_DBG = 0
79 .equ PRINT_PC = 0
80
81 #define MMC_SPI2X 1 /* 0 = SPI CLK/4, 1 = SPI CLK/2 */
82
83 #define MEMFILL_VAL 0x76 /* Fill ram with HALT opcode. */
84 #define DBG_TRACE_BOTTOM 0x01 /* Page boundaries for INS_DEBUG and PRINT_PC */
85 #define DBG_TRACE_TOP 0xdc /* Trace is off, below bottom page and above top page. */
86
87 #if EM_Z80
88 #define CPUSTR "Z80"
89 #else
90 #define CPUSTR "8080"
91 #endif
92
93 ;-----------------------------------------------------------------------
94 ; Port declarations
95
96 #if DRAM_8BIT /* Implies software uart */
97
98 ;Port D
99 .equ RAM_D0 = 0
100 .equ RAM_D1 = 1
101 .equ RAM_D2 = 2
102 .equ RAM_D3 = 3
103 .equ RAM_D4 = 4
104 .equ RAM_D5 = 5
105 .equ RAM_D6 = 6
106 .equ RAM_D7 = 7
107 .equ RAM_A0 = 0
108 .equ RAM_A1 = 1
109 .equ RAM_A2 = 2
110 .equ RAM_A3 = 3
111 .equ RAM_A4 = 4
112 .equ RAM_A5 = 5
113 .equ RAM_A6 = 6
114 .equ RAM_A7 = 7
115
116 ;Port B
117 .equ MMC_MOSI = 3
118 .equ MMC_MISO = 4
119 .equ MMC_SCK = 5
120 .equ RAM_A8 = 3
121 .equ RAM_A9 = 4
122 .equ RAM_A10 = 5
123
124 .equ RXD = 0
125 .equ TXD = 1
126 .equ MMC_CS = 2
127
128 .equ P_MMC_CS = PORTB
129 .equ P_A8 = PORTB
130 .equ P_RXD = PORTB
131
132 ;Port C
133 .equ RAM_RAS = 0
134 .equ RAM_CAS = 1
135 .equ RAM_OE = 2
136 .equ RAM_W = 3
137
138 .equ P_RAS = PORTC
139 .equ P_CAS = PORTC
140 .equ P_OE = PORTC
141 .equ P_W = PORTC
142
143
144 #else /* 4 bit RAM, hardware uart */
145
146 ; Port D
147 .equ RXD = 0
148 .equ TXD = 1
149 .equ RAM_OE = 2
150 .equ RAM_A8 = 3
151 .equ MMC_CS = 4
152 .equ RAM_A5 = 5
153 .equ RAM_A6 = 6
154 .equ RAM_A7 = 7
155
156 .equ P_RXD = PORTD
157 .equ P_OE = PORTD
158 .equ P_A8 = PORTD
159 .equ P_MMC_CS = PORTD
160 .equ P_AH = PORTD
161 ; RAM_A[7..5]
162 .equ RAM_AH_MASK = (1<<RAM_A8)|(1<<RAM_A7)|(1<<RAM_A6)|(1<<RAM_A5)
163 .equ PD_OUTPUT_MASK = (1<<MMC_CS) | (1<<RAM_OE) | RAM_AH_MASK
164
165
166 ;Port B
167 .equ RAM_A4 = 0
168 .equ RAM_A3 = 1
169 .equ RAM_A2 = 2
170 .equ RAM_A1 = 3
171 .equ MMC_MOSI = 3
172 .equ RAM_A0 = 4
173 .equ MMC_MISO = 4
174 .equ RAM_RAS = 5
175 .equ MMC_SCK = 5
176
177 .equ P_RAS = PORTB
178 .equ P_AL = PORTB
179 ; RAM_A[4..0]
180 .equ RAM_AL_MASK = (1<<RAM_A4)|(1<<RAM_A3)|(1<<RAM_A2)|(1<<RAM_A1)|(1<<RAM_A0)
181 .equ PB_OUTPUT_MASK = (1<<RAM_ras) | RAM_AL_MASK
182
183 ;Port C
184 .equ RAM_D0 = 0
185 .equ RAM_D1 = 1
186 .equ RAM_D2 = 2
187 .equ RAM_D3 = 3
188 .equ RAM_W = 4
189 .equ RAM_CAS = 5
190
191 .equ P_DQ = PORTC
192 .equ P_W = PORTC
193 .equ P_CAS = PORTC
194
195 .equ RAM_DQ_MASK = (1<<RAM_D3)|(1<<RAM_D2)|(1<<RAM_D1)|(1<<RAM_D0)
196 .equ PC_OUTPUT_MASK = (1<<RAM_CAS)|(1<<RAM_W)
197
198 #endif /* DRAM_8BIT */
199
200
201 ;-----------------------------------------------------------------------
202 ;Register definitions
203
204 .def _tmp0 = r0
205 .def _tmp1 = r1
206
207 .def _RAS0 = r2
208 .def _CAS0 = r3
209 .def _OE = r4
210 .def _WE = r5
211 .def _255 = r6
212 .def _0 = r7
213 .def z_a = r9
214 ;.def stx_bitcount = r9
215 ;.def stx_dr = r10
216
217 .def srx_lastedgel = r10
218 .def srx_lastedgeh = r11
219 ;.def insstore= r8 ;
220 ;.def insop = r13 ;
221
222 .def insdecl = r12 ;
223 .def insdech = r13 ;
224 .def z_spl = r14
225 .def z_sph = r15 ;
226 .def temp = r16 ;
227 .def temp2 = r17 ;
228 .def temp3 = r18
229 .def temp4 = r19
230 .def z_flags = r20 ;
231 .def intstat = r21 ; interpreter status / interrupt status
232 .def opl = r22 ;
233 .def oph = r23 ;
234 .def z_pcl = r24 ;
235 .def z_pch = r25 ;
236 ; xl ;r26
237 ; xh ;r27
238 ; yl ;r28
239 ; yh ;r29
240 ; zl ;r30 ;
241 ; zh ;r31 ;
242
243
244 .equ i_break = 0 ;break detected flag
245 .equ i_trace = 1 ;cpu interpreter trace flag
246 .equ i_halt = 2 ;executing halt instruction
247
248 #if defined __ATmega8__
249 .equ flags = TWBR
250 .equ P_PUD = SFIOR
251 #else
252 .equ flags = GPIOR0
253 .equ P_PUD = MCUCR
254 #endif
255
256 ; Flags:
257 .equ hostact = 7 ;host active flag
258 .equ hostwrt = 6 ;host written flag
259 .equ rsflag = 5 ;read sector flag
260 .equ readop = 4 ;1 if read operation
261
262 .equ prefixfd = 1 ;Opcode prefix DD=0, FD=1
263 .equ trace = 0
264
265 ; This is the base z80 port address for clock access
266 #define TIMERPORT 0x40
267 #define TIMER_CTL TIMERPORT
268 #define TIMER_MSECS TIMERPORT+1
269 #define TIMER_SECS TIMER_MSECS+2
270 #define CLOCKPORT TIMERPORT+7
271
272 #define starttimercmd 1
273 #define quitTimerCmd 2
274 #define printTimerCmd 15
275 #define uptimeCmd 16
276
277 #define DEBUGPORT 0x4F
278
279 #define startTraceCmd 1
280 #define stopTraceCmd 0
281
282 ; Virtual I2C Interface
283 #define I2CSTAT 0x05
284 #define I2CCTRL 0x05
285 #define I2CBLEN 0x06
286 #define I2CADR 0x07
287 #define I2CADRL 0x07
288 #define I2CADRH 0x08
289
290 ; Port-Expander PCF8574
291 #define PORT 0x80
292 #define PORT0 0x80
293 #define PORT1 0x81
294 #define PORT2 0x82
295 #define PORT3 0x83
296 #define PORT4 0x84
297 #define PORT5 0x85
298 #define PORT6 0x86
299 #define PORT7 0x87
300
301
302 #if defined __ATmega8__
303 .equ RXTXDR0 = UDR
304 .equ UCSR0A = UCSRA
305 .equ UDRE0 = UDRE
306 .equ UCSR0B = UCSRB
307 .equ RXCIE0 = RXCIE
308 .equ UDRIE0 = UDRIE
309 .equ RXEN0 = RXEN
310 .equ TXEN0 = TXEN
311 .equ UCSR0C = UCSRC
312 .equ UCSZ00 = UCSZ0
313 .equ UCSZ01 = UCSZ1
314 .equ UBRR0H = UBRRH
315 .equ UBRR0L = UBRRL
316 .equ OCR2A = OCR2
317 .equ OC2Aaddr= OC2addr
318 .equ TCCR2A = TCCR2
319 .equ TCCR2B = TCCR2
320 .equ TIMSK1 = TIMSK
321 .equ TIMSK2 = TIMSK
322 .equ OCIE2A = OCIE2
323 .equ TIFR1 = TIFR
324 .equ ICIE1 = TICIE1
325 #else
326 .equ RXTXDR0 = UDR0
327 #endif
328
329 ; vim:set ts=8 noet nowrap
330