From 64045ba0916623ab9e7c2f1eed837a2aae081e63 Mon Sep 17 00:00:00 2001 From: Leo C Date: Fri, 11 Jul 2014 17:14:53 +0200 Subject: Refactor Tupfiles --- avr/Tupfile | 37 +++++++------------------- avr/z180-stamp-avr.c | 73 ++++++++++++++-------------------------------------- avr/z80-if.c | 7 ----- avr/z80-if.h | 7 +++++ 4 files changed, 35 insertions(+), 89 deletions(-) (limited to 'avr') diff --git a/avr/Tupfile b/avr/Tupfile index b43a822..72f7e71 100644 --- a/avr/Tupfile +++ b/avr/Tupfile @@ -1,8 +1,13 @@ 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 @@ -16,47 +21,23 @@ 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 -!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 |> - +include $(CONFIG)/gcc.tup diff --git a/avr/z180-stamp-avr.c b/avr/z180-stamp-avr.c index 4ea4d47..6871027 100644 --- a/avr/z180-stamp-avr.c +++ b/avr/z180-stamp-avr.c @@ -22,52 +22,16 @@ #undef const #define FLASH __flash -//#define FLASH #define ESCCHAR ('^'-0x40) #define S_10MS_TO (1<<0) -volatile int_fast8_t timeout_1s; -volatile uint_least8_t Stat; +static volatile int_fast8_t timeout_1s; +static 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 ; - -} - -/****************************************************************/ - /*--------------------------------------------------------------------------*/ @@ -82,10 +46,7 @@ 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(); } @@ -101,6 +62,10 @@ 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) @@ -108,7 +73,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 %#.5x byte... ", length); + DBG_P(1, "SRAM: Check 0x%.5lX byte... ", length); while (length--) { if ((rval = z80_read(addr)) != wval) { if (errors == 0) { @@ -176,6 +141,8 @@ 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; @@ -187,13 +154,6 @@ uint8_t z80_get_byte(uint32_t adr) return data; } - -/*--------------------------------------------------------------------------*/ - -static void do_10ms(void) -{ -} - /*--------------------------------------------------------------------------*/ struct msg_item { @@ -202,6 +162,7 @@ struct msg_item { void (*func)(uint8_t, int, uint8_t *); }; +static uint32_t msg_to_addr(uint8_t *msg) { union { @@ -217,6 +178,7 @@ 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; @@ -225,6 +187,7 @@ 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; @@ -233,6 +196,7 @@ 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; @@ -242,6 +206,7 @@ void do_msg_char_out(uint8_t subf, int len, uint8_t * msg) } +static const FLASH struct msg_item z80_messages[] = { { 0, /* fct nr. */ @@ -260,8 +225,7 @@ const FLASH struct msg_item z80_messages[] = }; - - +static void do_message(int len, uint8_t *msg) { uint8_t fct, sub_fct; @@ -303,9 +267,10 @@ void do_message(int len, uint8_t *msg) } - +//TODO: #define CTRBUF_LEN 256 +static void check_msg_fifo(void) { int ch; @@ -344,6 +309,7 @@ void check_msg_fifo(void) } +static void z80_load_mem(void) { unsigned sec = 0; @@ -364,6 +330,7 @@ void z80_load_mem(void) sec++; } } + /*--------------------------------------------------------------------------*/ int main(void) @@ -373,7 +340,6 @@ 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... "); @@ -381,7 +347,6 @@ 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 955a61a..889849b 100644 --- a/avr/z80-if.c +++ b/avr/z80-if.c @@ -200,13 +200,6 @@ 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 1068225..1e7d675 100644 --- a/avr/z80-if.h +++ b/avr/z80-if.h @@ -1,6 +1,13 @@ 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); -- cgit v1.2.3