summaryrefslogtreecommitdiff
path: root/stmhal
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-16 10:54:16 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-16 10:54:16 +0100
commitbda2f709646f80dc82e52cd664d17cd41e8b2b6a (patch)
tree98da1f4bedc61563c9abc905da6aa02467a61a7b /stmhal
parent8a919fb051361e422817491c56e9096143b5fe7d (diff)
parent1452221aca8851df029702e8a71be339005bd5fd (diff)
Merge pull request #498 from lurch/create-headers-from-files
Auto-generate the stmhal/pybcdc_inf header file from static files
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/Makefile18
-rw-r--r--stmhal/main.c2
-rw-r--r--stmhal/pybcdc.h92
-rw-r--r--[-rwxr-xr-x]stmhal/pybcdc.inf_template (renamed from stmhal/pybcdc.inf)4
4 files changed, 21 insertions, 95 deletions
diff --git a/stmhal/Makefile b/stmhal/Makefile
index 978918994..f0d132520 100644
--- a/stmhal/Makefile
+++ b/stmhal/Makefile
@@ -210,6 +210,14 @@ PREFIX_FILE = boards/stm32f4xx-prefix.c
GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
GEN_PINS_HDR = $(BUILD)/pins.h
+INSERT_USB_IDS = ../tools/insert-usb-ids.py
+FILE2H = ../tools/file2h.py
+
+USB_IDS_FILE = usbd_desc_cdc_msc.c
+CDCINF_TEMPLATE = pybcdc.inf_template
+GEN_CDCINF_FILE = $(BUILD)/pybcdc.inf
+GEN_CDCINF_HEADER = $(BUILD)/pybcdc_inf.h
+
# Making OBJ use an order-only depenedency on the generated pins.h file
# has the side effect of making the pins.h file before we actually compile
# any of the objects. The normal dependency generation will deal with the
@@ -217,6 +225,8 @@ GEN_PINS_HDR = $(BUILD)/pins.h
# which source files might need it.
$(OBJ): | $(BUILD)/pins.h
+$(BUILD)/main.o: $(GEN_CDCINF_HEADER)
+
# Use a pattern rule here so that make will only call make-pins.py once to make
# both pins_$(BOARD).c and pins.h
$(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE)
@@ -226,4 +236,12 @@ $(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE
$(BUILD)/pins_$(BOARD).o: $(BUILD)/pins_$(BOARD).c
$(call compile_c)
+$(GEN_CDCINF_HEADER): $(GEN_CDCINF_FILE) $(FILE2H)
+ $(ECHO) "Create $@"
+ $(Q)$(PYTHON) $(FILE2H) $< > $@
+
+$(GEN_CDCINF_FILE): $(CDCINF_TEMPLATE) $(INSERT_USB_IDS) $(USB_IDS_FILE)
+ $(ECHO) "Create $@"
+ $(Q)$(PYTHON) $(INSERT_USB_IDS) $(USB_IDS_FILE) $< > $@
+
include ../py/mkrules.mk
diff --git a/stmhal/main.c b/stmhal/main.c
index cc41a195a..c5633fb68 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -134,7 +134,7 @@ static const char fresh_main_py[] =
;
static const char fresh_pybcdc_inf[] =
-#include "pybcdc.h"
+#include "build/pybcdc_inf.h"
;
static const char fresh_readme_txt[] =
diff --git a/stmhal/pybcdc.h b/stmhal/pybcdc.h
deleted file mode 100644
index 44685a05b..000000000
--- a/stmhal/pybcdc.h
+++ /dev/null
@@ -1,92 +0,0 @@
-"; Windows USB CDC ACM Setup File\r\n"
-"; Based on INF files which were:\r\n"
-"; Copyright (c) 2000 Microsoft Corporation\r\n"
-"; Copyright (C) 2007 Microchip Technology Inc.\r\n"
-"; Likely to be covered by the MLPL as found at:\r\n"
-"; <http://msdn.microsoft.com/en-us/cc300389.aspx#MLPL>.\r\n"
-"\r\n"
-"[Version]\r\n"
-"Signature=\"$Windows NT$\"\r\n"
-"Class=Ports\r\n"
-"ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}\r\n"
-"Provider=%MFGNAME%\r\n"
-"LayoutFile=layout.inf\r\n"
-"DriverVer=03/11/2010,5.1.2600.3\r\n"
-"\r\n"
-"[Manufacturer]\r\n"
-"%MFGNAME%=DeviceList, NTamd64\r\n"
-"\r\n"
-"[DestinationDirs]\r\n"
-"DefaultDestDir=12\r\n"
-"\r\n"
-";---------------------------------------------------------------------\r\n"
-"; Windows 2000/XP/Server2003/Vista/Server2008/7 - 32bit Sections\r\n"
-"\r\n"
-"[DriverInstall.nt]\r\n"
-"include=mdmcpq.inf\r\n"
-"CopyFiles=DriverCopyFiles.nt\r\n"
-"AddReg=DriverInstall.nt.AddReg\r\n"
-"\r\n"
-"[DriverCopyFiles.nt]\r\n"
-"usbser.sys,,,0x20\r\n"
-"\r\n"
-"[DriverInstall.nt.AddReg]\r\n"
-"HKR,,DevLoader,,*ntkern\r\n"
-"HKR,,NTMPDriver,,usbser.sys\r\n"
-"HKR,,EnumPropPages32,,\"MsPorts.dll,SerialPortPropPageProvider\"\r\n"
-"\r\n"
-"[DriverInstall.nt.Services]\r\n"
-"AddService=usbser, 0x00000002, DriverService.nt\r\n"
-"\r\n"
-"[DriverService.nt]\r\n"
-"DisplayName=%SERVICE%\r\n"
-"ServiceType=1\r\n"
-"StartType=3\r\n"
-"ErrorControl=1\r\n"
-"ServiceBinary=%12%\\usbser.sys\r\n"
-"\r\n"
-";---------------------------------------------------------------------\r\n"
-"; Windows XP/Server2003/Vista/Server2008/7 - 64bit Sections\r\n"
-"\r\n"
-"[DriverInstall.NTamd64]\r\n"
-"include=mdmcpq.inf\r\n"
-"CopyFiles=DriverCopyFiles.NTamd64\r\n"
-"AddReg=DriverInstall.NTamd64.AddReg\r\n"
-"\r\n"
-"[DriverCopyFiles.NTamd64]\r\n"
-"usbser.sys,,,0x20\r\n"
-"\r\n"
-"[DriverInstall.NTamd64.AddReg]\r\n"
-"HKR,,DevLoader,,*ntkern\r\n"
-"HKR,,NTMPDriver,,usbser.sys\r\n"
-"HKR,,EnumPropPages32,,\"MsPorts.dll,SerialPortPropPageProvider\"\r\n"
-"\r\n"
-"[DriverInstall.NTamd64.Services]\r\n"
-"AddService=usbser, 0x00000002, DriverService.NTamd64\r\n"
-"\r\n"
-"[DriverService.NTamd64]\r\n"
-"DisplayName=%SERVICE%\r\n"
-"ServiceType=1\r\n"
-"StartType=3\r\n"
-"ErrorControl=1\r\n"
-"ServiceBinary=%12%\\usbser.sys\r\n"
-"\r\n"
-";---------------------------------------------------------------------\r\n"
-"; Vendor and Product ID Definitions\r\n"
-"\r\n"
-"[SourceDisksFiles]\r\n"
-"[SourceDisksNames]\r\n"
-"[DeviceList]\r\n"
-"%DESCRIPTION%=DriverInstall, USB\\VID_0483&PID_5740&MI_00, USB\\VID_0483&PID_5740&MI_01\r\n"
-"\r\n"
-"[DeviceList.NTamd64]\r\n"
-"%DESCRIPTION%=DriverInstall, USB\\VID_0483&PID_5740&MI_00, USB\\VID_0483&PID_5740&MI_01\r\n"
-"\r\n"
-";---------------------------------------------------------------------\r\n"
-"; String Definitions\r\n"
-"\r\n"
-"[Strings]\r\n"
-"MFGFILENAME=\"pybcdc\"\r\n"
-"MFGNAME=\"Micro Python\"\r\n"
-"DESCRIPTION=\"Pyboard USB Comm Port\"\r\n"
-"SERVICE=\"USB Serial Driver\"\r\n"
diff --git a/stmhal/pybcdc.inf b/stmhal/pybcdc.inf_template
index eb04b65ce..87cd1467b 100755..100644
--- a/stmhal/pybcdc.inf
+++ b/stmhal/pybcdc.inf_template
@@ -77,10 +77,10 @@ ServiceBinary=%12%\usbser.sys
[SourceDisksFiles]
[SourceDisksNames]
[DeviceList]
-%DESCRIPTION%=DriverInstall, USB\VID_0483&PID_5740&MI_00, USB\VID_0483&PID_5740&MI_01
+%DESCRIPTION%=DriverInstall, USB\VID_${USB_VID}&PID_${USB_PID}&MI_00, USB\VID_${USB_VID}&PID_${USB_PID}&MI_01
[DeviceList.NTamd64]
-%DESCRIPTION%=DriverInstall, USB\VID_0483&PID_5740&MI_00, USB\VID_0483&PID_5740&MI_01
+%DESCRIPTION%=DriverInstall, USB\VID_${USB_VID}&PID_${USB_PID}&MI_00, USB\VID_${USB_VID}&PID_${USB_PID}&MI_01
;---------------------------------------------------------------------
; String Definitions