diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 000000000..735a5ef22
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,4 @@
+contact_links:
+ - name: TinyUSB Discussion
+ url: https://github.com/hathach/tinyusb/discussions
+ about: If you have other questions or need help, post it here.
diff --git a/.github/ISSUE_TEMPLATE/porting.md b/.github/ISSUE_TEMPLATE/porting.md
deleted file mode 100644
index 9e4097ac2..000000000
--- a/.github/ISSUE_TEMPLATE/porting.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-name: Porting
-about: Adding a new port for this project
-title: ''
-labels: Porting
-assignees: ''
-
----
-
-**Description**
-Describe which API you want to port (DCD/HCD/OSAL/BSP). It is also helpful to go through [porting.md](docs/porting.md) first if you haven't yet.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5ec29686a..0f2b9ea3b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -9,7 +9,9 @@ on:
- created
jobs:
+ # ---------------------------------------
# Unit testing with Ceedling
+ # ---------------------------------------
unit-test:
runs-on: ubuntu-latest
steps:
@@ -28,8 +30,10 @@ jobs:
cd test
ceedling test:all
- # build all example for each family
- build-family:
+ # ---------------------------------------
+ # Build ARM family
+ # ---------------------------------------
+ build-arm:
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -37,6 +41,8 @@ jobs:
family:
# Alphabetical order
- 'imxrt'
+ - 'lpc18'
+ - 'lpc55'
- 'nrf'
- 'rp2040'
- 'samd11'
@@ -44,30 +50,36 @@ jobs:
- 'samd51'
- 'stm32f4'
- 'stm32f7'
+ - 'stm32h7'
steps:
- name: Setup Python
uses: actions/setup-python@v2
- - name: Setup Node.js
- uses: actions/setup-node@v1
-
- - name: Install Toolchains
- run: |
- # ARM GCC from xpack
- npm install --global xpm
- xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest
- echo `echo $HOME/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH
-
- name: Checkout TinyUSB
uses: actions/checkout@v2
- with:
- submodules: 'true'
- - name: Checkout Sub-Submodules
+ - name: Checkout common submodules in lib
+ run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel
+
+ - name: Set Toolchain URL
+ run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-linux-x64.tar.gz
+
+ - name: Cache Toolchain
+ uses: actions/cache@v2
+ id: cache-toolchain
+ with:
+ path: ~/cache/
+ key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }}
+
+ - name: Install Toolchain
+ if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
- # some submodule has it own submodules that need to be fetched as well
- git submodule update --init --recursive hw/mcu/microchip
- git submodule update --init --recursive lib/FreeRTOS
+ mkdir -p ~/cache/toolchain
+ wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz
+ tar -C ~/cache/toolchain -xaf toolchain.tar.gz
+
+ - name: Set Toolchain Path
+ run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
- name: Build
run: python3 tools/build_family.py ${{ matrix.family }}
@@ -94,84 +106,75 @@ jobs:
asset_name: ${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip
asset_content_type: application/zip
- # Build all no-family (opharned) boards
- build-board:
+ # ---------------------------------------
+ # Build RISC-V family
+ # ---------------------------------------
+ build-riscv:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- example:
+ family:
# Alphabetical order
- - 'device/audio_test'
- - 'device/board_test'
- - 'device/cdc_dual_ports'
- - 'device/cdc_msc'
- - 'device/cdc_msc_freertos'
- - 'device/dfu_runtime'
- - 'device/hid_composite'
- - 'device/hid_composite_freertos'
- - 'device/hid_generic_inout'
- - 'device/hid_multiple_interface'
- - 'device/midi_test'
- - 'device/msc_dual_lun'
- - 'device/net_lwip_webserver'
- - 'device/uac2_headset'
- - 'device/usbtmc'
- - 'device/webusb_serial'
- - 'host/cdc_msc_hid'
-
+ - 'fomu'
steps:
- name: Setup Python
uses: actions/setup-python@v2
- - name: Setup Node.js
- uses: actions/setup-node@v1
-
- name: Checkout TinyUSB
uses: actions/checkout@v2
- with:
- submodules: 'true'
- - name: Checkout Sub-Submodules
- run: |
- # some submodule has it own submodules that need to be fetched as well
- git submodule update --init --recursive hw/mcu/microchip
- git submodule update --init --recursive lib/FreeRTOS
+ - name: Checkout common submodules in lib
+ run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
- # Add msp430-gcc url to env
- echo >> $GITHUB_ENV MSP430_GCC_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2
+ - name: Set Toolchain URL
+ run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz
- - name: Cache MSP430-GCC
+ - name: Cache Toolchain
uses: actions/cache@v2
- id: cache-msp430
+ id: cache-toolchain
with:
path: ~/cache/
- key: ${{ runner.os }}-21-01-26-${{ env.MSP430_GCC_URL }}
+ key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }}
- - name: Install MSP430-GCC
- if: steps.cache-msp430.outputs.cache-hit != 'true'
+ - name: Install Toolchain
+ if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
- # MSP430 GCC
- mkdir -p ~/cache/msp430-gcc
- wget --progress=dot:mega $MSP430_GCC_URL -O msp430-gcc.tar.bz2
- tar -C ~/cache/msp430-gcc -xaf msp430-gcc.tar.bz2
+ mkdir -p ~/cache/toolchain
+ wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz
+ tar -C ~/cache/toolchain -xaf toolchain.tar.gz
- - name: Install Toolchains
- run: |
- # ARM & RISC-V GCC from xpack
- npm install --global xpm
- xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest
- xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@latest
- echo `echo $HOME/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH
- echo `echo $HOME/.local/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin` >> $GITHUB_PATH
-
- # TI MSP430 GCC
- echo >> $GITHUB_PATH `echo ~/cache/msp430-gcc/msp430-gcc-*/bin`
+ - name: Set Toolchain Path
+ run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
- name: Build
- run: python3 tools/build_board.py ${{ matrix.example }}
+ run: python3 tools/build_family.py ${{ matrix.family }}
- # Build ESP32S2
+ - uses: actions/upload-artifact@v2
+ with:
+ name: ${{ matrix.family }}-tinyusb-examples
+ path: _bin/
+
+ - name: Create Release Asset
+ if: ${{ github.event_name == 'release' }}
+ run: |
+ cd _bin/
+ zip -r ../${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip *
+
+ - name: Upload Release Asset
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ if: ${{ github.event_name == 'release' }}
+ with:
+ upload_url: ${{ github.event.release.upload_url }}
+ asset_path: ${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip
+ asset_name: ${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip
+ asset_content_type: application/zip
+
+ # ---------------------------------------
+ # Build ESP32S2 family
+ # ---------------------------------------
build-esp32s2:
runs-on: ubuntu-latest
strategy:
@@ -194,8 +197,121 @@ jobs:
- name: Checkout TinyUSB
uses: actions/checkout@v2
- with:
- submodules: 'false'
- name: Build
run: docker run --rm -v $PWD:/project -w /project espressif/idf:latest python3 tools/build_esp32s2.py ${{ matrix.board }}
+
+ # ---------------------------------------
+ # Build msp430 family
+ # ---------------------------------------
+ build-msp430:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ family:
+ # Alphabetical order
+ - 'msp430'
+ steps:
+ - name: Setup Python
+ uses: actions/setup-python@v2
+
+ - name: Checkout TinyUSB
+ uses: actions/checkout@v2
+
+ - name: Checkout common submodules in lib
+ run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
+
+ - name: Set Toolchain URL
+ run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2
+
+ - name: Cache Toolchain
+ uses: actions/cache@v2
+ id: cache-toolchain
+ with:
+ path: ~/cache/
+ key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }}
+
+ - name: Install Toolchain
+ if: steps.cache-toolchain.outputs.cache-hit != 'true'
+ run: |
+ mkdir -p ~/cache/toolchain
+ wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.bz2
+ tar -C ~/cache/toolchain -xaf toolchain.tar.bz2
+
+ - name: Set Toolchain Path
+ run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
+
+ - name: Build
+ run: python3 tools/build_family.py ${{ matrix.family }}
+
+ - uses: actions/upload-artifact@v2
+ with:
+ name: ${{ matrix.family }}-tinyusb-examples
+ path: _bin/
+
+ - name: Create Release Asset
+ if: ${{ github.event_name == 'release' }}
+ run: |
+ cd _bin/
+ zip -r ../${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip *
+
+ - name: Upload Release Asset
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ if: ${{ github.event_name == 'release' }}
+ with:
+ upload_url: ${{ github.event.release.upload_url }}
+ asset_path: ${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip
+ asset_name: ${{ matrix.family }}-tinyusb-${{ github.event.release.tag_name }}-examples.zip
+ asset_content_type: application/zip
+
+ # ---------------------------------------
+ # Build all no-family (opharned) boards
+ # ---------------------------------------
+ build-board:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ example:
+ # Alphabetical order, a group of 4
+ - 'device/audio_test device/board_test device/cdc_dual_ports device/cdc_msc'
+ - 'device/cdc_msc_freertos device/dfu_runtime device/hid_composite device/hid_composite_freertos'
+ - 'device/hid_generic_inout device/hid_multiple_interface device/midi_test device/msc_dual_lun'
+ - 'device/net_lwip_webserver'
+ - 'device/uac2_headset device/usbtmc device/webusb_serial host/cdc_msc_hid'
+
+ steps:
+ - name: Setup Python
+ uses: actions/setup-python@v2
+
+ - name: Checkout TinyUSB
+ uses: actions/checkout@v2
+
+ - name: Checkout common submodules in lib
+ run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip
+
+ - name: Set Toolchain URL
+ run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-linux-x64.tar.gz
+
+ - name: Cache Toolchain
+ uses: actions/cache@v2
+ id: cache-toolchain
+ with:
+ path: ~/cache/
+ key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }}
+
+ - name: Install Toolchain
+ if: steps.cache-toolchain.outputs.cache-hit != 'true'
+ run: |
+ mkdir -p ~/cache/toolchain
+ wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz
+ tar -C ~/cache/toolchain -xaf toolchain.tar.gz
+
+ - name: Set Toolchain Path
+ run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
+
+ - name: Build
+ run: python3 tools/build_board.py ${{ matrix.example }}
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
index 46e2d807c..c0e6eef03 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -22,12 +22,6 @@
[submodule "lib/lwip"]
path = lib/lwip
url = https://github.com/lwip-tcpip/lwip.git
-[submodule "lib/FreeRTOS"]
- path = lib/FreeRTOS
- url = https://github.com/FreeRTOS/FreeRTOS.git
-[submodule "lib/CMSIS_4"]
- path = lib/CMSIS_4
- url = https://github.com/ARM-software/CMSIS.git
[submodule "hw/mcu/st/cmsis_device_f4"]
path = hw/mcu/st/cmsis_device_f4
url = https://github.com/STMicroelectronics/cmsis_device_f4.git
@@ -106,9 +100,6 @@
[submodule "hw/mcu/st/stm32l5xx_hal_driver"]
path = hw/mcu/st/stm32l5xx_hal_driver
url = https://github.com/STMicroelectronics/stm32l5xx_hal_driver.git
-[submodule "lib/CMSIS_5"]
- path = lib/CMSIS_5
- url = https://github.com/ARM-software/CMSIS_5.git
[submodule "lib/sct_neopixel"]
path = lib/sct_neopixel
url = https://github.com/gsteiert/sct_neopixel
@@ -116,4 +107,9 @@
path = hw/mcu/raspberrypi/pico-sdk
url = https://github.com/raspberrypi/pico-sdk.git
fetchRecurseSubmodules = false
-
+[submodule "lib/FreeRTOS-Kernel"]
+ path = lib/FreeRTOS-Kernel
+ url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
+[submodule "lib/CMSIS_5"]
+ path = lib/CMSIS_5
+ url = https://github.com/ARM-software/CMSIS_5.git
diff --git a/docs/boards.md b/docs/boards.md
index bff3f32be..275143118 100644
--- a/docs/boards.md
+++ b/docs/boards.md
@@ -94,9 +94,11 @@ This code base already had supported for a handful of following boards (sorted a
- [LPCXpresso 11u68](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc11u68:OM13058)
- [LPCXpresso 1347](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc1347:OM13045)
- [LPCXpresso 1769](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc1769:OM13000)
+- [LPCXpresso18S37 Development Board](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc4000-cortex-m4/lpcxpresso18s37-development-board:OM13076)
- [LPCXpresso 51U68](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpcxpresso51u68-for-the-lpc51u68-mcus:OM40005)
- [LPCXpresso 54114](https://www.nxp.com/design/microcontrollers-developer-resources/lpcxpresso-boards/lpcxpresso54114-board:OM13089)
-- [LPCXpresso 55s69 EVK](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc5500-cortex-m33/lpcxpresso55s69-development-board:LPC55S69-EVK)
+- [LPCXpresso 55s28 EVK](https://www.nxp.com/design/software/development-software/lpcxpresso55s28-development-board:LPC55S28-EVK)
+- [LPCXpresso 55s69 EVK](https://www.nxp.com/design/development-boards/lpcxpresso-boards/lpcxpresso55s69-development-board:LPC55S69-EVK)
- [NGX LPC4330-Xplorer](https://www.nxp.com/design/designs/lpc4330-xplorer-board:OM13027)
- [Double M33 Express](https://www.crowdsupply.com/steiert-solutions/double-m33-express)
@@ -104,7 +106,7 @@ This code base already had supported for a handful of following boards (sorted a
- [Adafruit Feather RP2040](https://www.adafruit.com/product/4884)
- [Adafruit ItsyBitsy RP2040](https://www.adafruit.com/product/4888)
-- Adafruit QT RP2040
+- [Adafruit QT Py RP2040](https://www.adafruit.com/product/4900)
- [Raspberry Pi Pico](https://www.raspberrypi.org/products/raspberry-pi-pico/)
### Sony
diff --git a/docs/getting_started.md b/docs/getting_started.md
index 06dcbd136..8ec0ea748 100644
--- a/docs/getting_started.md
+++ b/docs/getting_started.md
@@ -10,9 +10,9 @@ It is relatively simple to incorporate tinyusb to your (existing) project
- Make sure all required macros are all defined properly in tusb_config.h (configure file in demo application is sufficient, but you need to add a few more such as CFG_TUSB_MCU, CFG_TUSB_OS since they are passed by IDE/compiler to maintain a unique configure for all boards).
- If you use the device stack, make sure you have created/modified usb descriptors for your own need. Ultimately you need to implement all **tud_descriptor_** callbacks for the stack to work.
- Add tusb_init() call to your reset initialization code.
-- Call `tud_int_handler()` (device stack) and/or `tuh_int_handler()` in your USB IRQ Handler
+- Call `tud_int_handler()` (device) and/or `tuh_int_handler()` (host) in your USB IRQ Handler
- Implement all enabled classes's callbacks.
-- If you don't use any RTOSes at all, you need to continuously and/or periodically call tud_task()/tuh_task() function. All of the callbacks and functionality are handled and invoke within the call of that task runner.
+- If you don't use any RTOSes at all, you need to continuously and/or periodically call tud_task()/tuh_task() function. All of the callbacks and functionality are handled and invoked within the call of that task runner.
~~~{.c}
int main(void)
@@ -39,13 +39,15 @@ $ git clone https://github.com/hathach/tinyusb tinyusb
$ cd tinyusb
```
-TinyUSB examples includes external repos aka submodules to provide low-level MCU peripheral's driver as well as external libraries such as FreeRTOS to compile with. Therefore we will firstly fetch those mcu driver repo by running this command in the top folder repo
+Some TinyUSB examples also requires external submodule libraries in `/lib` such as FreeRTOS, Lightweight IP to build. Run following command to fetch them
```
-$ git submodule update --init --recursive
+$ git submodule update --init lib
```
-It will takes a bit of time due to the number of supported MCUs, luckily we only need to do this once. Or if you only want to test with a specific mcu, you could only fetch its driver submodule.
+In addition, MCU driver submodule is also needed to provide low-level MCU peripheral's driver. Luckily, it will be fetched if needed when you run the `make` to build your board.
+
+Note: some examples especially those that uses Vendor class (e.g webUSB) may requires udev permission on Linux (and/or macOS) to access usb device. It depends on your OS distro, typically copy `/examples/device/99-tinyusb.rules` file to /etc/udev/rules.d/ then run `sudo udevadm control --reload-rules && sudo udevadm trigger` is good enough.
### Build
@@ -61,6 +63,8 @@ Then compile with `make BOARD=[board_name] all`, for example
$ make BOARD=feather_nrf52840_express all
```
+Note: `BOARD` can be found as directory name in `hw/bsp`, either in its family/boards or directly under bsp (no family).
+
#### Port Selection
If a board has several ports, one port is chosen by default in the individual board.mk file. Use option `PORT=x` To choose another port. For example to select the HS port of a STM32F746Disco board, use:
diff --git a/tools/usb_drivers/99-tinyusb.rules b/examples/device/99-tinyusb.rules
similarity index 67%
rename from tools/usb_drivers/99-tinyusb.rules
rename to examples/device/99-tinyusb.rules
index 334159f9a..e6372ed58 100644
--- a/tools/usb_drivers/99-tinyusb.rules
+++ b/examples/device/99-tinyusb.rules
@@ -12,7 +12,3 @@ ATTRS{idVendor}=="cafe", MODE="0666", GROUP="dialout"
# Rule to blacklist TinyUSB example from being manipulated by ModemManager.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="cafe", ENV{ID_MM_DEVICE_IGNORE}="1"
-
-# Xplained Pro SamG55 Device
-SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="0666", GROUP="users", ENV{ID_MM_DEVICE_IGNORE}="1"
-SUBSYSTEMS=="tty", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE="0666", GROUP="users", ENV{ID_MM_DEVICE_IGNORE}="1"
diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt
index a10473b79..7038dd041 100644
--- a/examples/device/audio_test/CMakeLists.txt
+++ b/examples/device/audio_test/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt
index b8b7e7297..4e6a9b3f8 100644
--- a/examples/device/board_test/CMakeLists.txt
+++ b/examples/device/board_test/CMakeLists.txt
@@ -37,9 +37,6 @@ elseif(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt
index f4bf75c26..5e3ec0909 100644
--- a/examples/device/cdc_dual_ports/CMakeLists.txt
+++ b/examples/device/cdc_dual_ports/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt
index 9e0d1f790..41dd167b7 100644
--- a/examples/device/cdc_msc/CMakeLists.txt
+++ b/examples/device/cdc_msc/CMakeLists.txt
@@ -39,9 +39,6 @@ elseif(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/cdc_msc/ses/nrf5x/nrf5x.emProject b/examples/device/cdc_msc/ses/nrf5x/nrf5x.emProject
index f7714f269..944199138 100644
--- a/examples/device/cdc_msc/ses/nrf5x/nrf5x.emProject
+++ b/examples/device/cdc_msc/ses/nrf5x/nrf5x.emProject
@@ -21,7 +21,7 @@
build_treat_warnings_as_errors="Yes"
c_additional_options="-Wno-error=undef;-Wno-error=unused-parameter;-Wno-error=cast-align;-Wno-error=cast-function-type"
c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;CFG_TUSB_MCU=OPT_MCU_NRF5X;CFG_TUSB_DEBUG=1"
- c_user_include_directories="../../src;$(rootDir)/lib/CMSIS_4/CMSIS/Include;$(rootDir)/hw;$(rootDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(nrfxDir)/drivers/src"
+ c_user_include_directories="../../src;$(rootDir)/lib/CMSIS_5/CMSIS/Core/Include;$(rootDir)/hw;$(rootDir)/src;$(nrfxDir)/..;$(nrfxDir);$(nrfxDir)/mdk;$(nrfxDir)/hal;$(nrfxDir)/drivers/include;$(nrfxDir)/drivers/src"
debug_register_definition_file="nrf52840_Registers.xml"
debug_target_connection="J-Link"
gcc_enable_all_warnings="Yes"
diff --git a/examples/device/cdc_msc_freertos/Makefile b/examples/device/cdc_msc_freertos/Makefile
index 3570daa41..36174b5e1 100644
--- a/examples/device/cdc_msc_freertos/Makefile
+++ b/examples/device/cdc_msc_freertos/Makefile
@@ -1,7 +1,7 @@
include ../../../tools/top.mk
include ../../make.mk
-FREERTOS_SRC = lib/FreeRTOS/FreeRTOS/Source
+FREERTOS_SRC = lib/FreeRTOS-Kernel
INC += \
src \
diff --git a/examples/device/cdc_msc_freertos/ses/lpc175x_6x/lpc175x_6x.emProject b/examples/device/cdc_msc_freertos/ses/lpc175x_6x/lpc175x_6x.emProject
index 4dc111f2e..691f8c3b0 100644
--- a/examples/device/cdc_msc_freertos/ses/lpc175x_6x/lpc175x_6x.emProject
+++ b/examples/device/cdc_msc_freertos/ses/lpc175x_6x/lpc175x_6x.emProject
@@ -20,7 +20,7 @@
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="No"
c_preprocessor_definitions="LPC175x_6x;__LPC1700_FAMILY;__LPC176x_SUBFAMILY;ARM_MATH_CM3;FLASH_PLACEMENT=1;CORE_M3;CFG_TUSB_MCU=OPT_MCU_LPC175X_6X"
- c_user_include_directories=".;../../src;$(rootDir)/hw;$(rootDir)/src;$(rootDir)/hw/mcu/nxp/lpc_driver/lpc_chip_175x_6x/inc;$(rootDir)/lib/FreeRTOS/Source/include;$(rootDir)/lib/FreeRTOS/Source/portable/GCC/ARM_CM3"
+ c_user_include_directories=".;../../src;$(rootDir)/hw;$(rootDir)/src;$(rootDir)/hw/mcu/nxp/lpc_driver/lpc_chip_175x_6x/inc;$(rootDir)/lib/FreeRTOS-Kernel/include;$(rootDir)/lib/FreeRTOS-Kernel/portable/GCC/ARM_CM3"
debug_register_definition_file="LPC176x5x_Registers.xml"
debug_target_connection="J-Link"
gcc_enable_all_warnings="Yes"
@@ -92,39 +92,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
diff --git a/examples/device/cdc_msc_freertos/ses/nrf5x/nrf5x.emProject b/examples/device/cdc_msc_freertos/ses/nrf5x/nrf5x.emProject
index f01b26d23..e964d6fb5 100644
--- a/examples/device/cdc_msc_freertos/ses/nrf5x/nrf5x.emProject
+++ b/examples/device/cdc_msc_freertos/ses/nrf5x/nrf5x.emProject
@@ -107,39 +107,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
diff --git a/examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject b/examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject
index b8b099b68..b3db856d3 100644
--- a/examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject
+++ b/examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject
@@ -100,39 +100,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
diff --git a/examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject b/examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject
index d84d070c0..77ff38b62 100644
--- a/examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject
+++ b/examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject
@@ -104,39 +104,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
diff --git a/examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h b/examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h
index 494452d43..7b2b93d7b 100644
--- a/examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h
+++ b/examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h
@@ -71,6 +71,7 @@ extern uint32_t SystemCoreClock;
#define configUSE_TIME_SLICING 0
#define configUSE_NEWLIB_REENTRANT 0
#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 0
diff --git a/examples/device/cdc_msc_freertos/src/freertos_hook.c b/examples/device/cdc_msc_freertos/src/freertos_hook.c
index 423bad4d3..df15a8de7 100644
--- a/examples/device/cdc_msc_freertos/src/freertos_hook.c
+++ b/examples/device/cdc_msc_freertos/src/freertos_hook.c
@@ -37,7 +37,7 @@ void vApplicationMallocFailedHook(void)
TU_ASSERT(false, );
}
-void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName)
+void vApplicationStackOverflowHook(xTaskHandle pxTask, char *pcTaskName)
{
(void) pxTask;
(void) pcTaskName;
diff --git a/examples/device/dfu_runtime/CMakeLists.txt b/examples/device/dfu_runtime/CMakeLists.txt
index f4bf75c26..5e3ec0909 100644
--- a/examples/device/dfu_runtime/CMakeLists.txt
+++ b/examples/device/dfu_runtime/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt
index b4c95652a..be6224360 100644
--- a/examples/device/dynamic_configuration/CMakeLists.txt
+++ b/examples/device/dynamic_configuration/CMakeLists.txt
@@ -34,9 +34,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt
index f4bf75c26..5e3ec0909 100644
--- a/examples/device/hid_composite/CMakeLists.txt
+++ b/examples/device/hid_composite/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/hid_composite_freertos/Makefile b/examples/device/hid_composite_freertos/Makefile
index cef1af5a6..db7dfd345 100644
--- a/examples/device/hid_composite_freertos/Makefile
+++ b/examples/device/hid_composite_freertos/Makefile
@@ -1,7 +1,7 @@
include ../../../tools/top.mk
include ../../make.mk
-FREERTOS_SRC = lib/FreeRTOS/FreeRTOS/Source
+FREERTOS_SRC = lib/FreeRTOS-Kernel
INC += \
src \
diff --git a/examples/device/hid_composite_freertos/src/FreeRTOSConfig.h b/examples/device/hid_composite_freertos/src/FreeRTOSConfig.h
index 494452d43..7b2b93d7b 100644
--- a/examples/device/hid_composite_freertos/src/FreeRTOSConfig.h
+++ b/examples/device/hid_composite_freertos/src/FreeRTOSConfig.h
@@ -71,6 +71,7 @@ extern uint32_t SystemCoreClock;
#define configUSE_TIME_SLICING 0
#define configUSE_NEWLIB_REENTRANT 0
#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 0
diff --git a/examples/device/hid_composite_freertos/src/freertos_hook.c b/examples/device/hid_composite_freertos/src/freertos_hook.c
index 423bad4d3..df15a8de7 100644
--- a/examples/device/hid_composite_freertos/src/freertos_hook.c
+++ b/examples/device/hid_composite_freertos/src/freertos_hook.c
@@ -37,7 +37,7 @@ void vApplicationMallocFailedHook(void)
TU_ASSERT(false, );
}
-void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName)
+void vApplicationStackOverflowHook(xTaskHandle pxTask, char *pcTaskName)
{
(void) pxTask;
(void) pcTaskName;
diff --git a/examples/device/hid_generic_inout/CMakeLists.txt b/examples/device/hid_generic_inout/CMakeLists.txt
index f4bf75c26..5e3ec0909 100644
--- a/examples/device/hid_generic_inout/CMakeLists.txt
+++ b/examples/device/hid_generic_inout/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/hid_multiple_interface/CMakeLists.txt b/examples/device/hid_multiple_interface/CMakeLists.txt
index f4bf75c26..5e3ec0909 100644
--- a/examples/device/hid_multiple_interface/CMakeLists.txt
+++ b/examples/device/hid_multiple_interface/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/midi_test/CMakeLists.txt b/examples/device/midi_test/CMakeLists.txt
index f4bf75c26..5e3ec0909 100644
--- a/examples/device/midi_test/CMakeLists.txt
+++ b/examples/device/midi_test/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/msc_dual_lun/CMakeLists.txt b/examples/device/msc_dual_lun/CMakeLists.txt
index 6032308f2..0036dc685 100644
--- a/examples/device/msc_dual_lun/CMakeLists.txt
+++ b/examples/device/msc_dual_lun/CMakeLists.txt
@@ -34,9 +34,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt
index e3c8190f4..c9aabc636 100644
--- a/examples/device/net_lwip_webserver/CMakeLists.txt
+++ b/examples/device/net_lwip_webserver/CMakeLists.txt
@@ -80,9 +80,6 @@ if(FAMILY STREQUAL "rp2040")
HTTPD_USE_CUSTOM_FSDATA=0
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/uac2_headset/CMakeLists.txt b/examples/device/uac2_headset/CMakeLists.txt
index f4bf75c26..5e3ec0909 100644
--- a/examples/device/uac2_headset/CMakeLists.txt
+++ b/examples/device/uac2_headset/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt
index 9a4aa382b..808bdbcf8 100644
--- a/examples/device/usbtmc/CMakeLists.txt
+++ b/examples/device/usbtmc/CMakeLists.txt
@@ -34,9 +34,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/webusb_serial/CMakeLists.txt b/examples/device/webusb_serial/CMakeLists.txt
index f4bf75c26..5e3ec0909 100644
--- a/examples/device/webusb_serial/CMakeLists.txt
+++ b/examples/device/webusb_serial/CMakeLists.txt
@@ -33,9 +33,6 @@ if(FAMILY STREQUAL "rp2040")
CFG_TUSB_OS=OPT_OS_PICO
)
- target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration)
- pico_add_extra_outputs(${PROJECT})
-
else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
diff --git a/examples/device/webusb_serial/src/main.c b/examples/device/webusb_serial/src/main.c
index 143a73374..c85b3cc9a 100644
--- a/examples/device/webusb_serial/src/main.c
+++ b/examples/device/webusb_serial/src/main.c
@@ -23,6 +23,26 @@
*
*/
+/* This example demonstrates WebUSB as web serial with browser with WebUSB support (e.g Chrome).
+ * After enumerated successfully, browser will pop-up notification
+ * with URL to landing page, click on it to test
+ * - Click "Connect" and select device, When connected the on-board LED will litted up.
+ * - Any charters received from either webusb/Serial will be echo back to webusb and Serial
+ *
+ * Note:
+ * - The WebUSB landing page notification is currently disabled in Chrome
+ * on Windows due to Chromium issue 656702 (https://crbug.com/656702). You have to
+ * go to landing page (below) to test
+ *
+ * - On Windows 7 and prior: You need to use Zadig tool to manually bind the
+ * WebUSB interface with the WinUSB driver for Chrome to access. From windows 8 and 10, this
+ * is done automatically by firmware.
+ *
+ * - On Linux/macOS, udev permission may need to be updated by
+ * - copying '/examples/device/99-tinyusb.rules' file to /etc/udev/rules.d/ then
+ * - run 'sudo udevadm control --reload-rules && sudo udevadm trigger'
+ */
+
#include
#include
#include
@@ -149,52 +169,59 @@ void tud_resume_cb(void)
bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request)
{
// nothing to with DATA & ACK stage
- if (stage != CONTROL_STAGE_SETUP ) return true;
+ if (stage != CONTROL_STAGE_SETUP) return true;
- if (request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR) {
- switch (request->bRequest)
- {
- case VENDOR_REQUEST_WEBUSB:
- // match vendor request in BOS descriptor
- // Get landing page url
- return tud_control_xfer(rhport, request, (void*) &desc_url, desc_url.bLength);
+ switch (request->bmRequestType_bit.type)
+ {
+ case TUSB_REQ_TYPE_VENDOR:
+ switch (request->bRequest)
+ {
+ case VENDOR_REQUEST_WEBUSB:
+ // match vendor request in BOS descriptor
+ // Get landing page url
+ return tud_control_xfer(rhport, request, (void*) &desc_url, desc_url.bLength);
- case VENDOR_REQUEST_MICROSOFT:
- if ( request->wIndex == 7 )
+ case VENDOR_REQUEST_MICROSOFT:
+ if ( request->wIndex == 7 )
+ {
+ // Get Microsoft OS 2.0 compatible descriptor
+ uint16_t total_len;
+ memcpy(&total_len, desc_ms_os_20+8, 2);
+
+ return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len);
+ }else
+ {
+ return false;
+ }
+
+ default: break;
+ }
+ break;
+
+ case TUSB_REQ_TYPE_CLASS:
+ if (request->bRequest == 0x22)
+ {
+ // Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to connect and disconnect.
+ web_serial_connected = (request->wValue != 0);
+
+ // Always lit LED if connected
+ if ( web_serial_connected )
{
- // Get Microsoft OS 2.0 compatible descriptor
- uint16_t total_len;
- memcpy(&total_len, desc_ms_os_20+8, 2);
+ board_led_write(true);
+ blink_interval_ms = BLINK_ALWAYS_ON;
- return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len);
+ tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n");
}else
{
- return false;
+ blink_interval_ms = BLINK_MOUNTED;
}
- default:
- return false;
- }
- } else if (
- request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS &&
- request->bRequest == 0x22) {
- // Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to
- // connect and disconnect.
- web_serial_connected = (request->wValue != 0);
+ // response with status OK
+ return tud_control_status(rhport, request);
+ }
+ break;
- // Always lit LED if connected
- if ( web_serial_connected ) {
- board_led_write(true);
- blink_interval_ms = BLINK_ALWAYS_ON;
-
- tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n");
- }else
- {
- blink_interval_ms = BLINK_MOUNTED;
- }
-
- // response with status OK
- return tud_control_status(rhport, request);
+ default: break;
}
// stall unknown request
diff --git a/examples/host/cdc_msc_hid/.only.MCU_RP2040 b/examples/host/cdc_msc_hid/.only.MCU_RP2040
new file mode 100644
index 000000000..e69de29bb
diff --git a/examples/host/cdc_msc_hid/CMakeLists.txt b/examples/host/cdc_msc_hid/CMakeLists.txt
new file mode 100644
index 000000000..2302678b7
--- /dev/null
+++ b/examples/host/cdc_msc_hid/CMakeLists.txt
@@ -0,0 +1,43 @@
+# use directory name for project id
+get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+set(PROJECT ${BOARD}-${PROJECT})
+
+# TOP is absolute path to root directory of TinyUSB git repo
+set(TOP "../../..")
+get_filename_component(TOP "${TOP}" REALPATH)
+
+# Check for -DFAMILY=
+if(FAMILY STREQUAL "esp32s2")
+ cmake_minimum_required(VERSION 3.5)
+ include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+ project(${PROJECT})
+
+elseif(FAMILY STREQUAL "rp2040")
+ cmake_minimum_required(VERSION 3.12)
+ set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk)
+ include(${PICO_SDK_PATH}/pico_sdk_init.cmake)
+ project(${PROJECT})
+ pico_sdk_init()
+ add_executable(${PROJECT})
+
+ include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
+
+ # Example source
+ target_sources(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c
+ )
+
+ # Example include
+ target_include_directories(${PROJECT} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
+
+ # Example defines
+ target_compile_definitions(${PROJECT} PUBLIC
+ CFG_TUSB_OS=OPT_OS_PICO
+ )
+
+else()
+ message(FATAL_ERROR "Invalid FAMILY specified")
+endif()
diff --git a/examples/make.mk b/examples/make.mk
index 5387a4ec4..82fbd020b 100644
--- a/examples/make.mk
+++ b/examples/make.mk
@@ -15,24 +15,14 @@ check_defined = \
__check_defined = \
$(if $(value $1),, \
$(error Undefined make flag: $1$(if $2, ($2))))
-
-# TODO Check if submodule haven't checkout yet
-fetch_submodule_if_empty = \
- ifeq ($(wildcard $(TOP)/$1/*),) \
- $(info $(shell git -C $(TOP) submodule update --init)) \
- endif
#-------------- Select the board to build for. ------------
-#BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.))))
-#ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
-# $(info You must provide a BOARD parameter with 'BOARD=', supported boards are:)
-# $(foreach b,$(BOARD_LIST),$(info - $(b)))
-# $(error Invalid BOARD specified)
-#endif
# Board without family
-BOARD_PATH := $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)))
+ifneq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/board.mk),)
+BOARD_PATH := hw/bsp/$(BOARD)
FAMILY :=
+endif
# Board within family
ifeq ($(BOARD_PATH),)
@@ -42,6 +32,7 @@ ifeq ($(BOARD_PATH),)
endif
ifeq ($(BOARD_PATH),)
+ $(info You must provide a BOARD parameter with 'BOARD=')
$(error Invalid BOARD specified)
endif
@@ -56,6 +47,16 @@ endif
#TODO $(call fetch_submodule_if_empty,lib/sct_neopixel)
+# Fetch submodules depended by family
+fetch_submodule_if_empty = \
+ ifeq ($(wildcard $(TOP)/$1/*),) \
+ $(info $(shell git -C $(TOP) submodule update --init $1)) \
+ endif
+
+ifdef DEPS_SUBMODULES
+ $(foreach s,$(DEPS_SUBMODULES),:$(call fetch_submodule_if_empty,$(s)))
+endif
+
#-------------- Cross Compiler ------------
# Can be set by board, default to ARM GCC
CROSS_COMPILE ?= arm-none-eabi-
@@ -65,13 +66,14 @@ CXX = $(CROSS_COMPILE)g++
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
MKDIR = mkdir
+
ifeq ($(CMDEXE),1)
-CP = copy
-RM = del
+ CP = copy
+ RM = del
else
-SED = sed
-CP = cp
-RM = rm
+ SED = sed
+ CP = cp
+ RM = rm
endif
#-------------- Source files and compiler flags --------------
@@ -80,6 +82,8 @@ endif
SRC_C += hw/bsp/board.c
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_PATH)/*.c))
+INC += $(TOP)/$(FAMILY_PATH)
+
# Compiler Flags
CFLAGS += \
-ggdb \
diff --git a/examples/rules.mk b/examples/rules.mk
index d248ed247..a97eb566a 100644
--- a/examples/rules.mk
+++ b/examples/rules.mk
@@ -6,7 +6,9 @@
.DEFAULT_GOAL := all
ifeq ($(FAMILY),esp32s2)
+# ---------------------------------------
# Espressif IDF use CMake build system, this add wrapper target to call idf.py
+# ---------------------------------------
.PHONY: all clean flash
@@ -44,6 +46,9 @@ $(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).bin
$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -b 0x0 -c -o $@ $^
else ifeq ($(FAMILY),rp2040)
+# ---------------------------------------
+# RP2040 CMake
+# ---------------------------------------
ifeq ($(DEBUG), 1)
CMAKE_DEFSYM += -DCMAKE_BUILD_TYPE=Debug
@@ -58,11 +63,14 @@ all: $(BUILD)
clean:
$(RM) -rf $(BUILD)
+#flash: flash-pyocd
flash:
@$(CP) $(BUILD)/$(PROJECT).uf2 /media/$(USER)/RPI-RP2
else
+# ---------------------------------------
# GNU Make build system
+# ---------------------------------------
# libc
LIBS += -lgcc -lm -lnosys
@@ -93,12 +101,11 @@ INC += $(TOP)/src
CFLAGS += $(addprefix -I,$(INC))
-# TODO Skip nanolib for MSP430
-ifeq ($(BOARD), msp_exp430f5529lp)
- LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections
-else
- LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nosys.specs -specs=nano.specs
+LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections
+ifneq ($(SKIP_NANOLIB), 1)
+LDFLAGS += -specs=nosys.specs -specs=nano.specs
endif
+
ASFLAGS += $(CFLAGS)
# Assembly files can be name with upper case .S, convert it to .s
@@ -188,6 +195,8 @@ else
$(RM) -rf $(BUILD)
endif
+endif # GNU Make
+
# Print out the value of a make variable.
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
print-%:
@@ -221,7 +230,6 @@ flash-pyocd: $(BUILD)/$(PROJECT).hex
pyocd flash -t $(PYOCD_TARGET) $<
pyocd reset -t $(PYOCD_TARGET)
-endif # GNU Make
#-------------- Artifacts --------------
diff --git a/hw/bsp/d5035_01/board.mk b/hw/bsp/d5035_01/board.mk
index 4d126dc41..dc364a70c 100644
--- a/hw/bsp/d5035_01/board.mk
+++ b/hw/bsp/d5035_01/board.mk
@@ -1,3 +1,4 @@
+DEPS_SUBMODULES = hw/mcu/microchip
HWREV ?= 1
CFLAGS += \
@@ -21,30 +22,30 @@ CFLAGS += \
LD_FILE = hw/bsp/$(BOARD)/same51j19a_flash.ld
SRC_C += \
- hw/mcu/microchip/asf4/same51/gcc/gcc/startup_same51.c \
- hw/mcu/microchip/asf4/same51/gcc/system_same51.c \
+ hw/mcu/microchip/same51/gcc/gcc/startup_same51.c \
+ hw/mcu/microchip/same51/gcc/system_same51.c \
ifdef SYSCALLS
ifneq ($(SYSCALLS),0)
- SRC_C += hw/mcu/microchip/asf4/same51/hal/utils/src/utils_syscalls.c
+ SRC_C += hw/mcu/microchip/same51/hal/utils/src/utils_syscalls.c
endif
endif
ifdef LOG
ifneq ($(LOG),0)
- SRC_C += hw/mcu/microchip/asf4/same51/hal/utils/src/utils_syscalls.c
+ SRC_C += hw/mcu/microchip/same51/hal/utils/src/utils_syscalls.c
endif
endif
INC += \
- $(TOP)/hw/mcu/microchip/asf4/same51/ \
- $(TOP)/hw/mcu/microchip/asf4/same51/config \
- $(TOP)/hw/mcu/microchip/asf4/same51/include \
- $(TOP)/hw/mcu/microchip/asf4/same51/hal/include \
- $(TOP)/hw/mcu/microchip/asf4/same51/hal/utils/include \
- $(TOP)/hw/mcu/microchip/asf4/same51/hpl/port \
- $(TOP)/hw/mcu/microchip/asf4/same51/hri \
- $(TOP)/hw/mcu/microchip/asf4/same51/CMSIS/Include
+ $(TOP)/hw/mcu/microchip/same51/ \
+ $(TOP)/hw/mcu/microchip/same51/config \
+ $(TOP)/hw/mcu/microchip/same51/include \
+ $(TOP)/hw/mcu/microchip/same51/hal/include \
+ $(TOP)/hw/mcu/microchip/same51/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/same51/hpl/port \
+ $(TOP)/hw/mcu/microchip/same51/hri \
+ $(TOP)/hw/mcu/microchip/same51/CMSIS/Include
# For TinyUSB port source
VENDOR = microchip
diff --git a/hw/bsp/da14695_dk_usb/board.mk b/hw/bsp/da14695_dk_usb/board.mk
index 2e76012d2..58f3947cc 100644
--- a/hw/bsp/da14695_dk_usb/board.mk
+++ b/hw/bsp/da14695_dk_usb/board.mk
@@ -1,4 +1,4 @@
- CFLAGS += \
+CFLAGS += \
-flto \
-mthumb \
-mthumb-interwork \
diff --git a/hw/bsp/da1469x_dk_pro/board.mk b/hw/bsp/da1469x_dk_pro/board.mk
index 52064e63c..5362498ea 100644
--- a/hw/bsp/da1469x_dk_pro/board.mk
+++ b/hw/bsp/da1469x_dk_pro/board.mk
@@ -1,4 +1,4 @@
- CFLAGS += \
+CFLAGS += \
-flto \
-mthumb \
-mthumb-interwork \
diff --git a/hw/bsp/ea4088qs/board.mk b/hw/bsp/ea4088qs/board.mk
index 15e0bfb86..51e5babe8 100644
--- a/hw/bsp/ea4088qs/board.mk
+++ b/hw/bsp/ea4088qs/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/ea4357/board.mk b/hw/bsp/ea4357/board.mk
index f6c42e0cf..09c782cac 100644
--- a/hw/bsp/ea4357/board.mk
+++ b/hw/bsp/ea4357/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/fomu/boards/fomu/board.h b/hw/bsp/fomu/boards/fomu/board.h
new file mode 100644
index 000000000..666ba1d98
--- /dev/null
+++ b/hw/bsp/fomu/boards/fomu/board.h
@@ -0,0 +1,40 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// Place holder only
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/fomu/boards/fomu/board.mk b/hw/bsp/fomu/boards/fomu/board.mk
new file mode 100644
index 000000000..8ced11412
--- /dev/null
+++ b/hw/bsp/fomu/boards/fomu/board.mk
@@ -0,0 +1 @@
+# place holder
\ No newline at end of file
diff --git a/hw/bsp/fomu/board.mk b/hw/bsp/fomu/family.mk
similarity index 79%
rename from hw/bsp/fomu/board.mk
rename to hw/bsp/fomu/family.mk
index f31dfec2a..f615216be 100644
--- a/hw/bsp/fomu/board.mk
+++ b/hw/bsp/fomu/family.mk
@@ -8,16 +8,13 @@ CFLAGS += \
# Cross Compiler for RISC-V
CROSS_COMPILE = riscv-none-embed-
-MCU_DIR = hw/mcu/fomu
-BSP_DIR = hw/bsp/fomu
-
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/fomu.ld
+LD_FILE = $(FAMILY_PATH)/fomu.ld
-SRC_S += hw/bsp/$(BOARD)/crt0-vexriscv.S
+SRC_S += $(FAMILY_PATH)/crt0-vexriscv.S
INC += \
- $(TOP)/$(BSP_DIR)/include
+ $(TOP)/$(FAMILY_PATH)/include
# For TinyUSB port source
VENDOR = valentyusb
diff --git a/hw/bsp/frdm_kl25z/board.mk b/hw/bsp/frdm_kl25z/board.mk
index 9d86c4542..5ad4d2052 100644
--- a/hw/bsp/frdm_kl25z/board.mk
+++ b/hw/bsp/frdm_kl25z/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-mthumb \
-mabi=aapcs \
diff --git a/hw/bsp/imxrt/family.mk b/hw/bsp/imxrt/family.mk
index 3311768bd..c07e68d2b 100644
--- a/hw/bsp/imxrt/family.mk
+++ b/hw/bsp/imxrt/family.mk
@@ -1,4 +1,5 @@
UF2_FAMILY_ID = 0x4fb2d5bd
+DEPS_SUBMODULES = hw/mcu/nxp
include $(TOP)/$(BOARD_PATH)/board.mk
diff --git a/hw/bsp/lpc18/boards/lpcxpresso18s37/board.h b/hw/bsp/lpc18/boards/lpcxpresso18s37/board.h
new file mode 100644
index 000000000..b3a7bc44f
--- /dev/null
+++ b/hw/bsp/lpc18/boards/lpcxpresso18s37/board.h
@@ -0,0 +1,77 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+// Note: For USB Host demo, install JP4
+// WARNING: don't install JP4 when running as device
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED Red
+#define LED_PORT 3
+#define LED_PIN 7
+
+// ISP Button
+#define BUTTON_PORT 0
+#define BUTTON_PIN 7
+
+#define UART_DEV LPC_USART0
+
+static inline void board_lpc18_pinmux(void)
+{
+ const PINMUX_GRP_T pinmuxing[] =
+ {
+ // LEDs
+ { 0x6, 9 , SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP | SCU_MODE_FUNC0 },
+ { 0x6, 11, SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP | SCU_MODE_FUNC0 },
+
+ // Button
+ { 0x2, 7, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0 },
+
+ // UART
+ { 0x06, 4, SCU_MODE_PULLDOWN | SCU_MODE_FUNC2 },
+ { 0x02, 1, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC1 },
+
+ // USB0
+ //{ 0x6, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1 }, // P6_3 USB0_PWR_EN, USB0 VBus function
+
+ //{ 0x9, 5, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2 }, // P9_5 USB1_VBUS_EN, USB1 VBus function
+ //{ 0x2, 5, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 }, // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION
+ {0x2, 5, SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP | SCU_MODE_FUNC4 },
+ };
+
+ Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/lpc18/boards/lpcxpresso18s37/board.mk b/hw/bsp/lpc18/boards/lpcxpresso18s37/board.mk
new file mode 100644
index 000000000..29b129130
--- /dev/null
+++ b/hw/bsp/lpc18/boards/lpcxpresso18s37/board.mk
@@ -0,0 +1,6 @@
+LD_FILE = $(BOARD_PATH)/lpc1837.ld
+
+# For flash-jlink target
+JLINK_DEVICE = LPC18S37
+
+flash: flash-jlink
diff --git a/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld b/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld
new file mode 100644
index 000000000..51fd1539d
--- /dev/null
+++ b/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld
@@ -0,0 +1,404 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * Copyright (c) 2008-2013 Code Red Technologies Ltd,
+ * Copyright 2015, 2018-2019 NXP
+ * (c) NXP Semiconductors 2013-2021
+ * Generated linker script file for LPC1837
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v11.2.0 [Build 4120] [2020-07-09] on Mar 3, 2021 4:22:49 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlashA512 (rx) : ORIGIN = 0x1a000000, LENGTH = 0x80000 /* 512K bytes (alias Flash) */
+ MFlashB512 (rx) : ORIGIN = 0x1b000000, LENGTH = 0x80000 /* 512K bytes (alias Flash2) */
+ RamLoc32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */
+ RamLoc40 (rwx) : ORIGIN = 0x10080000, LENGTH = 0xa000 /* 40K bytes (alias RAM2) */
+ RamAHB32 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM3) */
+ RamAHB16 (rwx) : ORIGIN = 0x20008000, LENGTH = 0x4000 /* 16K bytes (alias RAM4) */
+ RamAHB_ETB16 (rwx) : ORIGIN = 0x2000c000, LENGTH = 0x4000 /* 16K bytes (alias RAM5) */
+}
+
+/* Define a symbol for the top of each memory region */
+__base_MFlashA512 = 0x1a000000 ; /* MFlashA512 */
+__base_Flash = 0x1a000000 ; /* Flash */
+__top_MFlashA512 = 0x1a000000 + 0x80000 ; /* 512K bytes */
+__top_Flash = 0x1a000000 + 0x80000 ; /* 512K bytes */
+__base_MFlashB512 = 0x1b000000 ; /* MFlashB512 */
+__base_Flash2 = 0x1b000000 ; /* Flash2 */
+__top_MFlashB512 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+__top_Flash2 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+__base_RamLoc32 = 0x10000000 ; /* RamLoc32 */
+__base_RAM = 0x10000000 ; /* RAM */
+__top_RamLoc32 = 0x10000000 + 0x8000 ; /* 32K bytes */
+__top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
+__base_RamLoc40 = 0x10080000 ; /* RamLoc40 */
+__base_RAM2 = 0x10080000 ; /* RAM2 */
+__top_RamLoc40 = 0x10080000 + 0xa000 ; /* 40K bytes */
+__top_RAM2 = 0x10080000 + 0xa000 ; /* 40K bytes */
+__base_RamAHB32 = 0x20000000 ; /* RamAHB32 */
+__base_RAM3 = 0x20000000 ; /* RAM3 */
+__top_RamAHB32 = 0x20000000 + 0x8000 ; /* 32K bytes */
+__top_RAM3 = 0x20000000 + 0x8000 ; /* 32K bytes */
+__base_RamAHB16 = 0x20008000 ; /* RamAHB16 */
+__base_RAM4 = 0x20008000 ; /* RAM4 */
+__top_RamAHB16 = 0x20008000 + 0x4000 ; /* 16K bytes */
+__top_RAM4 = 0x20008000 + 0x4000 ; /* 16K bytes */
+__base_RamAHB_ETB16 = 0x2000c000 ; /* RamAHB_ETB16 */
+__base_RAM5 = 0x2000c000 ; /* RAM5 */
+__top_RamAHB_ETB16 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+__top_RAM5 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ .text_Flash2 : ALIGN(4)
+ {
+ FILL(0xff)
+ *(.text_Flash2) /* for compatibility with previous releases */
+ *(.text_MFlashB512) /* for compatibility with previous releases */
+ *(.text.$Flash2)
+ *(.text.$MFlashB512)
+ *(.text_Flash2.*) /* for compatibility with previous releases */
+ *(.text_MFlashB512.*) /* for compatibility with previous releases */
+ *(.text.$Flash2.*)
+ *(.text.$MFlashB512.*)
+ *(.rodata.$Flash2)
+ *(.rodata.$MFlashB512)
+ *(.rodata.$Flash2.*)
+ *(.rodata.$MFlashB512.*) } > MFlashB512
+
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ LONG(LOADADDR(.data_RAM3));
+ LONG( ADDR(.data_RAM3));
+ LONG( SIZEOF(.data_RAM3));
+ LONG(LOADADDR(.data_RAM4));
+ LONG( ADDR(.data_RAM4));
+ LONG( SIZEOF(.data_RAM4));
+ LONG(LOADADDR(.data_RAM5));
+ LONG( ADDR(.data_RAM5));
+ LONG( SIZEOF(.data_RAM5));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ LONG( ADDR(.bss_RAM3));
+ LONG( SIZEOF(.bss_RAM3));
+ LONG( ADDR(.bss_RAM4));
+ LONG( SIZEOF(.bss_RAM4));
+ LONG( ADDR(.bss_RAM5));
+ LONG( SIZEOF(.bss_RAM5));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlashA512
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlashA512
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlashA512
+
+ .ARM.exidx : ALIGN(4)
+ {
+ __exidx_start = .;
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ __exidx_end = .;
+ } > MFlashA512
+
+ _etext = .;
+
+ /* DATA section for RamLoc40 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ PROVIDE(__start_data_RamLoc40 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamLoc40)
+ *(.data.$RAM2)
+ *(.data.$RamLoc40)
+ *(.data.$RAM2.*)
+ *(.data.$RamLoc40.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ PROVIDE(__end_data_RamLoc40 = .) ;
+ } > RamLoc40 AT>MFlashA512
+
+ /* DATA section for RamAHB32 */
+
+ .data_RAM3 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM3 = .) ;
+ PROVIDE(__start_data_RamAHB32 = .) ;
+ *(.ramfunc.$RAM3)
+ *(.ramfunc.$RamAHB32)
+ *(.data.$RAM3)
+ *(.data.$RamAHB32)
+ *(.data.$RAM3.*)
+ *(.data.$RamAHB32.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM3 = .) ;
+ PROVIDE(__end_data_RamAHB32 = .) ;
+ } > RamAHB32 AT>MFlashA512
+
+ /* DATA section for RamAHB16 */
+
+ .data_RAM4 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM4 = .) ;
+ PROVIDE(__start_data_RamAHB16 = .) ;
+ *(.ramfunc.$RAM4)
+ *(.ramfunc.$RamAHB16)
+ *(.data.$RAM4)
+ *(.data.$RamAHB16)
+ *(.data.$RAM4.*)
+ *(.data.$RamAHB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM4 = .) ;
+ PROVIDE(__end_data_RamAHB16 = .) ;
+ } > RamAHB16 AT>MFlashA512
+
+ /* DATA section for RamAHB_ETB16 */
+
+ .data_RAM5 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM5 = .) ;
+ PROVIDE(__start_data_RamAHB_ETB16 = .) ;
+ *(.ramfunc.$RAM5)
+ *(.ramfunc.$RamAHB_ETB16)
+ *(.data.$RAM5)
+ *(.data.$RamAHB_ETB16)
+ *(.data.$RAM5.*)
+ *(.data.$RamAHB_ETB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM5 = .) ;
+ PROVIDE(__end_data_RamAHB_ETB16 = .) ;
+ } > RamAHB_ETB16 AT>MFlashA512
+
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED (NOLOAD) : ALIGN(4)
+ {
+ _start_uninit_RESERVED = .;
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc32 AT> RamLoc32
+
+ /* Main DATA section (RamLoc32) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ PROVIDE(__start_data_RAM = .) ;
+ PROVIDE(__start_data_RamLoc32 = .) ;
+ *(vtable)
+ *(.ramfunc*)
+ KEEP(*(CodeQuickAccess))
+ KEEP(*(DataQuickAccess))
+ *(RamFunction)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ PROVIDE(__end_data_RAM = .) ;
+ PROVIDE(__end_data_RamLoc32 = .) ;
+ } > RamLoc32 AT>MFlashA512
+
+ /* BSS section for RamLoc40 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ PROVIDE(__start_bss_RamLoc40 = .) ;
+ *(.bss.$RAM2)
+ *(.bss.$RamLoc40)
+ *(.bss.$RAM2.*)
+ *(.bss.$RamLoc40.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ PROVIDE(__end_bss_RamLoc40 = .) ;
+ } > RamLoc40 AT> RamLoc40
+
+ /* BSS section for RamAHB32 */
+ .bss_RAM3 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM3 = .) ;
+ PROVIDE(__start_bss_RamAHB32 = .) ;
+ *(.bss.$RAM3)
+ *(.bss.$RamAHB32)
+ *(.bss.$RAM3.*)
+ *(.bss.$RamAHB32.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM3 = .) ;
+ PROVIDE(__end_bss_RamAHB32 = .) ;
+ } > RamAHB32 AT> RamAHB32
+
+ /* BSS section for RamAHB16 */
+ .bss_RAM4 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM4 = .) ;
+ PROVIDE(__start_bss_RamAHB16 = .) ;
+ *(.bss.$RAM4)
+ *(.bss.$RamAHB16)
+ *(.bss.$RAM4.*)
+ *(.bss.$RamAHB16.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM4 = .) ;
+ PROVIDE(__end_bss_RamAHB16 = .) ;
+ } > RamAHB16 AT> RamAHB16
+
+ /* BSS section for RamAHB_ETB16 */
+ .bss_RAM5 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM5 = .) ;
+ PROVIDE(__start_bss_RamAHB_ETB16 = .) ;
+ *(.bss.$RAM5)
+ *(.bss.$RamAHB_ETB16)
+ *(.bss.$RAM5.*)
+ *(.bss.$RamAHB_ETB16.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM5 = .) ;
+ PROVIDE(__end_bss_RamAHB_ETB16 = .) ;
+ } > RamAHB_ETB16 AT> RamAHB_ETB16
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ PROVIDE(__start_bss_RAM = .) ;
+ PROVIDE(__start_bss_RamLoc32 = .) ;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(__end_bss_RAM = .) ;
+ PROVIDE(__end_bss_RamLoc32 = .) ;
+ PROVIDE(end = .);
+ } > RamLoc32 AT> RamLoc32
+
+ /* NOINIT section for RamLoc40 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ PROVIDE(__start_noinit_RAM2 = .) ;
+ PROVIDE(__start_noinit_RamLoc40 = .) ;
+ *(.noinit.$RAM2)
+ *(.noinit.$RamLoc40)
+ *(.noinit.$RAM2.*)
+ *(.noinit.$RamLoc40.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_noinit_RAM2 = .) ;
+ PROVIDE(__end_noinit_RamLoc40 = .) ;
+ } > RamLoc40 AT> RamLoc40
+
+ /* NOINIT section for RamAHB32 */
+ .noinit_RAM3 (NOLOAD) : ALIGN(4)
+ {
+ PROVIDE(__start_noinit_RAM3 = .) ;
+ PROVIDE(__start_noinit_RamAHB32 = .) ;
+ *(.noinit.$RAM3)
+ *(.noinit.$RamAHB32)
+ *(.noinit.$RAM3.*)
+ *(.noinit.$RamAHB32.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_noinit_RAM3 = .) ;
+ PROVIDE(__end_noinit_RamAHB32 = .) ;
+ } > RamAHB32 AT> RamAHB32
+
+ /* NOINIT section for RamAHB16 */
+ .noinit_RAM4 (NOLOAD) : ALIGN(4)
+ {
+ PROVIDE(__start_noinit_RAM4 = .) ;
+ PROVIDE(__start_noinit_RamAHB16 = .) ;
+ *(.noinit.$RAM4)
+ *(.noinit.$RamAHB16)
+ *(.noinit.$RAM4.*)
+ *(.noinit.$RamAHB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_noinit_RAM4 = .) ;
+ PROVIDE(__end_noinit_RamAHB16 = .) ;
+ } > RamAHB16 AT> RamAHB16
+
+ /* NOINIT section for RamAHB_ETB16 */
+ .noinit_RAM5 (NOLOAD) : ALIGN(4)
+ {
+ PROVIDE(__start_noinit_RAM5 = .) ;
+ PROVIDE(__start_noinit_RamAHB_ETB16 = .) ;
+ *(.noinit.$RAM5)
+ *(.noinit.$RamAHB_ETB16)
+ *(.noinit.$RAM5.*)
+ *(.noinit.$RamAHB_ETB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_noinit_RAM5 = .) ;
+ PROVIDE(__end_noinit_RamAHB_ETB16 = .) ;
+ } > RamAHB_ETB16 AT> RamAHB_ETB16
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ PROVIDE(__start_noinit_RAM = .) ;
+ PROVIDE(__start_noinit_RamLoc32 = .) ;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ PROVIDE(__end_noinit_RAM = .) ;
+ PROVIDE(__end_noinit_RamLoc32 = .) ;
+ } > RamLoc32 AT> RamLoc32
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+}
\ No newline at end of file
diff --git a/hw/bsp/lpc18/boards/mcb1800/board.h b/hw/bsp/lpc18/boards/mcb1800/board.h
new file mode 100644
index 000000000..6111da975
--- /dev/null
+++ b/hw/bsp/lpc18/boards/mcb1800/board.h
@@ -0,0 +1,94 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// PD_10
+#define LED_PORT 6
+#define LED_PIN 24
+
+// P4_0
+#define BUTTON_PORT 2
+#define BUTTON_PIN 0
+
+#define UART_DEV LPC_USART3
+
+static inline void board_lpc18_pinmux(void)
+{
+ const PINMUX_GRP_T pinmuxing[] =
+ {
+ // LEDs
+ { 0xD, 10, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4) },
+ { 0xD, 11, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
+ { 0xD, 12, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
+ { 0xD, 13, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
+ { 0xD, 14, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
+ { 0x9, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+ { 0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+ { 0x9, 2, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+
+ // Button
+ { 0x4, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLUP) },
+
+ // UART
+ { 2, 3, SCU_MODE_PULLDOWN | SCU_MODE_FUNC2 },
+ { 2, 4, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 },
+
+ // USB0
+ { 0x6, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1 }, // P6_3 USB0_PWR_EN, USB0 VBus function
+
+ { 0x9, 5, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2 }, // P9_5 USB1_VBUS_EN, USB1 VBus function
+ { 0x2, 5, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 }, // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION
+ };
+
+ Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+
+ /* Pin clock mux values, re-used structure, value in first index is meaningless */
+ const PINMUX_GRP_T pinclockmuxing[] =
+ {
+ { 0, 0, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ };
+
+ /* Clock pins only, group field not used */
+ for (uint32_t i = 0; i < (sizeof(pinclockmuxing) / sizeof(pinclockmuxing[0])); i++)
+ {
+ Chip_SCU_ClockPinMuxSet(pinclockmuxing[i].pinnum, pinclockmuxing[i].modefunc);
+ }
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/lpc18/boards/mcb1800/board.mk b/hw/bsp/lpc18/boards/mcb1800/board.mk
new file mode 100644
index 000000000..0307a21d6
--- /dev/null
+++ b/hw/bsp/lpc18/boards/mcb1800/board.mk
@@ -0,0 +1,7 @@
+LD_FILE = $(BOARD_PATH)/lpc1857.ld
+
+# For flash-jlink target
+JLINK_DEVICE = LPC1857
+
+# flash using jlink
+flash: flash-jlink
diff --git a/hw/bsp/mcb1800/lpc1857.ld b/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld
similarity index 84%
rename from hw/bsp/mcb1800/lpc1857.ld
rename to hw/bsp/lpc18/boards/mcb1800/lpc1857.ld
index 983b41eb0..9a308e342 100644
--- a/hw/bsp/mcb1800/lpc1857.ld
+++ b/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld
@@ -20,35 +20,35 @@ MEMORY
RamAHB_ETB16 (rwx) : ORIGIN = 0x2000c000, LENGTH = 0x4000 /* 16K bytes (alias RAM5) */
}
- /* Define a symbol for the top of each memory region */
- __base_MFlashA512 = 0x1a000000 ; /* MFlashA512 */
- __base_Flash = 0x1a000000 ; /* Flash */
- __top_MFlashA512 = 0x1a000000 + 0x80000 ; /* 512K bytes */
- __top_Flash = 0x1a000000 + 0x80000 ; /* 512K bytes */
- __base_MFlashB512 = 0x1b000000 ; /* MFlashB512 */
- __base_Flash2 = 0x1b000000 ; /* Flash2 */
- __top_MFlashB512 = 0x1b000000 + 0x80000 ; /* 512K bytes */
- __top_Flash2 = 0x1b000000 + 0x80000 ; /* 512K bytes */
- __base_RamLoc32 = 0x10000000 ; /* RamLoc32 */
- __base_RAM = 0x10000000 ; /* RAM */
- __top_RamLoc32 = 0x10000000 + 0x8000 ; /* 32K bytes */
- __top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
- __base_RamLoc40 = 0x10080000 ; /* RamLoc40 */
- __base_RAM2 = 0x10080000 ; /* RAM2 */
- __top_RamLoc40 = 0x10080000 + 0xa000 ; /* 40K bytes */
- __top_RAM2 = 0x10080000 + 0xa000 ; /* 40K bytes */
- __base_RamAHB32 = 0x20000000 ; /* RamAHB32 */
- __base_RAM3 = 0x20000000 ; /* RAM3 */
- __top_RamAHB32 = 0x20000000 + 0x8000 ; /* 32K bytes */
- __top_RAM3 = 0x20000000 + 0x8000 ; /* 32K bytes */
- __base_RamAHB16 = 0x20008000 ; /* RamAHB16 */
- __base_RAM4 = 0x20008000 ; /* RAM4 */
- __top_RamAHB16 = 0x20008000 + 0x4000 ; /* 16K bytes */
- __top_RAM4 = 0x20008000 + 0x4000 ; /* 16K bytes */
- __base_RamAHB_ETB16 = 0x2000c000 ; /* RamAHB_ETB16 */
- __base_RAM5 = 0x2000c000 ; /* RAM5 */
- __top_RamAHB_ETB16 = 0x2000c000 + 0x4000 ; /* 16K bytes */
- __top_RAM5 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+/* Define a symbol for the top of each memory region */
+__base_MFlashA512 = 0x1a000000 ; /* MFlashA512 */
+__base_Flash = 0x1a000000 ; /* Flash */
+__top_MFlashA512 = 0x1a000000 + 0x80000 ; /* 512K bytes */
+__top_Flash = 0x1a000000 + 0x80000 ; /* 512K bytes */
+__base_MFlashB512 = 0x1b000000 ; /* MFlashB512 */
+__base_Flash2 = 0x1b000000 ; /* Flash2 */
+__top_MFlashB512 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+__top_Flash2 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+__base_RamLoc32 = 0x10000000 ; /* RamLoc32 */
+__base_RAM = 0x10000000 ; /* RAM */
+__top_RamLoc32 = 0x10000000 + 0x8000 ; /* 32K bytes */
+__top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
+__base_RamLoc40 = 0x10080000 ; /* RamLoc40 */
+__base_RAM2 = 0x10080000 ; /* RAM2 */
+__top_RamLoc40 = 0x10080000 + 0xa000 ; /* 40K bytes */
+__top_RAM2 = 0x10080000 + 0xa000 ; /* 40K bytes */
+__base_RamAHB32 = 0x20000000 ; /* RamAHB32 */
+__base_RAM3 = 0x20000000 ; /* RAM3 */
+__top_RamAHB32 = 0x20000000 + 0x8000 ; /* 32K bytes */
+__top_RAM3 = 0x20000000 + 0x8000 ; /* 32K bytes */
+__base_RamAHB16 = 0x20008000 ; /* RamAHB16 */
+__base_RAM4 = 0x20008000 ; /* RAM4 */
+__top_RamAHB16 = 0x20008000 + 0x4000 ; /* 16K bytes */
+__top_RAM4 = 0x20008000 + 0x4000 ; /* 16K bytes */
+__base_RamAHB_ETB16 = 0x2000c000 ; /* RamAHB_ETB16 */
+__base_RAM5 = 0x2000c000 ; /* RAM5 */
+__top_RamAHB_ETB16 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+__top_RAM5 = 0x2000c000 + 0x4000 ; /* 16K bytes */
ENTRY(ResetISR)
diff --git a/hw/bsp/mcb1800/mcb1800.c b/hw/bsp/lpc18/family.c
similarity index 61%
rename from hw/bsp/mcb1800/mcb1800.c
rename to hw/bsp/lpc18/family.c
index 5256501ed..d74ebcd33 100644
--- a/hw/bsp/mcb1800/mcb1800.c
+++ b/hw/bsp/lpc18/family.c
@@ -25,7 +25,8 @@
*/
#include "chip.h"
-#include "../board.h"
+#include "bsp/board.h"
+#include "board.h"
//--------------------------------------------------------------------+
// USB Interrupt Handler
@@ -56,59 +57,11 @@ void USB1_IRQHandler(void)
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
-// PD_10
-#define LED_PORT 6
-#define LED_PIN 24
-
-// P4_0
-#define BUTTON_PORT 2
-#define BUTTON_PIN 0
-
-#define UART_DEV LPC_USART3
-#define UART_PORT 0x02
-#define UART_PIN_TX 3
-#define UART_PIN_RX 4
-
/* System configuration variables used by chip driver */
const uint32_t OscRateIn = 12000000;
const uint32_t ExtRateIn = 0;
-static const PINMUX_GRP_T pinmuxing[] =
-{
- // LEDs
- { 0xD, 10, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4) },
- { 0xD, 11, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
- { 0xD, 12, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
- { 0xD, 13, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
- { 0xD, 14, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
- { 0x9, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
- { 0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
- { 0x9, 2, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
-
- // Button
- { 0x4, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLUP) },
-
- // UART
- { UART_PORT, UART_PIN_TX, SCU_MODE_PULLDOWN | SCU_MODE_FUNC2 },
- { UART_PORT, UART_PIN_RX, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 },
-
- // USB0
- { 0x6, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1 }, // P6_3 USB0_PWR_EN, USB0 VBus function
-
- { 0x9, 5, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2 }, // P9_5 USB1_VBUS_EN, USB1 VBus function
- { 0x2, 5, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 }, // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION
-};
-
-/* Pin clock mux values, re-used structure, value in first index is meaningless */
-static const PINMUX_GRP_T pinclockmuxing[] =
-{
- { 0, 0, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
- { 0, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
- { 0, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
- { 0, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
-};
-
// Invoked by startup code
void SystemInit(void)
{
@@ -118,15 +71,7 @@ void SystemInit(void)
*pSCB_VTOR = (unsigned int) g_pfnVectors;
#endif
- /* Setup system level pin muxing */
- Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
-
- /* Clock pins only, group field not used */
- for (uint32_t i = 0; i < (sizeof(pinclockmuxing) / sizeof(pinclockmuxing[0])); i++)
- {
- Chip_SCU_ClockPinMuxSet(pinclockmuxing[i].pinnum, pinclockmuxing[i].modefunc);
- }
-
+ board_lpc18_pinmux();
Chip_SetupXtalClocking();
}
diff --git a/hw/bsp/mcb1800/board.mk b/hw/bsp/lpc18/family.mk
similarity index 80%
rename from hw/bsp/mcb1800/board.mk
rename to hw/bsp/lpc18/family.mk
index f8fd25800..05ff27c38 100644
--- a/hw/bsp/mcb1800/board.mk
+++ b/hw/bsp/lpc18/family.mk
@@ -1,3 +1,7 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
CFLAGS += \
-flto \
-mthumb \
@@ -13,9 +17,6 @@ CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes
MCU_DIR = hw/mcu/nxp/lpcopen/lpc18xx/lpc_chip_18xx
-# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/lpc1857.ld
-
SRC_C += \
$(MCU_DIR)/../gcc/cr_startup_lpc18xx.c \
$(MCU_DIR)/src/chip_18xx_43xx.c \
@@ -25,6 +26,7 @@ SRC_C += \
$(MCU_DIR)/src/uart_18xx_43xx.c
INC += \
+ $(TOP)/$(BOARD_PATH) \
$(TOP)/$(MCU_DIR)/inc \
$(TOP)/$(MCU_DIR)/inc/config_18xx
@@ -34,9 +36,3 @@ CHIP_FAMILY = transdimension
# For freeRTOS port source
FREERTOS_PORT = ARM_CM3
-
-# For flash-jlink target
-JLINK_DEVICE = LPC1857
-
-# flash using jlink
-flash: flash-jlink
diff --git a/hw/bsp/double_m33_express/LPC55S69_cm33_core0_uf2.ld b/hw/bsp/lpc55/boards/double_m33_express/LPC55S69_cm33_core0_uf2.ld
similarity index 100%
rename from hw/bsp/double_m33_express/LPC55S69_cm33_core0_uf2.ld
rename to hw/bsp/lpc55/boards/double_m33_express/LPC55S69_cm33_core0_uf2.ld
diff --git a/hw/bsp/lpc55/boards/double_m33_express/board.h b/hw/bsp/lpc55/boards/double_m33_express/board.h
new file mode 100644
index 000000000..e73d700ba
--- /dev/null
+++ b/hw/bsp/lpc55/boards/double_m33_express/board.h
@@ -0,0 +1,60 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 0
+#define LED_PIN 1
+#define LED_STATE_ON 1
+
+// WAKE button
+#define BUTTON_PORT 0
+#define BUTTON_PIN 5
+#define BUTTON_STATE_ACTIVE 0
+
+// Number of neopixels
+#define NEOPIXEL_NUMBER 2
+#define NEOPIXEL_PORT 0
+#define NEOPIXEL_PIN 27
+#define NEOPIXEL_CH 6
+#define NEOPIXEL_TYPE 0
+
+// UART
+#define UART_DEV USART0
+#define UART_RX_PINMUX 0U, 29U, IOCON_PIO_DIG_FUNC1_EN
+#define UART_TX_PINMUX 0U, 30U, IOCON_PIO_DIG_FUNC1_EN
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/lpc55/boards/double_m33_express/board.mk b/hw/bsp/lpc55/boards/double_m33_express/board.mk
new file mode 100644
index 000000000..9bbfcc330
--- /dev/null
+++ b/hw/bsp/lpc55/boards/double_m33_express/board.mk
@@ -0,0 +1,11 @@
+MCU_VARIANT = LPC55S69
+MCU_CORE = LPC55S69_cm33_core0
+
+CFLAGS += -DCPU_LPC55S69JBD100_cm33_core0
+LD_FILE = $(BOARD_PATH)/LPC55S69_cm33_core0_uf2.ld
+
+JLINK_DEVICE = LPC55S69
+PYOCD_TARGET = LPC55S69
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/hw/bsp/lpc55/boards/lpcxpresso55s28/board.h b/hw/bsp/lpc55/boards/lpcxpresso55s28/board.h
new file mode 100644
index 000000000..7e76df953
--- /dev/null
+++ b/hw/bsp/lpc55/boards/lpcxpresso55s28/board.h
@@ -0,0 +1,53 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 1
+#define LED_PIN 6
+#define LED_STATE_ON 0
+
+// WAKE button
+#define BUTTON_PORT 1
+#define BUTTON_PIN 18
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+//#define UART_DEV USART0
+//#define UART_RX_PINMUX 0U, 29U, IOCON_PIO_DIG_FUNC1_EN
+//#define UART_TX_PINMUX 0U, 30U, IOCON_PIO_DIG_FUNC1_EN
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/lpc55/boards/lpcxpresso55s28/board.mk b/hw/bsp/lpc55/boards/lpcxpresso55s28/board.mk
new file mode 100644
index 000000000..e01a3d04f
--- /dev/null
+++ b/hw/bsp/lpc55/boards/lpcxpresso55s28/board.mk
@@ -0,0 +1,10 @@
+MCU_VARIANT = LPC55S28
+MCU_CORE = LPC55S28
+
+CFLAGS += -DCPU_LPC55S28JBD100
+
+JLINK_DEVICE = LPC55S28
+PYOCD_TARGET = LPC55S28
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/hw/bsp/lpc55/boards/lpcxpresso55s69/board.h b/hw/bsp/lpc55/boards/lpcxpresso55s69/board.h
new file mode 100644
index 000000000..7e76df953
--- /dev/null
+++ b/hw/bsp/lpc55/boards/lpcxpresso55s69/board.h
@@ -0,0 +1,53 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 1
+#define LED_PIN 6
+#define LED_STATE_ON 0
+
+// WAKE button
+#define BUTTON_PORT 1
+#define BUTTON_PIN 18
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+//#define UART_DEV USART0
+//#define UART_RX_PINMUX 0U, 29U, IOCON_PIO_DIG_FUNC1_EN
+//#define UART_TX_PINMUX 0U, 30U, IOCON_PIO_DIG_FUNC1_EN
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/lpc55/boards/lpcxpresso55s69/board.mk b/hw/bsp/lpc55/boards/lpcxpresso55s69/board.mk
new file mode 100644
index 000000000..88a065d4c
--- /dev/null
+++ b/hw/bsp/lpc55/boards/lpcxpresso55s69/board.mk
@@ -0,0 +1,10 @@
+MCU_VARIANT = LPC55S69
+MCU_CORE = LPC55S69_cm33_core0
+
+CFLAGS += -DCPU_LPC55S69JBD100_cm33_core0
+
+JLINK_DEVICE = LPC55S69
+PYOCD_TARGET = LPC55S69
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/hw/bsp/double_m33_express/double_m33_express.c b/hw/bsp/lpc55/family.c
similarity index 80%
rename from hw/bsp/double_m33_express/double_m33_express.c
rename to hw/bsp/lpc55/family.c
index 655f23cc0..0e238129d 100644
--- a/hw/bsp/double_m33_express/double_m33_express.c
+++ b/hw/bsp/lpc55/family.c
@@ -24,7 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#include "../board.h"
+#include "bsp/board.h"
+#include "board.h"
#include "fsl_device_registers.h"
#include "fsl_gpio.h"
#include "fsl_power.h"
@@ -49,45 +50,23 @@ void USB1_IRQHandler(void)
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+
-#define LED_PORT 0
-#define LED_PIN 1
-#define LED_STATE_ON 1
-
-// WAKE button
-#define BUTTON_PORT 0
-#define BUTTON_PIN 5
-#define BUTTON_STATE_ACTIVE 0
-
-// Number of neopixels
-#define NEOPIXEL_NUMBER 2
-#define NEOPIXEL_PORT 0
-#define NEOPIXEL_PIN 27
-#define NEOPIXEL_CH 6
-#define NEOPIXEL_TYPE 0
-
-// UART
-#define UART_DEV USART0
// IOCON pin mux
-#define IOCON_PIO_DIGITAL_EN 0x0100u /*!<@brief Enables digital function */
-#define IOCON_PIO_FUNC0 0x00u /*!<@brief Selects pin function 0 */
-#define IOCON_PIO_FUNC1 0x01u /*!<@brief Selects pin function 1 */
-#define IOCON_PIO_FUNC4 0x04u /*!<@brief Selects pin function 4 */
-#define IOCON_PIO_FUNC7 0x07u /*!<@brief Selects pin function 7 */
-#define IOCON_PIO_INV_DI 0x00u /*!<@brief Input function is not inverted */
-#define IOCON_PIO_MODE_INACT 0x00u /*!<@brief No addition pin function */
-#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!<@brief Open drain is disabled */
-#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */
+#define IOCON_PIO_DIGITAL_EN 0x0100u /*!<@brief Enables digital function */
+#define IOCON_PIO_FUNC0 0x00u /*!<@brief Selects pin function 0 */
+#define IOCON_PIO_FUNC1 0x01u /*!<@brief Selects pin function 1 */
+#define IOCON_PIO_FUNC4 0x04u /*!<@brief Selects pin function 4 */
+#define IOCON_PIO_FUNC7 0x07u /*!<@brief Selects pin function 7 */
+#define IOCON_PIO_INV_DI 0x00u /*!<@brief Input function is not inverted */
+#define IOCON_PIO_MODE_INACT 0x00u /*!<@brief No addition pin function */
+#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!<@brief Open drain is disabled */
+#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */
#define IOCON_PIO_DIG_FUNC0_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC0) /*!<@brief Digital pin function 0 enabled */
#define IOCON_PIO_DIG_FUNC1_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC1) /*!<@brief Digital pin function 1 enabled */
#define IOCON_PIO_DIG_FUNC4_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC4) /*!<@brief Digital pin function 2 enabled */
#define IOCON_PIO_DIG_FUNC7_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC7) /*!<@brief Digital pin function 2 enabled */
-
-// Global Variables
-uint32_t pixelData[NEOPIXEL_NUMBER];
-
/****************************************************************
name: BOARD_BootClockFROHF96M
outputs:
@@ -138,18 +117,20 @@ void board_init(void)
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
#endif
+ // Init all GPIO ports
GPIO_PortInit(GPIO, 0);
GPIO_PortInit(GPIO, 1);
// LED
- /* PORT0 PIN1 configured as PIO0_1 */
- IOCON_PinMuxSet(IOCON, 0U, 1U, IOCON_PIO_DIG_FUNC0_EN);
-
+ IOCON_PinMuxSet(IOCON, LED_PORT, LED_PIN, IOCON_PIO_DIG_FUNC0_EN);
gpio_pin_config_t const led_config = { kGPIO_DigitalOutput, 1};
GPIO_PinInit(GPIO, LED_PORT, LED_PIN, &led_config);
+ board_led_write(0);
+
+#ifdef NEOPIXEL_PIN
// Neopixel
- /* PORT0 PIN27 configured as SCT0_OUT6 */
+ static uint32_t pixelData[NEOPIXEL_NUMBER];
IOCON_PinMuxSet(IOCON, NEOPIXEL_PORT, NEOPIXEL_PIN, IOCON_PIO_DIG_FUNC4_EN);
sctpix_init(NEOPIXEL_TYPE);
@@ -157,22 +138,18 @@ void board_init(void)
sctpix_setPixel(NEOPIXEL_CH, 0, 0x100010);
sctpix_setPixel(NEOPIXEL_CH, 1, 0x100010);
sctpix_show();
-
+#endif
// Button
- /* PORT0 PIN5 configured as PIO0_5 */
IOCON_PinMuxSet(IOCON, BUTTON_PORT, BUTTON_PIN, IOCON_PIO_DIG_FUNC0_EN);
-
gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
+#if defined(UART_DEV)
// UART
- /* PORT0 PIN29 (coords: 92) is configured as FC0_RXD_SDA_MOSI_DATA */
- IOCON_PinMuxSet(IOCON, 0U, 29U, IOCON_PIO_DIG_FUNC1_EN);
- /* PORT0 PIN30 (coords: 94) is configured as FC0_TXD_SCL_MISO_WS */
- IOCON_PinMuxSet(IOCON, 0U, 30U, IOCON_PIO_DIG_FUNC1_EN);
+ IOCON_PinMuxSet(IOCON, UART_RX_PINMUX);
+ IOCON_PinMuxSet(IOCON, UART_TX_PINMUX);
-#if defined(UART_DEV) && CFG_TUSB_DEBUG
// Enable UART when debug log is on
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0);
usart_config_t uart_config;
@@ -200,7 +177,7 @@ void board_init(void)
RESET_PeripheralReset(kUSB1_RST_SHIFT_RSTn);
RESET_PeripheralReset(kUSB1RAM_RST_SHIFT_RSTn);
-#if (defined CFG_TUSB_RHPORT1_MODE) && (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE)
+#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
CLOCK_EnableClock(kCLOCK_Usbh1);
/* Put PHY powerdown under software control */
USBHSH->PORTMODE = USBHSH_PORTMODE_SW_PDCOM_MASK;
@@ -210,7 +187,7 @@ void board_init(void)
CLOCK_DisableClock(kCLOCK_Usbh1);
#endif
-#if (defined CFG_TUSB_RHPORT0_MODE) && (CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE)
+#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
// Enable USB Clock Adjustments to trim the FRO for the full speed controller
ANACTRL->FRO192M_CTRL |= ANACTRL_FRO192M_CTRL_USBCLKADJ_MASK;
CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
@@ -233,6 +210,8 @@ void board_init(void)
void board_led_write(bool state)
{
GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+
+#ifdef NEOPIXEL_PIN
if (state) {
sctpix_setPixel(NEOPIXEL_CH, 0, 0x100000);
sctpix_setPixel(NEOPIXEL_CH, 1, 0x101010);
@@ -241,6 +220,7 @@ void board_led_write(bool state)
sctpix_setPixel(NEOPIXEL_CH, 1, 0x000010);
}
sctpix_show();
+#endif
}
uint32_t board_button_read(void)
diff --git a/hw/bsp/double_m33_express/board.mk b/hw/bsp/lpc55/family.mk
similarity index 58%
rename from hw/bsp/double_m33_express/board.mk
rename to hw/bsp/lpc55/family.mk
index 5757aa5cd..8934cb422 100644
--- a/hw/bsp/double_m33_express/board.mk
+++ b/hw/bsp/lpc55/family.mk
@@ -1,3 +1,11 @@
+UF2_FAMILY_ID = 0x2abc77ec
+DEPS_SUBMODULES = lib/sct_neopixel hw/mcu/nxp
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+# TODO change Default to Highspeed PORT1
+PORT ?= 0
+
CFLAGS += \
-flto \
-mthumb \
@@ -5,38 +13,44 @@ CFLAGS += \
-mcpu=cortex-m33 \
-mfloat-abi=hard \
-mfpu=fpv5-sp-d16 \
- -DCPU_LPC55S69JBD100_cm33_core0 \
-DCFG_TUSB_MCU=OPT_MCU_LPC55XX \
-DCFG_TUSB_MEM_SECTION='__attribute__((section(".data")))' \
- -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
+ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' \
+ -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
+
+ifeq ($(PORT), 1)
+ CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
+ $(info "PORT1 High Speed")
+else
+ $(info "PORT0 Full Speed")
+endif
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=float-equal
-MCU_DIR = hw/mcu/nxp/sdk/devices/LPC55S69
+MCU_DIR = hw/mcu/nxp/sdk/devices/$(MCU_VARIANT)
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/LPC55S69_cm33_core0_uf2.ld
+LD_FILE ?= $(MCU_DIR)/gcc/$(MCU_CORE)_flash.ld
SRC_C += \
- $(MCU_DIR)/system_LPC55S69_cm33_core0.c \
+ $(MCU_DIR)/system_$(MCU_CORE).c \
$(MCU_DIR)/drivers/fsl_clock.c \
$(MCU_DIR)/drivers/fsl_gpio.c \
$(MCU_DIR)/drivers/fsl_power.c \
$(MCU_DIR)/drivers/fsl_reset.c \
$(MCU_DIR)/drivers/fsl_usart.c \
$(MCU_DIR)/drivers/fsl_flexcomm.c \
- lib/sct_neopixel/sct_neopixel.c
+ lib/sct_neopixel/sct_neopixel.c
INC += \
- $(TOP)/hw/bsp/ \
- $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(BOARD_PATH) \
$(TOP)/lib/sct_neopixel \
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
$(TOP)/$(MCU_DIR) \
$(TOP)/$(MCU_DIR)/drivers
-SRC_S += $(MCU_DIR)/gcc/startup_LPC55S69_cm33_core0.S
+SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_CORE).S
LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_hardabi.a
@@ -46,10 +60,3 @@ CHIP_FAMILY = lpc_ip3511
# For freeRTOS port source
FREERTOS_PORT = ARM_CM33_NTZ/non_secure
-
-# For flash-jlink target
-JLINK_DEVICE = LPC55S69
-
-# flash using pyocd
-flash: $(BUILD)/$(PROJECT).hex
- pyocd flash -t LPC55S69 $<
diff --git a/hw/bsp/lpcxpresso11u37/board.mk b/hw/bsp/lpcxpresso11u37/board.mk
index 441e5215d..e1338c9a3 100644
--- a/hw/bsp/lpcxpresso11u37/board.mk
+++ b/hw/bsp/lpcxpresso11u37/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/lpcxpresso11u68/board.mk b/hw/bsp/lpcxpresso11u68/board.mk
index 53d809cfc..e038a9cd9 100644
--- a/hw/bsp/lpcxpresso11u68/board.mk
+++ b/hw/bsp/lpcxpresso11u68/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/lpcxpresso1347/board.mk b/hw/bsp/lpcxpresso1347/board.mk
index 915834ddf..277282b9c 100644
--- a/hw/bsp/lpcxpresso1347/board.mk
+++ b/hw/bsp/lpcxpresso1347/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/lpcxpresso1549/board.mk b/hw/bsp/lpcxpresso1549/board.mk
index 27c3ca8d6..8d98379dc 100644
--- a/hw/bsp/lpcxpresso1549/board.mk
+++ b/hw/bsp/lpcxpresso1549/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/lpcxpresso1769/board.mk b/hw/bsp/lpcxpresso1769/board.mk
index 11da5f722..4b77ac0c3 100644
--- a/hw/bsp/lpcxpresso1769/board.mk
+++ b/hw/bsp/lpcxpresso1769/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/lpcxpresso51u68/board.mk b/hw/bsp/lpcxpresso51u68/board.mk
index e5ff8242d..57af215bb 100644
--- a/hw/bsp/lpcxpresso51u68/board.mk
+++ b/hw/bsp/lpcxpresso51u68/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/lpcxpresso54114/board.mk b/hw/bsp/lpcxpresso54114/board.mk
index 88f2bc734..431ad9122 100644
--- a/hw/bsp/lpcxpresso54114/board.mk
+++ b/hw/bsp/lpcxpresso54114/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/lpcxpresso55s69/board.mk b/hw/bsp/lpcxpresso55s69/board.mk
deleted file mode 100644
index 646ca2833..000000000
--- a/hw/bsp/lpcxpresso55s69/board.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-CFLAGS += \
- -flto \
- -mthumb \
- -mabi=aapcs \
- -mcpu=cortex-m33 \
- -mfloat-abi=hard \
- -mfpu=fpv5-sp-d16 \
- -DCPU_LPC55S69JBD100_cm33_core0 \
- -DCFG_TUSB_MCU=OPT_MCU_LPC55XX \
- -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data")))' \
- -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
-
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=unused-parameter -Wno-error=float-equal
-
-MCU_DIR = hw/mcu/nxp/sdk/devices/LPC55S69
-
-# All source paths should be relative to the top level.
-LD_FILE = $(MCU_DIR)/gcc/LPC55S69_cm33_core0_flash.ld
-
-SRC_C += \
- $(MCU_DIR)/system_LPC55S69_cm33_core0.c \
- $(MCU_DIR)/drivers/fsl_clock.c \
- $(MCU_DIR)/drivers/fsl_gpio.c \
- $(MCU_DIR)/drivers/fsl_power.c \
- $(MCU_DIR)/drivers/fsl_reset.c
-
-INC += \
- $(TOP)/$(MCU_DIR)/../../CMSIS/Include \
- $(TOP)/$(MCU_DIR) \
- $(TOP)/$(MCU_DIR)/drivers
-
-SRC_S += $(MCU_DIR)/gcc/startup_LPC55S69_cm33_core0.S
-
-LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_hardabi.a
-
-# For TinyUSB port source
-VENDOR = nxp
-CHIP_FAMILY = lpc_ip3511
-
-# For freeRTOS port source
-FREERTOS_PORT = ARM_CM33_NTZ/non_secure
-
-# For flash-jlink target
-JLINK_DEVICE = LPC55S69
-
-# flash using pyocd
-flash: $(BUILD)/$(PROJECT).hex
- pyocd flash -t LPC55S69 $<
diff --git a/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c b/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c
deleted file mode 100644
index a17cffe9c..000000000
--- a/hw/bsp/lpcxpresso55s69/lpcxpresso55s69.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2018, hathach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#include "../board.h"
-#include "fsl_device_registers.h"
-#include "fsl_gpio.h"
-#include "fsl_power.h"
-#include "fsl_iocon.h"
-
-//--------------------------------------------------------------------+
-// Forward USB interrupt events to TinyUSB IRQ Handler
-//--------------------------------------------------------------------+
-void USB0_IRQHandler(void)
-{
- tud_int_handler(0);
-}
-
-void USB1_IRQHandler(void)
-{
- tud_int_handler(1);
-}
-
-//--------------------------------------------------------------------+
-// MACRO TYPEDEF CONSTANT ENUM
-//--------------------------------------------------------------------+
-#define LED_PORT 1
-#define LED_PIN 6
-#define LED_STATE_ON 0
-
-// WAKE button
-#define BUTTON_PORT 1
-#define BUTTON_PIN 18
-#define BUTTON_STATE_ACTIVE 0
-
-// IOCON pin mux
-#define IOCON_PIO_DIGITAL_EN 0x0100u /*!<@brief Enables digital function */
-#define IOCON_PIO_FUNC0 0x00u /*!<@brief Selects pin function 0 */
-#define IOCON_PIO_FUNC1 0x01u /*!<@brief Selects pin function 1 */
-#define IOCON_PIO_FUNC7 0x07u /*!<@brief Selects pin function 7 */
-#define IOCON_PIO_INV_DI 0x00u /*!<@brief Input function is not inverted */
-#define IOCON_PIO_MODE_INACT 0x00u /*!<@brief No addition pin function */
-#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!<@brief Open drain is disabled */
-#define IOCON_PIO_SLEW_STANDARD 0x00u /*!<@brief Standard mode, output slew rate control is enabled */
-
-/****************************************************************
-name: BOARD_BootClockFROHF96M
-outputs:
-- {id: SYSTICK_clock.outFreq, value: 96 MHz}
-- {id: System_clock.outFreq, value: 96 MHz}
-settings:
-- {id: SYSCON.MAINCLKSELA.sel, value: SYSCON.fro_hf}
-sources:
-- {id: SYSCON.fro_hf.outFreq, value: 96 MHz}
-******************************************************************/
-void BootClockFROHF96M(void)
-{
- /*!< Set up the clock sources */
- /*!< Set up FRO */
- POWER_DisablePD(kPDRUNCFG_PD_FRO192M); /*!< Ensure FRO is on */
- CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
- CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without
- accidentally being below the voltage for current speed */
-
- CLOCK_SetupFROClocking(96000000U); /*!< Set up high frequency FRO output to selected frequency */
-
- POWER_SetVoltageForFreq(96000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
- CLOCK_SetFLASHAccessCyclesForFreq(96000000U); /*!< Set FLASH wait states for core */
-
- /*!< Set up dividers */
- CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
-
- /*!< Set up clock selectors - Attach clocks to the peripheries */
- CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
-
- /*!< Set SystemCoreClock variable. */
- SystemCoreClock = 96000000U;
-}
-
-void board_init(void)
-{
- // Enable IOCON clock
- CLOCK_EnableClock(kCLOCK_Iocon);
-
- // Init 96 MHz clock
- BootClockFROHF96M();
-
-#if CFG_TUSB_OS == OPT_OS_NONE
- // 1ms tick timer
- SysTick_Config(SystemCoreClock / 1000);
-#elif CFG_TUSB_OS == OPT_OS_FREERTOS
- // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
- NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
-#endif
-
- GPIO_PortInit(GPIO, LED_PORT);
- GPIO_PortInit(GPIO, BUTTON_PORT);
-
- // LED
- gpio_pin_config_t const led_config = { kGPIO_DigitalOutput, 0};
- GPIO_PinInit(GPIO, LED_PORT, LED_PIN, &led_config);
- board_led_write(true);
-
- // Button
- const uint32_t port1_pin18_config = (
- IOCON_PIO_FUNC0 | /* Pin is configured as PIO1_18 */
- IOCON_PIO_MODE_INACT | /* No addition pin function */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- /* PORT1 PIN18 (coords: 64) is configured as PIO1_18 */
- IOCON_PinMuxSet(IOCON, 1U, 18U, port1_pin18_config);
-
- gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
- GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
-
- // USB VBUS
- const uint32_t port0_pin22_config = (
- IOCON_PIO_FUNC7 | /* Pin is configured as USB0_VBUS */
- IOCON_PIO_MODE_INACT | /* No addition pin function */
- IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
- IOCON_PIO_INV_DI | /* Input function is not inverted */
- IOCON_PIO_DIGITAL_EN | /* Enables digital function */
- IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
- );
- /* PORT0 PIN22 (coords: 78) is configured as USB0_VBUS */
- IOCON_PinMuxSet(IOCON, 0U, 22U, port0_pin22_config);
-
- // USB Controller
- POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB0 Phy */
- POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY); /*< Turn on USB1 Phy */
-
- /* reset the IP to make sure it's in reset state. */
- RESET_PeripheralReset(kUSB0D_RST_SHIFT_RSTn);
- RESET_PeripheralReset(kUSB0HSL_RST_SHIFT_RSTn);
- RESET_PeripheralReset(kUSB0HMR_RST_SHIFT_RSTn);
- RESET_PeripheralReset(kUSB1H_RST_SHIFT_RSTn);
- RESET_PeripheralReset(kUSB1D_RST_SHIFT_RSTn);
- RESET_PeripheralReset(kUSB1_RST_SHIFT_RSTn);
- RESET_PeripheralReset(kUSB1RAM_RST_SHIFT_RSTn);
-
-#if (defined USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS)
- CLOCK_EnableClock(kCLOCK_Usbh1);
- /* Put PHY powerdown under software control */
- *((uint32_t *)(USBHSH_BASE + 0x50)) = USBHSH_PORTMODE_SW_PDCOM_MASK;
- /* According to reference mannual, device mode setting has to be set by access usb host register */
- *((uint32_t *)(USBHSH_BASE + 0x50)) |= USBHSH_PORTMODE_DEV_ENABLE_MASK;
- /* enable usb1 host clock */
- CLOCK_DisableClock(kCLOCK_Usbh1);
-#endif
-
-#if 1 || (defined USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS)
- CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
- CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
- /* enable usb0 host clock */
- CLOCK_EnableClock(kCLOCK_Usbhsl0);
- /*According to reference mannual, device mode setting has to be set by access usb host register */
- *((uint32_t *)(USBFSH_BASE + 0x5C)) |= USBFSH_PORTMODE_DEV_ENABLE_MASK;
- /* disable usb0 host clock */
- CLOCK_DisableClock(kCLOCK_Usbhsl0);
- CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB Device clock */
-#endif
-}
-
-//--------------------------------------------------------------------+
-// Board porting API
-//--------------------------------------------------------------------+
-
-void board_led_write(bool state)
-{
- GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
-}
-
-uint32_t board_button_read(void)
-{
- // active low
- return BUTTON_STATE_ACTIVE == GPIO_PinRead(GPIO, BUTTON_PORT, BUTTON_PIN);
-}
-
-int board_uart_read(uint8_t* buf, int len)
-{
- (void) buf; (void) len;
- return 0;
-}
-
-int board_uart_write(void const * buf, int len)
-{
- (void) buf; (void) len;
- return 0;
-}
-
-#if CFG_TUSB_OS == OPT_OS_NONE
-volatile uint32_t system_ticks = 0;
-void SysTick_Handler(void)
-{
- system_ticks++;
-}
-
-uint32_t board_millis(void)
-{
- return system_ticks;
-}
-#endif
diff --git a/hw/bsp/mbed1768/board.mk b/hw/bsp/mbed1768/board.mk
index 1b09a7f7a..2b934aa16 100644
--- a/hw/bsp/mbed1768/board.mk
+++ b/hw/bsp/mbed1768/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/msp430/boards/msp_exp430f5529lp/board.h b/hw/bsp/msp430/boards/msp_exp430f5529lp/board.h
new file mode 100644
index 000000000..ccfe321c2
--- /dev/null
+++ b/hw/bsp/msp430/boards/msp_exp430f5529lp/board.h
@@ -0,0 +1,46 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT P1OUT
+#define LED_PIN BIT0
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT P1IN
+#define BUTTON_PIN BIT1
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c b/hw/bsp/msp430/family.c
similarity index 96%
rename from hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c
rename to hw/bsp/msp430/family.c
index e9336b634..4b8ae393d 100644
--- a/hw/bsp/msp_exp430f5529lp/msp_exp430f5529lp.c
+++ b/hw/bsp/msp430/family.c
@@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/
-#include "../board.h"
-
+#include "bsp/board.h"
+#include "board.h"
#include "msp430.h"
//--------------------------------------------------------------------+
@@ -39,13 +39,6 @@ void __attribute__ ((interrupt(USB_UBM_VECTOR))) USB_UBM_ISR(void)
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+
-#define LED_PORT P1OUT
-#define LED_PIN BIT0
-#define LED_STATE_ON 1
-
-#define BUTTON_PORT P1IN
-#define BUTTON_PIN BIT1
-#define BUTTON_STATE_ACTIVE 0
uint32_t cnt = 0;
diff --git a/hw/bsp/msp_exp430f5529lp/board.mk b/hw/bsp/msp430/family.mk
similarity index 86%
rename from hw/bsp/msp_exp430f5529lp/board.mk
rename to hw/bsp/msp430/family.mk
index 9fe8da274..53ebca1c0 100644
--- a/hw/bsp/msp_exp430f5529lp/board.mk
+++ b/hw/bsp/msp430/family.mk
@@ -1,3 +1,7 @@
+CROSS_COMPILE = msp430-elf-
+DEPS_SUBMODULES = hw/mcu/ti
+SKIP_NANOLIB = 1
+
CFLAGS += \
-D__MSP430F5529__ \
-DCFG_TUSB_MCU=OPT_MCU_MSP430x5xx \
@@ -6,15 +10,16 @@ CFLAGS += \
#-mmcu=msp430f5529
-# Cross Compiler for MSP430
-CROSS_COMPILE = msp430-elf-
+
# All source paths should be relative to the top level.
LD_FILE = hw/mcu/ti/msp430/msp430-gcc-support-files/include/msp430f5529.ld
LDINC += $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include
LDFLAGS += $(addprefix -L,$(LDINC))
-INC += $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include
+INC += \
+ $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include \
+ $(TOP)/$(BOARD_PATH)
# For TinyUSB port source
VENDOR = ti
diff --git a/hw/bsp/ngx4330/board.mk b/hw/bsp/ngx4330/board.mk
index fe66fceb5..c78d4c02d 100644
--- a/hw/bsp/ngx4330/board.mk
+++ b/hw/bsp/ngx4330/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nxp
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c
index 48f560a6f..fc5e805d9 100644
--- a/hw/bsp/nrf/family.c
+++ b/hw/bsp/nrf/family.c
@@ -25,7 +25,6 @@
*/
#include "bsp/board.h"
-
#include "board.h"
#include "nrfx.h"
diff --git a/hw/bsp/nrf/family.mk b/hw/bsp/nrf/family.mk
index c7dff1d0c..8756ad9a3 100644
--- a/hw/bsp/nrf/family.mk
+++ b/hw/bsp/nrf/family.mk
@@ -1,4 +1,5 @@
UF2_FAMILY_ID = 0xADA52840
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/nordic/nrfx
include $(TOP)/$(BOARD_PATH)/board.mk
@@ -39,7 +40,7 @@ SRC_C += \
INC += \
$(TOP)/$(BOARD_PATH) \
- $(TOP)/lib/CMSIS_4/CMSIS/Include \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
$(TOP)/hw/mcu/nordic \
$(TOP)/hw/mcu/nordic/nrfx \
$(TOP)/hw/mcu/nordic/nrfx/mdk \
diff --git a/hw/bsp/nutiny_nuc121s/board.mk b/hw/bsp/nutiny_nuc121s/board.mk
index ce18a749c..68688be76 100644
--- a/hw/bsp/nutiny_nuc121s/board.mk
+++ b/hw/bsp/nutiny_nuc121s/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nuvoton
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/nutiny_nuc125s/board.mk b/hw/bsp/nutiny_nuc125s/board.mk
index fe51b79d2..cb75f2ba2 100644
--- a/hw/bsp/nutiny_nuc125s/board.mk
+++ b/hw/bsp/nutiny_nuc125s/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nuvoton
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/nutiny_nuc126v/board.mk b/hw/bsp/nutiny_nuc126v/board.mk
index 30cb3df03..5beb5f457 100644
--- a/hw/bsp/nutiny_nuc126v/board.mk
+++ b/hw/bsp/nutiny_nuc126v/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nuvoton
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/nutiny_sdk_nuc120/board.mk b/hw/bsp/nutiny_sdk_nuc120/board.mk
index 0d3a3bff4..affa64058 100644
--- a/hw/bsp/nutiny_sdk_nuc120/board.mk
+++ b/hw/bsp/nutiny_sdk_nuc120/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nuvoton
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/nutiny_sdk_nuc505/board.mk b/hw/bsp/nutiny_sdk_nuc505/board.mk
index 99103fc65..8b2e53d44 100644
--- a/hw/bsp/nutiny_sdk_nuc505/board.mk
+++ b/hw/bsp/nutiny_sdk_nuc505/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/nuvoton
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c
index e42941483..9995c23d7 100644
--- a/hw/bsp/rp2040/family.c
+++ b/hw/bsp/rp2040/family.c
@@ -78,7 +78,10 @@ bool __no_inline_not_in_flash_func(get_bootsel_button)() {
//------------- Segger RTT retarget -------------//
#if defined(LOGGER_RTT)
+
// Logging with RTT
+// - If RTT Control Block is not found by 'Auto Detection` try to use 'Search Range` with '0x20000000 0x10000'
+// - SWD speed is rather slow around 1000Khz
#include "pico/stdio/driver.h"
#include "SEGGER_RTT.h"
diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake
index e4f5f47b4..af23c2368 100644
--- a/hw/bsp/rp2040/family.cmake
+++ b/hw/bsp/rp2040/family.cmake
@@ -1,3 +1,12 @@
+target_link_libraries(${PROJECT}
+ pico_stdlib
+ pico_bootsel_via_double_reset
+ pico_fix_rp2040_usb_device_enumeration
+)
+
+pico_add_extra_outputs(${PROJECT})
+pico_enable_stdio_uart(${PROJECT} 1)
+
# TinyUSB Stack source
set(SRC_TINYUSB
${TOP}/src/tusb.c
@@ -13,8 +22,15 @@ set(SRC_TINYUSB
${TOP}/src/class/net/net_device.c
${TOP}/src/class/usbtmc/usbtmc_device.c
${TOP}/src/class/vendor/vendor_device.c
- ${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c
+ ${TOP}/src/host/hub.c
+ ${TOP}/src/host/usbh.c
+ ${TOP}/src/host/usbh_control.c
+ ${TOP}/src/class/cdc/cdc_host.c
+ ${TOP}/src/class/hid/hid_host.c
+ ${TOP}/src/class/msc/msc_host.c
${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c
+ ${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c
+ ${TOP}/src/portable/raspberrypi/${FAMILY}/hcd_rp2040.c
)
target_sources(${PROJECT} PUBLIC
@@ -35,12 +51,9 @@ target_compile_definitions(${PROJECT} PUBLIC
if(DEFINED LOG)
target_compile_definitions(${PROJECT} PUBLIC CFG_TUSB_DEBUG=${LOG} )
- pico_enable_stdio_uart(${PROJECT} 1)
endif()
if(LOGGER STREQUAL "rtt")
- pico_enable_stdio_uart(${PROJECT} 0)
-
target_compile_definitions(${PROJECT} PUBLIC
LOGGER_RTT
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
diff --git a/hw/bsp/rp2040/family.mk b/hw/bsp/rp2040/family.mk
new file mode 100644
index 000000000..2778183f8
--- /dev/null
+++ b/hw/bsp/rp2040/family.mk
@@ -0,0 +1,4 @@
+DEPS_SUBMODULES = hw/mcu/raspberrypi/pico-sdk
+
+JLINK_DEVICE = rp2040_m0_0
+PYOCD_TARGET = rp2040
diff --git a/hw/bsp/samd11/family.mk b/hw/bsp/samd11/family.mk
index 4f01db8d7..e0005d853 100644
--- a/hw/bsp/samd11/family.mk
+++ b/hw/bsp/samd11/family.mk
@@ -1,3 +1,4 @@
+DEPS_SUBMODULES = hw/mcu/microchip
include $(TOP)/$(BOARD_PATH)/board.mk
diff --git a/hw/bsp/samd21/family.mk b/hw/bsp/samd21/family.mk
index e2bba494a..e748796fd 100644
--- a/hw/bsp/samd21/family.mk
+++ b/hw/bsp/samd21/family.mk
@@ -1,4 +1,5 @@
UF2_FAMILY_ID = 0x68ed2b88
+DEPS_SUBMODULES = hw/mcu/microchip
include $(TOP)/$(BOARD_PATH)/board.mk
@@ -12,24 +13,24 @@ CFLAGS += \
-DCFG_TUSB_MCU=OPT_MCU_SAMD21
SRC_C += \
- hw/mcu/microchip/asf4/samd21/gcc/gcc/startup_samd21.c \
- hw/mcu/microchip/asf4/samd21/gcc/system_samd21.c \
- hw/mcu/microchip/asf4/samd21/hpl/gclk/hpl_gclk.c \
- hw/mcu/microchip/asf4/samd21/hpl/pm/hpl_pm.c \
- hw/mcu/microchip/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c \
- hw/mcu/microchip/asf4/samd21/hal/src/hal_atomic.c
+ hw/mcu/microchip/samd21/gcc/gcc/startup_samd21.c \
+ hw/mcu/microchip/samd21/gcc/system_samd21.c \
+ hw/mcu/microchip/samd21/hpl/gclk/hpl_gclk.c \
+ hw/mcu/microchip/samd21/hpl/pm/hpl_pm.c \
+ hw/mcu/microchip/samd21/hpl/sysctrl/hpl_sysctrl.c \
+ hw/mcu/microchip/samd21/hal/src/hal_atomic.c
INC += \
$(TOP)/$(BOARD_PATH) \
- $(TOP)/hw/mcu/microchip/asf4/samd21/ \
- $(TOP)/hw/mcu/microchip/asf4/samd21/config \
- $(TOP)/hw/mcu/microchip/asf4/samd21/include \
- $(TOP)/hw/mcu/microchip/asf4/samd21/hal/include \
- $(TOP)/hw/mcu/microchip/asf4/samd21/hal/utils/include \
- $(TOP)/hw/mcu/microchip/asf4/samd21/hpl/pm/ \
- $(TOP)/hw/mcu/microchip/asf4/samd21/hpl/port \
- $(TOP)/hw/mcu/microchip/asf4/samd21/hri \
- $(TOP)/hw/mcu/microchip/asf4/samd21/CMSIS/Include
+ $(TOP)/hw/mcu/microchip/samd21/ \
+ $(TOP)/hw/mcu/microchip/samd21/config \
+ $(TOP)/hw/mcu/microchip/samd21/include \
+ $(TOP)/hw/mcu/microchip/samd21/hal/include \
+ $(TOP)/hw/mcu/microchip/samd21/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/samd21/hpl/pm/ \
+ $(TOP)/hw/mcu/microchip/samd21/hpl/port \
+ $(TOP)/hw/mcu/microchip/samd21/hri \
+ $(TOP)/hw/mcu/microchip/samd21/CMSIS/Include
# For TinyUSB port source
VENDOR = microchip
diff --git a/hw/bsp/samd51/family.mk b/hw/bsp/samd51/family.mk
index bb895dfc4..2cf8f0902 100644
--- a/hw/bsp/samd51/family.mk
+++ b/hw/bsp/samd51/family.mk
@@ -1,4 +1,5 @@
UF2_FAMILY_ID = 0x55114460
+DEPS_SUBMODULES = hw/mcu/microchip
include $(TOP)/$(BOARD_PATH)/board.mk
@@ -15,24 +16,24 @@ CFLAGS += \
CFLAGS += -Wno-error=undef
SRC_C += \
- hw/mcu/microchip/asf4/samd51/gcc/gcc/startup_samd51.c \
- hw/mcu/microchip/asf4/samd51/gcc/system_samd51.c \
- hw/mcu/microchip/asf4/samd51/hpl/gclk/hpl_gclk.c \
- hw/mcu/microchip/asf4/samd51/hpl/mclk/hpl_mclk.c \
- hw/mcu/microchip/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c \
- hw/mcu/microchip/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c \
- hw/mcu/microchip/asf4/samd51/hal/src/hal_atomic.c
+ hw/mcu/microchip/samd51/gcc/gcc/startup_samd51.c \
+ hw/mcu/microchip/samd51/gcc/system_samd51.c \
+ hw/mcu/microchip/samd51/hpl/gclk/hpl_gclk.c \
+ hw/mcu/microchip/samd51/hpl/mclk/hpl_mclk.c \
+ hw/mcu/microchip/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c \
+ hw/mcu/microchip/samd51/hpl/oscctrl/hpl_oscctrl.c \
+ hw/mcu/microchip/samd51/hal/src/hal_atomic.c
INC += \
$(TOP)/$(BOARD_PATH) \
- $(TOP)/hw/mcu/microchip/asf4/samd51/ \
- $(TOP)/hw/mcu/microchip/asf4/samd51/config \
- $(TOP)/hw/mcu/microchip/asf4/samd51/include \
- $(TOP)/hw/mcu/microchip/asf4/samd51/hal/include \
- $(TOP)/hw/mcu/microchip/asf4/samd51/hal/utils/include \
- $(TOP)/hw/mcu/microchip/asf4/samd51/hpl/port \
- $(TOP)/hw/mcu/microchip/asf4/samd51/hri \
- $(TOP)/hw/mcu/microchip/asf4/samd51/CMSIS/Include
+ $(TOP)/hw/mcu/microchip/samd51/ \
+ $(TOP)/hw/mcu/microchip/samd51/config \
+ $(TOP)/hw/mcu/microchip/samd51/include \
+ $(TOP)/hw/mcu/microchip/samd51/hal/include \
+ $(TOP)/hw/mcu/microchip/samd51/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/samd51/hpl/port \
+ $(TOP)/hw/mcu/microchip/samd51/hri \
+ $(TOP)/hw/mcu/microchip/samd51/CMSIS/Include
# For TinyUSB port source
VENDOR = microchip
diff --git a/hw/bsp/same54xplainedpro/board.mk b/hw/bsp/same54xplainedpro/board.mk
index 645372a2d..508ab20f8 100644
--- a/hw/bsp/same54xplainedpro/board.mk
+++ b/hw/bsp/same54xplainedpro/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/microchip
+
CONF_CPU_FREQUENCY ?= 120000000
CFLAGS += \
@@ -20,19 +22,19 @@ CFLAGS += \
LD_FILE = hw/bsp/$(BOARD)/same54p20a_flash.ld
SRC_C += \
- hw/mcu/microchip/asf4/same54/gcc/gcc/startup_same54.c \
- hw/mcu/microchip/asf4/same54/gcc/system_same54.c \
- hw/mcu/microchip/asf4/same54/hal/utils/src/utils_syscalls.c
+ hw/mcu/microchip/same54/gcc/gcc/startup_same54.c \
+ hw/mcu/microchip/same54/gcc/system_same54.c \
+ hw/mcu/microchip/same54/hal/utils/src/utils_syscalls.c
INC += \
- $(TOP)/hw/mcu/microchip/asf4/same54/ \
- $(TOP)/hw/mcu/microchip/asf4/same54/config \
- $(TOP)/hw/mcu/microchip/asf4/same54/include \
- $(TOP)/hw/mcu/microchip/asf4/same54/hal/include \
- $(TOP)/hw/mcu/microchip/asf4/same54/hal/utils/include \
- $(TOP)/hw/mcu/microchip/asf4/same54/hpl/port \
- $(TOP)/hw/mcu/microchip/asf4/same54/hri \
- $(TOP)/hw/mcu/microchip/asf4/same54/CMSIS/Include
+ $(TOP)/hw/mcu/microchip/same54/ \
+ $(TOP)/hw/mcu/microchip/same54/config \
+ $(TOP)/hw/mcu/microchip/same54/include \
+ $(TOP)/hw/mcu/microchip/same54/hal/include \
+ $(TOP)/hw/mcu/microchip/same54/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/same54/hpl/port \
+ $(TOP)/hw/mcu/microchip/same54/hri \
+ $(TOP)/hw/mcu/microchip/same54/CMSIS/Include
# For TinyUSB port source
VENDOR = microchip
diff --git a/hw/bsp/same54xplainedpro/same54xplainedpro.c b/hw/bsp/same54xplainedpro/same54xplainedpro.c
index a176c02f4..a1d920757 100644
--- a/hw/bsp/same54xplainedpro/same54xplainedpro.c
+++ b/hw/bsp/same54xplainedpro/same54xplainedpro.c
@@ -166,15 +166,16 @@ void board_init(void)
#endif
// LED0 init
+ gpio_set_pin_function(LED_PIN, GPIO_PIN_FUNCTION_OFF);
gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
- gpio_set_pin_level(LED_PIN, 0);
+ board_led_write(0);
#if CFG_TUSB_DEBUG >= 2
uart_send_str(BOARD_NAME " LED pin configured\n");
#endif
// BTN0 init
- gpio_set_pin_function(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_function(BUTTON_PIN, GPIO_PIN_FUNCTION_OFF);
gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP);
@@ -228,7 +229,7 @@ void board_init(void)
void board_led_write(bool state)
{
- gpio_set_pin_level(LED_PIN, state);
+ gpio_set_pin_level(LED_PIN, !state);
}
uint32_t board_button_read(void)
diff --git a/hw/bsp/same70_xplained/board.mk b/hw/bsp/same70_xplained/board.mk
index 21f5350c3..fd9dc5cf2 100644
--- a/hw/bsp/same70_xplained/board.mk
+++ b/hw/bsp/same70_xplained/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/microchip
+
CFLAGS += \
-mthumb \
-mabi=aapcs \
diff --git a/hw/bsp/samg55xplained/board.mk b/hw/bsp/samg55xplained/board.mk
index b574a39e7..3a783d310 100644
--- a/hw/bsp/samg55xplained/board.mk
+++ b/hw/bsp/samg55xplained/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/microchip
+
CFLAGS += \
-flto \
-mthumb \
diff --git a/hw/bsp/spresense/board.mk b/hw/bsp/spresense/board.mk
index 245976235..c04296cfa 100644
--- a/hw/bsp/spresense/board.mk
+++ b/hw/bsp/spresense/board.mk
@@ -1,3 +1,5 @@
+DEPS_SUBMODULES = hw/mcu/sony/cxd56/spresense-exported-sdk
+
# Platforms are: Linux, Darwin, MSYS, CYGWIN
PLATFORM := $(firstword $(subst _, ,$(shell uname -s 2>/dev/null)))
diff --git a/hw/bsp/stm32f070rbnucleo/board.mk b/hw/bsp/stm32f070rbnucleo/board.mk
index be2ce3b83..0cf28b793 100644
--- a/hw/bsp/stm32f070rbnucleo/board.mk
+++ b/hw/bsp/stm32f070rbnucleo/board.mk
@@ -1,3 +1,9 @@
+ST_FAMILY = f0
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
CFLAGS += \
-flto \
-mthumb \
@@ -12,9 +18,6 @@ CFLAGS += \
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align
-ST_FAMILY = f0
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
# All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/stm32F070rbtx_flash.ld
diff --git a/hw/bsp/stm32f072disco/board.mk b/hw/bsp/stm32f072disco/board.mk
index bbb7baf5a..81fb0df89 100644
--- a/hw/bsp/stm32f072disco/board.mk
+++ b/hw/bsp/stm32f072disco/board.mk
@@ -1,3 +1,9 @@
+ST_FAMILY = f0
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
CFLAGS += \
-flto \
-mthumb \
@@ -12,10 +18,6 @@ CFLAGS += \
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align
-ST_FAMILY = f0
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
# All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/STM32F072RBTx_FLASH.ld
diff --git a/hw/bsp/stm32f103bluepill/board.mk b/hw/bsp/stm32f103bluepill/board.mk
index e1517cfaa..e1cf26e88 100644
--- a/hw/bsp/stm32f103bluepill/board.mk
+++ b/hw/bsp/stm32f103bluepill/board.mk
@@ -1,3 +1,9 @@
+ST_FAMILY = f1
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
CFLAGS += \
-flto \
-mthumb \
@@ -11,10 +17,6 @@ CFLAGS += \
# mcu driver cause following warnings
#CFLAGS += -Wno-error=unused-parameter
-ST_FAMILY = f1
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
# All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/STM32F103XB_FLASH.ld
diff --git a/hw/bsp/stm32f207nucleo/board.mk b/hw/bsp/stm32f207nucleo/board.mk
index 025c2d7b7..4be6e250e 100644
--- a/hw/bsp/stm32f207nucleo/board.mk
+++ b/hw/bsp/stm32f207nucleo/board.mk
@@ -1,3 +1,9 @@
+ST_FAMILY = f2
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
CFLAGS += \
-flto \
-mthumb \
@@ -11,11 +17,6 @@ CFLAGS += \
# mcu driver cause following warnings
CFLAGS += -Wno-error=sign-compare
-ST_FAMILY = f2
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
-
# All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/STM32F207ZGTx_FLASH.ld
diff --git a/hw/bsp/stm32f303disco/board.mk b/hw/bsp/stm32f303disco/board.mk
index 3abaf5cec..304fa9c5a 100644
--- a/hw/bsp/stm32f303disco/board.mk
+++ b/hw/bsp/stm32f303disco/board.mk
@@ -1,3 +1,9 @@
+ST_FAMILY = f3
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
CFLAGS += \
-flto \
-mthumb \
@@ -12,10 +18,6 @@ CFLAGS += \
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter
-ST_FAMILY = f3
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
# All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/STM32F303VCTx_FLASH.ld
diff --git a/hw/bsp/stm32f4/family.mk b/hw/bsp/stm32f4/family.mk
index 332d6ee02..1bfb38151 100644
--- a/hw/bsp/stm32f4/family.mk
+++ b/hw/bsp/stm32f4/family.mk
@@ -1,4 +1,9 @@
UF2_FAMILY_ID = 0x57755a57
+ST_FAMILY = f4
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
include $(TOP)/$(BOARD_PATH)/board.mk
@@ -15,10 +20,6 @@ CFLAGS += \
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-align
-ST_FAMILY = f4
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
SRC_C += \
$(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
@@ -32,8 +33,7 @@ INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
$(TOP)/$(ST_CMSIS)/Include \
- $(TOP)/$(ST_HAL_DRIVER)/Inc \
- $(TOP)/hw/bsp/$(BOARD)
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
# For TinyUSB port source
VENDOR = st
diff --git a/hw/bsp/stm32f7/family.c b/hw/bsp/stm32f7/family.c
index 1649e935f..c0d324598 100644
--- a/hw/bsp/stm32f7/family.c
+++ b/hw/bsp/stm32f7/family.c
@@ -55,7 +55,7 @@ void board_init(void)
{
board_clock_init();
- // Enable peripherals clocks
+ // Enable All GPIOs clocks
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
@@ -154,7 +154,7 @@ void board_init(void)
// B-peripheral session valid override enable
USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
-#endif
+#endif // vbus sense
#else
// OTG_HS
@@ -231,7 +231,7 @@ void board_init(void)
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
#endif // USB_HS_PHYC
- /* Enable USB HS & ULPI Clocks */
+ // Enable USB HS & ULPI Clocks
__HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
__HAL_RCC_USB_OTG_HS_CLK_ENABLE();
@@ -260,7 +260,7 @@ void board_init(void)
void board_led_write(bool state)
{
- HAL_GPIO_WritePin(LED_PORT, LED_PIN, state);
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
}
uint32_t board_button_read(void)
diff --git a/hw/bsp/stm32f7/family.mk b/hw/bsp/stm32f7/family.mk
index b09d8143b..ed7670850 100644
--- a/hw/bsp/stm32f7/family.mk
+++ b/hw/bsp/stm32f7/family.mk
@@ -1,4 +1,9 @@
UF2_FAMILY_ID = 0x53b80f00
+ST_FAMILY = f7
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
include $(TOP)/$(BOARD_PATH)/board.mk
@@ -28,10 +33,6 @@ endif
# mcu driver cause following warnings
CFLAGS += -Wno-error=shadow -Wno-error=cast-align
-ST_FAMILY = f7
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
SRC_C += \
$(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
@@ -46,8 +47,7 @@ INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
$(TOP)/$(ST_CMSIS)/Include \
- $(TOP)/$(ST_HAL_DRIVER)/Inc \
- $(TOP)/hw/bsp/$(BOARD)
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
# For TinyUSB port source
VENDOR = st
diff --git a/hw/bsp/stm32h7/boards/stm32h743eval/board.h b/hw/bsp/stm32h7/boards/stm32h743eval/board.h
new file mode 100644
index 000000000..ab263d2b7
--- /dev/null
+++ b/hw/bsp/stm32h7/boards/stm32h743eval/board.h
@@ -0,0 +1,132 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOA
+#define LED_PIN GPIO_PIN_4
+#define LED_STATE_ON 1
+
+// Tamper push-button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 0
+
+// Need to change jumper setting J7 and J8 from RS-232 to STLink
+#define UART_DEV USART1
+#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
+#define UART_GPIO_PORT GPIOB
+#define UART_GPIO_AF GPIO_AF4_USART1
+#define UART_TX_PIN GPIO_PIN_14
+#define UART_RX_PIN GPIO_PIN_15
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32h7_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
+
+ /*!< Supply configuration update enable */
+ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
+ RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+
+ /* PLL1 for System Clock */
+ RCC_OscInitStruct.PLL.PLLM = 5;
+ RCC_OscInitStruct.PLL.PLLN = 160;
+ RCC_OscInitStruct.PLL.PLLFRACN = 0;
+ RCC_OscInitStruct.PLL.PLLP = 2;
+ RCC_OscInitStruct.PLL.PLLR = 2;
+ RCC_OscInitStruct.PLL.PLLQ = 4;
+
+ RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
+ RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* PLL3 for USB Clock */
+ PeriphClkInitStruct.PLL3.PLL3M = 25;
+ PeriphClkInitStruct.PLL3.PLL3N = 336;
+ PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
+ PeriphClkInitStruct.PLL3.PLL3P = 2;
+ PeriphClkInitStruct.PLL3.PLL3R = 2;
+ PeriphClkInitStruct.PLL3.PLL3Q = 7;
+
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure bus clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
+ RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
+
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
+ RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
+
+ /*activate CSI clock mondatory for I/O Compensation Cell*/
+ __HAL_RCC_CSI_ENABLE() ;
+
+ /* Enable SYSCFG clock mondatory for I/O Compensation Cell */
+ __HAL_RCC_SYSCFG_CLK_ENABLE() ;
+
+ /* Enables the I/O Compensation Cell */
+ HAL_EnableCompensationCell();
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/stm32h7/boards/stm32h743eval/board.mk b/hw/bsp/stm32h7/boards/stm32h743eval/board.mk
new file mode 100644
index 000000000..96d14a795
--- /dev/null
+++ b/hw/bsp/stm32h7/boards/stm32h743eval/board.mk
@@ -0,0 +1,13 @@
+CFLAGS += -DSTM32H743xx -DHSE_VALUE=25000000
+
+# Default is Highspeed port
+PORT ?= 1
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h743xx.s
+LD_FILE = $(BOARD_PATH)/stm32h743xx_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = stm32h743xi
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/hw/bsp/stm32h743eval/STM32H743XIHx_FLASH.ld b/hw/bsp/stm32h7/boards/stm32h743eval/stm32h743xx_flash.ld
similarity index 100%
rename from hw/bsp/stm32h743eval/STM32H743XIHx_FLASH.ld
rename to hw/bsp/stm32h7/boards/stm32h743eval/stm32h743xx_flash.ld
diff --git a/hw/bsp/stm32h7/boards/stm32h743nucleo/board.h b/hw/bsp/stm32h7/boards/stm32h743nucleo/board.h
new file mode 100644
index 000000000..3a31783a8
--- /dev/null
+++ b/hw/bsp/stm32h7/boards/stm32h743nucleo/board.h
@@ -0,0 +1,116 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_0
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART3
+#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
+#define UART_GPIO_PORT GPIOD
+#define UART_GPIO_AF GPIO_AF7_USART3
+#define UART_TX_PIN GPIO_PIN_8
+#define UART_RX_PIN GPIO_PIN_9
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32h7_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* The PWR block is always enabled on the H7 series- there is no clock
+ enable. For now, use the default VOS3 scale mode (lowest) and limit clock
+ frequencies to avoid potential current draw problems from bus
+ power when using the max clock speeds throughout the chip. */
+
+ /* Enable HSE Oscillator and activate PLL1 with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
+ RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = 2;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ RCC_OscInitStruct.PLL.PLLR = 2; /* Unused */
+ RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_0;
+ RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
+ RCC_OscInitStruct.PLL.PLLFRACN = 0;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | \
+ RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | \
+ RCC_CLOCKTYPE_D3PCLK1);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
+
+ /* Unlike on the STM32F4 family, it appears the maximum APB frequencies are
+ device-dependent- 120 MHz for this board according to Figure 2 of
+ the datasheet. Dividing by half will be safe for now. */
+ RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
+ RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
+
+ /* 4 wait states required for 168MHz and VOS3. */
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
+
+ /* Like on F4, on H7, USB's actual peripheral clock and bus clock are
+ separate. However, the main system PLL (PLL1) doesn't have a direct
+ connection to the USB peripheral clock to generate 48 MHz, so we do this
+ dance. This will connect PLL1's Q output to the USB peripheral clock. */
+ RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct;
+
+ RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ RCC_PeriphCLKInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
+ HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/stm32h7/boards/stm32h743nucleo/board.mk b/hw/bsp/stm32h7/boards/stm32h743nucleo/board.mk
new file mode 100644
index 000000000..fc670fe76
--- /dev/null
+++ b/hw/bsp/stm32h7/boards/stm32h743nucleo/board.mk
@@ -0,0 +1,13 @@
+CFLAGS += -DSTM32H743xx -DHSE_VALUE=8000000
+
+# Default is FulSpeed port
+PORT ?= 0
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h743xx.s
+LD_FILE = $(BOARD_PATH)/stm32h743xx_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = stm32h743zi
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/hw/bsp/stm32h745disco/STM32H74xXIHx_FLASH.ld b/hw/bsp/stm32h7/boards/stm32h743nucleo/stm32h743xx_flash.ld
similarity index 100%
rename from hw/bsp/stm32h745disco/STM32H74xXIHx_FLASH.ld
rename to hw/bsp/stm32h7/boards/stm32h743nucleo/stm32h743xx_flash.ld
diff --git a/hw/bsp/stm32h7/boards/stm32h745disco/board.h b/hw/bsp/stm32h7/boards/stm32h745disco/board.h
new file mode 100644
index 000000000..30a7a9ff6
--- /dev/null
+++ b/hw/bsp/stm32h7/boards/stm32h745disco/board.h
@@ -0,0 +1,134 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOJ
+#define LED_PIN GPIO_PIN_2
+#define LED_STATE_ON 1
+
+// Blue push-button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+// UART
+#define UART_DEV USART3
+#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
+#define UART_GPIO_PORT GPIOB
+#define UART_GPIO_AF GPIO_AF7_USART3
+#define UART_TX_PIN GPIO_PIN_10
+#define UART_RX_PIN GPIO_PIN_11
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32h7_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
+
+ /*!< Supply configuration update enable */
+ /* For STM32H750XB, use "HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);" */
+ HAL_PWREx_ConfigSupply(PWR_DIRECT_SMPS_SUPPLY);
+
+ /* The voltage scaling allows optimizing the power consumption when the
+ device is clocked below the maximum system frequency, to update the
+ voltage scaling value regarding system frequency refer to product
+ datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
+ RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
+ RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+
+ /* PLL1 for System Clock */
+ RCC_OscInitStruct.PLL.PLLM = 5;
+ RCC_OscInitStruct.PLL.PLLN = 160;
+ RCC_OscInitStruct.PLL.PLLFRACN = 0;
+ RCC_OscInitStruct.PLL.PLLP = 2;
+ RCC_OscInitStruct.PLL.PLLR = 2;
+ RCC_OscInitStruct.PLL.PLLQ = 4;
+
+ RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
+ RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* PLL3 for USB Clock */
+ PeriphClkInitStruct.PLL3.PLL3M = 25;
+ PeriphClkInitStruct.PLL3.PLL3N = 336;
+ PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
+ PeriphClkInitStruct.PLL3.PLL3P = 2;
+ PeriphClkInitStruct.PLL3.PLL3R = 2;
+ PeriphClkInitStruct.PLL3.PLL3Q = 7;
+
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure bus clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
+ RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
+
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
+ RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
+
+ /*activate CSI clock mondatory for I/O Compensation Cell*/
+ __HAL_RCC_CSI_ENABLE() ;
+
+ /* Enable SYSCFG clock mondatory for I/O Compensation Cell */
+ __HAL_RCC_SYSCFG_CLK_ENABLE() ;
+
+ /* Enables the I/O Compensation Cell */
+ HAL_EnableCompensationCell();
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/stm32h7/boards/stm32h745disco/board.mk b/hw/bsp/stm32h7/boards/stm32h745disco/board.mk
new file mode 100644
index 000000000..384065bde
--- /dev/null
+++ b/hw/bsp/stm32h7/boards/stm32h745disco/board.mk
@@ -0,0 +1,17 @@
+# STM32H745I-DISCO uses OTG_FS
+# FIXME: Reset enumerates, un/replug USB plug does not enumerate
+
+CFLAGS += -DSTM32H745xx -DCORE_CM7 -DHSE_VALUE=25000000
+
+# Default is FulSpeed port
+PORT ?= 0
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h745xx.s
+LD_FILE = $(ST_CMSIS)/Source/Templates/gcc/linker/stm32h745xx_flash_CM7.ld
+
+# For flash-jlink target
+JLINK_DEVICE = stm32h745xi_m7
+
+# flash target using on-board stlink
+flash: flash-stlink
+
diff --git a/hw/bsp/stm32h743eval/stm32h743eval.c b/hw/bsp/stm32h7/family.c
similarity index 59%
rename from hw/bsp/stm32h743eval/stm32h743eval.c
rename to hw/bsp/stm32h7/family.c
index 6a51d8884..e94e5c974 100644
--- a/hw/bsp/stm32h743eval/stm32h743eval.c
+++ b/hw/bsp/stm32h7/family.c
@@ -1,8 +1,10 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2019 William D. Jones (thor0505@comcast.net),
- * Ha Thach (tinyusb.org)
+ * Copyright (c) 2019
+ * William D. Jones (thor0505@comcast.net),
+ * Ha Thach (tinyusb.org)
+ * Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,9 +27,9 @@
* This file is part of the TinyUSB stack.
*/
-#include "../board.h"
-
#include "stm32h7xx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
@@ -52,139 +54,25 @@ void OTG_HS_IRQHandler(void)
// MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+
-#define LED_PORT GPIOA
-#define LED_PIN GPIO_PIN_4
-#define LED_STATE_ON 1
-
-// Tamper push-button
-#define BUTTON_PORT GPIOC
-#define BUTTON_PIN GPIO_PIN_13
-#define BUTTON_STATE_ACTIVE 0
-
-// Need to change jumper setting J7 and J8 from RS-232 to STLink
-#define UARTx USART1
-#define UART_GPIO_PORT GPIOB
-#define UART_GPIO_AF GPIO_AF4_USART1
-#define UART_TX_PIN GPIO_PIN_14
-#define UART_RX_PIN GPIO_PIN_15
-
UART_HandleTypeDef UartHandle;
-// enable all LED, Button, Uart, USB clock
-static void all_rcc_clk_enable(void)
-{
- __HAL_RCC_GPIOA_CLK_ENABLE(); // LED
- __HAL_RCC_GPIOC_CLK_ENABLE(); // Button
- __HAL_RCC_GPIOB_CLK_ENABLE(); // Uart tx, rx
- __HAL_RCC_USART1_CLK_ENABLE(); // Uart module
-}
-
-/* PWR, RCC, GPIO (All): AHB4 (D3 domain)
- USB{1,2} OTG_{H,F}S: AHB1 (D2 domain)
-*/
-
-/**
- * @brief System Clock Configuration
- * The system Clock is configured as follow :
- * System Clock source = PLL (HSE)
- * SYSCLK(Hz) = 400000000 (CPU Clock)
- * HCLK(Hz) = 200000000 (AXI and AHBs Clock)
- * AHB Prescaler = 2
- * D1 APB3 Prescaler = 2 (APB3 Clock 100MHz)
- * D2 APB1 Prescaler = 2 (APB1 Clock 100MHz)
- * D2 APB2 Prescaler = 2 (APB2 Clock 100MHz)
- * D3 APB4 Prescaler = 2 (APB4 Clock 100MHz)
- * HSE Frequency(Hz) = 25000000
- * PLL_M = 5
- * PLL_N = 160
- * PLL_P = 2
- * PLL_Q = 4
- * PLL_R = 2
- * PLL3_M = 25
- * PLL3_N = 336
- * PLL3_P = 2
- * PLL3_Q = 7
- * PLL3_R = 2
- * VDD(V) = 3.3
- * Flash Latency(WS) = 4
- * @param None
- * @retval None
- */
-
-void SystemClock_Config(void)
-{
- RCC_ClkInitTypeDef RCC_ClkInitStruct;
- RCC_OscInitTypeDef RCC_OscInitStruct;
- RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
-
- /*!< Supply configuration update enable */
- HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
-
- /* The voltage scaling allows optimizing the power consumption when the device is
- clocked below the maximum system frequency, to update the voltage scaling value
- regarding system frequency refer to product datasheet. */
- __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
-
- while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}
-
- /* Enable HSE Oscillator and activate PLL with HSE as source */
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
- RCC_OscInitStruct.HSEState = RCC_HSE_ON;
- RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
- RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
- RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
-
- /* PLL1 for System Clock */
- RCC_OscInitStruct.PLL.PLLM = 5;
- RCC_OscInitStruct.PLL.PLLN = 160;
- RCC_OscInitStruct.PLL.PLLFRACN = 0;
- RCC_OscInitStruct.PLL.PLLP = 2;
- RCC_OscInitStruct.PLL.PLLR = 2;
- RCC_OscInitStruct.PLL.PLLQ = 4;
-
- RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
- RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
- HAL_RCC_OscConfig(&RCC_OscInitStruct);
-
- /* PLL3 for USB Clock */
- PeriphClkInitStruct.PLL3.PLL3M = 25;
- PeriphClkInitStruct.PLL3.PLL3N = 336;
- PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
- PeriphClkInitStruct.PLL3.PLL3P = 2;
- PeriphClkInitStruct.PLL3.PLL3R = 2;
- PeriphClkInitStruct.PLL3.PLL3Q = 7;
-
- PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
- PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
- HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
-
- /* Select PLL as system clock source and configure bus clocks dividers */
- RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
- RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
-
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
- RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
- RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
- RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
- RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
- RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
- HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
-
- /*activate CSI clock mondatory for I/O Compensation Cell*/
- __HAL_RCC_CSI_ENABLE() ;
-
- /* Enable SYSCFG clock mondatory for I/O Compensation Cell */
- __HAL_RCC_SYSCFG_CLK_ENABLE() ;
-
- /* Enables the I/O Compensation Cell */
- HAL_EnableCompensationCell();
-}
-
void board_init(void)
{
- SystemClock_Config();
- all_rcc_clk_enable();
+ board_stm32h7_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE(); // USB ULPI NXT
+ __HAL_RCC_GPIOC_CLK_ENABLE(); // USB ULPI NXT
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+ __HAL_RCC_GPIOH_CLK_ENABLE(); // USB ULPI NXT
+ __HAL_RCC_GPIOI_CLK_ENABLE(); // USB ULPI NXT
+ __HAL_RCC_GPIOJ_CLK_ENABLE();
+
+ UART_CLK_EN();
// 1ms tick timer
SysTick_Config(SystemCoreClock / 1000);
@@ -219,7 +107,7 @@ void board_init(void)
GPIO_InitStruct.Alternate = UART_GPIO_AF;
HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
- UartHandle.Instance = UARTx;
+ UartHandle.Instance = UART_DEV;
UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
UartHandle.Init.StopBits = UART_STOPBITS_1;
@@ -234,8 +122,6 @@ void board_init(void)
// OTG_FS is marked as RHPort0 by TinyUSB to be consistent across stm32 port
// PA9 VUSB, PA10 ID, PA11 DM, PA12 DP
- __HAL_RCC_GPIOA_CLK_ENABLE();
-
/* Configure DM DP Pins */
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
@@ -244,12 +130,6 @@ void board_init(void)
GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- /* Configure VBUS Pin */
- GPIO_InitStruct.Pin = GPIO_PIN_9;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
/* This for ID line debug */
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
@@ -263,18 +143,27 @@ void board_init(void)
HAL_PWREx_EnableUSBVoltageDetector();
__HAL_RCC_USB2_OTG_FS_CLK_ENABLE();
+#if OTG_FS_VBUS_SENSE
+ /* Configure VBUS Pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_9;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
// Enable VBUS sense (B device) via pin PA9
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+#else
+ // Disable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
+
+ // B-peripheral session valid override enable
+ USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
+ USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
+#endif // vbus sense
#elif BOARD_DEVICE_RHPORT_NUM == 1
-
// Despite being call USB2_OTG
// OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port
- __GPIOA_CLK_ENABLE();
- __GPIOB_CLK_ENABLE();
- __GPIOC_CLK_ENABLE();
- __GPIOH_CLK_ENABLE();
- __GPIOI_CLK_ENABLE();
/* CLK */
GPIO_InitStruct.Pin = GPIO_PIN_5;
@@ -320,18 +209,20 @@ void board_init(void)
GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
- // Enable ULPI clock
+ // Enable USB HS & ULPI Clocks
__HAL_RCC_USB1_OTG_HS_ULPI_CLK_ENABLE();
-
- /* Enable USB HS Clocks */
__HAL_RCC_USB1_OTG_HS_CLK_ENABLE();
+#if OTG_HS_VBUS_SENSE
+ #error OTG HS VBUS Sense enabled is not implemented
+#else
// No VBUS sense
USB_OTG_HS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
// B-peripheral session valid override enable
USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
+#endif
// Force device mode
USB_OTG_HS->GUSBCFG &= ~USB_OTG_GUSBCFG_FHMOD;
@@ -348,7 +239,7 @@ void board_init(void)
void board_led_write(bool state)
{
- HAL_GPIO_WritePin(LED_PORT, LED_PIN, state);
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
}
uint32_t board_button_read(void)
diff --git a/hw/bsp/stm32h743eval/board.mk b/hw/bsp/stm32h7/family.mk
similarity index 79%
rename from hw/bsp/stm32h743eval/board.mk
rename to hw/bsp/stm32h7/family.mk
index 7f42e1a88..8e49604e1 100644
--- a/hw/bsp/stm32h743eval/board.mk
+++ b/hw/bsp/stm32h7/family.mk
@@ -1,5 +1,11 @@
-# Default is Highspeed port
-PORT ?= 1
+UF2_FAMILY_ID = 0x6db66082
+ST_FAMILY = h7
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
CFLAGS += \
-flto \
@@ -9,7 +15,6 @@ CFLAGS += \
-mfloat-abi=hard \
-mfpu=fpv5-d16 \
-nostdlib -nostartfiles \
- -DSTM32H743xx \
-DCFG_TUSB_MCU=OPT_MCU_STM32H7 \
-DBOARD_DEVICE_RHPORT_NUM=$(PORT)
@@ -23,13 +28,7 @@ endif
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align
-ST_FAMILY = h7
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/STM32H743XIHx_FLASH.ld
-
SRC_C += \
$(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
@@ -40,14 +39,11 @@ SRC_C += \
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c
-SRC_S += \
- $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h743xx.s
-
INC += \
+ $(TOP)/$(BOARD_PATH) \
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
$(TOP)/$(ST_CMSIS)/Include \
- $(TOP)/$(ST_HAL_DRIVER)/Inc \
- $(TOP)/hw/bsp/$(BOARD)
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
# For TinyUSB port source
VENDOR = st
@@ -56,8 +52,3 @@ CHIP_FAMILY = synopsys
# For freeRTOS port source
FREERTOS_PORT = ARM_CM7/r0p1
-# For flash-jlink target
-JLINK_DEVICE = stm32h743xi
-
-# flash target using on-board stlink
-flash: flash-stlink
diff --git a/hw/bsp/stm32h745disco/stm32h7xx_hal_conf.h b/hw/bsp/stm32h7/stm32h7xx_hal_conf.h
similarity index 99%
rename from hw/bsp/stm32h745disco/stm32h7xx_hal_conf.h
rename to hw/bsp/stm32h7/stm32h7xx_hal_conf.h
index b9fa348ec..a7cc6d826 100644
--- a/hw/bsp/stm32h745disco/stm32h7xx_hal_conf.h
+++ b/hw/bsp/stm32h7/stm32h7xx_hal_conf.h
@@ -111,7 +111,8 @@
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
-#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
+//#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
+#error HSE_VALUE is not defined
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
diff --git a/hw/bsp/stm32h743eval/stm32h7xx_hal_conf.h b/hw/bsp/stm32h743eval/stm32h7xx_hal_conf.h
deleted file mode 100644
index b9fa348ec..000000000
--- a/hw/bsp/stm32h743eval/stm32h7xx_hal_conf.h
+++ /dev/null
@@ -1,482 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_conf_template.h
- * @brief HAL configuration template file.
- * This file should be copied to the application folder and renamed
- * to stm32h7xx_hal_conf.h.
- ******************************************************************************
- * @attention
- *
- * © COPYRIGHT(c) 2019 STMicroelectronics
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32H7xx_HAL_CONF_H
-#define __STM32H7xx_HAL_CONF_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-
-/* ########################## Module Selection ############################## */
-/**
- * @brief This is the list of modules to be used in the HAL driver
- */
-#define HAL_MODULE_ENABLED
-#define HAL_ADC_MODULE_ENABLED
-/* #define HAL_CEC_MODULE_ENABLED */
-/* #define HAL_COMP_MODULE_ENABLED */
-#define HAL_CORTEX_MODULE_ENABLED
-/* #define HAL_CRC_MODULE_ENABLED */
-/* #define HAL_CRYP_MODULE_ENABLED */
-/* #define HAL_DAC_MODULE_ENABLED */
-/* #define HAL_DCMI_MODULE_ENABLED */
-/* #define HAL_DFSDM_MODULE_ENABLED */
-#define HAL_DMA_MODULE_ENABLED
-/* #define HAL_DMA2D_MODULE_ENABLED */
-/* #define HAL_ETH_MODULE_ENABLED */
-/* #define HAL_EXTI_MODULE_ENABLED */
-/* #define HAL_FDCAN_MODULE_ENABLED */
-#define HAL_FLASH_MODULE_ENABLED
-#define HAL_GPIO_MODULE_ENABLED
-/* #define HAL_HASH_MODULE_ENABLED */
-/* #define HAL_HCD_MODULE_ENABLED */
-/* #define HAL_HRTIM_MODULE_ENABLED */
-/* #define HAL_HSEM_MODULE_ENABLED */
-/* #define HAL_I2C_MODULE_ENABLED */
-/* #define HAL_I2S_MODULE_ENABLED */
-/* #define HAL_IRDA_MODULE_ENABLED */
-/* #define HAL_IWDG_MODULE_ENABLED */
-/* #define HAL_JPEG_MODULE_ENABLED */
-/* #define HAL_LPTIM_MODULE_ENABLED */
-/* #define HAL_LTDC_MODULE_ENABLED */
-/* #define HAL_MDIOS_MODULE_ENABLED */
-/* #define HAL_MDMA_MODULE_ENABLED */
-/* #define HAL_MMC_MODULE_ENABLED */
-/* #define HAL_NAND_MODULE_ENABLED */
-/* #define HAL_NOR_MODULE_ENABLED */
-/* #define HAL_OPAMP_MODULE_ENABLED */
-/* #define HAL_PCD_MODULE_ENABLED */
-#define HAL_PWR_MODULE_ENABLED
-/* #define HAL_QSPI_MODULE_ENABLED */
-/* #define HAL_RAMECC_MODULE_ENABLED */
-#define HAL_RCC_MODULE_ENABLED
-/* #define HAL_RNG_MODULE_ENABLED */
-/* #define HAL_RTC_MODULE_ENABLED */
-/* #define HAL_SAI_MODULE_ENABLED */
-/* #define HAL_SD_MODULE_ENABLED */
-/* #define HAL_SDRAM_MODULE_ENABLED */
-/* #define HAL_SMARTCARD_MODULE_ENABLED */
-/* #define HAL_SMBUS_MODULE_ENABLED */
-/* #define HAL_SPDIFRX_MODULE_ENABLED */
-#define HAL_SPI_MODULE_ENABLED
-/* #define HAL_SRAM_MODULE_ENABLED */
-/* #define HAL_SWPMI_MODULE_ENABLED */
-/* #define HAL_TIM_MODULE_ENABLED */
-#define HAL_UART_MODULE_ENABLED
-/* #define HAL_USART_MODULE_ENABLED */
-/* #define HAL_WWDG_MODULE_ENABLED */
-
-/* ########################## Oscillator Values adaptation ####################*/
-/**
- * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
- * This value is used by the RCC HAL module to compute the system frequency
- * (when HSE is used as system clock source, directly or through the PLL).
- */
-#if !defined (HSE_VALUE)
-#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
-#endif /* HSE_VALUE */
-
-#if !defined (HSE_STARTUP_TIMEOUT)
- #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */
-#endif /* HSE_STARTUP_TIMEOUT */
-
-/**
- * @brief Internal oscillator (CSI) default value.
- * This value is the default CSI value after Reset.
- */
-#if !defined (CSI_VALUE)
- #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
-#endif /* CSI_VALUE */
-
-/**
- * @brief Internal High Speed oscillator (HSI) value.
- * This value is used by the RCC HAL module to compute the system frequency
- * (when HSI is used as system clock source, directly or through the PLL).
- */
-#if !defined (HSI_VALUE)
- #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
-#endif /* HSI_VALUE */
-
-/**
- * @brief External Low Speed oscillator (LSE) value.
- * This value is used by the UART, RTC HAL module to compute the system frequency
- */
-#if !defined (LSE_VALUE)
- #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
-#endif /* LSE_VALUE */
-
-
-#if !defined (LSE_STARTUP_TIMEOUT)
- #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
-#endif /* LSE_STARTUP_TIMEOUT */
-
-#if !defined (LSI_VALUE)
- #define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/
-#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
- The real value may vary depending on the variations
- in voltage and temperature.*/
-
-/**
- * @brief External clock source for I2S peripheral
- * This value is used by the I2S HAL module to compute the I2S clock source
- * frequency, this source is inserted directly through I2S_CKIN pad.
- */
-#if !defined (EXTERNAL_CLOCK_VALUE)
- #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/
-#endif /* EXTERNAL_CLOCK_VALUE */
-
-/* Tip: To avoid modifying this file each time you need to use different HSE,
- === you can define the HSE value in your toolchain compiler preprocessor. */
-
-/* ########################### System Configuration ######################### */
-/**
- * @brief This is the HAL system configuration section
- */
-#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
-#define TICK_INT_PRIORITY ((uint32_t)0x0F) /*!< tick interrupt priority */
-#define USE_RTOS 0
-#define USE_SD_TRANSCEIVER 1U /*!< use uSD Transceiver */
-#define USE_SPI_CRC 1U /*!< use CRC in SPI */
-
-#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
-#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
-#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */
-#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
-#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
-#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
-#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
-#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
-#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
-#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
-#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */
-#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
-#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
-#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
-#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
-#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
-#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
-#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */
-#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
-#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
-#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
-#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
-#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
-#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
-#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
-#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
-#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
-#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
-#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
-#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
-#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
-#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
-#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
-#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */
-#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
-#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
-#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
-#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
-
-/* ########################### Ethernet Configuration ######################### */
-#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */
-#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */
-
-#define ETH_MAC_ADDR0 ((uint8_t)0x02)
-#define ETH_MAC_ADDR1 ((uint8_t)0x00)
-#define ETH_MAC_ADDR2 ((uint8_t)0x00)
-#define ETH_MAC_ADDR3 ((uint8_t)0x00)
-#define ETH_MAC_ADDR4 ((uint8_t)0x00)
-#define ETH_MAC_ADDR5 ((uint8_t)0x00)
-
-/* ########################## Assert Selection ############################## */
-/**
- * @brief Uncomment the line below to expanse the "assert_param" macro in the
- * HAL drivers code
- */
-/* #define USE_FULL_ASSERT 1 */
-
-
-/* Includes ------------------------------------------------------------------*/
-/**
- * @brief Include module's header file
- */
-
-#ifdef HAL_RCC_MODULE_ENABLED
- #include "stm32h7xx_hal_rcc.h"
-#endif /* HAL_RCC_MODULE_ENABLED */
-
-#ifdef HAL_GPIO_MODULE_ENABLED
- #include "stm32h7xx_hal_gpio.h"
-#endif /* HAL_GPIO_MODULE_ENABLED */
-
-#ifdef HAL_DMA_MODULE_ENABLED
- #include "stm32h7xx_hal_dma.h"
-#endif /* HAL_DMA_MODULE_ENABLED */
-
-#ifdef HAL_MDMA_MODULE_ENABLED
- #include "stm32h7xx_hal_mdma.h"
-#endif /* HAL_MDMA_MODULE_ENABLED */
-
-#ifdef HAL_HASH_MODULE_ENABLED
- #include "stm32h7xx_hal_hash.h"
-#endif /* HAL_HASH_MODULE_ENABLED */
-
-#ifdef HAL_DCMI_MODULE_ENABLED
- #include "stm32h7xx_hal_dcmi.h"
-#endif /* HAL_DCMI_MODULE_ENABLED */
-
-#ifdef HAL_DMA2D_MODULE_ENABLED
- #include "stm32h7xx_hal_dma2d.h"
-#endif /* HAL_DMA2D_MODULE_ENABLED */
-
-#ifdef HAL_DSI_MODULE_ENABLED
- #include "stm32h7xx_hal_dsi.h"
-#endif /* HAL_DSI_MODULE_ENABLED */
-
-#ifdef HAL_DFSDM_MODULE_ENABLED
- #include "stm32h7xx_hal_dfsdm.h"
-#endif /* HAL_DFSDM_MODULE_ENABLED */
-
-#ifdef HAL_ETH_MODULE_ENABLED
- #include "stm32h7xx_hal_eth.h"
-#endif /* HAL_ETH_MODULE_ENABLED */
-
-#ifdef HAL_EXTI_MODULE_ENABLED
- #include "stm32h7xx_hal_exti.h"
-#endif /* HAL_EXTI_MODULE_ENABLED */
-
-#ifdef HAL_CORTEX_MODULE_ENABLED
- #include "stm32h7xx_hal_cortex.h"
-#endif /* HAL_CORTEX_MODULE_ENABLED */
-
-#ifdef HAL_ADC_MODULE_ENABLED
- #include "stm32h7xx_hal_adc.h"
-#endif /* HAL_ADC_MODULE_ENABLED */
-
-#ifdef HAL_FDCAN_MODULE_ENABLED
- #include "stm32h7xx_hal_fdcan.h"
-#endif /* HAL_FDCAN_MODULE_ENABLED */
-
-#ifdef HAL_CEC_MODULE_ENABLED
- #include "stm32h7xx_hal_cec.h"
-#endif /* HAL_CEC_MODULE_ENABLED */
-
-#ifdef HAL_COMP_MODULE_ENABLED
- #include "stm32h7xx_hal_comp.h"
-#endif /* HAL_COMP_MODULE_ENABLED */
-
-#ifdef HAL_CRC_MODULE_ENABLED
- #include "stm32h7xx_hal_crc.h"
-#endif /* HAL_CRC_MODULE_ENABLED */
-
-#ifdef HAL_CRYP_MODULE_ENABLED
- #include "stm32h7xx_hal_cryp.h"
-#endif /* HAL_CRYP_MODULE_ENABLED */
-
-#ifdef HAL_DAC_MODULE_ENABLED
- #include "stm32h7xx_hal_dac.h"
-#endif /* HAL_DAC_MODULE_ENABLED */
-
-#ifdef HAL_FLASH_MODULE_ENABLED
- #include "stm32h7xx_hal_flash.h"
-#endif /* HAL_FLASH_MODULE_ENABLED */
-
-#ifdef HAL_HRTIM_MODULE_ENABLED
- #include "stm32h7xx_hal_hrtim.h"
-#endif /* HAL_HRTIM_MODULE_ENABLED */
-
-#ifdef HAL_HSEM_MODULE_ENABLED
- #include "stm32h7xx_hal_hsem.h"
-#endif /* HAL_HSEM_MODULE_ENABLED */
-
-#ifdef HAL_SRAM_MODULE_ENABLED
- #include "stm32h7xx_hal_sram.h"
-#endif /* HAL_SRAM_MODULE_ENABLED */
-
-#ifdef HAL_NOR_MODULE_ENABLED
- #include "stm32h7xx_hal_nor.h"
-#endif /* HAL_NOR_MODULE_ENABLED */
-
-#ifdef HAL_NAND_MODULE_ENABLED
- #include "stm32h7xx_hal_nand.h"
-#endif /* HAL_NAND_MODULE_ENABLED */
-
-#ifdef HAL_I2C_MODULE_ENABLED
- #include "stm32h7xx_hal_i2c.h"
-#endif /* HAL_I2C_MODULE_ENABLED */
-
-#ifdef HAL_I2S_MODULE_ENABLED
- #include "stm32h7xx_hal_i2s.h"
-#endif /* HAL_I2S_MODULE_ENABLED */
-
-#ifdef HAL_IWDG_MODULE_ENABLED
- #include "stm32h7xx_hal_iwdg.h"
-#endif /* HAL_IWDG_MODULE_ENABLED */
-
-#ifdef HAL_JPEG_MODULE_ENABLED
- #include "stm32h7xx_hal_jpeg.h"
-#endif /* HAL_JPEG_MODULE_ENABLED */
-
-#ifdef HAL_MDIOS_MODULE_ENABLED
- #include "stm32h7xx_hal_mdios.h"
-#endif /* HAL_MDIOS_MODULE_ENABLED */
-
-#ifdef HAL_MMC_MODULE_ENABLED
- #include "stm32h7xx_hal_mmc.h"
-#endif /* HAL_MMC_MODULE_ENABLED */
-
-#ifdef HAL_LPTIM_MODULE_ENABLED
-#include "stm32h7xx_hal_lptim.h"
-#endif /* HAL_LPTIM_MODULE_ENABLED */
-
-#ifdef HAL_LTDC_MODULE_ENABLED
-#include "stm32h7xx_hal_ltdc.h"
-#endif /* HAL_LTDC_MODULE_ENABLED */
-
-#ifdef HAL_OPAMP_MODULE_ENABLED
-#include "stm32h7xx_hal_opamp.h"
-#endif /* HAL_OPAMP_MODULE_ENABLED */
-
-#ifdef HAL_PWR_MODULE_ENABLED
- #include "stm32h7xx_hal_pwr.h"
-#endif /* HAL_PWR_MODULE_ENABLED */
-
-#ifdef HAL_QSPI_MODULE_ENABLED
- #include "stm32h7xx_hal_qspi.h"
-#endif /* HAL_QSPI_MODULE_ENABLED */
-
-#ifdef HAL_RAMECC_MODULE_ENABLED
- #include "stm32h7xx_hal_ramecc.h"
-#endif /* HAL_HCD_MODULE_ENABLED */
-
-#ifdef HAL_RNG_MODULE_ENABLED
- #include "stm32h7xx_hal_rng.h"
-#endif /* HAL_RNG_MODULE_ENABLED */
-
-#ifdef HAL_RTC_MODULE_ENABLED
- #include "stm32h7xx_hal_rtc.h"
-#endif /* HAL_RTC_MODULE_ENABLED */
-
-#ifdef HAL_SAI_MODULE_ENABLED
- #include "stm32h7xx_hal_sai.h"
-#endif /* HAL_SAI_MODULE_ENABLED */
-
-#ifdef HAL_SD_MODULE_ENABLED
- #include "stm32h7xx_hal_sd.h"
-#endif /* HAL_SD_MODULE_ENABLED */
-
-#ifdef HAL_SDRAM_MODULE_ENABLED
- #include "stm32h7xx_hal_sdram.h"
-#endif /* HAL_SDRAM_MODULE_ENABLED */
-
-#ifdef HAL_SPI_MODULE_ENABLED
- #include "stm32h7xx_hal_spi.h"
-#endif /* HAL_SPI_MODULE_ENABLED */
-
-#ifdef HAL_SPDIFRX_MODULE_ENABLED
- #include "stm32h7xx_hal_spdifrx.h"
-#endif /* HAL_SPDIFRX_MODULE_ENABLED */
-
-#ifdef HAL_SWPMI_MODULE_ENABLED
- #include "stm32h7xx_hal_swpmi.h"
-#endif /* HAL_SWPMI_MODULE_ENABLED */
-
-#ifdef HAL_TIM_MODULE_ENABLED
- #include "stm32h7xx_hal_tim.h"
-#endif /* HAL_TIM_MODULE_ENABLED */
-
-#ifdef HAL_UART_MODULE_ENABLED
- #include "stm32h7xx_hal_uart.h"
-#endif /* HAL_UART_MODULE_ENABLED */
-
-#ifdef HAL_USART_MODULE_ENABLED
- #include "stm32h7xx_hal_usart.h"
-#endif /* HAL_USART_MODULE_ENABLED */
-
-#ifdef HAL_IRDA_MODULE_ENABLED
- #include "stm32h7xx_hal_irda.h"
-#endif /* HAL_IRDA_MODULE_ENABLED */
-
-#ifdef HAL_SMARTCARD_MODULE_ENABLED
- #include "stm32h7xx_hal_smartcard.h"
-#endif /* HAL_SMARTCARD_MODULE_ENABLED */
-
-#ifdef HAL_SMBUS_MODULE_ENABLED
- #include "stm32h7xx_hal_smbus.h"
-#endif /* HAL_SMBUS_MODULE_ENABLED */
-
-#ifdef HAL_WWDG_MODULE_ENABLED
- #include "stm32h7xx_hal_wwdg.h"
-#endif /* HAL_WWDG_MODULE_ENABLED */
-
-#ifdef HAL_PCD_MODULE_ENABLED
- #include "stm32h7xx_hal_pcd.h"
-#endif /* HAL_PCD_MODULE_ENABLED */
-
-#ifdef HAL_HCD_MODULE_ENABLED
- #include "stm32h7xx_hal_hcd.h"
-#endif /* HAL_HCD_MODULE_ENABLED */
-
-/* Exported macro ------------------------------------------------------------*/
-#ifdef USE_FULL_ASSERT
-/**
- * @brief The assert_param macro is used for function's parameters check.
- * @param expr: If expr is false, it calls assert_failed function
- * which reports the name of the source file and the source
- * line number of the call that failed.
- * If expr is true, it returns no value.
- * @retval None
- */
- #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
-/* Exported functions ------------------------------------------------------- */
- void assert_failed(uint8_t *file, uint32_t line);
-#else
- #define assert_param(expr) ((void)0U)
-#endif /* USE_FULL_ASSERT */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STM32H7xx_HAL_CONF_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/hw/bsp/stm32h743nucleo/STM32H743ZITx_FLASH.ld b/hw/bsp/stm32h743nucleo/STM32H743ZITx_FLASH.ld
deleted file mode 100644
index 65274992e..000000000
--- a/hw/bsp/stm32h743nucleo/STM32H743ZITx_FLASH.ld
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-*****************************************************************************
-**
-
-** File : LinkerScript.ld
-**
-** Abstract : Linker script for STM32H743ZITx Device with
-** 2048KByte FLASH, 1056KByte RAM
-**
-** Set heap size, stack size and stack location according
-** to application requirements.
-**
-** Set memory bank area and size if external memory is used.
-**
-** Target : STMicroelectronics STM32
-**
-**
-** Distribution: The file is distributed as is, without any warranty
-** of any kind.
-**
-** (c)Copyright Ac6.
-** You may use this file as-is or modify it according to the needs of your
-** project. Distribution of this file (unmodified or modified) is not
-** permitted. Ac6 permit registered System Workbench for MCU users the
-** rights to distribute the assembled, compiled & linked contents of this
-** file as part of an application binary file, provided that it is built
-** using the System Workbench for MCU toolchain.
-**
-*****************************************************************************
-*/
-
-/* Entry Point */
-ENTRY(Reset_Handler)
-
-/* Highest address of the user mode stack */
-_estack = 0x20020000; /* end of RAM */
-/* Generate a link error if heap and stack don't fit into RAM */
-_Min_Heap_Size = 0x200; /* required amount of heap */
-_Min_Stack_Size = 0x400; /* required amount of stack */
-
-/* Specify the memory areas */
-MEMORY
-{
-DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
-RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
-RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
-RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
-ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
-FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
-}
-
-/* Define output sections */
-SECTIONS
-{
- /* The startup code goes first into FLASH */
- .isr_vector :
- {
- . = ALIGN(4);
- KEEP(*(.isr_vector)) /* Startup code */
- . = ALIGN(4);
- } >FLASH
-
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.glue_7) /* glue arm to thumb code */
- *(.glue_7t) /* glue thumb to arm code */
- *(.eh_frame)
-
- KEEP (*(.init))
- KEEP (*(.fini))
-
- . = ALIGN(4);
- _etext = .; /* define a global symbols at end of code */
- } >FLASH
-
- /* Constant data goes into FLASH */
- .rodata :
- {
- . = ALIGN(4);
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
- . = ALIGN(4);
- } >FLASH
-
- .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
- .ARM : {
- __exidx_start = .;
- *(.ARM.exidx*)
- __exidx_end = .;
- } >FLASH
-
- .preinit_array :
- {
- PROVIDE_HIDDEN (__preinit_array_start = .);
- KEEP (*(.preinit_array*))
- PROVIDE_HIDDEN (__preinit_array_end = .);
- } >FLASH
- .init_array :
- {
- PROVIDE_HIDDEN (__init_array_start = .);
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array*))
- PROVIDE_HIDDEN (__init_array_end = .);
- } >FLASH
- .fini_array :
- {
- PROVIDE_HIDDEN (__fini_array_start = .);
- KEEP (*(SORT(.fini_array.*)))
- KEEP (*(.fini_array*))
- PROVIDE_HIDDEN (__fini_array_end = .);
- } >FLASH
-
- /* used by the startup to initialize data */
- _sidata = LOADADDR(.data);
-
- /* Initialized data sections goes into RAM, load LMA copy after code */
- .data :
- {
- . = ALIGN(4);
- _sdata = .; /* create a global symbol at data start */
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _edata = .; /* define a global symbol at data end */
- } >DTCMRAM AT> FLASH
-
-
- /* Uninitialized data section */
- . = ALIGN(4);
- .bss :
- {
- /* This is used by the startup in order to initialize the .bss secion */
- _sbss = .; /* define a global symbol at bss start */
- __bss_start__ = _sbss;
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ebss = .; /* define a global symbol at bss end */
- __bss_end__ = _ebss;
- } >DTCMRAM
-
- /* User_heap_stack section, used to check that there is enough RAM left */
- ._user_heap_stack :
- {
- . = ALIGN(8);
- PROVIDE ( end = . );
- PROVIDE ( _end = . );
- . = . + _Min_Heap_Size;
- . = . + _Min_Stack_Size;
- . = ALIGN(8);
- } >DTCMRAM
-
-
-
- /* Remove information from the standard libraries */
- /DISCARD/ :
- {
- libc.a ( * )
- libm.a ( * )
- libgcc.a ( * )
- }
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
-
-
diff --git a/hw/bsp/stm32h743nucleo/board.mk b/hw/bsp/stm32h743nucleo/board.mk
deleted file mode 100644
index 2a5ed8fc2..000000000
--- a/hw/bsp/stm32h743nucleo/board.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-CFLAGS += \
- -flto \
- -mthumb \
- -mabi=aapcs \
- -mcpu=cortex-m7 \
- -mfloat-abi=hard \
- -mfpu=fpv5-d16 \
- -nostdlib -nostartfiles \
- -DSTM32H743xx \
- -DCFG_TUSB_MCU=OPT_MCU_STM32H7
-
-# suppress warning caused by vendor mcu driver
-CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align
-
-ST_FAMILY = h7
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
-# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/STM32H743ZITx_FLASH.ld
-
-SRC_C += \
- $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c
-
-SRC_S += \
- $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h743xx.s
-
-INC += \
- $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
- $(TOP)/$(ST_CMSIS)/Include \
- $(TOP)/$(ST_HAL_DRIVER)/Inc \
- $(TOP)/hw/bsp/$(BOARD)
-
-# For TinyUSB port source
-VENDOR = st
-CHIP_FAMILY = synopsys
-
-# For freeRTOS port source
-FREERTOS_PORT = ARM_CM7/r0p1
-
-# flash target using on-board stlink
-flash: flash-stlink
diff --git a/hw/bsp/stm32h743nucleo/stm32h743nucleo.c b/hw/bsp/stm32h743nucleo/stm32h743nucleo.c
deleted file mode 100644
index b4a723871..000000000
--- a/hw/bsp/stm32h743nucleo/stm32h743nucleo.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 William D. Jones (thor0505@comcast.net),
- * Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#include "../board.h"
-
-#include "stm32h7xx_hal.h"
-
-//--------------------------------------------------------------------+
-// Forward USB interrupt events to TinyUSB IRQ Handler
-//--------------------------------------------------------------------+
-void OTG_FS_IRQHandler(void)
-{
- tud_int_handler(0);
-}
-
-//--------------------------------------------------------------------+
-// MACRO TYPEDEF CONSTANT ENUM
-//--------------------------------------------------------------------+
-
-#define LED_PORT GPIOB
-#define LED_PIN GPIO_PIN_0
-#define LED_STATE_ON 1
-
-#define BUTTON_PORT GPIOC
-#define BUTTON_PIN GPIO_PIN_13
-#define BUTTON_STATE_ACTIVE 1
-
-#define UARTx USART3
-#define UART_GPIO_PORT GPIOD
-#define UART_GPIO_AF GPIO_AF7_USART3
-#define UART_TX_PIN GPIO_PIN_8
-#define UART_RX_PIN GPIO_PIN_9
-
-UART_HandleTypeDef UartHandle;
-
-// enable all LED, Button, Uart, USB clock
-static void all_rcc_clk_enable(void)
-{
- __HAL_RCC_GPIOA_CLK_ENABLE(); // USB D+, D-
- __HAL_RCC_GPIOB_CLK_ENABLE(); // LED
- __HAL_RCC_GPIOC_CLK_ENABLE(); // Button
- __HAL_RCC_GPIOD_CLK_ENABLE(); // Uart tx, rx
- __HAL_RCC_USART3_CLK_ENABLE(); // Uart module
-}
-
-/* PWR, RCC, GPIO (All): AHB4 (D3 domain)
- USB{1,2} OTG_{H,F}S: AHB1 (D2 domain)
-*/
-
-/**
- * @brief System Clock Configuration
- * The system Clock is configured as follows :
- * System Clock source = PLL (HSE)
- * SYSCLK(Hz) = 168000000
- * ACLK(Hz) = 168000000
- * HCLK(Hz) = 168000000
- * AHB1-4 Prescaler = 1
- * APB1 Prescaler (Domain 2) = 2
- * APB2 Prescaler (Domain 2) = 2
- * APB3 Prescaler (Domain 1) = 2
- * APB4 Prescaler (Domain 3) = 2
- * HSE Frequency(Hz) = 8000000
- * PLL1_M = 8
- * PLL1_N = 336
- * PLL1_P = 2
- * PLL1_Q = 7
- * PLL1_R = Unused (TODO: figure out how
- * to gate from HAL?)
- * VDD(V) = 3.3
- * Main regulator output voltage = Scale3 mode
- * Flash Latency(WS) = 4
- * @param None
- * @retval None
- */
-static void SystemClock_Config(void)
-{
- RCC_ClkInitTypeDef RCC_ClkInitStruct;
- RCC_OscInitTypeDef RCC_OscInitStruct;
-
- /* The PWR block is always enabled on the H7 series- there is no clock
- enable. For now, use the default VOS3 scale mode (lowest) and limit clock
- frequencies to avoid potential current draw problems from bus
- power when using the max clock speeds throughout the chip. */
-
- /* Enable HSE Oscillator and activate PLL1 with HSE as source */
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
- RCC_OscInitStruct.HSEState = RCC_HSE_ON;
- RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
- RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
- RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
- RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
- RCC_OscInitStruct.PLL.PLLN = 336;
- RCC_OscInitStruct.PLL.PLLP = 2;
- RCC_OscInitStruct.PLL.PLLQ = 7;
- RCC_OscInitStruct.PLL.PLLR = 2; /* Unused */
- RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_0;
- RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
- RCC_OscInitStruct.PLL.PLLFRACN = 0;
- HAL_RCC_OscConfig(&RCC_OscInitStruct);
-
- RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | \
- RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | \
- RCC_CLOCKTYPE_D3PCLK1);
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
- RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
- RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
-
- /* Unlike on the STM32F4 family, it appears the maximum APB frequencies are
- device-dependent- 120 MHz for this board according to Figure 2 of
- the datasheet. Dividing by half will be safe for now. */
- RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
- RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
- RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
- RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
-
- /* 4 wait states required for 168MHz and VOS3. */
- HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
-
- /* Like on F4, on H7, USB's actual peripheral clock and bus clock are
- separate. However, the main system PLL (PLL1) doesn't have a direct
- connection to the USB peripheral clock to generate 48 MHz, so we do this
- dance. This will connect PLL1's Q output to the USB peripheral clock. */
- RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct;
-
- RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
- RCC_PeriphCLKInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
- HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
-}
-
-void board_init(void)
-{
- SystemClock_Config();
- all_rcc_clk_enable();
-
- #if CFG_TUSB_OS == OPT_OS_NONE
- // 1ms tick timer
- SysTick_Config(SystemCoreClock / 1000);
- #endif
-
- GPIO_InitTypeDef GPIO_InitStruct;
-
- // LED
- GPIO_InitStruct.Pin = LED_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
-
- // Button
- GPIO_InitStruct.Pin = BUTTON_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
-
- // Uart
- GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = UART_GPIO_AF;
- HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
-
- UartHandle.Instance = UARTx;
- UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
- UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
- UartHandle.Init.StopBits = UART_STOPBITS_1;
- UartHandle.Init.Parity = UART_PARITY_NONE;
- UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- UartHandle.Init.Mode = UART_MODE_TX_RX;
- UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
- HAL_UART_Init(&UartHandle);
-
- // USB Pin Init
- // PA9- VUSB, PA10- ID, PA11- DM, PA12- DP
-
- /* Configure DM DP Pins */
- GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* Configure VBUS Pin */
- GPIO_InitStruct.Pin = GPIO_PIN_9;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* This for ID line debug */
- GPIO_InitStruct.Pin = GPIO_PIN_10;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- // https://community.st.com/s/question/0D50X00009XkYZLSA3/stm32h7-nucleo-usb-fs-cdc
- // TODO: Board init actually works fine without this line.
- HAL_PWREx_EnableUSBVoltageDetector();
- __HAL_RCC_USB2_OTG_FS_CLK_ENABLE();
-
- // Enable VBUS sense (B device) via pin PA9
- USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
-}
-
-//--------------------------------------------------------------------+
-// Board porting API
-//--------------------------------------------------------------------+
-
-void board_led_write(bool state)
-{
- HAL_GPIO_WritePin(LED_PORT, LED_PIN, state);
-}
-
-uint32_t board_button_read(void)
-{
- return HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
-}
-
-int board_uart_read(uint8_t* buf, int len)
-{
- (void) buf; (void) len;
- return 0;
-}
-
-int board_uart_write(void const * buf, int len)
-{
- HAL_UART_Transmit(&UartHandle, (uint8_t*) buf, len, 0xffff);
- return len;
-}
-
-
-#if CFG_TUSB_OS == OPT_OS_NONE
-volatile uint32_t system_ticks = 0;
-void SysTick_Handler (void)
-{
- system_ticks++;
-}
-
-uint32_t board_millis(void)
-{
- return system_ticks;
-}
-#endif
-
-void HardFault_Handler (void)
-{
- asm("bkpt");
-}
-
-// Required by __libc_init_array in startup code if we are compiling using
-// -nostdlib/-nostartfiles.
-void _init(void)
-{
-
-}
diff --git a/hw/bsp/stm32h743nucleo/stm32h7xx_hal_conf.h b/hw/bsp/stm32h743nucleo/stm32h7xx_hal_conf.h
deleted file mode 100644
index 8548ca246..000000000
--- a/hw/bsp/stm32h743nucleo/stm32h7xx_hal_conf.h
+++ /dev/null
@@ -1,481 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32h7xx_hal_conf_template.h
- * @brief HAL configuration template file.
- * This file should be copied to the application folder and renamed
- * to stm32h7xx_hal_conf.h.
- ******************************************************************************
- * @attention
- *
- * © COPYRIGHT(c) 2019 STMicroelectronics
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32H7xx_HAL_CONF_H
-#define __STM32H7xx_HAL_CONF_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-
-/* ########################## Module Selection ############################## */
-/**
- * @brief This is the list of modules to be used in the HAL driver
- */
-#define HAL_MODULE_ENABLED
-#define HAL_ADC_MODULE_ENABLED
-/* #define HAL_CEC_MODULE_ENABLED */
-/* #define HAL_COMP_MODULE_ENABLED */
-#define HAL_CORTEX_MODULE_ENABLED
-/* #define HAL_CRC_MODULE_ENABLED */
-/* #define HAL_CRYP_MODULE_ENABLED */
-/* #define HAL_DAC_MODULE_ENABLED */
-/* #define HAL_DCMI_MODULE_ENABLED */
-/* #define HAL_DFSDM_MODULE_ENABLED */
-#define HAL_DMA_MODULE_ENABLED
-/* #define HAL_DMA2D_MODULE_ENABLED */
-/* #define HAL_ETH_MODULE_ENABLED */
-/* #define HAL_EXTI_MODULE_ENABLED */
-/* #define HAL_FDCAN_MODULE_ENABLED */
-#define HAL_FLASH_MODULE_ENABLED
-#define HAL_GPIO_MODULE_ENABLED
-/* #define HAL_HASH_MODULE_ENABLED */
-/* #define HAL_HCD_MODULE_ENABLED */
-/* #define HAL_HRTIM_MODULE_ENABLED */
-/* #define HAL_HSEM_MODULE_ENABLED */
-/* #define HAL_I2C_MODULE_ENABLED */
-/* #define HAL_I2S_MODULE_ENABLED */
-/* #define HAL_IRDA_MODULE_ENABLED */
-/* #define HAL_IWDG_MODULE_ENABLED */
-/* #define HAL_JPEG_MODULE_ENABLED */
-/* #define HAL_LPTIM_MODULE_ENABLED */
-/* #define HAL_LTDC_MODULE_ENABLED */
-/* #define HAL_MDIOS_MODULE_ENABLED */
-/* #define HAL_MDMA_MODULE_ENABLED */
-/* #define HAL_MMC_MODULE_ENABLED */
-/* #define HAL_NAND_MODULE_ENABLED */
-/* #define HAL_NOR_MODULE_ENABLED */
-/* #define HAL_OPAMP_MODULE_ENABLED */
-/* #define HAL_PCD_MODULE_ENABLED */
-#define HAL_PWR_MODULE_ENABLED
-/* #define HAL_QSPI_MODULE_ENABLED */
-/* #define HAL_RAMECC_MODULE_ENABLED */
-#define HAL_RCC_MODULE_ENABLED
-/* #define HAL_RNG_MODULE_ENABLED */
-/* #define HAL_RTC_MODULE_ENABLED */
-/* #define HAL_SAI_MODULE_ENABLED */
-/* #define HAL_SD_MODULE_ENABLED */
-/* #define HAL_SDRAM_MODULE_ENABLED */
-/* #define HAL_SMARTCARD_MODULE_ENABLED */
-/* #define HAL_SMBUS_MODULE_ENABLED */
-/* #define HAL_SPDIFRX_MODULE_ENABLED */
-#define HAL_SPI_MODULE_ENABLED
-/* #define HAL_SRAM_MODULE_ENABLED */
-/* #define HAL_SWPMI_MODULE_ENABLED */
-/* #define HAL_TIM_MODULE_ENABLED */
-#define HAL_UART_MODULE_ENABLED */
-/* #define HAL_USART_MODULE_ENABLED */
-/* #define HAL_WWDG_MODULE_ENABLED */
-
-/* ########################## Oscillator Values adaptation ####################*/
-/**
- * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
- * This value is used by the RCC HAL module to compute the system frequency
- * (when HSE is used as system clock source, directly or through the PLL).
- */
-#if !defined (HSE_VALUE)
-#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
-#endif /* HSE_VALUE */
-
-#if !defined (HSE_STARTUP_TIMEOUT)
- #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */
-#endif /* HSE_STARTUP_TIMEOUT */
-
-/**
- * @brief Internal oscillator (CSI) default value.
- * This value is the default CSI value after Reset.
- */
-#if !defined (CSI_VALUE)
- #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
-#endif /* CSI_VALUE */
-
-/**
- * @brief Internal High Speed oscillator (HSI) value.
- * This value is used by the RCC HAL module to compute the system frequency
- * (when HSI is used as system clock source, directly or through the PLL).
- */
-#if !defined (HSI_VALUE)
- #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
-#endif /* HSI_VALUE */
-
-/**
- * @brief External Low Speed oscillator (LSE) value.
- * This value is used by the UART, RTC HAL module to compute the system frequency
- */
-#if !defined (LSE_VALUE)
- #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
-#endif /* LSE_VALUE */
-
-
-#if !defined (LSE_STARTUP_TIMEOUT)
- #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
-#endif /* LSE_STARTUP_TIMEOUT */
-
-#if !defined (LSI_VALUE)
- #define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/
-#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
- The real value may vary depending on the variations
- in voltage and temperature.*/
-
-/**
- * @brief External clock source for I2S peripheral
- * This value is used by the I2S HAL module to compute the I2S clock source
- * frequency, this source is inserted directly through I2S_CKIN pad.
- */
-#if !defined (EXTERNAL_CLOCK_VALUE)
- #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/
-#endif /* EXTERNAL_CLOCK_VALUE */
-
-/* Tip: To avoid modifying this file each time you need to use different HSE,
- === you can define the HSE value in your toolchain compiler preprocessor. */
-
-/* ########################### System Configuration ######################### */
-/**
- * @brief This is the HAL system configuration section
- */
-#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
-#define TICK_INT_PRIORITY ((uint32_t)0x0F) /*!< tick interrupt priority */
-#define USE_RTOS 0
-#define USE_SD_TRANSCEIVER 1U /*!< use uSD Transceiver */
-#define USE_SPI_CRC 1U /*!< use CRC in SPI */
-
-#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
-#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
-#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */
-#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
-#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
-#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
-#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
-#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
-#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
-#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
-#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */
-#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
-#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
-#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
-#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
-#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
-#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
-#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */
-#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
-#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
-#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
-#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
-#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
-#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
-#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
-#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
-#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
-#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
-#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
-#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
-#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
-#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
-#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
-#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */
-#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
-#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
-#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
-
-/* ########################### Ethernet Configuration ######################### */
-#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */
-#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */
-
-#define ETH_MAC_ADDR0 ((uint8_t)0x02)
-#define ETH_MAC_ADDR1 ((uint8_t)0x00)
-#define ETH_MAC_ADDR2 ((uint8_t)0x00)
-#define ETH_MAC_ADDR3 ((uint8_t)0x00)
-#define ETH_MAC_ADDR4 ((uint8_t)0x00)
-#define ETH_MAC_ADDR5 ((uint8_t)0x00)
-
-/* ########################## Assert Selection ############################## */
-/**
- * @brief Uncomment the line below to expanse the "assert_param" macro in the
- * HAL drivers code
- */
-/* #define USE_FULL_ASSERT 1 */
-
-
-/* Includes ------------------------------------------------------------------*/
-/**
- * @brief Include module's header file
- */
-
-#ifdef HAL_RCC_MODULE_ENABLED
- #include "stm32h7xx_hal_rcc.h"
-#endif /* HAL_RCC_MODULE_ENABLED */
-
-#ifdef HAL_GPIO_MODULE_ENABLED
- #include "stm32h7xx_hal_gpio.h"
-#endif /* HAL_GPIO_MODULE_ENABLED */
-
-#ifdef HAL_DMA_MODULE_ENABLED
- #include "stm32h7xx_hal_dma.h"
-#endif /* HAL_DMA_MODULE_ENABLED */
-
-#ifdef HAL_MDMA_MODULE_ENABLED
- #include "stm32h7xx_hal_mdma.h"
-#endif /* HAL_MDMA_MODULE_ENABLED */
-
-#ifdef HAL_HASH_MODULE_ENABLED
- #include "stm32h7xx_hal_hash.h"
-#endif /* HAL_HASH_MODULE_ENABLED */
-
-#ifdef HAL_DCMI_MODULE_ENABLED
- #include "stm32h7xx_hal_dcmi.h"
-#endif /* HAL_DCMI_MODULE_ENABLED */
-
-#ifdef HAL_DMA2D_MODULE_ENABLED
- #include "stm32h7xx_hal_dma2d.h"
-#endif /* HAL_DMA2D_MODULE_ENABLED */
-
-#ifdef HAL_DSI_MODULE_ENABLED
- #include "stm32h7xx_hal_dsi.h"
-#endif /* HAL_DSI_MODULE_ENABLED */
-
-#ifdef HAL_DFSDM_MODULE_ENABLED
- #include "stm32h7xx_hal_dfsdm.h"
-#endif /* HAL_DFSDM_MODULE_ENABLED */
-
-#ifdef HAL_ETH_MODULE_ENABLED
- #include "stm32h7xx_hal_eth.h"
-#endif /* HAL_ETH_MODULE_ENABLED */
-
-#ifdef HAL_EXTI_MODULE_ENABLED
- #include "stm32h7xx_hal_exti.h"
-#endif /* HAL_EXTI_MODULE_ENABLED */
-
-#ifdef HAL_CORTEX_MODULE_ENABLED
- #include "stm32h7xx_hal_cortex.h"
-#endif /* HAL_CORTEX_MODULE_ENABLED */
-
-#ifdef HAL_ADC_MODULE_ENABLED
- #include "stm32h7xx_hal_adc.h"
-#endif /* HAL_ADC_MODULE_ENABLED */
-
-#ifdef HAL_FDCAN_MODULE_ENABLED
- #include "stm32h7xx_hal_fdcan.h"
-#endif /* HAL_FDCAN_MODULE_ENABLED */
-
-#ifdef HAL_CEC_MODULE_ENABLED
- #include "stm32h7xx_hal_cec.h"
-#endif /* HAL_CEC_MODULE_ENABLED */
-
-#ifdef HAL_COMP_MODULE_ENABLED
- #include "stm32h7xx_hal_comp.h"
-#endif /* HAL_COMP_MODULE_ENABLED */
-
-#ifdef HAL_CRC_MODULE_ENABLED
- #include "stm32h7xx_hal_crc.h"
-#endif /* HAL_CRC_MODULE_ENABLED */
-
-#ifdef HAL_CRYP_MODULE_ENABLED
- #include "stm32h7xx_hal_cryp.h"
-#endif /* HAL_CRYP_MODULE_ENABLED */
-
-#ifdef HAL_DAC_MODULE_ENABLED
- #include "stm32h7xx_hal_dac.h"
-#endif /* HAL_DAC_MODULE_ENABLED */
-
-#ifdef HAL_FLASH_MODULE_ENABLED
- #include "stm32h7xx_hal_flash.h"
-#endif /* HAL_FLASH_MODULE_ENABLED */
-
-#ifdef HAL_HRTIM_MODULE_ENABLED
- #include "stm32h7xx_hal_hrtim.h"
-#endif /* HAL_HRTIM_MODULE_ENABLED */
-
-#ifdef HAL_HSEM_MODULE_ENABLED
- #include "stm32h7xx_hal_hsem.h"
-#endif /* HAL_HSEM_MODULE_ENABLED */
-
-#ifdef HAL_SRAM_MODULE_ENABLED
- #include "stm32h7xx_hal_sram.h"
-#endif /* HAL_SRAM_MODULE_ENABLED */
-
-#ifdef HAL_NOR_MODULE_ENABLED
- #include "stm32h7xx_hal_nor.h"
-#endif /* HAL_NOR_MODULE_ENABLED */
-
-#ifdef HAL_NAND_MODULE_ENABLED
- #include "stm32h7xx_hal_nand.h"
-#endif /* HAL_NAND_MODULE_ENABLED */
-
-#ifdef HAL_I2C_MODULE_ENABLED
- #include "stm32h7xx_hal_i2c.h"
-#endif /* HAL_I2C_MODULE_ENABLED */
-
-#ifdef HAL_I2S_MODULE_ENABLED
- #include "stm32h7xx_hal_i2s.h"
-#endif /* HAL_I2S_MODULE_ENABLED */
-
-#ifdef HAL_IWDG_MODULE_ENABLED
- #include "stm32h7xx_hal_iwdg.h"
-#endif /* HAL_IWDG_MODULE_ENABLED */
-
-#ifdef HAL_JPEG_MODULE_ENABLED
- #include "stm32h7xx_hal_jpeg.h"
-#endif /* HAL_JPEG_MODULE_ENABLED */
-
-#ifdef HAL_MDIOS_MODULE_ENABLED
- #include "stm32h7xx_hal_mdios.h"
-#endif /* HAL_MDIOS_MODULE_ENABLED */
-
-#ifdef HAL_MMC_MODULE_ENABLED
- #include "stm32h7xx_hal_mmc.h"
-#endif /* HAL_MMC_MODULE_ENABLED */
-
-#ifdef HAL_LPTIM_MODULE_ENABLED
-#include "stm32h7xx_hal_lptim.h"
-#endif /* HAL_LPTIM_MODULE_ENABLED */
-
-#ifdef HAL_LTDC_MODULE_ENABLED
-#include "stm32h7xx_hal_ltdc.h"
-#endif /* HAL_LTDC_MODULE_ENABLED */
-
-#ifdef HAL_OPAMP_MODULE_ENABLED
-#include "stm32h7xx_hal_opamp.h"
-#endif /* HAL_OPAMP_MODULE_ENABLED */
-
-#ifdef HAL_PWR_MODULE_ENABLED
- #include "stm32h7xx_hal_pwr.h"
-#endif /* HAL_PWR_MODULE_ENABLED */
-
-#ifdef HAL_QSPI_MODULE_ENABLED
- #include "stm32h7xx_hal_qspi.h"
-#endif /* HAL_QSPI_MODULE_ENABLED */
-
-#ifdef HAL_RAMECC_MODULE_ENABLED
- #include "stm32h7xx_hal_ramecc.h"
-#endif /* HAL_HCD_MODULE_ENABLED */
-
-#ifdef HAL_RNG_MODULE_ENABLED
- #include "stm32h7xx_hal_rng.h"
-#endif /* HAL_RNG_MODULE_ENABLED */
-
-#ifdef HAL_RTC_MODULE_ENABLED
- #include "stm32h7xx_hal_rtc.h"
-#endif /* HAL_RTC_MODULE_ENABLED */
-
-#ifdef HAL_SAI_MODULE_ENABLED
- #include "stm32h7xx_hal_sai.h"
-#endif /* HAL_SAI_MODULE_ENABLED */
-
-#ifdef HAL_SD_MODULE_ENABLED
- #include "stm32h7xx_hal_sd.h"
-#endif /* HAL_SD_MODULE_ENABLED */
-
-#ifdef HAL_SDRAM_MODULE_ENABLED
- #include "stm32h7xx_hal_sdram.h"
-#endif /* HAL_SDRAM_MODULE_ENABLED */
-
-#ifdef HAL_SPI_MODULE_ENABLED
- #include "stm32h7xx_hal_spi.h"
-#endif /* HAL_SPI_MODULE_ENABLED */
-
-#ifdef HAL_SPDIFRX_MODULE_ENABLED
- #include "stm32h7xx_hal_spdifrx.h"
-#endif /* HAL_SPDIFRX_MODULE_ENABLED */
-
-#ifdef HAL_SWPMI_MODULE_ENABLED
- #include "stm32h7xx_hal_swpmi.h"
-#endif /* HAL_SWPMI_MODULE_ENABLED */
-
-#ifdef HAL_TIM_MODULE_ENABLED
- #include "stm32h7xx_hal_tim.h"
-#endif /* HAL_TIM_MODULE_ENABLED */
-
-#ifdef HAL_UART_MODULE_ENABLED
- #include "stm32h7xx_hal_uart.h"
-#endif /* HAL_UART_MODULE_ENABLED */
-
-#ifdef HAL_USART_MODULE_ENABLED
- #include "stm32h7xx_hal_usart.h"
-#endif /* HAL_USART_MODULE_ENABLED */
-
-#ifdef HAL_IRDA_MODULE_ENABLED
- #include "stm32h7xx_hal_irda.h"
-#endif /* HAL_IRDA_MODULE_ENABLED */
-
-#ifdef HAL_SMARTCARD_MODULE_ENABLED
- #include "stm32h7xx_hal_smartcard.h"
-#endif /* HAL_SMARTCARD_MODULE_ENABLED */
-
-#ifdef HAL_SMBUS_MODULE_ENABLED
- #include "stm32h7xx_hal_smbus.h"
-#endif /* HAL_SMBUS_MODULE_ENABLED */
-
-#ifdef HAL_WWDG_MODULE_ENABLED
- #include "stm32h7xx_hal_wwdg.h"
-#endif /* HAL_WWDG_MODULE_ENABLED */
-
-#ifdef HAL_PCD_MODULE_ENABLED
- #include "stm32h7xx_hal_pcd.h"
-#endif /* HAL_PCD_MODULE_ENABLED */
-
-#ifdef HAL_HCD_MODULE_ENABLED
- #include "stm32h7xx_hal_hcd.h"
-#endif /* HAL_HCD_MODULE_ENABLED */
-
-/* Exported macro ------------------------------------------------------------*/
-#ifdef USE_FULL_ASSERT
-/**
- * @brief The assert_param macro is used for function's parameters check.
- * @param expr: If expr is false, it calls assert_failed function
- * which reports the name of the source file and the source
- * line number of the call that failed.
- * If expr is true, it returns no value.
- * @retval None
- */
- #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
-/* Exported functions ------------------------------------------------------- */
- void assert_failed(uint8_t *file, uint32_t line);
-#else
- #define assert_param(expr) ((void)0U)
-#endif /* USE_FULL_ASSERT */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STM32H7xx_HAL_CONF_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/hw/bsp/stm32h745disco/board.mk b/hw/bsp/stm32h745disco/board.mk
deleted file mode 100644
index 78f22a5a2..000000000
--- a/hw/bsp/stm32h745disco/board.mk
+++ /dev/null
@@ -1,58 +0,0 @@
-# STM32H745I-DISCO uses OTG_FS
-# FIXME: Reset enumerates, un/replug USB plug does not enumerate
-
-CFLAGS += \
- -flto \
- -mthumb \
- -mabi=aapcs \
- -mcpu=cortex-m7 \
- -mfloat-abi=hard \
- -mfpu=fpv5-d16 \
- -nostdlib -nostartfiles \
- -DSTM32H745xx \
- -DCORE_CM7 \
- -DCFG_TUSB_MCU=OPT_MCU_STM32H7 \
- -DBOARD_DEVICE_RHPORT_NUM=0 \
- -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_FULL_SPEED
-
-# suppress warning caused by vendor mcu driver
-CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align
-
-ST_FAMILY = h7
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
-# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/STM32H74xXIHx_FLASH.ld
-
-SRC_C += \
- $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \
- $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c
-
-SRC_S += \
- $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h745xx.s
-
-INC += \
- $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
- $(TOP)/$(ST_CMSIS)/Include \
- $(TOP)/$(ST_HAL_DRIVER)/Inc \
- $(TOP)/hw/bsp/$(BOARD)
-
-# For TinyUSB port source
-VENDOR = st
-CHIP_FAMILY = synopsys
-
-# For freeRTOS port source
-FREERTOS_PORT = ARM_CM7/r0p1
-
-# For flash-jlink target
-JLINK_DEVICE = stm32h745xi
-
-# flash target using on-board stlink
-flash: flash-stlink
diff --git a/hw/bsp/stm32h745disco/stm32h745disco.c b/hw/bsp/stm32h745disco/stm32h745disco.c
deleted file mode 100644
index d4fcdbfc0..000000000
--- a/hw/bsp/stm32h745disco/stm32h745disco.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 William D. Jones (thor0505@comcast.net),
- * Ha Thach (tinyusb.org)
- * Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#include "../board.h"
-
-#include "stm32h7xx_hal.h"
-
-//--------------------------------------------------------------------+
-// Forward USB interrupt events to TinyUSB IRQ Handler
-//--------------------------------------------------------------------+
-
-// Despite being call USB2_OTG
-// OTG_FS is marked as RHPort0 by TinyUSB to be consistent across stm32 port
-void OTG_FS_IRQHandler(void)
-{
- tud_int_handler(0);
-}
-
-// Despite being call USB2_OTG
-// OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port
-void OTG_HS_IRQHandler(void)
-{
- tud_int_handler(1);
-}
-
-
-//--------------------------------------------------------------------+
-// MACRO TYPEDEF CONSTANT ENUM
-//--------------------------------------------------------------------+
-
-#define LED_PORT GPIOJ
-#define LED_PIN GPIO_PIN_2
-#define LED_STATE_ON 1
-
-// Blue push-button
-#define BUTTON_PORT GPIOC
-#define BUTTON_PIN GPIO_PIN_13
-#define BUTTON_STATE_ACTIVE 1
-
-// UART
-#define UARTx USART3
-#define UART_GPIO_PORT GPIOB
-#define UART_GPIO_AF GPIO_AF7_USART3
-#define UART_TX_PIN GPIO_PIN_10
-#define UART_RX_PIN GPIO_PIN_11
-
-UART_HandleTypeDef UartHandle;
-
-// enable all LED, Button, Uart, USB clock
-static void all_rcc_clk_enable(void)
-{
- __HAL_RCC_GPIOA_CLK_ENABLE(); // OTG_FS
- __HAL_RCC_GPIOB_CLK_ENABLE(); // USART3 (VCP
- __HAL_RCC_GPIOC_CLK_ENABLE(); // Button
- __HAL_RCC_GPIOJ_CLK_ENABLE(); // LED
- __HAL_RCC_USART3_CLK_ENABLE(); // Uart module
-}
-
-/* PWR, RCC, GPIO (All): AHB4 (D3 domain)
- USB{1,2} OTG_{H,F}S: AHB1 (D2 domain)
-*/
-
-/**
- * @brief System Clock Configuration
- * The system Clock is configured as follow :
- * System Clock source = PLL (HSE)
- * SYSCLK(Hz) = 400000000 (CPU Clock)
- * HCLK(Hz) = 200000000 (AXI and AHBs Clock)
- * AHB Prescaler = 2
- * D1 APB3 Prescaler = 2 (APB3 Clock 100MHz)
- * D2 APB1 Prescaler = 2 (APB1 Clock 100MHz)
- * D2 APB2 Prescaler = 2 (APB2 Clock 100MHz)
- * D3 APB4 Prescaler = 2 (APB4 Clock 100MHz)
- * HSE Frequency(Hz) = 25000000
- * PLL_M = 5
- * PLL_N = 160
- * PLL_P = 2
- * PLL_Q = 4
- * PLL_R = 2
- * PLL3_M = 25
- * PLL3_N = 336
- * PLL3_P = 2
- * PLL3_Q = 7
- * PLL3_R = 2
- * VDD(V) = 3.3
- * Flash Latency(WS) = 4
- * @param None
- * @retval None
- */
-
-void SystemClock_Config(void)
-{
- RCC_ClkInitTypeDef RCC_ClkInitStruct;
- RCC_OscInitTypeDef RCC_OscInitStruct;
- RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
-
- /*!< Supply configuration update enable */
- /* For STM32H750XB, use "HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);" */
- HAL_PWREx_ConfigSupply(PWR_DIRECT_SMPS_SUPPLY);
-
- /* The voltage scaling allows optimizing the power consumption when the
- device is clocked below the maximum system frequency, to update the
- voltage scaling value regarding system frequency refer to product
- datasheet. */
- __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
-
- while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}
-
- /* Enable HSE Oscillator and activate PLL with HSE as source */
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
- RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
- RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
- RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
- RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
-
- /* PLL1 for System Clock */
- RCC_OscInitStruct.PLL.PLLM = 5;
- RCC_OscInitStruct.PLL.PLLN = 160;
- RCC_OscInitStruct.PLL.PLLFRACN = 0;
- RCC_OscInitStruct.PLL.PLLP = 2;
- RCC_OscInitStruct.PLL.PLLR = 2;
- RCC_OscInitStruct.PLL.PLLQ = 4;
-
- RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
- RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
- HAL_RCC_OscConfig(&RCC_OscInitStruct);
-
- /* PLL3 for USB Clock */
- PeriphClkInitStruct.PLL3.PLL3M = 25;
- PeriphClkInitStruct.PLL3.PLL3N = 336;
- PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
- PeriphClkInitStruct.PLL3.PLL3P = 2;
- PeriphClkInitStruct.PLL3.PLL3R = 2;
- PeriphClkInitStruct.PLL3.PLL3Q = 7;
-
- PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
- PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
- HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
-
- /* Select PLL as system clock source and configure bus clocks dividers */
- RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
- RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
-
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
- RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
- RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
- RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
- RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
- RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
- HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
-
- /*activate CSI clock mondatory for I/O Compensation Cell*/
- __HAL_RCC_CSI_ENABLE() ;
-
- /* Enable SYSCFG clock mondatory for I/O Compensation Cell */
- __HAL_RCC_SYSCFG_CLK_ENABLE() ;
-
- /* Enables the I/O Compensation Cell */
- HAL_EnableCompensationCell();
-}
-
-void board_init(void)
-{
- SystemClock_Config();
- all_rcc_clk_enable();
-
- // 1ms tick timer
- SysTick_Config(SystemCoreClock / 1000);
-
-#if CFG_TUSB_OS == OPT_OS_FREERTOS
- // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
- NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
- NVIC_SetPriority(OTG_HS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
-#endif
-
- GPIO_InitTypeDef GPIO_InitStruct;
-
- // LED
- GPIO_InitStruct.Pin = LED_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
-
- // Button
- GPIO_InitStruct.Pin = BUTTON_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
-
- // Uart
- GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = UART_GPIO_AF;
- HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
-
- UartHandle.Instance = UARTx;
- UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
- UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
- UartHandle.Init.StopBits = UART_STOPBITS_1;
- UartHandle.Init.Parity = UART_PARITY_NONE;
- UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- UartHandle.Init.Mode = UART_MODE_TX_RX;
- UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
- HAL_UART_Init(&UartHandle);
-
-#if BOARD_DEVICE_RHPORT_NUM == 0
- // Despite being call USB2_OTG
- // OTG_FS is marked as RHPort0 by TinyUSB to be consistent across stm32 port
- // PA9 VUSB, PA10 ID, PA11 DM, PA12 DP
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
-
- /* Configure DM DP Pins */
- GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* Configure VBUS Pin */
- GPIO_InitStruct.Pin = GPIO_PIN_9;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* This for ID line debug */
- GPIO_InitStruct.Pin = GPIO_PIN_10;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- // https://community.st.com/s/question/0D50X00009XkYZLSA3/stm32h7-nucleo-usb-fs-cdc
- HAL_PWREx_EnableUSBVoltageDetector();
- __HAL_RCC_USB2_OTG_FS_CLK_ENABLE();
-
- // Enable VBUS sense (B device) via pin PA9
- USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
-
-#elif BOARD_DEVICE_RHPORT_NUM == 1
-
- // Despite being call USB2_OTG
- // OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port
- __GPIOA_CLK_ENABLE();
- __GPIOB_CLK_ENABLE();
- __GPIOC_CLK_ENABLE();
- __GPIOH_CLK_ENABLE();
- __GPIOI_CLK_ENABLE();
-
- /* CLK */
- GPIO_InitStruct.Pin = GPIO_PIN_5;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* D0 */
- GPIO_InitStruct.Pin = GPIO_PIN_3;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* D1 D2 D3 D4 D5 D6 D7 */
- GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
- /* STP */
- GPIO_InitStruct.Pin = GPIO_PIN_0;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
- /* NXT */
- GPIO_InitStruct.Pin = GPIO_PIN_4;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
- HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
-
- /* DIR */
- GPIO_InitStruct.Pin = GPIO_PIN_11;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
- HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
-
- // Enable ULPI clock
- __HAL_RCC_USB1_OTG_HS_ULPI_CLK_ENABLE();
-
- /* Enable USB HS Clocks */
- __HAL_RCC_USB1_OTG_HS_CLK_ENABLE();
-
- // No VBUS sense
- USB_OTG_HS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
-
- // B-peripheral session valid override enable
- USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
- USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
-
- // Force device mode
- USB_OTG_HS->GUSBCFG &= ~USB_OTG_GUSBCFG_FHMOD;
- USB_OTG_HS->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD;
-
- HAL_PWREx_EnableUSBVoltageDetector();
-#endif // rhport = 1
-
-}
-
-//--------------------------------------------------------------------+
-// Board porting API
-//--------------------------------------------------------------------+
-
-void board_led_write(bool state)
-{
- HAL_GPIO_WritePin(LED_PORT, LED_PIN, state);
-}
-
-uint32_t board_button_read(void)
-{
- return (BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) ? 1 : 0;
-}
-
-int board_uart_read(uint8_t* buf, int len)
-{
- (void) buf; (void) len;
- return 0;
-}
-
-int board_uart_write(void const * buf, int len)
-{
- HAL_UART_Transmit(&UartHandle, (uint8_t*) buf, len, 0xffff);
- return len;
-}
-
-
-#if CFG_TUSB_OS == OPT_OS_NONE
-volatile uint32_t system_ticks = 0;
-void SysTick_Handler (void)
-{
- system_ticks++;
-}
-
-uint32_t board_millis(void)
-{
- return system_ticks;
-}
-#endif
-
-void HardFault_Handler (void)
-{
- asm("bkpt");
-}
-
-// Required by __libc_init_array in startup code if we are compiling using
-// -nostdlib/-nostartfiles.
-void _init(void)
-{
-
-}
diff --git a/hw/bsp/stm32l0538disco/board.mk b/hw/bsp/stm32l0538disco/board.mk
index 2c9ffad69..5c1929aea 100644
--- a/hw/bsp/stm32l0538disco/board.mk
+++ b/hw/bsp/stm32l0538disco/board.mk
@@ -1,3 +1,9 @@
+ST_FAMILY = l0
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
CFLAGS += \
-flto \
-mthumb \
@@ -12,10 +18,6 @@ CFLAGS += \
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=maybe-uninitialized
-ST_FAMILY = l0
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
# All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/STM32L053C8Tx_FLASH.ld
diff --git a/hw/bsp/stm32l476disco/board.mk b/hw/bsp/stm32l476disco/board.mk
index 9e44598b0..fefcd6433 100644
--- a/hw/bsp/stm32l476disco/board.mk
+++ b/hw/bsp/stm32l476disco/board.mk
@@ -1,3 +1,9 @@
+ST_FAMILY = l4
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
CFLAGS += \
-flto \
-mthumb \
@@ -12,10 +18,6 @@ CFLAGS += \
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align
-ST_FAMILY = l4
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
# All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/STM32L476VGTx_FLASH.ld
diff --git a/hw/bsp/stm32l4r5nucleo/board.mk b/hw/bsp/stm32l4r5nucleo/board.mk
index cee5ce86e..f9fccf9b1 100644
--- a/hw/bsp/stm32l4r5nucleo/board.mk
+++ b/hw/bsp/stm32l4r5nucleo/board.mk
@@ -1,3 +1,9 @@
+ST_FAMILY = l4
+DEPS_SUBMODULES = lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
CFLAGS += \
-flto \
-mthumb \
@@ -13,10 +19,6 @@ CFLAGS += \
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align
-ST_FAMILY = l4
-ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
-ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
-
# All source paths should be relative to the top level.
LD_FILE = hw/bsp/$(BOARD)/STM32L4RXxI_FLASH.ld
diff --git a/hw/mcu/microchip b/hw/mcu/microchip
index 6fd71727d..d75bb2d8c 160000
--- a/hw/mcu/microchip
+++ b/hw/mcu/microchip
@@ -1 +1 @@
-Subproject commit 6fd71727de19733a96766fb93990d7d3ab24ce8a
+Subproject commit d75bb2d8c877043218de104257203bcba6e11cc8
diff --git a/hw/mcu/raspberrypi/pico-sdk b/hw/mcu/raspberrypi/pico-sdk
index 2d5789eca..61978dc70 160000
--- a/hw/mcu/raspberrypi/pico-sdk
+++ b/hw/mcu/raspberrypi/pico-sdk
@@ -1 +1 @@
-Subproject commit 2d5789eca89658a7f0a01e2d6010c0f254605d72
+Subproject commit 61978dc707c7f2026efa4c3300bbb94baa89c78a
diff --git a/lib/CMSIS_4 b/lib/CMSIS_4
deleted file mode 160000
index f2cad4345..000000000
--- a/lib/CMSIS_4
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit f2cad4345783c948ed4a7f5cdb02cdc0856366f1
diff --git a/lib/CMSIS_5 b/lib/CMSIS_5
index b7b26f50d..202852626 160000
--- a/lib/CMSIS_5
+++ b/lib/CMSIS_5
@@ -1 +1 @@
-Subproject commit b7b26f50d00072812aec8453f643e24bafedccb5
+Subproject commit 20285262657d1b482d132d20d755c8c330d55c1f
diff --git a/lib/FreeRTOS b/lib/FreeRTOS
deleted file mode 160000
index c40a6da2e..000000000
--- a/lib/FreeRTOS
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit c40a6da2e4cb8042b56d1b174051cbbe9813781a
diff --git a/lib/FreeRTOS-Kernel b/lib/FreeRTOS-Kernel
new file mode 160000
index 000000000..2a604f4a2
--- /dev/null
+++ b/lib/FreeRTOS-Kernel
@@ -0,0 +1 @@
+Subproject commit 2a604f4a2818b8354b5e1a39e388eb5e16cfbc1f
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index c679dc71e..18919c486 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -396,6 +396,17 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
if ( tud_cdc_line_state_cb ) tud_cdc_line_state_cb(itf, dtr, rts);
}
break;
+ case CDC_REQUEST_SEND_BREAK:
+ if (stage == CONTROL_STAGE_SETUP)
+ {
+ tud_control_status(rhport, request);
+ }
+ else if (stage == CONTROL_STAGE_ACK)
+ {
+ TU_LOG2(" Send Break\r\n");
+ if ( tud_cdc_send_break_cb ) tud_cdc_send_break_cb(itf, request->wValue);
+ }
+ break;
default: return false; // stall unsupported request
}
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h
index 62dcd3c0a..0885922c6 100644
--- a/src/class/cdc/cdc_device.h
+++ b/src/class/cdc/cdc_device.h
@@ -145,6 +145,9 @@ TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
// Invoked when line coding is change via SET_LINE_CODING
TU_ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
+// Invoked when received send break
+TU_ATTR_WEAK void tud_cdc_send_break_cb(uint8_t itf, uint16_t duration_ms);
+
//--------------------------------------------------------------------+
// Inline Functions
//--------------------------------------------------------------------+
diff --git a/src/class/midi/midi_device.c b/src/class/midi/midi_device.c
index c61bad17c..73536a8b0 100644
--- a/src/class/midi/midi_device.c
+++ b/src/class/midi/midi_device.c
@@ -387,6 +387,7 @@ uint16_t midid_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint
p_midi->ep_out = ep_addr;
}
+ // Class Specific MIDI Stream endpoint descriptor
drv_len += tu_desc_len(p_desc);
p_desc = tu_desc_next(p_desc);
diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h
index d31e52f1c..4b4fe92ba 100644
--- a/src/common/tusb_fifo.h
+++ b/src/common/tusb_fifo.h
@@ -53,6 +53,7 @@ extern "C" {
#endif
#if CFG_FIFO_MUTEX
+#include "osal/osal.h"
#define tu_fifo_mutex_t osal_mutex_t
#endif
@@ -108,7 +109,7 @@ static inline void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t write_mute
bool tu_fifo_write (tu_fifo_t* f, void const * p_data);
uint16_t tu_fifo_write_n (tu_fifo_t* f, void const * p_data, uint16_t n);
-uint16_t tu_fifo_write_n_const_addr (tu_fifo_t* f, const void * data, uint16_t n);
+uint16_t tu_fifo_write_n_const_addr (tu_fifo_t* f, const void * data, uint16_t n);
bool tu_fifo_read (tu_fifo_t* f, void * p_buffer);
uint16_t tu_fifo_read_n (tu_fifo_t* f, void * p_buffer, uint16_t n);
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 89f8760d0..1e5b3ff1e 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -134,8 +134,9 @@ void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) TU_ATTR_WEAK;
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
-// Submit an ISO transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
-bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes);
+// Submit an transfer using fifo, When complete dcd_event_xfer_complete() is invoked to notify the stack
+// This API is optional, may be useful for register-based for transferring data.
+bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) TU_ATTR_WEAK;
// Stall endpoint
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 1879729e8..8b126a9f6 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -699,13 +699,21 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
// notable requests are: GET HID REPORT DESCRIPTOR, SET_INTERFACE, GET_INTERFACE
if ( !invoke_class_control(rhport, driver, p_request) )
{
- // For GET_INTERFACE, it is mandatory to respond even if the class
- // driver doesn't use alternate settings.
- TU_VERIFY( TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type &&
- TUSB_REQ_GET_INTERFACE == p_request->bRequest);
+ // For GET_INTERFACE and SET_INTERFACE, it is mandatory to respond even if the class
+ // driver doesn't use alternate settings or implement this
+ TU_VERIFY(TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type);
- uint8_t alternate = 0;
- tud_control_xfer(rhport, p_request, &alternate, 1);
+ if (TUSB_REQ_GET_INTERFACE == p_request->bRequest)
+ {
+ uint8_t alternate = 0;
+ tud_control_xfer(rhport, p_request, &alternate, 1);
+ }else if (TUSB_REQ_SET_INTERFACE == p_request->bRequest)
+ {
+ tud_control_status(rhport, p_request);
+ } else
+ {
+ return false;
+ }
}
}
break;
@@ -992,11 +1000,15 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
switch (event->event_id)
{
case DCD_EVENT_UNPLUGGED:
- _usbd_dev.connected = 0;
- _usbd_dev.addressed = 0;
- _usbd_dev.cfg_num = 0;
- _usbd_dev.suspended = 0;
- osal_queue_send(_usbd_q, event, in_isr);
+ // UNPLUGGED event can be bouncing, only processing if we are currently connected
+ if ( _usbd_dev.connected )
+ {
+ _usbd_dev.connected = 0;
+ _usbd_dev.addressed = 0;
+ _usbd_dev.cfg_num = 0;
+ _usbd_dev.suspended = 0;
+ osal_queue_send(_usbd_q, event, in_isr);
+ }
break;
case DCD_EVENT_SOF:
@@ -1004,9 +1016,10 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
break;
case DCD_EVENT_SUSPEND:
- // NOTE: When plugging/unplugging device, the D+/D- state are unstable and can accidentally meet the
- // SUSPEND condition ( Idle for 3ms ). Some MCUs such as SAMD doesn't distinguish suspend vs disconnect as well.
- // We will skip handling SUSPEND/RESUME event if not currently connected
+ // NOTE: When plugging/unplugging device, the D+/D- state are unstable and
+ // can accidentally meet the SUSPEND condition ( Bus Idle for 3ms ).
+ // In addition, some MCUs such as SAMD or boards that haven no VBUS detection cannot distinguish
+ // suspended vs disconnected. We will skip handling SUSPEND/RESUME event if not currently connected
if ( _usbd_dev.connected )
{
_usbd_dev.suspended = 1;
diff --git a/src/device/usbd.h b/src/device/usbd.h
index b5f7dceba..56615b081 100644
--- a/src/device/usbd.h
+++ b/src/device/usbd.h
@@ -254,6 +254,7 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval
//------------- MIDI -------------//
+// MIDI v1.0 is based on Audio v1.0
#define TUD_MIDI_DESC_HEAD_LEN (9 + 9 + 9 + 7)
#define TUD_MIDI_DESC_HEAD(_itfnum, _stridx, _numcables) \
@@ -289,10 +290,10 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
/* MS Out Jack (External), connected to In Jack Embedded */\
9, TUSB_DESC_CS_INTERFACE, MIDI_CS_INTERFACE_OUT_JACK, MIDI_JACK_EXTERNAL, TUD_MIDI_JACKID_OUT_EXT(_cablenum), 1, TUD_MIDI_JACKID_IN_EMB(_cablenum), 1, 0
-#define TUD_MIDI_DESC_EP_LEN(_numcables) (7 + 4 + (_numcables))
+#define TUD_MIDI_DESC_EP_LEN(_numcables) (9 + 4 + (_numcables))
#define TUD_MIDI_DESC_EP(_epout, _epsize, _numcables) \
- /* Endpoint */\
- 7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0,\
+ /* Endpoint: Note Audio v1.0's endpoint has 9 bytes instead of 7 */\
+ 9, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0, 0, 0, \
/* MS Endpoint (connected to embedded jack) */\
(uint8_t)(4 + (_numcables)), TUSB_DESC_CS_ENDPOINT, MIDI_CS_ENDPOINT_GENERAL, _numcables
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 0bc6378b2..a4ee4cb5c 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -157,6 +157,7 @@ tusb_speed_t tuh_device_get_speed (uint8_t const dev_addr)
return (tusb_speed_t) _usbh_devices[dev_addr].speed;
}
+#if CFG_TUSB_OS == OPT_OS_NONE
void osal_task_delay(uint32_t msec)
{
(void) msec;
@@ -164,6 +165,7 @@ void osal_task_delay(uint32_t msec)
const uint32_t start = hcd_frame_number(TUH_OPT_RHPORT);
while ( ( hcd_frame_number(TUH_OPT_RHPORT) - start ) < msec ) {}
}
+#endif
//--------------------------------------------------------------------+
// CLASS-USBD API (don't require to verify parameters)
diff --git a/src/osal/osal.h b/src/osal/osal.h
index 02e3e0a06..28bdf479c 100644
--- a/src/osal/osal.h
+++ b/src/osal/osal.h
@@ -66,7 +66,6 @@ typedef void (*osal_task_func_t)( void * );
//--------------------------------------------------------------------+
// OSAL Porting API
//--------------------------------------------------------------------+
-//static inline void osal_task_delay(uint32_t msec);
//------------- Semaphore -------------//
static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef);
diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h
index ea6818621..a1f997cf2 100644
--- a/src/osal/osal_none.h
+++ b/src/osal/osal_none.h
@@ -34,14 +34,7 @@
//--------------------------------------------------------------------+
// TASK API
//--------------------------------------------------------------------+
-//static inline void osal_task_delay(uint32_t msec)
-//{
-// (void) msec;
-// // TODO only used by Host stack, will implement using SOF
-//
-//// uint32_t start = tusb_hal_millis();
-//// while ( ( tusb_hal_millis() - start ) < msec ) {}
-//}
+
//--------------------------------------------------------------------+
// Binary Semaphore API
diff --git a/src/osal/osal_pico.h b/src/osal/osal_pico.h
index de964a7a0..bae1217eb 100644
--- a/src/osal/osal_pico.h
+++ b/src/osal/osal_pico.h
@@ -39,12 +39,10 @@
//--------------------------------------------------------------------+
// TASK API
//--------------------------------------------------------------------+
-#ifndef RP2040_USB_HOST_MODE
static inline void osal_task_delay(uint32_t msec)
{
- sleep_ms(msec);
+ sleep_ms(msec);
}
-#endif
//--------------------------------------------------------------------+
// Binary Semaphore API
@@ -145,7 +143,7 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data)
// TODO: revisit... docs say that mutexes are never used from IRQ context,
// however osal_queue_recieve may be. therefore my assumption is that
// the fifo mutex is not populated for queues used from an IRQ context
- assert(!qhdl->ff.mutex);
+ //assert(!qhdl->ff.mutex);
_osal_q_lock(qhdl);
bool success = tu_fifo_read(&qhdl->ff, data);
@@ -159,7 +157,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in
// TODO: revisit... docs say that mutexes are never used from IRQ context,
// however osal_queue_recieve may be. therefore my assumption is that
// the fifo mutex is not populated for queues used from an IRQ context
- assert(!qhdl->ff.mutex);
+ //assert(!qhdl->ff.mutex);
_osal_q_lock(qhdl);
bool success = tu_fifo_write(&qhdl->ff, data);
diff --git a/src/portable/raspberrypi/rp2040/dcd_rp2040.c b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
index 95b0963a3..7731078b5 100644
--- a/src/portable/raspberrypi/rp2040/dcd_rp2040.c
+++ b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
@@ -35,7 +35,8 @@
#include "pico/fix/rp2040_usb_device_enumeration.h"
#endif
-
+#include "osal/osal.h"
+#include "common/tusb_fifo.h"
#include "device/dcd.h"
/*------------------------------------------------------------------*/
@@ -48,23 +49,24 @@
// Init these in dcd_init
static uint8_t *next_buffer_ptr;
-// Endpoints 0-15, direction 0 for out and 1 for in.
-static struct hw_endpoint hw_endpoints[16][2] = {0};
+// USB_MAX_ENDPOINTS Endpoints, direction TUSB_DIR_OUT for out and TUSB_DIR_IN for in.
+static struct hw_endpoint hw_endpoints[USB_MAX_ENDPOINTS][2] = {0};
-static inline struct hw_endpoint *hw_endpoint_get_by_num(uint8_t num, uint8_t in)
+static inline struct hw_endpoint *hw_endpoint_get_by_num(uint8_t num, tusb_dir_t dir)
{
- return &hw_endpoints[num][in];
+ return &hw_endpoints[num][dir];
}
static struct hw_endpoint *hw_endpoint_get_by_addr(uint8_t ep_addr)
{
uint8_t num = tu_edpt_number(ep_addr);
- uint8_t in = (ep_addr & TUSB_DIR_IN_MASK) ? 1 : 0;
- return hw_endpoint_get_by_num(num, in);
+ tusb_dir_t dir = tu_edpt_dir(ep_addr);
+ return hw_endpoint_get_by_num(num, dir);
}
+
static void _hw_endpoint_alloc(struct hw_endpoint *ep)
{
- uint size = TU_MIN(64, ep->wMaxPacketSize);
+ uint16_t size = tu_min16(64, ep->wMaxPacketSize);
// Assumes single buffered for now
ep->hw_data_buf = next_buffer_ptr;
@@ -99,15 +101,13 @@ static void _hw_endpoint_alloc(struct hw_endpoint *ep)
*ep->endpoint_control = reg;
}
-static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t ep_addr, uint wMaxPacketSize, uint8_t transfer_type)
+static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t ep_addr, uint16_t wMaxPacketSize, uint8_t transfer_type)
{
- uint8_t num = tu_edpt_number(ep_addr);
- bool in = ep_addr & TUSB_DIR_IN_MASK;
+ const uint8_t num = tu_edpt_number(ep_addr);
+ const tusb_dir_t dir = tu_edpt_dir(ep_addr);
ep->ep_addr = ep_addr;
- ep->in = in;
// For device, IN is a tx transfer and OUT is an rx transfer
- ep->rx = in == false;
- ep->num = num;
+ ep->rx = (dir == TUSB_DIR_OUT);
// Response to a setup packet on EP0 starts with pid of 1
ep->next_pid = num == 0 ? 1u : 0u;
@@ -131,7 +131,7 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t ep_addr, uint wMax
ep->transfer_type = transfer_type;
// Every endpoint has a buffer control register in dpram
- if (ep->in)
+ if (dir == TUSB_DIR_IN)
{
ep->buffer_control = &usb_dpram->ep_buf_ctrl[num].in;
}
@@ -143,7 +143,7 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t ep_addr, uint wMax
// Clear existing buffer control state
*ep->buffer_control = 0;
- if (ep->num == 0)
+ if (num == 0)
{
// EP0 has no endpoint control register because
// the buffer offsets are fixed
@@ -155,7 +155,7 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t ep_addr, uint wMax
else
{
// Set the endpoint control register (starts at EP1, hence num-1)
- if (in)
+ if (dir == TUSB_DIR_IN)
{
ep->endpoint_control = &usb_dpram->ep_ctrl[num-1].in;
}
@@ -194,7 +194,7 @@ static void hw_endpoint_close(uint8_t ep_addr)
}
#endif
-static void hw_endpoint_init(uint8_t ep_addr, uint wMaxPacketSize, uint8_t bmAttributes)
+static void hw_endpoint_init(uint8_t ep_addr, uint16_t wMaxPacketSize, uint8_t bmAttributes)
{
struct hw_endpoint *ep = hw_endpoint_get_by_addr(ep_addr);
_hw_endpoint_init(ep, ep_addr, wMaxPacketSize, bmAttributes);
@@ -259,10 +259,10 @@ static void ep0_0len_status(void)
static void _hw_endpoint_stall(struct hw_endpoint *ep)
{
assert(!ep->stalled);
- if (ep->num == 0)
+ if (tu_edpt_number(ep->ep_addr) == 0)
{
// A stall on EP0 has to be armed so it can be cleared on the next setup packet
- usb_hw_set->ep_stall_arm = ep->in ? USB_EP_STALL_ARM_EP0_IN_BITS : USB_EP_STALL_ARM_EP0_OUT_BITS;
+ usb_hw_set->ep_stall_arm = (tu_edpt_dir(ep->ep_addr) == TUSB_DIR_IN) ? USB_EP_STALL_ARM_EP0_IN_BITS : USB_EP_STALL_ARM_EP0_OUT_BITS;
}
_hw_endpoint_buffer_control_set_mask32(ep, USB_BUF_CTRL_STALL);
ep->stalled = true;
@@ -276,10 +276,10 @@ static void hw_endpoint_stall(uint8_t ep_addr)
static void _hw_endpoint_clear_stall(struct hw_endpoint *ep)
{
- if (ep->num == 0)
+ if (tu_edpt_number(ep->ep_addr) == 0)
{
// Probably already been cleared but no harm
- usb_hw_clear->ep_stall_arm = ep->in ? USB_EP_STALL_ARM_EP0_IN_BITS : USB_EP_STALL_ARM_EP0_OUT_BITS;
+ usb_hw_clear->ep_stall_arm = (tu_edpt_dir(ep->ep_addr) == TUSB_DIR_IN) ? USB_EP_STALL_ARM_EP0_IN_BITS : USB_EP_STALL_ARM_EP0_OUT_BITS;
}
_hw_endpoint_buffer_control_clear_mask32(ep, USB_BUF_CTRL_STALL);
ep->stalled = false;
@@ -313,18 +313,67 @@ static void dcd_rp2040_irq(void)
hw_handle_buff_status();
}
+ // SE0 for 2 us or more, usually together with Bus Reset
+ if (status & USB_INTS_DEV_CONN_DIS_BITS)
+ {
+ handled |= USB_INTS_DEV_CONN_DIS_BITS;
+
+ if ( usb_hw->sie_status & USB_SIE_STATUS_CONNECTED_BITS )
+ {
+ // Connected: nothing to do
+ }else
+ {
+ // Disconnected
+ dcd_event_bus_signal(0, DCD_EVENT_UNPLUGGED, true);
+ }
+
+ usb_hw_clear->sie_status = USB_SIE_STATUS_CONNECTED_BITS;
+ }
+
+ // SE0 for 2.5 us or more
if (status & USB_INTS_BUS_RESET_BITS)
{
- pico_trace("BUS RESET (addr %d -> %d)\n", assigned_address, 0);
+ pico_trace("BUS RESET\n");
usb_hw->dev_addr_ctrl = 0;
handled |= USB_INTS_BUS_RESET_BITS;
- dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET, true);
+ dcd_event_bus_reset(0, TUSB_SPEED_FULL, true);
usb_hw_clear->sie_status = USB_SIE_STATUS_BUS_RESET_BITS;
+
#if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX
- rp2040_usb_device_enumeration_fix();
+ // Only run enumeration walk-around if pull up is enabled
+ if ( usb_hw->sie_ctrl & USB_SIE_CTRL_PULLUP_EN_BITS )
+ {
+ rp2040_usb_device_enumeration_fix();
+ }
#endif
}
+#if 0
+ // TODO Enable SUSPEND & RESUME interrupt and test later on with/without VBUS detection
+
+ /* Note from pico datasheet 4.1.2.6.4 (v1.2)
+ * If you enable the suspend interrupt, it is likely you will see a suspend interrupt when
+ * the device is first connected but the bus is idle. The bus can be idle for a few ms before
+ * the host begins sending start of frame packets. You will also see a suspend interrupt
+ * when the device is disconnected if you do not have a VBUS detect circuit connected. This is
+ * because without VBUS detection, it is impossible to tell the difference between
+ * being disconnected and suspended.
+ */
+ if (status & USB_INTS_DEV_SUSPEND_BITS)
+ {
+ handled |= USB_INTS_DEV_SUSPEND_BITS;
+ dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
+ usb_hw_clear->sie_status = USB_SIE_STATUS_SUSPENDED_BITS;
+ }
+
+ if (status & USB_INTS_DEV_RESUME_FROM_HOST_BITS)
+ {
+ handled |= USB_INTS_DEV_RESUME_FROM_HOST_BITS;
+ dcd_event_bus_signal(0, DCD_EVENT_RESUME, true);
+ usb_hw_clear->sie_status = USB_SIE_STATUS_RESUME_BITS;
+ }
+#endif
+
if (status ^ handled)
{
panic("Unhandled IRQ 0x%x\n", (uint) (status ^ handled));
@@ -365,8 +414,10 @@ void dcd_init (uint8_t rhport)
// Enable individual controller IRQS here. Processor interrupt enable will be used
// for the global interrupt enable...
+ // TODO Enable SUSPEND & RESUME interrupt
usb_hw->sie_ctrl = USB_SIE_CTRL_EP0_INT_1BUF_BITS;
- usb_hw->inte = USB_INTS_BUFF_STATUS_BITS | USB_INTS_BUS_RESET_BITS | USB_INTS_SETUP_REQ_BITS;
+ usb_hw->inte = USB_INTS_BUFF_STATUS_BITS | USB_INTS_BUS_RESET_BITS | USB_INTS_SETUP_REQ_BITS |
+ USB_INTS_DEV_CONN_DIS_BITS /* | USB_INTS_DEV_SUSPEND_BITS | USB_INTS_DEV_RESUME_FROM_HOST_BITS */ ;
dcd_connect(rhport);
}
@@ -394,8 +445,9 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
void dcd_remote_wakeup(uint8_t rhport)
{
- pico_info("dcd_remote_wakeup %d is not supported yet\n", rhport);
+ pico_info("dcd_remote_wakeup %d\n", rhport);
assert(rhport == 0);
+ usb_hw_set->sie_ctrl = USB_SIE_CTRL_RESUME_BITS;
}
// disconnect by disabling internal pull-up resistor on D+/D-
diff --git a/src/portable/raspberrypi/rp2040/hcd_rp2040.c b/src/portable/raspberrypi/rp2040/hcd_rp2040.c
index efb2bd430..224f6ef21 100644
--- a/src/portable/raspberrypi/rp2040/hcd_rp2040.c
+++ b/src/portable/raspberrypi/rp2040/hcd_rp2040.c
@@ -291,14 +291,16 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t dev_addr, uint8_t
assert(ep->buffer_control);
assert(ep->hw_data_buf);
- uint8_t num = tu_edpt_number(ep_addr);
+ uint8_t const num = tu_edpt_number(ep_addr);
+ tusb_dir_t const dir = tu_edpt_dir(ep_addr);
+
bool in = ep_addr & TUSB_DIR_IN_MASK;
ep->ep_addr = ep_addr;
ep->dev_addr = dev_addr;
- ep->in = in;
+
// For host, IN to host == RX, anything else rx == false
- ep->rx = in == true;
- ep->num = num;
+ ep->rx = (dir == TUSB_DIR_IN);
+
// Response to a setup packet on EP0 starts with pid of 1
ep->next_pid = num == 0 ? 1u : 0u;
ep->wMaxPacketSize = wMaxPacketSize;
@@ -327,9 +329,9 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t dev_addr, uint8_t
// device address
// endpoint number / direction
// preamble
- uint32_t reg = dev_addr | (ep->num << USB_ADDR_ENDP1_ENDPOINT_LSB);
+ uint32_t reg = dev_addr | (num << USB_ADDR_ENDP1_ENDPOINT_LSB);
// Assert the interrupt endpoint is IN_TO_HOST
- assert(ep->in);
+ assert(dir == TUSB_DIR_IN);
if (need_pre(dev_addr))
{
@@ -363,9 +365,10 @@ static void hw_endpoint_init(uint8_t dev_addr, const tusb_desc_endpoint_t *ep_de
//--------------------------------------------------------------------+
// HCD API
//--------------------------------------------------------------------+
-bool hcd_init(void)
+bool hcd_init(uint8_t rhport)
{
- pico_trace("hcd_init\n");
+ pico_trace("hcd_init %d\n", rhport);
+ assert(rhport == 0);
// Reset any previous state
rp2040_usb_init();
@@ -461,7 +464,7 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t *
if (ep == &epx) {
// That has set up buffer control, endpoint control etc
// for host we have to initiate the transfer
- usb_hw->dev_addr_ctrl = dev_addr | ep->num << USB_ADDR_ENDP_ENDPOINT_LSB;
+ usb_hw->dev_addr_ctrl = dev_addr | (tu_edpt_number(ep_addr) << USB_ADDR_ENDP_ENDPOINT_LSB);
uint32_t flags = USB_SIE_CTRL_START_TRANS_BITS | sie_ctrl_base;
flags |= ep->rx ? USB_SIE_CTRL_RECEIVE_DATA_BITS : USB_SIE_CTRL_SEND_DATA_BITS;
// Set pre if we are a low speed device on full speed hub
diff --git a/src/portable/raspberrypi/rp2040/rp2040_usb.c b/src/portable/raspberrypi/rp2040/rp2040_usb.c
index 339297ad6..98ffea9a3 100644
--- a/src/portable/raspberrypi/rp2040/rp2040_usb.c
+++ b/src/portable/raspberrypi/rp2040/rp2040_usb.c
@@ -30,7 +30,6 @@
#include
#include "rp2040_usb.h"
-#include "hardware/clocks.h"
// Direction strings for debug
const char *ep_dir_string[] = {
@@ -44,10 +43,12 @@ static inline void _hw_endpoint_lock_update(struct hw_endpoint *ep, int delta) {
// sense to have worker and IRQ on same core, however I think using critsec is about equivalent.
}
+#if TUSB_OPT_HOST_ENABLED
static inline void _hw_endpoint_update_last_buf(struct hw_endpoint *ep)
{
ep->last_buf = ep->len + ep->transfer_size == ep->total_len;
}
+#endif
void rp2040_usb_init(void)
{
@@ -59,8 +60,11 @@ void rp2040_usb_init(void)
memset(usb_hw, 0, sizeof(*usb_hw));
memset(usb_dpram, 0, sizeof(*usb_dpram));
- // Mux to phy
+ // Mux the controller to the onboard usb phy
usb_hw->muxing = USB_USB_MUXING_TO_PHY_BITS | USB_USB_MUXING_SOFTCON_BITS;
+
+ // Force VBUS detect so the device thinks it is plugged into a host
+ // TODO support VBUs detect
usb_hw->pwr = USB_USB_PWR_VBUS_DETECT_BITS | USB_USB_PWR_VBUS_DETECT_OVERRIDE_EN_BITS;
}
@@ -68,7 +72,9 @@ void hw_endpoint_reset_transfer(struct hw_endpoint *ep)
{
ep->stalled = false;
ep->active = false;
+#if TUSB_OPT_HOST_ENABLED
ep->sent_setup = false;
+#endif
ep->total_len = 0;
ep->len = 0;
ep->transfer_size = 0;
@@ -84,12 +90,12 @@ void _hw_endpoint_buffer_control_update32(struct hw_endpoint *ep, uint32_t and_m
value |= or_mask;
if (or_mask & USB_BUF_CTRL_AVAIL) {
if (*ep->buffer_control & USB_BUF_CTRL_AVAIL) {
- panic("ep %d %s was already available", ep->num, ep_dir_string[ep->in]);
+ panic("ep %d %s was already available", tu_edpt_number(ep->ep_addr), ep_dir_string[tu_edpt_dir(ep->ep_addr)]);
}
*ep->buffer_control = value & ~USB_BUF_CTRL_AVAIL;
// 12 cycle delay.. (should be good for 48*12Mhz = 576Mhz)
// Don't need delay in host mode as host is in charge
-#ifndef RP2040_USB_HOST_MODE
+#if !TUSB_OPT_HOST_ENABLED
__asm volatile (
"b 1f\n"
"1: b 1f\n"
@@ -122,6 +128,7 @@ void _hw_endpoint_start_next_buffer(struct hw_endpoint *ep)
val |= ep->next_pid ? USB_BUF_CTRL_DATA1_PID : USB_BUF_CTRL_DATA0_PID;
ep->next_pid ^= 1u;
+#if TUSB_OPT_HOST_ENABLED
// Is this the last buffer? Only really matters for host mode. Will trigger
// the trans complete irq but also stop it polling. We only really care about
// trans complete for setup packets being sent
@@ -130,6 +137,7 @@ void _hw_endpoint_start_next_buffer(struct hw_endpoint *ep)
pico_trace("Last buf (%d bytes left)\n", ep->transfer_size);
val |= USB_BUF_CTRL_LAST;
}
+#endif
// Finally, write to buffer_control which will trigger the transfer
// the next time the controller polls this dpram address
@@ -141,11 +149,11 @@ void _hw_endpoint_start_next_buffer(struct hw_endpoint *ep)
void _hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, uint16_t total_len)
{
_hw_endpoint_lock_update(ep, 1);
- pico_trace("Start transfer of total len %d on ep %d %s\n", total_len, ep->num, ep_dir_string[ep->in]);
+ pico_trace("Start transfer of total len %d on ep %d %s\n", total_len, tu_edpt_number(ep->ep_addr), ep_dir_string[tu_edpt_dir(ep->ep_addr)]);
if (ep->active)
{
// TODO: Is this acceptable for interrupt packets?
- pico_warn("WARN: starting new transfer on already active ep %d %s\n", ep->num, ep_dir_string[ep->in]);
+ pico_warn("WARN: starting new transfer on already active ep %d %s\n", tu_edpt_number(ep->ep_addr), ep_dir_string[tu_edpt_dir(ep->ep_addr)]);
hw_endpoint_reset_transfer(ep);
}
@@ -153,12 +161,14 @@ void _hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, uint16_t t
// Fill in info now that we're kicking off the hw
ep->total_len = total_len;
ep->len = 0;
- ep->transfer_size = tu_min32(total_len, ep->wMaxPacketSize);
+ ep->transfer_size = tu_min16(total_len, ep->wMaxPacketSize);
ep->active = true;
ep->user_buf = buffer;
+#if TUSB_OPT_HOST_ENABLED
// Recalculate if this is the last buffer
_hw_endpoint_update_last_buf(ep);
ep->buf_sel = 0;
+#endif
_hw_endpoint_start_next_buffer(ep);
_hw_endpoint_lock_update(ep, -1);
@@ -172,9 +182,9 @@ void _hw_endpoint_xfer_sync(struct hw_endpoint *ep)
// Get the buffer state and amount of bytes we have
// transferred
uint32_t buf_ctrl = _hw_endpoint_buffer_control_get_value32(ep);
- uint transferred_bytes = buf_ctrl & USB_BUF_CTRL_LEN_MASK;
+ uint16_t transferred_bytes = buf_ctrl & USB_BUF_CTRL_LEN_MASK;
-#ifdef RP2040_USB_HOST_MODE
+#if TUSB_OPT_HOST_ENABLED
// tag::host_buf_sel_fix[]
if (ep->buf_sel == 1)
{
@@ -223,16 +233,18 @@ bool _hw_endpoint_xfer_continue(struct hw_endpoint *ep)
// Part way through a transfer
if (!ep->active)
{
- panic("Can't continue xfer on inactive ep %d %s", ep->num, ep_dir_string);
+ panic("Can't continue xfer on inactive ep %d %s", tu_edpt_number(ep->ep_addr), ep_dir_string);
}
// Update EP struct from hardware state
_hw_endpoint_xfer_sync(ep);
// Now we have synced our state with the hardware. Is there more data to transfer?
- uint remaining_bytes = ep->total_len - ep->len;
- ep->transfer_size = tu_min32(remaining_bytes, ep->wMaxPacketSize);
+ uint16_t remaining_bytes = ep->total_len - ep->len;
+ ep->transfer_size = tu_min16(remaining_bytes, ep->wMaxPacketSize);
+#if TUSB_OPT_HOST_ENABLED
_hw_endpoint_update_last_buf(ep);
+#endif
// Can happen because of programmer error so check for it
if (ep->len > ep->total_len)
@@ -244,7 +256,7 @@ bool _hw_endpoint_xfer_continue(struct hw_endpoint *ep)
if (ep->len == ep->total_len)
{
pico_trace("Completed transfer of %d bytes on ep %d %s\n",
- ep->len, ep->num, ep_dir_string[ep->in]);
+ ep->len, tu_edpt_number(ep->ep_addr), ep_dir_string[tu_edpt_dir(ep->ep_addr)]);
// Notify caller we are done so it can notify the tinyusb
// stack
_hw_endpoint_lock_update(ep, -1);
@@ -263,7 +275,7 @@ bool _hw_endpoint_xfer_continue(struct hw_endpoint *ep)
void _hw_endpoint_xfer(struct hw_endpoint *ep, uint8_t *buffer, uint16_t total_len, bool start)
{
// Trace
- pico_trace("hw_endpoint_xfer ep %d %s", ep->num, ep_dir_string[ep->in]);
+ pico_trace("hw_endpoint_xfer ep %d %s", tu_edpt_number(ep->ep_addr), ep_dir_string[tu_edpt_dir(ep->ep_addr)]);
pico_trace(" total_len %d, start=%d\n", total_len, start);
assert(ep->configured);
diff --git a/src/portable/raspberrypi/rp2040/rp2040_usb.h b/src/portable/raspberrypi/rp2040/rp2040_usb.h
index 7c3234e8d..bb88d977f 100644
--- a/src/portable/raspberrypi/rp2040/rp2040_usb.h
+++ b/src/portable/raspberrypi/rp2040/rp2040_usb.h
@@ -42,10 +42,6 @@ struct hw_endpoint
{
// Is this a valid struct
bool configured;
- // EP direction
- bool in;
- // EP num (not including direction)
- uint8_t num;
// Transfer direction (i.e. IN is rx for host but tx for device)
// allows us to common up transfer functions
@@ -67,28 +63,30 @@ struct hw_endpoint
// Current transfer information
bool active;
- uint total_len;
- uint len;
+ uint16_t total_len;
+ uint16_t len;
// Amount of data with the hardware
- uint transfer_size;
+ uint16_t transfer_size;
+ // User buffer in main memory
+ uint8_t *user_buf;
+
+ // Data needed from EP descriptor
+ uint16_t wMaxPacketSize;
+ // Interrupt, bulk, etc
+ uint8_t transfer_type;
+
+#if TUSB_OPT_HOST_ENABLED
// Only needed for host mode
bool last_buf;
// HOST BUG. Host will incorrect write status to top half of buffer
// control register when doing transfers > 1 packet
uint8_t buf_sel;
- // User buffer in main memory
- uint8_t *user_buf;
-
- // Data needed from EP descriptor
- uint wMaxPacketSize;
- // Interrupt, bulk, etc
- uint8_t transfer_type;
-
// Only needed for host
uint8_t dev_addr;
bool sent_setup;
// If interrupt endpoint
uint8_t interrupt_num;
+#endif
};
void rp2040_usb_init(void);
diff --git a/tools/build_esp32s2.py b/tools/build_esp32s2.py
index 6580b6562..0ef05023c 100644
--- a/tools/build_esp32s2.py
+++ b/tools/build_esp32s2.py
@@ -27,8 +27,8 @@ def filter_with_input(mylist):
# Build all examples if not specified
all_examples = []
for entry in os.scandir("examples/device"):
- # Only includes example with CMakeLists.txt for esp32s
- if entry.is_dir() and os.path.exists(entry.path + "/sdkconfig.defaults"):
+ # Only includes example with CMakeLists.txt for esp32s, and skip board_test to speed up ci
+ if entry.is_dir() and os.path.exists(entry.path + "/sdkconfig.defaults") and entry.name != 'board_test':
all_examples.append(entry.name)
filter_with_input(all_examples)
all_examples.sort()
diff --git a/tools/build_family.py b/tools/build_family.py
index 23a08c663..65d0e8fc2 100644
--- a/tools/build_family.py
+++ b/tools/build_family.py
@@ -98,12 +98,12 @@ def build_size(example, board):
def skip_example(example, board):
ex_dir = 'examples/' + example
+ # family CMake
+ board_mk = 'hw/bsp/{}/family.cmake'.format(family)
+
# family.mk
- board_mk = 'hw/bsp/{}/family.mk'.format(family)
-
- # family.cmake
if not os.path.exists(board_mk):
- board_mk = 'hw/bsp/{}/family.cmake'.format(family)
+ board_mk = 'hw/bsp/{}/family.mk'.format(family)
with open(board_mk) as mk:
mk_contents = mk.read()