From 448910a94ff1a0f870959eda59eb111b71bae3d4 Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Mon, 13 Feb 2017 02:55:24 -0800 Subject: [PATCH] Configurable periodic frame list size --- ehci.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ehci.cpp b/ehci.cpp index 013801b..8811bbb 100644 --- a/ehci.cpp +++ b/ehci.cpp @@ -24,7 +24,9 @@ #include #include "USBHost.h" -static uint32_t periodictable[32] __attribute__ ((aligned(4096), used)); +#define PERIODIC_LIST_SIZE 64 + +static uint32_t periodictable[PERIODIC_LIST_SIZE] __attribute__ ((aligned(4096), used)); static uint8_t port_state; #define PORT_STATE_DISCONNECTED 0 #define PORT_STATE_DEBOUNCE 1 @@ -131,7 +133,25 @@ void USBHost::begin() USBHS_ASYNCLISTADDR = 0; USBHS_USBCMD = USBHS_USBCMD_ITC(8) | USBHS_USBCMD_RS | USBHS_USBCMD_ASP(3) | USBHS_USBCMD_ASPE | - USBHS_USBCMD_FS2 | USBHS_USBCMD_FS(1); // periodic table is 32 pointers + #if PERIODIC_LIST_SIZE == 8 + USBHS_USBCMD_FS2 | USBHS_USBCMD_FS(3); + #elif PERIODIC_LIST_SIZE == 16 + USBHS_USBCMD_FS2 | USBHS_USBCMD_FS(2); + #elif PERIODIC_LIST_SIZE == 32 + USBHS_USBCMD_FS2 | USBHS_USBCMD_FS(1); + #elif PERIODIC_LIST_SIZE == 64 + USBHS_USBCMD_FS2 | USBHS_USBCMD_FS(0); + #elif PERIODIC_LIST_SIZE == 128 + USBHS_USBCMD_FS(3); + #elif PERIODIC_LIST_SIZE == 256 + USBHS_USBCMD_FS(2); + #elif PERIODIC_LIST_SIZE == 512 + USBHS_USBCMD_FS(1); + #elif PERIODIC_LIST_SIZE == 1024 + USBHS_USBCMD_FS(0); + #else + #error "Unsupported PERIODIC_LIST_SIZE" + #endif // turn on the USB port //USBHS_PORTSC1 = USBHS_PORTSC_PP; @@ -467,6 +487,8 @@ bool USBHost::queue_Data_Transfer(Pipe_t *pipe, void *buffer, uint32_t len, USBD uint32_t count; bool last = false; + // TODO: option for zero length packet? Maybe in Pipe_t fields? + Serial.println("new_Data_Transfer"); // allocate qTDs transfer = allocate_Transfer();