fome-fw/firmware/hw_layer/serial_over_usb/usbconsole.c

54 lines
1.1 KiB
C
Raw Normal View History

2014-08-29 07:52:33 -07:00
/**
* @file usbconsole.c
* @brief USB-over-serial configuration
*
* @date Oct 14, 2013
2015-01-12 15:04:10 -08:00
* @author Andrey Belomutskiy, (c) 2012-2015
2014-08-29 07:52:33 -07:00
*/
#include "main.h"
2015-01-06 06:03:36 -08:00
#if EFI_USB_SERIAL || defined(__DOXYGEN__)
2014-08-29 07:52:33 -07:00
#include "usbconsole.h"
#include "usbcfg.h"
#include "efifeatures.h"
extern SerialUSBDriver SDU1;
extern const SerialUSBConfig serusbcfg;
extern const USBConfig usbcfg;
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);
2014-12-06 20:03:14 -08:00
chThdSleepMilliseconds(1500);
2014-08-29 07:52:33 -07:00
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);
/*
* Activates the serial driver 2 using the driver default configuration.
*/
sdStart(&SD2, NULL);
}
bool is_usb_serial_ready(void) {
return SDU1.config->usbp->state == USB_ACTIVE;
}
2014-12-23 20:03:31 -08:00
#else
bool is_usb_serial_ready(void) {
return false;
}
2014-08-29 07:52:33 -07:00
#endif