This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with USBD_HID_GetReportTrigger() with USB-HID for STM32L4P5 under Keil RTX4

Dear readers,

 

I’m developing a SW project with KEIL µVision V5.35 and the STM32CubeMX (V6.4) tool. The target processor is the STM32L4P5VETx and everything goes well until I added a USB device to the project.

 

Detail informations version are :

Informations from “Manage Run-Time Environment” are :

  • CMSIS Core V5.6.0
  • CMSIS Keil RTX V2.82.0
  • CMSIS Driver USB Device (API) V2.3.0
  • ARM Compiler V1.7.2
  • USB MD-Plus V6.15.0

Informations from “Select with Select Software Packs” are :

  • ARM::CMSIS V5.9.0
  • ARM::CMSIS-Driver V2.7.1
  • Keil::ARM_Compiler V1.7.2
  • Keil::MDK-Middleware V7.13.0
  • Keil::STM32L4xx_DFP V2.6.1

 

I join main.c file as well as extra configuration files (see extra files).  

 

I try to send USB HID frame with 0x2 as modifier (byte 0) and a F1 key (bye N°2 0x3A) to generate a SHIFT-F1 key to a USB HOST target (PC).

If I analyze with (Free Device Monitoring Studio), I view that USB stack send 2 frames and a first frame beginning with a 0 bye value (see LOG_Free_Device_Monitoring_Studio.txt file for detail information) .

 

The normal USB frame is :

0x02 0x00 0x3A 0x00 0x00 0x00 0x00 0x00

Result USB frames are :

0x00 0x02 0x00 0x3A 0x00 0x00 0x00 0x00

0x00

 

 

Do you have a way to analyze why Keil USB stack (USB_Dbg_CM3.LIB) is wrong with USBD_HID_GetReportTrigger() function ?

Is there is other version work better ?

 

Thanks, by advance for the support.

Gabriel GRANGE

Associated files with advanced information :

LOG_Free_Device_Monitoring_Studio.txt

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
000005: PnP Event: Device Connected (UP), 2022-06-21 14:55:42,1197503 +10,7110252 (1. Device: K-USB-Device)
The USB device has just been connected to the system.
000006: Get Descriptor Request (DOWN), 2022-06-21 14:55:42,1199180 +0,0001677 (1. Device: K-USB-Device)
Descriptor Type: Device
Descriptor Index: 0x0
Transfer Buffer Size: 0x12 bytes
000007: Control Transfer (UP), 2022-06-21 14:55:42,1203408 +0,0004228. (1. Device: K-USB-Device) Status: 0x00000000
Pipe Handle: Control Pipe
12 01 10 01 00 00 00 08 51 C2 00 00 00 01 01 02 ........QÂ......
03 01 ..
Setup Packet
80 06 00 01 00 00 12 00 €.......
Recipient: Device
Request Type: Standard
Direction: Device->Host
Request: 0x6 (GET_DESCRIPTOR)
Value: 0x100
Index: 0x0
Length: 0x12
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

main.c

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2022 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

RTX_Conf_CM.c

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*----------------------------------------------------------------------------
* CMSIS-RTOS - RTX
*----------------------------------------------------------------------------
* Name: RTX_Conf_CM.C
* Purpose: Configuration of CMSIS RTX Kernel for Cortex-M
* Rev.: V4.70.1
*----------------------------------------------------------------------------
*
* Copyright (c) 1999-2009 KEIL, 2009-2016 ARM Germany GmbH. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

STCubeGenerated.ioc

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#MicroXplorer Configuration settings - do not modify
File.Version=6
GPIO.groupedBy=
KeepUserPlacement=false
Mcu.Family=STM32L4
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=SYS
Mcu.IP3=USB_OTG_FS
Mcu.IPNb=4
Mcu.Name=STM32L4P5V(G-E)Tx
Mcu.Package=LQFP100
Mcu.Pin0=PC14-OSC32_IN (PC14)
Mcu.Pin1=PC15-OSC32_OUT (PC15)
Mcu.Pin10=PB4 (NJTRST)
Mcu.Pin11=VP_SYS_VS_tim6
Mcu.Pin2=PH0-OSC_IN (PH0)
Mcu.Pin3=PH1-OSC_OUT (PH1)
Mcu.Pin4=PA11
Mcu.Pin5=PA12
Mcu.Pin6=PA13 (JTMS/SWDIO)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

