فهرست منبع

Merge pull request #1071 from HiFiPhile/iar

More IAR support
Ha Thach 4 سال پیش
والد
کامیت
f878f892ad
3فایلهای تغییر یافته به همراه234 افزوده شده و 0 حذف شده
  1. 36 0
      docs/reference/getting_started.rst
  2. 51 0
      tools/iar_gen.py
  3. 147 0
      tools/iar_template.ipcf

+ 36 - 0
docs/reference/getting_started.rst

@@ -151,3 +151,39 @@ Some board use uf2 bootloader for drag & drop in to mass storage device, uf2 can
 .. code-block::
 
    $ make BOARD=feather_nrf52840_express all uf2
+
+IAR Support
+-----------
+
+IAR Project Connection files are provided to import TinyUSB stack into your project.
+
+* A buldable project of your MCU need to be created in advance.
+
+
+  * Take example of STM32F0:
+  
+    -  You need `stm32l0xx.h`, `startup_stm32f0xx.s`, `system_stm32f0xx.c`.
+
+    - `STM32L0xx_HAL_Driver` is only needed to run examples, TinyUSB stack itself doesn't rely on MCU's SDKs.
+
+* Open `Tools -> Configure Custom Argument Variables` (Switch to `Global` tab if you want to do it for all your projects) 
+   Click `New Group ...`, name it to `TUSB`, Click `Add Variable ...`, name it to `TUSB_DIR`, change it's value to the path of your TinyUSB stack,
+   for example `C:\\tinyusb`
+
+Import stack only
+^^^^^^^^^^^^^^^^^
+
+1. Open `Project -> Add project Connection ...`, click `OK`, choose `tinyusb\\tools\\iar_template.ipcf`.
+
+Run examples
+^^^^^^^^^^^^
+
+1. (Python3 is needed) Run `iar_gen.py` to generate .ipcf files of examples:
+
+   .. code-block::
+
+     cd C:\tinyusb\tools
+     python iar_gen.py
+
+2. Open `Project -> Add project Connection ...`, click `OK`, choose `tinyusb\\examples\\(.ipcf of example)`.
+   For example `C:\\tinyusb\\examples\\device\\cdc_msc\\iar_cdc_msc.ipcf`

+ 51 - 0
tools/iar_gen.py

@@ -0,0 +1,51 @@
+#!/usr/bin/python3
+
+import os
+import xml.dom.minidom as XML
+
+# 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)

+ 147 - 0
tools/iar_template.ipcf

