Ejemplo n.º 1
0
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();
}
USBSerial::USBSerial(HAL_USB_USART_Serial serial, const HAL_USB_USART_Config& conf)
{
  _serial = serial;
  _blocking = true;

  HAL_USB_USART_Init(_serial, &conf);
}
//
// Constructor
//
USBSerial::USBSerial()
{
  _serial = HAL_USB_USART_SERIAL;
  _blocking = true;

  HAL_USB_USART_Config conf = acquireSerialBuffer();
  HAL_USB_USART_Init(_serial, &conf);
}
Ejemplo n.º 4
0
void HAL_USB_USART_Begin(HAL_USB_USART_Serial serial, uint32_t baud, void *reserved)
{
    if (!usbUsartMap[serial].data || !usbUsartMap[serial].cls) {
        HAL_USB_USART_Init(serial, NULL);
    }
    
    if (!usbUsartMap[serial].registered) {
        if (USBD_Composite_Get_State(usbUsartMap[serial].cls) == false) {
            // Detach, change state, re-attach
            HAL_USB_Detach();
            USBD_Composite_Set_State(usbUsartMap[serial].cls, true);
            usbUsartMap[serial].registered = 1;
            usbUsartMap[serial].data->linecoding.bitrate = baud;
            HAL_USB_Attach();
        }
    }
}