From 21ee4f0774db052b2f3fb22342c2e613c9a6055e Mon Sep 17 00:00:00 2001 From: Thibault RICHARD Date: Mon, 18 Jun 2012 18:59:09 +0200 Subject: [PATCH] [sam] enabling High Speed support for USB Device stack --- hardware/arduino/sam/cores/arduino/Arduino.h | 20 +++-- .../arduino/sam/cores/arduino/USB/CDC.cpp | 3 - .../arduino/sam/cores/arduino/USB/HID.cpp | 3 - .../arduino/sam/cores/arduino/USB/USBAPI.h | 5 +- .../arduino/sam/cores/arduino/USB/USBCore.cpp | 14 ++-- .../arduino/sam/cores/arduino/USB/USBCore.h | 1 - .../arduino/sam/cores/arduino/USB/USBDesc.h | 1 - hardware/arduino/sam/cores/arduino/main.cpp | 6 +- .../validation_usb_device/build_gcc/debug.mk | 2 +- .../build_gcc/test_usb_device.mk | 4 +- .../validation_usb_device/test_usb_device.cpp | 5 +- .../validation_usb_host/test_usb_host.cpp | 75 ++++++++---------- .../sam/system/libsam/source/uotghs_device.c | 33 ++++---- .../sam/system/libsam/source/uotghs_host.c | 36 ++++++--- .../arduino_due_x/libsam_sam3x8e_gcc_rel.a | Bin 86236 -> 87408 bytes .../libsam_sam3x8e_gcc_rel.a.txt | 2 + .../sam/variants/arduino_due_x/variant.h | 3 - 17 files changed, 98 insertions(+), 115 deletions(-) diff --git a/hardware/arduino/sam/cores/arduino/Arduino.h b/hardware/arduino/sam/cores/arduino/Arduino.h index 00b6715b1..ec4274ccb 100644 --- a/hardware/arduino/sam/cores/arduino/Arduino.h +++ b/hardware/arduino/sam/cores/arduino/Arduino.h @@ -194,6 +194,7 @@ extern const PinDescription g_APinDescription[] ; #include "HardwareSerial.h" #include "wiring_pulse.h" +// USB Host #include "Usb.h" #endif // __cplusplus @@ -201,16 +202,13 @@ extern const PinDescription g_APinDescription[] ; // Include board variant #include "variant.h" -#if defined USBCON - #define USB_VID 0x2341 // arduino LLC vid - - #define USB_PID_LEONARDO 0x0034 - #define USB_PID_MICRO 0x0035 - #define USB_PID_DUE 0x003E - - #include "USB/USBDesc.h" - #include "USB/USBCore.h" - #include "USB/USBAPI.h" -#endif // if defined USBCON +// USB Device +#define USB_VID 0x2341 // arduino LLC vid +#define USB_PID_LEONARDO 0x0034 +#define USB_PID_MICRO 0x0035 +#define USB_PID_DUE 0x003E +#include "USB/USBDesc.h" +#include "USB/USBCore.h" +#include "USB/USBAPI.h" #endif // Arduino_h diff --git a/hardware/arduino/sam/cores/arduino/USB/CDC.cpp b/hardware/arduino/sam/cores/arduino/USB/CDC.cpp index 8992a2e63..5c451a5c0 100644 --- a/hardware/arduino/sam/cores/arduino/USB/CDC.cpp +++ b/hardware/arduino/sam/cores/arduino/USB/CDC.cpp @@ -17,8 +17,6 @@ #include "Arduino.h" #include "USBAPI.h" -#if defined(USBCON) - #ifdef CDC_ENABLED #define CDC_SERIAL_BUFFER_SIZE 64 @@ -252,4 +250,3 @@ Serial_::operator bool() Serial_ Serial; #endif -#endif /* if defined(USBCON) */ diff --git a/hardware/arduino/sam/cores/arduino/USB/HID.cpp b/hardware/arduino/sam/cores/arduino/USB/HID.cpp index a02dbec8c..2a4e73b8c 100644 --- a/hardware/arduino/sam/cores/arduino/USB/HID.cpp +++ b/hardware/arduino/sam/cores/arduino/USB/HID.cpp @@ -16,7 +16,6 @@ #include "Arduino.h" -#if defined(USBCON) #ifdef HID_ENABLED //#define RAWHID_ENABLED @@ -509,5 +508,3 @@ size_t Keyboard_::write(uint8_t c) } #endif - -#endif /* if defined(USBCON) */ diff --git a/hardware/arduino/sam/cores/arduino/USB/USBAPI.h b/hardware/arduino/sam/cores/arduino/USB/USBAPI.h index b65d20bb8..592d3a0b1 100644 --- a/hardware/arduino/sam/cores/arduino/USB/USBAPI.h +++ b/hardware/arduino/sam/cores/arduino/USB/USBAPI.h @@ -19,7 +19,7 @@ #ifndef __USBAPI__ #define __USBAPI__ -#if defined __cplusplus && defined USBCON +#if defined __cplusplus #include "RingBuffer.h" @@ -214,5 +214,4 @@ void USBD_Flush(uint32_t ep); uint32_t USBD_Connected(void); #endif - -#endif /* if defined USBCON */ +#endif diff --git a/hardware/arduino/sam/cores/arduino/USB/USBCore.cpp b/hardware/arduino/sam/cores/arduino/USB/USBCore.cpp index 8a9d2410a..51bc6b92f 100644 --- a/hardware/arduino/sam/cores/arduino/USB/USBCore.cpp +++ b/hardware/arduino/sam/cores/arduino/USB/USBCore.cpp @@ -1,5 +1,3 @@ -#ifdef USBCON - /* Copyright (c) 2010, Peter Barrett ** ** Permission to use, copy, modify, and/or distribute this software for @@ -20,8 +18,8 @@ #include "USBAPI.h" #include -//#define TRACE_CORE(x) x -#define TRACE_CORE(x) +#define TRACE_CORE(x) x +//#define TRACE_CORE(x) static const uint32_t EndPoints[] = { @@ -212,14 +210,14 @@ int USBD_SendControl(uint8_t flags, const void* d, uint32_t len) uint32_t sent = 0; uint32_t pos = 0; - TRACE_CORE(printf("=> USBD_SendControl TOTAL len=%d\r\n", len);) + TRACE_CORE(printf("=> USBD_SendControl TOTAL len=%lu\r\n", len);) if (_cmark < _cend) { while (len > 0) { sent = UDD_Send(EP0, data + pos, len); - TRACE_CORE(printf("=> USBD_SendControl sent=%d\r\n", sent);) + TRACE_CORE(printf("=> USBD_SendControl sent=%lu\r\n", sent);) pos += sent; len -= sent; } @@ -540,7 +538,7 @@ uint32_t USBD_Connected(void) //======================================================================= //======================================================================= -//USB_ USB; +USB_ USB; USB_::USB_() { @@ -589,5 +587,3 @@ bool USB_::configured() void USB_::poll() { } - -#endif // USBCON diff --git a/hardware/arduino/sam/cores/arduino/USB/USBCore.h b/hardware/arduino/sam/cores/arduino/USB/USBCore.h index 68b18ff65..d4dac653e 100644 --- a/hardware/arduino/sam/cores/arduino/USB/USBCore.h +++ b/hardware/arduino/sam/cores/arduino/USB/USBCore.h @@ -301,5 +301,4 @@ _Pragma("pack()") #define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 } #define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 } - #endif diff --git a/hardware/arduino/sam/cores/arduino/USB/USBDesc.h b/hardware/arduino/sam/cores/arduino/USB/USBDesc.h index fb5895adf..275d4862e 100644 --- a/hardware/arduino/sam/cores/arduino/USB/USBDesc.h +++ b/hardware/arduino/sam/cores/arduino/USB/USBDesc.h @@ -60,4 +60,3 @@ #define IMANUFACTURER 1 #define IPRODUCT 2 - diff --git a/hardware/arduino/sam/cores/arduino/main.cpp b/hardware/arduino/sam/cores/arduino/main.cpp index 818679f18..69f25f2a5 100644 --- a/hardware/arduino/sam/cores/arduino/main.cpp +++ b/hardware/arduino/sam/cores/arduino/main.cpp @@ -39,9 +39,7 @@ int main( void ) delay(1); -#if defined(USBCON) - //USB.attach(); -#endif + USB.attach(); setup(); @@ -50,5 +48,5 @@ int main( void ) loop(); } -// return 0 ; + return 0; } diff --git a/hardware/arduino/sam/cores/arduino/validation_usb_device/build_gcc/debug.mk b/hardware/arduino/sam/cores/arduino/validation_usb_device/build_gcc/debug.mk index d0716744a..a3cc2337a 100644 --- a/hardware/arduino/sam/cores/arduino/validation_usb_device/build_gcc/debug.mk +++ b/hardware/arduino/sam/cores/arduino/validation_usb_device/build_gcc/debug.mk @@ -8,7 +8,7 @@ # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public diff --git a/hardware/arduino/sam/cores/arduino/validation_usb_device/build_gcc/test_usb_device.mk b/hardware/arduino/sam/cores/arduino/validation_usb_device/build_gcc/test_usb_device.mk index 1fdd9b12c..336bbc609 100644 --- a/hardware/arduino/sam/cores/arduino/validation_usb_device/build_gcc/test_usb_device.mk +++ b/hardware/arduino/sam/cores/arduino/validation_usb_device/build_gcc/test_usb_device.mk @@ -78,6 +78,7 @@ CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE) ARDUINO_CORE_PATH=$(PROJECT_BASE_PATH)/.. ARDUINO_USB_PATH=$(PROJECT_BASE_PATH)/../USB +ARDUINO_USB_HOST_PATH=$(PROJECT_BASE_PATH)/../../../system/USBHost # Output directories OUTPUT_PATH = debug_$(VARIANT) @@ -99,7 +100,8 @@ INCLUDES += -I$(SYSTEM_PATH)/libsam INCLUDES += -I$(CMSIS_ARM_PATH) INCLUDES += -I$(CMSIS_ATMEL_PATH) INCLUDES += -I$(CMSIS_CHIP_PATH) -INCLUDES += -I$(PROJECT_BASE_PATH)/../USB +INCLUDES += -I$(ARDUINO_USB_PATH) +INCLUDES += -I$(ARDUINO_USB_HOST_PATH) #------------------------------------------------------------------------------- ifdef DEBUG diff --git a/hardware/arduino/sam/cores/arduino/validation_usb_device/test_usb_device.cpp b/hardware/arduino/sam/cores/arduino/validation_usb_device/test_usb_device.cpp index 1b8fab7d5..e6c07c7e1 100644 --- a/hardware/arduino/sam/cores/arduino/validation_usb_device/test_usb_device.cpp +++ b/hardware/arduino/sam/cores/arduino/validation_usb_device/test_usb_device.cpp @@ -16,8 +16,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#if defined(USBCON) - #include "variant.h" #include @@ -36,7 +34,6 @@ void loop() { Serial.print(inChar); Serial1.print(inChar); } + delay(10); } - -#endif diff --git a/hardware/arduino/sam/cores/arduino/validation_usb_host/test_usb_host.cpp b/hardware/arduino/sam/cores/arduino/validation_usb_host/test_usb_host.cpp index 60583671b..a836acfd5 100644 --- a/hardware/arduino/sam/cores/arduino/validation_usb_host/test_usb_host.cpp +++ b/hardware/arduino/sam/cores/arduino/validation_usb_host/test_usb_host.cpp @@ -2,58 +2,49 @@ #include #include -class KbdRptParser : public KeyboardReportParser +class MouseRptParser : public MouseReportParser { - void PrintKey(uint8_t mod, uint8_t key); - protected: - virtual void OnKeyDown (uint8_t mod, uint8_t key); - virtual void OnKeyUp (uint8_t mod, uint8_t key); - virtual void OnKeyPressed(uint8_t key); + virtual void OnMouseMove (MOUSEINFO *mi); + virtual void OnLeftButtonUp (MOUSEINFO *mi); + virtual void OnLeftButtonDown (MOUSEINFO *mi); + virtual void OnRightButtonUp (MOUSEINFO *mi); + virtual void OnRightButtonDown (MOUSEINFO *mi); + virtual void OnMiddleButtonUp (MOUSEINFO *mi); + virtual void OnMiddleButtonDown (MOUSEINFO *mi); }; - -void KbdRptParser::PrintKey(uint8_t m, uint8_t key) +void MouseRptParser::OnMouseMove(MOUSEINFO *mi) { - MODIFIERKEYS mod; - - *((uint8_t*)&mod) = m; - printf((mod.bmLeftCtrl == 1) ? "C" : " "); - printf((mod.bmLeftShift == 1) ? "S" : " "); - printf((mod.bmLeftAlt == 1) ? "A" : " "); - printf((mod.bmLeftGUI == 1) ? "G" : " "); - - printf("<%c>", key); - - printf((mod.bmRightCtrl == 1) ? "C" : " "); - printf((mod.bmRightShift == 1) ? "S" : " "); - printf((mod.bmRightAlt == 1) ? "A" : " "); - printf((mod.bmRightGUI == 1) ? "G" : " "); + printf("Pos={%d,%d}\r\n", mi->dX, mi->dY); }; - -void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) +void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) { - printf("DN "); - PrintKey(mod, key); - uint8_t c = OemToAscii(mod, key); - - if (c) - OnKeyPressed(c); -} - -void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) + printf("L Butt Up\r\n"); +}; +void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) { - printf("UP "); - PrintKey(mod, key); -} - -void KbdRptParser::OnKeyPressed(uint8_t key) + printf("L Butt Dn\r\n"); +}; +void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) { - printf("ASCII: %c", key); + printf("R Butt Up\r\n"); +}; +void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi) +{ + printf("R Butt Dn\r\n"); +}; +void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi) +{ + printf("M Butt Up\r\n"); +}; +void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) +{ + printf("M Butt Dn\r\n"); }; USBHost Usb; -HIDBoot Kbd(&Usb); -KbdRptParser Prs; +HIDBoot HostMouse(&Usb); +MouseRptParser Prs; void setup() { @@ -61,7 +52,7 @@ void setup() printf("\r\nProgram started:\r\n"); delay(200); - Kbd.SetReportParser(0, (HIDReportParser*)&Prs); + HostMouse.SetReportParser(0,(HIDReportParser*)&Prs); } void loop() diff --git a/hardware/arduino/sam/system/libsam/source/uotghs_device.c b/hardware/arduino/sam/system/libsam/source/uotghs_device.c index 2f8bb881b..cf439a5d0 100644 --- a/hardware/arduino/sam/system/libsam/source/uotghs_device.c +++ b/hardware/arduino/sam/system/libsam/source/uotghs_device.c @@ -32,8 +32,8 @@ #if SAM3XA_SERIES -//#define TRACE_UOTGHS(x) x -#define TRACE_UOTGHS(x) +#define TRACE_UOTGHS_DEVICE(x) x +//#define TRACE_UOTGHS_DEVICE(x) extern void (*gpf_isr)(void); @@ -83,8 +83,9 @@ uint32_t UDD_Init(void) //while (!Is_otg_clock_usable()) // ; + // Enable High Speed udd_low_speed_disable(); - udd_high_speed_disable(); + udd_high_speed_enable(); //otg_ack_vbus_transition(); // Force Vbus interrupt in case of Vbus always with a high level @@ -102,7 +103,7 @@ void UDD_Attach(void) { irqflags_t flags = cpu_irq_save(); - TRACE_UOTGHS(printf("=> UDD_Attach\r\n");) + TRACE_UOTGHS_DEVICE(printf("=> UDD_Attach\r\n");) otg_unfreeze_clock(); @@ -121,7 +122,7 @@ void UDD_Attach(void) void UDD_Detach(void) { - TRACE_UOTGHS(printf("=> UDD_Detach\r\n");) + TRACE_UOTGHS_DEVICE(printf("=> UDD_Detach\r\n");) UOTGHS->UOTGHS_DEVCTRL |= UOTGHS_DEVCTRL_DETACH; } @@ -129,7 +130,7 @@ void UDD_InitEP( uint32_t ul_ep_nb, uint32_t ul_ep_cfg ) { ul_ep_nb = ul_ep_nb & 0xF; // EP range is 0..9, hence mask is 0xF. - TRACE_UOTGHS(printf("=> UDD_InitEP : init EP %d\r\n", ul_ep_nb);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_InitEP : init EP %lu\r\n", ul_ep_nb);) // Configure EP UOTGHS->UOTGHS_DEVEPTCFG[ul_ep_nb] = ul_ep_cfg; @@ -137,7 +138,7 @@ void UDD_InitEP( uint32_t ul_ep_nb, uint32_t ul_ep_cfg ) udd_enable_endpoint(ul_ep_nb); if (!Is_udd_endpoint_configured(ul_ep_nb)) { - TRACE_UOTGHS(printf("=> UDD_InitEP : ERROR FAILED TO INIT EP %d\r\n", ul_ep_nb);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_InitEP : ERROR FAILED TO INIT EP %lu\r\n", ul_ep_nb);) } } @@ -154,7 +155,7 @@ void UDD_InitEndpoints(const uint32_t* eps_table, const uint32_t ul_eps_table_si udd_enable_endpoint(ul_ep_nb); if (!Is_udd_endpoint_configured(ul_ep_nb)) { - TRACE_UOTGHS(printf("=> UDD_InitEP : ERROR FAILED TO INIT EP %d\r\n", ul_ep_nb);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_InitEP : ERROR FAILED TO INIT EP %lu\r\n", ul_ep_nb);) } } } @@ -175,7 +176,7 @@ void UDD_WaitOUT(void) // Send packet. void UDD_ClearIN(void) { - TRACE_UOTGHS(printf("=> UDD_ClearIN: sent %d bytes\r\n", ul_send_fifo_ptr[EP0]);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_ClearIN: sent %lu bytes\r\n", ul_send_fifo_ptr[EP0]);) UOTGHS->UOTGHS_DEVEPTICR[EP0] = UOTGHS_DEVEPTICR_TXINIC; ul_send_fifo_ptr[EP0] = 0; @@ -212,7 +213,7 @@ uint32_t UDD_Send(uint32_t ep, const void* data, uint32_t len) uint8_t *ptr_dest = (uint8_t *) &udd_get_endpoint_fifo_access8(ep); uint32_t i; - TRACE_UOTGHS(printf("=> UDD_Send (1): ep=%d ul_send_fifo_ptr=%d len=%d\r\n", ep, ul_send_fifo_ptr[ep], len);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_Send (1): ep=%lu ul_send_fifo_ptr=%lu len=%lu\r\n", ep, ul_send_fifo_ptr[ep], len);) if (ep == EP0) { @@ -233,7 +234,7 @@ uint32_t UDD_Send(uint32_t ep, const void* data, uint32_t len) if (ep == EP0) { - TRACE_UOTGHS(printf("=> UDD_Send (2): ep=%d ptr_dest=%d maxlen=%d\r\n", ep, ul_send_fifo_ptr[ep], EP0_SIZE);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_Send (2): ep=%lu ptr_dest=%lu maxlen=%d\r\n", ep, ul_send_fifo_ptr[ep], EP0_SIZE);) if (ul_send_fifo_ptr[ep] == EP0_SIZE) { UDD_ClearIN(); // Fifo is full, release this packet @@ -256,7 +257,7 @@ void UDD_Send8(uint32_t ep, uint8_t data ) { uint8_t *ptr_dest = (uint8_t *) &udd_get_endpoint_fifo_access8(ep); - TRACE_UOTGHS(printf("=> UDD_Send8 : ul_send_fifo_ptr=%d data=0x%x\r\n", ul_send_fifo_ptr[ep], data);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_Send8 : ul_send_fifo_ptr=%lu data=0x%x\r\n", ul_send_fifo_ptr[ep], data);) ptr_dest[ul_send_fifo_ptr[ep]] = data; ul_send_fifo_ptr[ep] += 1; @@ -267,7 +268,7 @@ uint8_t UDD_Recv8(uint32_t ep) uint8_t *ptr_dest = (uint8_t *) &udd_get_endpoint_fifo_access8(ep); uint8_t data = ptr_dest[ul_recv_fifo_ptr[ep]]; - TRACE_UOTGHS(printf("=> UDD_Recv8 : ul_recv_fifo_ptr=%d\r\n", ul_recv_fifo_ptr[ep]);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_Recv8 : ul_recv_fifo_ptr=%lu\r\n", ul_recv_fifo_ptr[ep]);) ul_recv_fifo_ptr[ep] += 1; return data; @@ -299,7 +300,7 @@ uint32_t UDD_FifoByteCount(uint32_t ep) void UDD_ReleaseRX(uint32_t ep) { - TRACE_UOTGHS(puts("=> UDD_ReleaseRX\r\n");) + TRACE_UOTGHS_DEVICE(puts("=> UDD_ReleaseRX\r\n");) UOTGHS->UOTGHS_DEVEPTICR[ep] = (UOTGHS_DEVEPTICR_NAKOUTIC | UOTGHS_DEVEPTICR_RXOUTIC); UOTGHS->UOTGHS_DEVEPTIDR[ep] = UOTGHS_DEVEPTIDR_FIFOCONC; ul_recv_fifo_ptr[ep] = 0; @@ -307,7 +308,7 @@ void UDD_ReleaseRX(uint32_t ep) void UDD_ReleaseTX(uint32_t ep) { - TRACE_UOTGHS(printf("=> UDD_ReleaseTX ep=%d\r\n", ep);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_ReleaseTX ep=%lu\r\n", ep);) UOTGHS->UOTGHS_DEVEPTICR[ep] = (UOTGHS_DEVEPTICR_NAKINIC | UOTGHS_DEVEPTICR_RXOUTIC | UOTGHS_DEVEPTICR_TXINIC); UOTGHS->UOTGHS_DEVEPTIDR[ep] = UOTGHS_DEVEPTIDR_FIFOCONC; ul_send_fifo_ptr[ep] = 0; @@ -321,7 +322,7 @@ uint32_t UDD_ReadWriteAllowed(uint32_t ep) void UDD_SetAddress(uint32_t addr) { - TRACE_UOTGHS(printf("=> UDD_SetAddress : setting address to %d\r\n", addr);) + TRACE_UOTGHS_DEVICE(printf("=> UDD_SetAddress : setting address to %lu\r\n", addr);) udd_configure_address(addr); udd_enable_address(); diff --git a/hardware/arduino/sam/system/libsam/source/uotghs_host.c b/hardware/arduino/sam/system/libsam/source/uotghs_host.c index 1090c774d..64b75a8ca 100644 --- a/hardware/arduino/sam/system/libsam/source/uotghs_host.c +++ b/hardware/arduino/sam/system/libsam/source/uotghs_host.c @@ -32,8 +32,8 @@ #if SAM3XA_SERIES -#define TRACE_UOTGHS(x) x -//#define TRACE_UOTGHS(x) +#define TRACE_UOTGHS_HOST(x) x +//#define TRACE_UOTGHS_HOST(x) extern void (*gpf_isr)(void); @@ -43,7 +43,7 @@ static void UHD_ISR(void) { // Manage dis/connection event if (Is_uhd_disconnection() && Is_uhd_disconnection_int_enabled()) { - TRACE_UOTGHS(printf(">>> UHD_ISR : Disconnection INT\r\n");) + TRACE_UOTGHS_HOST(printf(">>> UHD_ISR : Disconnection INT\r\n");) uhd_ack_disconnection(); uhd_disable_disconnection_int(); // Stop reset signal, in case of disconnection during reset @@ -59,7 +59,7 @@ static void UHD_ISR(void) return; } if (Is_uhd_connection() && Is_uhd_connection_int_enabled()) { - TRACE_UOTGHS(printf(">>> UHD_ISR : Connection INT\r\n");) + TRACE_UOTGHS_HOST(printf(">>> UHD_ISR : Connection INT\r\n");) uhd_ack_connection(); uhd_disable_connection_int(); uhd_ack_disconnection(); @@ -72,7 +72,7 @@ static void UHD_ISR(void) // Manage Vbus error if (Is_uhd_vbus_error_interrupt()) { - TRACE_UOTGHS(printf(">>> UHD_ISR : VBUS error INT\r\n");) + TRACE_UOTGHS_HOST(printf(">>> UHD_ISR : VBUS error INT\r\n");) uhd_ack_vbus_error_interrupt(); uhd_state = UHD_STATE_ERROR; return; @@ -89,23 +89,23 @@ static void UHD_ISR(void) otg_ack_vbus_transition(); if (Is_otg_vbus_high()) { - TRACE_UOTGHS(printf(">>> UHD_ISR : VBUS transition INT : UHD_STATE_DISCONNECT\r\n");) + TRACE_UOTGHS_HOST(printf(">>> UHD_ISR : VBUS transition INT : UHD_STATE_DISCONNECT\r\n");) uhd_state = UHD_STATE_DISCONNECTED; } else { - TRACE_UOTGHS(printf(">>> UHD_ISR : VBUS transition INT : UHD_STATE_NO_VBUS\r\n");) + TRACE_UOTGHS_HOST(printf(">>> UHD_ISR : VBUS transition INT : UHD_STATE_NO_VBUS\r\n");) otg_freeze_clock(); uhd_state = UHD_STATE_NO_VBUS; } - TRACE_UOTGHS(printf(">>> UHD_ISR : VBUS transition INT : done.\r\n");) + TRACE_UOTGHS_HOST(printf(">>> UHD_ISR : VBUS transition INT : done.\r\n");) return; } // Other errors if (Is_uhd_errors_interrupt()) { - TRACE_UOTGHS(printf(">>> UHD_ISR : Other error INT\r\n");) + TRACE_UOTGHS_HOST(printf(">>> UHD_ISR : Other error INT\r\n");) uhd_ack_errors_interrupt(); return; } @@ -228,7 +228,7 @@ uint32_t UHD_EP0_Alloc(uint32_t ul_add, uint32_t ul_ep_size) { if (ul_ep_size < 8) { - TRACE_UOTGHS(printf("/!\\ UHD_EP0_Alloc : incorrect pipe size!\r\n");) + TRACE_UOTGHS_HOST(printf("/!\\ UHD_EP0_Alloc : incorrect pipe size!\r\n");) return 1; } @@ -251,7 +251,7 @@ uint32_t UHD_EP0_Alloc(uint32_t ul_add, uint32_t ul_ep_size) if (!Is_uhd_pipe_configured(0)) { - TRACE_UOTGHS(printf("/!\\ UHD_EP0_Alloc : incorrect pipe settings!\r\n");) + TRACE_UOTGHS_HOST(printf("/!\\ UHD_EP0_Alloc : incorrect pipe settings!\r\n");) uhd_disable_pipe(0); return 1; } @@ -264,11 +264,21 @@ uint32_t UHD_EP0_Alloc(uint32_t ul_add, uint32_t ul_ep_size) /** * \brief Allocate FIFO for the specified pipe. * + * \param ul_add Address of remote device for pipe 0. + * \param ul_ep_size Actual size of the FIFO in bytes. + * * \retval 0 success. * \retval 1 error. */ uint32_t UHD_EP_Alloc(uint32_t ul_pipe, uint32_t ul_addr, uint32_t ul_interval, uint32_t ul_type, uint32_t ul_dir, uint32_t ul_maxsize, uint32_t ul_bank) { + +/* + * Warning: this is a first implementation, pipe allocation is very limited. + * We should probably check maxsize and if maxsize > current size, then realloc with maxsize. + * If pipe type is changed, a pipe reset and re-configuration is required. + */ + if (Is_uhd_pipe_enabled(ul_pipe)) { // Pipe is already allocated @@ -355,7 +365,7 @@ void UHD_EP_Write(uint32_t ul_ep, uint32_t ul_size, uint8_t* data) if (!Is_uhd_pipe_enabled(ul_ep)) { // Endpoint not valid - TRACE_UOTGHS(printf("/!\\ UHD_EP_Send : pipe is not enabled!\r\n");) + TRACE_UOTGHS_HOST(printf("/!\\ UHD_EP_Send : pipe is not enabled!\r\n");) return; } @@ -370,7 +380,7 @@ void UHD_EP_Send(uint32_t ul_ep, uint32_t ul_token_type) if (!Is_uhd_pipe_enabled(ul_ep)) { // Endpoint not valid - TRACE_UOTGHS(printf("/!\\ UHD_EP_Send : pipe %lu is not enabled!\r\n", ul_ep);) + TRACE_UOTGHS_HOST(printf("/!\\ UHD_EP_Send : pipe %lu is not enabled!\r\n", ul_ep);) return; } diff --git a/hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a b/hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a index 1a9194c141417260bde5d987aaaf7258f4aa13d8..ef35d08c604cd5393303eef3d17efd04ee4c096a 100644 GIT binary patch delta 4628 zcmb_geQZj;p7()o!l}Go|wbLkN8f%#f4QZ%EMp~#gZFDLn?bdZ#!zxWcrZyRkWK~nQbKZyj z{8ml-V>evidw%Eqe)rsS@3W2n{E~Lz73~j;(ra8Ucdfhng6$`4%r!^o|Js``6Z-${ zTPNzZ+sqkKLT>K-ZsWu+SKiXfDe?^s)HrdjRHsWtW~*kMGBWYn?&=cR;9diTuMQL~ zmw}0r!`ckl;7SggCK{jKmjL*EX`ui9kN&1YKK$v4beSZ^9RB%dCOOYq$g^&yf*vn>X+97I}#&NMlJOTezTk>To9gOA2J1dMcaR z*+dkUX6kJ{9c7YGJ~gu6TvxY_JHOJI_g*H!rmYbMCvg)O&*#%$P&?mHK;1DzKtE{- z55IBcUiUM^UKCvJ*9XRZ`oPUNaoWEa+j14gBJcZg)|3@!VZZ#KC=BRuQ82^)Z0TSw;7jQNsp)0^(_yveiX(3SP!cNRU`%(-2# z$$8Vn(%8_UD=^>s&eB*2vFDqJgPk+Q8EYnV>V9=g{Km3&G1?3MrZ+tfn|EC}%dcxa z<#Wfvo;8dhhEmLpbT|O)PVe;X_(9C{IKDu;CJw@DWHP%g$IE(m#;tl?Aj`kbJMP;F z;>`RtH?v4~FiSIeDH)w7u&;pw2F7OG(d;P_&`1 zZ#XnE0*Q=-q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>y~_e05CCSVhu%J1F<0?Ztip#G+i`kKRg799EMtTyMYv<1B|^c}2SqaaIBba^ ziF9M`$XMhrndAYJJZF)&i^^+rp5Bud`D-S5&?G-&k*7rf7uD~+U|E?mRvLd}S$RzP zW8T}dV9EHFDWh!4xMWd3OKK%`m(*k4?`4xZVp4x-Q7;=+IRxB!TwFciH$|oJLyyC2 zfnAb%AmRwq8AQ1{q7v=8W9UD_bS@}1edTB%yYMZKV;o@&a8v^UMkOWvqn66Y@zy>p zD2YRnx_CW`@E2w)QuZs8hngzWZh#Vg_YNKBPqwfrHpp2kyPef4eeF$dI^Sz!1GvzM zDr4twYx zI>2i~grJ2Vq%%0YG2Cpyo3&0>rOo{7ZR|E|=jk@)56c#|Y{@F~cZnV4Y%}vaqZW1) zbM6@l@sZ8gQ;?4lr^Ui)LC(dIP?qk?+Gqtltm=s2Cxceq(~Jl)wT?9~hKM#azTp}C zwlykViLe=Z(9-#<#pwWve|HO;$d0Iv4StQ*7hsWnJJg~RWR>8A9^Kahy5I}zd^eDQ?0L+t30X$0<-(-G8b`;>ZWWNkh zAo~@7D`dY4Fi7@3t#Hy&!K9lei$48G3l9L~$c_QXWD%#GAzmEqR=S|AS+z)bcyj8& m%!z}U$rDo@lef!qXP5quf%nlnvAvT$?^^#({P8X})9`PmdN6MQ diff --git a/hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a.txt b/hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a.txt index 86c0b679d..d4f904640 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a.txt +++ b/hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a.txt @@ -376,10 +376,12 @@ uotghs_device.o: 00000000 T UDD_WaitOUT U g_interrupt_enabled U gpf_isr + U iprintf U pmc_enable_periph_clk U pmc_enable_udpck U pmc_enable_upll_clock U pmc_switch_udpck_to_upllck + U puts 00000000 b ul_recv_fifo_ptr 00000000 b ul_send_fifo_ptr diff --git a/hardware/arduino/sam/variants/arduino_due_x/variant.h b/hardware/arduino/sam/variants/arduino_due_x/variant.h index 884a4d01f..faf354a42 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/variant.h +++ b/hardware/arduino/sam/variants/arduino_due_x/variant.h @@ -23,9 +23,6 @@ * Headers *----------------------------------------------------------------------------*/ -// We have native USB on this variant -#define USBCON - #include "Arduino.h" #ifdef __cplusplus #include "UARTClass.h"