intermediate work

This commit is contained in:
Oliver Lehmann 2012-06-16 23:41:42 +00:00
parent e9cdb6216e
commit e27aefec5e
6 changed files with 66 additions and 29 deletions

View File

@ -138,7 +138,7 @@ 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
$(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: $< @echo Finished building: $<

View File

@ -54,6 +54,7 @@
<avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection> <avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers> <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum> <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.miscellaneous.OtherFlags />
<avrgcc.compiler.miscellaneous.DoNotDeleteTemporaryFiles>True</avrgcc.compiler.miscellaneous.DoNotDeleteTemporaryFiles> <avrgcc.compiler.miscellaneous.DoNotDeleteTemporaryFiles>True</avrgcc.compiler.miscellaneous.DoNotDeleteTemporaryFiles>
<avrgcc.linker.libraries.Libraries> <avrgcc.linker.libraries.Libraries>
<ListValues> <ListValues>

View File

@ -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 MMC_MULTIBLOCK 1
#define MEASURE_DISK_PERFORMANCE 1 #define MEASURE_DISK_PERFORMANCE 1
#undef MEASURE_DISK_PERFORMANCE //#undef MEASURE_DISK_PERFORMANCE
#define DEBUG 1 #define DEBUG 1

View File

@ -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 <avr/io.h> #include <avr/io.h>
@ -270,6 +270,7 @@ uint8_t mmc_cmd ( uint8_t *cmd )
uint8_t tmp = 0x80; uint8_t tmp = 0x80;
uint8_t i = 10; uint8_t i = 10;
uint8_t cmd0 = cmd[0]; uint8_t cmd0 = cmd[0];
uint8_t a;
#ifdef SPI_CRC #ifdef SPI_CRC
/* Calculate CRC and framing bits */ /* Calculate CRC and framing bits */
cmd[0] = ( cmd[0] | ( 1 << 6 ) ) & 0x7F; cmd[0] = ( cmd[0] | ( 1 << 6 ) ) & 0x7F;
@ -277,7 +278,7 @@ uint8_t mmc_cmd ( uint8_t *cmd )
#endif #endif
/* send command */ /* send command */
for ( uint8_t a = 0; a < 0x06; a++ ) { for ( a = 0; a < 0x06; a++ ) {
xmit_byte ( *cmd++ ); xmit_byte ( *cmd++ );
wait_till_send_done(); wait_till_send_done();
} }

View File

@ -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" #include "wdc_config.h"
@ -57,16 +57,18 @@ void pata_read_bytes ( uint8_t *buffer, uint16_t bytes );
* |||+-- DA1 * |||+-- DA1
* ||||+- DA2 * ||||+- DA2
* ||||| */ * ||||| */
#define PATA_W_DEVICE_CONTROL_REGISTER 0x0B /* 0b10011 */
#define PATA_R_STATUS_REGISTER 0x0F /* 0b01111 */ #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_W_COMMAND_REGISTER 0x0F /* 0b01111 */
#define PATA_W_DEVICE_CONTROL_REGISTER 0x0B /* 0b01011 */
#define PATA_RW_DATA_REGISTER 0x08 /* 0b01000 */ #define PATA_RW_DATA_REGISTER 0x08 /* 0b01000 */
#define PATA_RW_SECTOR_COUNT_REGISTER 0b00001010 #define PATA_RW_SECTOR_COUNT_REGISTER 0x0A /* 0b01010 */
#define PATA_RW_SECTOR_NUMBER_REGISTER 0b00001110 #define PATA_RW_SECTOR_NUMBER_REGISTER 0x0E /* 0b01110 */
#define PATA_RW_CYLINDER_LOW_REGISTER 0b00001001 #define PATA_RW_CYLINDER_LOW_REGISTER 0x09 /* 0b01001 */
#define PATA_RW_CYLINDER_HIGH_REGISTER 0b00001101 #define PATA_RW_CYLINDER_HIGH_REGISTER 0x0D /* 0b01101 */
#define PATA_RW_DEVICE_HEAD_REGISTER 0b00001011 #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(); #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(); enable_rdwrtoata();
nop(); nop();
nop(); nop();
nop();
disable_rdwrtoata(); disable_rdwrtoata();
} }
@ -132,6 +135,7 @@ uint8_t pata_get_lowbyte ()
enable_rdwrtoata(); enable_rdwrtoata();
nop(); nop();
nop(); nop();
nop();
byte = port_data_get(); byte = port_data_get();
disable_rdwrtoata(); disable_rdwrtoata();
@ -145,6 +149,7 @@ uint8_t pata_get_highbyte ()
enable_atalatch(); enable_atalatch();
nop(); nop();
nop(); nop();
nop();
byte = port_data_get(); byte = port_data_get();
disable_atalatch(); disable_atalatch();
@ -268,7 +273,7 @@ void ata_identify()
} }
uart_putc ( '\n' ); uart_putc ( '\n' );
uart_puts_p ( PSTR ( "Model number: " ) ); 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] >> 8 );
uart_putc ( word[i] & 0x00FF ); uart_putc ( word[i] & 0x00FF );
} }
@ -296,9 +301,12 @@ void ata_identify()
* Public functions * Public functions
*/ */
uint8_t data2_buffer[4096]; uint8_t data2_buffer[512];
//uint8_t data3_buffer[512];
uint8_t pata_init () uint8_t pata_init ()
{ {
uint16_t a;
// is needed for some disks (for example Maxtor 6L080J4) // is needed for some disks (for example Maxtor 6L080J4)
_delay_ms ( 200 ); _delay_ms ( 200 );
@ -307,17 +315,28 @@ uint8_t pata_init ()
while ( ( !pata_rdy() ) & pata_bsy() ); while ( ( !pata_rdy() ) & pata_bsy() );
/*set drive 0 to LBA mode*/ /*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() ); 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*/ /*recalibrate*/
write_io_register ( PATA_W_COMMAND_REGISTER, CMD_RECALIBRATE ); write_io_register ( PATA_W_COMMAND_REGISTER, CMD_RECALIBRATE );
while ( pata_bsy() ); while ( pata_bsy() );
uart_puts_p ( PSTR ( "disk is now ready\n" ) ); 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; 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 ) 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_COUNT_REGISTER, numblocks );
write_io_register ( PATA_RW_SECTOR_NUMBER_REGISTER, ( uint8_t ) addr ); 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 ); pata_read_bytes ( buffer, numblocks * PATA_BLOCKLEN );
read_io_register ( PATA_R_ALTERNATE_STATUS_REGISTER );
read_io_register ( PATA_R_STATUS_REGISTER );
return 0; 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 ); 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; return 0;
} }

