From 39eed1c0453109cdf28bf37f11bf41c250045a99 Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Thu, 14 Jun 2012 20:24:24 +0000 Subject: [PATCH] bit more work on PATA support --- .../P8000_WDC_Emulator/wdc_avr.c | 19 +++++++++- .../P8000_WDC_Emulator/wdc_avr.h | 34 ++++++++++++++++-- .../P8000_WDC_Emulator/wdc_config.h | 29 ++++++++++++++- .../P8000_WDC_Emulator/wdc_drv_pata.c | 36 +++++++++++++++++-- .../P8000_WDC_Emulator/wdc_drv_pata.h | 35 +++++++++++++++--- 5 files changed, 142 insertions(+), 11 deletions(-) diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c index 18d08ef..4669099 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_avr.c,v 1.2 2012/06/13 20:17:45 olivleh1 Exp $ + * $Id: wdc_avr.c,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $ */ @@ -62,6 +62,23 @@ void wdc_init_avr() configure_pin_sck(); configure_pin_mosi(); configure_pin_mmc_cs(); + + /* configure the ATA interface */ + configure_ata_wr(); + configure_ata_rd(); + configure_ata_cs0(); + configure_ata_cs1(); + configure_ata_da0(); + configure_ata_da1(); + configure_ata_da2(); + + ata_wr_disable(); + ata_rd_disable(); + ata_cs0_disable(); + ata_cs1_disable(); + ata_da0_disable(); + ata_da1_disable(); + ata_da2_disable(); } void wdc_get_sysconf() diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h index 38dec67..7f7aa8d 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_avr.h,v 1.2 2012/06/13 20:17:45 olivleh1 Exp $ + * $Id: wdc_avr.h,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $ */ @@ -57,6 +57,10 @@ #define init_addressdecoder() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) ) #define enable_p8000com() PORT_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR0 ) #define disable_p8000com() PORT_ADRDEC &= ~( 1 << PIN_ADRDEC_ADDR0 ) +#define enable_rdwrtoata() PORT_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR1 ) +#define disable_rdwrtoata() PORT_ADRDEC &= ~( 1 << PIN_ADRDEC_ADDR1 ) +#define enable_atalatch() PORT_ADRDEC |= ( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 )) +#define disable_atalatch() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 )) #define enable_sysconf() PORT_ADRDEC |= ( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) ) #define disable_sysconf() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) ) @@ -66,8 +70,8 @@ #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 "wdc_config.h" +#include +#include +#include "wdc_avr.h" +#include "uart.h" + +void pata_set_highbyte ( uint8_t byte ) +{ + port_data_set ( byte ); + enable_atalatch(); + nop(); + nop(); + disable_atalatch(); +} + +void pata_set_lowbyte ( uint8_t byte ) +{ + port_data_set ( byte ); +} + +void pata_send_data() +{ + enable_rdwrtoata(); + _delay_us(10); +// disable_rdwrtoata(); +} uint8_t pata_init () { +uart_putc('1'); + /* test write */ + configure_port_data_write(); + ata_wr_enable(); + pata_set_highbyte ( 0xff ); + pata_set_lowbyte ( 0x00 ); + pata_send_data(); +// ata_wr_disable(); return 1; } diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_pata.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_pata.h index 18b5b3a..deee335 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_pata.h +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_pata.h @@ -1,14 +1,41 @@ -/* - * wdc_drv_pata.h +/*- + * 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. * - * Created: 12.06.2012 21:57:08 - * Author: olivleh1 */ +/* + * $Id: wdc_drv_pata.h,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $ + */ #ifndef WDC_DRV_PATA_H_ #define WDC_DRV_PATA_H_ +extern void pata_set_highbyte(uint8_t byte); +extern void pata_set_lowbyte(uint8_t byte); +extern void pata_send_data(); + extern uint8_t pata_init (); extern uint8_t pata_read_block ( uint32_t addr, uint8_t *buffer );