Skip to content

Commit

Permalink
#38 warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jul 22, 2020
1 parent 7e2070a commit 9071958
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/eez/action_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,9 +1386,17 @@ void action_channel_toggle_ramp_state() {
}
}

void doSetDeviceMode() {
sendMessageToLowPriorityThread(THREAD_MESSAGE_SELECT_USB_MODE, USB_MODE_DEVICE);
}

void onSetUsbMode(uint16_t value) {
popPage();
sendMessageToLowPriorityThread(THREAD_MESSAGE_SELECT_USB_MODE, value);
if (value == USB_MODE_DEVICE && usb::isOtgHostModeDetected()) {
areYouSureWithMessage("OTG cable detected.", doSetDeviceMode);
} else {
sendMessageToLowPriorityThread(THREAD_MESSAGE_SELECT_USB_MODE, value);
}
}

void action_select_usb_mode() {
Expand Down
4 changes: 4 additions & 0 deletions src/eez/usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ bool isMassStorageActive() {
return (g_usbMode == USB_MODE_DEVICE || (g_usbMode == USB_MODE_OTG && g_otgMode == USB_MODE_DEVICE)) && g_usbDeviceClass == USB_DEVICE_CLASS_MASS_STORAGE_CLIENT;
}

bool isOtgHostModeDetected() {
return !HAL_GPIO_ReadPin(USB_OTG_FS_ID_GPIO_Port, USB_OTG_FS_ID_Pin);
}

} // usb
} // eez

Expand Down
2 changes: 2 additions & 0 deletions src/eez/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ void selectUsbDeviceClass(int usbDeviceClass);
bool isVirtualComPortActive();
bool isMassStorageActive();

bool isOtgHostModeDetected();

} // usb
} // eez

Expand Down

0 comments on commit 9071958

Please sign in to comment.