diff -Naru old/isp.c new/isp.c --- old/isp.c 2009-05-17 15:14:30.000000000 +0900 +++ new/isp.c 2009-05-17 15:25:35.000000000 +0900 @@ -105,6 +105,11 @@ void ispConnect() { + /* added by Yuki */ + ISP_OUT |= (1 << ISP_MISO); // MISO pull up + DDRC |= (1 << 5); // PC5 OE + PORTC &= ~(1 << 5); // OE=L + /* all ISP pins are inputs before */ /* now set output pins */ ISP_DDR |= (1 << ISP_RST) | (1 << ISP_SCK) | (1 << ISP_MOSI); @@ -131,6 +136,9 @@ /* switch pullups off */ ISP_OUT &= ~((1 << ISP_RST) | (1 << ISP_SCK) | (1 << ISP_MOSI)); + /* added by Yuki */ + DDRC &= ~(1 << 5); // PC5 OE off + /* disable hardware SPI */ spiHWdisable(); } @@ -191,10 +199,11 @@ spiHWdisable(); /* pulse SCK */ + ispDelay(); /* moved by Yuki */ ISP_OUT |= (1 << ISP_SCK); /* SCK high */ ispDelay(); ISP_OUT &= ~(1 << ISP_SCK); /* SCK low */ - ispDelay(); + /* ispDelay(); */ /* moved by Yuki */ if (ispTransmit == ispTransmit_hw) { spiHWenable(); diff -Naru old/main.c new/main.c --- old/main.c 2009-05-17 15:14:41.000000000 +0900 +++ new/main.c 2009-05-17 15:25:35.000000000 +0900 @@ -42,10 +42,26 @@ if (data[1] == USBASP_FUNC_CONNECT) { /* set SCK speed */ - if ((PINC & (1 << PC2)) == 0) { - ispSetSCKOption(USBASP_ISP_SCK_8); + DDRC &= ~(1<<3); + PORTC |= (1<<3); + asm volatile("nop\n"::); + asm volatile("nop\n"::); + if (!(PINC & (1<<3))){ + /* PC3 = L */ + ispSetSCKOption(USBASP_ISP_SCK_187_5); /* 187.5kHz */ } else { - ispSetSCKOption(prog_sck); + DDRC |= (1<<2); + PORTC &= ~(1<<2); + asm volatile("nop\n"::); + asm volatile("nop\n"::); + if (!(PINC & (1<<3))){ + /* PC2 = PC3 */ + ispSetSCKOption(USBASP_ISP_SCK_93_75); /* 93.75kHz */ + } else { + ispSetSCKOption(prog_sck); /* auto */ + } + DDRC &= ~(1<<2); + PORTC |= (1<<2); } /* set compatibility mode of address delivering */