diff --git a/src/Makefile b/src/Makefile index 4b7050b..e69d2d4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -64,7 +64,6 @@ SRC = \ target.c \ target_probe.c - include $(PLATFORM_DIR)/Makefile.inc ifneq ($(PC_HOSTED),1) @@ -91,10 +90,8 @@ endif ifdef PC_HOSTED CFLAGS += -DPC_HOSTED=1 else -SRC += swdptap.c jtagtap.c CFLAGS += -DPC_HOSTED=0 -VPATH += platforms/common -CFLAGS += -Iplatforms/common +include platforms/common/Makefile.inc endif ifeq ($(ENABLE_RTT), 1) @@ -150,6 +147,9 @@ all_platforms: $(MAKE) clean ;\ for i in platforms/*/Makefile.inc ; do \ export DIRNAME=`dirname $$i` ;\ + if [ "$$DIRNAME" = "platforms/common" ]; then \ + continue; \ + fi; \ export PROBE_HOST=`basename $$DIRNAME` ;\ export CFLAGS=-Werror ;\ echo "Building for hardware platform: $$PROBE_HOST" ;\ diff --git a/src/platforms/common/Makefile.inc b/src/platforms/common/Makefile.inc new file mode 100644 index 0000000..774faa8 --- /dev/null +++ b/src/platforms/common/Makefile.inc @@ -0,0 +1,27 @@ +# +# 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 . +# + +VPATH += platforms/common +CFLAGS += -Iplatforms/common + +SRC += \ + jtagtap.c \ + swdptap.c \ + usb.c \ diff --git a/src/platforms/common/cdcacm.c b/src/platforms/common/cdcacm.c index fe90c49..a987cbb 100644 --- a/src/platforms/common/cdcacm.c +++ b/src/platforms/common/cdcacm.c @@ -589,8 +589,3 @@ void cdcacm_init(void) nvic_set_priority(USB_IRQ, IRQ_PRI_USB); nvic_enable_irq(USB_IRQ); } - -void USB_ISR(void) -{ - usbd_poll(usbdev); -} diff --git a/src/platforms/common/cdcacm.h b/src/platforms/common/cdcacm.h index 7cdfe23..db90011 100644 --- a/src/platforms/common/cdcacm.h +++ b/src/platforms/common/cdcacm.h @@ -28,7 +28,7 @@ #ifndef __CDCACM_H #define __CDCACM_H -#include +#include "usb.h" #define CDCACM_PACKET_SIZE 64 @@ -36,8 +36,6 @@ #define CDCACM_UART_ENDPOINT 3 #define TRACE_ENDPOINT 5 -extern usbd_device *usbdev; - void cdcacm_init(void); /* Returns current usb configuration, or 0 if not configured. */ int cdcacm_get_config(void); diff --git a/src/platforms/common/usb.c b/src/platforms/common/usb.c new file mode 100644 index 0000000..441984e --- /dev/null +++ b/src/platforms/common/usb.c @@ -0,0 +1,27 @@ +/* + * 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 "general.h" +#include "usb.h" + +void USB_ISR(void) +{ + usbd_poll(usbdev); +} diff --git a/src/platforms/common/usb.h b/src/platforms/common/usb.h new file mode 100644 index 0000000..43b1fea --- /dev/null +++ b/src/platforms/common/usb.h @@ -0,0 +1,28 @@ +/* + * 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 . + */ + +#ifndef USB_H +#define USB_H + +#include + +extern usbd_device *usbdev; + +#endif /*USB_H*/