First step towards PATA support.

Rename files to better fit into the architecture
This commit is contained in:
Oliver Lehmann 2012-06-12 17:34:14 +00:00
parent 0698982318
commit d12779e8d7
18 changed files with 312 additions and 207 deletions

View File

@ -35,12 +35,13 @@ SUBDIRS :=
# Add inputs and outputs from these tool invocations to the build variables # Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \ C_SRCS += \
../main.c \ ../wdc_avr.c \
../mmc.c \ ../wdc_main.c \
../mmc_perf.c \ ../wdc_drv_mmc.c \
../wdc_drv_mmc_perf.c \
../uart.c \ ../uart.c \
../wdc_if_pio.c \ ../wdc_if_p8000.c \
../wdc_if_sdcard.c \ ../wdc_if_disk.c \
../wdc_par.c \ ../wdc_par.c \
../wdc_ram.c ../wdc_ram.c
@ -52,45 +53,49 @@ ASM_SRCS +=
OBJS += \ OBJS += \
main.o \ wdc_avr.o \
mmc.o \ wdc_main.o \
mmc_perf.o \ wdc_drv_mmc.o \
wdc_drv_mmc_perf.o \
uart.o \ uart.o \
wdc_if_pio.o \ wdc_if_p8000.o \
wdc_if_sdcard.o \ wdc_if_disk.o \
wdc_par.o \ wdc_par.o \
wdc_ram.o wdc_ram.o
OBJS_AS_ARGS += \ OBJS_AS_ARGS += \
main.o \ wdc_avr.o \
mmc.o \ wdc_main.o \
mmc_perf.o \ wdc_drv_mmc.o \
wdc_drv_mmc_perf.o \
uart.o \ uart.o \
wdc_if_pio.o \ wdc_if_p8000.o \
wdc_if_sdcard.o \ wdc_if_disk.o \
wdc_par.o \ wdc_par.o \
wdc_ram.o wdc_ram.o
C_DEPS += \ C_DEPS += \
main.d \ wdc_avr.d \
mmc.d \ wdc_main.d \
mmc_perf.d \ wdc_drv_mmc.d \
wdc_drv_mmc_perf.d \
uart.d \ uart.d \
wdc_if_pio.d \ wdc_if_p8000.d \
wdc_if_sdcard.d \ wdc_if_disk.d \
wdc_par.d \ wdc_par.d \
wdc_ram.d wdc_ram.d
C_DEPS_AS_ARGS += \ C_DEPS_AS_ARGS += \
main.d \ wdc_avr.d \
mmc.d \ wdc_main.d \
mmc_perf.d \ wdc_drv_mmc.d \
wdc_drv_mmc_perf.d \
uart.d \ uart.d \
wdc_if_pio.d \ wdc_if_p8000.d \
wdc_if_sdcard.d \ wdc_if_disk.d \
wdc_par.d \ wdc_par.d \
wdc_ram.d wdc_ram.d
@ -121,6 +126,8 @@ OUTPUT_FILE_DEP:= ./makedep.mk
./%.o: .././%.c ./%.o: .././%.c
@echo Building file: $< @echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : (AVR_8_bit_GNU_Toolchain_3.4.0_663) 4.6.2 @echo Invoking: AVR/GNU C Compiler : (AVR_8_bit_GNU_Toolchain_3.4.0_663) 4.6.2

View File

@ -2,17 +2,19 @@
# Automatically-generated file. Do not edit or delete the file # 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 uart.c
wdc_if_pio.c wdc_if_p8000.c
wdc_if_sdcard.c wdc_if_disk.c
wdc_par.c wdc_par.c

View File

