From f9301a6acf4290f56ffc28e7785a681655426fa2 Mon Sep 17 00:00:00 2001 From: jaretburkett Date: Thu, 13 Oct 2016 07:06:29 -0500 Subject: [PATCH] USB core and CDC fixes --- STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c | 4 ++-- STM32F1/cores/maple/libmaple/usb/usb_lib/usb_core.c | 9 +++------ STM32F1/system/libmaple/usb/usb_lib/usb_core.h | 5 ++++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c b/STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c index 679f3fb..ecdd0b4 100644 --- a/STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c +++ b/STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c @@ -451,7 +451,7 @@ uint32 usb_cdcacm_rx(uint8* buf, uint32 len) { /* If all bytes have been read, re-enable the RX endpoint, which * was set to NAK when the current batch of bytes was received. */ - if (n_unread_bytes <= (CDC_SERIAL_BUFFER_SIZE - USB_CDCACM_RX_EPSIZE)) { + if (n_unread_bytes == 0) { usb_set_ep_rx_count(USB_CDCACM_RX_ENDP, USB_CDCACM_RX_EPSIZE); usb_set_ep_rx_stat(USB_CDCACM_RX_ENDP, USB_EP_STAT_RX_VALID); } @@ -567,7 +567,7 @@ static void vcomDataRxCb(void) { n_unread_bytes += ep_rx_size; - if (n_unread_bytes <= (CDC_SERIAL_BUFFER_SIZE - USB_CDCACM_RX_EPSIZE)) { + if (n_unread_bytes == 0) { usb_set_ep_rx_count(USB_CDCACM_RX_ENDP, USB_CDCACM_RX_EPSIZE); usb_set_ep_rx_stat(USB_CDCACM_RX_ENDP, USB_EP_STAT_RX_VALID); } diff --git a/STM32F1/cores/maple/libmaple/usb/usb_lib/usb_core.c b/STM32F1/cores/maple/libmaple/usb/usb_lib/usb_core.c index 5cf9e87..38cfa3e 100644 --- a/STM32F1/cores/maple/libmaple/usb/usb_lib/usb_core.c +++ b/STM32F1/cores/maple/libmaple/usb/usb_lib/usb_core.c @@ -31,9 +31,6 @@ #define USB_StatusIn() Send0LengthData() #define USB_StatusOut() vSetEPRxStatus(EP_RX_VALID) -#define StatusInfo0 StatusInfo.bw.bb1 /* Reverse bb0 & bb1 */ -#define StatusInfo1 StatusInfo.bw.bb0 - /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ u16_u8 StatusInfo; @@ -857,11 +854,11 @@ u8 Setup0_Process(void) pInformation->USBbmRequestType = *pBuf.b++; /* bmRequestType */ pInformation->USBbRequest = *pBuf.b++; /* bRequest */ pBuf.w++; /* word not accessed because of 32 bits addressing */ - pInformation->USBwValue = ByteSwap(*pBuf.w++); /* wValue */ + pInformation->USBwValue = *pBuf.w++; /* wValue in Little Endian */ pBuf.w++; /* word not accessed because of 32 bits addressing */ - pInformation->USBwIndex = ByteSwap(*pBuf.w++); /* wIndex */ + pInformation->USBwIndex = *pBuf.w++; /* wIndex in Little Endian */ pBuf.w++; /* word not accessed because of 32 bits addressing */ - pInformation->USBwLength = *pBuf.w; /* wLength */ + pInformation->USBwLength = *pBuf.w; /* wLength in Little Endian */ } pInformation->ControlState = SETTING_UP; diff --git a/STM32F1/system/libmaple/usb/usb_lib/usb_core.h b/STM32F1/system/libmaple/usb/usb_lib/usb_core.h index fa29a18..cb8c21e 100644 --- a/STM32F1/system/libmaple/usb/usb_lib/usb_core.h +++ b/STM32F1/system/libmaple/usb/usb_lib/usb_core.h @@ -101,8 +101,9 @@ typedef union u16 w; struct BW { - u8 bb1; + /* Little Endian */ u8 bb0; + u8 bb1; } bw; } u16_u8; @@ -211,6 +212,8 @@ USER_STANDARD_REQUESTS; #define USBwLength USBwLengths.w #define USBwLength0 USBwLengths.bw.bb0 #define USBwLength1 USBwLengths.bw.bb1 +#define StatusInfo0 StatusInfo.bw.bb0 +#define StatusInfo1 StatusInfo.bw.bb1 /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */