diff --git a/tools/iar_gen.py b/tools/iar_gen.py
index 73c8b29fc..646a581f4 100644
--- a/tools/iar_gen.py
+++ b/tools/iar_gen.py
@@ -1,51 +1,84 @@
#!/usr/bin/python3
import os
+import sys
import xml.dom.minidom as XML
+import glob
-# Read base configuration
-base = ""
-with open("iar_template.ipcf") as f:
- base = f.read()
+def Main():
+ # Read base configuration
+ base = ""
+ with open("iar_template.ipcf") as f:
+ base = f.read()
-# Enumerate all device/host examples
-dir_1 = os.listdir("../examples")
-for dir_2 in dir_1:
- if os.path.isdir("../examples/{}".format(dir_2)):
- print(dir_2)
- examples = os.listdir("../examples/{}".format(dir_2))
- for example in examples:
- if os.path.isdir("../examples/{}/{}".format(dir_2, example)):
- print("../examples/{}/{}".format(dir_2, example))
- conf = XML.parseString(base)
- files = conf.getElementsByTagName("files")[0]
- inc = conf.getElementsByTagName("includePath")[0]
- # Add bsp inc
- path = conf.createElement('path')
- path_txt = conf.createTextNode("$TUSB_DIR$/hw")
- path.appendChild(path_txt)
- inc.appendChild(path)
- # Add board.c/.h
- grp = conf.createElement('group')
- grp.setAttribute("name", "bsp")
- path = conf.createElement('path')
- path_txt = conf.createTextNode("$TUSB_DIR$/hw/bsp/board.c")
- path.appendChild(path_txt)
- grp.appendChild(path)
- files.appendChild(grp)
- # Add example's .c/.h
- grp = conf.createElement('group')
- grp.setAttribute("name", "example")
- for file in os.listdir("../examples/{}/{}/src".format(dir_2, example)):
- if file.endswith(".c") or file.endswith(".h"):
- path = conf.createElement('path')
- path.setAttribute("copyTo", "$PROJ_DIR$/{}".format(file))
- path_txt = conf.createTextNode("$TUSB_DIR$/examples/{0}/{1}/src/{2}".format(dir_2, example, file))
- path.appendChild(path_txt)
- grp.appendChild(path)
- files.appendChild(grp)
- cfg_str = conf.toprettyxml()
- cfg_str = '\n'.join([s for s in cfg_str.splitlines() if s.strip()])
- #print(cfg_str)
- with open("../examples/{0}/{1}/iar_{1}.ipcf".format(dir_2, example), 'w') as f:
- f.write(cfg_str)
+ # Enumerate all device/host examples
+ dir_1 = os.listdir("../examples")
+ for dir_2 in dir_1:
+ if os.path.isdir("../examples/{}".format(dir_2)):
+ print(dir_2)
+ examples = os.listdir("../examples/{}".format(dir_2))
+ for example in examples:
+ if os.path.isdir("../examples/{}/{}".format(dir_2, example)):
+ print("../examples/{}/{}".format(dir_2, example))
+ conf = XML.parseString(base)
+ files = conf.getElementsByTagName("files")[0]
+ inc = conf.getElementsByTagName("includePath")[0]
+ # Add bsp inc
+ path = conf.createElement('path')
+ path_txt = conf.createTextNode("$TUSB_DIR$/hw")
+ path.appendChild(path_txt)
+ inc.appendChild(path)
+ # Add board.c/.h
+ grp = conf.createElement('group')
+ grp.setAttribute("name", "bsp")
+ path = conf.createElement('path')
+ path_txt = conf.createTextNode("$TUSB_DIR$/hw/bsp/board.c")
+ path.appendChild(path_txt)
+ grp.appendChild(path)
+ files.appendChild(grp)
+ # Add example's .c/.h
+ grp = conf.createElement('group')
+ grp.setAttribute("name", "example")
+ for file in os.listdir("../examples/{}/{}/src".format(dir_2, example)):
+ if file.endswith(".c") or file.endswith(".h"):
+ path = conf.createElement('path')
+ path.setAttribute("copyTo", "$PROJ_DIR$/{}".format(file))
+ path_txt = conf.createTextNode("$TUSB_DIR$/examples/{0}/{1}/src/{2}".format(dir_2, example, file))
+ path.appendChild(path_txt)
+ grp.appendChild(path)
+ files.appendChild(grp)
+ cfg_str = conf.toprettyxml()
+ cfg_str = '\n'.join([s for s in cfg_str.splitlines() if s.strip()])
+ #print(cfg_str)
+ with open("../examples/{0}/{1}/iar_{1}.ipcf".format(dir_2, example), 'w') as f:
+ f.write(cfg_str)
+
+def ListPath(path, blacklist=[]):
+ # Get all .c files
+ files = glob.glob(f'../{path}/**/*.c', recursive=True)
+ # Filter
+ files = [x for x in files if all(y not in x for y in blacklist)]
+ # Get common dir list
+ dirs = []
+ for file in files:
+ dir = os.path.dirname(file)
+ if dir not in dirs:
+ dirs.append(dir)
+ # Print .c groupped by dir
+ for dir in dirs:
+ print('')
+ for file in files:
+ if os.path.dirname(file) == dir:
+ print(' $TUSB_DIR$/' + file.replace('../','').replace('\\','/')+'')
+ print('')
+
+def List():
+ ListPath('src', [ 'template.c', 'dcd_synopsys.c', 'dcd_esp32sx.c' ])
+ ListPath('lib/SEGGER_RTT')
+
+if __name__ == "__main__":
+ if (len(sys.argv) > 1):
+ if (sys.argv[1] == 'l'):
+ List()
+ else:
+ Main()
diff --git a/tools/iar_template.ipcf b/tools/iar_template.ipcf
index 6ea1d576d..4919fe7b4 100644
--- a/tools/iar_template.ipcf
+++ b/tools/iar_template.ipcf
@@ -4,166 +4,176 @@
$TUSB_DIR$/src
$TUSB_DIR$/lib/SEGGER_RTT/RTT
+ $TUSB_DIR$/lib/SEGGER_RTT/Config
$PROJ_DIR$
-
- $TUSB_DIR$/src/device/usbd.c
- $TUSB_DIR$/src/device/usbd_control.c
-
-
- $TUSB_DIR$/src/common/tusb_fifo.c
-
-
- $TUSB_DIR$/src/class/audio/audio_device.c
-
-
- $TUSB_DIR$/src/class/bth/bth_device.c
-
-
- $TUSB_DIR$/src/class/cdc/cdc_device.c
- $TUSB_DIR$/src/class/cdc/cdc_host.c
- $TUSB_DIR$/src/class/cdc/cdc_rndis_host.c
-
-
- $TUSB_DIR$/src/class/dfu/dfu_device.c
- $TUSB_DIR$/src/class/dfu/dfu_rt_device.c
-
-
- $TUSB_DIR$/src/class/hid/hid_device.c
- $TUSB_DIR$/src/class/hid/hid_host.c
-
-
- $TUSB_DIR$/src/class/midi/midi_device.c
-
-
- $TUSB_DIR$/src/class/msc/msc_device.c
- $TUSB_DIR$/src/class/msc/msc_host.c
-
-
- $TUSB_DIR$/src/class/net/ecm_rndis_device.c
- $TUSB_DIR$/src/class/net/ncm_device.c
-
-
- $TUSB_DIR$/src/class/usbtmc/usbtmc_device.c
-
-
- $TUSB_DIR$/src/class/vendor/vendor_device.c
- $TUSB_DIR$/src/class/vendor/vendor_host.c
-
$TUSB_DIR$/src/tusb.c
-
- $TUSB_DIR$/src/host/hub.c
- $TUSB_DIR$/src/host/usbh.c
-
-
- $TUSB_DIR$/src/portable/bridgetek/ft9xx/dcd_ft9xx.c
-
-
- $TUSB_DIR$/src/portable/chipidea/ci_hs/dcd_ci_hs.c
- $TUSB_DIR$/src/portable/chipidea/ci_hs/hcd_ci_hs.c
-
-
- $TUSB_DIR$/src/portable/synopsys/dwc2/dcd_dwc2.c
-
-
- $TUSB_DIR$/src/portable/dialog/da146xx/dcd_da146xx.c
-
-
- $TUSB_DIR$/src/portable/ehci/ehci.c
-
-
- $TUSB_DIR$/src/portable/espressif/esp32sx/dcd_esp32sx.c
-
-
- $TUSB_DIR$/src/portable/mentor/musb/dcd_musb.c
- $TUSB_DIR$/src/portable/mentor/musb/hcd_musb.c
-
-
- $TUSB_DIR$/src/portable/microchip/samd/dcd_samd.c
-
-
- $TUSB_DIR$/src/portable/microchip/samg/dcd_samg.c
-
-
- $TUSB_DIR$/src/portable/microchip/samx7x/dcd_samx7x.c
-
-
- $TUSB_DIR$/src/portable/microchip/pic/dcd_pic.c
-
-
- $TUSB_DIR$/src/portable/microchip/pic32mz/dcd_pic32mz.c
-
-
- $TUSB_DIR$/src/portable/mindmotion/mm32/dcd_mm32f327x_otg.c
-
-
- $TUSB_DIR$/src/portable/nordic/nrf5x/dcd_nrf5x.c
-
-
- $TUSB_DIR$/src/portable/nuvoton/nuc120/dcd_nuc120.c
-
-
- $TUSB_DIR$/src/portable/nuvoton/nuc121/dcd_nuc121.c
-
-
- $TUSB_DIR$/src/portable/nuvoton/nuc505/dcd_nuc505.c
-
-
- $TUSB_DIR$/src/portable/nxp/khci/dcd_khci.c
- $TUSB_DIR$/src/portable/nxp/khci/hcd_khci.c
-
-
- $TUSB_DIR$/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
- $TUSB_DIR$/src/portable/nxp/lpc17_40/hcd_lpc17_40.c
-
-
- $TUSB_DIR$/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
-
-
- $TUSB_DIR$/src/portable/nxp/transdimension/dcd_transdimension.c
- $TUSB_DIR$/src/portable/nxp/transdimension/hcd_transdimension.c
-
-
- $TUSB_DIR$/src/portable/ohci/ohci.c
-
-
- $TUSB_DIR$/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c
- $TUSB_DIR$/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
-
-
- $TUSB_DIR$/src/portable/raspberrypi/rp2040/dcd_rp2040.c
- $TUSB_DIR$/src/portable/raspberrypi/rp2040/hcd_rp2040.c
-
-
- $TUSB_DIR$/src/portable/renesas/rusb2/dcd_rusb2.c
- $TUSB_DIR$/src/portable/renesas/rusb2/hcd_rusb2.c
-
-
- $TUSB_DIR$/src/portable/sony/cxd56/dcd_cxd56.c
-
-
- $TUSB_DIR$/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
-
-
- $TUSB_DIR$/src/portable/sunxi/dcd_sunxi_musb.c
-
-
- $TUSB_DIR$/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
-
-
- $TUSB_DIR$/src/portable/valentyusb/eptri/dcd_eptri.c
-
-
- $TUSB_DIR$/src/portable/wch/ch32v307/dcd_usbhs.c
-
-
- $TUSB_DIR$/lib/SEGGER_RTT/RTT/SEGGER_RTT.c
+
+ $TUSB_DIR$/src/class/audio/audio_device.c
+
+
+ $TUSB_DIR$/src/class/bth/bth_device.c
+
+
+ $TUSB_DIR$/src/class/cdc/cdc_device.c
+ $TUSB_DIR$/src/class/cdc/cdc_host.c
+ $TUSB_DIR$/src/class/cdc/cdc_rndis_host.c
+
+
+ $TUSB_DIR$/src/class/dfu/dfu_device.c
+ $TUSB_DIR$/src/class/dfu/dfu_rt_device.c
+
+
+ $TUSB_DIR$/src/class/hid/hid_device.c
+ $TUSB_DIR$/src/class/hid/hid_host.c
+
+
+ $TUSB_DIR$/src/class/midi/midi_device.c
+
+
+ $TUSB_DIR$/src/class/msc/msc_device.c
+ $TUSB_DIR$/src/class/msc/msc_host.c
+
+
+ $TUSB_DIR$/src/class/net/ecm_rndis_device.c
+ $TUSB_DIR$/src/class/net/ncm_device.c
+
+
+ $TUSB_DIR$/src/class/usbtmc/usbtmc_device.c
+
+
+ $TUSB_DIR$/src/class/vendor/vendor_device.c
+ $TUSB_DIR$/src/class/vendor/vendor_host.c
+
+
+ $TUSB_DIR$/src/class/video/video_device.c
+
+
+ $TUSB_DIR$/src/common/tusb_fifo.c
+
+
+ $TUSB_DIR$/src/device/usbd.c
+ $TUSB_DIR$/src/device/usbd_control.c
+
+
+ $TUSB_DIR$/src/host/hub.c
+ $TUSB_DIR$/src/host/usbh.c
+
+
+ $TUSB_DIR$/src/portable/analog/max3421/hcd_max3421.c
+
+
+ $TUSB_DIR$/src/portable/bridgetek/ft9xx/dcd_ft9xx.c
+
+
+ $TUSB_DIR$/src/portable/chipidea/ci_fs/dcd_ci_fs.c
+
+
+ $TUSB_DIR$/src/portable/chipidea/ci_hs/dcd_ci_hs.c
+ $TUSB_DIR$/src/portable/chipidea/ci_hs/hcd_ci_hs.c
+
+
+ $TUSB_DIR$/src/portable/dialog/da146xx/dcd_da146xx.c
+
+
+ $TUSB_DIR$/src/portable/ehci/ehci.c
+
+
+ $TUSB_DIR$/src/portable/mentor/musb/dcd_musb.c
+ $TUSB_DIR$/src/portable/mentor/musb/hcd_musb.c
+
+
+ $TUSB_DIR$/src/portable/microchip/pic/dcd_pic.c
+
+
+ $TUSB_DIR$/src/portable/microchip/pic32mz/dcd_pic32mz.c
+
+
+ $TUSB_DIR$/src/portable/microchip/samd/dcd_samd.c
+
+
+ $TUSB_DIR$/src/portable/microchip/samg/dcd_samg.c
+
+
+ $TUSB_DIR$/src/portable/microchip/samx7x/dcd_samx7x.c
+
+
+ $TUSB_DIR$/src/portable/mindmotion/mm32/dcd_mm32f327x_otg.c
+
+
+ $TUSB_DIR$/src/portable/nordic/nrf5x/dcd_nrf5x.c
+
+
+ $TUSB_DIR$/src/portable/nuvoton/nuc120/dcd_nuc120.c
+
+
+ $TUSB_DIR$/src/portable/nuvoton/nuc121/dcd_nuc121.c
+
+
+ $TUSB_DIR$/src/portable/nuvoton/nuc505/dcd_nuc505.c
+
+
+ $TUSB_DIR$/src/portable/nxp/khci/dcd_khci.c
+ $TUSB_DIR$/src/portable/nxp/khci/hcd_khci.c
+
+
+ $TUSB_DIR$/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+ $TUSB_DIR$/src/portable/nxp/lpc17_40/hcd_lpc17_40.c
+
+
+ $TUSB_DIR$/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+
+
+ $TUSB_DIR$/src/portable/ohci/ohci.c
+
+
+ $TUSB_DIR$/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c
+ $TUSB_DIR$/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
+
+
+ $TUSB_DIR$/src/portable/raspberrypi/rp2040/dcd_rp2040.c
+ $TUSB_DIR$/src/portable/raspberrypi/rp2040/hcd_rp2040.c
+ $TUSB_DIR$/src/portable/raspberrypi/rp2040/rp2040_usb.c
+
+
+ $TUSB_DIR$/src/portable/renesas/rusb2/dcd_rusb2.c
+ $TUSB_DIR$/src/portable/renesas/rusb2/hcd_rusb2.c
+ $TUSB_DIR$/src/portable/renesas/rusb2/rusb2_common.c
+
+
+ $TUSB_DIR$/src/portable/sony/cxd56/dcd_cxd56.c
+
+
+ $TUSB_DIR$/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+
+
+ $TUSB_DIR$/src/portable/st/typec/typec_stm32.c
+
+
+ $TUSB_DIR$/src/portable/sunxi/dcd_sunxi_musb.c
+
+
+ $TUSB_DIR$/src/portable/synopsys/dwc2/dcd_dwc2.c
+
+
+ $TUSB_DIR$/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
+
+
+ $TUSB_DIR$/src/portable/valentyusb/eptri/dcd_eptri.c
+
+
+ $TUSB_DIR$/src/portable/wch/ch32v307/dcd_usbhs.c
+
+
+ $TUSB_DIR$/src/typec/usbc.c
+
+
+ $TUSB_DIR$/lib/SEGGER_RTT/RTT/SEGGER_RTT.c
$TUSB_DIR$/lib/SEGGER_RTT/RTT/SEGGER_RTT_printf.c
- $TUSB_DIR$/lib/SEGGER_RTT/Syscalls/SEGGER_RTT_Syscalls_IAR.c
-
+