@ -174,7 +174,7 @@ T 67100 33100 9 8 1 0 0 0 1
T 68500 33100 9 8 1 0 0 0 1 T 68500 33100 9 8 1 0 0 0 1
1 1
T 71000 33400 9 7 1 0 0 0 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 T 71000 33100 9 8 1 0 0 0 1
Oliver Lehmann <lehmann@ans-netz.de> Oliver Lehmann <lehmann@ans-netz.de>
N 50600 59400 51200 59400 4 N 50600 59400 51200 59400 4
@ -573,7 +573,7 @@ T 35200 56500 5 10 1 1 0 6 1
pinlabel=\_TE\_ pinlabel=\_TE\_
} }
N 31900 56400 35200 56400 4 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 T 35600 58600 5 10 1 1 0 0 1
pinlabel=\_TR\_ pinlabel=\_TR\_
@ -686,35 +686,13 @@ T 42000 52500 5 10 1 1 0 0 1
pinlabel=\_RDY\_ pinlabel=\_RDY\_
} }
N 31900 57000 35200 57000 4 N 31900 57000 35200 57000 4
N 39300 60600 40100 60600 4 N 31900 60600 36300 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
{ {
T 35600 60700 5 10 1 1 0 0 1 T 35600 60700 5 10 1 1 0 0 1
pinlabel=\_ASTB\_ 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 41600 56400 4
N 38800 56400 38800 58600 4 N 38800 56400 38800 60400 4
N 38800 59500 38800 60000 4
C 35200 57000 1 270 0 busripper-1.sym C 35200 57000 1 270 0 busripper-1.sym
{ {
T 35200 57400 5 8 0 0 0 0 1 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\_ pinlabel=\_RST\_
} }
N 47300 51800 42000 51800 4 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 N 41100 46600 47900 46600 4
T 41200 46800 9 10 1 0 0 0 1 T 41200 46800 9 10 1 0 0 0 1
/RDWR TO ATA /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 T 48500 46800 5 10 0 0 0 0 1
device=7432 device=7432
T 48200 46800 5 10 1 1 0 0 1 T 48200 46800 5 10 1 1 0 0 1
refdes=D6 refdes=D7
T 48500 48200 5 10 0 0 0 0 1 T 48500 48200 5 10 0 0 0 0 1
footprint=DIP14 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 T 51300 45900 5 10 0 0 0 0 1
device=7404 device=7404
T 51000 45900 5 10 1 1 0 0 1 T 51000 45900 5 10 1 1 0 0 1
refdes=D5 refdes=D8
T 51300 48500 5 10 0 0 0 0 1 T 51300 48500 5 10 0 0 0 0 1
footprint=DIP14 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 T 48500 45400 5 10 0 0 0 0 1
device=7432 device=7432
T 48200 45400 5 10 1 1 0 0 1 T 48200 45400 5 10 1 1 0 0 1
refdes=D6 refdes=D7
T 48500 46800 5 10 0 0 0 0 1 T 48500 46800 5 10 0 0 0 0 1
footprint=DIP14 footprint=DIP14
T 47900 44500 5 10 0 1 0 6 1 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 T 48500 42600 5 10 0 0 180 6 1
device=7432 device=7432
T 48200 42600 5 10 1 1 180 6 1 T 48200 42600 5 10 1 1 180 6 1
refdes=D6 refdes=D7
T 48500 41200 5 10 0 0 180 6 1 T 48500 41200 5 10 0 0 180 6 1
footprint=DIP14 footprint=DIP14
T 47900 43500 5 10 0 0 180 6 1 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 T 48500 41200 5 10 0 0 180 6 1
device=7432 device=7432
T 48200 41200 5 10 1 1 180 6 1 T 48200 41200 5 10 1 1 180 6 1
refdes=D6 refdes=D7
T 48500 39800 5 10 0 0 180 6 1 T 48500 39800 5 10 0 0 180 6 1
footprint=DIP14 footprint=DIP14
T 47900 42100 5 10 0 1 180 0 1 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 T 51300 42900 5 10 0 0 0 0 1
device=7404 device=7404
T 51000 42900 5 10 1 1 0 0 1 T 51000 42900 5 10 1 1 0 0 1
refdes=D5 refdes=D8
T 51300 45500 5 10 0 0 0 0 1 T 51300 45500 5 10 0 0 0 0 1
footprint=DIP14 footprint=DIP14
T 50700 42000 5 10 0 0 0 0 1 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 T 41600 56200 5 10 1 1 0 6 1
pinlabel=TR pinlabel=TR
} }
N 36900 56100 41600 56100 4 N 38500 56100 41600 56100 4
C 41600 49000 1 270 0 busripper-1.sym C 41600 49000 1 270 0 busripper-1.sym
{ {
T 41600 49400 5 8 0 0 0 0 1 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 T 39600 50100 5 10 0 0 0 0 1
device=7404 device=7404
T 39300 50100 5 10 1 1 0 0 1 T 39300 50100 5 10 1 1 0 0 1
refdes=D5 refdes=D8
T 39600 52700 5 10 0 0 0 0 1 T 39600 52700 5 10 0 0 0 0 1
footprint=DIP14 footprint=DIP14
T 39000 49200 5 10 0 0 0 0 1 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 value=10k
} }
N 52300 45500 52300 41500 4 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