system_stm32l4xx.c

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
******************************************************************************
* @file system_stm32l4xx.c
* @author MCD Application Team
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File
*
* This file provides two functions and one global variable to be called from
* user application:
* - SystemInit(): This function is called at startup just after reset and
* before branch to main program. This call is made inside
* the "startup_stm32l4xx.s" file.
*
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
* by the user application to setup the SysTick
* timer or configure other parameters.
*
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
* be called whenever the core clock is changed
* during program execution.
*
* After each device reset the MSI (4 MHz) is used as system clock source.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

USB_Debug.c

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB
* Copyright (c) 2004-2019 Arm Limited (or its affiliates). All rights reserved.
*------------------------------------------------------------------------------
* Name: USB_Debug.c
* Purpose: USB Host/Device Debug Configuration
* Rev.: V1.0.0
*----------------------------------------------------------------------------*/
//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
// <e>USB Host Debug
// <i>Enable USB Host debugging with Event Recorder
#define USBH_DEBUG_EVR 1
// <o>Core <0=>Off <1=>Errors <2=>Errors + API <3=>All
// <i>Configure USB Host Core event recording
#define USBH_DEBUG_EVR_Core 3
// <o>Driver <0=>Off <1=>Errors <2=>Errors + API <3=>All
// <i>Configure USB Host Driver event recording
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

USBD_Config_0.c

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB:Device
* Copyright (c) 2004-2019 Arm Limited (or its affiliates). All rights reserved.
*------------------------------------------------------------------------------
* Name: USBD_Config_0.c
* Purpose: USB Device Configuration
* Rev.: V5.2.0
*------------------------------------------------------------------------------
* Use the following configuration settings in the Device Class configuration
* files to assign a Device Class to this USB Device 0.
*
* Configuration Setting Value
* --------------------- -----
* Assign Device Class to USB Device # = 0
*----------------------------------------------------------------------------*/
//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
// <h>USB Device 0
// <o>Connect to hardware via Driver_USBD# <0-255>
// <i>Select driver control block for hardware interface.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

USBD_Config_HID_0.h

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB:Device
* Copyright (c) 2004-2020 Arm Limited (or its affiliates). All rights reserved.
*------------------------------------------------------------------------------
* Name: USBD_Config_HID_0.h
* Purpose: USB Device Human Interface Device class (HID) Configuration
* Rev.: V5.0.2
*----------------------------------------------------------------------------*/
//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
// <h>USB Device: Human Interface Device class (HID) 0
// <o>Assign Device Class to USB Device # <0-3>
// <i>Select USB Device that is used for this Device Class instance
#define USBD_HID0_DEV 0
// <h>Interrupt Endpoint Settings
// <i>By default, the settings match the first USB Class instance in a USB Device.
// <i>Endpoint conflicts are flagged by compile-time error messages.
//
// <h>Interrupt IN Endpoint Settings
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

USBD_HID_Keyboard.c

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB:Device:HID
* Copyright (c) 2004-2020 Arm Limited (or its affiliates). All rights reserved.
*------------------------------------------------------------------------------
* Name: USBD_User_HID_Mouse_0.c
* Purpose: USB Device Human Interface Device class (HID) User module
* Rev.: V6.3.4
*----------------------------------------------------------------------------*/
/**
* \addtogroup usbd_hidFunctions
*
* USBD_User_HID_Mouse_0.c implements the application specific
* functionality of the HID class and is used to receive and send data reports
* to the USB Host.
*
* The implementation must match the configuration file USBD_Config_HID_0.h.
* The following values in USBD_Config_HID_0.h affect the user code:
*
* - 'Endpoint polling Interval' specifies the frequency of requests
* initiated by USB Host for \ref USBD_HIDn_GetReport.
*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

0