cancel
Showing results for 
Search instead for 
Did you mean: 

I have problems with buffers related to USB endpoints. It seems that data is placed in the wrong buffers or pointer offsets are wrong. I need help to find out what the problem is.

Annette1
Associate II

Custom HID class device based on the custom HID example.

What I need:

Control endpoint 0 IN

Control endpoint 0 OUT

endpoint 1 IN (0x81)

endpoint 2 OUT (0x02)

endpoint 3 IN (0x83)

endpoint 4 OUT (0x04)

Page 2012 in RM0440: “For this reason, a dedicated feature called ‘double-buffering’ can be used with bulk endpoints.

I want interrupt endpoints - not bulk endpoints. FS devices should support 64 bytes packets and this is what I transmit in my initial tests.

I have set USE_USB_DOUBLE_BUFFER to 0 in stm32g4xx_ll_usb.h.

I allocate 64 Bytes (0x40 bytes) to each endpoint buffer.

The attached files are outputs with different combinations of pmaadress and endpoints conififured as seen below for each output.

Output 1:

In usbd_conf.c, USBD_LL_Init() function I set the following:

  /* USER CODE BEGIN EndPoint_Configuration */

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);

 /* USER CODE END EndPoint_Configuration */

 /* USER CODE BEGIN EndPoint_Configuration_CUSTOM_HID */

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x02, PCD_SNG_BUF, 0x98);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x81, PCD_SNG_BUF, 0xD8);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x04, PCD_SNG_BUF, 0x118);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x83, PCD_SNG_BUF, 0x158);

 /* USER CODE END EndPoint_Configuration_CUSTOM_HID */

 

Output 2:

In usbd_conf.c, USBD_LL_Init() function I set the following:

  /* USER CODE BEGIN EndPoint_Configuration */

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);

 /* USER CODE END EndPoint_Configuration */

 /* USER CODE BEGIN EndPoint_Configuration_CUSTOM_HID */

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x81, PCD_SNG_BUF, 0x98);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x02, PCD_SNG_BUF, 0xD8);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x83, PCD_SNG_BUF, 0x118);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x04, PCD_SNG_BUF, 0x158);

 /* USER CODE END EndPoint_Configuration_CUSTOM_HID */

Output 3:

In usbd_conf.c, USBD_LL_Init() function I set the following:

 /* USER CODE BEGIN EndPoint_Configuration */

  HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);

 /* USER CODE END EndPoint_Configuration */

 /* USER CODE BEGIN EndPoint_Configuration_CUSTOM_HID */

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x82, PCD_SNG_BUF, 0x98);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x01, PCD_SNG_BUF, 0xD8);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x84, PCD_SNG_BUF, 0x118);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x03, PCD_SNG_BUF, 0x158);

 /* USER CODE END EndPoint_Configuration_CUSTOM_HID */

Output 4:

In usbd_conf.c, USBD_LL_Init() function I set the following:

 /* USER CODE BEGIN EndPoint_Configuration */

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);

 /* USER CODE END EndPoint_Configuration */

 /* USER CODE BEGIN EndPoint_Configuration_CUSTOM_HID */

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x01, PCD_SNG_BUF, 0x98);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x82, PCD_SNG_BUF, 0xD8);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x03, PCD_SNG_BUF, 0x118);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x84, PCD_SNG_BUF, 0x158);

 /* USER CODE END EndPoint_Configuration_CUSTOM_HID */

For output 1 and output 2:

Some buffers have incorrect data or buffer pointers are incorrect.

For output 3 and output 4:

Pipe error

1 REPLY 1
Piranha
Chief II