View File

@ -72,22 +72,28 @@
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="config.h"> <Compile Include="wdc_config.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="main.c"> <Compile Include="wdc_avr.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="main.h"> <Compile Include="wdc_avr.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="mmc.c"> <Compile Include="wdc_main.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="mmc.h"> <Compile Include="wdc_main.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="mmc_perf.c"> <Compile Include="wdc_drv_mmc.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="wdc_drv_mmc.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="wdc_drv_mmc_perf.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="uart.c"> <Compile Include="uart.c">
@ -96,16 +102,16 @@
<Compile Include="uart.h"> <Compile Include="uart.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="wdc_if_pio.c"> <Compile Include="wdc_if_p8000.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="wdc_if_pio.h"> <Compile Include="wdc_if_p8000.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="wdc_if_sdcard.c"> <Compile Include="wdc_if_disk.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="wdc_if_sdcard.h"> <Compile Include="wdc_if_disk.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="wdc_par.c"> <Compile Include="wdc_par.c">

View File

@ -14,7 +14,7 @@
#include <avr/sleep.h> #include <avr/sleep.h>
#include "uart.h" #include "uart.h"
#include "config.h" #include "wdc_config.h"
/* some mcus have multiple uarts */ /* some mcus have multiple uarts */
#ifdef UDR0 #ifdef UDR0

View File

@ -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 <avr/io.h>
#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();
}

View File

@ -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<<PIN_MMC_CS);
#define mmc_enable() PORT_MMC&=~(1<<PIN_MMC_CS);
extern void wdc_init_avr();
#endif /* WDC_AVR_H_ */

View File

@ -26,7 +26,7 @@
*/ */
/* /*
* $Id: wdc_config.h,v 1.13 2012/06/10 21:03:23 olivleh1 Exp $ * $Id: wdc_config.h,v 1.14 2012/06/12 17:34:14 olivleh1 Exp $
*/ */
@ -47,15 +47,21 @@
#define PIN_INFO PINC #define PIN_INFO PINC
#define DDR_INFO DDRC #define DDR_INFO DDRC
#define PORT_ADRDEC PORTD
#define PIN_ADRDEC PIND
#define DDR_ADRDEC DDRD
#define PIN_INFO_STATUS0 PINC0 #define PIN_INFO_STATUS0 PINC0
#define PIN_INFO_STATUS1 PINC1 #define PIN_INFO_STATUS1 PINC1
#define PIN_INFO_STATUS2 PINC2 #define PIN_INFO_STATUS2 PINC2
#define PIN_INFO_ASTB PINC3
#define PIN_INFO_TE PINC4 #define PIN_INFO_TE PINC4
#define PIN_INFO_WDARDY PINC5 #define PIN_INFO_WDARDY PINC5
#define PIN_INFO_TR PINC6 #define PIN_INFO_TR PINC6
#define PIN_INFO_RST PINC7 #define PIN_INFO_RST PINC7
#define PIN_ADRDEC_ADDR0 PIND5
#define PIN_ADRDEC_ADDR1 PIND6
#define PIN_ADRDEC_ADDR2 PIND7
/* /*
* SD-Card Interface * SD-Card Interface
*/ */
@ -81,6 +87,6 @@
#define MEASURE_SDCARD_TIME 1 #define MEASURE_SDCARD_TIME 1
#undef MEASURE_SDCARD_TIME #undef MEASURE_SDCARD_TIME
#define DEBUG 3 #define DEBUG 1
#endif /* CONFIG_H_ */ #endif /* CONFIG_H_ */

View File