@@ -0,0 +1,147 @@
+<?xml version="1.0"?>
+<iarProjectConnection name="tinyusb" oneShot="true">
+
+	<includePath>
+		<path>$TUSB_DIR$/src</path>
+        <path>$TUSB_DIR$/lib/SEGGER_RTT/RTT</path>
+        <path>$PROJ_DIR$</path>
+	</includePath>
+	<files>
+		<group name="src/device">
+			<path>$TUSB_DIR$/src/device/usbd.c</path>
+			<path>$TUSB_DIR$/src/device/usbd_control.c</path>
+		</group>
+		<group name="src/common">
+			<path>$TUSB_DIR$/src/common/tusb_fifo.c</path>
+		</group>
+		<group name="src/class/audio">
+			<path>$TUSB_DIR$/src/class/audio/audio_device.c</path>
+		</group>
+		<group name="src/class/bth">
+			<path>$TUSB_DIR$/src/class/bth/bth_device.c</path>
+		</group>
+		<group name="src/class/cdc">
+			<path>$TUSB_DIR$/src/class/cdc/cdc_device.c</path>
+			<path>$TUSB_DIR$/src/class/cdc/cdc_host.c</path>
+			<path>$TUSB_DIR$/src/class/cdc/cdc_rndis_host.c</path>
+		</group>
+		<group name="src/class/dfu">
+			<path>$TUSB_DIR$/src/class/dfu/dfu_device.c</path>
+			<path>$TUSB_DIR$/src/class/dfu/dfu_rt_device.c</path>
+		</group>
+		<group name="src/class/hid">
+			<path>$TUSB_DIR$/src/class/hid/hid_device.c</path>
+			<path>$TUSB_DIR$/src/class/hid/hid_host.c</path>
+		</group>
+		<group name="src/class/midi">
+			<path>$TUSB_DIR$/src/class/midi/midi_device.c</path>
+		</group>
+		<group name="src/class/msc">
+			<path>$TUSB_DIR$/src/class/msc/msc_device.c</path>
+			<path>$TUSB_DIR$/src/class/msc/msc_host.c</path>
+		</group>
+		<group name="src/class/net">
+			<path>$TUSB_DIR$/src/class/net/net_device.c</path>
+		</group>
+		<group name="src/class/usbtmc">
+			<path>$TUSB_DIR$/src/class/usbtmc/usbtmc_device.c</path>
+		</group>
+		<group name="src/class/vendor">
+			<path>$TUSB_DIR$/src/class/vendor/vendor_device.c</path>
+			<path>$TUSB_DIR$/src/class/vendor/vendor_host.c</path>
+		</group>
+        <group name="src">
+            <path>$TUSB_DIR$/src/tusb.c</path>
+        </group>
+		<group name="src/host">
+			<path>$TUSB_DIR$/src/host/hub.c</path>
+			<path>$TUSB_DIR$/src/host/usbh.c</path>
+			<path>$TUSB_DIR$/src/host/usbh_control.c</path>
+		</group>
+		<group name="src/portable/dialog/da146xx">
+			<path>$TUSB_DIR$/src/portable/dialog/da146xx/dcd_da146xx.c</path>
+		</group>
+		<group name="src/portable/ehci">
+			<path>$TUSB_DIR$/src/portable/ehci/ehci.c</path>
+		</group>
+		<group name="src/portable/espressif/esp32sx">
+			<path>$TUSB_DIR$/src/portable/espressif/esp32sx/dcd_esp32sx.c</path>
+		</group>
+		<group name="src/portable/microchip/samd">
+			<path>$TUSB_DIR$/src/portable/microchip/samd/dcd_samd.c</path>
+		</group>
+		<group name="src/portable/microchip/samg">
+			<path>$TUSB_DIR$/src/portable/microchip/samg/dcd_samg.c</path>
+		</group>
+		<group name="src/portable/microchip/samx7x">
+			<path>$TUSB_DIR$/src/portable/microchip/samx7x/dcd_samx7x.c</path>
+		</group>
+		<group name="src/portable/mindmotion/mm32">
+			<path>$TUSB_DIR$/src/portable/mindmotion/mm32/dcd_mm32f327x_otg.c</path>
+		</group>
+		<group name="src/portable/nordic/nrf5x">
+			<path>$TUSB_DIR$/src/portable/nordic/nrf5x/dcd_nrf5x.c</path>
+		</group>
+		<group name="src/portable/nuvoton/nuc120">
+			<path>$TUSB_DIR$/src/portable/nuvoton/nuc120/dcd_nuc120.c</path>
+		</group>
+		<group name="src/portable/nuvoton/nuc121">
+			<path>$TUSB_DIR$/src/portable/nuvoton/nuc121/dcd_nuc121.c</path>
+		</group>
+		<group name="src/portable/nuvoton/nuc505">
+			<path>$TUSB_DIR$/src/portable/nuvoton/nuc505/dcd_nuc505.c</path>
+		</group>
+		<group name="src/portable/nxp/khci">
+			<path>$TUSB_DIR$/src/portable/nxp/khci/dcd_khci.c</path>
+		</group>
+		<group name="src/portable/nxp/lpc17_40">
+			<path>$TUSB_DIR$/src/portable/nxp/lpc17_40/dcd_lpc17_40.c</path>
+			<path>$TUSB_DIR$/src/portable/nxp/lpc17_40/hcd_lpc17_40.c</path>
+		</group>
+		<group name="src/portable/nxp/lpc_ip3511">
+			<path>$TUSB_DIR$/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c</path>
+		</group>
+		<group name="src/portable/nxp/transdimension">
+			<path>$TUSB_DIR$/src/portable/nxp/transdimension/dcd_transdimension.c</path>
+			<path>$TUSB_DIR$/src/portable/nxp/transdimension/hcd_transdimension.c</path>
+		</group>
+		<group name="src/portable/ohci">
+			<path>$TUSB_DIR$/src/portable/ohci/ohci.c</path>
+		</group>
+		<group name="src/portable/raspberrypi/rp2040">
+			<path>$TUSB_DIR$/src/portable/raspberrypi/rp2040/dcd_rp2040.c</path>
+			<path>$TUSB_DIR$/src/portable/raspberrypi/rp2040/hcd_rp2040.c</path>
+			<path>$TUSB_DIR$/src/portable/raspberrypi/rp2040/rp2040_usb.c</path>
+		</group>
+		<group name="src/portable/renesas/usba">
+			<path>$TUSB_DIR$/src/portable/renesas/usba/dcd_usba.c</path>
+		</group>
+		<group name="src/portable/silabs/efm32">
+			<path>$TUSB_DIR$/src/portable/silabs/efm32/dcd_efm32.c</path>
+		</group>
+		<group name="src/portable/sony/cxd56">
+			<path>$TUSB_DIR$/src/portable/sony/cxd56/dcd_cxd56.c</path>
+		</group>
+		<group name="src/portable/st/stm32_fsdev">
+			<path>$TUSB_DIR$/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c</path>
+		</group>
+		<group name="src/portable/st/synopsys">
+			<path>$TUSB_DIR$/src/portable/st/synopsys/dcd_synopsys.c</path>
+		</group>
+		<group name="src/portable/template">
+			<path>$TUSB_DIR$/src/portable/template/dcd_template.c</path>
+		</group>
+		<group name="src/portable/ti/msp430x5xx">
+			<path>$TUSB_DIR$/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c</path>
+		</group>
+		<group name="src/portable/valentyusb/eptri">
+			<path>$TUSB_DIR$/src/portable/valentyusb/eptri/dcd_eptri.c</path>
+		</group>
+        <group name="lib/SEGGER_RTT">
+			<path>$TUSB_DIR$/lib/SEGGER_RTT/RTT/SEGGER_RTT.c</path>
+            <path>$TUSB_DIR$/lib/SEGGER_RTT/RTT/SEGGER_RTT_printf.c</path>
+            <path>$TUSB_DIR$/lib/SEGGER_RTT/Syscalls/SEGGER_RTT_Syscalls_IAR.c</path>
+		</group>
+    </files>
+    
+</iarProjectConnection>