diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2009-06-05 10:51:18 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2009-06-05 10:51:18 +0100 |
commit | b6a6509532c756f1ef2c41fbe1fc3c777e1d710d (patch) | |
tree | 696f37ad7b662cb70de1aaff09c8d54ca33f1897 | |
parent | e7c94ad7b663b1ee720ce7c0aa4328079cbdc338 (diff) | |
download | stm32-virtcomport-b6a6509532c756f1ef2c41fbe1fc3c777e1d710d.tar.bz2 |
-rw-r--r-- | hw_config.c | 3 | ||||
-rw-r--r-- | main.c | 15 | ||||
-rw-r--r-- | usb_endp.c | 3 |
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); } /******************************************************************************* @@ -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); } } } @@ -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****/ |