View File

@ -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 <avr/io.h> #include <avr/io.h>
@ -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_puts_p ( PSTR ( "Test Write 5000 512B-Blocks with Singleblock-Write (512B Blocksize):" ) );
uart_putc ( '\n' ); 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++ ) { for ( i8 = 0; i8 < nr_of_tests; i8++ ) {
blockno = BLOCKNO; blockno = BLOCKNO;
for ( starttime = overflow; blockno < ( BLOCKNO + 5000 ); 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 starttime;
uint32_t blockno = 0; uint32_t blockno = 0;
uint8_t i8, errorcode; uint8_t i8, errorcode;
uint16_t a;
uart_puts_p ( PSTR ( "Test Read 5000 512B-Blocks with Singleblock-Read (512B Blocksize):" ) ); uart_puts_p ( PSTR ( "Test Read 5000 512B-Blocks with Singleblock-Read (512B Blocksize):" ) );
uart_putc ( '\n' ); uart_putc ( '\n' );
@ -139,6 +140,11 @@ void test_read512(uint8_t numblocks, uint8_t nr_of_tests)
blockno = BLOCKNO; blockno = BLOCKNO;
for ( starttime = overflow; blockno < ( BLOCKNO + 5000 ); blockno++ ) { for ( starttime = overflow; blockno < ( BLOCKNO + 5000 ); blockno++ ) {
errorcode = wdc_read_sector ( blockno, data_buffer ); errorcode = wdc_read_sector ( blockno, data_buffer );
for ( a = 0 ; a < 512 ; a++ )
uart_putc_hex ( data_buffer[a] );
uart_putc ( '\n' );
if ( errorcode ) { if ( errorcode ) {
break; break;
} }
@ -166,7 +172,7 @@ void measure_performance()
uart_puts_p ( PSTR ( "Timer is initialized with a Prescaler 8" ) ); uart_puts_p ( PSTR ( "Timer is initialized with a Prescaler 8" ) );
uart_putc ( '\n' ); uart_putc ( '\n' );
test_write512(numblocks,nr_of_tests); // test_write512(numblocks,nr_of_tests);
test_read512(numblocks,nr_of_tests); test_read512(numblocks,nr_of_tests);
test_write512(numblocks,nr_of_tests); test_write512(numblocks,nr_of_tests);
test_read4k(numblocks,nr_of_tests); test_read4k(numblocks,nr_of_tests);