I am trying to compile an example code as below for DISCO-L053C8 on mbed-os 5.15.6 on Mbed Studio. The code is:
#include “mbed.h” #include “USBSerial.h”
//Virtual serial port over USB
USBSerial serial;
//USBSerial ser (true, 0x1f00, 0x2012, 0x0001);
int main(void) {
while(1)
{
serial.printf(“I am a virtual serial port\n”);
wait_us(1000000);
}
}
However it shows the below errors:
[Error] @0,0: L6218E: Undefined symbol USBSerial::USBSerial(bool, unsigned short, unsigned short, unsigned short) (referred from BUILD/DISCO_L053C8/ARMC6/main.o).
[Error] @0,0: L6218E: Undefined symbol USBSerial::~USBSerial() (referred from BUILD/DISCO_L053C8/ARMC6/main.o).
the USB feature was probably not supported/implemented on this target
In the targets.json is missing USBDEVICE. That can be enabled but also in STM32L0 HAL drivers are not any USB drivers, so it seems to be pointless.
above you wrote about MbedOS 5.15 and now you poste some links to mbed-dev, which is Mbed2.
And of course there are pins for the USB because the board DISCO-L053C8 | Mbed has USB 2.0 full speed on-chip interface. But unfortunately the USB driver for STM32L0 was not implemented under Mbed - STM32L0 HAL drivers.
You can try to do what I mentioned in this topic but because your board is low memory target you also need additional setting for activate USB under bare metal.
Thank you. When I tried, it generated lots of errors. Where can I get the files, PinNames.h, PeripheralPins.c and system_clock.c for mbed-os 5.15.6 for this device?
Also when you use Mbed Studio, how you wrote above, you not need visit the github repo.
Just follow same path in project tree: YOUR_PROJECT/mbed-os/targets/TARGET_STM/TARGET_STM32L0/TARGET_STM32L053x8/TARGET_DISCO_L053C8/
Thank you Jan. How do I quickly know which peripherals on the controller are supported by mBed? I thought whatever is available in the PeripheralPins.c is all supported.
I would like to say here Development boards | Mbed but I do not think so. Support of boards/ targets are usually added by Mbed partners like are NXP, ST etc.
When you check the list above, it seems all use different rules.
The ST probably add all boards with physical on-board USB conector. F446RE is not on the list because it not have on-board USB connector probably but I tried USBSerial API on F446RE and seems be OK.
The NXP not care of that or not interested (I do not know right word) but how you can see both boards (FRDM-K64F | Mbed and also FRDM-KL46Z | Mbed) have on-board USB port and are not in the list.
Good point, it is good work from Jamie as usual. But I not mentioned it because it is similar situation (because it is based on targets.json), like I descripted above. Furthermore it is a parser of the master branch of MbedOS repo, I think. So that not contain MbedOS 5.15 and therefore does not contain STM32L053.
I believe the developers prefer Mbed because you get all the drivers and libraries ready. You need to just write the application specific code. You don’t have to worry about the start-up code and the drivers for the peripherals. However what I have observed is the developers need to struggle to find out what is available and what is not. Perhaps finally you spend almost the same time as you would on the target specific environment like STMCubeMX. This is because on Mbed you spend time on searching and trying to find what is available. I believe there should be a clear list for each target about the availability of the supported features for all supported OS versions.