void HAL_USB_Init(void) { if (USB_Configured) return; // Pre-register Serial and USBSerial1 but keep them inactive. // This is only needed to reserve interfaces #0 and #1 for Serial, and #3 and #4 for USBSerial1 HAL_USB_USART_Init(HAL_USB_USART_SERIAL, NULL); HAL_USB_USART_Init(HAL_USB_USART_SERIAL1, NULL); USB_Configured = 1; SPARK_USB_Setup(); }
/******************************************************************************* * Function Name : USB_USART_Init * Description : Start USB-USART protocol. * Input : baudRate (0 : disconnect usb else init usb only once). * Return : None. *******************************************************************************/ void USB_USART_Init(uint32_t baudRate) { if (linecoding.bitrate != baudRate) { if (!baudRate) { USB_Cable_Config(DISABLE); } else if (!linecoding.bitrate) { //Perform a Detach-Attach operation on USB bus USB_Cable_Config(DISABLE); USB_Cable_Config(ENABLE); //Initialize USB device only once (if linecoding.bitrate==0) SPARK_USB_Setup(); } //linecoding.bitrate will be overwritten by USB Host linecoding.bitrate = baudRate; } }
void USBMouse::begin(void) { SPARK_USB_Setup(); }