mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Control switch via GPX pin.
This commit is contained in:
parent
8e6ab3f3ae
commit
b30c56a86e
2 changed files with 21 additions and 6 deletions
10
Usb.cpp
10
Usb.cpp
|
@ -110,14 +110,14 @@ uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t &nak_l
|
|||
USBTRACE("\r\n");
|
||||
*/
|
||||
regWr(rPERADDR, addr); //set peripheral address
|
||||
|
||||
|
||||
uint8_t mode = regRd(rMODE);
|
||||
|
||||
|
||||
//Serial.print("\r\nMode: ");
|
||||
//Serial.println( mode, HEX);
|
||||
//Serial.print("\r\nLS: ");
|
||||
//Serial.println(p->lowspeed, HEX);
|
||||
|
||||
|
||||
|
||||
|
||||
// Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise
|
||||
|
@ -512,10 +512,10 @@ void USB::Task(void) //USB state machine
|
|||
if (delay < millis()) usb_task_state = USB_STATE_CONFIGURING;
|
||||
break;
|
||||
case USB_STATE_CONFIGURING:
|
||||
|
||||
|
||||
//Serial.print("\r\nConf.LS: ");
|
||||
//Serial.println(lowspeed, HEX);
|
||||
|
||||
|
||||
rcode = Configuring(0, 0, lowspeed);
|
||||
|
||||
if (rcode) {
|
||||
|
|
17
usbhost.h
17
usbhost.h
|
@ -18,6 +18,13 @@ e-mail : support@circuitsathome.com
|
|||
#ifndef _USBHOST_H_
|
||||
#define _USBHOST_H_
|
||||
|
||||
// So we can use delay() -- xxxajk
|
||||
#if defined(ARDUINO) && ARDUINO >=100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include <WProgram.h>
|
||||
#endif
|
||||
|
||||
#include "avrpins.h"
|
||||
#include "max3421e.h"
|
||||
#include "usb_ch9.h"
|
||||
|
@ -94,7 +101,7 @@ MAX3421e< SS, INTR >::MAX3421e() {
|
|||
#endif
|
||||
|
||||
/* MAX3421E - full-duplex SPI, level interrupt */
|
||||
regWr(rPINCTL, (bmFDUPSPI + bmINTLEVEL));
|
||||
regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | GPX_VBDET));
|
||||
};
|
||||
|
||||
/* write single byte into MAX3421 register */
|
||||
|
@ -218,6 +225,10 @@ int8_t MAX3421e< SS, INTR >::Init() {
|
|||
if(reset() == 0) { //OSCOKIRQ hasn't asserted in time
|
||||
return( -1);
|
||||
}
|
||||
|
||||
// Delay 1 second to ensure any capacitors are drained.
|
||||
delay(1000);
|
||||
|
||||
regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host
|
||||
|
||||
regWr(rHIEN, bmCONDETIE | bmFRAMEIE); //connection detection
|
||||
|
@ -230,6 +241,10 @@ int8_t MAX3421e< SS, INTR >::Init() {
|
|||
|
||||
regWr(rHIRQ, bmCONDETIRQ); //clear connection detect interrupt
|
||||
regWr(rCPUCTL, 0x01); //enable interrupt pin
|
||||
|
||||
// GPX pin on. This is done here so that busprobe will fail if we have a switch connected.
|
||||
regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL));
|
||||
|
||||
return( 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue