summaryrefslogtreecommitdiff
path: root/avr
diff options
context:
space:
mode:
authorLeo C2014-07-11 17:16:28 +0200
committerLeo C2014-07-11 17:16:28 +0200
commiteded7ec457ef999586c66b15ada5948bddcc735c (patch)
treee6fb72fe86054384f8ba893a6aca210c6f58a408 /avr
parent64045ba0916623ab9e7c2f1eed837a2aae081e63 (diff)
downloadz180-stamp-eded7ec457ef999586c66b15ada5948bddcc735c.zip
Revert "Refactro Tupfiles"
This reverts commit cda2107f6e52a3e131502a6ec318ac3f216ac186.
Diffstat (limited to 'avr')
-rw-r--r--avr/Tupfile37
-rw-r--r--avr/z180-stamp-avr.c73
-rw-r--r--avr/z80-if.c7
-rw-r--r--avr/z80-if.h7
4 files changed, 89 insertions, 35 deletions
diff --git a/avr/Tupfile b/avr/Tupfile
index 72f7e71..b43a822 100644
--- a/avr/Tupfile
+++ b/avr/Tupfile
@@ -1,13 +1,8 @@
include_rules
PROG = z180-stamp-avr
-
SRC = z180-stamp-avr.c serial.c z80-if.c
-
SRC_Z = ../z180/hdrom.c
-PREDEP = ../z180/hdrom.h
-
-#SRC += $(SRC_Z)
#TARGETS = $(PROG).elf
MCU_TARGET = atmega1281
@@ -21,23 +16,47 @@ INCLUDES += ../z180
TOOLCHAINDIR =
TOOLCHAIN = avr
+CC = $(TOOLCHAIN)-gcc
+LD = $(TOOLCHAIN)-gcc
+AR = $(TOOLCHAIN)-ar
+AS = $(TOOLCHAIN)-as
+OBJCOPY = $(TOOLCHAIN)-objcopy
+OBJDUMP = $(TOOLCHAIN)-objdump
+SIZE = $(TOOLCHAIN)-size
+GDB = $(TOOLCHAIN)-gdb
+
###############################################################################
ifdef DEBUG
DEFS += -DDEBUG=2
endif
+CFLAGS = -g -Os
CFLAGS += -mmcu=$(MCU_TARGET)
-
+CFLAGS += -std=gnu99
+CFLAGS += -Wall -Wextra -Wimplicit-function-declaration
+CFLAGS += -Wredundant-decls
+#CFLAGS += -fno-common -ffunction-sections -fdata-sections
#CFLAGS += -I $(INCLUDES)
CPPFLAGS += $(DEFS)
-CPPFLAGS_Z += -D'const=const __flash'
-
# Linker flags
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--cref
-include $(CONFIG)/gcc.tup
+!cc = |> ^ CC %f^ $(CC) $(CFLAGS) $(CPPFLAGS) -c %f -o %o |> %B.o
+!LINK = |> ^ LINK %o^ $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-Map=%O.map %f $(LDLIBS) -o %o |> | %O.map
+!OBJCOPY= |> ^ OBJCOPY %o^ $(OBJCOPY) -Oihex %f %o |>
+!OBJDUMP= |> ^ OBJDUMP %o^ $(OBJDUMP) -h -S %f > %o |> %O.lss
+!SIZE = |> ^ SIZE^ $(SIZE) %f |>
+
+: foreach $(SRC) | ../z180/hdrom.h |> !cc |> {objs}
+: $(SRC_Z) |> !cc -D'const=const __flash' |> {objs}
+
+: {objs} |> !LINK |> $(PROG).elf
+: $(PROG).elf |> !OBJCOPY |> %B.hex
+: $(PROG).elf |> !OBJDUMP |> %B.lss
+: $(PROG).elf |> !SIZE |>
+
diff --git a/avr/z180-stamp-avr.c b/avr/z180-stamp-avr.c
index 6871027..4ea4d47 100644
--- a/avr/z180-stamp-avr.c
+++ b/avr/z180-stamp-avr.c
@@ -22,16 +22,52 @@
#undef const
#define FLASH __flash
+//#define FLASH
#define ESCCHAR ('^'-0x40)
#define S_10MS_TO (1<<0)
-static volatile int_fast8_t timeout_1s;
-static volatile uint_least8_t Stat;
+volatile int_fast8_t timeout_1s;
+volatile uint_least8_t Stat;
+/****************************************************************/
+
+#define P_ADL PORTA
+#define P_ADH PORTC
+#define P_ADB PORTE
+#define PIN_ADB PINE
+
+#define ADB_WIDTH 3
+#define ADB_SHIFT 2
+//#define ADB_PORT GPIOE
+
+#define MASK(n) ((1<<(n))-1)
+#define SMASK(w,s) (MASK(w) << (s))
+
+typedef union {
+ uint32_t l;
+ uint16_t w[2];
+ uint8_t b[4];
+} addr_t;
+
+
+
+void z80_setaddress(uint32_t addr)
+{
+ addr_t x;
+
+ x.l = addr;
+ P_ADL = x.b[0];
+ P_ADH = x.b[1];
+ PIN_ADB = ((x.b[2] << ADB_SHIFT) ^ P_ADB) & MASK(ADB_WIDTH) << ADB_SHIFT ;
+
+}
+
+/****************************************************************/
+
/*--------------------------------------------------------------------------*/
@@ -46,7 +82,10 @@ void sys_tick_handler(void)
if (tick_10ms == 10)
{
Stat |= S_10MS_TO;
+
tick_10ms = 0;
+
+
/* Drive timer procedure of low level disk I/O module */
//disk_timerproc();
}
@@ -62,10 +101,6 @@ void sys_tick_handler(void)
}
-static void do_10ms(void)
-{
-}
-
/*--------------------------------------------------------------------------*/
static uint32_t z80_sram_cmp(uint32_t addr, uint32_t length, uint8_t wval, int inc)
@@ -73,7 +108,7 @@ static uint32_t z80_sram_cmp(uint32_t addr, uint32_t length, uint8_t wval, int i
uint8_t rval;
int_fast8_t errors = 0;
- DBG_P(1, "SRAM: Check 0x%.5lX byte... ", length);
+ DBG_P(1, "SRAM: Check %#.5x byte... ", length);
while (length--) {
if ((rval = z80_read(addr)) != wval) {
if (errors == 0) {
@@ -141,8 +176,6 @@ const char * const qbcat = "Zhe quick brown fox jumps over the lazy cat!";
#endif
-/*--------------------------------------------------------------------------*/
-
uint8_t z80_get_byte(uint32_t adr)
{
uint8_t data;
@@ -154,6 +187,13 @@ uint8_t z80_get_byte(uint32_t adr)
return data;
}
+
+/*--------------------------------------------------------------------------*/
+
+static void do_10ms(void)
+{
+}
+
/*--------------------------------------------------------------------------*/
struct msg_item {
@@ -162,7 +202,6 @@ struct msg_item {
void (*func)(uint8_t, int, uint8_t *);
};
-static
uint32_t msg_to_addr(uint8_t *msg)
{
union {
@@ -178,7 +217,6 @@ uint32_t msg_to_addr(uint8_t *msg)
return addr.as32;
}
-static
void do_msg_ini_msgfifo(uint8_t subf, int len, uint8_t * msg)
{
(void)subf; (void)len;
@@ -187,7 +225,6 @@ void do_msg_ini_msgfifo(uint8_t subf, int len, uint8_t * msg)
}
-static
void do_msg_ini_memfifo(uint8_t subf, int len, uint8_t * msg)
{
(void)len;
@@ -196,7 +233,6 @@ void do_msg_ini_memfifo(uint8_t subf, int len, uint8_t * msg)
}
-static
void do_msg_char_out(uint8_t subf, int len, uint8_t * msg)
{
(void)subf;
@@ -206,7 +242,6 @@ void do_msg_char_out(uint8_t subf, int len, uint8_t * msg)
}
-static
const FLASH struct msg_item z80_messages[] =
{
{ 0, /* fct nr. */
@@ -225,7 +260,8 @@ const FLASH struct msg_item z80_messages[] =
};
-static
+
+
void do_message(int len, uint8_t *msg)
{
uint8_t fct, sub_fct;
@@ -267,10 +303,9 @@ void do_message(int len, uint8_t *msg)
}
-//TODO:
+
#define CTRBUF_LEN 256
-static
void check_msg_fifo(void)
{
int ch;
@@ -309,7 +344,6 @@ void check_msg_fifo(void)
}
-static
void z80_load_mem(void)
{
unsigned sec = 0;
@@ -330,7 +364,6 @@ void z80_load_mem(void)
sec++;
}
}
-
/*--------------------------------------------------------------------------*/
int main(void)
@@ -340,6 +373,7 @@ int main(void)
// setvbuf(stdout, NULL, _IONBF, 0);
serial_setup();
+// printf("\n(STM32F100+HD64180)_stamp Tester\n");
printf("\n(ATMEGA1281+HD64180)_stamp Tester\n");
DBG_P(1, "z80_setup_bus... ");
@@ -347,6 +381,7 @@ int main(void)
z80_setup_bus();
DBG_P(1, "done.\n");
+
DBG_P(1, "Get bus... ");
z80_busreq(LOW);
z80_reset(HIGH);
diff --git a/avr/z80-if.c b/avr/z80-if.c
index 889849b..955a61a 100644
--- a/avr/z80-if.c
+++ b/avr/z80-if.c
@@ -200,6 +200,13 @@ int z80_stat_halt(void)
+typedef union {
+ uint32_t l;
+ uint16_t w[2];
+ uint8_t b[4];
+} addr_t;
+
+
/*--------------------------------------------------------------------------*/
diff --git a/avr/z80-if.h b/avr/z80-if.h
index 1e7d675..1068225 100644
--- a/avr/z80-if.h
+++ b/avr/z80-if.h
@@ -1,13 +1,6 @@
typedef enum {LOW, HIGH} level_t;
-typedef union {
- uint32_t l;
- uint16_t w[2];
- uint8_t b[4];
-} addr_t;
-
-
void z80_setup_bus(void);
void z80_write(uint32_t addr, uint8_t data);
uint8_t z80_read(uint32_t addr);