common: Make USB_VcomInit() take VID/PID and pass them on.
[gps-watch.git] / src / common / usb_serial.rs
index f08f679ed78c928e81acb20edffdeba461129767..6a7cd173b0fc09e51e04021e7a32604170914bbe 100644 (file)
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+use nvic;
+use clock;
+
 extern {
-    fn USB_VcomInit();
+    fn USB_VcomInit(vid: u16, pid: u16);
+}
+
+pub unsafe fn init(vid: u16, pid: u16) {
+    USB_VcomInit(vid, pid);
+}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+pub unsafe extern fn USB_DeviceIsrEnable()
+{
+    let irq_number = 24; // USB0
+    let irq_prio = 3; // Stolen from NXP example.
+
+    nvic::set_priority(irq_number, irq_prio);
+    nvic::enable_irq(irq_number);
 }
 
-pub unsafe fn init() {
-    USB_VcomInit();
+#[no_mangle]
+#[allow(non_snake_case)]
+pub unsafe extern fn USB_DeviceClockInit()
+{
+    clock::configure_usb();
 }