STM32F042 Nucleo USB detect connection and disconnection
Hi all,
i have a problem with STM32F042 Nucleo and USB Connect detection.
I made my own MIDI Interface with CUBEMX (generated a CDC Projekt and changed it with help from some internet sites to MIDI) and it works well. I can attach and deattach the USB connector and it works!
I can send data to the pc and the pc can send data to my Interface => tested with MIDIOX!
But i need to detect, that USB Connection to my window pc is established, because then i can only send data to the pc. In the moment i send without checking the connection!
But Problem:
If i connect my MIDI Interface to the pc with power off and then switch power on, i cannot detect the connection!I found in 'usbd_core.c' the following functions:
/**
* @brief USBD_DevConnected * Handle device connection event* @param pdev: device instance* @retval status*/USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev){ return USBD_OK;}/**
* @brief USBD_DevDisconnected * Handle device disconnection event* @param pdev: device instance* @retval status*/USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev){ /* Free Class Resources */ pdev->dev_state = USBD_STATE_DEFAULT; pdev->pClass->DeInit(pdev, pdev->dev_config); return USBD_OK;}But these function are never called inside my STM32CUBE projekt => so they dont work!
How can secure detect the USB Connection?
