diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/Makefile b/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/Makefile
index ad3c0c9..e896b35 100755
--- a/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/Makefile
+++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/Debug/Makefile
@@ -138,7 +138,7 @@ 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
- $(QUOTE)C:\Program Files (x86)\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.0.65\AVRToolchain\bin\avr-gcc.exe$(QUOTE) -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fpack-struct -fshort-enums -c -std=gnu99 -save-temps -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -mmcu=atmega1284p -o"$@" "$<"
+ $(QUOTE)C:\Program Files (x86)\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.0.65\AVRToolchain\bin\avr-gcc.exe$(QUOTE) -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fpack-struct -fshort-enums -c -save-temps -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -mmcu=atmega1284p -o"$@" "$<"
@echo Finished building: $<
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 31527f4..db8d216 100644
--- a/P8000_WDC_Emulator/P8000_WDC_Emulator/P8000_WDC_Emulator.cproj
+++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/P8000_WDC_Emulator.cproj
@@ -54,6 +54,7 @@
True
True
True
+
True
diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_config.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_config.h
index aabab43..b0a0c2d 100644
--- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_config.h
+++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_config.h
@@ -26,7 +26,7 @@
*/
/*
- * $Id: wdc_config.h,v 1.17 2012/06/16 19:34:39 olivleh1 Exp $
+ * $Id: wdc_config.h,v 1.18 2012/06/16 23:41:42 olivleh1 Exp $
*/
@@ -121,7 +121,7 @@
#define MMC_MULTIBLOCK 1
#define MEASURE_DISK_PERFORMANCE 1
-#undef MEASURE_DISK_PERFORMANCE
+//#undef MEASURE_DISK_PERFORMANCE
#define DEBUG 1
diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_mmc.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_mmc.c
index b62d6c0..4eb7e53 100644
--- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_mmc.c
+++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_mmc.c
@@ -26,7 +26,7 @@
*/
/*
- * $Id: wdc_drv_mmc.c,v 1.18 2012/06/13 20:17:45 olivleh1 Exp $
+ * $Id: wdc_drv_mmc.c,v 1.19 2012/06/16 23:41:42 olivleh1 Exp $
*/
#include
@@ -270,6 +270,7 @@ uint8_t mmc_cmd ( uint8_t *cmd )
uint8_t tmp = 0x80;
uint8_t i = 10;
uint8_t cmd0 = cmd[0];
+ uint8_t a;
#ifdef SPI_CRC
/* Calculate CRC and framing bits */
cmd[0] = ( cmd[0] | ( 1 << 6 ) ) & 0x7F;
@@ -277,7 +278,7 @@ uint8_t mmc_cmd ( uint8_t *cmd )
#endif
/* send command */
- for ( uint8_t a = 0; a < 0x06; a++ ) {
+ for ( a = 0; a < 0x06; a++ ) {
xmit_byte ( *cmd++ );
wait_till_send_done();
}
diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_pata.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_pata.c
index 3d9f1b9..69b5ebf 100644
--- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_pata.c
+++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_drv_pata.c
@@ -26,7 +26,7 @@
*/
/*
- * $Id: wdc_drv_pata.c,v 1.7 2012/06/16 19:34:39 olivleh1 Exp $
+ * $Id: wdc_drv_pata.c,v 1.8 2012/06/16 23:41:42 olivleh1 Exp $
*/
#include "wdc_config.h"
@@ -51,22 +51,24 @@ void pata_read_bytes ( uint8_t *buffer, uint16_t bytes );
/*
- * +----- CS0
- * |+---- CS1
- * ||+--- DA0
- * |||+-- DA1
- * ||||+- DA2
- * ||||| */
-#define PATA_R_STATUS_REGISTER 0x0F /* 0b01111 */
-#define PATA_W_COMMAND_REGISTER 0x0F /* 0b01111 */
-#define PATA_W_DEVICE_CONTROL_REGISTER 0x0B /* 0b01011 */
+ * +----- CS0
+ * |+---- CS1
+ * ||+--- DA0
+ * |||+-- DA1
+ * ||||+- DA2
+ * ||||| */
+#define PATA_W_DEVICE_CONTROL_REGISTER 0x0B /* 0b10011 */
+#define PATA_R_STATUS_REGISTER 0x0F /* 0b01111 */
+#define PATA_R_ALTERNATE_STATUS_REGISTER 0x0B /* 0b10011 */
+#define PATA_W_FEATURE_REGISTER 0x0C /* 0b01100 */
+#define PATA_W_COMMAND_REGISTER 0x0F /* 0b01111 */
-#define PATA_RW_DATA_REGISTER 0x08 /* 0b01000 */
-#define PATA_RW_SECTOR_COUNT_REGISTER 0b00001010
-#define PATA_RW_SECTOR_NUMBER_REGISTER 0b00001110
-#define PATA_RW_CYLINDER_LOW_REGISTER 0b00001001
-#define PATA_RW_CYLINDER_HIGH_REGISTER 0b00001101
-#define PATA_RW_DEVICE_HEAD_REGISTER 0b00001011
+#define PATA_RW_DATA_REGISTER 0x08 /* 0b01000 */
+#define PATA_RW_SECTOR_COUNT_REGISTER 0x0A /* 0b01010 */
+#define PATA_RW_SECTOR_NUMBER_REGISTER 0x0E /* 0b01110 */
+#define PATA_RW_CYLINDER_LOW_REGISTER 0x09 /* 0b01001 */
+#define PATA_RW_CYLINDER_HIGH_REGISTER 0x0D /* 0b01101 */
+#define PATA_RW_DEVICE_HEAD_REGISTER 0x0B /* 0b01011 */
#define ata_ctl_high() ata_cs0_disable();ata_cs1_disable();ata_da0_disable();ata_da1_disable();ata_da2_disable();
@@ -112,6 +114,7 @@ void pata_set_lowbyte ( uint8_t byte )
enable_rdwrtoata();
nop();
nop();
+ nop();
disable_rdwrtoata();
}
@@ -132,6 +135,7 @@ uint8_t pata_get_lowbyte ()
enable_rdwrtoata();
nop();
nop();
+ nop();
byte = port_data_get();
disable_rdwrtoata();
@@ -145,6 +149,7 @@ uint8_t pata_get_highbyte ()
enable_atalatch();
nop();
nop();
+ nop();
byte = port_data_get();
disable_atalatch();
@@ -216,7 +221,7 @@ void pata_write_bytes ( uint8_t *buffer, uint16_t bytes )
set_io_register ( PATA_RW_DATA_REGISTER );
ata_wr_enable();
-
+
for ( i = 0; i < PATA_BLOCKLEN / 2; i++ ) {
pata_set_highbyte ( buffer[a + 1] );
pata_set_lowbyte ( buffer[a] );
@@ -268,7 +273,7 @@ void ata_identify()
}
uart_putc ( '\n' );
uart_puts_p ( PSTR ( "Model number: " ) );
- for ( uint8_t i = 27; i <= 46; i++ ) {
+ for ( i = 27; i <= 46; i++ ) {
uart_putc ( word[i] >> 8 );
uart_putc ( word[i] & 0x00FF );
}
@@ -296,9 +301,12 @@ void ata_identify()
* Public functions
*/
-uint8_t data2_buffer[4096];
+uint8_t data2_buffer[512];
+//uint8_t data3_buffer[512];
+
uint8_t pata_init ()
{
+ uint16_t a;
// is needed for some disks (for example Maxtor 6L080J4)
_delay_ms ( 200 );
@@ -307,17 +315,28 @@ uint8_t pata_init ()
while ( ( !pata_rdy() ) & pata_bsy() );
/*set drive 0 to LBA mode*/
- write_io_register ( PATA_W_DEVICE_CONTROL_REGISTER, ATA_LBA_DRIVE_0 );
+ write_io_register ( PATA_RW_DEVICE_HEAD_REGISTER, ATA_LBA_DRIVE_0 );
while ( ( !pata_rdy() ) & pata_bsy() );
+/*
+ write_io_register ( PATA_W_FEATURE_REGISTER, 3 );
+ write_io_register ( PATA_RW_SECTOR_COUNT_REGISTER, 1 );
+ write_io_register ( PATA_W_COMMAND_REGISTER, CMD_SET_FEATURES );
+ while ( pata_bsy() );
+*/
+
/*recalibrate*/
write_io_register ( PATA_W_COMMAND_REGISTER, CMD_RECALIBRATE );
while ( pata_bsy() );
uart_puts_p ( PSTR ( "disk is now ready\n" ) );
- ata_identify();
+// ata_identify();
+ pata_read_block(0,data2_buffer);
+ for ( a = 0 ; a < 512 ; a++ )
+ uart_putc_hex ( data2_buffer[a] );
+while(1);
return 0;
}
@@ -333,6 +352,7 @@ uint8_t pata_write_block ( uint32_t addr, uint8_t *buffer )
uint8_t pata_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks )
{
+
write_io_register ( PATA_RW_SECTOR_COUNT_REGISTER, numblocks );
write_io_register ( PATA_RW_SECTOR_NUMBER_REGISTER, ( uint8_t ) addr );
@@ -344,6 +364,9 @@ uint8_t pata_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
pata_read_bytes ( buffer, numblocks * PATA_BLOCKLEN );
+ read_io_register ( PATA_R_ALTERNATE_STATUS_REGISTER );
+ read_io_register ( PATA_R_STATUS_REGISTER );
+
return 0;
}
@@ -360,5 +383,11 @@ uint8_t pata_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblock
pata_write_bytes ( buffer, numblocks * PATA_BLOCKLEN );
+ /* wait until drive completed write */
+ while(pata_bsy());
+
+ read_io_register ( PATA_R_ALTERNATE_STATUS_REGISTER );
+ read_io_register ( PATA_R_STATUS_REGISTER );
+
return 0;
}
\ 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 2aa7c8a..90fbe69 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.6 2012/06/16 19:34:39 olivleh1 Exp $
+ * $Id: wdc_if_disk_perf.c,v 1.7 2012/06/16 23:41:42 olivleh1 Exp $
*/
#include
@@ -109,7 +109,7 @@ void test_write512(uint8_t numblocks, uint8_t nr_of_tests)
uart_puts_p ( PSTR ( "Test Write 5000 512B-Blocks with Singleblock-Write (512B Blocksize):" ) );
uart_putc ( '\n' );
- memset ( &data_buffer[0], 0xCC, WDC_BLOCKLEN * numblocks );
+ memset ( &data_buffer[0], 0x11, WDC_BLOCKLEN * numblocks );
for ( i8 = 0; i8 < nr_of_tests; i8++ ) {
blockno = BLOCKNO;
for ( starttime = overflow; blockno < ( BLOCKNO + 5000 ); blockno++ ) {
@@ -131,6 +131,7 @@ void test_read512(uint8_t numblocks, uint8_t nr_of_tests)
uint32_t starttime;
uint32_t blockno = 0;
uint8_t i8, errorcode;
+ uint16_t a;
uart_puts_p ( PSTR ( "Test Read 5000 512B-Blocks with Singleblock-Read (512B Blocksize):" ) );
uart_putc ( '\n' );
@@ -139,6 +140,11 @@ void test_read512(uint8_t numblocks, uint8_t nr_of_tests)
blockno = BLOCKNO;
for ( starttime = overflow; blockno < ( BLOCKNO + 5000 ); blockno++ ) {
errorcode = wdc_read_sector ( blockno, data_buffer );
+
+ for ( a = 0 ; a < 512 ; a++ )
+ uart_putc_hex ( data_buffer[a] );
+ uart_putc ( '\n' );
+
if ( errorcode ) {
break;
}
@@ -166,7 +172,7 @@ void measure_performance()
uart_puts_p ( PSTR ( "Timer is initialized with a Prescaler 8" ) );
uart_putc ( '\n' );
- test_write512(numblocks,nr_of_tests);
+// test_write512(numblocks,nr_of_tests);
test_read512(numblocks,nr_of_tests);
test_write512(numblocks,nr_of_tests);
test_read4k(numblocks,nr_of_tests);