rename mmc enable/disable function
remove double declaration of _buffer vars for perf. measurement and normal usage
This commit is contained in:
parent
c4185041f7
commit
35cb20db08
|
|
@ -4,22 +4,22 @@ MCU= -mmcu=atmega1284p
|
|||
CC=avr-gcc
|
||||
CFLAGS= -I/usr/local/avr/include -funsigned-char -funsigned-bitfields -O1 \
|
||||
-ffunction-sections -fpack-struct -fshort-enums -Wall -Wundef \
|
||||
-Werror -pedantic -pedantic-errors -c -std=c99 ${MCU}
|
||||
-Werror -pedantic -pedantic-errors -c ${MCU}
|
||||
|
||||
LDFLAGS=-Wl,-Map="${OUTPUT_FILE}.map" -Wl,--start-group -Wl,-lm \
|
||||
-Wl,--end-group -Wl,--gc-sections -mrelax ${MCU}
|
||||
-Wl,--end-group -Wl,--gc-sections ${MCU}
|
||||
|
||||
RM := rm -rf
|
||||
|
||||
OBJS += \
|
||||
wdc_avr.o \
|
||||
wdc_drv_pata.o \
|
||||
wdc_main.o \
|
||||
wdc_drv_mmc.o \
|
||||
wdc_drv_pata.o \
|
||||
wdc_if_disk_perf.o \
|
||||
uart.o \
|
||||
wdc_if_p8000.o \
|
||||
wdc_if_disk.o \
|
||||
wdc_if_disk_perf.o \
|
||||
wdc_par.o \
|
||||
wdc_ram.o
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $Id: wdc_avr.c,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $
|
||||
* $Id: wdc_avr.c,v 1.4 2012/06/20 18:58:24 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -61,7 +61,6 @@ void wdc_init_avr()
|
|||
configure_pin_miso();
|
||||
configure_pin_sck();
|
||||
configure_pin_mosi();
|
||||
configure_pin_mmc_cs();
|
||||
|
||||
/* configure the ATA interface */
|
||||
configure_ata_wr();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $Id: wdc_avr.h,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $
|
||||
* $Id: wdc_avr.h,v 1.4 2012/06/20 18:58:24 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -61,6 +61,8 @@
|
|||
#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_mmc() PORT_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR2 );
|
||||
#define disable_mmc() PORT_ADRDEC &= ~( 1 << PIN_ADRDEC_ADDR2 );
|
||||
#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 ) )
|
||||
|
||||
|
|
@ -68,10 +70,6 @@
|
|||
#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);
|
||||
|
||||
/* functions dealing with the sysconf jumperpad */
|
||||
#define jumper_pata_set() ~port_data_get() & (1<<PIN_DATA_D0)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $Id: wdc_config.h,v 1.19 2012/06/17 13:21:55 olivleh1 Exp $
|
||||
* $Id: wdc_config.h,v 1.20 2012/06/20 18:58:24 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -52,7 +52,6 @@
|
|||
#define DDR_ADRDEC DDRD
|
||||
|
||||
|
||||
|
||||
#define PIN_DATA_D0 PINA0
|
||||
#define PIN_DATA_D1 PINA1
|
||||
#define PIN_DATA_D2 PINA2
|
||||
|
|
@ -81,7 +80,6 @@
|
|||
#define PIN_MMC PINB
|
||||
#define DDR_MMC DDRB
|
||||
|
||||
#define PIN_MMC_CS PINB4 /* AVR Port where the MMC Card /CS signal is connected to */
|
||||
#define PIN_MMC_MOSI PINB5 /* AVR Port: MOSI / MMC Card: Data-In */
|
||||
#define PIN_MMC_MISO PINB6 /* AVR Port: MISO / MMC Card: Data-Out */
|
||||
#define PIN_MMC_SCK PINB7 /* AVR Port: SCk / MMC Card: CLK */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $Id: wdc_drv_mmc.c,v 1.20 2012/06/17 13:21:55 olivleh1 Exp $
|
||||
* $Id: wdc_drv_mmc.c,v 1.21 2012/06/20 18:58:24 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
|
|
@ -187,13 +187,13 @@ uint8_t mmc_init ()
|
|||
SPCR = ( 1 << SPE ) | ( 1 << MSTR ) | ( 1 << SPR0 ) | ( 1 << SPR1 ); /* Enable SPI, SPI in Master Mode */
|
||||
SPSR = ( 0 << SPI2X );
|
||||
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
|
||||
for ( a = 0; a < 0x0f; a++ ) {
|
||||
send_dummy_byte();
|
||||
}
|
||||
|
||||
mmc_enable();
|
||||
enable_mmc();
|
||||
|
||||
/*
|
||||
* send CMD0
|
||||
|
|
@ -206,7 +206,7 @@ uint8_t mmc_init ()
|
|||
cmd[5] = 0x95;
|
||||
while ( mmc_cmd ( cmd ) != 1 ) {
|
||||
if ( t16++ > 1000 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 1 );
|
||||
}
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ uint8_t mmc_init ()
|
|||
while ( mmc_cmd ( cmd ) != 0 ) {
|
||||
send_dummy_byte();
|
||||
if ( t16++ > 1000 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 2 );
|
||||
}
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ uint8_t mmc_init ()
|
|||
mmc_enable_crc ( 1 );
|
||||
#endif
|
||||
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 0 );
|
||||
}
|
||||
|
||||
|
|
@ -308,7 +308,7 @@ uint8_t mmc_write_sector ( uint32_t addr, uint8_t *buffer )
|
|||
uint8_t crcl, crch;
|
||||
#endif
|
||||
|
||||
mmc_enable();
|
||||
enable_mmc();
|
||||
wait_till_card_ready();
|
||||
|
||||
/* convert blocks to bytes */
|
||||
|
|
@ -325,7 +325,7 @@ uint8_t mmc_write_sector ( uint32_t addr, uint8_t *buffer )
|
|||
*/
|
||||
tmp = mmc_cmd ( cmd );
|
||||
if ( tmp != 0 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( tmp );
|
||||
}
|
||||
|
||||
|
|
@ -361,11 +361,11 @@ uint8_t mmc_write_sector ( uint32_t addr, uint8_t *buffer )
|
|||
/* check for errors */
|
||||
send_dummy_byte();
|
||||
if ( ( recv_byte() & 0x1F ) != 0x05 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 2 );
|
||||
}
|
||||
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
|
||||
return ( 0 );
|
||||
}
|
||||
|
|
@ -378,12 +378,12 @@ uint8_t mmc_read_block ( uint8_t *cmd, uint8_t *buffer, uint16_t bytes )
|
|||
uint16_t crc;
|
||||
#endif
|
||||
|
||||
mmc_enable();
|
||||
enable_mmc();
|
||||
wait_till_card_ready();
|
||||
|
||||
/* send command */
|
||||
if ( mmc_cmd ( cmd ) != 0 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 1 );
|
||||
}
|
||||
|
||||
|
|
@ -419,14 +419,14 @@ uint8_t mmc_read_block ( uint8_t *cmd, uint8_t *buffer, uint16_t bytes )
|
|||
wait_till_send_done();
|
||||
crc |= recv_byte();
|
||||
if ( crc != crc16 ( buffer, bytes ) ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 3 );
|
||||
}
|
||||
#else
|
||||
send_dummy_byte();
|
||||
#endif
|
||||
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
|
||||
return ( 0 );
|
||||
}
|
||||
|
|
@ -463,7 +463,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
uint16_t crc;
|
||||
#endif
|
||||
|
||||
mmc_enable();
|
||||
enable_mmc();
|
||||
|
||||
#ifdef MMC_MULTIBLOCK
|
||||
#ifdef MMC_PRESET_MULTIBLOCKCOUNT
|
||||
|
|
@ -505,7 +505,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
*/
|
||||
resp = mmc_cmd ( cmd );
|
||||
if ( resp > 1 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 1 );
|
||||
}
|
||||
#else
|
||||
|
|
@ -526,7 +526,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
*/
|
||||
resp = mmc_cmd ( cmd );
|
||||
if ( resp > 1 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 1 );
|
||||
}
|
||||
x.value32 += MMC_BLOCKLEN;
|
||||
|
|
@ -559,7 +559,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
send_dummy_byte();
|
||||
crc |= recv_byte();
|
||||
if ( crc != crc16 ( buffer, MMC_BLOCKLEN ) ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 3 );
|
||||
}
|
||||
buffer = buffer + MMC_BLOCKLEN;
|
||||
|
|
@ -583,7 +583,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
|
||||
/* TODO: Apacer Card I have sends 0x7f after some reads - No idea why - CRC was correct
|
||||
if ( resp > 1 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 2 );
|
||||
}
|
||||
*/
|
||||
|
|
@ -591,7 +591,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
send_dummy_byte();
|
||||
#endif
|
||||
|
||||
mmc_disable()
|
||||
disable_mmc()
|
||||
|
||||
return ( 0 );
|
||||
}
|
||||
|
|
@ -608,7 +608,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
uint8_t crcl, crch;
|
||||
#endif
|
||||
|
||||
mmc_enable();
|
||||
enable_mmc();
|
||||
wait_till_card_ready();
|
||||
#ifdef MMC_MULTIBLOCK
|
||||
#ifdef MMC_PRESET_MULTIBLOCKCOUNT
|
||||
|
|
@ -646,7 +646,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
*/
|
||||
resp = mmc_cmd ( cmd );
|
||||
if ( resp > 1 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 1 );
|
||||
}
|
||||
#else
|
||||
|
|
@ -666,7 +666,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
*/
|
||||
resp = mmc_cmd ( cmd );
|
||||
if ( resp != 0 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( resp );
|
||||
}
|
||||
x.value32 += MMC_BLOCKLEN;
|
||||
|
|
@ -716,7 +716,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
|
||||
send_dummy_byte();
|
||||
if ( ( recv_byte() & 0x1F ) != 0x05 ) {
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
return ( 2 );
|
||||
}
|
||||
|
||||
|
|
@ -736,7 +736,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks
|
|||
/* Pad 8 */
|
||||
send_dummy_byte();
|
||||
#endif
|
||||
mmc_disable();
|
||||
disable_mmc();
|
||||
|
||||
return ( 0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $Id: wdc_if_disk_perf.c,v 1.9 2012/06/17 16:40:42 olivleh1 Exp $
|
||||
* $Id: wdc_if_disk_perf.c,v 1.10 2012/06/20 18:58:24 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
|
|
@ -44,11 +44,15 @@
|
|||
#ifdef MEASURE_DISK_PERFORMANCE
|
||||
#define BLOCKNO 300000
|
||||
|
||||
extern uint32_t overflow;
|
||||
volatile uint32_t overflow = 0;
|
||||
ISR ( TIMER0_OVF_vect )
|
||||
{
|
||||
overflow ++;
|
||||
}
|
||||
|
||||
/* switched from local to global for keeping an eye on memory usage */
|
||||
uint8_t data_buffer[4096];
|
||||
uint8_t cmd_buffer[9];
|
||||
extern uint8_t data_buffer[];
|
||||
extern uint8_t cmd_buffer[];
|
||||
|
||||
|
||||
void test_write4k ( uint8_t numblocks, uint8_t nr_of_tests )
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
/*
|
||||
* P8000 WDC Emulator
|
||||
*
|
||||
* $Id: wdc_main.c,v 1.29 2012/06/16 19:34:39 olivleh1 Exp $
|
||||
* $Id: wdc_main.c,v 1.30 2012/06/20 18:58:24 olivleh1 Exp $
|
||||
*
|
||||
* TODO: - right now, BTT entries are not taken into account
|
||||
*/
|
||||
|
|
@ -54,19 +54,14 @@
|
|||
|
||||
void atmega_setup ( void );
|
||||
|
||||
#ifdef MEASURE_DISK_PERFORMANCE
|
||||
extern void measure_performance();
|
||||
volatile uint32_t overflow = 0;
|
||||
ISR ( TIMER0_OVF_vect )
|
||||
{
|
||||
overflow ++;
|
||||
}
|
||||
#else
|
||||
|
||||
/* switched from local to global for keeping an eye on memory usage */
|
||||
uint8_t data_buffer[4096];
|
||||
uint8_t cmd_buffer[9];
|
||||
|
||||
#ifdef MEASURE_DISK_PERFORMANCE
|
||||
extern void measure_performance();
|
||||
#else
|
||||
|
||||
/* switched from local to global for keeping an eye on memory usage */
|
||||
extern uint8_t valid_disk;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue