byte MAX3421E::IntHandler() { byte HIRQ; byte HIRQ_sendback = 0x00; HIRQ = regRd( rHIRQ ); //determine interrupt source //if( HIRQ & bmFRAMEIRQ ) { //->1ms SOF interrupt handler // HIRQ_sendback |= bmFRAMEIRQ; //}//end FRAMEIRQ handling if( HIRQ & bmCONDETIRQ ) { busprobe(); HIRQ_sendback |= bmCONDETIRQ; } /* End HIRQ interrupts handling, clear serviced IRQs */ regWr( rHIRQ, HIRQ_sendback ); return( HIRQ_sendback ); }
/* MAX3421E initialization after power-on */ void MAX3421E::powerOn() { /* Configure full-duplex SPI, interrupt pulse */ regWr( rPINCTL,( bmFDUPSPI + bmINTLEVEL + bmGPXB )); //Full-duplex SPI, level interrupt, GPX if( reset() == false ) { //stop/start the oscillator Serial.println("Error: OSCOKIRQ failed to assert"); } /* configure host operation */ regWr( rMODE, bmDPPULLDN|bmDMPULLDN|bmHOST|bmSEPIRQ ); // set pull-downs, Host, Separate GPIN IRQ on GPX regWr( rHIEN, bmCONDETIE|bmFRAMEIE ); //connection detection /* check if device is connected */ regWr( rHCTL,bmSAMPLEBUS ); // sample USB bus while(!(regRd( rHCTL ) & bmSAMPLEBUS )); //wait for sample operation to finish busprobe(); //check if anything is connected regWr( rHIRQ, bmCONDETIRQ ); //clear connection detect interrupt regWr( rCPUCTL, 0x01 ); //enable interrupt pin }
/* MAX3421E initialization after power-on */ void MAX3421E::powerOn() { /* Configure full-duplex SPI, interrupt pulse */ regWr( rPINCTL,( bmFDUPSPI + bmINTLEVEL + bmGPXB )); //Full-duplex SPI, level interrupt, GPX if( reset() == false ) { //stop/start the oscillator Serial.println("Error: OSCOKIRQ failed to assert"); } // /* configure power switch */ // vbusPwr( OFF ); //turn Vbus power off // regWr( rGPINIEN, bmGPINIEN7 ); //enable interrupt on GPIN7 (power switch overload flag) // if( vbusPwr( ON ) == false ) { // Serial.println("Error: Vbus overload"); // } /* configure host operation */ regWr( rMODE, bmDPPULLDN|bmDMPULLDN|bmHOST|bmSEPIRQ ); // set pull-downs, Host, Separate GPIN IRQ on GPX regWr( rHIEN, bmCONDETIE|bmFRAMEIE ); //connection detection regWr(rHCTL,bmSAMPLEBUS); // update the JSTATUS and KSTATUS bits busprobe(); //check if anything is connected regWr( rHIRQ, bmCONDETIRQ ); //clear connection detect interrupt regWr( rCPUCTL, 0x01 ); //enable interrupt pin }