@ -26,12 +26,13 @@
*/ */
/* /*
* $Id: wdc_drv_mmc.c,v 1.16 2012/06/09 19:47:31 olivleh1 Exp $ * $Id: wdc_drv_mmc.c,v 1.17 2012/06/12 17:34:14 olivleh1 Exp $
*/ */
#include <avr/io.h> #include <avr/io.h>
#include "config.h" #include "wdc_config.h"
#include "mmc.h" #include "wdc_avr.h"
#include "wdc_drv_mmc.h"
#include "uart.h" #include "uart.h"
#define wait_till_send_done() while ( ! ( SPSR & ( 1 << SPIF ) ) ) #define wait_till_send_done() while ( ! ( SPSR & ( 1 << SPIF ) ) )
@ -39,8 +40,6 @@
#define send_dummy_byte() SPDR = 0xFF; wait_till_send_done() #define send_dummy_byte() SPDR = 0xFF; wait_till_send_done()
#define recv_byte() SPDR #define recv_byte() SPDR
#define xmit_byte(x) SPDR = x #define xmit_byte(x) SPDR = x
#define mmc_disable() PORT_MMC|= (1<<PIN_MMC_CS);
#define mmc_enable() PORT_MMC=~(1<<PIN_MMC_CS);
#define nop() __asm__ __volatile__ ("nop" ::) #define nop() __asm__ __volatile__ ("nop" ::)
#define CMD0 (0x40 + 0) #define CMD0 (0x40 + 0)
@ -182,12 +181,6 @@ uint8_t mmc_init ()
uint16_t t16 = 0; uint16_t t16 = 0;
uint8_t a; uint8_t a;
DDR_MMC &= ~ ( 1 << PIN_MMC_MISO );
DDR_MMC |= ( 1 << PIN_MMC_SCK );
DDR_MMC |= ( 1 << PIN_MMC_MOSI );
DDR_MMC |= ( 1 << PIN_MMC_CS );
for ( a = 0; a < 200; a++ ) { for ( a = 0; a < 200; a++ ) {
nop(); nop();
}; };

View File

@ -26,11 +26,11 @@
*/ */
/* /*
* $Id: wdc_drv_mmc.h,v 1.7 2012/06/07 18:01:02 olivleh1 Exp $ * $Id: wdc_drv_mmc.h,v 1.8 2012/06/12 17:34:14 olivleh1 Exp $
*/ */
#ifndef MMC_H_ #ifndef WDC_DRV_MMC_H_
#define MMC_H_ #define WDC_DRV_MMC_H_
extern uint8_t mmc_init (); extern uint8_t mmc_init ();
@ -42,6 +42,6 @@ extern uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t nu
#define MMC_BLOCKLEN 512 #define MMC_BLOCKLEN 512
#endif /* MMC_H_ */ #endif /* WDC_DRV_MMC_H_ */

View File

