From 01a1f8e65c018fb3b003d357eeb42165319fed33 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 21 Jun 2009 15:36:40 +0200 Subject: [PATCH] New USBGecko function to specify a retry count. --- gc/ogc/usbgecko.h | 4 ++++ libogc/usbgecko.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/gc/ogc/usbgecko.h b/gc/ogc/usbgecko.h index a74b995..d758b7f 100644 --- a/gc/ogc/usbgecko.h +++ b/gc/ogc/usbgecko.h @@ -13,6 +13,10 @@ int usb_recvbuffer(s32 chn,void *buffer,int size); int usb_sendbuffer(s32 chn,const void *buffer,int size); int usb_recvbuffer_safe(s32 chn,void *buffer,int size); int usb_sendbuffer_safe(s32 chn,const void *buffer,int size); +int usb_recvbuffer_ex(s32 chn,void *buffer,int size, int retries); +int usb_sendbuffer_ex(s32 chn,const void *buffer,int size, int retries); +int usb_recvbuffer_safe_ex(s32 chn,void *buffer,int size, int retries); +int usb_sendbuffer_safe_ex(s32 chn,const void *buffer,int size, int retries); #ifdef __cplusplus } diff --git a/libogc/usbgecko.c b/libogc/usbgecko.c index 653ad08..2654d4d 100644 --- a/libogc/usbgecko.c +++ b/libogc/usbgecko.c @@ -140,7 +140,7 @@ int usb_isgeckoalive(s32 chn) return ret; } -int usb_recvbuffer(s32 chn,void *buffer,int size) +int usb_recvbuffer_ex(s32 chn,void *buffer,int size, int retries) { s32 ret; s32 left = size; @@ -153,13 +153,23 @@ int usb_recvbuffer(s32 chn,void *buffer,int size) ptr++; left--; + + if (retries >= 0) { + retries--; + if (retries == 0) + break; + } } EXI_Unlock(chn); return (size - left); } -int usb_sendbuffer(s32 chn,const void *buffer,int size) +int usb_recvbuffer(s32 chn,void *buffer,int size) { + return usb_recvbuffer_ex(chn, buffer, size, -1); +} + +int usb_sendbuffer_ex(s32 chn,const void *buffer,int size, int retries) { s32 ret; s32 left = size; @@ -172,13 +182,23 @@ int usb_sendbuffer(s32 chn,const void *buffer,int size) ptr++; left--; + + if (retries >= 0) { + retries--; + if (retries == 0) + break; + } } EXI_Unlock(chn); return (size - left); } -int usb_recvbuffer_safe(s32 chn,void *buffer,int size) +int usb_sendbuffer(s32 chn,const void *buffer,int size) { + return usb_sendbuffer_ex(chn, buffer, size, -1); +} + +int usb_recvbuffer_safe_ex(s32 chn,void *buffer,int size, int retries) { s32 ret; s32 left = size; @@ -193,13 +213,23 @@ int usb_recvbuffer_safe(s32 chn,void *buffer,int size) ptr++; left--; } + + if (retries >= 0) { + retries--; + if (retries == 0) + break; + } } EXI_Unlock(chn); return (size - left); } -int usb_sendbuffer_safe(s32 chn,const void *buffer,int size) +int usb_recvbuffer_safe(s32 chn,void *buffer,int size) { + return usb_recvbuffer_safe_ex(chn, buffer, size, -1); +} + +int usb_sendbuffer_safe_ex(s32 chn,const void *buffer,int size, int retries) { s32 ret; s32 left = size; @@ -214,8 +244,20 @@ int usb_sendbuffer_safe(s32 chn,const void *buffer,int size) ptr++; left--; } + + if (retries >= 0) { + retries--; + if (retries == 0) + break; + } } EXI_Unlock(chn); return (size - left); } + +int usb_sendbuffer_safe(s32 chn,const void *buffer,int size) { + return usb_sendbuffer_safe_ex(chn, buffer, size, -1); +} + + -- 2.11.4.GIT