From 5daa359bd3c3840320fa08a6a45a26bf2ff3216a Mon Sep 17 00:00:00 2001 From: Ilya Bakulin Date: Mon, 23 Jan 2012 05:32:51 +0400 Subject: [PATCH 1/3] - Added support for Arduino Mega ADK board. --- Usb.h | 5 +++-- usbhost.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Usb.h b/Usb.h index 341c1368..7e9113fb 100644 --- a/Usb.h +++ b/Usb.h @@ -50,7 +50,8 @@ e-mail : support@circuitsathome.com #ifdef BOARD_BLACK_WIDDOW typedef MAX3421e MAX3421E; // Black Widow #else -typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560 +//typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560 +typedef MAX3421e MAX3421E; // Arduino Mega ADK #endif //Debug macros. In 1.0 it is possible to move strings to PROGMEM by defining USBTRACE (Serial.print(F(s))) @@ -272,4 +273,4 @@ inline uint8_t USB::setConf( uint8_t addr, uint8_t ep, uint8_t conf_value ) #endif // defined(USB_METHODS_INLINE) -#endif //_usb_h_ \ No newline at end of file +#endif //_usb_h_ diff --git a/usbhost.h b/usbhost.h index 264b317a..b86101e8 100644 --- a/usbhost.h +++ b/usbhost.h @@ -86,6 +86,10 @@ MAX3421e< SS, INTR >::MAX3421e() SS::Set(); spi::init(); INTR::SetDirRead(); + + /* For Mega ADK, which has Max3421e on-board, set MAX_RESET to Output mode, and pull Reset to HIGH */ + DDRJ |= 0x04; + PORTJ |= 0x04; /* MAX3421E - full-duplex SPI, level interrupt */ regWr( rPINCTL,( bmFDUPSPI + bmINTLEVEL )); From 79668d97ea02d49ca9a20d6e98b9f044e6040c13 Mon Sep 17 00:00:00 2001 From: Ilya Bakulin Date: Mon, 23 Jan 2012 12:19:39 +0400 Subject: [PATCH 2/3] - Create conditional define BOARD_MEGA_ADK and move it into avrpins.h, which seems like a most suitable place for such things; - Added pin define for Pj2; - Use newly created BOARD_MEGA_ADK #define for separating Mega ADK-specific code from the common code. --- Usb.h | 5 +++-- avrpins.h | 4 ++++ usbhost.h | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Usb.h b/Usb.h index 7e9113fb..9432b4b0 100644 --- a/Usb.h +++ b/Usb.h @@ -49,9 +49,10 @@ e-mail : support@circuitsathome.com #ifdef BOARD_BLACK_WIDDOW typedef MAX3421e MAX3421E; // Black Widow +#elif defined(BOARD_MEGA_ADK) +typedef MAX3421e MAX3421E; // Arduino Mega ADK #else -//typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560 -typedef MAX3421e MAX3421E; // Arduino Mega ADK +typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560 #endif //Debug macros. In 1.0 it is possible to move strings to PROGMEM by defining USBTRACE (Serial.print(F(s))) diff --git a/avrpins.h b/avrpins.h index 99e10776..d2297a6b 100644 --- a/avrpins.h +++ b/avrpins.h @@ -20,6 +20,9 @@ e-mail : support@circuitsathome.com #ifndef _avrpins_h_ #define _avrpins_h_ +/* Uncomment the following if you have Arduino Mega ADK board with MAX3421e built-in */ +#define BOARD_MEGA_ADK + #include #ifdef PORTA @@ -465,6 +468,7 @@ template #define P51 Pb2 #define P52 Pb1 #define P53 Pb0 +#define P54 Pj2 #endif //"Mega" pin numbers diff --git a/usbhost.h b/usbhost.h index b86101e8..a94b42e1 100644 --- a/usbhost.h +++ b/usbhost.h @@ -86,10 +86,12 @@ MAX3421e< SS, INTR >::MAX3421e() SS::Set(); spi::init(); INTR::SetDirRead(); - + +#ifdef BOARD_MEGA_ADK /* For Mega ADK, which has Max3421e on-board, set MAX_RESET to Output mode, and pull Reset to HIGH */ DDRJ |= 0x04; PORTJ |= 0x04; +#endif /* MAX3421E - full-duplex SPI, level interrupt */ regWr( rPINCTL,( bmFDUPSPI + bmINTLEVEL )); From d973575908927d0264d18b9295a0f46a1abf4b7e Mon Sep 17 00:00:00 2001 From: Ilya Bakulin Date: Mon, 23 Jan 2012 12:23:59 +0400 Subject: [PATCH 3/3] - Switch off Mega ADK by default. --- avrpins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avrpins.h b/avrpins.h index d2297a6b..eb999a98 100644 --- a/avrpins.h +++ b/avrpins.h @@ -21,7 +21,7 @@ e-mail : support@circuitsathome.com #define _avrpins_h_ /* Uncomment the following if you have Arduino Mega ADK board with MAX3421e built-in */ -#define BOARD_MEGA_ADK +//#define BOARD_MEGA_ADK #include