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  uint16_t reset();
144  int8_t Init();
145  int8_t Init(int mseconds);
146 
147  void vbusPower(VBUS_t state) {
148  regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | state));
149  }
150 
151  uint8_t getVbusState(void) {
152  return vbusState;
153  };
154  void busprobe();
155  uint8_t GpxHandler();
156  uint8_t IntHandler();
157  uint8_t Task();
158 };
159 
160 template< typename SPI_SS, typename INTR >
162 
163 /* constructor */
164 template< typename SPI_SS, typename INTR >
166  // Leaving ADK hardware setup in here, for now. This really belongs with the other parts.
167 #ifdef BOARD_MEGA_ADK
168  // For Mega ADK, which has a Max3421e on-board, set MAX_RESET to output mode, and then set it to HIGH
169  P55::SetDirWrite();
170  P55::Set();
171 #endif
172 };
173 
174 /* write single byte into MAX3421 register */
175 template< typename SPI_SS, typename INTR >
176 void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
178 #if defined(SPI_HAS_TRANSACTION)
179  USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
180 #endif
181  SPI_SS::Clear();
182 
183 #if USING_SPI4TEENSY3
184  uint8_t c[2];
185  c[0] = reg | 0x02;
186  c[1] = data;
187  spi4teensy3::send(c, 2);
188 #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
189  uint8_t c[2];
190  c[0] = reg | 0x02;
191  c[1] = data;
192  USB_SPI.transfer(c, 2);
193 #elif defined(STM32F4)
194  uint8_t c[2];
195  c[0] = reg | 0x02;
196  c[1] = data;
197  HAL_SPI_Transmit(&SPI_Handle, c, 2, HAL_MAX_DELAY);
198 #elif !defined(SPDR) // ESP8266, ESP32
199  USB_SPI.transfer(reg | 0x02);
200  USB_SPI.transfer(data);
201 #else
202  SPDR = (reg | 0x02);
203  while(!(SPSR & (1 << SPIF)));
204  SPDR = data;
205  while(!(SPSR & (1 << SPIF)));
206 #endif
207 
208  SPI_SS::Set();
209 #if defined(SPI_HAS_TRANSACTION)
210  USB_SPI.endTransaction();
211 #endif
213  return;
214 };
215 /* multiple-byte write */
216 
217 /* returns a pointer to memory position after last written */
218 template< typename SPI_SS, typename INTR >
219 uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
221 #if defined(SPI_HAS_TRANSACTION)
222  USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
223 #endif
224  SPI_SS::Clear();
225 
226 #if USING_SPI4TEENSY3
227  spi4teensy3::send(reg | 0x02);
228  spi4teensy3::send(data_p, nbytes);
229  data_p += nbytes;
230 #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
231  USB_SPI.transfer(reg | 0x02);
232  USB_SPI.transfer(data_p, nbytes);
233  data_p += nbytes;
234 #elif defined(__ARDUINO_X86__)
235  USB_SPI.transfer(reg | 0x02);
236  USB_SPI.transferBuffer(data_p, NULL, nbytes);
237  data_p += nbytes;
238 #elif defined(STM32F4)
239  uint8_t data = reg | 0x02;
240  HAL_SPI_Transmit(&SPI_Handle, &data, 1, HAL_MAX_DELAY);
241  HAL_SPI_Transmit(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
242  data_p += nbytes;
243 #elif !defined(SPDR) // ESP8266, ESP32
244  USB_SPI.transfer(reg | 0x02);
245  while(nbytes) {
246  USB_SPI.transfer(*data_p);
247  nbytes--;
248  data_p++; // advance data pointer
249  }
250 #else
251  SPDR = (reg | 0x02); //set WR bit and send register number
252  while(nbytes) {
253  while(!(SPSR & (1 << SPIF))); //check if previous byte was sent
254  SPDR = (*data_p); // send next data byte
255  nbytes--;
256  data_p++; // advance data pointer
257  }
258  while(!(SPSR & (1 << SPIF)));
259 #endif
260 
261  SPI_SS::Set();
262 #if defined(SPI_HAS_TRANSACTION)
263  USB_SPI.endTransaction();
264 #endif
266  return ( data_p);
267 }
268 /* GPIO write */
269 /*GPIO byte is split between 2 registers, so two writes are needed to write one byte */
270 
271 /* GPOUT bits are in the low nibble. 0-3 in IOPINS1, 4-7 in IOPINS2 */
272 template< typename SPI_SS, typename INTR >
274  regWr(rIOPINS1, data);
275  data >>= 4;
276  regWr(rIOPINS2, data);
277  return;
278 }
279 
280 /* single host register read */
281 template< typename SPI_SS, typename INTR >
282 uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
284 #if defined(SPI_HAS_TRANSACTION)
285  USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
286 #endif
287  SPI_SS::Clear();
288 
289 #if USING_SPI4TEENSY3
290  spi4teensy3::send(reg);
291  uint8_t rv = spi4teensy3::receive();
292  SPI_SS::Set();
293 #elif defined(STM32F4)
294  HAL_SPI_Transmit(&SPI_Handle, &reg, 1, HAL_MAX_DELAY);
295  uint8_t rv = 0;
296  HAL_SPI_Receive(&SPI_Handle, &rv, 1, HAL_MAX_DELAY);
297  SPI_SS::Set();
298 #elif !defined(SPDR) || defined(SPI_HAS_TRANSACTION)
299  USB_SPI.transfer(reg);
300  uint8_t rv = USB_SPI.transfer(0); // Send empty byte
301  SPI_SS::Set();
302 #else
303  SPDR = reg;
304  while(!(SPSR & (1 << SPIF)));
305  SPDR = 0; // Send empty byte
306  while(!(SPSR & (1 << SPIF)));
307  SPI_SS::Set();
308  uint8_t rv = SPDR;
309 #endif
310 
311 #if defined(SPI_HAS_TRANSACTION)
312  USB_SPI.endTransaction();
313 #endif
315  return (rv);
316 }
317 /* multiple-byte register read */
318 
319 /* returns a pointer to a memory position after last read */
320 template< typename SPI_SS, typename INTR >
321 uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
323 #if defined(SPI_HAS_TRANSACTION)
324  USB_SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0
325 #endif
326  SPI_SS::Clear();
327 
328 #if USING_SPI4TEENSY3
329  spi4teensy3::send(reg);
330  spi4teensy3::receive(data_p, nbytes);
331  data_p += nbytes;
332 #elif defined(SPI_HAS_TRANSACTION) && !defined(ESP8266) && !defined(ESP32)
333  USB_SPI.transfer(reg);
334  memset(data_p, 0, nbytes); // Make sure we send out empty bytes
335  USB_SPI.transfer(data_p, nbytes);
336  data_p += nbytes;
337 #elif defined(__ARDUINO_X86__)
338  USB_SPI.transfer(reg);
339  USB_SPI.transferBuffer(NULL, data_p, nbytes);
340  data_p += nbytes;
341 #elif defined(STM32F4)
342  HAL_SPI_Transmit(&SPI_Handle, &reg, 1, HAL_MAX_DELAY);
343  memset(data_p, 0, nbytes); // Make sure we send out empty bytes
344  HAL_SPI_Receive(&SPI_Handle, data_p, nbytes, HAL_MAX_DELAY);
345  data_p += nbytes;
346 #elif !defined(SPDR) // ESP8266, ESP32
347  USB_SPI.transfer(reg);
348  while(nbytes) {
349  *data_p++ = USB_SPI.transfer(0);
350  nbytes--;
351  }
352 #else
353  SPDR = reg;
354  while(!(SPSR & (1 << SPIF))); //wait
355  while(nbytes) {
356  SPDR = 0; // Send empty byte
357  nbytes--;
358  while(!(SPSR & (1 << SPIF)));
359 #if 0
360  {
361  *data_p = SPDR;
362  printf("%2.2x ", *data_p);
363  }
364  data_p++;
365  }
366  printf("\r\n");
367 #else
368  *data_p++ = SPDR;
369  }
370 #endif
371 #endif
372 
373  SPI_SS::Set();
374 #if defined(SPI_HAS_TRANSACTION)
375  USB_SPI.endTransaction();
376 #endif
378  return ( data_p);
379 }
380 /* GPIO read. See gpioWr for explanation */
381 
382 /* GPIN pins are in high nibbles of IOPINS1, IOPINS2 */
383 template< typename SPI_SS, typename INTR >
385  uint8_t gpin = 0;
386  gpin = regRd(rIOPINS2); //pins 4-7
387  gpin &= 0xf0; //clean lower nibble
388  gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation.
389  return ( gpin);
390 }
391 
392 /* reset MAX3421E. Returns number of cycles it took for PLL to stabilize after reset
393  or zero if PLL haven't stabilized in 65535 cycles */
394 template< typename SPI_SS, typename INTR >
396  uint16_t i = 0;
397  regWr(rUSBCTL, bmCHIPRES);
398  regWr(rUSBCTL, 0x00);
399  while(++i) {
400  if((regRd(rUSBIRQ) & bmOSCOKIRQ)) {
401  break;
402  }
403  }
404  return ( i);
405 }
406 
407 /* initialize MAX3421E. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not */
408 template< typename SPI_SS, typename INTR >
411  // Moved here.
412  // you really should not init hardware in the constructor when it involves locks.
413  // Also avoids the vbus flicker issue confusing some devices.
414  /* pin and peripheral setup */
415  SPI_SS::SetDirWrite();
416  SPI_SS::Set();
417  spi::init();
418  INTR::SetDirRead();
420  /* MAX3421E - full-duplex SPI, level interrupt */
421  // GPX pin on. Moved here, otherwise we flicker the vbus.
422  regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL));
423 
424  if(reset() == 0) { //OSCOKIRQ hasn't asserted in time
425  return ( -1);
426  }
427 
428  regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host
429 
430  regWr(rHIEN, bmCONDETIE | bmFRAMEIE); //connection detection
431 
432  /* check if device is connected */
433  regWr(rHCTL, bmSAMPLEBUS); // sample USB bus
434  while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish
435 
436  busprobe(); //check if anything is connected
437 
438  regWr(rHIRQ, bmCONDETIRQ); //clear connection detect interrupt
439  regWr(rCPUCTL, 0x01); //enable interrupt pin
440 
441  return ( 0);
442 }
443 
444 /* initialize MAX3421E. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not */
445 template< typename SPI_SS, typename INTR >
446 int8_t MAX3421e< SPI_SS, INTR >::Init(int mseconds) {
448  // Moved here.
449  // you really should not init hardware in the constructor when it involves locks.
450  // Also avoids the vbus flicker issue confusing some devices.
451  /* pin and peripheral setup */
452  SPI_SS::SetDirWrite();
453  SPI_SS::Set();
454  spi::init();
455  INTR::SetDirRead();
457  /* MAX3421E - full-duplex SPI, level interrupt, vbus off */
458  regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | GPX_VBDET));
459 
460  if(reset() == 0) { //OSCOKIRQ hasn't asserted in time
461  return ( -1);
462  }
463 
464  // Delay a minimum of 1 second to ensure any capacitors are drained.
465  // 1 second is required to make sure we do not smoke a Microdrive!
466  if(mseconds < 1000) mseconds = 1000;
467  delay(mseconds);
468 
469  regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host
470 
471  regWr(rHIEN, bmCONDETIE | bmFRAMEIE); //connection detection
472 
473  /* check if device is connected */
474  regWr(rHCTL, bmSAMPLEBUS); // sample USB bus
475  while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish
476 
477  busprobe(); //check if anything is connected
478 
479  regWr(rHIRQ, bmCONDETIRQ); //clear connection detect interrupt
480  regWr(rCPUCTL, 0x01); //enable interrupt pin
481 
482  // GPX pin on. This is done here so that busprobe will fail if we have a switch connected.
483  regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL));
484 
485  return ( 0);
486 }
487 
488 /* probe bus to determine device presence and speed and switch host to this speed */
489 template< typename SPI_SS, typename INTR >
491  uint8_t bus_sample;
492  bus_sample = regRd(rHRSL); //Get J,K status
493  bus_sample &= (bmJSTATUS | bmKSTATUS); //zero the rest of the byte
494  switch(bus_sample) { //start full-speed or low-speed host
495  case( bmJSTATUS):
496  if((regRd(rMODE) & bmLOWSPEED) == 0) {
497  regWr(rMODE, MODE_FS_HOST); //start full-speed host
498  vbusState = FSHOST;
499  } else {
500  regWr(rMODE, MODE_LS_HOST); //start low-speed host
501  vbusState = LSHOST;
502  }
503  break;
504  case( bmKSTATUS):
505  if((regRd(rMODE) & bmLOWSPEED) == 0) {
506  regWr(rMODE, MODE_LS_HOST); //start low-speed host
507  vbusState = LSHOST;
508  } else {
509  regWr(rMODE, MODE_FS_HOST); //start full-speed host
510  vbusState = FSHOST;
511  }
512  break;
513  case( bmSE1): //illegal state
514  vbusState = SE1;
515  break;
516  case( bmSE0): //disconnected state
517  regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST | bmSEPIRQ);
518  vbusState = SE0;
519  break;
520  }//end switch( bus_sample )
521 }
522 
523 /* MAX3421 state change task and interrupt handler */
524 template< typename SPI_SS, typename INTR >
526  uint8_t rcode = 0;
527  uint8_t pinvalue;
528  //USB_HOST_SERIAL.print("Vbus state: ");
529  //USB_HOST_SERIAL.println( vbusState, HEX );
530  pinvalue = INTR::IsSet(); //Read();
531  //pinvalue = digitalRead( MAX_INT );
532  if(pinvalue == 0) {
533  rcode = IntHandler();
534  }
535  // pinvalue = digitalRead( MAX_GPX );
536  // if( pinvalue == LOW ) {
537  // GpxHandler();
538  // }
539  // usbSM(); //USB state machine
540  return ( rcode);
541 }
542 
543 template< typename SPI_SS, typename INTR >
545  uint8_t HIRQ;
546  uint8_t HIRQ_sendback = 0x00;
547  HIRQ = regRd(rHIRQ); //determine interrupt source
548  //if( HIRQ & bmFRAMEIRQ ) { //->1ms SOF interrupt handler
549  // HIRQ_sendback |= bmFRAMEIRQ;
550  //}//end FRAMEIRQ handling
551  if(HIRQ & bmCONDETIRQ) {
552  busprobe();
553  HIRQ_sendback |= bmCONDETIRQ;
554  }
555  /* End HIRQ interrupts handling, clear serviced IRQs */
556  regWr(rHIRQ, HIRQ_sendback);
557  return ( HIRQ_sendback);
558 }
559 //template< typename SPI_SS, typename INTR >
560 //uint8_t MAX3421e< SPI_SS, INTR >::GpxHandler()
561 //{
562 // uint8_t GPINIRQ = regRd( rGPINIRQ ); //read GPIN IRQ register
569 // return( GPINIRQ );
570 //}
571 
572 #endif // _USBHOST_H_
#define GPX_VBDET
Definition: max3421e.h:82
#define rIOPINS1
Definition: max3421e.h:88
void busprobe()
Definition: usbhost.h:490
#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:151
#define rCPUCTL
Definition: max3421e.h:67
#define bmJSTATUS
Definition: max3421e.h:209
uint16_t reset()
Definition: usbhost.h:395
#define MODE_LS_HOST
Definition: max3421e.h:232
#define bmINTLEVEL
Definition: max3421e.h:76
void gpioWr(uint8_t data)
Definition: usbhost.h:273
uint8_t Task()
Definition: usbhost.h:525
#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()
Definition: usbhost.h:384
int8_t Init()
Definition: usbhost.h:409
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:147
#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:321
#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:219
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:176
#define bmFRAMEIE
Definition: max3421e.h:164
uint8_t IntHandler()
Definition: usbhost.h:544
#define bmOSCOKIRQ
Definition: max3421e.h:54
uint8_t regRd(uint8_t reg)
Definition: usbhost.h:282
MAX3421e()
Definition: usbhost.h:165
#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