initialise the USB bus, called from both UARTDriver and stdio for startup debug This can be called before the hal is initialised so must not call any hal functions */
| 1863 | This can be called before the hal is initialised so must not call any hal functions |
| 1864 | */ |
| 1865 | void usb_initialise(void) |
| 1866 | { |
| 1867 | static bool initialised; |
| 1868 | if (initialised) { |
| 1869 | return; |
| 1870 | } |
| 1871 | initialised = true; |
| 1872 | sduObjectInit(&SDU1); |
| 1873 | sduStart(&SDU1, &serusbcfg1); |
| 1874 | #if HAL_HAVE_DUAL_USB_CDC |
| 1875 | sduObjectInit(&SDU2); |
| 1876 | sduStart(&SDU2, &serusbcfg2); |
| 1877 | #endif |
| 1878 | /* |
| 1879 | * Activates the USB driver and then the USB bus pull-up on D+. |
| 1880 | * Note, a delay is inserted in order to not have to disconnect the cable |
| 1881 | * after a reset. |
| 1882 | */ |
| 1883 | usbDisconnectBus(serusbcfg1.usbp); |
| 1884 | chThdSleep(chTimeUS2I(1500)); |
| 1885 | usbStart(serusbcfg1.usbp, &usbcfg); |
| 1886 | usbConnectBus(serusbcfg1.usbp); |
| 1887 | } |
| 1888 | #endif |
| 1889 | |
| 1890 | // disable TX/RX pins for unusued uart |
no outgoing calls
no test coverage detected