summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw_config.c3
-rw-r--r--main.c15
-rw-r--r--usb_endp.c3
3 files changed, 16 insertions, 5 deletions
diff --git a/hw_config.c b/hw_config.c
index e843c62..0e88f24 100644
--- a/hw_config.c
+++ b/hw_config.c
@@ -371,9 +371,6 @@ void USART_To_USB_Send_Data(void)
buffer_in[count_in] = USART_ReceiveData(ACTIVE_USART);
}
count_in++;
- UserToPMABufferCopy(buffer_in, ENDP1_TXADDR, count_in);
- SetEPTxCount(ENDP1, count_in);
- SetEPTxValid(ENDP1);
}
/*******************************************************************************
diff --git a/main.c b/main.c
index 0769f2d..6aaa856 100644
--- a/main.c
+++ b/main.c
@@ -27,6 +27,8 @@
/* Extern variables ----------------------------------------------------------*/
extern u32 count_out;
extern u8 buffer_out[VIRTUAL_COM_PORT_DATA_SIZE];
+extern u32 count_in;
+extern u8 buffer_in[VIRTUAL_COM_PORT_DATA_SIZE];
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
@@ -56,6 +58,19 @@ int main(void)
{
USB_To_USART_Send_Data(&buffer_out[0], count_out);
count_out = 0;
+ SetEPRxValid(ENDP3);
+ }
+ if ((count_in != 0) && (GetEPTxStatus(ENDP1) != EP_TX_VALID)) {
+ u32 count_copy;
+ /* Disable IRQs */
+ NVIC_SETPRIMASK();
+ count_copy = count_in;
+ UserToPMABufferCopy(buffer_in, ENDP1_TXADDR, count_copy);
+ count_in = 0;
+ NVIC_RESETPRIMASK();
+ /* IRQs are enabled once more */
+ SetEPTxCount(ENDP1, count_copy);
+ SetEPTxValid(ENDP1);
}
}
}
diff --git a/usb_endp.c b/usb_endp.c
index 56d3ac8..2c7d442 100644
--- a/usb_endp.c
+++ b/usb_endp.c
@@ -41,7 +41,6 @@ void EP3_OUT_Callback(void)
{
count_out = GetEPRxCount(ENDP3);
PMAToUserBufferCopy(buffer_out, ENDP3_RXADDR, count_out);
- SetEPRxValid(ENDP3);
}
/*******************************************************************************
@@ -53,7 +52,7 @@ void EP3_OUT_Callback(void)
*******************************************************************************/
void EP1_IN_Callback(void)
{
- count_in = 0;
+ /* Nothing to do here */
}
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/