/* * This file is part of the Black Magic Debug project. * * Copyright (C) 2022 1BitSquared * Written by Rachel Mant * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "general.h" #include "usb.h" #include "usb_descriptors.h" #include "cdcacm.h" #include "serialno.h" char serial_no[DFU_SERIAL_LENGTH]; usbd_device *usbdev = NULL; /* We need a special large control buffer for this device: */ static uint8_t usbd_control_buffer[256]; void blackmagic_usb_init(void) { serial_no_read(serial_no); usbdev = usbd_init(&USB_DRIVER, &dev_desc, &config, usb_strings, sizeof(usb_strings) / sizeof(char *), usbd_control_buffer, sizeof(usbd_control_buffer)); usbd_register_set_config_callback(usbdev, cdcacm_set_config); nvic_set_priority(USB_IRQ, IRQ_PRI_USB); nvic_enable_irq(USB_IRQ); } void USB_ISR(void) { usbd_poll(usbdev); }