USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
usbhost.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 
17 Contact information
18 -------------------
19 
20 Circuits At Home, LTD
21 Web : http://www.circuitsathome.com
22 e-mail : support@circuitsathome.com
23  */
24 /* MAX3421E-based USB Host Library header file */
25 
26 
27 #if !defined(_usb_h_) || defined(_USBHOST_H_)
28 #error "Never include usbhost.h directly; include Usb.h instead"
29 #else
30 #define _USBHOST_H_
31 
32 #if USING_SPI4TEENSY3
33 #include <spi4teensy3.h>
34 #include <sys/types.h>
35 #endif
36 
37 /* SPI initialization */
38 template< typename SPI_CLK, typename SPI_MOSI, typename SPI_MISO, typename SPI_SS > class SPi {
39 public:
40 #if USING_SPI4TEENSY3
41  static void init() {
42  // spi4teensy3 inits everything for us, except /SS
43  // CLK, MOSI and MISO are hard coded for now.
44  // spi4teensy3::init(0,0,0); // full speed, cpol 0, cpha 0
45  spi4teensy3::init(); // full speed, cpol 0, cpha 0
46  SPI_SS::SetDirWrite();
47  SPI_SS::Set();
48  }
49 #elif defined(SPI_HAS_TRANSACTION)
50  static void init() {
51  USB_SPI.begin(); // The SPI library with transaction will take care of setting up the pins - settings is set in beginTransaction()
52  SPI_SS::SetDirWrite();
53  SPI_SS::Set();
54  }
55 #elif defined(STM32F4)
56 #warning "You need to initialize the SPI interface manually when using the STM32F4 platform"
57  static void init() {
58  // Should be initialized by the user manually for now
59  }
60 #elif !defined(SPDR)
61  static void init() {
62  SPI_SS::SetDirWrite();
63  SPI_SS::Set();
64  USB_SPI.begin();
65 #if defined(__MIPSEL__)
66  USB_SPI.setClockDivider(1);
67 #elif defined(__ARDUINO_X86__)
68  #ifdef SPI_CLOCK_1M // Hack used to check if setClockSpeed is available
69  USB_SPI.setClockSpeed(12000000); // The MAX3421E can handle up to 26MHz, but in practice this was the maximum that I could reliably use
70  #else
71  USB_SPI.setClockDivider(SPI_CLOCK_DIV2); // This will set the SPI frequency to 8MHz - it could be higher, but it is not supported in the old API
72  #endif
73 #elif !defined(RBL_NRF51822)
74  USB_SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz
75 #endif
76  }
77 #else
78  static void init() {
79  //uint8_t tmp;
80  SPI_CLK::SetDirWrite();
81  SPI_MOSI::SetDirWrite();
82  SPI_MISO::SetDirRead();
83  SPI_SS::SetDirWrite();
84  /* mode 00 (CPOL=0, CPHA=0) master, fclk/2. Mode 11 (CPOL=11, CPHA=11) is also supported by MAX3421E */
85  SPCR = 0x50;
86  SPSR = 0x01; // 0x01
87 
88  //tmp = SPSR;
89  //tmp = SPDR;
90  }
91 #endif
92 };
93 
94 /* SPI pin definitions. see avrpins.h */
95 #if defined(PIN_SPI_SCK) && defined(PIN_SPI_MOSI) && defined(PIN_SPI_MISO) && defined(PIN_SPI_SS)
96 // Use pin defines: https://github.com/arduino/Arduino/pull/4814
97 // Based on: https://www.mikeash.com/pyblog/friday-qa-2015-03-20-preprocessor-abuse-and-optional-parentheses.html
98 #define NOTHING_EXTRACT
99 #define EXTRACT(...) EXTRACT __VA_ARGS__
100 #define PASTE(x, ...) x ## __VA_ARGS__
101 #define EVALUATING_PASTE(x, ...) PASTE(x, __VA_ARGS__)
102 #define UNPAREN(x) EVALUATING_PASTE(NOTHING_, EXTRACT x)
103 #define APPEND_PIN(pin) P ## pin // Appends the pin to 'P', e.g. 1 becomes P1
104 #define MAKE_PIN(x) EVALUATING_PASTE(APPEND_, PIN(UNPAREN(x)))
106 #undef MAKE_PIN
107 #elif defined(__AVR_ATmega1280__) || (__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
108 typedef SPi< Pb1, Pb2, Pb3, Pb0 > spi;
109 #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
110 typedef SPi< Pb5, Pb3, Pb4, Pb2 > spi;
111 #elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
112 typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi;
113 #elif (defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__MKL26Z64__))) || defined(__ARDUINO_ARC__) || defined(__ARDUINO_X86__) || defined(__MIPSEL__) || defined(STM32F4)
114 typedef SPi< P13, P11, P12, P10 > spi;
115 #elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
116 typedef SPi< P76, P75, P74, P10 > spi;
117 #elif defined(RBL_NRF51822)
118 typedef SPi< P16, P18, P17, P10 > spi;
119 #elif defined(ESP8266)
120 typedef SPi< P14, P13, P12, P15 > spi;
121 #elif defined(ESP32)
122 typedef SPi< P18, P23, P19, P5 > spi;
123 #else
124 #error "No SPI entry in usbhost.h"
125 #endif
126 
127 typedef enum {
128  vbus_on = 0,
130 } VBUS_t;
131 
132 template< typename SPI_SS, typename INTR > class MAX3421e /* : public spi */ {
133  static uint8_t vbusState;
134 
135 public:
136  MAX3421e();
137  void regWr(uint8_t reg, uint8_t data);
138  uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
139  void gpioWr(uint8_t data);
140  uint8_t regRd(uint8_t reg);
141  uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
142  uint8_t gpioRd();
143  uint8_t gpioRdOutput();
144  uint16_t reset();
145  int8_t Init();
146  int8_t Init(int mseconds);
147 
148  void vbusPower(VBUS_t state) {
149  regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | state));
150  }
151 
152  uint8_t getVbusState(void) {
153  return vbusState;
154  };
155  void busprobe();
156  uint8_t GpxHandler();
157  uint8_t IntHandler();
158  uint8_t Task();
159 };
160 
161 template< typename SPI_SS, typename INTR >
163 
164 /* constructor */
165 template< typename SPI_SS, typename INTR >
167  // Leaving ADK hardware setup in here, for now. This really belongs with the other parts.
168 #ifdef BOARD_MEGA_ADK
169  // For Mega ADK, which has a Max3421e on-board, set MAX_RESET to output mode, and then set it to HIGH
170  P55::SetDirWrite();
171  P55::Set();
172 #endif
173 };
174 
175 /* write single byte into MAX3421 register */
176 template< typename SPI_SS, typename INTR >
177 void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
179 #if defined(SPI_HAS_TRANSACTION)
180  USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
181 #endif
182  SPI_SS::Clear();
183 
184 #if USING_SPI4TEENSY3
185  uint8_t c[2];
186  c[0] = reg | 0x02;
187  c[1] = data;
188  spi4teensy3::send(c, 2);
189 #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
190  uint8_t c[2];
191  c[0] = reg | 0x02;
192  c[1] = data;
193  USB_SPI.transfer(c, 2);
194 #elif defined(STM32F4)
195  uint8_t c[2];
196  c[0] = reg | 0x02;
197  c[1] = data;
198  HAL_SPI_Transmit(&SPI_Handle, c, 2, HAL_MAX_DELAY);
199 #elif !defined(SPDR) // ESP8266, ESP32
200  USB_SPI.transfer(reg | 0x02);
201  USB_SPI.transfer(data);
202 #else
203  SPDR = (reg | 0x02);
204  while(!(SPSR & (1 << SPIF)));
205  SPDR = data;
206  while(!(SPSR & (1 << SPIF)));
207 #endif
208 
209  SPI_SS::Set();
210 #if defined(SPI_HAS_TRANSACTION)
211  USB_SPI.endTransaction();
212 #endif
214  return;
215 };
216 /* multiple-byte write */
217 
218 /* returns a pointer to memory position after last written */
219 template< typename SPI_SS, typename INTR >
220 uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
222 #if defined(SPI_HAS_TRANSACTION)
223  USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
224 #endif
225  SPI_SS::Clear();
226 
227 #if USING_SPI4TEENSY3
228  spi4teensy3::send(reg | 0x02);
229  spi4teensy3::send(data_p, nbytes);
230  data_p += nbytes;
231 #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
232  USB_SPI.transfer(reg | 0x02);
233  USB_SPI.transfer(data_p, nbytes);
234  data_p += nbytes;
235 #elif defined(__ARDUINO_X86__)
236  USB_SPI.transfer(reg | 0x02);
237  USB_SPI.transferBuffer(data_p, NULL, nbytes);
238  data_p += nbytes;
239 #elif defined(STM32F4)
240  uint8_t data = reg | 0x02;
241  HAL_SPI_Transmit(&SPI_Handle, &data, 1, HAL_MAX_DELAY);
242  HAL_SPI_Transmit(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
243  data_p += nbytes;
244 #elif !defined(SPDR) // ESP8266, ESP32
245  USB_SPI.transfer(reg | 0x02);
246  while(nbytes) {
247  USB_SPI.transfer(*data_p);
248  nbytes--;
249  data_p++; // advance data pointer
250  }
251 #else
252  SPDR = (reg | 0x02); //set WR bit and send register number
253  while(nbytes) {
254  while(!(SPSR & (1 << SPIF))); //check if previous byte was sent
255  SPDR = (*data_p); // send next data byte
256  nbytes--;
257  data_p++; // advance data pointer
258  }
259  while(!(SPSR & (1 << SPIF)));
260 #endif
261 
262  SPI_SS::Set();
263 #if defined(SPI_HAS_TRANSACTION)
264  USB_SPI.endTransaction();
265 #endif
267  return ( data_p);
268 }
269 /* GPIO write */
270 /*GPIO byte is split between 2 registers, so two writes are needed to write one byte */
271 
272 /* GPOUT bits are in the low nibble. 0-3 in IOPINS1, 4-7 in IOPINS2 */
273 template< typename SPI_SS, typename INTR >
275  regWr(rIOPINS1, data);
276  data >>= 4;
277  regWr(rIOPINS2, data);
278  return;
279 }
280 
281 /* single host register read */
282 template< typename SPI_SS, typename INTR >
283 uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
285 #if defined(SPI_HAS_TRANSACTION)
286  USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
287 #endif
288  SPI_SS::Clear();
289 
290 #if USING_SPI4TEENSY3
291  spi4teensy3::send(reg);
292  uint8_t rv = spi4teensy3::receive();
293  SPI_SS::Set();
294 #elif defined(STM32F4)
295  HAL_SPI_Transmit(&SPI_Handle, &reg, 1, HAL_MAX_DELAY);
296  uint8_t rv = 0;
297  HAL_SPI_Receive(&SPI_Handle, &rv, 1, HAL_MAX_DELAY);
298  SPI_SS::Set();
299 #elif !defined(SPDR) || defined(SPI_HAS_TRANSACTION)
300  USB_SPI.transfer(reg);
301  uint8_t rv = USB_SPI.transfer(0); // Send empty byte
302  SPI_SS::Set();
303 #else
304  SPDR = reg;
305  while(!(SPSR & (1 << SPIF)));
306  SPDR = 0; // Send empty byte
307  while(!(SPSR & (1 << SPIF)));
308  SPI_SS::Set();
309  uint8_t rv = SPDR;
310 #endif
311 
312 #if defined(SPI_HAS_TRANSACTION)
313  USB_SPI.endTransaction();
314 #endif
316  return (rv);
317 }
318 /* multiple-byte register read */
319 
320 /* returns a pointer to a memory position after last read */
321 template< typename SPI_SS, typename INTR >
322 uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
324 #if defined(SPI_HAS_TRANSACTION)
325  USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
326 #endif
327  SPI_SS::Clear();
328 
329 #if USING_SPI4TEENSY3
330  spi4teensy3::send(reg);
331  spi4teensy3::receive(data_p, nbytes);
332  data_p += nbytes;
333 #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
334  USB_SPI.transfer(reg);
335  memset(data_p, 0, nbytes); // Make sure we send out empty bytes
336  USB_SPI.transfer(data_p, nbytes);
337  data_p += nbytes;
338 #elif defined(__ARDUINO_X86__)
339  USB_SPI.transfer(reg);
340  USB_SPI.transferBuffer(NULL, data_p, nbytes);
341  data_p += nbytes;
342 #elif defined(STM32F4)
343  HAL_SPI_Transmit(&SPI_Handle, &reg, 1, HAL_MAX_DELAY);
344  memset(data_p, 0, nbytes); // Make sure we send out empty bytes
345  HAL_SPI_Receive(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
346  data_p += nbytes;
347 #elif !defined(SPDR) // ESP8266, ESP32
348  USB_SPI.transfer(reg);
349  while(nbytes) {
350  *data_p++ = USB_SPI.transfer(0);
351  nbytes--;
352  }
353 #else
354  SPDR = reg;
355  while(!(SPSR & (1 << SPIF))); //wait
356  while(nbytes) {
357  SPDR = 0; // Send empty byte
358  nbytes--;
359  while(!(SPSR & (1 << SPIF)));
360 #if 0
361  {
362  *data_p = SPDR;
363  printf("%2.2x ", *data_p);
364  }
365  data_p++;
366  }
367  printf("\r\n");
368 #else
369  *data_p++ = SPDR;
370  }
371 #endif
372 #endif
373 
374  SPI_SS::Set();
375 #if defined(SPI_HAS_TRANSACTION)
376  USB_SPI.endTransaction();
377 #endif
379  return ( data_p);
380 }
381 /* GPIO read. See gpioWr for explanation */
382 
386 /* GPIN pins are in high nibbles of IOPINS1, IOPINS2 */
387 template< typename SPI_SS, typename INTR >
389  uint8_t gpin = 0;
390  gpin = regRd(rIOPINS2); //pins 4-7
391  gpin &= 0xf0; //clean lower nibble
392  gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation.
393  return ( gpin);
394 }
395 
399 /* GPOUT pins are in low nibbles of IOPINS1, IOPINS2 */
400 template< typename SPI_SS, typename INTR >
402  uint8_t gpout = 0;
403  gpout = regRd(rIOPINS1); //pins 0-3
404  gpout &= 0x0f; //clean upper nibble
405  gpout |= (regRd(rIOPINS2) << 4); //shift high bits and OR with lower from previous operation.
406  return ( gpout);
407 }
408 
409 /* reset MAX3421E. Returns number of cycles it took for PLL to stabilize after reset
410  or zero if PLL haven't stabilized in 65535 cycles */
411 template< typename SPI_SS, typename INTR >
413  uint16_t i = 0;
414  regWr(rUSBCTL, bmCHIPRES);
415  regWr(rUSBCTL, 0x00);
416  while(++i) {
417  if((regRd(rUSBIRQ) & bmOSCOKIRQ)) {
418  break;
419  }
420  }
421  return ( i);
422 }
423 
424 /* initialize MAX3421E. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not */
425 template< typename SPI_SS, typename INTR >
428  // Moved here.
429  // you really should not init hardware in the constructor when it involves locks.
430  // Also avoids the vbus flicker issue confusing some devices.
431  /* pin and peripheral setup */
432  SPI_SS::SetDirWrite();
433  SPI_SS::Set();
434  spi::init();
435  INTR::SetDirRead();
437  /* MAX3421E - full-duplex SPI, level interrupt */
438  // GPX pin on. Moved here, otherwise we flicker the vbus.
439  regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL));
440 
441  if(reset() == 0) { //OSCOKIRQ hasn't asserted in time
442  return ( -1);
443  }
444 
445  regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host
446 
447  regWr(rHIEN, bmCONDETIE | bmFRAMEIE); //connection detection
448 
449  /* check if device is connected */
450  regWr(rHCTL, bmSAMPLEBUS); // sample USB bus
451  while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish
452 
453  busprobe(); //check if anything is connected
454 
455  regWr(rHIRQ, bmCONDETIRQ); //clear connection detect interrupt
456  regWr(rCPUCTL, 0x01); //enable interrupt pin
457 
458  return ( 0);
459 }
460 
461 /* initialize MAX3421E. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not */
462 template< typename SPI_SS, typename INTR >
463 int8_t MAX3421e< SPI_SS, INTR >::Init(int mseconds) {
465  // Moved here.
466  // you really should not init hardware in the constructor when it involves locks.
467  // Also avoids the vbus flicker issue confusing some devices.
468  /* pin and peripheral setup */
469  SPI_SS::SetDirWrite();
470  SPI_SS::Set();
471  spi::init();
472  INTR::SetDirRead();
474  /* MAX3421E - full-duplex SPI, level interrupt, vbus off */
475  regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | GPX_VBDET));
476 
477  if(reset() == 0) { //OSCOKIRQ hasn't asserted in time
478  return ( -1);
479  }
480 
481  // Delay a minimum of 1 second to ensure any capacitors are drained.
482  // 1 second is required to make sure we do not smoke a Microdrive!
483  if(mseconds < 1000) mseconds = 1000;
484  delay(mseconds);
485 
486  regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host
487 
488  regWr(rHIEN, bmCONDETIE | bmFRAMEIE); //connection detection
489 
490  /* check if device is connected */
491  regWr(rHCTL, bmSAMPLEBUS); // sample USB bus
492  while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish
493 
494  busprobe(); //check if anything is connected
495 
496  regWr(rHIRQ, bmCONDETIRQ); //clear connection detect interrupt
497  regWr(rCPUCTL, 0x01); //enable interrupt pin
498 
499  // GPX pin on. This is done here so that busprobe will fail if we have a switch connected.
500  regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL));
501 
502  return ( 0);
503 }
504 
505 /* probe bus to determine device presence and speed and switch host to this speed */
506 template< typename SPI_SS, typename INTR >
508  uint8_t bus_sample;
509  bus_sample = regRd(rHRSL); //Get J,K status
510  bus_sample &= (bmJSTATUS | bmKSTATUS); //zero the rest of the byte
511  switch(bus_sample) { //start full-speed or low-speed host
512  case( bmJSTATUS):
513  if((regRd(rMODE) & bmLOWSPEED) == 0) {
514  regWr(rMODE, MODE_FS_HOST); //start full-speed host
515  vbusState = FSHOST;
516  } else {
517  regWr(rMODE, MODE_LS_HOST); //start low-speed host
518  vbusState = LSHOST;
519  }
520  break;
521  case( bmKSTATUS):
522  if((regRd(rMODE) & bmLOWSPEED) == 0) {
523  regWr(rMODE, MODE_LS_HOST); //start low-speed host
524  vbusState = LSHOST;
525  } else {
526  regWr(rMODE, MODE_FS_HOST); //start full-speed host
527  vbusState = FSHOST;
528  }
529  break;
530  case( bmSE1): //illegal state
531  vbusState = SE1;
532  break;
533  case( bmSE0): //disconnected state
534  regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST | bmSEPIRQ);
535  vbusState = SE0;
536  break;
537  }//end switch( bus_sample )
538 }
539 
540 /* MAX3421 state change task and interrupt handler */
541 template< typename SPI_SS, typename INTR >
543  uint8_t rcode = 0;
544  uint8_t pinvalue;
545  //USB_HOST_SERIAL.print("Vbus state: ");
546  //USB_HOST_SERIAL.println( vbusState, HEX );
547  pinvalue = INTR::IsSet(); //Read();
548  //pinvalue = digitalRead( MAX_INT );
549  if(pinvalue == 0) {
550  rcode = IntHandler();
551  }
552  // pinvalue = digitalRead( MAX_GPX );
553  // if( pinvalue == LOW ) {
554  // GpxHandler();
555  // }
556  // usbSM(); //USB state machine
557  return ( rcode);
558 }
559 
560 template< typename SPI_SS, typename INTR >
562  uint8_t HIRQ;
563  uint8_t HIRQ_sendback = 0x00;
564  HIRQ = regRd(rHIRQ); //determine interrupt source
565  //if( HIRQ & bmFRAMEIRQ ) { //->1ms SOF interrupt handler
566  // HIRQ_sendback |= bmFRAMEIRQ;
567  //}//end FRAMEIRQ handling
568  if(HIRQ & bmCONDETIRQ) {
569  busprobe();
570  HIRQ_sendback |= bmCONDETIRQ;
571  }
572  /* End HIRQ interrupts handling, clear serviced IRQs */
573  regWr(rHIRQ, HIRQ_sendback);
574  return ( HIRQ_sendback);
575 }
576 //template< typename SPI_SS, typename INTR >
577 //uint8_t MAX3421e< SPI_SS, INTR >::GpxHandler()
578 //{
579 // uint8_t GPINIRQ = regRd( rGPINIRQ ); //read GPIN IRQ register
586 // return( GPINIRQ );
587 //}
588 
589 #endif // _USBHOST_H_
#define GPX_VBDET
Definition: max3421e.h:82
#define rIOPINS1
Definition: max3421e.h:88
void busprobe()
Definition: usbhost.h:507
#define rHIEN
Definition: max3421e.h:155
#define FSHOST
Definition: max3421e.h:37
#define rHCTL
Definition: max3421e.h:181
#define bmCONDETIRQ
Definition: max3421e.h:151
#define bmCONDETIE
Definition: max3421e.h:163
#define bmSE1
Definition: max3421e.h:211
#define bmCHIPRES
Definition: max3421e.h:64
uint8_t getVbusState(void)
Definition: usbhost.h:152
#define rCPUCTL
Definition: max3421e.h:67
#define bmJSTATUS
Definition: max3421e.h:209
uint16_t reset()
Definition: usbhost.h:412
#define MODE_LS_HOST
Definition: max3421e.h:232
uint8_t gpioRdOutput()
Reads the current GPI output values.
Definition: usbhost.h:401
#define bmINTLEVEL
Definition: max3421e.h:76
void gpioWr(uint8_t data)
Definition: usbhost.h:274
uint8_t Task()
Definition: usbhost.h:542
#define rUSBCTL
Definition: max3421e.h:62
#define bmSE0
Definition: max3421e.h:210
#define bmHOST
Definition: max3421e.h:170
#define bmSEPIRQ
Definition: max3421e.h:174
uint8_t gpioRd()
Reads the current GPI input values.
Definition: usbhost.h:388
int8_t Init()
Definition: usbhost.h:426
uint8_t GpxHandler()
#define LSHOST
Definition: max3421e.h:38
#define rMODE
Definition: max3421e.h:167
#define MODE_FS_HOST
Definition: max3421e.h:231
void vbusPower(VBUS_t state)
Definition: usbhost.h:148
#define bmKSTATUS
Definition: max3421e.h:208
#define rHRSL
Definition: max3421e.h:203
uint8_t * bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
Definition: usbhost.h:322
#define XMEM_ACQUIRE_SPI()
Definition: settings.h:136
#define bmLOWSPEED
Definition: max3421e.h:171
uint8_t * bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
Definition: usbhost.h:220
Definition: usbhost.h:38
#define rHIRQ
Definition: max3421e.h:144
#define rUSBIRQ
Definition: max3421e.h:50
#define XMEM_RELEASE_SPI()
Definition: settings.h:137
#define bmFDUPSPI
Definition: max3421e.h:75
#define rPINCTL
Definition: max3421e.h:73
VBUS_t
Definition: usbhost.h:127
void regWr(uint8_t reg, uint8_t data)
Definition: usbhost.h:177
#define bmFRAMEIE
Definition: max3421e.h:164
uint8_t IntHandler()
Definition: usbhost.h:561
#define bmOSCOKIRQ
Definition: max3421e.h:54
uint8_t regRd(uint8_t reg)
Definition: usbhost.h:283
MAX3421e()
Definition: usbhost.h:166
#define USB_SPI
Definition: settings.h:33
#define SE0
Definition: max3421e.h:35
#define rIOPINS2
Definition: max3421e.h:100
#define bmDMPULLDN
Definition: max3421e.h:176
#define SE1
Definition: max3421e.h:36
#define bmSAMPLEBUS
Definition: max3421e.h:185
static void init()
Definition: usbhost.h:61
#define bmDPPULLDN
Definition: max3421e.h:177