]> cloudbase.mooo.com Git - avrcpm.git/blame - avr/config.inc
SVN --> GIT
[avrcpm.git] / avr / config.inc
CommitLineData
9c15f366 1; Configuration, hardware definition, ...
4bd49b80 2;
9c15f366 3; Copyright (C) 2010 Sprite_tm
2ccaac16 4; Copyright (C) 2010,2012,2013 Leo C.
9c15f366
L
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;
12a27f27 21; $Id: config.inc 242 2015-12-11 16:05:52Z rapid $
9c15f366 22
5c8bb361
L
23;-----------------------------------------------------------------------
24;
25; Hardware and feature configuration
26;
9c15f366 27
4bd49b80 28; Supported MCUs are: atmega328P atmega168 atmega88 atmega8
5c8bb361 29; Z80 emulation currently needs atmega328P, so this is the default.
2ccaac16 30;#define atmega328p
80e1fa71 31
5c8bb361
L
32; MCU frequency in Hz.
33;#define F_CPU 20000000
9c15f366 34
5c8bb361
L
35; Set this to 0, if you have a (one) DRAM chip whith 4 Bit data bus.
36;#define DRAM_8BIT 1
9c15f366 37
5c8bb361
L
38; Baudrate of serial port (console).
39;#define BAUD 115200
9c15f366 40
825ecc9d 41; I2C_SUPPORT defaults to 1 on 8-bit-ram systems and must be 0 on 4-bit-ram systems.
4bd49b80 42; Set this do 0, if you don't have I2C peripherals and want to save some flash
5c8bb361 43; or use the I2C pins for other purposes.
4bd49b80 44;#define I2C_SUPPORT
5c8bb361 45
12a27f27
L
46; Support for the SC16IS740 I2C UART chip is included automatically, when
47; I2C support is enabled. Uncomment and set to 0 if you don't want support for
48; the SC16IS740 I2C UART chip.
49;#define I2C_UART_SUPPORT 1
50
5c8bb361
L
51; Emulate Z80 cpu if 1, 8080 otherwise.
52;
53;#define EM_Z80 1
54
4bd49b80
L
55; Uncomment and set RAMDISKCOUNT to 1-4 if you want to test the experimental and
56; unsupported ramdisk feature . Number depends on actual ram size (256kx4 - 4Mx8)
5c8bb361
L
57; and bios dpb/dph definitions.
58;#define RAMDISKCNT 0
59
60; Uncomment and set to 0, if you need to save flash (ie. ATmega88).
61;#define FAT16_SUPPORT 1
62
ce520bff
L
63; Uncomment and set to 0, if you don't want to use CP/M partitions.
64; (Saves some bytes.)
65;#define CPMDSK_SUPPORT 1
66
5c8bb361
L
67; Uncomment and set to 0, if you need to save flash.
68;#define MMCBOOTLOADER 1
9c15f366 69
5c8bb361
L
70;-----------------------------------------------------------------------
71;Debugging aids
72
12a27f27
L
73.equ BOOTWAIT = 1
74.equ MEMTEST = 1
75.equ MEMFILL = 1 /* Fill DRAM */
76.equ SRAM_FILL = 1 /* Fill unused SRAM */
77.equ MMC_DEBUG = 0 /* Increase for more debugging */
78.equ MMC_DEBUG_RDW = 0
79.equ DSKSEL_DEBUG = 0
80.equ DISK_DEBUG = 0 /* 1 = BOOT/HOME debug, 2 = +R/W debug */
81.equ HOSTRW_DEBUG = 0
82.equ FAT16_DEBUG = 0
83.equ FAT16_DBG_FAT = 0
84.equ HEAP_DEBUG = 0
85.equ PORT_DEBUG = 0
86.equ INS_DEBUG = 0
87.equ STACK_DBG = 0
88.equ PRINT_PC = 0
89.equ TIMER_DEBUG = 0
90.equ I2C_STATE_DEBUG = 0
91.equ MEMDUMP_DEBUG = 1
9c15f366 92
5c8bb361
L
93;-----------------------------------------------------------------------
94; Z80/8080 Virtual Ports
95
e8384f88
L
96#define UARTDR 1 /* UART Data Register */
97#define UARTCSR 3 /* UART Control/Status Register */
98#define UARTRXRDY 0x01 /* RxReady Status Bit Mask */
99#define UARTTXRDY 0x02 /* TxReady Status Bit Mask */
100
2ccaac16
L
101#define READ_FUNC 7
102#define WRITE_FUNC 6
103#define BOOT_FUNC 5
104#define HOME_FUNC 4
105
5c8bb361
L
106#define TIMERPORT 0x40 /* Base z80 port address for clock access */
107#define TIMER_CTL TIMERPORT
108#define TIMER_MSECS TIMERPORT+1
109#define TIMER_SECS TIMER_MSECS+2
110#define CLOCKPORT TIMERPORT+7 /* Real time clock BCD (ss,mm,hh,DD,MM,YYYY) */
111
112#define starttimercmd 1
113#define quitTimerCmd 2
114#define printTimerCmd 15
115#define uptimeCmd 16
116
12a27f27
L
117#define MEMDUMPPORT 0x09
118#define DEBUGPORT 0x4F
5c8bb361 119
12a27f27
L
120#define startTraceCmd 0x01 /* 'OUT (DEBUGPORT),startTraceCmd' starts tracing */
121#define stopTraceCmd 0x00
122#define PrintStackCmd 0x02
5c8bb361
L
123
124; Virtual I2C Interface
125#define I2CSTAT 0x05
126#define I2CCTRL 0x05
127#define I2CBLEN 0x06
128#define I2CADR 0x07
129#define I2CADRL 0x07
130#define I2CADRH 0x08
131
12a27f27
L
132; ISC16IS740 UART
133#define I2C_UART 0x50 /* ISC16IS740 base port */
825ecc9d 134
5c8bb361
L
135; Port-Expander PCF8574
136#define PORT 0x80
137#define PORT0 0x80
138#define PORT1 0x81
139#define PORT2 0x82
140#define PORT3 0x83
141#define PORT4 0x84
142#define PORT5 0x85
143#define PORT6 0x86
144#define PORT7 0x87
145
146;-----------------------------------------------------------------------
147;
148
5c8bb361
L
149#define IPLADDR 0x2000 /* Bootloader load address */
150
151#define DRAM_WAITSTATES 1 /* Number of additional clock cycles for dram read access */
152#define REFR_RATE 64000 /* dram refresh rate in cycles/s. */
153 /* Most drams need 1/15.6µs. */
154#define RXBUFSIZE 128 /* USART recieve buffer size. Must be power of 2 */
12a27f27
L
155.if SRAM_SIZE > 1024
156 .equ TXBUFSIZE = 128 /* USART transmit buffer size. Must be power of 2 */
157.else
158 .equ TXBUFSIZE = 32 /* USART transmit buffer size. Must be power of 2 */
159.endif
160
161.if SRAM_SIZE > 1024
162 .equ FAT16_FATBUF = 1
163.else
164 .equ FAT16_FATBUF = 0
165.endif
166
5c8bb361
L
167
168#define I2C_CLOCK 100000 /* 100kHz */
12a27f27 169#define I2C_BUFSIZE 66 /* largest message size + slave address (SLA) + subaddress */
5c8bb361
L
170
171
9c15f366
L
172#define MMC_SPI2X 1 /* 0 = SPI CLK/4, 1 = SPI CLK/2 */
173
80e1fa71 174#define MEMFILL_VAL 0x76 /* Fill ram with HALT opcode. */
9c15f366
L
175#define DBG_TRACE_BOTTOM 0x01 /* Page boundaries for INS_DEBUG and PRINT_PC */
176#define DBG_TRACE_TOP 0xdc /* Trace is off, below bottom page and above top page. */
98979541 177#define SRAMFILL_VAL 0x5A /* Fill unused SRAM */
9c15f366 178
e8384f88
L
179; define PARTID 0x52 /* Partition table id */
180 /* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */
181; Partition Table Structures
182
183#define PART_TYPE 4
184#define PART_START 8
185#define PART_SIZE 12
186
187/*
4bd49b80 188 * Partition table id
e8384f88 189 * (see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html)
4bd49b80 190 */
e8384f88
L
191#define PARTID1_FAT16 0x0E
192#define PARTID2_FAT16 0x06
193#define PARTID_CPM 0x52
194
195
196;-----------------------------------------------------------------------
197;
5c8bb361
L
198#ifndef DRAM_8BIT
199 #define DRAM_8BIT 1 /* 1 = 8bit wide data bus to DRAM (ie two 4-bit Chips)*/
200#endif /* 0 = only one 4 bit wide DRAM chip */
201#ifndef F_CPU
202 #define F_CPU 20000000 /* system clock in Hz; defaults to 20MHz */
203#endif
204#ifndef BAUD
205 #define BAUD 115200 /* console baud rate */
206#endif
825ecc9d
L
207#ifndef I2C_SUPPORT
208 #define I2C_SUPPORT DRAM_8BIT /* I2C requires 8 bit DRAM */
209#endif
210#if I2C_SUPPORT && !DRAM_8BIT
211 #error "I2C_SUPPORT requires 8 bit DRAM (DRAM_8BIT=1)!"
5c8bb361 212#endif
12a27f27
L
213#ifndef I2C_UART_SUPPORT
214 #define I2C_UART_SUPPORT I2C_SUPPORT
215#endif
216#if I2C_UART_SUPPORT
217 #define SC16IS740_ADDR 0x90 /* SC16IS740 I2C address. (8bit, A0=VDD, A1=VDD) */
218 #define SC16IS740_CLOCK 9216000 /* */
219#endif
5c8bb361
L
220
221#ifndef EM_Z80
222 #define EM_Z80 1 /* Emulate Z80 if true, else 8080 */
223#endif
2ccaac16 224
ce520bff 225#ifndef CPMDSK_SUPPORT
4bd49b80
L
226 #define CPMDSK_SUPPORT 1 /* Include Support for CP/M partitions */
227#endif
ce520bff 228
5c8bb361 229#ifndef FAT16_SUPPORT
ce520bff 230 #define FAT16_SUPPORT 1 /* Include Support for a FAT16 partition */
4bd49b80 231#endif /* which may contain CP/M image files. */
2ccaac16 232
5c8bb361
L
233#ifndef RAMDISKCNT
234 #define RAMDISKCNT 0 /* Number of RAM disks */
235#endif
236#define RAMDISKNR 'I'-'A' /* Drive "letter" for first RAM disk */
237
238/* MMC/SD Bootloader support. */
239#define BOOTLDRSIZE 2048 /* Bytes needed for Bootloader (1024 Words Bootsection Size) */
240#define DEVID_S "ACPM"
241#ifndef MMCBOOTLOADER
242 #define MMCBOOTLOADER 1
243#endif
244#ifndef TESTVERSION
4bd49b80 245 #define TESTVERSION 0
5c8bb361
L
246#endif
247
12a27f27
L
248#define TC_1MS (F_CPU/1000)
249#define TC_1US (F_CPU/1000000)
250
9c15f366
L
251;-----------------------------------------------------------------------
252; Port declarations
253
254#if DRAM_8BIT /* Implies software uart */
255
256;Port D
257.equ RAM_D0 = 0
258.equ RAM_D1 = 1
259.equ RAM_D2 = 2
260.equ RAM_D3 = 3
261.equ RAM_D4 = 4
262.equ RAM_D5 = 5
263.equ RAM_D6 = 6
264.equ RAM_D7 = 7
265.equ RAM_A0 = 0
266.equ RAM_A1 = 1
267.equ RAM_A2 = 2
268.equ RAM_A3 = 3
269.equ RAM_A4 = 4
270.equ RAM_A5 = 5
271.equ RAM_A6 = 6
272.equ RAM_A7 = 7
273
274;Port B
275.equ MMC_MOSI = 3
276.equ MMC_MISO = 4
277.equ MMC_SCK = 5
278.equ RAM_A8 = 3
279.equ RAM_A9 = 4
280.equ RAM_A10 = 5
281
282.equ RXD = 0
283.equ TXD = 1
284.equ MMC_CS = 2
285
286.equ P_MMC_CS = PORTB
287.equ P_A8 = PORTB
288.equ P_RXD = PORTB
79986122 289.equ P_TXD = PORTB
9c15f366
L
290
291;Port C
292.equ RAM_RAS = 0
293.equ RAM_CAS = 1
294.equ RAM_OE = 2
295.equ RAM_W = 3
12a27f27
L
296.equ SDA = 4
297.equ SCL = 5
9c15f366
L
298
299.equ P_RAS = PORTC
300.equ P_CAS = PORTC
301.equ P_OE = PORTC
302.equ P_W = PORTC
12a27f27 303.equ P_I2C = PORTC
9c15f366
L
304
305
306#else /* 4 bit RAM, hardware uart */
307
308; Port D
309.equ RXD = 0
310.equ TXD = 1
311.equ RAM_OE = 2
312.equ RAM_A8 = 3
313.equ MMC_CS = 4
314.equ RAM_A5 = 5
315.equ RAM_A6 = 6
316.equ RAM_A7 = 7
317
318.equ P_RXD = PORTD
319.equ P_OE = PORTD
320.equ P_A8 = PORTD
321.equ P_MMC_CS = PORTD
322.equ P_AH = PORTD
323 ; RAM_A[7..5]
324.equ RAM_AH_MASK = (1<<RAM_A8)|(1<<RAM_A7)|(1<<RAM_A6)|(1<<RAM_A5)
325.equ PD_OUTPUT_MASK = (1<<MMC_CS) | (1<<RAM_OE) | RAM_AH_MASK
326
327
328;Port B
329.equ RAM_A4 = 0
330.equ RAM_A3 = 1
331.equ RAM_A2 = 2
332.equ RAM_A1 = 3
333.equ MMC_MOSI = 3
334.equ RAM_A0 = 4
335.equ MMC_MISO = 4
336.equ RAM_RAS = 5
337.equ MMC_SCK = 5
338
339.equ P_RAS = PORTB
340.equ P_AL = PORTB
341 ; RAM_A[4..0]
342.equ RAM_AL_MASK = (1<<RAM_A4)|(1<<RAM_A3)|(1<<RAM_A2)|(1<<RAM_A1)|(1<<RAM_A0)
343.equ PB_OUTPUT_MASK = (1<<RAM_ras) | RAM_AL_MASK
344
345;Port C
346.equ RAM_D0 = 0
347.equ RAM_D1 = 1
348.equ RAM_D2 = 2
349.equ RAM_D3 = 3
350.equ RAM_W = 4
351.equ RAM_CAS = 5
352
353.equ P_DQ = PORTC
354.equ P_W = PORTC
355.equ P_CAS = PORTC
356
357.equ RAM_DQ_MASK = (1<<RAM_D3)|(1<<RAM_D2)|(1<<RAM_D1)|(1<<RAM_D0)
358.equ PC_OUTPUT_MASK = (1<<RAM_CAS)|(1<<RAM_W)
359
360#endif /* DRAM_8BIT */
361
362
363;-----------------------------------------------------------------------
364;Register definitions
365
366.def _tmp0 = r0
367.def _tmp1 = r1
368
369.def _RAS0 = r2
370.def _CAS0 = r3
371.def _OE = r4
372.def _WE = r5
373.def _255 = r6
374.def _0 = r7
825ecc9d
L
375
376.def z_c = r8 ;
377.def z_b = r9 ;
bca3519f
L
378.def z_bcl = r8 ;
379.def z_bch = r9 ;
825ecc9d
L
380.def z_e = r10 ;
381.def z_d = r11 ;
bca3519f
L
382.def z_del = r10 ;
383.def z_deh = r11 ;
825ecc9d
L
384.def z_l = r12 ;
385.def z_h = r13 ;
bca3519f
L
386.def z_hll = r12 ;
387.def z_hlh = r13 ;
825ecc9d 388.def z_spl = r14 ;
9c15f366
L
389.def z_sph = r15 ;
390.def temp = r16 ;
391.def temp2 = r17 ;
825ecc9d
L
392.def temp3 = r18 ;
393;.def temp4 = r19 ;
394.def intstat = r19 ;interpreter status / interrupt status
9c15f366 395.def z_flags = r20 ;
825ecc9d 396.def z_a = r21 ;
9c15f366
L
397.def opl = r22 ;
398.def oph = r23 ;
399.def z_pcl = r24 ;
400.def z_pch = r25 ;
401; xl ;r26
402; xh ;r27
403; yl ;r28
404; yh ;r29
825ecc9d
L
405; zl ;r30
406; zh ;r31
9c15f366
L
407
408
fa9059af 409.equ i_break = 0 ;break detected flag
80e1fa71
L
410.equ i_trace = 1 ;cpu interpreter trace flag
411.equ i_halt = 2 ;executing halt instruction
9c15f366
L
412
413#if defined __ATmega8__
623dd899
L
414 #if DRAM_8BIT
415
416 .equ flags = UBRRL ;UART is unused with 8-Bit RAM
417 #else
418 .equ flags = TWBR ;TWI is unused with 4-Bit RAM
4bd49b80 419 #endif
623dd899
L
420 .equ P_PUD = SFIOR
421
4bd49b80 422#else
623dd899
L
423
424 .equ flags = GPIOR0
425 .equ P_PUD = MCUCR
426
427#endif /* __ATmega8__ */
9c15f366
L
428
429; Flags:
430 .equ hostact = 7 ;host active flag
431 .equ hostwrt = 6 ;host written flag
432 .equ rsflag = 5 ;read sector flag
433 .equ readop = 4 ;1 if read operation
80e1fa71
L
434
435 .equ prefixfd = 1 ;Opcode prefix DD=0, FD=1
9c15f366 436
80e1fa71 437
79986122
L
438#if EM_Z80
439 #define CPUSTR "Z80"
440#else
441 #define CPUSTR "8080"
442#endif
5c8bb361 443#if TESTVERSION
12a27f27 444 #define TESTSTR " Test"
5c8bb361
L
445#else
446 #define TESTSTR ""
447#endif
79986122 448
9c15f366
L
449#if defined __ATmega8__
450.equ RXTXDR0 = UDR
451.equ UCSR0A = UCSRA
452.equ UDRE0 = UDRE
453.equ UCSR0B = UCSRB
454.equ RXCIE0 = RXCIE
455.equ UDRIE0 = UDRIE
456.equ RXEN0 = RXEN
457.equ TXEN0 = TXEN
458.equ UCSR0C = UCSRC
459.equ UCSZ00 = UCSZ0
460.equ UCSZ01 = UCSZ1
461.equ UBRR0H = UBRRH
462.equ UBRR0L = UBRRL
463.equ OCR2A = OCR2
464.equ OC2Aaddr= OC2addr
465.equ TCCR2A = TCCR2
466.equ TCCR2B = TCCR2
467.equ TIMSK1 = TIMSK
468.equ TIMSK2 = TIMSK
469.equ OCIE2A = OCIE2
470.equ TIFR1 = TIFR
471.equ ICIE1 = TICIE1
472#else
473.equ RXTXDR0 = UDR0
474#endif
475
476; vim:set ts=8 noet nowrap