20 #if !defined(_usb_h_) || defined(_USBHOST_H_)
21 #error "Never include usbhost.h directly; include Usb.h instead"
26 template<
typename CLK,
typename MOSI,
typename MISO,
typename SPI_SS >
class SPi {
34 SPI_SS::SetDirWrite();
45 #if defined(__AVR_ATmega1280__) || (__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
47 #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
49 #elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
51 #elif defined(__MK20DX128__)
54 #error "No SPI entry in usbhost.h"
62 template<
typename SS,
typename INTR >
class MAX3421e {
63 static uint8_t vbusState;
67 void regWr(uint8_t reg, uint8_t data);
68 uint8_t*
bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
70 uint8_t
regRd(uint8_t reg);
71 uint8_t*
bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
75 int8_t
Init(
int mseconds);
90 template<
typename SS,
typename INTR >
94 template<
typename SS,
typename INTR >
105 template<
typename SS,
typename INTR >
110 while(!(SPSR & (1 << SPIF)));
112 while(!(SPSR & (1 << SPIF)));
120 template<
typename SS,
typename INTR >
126 while(!(SPSR & (1 << SPIF)));
130 while(!(SPSR & (1 << SPIF)));
139 template<
typename SS,
typename INTR >
148 template<
typename SS,
typename INTR >
153 while(!(SPSR & (1 << SPIF)));
155 while(!(SPSR & (1 << SPIF)));
164 template<
typename SS,
typename INTR >
169 while(!(SPSR & (1 << SPIF)));
173 while(!(SPSR & (1 << SPIF)));
177 printf(
"%2.2x ", *data_p);
193 template<
typename SS,
typename INTR >
204 template<
typename SS,
typename INTR >
218 template<
typename SS,
typename INTR >
255 template<
typename SS,
typename INTR >
276 if(mseconds < 1000) mseconds = 1000;
299 template<
typename SS,
typename INTR >
302 bus_sample = regRd(
rHRSL);
315 if((regRd(
rMODE) & bmLOWSPEED) == 0) {
334 template<
typename SS,
typename INTR >
340 pinvalue = INTR::IsSet();
343 rcode = IntHandler();
353 template<
typename SS,
typename INTR >
356 uint8_t HIRQ_sendback = 0x00;
366 regWr(
rHIRQ, HIRQ_sendback);
367 return( HIRQ_sendback);
void regWr(uint8_t reg, uint8_t data)
void gpioWr(uint8_t data)
#define XMEM_ACQUIRE_SPI()
void vbusPower(VBUS_t state)
uint8_t * bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
#define XMEM_RELEASE_SPI()
uint8_t * bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
uint8_t getVbusState(void)
uint8_t regRd(uint8_t reg)