我用的LPC2294,用IO方式寫的讀寫函數(shù),但是速度寫U盤速度慢,請(qǐng)幫忙看下代碼能否優(yōu)化
void usb_write_command( uint8 mCmd ) { mDelay1_2uS( ); IO2DIR |= 0xffff; IO2SET |= mCmd; IO3SET |= addr0; IO3CLR |= we; IO1CLR |= cs0; IO3SET |= we; IO1SET |= cs0; IO2CLR |= mCmd; IO2DIR &= 0x00; mDelay2uS(); }
void usb_write_data( uint8 mData ) { mDelay1_2uS( ); IO2DIR |= 0xffff; IO2SET |= mData;
IO3CLR |= we |addr0; IO1CLR |= cs0; IO3SET |= we; IO1SET |= cs0; IO2CLR |= mData; IO2DIR &= 0x00; mDelay1_2uS( ); }
uint8 usb_read( void ) { uint8 mData;
mDelay1_2uS(); IO2DIR &= 0x00000000; IO1CLR |= cs0 |rd; IO3CLR |= addr0;
mData = IO2PIN; IO1SET |= cs0 |rd; return( mData ); }