@ -26,27 +26,27 @@
*/ */
/* /*
* $Id: wdc_if_disk.c,v 1.11 2012/06/09 19:47:31 olivleh1 Exp $ * $Id: wdc_if_disk.c,v 1.12 2012/06/12 17:34:14 olivleh1 Exp $
*/ */
#include <stdint.h> #include <stdint.h>
#include "mmc.h" #include "wdc_drv_mmc.h"
#include "uart.h" #include "uart.h"
#include "wdc_par.h" #include "wdc_par.h"
uint8_t wdc_init_sdcard() uint8_t wdc_init_disk()
{ {
return mmc_init(); 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() ) return ( ( req_cylinder * wdc_get_hdd_heads() * wdc_get_hdd_sectors() )
+ ( req_head * wdc_get_hdd_sectors() ) + ( req_head * wdc_get_hdd_sectors() )
+ ( req_sector - 1 ) ); + ( req_sector - 1 ) );
} }
uint32_t wdc_p8kblock2sdblock ( uint32_t blockno ) uint32_t wdc_p8kblock2diskblock ( uint32_t blockno )
{ {
return ( blockno return ( blockno
+ ( wdc_get_hdd_heads() * wdc_get_hdd_sectors() ) ); + ( wdc_get_hdd_heads() * wdc_get_hdd_sectors() ) );

View File

@ -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_ #ifndef WDC_IF_DISK_H_
#define WDC_IF_SDCARD_H_ #define WDC_IF_DISK_H_
extern uint8_t wdc_init_sdcard(); extern uint8_t wdc_init_disk();
extern uint32_t wdc_sector2sdblock ( uint16_t req_cylinder, uint8_t req_head, uint8_t req_sector ); extern uint32_t wdc_sector2diskblock ( uint16_t req_cylinder, uint8_t req_head, uint8_t req_sector );
extern uint32_t wdc_p8kblock2sdblock ( uint32_t blockno ); extern uint32_t wdc_p8kblock2diskblock ( uint32_t blockno );
extern uint8_t wdc_write_sector ( uint32_t addr, uint8_t *sector ); 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_sector ( uint32_t addr, uint8_t *sector );
extern uint8_t wdc_read_multiblock ( uint32_t addr, uint8_t *sector, uint8_t numblocks ); 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 #define WDC_BLOCKLEN 512
#endif /* WDC_IF_SDCARD_H_ */ #endif /* WDC_IF_DISK_H_ */

View File

@ -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 <avr/io.h> #include <avr/io.h>
@ -36,8 +36,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <avr/sleep.h> #include <avr/sleep.h>
#include "config.h" #include "wdc_config.h"
#include "wdc_if_sdcard.h" #include "wdc_if_disk.h"
#include "wdc_ram.h" #include "wdc_ram.h"
#include "uart.h" #include "uart.h"

View File

@ -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 "wdc_config.h"
#include <avr/pgmspace.h> #include <avr/io.h>
#include <util/delay.h> #include <util/delay.h>
#include "wdc_if_pio.h" #include "wdc_avr.h"
#include "wdc_if_p8000.h"
#include "wdc_par.h" #include "wdc_par.h"
#include "uart.h"
#define nop() __asm__ __volatile__ ("nop" ::) #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() void wdc_wait_for_reset()
{ {
while ( !isset_info_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; return 0;
while ( !isset_info_wdardy() ); while ( !isset_info_wdardy() );
do { do {
enable_p8000_transeiver(); /* this also generates /ASTB in the moment /WDARDY gets low with a 7403 */
while ( isset_info_wdardy() ); while ( isset_info_wdardy() );
PORTD |= ( ( 1 << PIND5 ) );
nop();
nop();
buffer[datacnt] = ( uint8_t ) port_data_get(); buffer[datacnt] = ( uint8_t ) port_data_get();
PORTD &= ~ ( ( 1 << PIND5 ) ); disable_p8000_transeiver(); /* this additionally brings /ASTB to high */
while ( !isset_info_wdardy() ); while ( !isset_info_wdardy() );
datacnt++; datacnt++;
} while ( datacnt < count ); } 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(); configure_port_data_write();
while ( !isset_info_wdardy() ); while ( !isset_info_wdardy() );
do { do {
enable_p8000_transeiver(); /* this also generates /ASTB in the moment /WDARDY gets low with a 7403 */
while ( isset_info_wdardy() ); while ( isset_info_wdardy() );
PORTD |= ( ( 1 << PIND5 ) );
nop();
nop();
port_data_set ( buffer[datacnt] ); port_data_set ( buffer[datacnt] );
PORTD &= ~ ( ( 1 << PIND5 ) ); disable_p8000_transeiver(); /* this additionally brings /ASTB to high */
while ( !isset_info_wdardy() ); while ( !isset_info_wdardy() );
datacnt++; datacnt++;
} while ( datacnt < count ); } while ( datacnt < count );
while ( isset_info_wdardy() ); while ( isset_info_wdardy() );
PORTD |= ( ( 1 << PIND5 ) ); enable_p8000_transeiver();
nop(); nop();
PORTD &= ~ ( ( 1 << PIND5 ) ); disable_p8000_transeiver();
configure_port_data_read(); configure_port_data_read();
while ( !isset_info_wdardy() ); while ( !isset_info_wdardy() );
port_info_set ( INFO_CLEAR ); port_info_set ( INFO_CLEAR );
} }
uint8_t wdc_receive_cmd ( uint8_t *buffer, uint16_t count ) uint8_t wdc_receive_cmd ( uint8_t *buffer, uint16_t count )

View File

@ -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_ #ifndef WDC_IF_P8000_H_
#define WDC_IF_PIO_H_ #define WDC_IF_P8000_H_
#define DELAY_PIO_US 550 #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 */ /* input pin handling */
#define isset_info_reset() ((PIN_INFO) & (1 << PIN_INFO_RST)) #define isset_info_reset() ((PIN_INFO) & (1 << PIN_INFO_RST))
#define isset_info_te() ((PIN_INFO) & (1 << PIN_INFO_TE)) #define isset_info_te() ((PIN_INFO) & (1 << PIN_INFO_TE))
@ -60,14 +43,12 @@
#define DATA_CLEAR 0x00 #define DATA_CLEAR 0x00
#define INFO_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_GCMD (1 << PIN_INFO_STATUS0) /* 0x01 */
#define INFO_STAT_RDATA (1 << PIN_INFO_STATUS1) /* 0x02 */ #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_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_STAT_ERROR ((1 << PIN_INFO_STATUS0) | (1 << PIN_INFO_STATUS1) | (1 << PIN_INFO_STATUS2)) /* 0x07 */
#define INFO_TR (1 << PIN_INFO_TR) /* 0x40 */ #define INFO_TR (1 << PIN_INFO_TR) /* 0x40 */
extern void wdc_init_ports();
extern void wdc_wait_for_reset(); extern void wdc_wait_for_reset();
extern uint8_t wdc_receive_cmd ( uint8_t *buffer, uint16_t count ); extern uint8_t wdc_receive_cmd ( uint8_t *buffer, uint16_t count );
extern void wdc_receive_data ( 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_error();
extern void wdc_send_errorcode ( uint8_t error ); extern void wdc_send_errorcode ( uint8_t error );
#endif /* WDC_IF_PIO_H_ */ #endif /* WDC_IF_P8000_H_ */

View File

@ -29,7 +29,7 @@
/* /*
* P8000 WDC Emulator * 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 * TODO: - right now, BTT entries are not taken into account
*/ */
@ -41,16 +41,16 @@
#include <stdlib.h> #include <stdlib.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <avr/sleep.h> #include <avr/sleep.h>
#include "config.h" #include "wdc_config.h"
#include "main.h" #include "wdc_main.h"
#ifdef DEBUG #ifdef DEBUG
#include "uart.h" #include "uart.h"
#endif #endif
#include "wdc_avr.h"
#include "wdc_ram.h" #include "wdc_ram.h"
#include "wdc_par.h" #include "wdc_par.h"
#include "wdc_if_pio.h" #include "wdc_if_p8000.h"
#include "wdc_if_sdcard.h" #include "wdc_if_disk.h"
void atmega_setup ( void ); void atmega_setup ( void );
@ -94,7 +94,6 @@ main ( void )
blockno = 0; blockno = 0;
data_counter = WDC_BLOCKLEN; data_counter = WDC_BLOCKLEN;
wdc_read_sector ( blockno, data_buffer ); wdc_read_sector ( blockno, data_buffer );
if ( data_buffer[0] == 'W' && if ( data_buffer[0] == 'W' &&
data_buffer[1] == 'D' && data_buffer[1] == 'D' &&
data_buffer[2] == 'C' && data_buffer[2] == 'C' &&
@ -175,7 +174,7 @@ main ( void )
case CMD_WR_BLOCK: case CMD_WR_BLOCK:
data_counter = ( cmd_buffer[7] << 8 ) | cmd_buffer[6]; 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 wdc_receive_data ( data_buffer
, data_counter , data_counter
); );
@ -193,7 +192,7 @@ main ( void )
case CMD_RD_BLOCK: case CMD_RD_BLOCK:
data_counter = ( cmd_buffer[7] << 8 ) | cmd_buffer[6]; 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; errorcode = 1;
if ( data_counter == WDC_BLOCKLEN ) { if ( data_counter == WDC_BLOCKLEN ) {
@ -298,7 +297,7 @@ main ( void )
data_counter = WDC_BLOCKLEN; data_counter = WDC_BLOCKLEN;
memset ( &data_buffer[0], 0x00, data_counter ); 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[4]
, cmd_buffer[5] , cmd_buffer[5]
); );
@ -356,7 +355,7 @@ main ( void )
case CMD_VER_TRACK: case CMD_VER_TRACK:
data_counter = WDC_BLOCKLEN; 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[4]
, cmd_buffer[5] , cmd_buffer[5]
); );
@ -373,7 +372,7 @@ main ( void )
case CMD_RD_SECTOR: case CMD_RD_SECTOR:
data_counter = ( cmd_buffer[7] << 8 ) | cmd_buffer[6]; 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[4]
, cmd_buffer[5] , cmd_buffer[5]
); );
@ -417,9 +416,8 @@ void atmega_setup ( void )
{ {
set_sleep_mode ( SLEEP_MODE_IDLE ); set_sleep_mode ( SLEEP_MODE_IDLE );
uart_init(); uart_init();
wdc_init_ports(); wdc_init_avr();
if ( wdc_init_sdcard() ) { if ( wdc_init_disk() ) {
wdc_set_no_disk(); wdc_set_no_disk();
} }
} }

View File

@ -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 <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "main.h" #include "wdc_main.h"
#include "wdc_par.h" #include "wdc_par.h"
#include "uart.h" #include "uart.h"