How to transmit and receive data with USB Custom HID device?
I am using a custom board with a STM32F4. It seems that I can receive the data through this function that is called by interrupt and adding the pointer read_buffer, that I use inside the RxUSB() function to get the data and do the necessary operations on it.
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
read_buffer = pbuf;
hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size);
usb_status = USBD_Get_USB_Status(hal_status);
if(usb_status == USBD_OK)
RxUSB();
return usb_status;
}
Instead I transmit using in every point I need (for example in the functions that are in the Main) the function USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, ArrayTxUSB, CODA_USB);. It's not called by an interrupt.
The problem that I am seeing is that the communication stops to work soon and sometimes I can't even transmit. Maybe this is not the right way to trasmit and receive.
Could anyone help me? I'm stuck on this problem.
