Compilation Error with USB Keyboard Example on STM32 Nucleo F303K8 in Mbed

I've been trying to compile a simple USB Keyboard example for my STM32 Nucleo F303K8, following the guides from Mbed and Hackerspace NTNU. My main.cpp file is as follows:
#include "mbed.h"
#include "USBKeyboard.h"

USBKeyboard keyboard;

int main(void) {

while (1) {
wait(1);
keyboard.printf("Test");
}
}
#include "mbed.h"
#include "USBKeyboard.h"

USBKeyboard keyboard;

int main(void) {

while (1) {
wait(1);
keyboard.printf("Test");
}
}
However, when I try to compile, I encounter this error:
Error: Identifier "PCD_HandleTypeDef" is undefined in "USBDevice/USBDevice/USBHAL.h", Line: 134, Col: 6
Error: Identifier "PCD_HandleTypeDef" is undefined in "USBDevice/USBDevice/USBHAL.h", Line: 134, Col: 6
The error presents itself in both the Mbed Online Compiler and locally using the PlatformIO plugin for VSCode. Surprisingly, excluding the USBDevice library from Mbed allows successful compilation of code in both IDEs. Is there any information about why this occurrence is happening? Is it necessary for me to incorporate another library or dependency?
Solution:
Hey @Sterling The error you're encountering,
Identifier 'PCD_HandleTypeDef' is undefined,
Identifier 'PCD_HandleTypeDef' is undefined,
indicates that your USB Device library is missing necessary definitions for USB handling specific to your STM32 Nucleo F303K8. This kind of error usually occurs when the required USB HAL is not included or configured properly in your project. Inorder to resolve this,ensure that your USB support is correctly set up in your Mbed environment, as the STM32F3 series requires specific configurations.And secondly,if you are using the older version of Mbed, try to update it to the latest version....
Jump to solution
2 Replies
Solution
UC GEE
UC GEE3mo ago
Hey @Sterling The error you're encountering,
Identifier 'PCD_HandleTypeDef' is undefined,
Identifier 'PCD_HandleTypeDef' is undefined,
indicates that your USB Device library is missing necessary definitions for USB handling specific to your STM32 Nucleo F303K8. This kind of error usually occurs when the required USB HAL is not included or configured properly in your project. Inorder to resolve this,ensure that your USB support is correctly set up in your Mbed environment, as the STM32F3 series requires specific configurations.And secondly,if you are using the older version of Mbed, try to update it to the latest version.
Sterling
Sterling3mo ago
Alright man, I will get moving on this 🙏
Want results from more Discord servers?
Add your server