2017-07-29 02:52 AM
Hello, I am trying to use stm32f042k6t6 MCU and I want to use the USB peripheral implemented in it. Could someone suggest me a USB CDC library I can use with this MCU to connect with PC, I am using the standard peripheral libraries from ST so I am looking for a compatible CDC library.
Thanks in advance.
2017-07-29 08:21 AM
I am trying to port this library to my IAR project and use the CDC library:
I got many errors so what is the right functions to send data, receive data and get USB status?
2017-07-29 03:42 PM
Hello!
Yes you are right! errors.
There is a good solution for making your USB functional.
Try the
with HAL OR/AND LL drivers.This is not like StdPeriph_Driver but is compatible with IAR EWARM and has also functional examples.
2017-08-01 09:55 AM
Turvey.Clive.002
2017-08-01 10:01 AM
Palmer.Randall
2017-08-01 11:54 AM
Thanks Vangelis for your reply but I built the whole project based on the standard peripheral libraries so I want to use STSW-STM32092
librarythis my code, I just want to initialize the CDC library and if any data received from the host, I send it back. does my code right?
♯ include 'usbd_cdc_core.h'
♯ include 'usbd_usr.h'USB_CORE_HANDLE USB_Device_dev ;
extern USBD_Class_cb_TypeDef USBD_CDC_cb;int main(void)
{USBD_Init(&USB_Device_dev, &USR_desc, &USBD_CDC_cb, &USR_cb);char data = 0;
void *x = 0;USBD_CDC_cb.Init(x, 1);while (1)
{if(USBD_CDC_cb.EP0_RxReady(x) == 1){USBD_CDC_cb.DataIn(x, data);USBD_CDC_cb.DataOut(x, data);}}}2017-08-01 01:20 PM
Hello again!
Inside your USBD_CDC_cb structure you put some callback functions like usbd_cdc_DataIn, usbd_cdc_DataOut called when the appropriatre endpoind received or transmitted something.
You can not use theese functions by calling them.
Try to send from host , some characters and observe theese callback functions how to behave.
You can study also the example in STM32F0x2_USB-FS-Device_Lib V1.0.0\Projects\Virtual_COM_Port.