[I can’t squeeze any more acronyms into this title]
It’s probably very easy to setup an STM32F4 as a virtual com port (VCP) with the CubeMX software, but I’m getting old and new tricks are getting increasingly hard to learn, so I did it with the standard peripherals library (SPL). Here’s how:
Download the STM32 SPL USB OTG host and device library.
Unzip to somewhere. It should give you a directory like this:
Download the USB CDC VCP Loopback firmware and place the zip-file in the above directory and unzip.
Set the HSE-frequency in:
Modify this file:
Specifically line 98. Change the declaration of *pIf_DataTx from
uint16_t (*pIf_DataTx) (void);
uint16_t (*pIf_DataTx) (uint8_t* Buf, uint32_t Len);
You will of course need the gcc-arm-none-eabi compiler, and put it in your path, so add a line similar to this to .bashrc:
(of course change “/home/user” and the version number).
After that it should simply be a matter of entering the directory of the firmware and typing make.
Let me know if it’s not working for you..
ps. I realize there’s a more straighth-forward example in the project-directory of USB library, but I just couldn’t get it working.