rusefi-1/firmware/hw_layer/serial_over_usb/usbconsole.c

52 lines
1.0 KiB
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file usbconsole.c
* @brief USB-over-serial configuration
*
* @date Oct 14, 2013
2018-01-20 17:55:31 -08:00
* @author Andrey Belomutskiy, (c) 2012-2018
2015-07-10 06:01:56 -07:00
*/
2018-09-16 19:39:46 -07:00
#include "global.h"
2015-07-10 06:01:56 -07:00
#if EFI_USB_SERIAL || defined(__DOXYGEN__)
#include "usbconsole.h"
#include "usbcfg.h"
#include "efifeatures.h"
void usb_serial_start(void) {
/*
* Initializes a serial-over-USB CDC driver.
*/
sduObjectInit(&SDU1);
sduStart(&SDU1, &serusbcfg);
/*
* Activates the USB driver and then the USB bus pull-up on D+.
* Note, a delay is inserted in order to not have to disconnect the cable
* after a reset.
*/
usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(1500);
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);
2017-05-23 15:06:09 -07:00
#if HAL_USE_SERIAL
2015-07-10 06:01:56 -07:00
/*
* Activates the serial driver 2 using the driver default configuration.
*/
sdStart(&SD2, NULL);
2017-05-23 15:06:09 -07:00
#endif
2015-07-10 06:01:56 -07:00
}
bool is_usb_serial_ready(void) {
return SDU1.config->usbp->state == USB_ACTIVE;
}
#else
bool is_usb_serial_ready(void) {
return false;
}
2017-04-01 21:20:47 -07:00
#endif /* EFI_USB_SERIAL */