예제 #1
0
unsigned char PS2X::_gamepad_shiftinout (char byte) {
   SaveInterruptState;        // *** KJE *** save away the current state of interrupts
  

   unsigned char tmp = 0;
   DisableInterrupts;                          // *** KJE *** disable for now
   for(i=0;i<8;i++) {

	  if(CHK(byte,i)) CMD_SET();
	  else  CMD_CLR();
	  CLK_CLR();

      RestoreInterrupts;  // *** *** KJE *** *** Interrupts may be enabled again 
	  delayMicroseconds(CTRL_CLK);
	  DisableInterrupts;	// *** KJE ***

	  if(DAT_CHK()) SET(tmp,i);
	  CLK_SET();
#if CTRL_CLK_HIGH
	  delayMicroseconds(CTRL_CLK_HIGH);
#endif	  
   }
   CMD_SET();
   RestoreInterrupts;  // *** *** KJE *** *** Interrupts may be enabled again 
   delayMicroseconds(CTRL_BYTE_DELAY);
   return tmp;
}
예제 #2
0
파일: PS2X_lib.cpp 프로젝트: osmaneralp/RED
unsigned char PS2X::_gamepad_shiftinout (char byte) {
   unsigned char tmp = 0;
   for(unsigned char i=0;i<8;i++) {
      if(CHK(byte,i)) CMD_SET();
      else CMD_CLR();
	  
      CLK_CLR();
      delayMicroseconds(CTRL_CLK);

      //if(DAT_CHK()) SET(tmp,i);
      if(DAT_CHK()) bitSet(tmp,i);

      CLK_SET();
#if CTRL_CLK_HIGH
      delayMicroseconds(CTRL_CLK_HIGH);
#endif
   }
   CMD_SET();
   delayMicroseconds(CTRL_BYTE_DELAY);
   return tmp;
}