thanks brucehoult, I'm using MounRiver, where can I find the thread and what should I do?
Also I could manage to send and received data in sram buffers, using Termite terminal to test it, But when I use brays terminal, it does not work and the terminal program would crash, I have investigated it and noticed that the brays terminal would send data 1 bye in a single endpoint, and when I try to input single characters into the termite, the Receive endpoint would not get the second character!!! I'm totally confused and out of Ideas,
Here are the modified parts of the code
I defined these in the main.c
#define BUFFER_SIZE 64
uint8_t UART_Rx_Buf[ 1024 ]; /* Serial port 2 receive data buffer */
uint8_t UART_Tx_Buf[ 1024 ]; /* Serial port 2 transmit data buffer */
uint16_t txBufferIndex = 0;
uint16_t rxBufferIndex = 0;
extern uint8_t USBD_Endp3_Busy;
I modified the usb_endp.c for EP2_OUT_Callback like this
void EP2_OUT_Callback (void)
{
uint32_t len;
len = GetEPRxCount(EP2_OUT & 0x7F);
PMAToUserBufferCopy(UART_Rx_Buf + rxBufferIndex, GetEPRxAddr(EP2_OUT & 0x7F), len);
rxBufferIndex += len;
SetEPRxValid(ENDP2);
}
this is the send function which is not working for more than 64 bytes for now and I do not know what has caused it
void send_data(uint8_t *buffer, uint16_t length)
{
while (length > 0) {
if (!USBD_Endp3_Busy) {
uint16_t len = (length > BUFFER_SIZE) ? BUFFER_SIZE : length;
USBD_ENDPx_DataUp(ENDP3, buffer, len);
buffer += len;
length -= len;
}
}
}
and this is the task2 body that would receive and answer some strings for testing
void task2_task(void *pvParameters)
{
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE );
RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2, ENABLE );
RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM2, ENABLE );
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_DMA1, ENABLE );
Set_USBConfig();
USB_Init();
USB_Interrupts_Config();
// Wait for USB to be configured
while (bDeviceState != CONFIGURED) {
vTaskDelay(10);
}
while(1)
{
// Send data if available
if (txBufferIndex > 0) {
send_data(UART_Tx_Buf, txBufferIndex);
txBufferIndex = 0;
}
// Receive data
//if (rxBufferIndex > 0) {
if(UART_Rx_Buf[0] =='N' && UART_Rx_Buf[1]== 'A' && UART_Rx_Buf[2]=='M'){
// Process received data
// Clear the buffer after processing
memset(UART_Rx_Buf, 0, sizeof(UART_Rx_Buf));
rxBufferIndex = 0;
// Copy received data to transmit buffer
memcpy(UART_Tx_Buf, "my name is ASiDeigner hello how are you? what do you do with this code and what's the plan? are you sure it's working? have you seen seasnon 2", 60);
txBufferIndex = 60;
}
else if(rxBufferIndex>10){
// Clear the buffer after processing
memset(UART_Rx_Buf, 0, sizeof(UART_Rx_Buf));
rxBufferIndex = 0;
memcpy(UART_Rx_Buf, "Error", 5);
txBufferIndex = 5;
}
vTaskDelay(1); // Delay to avoid flooding the terminal
}
}