Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:fix issue of the M300 without usb connected #560

Merged
merged 1 commit into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
#include "stm32f4xx.h"
#include "FreeRTOS.h"
#include "queue.h"
#include "stdbool.h"

extern QueueHandle_t UartDataRecvQueue;
extern QueueHandle_t ACMDataRecvQueue;
extern QueueHandle_t ACMDataSendQueue;
extern bool USBConnected;

enum STM32_LINK_FD
{
Expand Down Expand Up @@ -98,6 +100,7 @@ E_OsdkStat OsdkSTM32_UartInit(const char *port, const int baudrate,
obj->uartObject.fd = UART_FD;
} else if (strcmp(port, ACM_PORT) == 0) {
obj->uartObject.fd = ACM_FD;
if (USBConnected == false) return OSDK_STAT_ERR;
} else {
obj->uartObject.fd = INVALID_FD;
}
Expand Down
3 changes: 3 additions & 0 deletions sample/platform/STM32/OnBoardSDK_STM32/User/usbh_usr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern CDC_Usercb_TypeDef UserCb;
CDC_Demo_State CDCUsrState;

extern QueueHandle_t ACMDataSendQueue;
bool USBConnected = false;

USBH_Usr_cb_TypeDef USR_Callbacks =
{
Expand Down Expand Up @@ -85,11 +86,13 @@ void USBH_USR_Init(void)

void USBH_USR_DeviceAttached(void)
{
USBConnected = true;
USB_DEBUG("USBH_USR_DeviceAttached!");
}

void USBH_USR_DeviceDisconnected (void)
{
USBConnected = false;
USB_DEBUG("USBH_USR_DeviceDisconnected!");
}

Expand Down