diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/Makefile b/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/Makefile index 68e6d5c..5334723 100755 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/Makefile +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/Makefile @@ -35,12 +35,13 @@ SUBDIRS := # Add inputs and outputs from these tool invocations to the build variables C_SRCS += \ -../main.c \ -../mmc.c \ -../mmc_perf.c \ +../wdc_avr.c \ +../wdc_main.c \ +../wdc_drv_mmc.c \ +../wdc_drv_mmc_perf.c \ ../uart.c \ -../wdc_if_pio.c \ -../wdc_if_sdcard.c \ +../wdc_if_p8000.c \ +../wdc_if_disk.c \ ../wdc_par.c \ ../wdc_ram.c @@ -52,45 +53,49 @@ ASM_SRCS += OBJS += \ -main.o \ -mmc.o \ -mmc_perf.o \ +wdc_avr.o \ +wdc_main.o \ +wdc_drv_mmc.o \ +wdc_drv_mmc_perf.o \ uart.o \ -wdc_if_pio.o \ -wdc_if_sdcard.o \ +wdc_if_p8000.o \ +wdc_if_disk.o \ wdc_par.o \ wdc_ram.o OBJS_AS_ARGS += \ -main.o \ -mmc.o \ -mmc_perf.o \ +wdc_avr.o \ +wdc_main.o \ +wdc_drv_mmc.o \ +wdc_drv_mmc_perf.o \ uart.o \ -wdc_if_pio.o \ -wdc_if_sdcard.o \ +wdc_if_p8000.o \ +wdc_if_disk.o \ wdc_par.o \ wdc_ram.o C_DEPS += \ -main.d \ -mmc.d \ -mmc_perf.d \ +wdc_avr.d \ +wdc_main.d \ +wdc_drv_mmc.d \ +wdc_drv_mmc_perf.d \ uart.d \ -wdc_if_pio.d \ -wdc_if_sdcard.d \ +wdc_if_p8000.d \ +wdc_if_disk.d \ wdc_par.d \ wdc_ram.d C_DEPS_AS_ARGS += \ -main.d \ -mmc.d \ -mmc_perf.d \ +wdc_avr.d \ +wdc_main.d \ +wdc_drv_mmc.d \ +wdc_drv_mmc_perf.d \ uart.d \ -wdc_if_pio.d \ -wdc_if_sdcard.d \ +wdc_if_p8000.d \ +wdc_if_disk.d \ wdc_par.d \ wdc_ram.d @@ -121,6 +126,8 @@ OUTPUT_FILE_DEP:= ./makedep.mk + + ./%.o: .././%.c @echo Building file: $< @echo Invoking: AVR/GNU C Compiler : (AVR_8_bit_GNU_Toolchain_3.4.0_663) 4.6.2 diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/makedep.mk b/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/makedep.mk index 6a82325..4895925 100755 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/makedep.mk +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/makedep.mk @@ -2,17 +2,19 @@ # Automatically-generated file. Do not edit or delete the file ################################################################################ -main.c +wdc_avr.c -mmc.c +wdc_main.c -mmc_perf.c +wdc_drv_mmc.c + +wdc_drv_mmc_perf.c uart.c -wdc_if_pio.c +wdc_if_p8000.c -wdc_if_sdcard.c +wdc_if_disk.c wdc_par.c diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/Hardware/P8000_WDC_Emulator.pdf b/P8000_WDC_Emulator/P8000_WDC_Emulator/Hardware/P8000_WDC_Emulator.pdf index b80d4fa..0d0b552 100644 Binary files a/P8000_WDC_Emulator/P8000_WDC_Emulator/Hardware/P8000_WDC_Emulator.pdf and b/P8000_WDC_Emulator/P8000_WDC_Emulator/Hardware/P8000_WDC_Emulator.pdf differ diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/Hardware/P8000_WDC_Emulator.sch b/P8000_WDC_Emulator/P8000_WDC_Emulator/Hardware/P8000_WDC_Emulator.sch index fb3a8e7..edb9282 100755 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/Hardware/P8000_WDC_Emulator.sch +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/Hardware/P8000_WDC_Emulator.sch @@ -174,7 +174,7 @@ T 67100 33100 9 8 1 0 0 0 1 T 68500 33100 9 8 1 0 0 0 1 1 T 71000 33400 9 7 1 0 0 0 1 -$Revision: 1.12 $ / $Date: 2012/06/10 21:03:24 $ +$Revision: 1.13 $ / $Date: 2012/06/12 17:34:14 $ T 71000 33100 9 8 1 0 0 0 1 Oliver Lehmann N 50600 59400 51200 59400 4 @@ -573,7 +573,7 @@ T 35200 56500 5 10 1 1 0 6 1 pinlabel=\_TE\_ } N 31900 56400 35200 56400 4 -N 31900 58500 36400 58500 4 +N 31900 58500 36300 58500 4 { T 35600 58600 5 10 1 1 0 0 1 pinlabel=\_TR\_ @@ -686,35 +686,13 @@ T 42000 52500 5 10 1 1 0 0 1 pinlabel=\_RDY\_ } N 31900 57000 35200 57000 4 -N 39300 60600 40100 60600 4 -N 40100 60600 40100 59400 4 -C 40000 59100 1 0 0 gnd-1.sym -C 39300 60000 1 90 0 npn-3.sym -{ -T 38800 60900 5 10 0 0 90 0 1 -device=NPN_TRANSISTOR -T 39200 61100 5 10 1 1 0 0 1 -refdes=1T1 -T 39200 60800 5 10 1 1 0 0 1 -pinlabel=BC548A -} -N 31900 60600 38300 60600 4 +N 31900 60600 36300 60600 4 { T 35600 60700 5 10 1 1 0 0 1 pinlabel=\_ASTB\_ } -C 38700 59500 1 270 0 resistor-1.sym -{ -T 39100 59200 5 10 0 0 270 0 1 -device=RESISTOR -T 39000 59100 5 10 1 1 0 0 1 -refdes=4R1 -T 39000 58900 5 10 1 1 0 0 1 -value=1k8 -} N 38800 56400 41600 56400 4 -N 38800 56400 38800 58600 4 -N 38800 59500 38800 60000 4 +N 38800 56400 38800 60400 4 C 35200 57000 1 270 0 busripper-1.sym { T 35200 57400 5 8 0 0 0 0 1 @@ -730,29 +708,6 @@ T 42000 51900 5 10 1 1 0 0 1 pinlabel=\_RST\_ } N 47300 51800 42000 51800 4 -N 37400 58500 38200 58500 4 -N 38200 58500 38200 57300 4 -C 38100 57000 1 0 0 gnd-1.sym -C 37400 57900 1 90 0 npn-3.sym -{ -T 36900 58800 5 10 0 0 90 0 1 -device=NPN_TRANSISTOR -T 37300 59000 5 10 1 1 0 0 1 -refdes=1T1 -T 37300 58700 5 10 1 1 0 0 1 -pinlabel=BC548A -} -C 36800 57400 1 270 0 resistor-1.sym -{ -T 37200 57100 5 10 0 0 270 0 1 -device=RESISTOR -T 37100 57000 5 10 1 1 0 0 1 -refdes=4R1 -T 37100 56800 5 10 1 1 0 0 1 -value=1k8 -} -N 36900 57400 36900 57900 4 -N 36900 56100 36900 56500 4 N 41100 46600 47900 46600 4 T 41200 46800 9 10 1 0 0 0 1 /RDWR TO ATA @@ -1670,7 +1625,7 @@ C 47900 45900 1 0 0 7432-1.sym T 48500 46800 5 10 0 0 0 0 1 device=7432 T 48200 46800 5 10 1 1 0 0 1 -refdes=D6 +refdes=D7 T 48500 48200 5 10 0 0 0 0 1 footprint=DIP14 } @@ -1679,7 +1634,7 @@ C 50700 45000 1 0 0 7404-1.sym T 51300 45900 5 10 0 0 0 0 1 device=7404 T 51000 45900 5 10 1 1 0 0 1 -refdes=D5 +refdes=D8 T 51300 48500 5 10 0 0 0 0 1 footprint=DIP14 } @@ -1689,7 +1644,7 @@ C 47900 44500 1 0 0 7432-1.sym T 48500 45400 5 10 0 0 0 0 1 device=7432 T 48200 45400 5 10 1 1 0 0 1 -refdes=D6 +refdes=D7 T 48500 46800 5 10 0 0 0 0 1 footprint=DIP14 T 47900 44500 5 10 0 1 0 6 1 @@ -1713,7 +1668,7 @@ C 47900 43500 1 180 1 7432-1.sym T 48500 42600 5 10 0 0 180 6 1 device=7432 T 48200 42600 5 10 1 1 180 6 1 -refdes=D6 +refdes=D7 T 48500 41200 5 10 0 0 180 6 1 footprint=DIP14 T 47900 43500 5 10 0 0 180 6 1 @@ -1724,7 +1679,7 @@ C 47900 42100 1 180 1 7432-1.sym T 48500 41200 5 10 0 0 180 6 1 device=7432 T 48200 41200 5 10 1 1 180 6 1 -refdes=D6 +refdes=D7 T 48500 39800 5 10 0 0 180 6 1 footprint=DIP14 T 47900 42100 5 10 0 1 180 0 1 @@ -1739,7 +1694,7 @@ C 50700 42000 1 0 0 7404-1.sym T 51300 42900 5 10 0 0 0 0 1 device=7404 T 51000 42900 5 10 1 1 0 0 1 -refdes=D5 +refdes=D8 T 51300 45500 5 10 0 0 0 0 1 footprint=DIP14 T 50700 42000 5 10 0 0 0 0 1 @@ -1841,7 +1796,7 @@ device=none T 41600 56200 5 10 1 1 0 6 1 pinlabel=TR } -N 36900 56100 41600 56100 4 +N 38500 56100 41600 56100 4 C 41600 49000 1 270 0 busripper-1.sym { T 41600 49400 5 8 0 0 0 0 1 @@ -1862,7 +1817,7 @@ C 39000 49200 1 0 0 7404-1.sym T 39600 50100 5 10 0 0 0 0 1 device=7404 T 39300 50100 5 10 1 1 0 0 1 -refdes=D5 +refdes=D8 T 39600 52700 5 10 0 0 0 0 1 footprint=DIP14 T 39000 49200 5 10 0 0 0 0 1 @@ -1975,3 +1930,49 @@ T 70800 42200 5 10 1 1 90 0 1 value=10k } N 52300 45500 52300 41500 4 +C 37600 60100 1 0 1 7403-1.sym +{ +T 37100 61000 5 10 0 0 0 6 1 +device=7403 +T 37300 61000 5 10 1 1 0 6 1 +refdes=D9 +T 37100 62400 5 10 0 0 0 6 1 +footprint=DIP14 +} +N 37600 60400 38800 60400 4 +C 35600 63300 1 90 1 busripper-1.sym +{ +T 35600 63700 1 8 0 0 0 6 1 +device=none +T 35600 63400 5 10 1 1 0 0 1 +pinlabel=\_RDY\_ +} +N 35600 63300 41200 63300 4 +N 41200 63300 41200 60800 4 +N 41200 60800 40300 60800 4 +C 37600 58000 1 0 1 7403-1.sym +{ +T 37100 58900 5 10 0 0 0 6 1 +device=7403 +T 37300 58900 5 10 1 1 0 6 1 +refdes=D9 +T 37100 60300 5 10 0 0 0 6 1 +footprint=DIP14 +T 37600 58000 5 10 0 0 0 0 1 +slot=2 +} +N 37600 58700 38500 58700 4 +N 38500 58700 38500 56100 4 +N 37600 58300 38500 58300 4 +C 40300 60300 1 0 1 7404-1.sym +{ +T 39700 61200 5 10 0 0 0 6 1 +device=7404 +T 40000 61200 5 10 1 1 0 6 1 +refdes=D8 +T 39700 63800 5 10 0 0 0 6 1 +footprint=DIP14 +T 40300 60300 5 10 0 0 0 6 1 +slot=4 +} +N 37600 60800 39200 60800 4 diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/P8000_WDC_Emulator.cproj b/P8000_WDC_Emulator/P8000_WDC_Emulator/P8000_WDC_Emulator.cproj index b427cd0..ff56132 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/P8000_WDC_Emulator.cproj +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/P8000_WDC_Emulator.cproj @@ -72,22 +72,28 @@ - + compile - + compile - + compile - + compile - + compile - + + compile + + + compile + + compile @@ -96,16 +102,16 @@ compile - + compile - + compile - + compile - + compile diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/uart.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/uart.c index 7c0dde1..81cb235 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/uart.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/uart.c @@ -14,7 +14,7 @@ #include #include "uart.h" -#include "config.h" +#include "wdc_config.h" /* some mcus have multiple uarts */ #ifdef UDR0 diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c new file mode 100644 index 0000000..060b151 --- /dev/null +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2012 Oliver Lehmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * $Id: wdc_avr.c,v 1.1 2012/06/12 17:34:14 olivleh1 Exp $ + */ + + +#include +#include "wdc_config.h" +#include "wdc_avr.h" + +void wdc_init_avr() +{ + /* configure the P8000 interface */ + configure_pin_status0(); + configure_pin_status1(); + configure_pin_status2(); + configure_pin_te(); + configure_pin_wdardy(); + configure_pin_tr(); + configure_pin_reset(); + + configure_port_data_read(); + + /* configure the address decoder */ + configure_pin_addr0(); + configure_pin_addr1(); + configure_pin_addr2(); + + init_addressdecoder(); + + /* configure the MMC interface */ + configure_pin_miso(); + configure_pin_sck(); + configure_pin_mosi(); + configure_pin_mmc_cs(); +} \ No newline at end of file diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h new file mode 100644 index 0000000..9d900b9 --- /dev/null +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2012 Oliver Lehmann + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * $Id: wdc_avr.h,v 1.1 2012/06/12 17:34:14 olivleh1 Exp $ + */ + + +#ifndef WDC_AVR_H_ +#define WDC_AVR_H_ + +#define configure_port_data_read() DDR_DATA = 0x00 /* programs the DATA-Port as Input-only for reading from the P8000*/ +#define configure_port_data_write() DDR_DATA = 0xff /* programs the DATA-Port as Out-only for writing to the P8000*/ + +#define configure_pin_status0() DDR_INFO |= ( 1 << PIN_INFO_STATUS0 ) +#define configure_pin_status1() DDR_INFO |= ( 1 << PIN_INFO_STATUS1 ) +#define configure_pin_status2() DDR_INFO |= ( 1 << PIN_INFO_STATUS2 ) +#define configure_pin_te() DDR_INFO &= ~( 1 << PIN_INFO_TE ) +#define configure_pin_wdardy() DDR_INFO &= ~( 1 << PIN_INFO_WDARDY ) +#define configure_pin_tr() DDR_INFO |= ( 1 << PIN_INFO_TR ) +#define configure_pin_reset() DDR_INFO &= ~( 1 << PIN_INFO_RST ) + +#define port_data_set(x) ( PORT_DATA = ( x ) ) +#define port_info_set(x) ( PORT_INFO = ( x ) ) +#define port_data_get() PIN_DATA +#define port_info_get() PIN_INFO + +/* functions dealing with the 74138 address decoder */ +#define configure_pin_addr0() DDR_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR0 ) +#define configure_pin_addr1() DDR_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR1 ) +#define configure_pin_addr2() DDR_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR2 ) + +#define init_addressdecoder() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) ) +#define enable_p8000_transeiver() PORT_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR0 ) +#define disable_p8000_transeiver() PORT_ADRDEC &= ~( 1 << PIN_ADRDEC_ADDR0 ) + +/* functions dealing with the MMC interface */ + +#define configure_pin_miso() DDR_MMC &= ~ ( 1 << PIN_MMC_MISO ) +#define configure_pin_sck() DDR_MMC |= ( 1 << PIN_MMC_SCK ) +#define configure_pin_mosi() DDR_MMC |= ( 1 << PIN_MMC_MOSI ) +#define configure_pin_mmc_cs() DDR_MMC |= ( 1 << PIN_MMC_CS ) + +#define mmc_disable() PORT_MMC|= (1< -#include "config.h" -#include "mmc.h" +#include "wdc_config.h" +#include "wdc_avr.h" +#include "wdc_drv_mmc.h" #include "uart.h" #define wait_till_send_done() while ( ! ( SPSR & ( 1 << SPIF ) ) ) @@ -39,8 +40,6 @@ #define send_dummy_byte() SPDR = 0xFF; wait_till_send_done() #define recv_byte() SPDR #define xmit_byte(x) SPDR = x -#define mmc_disable() PORT_MMC|= (1< -#include "mmc.h" +#include "wdc_drv_mmc.h" #include "uart.h" #include "wdc_par.h" -uint8_t wdc_init_sdcard() +uint8_t wdc_init_disk() { return mmc_init(); } -uint32_t wdc_sector2sdblock ( uint16_t req_cylinder, uint8_t req_head, uint8_t req_sector ) +uint32_t wdc_sector2diskblock ( uint16_t req_cylinder, uint8_t req_head, uint8_t req_sector ) { return ( ( req_cylinder * wdc_get_hdd_heads() * wdc_get_hdd_sectors() ) + ( req_head * wdc_get_hdd_sectors() ) + ( req_sector - 1 ) ); } -uint32_t wdc_p8kblock2sdblock ( uint32_t blockno ) +uint32_t wdc_p8kblock2diskblock ( uint32_t blockno ) { return ( blockno + ( wdc_get_hdd_heads() * wdc_get_hdd_sectors() ) ); diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk.h index 4e23c42..1bf62ab 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk.h +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk.h @@ -26,15 +26,15 @@ */ /* - * $Id: wdc_if_disk.h,v 1.6 2012/06/07 18:01:02 olivleh1 Exp $ + * $Id: wdc_if_disk.h,v 1.7 2012/06/12 17:34:14 olivleh1 Exp $ */ -#ifndef WDC_IF_SDCARD_H_ -#define WDC_IF_SDCARD_H_ +#ifndef WDC_IF_DISK_H_ +#define WDC_IF_DISK_H_ -extern uint8_t wdc_init_sdcard(); -extern uint32_t wdc_sector2sdblock ( uint16_t req_cylinder, uint8_t req_head, uint8_t req_sector ); -extern uint32_t wdc_p8kblock2sdblock ( uint32_t blockno ); +extern uint8_t wdc_init_disk(); +extern uint32_t wdc_sector2diskblock ( uint16_t req_cylinder, uint8_t req_head, uint8_t req_sector ); +extern uint32_t wdc_p8kblock2diskblock ( uint32_t blockno ); extern uint8_t wdc_write_sector ( uint32_t addr, uint8_t *sector ); extern uint8_t wdc_read_sector ( uint32_t addr, uint8_t *sector ); extern uint8_t wdc_read_multiblock ( uint32_t addr, uint8_t *sector, uint8_t numblocks ); @@ -42,4 +42,4 @@ extern uint8_t wdc_write_multiblock ( uint32_t addr, uint8_t *sector, uint8_t nu #define WDC_BLOCKLEN 512 -#endif /* WDC_IF_SDCARD_H_ */ \ No newline at end of file +#endif /* WDC_IF_DISK_H_ */ \ No newline at end of file diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk_perf.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk_perf.c index 5950e18..7d72f10 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk_perf.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk_perf.c @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_if_disk_perf.c,v 1.4 2012/06/09 19:47:31 olivleh1 Exp $ + * $Id: wdc_if_disk_perf.c,v 1.5 2012/06/12 17:34:14 olivleh1 Exp $ */ #include @@ -36,8 +36,8 @@ #include #include #include -#include "config.h" -#include "wdc_if_sdcard.h" +#include "wdc_config.h" +#include "wdc_if_disk.h" #include "wdc_ram.h" #include "uart.h" diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.c index dd60903..8350519 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.c @@ -26,37 +26,18 @@ */ /* - * $Id: wdc_if_p8000.c,v 1.8 2012/06/10 21:11:03 olivleh1 Exp $ + * $Id: wdc_if_p8000.c,v 1.9 2012/06/12 17:34:14 olivleh1 Exp $ */ -#include "config.h" -#include +#include "wdc_config.h" +#include #include -#include "wdc_if_pio.h" +#include "wdc_avr.h" +#include "wdc_if_p8000.h" #include "wdc_par.h" -#include "uart.h" #define nop() __asm__ __volatile__ ("nop" ::) -void wdc_init_ports() -{ - configure_pin_status0(); - configure_pin_status1(); - configure_pin_status2(); - configure_pin_astb(); - configure_pin_te(); - configure_pin_wdardy(); - configure_pin_tr(); - configure_pin_reset(); - DDRD |= ( ( 1 << PIND5 ) ); - DDRD |= ( ( 1 << PIND6 ) ); - DDRD |= ( ( 1 << PIND7 ) ); - PORTD &= ~ ( ( 1 << PIND5 ) ); - PORTD &= ~ ( ( 1 << PIND6 ) ); - PORTD &= ~ ( ( 1 << PIND7 ) ); - configure_port_data_read(); -} - void wdc_wait_for_reset() { while ( !isset_info_reset() ) { @@ -81,12 +62,10 @@ uint8_t wdc_read_data_from_p8k ( uint8_t *buffer, uint16_t count, uint8_t wdc_st return 0; while ( !isset_info_wdardy() ); do { + enable_p8000_transeiver(); /* this also generates /ASTB in the moment /WDARDY gets low with a 7403 */ while ( isset_info_wdardy() ); - PORTD |= ( ( 1 << PIND5 ) ); - nop(); - nop(); buffer[datacnt] = ( uint8_t ) port_data_get(); - PORTD &= ~ ( ( 1 << PIND5 ) ); + disable_p8000_transeiver(); /* this additionally brings /ASTB to high */ while ( !isset_info_wdardy() ); datacnt++; } while ( datacnt < count ); @@ -106,24 +85,21 @@ void wdc_write_data_to_p8k ( uint8_t *buffer, uint16_t count, uint8_t wdc_status configure_port_data_write(); while ( !isset_info_wdardy() ); do { + enable_p8000_transeiver(); /* this also generates /ASTB in the moment /WDARDY gets low with a 7403 */ while ( isset_info_wdardy() ); - PORTD |= ( ( 1 << PIND5 ) ); - nop(); - nop(); port_data_set ( buffer[datacnt] ); - PORTD &= ~ ( ( 1 << PIND5 ) ); - while ( !isset_info_wdardy() ); + disable_p8000_transeiver(); /* this additionally brings /ASTB to high */ + while ( !isset_info_wdardy() ); datacnt++; } while ( datacnt < count ); while ( isset_info_wdardy() ); - PORTD |= ( ( 1 << PIND5 ) ); + enable_p8000_transeiver(); nop(); - PORTD &= ~ ( ( 1 << PIND5 ) ); + disable_p8000_transeiver(); configure_port_data_read(); while ( !isset_info_wdardy() ); port_info_set ( INFO_CLEAR ); - } uint8_t wdc_receive_cmd ( uint8_t *buffer, uint16_t count ) diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.h index b121b76..ad8dd04 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.h +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.h @@ -26,31 +26,14 @@ */ /* - * $Id: wdc_if_p8000.h,v 1.9 2012/06/10 21:03:23 olivleh1 Exp $ + * $Id: wdc_if_p8000.h,v 1.10 2012/06/12 17:34:14 olivleh1 Exp $ */ -#ifndef WDC_IF_PIO_H_ -#define WDC_IF_PIO_H_ +#ifndef WDC_IF_P8000_H_ +#define WDC_IF_P8000_H_ #define DELAY_PIO_US 550 -#define configure_port_data_read() DDR_DATA = 0x00 /* programs the DATA-Port as Input-only for reading from the P8000*/ -#define configure_port_data_write() DDR_DATA = 0xff /* programs the DATA-Port as Out-only for writing to the P8000*/ - -#define configure_pin_status0() DDR_INFO |= (1 << PIN_INFO_STATUS0) -#define configure_pin_status1() DDR_INFO |= (1 << PIN_INFO_STATUS1) -#define configure_pin_status2() DDR_INFO |= (1 << PIN_INFO_STATUS2) -#define configure_pin_astb() DDR_INFO |= (1 << PIN_INFO_ASTB) -#define configure_pin_te() DDR_INFO &= ~(1 << PIN_INFO_TE) -#define configure_pin_wdardy() DDR_INFO &= ~(1 << PIN_INFO_WDARDY) -#define configure_pin_tr() DDR_INFO |= (1 << PIN_INFO_TR) -#define configure_pin_reset() DDR_INFO &= ~(1 << PIN_INFO_RST) - -#define port_data_set(x) (PORT_DATA = (x)) -#define port_info_set(x) (PORT_INFO = (x)) -#define port_data_get(x) PIN_DATA -#define port_info_get(x) PIN_INFO - /* input pin handling */ #define isset_info_reset() ((PIN_INFO) & (1 << PIN_INFO_RST)) #define isset_info_te() ((PIN_INFO) & (1 << PIN_INFO_TE)) @@ -60,14 +43,12 @@ #define DATA_CLEAR 0x00 #define INFO_CLEAR 0x00 -#define INFO_ASTB (1 << PIN_INFO_ASTB) /* 0x08 */ #define INFO_STAT_GCMD (1 << PIN_INFO_STATUS0) /* 0x01 */ #define INFO_STAT_RDATA (1 << PIN_INFO_STATUS1) /* 0x02 */ #define INFO_STAT_WDATA ((1 << PIN_INFO_STATUS0) | (1 << PIN_INFO_STATUS1)) /* 0x03 */ #define INFO_STAT_ERROR ((1 << PIN_INFO_STATUS0) | (1 << PIN_INFO_STATUS1) | (1 << PIN_INFO_STATUS2)) /* 0x07 */ #define INFO_TR (1 << PIN_INFO_TR) /* 0x40 */ -extern void wdc_init_ports(); extern void wdc_wait_for_reset(); extern uint8_t wdc_receive_cmd ( uint8_t *buffer, uint16_t count ); extern void wdc_receive_data ( uint8_t *buffer, uint16_t count ); @@ -75,4 +56,4 @@ extern void wdc_send_data ( uint8_t *buffer, uint16_t count ); extern void wdc_send_error(); extern void wdc_send_errorcode ( uint8_t error ); -#endif /* WDC_IF_PIO_H_ */ \ No newline at end of file +#endif /* WDC_IF_P8000_H_ */ \ No newline at end of file diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c index 19a225f..06e07e2 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c @@ -29,7 +29,7 @@ /* * P8000 WDC Emulator * - * $Id: wdc_main.c,v 1.26 2012/06/10 21:10:44 olivleh1 Exp $ + * $Id: wdc_main.c,v 1.27 2012/06/12 17:34:14 olivleh1 Exp $ * * TODO: - right now, BTT entries are not taken into account */ @@ -41,16 +41,16 @@ #include #include #include -#include "config.h" -#include "main.h" +#include "wdc_config.h" +#include "wdc_main.h" #ifdef DEBUG #include "uart.h" #endif +#include "wdc_avr.h" #include "wdc_ram.h" #include "wdc_par.h" -#include "wdc_if_pio.h" -#include "wdc_if_sdcard.h" - +#include "wdc_if_p8000.h" +#include "wdc_if_disk.h" void atmega_setup ( void ); @@ -94,7 +94,6 @@ main ( void ) blockno = 0; data_counter = WDC_BLOCKLEN; wdc_read_sector ( blockno, data_buffer ); - if ( data_buffer[0] == 'W' && data_buffer[1] == 'D' && data_buffer[2] == 'C' && @@ -175,7 +174,7 @@ main ( void ) case CMD_WR_BLOCK: data_counter = ( cmd_buffer[7] << 8 ) | cmd_buffer[6]; - blockno = wdc_p8kblock2sdblock ( ( ( uint32_t ) cmd_buffer[5] << 24 ) | ( ( uint32_t ) cmd_buffer[4] << 16 ) | ( ( uint16_t ) cmd_buffer[3] << 8 ) | cmd_buffer[2] ); + blockno = wdc_p8kblock2diskblock ( ( ( uint32_t ) cmd_buffer[5] << 24 ) | ( ( uint32_t ) cmd_buffer[4] << 16 ) | ( ( uint16_t ) cmd_buffer[3] << 8 ) | cmd_buffer[2] ); wdc_receive_data ( data_buffer , data_counter ); @@ -193,7 +192,7 @@ main ( void ) case CMD_RD_BLOCK: data_counter = ( cmd_buffer[7] << 8 ) | cmd_buffer[6]; - blockno = wdc_p8kblock2sdblock ( ( ( uint32_t ) cmd_buffer[5] << 24 ) | ( ( uint32_t ) cmd_buffer[4] << 16 ) | ( ( uint16_t ) cmd_buffer[3] << 8 ) | cmd_buffer[2] ); + blockno = wdc_p8kblock2diskblock ( ( ( uint32_t ) cmd_buffer[5] << 24 ) | ( ( uint32_t ) cmd_buffer[4] << 16 ) | ( ( uint16_t ) cmd_buffer[3] << 8 ) | cmd_buffer[2] ); errorcode = 1; if ( data_counter == WDC_BLOCKLEN ) { @@ -298,7 +297,7 @@ main ( void ) data_counter = WDC_BLOCKLEN; memset ( &data_buffer[0], 0x00, data_counter ); - blockno = wdc_sector2sdblock ( cmd_buffer[2] | ( cmd_buffer[3] << 8 ) + blockno = wdc_sector2diskblock ( cmd_buffer[2] | ( cmd_buffer[3] << 8 ) , cmd_buffer[4] , cmd_buffer[5] ); @@ -356,7 +355,7 @@ main ( void ) case CMD_VER_TRACK: data_counter = WDC_BLOCKLEN; - blockno = wdc_sector2sdblock ( cmd_buffer[2] | ( cmd_buffer[3] << 8 ) + blockno = wdc_sector2diskblock ( cmd_buffer[2] | ( cmd_buffer[3] << 8 ) , cmd_buffer[4] , cmd_buffer[5] ); @@ -373,7 +372,7 @@ main ( void ) case CMD_RD_SECTOR: data_counter = ( cmd_buffer[7] << 8 ) | cmd_buffer[6]; - blockno = wdc_sector2sdblock ( cmd_buffer[2] | ( cmd_buffer[3] << 8 ) + blockno = wdc_sector2diskblock ( cmd_buffer[2] | ( cmd_buffer[3] << 8 ) , cmd_buffer[4] , cmd_buffer[5] ); @@ -417,9 +416,8 @@ void atmega_setup ( void ) { set_sleep_mode ( SLEEP_MODE_IDLE ); uart_init(); - wdc_init_ports(); - if ( wdc_init_sdcard() ) { + wdc_init_avr(); + if ( wdc_init_disk() ) { wdc_set_no_disk(); } - } \ No newline at end of file diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.c index 25389f1..13c7bda 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.c @@ -26,11 +26,11 @@ */ /* - * $Id: wdc_par.c,v 1.4 2012/06/09 19:47:31 olivleh1 Exp $ + * $Id: wdc_par.c,v 1.5 2012/06/12 17:34:14 olivleh1 Exp $ */ #include -#include "main.h" +#include "wdc_main.h" #include "wdc_par.h" #include "uart.h"