diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cc5caa03..1ff5d813 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,45 +1,40 @@ -name: Silicon Labs firmware build +name: Build firmwares on: push: paths: - Dockerfile - .github/workflows/build.yaml - - .github/workflows/silabs-firmware-build.yaml - - .github/workflows/silabs-firmware-build-zwave.yaml - - EmberZNet/** - - OpenThreadRCP/** - - RCPMultiPAN/** - - ZWave/** + - manifests/**/*.yaml branches: - main tags: - '*' -env: - sdk_version: 4.4.0 - jobs: build-container: name: Create build container image runs-on: ubuntu-latest permissions: packages: write - outputs: - sdk_version: ${{ env.sdk_version }} - image_name: ghcr.io/${{ steps.lower.outputs.repository_owner }}/silabs-firmware-builder:${{ env.sdk_version }} steps: - - name: Repository owner lowercase - id: lower - run: | - echo "repository_owner=$(echo $GITHUB_REPOSITORY_OWNER | tr [:upper:] [:lower:])" >> $GITHUB_OUTPUT - uses: actions/checkout@v3.3.0 + - name: Create container name + id: create-container-name + run: | + repository_owner=$(echo $GITHUB_REPOSITORY_OWNER | tr [:upper:] [:lower:]) + image_name="ghcr.io/$repository_owner/silabs-firmware-builder" + tag_name="${{ hashFiles('Dockerfile') }}" + + echo "image_name=$image_name" >> $GITHUB_OUTPUT + echo "tag_name=$tag_name" >> $GITHUB_OUTPUT + echo "container_name=$image_name:$tag_name" >> $GITHUB_OUTPUT - name: Log in to the GitHub container registry uses: docker/login-action@v2.1.0 with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2.2.1 - name: Build and Push @@ -47,160 +42,101 @@ jobs: with: context: . file: Dockerfile - tags: ghcr.io/${{ steps.lower.outputs.repository_owner }}/silabs-firmware-builder:${{ env.sdk_version }} - cache-from: ghcr.io/${{ steps.lower.outputs.repository_owner }}/silabs-firmware-builder:cache-${{ env.sdk_version }} - cache-to: ghcr.io/${{ steps.lower.outputs.repository_owner }}/silabs-firmware-builder:cache-${{ env.sdk_version }} + tags: ${{ steps.create-container-name.outputs.container_name }} + cache-from: ${{ steps.create-container-name.outputs.image_name }}:cache-${{ steps.create-container-name.outputs.tag_name }} + cache-to: ${{ steps.create-container-name.outputs.image_name }}:cache-${{ steps.create-container-name.outputs.tag_name }} push: true - build-args: - "GECKO_SDK_VERSION=v${{ env.sdk_version }}" + outputs: + container_name: ${{ steps.create-container-name.outputs.container_name }} - ezsp-firmware-build: - name: EmberZNet NCP - needs: build-container - strategy: - matrix: - include: - - target: yellow - device: MGM210PA32JIA - components: simple_led:board_activity,zigbee_token_interface,zigbee_mfglib - patchpath: "EmberZNet/Yellow" - - target: skyconnect - device: EFR32MG21A020F512IM32 - components: zigbee_token_interface,zigbee_mfglib - patchpath: "EmberZNet/SkyConnect" - uses: ./.github/workflows/silabs-firmware-build.yaml - with: - image_name: ${{ needs.build-container.outputs.image_name }} - firmware_name: ncp-uart-hw-${{ matrix.target }} - project_file: "/gecko_sdk/protocol/zigbee/app/ncp/sample-app/ncp-uart-hw/ncp-uart-hw.slcp" - project_name: "ncp-uart-hw" - device: ${{ matrix.device }} - components: ${{ matrix.components }} - configuration: | - SL_IOSTREAM_USART_VCOM_RX_BUFFER_SIZE:64, - EMBER_APS_UNICAST_MESSAGE_COUNT:20, - EMBER_NEIGHBOR_TABLE_SIZE:26, - EMBER_SOURCE_ROUTE_TABLE_SIZE:200, - patchpath: ${{ matrix.patchpath }} - extra_c_defs: "'-DEMBER_ADDRESS_TABLE_SIZE=16' '-DEMBER_MULTICAST_TABLE_SIZE=16'" - sdk_version: ${{ needs.build-container.outputs.sdk_version }} - metadata_fw_type: "ncp-uart-hw" - baudrate: 115200 - metadata_extra: "{ \"ezsp_version\": \"7.4.0.0\" }" - - rcp-multi-pan-firmware-build: - name: RCP Multi-PAN - needs: build-container - strategy: - matrix: - include: - - target: yellow - device: MGM210PA32JIA - components: simple_led:board_activity,cpc_security_secondary_none,zigbee_mfglib - without_components: ot_rcp_gp_interface - patchpath: "RCPMultiPAN/Yellow" - slcp_yaml_changes: > - . += {"sdk_extension": [{"id": "nc_efr32_watchdog", version: "1.0.0"}]} - | .component += [{"from": "nc_efr32_watchdog", "id": "nc_efr32_watchdog"}] - - target: skyconnect - device: EFR32MG21A020F512IM32 - components: cpc_security_secondary_none,zigbee_mfglib - without_components: ot_rcp_gp_interface - patchpath: "RCPMultiPAN/SkyConnect" - slcp_yaml_changes: > - . += {"sdk_extension": [{"id": "nc_efr32_watchdog", version: "1.0.0"}]} - | .component += [{"from": "nc_efr32_watchdog", "id": "nc_efr32_watchdog"}] - uses: ./.github/workflows/silabs-firmware-build.yaml - with: - image_name: ${{ needs.build-container.outputs.image_name }} - firmware_name: rcp-uart-802154-${{ matrix.target }} - project_file: "/gecko_sdk/protocol/openthread/sample-apps/ot-ncp/rcp-uart-802154.slcp" - project_name: "rcp-uart-802154" - device: ${{ matrix.device }} - components: ${{ matrix.components }} - without_components: ${{ matrix.without_components }} - patchpath: ${{ matrix.patchpath }} - slcp_yaml_changes: ${{ matrix.slcp_yaml_changes }} - sdk_version: ${{ needs.build-container.outputs.sdk_version }} - metadata_fw_type: "rcp-uart-802154" - baudrate: 460800 - - ot-rcp-firmware-build: - name: OpenThread RCP - needs: build-container - strategy: - matrix: - include: - - target: yellow - device: MGM210PA32JIA - components: simple_led:board_activity,bootloader_interface - patchpath: "OpenThreadRCP/Yellow" - - target: skyconnect - device: EFR32MG21A020F512IM32 - components: bootloader_interface - patchpath: "OpenThreadRCP/SkyConnect" - uses: ./.github/workflows/silabs-firmware-build.yaml - with: - image_name: ${{ needs.build-container.outputs.image_name }} - firmware_name: ot-rcp-${{ matrix.target }} - project_file: "/gecko_sdk/protocol/openthread/sample-apps/ot-ncp/ot-rcp.slcp" - project_name: "ot-rcp" - device: ${{ matrix.device }} - components: ${{ matrix.components }} - patchpath: ${{ matrix.patchpath }} - sdkpatchpath: "OpenThreadRCP/GeckoSDK" - extra_c_defs: "'-DOPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE=1'" - sdk_version: ${{ needs.build-container.outputs.sdk_version }} - metadata_fw_type: "ot-rcp" - baudrate: 460800 - metadata_extra: "{ \"ot_rcp_version\": \"SL-OPENTHREAD/2.4.0.0_GitHub-7074a43e4\" }" - - zwave-firmware-build: - name: Z-Wave Serial API Controller + list-manifests: + name: List firmware manifests needs: build-container + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v3.3.0 + - id: set-matrix + run: | + echo "matrix=$(find manifests -type f \( -name "*.yaml" -o -name "*.yml" \) -print | sort | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + + build-firmwares: + name: Firmware builder + needs: [list-manifests, build-container] + runs-on: ubuntu-latest + container: + image: ${{ needs.build-container.outputs.container_name }} + options: --user root strategy: matrix: - include: - # Silicon Labs UZB-7 (SLUSB001A), +14 dBm, with SAW filters - # (???) Aeotec Z-Stick 7 / Z-Pi 7 - - target: BRD4201A - device: EFR32ZG14P231F256GM32 - components: brd4201a - compression: lz4 - sign_key: /gecko_sdk/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key - enc_key: /gecko_sdk/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key - - # Silicon Labs UZB-7 (SLUSB001A), +14 dBm, Z-Wave Long Range - - target: BRD4206A - device: EFR32ZG14P231F256GM32 - components: brd4206a - compression: lz4 - sign_key: /gecko_sdk/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key - enc_key: /gecko_sdk/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key - - - target: BRD4207A - device: ZGM130S037HGN - components: brd4207a - compression: lz4 - sign_key: /gecko_sdk/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key - enc_key: /gecko_sdk/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key - - uses: ./.github/workflows/silabs-firmware-build-zwave.yaml - with: - image_name: ${{ needs.build-container.outputs.image_name }} - firmware_name: zwave_serial_api_controller_${{ needs.build-container.outputs.sdk_version }}_${{ matrix.target }} - project_file: "/gecko_sdk/protocol/z-wave/Apps/zwave_ncp_serial_api/zwave_ncp_serial_api_controller.slcp" - project_name: "zwave_ncp_serial_api_controller" - device: ${{ matrix.device }} - components: ${{ matrix.components }} - # Fix known issue 1171840 in Z-Wave SDK - configuration: "ZAF_CONFIG_GENERIC_TYPE:0,ZAF_CONFIG_SPECIFIC_TYPE:0" - # patchpath: ${{ matrix.patchpath }} - sdk_version: ${{ needs.build-container.outputs.sdk_version }} - metadata_fw_type: "zwave" - # There are two "series" of chips: - # * Series 1 devices (EFR32xG1x, ZG[M]13) require lz4 compression - # * Series 2 devices (EFR32xG2x) require lzma compression - gbl_compression: lz4 - gbl_sign_key: "/gecko_sdk/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" - gbl_enc_key: "/gecko_sdk/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" + manifest: ${{ fromJson(needs.list-manifests.outputs.matrix) }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Parse firmware manifest + id: read_manifest_yaml + run: | + yq -r ' + to_entries + | .[] + | select(.value | type == "string") + | .key + "=" + .value + ' "${{ matrix.manifest }}" >> $GITHUB_OUTPUT + + manifest_filename=$(basename "${{ matrix.manifest }}") + manifest_base="${manifest_filename%%.*}" + echo "manifest_base=$manifest_base" >> $GITHUB_OUTPUT + + - name: Install SDK extensions + run: | + # XXX: slc-cli does not actually work when the extensions aren't in the SDK! + for sdk in /gecko_sdk_*; do + slc signature trust --sdk "$sdk" + + ln -s $PWD/gecko_sdk_extensions "$sdk"/extension + + for ext in "$sdk"/extension/*/; do + slc signature trust --sdk "$sdk" --extension-path "$ext" + done + done + + - name: Build firmware + run: | + # Pass all SDKs as consecutive `--sdk ...` arguments + sdk_args="" + for sdk_dir in /gecko_sdk*; do + sdk_args="$sdk_args --sdk $sdk_dir" + done + + # Pass all toolchains as consecutive `--toolchain ...` arguments + toolchain_args="" + for toolchain_dir in /opt/*arm-none-eabi*; do + toolchain_args="$toolchain_args --toolchain $toolchain_dir" + done + + # Build it + mkdir outputs + filename="${{ steps.read_manifest_yaml.outputs['manifest_base'] }}" + + python3 tools/build_project.py \ + $sdk_args \ + $toolchain_args \ + --manifest "${{ matrix.manifest }}" \ + --build-dir build \ + --build-system makefile \ + --output "gbl:outputs/$filename.gbl" \ + --output "hex:outputs/$filename.hex" \ + --output "out:outputs/$filename.out" + + - name: Install node within container (act) + if: ${{ env.ACT }} + run: | + curl -fsSL https://deb.nodesource.com/nsolid_setup_deb.sh | bash -s 20 + apt-get install -y nodejs + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.read_manifest_yaml.outputs['manifest_base'] }} + path: outputs/* diff --git a/.github/workflows/silabs-firmware-build-zwave.yaml b/.github/workflows/silabs-firmware-build-zwave.yaml deleted file mode 100644 index 22b6a6f5..00000000 --- a/.github/workflows/silabs-firmware-build-zwave.yaml +++ /dev/null @@ -1,155 +0,0 @@ -name: Single firmware build - -on: - workflow_call: - inputs: - image_name: - required: false - type: string - default: "ghcr.io/${{ github.repository_owner }}/silabs-firmware-builder:${{ inputs.sdk_version }}" - firmware_name: - required: true - type: string - project_file: - required: true - type: string - project_name: - required: true - type: string - device: - required: true - type: string - components: - required: false - type: string - configuration: - required: false - type: string - patchpath: - required: false - type: string - sdkpatchpath: - required: false - type: string - extra_c_defs: - required: false - type: string - sdk_version: - required: true - type: string - metadata_fw_type: - required: true - type: string - metadata_extra: - required: false - default: "null" - type: string - gbl_compression: - required: true - type: string - gbl_sign_key: - required: false - type: string - gbl_enc_key: - required: false - type: string - -jobs: - firmware-build: - name: Build firmware - runs-on: ubuntu-latest - container: - image: ${{ inputs.image_name }} - options: --user root - defaults: - run: - shell: su --shell=/bin/bash builder {0} - steps: - - uses: actions/checkout@v3.3.0 - - name: Adjust permission - shell: bash - run: chown builder . - - name: Generate Firmware Project - run: | - slc generate \ - --with="${{ inputs.device }},${{ inputs.components }}" \ - --project-file="${{ inputs.project_file }}" \ - --output-type="makefile" \ - --export-destination="$PWD/${{ inputs.firmware_name }}" \ - --copy-proj-sources --copy-sdk-sources --new-project --force \ - --configuration="${{ inputs.configuration }}" - - - name: Patch Firmware - if: "${{ inputs.patchpath != '' }}" - run: | - cd ${{ inputs.firmware_name }} - for patch in "../${{ inputs.patchpath }}"/*.patch - do - echo "Applying ${patch}" - patch -p1 < $patch - done - - - name: Patch SDK - if: "${{ inputs.sdkpatchpath != '' }}" - run: | - if [ ! -d "${{ inputs.sdkpatchpath }}" ]; then - exit 0 - fi - - cd ${{ inputs.firmware_name }}/gecko_sdk_${{ inputs.sdk_version }} - for patch in "../../${{ inputs.sdkpatchpath }}"/*.patch - do - echo "Applying ${patch}" - patch -p1 < $patch - done - - - name: Patch Makefile - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - cd ${{ inputs.firmware_name }} - echo "POST_BUILD_EXE = $PWD/${{ inputs.firmware_name }}/postbuild.sh" - sed -i "s/^C_DEFS\s*=.*$/C_DEFS = ${{ inputs.extra_c_defs }}/" \ - "${{ inputs.project_name }}.Makefile" - sed -i 's#^POST_BUILD_EXE_LINUX = .*$#POST_BUILD_EXE_LINUX = true#' \ - "${{ inputs.project_name }}.Makefile" - - - name: Build Firmware - run: | - cd ${{ inputs.firmware_name }} - make -f ${{ inputs.project_name }}.Makefile release - - name: Add Firmware Metadata - run: | - cd ${{ inputs.firmware_name }} - jq --null-input \ - '{ - "metadata_version": 1, - "sdk_version": "${{ inputs.sdk_version }}", - "fw_type": "${{ inputs.metadata_fw_type }}" - } + ${{ inputs.metadata_extra }}' > version.json - - - name: Generate gbl Firmware - run: | - cd ${{ inputs.firmware_name }} - if [ -n "${{ inputs.gbl_sign_key }}" ] ; then - SIGN_KEY="--sign ${{ inputs.gbl_sign_key }}" - fi - if [ -n "${{ inputs.gbl_enc_key }}" ] ; then - ENC_KEY="--encrypt ${{ inputs.gbl_enc_key }}" - fi - commander gbl create build/release/${{ inputs.firmware_name }}.gbl \ - --app build/release/${{ inputs.project_name }}.hex \ - $SIGN_KEY $ENC_KEY \ - --compress ${{ inputs.gbl_compression }} - - - name: Install node within container (act) - if: ${{ env.ACT }} - shell: bash - run: | - curl -fsSL https://deb.nodesource.com/nsolid_setup_deb.sh | bash -s 20 - apt-get install -y nodejs - - - uses: actions/upload-artifact@v3 - if: success() || failure() - with: - name: ${{ inputs.firmware_name }} - path: ${{ inputs.firmware_name }}/build/release/${{ inputs.firmware_name }}.gbl diff --git a/.github/workflows/silabs-firmware-build.yaml b/.github/workflows/silabs-firmware-build.yaml deleted file mode 100644 index 371fbbb0..00000000 --- a/.github/workflows/silabs-firmware-build.yaml +++ /dev/null @@ -1,172 +0,0 @@ -name: Single firmware build - -on: - workflow_call: - inputs: - image_name: - required: false - type: string - default: "ghcr.io/${{ github.repository_owner }}/silabs-firmware-builder:${{ inputs.sdk_version }}" - firmware_name: - required: true - type: string - project_file: - required: true - type: string - project_name: - required: true - type: string - baudrate: - required: true - type: number - device: - required: true - type: string - components: - required: false - type: string - without_components: - required: false - type: string - configuration: - required: false - type: string - patchpath: - required: false - type: string - sdkpatchpath: - required: false - type: string - extra_c_defs: - required: false - type: string - sdk_version: - required: true - type: string - metadata_fw_type: - required: true - type: string - metadata_extra: - required: false - default: "null" - type: string - slcp_yaml_changes: - required: false - type: string - -jobs: - firmware-build: - name: Build firmware - runs-on: ubuntu-latest - container: - image: ${{ inputs.image_name }} - options: --user root - defaults: - run: - shell: su --shell=/bin/bash builder {0} - steps: - - uses: actions/checkout@v3.3.0 - - name: Adjust permission - shell: bash - run: chown builder . - - - name: Link SDK extensions - shell: bash - run: | - # XXX: slc-cli does not actually work when the extensions aren't in the SDK! - ln -s $PWD/gecko_sdk_extensions /gecko_sdk/extension - - - name: Trust SDK extensions - run: | - for ext in /gecko_sdk/extension/*/; do - slc signature trust --extension-path="$ext" - done - - - name: Generate Firmware Project - run: | - slc generate \ - --with="${{ inputs.device }},${{ inputs.components }}" \ - --without="${{ inputs.without_components }}" \ - --project-file="${{ inputs.project_file }}" \ - --export-destination="$PWD/${{ inputs.firmware_name }}" \ - --copy-proj-sources --copy-sdk-sources --new-project --force \ - --configuration="${{ inputs.configuration }}" - - - name: Set Baudrate - run: | - cd ${{ inputs.firmware_name }} - sed -Ei "s/^(\s*#define SL_\S+_VCOM_BAUDRATE\s+)[0-9]+/\\1${{ inputs.baudrate }}/" \ - config/sl_*usart_vcom_config.h - - - name: Patch Firmware - if: "${{ inputs.patchpath != '' }}" - run: | - cd ${{ inputs.firmware_name }} - for patch in "../${{ inputs.patchpath }}"/*.patch - do - echo "Applying ${patch}" - patch -p1 < $patch - done - - - name: Patch SDK - if: "${{ inputs.sdkpatchpath != '' }}" - run: | - if [ ! -d "${{ inputs.sdkpatchpath }}" ]; then - exit 0 - fi - - cd ${{ inputs.firmware_name }}/gecko_sdk_${{ inputs.sdk_version }} - for patch in "../../${{ inputs.sdkpatchpath }}"/*.patch - do - echo "Applying ${patch}" - patch -p1 < $patch - done - - - name: Patch Makefile - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - LC_TIME=C meta_datetime=$(git log -1 --format="%cd" --date=format:"%b %-d %Y %H:%M:%S") - cd ${{ inputs.firmware_name }} - sed -i "s/^C_DEFS\s*=.*$/C_DEFS = '-DOPENTHREAD_BUILD_DATETIME=\"$meta_datetime\"' ${{ inputs.extra_c_defs }}/" \ - "${{ inputs.project_name }}.Makefile" - - - name: Patch SLCP project file - if: "${{ inputs.slcp_yaml_changes != '' }}" - run: | - cd ${{ inputs.firmware_name }} - yq --in-place --yaml-output '${{ inputs.slcp_yaml_changes }}' "${{ inputs.project_name }}.slcp" - - - name: Build Firmware - run: | - cd ${{ inputs.firmware_name }} - make -f ${{ inputs.project_name }}.Makefile release - - name: Add Firmware Metadata - run: | - cd ${{ inputs.firmware_name }} - jq --null-input \ - '{ - "metadata_version": 1, - "sdk_version": "${{ inputs.sdk_version }}", - "fw_type": "${{ inputs.metadata_fw_type }}", - "baudrate": ${{ inputs.baudrate }} - } + ${{ inputs.metadata_extra }}' > version.json - - - name: Generate gbl Firmware - run: | - cd ${{ inputs.firmware_name }} - commander gbl create build/release/${{ inputs.project_name }}.gbl \ - --app build/release/${{ inputs.project_name }}.out \ - --device ${{ inputs.device }} --metadata version.json - - - name: Install node within container (act) - if: ${{ env.ACT }} - shell: bash - run: | - curl -fsSL https://deb.nodesource.com/nsolid_setup_deb.sh | bash -s 20 - apt-get install -y nodejs - - - uses: actions/upload-artifact@v3 - if: success() || failure() - with: - name: ${{ inputs.firmware_name }} - path: ${{ inputs.firmware_name }}/build/release/*.* diff --git a/.gitignore b/.gitignore index 496ee2ca..abf395f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,14 @@ -.DS_Store \ No newline at end of file +.DS_Store +.pdm/ +.uceditor/ +GNU ARM v*/ +autogen/ +.project +.settings/ +.projectlinkstore +*.project.mak +*.Makefile +build/ +artifact/ +artifacts/ +trashed_modified_files/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8929e12d..6baf7c3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ RUN \ default-jre-headless \ patch \ python3 \ + python3-ruamel.yaml \ unzip \ xz-utils @@ -38,22 +39,27 @@ RUN \ ENV PATH="$PATH:/opt/slc_cli" -ARG GCC_ARM_VERSION="12.2.rel1" - -# Install ARM GCC embedded toolchain +# GCC Embedded Toolchain 12.2.rel1 (for Gecko SDK 4.4.0+) RUN \ - curl -O https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/${GCC_ARM_VERSION}/binrel/arm-gnu-toolchain-${GCC_ARM_VERSION}-x86_64-arm-none-eabi.tar.xz \ - && tar -C /opt -xJf arm-gnu-toolchain-${GCC_ARM_VERSION}-x86_64-arm-none-eabi.tar.xz \ - && rm arm-gnu-toolchain-${GCC_ARM_VERSION}-x86_64-arm-none-eabi.tar.xz + curl -O https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz \ + && tar -C /opt -xf arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz \ + && rm arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz -ENV PATH="$PATH:/opt/arm-gnu-toolchain-${GCC_ARM_VERSION}-x86_64-arm-none-eabi/bin" +# GCC Embedded Toolchain 10.3-2021.10 (for earlier Gecko SDKs) +RUN \ + curl -O https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 \ + && tar -C /opt -xf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 \ + && rm gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 -ARG GECKO_SDK_VERSION="v4.4.0" +# Gecko SDK 4.4.0 +RUN \ + git clone --depth 1 -b v4.4.0 https://github.com/SiliconLabs/gecko_sdk.git gecko_sdk_4.4.0 \ + && rm -rf gecko_sdk_4.4.0/.git +# Gecko SDK 4.3.1 RUN \ - git clone --depth 1 -b ${GECKO_SDK_VERSION} \ - https://github.com/SiliconLabs/gecko_sdk.git \ - && rm -rf gecko_sdk/.git + git clone --depth 1 -b v4.3.1 https://github.com/SiliconLabs/gecko_sdk.git gecko_sdk_4.3.1 \ + && rm -rf gecko_sdk_4.3.1/.git ARG USERNAME=builder ARG USER_UID=1000 @@ -65,11 +71,3 @@ RUN groupadd --gid $USER_GID $USERNAME \ USER $USERNAME WORKDIR /build - -RUN \ - slc configuration \ - --sdk="/gecko_sdk/" \ - && slc signature trust --sdk "/gecko_sdk/" \ - && slc configuration \ - --gcc-toolchain="/opt/arm-gnu-toolchain-${GCC_ARM_VERSION}-x86_64-arm-none-eabi/" - diff --git a/EmberZNet/SkyConnect/0001-config-configure-usart-vcom-for-SkyConnect.patch b/EmberZNet/SkyConnect/0001-config-configure-usart-vcom-for-SkyConnect.patch deleted file mode 100644 index aae338c8..00000000 --- a/EmberZNet/SkyConnect/0001-config-configure-usart-vcom-for-SkyConnect.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 769a0b5cfbaf0d9beb26606b1692c81e7327dc9a Mon Sep 17 00:00:00 2001 -Message-Id: <769a0b5cfbaf0d9beb26606b1692c81e7327dc9a.1675331061.git.stefan@agner.ch> -From: Stefan Agner -Date: Thu, 2 Feb 2023 10:41:24 +0100 -Subject: [PATCH] config: configure usart vcom for SkyConnect - ---- - config/sl_iostream_usart_vcom_config.h | 25 ++++++++++++++----------- - 1 file changed, 14 insertions(+), 11 deletions(-) - -diff --git a/config/sl_iostream_usart_vcom_config.h b/config/sl_iostream_usart_vcom_config.h -index 330844c..a58a1bb 100644 ---- a/config/sl_iostream_usart_vcom_config.h -+++ b/config/sl_iostream_usart_vcom_config.h -@@ -84,21 +84,24 @@ - // <<< sl:start pin_tool >>> - // SL_IOSTREAM_USART_VCOM - // $[USART_SL_IOSTREAM_USART_VCOM] --#warning "IO Stream USART peripheral not configured" --// #define SL_IOSTREAM_USART_VCOM_PERIPHERAL USART0 --// #define SL_IOSTREAM_USART_VCOM_PERIPHERAL_NO 0 -+#define SL_IOSTREAM_USART_VCOM_PERIPHERAL USART0 -+#define SL_IOSTREAM_USART_VCOM_PERIPHERAL_NO 0 - --// #define SL_IOSTREAM_USART_VCOM_TX_PORT gpioPortC --// #define SL_IOSTREAM_USART_VCOM_TX_PIN 11 -+// USART0 TX on PA06 -+#define SL_IOSTREAM_USART_VCOM_TX_PORT gpioPortA -+#define SL_IOSTREAM_USART_VCOM_TX_PIN 6 - --// #define SL_IOSTREAM_USART_VCOM_RX_PORT gpioPortC --// #define SL_IOSTREAM_USART_VCOM_RX_PIN 10 -+// USART0 RX on PA05 -+#define SL_IOSTREAM_USART_VCOM_RX_PORT gpioPortA -+#define SL_IOSTREAM_USART_VCOM_RX_PIN 5 - --// #define SL_IOSTREAM_USART_VCOM_CTS_PORT gpioPortA --// #define SL_IOSTREAM_USART_VCOM_CTS_PIN 12 -+// USART0 CTS on PB01 -+#define SL_IOSTREAM_USART_VCOM_CTS_PORT gpioPortB -+#define SL_IOSTREAM_USART_VCOM_CTS_PIN 1 - --// #define SL_IOSTREAM_USART_VCOM_RTS_PORT gpioPortC --// #define SL_IOSTREAM_USART_VCOM_RTS_PIN 8 -+// USART0 RTS on PB00 -+#define SL_IOSTREAM_USART_VCOM_RTS_PORT gpioPortB -+#define SL_IOSTREAM_USART_VCOM_RTS_PIN 0 - // [USART_SL_IOSTREAM_USART_VCOM]$ - // <<< sl:end pin_tool >>> - --- -2.39.1 - diff --git a/EmberZNet/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch b/EmberZNet/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch deleted file mode 100644 index 951b356b..00000000 --- a/EmberZNet/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 254abe857b7ade936fdde9c9bf0481f9d2489049 Mon Sep 17 00:00:00 2001 -Message-Id: <254abe857b7ade936fdde9c9bf0481f9d2489049.1675331135.git.stefan@agner.ch> -From: Stefan Agner -Date: Thu, 2 Feb 2023 10:44:57 +0100 -Subject: [PATCH] config: use SkyConnect specific UUID as Application Product - ID - ---- - config/app_properties_config.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/config/app_properties_config.h b/config/app_properties_config.h -index 6a6b976..af5ece7 100644 ---- a/config/app_properties_config.h -+++ b/config/app_properties_config.h -@@ -58,7 +58,7 @@ - #define SL_APPLICATION_CAPABILITIES 0 - - //Product ID of the device for which the application is built --#define SL_APPLICATION_PRODUCT_ID { 0 } -+#define SL_APPLICATION_PRODUCT_ID { 0xe9, 0x92, 0x67, 0x94, 0xbb, 0x2c, 0x4e, 0xc8, 0x9f, 0x36, 0xd9, 0xc6, 0x79, 0x4a, 0x81, 0xfb } - - // - --- -2.39.1 - diff --git a/EmberZNet/Yellow/0001-config-configure-usart-vcom-for-Yellow.patch b/EmberZNet/Yellow/0001-config-configure-usart-vcom-for-Yellow.patch deleted file mode 100644 index 25c7b5e3..00000000 --- a/EmberZNet/Yellow/0001-config-configure-usart-vcom-for-Yellow.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 5b5fe524e2abb452d805ffa956c7c045f8e4d3d6 Mon Sep 17 00:00:00 2001 -Message-Id: <5b5fe524e2abb452d805ffa956c7c045f8e4d3d6.1675330959.git.stefan@agner.ch> -From: Stefan Agner -Date: Thu, 2 Feb 2023 10:41:24 +0100 -Subject: [PATCH] config: configure usart vcom for Yellow - ---- - config/sl_iostream_usart_vcom_config.h | 25 ++++++++++++++----------- - 1 file changed, 14 insertions(+), 11 deletions(-) - -diff --git a/config/sl_iostream_usart_vcom_config.h b/config/sl_iostream_usart_vcom_config.h -index 330844c..0d013fb 100644 ---- a/config/sl_iostream_usart_vcom_config.h -+++ b/config/sl_iostream_usart_vcom_config.h -@@ -84,21 +84,24 @@ - // <<< sl:start pin_tool >>> - // SL_IOSTREAM_USART_VCOM - // $[USART_SL_IOSTREAM_USART_VCOM] --#warning "IO Stream USART peripheral not configured" --// #define SL_IOSTREAM_USART_VCOM_PERIPHERAL USART0 --// #define SL_IOSTREAM_USART_VCOM_PERIPHERAL_NO 0 -+#define SL_IOSTREAM_USART_VCOM_PERIPHERAL USART0 -+#define SL_IOSTREAM_USART_VCOM_PERIPHERAL_NO 0 - --// #define SL_IOSTREAM_USART_VCOM_TX_PORT gpioPortC --// #define SL_IOSTREAM_USART_VCOM_TX_PIN 11 -+// USART0 TX on PA05 -+#define SL_IOSTREAM_USART_VCOM_TX_PORT gpioPortA -+#define SL_IOSTREAM_USART_VCOM_TX_PIN 5 - --// #define SL_IOSTREAM_USART_VCOM_RX_PORT gpioPortC --// #define SL_IOSTREAM_USART_VCOM_RX_PIN 10 -+// USART0 RX on PA06 -+#define SL_IOSTREAM_USART_VCOM_RX_PORT gpioPortA -+#define SL_IOSTREAM_USART_VCOM_RX_PIN 6 - --// #define SL_IOSTREAM_USART_VCOM_CTS_PORT gpioPortA --// #define SL_IOSTREAM_USART_VCOM_CTS_PIN 12 -+// USART0 CTS on PD02 -+#define SL_IOSTREAM_USART_VCOM_CTS_PORT gpioPortD -+#define SL_IOSTREAM_USART_VCOM_CTS_PIN 2 - --// #define SL_IOSTREAM_USART_VCOM_RTS_PORT gpioPortC --// #define SL_IOSTREAM_USART_VCOM_RTS_PIN 8 -+// USART0 RTS on PC01 -+#define SL_IOSTREAM_USART_VCOM_RTS_PORT gpioPortC -+#define SL_IOSTREAM_USART_VCOM_RTS_PIN 1 - // [USART_SL_IOSTREAM_USART_VCOM]$ - // <<< sl:end pin_tool >>> - --- -2.39.1 - diff --git a/EmberZNet/Yellow/0002-config-add-board-activity-LED-pin-config.patch b/EmberZNet/Yellow/0002-config-add-board-activity-LED-pin-config.patch deleted file mode 100644 index a9150999..00000000 --- a/EmberZNet/Yellow/0002-config-add-board-activity-LED-pin-config.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 267ced2ecad0ee665000be892c82ba9240be531d Mon Sep 17 00:00:00 2001 -Message-Id: <267ced2ecad0ee665000be892c82ba9240be531d.1675332582.git.stefan@agner.ch> -From: Stefan Agner -Date: Thu, 2 Feb 2023 11:09:02 +0100 -Subject: [PATCH] config: add board activity LED pin config - ---- - config/sl_simple_led_board_activity_config.h | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -diff --git a/config/sl_simple_led_board_activity_config.h b/config/sl_simple_led_board_activity_config.h -index ba9de29..ec0714d 100644 ---- a/config/sl_simple_led_board_activity_config.h -+++ b/config/sl_simple_led_board_activity_config.h -@@ -25,7 +25,7 @@ - // Active low - // Active high - // Default: SL_SIMPLE_LED_POLARITY_ACTIVE_HIGH --#define SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY SL_SIMPLE_LED_POLARITY_ACTIVE_HIGH -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY SL_SIMPLE_LED_POLARITY_ACTIVE_LOW - // end led configuration - - // <<< end of configuration section >>> -@@ -34,9 +34,8 @@ - - // SL_SIMPLE_LED_BOARD_ACTIVITY - // $[GPIO_SL_SIMPLE_LED_BOARD_ACTIVITY] --#warning "Simple LED Driver GPIO pin not configured" --// #define SL_SIMPLE_LED_BOARD_ACTIVITY_PORT gpioPortA --// #define SL_SIMPLE_LED_BOARD_ACTIVITY_PIN 1 -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_PORT gpioPortB -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_PIN 1 - // [GPIO_SL_SIMPLE_LED_BOARD_ACTIVITY]$ - - // <<< sl:end pin_tool >>> --- -2.39.1 - diff --git a/OpenThreadRCP/SkyConnect/0001-Configure-UART.patch b/OpenThreadRCP/SkyConnect/0001-Configure-UART.patch deleted file mode 100644 index 756ae328..00000000 --- a/OpenThreadRCP/SkyConnect/0001-Configure-UART.patch +++ /dev/null @@ -1,77 +0,0 @@ -From aca87d890c1d779add80a9a418f89e30f6d52f6d Mon Sep 17 00:00:00 2001 -From: puddly <32534428+puddly@users.noreply.github.com> -Date: Wed, 3 Jan 2024 10:47:37 -0500 -Subject: [PATCH] Configure UART - -Configure UART ---- - config/sl_uartdrv_usart_vcom_config.h | 54 +++++++++++++++------- - 1 file changed, 38 insertions(+), 16 deletions(-) - -diff --git a/config/sl_uartdrv_usart_vcom_config.h b/config/sl_uartdrv_usart_vcom_config.h -index c64b243..bb58433 100644 ---- a/config/sl_uartdrv_usart_vcom_config.h -+++ b/config/sl_uartdrv_usart_vcom_config.h -@@ -89,21 +89,44 @@ - // <<< sl:start pin_tool >>> - // SL_UARTDRV_USART_VCOM - // $[USART_SL_UARTDRV_USART_VCOM] --#warning "UARTDRV USART peripheral not configured" --// #define SL_UARTDRV_USART_VCOM_PERIPHERAL USART0 --// #define SL_UARTDRV_USART_VCOM_PERIPHERAL_NO 0 -- --// #define SL_UARTDRV_USART_VCOM_TX_PORT gpioPortA --// #define SL_UARTDRV_USART_VCOM_TX_PIN 0 -- --// #define SL_UARTDRV_USART_VCOM_RX_PORT gpioPortA --// #define SL_UARTDRV_USART_VCOM_RX_PIN 1 -- --// #define SL_UARTDRV_USART_VCOM_CTS_PORT gpioPortA --// #define SL_UARTDRV_USART_VCOM_CTS_PIN 2 -- --// #define SL_UARTDRV_USART_VCOM_RTS_PORT gpioPortA --// #define SL_UARTDRV_USART_VCOM_RTS_PIN 3 -+#ifndef SL_UARTDRV_USART_VCOM_PERIPHERAL -+#define SL_UARTDRV_USART_VCOM_PERIPHERAL USART0 -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_PERIPHERAL_NO -+#define SL_UARTDRV_USART_VCOM_PERIPHERAL_NO 0 -+#endif -+ -+// USART0 TX on PA06 -+#ifndef SL_UARTDRV_USART_VCOM_TX_PORT -+#define SL_UARTDRV_USART_VCOM_TX_PORT gpioPortA -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_TX_PIN -+#define SL_UARTDRV_USART_VCOM_TX_PIN 6 -+#endif -+ -+// USART0 RX on PA05 -+#ifndef SL_UARTDRV_USART_VCOM_RX_PORT -+#define SL_UARTDRV_USART_VCOM_RX_PORT gpioPortA -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_RX_PIN -+#define SL_UARTDRV_USART_VCOM_RX_PIN 5 -+#endif -+ -+// USART0 CTS on PB01 -+#ifndef SL_UARTDRV_USART_VCOM_CTS_PORT -+#define SL_UARTDRV_USART_VCOM_CTS_PORT gpioPortB -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_CTS_PIN -+#define SL_UARTDRV_USART_VCOM_CTS_PIN 1 -+#endif -+ -+// USART0 RTS on PB00 -+#ifndef SL_UARTDRV_USART_VCOM_RTS_PORT -+#define SL_UARTDRV_USART_VCOM_RTS_PORT gpioPortB -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_RTS_PIN -+#define SL_UARTDRV_USART_VCOM_RTS_PIN 0 -+#endif - // [USART_SL_UARTDRV_USART_VCOM]$ - // <<< sl:end pin_tool >>> - --- -2.43.0 - diff --git a/OpenThreadRCP/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch b/OpenThreadRCP/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch deleted file mode 100644 index 1e132492..00000000 --- a/OpenThreadRCP/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch +++ /dev/null @@ -1,28 +0,0 @@ -From c39176b8b1972a585b04503b0a4b20e621b3f41d Mon Sep 17 00:00:00 2001 -Message-Id: -In-Reply-To: <51ef16ec2d80cdf032612159d3d9307639cfc561.1678798117.git.stefan@agner.ch> -References: <51ef16ec2d80cdf032612159d3d9307639cfc561.1678798117.git.stefan@agner.ch> -From: Stefan Agner -Date: Tue, 7 Feb 2023 00:21:00 +0100 -Subject: [PATCH] config: use SkyConnect specific UUID as Application Product - ---- - config/app_properties_config.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/config/app_properties_config.h b/config/app_properties_config.h -index 6a6b976..af5ece7 100644 ---- a/config/app_properties_config.h -+++ b/config/app_properties_config.h -@@ -58,7 +58,7 @@ - #define SL_APPLICATION_CAPABILITIES 0 - - //Product ID of the device for which the application is built --#define SL_APPLICATION_PRODUCT_ID { 0 } -+#define SL_APPLICATION_PRODUCT_ID { 0xe9, 0x92, 0x67, 0x94, 0xbb, 0x2c, 0x4e, 0xc8, 0x9f, 0x36, 0xd9, 0xc6, 0x79, 0x4a, 0x81, 0xfb } - - // - --- -2.39.2 - diff --git a/OpenThreadRCP/Yellow/0001-Configure-UART.patch b/OpenThreadRCP/Yellow/0001-Configure-UART.patch deleted file mode 100644 index d61c5357..00000000 --- a/OpenThreadRCP/Yellow/0001-Configure-UART.patch +++ /dev/null @@ -1,77 +0,0 @@ -From aca87d890c1d779add80a9a418f89e30f6d52f6d Mon Sep 17 00:00:00 2001 -From: puddly <32534428+puddly@users.noreply.github.com> -Date: Wed, 3 Jan 2024 10:47:37 -0500 -Subject: [PATCH] Configure UART - -Configure UART ---- - config/sl_uartdrv_usart_vcom_config.h | 54 +++++++++++++++------- - 1 file changed, 38 insertions(+), 16 deletions(-) - -diff --git a/config/sl_uartdrv_usart_vcom_config.h b/config/sl_uartdrv_usart_vcom_config.h -index c64b243..bb58433 100644 ---- a/config/sl_uartdrv_usart_vcom_config.h -+++ b/config/sl_uartdrv_usart_vcom_config.h -@@ -89,21 +89,44 @@ - // <<< sl:start pin_tool >>> - // SL_UARTDRV_USART_VCOM - // $[USART_SL_UARTDRV_USART_VCOM] --#warning "UARTDRV USART peripheral not configured" --// #define SL_UARTDRV_USART_VCOM_PERIPHERAL USART0 --// #define SL_UARTDRV_USART_VCOM_PERIPHERAL_NO 0 -- --// #define SL_UARTDRV_USART_VCOM_TX_PORT gpioPortA --// #define SL_UARTDRV_USART_VCOM_TX_PIN 0 -- --// #define SL_UARTDRV_USART_VCOM_RX_PORT gpioPortA --// #define SL_UARTDRV_USART_VCOM_RX_PIN 1 -- --// #define SL_UARTDRV_USART_VCOM_CTS_PORT gpioPortA --// #define SL_UARTDRV_USART_VCOM_CTS_PIN 2 -- --// #define SL_UARTDRV_USART_VCOM_RTS_PORT gpioPortA --// #define SL_UARTDRV_USART_VCOM_RTS_PIN 3 -+#ifndef SL_UARTDRV_USART_VCOM_PERIPHERAL -+#define SL_UARTDRV_USART_VCOM_PERIPHERAL USART0 -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_PERIPHERAL_NO -+#define SL_UARTDRV_USART_VCOM_PERIPHERAL_NO 0 -+#endif -+ -+// USART0 TX on PA05 -+#ifndef SL_UARTDRV_USART_VCOM_TX_PORT -+#define SL_UARTDRV_USART_VCOM_TX_PORT gpioPortA -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_TX_PIN -+#define SL_UARTDRV_USART_VCOM_TX_PIN 5 -+#endif -+ -+// USART0 RX on PA06 -+#ifndef SL_UARTDRV_USART_VCOM_RX_PORT -+#define SL_UARTDRV_USART_VCOM_RX_PORT gpioPortA -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_RX_PIN -+#define SL_UARTDRV_USART_VCOM_RX_PIN 6 -+#endif -+ -+// USART0 CTS on PD02 -+#ifndef SL_UARTDRV_USART_VCOM_CTS_PORT -+#define SL_UARTDRV_USART_VCOM_CTS_PORT gpioPortD -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_CTS_PIN -+#define SL_UARTDRV_USART_VCOM_CTS_PIN 2 -+#endif -+ -+// USART0 RTS on PC01 -+#ifndef SL_UARTDRV_USART_VCOM_RTS_PORT -+#define SL_UARTDRV_USART_VCOM_RTS_PORT gpioPortC -+#endif -+#ifndef SL_UARTDRV_USART_VCOM_RTS_PIN -+#define SL_UARTDRV_USART_VCOM_RTS_PIN 1 -+#endif - // [USART_SL_UARTDRV_USART_VCOM]$ - // <<< sl:end pin_tool >>> - --- -2.43.0 - diff --git a/OpenThreadRCP/Yellow/0002-config-add-board-activity-LED-pin-config.patch b/OpenThreadRCP/Yellow/0002-config-add-board-activity-LED-pin-config.patch deleted file mode 100644 index 056ba242..00000000 --- a/OpenThreadRCP/Yellow/0002-config-add-board-activity-LED-pin-config.patch +++ /dev/null @@ -1,40 +0,0 @@ -From c23162d967e211ecdb1835d88c11aa0e87b31acc Mon Sep 17 00:00:00 2001 -Message-Id: -In-Reply-To: <05cfb71f684cf20e48c51eefaf301cce035f0c64.1678797714.git.stefan@agner.ch> -References: <05cfb71f684cf20e48c51eefaf301cce035f0c64.1678797714.git.stefan@agner.ch> -From: Stefan Agner -Date: Thu, 2 Feb 2023 11:09:02 +0100 -Subject: [PATCH] config: add board activity LED pin config - ---- - config/sl_simple_led_board_activity_config.h | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -diff --git a/config/sl_simple_led_board_activity_config.h b/config/sl_simple_led_board_activity_config.h -index ba9de29..ec0714d 100644 ---- a/config/sl_simple_led_board_activity_config.h -+++ b/config/sl_simple_led_board_activity_config.h -@@ -25,7 +25,7 @@ - // Active low - // Active high - // Default: SL_SIMPLE_LED_POLARITY_ACTIVE_HIGH --#define SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY SL_SIMPLE_LED_POLARITY_ACTIVE_HIGH -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY SL_SIMPLE_LED_POLARITY_ACTIVE_LOW - // end led configuration - - // <<< end of configuration section >>> -@@ -34,9 +34,8 @@ - - // SL_SIMPLE_LED_BOARD_ACTIVITY - // $[GPIO_SL_SIMPLE_LED_BOARD_ACTIVITY] --#warning "Simple LED Driver GPIO pin not configured" --// #define SL_SIMPLE_LED_BOARD_ACTIVITY_PORT gpioPortA --// #define SL_SIMPLE_LED_BOARD_ACTIVITY_PIN 1 -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_PORT gpioPortB -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_PIN 1 - // [GPIO_SL_SIMPLE_LED_BOARD_ACTIVITY]$ - - // <<< sl:end pin_tool >>> --- -2.39.2 - diff --git a/RCPMultiPAN/SkyConnect/0001-Configure-UART.patch b/RCPMultiPAN/SkyConnect/0001-Configure-UART.patch deleted file mode 100644 index 0ef4c1e7..00000000 --- a/RCPMultiPAN/SkyConnect/0001-Configure-UART.patch +++ /dev/null @@ -1,85 +0,0 @@ -From aca87d890c1d779add80a9a418f89e30f6d52f6d Mon Sep 17 00:00:00 2001 -From: puddly <32534428+puddly@users.noreply.github.com> -Date: Wed, 3 Jan 2024 10:47:37 -0500 -Subject: [PATCH] Configure UART - -Configure UART ---- - config/sl_cpc_drv_uart_usart_vcom_config.h | 54 +++++++++++++++------- - 1 file changed, 38 insertions(+), 16 deletions(-) - -diff --git a/config/sl_cpc_drv_uart_usart_vcom_config.h b/config/sl_cpc_drv_uart_usart_vcom_config.h -index 265c262..bb0d7d5 100644 ---- a/config/sl_cpc_drv_uart_usart_vcom_config.h -+++ b/config/sl_cpc_drv_uart_usart_vcom_config.h -@@ -29,7 +29,6 @@ - ******************************************************************************/ - - // <<< Use Configuration Wizard in Context Menu >>> -- - #ifndef SL_CPC_DRV_UART_USART_VCOM_CONFIG_H - #define SL_CPC_DRV_UART_USART_VCOM_CONFIG_H - -@@ -59,21 +58,44 @@ - // <<< sl:start pin_tool >>> - // SL_CPC_DRV_UART_VCOM - // $[USART_SL_CPC_DRV_UART_VCOM] --#warning "CPC USART peripheral not configured" --// #define SL_CPC_DRV_UART_VCOM_PERIPHERAL USART0 --// #define SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO 0 --// --// #define SL_CPC_DRV_UART_VCOM_TX_PORT gpioPortD --// #define SL_CPC_DRV_UART_VCOM_TX_PIN 13 --// --// #define SL_CPC_DRV_UART_VCOM_RX_PORT gpioPortD --// #define SL_CPC_DRV_UART_VCOM_RX_PIN 14 --// --// #define SL_CPC_DRV_UART_VCOM_CTS_PORT gpioPortD --// #define SL_CPC_DRV_UART_VCOM_CTS_PIN 13 --// --// #define SL_CPC_DRV_UART_VCOM_RTS_PORT gpioPortD --// #define SL_CPC_DRV_UART_VCOM_RTS_PIN 14 -+#ifndef SL_CPC_DRV_UART_VCOM_PERIPHERAL -+#define SL_CPC_DRV_UART_VCOM_PERIPHERAL USART0 -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO -+#define SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO 0 -+#endif -+ -+// USART0 TX on PA06 -+#ifndef SL_CPC_DRV_UART_VCOM_TX_PORT -+#define SL_CPC_DRV_UART_VCOM_TX_PORT gpioPortA -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_TX_PIN -+#define SL_CPC_DRV_UART_VCOM_TX_PIN 6 -+#endif -+ -+// USART0 RX on PA05 -+#ifndef SL_CPC_DRV_UART_VCOM_RX_PORT -+#define SL_CPC_DRV_UART_VCOM_RX_PORT gpioPortA -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_RX_PIN -+#define SL_CPC_DRV_UART_VCOM_RX_PIN 5 -+#endif -+ -+// USART0 CTS on PB01 -+#ifndef SL_CPC_DRV_UART_VCOM_CTS_PORT -+#define SL_CPC_DRV_UART_VCOM_CTS_PORT gpioPortB -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_CTS_PIN -+#define SL_CPC_DRV_UART_VCOM_CTS_PIN 1 -+#endif -+ -+// USART0 RTS on PB00 -+#ifndef SL_CPC_DRV_UART_VCOM_RTS_PORT -+#define SL_CPC_DRV_UART_VCOM_RTS_PORT gpioPortB -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_RTS_PIN -+#define SL_CPC_DRV_UART_VCOM_RTS_PIN 0 -+#endif - // [USART_SL_CPC_DRV_UART_VCOM]$ - // <<< sl:end pin_tool >>> - --- -2.43.0 - diff --git a/RCPMultiPAN/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch b/RCPMultiPAN/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch deleted file mode 100644 index f8a87262..00000000 --- a/RCPMultiPAN/SkyConnect/0002-config-use-SkyConnect-specific-UUID-as-Application-P.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 17deb2f253ba037824ec00f2a3f0caf8ef34b018 Mon Sep 17 00:00:00 2001 -Message-Id: <17deb2f253ba037824ec00f2a3f0caf8ef34b018.1675725669.git.stefan@agner.ch> -In-Reply-To: <952a0a662f48fe5c44d7350f6d89b90dfbea60ad.1675725669.git.stefan@agner.ch> -References: <952a0a662f48fe5c44d7350f6d89b90dfbea60ad.1675725669.git.stefan@agner.ch> -From: Stefan Agner -Date: Tue, 7 Feb 2023 00:21:00 +0100 -Subject: [PATCH] config: use SkyConnect specific UUID as Application Product - ---- - config/app_properties_config.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/config/app_properties_config.h b/config/app_properties_config.h -index 6a6b976..af5ece7 100644 ---- a/config/app_properties_config.h -+++ b/config/app_properties_config.h -@@ -58,7 +58,7 @@ - #define SL_APPLICATION_CAPABILITIES 0 - - //Product ID of the device for which the application is built --#define SL_APPLICATION_PRODUCT_ID { 0 } -+#define SL_APPLICATION_PRODUCT_ID { 0xe9, 0x92, 0x67, 0x94, 0xbb, 0x2c, 0x4e, 0xc8, 0x9f, 0x36, 0xd9, 0xc6, 0x79, 0x4a, 0x81, 0xfb } - - // - --- -2.39.1 - diff --git a/RCPMultiPAN/Yellow/0001-Configure-UART.patch b/RCPMultiPAN/Yellow/0001-Configure-UART.patch deleted file mode 100644 index 5c5ad8fa..00000000 --- a/RCPMultiPAN/Yellow/0001-Configure-UART.patch +++ /dev/null @@ -1,85 +0,0 @@ -From aca87d890c1d779add80a9a418f89e30f6d52f6d Mon Sep 17 00:00:00 2001 -From: puddly <32534428+puddly@users.noreply.github.com> -Date: Wed, 3 Jan 2024 10:47:37 -0500 -Subject: [PATCH] Configure UART - -Configure UART ---- - config/sl_cpc_drv_uart_usart_vcom_config.h | 54 +++++++++++++++------- - 1 file changed, 38 insertions(+), 16 deletions(-) - -diff --git a/config/sl_cpc_drv_uart_usart_vcom_config.h b/config/sl_cpc_drv_uart_usart_vcom_config.h -index 265c262..bb0d7d5 100644 ---- a/config/sl_cpc_drv_uart_usart_vcom_config.h -+++ b/config/sl_cpc_drv_uart_usart_vcom_config.h -@@ -29,7 +29,6 @@ - ******************************************************************************/ - - // <<< Use Configuration Wizard in Context Menu >>> -- - #ifndef SL_CPC_DRV_UART_USART_VCOM_CONFIG_H - #define SL_CPC_DRV_UART_USART_VCOM_CONFIG_H - -@@ -59,21 +58,44 @@ - // <<< sl:start pin_tool >>> - // SL_CPC_DRV_UART_VCOM - // $[USART_SL_CPC_DRV_UART_VCOM] --#warning "CPC USART peripheral not configured" --// #define SL_CPC_DRV_UART_VCOM_PERIPHERAL USART0 --// #define SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO 0 --// --// #define SL_CPC_DRV_UART_VCOM_TX_PORT gpioPortD --// #define SL_CPC_DRV_UART_VCOM_TX_PIN 13 --// --// #define SL_CPC_DRV_UART_VCOM_RX_PORT gpioPortD --// #define SL_CPC_DRV_UART_VCOM_RX_PIN 14 --// --// #define SL_CPC_DRV_UART_VCOM_CTS_PORT gpioPortD --// #define SL_CPC_DRV_UART_VCOM_CTS_PIN 13 --// --// #define SL_CPC_DRV_UART_VCOM_RTS_PORT gpioPortD --// #define SL_CPC_DRV_UART_VCOM_RTS_PIN 14 -+#ifndef SL_CPC_DRV_UART_VCOM_PERIPHERAL -+#define SL_CPC_DRV_UART_VCOM_PERIPHERAL USART0 -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO -+#define SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO 0 -+#endif -+ -+// USART0 TX on PA05 -+#ifndef SL_CPC_DRV_UART_VCOM_TX_PORT -+#define SL_CPC_DRV_UART_VCOM_TX_PORT gpioPortA -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_TX_PIN -+#define SL_CPC_DRV_UART_VCOM_TX_PIN 5 -+#endif -+ -+// USART0 RX on PA06 -+#ifndef SL_CPC_DRV_UART_VCOM_RX_PORT -+#define SL_CPC_DRV_UART_VCOM_RX_PORT gpioPortA -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_RX_PIN -+#define SL_CPC_DRV_UART_VCOM_RX_PIN 6 -+#endif -+ -+// USART0 CTS on PD02 -+#ifndef SL_CPC_DRV_UART_VCOM_CTS_PORT -+#define SL_CPC_DRV_UART_VCOM_CTS_PORT gpioPortD -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_CTS_PIN -+#define SL_CPC_DRV_UART_VCOM_CTS_PIN 2 -+#endif -+ -+// USART0 RTS on PC01 -+#ifndef SL_CPC_DRV_UART_VCOM_RTS_PORT -+#define SL_CPC_DRV_UART_VCOM_RTS_PORT gpioPortC -+#endif -+#ifndef SL_CPC_DRV_UART_VCOM_RTS_PIN -+#define SL_CPC_DRV_UART_VCOM_RTS_PIN 1 -+#endif - // [USART_SL_CPC_DRV_UART_VCOM]$ - // <<< sl:end pin_tool >>> - --- -2.43.0 - diff --git a/RCPMultiPAN/Yellow/0002-config-add-board-activity-LED-pin-config.patch b/RCPMultiPAN/Yellow/0002-config-add-board-activity-LED-pin-config.patch deleted file mode 100644 index 9357850e..00000000 --- a/RCPMultiPAN/Yellow/0002-config-add-board-activity-LED-pin-config.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 06ed57d1e677cef9d10cd10a3eb770f49b9e6f99 Mon Sep 17 00:00:00 2001 -Message-Id: <06ed57d1e677cef9d10cd10a3eb770f49b9e6f99.1679556106.git.stefan@agner.ch> -In-Reply-To: <20184d2a2b267ce0ff81464d140481ce1657da74.1679556106.git.stefan@agner.ch> -References: <20184d2a2b267ce0ff81464d140481ce1657da74.1679556106.git.stefan@agner.ch> -From: Stefan Agner -Date: Thu, 2 Feb 2023 11:09:02 +0100 -Subject: [PATCH] config: add board activity LED pin config - ---- - config/sl_simple_led_board_activity_config.h | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -diff --git a/config/sl_simple_led_board_activity_config.h b/config/sl_simple_led_board_activity_config.h -index ba9de29..ec0714d 100644 ---- a/config/sl_simple_led_board_activity_config.h -+++ b/config/sl_simple_led_board_activity_config.h -@@ -25,7 +25,7 @@ - // Active low - // Active high - // Default: SL_SIMPLE_LED_POLARITY_ACTIVE_HIGH --#define SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY SL_SIMPLE_LED_POLARITY_ACTIVE_HIGH -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY SL_SIMPLE_LED_POLARITY_ACTIVE_LOW - // end led configuration - - // <<< end of configuration section >>> -@@ -34,9 +34,8 @@ - - // SL_SIMPLE_LED_BOARD_ACTIVITY - // $[GPIO_SL_SIMPLE_LED_BOARD_ACTIVITY] --#warning "Simple LED Driver GPIO pin not configured" --// #define SL_SIMPLE_LED_BOARD_ACTIVITY_PORT gpioPortA --// #define SL_SIMPLE_LED_BOARD_ACTIVITY_PIN 1 -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_PORT gpioPortB -+#define SL_SIMPLE_LED_BOARD_ACTIVITY_PIN 1 - // [GPIO_SL_SIMPLE_LED_BOARD_ACTIVITY]$ - - // <<< sl:end pin_tool >>> --- -2.40.0 - diff --git a/manifests/skyconnect_bootloader-uart-xmodem.yaml b/manifests/skyconnect_bootloader-uart-xmodem.yaml new file mode 100644 index 00000000..ea2953d4 --- /dev/null +++ b/manifests/skyconnect_bootloader-uart-xmodem.yaml @@ -0,0 +1,29 @@ +name: SkyConnect Bootloader +device: EFR32MG21A020F512IM32 +base_project: src/bootloader-uart-xmodem + +gbl: + fw_type: gecko-bootloader + dynamic: ["gecko_bootloader_version"] + baudrate: 115200 + +remove_components: + - id: bootloader_gpio_activation + +c_defines: + SL_SERIAL_UART_FLOW_CONTROL: 1 + + SL_SERIAL_UART_PERIPHERAL: USART0 + SL_SERIAL_UART_PERIPHERAL_NO: 0 + + SL_SERIAL_UART_TX_PORT: gpioPortA + SL_SERIAL_UART_TX_PIN: 6 + + SL_SERIAL_UART_RX_PORT: gpioPortA + SL_SERIAL_UART_RX_PIN: 5 + + SL_SERIAL_UART_CTS_PORT: gpioPortB + SL_SERIAL_UART_CTS_PIN: 1 + + SL_SERIAL_UART_RTS_PORT: gpioPortB + SL_SERIAL_UART_RTS_PIN: 0 diff --git a/manifests/skyconnect_firmware-eraser.yaml b/manifests/skyconnect_firmware-eraser.yaml new file mode 100644 index 00000000..4950a00d --- /dev/null +++ b/manifests/skyconnect_firmware-eraser.yaml @@ -0,0 +1,5 @@ +name: SkyConnect Firmware Eraser +device: EFR32MG21A020F512IM32 +base_project: misc/firmware-eraser + +gbl: {} diff --git a/manifests/skyconnect_ncp-uart-hw.yaml b/manifests/skyconnect_ncp-uart-hw.yaml new file mode 100644 index 00000000..cb6d8c60 --- /dev/null +++ b/manifests/skyconnect_ncp-uart-hw.yaml @@ -0,0 +1,31 @@ +name: SkyConnect Zigbee +device: EFR32MG21A020F512IM32 +base_project: src/ncp-uart-hw + +gbl: + fw_type: ncp-uart-hw + dynamic: ["ezsp_version"] + baudrate: 115200 + +configuration: + SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED + SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200 + SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts + +c_defines: + SL_IOSTREAM_USART_VCOM_PERIPHERAL: USART0 + SL_IOSTREAM_USART_VCOM_PERIPHERAL_NO: 0 + + SL_IOSTREAM_USART_VCOM_TX_PORT: gpioPortA + SL_IOSTREAM_USART_VCOM_TX_PIN: 6 + + SL_IOSTREAM_USART_VCOM_RX_PORT: gpioPortA + SL_IOSTREAM_USART_VCOM_RX_PIN: 5 + + SL_IOSTREAM_USART_VCOM_CTS_PORT: gpioPortB + SL_IOSTREAM_USART_VCOM_CTS_PIN: 1 + + SL_IOSTREAM_USART_VCOM_RTS_PORT: gpioPortB + SL_IOSTREAM_USART_VCOM_RTS_PIN: 0 + + SL_APPLICATION_PRODUCT_ID: '{0xE9, 0x92, 0x67, 0x94, 0xBB, 0x2C, 0x4E, 0xC8, 0x9F, 0x36, 0xD9, 0xC6, 0x79, 0x4A, 0x81, 0xFB}' diff --git a/manifests/skyconnect_ot-rcp.yaml b/manifests/skyconnect_ot-rcp.yaml new file mode 100644 index 00000000..b3889686 --- /dev/null +++ b/manifests/skyconnect_ot-rcp.yaml @@ -0,0 +1,30 @@ +name: SkyConnect OpenThread RCP +device: EFR32MG21A020F512IM32 +base_project: src/ot-rcp + +gbl: + fw_type: ot-rcp + dynamic: ["ot_rcp_version"] + baudrate: 460800 + +configuration: + SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED + SL_UARTDRV_USART_VCOM_BAUDRATE: 460800 + +c_defines: + SL_UARTDRV_USART_VCOM_PERIPHERAL: USART0 + SL_UARTDRV_USART_VCOM_PERIPHERAL_NO: 0 + + SL_UARTDRV_USART_VCOM_TX_PORT: gpioPortA + SL_UARTDRV_USART_VCOM_TX_PIN: 6 + + SL_UARTDRV_USART_VCOM_RX_PORT: gpioPortA + SL_UARTDRV_USART_VCOM_RX_PIN: 5 + + SL_UARTDRV_USART_VCOM_CTS_PORT: gpioPortB + SL_UARTDRV_USART_VCOM_CTS_PIN: 1 + + SL_UARTDRV_USART_VCOM_RTS_PORT: gpioPortB + SL_UARTDRV_USART_VCOM_RTS_PIN: 0 + + SL_APPLICATION_PRODUCT_ID: '{0xE9, 0x92, 0x67, 0x94, 0xBB, 0x2C, 0x4E, 0xC8, 0x9F, 0x36, 0xD9, 0xC6, 0x79, 0x4A, 0x81, 0xFB}' diff --git a/manifests/skyconnect_rcp-uart-802154.yaml b/manifests/skyconnect_rcp-uart-802154.yaml new file mode 100644 index 00000000..0ab42d5b --- /dev/null +++ b/manifests/skyconnect_rcp-uart-802154.yaml @@ -0,0 +1,32 @@ +name: SkyConnect Multi-PAN +device: EFR32MG21A020F512IM32 +base_project: src/rcp-uart-802154 + +gbl: + fw_type: rcp-uart-802154 + dynamic: ["ezsp_version", "ot_rcp_version", "cpc_version"] + baudrate: 460800 + +configuration: + SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED + SL_CPC_DRV_UART_VCOM_BAUDRATE: 460800 + +c_defines: + CPC_SECONDARY_APP_VERSION_SUFFIX: 'template:"-{git_repo_hash}"' + + SL_CPC_DRV_UART_VCOM_PERIPHERAL: USART0 + SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO: 0 + + SL_CPC_DRV_UART_VCOM_TX_PORT: gpioPortA + SL_CPC_DRV_UART_VCOM_TX_PIN: 6 + + SL_CPC_DRV_UART_VCOM_RX_PORT: gpioPortA + SL_CPC_DRV_UART_VCOM_RX_PIN: 5 + + SL_CPC_DRV_UART_VCOM_CTS_PORT: gpioPortB + SL_CPC_DRV_UART_VCOM_CTS_PIN: 1 + + SL_CPC_DRV_UART_VCOM_RTS_PORT: gpioPortB + SL_CPC_DRV_UART_VCOM_RTS_PIN: 0 + + SL_APPLICATION_PRODUCT_ID: '{0xE9, 0x92, 0x67, 0x94, 0xBB, 0x2C, 0x4E, 0xC8, 0x9F, 0x36, 0xD9, 0xC6, 0x79, 0x4A, 0x81, 0xFB}' diff --git a/manifests/slusb001a-lr2_zwave_ncp_serial_api_controller.yaml b/manifests/slusb001a-lr2_zwave_ncp_serial_api_controller.yaml new file mode 100644 index 00000000..cfcd0fbb --- /dev/null +++ b/manifests/slusb001a-lr2_zwave_ncp_serial_api_controller.yaml @@ -0,0 +1,14 @@ +name: ??? +device: ZGM130S037HGN +base_project: src/zwave_ncp_serial_api_controller + +gbl: + fw_type: z-wave + dynamic: ["zwave_version"] + baudrate: 115200 + compression: lz4 + sign_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" + encrypt_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" + +add_components: +- id: brd4207a diff --git a/manifests/slusb001a-lr_zwave_ncp_serial_api_controller.yaml b/manifests/slusb001a-lr_zwave_ncp_serial_api_controller.yaml new file mode 100644 index 00000000..4f7c243a --- /dev/null +++ b/manifests/slusb001a-lr_zwave_ncp_serial_api_controller.yaml @@ -0,0 +1,14 @@ +name: Silicon Labs UZB-7 (SLUSB001A), +14 dBm, Z-Wave Long Range +device: EFR32ZG14P231F256GM32 +base_project: src/zwave_ncp_serial_api_controller + +gbl: + fw_type: z-wave + dynamic: ["zwave_version"] + baudrate: 115200 + compression: lz4 + sign_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" + encrypt_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" + +add_components: +- id: brd4206a diff --git a/manifests/slusb001a_zwave_ncp_serial_api_controller.yaml b/manifests/slusb001a_zwave_ncp_serial_api_controller.yaml new file mode 100644 index 00000000..fae99012 --- /dev/null +++ b/manifests/slusb001a_zwave_ncp_serial_api_controller.yaml @@ -0,0 +1,14 @@ +name: Silicon Labs UZB-7 (SLUSB001A), +14 dBm, with SAW filters +device: EFR32ZG14P231F256GM32 +base_project: src/zwave_ncp_serial_api_controller + +gbl: + fw_type: z-wave + dynamic: ["zwave_version"] + baudrate: 115200 + compression: lz4 + sign_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" + encrypt_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" + +add_components: +- id: brd4201a diff --git a/manifests/yellow_bootloader-uart-xmodem.yaml b/manifests/yellow_bootloader-uart-xmodem.yaml new file mode 100644 index 00000000..91c98bee --- /dev/null +++ b/manifests/yellow_bootloader-uart-xmodem.yaml @@ -0,0 +1,30 @@ +name: Yellow Bootloader +device: MGM210PA32JIA +base_project: src/bootloader-uart-xmodem + +gbl: + fw_type: gecko-bootloader + dynamic: ["gecko_bootloader_version"] + baudrate: 115200 + +c_defines: + SL_SERIAL_UART_FLOW_CONTROL: 1 + + SL_SERIAL_UART_PERIPHERAL: USART0 + SL_SERIAL_UART_PERIPHERAL_NO: 0 + + SL_SERIAL_UART_TX_PORT: gpioPortA + SL_SERIAL_UART_TX_PIN: 5 + + SL_SERIAL_UART_RX_PORT: gpioPortA + SL_SERIAL_UART_RX_PIN: 6 + + SL_SERIAL_UART_CTS_PORT: gpioPortD + SL_SERIAL_UART_CTS_PIN: 2 + + SL_SERIAL_UART_RTS_PORT: gpioPortC + SL_SERIAL_UART_RTS_PIN: 1 + + SL_GPIO_ACTIVATION_POLARITY: LOW + SL_BTL_BUTTON_PORT: gpioPortB + SL_BTL_BUTTON_PIN: 0 diff --git a/manifests/yellow_ncp-uart-hw.yaml b/manifests/yellow_ncp-uart-hw.yaml new file mode 100644 index 00000000..de4df9c2 --- /dev/null +++ b/manifests/yellow_ncp-uart-hw.yaml @@ -0,0 +1,37 @@ +name: Yellow Zigbee +device: MGM210PA32JIA +base_project: src/ncp-uart-hw + +gbl: + fw_type: ncp-uart-hw + dynamic: ["ezsp_version"] + baudrate: 115200 + +add_components: +- id: simple_led + instance: [board_activity] + +configuration: + SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED + SL_IOSTREAM_USART_VCOM_BAUDRATE: 115200 + SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE: usartHwFlowControlCtsAndRts + +c_defines: + SL_IOSTREAM_USART_VCOM_PERIPHERAL: USART0 + SL_IOSTREAM_USART_VCOM_PERIPHERAL_NO: 0 + + SL_IOSTREAM_USART_VCOM_TX_PORT: gpioPortA + SL_IOSTREAM_USART_VCOM_TX_PIN: 5 + + SL_IOSTREAM_USART_VCOM_RX_PORT: gpioPortA + SL_IOSTREAM_USART_VCOM_RX_PIN: 6 + + SL_IOSTREAM_USART_VCOM_CTS_PORT: gpioPortD + SL_IOSTREAM_USART_VCOM_CTS_PIN: 2 + + SL_IOSTREAM_USART_VCOM_RTS_PORT: gpioPortC + SL_IOSTREAM_USART_VCOM_RTS_PIN: 1 + + SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY: SL_SIMPLE_LED_POLARITY_ACTIVE_LOW + SL_SIMPLE_LED_BOARD_ACTIVITY_PORT: gpioPortB + SL_SIMPLE_LED_BOARD_ACTIVITY_PIN: 1 diff --git a/manifests/yellow_ot-rcp.yaml b/manifests/yellow_ot-rcp.yaml new file mode 100644 index 00000000..45fca086 --- /dev/null +++ b/manifests/yellow_ot-rcp.yaml @@ -0,0 +1,36 @@ +name: Yellow OpenThread RCP +device: MGM210PA32JIA +base_project: src/ot-rcp + +gbl: + fw_type: ot-rcp + dynamic: ["ot_rcp_version"] + baudrate: 460800 + +add_components: +- id: simple_led + instance: [board_activity] + +configuration: + SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED + SL_UARTDRV_USART_VCOM_BAUDRATE: 460800 + +c_defines: + SL_UARTDRV_USART_VCOM_PERIPHERAL: USART0 + SL_UARTDRV_USART_VCOM_PERIPHERAL_NO: 0 + + SL_UARTDRV_USART_VCOM_TX_PORT: gpioPortA + SL_UARTDRV_USART_VCOM_TX_PIN: 5 + + SL_UARTDRV_USART_VCOM_RX_PORT: gpioPortA + SL_UARTDRV_USART_VCOM_RX_PIN: 6 + + SL_UARTDRV_USART_VCOM_CTS_PORT: gpioPortD + SL_UARTDRV_USART_VCOM_CTS_PIN: 2 + + SL_UARTDRV_USART_VCOM_RTS_PORT: gpioPortC + SL_UARTDRV_USART_VCOM_RTS_PIN: 1 + + SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY: SL_SIMPLE_LED_POLARITY_ACTIVE_LOW + SL_SIMPLE_LED_BOARD_ACTIVITY_PORT: gpioPortB + SL_SIMPLE_LED_BOARD_ACTIVITY_PIN: 1 diff --git a/manifests/yellow_rcp-uart-802154.yaml b/manifests/yellow_rcp-uart-802154.yaml new file mode 100644 index 00000000..23cc65bd --- /dev/null +++ b/manifests/yellow_rcp-uart-802154.yaml @@ -0,0 +1,38 @@ +name: Yellow Multi-PAN +device: MGM210PA32JIA +base_project: src/rcp-uart-802154 + +gbl: + fw_type: rcp-uart-802154 + dynamic: ["ezsp_version", "ot_rcp_version", "cpc_version"] + baudrate: 460800 + +add_components: +- id: simple_led + instance: [board_activity] + +configuration: + SL_RAIL_UTIL_PTI_MODE: RAIL_PTI_MODE_DISABLED + SL_CPC_DRV_UART_VCOM_BAUDRATE: 460800 + +c_defines: + CPC_SECONDARY_APP_VERSION_SUFFIX: 'template:"-{git_repo_hash}"' + + SL_CPC_DRV_UART_VCOM_PERIPHERAL: USART0 + SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO: 0 + + SL_CPC_DRV_UART_VCOM_TX_PORT: gpioPortA + SL_CPC_DRV_UART_VCOM_TX_PIN: 5 + + SL_CPC_DRV_UART_VCOM_RX_PORT: gpioPortA + SL_CPC_DRV_UART_VCOM_RX_PIN: 6 + + SL_CPC_DRV_UART_VCOM_CTS_PORT: gpioPortD + SL_CPC_DRV_UART_VCOM_CTS_PIN: 2 + + SL_CPC_DRV_UART_VCOM_RTS_PORT: gpioPortC + SL_CPC_DRV_UART_VCOM_RTS_PIN: 1 + + SL_SIMPLE_LED_BOARD_ACTIVITY_POLARITY: SL_SIMPLE_LED_POLARITY_ACTIVE_LOW + SL_SIMPLE_LED_BOARD_ACTIVITY_PORT: gpioPortB + SL_SIMPLE_LED_BOARD_ACTIVITY_PIN: 1 diff --git a/misc/firmware-eraser/.cproject b/misc/firmware-eraser/.cproject new file mode 100644 index 00000000..a4c2a4c7 --- /dev/null +++ b/misc/firmware-eraser/.cproject @@ -0,0 +1,362 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/misc/firmware-eraser/app.cpp b/misc/firmware-eraser/app.cpp new file mode 100644 index 00000000..55706027 --- /dev/null +++ b/misc/firmware-eraser/app.cpp @@ -0,0 +1,44 @@ +#include + +#include +#include + +#include + + +// TODO: figure out how to actually include this properly +void bootloader_rebootAndInstall(void) +{ + // Set reset reason to bootloader entry + BootloaderResetCause_t* resetCause = (BootloaderResetCause_t*) (SRAM_BASE); + resetCause->reason = BOOTLOADER_RESET_REASON_BADAPP; + resetCause->signature = BOOTLOADER_RESET_SIGNATURE_INVALID; +#if defined(RMU_PRESENT) + // Clear resetcause + RMU->CMD = RMU_CMD_RCCLR; + // Trigger a software system reset + RMU->CTRL = (RMU->CTRL & ~_RMU_CTRL_SYSRMODE_MASK) | RMU_CTRL_SYSRMODE_FULL; +#endif + NVIC_SystemReset(); +} + +/***************************************************************************//** + * Initialize application. + ******************************************************************************/ +void app_init(void) +{ + // This will set the program counter (startOfAppSpace + 4) to 0xFFFFFFFF, which + // breaks the bootloader early with `BOOTLOADER_RESET_REASON_BADAPP`. + MSC_Init(); + MSC_ErasePage((uint32_t*)BTL_APPLICATION_BASE); + MSC_Deinit(); + + bootloader_rebootAndInstall(); +} + +/***************************************************************************//** + * App ticking function. + ******************************************************************************/ +void app_process_action(void) +{ +} diff --git a/misc/firmware-eraser/app.h b/misc/firmware-eraser/app.h new file mode 100644 index 00000000..b8f74c81 --- /dev/null +++ b/misc/firmware-eraser/app.h @@ -0,0 +1,31 @@ +/***************************************************************************//** + * @file + * @brief Top level application functions + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#ifndef APP_H +#define APP_H + +/***************************************************************************//** + * Initialize application. + ******************************************************************************/ +void app_init(void); + +/***************************************************************************//** + * App ticking function. + ******************************************************************************/ +void app_process_action(void); + +#endif // APP_H diff --git a/misc/firmware-eraser/config/app_properties_config.h b/misc/firmware-eraser/config/app_properties_config.h new file mode 100644 index 00000000..a19960d9 --- /dev/null +++ b/misc/firmware-eraser/config/app_properties_config.h @@ -0,0 +1,65 @@ +/***************************************************************************//** + * @file + * @brief Application Properties Header File + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef APP_PROPERTIES_CONFIG_H +#define APP_PROPERTIES_CONFIG_H + +#include "sl_application_type.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// App Properties settings + +// Type of signature this application is signed with +// Default: APPLICATION_SIGNATURE_NONE(0) +#define SL_APPLICATION_SIGNATURE 0 + +// Location of the signature +// Default: 0xFFFFFFFF +#define SL_APPLICATION_SIGNATURE_LOCATION 0xFFFFFFFF + +// Bitfield representing type of application +#define SL_APPLICATION_TYPE APPLICATION_TYPE + +// Version number for this application +// <0-4294967295:1> +// Default: 1 [0-4294967295] +#define SL_APPLICATION_VERSION 1 + +// Capabilities of this application +// Default: 0 +#define SL_APPLICATION_CAPABILITIES 0 + +//Product ID of the device for which the application is built +#define SL_APPLICATION_PRODUCT_ID { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } + +// + +#endif // APP_PROPERTIES_CONFIG_H diff --git a/misc/firmware-eraser/config/btl_interface_cfg.h b/misc/firmware-eraser/config/btl_interface_cfg.h new file mode 100644 index 00000000..8e246f80 --- /dev/null +++ b/misc/firmware-eraser/config/btl_interface_cfg.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_H +#define BTL_INTERFACE_CFG_H + +#if !defined(BOOTLOADER_APPLOADER) + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1) +#include "btl_interface_cfg_s2c1.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_2) +#include "btl_interface_cfg_s2c2.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_3) +#include "btl_interface_cfg_s2c3.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4) +#include "btl_interface_cfg_s2c4.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_8) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#endif // !BOOTLOADER_APPLOADER + +#endif // BTL_INTERFACE_CFG_H diff --git a/misc/firmware-eraser/config/btl_interface_cfg_s2c1.h b/misc/firmware-eraser/config/btl_interface_cfg_s2c1.h new file mode 100644 index 00000000..c72c27b0 --- /dev/null +++ b/misc/firmware-eraser/config/btl_interface_cfg_s2c1.h @@ -0,0 +1,281 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_S2C1_H +#define BTL_INTERFACE_CFG_S2C1_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Bootloader Interface Trust Zone Security State Configuration + +// Disable multi tiered fallback logic +// The fault handling logic as well as the USART auto-detection logic will be disabled. +// The re-configuration of SMU will be handled by querying the running bootloader +// for the peripheral list. Querying the peripheral list is supported from the bootloader +// version 2.0.0. Check for the BOOTLOADER_CAPABILITY_PERIPHERAL_LIST capability to +// see if the running bootloader supports querying the peripheral list. +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 0 + +// Disable peripheral access fault handling +// The fault handling triggered by an erroneous access of peripherals will be disabled. +// +// This should be disabled iff all the peripherals that are in use by the bootloader +// have been properly configured by the "Manually override security state of peripherals" option. +#define BOOTLOADER_DISABLE_NVM3_FAULT_HANDLING 0 + +// Manually override the security state of peripherals in use by the bootloader +// Default: 0. +// Manually override the security state of peripherals. Choose the peripherals touched +// by the customized code to have a valid secure access state before interacting with the bootloader +// In practice, this means that the chosen peripherals will be available at the secure address, +// which is accessible by the bootloader. Once the application is entered back the secure access state +// is changed back to the original state. +// +// The USART auto-detection logic that detects which, if any, USART is in use by the bootloader +// will be disabled. Make sure to choose the correct USART used by the bootloader. +#define BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE 0 +// EMU +// Update secure access state of EMU before calling into bootloader +#define BOOTLOADER_PPUSATD0_EMU 0 + +// CMU +// Update secure access state of CMU before calling into bootloader +#define BOOTLOADER_PPUSATD0_CMU 0 + +// HFXO0 +// Update secure access state of HFXO0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_HFXO0 0 + +// HFRCO0 +// Update secure access state of HFRCO0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_HFRCO0 0 + +// FSRCO +// Update secure access state of FSRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_FSRCO 0 + +// DPLL0 +// Update secure access state of DPLL0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_DPLL0 0 + +// LFXO +// Update secure access state of LFXO before calling into bootloader +#define BOOTLOADER_PPUSATD0_LFXO 0 + +// LFRCO +// Update secure access state of LFRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_LFRCO 0 + +// ULFRCO +// Update secure access state of ULFRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_ULFRCO 0 + +// MSC +// Update secure access state of MSC before calling into bootloader +#define BOOTLOADER_PPUSATD0_MSC 0 + +// ICACHE0 +// Update secure access state of ICACHE0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_ICACHE0 0 + +// PRS +// Update secure access state of PRS before calling into bootloader +#define BOOTLOADER_PPUSATD0_PRS 0 + +// GPIO +// Update secure access state of GPIO before calling into bootloader +#define BOOTLOADER_PPUSATD0_GPIO 0 + +// LDMA +// Update secure access state of LDMA before calling into bootloader +#define BOOTLOADER_PPUSATD0_LDMA 0 + +// LDMAXBAR +// Update secure access state of LDMAXBAR before calling into bootloader +#define BOOTLOADER_PPUSATD0_LDMAXBAR 0 + +// TIMER0 +// Update secure access state of TIMER0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER0 0 + +// TIMER1 +// Update secure access state of TIMER1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER1 0 + +// TIMER2 +// Update secure access state of TIMER2 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER2 0 + +// TIMER3 +// Update secure access state of TIMER3 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER3 0 + +// USART0 +// Update secure access state of USART0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART0 0 + +// USART1 +// Update secure access state of USART1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART1 0 + +// USART2 +// Update secure access state of USART2 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART2 0 + +// BURTC +// Update secure access state of BURTC before calling into bootloader +#define BOOTLOADER_PPUSATD0_BURTC 0 + +// I2C1 +// Update secure access state of I2C1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_I2C1 0 + +// CHIPTESTCTRL +// Update secure access state of CHIPTESTCTRL before calling into bootloader +#define BOOTLOADER_PPUSATD0_CHIPTESTCTRL 0 + +// LVGD +// Update secure access state of LVGD before calling into bootloader +#define BOOTLOADER_PPUSATD0_LVGD 0 + +// SYSCFG +// Update secure access state of SYSCFG before calling into bootloader +#define BOOTLOADER_PPUSATD0_SYSCFG 0 + +// BURAM +// Update secure access state of BURAM before calling into bootloader +#define BOOTLOADER_PPUSATD0_BURAM 0 + +// IFADCDEBUG +// Update secure access state of IFADCDEBUG before calling into bootloader +#define BOOTLOADER_PPUSATD0_IFADCDEBUG 0 + +// GPCRC +// Update secure access state of GPCRC before calling into bootloader +#define BOOTLOADER_PPUSATD0_GPCRC 0 + +// RTCC +// Update secure access state of RTCC before calling into bootloader +#define BOOTLOADER_PPUSATD0_RTCC 0 + +// LETIMER0 +// Update secure access state of LETIMER0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_LETIMER0 0 + +// IADC0 +// Update secure access state of IADC0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_IADC0 0 + +// ACMP0 +// Update secure access state of ACMP0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_ACMP0 0 + +// ACMP1 +// Update secure access state of ACMP1 before calling into bootloader +#define BOOTLOADER_PPUSATD1_ACMP1 0 + +// I2C0 +// Update secure access state of I2C0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_I2C0 0 + +// HFRCOEM23 +// Update secure access state of HFRCOEM23 before calling into bootloader +#define BOOTLOADER_PPUSATD1_HFRCOEM23 0 + +// WDOG0 +// Update secure access state of WDOG0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_WDOG0 0 + +// WDOG1 +// Update secure access state of WDOG1 before calling into bootloader +#define BOOTLOADER_PPUSATD1_WDOG1 0 + +// AMUXCP0 +// Update secure access state of AMUXCP0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_AMUXCP0 0 + +// RADIOAES +// Update secure access state of RADIOAES before calling into bootloader +#define BOOTLOADER_PPUSATD1_RADIOAES 0 + +// BUFC +// Update secure access state of BUFC before calling into bootloader +#define BOOTLOADER_PPUSATD1_BUFC 0 + +// SMU +// Update secure access state of SMU before calling into bootloader +#define BOOTLOADER_PPUSATD1_SMU 0 + +// AHBRADIO +// Update secure access state of AHBRADIO before calling into bootloader +#define BOOTLOADER_PPUSATD1_AHBRADIO 0 + +// SEMAILBOX +// Update secure access state of SEMAILBOX before calling into bootloader +#define BOOTLOADER_PPUSATD1_SEMAILBOX 0 +// + +// +// <<< end of configuration section >>> + +#if BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE == 1 +#define BOOTLOADER_PPUSATD0_MASK ((BOOTLOADER_PPUSATD0_EMU << _SMU_PPUSATD0_EMU_SHIFT) \ + | (BOOTLOADER_PPUSATD0_CMU << _SMU_PPUSATD0_CMU_SHIFT) \ + | (BOOTLOADER_PPUSATD0_HFXO0 << _SMU_PPUSATD0_HFXO0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_HFRCO0 << _SMU_PPUSATD0_HFRCO0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_FSRCO << _SMU_PPUSATD0_FSRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_DPLL0 << _SMU_PPUSATD0_DPLL0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LFXO << _SMU_PPUSATD0_LFXO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LFRCO << _SMU_PPUSATD0_LFRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_ULFRCO << _SMU_PPUSATD0_ULFRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_MSC << _SMU_PPUSATD0_MSC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_ICACHE0 << _SMU_PPUSATD0_ICACHE0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_PRS << _SMU_PPUSATD0_PRS_SHIFT) \ + | (BOOTLOADER_PPUSATD0_GPIO << _SMU_PPUSATD0_GPIO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LDMA << _SMU_PPUSATD0_LDMA_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LDMAXBAR << _SMU_PPUSATD0_LDMAXBAR_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER0 << _SMU_PPUSATD0_TIMER0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER1 << _SMU_PPUSATD0_TIMER1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER2 << _SMU_PPUSATD0_TIMER2_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER3 << _SMU_PPUSATD0_TIMER3_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART0 << _SMU_PPUSATD0_USART0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART1 << _SMU_PPUSATD0_USART1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART2 << _SMU_PPUSATD0_USART2_SHIFT) \ + | (BOOTLOADER_PPUSATD0_BURTC << _SMU_PPUSATD0_BURTC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_I2C1 << _SMU_PPUSATD0_I2C1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_CHIPTESTCTRL << _SMU_PPUSATD0_CHIPTESTCTRL_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LVGD << _SMU_PPUSATD0_LVGD_SHIFT) \ + | (BOOTLOADER_PPUSATD0_SYSCFG << _SMU_PPUSATD0_SYSCFG_SHIFT) \ + | (BOOTLOADER_PPUSATD0_BURAM << _SMU_PPUSATD0_BURAM_SHIFT) \ + | (BOOTLOADER_PPUSATD0_IFADCDEBUG << _SMU_PPUSATD0_IFADCDEBUG_SHIFT) \ + | (BOOTLOADER_PPUSATD0_GPCRC << _SMU_PPUSATD0_GPCRC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_RTCC << _SMU_PPUSATD0_RTCC_SHIFT)) +#define BOOTLOADER_PPUSATD1_MASK ((BOOTLOADER_PPUSATD1_LETIMER0 << _SMU_PPUSATD1_LETIMER0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_IADC0 << _SMU_PPUSATD1_IADC0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_ACMP0 << _SMU_PPUSATD1_ACMP0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_ACMP1 << _SMU_PPUSATD1_ACMP1_SHIFT) \ + | (BOOTLOADER_PPUSATD1_I2C0 << _SMU_PPUSATD1_I2C0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_HFRCOEM23 << _SMU_PPUSATD1_HFRCOEM23_SHIFT) \ + | (BOOTLOADER_PPUSATD1_WDOG0 << _SMU_PPUSATD1_WDOG0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_WDOG1 << _SMU_PPUSATD1_WDOG1_SHIFT) \ + | (BOOTLOADER_PPUSATD1_AMUXCP0 << _SMU_PPUSATD1_AMUXCP0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_RADIOAES << _SMU_PPUSATD1_RADIOAES_SHIFT) \ + | (BOOTLOADER_PPUSATD1_BUFC << _SMU_PPUSATD1_BUFC_SHIFT) \ + | (BOOTLOADER_PPUSATD1_SMU << _SMU_PPUSATD1_SMU_SHIFT) \ + | (BOOTLOADER_PPUSATD1_AHBRADIO << _SMU_PPUSATD1_AHBRADIO_SHIFT) \ + | (BOOTLOADER_PPUSATD1_SEMAILBOX << _SMU_PPUSATD1_SEMAILBOX_SHIFT)) +#endif // BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE + +#endif // BTL_INTERFACE_CFG_S2C1_H diff --git a/misc/firmware-eraser/config/emlib_core_debug_config.h b/misc/firmware-eraser/config/emlib_core_debug_config.h new file mode 100644 index 00000000..07ee9b9e --- /dev/null +++ b/misc/firmware-eraser/config/emlib_core_debug_config.h @@ -0,0 +1,45 @@ +/***************************************************************************//** + * @file + * @brief emlib_core Configuration + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef EM_CORE_DEBUG_CONFIG_H +#define EM_CORE_DEBUG_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Core Configuration + +// Enables measuring of interrupt disable time for debugging purposes. +// Default: 0 +#define SL_EMLIB_CORE_ENABLE_INTERRUPT_DISABLED_TIMING 0 + +// + +// <<< end of configuration section >>> +#endif // EM_CORE_CONFIG_H diff --git a/misc/firmware-eraser/config/pin_config.h b/misc/firmware-eraser/config/pin_config.h new file mode 100644 index 00000000..4b558eb2 --- /dev/null +++ b/misc/firmware-eraser/config/pin_config.h @@ -0,0 +1,125 @@ +#ifndef PIN_CONFIG_H +#define PIN_CONFIG_H + +// $[CMU] +// [CMU]$ + +// $[LFXO] +// [LFXO]$ + +// $[PRS.ASYNCH0] +// [PRS.ASYNCH0]$ + +// $[PRS.ASYNCH1] +// [PRS.ASYNCH1]$ + +// $[PRS.ASYNCH2] +// [PRS.ASYNCH2]$ + +// $[PRS.ASYNCH3] +// [PRS.ASYNCH3]$ + +// $[PRS.ASYNCH4] +// [PRS.ASYNCH4]$ + +// $[PRS.ASYNCH5] +// [PRS.ASYNCH5]$ + +// $[PRS.ASYNCH6] +// [PRS.ASYNCH6]$ + +// $[PRS.ASYNCH7] +// [PRS.ASYNCH7]$ + +// $[PRS.ASYNCH8] +// [PRS.ASYNCH8]$ + +// $[PRS.ASYNCH9] +// [PRS.ASYNCH9]$ + +// $[PRS.ASYNCH10] +// [PRS.ASYNCH10]$ + +// $[PRS.ASYNCH11] +// [PRS.ASYNCH11]$ + +// $[PRS.SYNCH0] +// [PRS.SYNCH0]$ + +// $[PRS.SYNCH1] +// [PRS.SYNCH1]$ + +// $[PRS.SYNCH2] +// [PRS.SYNCH2]$ + +// $[PRS.SYNCH3] +// [PRS.SYNCH3]$ + +// $[GPIO] +// GPIO SWV on PA03 +#ifndef GPIO_SWV_PORT +#define GPIO_SWV_PORT gpioPortA +#endif +#ifndef GPIO_SWV_PIN +#define GPIO_SWV_PIN 3 +#endif + +// [GPIO]$ + +// $[TIMER0] +// [TIMER0]$ + +// $[TIMER1] +// [TIMER1]$ + +// $[TIMER2] +// [TIMER2]$ + +// $[TIMER3] +// [TIMER3]$ + +// $[USART0] +// [USART0]$ + +// $[USART1] +// [USART1]$ + +// $[USART2] +// [USART2]$ + +// $[I2C1] +// [I2C1]$ + +// $[LETIMER0] +// [LETIMER0]$ + +// $[IADC0] +// [IADC0]$ + +// $[ACMP0] +// [ACMP0]$ + +// $[ACMP1] +// [ACMP1]$ + +// $[I2C0] +// [I2C0]$ + +// $[PTI] +// [PTI]$ + +// $[MODEM] +// [MODEM]$ + +// $[CUSTOM_PIN_NAME] +#ifndef _PORT +#define _PORT gpioPortA +#endif +#ifndef _PIN +#define _PIN 0 +#endif + +// [CUSTOM_PIN_NAME]$ + +#endif // PIN_CONFIG_H + diff --git a/misc/firmware-eraser/config/sl_board_control_config.h b/misc/firmware-eraser/config/sl_board_control_config.h new file mode 100644 index 00000000..b5a16b94 --- /dev/null +++ b/misc/firmware-eraser/config/sl_board_control_config.h @@ -0,0 +1,56 @@ +/***************************************************************************//** + * @file + * @brief Board Control + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_BOARD_CONTROL_CONFIG_H +#define SL_BOARD_CONTROL_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Enable Virtual COM UART +// Default: 0 +#define SL_BOARD_ENABLE_VCOM 0 + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +// SL_BOARD_ENABLE_VCOM +// $[GPIO_SL_BOARD_ENABLE_VCOM] +#ifndef SL_BOARD_ENABLE_VCOM_PORT +#define SL_BOARD_ENABLE_VCOM_PORT gpioPortD +#endif +#ifndef SL_BOARD_ENABLE_VCOM_PIN +#define SL_BOARD_ENABLE_VCOM_PIN 4 +#endif +// [GPIO_SL_BOARD_ENABLE_VCOM]$ + +// <<< sl:end pin_tool >>> + +#endif // SL_BOARD_CONTROL_CONFIG_H diff --git a/misc/firmware-eraser/config/sl_debug_swo_config.h b/misc/firmware-eraser/config/sl_debug_swo_config.h new file mode 100644 index 00000000..fee7e65d --- /dev/null +++ b/misc/firmware-eraser/config/sl_debug_swo_config.h @@ -0,0 +1,106 @@ +/***************************************************************************//** + * @file + * @brief SWO configuration + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEBUG_SWO_CONFIG_H +#define SL_DEBUG_SWO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// SWO Configuration + +// SWO Frequency +// Must be 875 kHz for communication with Silicon Labs debuggers +// Default: 875000 +#define SL_DEBUG_SWO_FREQ 875000 + +// Enable interrupt event trace +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_IRQ 0 + +// Enable Program Counter samples +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_PC 0 + +// SWO debug sample intervals +// <64=> 64 +// <128=> 128 +// <192=> 192 +// <256=> 256 +// <320=> 320 +// <384=> 384 +// <448=> 448 +// <512=> 512 +// <576=> 576 +// <640=> 640 +// <704=> 704 +// <768=> 768 +// <832=> 832 +// <896=> 896 +// <960=> 960 +// <1024=> 1024 +// <2048=> 2048 +// <3072=> 3072 +// <4096=> 4096 +// <5102=> 5102 +// <6144=> 6144 +// <7168=> 7168 +// <8192=> 8192 +// <9216=> 9216 +// <10240=> 10240 +// <11264=> 11264 +// <12288=> 12288 +// <13312=> 13312 +// <14336=> 14336 +// <15360=> 15360 +// Must be 64, 128, 192, [ n * 64 ], 1024, 2048, 3072, [ n * 1024 ] , 15360 +// Default: 15360 +#define SL_DEBUG_SWO_SAMPLE_INTERVAL 15360 +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_DEBUG +// $[GPIO_SL_DEBUG] +#ifndef SL_DEBUG_PERIPHERAL +#define SL_DEBUG_PERIPHERAL GPIO +#endif + +// GPIO SWV on PA03 +#ifndef SL_DEBUG_SWV_PORT +#define SL_DEBUG_SWV_PORT gpioPortA +#endif +#ifndef SL_DEBUG_SWV_PIN +#define SL_DEBUG_SWV_PIN 3 +#endif +// [GPIO_SL_DEBUG]$ +// <<< sl:end pin_tool >>> + +#endif // SL_DEBUG_SWO_CONFIG_H diff --git a/misc/firmware-eraser/config/sl_device_init_emu_config.h b/misc/firmware-eraser/config/sl_device_init_emu_config.h new file mode 100644 index 00000000..4ac96bac --- /dev/null +++ b/misc/firmware-eraser/config/sl_device_init_emu_config.h @@ -0,0 +1,53 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_EMU Config + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_EMU_CONFIG_H +#define SL_DEVICE_INIT_EMU_CONFIG_H + +#include "em_emu.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// Allow debugger to remain connected in EM2 +// Force PD0B to stay on on EM2 entry. This allows the debugger to remain connected in EM2 and EM3. +// Enabling debug connectivity results in an increased power consumption in EM2/EM3. +// Default: 1 +#define SL_DEVICE_INIT_EMU_EM2_DEBUG_ENABLE 1 + +// EM4 pin retention mode +// No Retention: Pads enter reset state when entering EM4. +// Retention through EM4: Pads enter reset state when exiting EM4. +// Retention through EM4 and wakeup. +// Default: emuPinRetentionDisable +#define SL_DEVICE_INIT_EMU_EM4_PIN_RETENTION_MODE emuPinRetentionDisable + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_EMU_CONFIG_H diff --git a/misc/firmware-eraser/config/sl_device_init_hfrco_config.h b/misc/firmware-eraser/config/sl_device_init_hfrco_config.h new file mode 100644 index 00000000..d2d99400 --- /dev/null +++ b/misc/firmware-eraser/config/sl_device_init_hfrco_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFRCO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFRCO_CONFIG_H +#define SL_DEVICE_INIT_HFRCO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Frequency Band +// RC Oscillator Frequency Band +// 1 MHz +// 2 MHz +// 4 MHz +// 7 MHz +// 13 MHz +// 16 MHz +// 19 MHz +// 26 MHz +// 32 MHz +// 38 MHz +// 48 MHz +// 56 MHz +// 64 MHz +// 80 MHz +// Default: cmuHFRCODPLLFreq_80M0Hz +#define SL_DEVICE_INIT_HFRCO_BAND cmuHFRCODPLLFreq_80M0Hz + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFRCO_CONFIG_H diff --git a/misc/firmware-eraser/config/sl_device_init_hfxo_config.h b/misc/firmware-eraser/config/sl_device_init_hfxo_config.h new file mode 100644 index 00000000..6a35767e --- /dev/null +++ b/misc/firmware-eraser/config/sl_device_init_hfxo_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFXO_CONFIG_H +#define SL_DEVICE_INIT_HFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// External sine wave +// Default: cmuHfxoOscMode_Crystal +#define SL_DEVICE_INIT_HFXO_MODE cmuHfxoOscMode_Crystal + +// Frequency <38000000-40000000> +// Default: 38400000 +#define SL_DEVICE_INIT_HFXO_FREQ 38400000 + +// HFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_HFXO_PRECISION 50 + +// CTUNE <0-255> +// Default: 140 +#define SL_DEVICE_INIT_HFXO_CTUNE 133 + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFXO_CONFIG_H diff --git a/misc/firmware-eraser/config/sl_device_init_lfxo_config.h b/misc/firmware-eraser/config/sl_device_init_lfxo_config.h new file mode 100644 index 00000000..6bd763ba --- /dev/null +++ b/misc/firmware-eraser/config/sl_device_init_lfxo_config.h @@ -0,0 +1,66 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_LFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_LFXO_CONFIG_H +#define SL_DEVICE_INIT_LFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// AC-coupled buffer +// External digital clock +// Default: cmuLfxoOscMode_Crystal +#define SL_DEVICE_INIT_LFXO_MODE cmuLfxoOscMode_Crystal + +// CTUNE <0-127> +// Default: 63 +#define SL_DEVICE_INIT_LFXO_CTUNE 79 + +// LFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_LFXO_PRECISION 50 + +// Startup Timeout Delay +// +// 2 cycles +// 256 cycles +// 1K cycles +// 2K cycles +// 4K cycles +// 8K cycles +// 16K cycles +// 32K cycles +// Default: cmuLfxoStartupDelay_4KCycles +#define SL_DEVICE_INIT_LFXO_TIMEOUT cmuLfxoStartupDelay_4KCycles +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_LFXO_CONFIG_H diff --git a/misc/firmware-eraser/config/sl_memory_config.h b/misc/firmware-eraser/config/sl_memory_config.h new file mode 100644 index 00000000..b43ebcba --- /dev/null +++ b/misc/firmware-eraser/config/sl_memory_config.h @@ -0,0 +1,28 @@ +#ifndef SL_MEMORY_CONFIG_H +#define SL_MEMORY_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Memory configuration + +// Stack size for the application. +// Default: 4096 +// The stack size configured here will be used by the stack that the +// application uses when coming out of a reset. +#ifndef SL_STACK_SIZE + #define SL_STACK_SIZE 4096 +#endif + +// Minimum heap size for the application. +// Default: 2048 +// Note that this value will configure the c heap which is normally used by +// malloc() and free() from the c library. The value defines a minimum heap +// size that is guaranteed to be available. The available heap may be larger +// to make use of any memory that would otherwise remain unused. +#ifndef SL_HEAP_SIZE + #define SL_HEAP_SIZE 2048 +#endif + +// +// <<< end of configuration section >>> + +#endif diff --git a/misc/firmware-eraser/firmware-eraser.pintool b/misc/firmware-eraser/firmware-eraser.pintool new file mode 100644 index 00000000..d01f3a62 --- /dev/null +++ b/misc/firmware-eraser/firmware-eraser.pintool @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/misc/firmware-eraser/firmware-eraser.slcp b/misc/firmware-eraser/firmware-eraser.slcp new file mode 100644 index 00000000..87b35fed --- /dev/null +++ b/misc/firmware-eraser/firmware-eraser.slcp @@ -0,0 +1,41 @@ +# Silicon Labs Project Configuration Tools: slcp, v0, Component selection file. +project_name: firmware-eraser +label: firmware-eraser +description: | + This example project shows an empty configuration that can be used as a starting point to add components and functionality. +category: Example|Platform +filter: +- name: Device Type + value: [SoC] +- name: MCU + value: [32-bit MCU] +- name: Project Difficulty + value: [Beginner] +package: platform +quality: production +readme: +- {path: readme.md} +source: +- {path: app.cpp} +- {path: main.cpp} +include: +- path: '' + file_list: + - {path: app.h} +sdk: {id: gecko_sdk, version: 4.4.0} +toolchain_settings: [] +component: +- {id: sl_system} +- {id: brd4001a} +- {id: bootloader_app_properties} +- {id: cpp_support} +- {id: device_init} +- {id: brd4179b} +- {id: bootloader_interface} +- {id: EFR32MG21A010F1024IM32} +define: +- {name: DEBUG_EFM} +ui_hints: + highlight: + - {path: readme.md, focus: true} + diff --git a/misc/firmware-eraser/firmware-eraser.slps b/misc/firmware-eraser/firmware-eraser.slps new file mode 100644 index 00000000..d60e42ca --- /dev/null +++ b/misc/firmware-eraser/firmware-eraser.slps @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/misc/firmware-eraser/gbl_metadata.yaml b/misc/firmware-eraser/gbl_metadata.yaml new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/misc/firmware-eraser/gbl_metadata.yaml @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/misc/firmware-eraser/main.cpp b/misc/firmware-eraser/main.cpp new file mode 100644 index 00000000..3e095007 --- /dev/null +++ b/misc/firmware-eraser/main.cpp @@ -0,0 +1,58 @@ +/***************************************************************************//** + * @file main.cpp + * @brief main() function. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include "sl_component_catalog.h" +#include "sl_system_init.h" +#include "app.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif +#if defined(SL_CATALOG_KERNEL_PRESENT) +#include "sl_system_kernel.h" +#else // SL_CATALOG_KERNEL_PRESENT +#include "sl_system_process_action.h" +#endif // SL_CATALOG_KERNEL_PRESENT + +int main(void) +{ + // Initialize Silicon Labs device, system, service(s) and protocol stack(s). + // Note that if the kernel is present, processing task(s) will be created by + // this call. + sl_system_init(); + + // Initialize the application. For example, create periodic timer(s) or + // task(s) if the kernel is present. + app_init(); + +#if defined(SL_CATALOG_KERNEL_PRESENT) + // Start the kernel. Task(s) created in app_init() will start running. + sl_system_kernel_start(); +#else // SL_CATALOG_KERNEL_PRESENT + while (1) { + // Do not remove this call: Silicon Labs components process action routine + // must be called from the super loop. + sl_system_process_action(); + + // Application process. + app_process_action(); + +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + // Let the CPU go to sleep if the system allows it. + sl_power_manager_sleep(); +#endif + } +#endif // SL_CATALOG_KERNEL_PRESENT +} diff --git a/src/bootloader-uart-xmodem/.cproject b/src/bootloader-uart-xmodem/.cproject new file mode 100644 index 00000000..b960729a --- /dev/null +++ b/src/bootloader-uart-xmodem/.cproject @@ -0,0 +1,265 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/bootloader-uart-xmodem/bootloader-uart-xmodem.pintool b/src/bootloader-uart-xmodem/bootloader-uart-xmodem.pintool new file mode 100644 index 00000000..f6080cec --- /dev/null +++ b/src/bootloader-uart-xmodem/bootloader-uart-xmodem.pintool @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/bootloader-uart-xmodem/bootloader-uart-xmodem.slcp b/src/bootloader-uart-xmodem/bootloader-uart-xmodem.slcp new file mode 100644 index 00000000..68f54b00 --- /dev/null +++ b/src/bootloader-uart-xmodem/bootloader-uart-xmodem.slcp @@ -0,0 +1,40 @@ +# Silicon Labs Project Configuration Tools: slcp, v0, Component selection file. +project_name: bootloader-uart-xmodem +label: bootloader-uart-xmodem +description: | + Standalone Bootloader using XMODEM-CRC over UART. The bootloader shows a menu, where an XMODEM transfer can be started by sending ASCII '1', or the application can be started by sending ASCII '2'. This is the recommended UART bootloader for the EmberZNet and Connect protocol stacks. +category: Example|Bootloader +filter: +- name: Device Type + value: [NCP] +- name: MCU + value: [Bootloader] +- name: Project Difficulty + value: [Advanced] +package: bootloader +quality: production +readme: +- {path: readme.md} +sdk: {id: gecko_sdk, version: 4.4.0} +toolchain_settings: [] +component: +- {id: bootloader_token_management} +- {id: bootloader_serial_driver} +- {id: bootloader_crc} +- {id: bootloader_aes_sha_ecdsa} +- {id: bootloader_gpio_activation} +- {id: bootloader_uart_xmodem} +- {id: brd4001a} +- {id: bootloader_xmodem_parser} +- {id: bootloader_delay_driver} +- {id: bootloader_debug} +- {id: brd4179b} +- {id: bootloader_image_parser} +- {id: bootloader_core} +- {id: EFR32MG21A010F1024IM32} +configuration: +- {name: SL_VCOM_ENABLE, value: '1'} +ui_hints: + highlight: + - {path: readme.md, focus: true} + diff --git a/src/bootloader-uart-xmodem/bootloader-uart-xmodem.slps b/src/bootloader-uart-xmodem/bootloader-uart-xmodem.slps new file mode 100644 index 00000000..60e0819c --- /dev/null +++ b/src/bootloader-uart-xmodem/bootloader-uart-xmodem.slps @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/bootloader-uart-xmodem/config/btl_aes_ctr_stream_block_cfg.h b/src/bootloader-uart-xmodem/config/btl_aes_ctr_stream_block_cfg.h new file mode 100644 index 00000000..9be7befa --- /dev/null +++ b/src/bootloader-uart-xmodem/config/btl_aes_ctr_stream_block_cfg.h @@ -0,0 +1,44 @@ +/***************************************************************************//** + * @file + * @brief Configuration header for bootloader aes stream block + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_AES_CTR_STREAM_BLOCK_CFG_H +#define BTL_AES_CTR_STREAM_BLOCK_CFG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Enable AES CTR stream block size configuration +// Default: 0 +// Enable AES CTR Stream Block size configuration to change the number of stream blocks that are pre-computed. +#define BOOTLOADER_AES_CTR_STREAM_BLOCK_CFG_ON 0 +// Set the Number of AES CTR Stream Blocks +// Default: 1 +// BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED allows to configure the stream block size that are pre-computed +#define BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED 1 +// + +// <<< end of configuration section >>> + +#if (BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED != 1U) \ + && (BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED != 2U) \ + && (BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED != 4U) \ + && (BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED != 8U) +#error "Recommnded values for BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED value must be 1 or 2 or 4 or 8" +#endif + +#if defined(BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED) +#define SLI_SE_AES_CTR_NUM_BLOCKS_BUFFERED BOOTLOADER_AES_CTR_NUM_BLOCKS_BUFFERED +#endif + +#endif //BTL_AES_CTR_STREAM_BLOCK_CFG_H diff --git a/src/bootloader-uart-xmodem/config/btl_core_cfg.h b/src/bootloader-uart-xmodem/config/btl_core_cfg.h new file mode 100644 index 00000000..c60b190a --- /dev/null +++ b/src/bootloader-uart-xmodem/config/btl_core_cfg.h @@ -0,0 +1,139 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Core for Series 2 devices + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_CORE_CONFIG_H +#define BTL_CORE_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Bootloader Core Configuration + +// Require signed firmware upgrade files +// Default: 0 +// Require that firmware upgrade files are authenticated using asymmetric signature verification. +#define BOOTLOADER_ENFORCE_SIGNED_UPGRADE 0 + +// Require encrypted firmware upgrade files +// Default: 0 +// Require that firmware upgrade files are encrypted. +#define BOOTLOADER_ENFORCE_ENCRYPTED_UPGRADE 0 + +// Use symmetric key stored in Secure Element storage +// Default: 0 +// Use the symmetric key stored in Secure Element storage for encryption and decryption. +#define BOOTLOADER_USE_SYMMETRIC_KEY_FROM_SE_STORAGE 0 + +// Use symmetric key stored in Application Properties Struct +// Default: 0 +// Use the symmetric key stored in Application Properties Struct for encryption and decryption. +#define BOOTLOADER_USE_SYMMETRIC_KEY_FROM_APP_PROPERTIES 0 + +// Enable secure boot +// Default: 0 +// Enforce signature verification on the application image in internal flash before every boot. +#define BOOTLOADER_ENFORCE_SECURE_BOOT 0 + +// Prevent write/erase of verified application +// Default: 0 +// Lock the application area in flash after the signature verification is passed. This option is only valid if secure boot is +// enabled. If end address of the signature does not touch a page boundary, the remaining flash memory in the page becomes unavailable. +#define APPLICATION_WRITE_DISABLE 0 + +// Enable application rollback protection +// Default: 0 +// Prevent applications from being downgraded. The application version can remain the same for upgrades. The +// bootloader will only allow applications to increment its version x times. Bootloader can be upgraded thenceforth +// to allow applications to increment its version again. This option is not applicable on the devices with Secure +// Element configured to perform full page lock. +#define BOOTLOADER_ROLLBACK_PROTECTION 0 + +// Minimum application version allowed +// Default: 0 +// The minimum version of the applications allowed for boot and upgrade. Prevent applications from being downgraded +// to the version below this. +#define BOOTLOADER_ROLLBACK_PROTECTION_MINIMUM_VERSION 0 +// + +// Enable certificate support +// Default: 0 +// Enforce signature verification on the application image using the certificate of the bootloader image. +// To utilize certificate secure boot authentication, secure Element should be configured to authenticate +// the bootloader image by configuring (certificate based) secure boot option in Secure Element OTP. This +// option will also allow certificate based authentication of the GBL files. +#define BOOTLOADER_SUPPORT_CERTIFICATES 0 + +// Reject direct signed images +// Default: 0 +// On every boot, look for a certificate on application images and only accept the application images with a certificate. +#define BOOTLOADER_REJECT_DIRECT_SIGNED_IMG 0 +// + +// + +// Allow use of public key from manufacturing token storage +// Default: 1 +// Allow use of the public key from the manufacturing token storage for signature verification if the public key is not stored in Secure Element. +#define BOOTLOADER_FALLBACK_LEGACY_KEY 1 + +// Prevent bootloader write/erase +// Default: 0 +// Write lock bootloader area before entering application. The bootloader area in flash will be locked until the next reboot. +// This does not affect bootloader upgrades, but prevents the application running in main flash from disturbing the bootloader. +// On Series-1 devices this is only applicable to devices that use the bootloader area of flash (EFR32xG12 and later). +#define BOOTLOADER_WRITE_DISABLE 0 + +// APPLICATION_VERIFICATION_SKIP_EM4_RST Skip verification of application on EM4 reset +// Default: 0 +// Skip verification of the application when the device wakes up from EM4 sleep. +#define APPLICATION_VERIFICATION_SKIP_EM4_RST 0 + +// Upgrade SE without using the staging area +// Default: 0 +// Applicable to storage bootloaders only. When enabled, the SE upgrade image will be fetched for installation directly from inside the stored GBL file. +// This requires that the SE upgrade GBL tag is unencrypted. +#define BOOTLOADER_SE_UPGRADE_NO_STAGING 0 + +// Base address of bootloader upgrade image +// Default: 0x8000 +// At the upgrade stage of the bootloader, the running main bootloader extracts the upgrade image from the GBL file, +// and stores it in internal flash at the address chosen. The address need to be a multiple of the page size. +#define BTL_UPGRADE_LOCATION_BASE 0x8000UL + +// Bootloader Version Main Customer +// Default: 0 +// Bootloader Version Main Customer +#define BOOTLOADER_VERSION_MAIN_CUSTOMER 0 + +// Use custom Bootloader Application Size +// Default: 0 +#define USE_CUSTOM_APP_SIZE 0 + +// Enter Bootloader App Space Size +// Default: 0 +// Bootloader App Space Size +#define CUSTOM_BTL_APP_SPACE_SIZE 0 +// + +#if USE_CUSTOM_APP_SIZE +#define BTL_APP_SPACE_SIZE CUSTOM_BTL_APP_SPACE_SIZE +#else +#define BTL_APP_SPACE_SIZE (FLASH_BASE + FLASH_SIZE) - BTL_APPLICATION_BASE +#endif + +// + +// <<< end of configuration section >>> + +#endif // BTL_CORE_CONFIG_H diff --git a/src/bootloader-uart-xmodem/config/btl_debug_cfg.h b/src/bootloader-uart-xmodem/config/btl_debug_cfg.h new file mode 100644 index 00000000..a80201d5 --- /dev/null +++ b/src/bootloader-uart-xmodem/config/btl_debug_cfg.h @@ -0,0 +1,52 @@ +/***************************************************************************//** + * @file + * @brief Configuration header for bootloader debug + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + * + ******************************************************************************/ + +#ifndef BTL_DEBUG_CONFIG_H +#define BTL_DEBUG_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Bootloader Debug Configuration + +// Debug prints +// Default: 0 +// Print debug messages to SWO. +#ifndef SL_DEBUG_PRINT +/// Print debug message to SWO. +#define SL_DEBUG_PRINT 0 +#endif + +// Debug asserts +// Default: 0 +// Enable assertions in the source code +/// Enable Assert in source code. +#define SL_DEBUG_ASSERT 0 + +// +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_DEBUG +// $[GPIO_SL_DEBUG] +#ifndef SL_DEBUG_PERIPHERAL +#define SL_DEBUG_PERIPHERAL GPIO +#endif + +// [GPIO_SL_DEBUG]$ +// <<< sl:end pin_tool >>> + +#endif // BTL_DEBUG_CONFIG_H diff --git a/src/bootloader-uart-xmodem/config/btl_gpio_activation_cfg.h b/src/bootloader-uart-xmodem/config/btl_gpio_activation_cfg.h new file mode 100644 index 00000000..b85697a1 --- /dev/null +++ b/src/bootloader-uart-xmodem/config/btl_gpio_activation_cfg.h @@ -0,0 +1,50 @@ +/***************************************************************************//** + * @file + * @brief Configuration header for bootloader GPIO Activation + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_GPIO_ACTIVATION_CONFIG_H +#define BTL_GPIO_ACTIVATION_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Properties of Bootloader Entry + +// Active state +// Low +// High +// Default: LOW +// Enter firmware upgrade mode if GPIO pin has this state +#define SL_GPIO_ACTIVATION_POLARITY LOW + +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +// SL_BTL_BUTTON + +// $[GPIO_SL_BTL_BUTTON] +#ifndef SL_BTL_BUTTON_PORT +#define SL_BTL_BUTTON_PORT gpioPortB +#endif +#ifndef SL_BTL_BUTTON_PIN +#define SL_BTL_BUTTON_PIN 0 +#endif +// [GPIO_SL_BTL_BUTTON]$ + +// <<< sl:end pin_tool >>> + +#endif // BTL_GPIO_ACTIVATION_CONFIG_H diff --git a/src/bootloader-uart-xmodem/config/btl_uart_driver_cfg.h b/src/bootloader-uart-xmodem/config/btl_uart_driver_cfg.h new file mode 100644 index 00000000..7f5ab91f --- /dev/null +++ b/src/bootloader-uart-xmodem/config/btl_uart_driver_cfg.h @@ -0,0 +1,108 @@ +/***************************************************************************//** + * @file + * @brief Configuration header for bootloader Uart Driver + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_UART_DRIVER_CONFIG_H +#define BTL_UART_DRIVER_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// USART settings + +// Baud rate +// Default: 115200 +#define SL_SERIAL_UART_BAUD_RATE 115200 + +// Hardware flow control +// Default: 0 +#define SL_SERIAL_UART_FLOW_CONTROL 0 +// + +// Receive buffer size +// <0-2048:1> +// Default: 512 [0-2048] +#define SL_DRIVER_UART_RX_BUFFER_SIZE 512 + +// Transmit buffer size +// <0-2048:1> +// Default: 128 [0-2048] +#define SL_DRIVER_UART_TX_BUFFER_SIZE 128 + +// Virtual COM Port +// Default: 0 +#define SL_VCOM_ENABLE 1 +// + +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_SERIAL_UART +// $[USART_SL_SERIAL_UART] +#ifndef SL_SERIAL_UART_PERIPHERAL +#define SL_SERIAL_UART_PERIPHERAL USART0 +#endif +#ifndef SL_SERIAL_UART_PERIPHERAL_NO +#define SL_SERIAL_UART_PERIPHERAL_NO 0 +#endif + +// USART0 TX on PA05 +#ifndef SL_SERIAL_UART_TX_PORT +#define SL_SERIAL_UART_TX_PORT gpioPortA +#endif +#ifndef SL_SERIAL_UART_TX_PIN +#define SL_SERIAL_UART_TX_PIN 5 +#endif + +// USART0 RX on PA06 +#ifndef SL_SERIAL_UART_RX_PORT +#define SL_SERIAL_UART_RX_PORT gpioPortA +#endif +#ifndef SL_SERIAL_UART_RX_PIN +#define SL_SERIAL_UART_RX_PIN 6 +#endif + +// USART0 CTS on PC03 +#ifndef SL_SERIAL_UART_CTS_PORT +#define SL_SERIAL_UART_CTS_PORT gpioPortC +#endif +#ifndef SL_SERIAL_UART_CTS_PIN +#define SL_SERIAL_UART_CTS_PIN 3 +#endif + +// USART0 RTS on PC02 +#ifndef SL_SERIAL_UART_RTS_PORT +#define SL_SERIAL_UART_RTS_PORT gpioPortC +#endif +#ifndef SL_SERIAL_UART_RTS_PIN +#define SL_SERIAL_UART_RTS_PIN 2 +#endif +// [USART_SL_SERIAL_UART]$ + +// SL_VCOM_ENABLE + +// $[GPIO_SL_VCOM_ENABLE] +#ifndef SL_VCOM_ENABLE_PORT +#define SL_VCOM_ENABLE_PORT gpioPortD +#endif +#ifndef SL_VCOM_ENABLE_PIN +#define SL_VCOM_ENABLE_PIN 4 +#endif +// [GPIO_SL_VCOM_ENABLE]$ + +// <<< sl:end pin_tool >>> + +#endif // BTL_UART_DRIVER_CONFIG_H diff --git a/src/bootloader-uart-xmodem/config/btl_xmodem_config.h b/src/bootloader-uart-xmodem/config/btl_xmodem_config.h new file mode 100644 index 00000000..847cf2f8 --- /dev/null +++ b/src/bootloader-uart-xmodem/config/btl_xmodem_config.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file btl_xmodem_config.h + * @brief Status Uart Xmodem Functions Configuration - Configuration Template File + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +/********************************************************************************************************* + ********************************************************************************************************* + * MODULE + ******************************************************************************************************** + *******************************************************************************************************/ + +#ifndef BTL_XMODEM_CONFIG_H +#define BTL_XMODEM_CONFIG_H + +// Options: + +/******************************************************************************************************** + ******************************************************************************************************** + * XMODEM UART CONFIGURATION + ********************************************************************************************************* + ********************************************************************************************************/ +// Menu idle timeout (seconds)[0-60] +// <0-60:1> +// Default: 0 +// If the host hasn't initiated communication with the bootloader within this window, +// the bootloader will abort the firmware upgrade process and return to the application. +#define BTL_XMODEM_IDLE_TIMEOUT 0 + + +// + +#endif // End of BTL_XMODEM_CONFIG_H module include. + +// <<< end of configuration section >>> diff --git a/src/bootloader-uart-xmodem/config/emlib_core_debug_config.h b/src/bootloader-uart-xmodem/config/emlib_core_debug_config.h new file mode 100644 index 00000000..07ee9b9e --- /dev/null +++ b/src/bootloader-uart-xmodem/config/emlib_core_debug_config.h @@ -0,0 +1,45 @@ +/***************************************************************************//** + * @file + * @brief emlib_core Configuration + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef EM_CORE_DEBUG_CONFIG_H +#define EM_CORE_DEBUG_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Core Configuration + +// Enables measuring of interrupt disable time for debugging purposes. +// Default: 0 +#define SL_EMLIB_CORE_ENABLE_INTERRUPT_DISABLED_TIMING 0 + +// + +// <<< end of configuration section >>> +#endif // EM_CORE_CONFIG_H diff --git a/src/bootloader-uart-xmodem/config/pin_config.h b/src/bootloader-uart-xmodem/config/pin_config.h new file mode 100644 index 00000000..3ddb3667 --- /dev/null +++ b/src/bootloader-uart-xmodem/config/pin_config.h @@ -0,0 +1,149 @@ +#ifndef PIN_CONFIG_H +#define PIN_CONFIG_H + +// $[CMU] +// [CMU]$ + +// $[LFXO] +// [LFXO]$ + +// $[PRS.ASYNCH0] +// [PRS.ASYNCH0]$ + +// $[PRS.ASYNCH1] +// [PRS.ASYNCH1]$ + +// $[PRS.ASYNCH2] +// [PRS.ASYNCH2]$ + +// $[PRS.ASYNCH3] +// [PRS.ASYNCH3]$ + +// $[PRS.ASYNCH4] +// [PRS.ASYNCH4]$ + +// $[PRS.ASYNCH5] +// [PRS.ASYNCH5]$ + +// $[PRS.ASYNCH6] +// [PRS.ASYNCH6]$ + +// $[PRS.ASYNCH7] +// [PRS.ASYNCH7]$ + +// $[PRS.ASYNCH8] +// [PRS.ASYNCH8]$ + +// $[PRS.ASYNCH9] +// [PRS.ASYNCH9]$ + +// $[PRS.ASYNCH10] +// [PRS.ASYNCH10]$ + +// $[PRS.ASYNCH11] +// [PRS.ASYNCH11]$ + +// $[PRS.SYNCH0] +// [PRS.SYNCH0]$ + +// $[PRS.SYNCH1] +// [PRS.SYNCH1]$ + +// $[PRS.SYNCH2] +// [PRS.SYNCH2]$ + +// $[PRS.SYNCH3] +// [PRS.SYNCH3]$ + +// $[GPIO] +// [GPIO]$ + +// $[TIMER0] +// [TIMER0]$ + +// $[TIMER1] +// [TIMER1]$ + +// $[TIMER2] +// [TIMER2]$ + +// $[TIMER3] +// [TIMER3]$ + +// $[USART0] +// USART0 CTS on PC03 +#ifndef USART0_CTS_PORT +#define USART0_CTS_PORT gpioPortC +#endif +#ifndef USART0_CTS_PIN +#define USART0_CTS_PIN 3 +#endif + +// USART0 RTS on PC02 +#ifndef USART0_RTS_PORT +#define USART0_RTS_PORT gpioPortC +#endif +#ifndef USART0_RTS_PIN +#define USART0_RTS_PIN 2 +#endif + +// USART0 RX on PA06 +#ifndef USART0_RX_PORT +#define USART0_RX_PORT gpioPortA +#endif +#ifndef USART0_RX_PIN +#define USART0_RX_PIN 6 +#endif + +// USART0 TX on PA05 +#ifndef USART0_TX_PORT +#define USART0_TX_PORT gpioPortA +#endif +#ifndef USART0_TX_PIN +#define USART0_TX_PIN 5 +#endif + +// [USART0]$ + +// $[USART1] +// [USART1]$ + +// $[USART2] +// [USART2]$ + +// $[I2C1] +// [I2C1]$ + +// $[LETIMER0] +// [LETIMER0]$ + +// $[IADC0] +// [IADC0]$ + +// $[ACMP0] +// [ACMP0]$ + +// $[ACMP1] +// [ACMP1]$ + +// $[I2C0] +// [I2C0]$ + +// $[PTI] +// [PTI]$ + +// $[MODEM] +// [MODEM]$ + +// $[CUSTOM_PIN_NAME] +#ifndef _PORT +#define _PORT gpioPortA +#endif +#ifndef _PIN +#define _PIN 0 +#endif + +// [CUSTOM_PIN_NAME]$ + +#endif // PIN_CONFIG_H + diff --git a/src/bootloader-uart-xmodem/config/psa_crypto_config.h b/src/bootloader-uart-xmodem/config/psa_crypto_config.h new file mode 100644 index 00000000..7d9144b3 --- /dev/null +++ b/src/bootloader-uart-xmodem/config/psa_crypto_config.h @@ -0,0 +1,134 @@ +#ifndef PSA_CRYPTO_CONFIG_H +#define PSA_CRYPTO_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// Key management configuration + +// PSA User Maximum Open Keys Count <0-128> +// Maximum amount of keys that the user application will have open +// simultaneously. In context of PSA Crypto, an open key means any key +// either stored in RAM (lifetime set to PSA_KEY_LIFETIME_VOLATILE), or +// used as part of a cryptographic operation. +// When using a key for a multi-part (setup/update/finish) operation, a key +// is considered to be open from the moment the operation is successfully +// setup, until it finishes or aborts. +// When an application tries to open more keys than this value accounts for, +// the PSA API may return PSA_ERROR_INSUFFICIENT_MEMORY. Keep in mind that +// other software included in the application (e.g. wireless protocol stacks) +// also can have a need to have open keys in PSA Crypto. This could lead to +// a race condition when the application key slot count is set too low for +// the actual usage of the application, as a software stack may not fail +// gracefully in case an application opens more than its declared amount of +// keys, thereby precluding the stack from functioning. +// Default: 4 +#define SL_PSA_KEY_USER_SLOT_COUNT (4) + +// PSA Maximum User Persistent Keys Count <0-1024> +// Maximum amount of keys (or other files) that can be stored persistently +// by the application through the PSA interface, when persistent storage +// support for PSA Crypto is included in the project. +// Due to caching logic, this setting does have an impact on static RAM usage. +// Note that this number is added to the potential requirements from other +// software components in the project, such that the total amount of keys +// which can be stored through the ITS backend can be higher than what is +// configured here. +// +// WARNING: When changing this setting on an application that is already +// deployed, and thus will get the change through an application upgrade, +// care should be taken to ensure that the setting is only ever increased, +// and never decreased. Decreasing this setting might cause previously +// stored keys/files to become inaccessible. +// +// It is not possible to change this setting when using V3 ITS Driver. +// The file-storage indexing is dependent on the maximum number of files, +// and if SL_PSA_ITS_USER_MAX_FILES is changed, ITS should be cleared and +// all files need to be stored again. +// Default: 128 +#define SL_PSA_ITS_USER_MAX_FILES (128) + +// Enable V1 Format Support For ITS Files <0-1> +// Devices that used PSA ITS together with gecko_sdk_3.1.x or earlier +// might have keys (or other files) stored in V1 format. +// If no v1 files are used, its support can be disabled for space +// optimization. +// Default: 0 +#define SL_PSA_ITS_SUPPORT_V1_DRIVER 0 + +// Enable V2 ITS Driver Support <0-1> +// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys +// (or other files) stored using different address range. Enabling this +// config option adds upgrade code which converts V2 (and V1 if +// supported) format ITS keys/files to the latest V3 format. Update is +// fully automatic, needs to be run once and require extra flash space of +// approximately the size of the largest key. +// V1 ITS driver support can be disabled if the device has never used ITS +// driver before in GSDK 4.1.x and earlier, or the keys has been already +// migrated. +// Default: 0 +#define SL_PSA_ITS_SUPPORT_V2_DRIVER 0 + +// Enable support for V3 ITS Driver <0-1> +// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys +// (or other files) stored using different address range. In rare case +// that those devices have full nvm3 and not enough space for the +// upgrade, (that requires an extra space to store largest key in memory +// twice), this config option can disable v3 driver and use v2 one. +// To upgrade the device, make space for the upgrade, and enable v3 driver again. +// +// WARNING: When using V3 driver, it is not possible to increase or decrease +// the value of SL_PSA_ITS_USER_MAX_FILES. If the change of +// SL_PSA_ITS_USER_MAX_FILES is required, ITS should be cleared and +// all files need to be stored again. +// Default: 1 +#define SL_PSA_ITS_SUPPORT_V3_DRIVER 1 + +// Built-in AES Key Mode of Operation +// CTR Mode +// CFB Mode +// OFB Mode +// ECB Mode +// CBC Mode (no padding) +// CBC Mode (PKCS#7 padding) +// PSA Crypto only allows one specific usage algorithm per built-in key ID. +// Default: PSA_ALG_CTR +#define SL_SE_BUILTIN_KEY_AES128_ALG_CONFIG (PSA_ALG_CTR) + +#ifndef SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG +// Built-in PUF Key Algorithm +// PBKDF2 (CMAC-AES-128-PRF) +// CMAC +// PSA Crypto only allows one specific usage algorithm per built-in key ID. +// It is recommended to only use the PUF key for deriving further key +// material. +// Default: PSA_ALG_PBKDF2_AES_CMAC_PRF_128 +#define SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG (PSA_ALG_PBKDF2_AES_CMAC_PRF_128) +#endif // SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Sub-files + +#if defined(SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE) + #include SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE +#else + #include "sli_psa_config_autogen.h" +#endif + +#if defined(TFM_CONFIG_SL_SECURE_LIBRARY) + #include "sli_psa_tfm_translation.h" +#endif + +#if SL_MBEDTLS_DRIVERS_ENABLED + #include "sli_psa_acceleration.h" +#endif + +#include "sli_psa_builtin_config_autogen.h" + +#endif // PSA_CRYPTO_CONFIG_H diff --git a/src/bootloader-uart-xmodem/config/sl_fault_injection_hardening_cfg.h b/src/bootloader-uart-xmodem/config/sl_fault_injection_hardening_cfg.h new file mode 100644 index 00000000..313bb512 --- /dev/null +++ b/src/bootloader-uart-xmodem/config/sl_fault_injection_hardening_cfg.h @@ -0,0 +1,107 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Fault Injection Hardening Library + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef FAULT_INJECTION_HARDENING_CFG_H +#define FAULT_INJECTION_HARDENING_CFG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Fault Injection Profile Configuration + +// Enable TFM Fault Injection Hardening Profile +// Default: 0 +// Enforce TFM Fault Injection Hardening Profile ON in the firmware +// TZ bootloader applies the FI hardening to critical bootloader functions. +// TZ Secure Key Library initialisation applies FI hardening to secure that the TZ configuration is securely setup before jumping to the NonSecure application +#define SL_TFM_FIH_PROFILE_ON 0 + +#if defined(SL_TFM_FIH_PROFILE_ON) && (SL_TFM_FIH_PROFILE_ON == 1) +#define TFM_FIH_PROFILE_ON +#endif + +// TFM Fault Injection Hardening Profile as Low. +// Default: 0 +// enabled. Configures the TFM Fault Injection Hardening profile as low. +// Includes FIH_ENABLE_GLOBAL_FAIL (hardens the mitigations against the loop) +// Includes FIH_ENABLE_CFI (Control Flow Integrity) creates a global counter that is +// incremented before every FIH_CALL of vulnerable functions. On the function +// return the counter is decremented, and after the return it is verified that +// the counter has the same value as before this process. +#define SL_TFM_FIH_PROFILE_LOW 0 + +#if defined(SL_TFM_FIH_PROFILE_LOW) && (SL_TFM_FIH_PROFILE_LOW == 1) +#define TFM_FIH_PROFILE_LOW +#endif + +// TFM Fault Injection Hardening Profile as Medium. +// Default: 0 +// enabled. Configures the TFM Fault Injection Hardening profile as medium. +// Includes FIH_ENABLE_DOUBLE_VARS makes critical variables into a tuple (x, x ^ msk). +// Then the correctness of x can be checked by XORing the two tuple values together. +// This also means that comparisons between fih_ints can be verified +// by doing x == y && x_msk == y_msk. +// Includes FIH_ENABLE_GLOBAL_FAIL (hardens the mitigations against the loop) +// Includes FIH_ENABLE_CFI (Control Flow Integrity) creates a global counter that is +// incremented before every FIH_CALL of vulnerable functions. On the function +// return the counter is decremented, and after the return it is verified that +// the counter has the same value as before this process. +#define SL_TFM_FIH_PROFILE_MEDIUM 0 + +#if defined(SL_TFM_FIH_PROFILE_MEDIUM) && (SL_TFM_FIH_PROFILE_MEDIUM == 1) +#define TFM_FIH_PROFILE_MEDIUM +#endif + +// TFM Fault Injection Hardening Profile as High. +// Default: 0 +// enabled. Configures the TFM Fault Injection Hardening profile as high. +// Includes FIH_ENABLE_DELAY causes random delays. This makes it hard to cause faults precisely +// Includes FIH_ENABLE_DOUBLE_VARS makes critical variables into a tuple (x, x ^ msk). +// Then the correctness of x can be checked by XORing the two tuple values together. +// This also means that comparisons between fih_ints can be verified +// by doing x == y && x_msk == y_msk. +// Includes FIH_ENABLE_GLOBAL_FAIL (hardens the mitigations against the loop) +// Includes FIH_ENABLE_CFI (Control Flow Integrity) creates a global counter that is +// incremented before every FIH_CALL of vulnerable functions. On the function +// return the counter is decremented, and after the return it is verified that +// the counter has the same value as before this process. +#define SL_TFM_FIH_PROFILE_HIGH 0 + +#if defined(SL_TFM_FIH_PROFILE_HIGH) && (SL_TFM_FIH_PROFILE_HIGH == 1) +#define TFM_FIH_PROFILE_HIGH +#endif + +// + +// + +// <<< end of configuration section >>> +#if defined(TFM_FIH_PROFILE_ON) + #if (defined(TFM_FIH_PROFILE_LOW) && defined(TFM_FIH_PROFILE_MEDIUM) && defined(TFM_FIH_PROFILE_HIGH)) + #error "Choose either TFM fault injection hardening profile as LOW or Medium or High" + #endif // TFM_FIH_PROFILE_LOW && TFM_FIH_PROFILE_MEDIUM && TFM_FIH_PROFILE_HIGH + + #if (defined(TFM_FIH_PROFILE_LOW) && !defined(TFM_FIH_PROFILE_MEDIUM) && defined(TFM_FIH_PROFILE_HIGH)) + #error "Choose either TFM fault injection hardening profile as LOW or Medium or High" + #endif // TFM_FIH_PROFILE_LOW && !TFM_FIH_PROFILE_MEDIUM && TFM_FIH_PROFILE_HIGH + + #if (defined(TFM_FIH_PROFILE_LOW) && defined(TFM_FIH_PROFILE_MEDIUM) && !defined(TFM_FIH_PROFILE_HIGH)) + #error "Choose either TFM fault injection hardening profile as LOW or Medium or High" + #endif // TFM_FIH_PROFILE_LOW && TFM_FIH_PROFILE_MEDIUM && !TFM_FIH_PROFILE_HIGH + + #if (!defined(TFM_FIH_PROFILE_LOW) && defined(TFM_FIH_PROFILE_MEDIUM) && defined(TFM_FIH_PROFILE_HIGH)) + #error "Choose either TFM fault injection hardening profile as LOW or Medium or High" + #endif // !TFM_FIH_PROFILE_LOW && TFM_FIH_PROFILE_MEDIUM && TFM_FIH_PROFILE_HIGH +#endif // TFM_FIH_PROFILE_ON +#endif // FAULT_INJECTION_HARDENING_CFG_H diff --git a/src/bootloader-uart-xmodem/config/sl_mbedtls_config.h b/src/bootloader-uart-xmodem/config/sl_mbedtls_config.h new file mode 100644 index 00000000..39b51496 --- /dev/null +++ b/src/bootloader-uart-xmodem/config/sl_mbedtls_config.h @@ -0,0 +1,118 @@ +#ifndef SL_MBEDTLS_CONFIG_H +#define SL_MBEDTLS_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// TLS/DTLS configuration + +// Complete list of ciphersuites to use, in order of preference. +// Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 +// Complete list of ciphersuites to use, in order of preference. +// The value of this configuration should be updated for the application needs. +#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + +// Maximum TLS/DTLS fragment length in bytes (input). +// Default: 768 +// The size configured here determines the size of the internal I/O +// buffer used in mbedTLS when receiving data. +#define SL_MBEDTLS_SSL_IN_CONTENT_LEN 768 + +// Maximum TLS/DTLS fragment length in bytes (output). +// Default: 768 +// The size configured here determines the size of the internal I/O +// buffer used in mbedTLS when sending data. +#define SL_MBEDTLS_SSL_OUT_CONTENT_LEN 768 + +// Enable support for RFC 6066 max_fragment_length extension in SSL. +// Default: 1 +// Enable support for RFC 6066 max_fragment_length extension in SSL. +#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1 + +// Enable support for exporting key block and master secret. +// Default: 1 +// Enable support for exporting key block and master secret. +// This is required for certain users of TLS, e.g. EAP-TLS. +#define SL_MBEDTLS_SSL_EXPORT_KEYS 1 + +// Enable the PSK based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the PSK based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 0 + +// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0 + +// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 0 + +// Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED 0 + +// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0 + +// Enable parsing of the compressed curves. +// Default: 0 +// Enable parsing of the compressed curves. +#define SL_MBEDTLS_ECP_ENABLE_COMPRESSED_CURVE_PARSING 0 + +// + +// RSA configuration + +// Disable use of the Chinese Remainder Theorem for RSA. +// Default: 0 +// Disable use of the Chinese Remainder Theorem for RSA private key +// computations. +#define SL_MBEDTLS_RSA_NO_CRT 0 + +// + +// Miscellaneous configuration + +// Enable Silicon Labs' Mbed TLS- and PSA Crypto drivers. +// Default: 1 +// Enable drivers for hardware acceleration (Mbed TLS and PSA Crypto) and +// secure key handling (PSA Crypto). +#define SL_MBEDTLS_DRIVERS_ENABLED 1 + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Sub-files + +#if defined(SLI_MBEDTLS_CONFIG_AUTOGEN_OVERRIDE_FILE) + #include SLI_MBEDTLS_CONFIG_AUTOGEN_OVERRIDE_FILE +#else + #include "sli_mbedtls_config_autogen.h" +#endif + +#include "sli_mbedtls_omnipresent.h" + +#if SL_MBEDTLS_DRIVERS_ENABLED + #include "sli_mbedtls_acceleration.h" +#endif + +#include "sl_mbedtls_device_config.h" + +// Include transformation logic to apply CMSIS-config configuration options to +// the correct Mbed TLS / PSA Crypto options. +#include "sli_mbedtls_config_transform_autogen.h" + +// Included for backward compatibility reasons. +#include "mbedtls/build_info.h" + +#endif // SL_MBEDTLS_CONFIG_H diff --git a/src/bootloader-uart-xmodem/config/sl_mbedtls_device_config.h b/src/bootloader-uart-xmodem/config/sl_mbedtls_device_config.h new file mode 100644 index 00000000..33c34c42 --- /dev/null +++ b/src/bootloader-uart-xmodem/config/sl_mbedtls_device_config.h @@ -0,0 +1,72 @@ +#ifndef SL_MBEDTLS_DEVICE_CONFIG_H +#define SL_MBEDTLS_DEVICE_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// Secure Engine (SE) version configuration + +// Support SE firmware versions older than 1.2.2 <0-1> +// Enable software fallback for ECDH and ECC public key validation on xG21 +// devices running SE firmware versions lower than 1.2.2. +// +// Due to other stability concerns, it is strongly recommended to upgrade +// these devices to the latest firmware revision instead of turning on +// software fallback support. +// +// Not having fallback support will make ECDH operations, as well as PSA +// Crypto public key import, return an error code on affected devices. +// +// Default: 0 +#define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 0 + +// Assume an SE firmware version newer than 1.2.2 <0-1> +// For enhanced performance: if it is guaranteed that all devices on which +// this library will run are updated to at least SE FW 1.2.2, then turning +// on this option will remove certain fallback checks, thereby reducing the +// amount of processing required for ECDH and public key verification +// operations. +// Default: 0 +#define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 0 + +// Assume an SE firmware version that is unaffected by Ed25519 errata <0-1> +// For minimal code size and performance savings: if it is guaranteed that +// none of the devices running this library has SE FWs in the range +// [1.2.2, 1.2.8], then enabling this option will disable runtime version +// checks. +// Default: 0 +#define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 0 + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Additional SE version related logic (DO NOT MODIFY) + +// SL_SE_ASSUME_FW_AT_LEAST_1_2_10 is no longer in use, however, it is kept here +// for backwards compatibility. */ +#if defined(SL_SE_ASSUME_FW_AT_LEAST_1_2_10) + #undef SL_SE_ASSUME_FW_AT_LEAST_1_2_2 + #define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1 + #undef SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA + #define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 1 +#endif + +// SLI_SE_SUPPORT_FW_PRIOR_TO_1_2_2 is no longer in use, however, it is kept +// here for backwards compatibility. */ +#if defined(SLI_SE_SUPPORT_FW_PRIOR_TO_1_2_2) + #undef SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 + #define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 1 +#endif + +// SLI_SE_ASSUME_FW_AT_LEAST_1_2_2 is no longer in use, however, it is kept +// here for backwards compatibility. */ +#if defined(SLI_SE_ASSUME_FW_AT_LEAST_1_2_2) + #undef SL_SE_ASSUME_FW_AT_LEAST_1_2_2 + #define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1 +#endif + +#endif // SL_MBEDTLS_DEVICE_CONFIG_H diff --git a/src/bootloader-uart-xmodem/config/sl_memory_config.h b/src/bootloader-uart-xmodem/config/sl_memory_config.h new file mode 100644 index 00000000..b43ebcba --- /dev/null +++ b/src/bootloader-uart-xmodem/config/sl_memory_config.h @@ -0,0 +1,28 @@ +#ifndef SL_MEMORY_CONFIG_H +#define SL_MEMORY_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Memory configuration + +// Stack size for the application. +// Default: 4096 +// The stack size configured here will be used by the stack that the +// application uses when coming out of a reset. +#ifndef SL_STACK_SIZE + #define SL_STACK_SIZE 4096 +#endif + +// Minimum heap size for the application. +// Default: 2048 +// Note that this value will configure the c heap which is normally used by +// malloc() and free() from the c library. The value defines a minimum heap +// size that is guaranteed to be available. The available heap may be larger +// to make use of any memory that would otherwise remain unused. +#ifndef SL_HEAP_SIZE + #define SL_HEAP_SIZE 2048 +#endif + +// +// <<< end of configuration section >>> + +#endif diff --git a/src/bootloader-uart-xmodem/gbl_metadata.yaml b/src/bootloader-uart-xmodem/gbl_metadata.yaml new file mode 100644 index 00000000..45dc570c --- /dev/null +++ b/src/bootloader-uart-xmodem/gbl_metadata.yaml @@ -0,0 +1,3 @@ +baudrate: 115200 +dynamic: [gecko_bootloader_version] +fw_type: gecko-bootloader diff --git a/src/bootloader-uart-xmodem/readme.md b/src/bootloader-uart-xmodem/readme.md new file mode 100644 index 00000000..d6ed442a --- /dev/null +++ b/src/bootloader-uart-xmodem/readme.md @@ -0,0 +1,3 @@ +# UART XMODEM Bootloader + +Standalone Bootloader using XMODEM-CRC over UART. The bootloader shows a menu, where an XMODEM transfer can be started by sending ASCII '1', or the application can be started by sending ASCII '2'. This is the recommended UART bootloader for the EmberZNet and Connect protocol stacks. diff --git a/src/ncp-uart-hw/.cproject b/src/ncp-uart-hw/.cproject new file mode 100644 index 00000000..b9b8cb1b --- /dev/null +++ b/src/ncp-uart-hw/.cproject @@ -0,0 +1,415 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ncp-uart-hw/app.c b/src/ncp-uart-hw/app.c new file mode 100644 index 00000000..9e7f24f5 --- /dev/null +++ b/src/ncp-uart-hw/app.c @@ -0,0 +1,38 @@ +/***************************************************************************//** + * @file app.c + * @brief Callbacks implementation and application specific code. + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#include PLATFORM_HEADER +#include "ember.h" + +//---------------------- +// Implemented Callbacks + +/** @brief + * + * Application framework equivalent of ::emberRadioNeedsCalibratingHandler + */ +void emberAfRadioNeedsCalibratingCallback(void) +{ + sl_mac_calibrate_current_channel(); +} + +/** @brief Init + * Application init function + */ +void emberAfMainInitCallback(void) +{ +} diff --git a/src/ncp-uart-hw/config/SEGGER_RTT_Conf.h b/src/ncp-uart-hw/config/SEGGER_RTT_Conf.h new file mode 100644 index 00000000..df57e166 --- /dev/null +++ b/src/ncp-uart-hw/config/SEGGER_RTT_Conf.h @@ -0,0 +1,428 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2023 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER SystemView * Real-time application analysis * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the SystemView and RTT protocol, and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* 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 SEGGER Microcontroller 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. * +* * +********************************************************************** +* * +* SystemView version: 3.52 * +* * +********************************************************************** +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT_Conf.h +Purpose : Implementation of SEGGER real-time transfer (RTT) which + allows real-time communication on targets which support + debugger memory accesses while the CPU is running. +Revision: $Rev: 24316 $ + +*/ + +#ifndef SEGGER_RTT_CONF_H +#define SEGGER_RTT_CONF_H + +#ifdef __IAR_SYSTEMS_ICC__ + #include +#endif + +/********************************************************************* +* +* Defines, configurable +* +********************************************************************** +*/ + +// +// Take in and set to correct values for Cortex-A systems with CPU cache +// +//#define SEGGER_RTT_CPU_CACHE_LINE_SIZE (32) // Largest cache line size (in bytes) in the current system +//#define SEGGER_RTT_UNCACHED_OFF (0xFB000000) // Address alias where RTT CB and buffers can be accessed uncached +// +// Most common case: +// Up-channel 0: RTT +// Up-channel 1: SystemView +// +#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS + #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3) +#endif +// +// Most common case: +// Down-channel 0: RTT +// Down-channel 1: SystemView +// +#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS + #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3) +#endif + +#ifndef BUFFER_SIZE_UP + #define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k) +#endif + +#ifndef BUFFER_SIZE_DOWN + #define BUFFER_SIZE_DOWN (1024) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16) +#endif + +#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE + #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) +#endif + +#ifndef SEGGER_RTT_MODE_DEFAULT + #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0) +#endif + +/********************************************************************* +* +* RTT memcpy configuration +* +* memcpy() is good for large amounts of data, +* but the overhead is big for small amounts, which are usually stored via RTT. +* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead. +* +* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions. +* This is may be required with memory access restrictions, +* such as on Cortex-A devices with MMU. +*/ +#ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP + #define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop +#endif +// +// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets +// +//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__)) +// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes)) +//#endif + +// +// Target is not allowed to perform other RTT operations while string still has not been stored completely. +// Otherwise we would probably end up with a mixed string in the buffer. +// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here. +// +// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4. +// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches. +// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly. +// (Higher priority = lower priority number) +// Default value for embOS: 128u +// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC +// or define SEGGER_RTT_LOCK() to completely disable interrupts. +// +#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20) +#endif + +/********************************************************************* +* +* RTT lock configuration for SEGGER Embedded Studio, +* Rowley CrossStudio and GCC +*/ +#if ((defined(__SES_ARM) || defined(__SES_RISCV) || defined(__CROSSWORKS_ARM) || defined(__GNUC__) || defined(__clang__)) && !defined (__CC_ARM) && !defined(WIN32)) + #if (defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__)) + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + __asm volatile ("mrs %0, primask \n\t" \ + "movs r1, #1 \n\t" \ + "msr primask, r1 \n\t" \ + : "=r" (_SEGGER_RTT__LockState) \ + : \ + : "r1", "cc" \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \ + : \ + : "r" (_SEGGER_RTT__LockState) \ + : \ + ); \ + } + #elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__)) + #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) + #endif + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + __asm volatile ("mrs %0, basepri \n\t" \ + "mov r1, %1 \n\t" \ + "msr basepri, r1 \n\t" \ + : "=r" (_SEGGER_RTT__LockState) \ + : "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \ + : "r1", "cc" \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \ + : \ + : "r" (_SEGGER_RTT__LockState) \ + : \ + ); \ + } + + #elif (defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)) + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + __asm volatile ("mrs r1, CPSR \n\t" \ + "mov %0, r1 \n\t" \ + "orr r1, r1, #0xC0 \n\t" \ + "msr CPSR_c, r1 \n\t" \ + : "=r" (_SEGGER_RTT__LockState) \ + : \ + : "r1", "cc" \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \ + "mrs r1, CPSR \n\t" \ + "bic r1, r1, #0xC0 \n\t" \ + "and r0, r0, #0xC0 \n\t" \ + "orr r1, r1, r0 \n\t" \ + "msr CPSR_c, r1 \n\t" \ + : \ + : "r" (_SEGGER_RTT__LockState) \ + : "r0", "r1", "cc" \ + ); \ + } + #elif defined(__riscv) || defined(__riscv_xlen) + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + __asm volatile ("csrr %0, mstatus \n\t" \ + "csrci mstatus, 8 \n\t" \ + "andi %0, %0, 8 \n\t" \ + : "=r" (_SEGGER_RTT__LockState) \ + : \ + : \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("csrr a1, mstatus \n\t" \ + "or %0, %0, a1 \n\t" \ + "csrs mstatus, %0 \n\t" \ + : \ + : "r" (_SEGGER_RTT__LockState) \ + : "a1" \ + ); \ + } + #else + #define SEGGER_RTT_LOCK() + #define SEGGER_RTT_UNLOCK() + #endif +#endif + +/********************************************************************* +* +* RTT lock configuration for IAR EWARM +*/ +#ifdef __ICCARM__ + #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) || \ + (defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__)) + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + _SEGGER_RTT__LockState = __get_PRIMASK(); \ + __set_PRIMASK(1); + + #define SEGGER_RTT_UNLOCK() __set_PRIMASK(_SEGGER_RTT__LockState); \ + } + #elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || \ + (defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || \ + (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) || \ + (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) + #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) + #endif + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + _SEGGER_RTT__LockState = __get_BASEPRI(); \ + __set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); + + #define SEGGER_RTT_UNLOCK() __set_BASEPRI(_SEGGER_RTT__LockState); \ + } + #elif (defined (__ARM7A__) && (__CORE__ == __ARM7A__)) || \ + (defined (__ARM7R__) && (__CORE__ == __ARM7R__)) + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + __asm volatile ("mrs r1, CPSR \n\t" \ + "mov %0, r1 \n\t" \ + "orr r1, r1, #0xC0 \n\t" \ + "msr CPSR_c, r1 \n\t" \ + : "=r" (_SEGGER_RTT__LockState) \ + : \ + : "r1", "cc" \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \ + "mrs r1, CPSR \n\t" \ + "bic r1, r1, #0xC0 \n\t" \ + "and r0, r0, #0xC0 \n\t" \ + "orr r1, r1, r0 \n\t" \ + "msr CPSR_c, r1 \n\t" \ + : \ + : "r" (_SEGGER_RTT__LockState) \ + : "r0", "r1", "cc" \ + ); \ + } + #endif +#endif + +/********************************************************************* +* +* RTT lock configuration for IAR RX +*/ +#ifdef __ICCRX__ + #define SEGGER_RTT_LOCK() { \ + unsigned long _SEGGER_RTT__LockState; \ + _SEGGER_RTT__LockState = __get_interrupt_state(); \ + __disable_interrupt(); + + #define SEGGER_RTT_UNLOCK() __set_interrupt_state(_SEGGER_RTT__LockState); \ + } +#endif + +/********************************************************************* +* +* RTT lock configuration for IAR RL78 +*/ +#ifdef __ICCRL78__ + #define SEGGER_RTT_LOCK() { \ + __istate_t _SEGGER_RTT__LockState; \ + _SEGGER_RTT__LockState = __get_interrupt_state(); \ + __disable_interrupt(); + + #define SEGGER_RTT_UNLOCK() __set_interrupt_state(_SEGGER_RTT__LockState); \ + } +#endif + +/********************************************************************* +* +* RTT lock configuration for KEIL ARM +*/ +#ifdef __CC_ARM + #if (defined __TARGET_ARCH_6S_M) + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + register unsigned char _SEGGER_RTT__PRIMASK __asm( "primask"); \ + _SEGGER_RTT__LockState = _SEGGER_RTT__PRIMASK; \ + _SEGGER_RTT__PRIMASK = 1u; \ + __schedule_barrier(); + + #define SEGGER_RTT_UNLOCK() _SEGGER_RTT__PRIMASK = _SEGGER_RTT__LockState; \ + __schedule_barrier(); \ + } + #elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M)) + #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) + #endif + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + register unsigned char BASEPRI __asm( "basepri"); \ + _SEGGER_RTT__LockState = BASEPRI; \ + BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \ + __schedule_barrier(); + + #define SEGGER_RTT_UNLOCK() BASEPRI = _SEGGER_RTT__LockState; \ + __schedule_barrier(); \ + } + #endif +#endif + +/********************************************************************* +* +* RTT lock configuration for TI ARM +*/ +#ifdef __TI_ARM__ + #if defined (__TI_ARM_V6M0__) + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + _SEGGER_RTT__LockState = __get_PRIMASK(); \ + __set_PRIMASK(1); + + #define SEGGER_RTT_UNLOCK() __set_PRIMASK(_SEGGER_RTT__LockState); \ + } + #elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__)) + #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) + #endif + #define SEGGER_RTT_LOCK() { \ + unsigned int _SEGGER_RTT__LockState; \ + _SEGGER_RTT__LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); + + #define SEGGER_RTT_UNLOCK() _set_interrupt_priority(_SEGGER_RTT__LockState); \ + } + #endif +#endif + +/********************************************************************* +* +* RTT lock configuration for CCRX +*/ +#ifdef __RX + #include + #define SEGGER_RTT_LOCK() { \ + unsigned long _SEGGER_RTT__LockState; \ + _SEGGER_RTT__LockState = get_psw() & 0x010000; \ + clrpsw_i(); + + #define SEGGER_RTT_UNLOCK() set_psw(get_psw() | _SEGGER_RTT__LockState); \ + } +#endif + +/********************************************************************* +* +* RTT lock configuration for embOS Simulation on Windows +* (Can also be used for generic RTT locking with embOS) +*/ +#if defined(WIN32) || defined(SEGGER_RTT_LOCK_EMBOS) + +void OS_SIM_EnterCriticalSection(void); +void OS_SIM_LeaveCriticalSection(void); + +#define SEGGER_RTT_LOCK() { \ + OS_SIM_EnterCriticalSection(); + +#define SEGGER_RTT_UNLOCK() OS_SIM_LeaveCriticalSection(); \ + } +#endif + +/********************************************************************* +* +* RTT lock configuration fallback +*/ +#ifndef SEGGER_RTT_LOCK + #define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts) +#endif + +#ifndef SEGGER_RTT_UNLOCK + #define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state) +#endif + +#endif +/*************************** End of file ****************************/ diff --git a/src/ncp-uart-hw/config/app_properties_config.h b/src/ncp-uart-hw/config/app_properties_config.h new file mode 100644 index 00000000..6a6b9766 --- /dev/null +++ b/src/ncp-uart-hw/config/app_properties_config.h @@ -0,0 +1,65 @@ +/***************************************************************************//** + * @file + * @brief Application Properties Header File + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef APP_PROPERTIES_CONFIG_H +#define APP_PROPERTIES_CONFIG_H + +#include "sl_application_type.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// App Properties settings + +// Type of signature this application is signed with +// Default: APPLICATION_SIGNATURE_NONE(0) +#define SL_APPLICATION_SIGNATURE 0 + +// Location of the signature +// Default: 0xFFFFFFFF +#define SL_APPLICATION_SIGNATURE_LOCATION 0xFFFFFFFF + +// Bitfield representing type of application +#define SL_APPLICATION_TYPE APPLICATION_TYPE + +// Version number for this application +// <0-4294967295:1> +// Default: 1 [0-4294967295] +#define SL_APPLICATION_VERSION 1 + +// Capabilities of this application +// Default: 0 +#define SL_APPLICATION_CAPABILITIES 0 + +//Product ID of the device for which the application is built +#define SL_APPLICATION_PRODUCT_ID { 0 } + +// + +#endif // APP_PROPERTIES_CONFIG_H diff --git a/src/ncp-uart-hw/config/btl_interface_cfg.h b/src/ncp-uart-hw/config/btl_interface_cfg.h new file mode 100644 index 00000000..8e246f80 --- /dev/null +++ b/src/ncp-uart-hw/config/btl_interface_cfg.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_H +#define BTL_INTERFACE_CFG_H + +#if !defined(BOOTLOADER_APPLOADER) + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1) +#include "btl_interface_cfg_s2c1.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_2) +#include "btl_interface_cfg_s2c2.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_3) +#include "btl_interface_cfg_s2c3.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4) +#include "btl_interface_cfg_s2c4.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_8) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#endif // !BOOTLOADER_APPLOADER + +#endif // BTL_INTERFACE_CFG_H diff --git a/src/ncp-uart-hw/config/btl_interface_cfg_s2c1.h b/src/ncp-uart-hw/config/btl_interface_cfg_s2c1.h new file mode 100644 index 00000000..c72c27b0 --- /dev/null +++ b/src/ncp-uart-hw/config/btl_interface_cfg_s2c1.h @@ -0,0 +1,281 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_S2C1_H +#define BTL_INTERFACE_CFG_S2C1_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Bootloader Interface Trust Zone Security State Configuration + +// Disable multi tiered fallback logic +// The fault handling logic as well as the USART auto-detection logic will be disabled. +// The re-configuration of SMU will be handled by querying the running bootloader +// for the peripheral list. Querying the peripheral list is supported from the bootloader +// version 2.0.0. Check for the BOOTLOADER_CAPABILITY_PERIPHERAL_LIST capability to +// see if the running bootloader supports querying the peripheral list. +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 0 + +// Disable peripheral access fault handling +// The fault handling triggered by an erroneous access of peripherals will be disabled. +// +// This should be disabled iff all the peripherals that are in use by the bootloader +// have been properly configured by the "Manually override security state of peripherals" option. +#define BOOTLOADER_DISABLE_NVM3_FAULT_HANDLING 0 + +// Manually override the security state of peripherals in use by the bootloader +// Default: 0. +// Manually override the security state of peripherals. Choose the peripherals touched +// by the customized code to have a valid secure access state before interacting with the bootloader +// In practice, this means that the chosen peripherals will be available at the secure address, +// which is accessible by the bootloader. Once the application is entered back the secure access state +// is changed back to the original state. +// +// The USART auto-detection logic that detects which, if any, USART is in use by the bootloader +// will be disabled. Make sure to choose the correct USART used by the bootloader. +#define BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE 0 +// EMU +// Update secure access state of EMU before calling into bootloader +#define BOOTLOADER_PPUSATD0_EMU 0 + +// CMU +// Update secure access state of CMU before calling into bootloader +#define BOOTLOADER_PPUSATD0_CMU 0 + +// HFXO0 +// Update secure access state of HFXO0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_HFXO0 0 + +// HFRCO0 +// Update secure access state of HFRCO0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_HFRCO0 0 + +// FSRCO +// Update secure access state of FSRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_FSRCO 0 + +// DPLL0 +// Update secure access state of DPLL0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_DPLL0 0 + +// LFXO +// Update secure access state of LFXO before calling into bootloader +#define BOOTLOADER_PPUSATD0_LFXO 0 + +// LFRCO +// Update secure access state of LFRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_LFRCO 0 + +// ULFRCO +// Update secure access state of ULFRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_ULFRCO 0 + +// MSC +// Update secure access state of MSC before calling into bootloader +#define BOOTLOADER_PPUSATD0_MSC 0 + +// ICACHE0 +// Update secure access state of ICACHE0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_ICACHE0 0 + +// PRS +// Update secure access state of PRS before calling into bootloader +#define BOOTLOADER_PPUSATD0_PRS 0 + +// GPIO +// Update secure access state of GPIO before calling into bootloader +#define BOOTLOADER_PPUSATD0_GPIO 0 + +// LDMA +// Update secure access state of LDMA before calling into bootloader +#define BOOTLOADER_PPUSATD0_LDMA 0 + +// LDMAXBAR +// Update secure access state of LDMAXBAR before calling into bootloader +#define BOOTLOADER_PPUSATD0_LDMAXBAR 0 + +// TIMER0 +// Update secure access state of TIMER0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER0 0 + +// TIMER1 +// Update secure access state of TIMER1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER1 0 + +// TIMER2 +// Update secure access state of TIMER2 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER2 0 + +// TIMER3 +// Update secure access state of TIMER3 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER3 0 + +// USART0 +// Update secure access state of USART0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART0 0 + +// USART1 +// Update secure access state of USART1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART1 0 + +// USART2 +// Update secure access state of USART2 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART2 0 + +// BURTC +// Update secure access state of BURTC before calling into bootloader +#define BOOTLOADER_PPUSATD0_BURTC 0 + +// I2C1 +// Update secure access state of I2C1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_I2C1 0 + +// CHIPTESTCTRL +// Update secure access state of CHIPTESTCTRL before calling into bootloader +#define BOOTLOADER_PPUSATD0_CHIPTESTCTRL 0 + +// LVGD +// Update secure access state of LVGD before calling into bootloader +#define BOOTLOADER_PPUSATD0_LVGD 0 + +// SYSCFG +// Update secure access state of SYSCFG before calling into bootloader +#define BOOTLOADER_PPUSATD0_SYSCFG 0 + +// BURAM +// Update secure access state of BURAM before calling into bootloader +#define BOOTLOADER_PPUSATD0_BURAM 0 + +// IFADCDEBUG +// Update secure access state of IFADCDEBUG before calling into bootloader +#define BOOTLOADER_PPUSATD0_IFADCDEBUG 0 + +// GPCRC +// Update secure access state of GPCRC before calling into bootloader +#define BOOTLOADER_PPUSATD0_GPCRC 0 + +// RTCC +// Update secure access state of RTCC before calling into bootloader +#define BOOTLOADER_PPUSATD0_RTCC 0 + +// LETIMER0 +// Update secure access state of LETIMER0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_LETIMER0 0 + +// IADC0 +// Update secure access state of IADC0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_IADC0 0 + +// ACMP0 +// Update secure access state of ACMP0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_ACMP0 0 + +// ACMP1 +// Update secure access state of ACMP1 before calling into bootloader +#define BOOTLOADER_PPUSATD1_ACMP1 0 + +// I2C0 +// Update secure access state of I2C0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_I2C0 0 + +// HFRCOEM23 +// Update secure access state of HFRCOEM23 before calling into bootloader +#define BOOTLOADER_PPUSATD1_HFRCOEM23 0 + +// WDOG0 +// Update secure access state of WDOG0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_WDOG0 0 + +// WDOG1 +// Update secure access state of WDOG1 before calling into bootloader +#define BOOTLOADER_PPUSATD1_WDOG1 0 + +// AMUXCP0 +// Update secure access state of AMUXCP0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_AMUXCP0 0 + +// RADIOAES +// Update secure access state of RADIOAES before calling into bootloader +#define BOOTLOADER_PPUSATD1_RADIOAES 0 + +// BUFC +// Update secure access state of BUFC before calling into bootloader +#define BOOTLOADER_PPUSATD1_BUFC 0 + +// SMU +// Update secure access state of SMU before calling into bootloader +#define BOOTLOADER_PPUSATD1_SMU 0 + +// AHBRADIO +// Update secure access state of AHBRADIO before calling into bootloader +#define BOOTLOADER_PPUSATD1_AHBRADIO 0 + +// SEMAILBOX +// Update secure access state of SEMAILBOX before calling into bootloader +#define BOOTLOADER_PPUSATD1_SEMAILBOX 0 +// + +// +// <<< end of configuration section >>> + +#if BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE == 1 +#define BOOTLOADER_PPUSATD0_MASK ((BOOTLOADER_PPUSATD0_EMU << _SMU_PPUSATD0_EMU_SHIFT) \ + | (BOOTLOADER_PPUSATD0_CMU << _SMU_PPUSATD0_CMU_SHIFT) \ + | (BOOTLOADER_PPUSATD0_HFXO0 << _SMU_PPUSATD0_HFXO0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_HFRCO0 << _SMU_PPUSATD0_HFRCO0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_FSRCO << _SMU_PPUSATD0_FSRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_DPLL0 << _SMU_PPUSATD0_DPLL0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LFXO << _SMU_PPUSATD0_LFXO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LFRCO << _SMU_PPUSATD0_LFRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_ULFRCO << _SMU_PPUSATD0_ULFRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_MSC << _SMU_PPUSATD0_MSC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_ICACHE0 << _SMU_PPUSATD0_ICACHE0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_PRS << _SMU_PPUSATD0_PRS_SHIFT) \ + | (BOOTLOADER_PPUSATD0_GPIO << _SMU_PPUSATD0_GPIO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LDMA << _SMU_PPUSATD0_LDMA_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LDMAXBAR << _SMU_PPUSATD0_LDMAXBAR_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER0 << _SMU_PPUSATD0_TIMER0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER1 << _SMU_PPUSATD0_TIMER1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER2 << _SMU_PPUSATD0_TIMER2_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER3 << _SMU_PPUSATD0_TIMER3_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART0 << _SMU_PPUSATD0_USART0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART1 << _SMU_PPUSATD0_USART1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART2 << _SMU_PPUSATD0_USART2_SHIFT) \ + | (BOOTLOADER_PPUSATD0_BURTC << _SMU_PPUSATD0_BURTC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_I2C1 << _SMU_PPUSATD0_I2C1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_CHIPTESTCTRL << _SMU_PPUSATD0_CHIPTESTCTRL_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LVGD << _SMU_PPUSATD0_LVGD_SHIFT) \ + | (BOOTLOADER_PPUSATD0_SYSCFG << _SMU_PPUSATD0_SYSCFG_SHIFT) \ + | (BOOTLOADER_PPUSATD0_BURAM << _SMU_PPUSATD0_BURAM_SHIFT) \ + | (BOOTLOADER_PPUSATD0_IFADCDEBUG << _SMU_PPUSATD0_IFADCDEBUG_SHIFT) \ + | (BOOTLOADER_PPUSATD0_GPCRC << _SMU_PPUSATD0_GPCRC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_RTCC << _SMU_PPUSATD0_RTCC_SHIFT)) +#define BOOTLOADER_PPUSATD1_MASK ((BOOTLOADER_PPUSATD1_LETIMER0 << _SMU_PPUSATD1_LETIMER0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_IADC0 << _SMU_PPUSATD1_IADC0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_ACMP0 << _SMU_PPUSATD1_ACMP0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_ACMP1 << _SMU_PPUSATD1_ACMP1_SHIFT) \ + | (BOOTLOADER_PPUSATD1_I2C0 << _SMU_PPUSATD1_I2C0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_HFRCOEM23 << _SMU_PPUSATD1_HFRCOEM23_SHIFT) \ + | (BOOTLOADER_PPUSATD1_WDOG0 << _SMU_PPUSATD1_WDOG0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_WDOG1 << _SMU_PPUSATD1_WDOG1_SHIFT) \ + | (BOOTLOADER_PPUSATD1_AMUXCP0 << _SMU_PPUSATD1_AMUXCP0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_RADIOAES << _SMU_PPUSATD1_RADIOAES_SHIFT) \ + | (BOOTLOADER_PPUSATD1_BUFC << _SMU_PPUSATD1_BUFC_SHIFT) \ + | (BOOTLOADER_PPUSATD1_SMU << _SMU_PPUSATD1_SMU_SHIFT) \ + | (BOOTLOADER_PPUSATD1_AHBRADIO << _SMU_PPUSATD1_AHBRADIO_SHIFT) \ + | (BOOTLOADER_PPUSATD1_SEMAILBOX << _SMU_PPUSATD1_SEMAILBOX_SHIFT)) +#endif // BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE + +#endif // BTL_INTERFACE_CFG_S2C1_H diff --git a/src/ncp-uart-hw/config/dmadrv_config.h b/src/ncp-uart-hw/config/dmadrv_config.h new file mode 100644 index 00000000..ed105e4f --- /dev/null +++ b/src/ncp-uart-hw/config/dmadrv_config.h @@ -0,0 +1,26 @@ +#ifndef DMADRV_CONFIG_H +#define DMADRV_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// DMA interrupt priority <0-15> +// Priority of the DMA interrupt. Smaller number equals higher priority. +// Default: 8 +#define EMDRV_DMADRV_DMA_IRQ_PRIORITY 8 + +// Number of available channels <1-8> +// Number of DMA channels supported by the driver. A lower channel count +// will reduce RAM memory footprint. The default is to support all channels +// on the device. +// Default: 8 +#define EMDRV_DMADRV_DMA_CH_COUNT 8 + +// Number of fixed priority channels +// This will configure channels [0, CH_PRIORITY - 1] as fixed priority, +// and channels [CH_PRIORITY, CH_COUNT] as round-robin. +// Default: 0 +#define EMDRV_DMADRV_DMA_CH_PRIORITY 0 + +// <<< end of configuration section >>> + +#endif // DMADRV_CONFIG_H diff --git a/src/ncp-uart-hw/config/emlib_core_debug_config.h b/src/ncp-uart-hw/config/emlib_core_debug_config.h new file mode 100644 index 00000000..07ee9b9e --- /dev/null +++ b/src/ncp-uart-hw/config/emlib_core_debug_config.h @@ -0,0 +1,45 @@ +/***************************************************************************//** + * @file + * @brief emlib_core Configuration + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef EM_CORE_DEBUG_CONFIG_H +#define EM_CORE_DEBUG_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Core Configuration + +// Enables measuring of interrupt disable time for debugging purposes. +// Default: 0 +#define SL_EMLIB_CORE_ENABLE_INTERRUPT_DISABLED_TIMING 0 + +// + +// <<< end of configuration section >>> +#endif // EM_CORE_CONFIG_H diff --git a/src/ncp-uart-hw/config/legacy_common_ash_config.h b/src/ncp-uart-hw/config/legacy_common_ash_config.h new file mode 100644 index 00000000..ce1ad5d7 --- /dev/null +++ b/src/ncp-uart-hw/config/legacy_common_ash_config.h @@ -0,0 +1,43 @@ +/***************************************************************************//** + * @file + * @brief Legacy Host ASH configuration file. + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef LEGACY_NCP_ASH_CONFIG_H +#define LEGACY_NCP_ASH_CONFIG_H + +// The USART used for ASH communications in COM_Port_t format, as defined in platform/service/legacy_hal/inc/serial.h (see defined names for USART ports) <-1..3:1> +// Default: (-1) +// The default value of -1 causes the ASH code to try to use the USART assigned to the "VCOM" instance of SL_IOSTREAM_USART. Otherwise the value is passed to Legacy HAL, which attempts to find an instance of SL_IOSTREAM_USART which uses that USART. +#define LEGACY_NCP_ASH_SERIAL_PORT (-1) + +#endif /* LEGACY_NCP_ASH_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/legacy_hal_config.h b/src/ncp-uart-hw/config/legacy_hal_config.h new file mode 100644 index 00000000..e3386e94 --- /dev/null +++ b/src/ncp-uart-hw/config/legacy_hal_config.h @@ -0,0 +1,47 @@ +/***************************************************************************//** + * @file + * @brief Legacy HAL configuration file. + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef LEGACY_HAL_CONFIG_H +#define LEGACY_HAL_CONFIG_H + +// Translate button interrupt callback +// When the Simple Button component is included, it provides a callback for +// buttons configured in interrupt mode. When this option is 1, Legacy HAL +// will try to consume that callback and translate it to "halButtonIsr", +// the legacy callback. If anything else in the application consumes the +// Simple button callback, it will override Legacy HAL's version. +// Default: 1 +#define LEGACY_HAL_TRANSLATE_BUTTON_INTERRUPT (1) + +#endif /* LEGACY_HAL_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/nvm3_default_config.h b/src/ncp-uart-hw/config/nvm3_default_config.h new file mode 100644 index 00000000..5f127358 --- /dev/null +++ b/src/ncp-uart-hw/config/nvm3_default_config.h @@ -0,0 +1,45 @@ +#ifndef NVM3_DEFAULT_CONFIG_H +#define NVM3_DEFAULT_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// NVM3 Default Instance Configuration + +#ifndef NVM3_DEFAULT_CACHE_SIZE +// NVM3 Default Instance Cache Size +// Number of NVM3 objects to cache. To reduce access times this number +// should be equal to or higher than the number of NVM3 objects in the +// default NVM3 instance. +// Default: 200 +#define NVM3_DEFAULT_CACHE_SIZE 200 +#endif + +#ifndef NVM3_DEFAULT_MAX_OBJECT_SIZE +// NVM3 Default Instance Max Object Size +// Max NVM3 object size that can be stored. +// Default: 254 +#define NVM3_DEFAULT_MAX_OBJECT_SIZE 254 +#endif + +#ifndef NVM3_DEFAULT_REPACK_HEADROOM +// NVM3 Default Instance User Repack Headroom +// Headroom determining how many bytes below the forced repack limit the user +// repack limit should be placed. The default is 0, which means the user and +// forced repack limits are equal. +// Default: 0 +#define NVM3_DEFAULT_REPACK_HEADROOM 0 +#endif + +#ifndef NVM3_DEFAULT_NVM_SIZE +// NVM3 Default Instance Size +// Size of the NVM3 storage region in flash. This size should be aligned with +// the flash page size of the device. +// Default: 40960 +#define NVM3_DEFAULT_NVM_SIZE 32768 +#endif + +// + +// <<< end of configuration section >>> + +#endif // NVM3_DEFAULT_CONFIG_H diff --git a/src/ncp-uart-hw/config/pin_config.h b/src/ncp-uart-hw/config/pin_config.h new file mode 100644 index 00000000..ceb0ee66 --- /dev/null +++ b/src/ncp-uart-hw/config/pin_config.h @@ -0,0 +1,173 @@ +#ifndef PIN_CONFIG_H +#define PIN_CONFIG_H + +// $[CMU] +// [CMU]$ + +// $[LFXO] +// [LFXO]$ + +// $[PRS.ASYNCH0] +// [PRS.ASYNCH0]$ + +// $[PRS.ASYNCH1] +// [PRS.ASYNCH1]$ + +// $[PRS.ASYNCH2] +// [PRS.ASYNCH2]$ + +// $[PRS.ASYNCH3] +// [PRS.ASYNCH3]$ + +// $[PRS.ASYNCH4] +// [PRS.ASYNCH4]$ + +// $[PRS.ASYNCH5] +// [PRS.ASYNCH5]$ + +// $[PRS.ASYNCH6] +// [PRS.ASYNCH6]$ + +// $[PRS.ASYNCH7] +// [PRS.ASYNCH7]$ + +// $[PRS.ASYNCH8] +// [PRS.ASYNCH8]$ + +// $[PRS.ASYNCH9] +// [PRS.ASYNCH9]$ + +// $[PRS.ASYNCH10] +// [PRS.ASYNCH10]$ + +// $[PRS.ASYNCH11] +// [PRS.ASYNCH11]$ + +// $[PRS.SYNCH0] +// [PRS.SYNCH0]$ + +// $[PRS.SYNCH1] +// [PRS.SYNCH1]$ + +// $[PRS.SYNCH2] +// [PRS.SYNCH2]$ + +// $[PRS.SYNCH3] +// [PRS.SYNCH3]$ + +// $[GPIO] +// GPIO SWV on PA03 +#ifndef GPIO_SWV_PORT +#define GPIO_SWV_PORT gpioPortA +#endif +#ifndef GPIO_SWV_PIN +#define GPIO_SWV_PIN 3 +#endif + +// [GPIO]$ + +// $[TIMER0] +// [TIMER0]$ + +// $[TIMER1] +// [TIMER1]$ + +// $[TIMER2] +// [TIMER2]$ + +// $[TIMER3] +// [TIMER3]$ + +// $[USART0] +// USART0 CTS on PC03 +#ifndef USART0_CTS_PORT +#define USART0_CTS_PORT gpioPortC +#endif +#ifndef USART0_CTS_PIN +#define USART0_CTS_PIN 3 +#endif + +// USART0 RTS on PC02 +#ifndef USART0_RTS_PORT +#define USART0_RTS_PORT gpioPortC +#endif +#ifndef USART0_RTS_PIN +#define USART0_RTS_PIN 2 +#endif + +// USART0 RX on PA06 +#ifndef USART0_RX_PORT +#define USART0_RX_PORT gpioPortA +#endif +#ifndef USART0_RX_PIN +#define USART0_RX_PIN 6 +#endif + +// USART0 TX on PA05 +#ifndef USART0_TX_PORT +#define USART0_TX_PORT gpioPortA +#endif +#ifndef USART0_TX_PIN +#define USART0_TX_PIN 5 +#endif + +// [USART0]$ + +// $[USART1] +// [USART1]$ + +// $[USART2] +// [USART2]$ + +// $[I2C1] +// [I2C1]$ + +// $[LETIMER0] +// [LETIMER0]$ + +// $[IADC0] +// [IADC0]$ + +// $[ACMP0] +// [ACMP0]$ + +// $[ACMP1] +// [ACMP1]$ + +// $[I2C0] +// [I2C0]$ + +// $[PTI] +// PTI DFRAME on PC05 +#ifndef PTI_DFRAME_PORT +#define PTI_DFRAME_PORT gpioPortC +#endif +#ifndef PTI_DFRAME_PIN +#define PTI_DFRAME_PIN 5 +#endif + +// PTI DOUT on PC04 +#ifndef PTI_DOUT_PORT +#define PTI_DOUT_PORT gpioPortC +#endif +#ifndef PTI_DOUT_PIN +#define PTI_DOUT_PIN 4 +#endif + +// [PTI]$ + +// $[MODEM] +// [MODEM]$ + +// $[CUSTOM_PIN_NAME] +#ifndef _PORT +#define _PORT gpioPortA +#endif +#ifndef _PIN +#define _PIN 0 +#endif + +// [CUSTOM_PIN_NAME]$ + +#endif // PIN_CONFIG_H + diff --git a/src/ncp-uart-hw/config/psa_crypto_config.h b/src/ncp-uart-hw/config/psa_crypto_config.h new file mode 100644 index 00000000..7d9144b3 --- /dev/null +++ b/src/ncp-uart-hw/config/psa_crypto_config.h @@ -0,0 +1,134 @@ +#ifndef PSA_CRYPTO_CONFIG_H +#define PSA_CRYPTO_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// Key management configuration + +// PSA User Maximum Open Keys Count <0-128> +// Maximum amount of keys that the user application will have open +// simultaneously. In context of PSA Crypto, an open key means any key +// either stored in RAM (lifetime set to PSA_KEY_LIFETIME_VOLATILE), or +// used as part of a cryptographic operation. +// When using a key for a multi-part (setup/update/finish) operation, a key +// is considered to be open from the moment the operation is successfully +// setup, until it finishes or aborts. +// When an application tries to open more keys than this value accounts for, +// the PSA API may return PSA_ERROR_INSUFFICIENT_MEMORY. Keep in mind that +// other software included in the application (e.g. wireless protocol stacks) +// also can have a need to have open keys in PSA Crypto. This could lead to +// a race condition when the application key slot count is set too low for +// the actual usage of the application, as a software stack may not fail +// gracefully in case an application opens more than its declared amount of +// keys, thereby precluding the stack from functioning. +// Default: 4 +#define SL_PSA_KEY_USER_SLOT_COUNT (4) + +// PSA Maximum User Persistent Keys Count <0-1024> +// Maximum amount of keys (or other files) that can be stored persistently +// by the application through the PSA interface, when persistent storage +// support for PSA Crypto is included in the project. +// Due to caching logic, this setting does have an impact on static RAM usage. +// Note that this number is added to the potential requirements from other +// software components in the project, such that the total amount of keys +// which can be stored through the ITS backend can be higher than what is +// configured here. +// +// WARNING: When changing this setting on an application that is already +// deployed, and thus will get the change through an application upgrade, +// care should be taken to ensure that the setting is only ever increased, +// and never decreased. Decreasing this setting might cause previously +// stored keys/files to become inaccessible. +// +// It is not possible to change this setting when using V3 ITS Driver. +// The file-storage indexing is dependent on the maximum number of files, +// and if SL_PSA_ITS_USER_MAX_FILES is changed, ITS should be cleared and +// all files need to be stored again. +// Default: 128 +#define SL_PSA_ITS_USER_MAX_FILES (128) + +// Enable V1 Format Support For ITS Files <0-1> +// Devices that used PSA ITS together with gecko_sdk_3.1.x or earlier +// might have keys (or other files) stored in V1 format. +// If no v1 files are used, its support can be disabled for space +// optimization. +// Default: 0 +#define SL_PSA_ITS_SUPPORT_V1_DRIVER 0 + +// Enable V2 ITS Driver Support <0-1> +// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys +// (or other files) stored using different address range. Enabling this +// config option adds upgrade code which converts V2 (and V1 if +// supported) format ITS keys/files to the latest V3 format. Update is +// fully automatic, needs to be run once and require extra flash space of +// approximately the size of the largest key. +// V1 ITS driver support can be disabled if the device has never used ITS +// driver before in GSDK 4.1.x and earlier, or the keys has been already +// migrated. +// Default: 0 +#define SL_PSA_ITS_SUPPORT_V2_DRIVER 0 + +// Enable support for V3 ITS Driver <0-1> +// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys +// (or other files) stored using different address range. In rare case +// that those devices have full nvm3 and not enough space for the +// upgrade, (that requires an extra space to store largest key in memory +// twice), this config option can disable v3 driver and use v2 one. +// To upgrade the device, make space for the upgrade, and enable v3 driver again. +// +// WARNING: When using V3 driver, it is not possible to increase or decrease +// the value of SL_PSA_ITS_USER_MAX_FILES. If the change of +// SL_PSA_ITS_USER_MAX_FILES is required, ITS should be cleared and +// all files need to be stored again. +// Default: 1 +#define SL_PSA_ITS_SUPPORT_V3_DRIVER 1 + +// Built-in AES Key Mode of Operation +// CTR Mode +// CFB Mode +// OFB Mode +// ECB Mode +// CBC Mode (no padding) +// CBC Mode (PKCS#7 padding) +// PSA Crypto only allows one specific usage algorithm per built-in key ID. +// Default: PSA_ALG_CTR +#define SL_SE_BUILTIN_KEY_AES128_ALG_CONFIG (PSA_ALG_CTR) + +#ifndef SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG +// Built-in PUF Key Algorithm +// PBKDF2 (CMAC-AES-128-PRF) +// CMAC +// PSA Crypto only allows one specific usage algorithm per built-in key ID. +// It is recommended to only use the PUF key for deriving further key +// material. +// Default: PSA_ALG_PBKDF2_AES_CMAC_PRF_128 +#define SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG (PSA_ALG_PBKDF2_AES_CMAC_PRF_128) +#endif // SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Sub-files + +#if defined(SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE) + #include SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE +#else + #include "sli_psa_config_autogen.h" +#endif + +#if defined(TFM_CONFIG_SL_SECURE_LIBRARY) + #include "sli_psa_tfm_translation.h" +#endif + +#if SL_MBEDTLS_DRIVERS_ENABLED + #include "sli_psa_acceleration.h" +#endif + +#include "sli_psa_builtin_config_autogen.h" + +#endif // PSA_CRYPTO_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_board_control_config.h b/src/ncp-uart-hw/config/sl_board_control_config.h new file mode 100644 index 00000000..f1804587 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_board_control_config.h @@ -0,0 +1,56 @@ +/***************************************************************************//** + * @file + * @brief Board Control + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_BOARD_CONTROL_CONFIG_H +#define SL_BOARD_CONTROL_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Enable Virtual COM UART +// Default: 0 +#define SL_BOARD_ENABLE_VCOM 1 + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +// SL_BOARD_ENABLE_VCOM +// $[GPIO_SL_BOARD_ENABLE_VCOM] +#ifndef SL_BOARD_ENABLE_VCOM_PORT +#define SL_BOARD_ENABLE_VCOM_PORT gpioPortD +#endif +#ifndef SL_BOARD_ENABLE_VCOM_PIN +#define SL_BOARD_ENABLE_VCOM_PIN 4 +#endif +// [GPIO_SL_BOARD_ENABLE_VCOM]$ + +// <<< sl:end pin_tool >>> + +#endif // SL_BOARD_CONTROL_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_custom_manufacturing_token_header.h b/src/ncp-uart-hw/config/sl_custom_manufacturing_token_header.h new file mode 100644 index 00000000..08b66580 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_custom_manufacturing_token_header.h @@ -0,0 +1,84 @@ +/***************************************************************************//** + * @file + * @brief Custom manufacturing token header + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +/***************************************************************************//** + * Custom Manufacturing Token Usage Examples + * + * The macro DEFINE_MFG_TOKEN() should be used when instantiating a + * manufacturing token. Refer to the list of *_LOCATION defines to + * see what memory is allocated and what memory is unused/available. + * + * The _LOCATION is or'ed with either USERDATA_TOKENS or LOCKBITSDATA_TOKENS + * to control which segment of memory the token is placed in. + * + * REMEMBER: By definition, manufacturing tokens exist at fixed addresses. + * Tokens should not overlap. + * + * Here is a basic example of a manufacturing token header file: + * + * Note that the address used here is just an example. It places the 8 bytes + * in the middle of the USERDATA space on an EFR32MG12P433F1024GM68. + * To review addresses of existing tokens when choosing a new address, refer + * to an961-custom-nodes-efr32.pdf and the files + * platform/service/token_manager/inc/sl_token_manufacturing_series_1.h + * platform/service/token_manager/inc/sl_token_manufacturing_series_2.h + * + * @code + * #define CREATOR_MFG_EXAMPLE 0x4242 + * #ifdef DEFINETYPES + * typedef uint8_t tokTypeMfgExample[8]; + * #endif + * #ifdef DEFINETOKENS + * #define MFG_EXAMPLE_LOCATION (USERDATA_TOKENS | 0x2000) + * DEFINE_MFG_TOKEN(MFG_EXAMPLE, + * tokTypeMfgExample, + * MFG_EXAMPLE_LOCATION, + * {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}) + * #endif + * @endcode + * + * Since this file contains both the typedefs and the token defs, there are + * two \#defines used to select which one is needed when this file is included. + * \#define DEFINETYPES is used to select the type definitions and + * \#define DEFINETOKENS is used to select the token definitions. + * + * To use this example: + * Ensure the Token Manager's configuration in Studio + * has enabled Custom Manufacuturing Tokens. + * + * Ensure your application has: + * #include "sl_token_api.h" + * #include "sl_token_manager.h" + * + * This code will read the token data: + * uint8_t data[8]; + * sl_token_get_data(TOKEN_MFG_EXAMPLE, 0, &data, sizeof(data)); + ******************************************************************************/ + +/* + #define CREATOR_MFG_EXAMPLE 0x4242 + #ifdef DEFINETYPES + typedef uint8_t tokTypeMfgExample[8]; + #endif + #ifdef DEFINETOKENS + #define MFG_EXAMPLE_LOCATION (USERDATA_TOKENS | 0x2000) + DEFINE_MFG_TOKEN(MFG_EXAMPLE, + tokTypeMfgExample, + MFG_EXAMPLE_LOCATION, + {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}) + #endif + */ diff --git a/src/ncp-uart-hw/config/sl_custom_token_header.h b/src/ncp-uart-hw/config/sl_custom_token_header.h new file mode 100644 index 00000000..abfe057a --- /dev/null +++ b/src/ncp-uart-hw/config/sl_custom_token_header.h @@ -0,0 +1,86 @@ +/***************************************************************************//** + * @file + * @brief Custom token header + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +/***************************************************************************//** + * Custom Tokens Usage Examples + * + * #define BASICTOKEN1_DEFAULT 0xA5F0 + * #define BASICTOKEN2_DEFAULT { { 0xAA, 0xBB, 0xCC }, 0xDDDD } + * #define BASICTOKEN3_DEFAULT { { 0 } } + * #define COUNTERTOKEN1_DEFAULT 0 + * #define COUNTERTOKEN2_DEFAULT 0xCCCCCCCC + * #define INDEXEDTOKEN1_DEFAULT 0 + * #define INDEXEDTOKEN2_DEFAULT { 0xDDDD } + * #define INDEXEDTOKEN3_DEFAULT { 0xAA, 0xBBBB, { 0x00, 0x11, 0x22 }, 0xCC } + * + * #ifdef DEFINETYPES + * typedef uint16_t tokTypeBasicToken1; + * typedef struct { + * uint8_t basicToken2Array[3]; + * uint16_t basicToken2VarA; + * } tokTypeBasicToken2; + * + * typedef struct { + * uint8_t basicToken3Array[254]; + * } tokTypeBasicToken3; + * + * typedef uint32_t tokTypeCounterToken1; + * typedef uint32_t tokTypeCounterToken2; + * + * typedef uint8_t tokTypeIndexedToken1Element; + * typedef uint16_t tokTypeIndexedToken2Element; + * + * typedef struct { + * uint8_t indexedToken3VarA; + * uint16_t indexedToken3VarB; + * uint8_t indexedToken3Array[3]; + * int8_t indexedToken3VarC; + * } tokTypeIndexedToken3Element; + * + * #endif + * + * #ifdef DEFINETOKENS + * DEFINE_BASIC_TOKEN(BASICTOKEN1, + * tokTypeBasicToken1, + * BASICTOKEN1_DEFAULT) + * DEFINE_BASIC_TOKEN(BASICTOKEN2, + * tokTypeBasicToken2, + * BASICTOKEN2_DEFAULT) + * DEFINE_BASIC_TOKEN(BASICTOKEN3, + * tokTypeBasicToken3, + * BASICTOKEN3_DEFAULT) + * DEFINE_COUNTER_TOKEN(COUNTERTOKEN1, + * tokTypeCounterToken1, + * COUNTERTOKEN1_DEFAULT) + * DEFINE_COUNTER_TOKEN(COUNTERTOKEN2, + * tokTypeCounterToken2, + * COUNTERTOKEN2_DEFAULT) + * DEFINE_INDEXED_TOKEN(INDEXEDTOKEN1, + * tokTypeIndexedToken1Element, + * INDEXEDTOKEN1_ELEMENTS, + * INDEXEDTOKEN1_DEFAULT) + * DEFINE_INDEXED_TOKEN(INDEXEDTOKEN2, + * tokTypeIndexedToken2Element, + * INDEXEDTOKEN2_ELEMENTS, + * INDEXEDTOKEN2_DEFAULT) + * DEFINE_INDEXED_TOKEN(INDEXEDTOKEN3, + * tokTypeIndexedToken3Element, + * INDEXEDTOKEN3_ELEMENTS, + * INDEXEDTOKEN3_DEFAULT) + * #endif + * + ******************************************************************************/ diff --git a/src/ncp-uart-hw/config/sl_debug_swo_config.h b/src/ncp-uart-hw/config/sl_debug_swo_config.h new file mode 100644 index 00000000..fee7e65d --- /dev/null +++ b/src/ncp-uart-hw/config/sl_debug_swo_config.h @@ -0,0 +1,106 @@ +/***************************************************************************//** + * @file + * @brief SWO configuration + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEBUG_SWO_CONFIG_H +#define SL_DEBUG_SWO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// SWO Configuration + +// SWO Frequency +// Must be 875 kHz for communication with Silicon Labs debuggers +// Default: 875000 +#define SL_DEBUG_SWO_FREQ 875000 + +// Enable interrupt event trace +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_IRQ 0 + +// Enable Program Counter samples +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_PC 0 + +// SWO debug sample intervals +// <64=> 64 +// <128=> 128 +// <192=> 192 +// <256=> 256 +// <320=> 320 +// <384=> 384 +// <448=> 448 +// <512=> 512 +// <576=> 576 +// <640=> 640 +// <704=> 704 +// <768=> 768 +// <832=> 832 +// <896=> 896 +// <960=> 960 +// <1024=> 1024 +// <2048=> 2048 +// <3072=> 3072 +// <4096=> 4096 +// <5102=> 5102 +// <6144=> 6144 +// <7168=> 7168 +// <8192=> 8192 +// <9216=> 9216 +// <10240=> 10240 +// <11264=> 11264 +// <12288=> 12288 +// <13312=> 13312 +// <14336=> 14336 +// <15360=> 15360 +// Must be 64, 128, 192, [ n * 64 ], 1024, 2048, 3072, [ n * 1024 ] , 15360 +// Default: 15360 +#define SL_DEBUG_SWO_SAMPLE_INTERVAL 15360 +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_DEBUG +// $[GPIO_SL_DEBUG] +#ifndef SL_DEBUG_PERIPHERAL +#define SL_DEBUG_PERIPHERAL GPIO +#endif + +// GPIO SWV on PA03 +#ifndef SL_DEBUG_SWV_PORT +#define SL_DEBUG_SWV_PORT gpioPortA +#endif +#ifndef SL_DEBUG_SWV_PIN +#define SL_DEBUG_SWV_PIN 3 +#endif +// [GPIO_SL_DEBUG]$ +// <<< sl:end pin_tool >>> + +#endif // SL_DEBUG_SWO_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_device_init_emu_config.h b/src/ncp-uart-hw/config/sl_device_init_emu_config.h new file mode 100644 index 00000000..4ac96bac --- /dev/null +++ b/src/ncp-uart-hw/config/sl_device_init_emu_config.h @@ -0,0 +1,53 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_EMU Config + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_EMU_CONFIG_H +#define SL_DEVICE_INIT_EMU_CONFIG_H + +#include "em_emu.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// Allow debugger to remain connected in EM2 +// Force PD0B to stay on on EM2 entry. This allows the debugger to remain connected in EM2 and EM3. +// Enabling debug connectivity results in an increased power consumption in EM2/EM3. +// Default: 1 +#define SL_DEVICE_INIT_EMU_EM2_DEBUG_ENABLE 1 + +// EM4 pin retention mode +// No Retention: Pads enter reset state when entering EM4. +// Retention through EM4: Pads enter reset state when exiting EM4. +// Retention through EM4 and wakeup. +// Default: emuPinRetentionDisable +#define SL_DEVICE_INIT_EMU_EM4_PIN_RETENTION_MODE emuPinRetentionDisable + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_EMU_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_device_init_hfrco_config.h b/src/ncp-uart-hw/config/sl_device_init_hfrco_config.h new file mode 100644 index 00000000..d2d99400 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_device_init_hfrco_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFRCO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFRCO_CONFIG_H +#define SL_DEVICE_INIT_HFRCO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Frequency Band +// RC Oscillator Frequency Band +// 1 MHz +// 2 MHz +// 4 MHz +// 7 MHz +// 13 MHz +// 16 MHz +// 19 MHz +// 26 MHz +// 32 MHz +// 38 MHz +// 48 MHz +// 56 MHz +// 64 MHz +// 80 MHz +// Default: cmuHFRCODPLLFreq_80M0Hz +#define SL_DEVICE_INIT_HFRCO_BAND cmuHFRCODPLLFreq_80M0Hz + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFRCO_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_device_init_hfxo_config.h b/src/ncp-uart-hw/config/sl_device_init_hfxo_config.h new file mode 100644 index 00000000..6a35767e --- /dev/null +++ b/src/ncp-uart-hw/config/sl_device_init_hfxo_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFXO_CONFIG_H +#define SL_DEVICE_INIT_HFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// External sine wave +// Default: cmuHfxoOscMode_Crystal +#define SL_DEVICE_INIT_HFXO_MODE cmuHfxoOscMode_Crystal + +// Frequency <38000000-40000000> +// Default: 38400000 +#define SL_DEVICE_INIT_HFXO_FREQ 38400000 + +// HFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_HFXO_PRECISION 50 + +// CTUNE <0-255> +// Default: 140 +#define SL_DEVICE_INIT_HFXO_CTUNE 133 + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFXO_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_device_init_lfxo_config.h b/src/ncp-uart-hw/config/sl_device_init_lfxo_config.h new file mode 100644 index 00000000..6bd763ba --- /dev/null +++ b/src/ncp-uart-hw/config/sl_device_init_lfxo_config.h @@ -0,0 +1,66 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_LFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_LFXO_CONFIG_H +#define SL_DEVICE_INIT_LFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// AC-coupled buffer +// External digital clock +// Default: cmuLfxoOscMode_Crystal +#define SL_DEVICE_INIT_LFXO_MODE cmuLfxoOscMode_Crystal + +// CTUNE <0-127> +// Default: 63 +#define SL_DEVICE_INIT_LFXO_CTUNE 79 + +// LFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_LFXO_PRECISION 50 + +// Startup Timeout Delay +// +// 2 cycles +// 256 cycles +// 1K cycles +// 2K cycles +// 4K cycles +// 8K cycles +// 16K cycles +// 32K cycles +// Default: cmuLfxoStartupDelay_4KCycles +#define SL_DEVICE_INIT_LFXO_TIMEOUT cmuLfxoStartupDelay_4KCycles +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_LFXO_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_iostream_usart_vcom_config.h b/src/ncp-uart-hw/config/sl_iostream_usart_vcom_config.h new file mode 100644 index 00000000..d622f20a --- /dev/null +++ b/src/ncp-uart-hw/config/sl_iostream_usart_vcom_config.h @@ -0,0 +1,128 @@ +/***************************************************************************//** + * @file + * @brief IOSTREAM_USART Config. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_IOSTREAM_USART_VCOM_CONFIG_H +#define SL_IOSTREAM_USART_VCOM_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// USART settings + +// Baud rate +// Default: 115200 +#define SL_IOSTREAM_USART_VCOM_BAUDRATE 115200 + +// Parity mode to use +// No Parity +// Even parity +// Odd parity +// Default: usartNoParity +#define SL_IOSTREAM_USART_VCOM_PARITY usartNoParity + +// Number of stop bits to use. +// 0.5 stop bits +// 1 stop bits +// 1.5 stop bits +// 2 stop bits +// Default: usartStopbits1 +#define SL_IOSTREAM_USART_VCOM_STOP_BITS usartStopbits1 + +// Flow control +// None +// CTS +// RTS +// CTS/RTS +// Software Flow control (XON/XOFF) +// Default: usartHwFlowControlNone +#define SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE usartHwFlowControlCtsAndRts + +// Receive buffer size +// Default: 32 +#define SL_IOSTREAM_USART_VCOM_RX_BUFFER_SIZE 32 + +// Convert \n to \r\n +// It can be changed at runtime using the C API. +// Default: 0 +#define SL_IOSTREAM_USART_VCOM_CONVERT_BY_DEFAULT_LF_TO_CRLF 0 + +// Restrict the energy mode to allow the reception. +// Default: 1 +// Limits the lowest energy mode the system can sleep to in order to keep the reception on. May cause higher power consumption. +#define SL_IOSTREAM_USART_VCOM_RESTRICT_ENERGY_MODE_TO_ALLOW_RECEPTION 1 + +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_IOSTREAM_USART_VCOM +// $[USART_SL_IOSTREAM_USART_VCOM] +#ifndef SL_IOSTREAM_USART_VCOM_PERIPHERAL +#define SL_IOSTREAM_USART_VCOM_PERIPHERAL USART0 +#endif +#ifndef SL_IOSTREAM_USART_VCOM_PERIPHERAL_NO +#define SL_IOSTREAM_USART_VCOM_PERIPHERAL_NO 0 +#endif + +// USART0 TX on PA05 +#ifndef SL_IOSTREAM_USART_VCOM_TX_PORT +#define SL_IOSTREAM_USART_VCOM_TX_PORT gpioPortA +#endif +#ifndef SL_IOSTREAM_USART_VCOM_TX_PIN +#define SL_IOSTREAM_USART_VCOM_TX_PIN 5 +#endif + +// USART0 RX on PA06 +#ifndef SL_IOSTREAM_USART_VCOM_RX_PORT +#define SL_IOSTREAM_USART_VCOM_RX_PORT gpioPortA +#endif +#ifndef SL_IOSTREAM_USART_VCOM_RX_PIN +#define SL_IOSTREAM_USART_VCOM_RX_PIN 6 +#endif + +// USART0 CTS on PC03 +#ifndef SL_IOSTREAM_USART_VCOM_CTS_PORT +#define SL_IOSTREAM_USART_VCOM_CTS_PORT gpioPortC +#endif +#ifndef SL_IOSTREAM_USART_VCOM_CTS_PIN +#define SL_IOSTREAM_USART_VCOM_CTS_PIN 3 +#endif + +// USART0 RTS on PC02 +#ifndef SL_IOSTREAM_USART_VCOM_RTS_PORT +#define SL_IOSTREAM_USART_VCOM_RTS_PORT gpioPortC +#endif +#ifndef SL_IOSTREAM_USART_VCOM_RTS_PIN +#define SL_IOSTREAM_USART_VCOM_RTS_PIN 2 +#endif +// [USART_SL_IOSTREAM_USART_VCOM]$ +// <<< sl:end pin_tool >>> + +#endif diff --git a/src/ncp-uart-hw/config/sl_iostream_vuart_config.h b/src/ncp-uart-hw/config/sl_iostream_vuart_config.h new file mode 100644 index 00000000..82889008 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_iostream_vuart_config.h @@ -0,0 +1,42 @@ +/***************************************************************************//** + * @file + * @brief SL_IOSTREAM_VUART Config. + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ +#ifndef SL_IOSTREAM_VUART_CONFIG_H +#define SL_IOSTREAM_VUART_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// VUART settings +// Receive buffer size +// Default: 32 +#define SL_IOSTREAM_VUART_RX_BUFFER_SIZE 32 + +// +// <<< end of configuration section >>> +#endif diff --git a/src/ncp-uart-hw/config/sl_legacy_hal_wdog_config.h b/src/ncp-uart-hw/config/sl_legacy_hal_wdog_config.h new file mode 100644 index 00000000..86a5c629 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_legacy_hal_wdog_config.h @@ -0,0 +1,88 @@ +/***************************************************************************//** + * @file sl_legacy_hal_wdog_config.h + * @brief Legacy HAL watchdog configuration file. + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_LEGACY_HAL_WDOG_CONFIG_H +#define SL_LEGACY_HAL_WDOG_CONFIG_H + +// Legacy HAL WDOG Configurations + +// Disable calling halInternalEnableWatchDog in base-replacement.c's halInit(). +// Default: 0 +#define SL_LEGACY_HAL_DISABLE_WATCHDOG 0 +// + +// WDOG to use for SL_LEGACY_HAL_WDOGn. +// Default: 0 +// <0=> WDOG0 +// <1=> WDOD1 +#define SL_LEGACY_HAL_WDOGn 0 + +// Period for SL_LEGACY_HAL_WDOG timeout. +// Default: wdogPeriod_64k +// The default period of wdogPeriod_64k will trigger watchdog reset after 2 seconds (64k / 32k) and warning interrupt is triggered after 1.5 seconds (75% of timeout). +// wdogPeriod_9 / 9 clock periods +// wdogPeriod_17 / 17 clock periods +// wdogPeriod_33 / 33 clock periods +// wdogPeriod_65 / 65 clock periods +// wdogPeriod_129 / 129 clock periods +// wdogPeriod_257 / 257 clock periods +// wdogPeriod_513 / 513 clock periods +// wdogPeriod_1k / 1025 clock periods +// wdogPeriod_2k / 2049 clock periods +// wdogPeriod_4k / 4097 clock periods +// wdogPeriod_8k / 8193 clock periods +// wdogPeriod_16k / 16385 clock periods +// wdogPeriod_32k / 32769 clock periods +// wdogPeriod_64k / 65537 clock periods +// wdogPeriod_128k / 131073 clock periods +// wdogPeriod_256k / 262145 clock periods +#define SL_LEGACY_HAL_WDOG_PERIOD wdogPeriod_64k + +// Warning for SL_LEGACY_HAL_WDOG timeout. +// Default: wdogWarnTime75pct +// The default warning of wdogWarnTime75pct will trigger warning interrupt after 1.5 seconds (75% of timeout) if the period is wdogPeriod_64k. +// wdogWarnDisable / Watchdog warning period is disabled +// wdogWarnTime25pct / Watchdog warning period is 25% of the timeout +// wdogWarnTime50pct / Watchdog warning period is 50% of the timeout +// wdogWarnTime75pct / Watchdog warning period is 75% of the timeout +#define SL_LEGACY_HAL_WDOG_WARNING wdogWarnTime75pct + +// Counter keeps running during debug halt. +// Default: 0 +#define SL_LEGACY_HAL_WDOG_DEBUG_RUN 0 +// + +// + +#endif /* SL_LEGACY_HAL_WDOG_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_mbedtls_config.h b/src/ncp-uart-hw/config/sl_mbedtls_config.h new file mode 100644 index 00000000..39b51496 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_mbedtls_config.h @@ -0,0 +1,118 @@ +#ifndef SL_MBEDTLS_CONFIG_H +#define SL_MBEDTLS_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// TLS/DTLS configuration + +// Complete list of ciphersuites to use, in order of preference. +// Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 +// Complete list of ciphersuites to use, in order of preference. +// The value of this configuration should be updated for the application needs. +#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + +// Maximum TLS/DTLS fragment length in bytes (input). +// Default: 768 +// The size configured here determines the size of the internal I/O +// buffer used in mbedTLS when receiving data. +#define SL_MBEDTLS_SSL_IN_CONTENT_LEN 768 + +// Maximum TLS/DTLS fragment length in bytes (output). +// Default: 768 +// The size configured here determines the size of the internal I/O +// buffer used in mbedTLS when sending data. +#define SL_MBEDTLS_SSL_OUT_CONTENT_LEN 768 + +// Enable support for RFC 6066 max_fragment_length extension in SSL. +// Default: 1 +// Enable support for RFC 6066 max_fragment_length extension in SSL. +#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1 + +// Enable support for exporting key block and master secret. +// Default: 1 +// Enable support for exporting key block and master secret. +// This is required for certain users of TLS, e.g. EAP-TLS. +#define SL_MBEDTLS_SSL_EXPORT_KEYS 1 + +// Enable the PSK based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the PSK based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 0 + +// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0 + +// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 0 + +// Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED 0 + +// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0 + +// Enable parsing of the compressed curves. +// Default: 0 +// Enable parsing of the compressed curves. +#define SL_MBEDTLS_ECP_ENABLE_COMPRESSED_CURVE_PARSING 0 + +// + +// RSA configuration + +// Disable use of the Chinese Remainder Theorem for RSA. +// Default: 0 +// Disable use of the Chinese Remainder Theorem for RSA private key +// computations. +#define SL_MBEDTLS_RSA_NO_CRT 0 + +// + +// Miscellaneous configuration + +// Enable Silicon Labs' Mbed TLS- and PSA Crypto drivers. +// Default: 1 +// Enable drivers for hardware acceleration (Mbed TLS and PSA Crypto) and +// secure key handling (PSA Crypto). +#define SL_MBEDTLS_DRIVERS_ENABLED 1 + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Sub-files + +#if defined(SLI_MBEDTLS_CONFIG_AUTOGEN_OVERRIDE_FILE) + #include SLI_MBEDTLS_CONFIG_AUTOGEN_OVERRIDE_FILE +#else + #include "sli_mbedtls_config_autogen.h" +#endif + +#include "sli_mbedtls_omnipresent.h" + +#if SL_MBEDTLS_DRIVERS_ENABLED + #include "sli_mbedtls_acceleration.h" +#endif + +#include "sl_mbedtls_device_config.h" + +// Include transformation logic to apply CMSIS-config configuration options to +// the correct Mbed TLS / PSA Crypto options. +#include "sli_mbedtls_config_transform_autogen.h" + +// Included for backward compatibility reasons. +#include "mbedtls/build_info.h" + +#endif // SL_MBEDTLS_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_mbedtls_device_config.h b/src/ncp-uart-hw/config/sl_mbedtls_device_config.h new file mode 100644 index 00000000..33c34c42 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_mbedtls_device_config.h @@ -0,0 +1,72 @@ +#ifndef SL_MBEDTLS_DEVICE_CONFIG_H +#define SL_MBEDTLS_DEVICE_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// Secure Engine (SE) version configuration + +// Support SE firmware versions older than 1.2.2 <0-1> +// Enable software fallback for ECDH and ECC public key validation on xG21 +// devices running SE firmware versions lower than 1.2.2. +// +// Due to other stability concerns, it is strongly recommended to upgrade +// these devices to the latest firmware revision instead of turning on +// software fallback support. +// +// Not having fallback support will make ECDH operations, as well as PSA +// Crypto public key import, return an error code on affected devices. +// +// Default: 0 +#define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 0 + +// Assume an SE firmware version newer than 1.2.2 <0-1> +// For enhanced performance: if it is guaranteed that all devices on which +// this library will run are updated to at least SE FW 1.2.2, then turning +// on this option will remove certain fallback checks, thereby reducing the +// amount of processing required for ECDH and public key verification +// operations. +// Default: 0 +#define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 0 + +// Assume an SE firmware version that is unaffected by Ed25519 errata <0-1> +// For minimal code size and performance savings: if it is guaranteed that +// none of the devices running this library has SE FWs in the range +// [1.2.2, 1.2.8], then enabling this option will disable runtime version +// checks. +// Default: 0 +#define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 0 + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Additional SE version related logic (DO NOT MODIFY) + +// SL_SE_ASSUME_FW_AT_LEAST_1_2_10 is no longer in use, however, it is kept here +// for backwards compatibility. */ +#if defined(SL_SE_ASSUME_FW_AT_LEAST_1_2_10) + #undef SL_SE_ASSUME_FW_AT_LEAST_1_2_2 + #define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1 + #undef SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA + #define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 1 +#endif + +// SLI_SE_SUPPORT_FW_PRIOR_TO_1_2_2 is no longer in use, however, it is kept +// here for backwards compatibility. */ +#if defined(SLI_SE_SUPPORT_FW_PRIOR_TO_1_2_2) + #undef SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 + #define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 1 +#endif + +// SLI_SE_ASSUME_FW_AT_LEAST_1_2_2 is no longer in use, however, it is kept +// here for backwards compatibility. */ +#if defined(SLI_SE_ASSUME_FW_AT_LEAST_1_2_2) + #undef SL_SE_ASSUME_FW_AT_LEAST_1_2_2 + #define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1 +#endif + +#endif // SL_MBEDTLS_DEVICE_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_memory_config.h b/src/ncp-uart-hw/config/sl_memory_config.h new file mode 100644 index 00000000..b43ebcba --- /dev/null +++ b/src/ncp-uart-hw/config/sl_memory_config.h @@ -0,0 +1,28 @@ +#ifndef SL_MEMORY_CONFIG_H +#define SL_MEMORY_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Memory configuration + +// Stack size for the application. +// Default: 4096 +// The stack size configured here will be used by the stack that the +// application uses when coming out of a reset. +#ifndef SL_STACK_SIZE + #define SL_STACK_SIZE 4096 +#endif + +// Minimum heap size for the application. +// Default: 2048 +// Note that this value will configure the c heap which is normally used by +// malloc() and free() from the c library. The value defines a minimum heap +// size that is guaranteed to be available. The available heap may be larger +// to make use of any memory that would otherwise remain unused. +#ifndef SL_HEAP_SIZE + #define SL_HEAP_SIZE 2048 +#endif + +// +// <<< end of configuration section >>> + +#endif diff --git a/src/ncp-uart-hw/config/sl_power_manager_config.h b/src/ncp-uart-hw/config/sl_power_manager_config.h new file mode 100644 index 00000000..a97fb038 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_power_manager_config.h @@ -0,0 +1,64 @@ +/***************************************************************************//** + * @file + * @brief Power Manager configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_POWER_MANAGER_CONFIG_H +#define SL_POWER_MANAGER_CONFIG_H + +// Power Manager Configuration + +// Enable custom IRQ handler for external HF oscillator. +// Enable if CMU_IRQHandler/HFXO0_IRQHandler is needed from your application. +// The function sl_power_manager_irq_handler() will have to be called from you custom handler if this is enabled. +// Default: 0 +#define SL_POWER_MANAGER_CUSTOM_HF_OSCILLATOR_IRQ_HANDLER 0 + +// Enable fast wakeup (disable voltage scaling in EM2/3 mode) +// Enable or disable voltage scaling in EM2/3 modes (when available). This decreases wakeup time by about 30 us. +// Deprecated. It is replaced by the function sl_power_manager_em23_voltage_scaling_enable_fast_wakeup() +// Default: 0 +#define SL_POWER_MANAGER_CONFIG_VOLTAGE_SCALING_FAST_WAKEUP 0 + +// Enable debugging feature +// Enable or disable debugging features (trace the different modules that have requirements). +// Default: 0 +#define SL_POWER_MANAGER_DEBUG 0 + +// Maximum numbers of requirements that can be logged +// Default: 10 +#define SL_POWER_MANAGER_DEBUG_POOL_SIZE 10 +// + +// + +#endif /* SL_POWER_MANAGER_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_rail_util_pa_config.h b/src/ncp-uart-hw/config/sl_rail_util_pa_config.h new file mode 100644 index 00000000..357f4296 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_rail_util_pa_config.h @@ -0,0 +1,81 @@ +/***************************************************************************//** + * @file + * @brief Power Amplifier configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_PA_CONFIG_H +#define SL_RAIL_UTIL_PA_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// PA Configuration +// Initial PA Power (deci-dBm, 100 = 10.0 dBm) +// Default: 100 +#define SL_RAIL_UTIL_PA_POWER_DECI_DBM 100 +// PA Ramp Time (microseconds) +// <0-65535:1> +// Default: 10 +#define SL_RAIL_UTIL_PA_RAMP_TIME_US 10 +// Milli-volts on PA supply pin (PA_VDD) +// <0-65535:1> +// Default: 3300 +#define SL_RAIL_UTIL_PA_VOLTAGE_MV 1800 +// 2.4 GHz PA Selection +// Highest Possible +// High Power (chip-specific) +// Medium Power (chip-specific) +// Low Power +// Disable +// Default: RAIL_TX_POWER_MODE_2P4GIG_HIGHEST +#define SL_RAIL_UTIL_PA_SELECTION_2P4GHZ RAIL_TX_POWER_MODE_2P4GIG_HIGHEST +// Sub-1 GHz PA Selection +// Disable +// Default: RAIL_TX_POWER_MODE_NONE +#define SL_RAIL_UTIL_PA_SELECTION_SUBGHZ RAIL_TX_POWER_MODE_NONE +// + +// PA Curve Configuration +// Header file containing custom PA curves +// Default: "pa_curves_efr32.h" +#define SL_RAIL_UTIL_PA_CURVE_HEADER "pa_curves_efr32.h" +// Header file containing PA curve types +// Default: "pa_curve_types_efr32.h" +#define SL_RAIL_UTIL_PA_CURVE_TYPES "pa_curve_types_efr32.h" +// + +// PA Calibration Configuration +// Apply PA Calibration Factory Offset +// Default: 1 +#define SL_RAIL_UTIL_PA_CALIBRATION_ENABLE 1 +// + +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_PA_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_rail_util_power_manager_init_config.h b/src/ncp-uart-hw/config/sl_rail_util_power_manager_init_config.h new file mode 100644 index 00000000..cbc69f24 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_rail_util_power_manager_init_config.h @@ -0,0 +1,44 @@ +/***************************************************************************//** + * @file + * @brief RAIL power manager configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H +#define SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// RAIL power manager configuration + +// Enable RAIL power manager initialization +// Default: 1 +#define SL_RAIL_UTIL_RAIL_POWER_MANAGER_INIT 1 + +// +// <<< end of configuration section >>> +#endif // SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_rail_util_pti_config.h b/src/ncp-uart-hw/config/sl_rail_util_pti_config.h new file mode 100644 index 00000000..de9d71ae --- /dev/null +++ b/src/ncp-uart-hw/config/sl_rail_util_pti_config.h @@ -0,0 +1,82 @@ +/***************************************************************************//** + * @file + * @brief Packet Trace Information configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_PTI_CONFIG_H +#define SL_RAIL_UTIL_PTI_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> +// PTI Configuration + +// PTI mode +// UART +// UART onewire +// SPI +// Disabled +// Default: RAIL_PTI_MODE_UART +#define SL_RAIL_UTIL_PTI_MODE RAIL_PTI_MODE_UART + +// PTI Baud Rate (Hertz) +// <147800-20000000:1> +// Default: 1600000 +#define SL_RAIL_UTIL_PTI_BAUD_RATE_HZ 1600000 + +// +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_RAIL_UTIL_PTI +// $[PTI_SL_RAIL_UTIL_PTI] +#ifndef SL_RAIL_UTIL_PTI_PERIPHERAL +#define SL_RAIL_UTIL_PTI_PERIPHERAL PTI +#endif + +// PTI DOUT on PC04 +#ifndef SL_RAIL_UTIL_PTI_DOUT_PORT +#define SL_RAIL_UTIL_PTI_DOUT_PORT gpioPortC +#endif +#ifndef SL_RAIL_UTIL_PTI_DOUT_PIN +#define SL_RAIL_UTIL_PTI_DOUT_PIN 4 +#endif + +// PTI DFRAME on PC05 +#ifndef SL_RAIL_UTIL_PTI_DFRAME_PORT +#define SL_RAIL_UTIL_PTI_DFRAME_PORT gpioPortC +#endif +#ifndef SL_RAIL_UTIL_PTI_DFRAME_PIN +#define SL_RAIL_UTIL_PTI_DFRAME_PIN 5 +#endif + +// [PTI_SL_RAIL_UTIL_PTI]$ + +// <<< sl:end pin_tool >>> + +#endif // SL_RAIL_UTIL_PTI_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_rail_util_rf_path_config.h b/src/ncp-uart-hw/config/sl_rail_util_rf_path_config.h new file mode 100644 index 00000000..ca5be91c --- /dev/null +++ b/src/ncp-uart-hw/config/sl_rail_util_rf_path_config.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_RF_PATH_CONFIG_H +#define SL_RAIL_UTIL_RF_PATH_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// Chip-internal RF Path Configuration +// RF Path Mode +// Path 0 +// Path 1 +// Default: RAIL_ANTENNA_1 +#define SL_RAIL_UTIL_RF_PATH_INT_RF_PATH_MODE RAIL_ANTENNA_1 +// + +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_RF_PATH_CONFIG_H diff --git a/src/ncp-uart-hw/config/sl_sleeptimer_config.h b/src/ncp-uart-hw/config/sl_sleeptimer_config.h new file mode 100644 index 00000000..8344ef5f --- /dev/null +++ b/src/ncp-uart-hw/config/sl_sleeptimer_config.h @@ -0,0 +1,82 @@ +/***************************************************************************//** + * @file + * @brief Sleep Timer configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_SLEEPTIMER_CONFIG_H +#define SL_SLEEPTIMER_CONFIG_H + +#define SL_SLEEPTIMER_PERIPHERAL_DEFAULT 0 +#define SL_SLEEPTIMER_PERIPHERAL_RTCC 1 +#define SL_SLEEPTIMER_PERIPHERAL_PRORTC 2 +#define SL_SLEEPTIMER_PERIPHERAL_RTC 3 +#define SL_SLEEPTIMER_PERIPHERAL_SYSRTC 4 +#define SL_SLEEPTIMER_PERIPHERAL_BURTC 5 +#define SL_SLEEPTIMER_PERIPHERAL_WTIMER 6 +#define SL_SLEEPTIMER_PERIPHERAL_TIMER 7 + +// Timer Peripheral Used by Sleeptimer +// Default (auto select) +// RTCC +// Radio internal RTC (PRORTC) +// RTC +// SYSRTC +// Back-Up RTC (BURTC) +// WTIMER +// TIMER +// Selection of the Timer Peripheral Used by the Sleeptimer +#define SL_SLEEPTIMER_PERIPHERAL SL_SLEEPTIMER_PERIPHERAL_DEFAULT + +// TIMER/WTIMER Instance Used by Sleeptimer (not applicable for other peripherals) +// Make sure TIMER instance size is 32bits. Check datasheet for 32bits TIMERs. +// Default: 0 +#define SL_SLEEPTIMER_TIMER_INSTANCE 0 + +// Enable wallclock functionality +// Enable or disable wallclock functionalities (get_time, get_date, etc). +// Default: 0 +#define SL_SLEEPTIMER_WALLCLOCK_CONFIG 0 + +// Timer frequency divider (not applicable for WTIMER/TIMER) +// WTIMER/TIMER peripherals are always prescaled to 1024. +// Default: 1 +#define SL_SLEEPTIMER_FREQ_DIVIDER 1 + +// If Radio internal RTC (PRORTC) HAL is used, determines if it owns the IRQ handler. Enable, if no wireless stack is used. +// Default: 0 +#define SL_SLEEPTIMER_PRORTC_HAL_OWNS_IRQ_HANDLER 0 + +// Enable DEBUGRUN functionality on hardware RTC. +// Default: 0 +#define SL_SLEEPTIMER_DEBUGRUN 0 + +#endif /* SLEEPTIMER_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_token_manager_config.h b/src/ncp-uart-hw/config/sl_token_manager_config.h new file mode 100644 index 00000000..d99e78e0 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_token_manager_config.h @@ -0,0 +1,54 @@ +/***************************************************************************//** + * @file + * @brief Token Manager Configurations + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_TOKEN_MANAGER_CONFIG_H +#define SL_TOKEN_MANAGER_CONFIG_H + +// TOKEN MANAGER Configurations + +// Enable Custom Tokens +// Default: 0 +#define SL_TOKEN_MANAGER_CUSTOM_TOKENS_PRESENT 0 + +// File containing custom tokens +// Default: "sl_custom_token_header.h" +// Header file containing custom tokens located at project_root/config +#define SL_TOKEN_MANAGER_CUSTOM_TOKEN_HEADER "sl_custom_token_header.h" + +// + +// Enable Custom Manufacturing Tokens +// Default: 0 +#define SL_TOKEN_MANAGER_CUSTOM_MANUFACTURING_TOKENS_PRESENT 0 + +// File containing custom manufacturing tokens +// Default: "sl_custom_manufacturing_token_header.h" +// Header file containing custom tokens located at project_root/config +#define SL_TOKEN_MANAGER_CUSTOM_MANUFACTURING_TOKEN_HEADER "sl_custom_manufacturing_token_header.h" + +// +// + +#if (SL_TOKEN_MANAGER_CUSTOM_MANUFACTURING_TOKENS_PRESENT) +#define APPLICATION_MFG_TOKEN_HEADER SL_TOKEN_MANAGER_CUSTOM_MANUFACTURING_TOKEN_HEADER +#endif // SL_TOKEN_MANAGER_CUSTOM_MANUFACTURING_TOKENS_PRESENT + +#endif // SL_TOKEN_MANAGER_CONFIG_H + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_zigbee_debug_print_config.h b/src/ncp-uart-hw/config/sl_zigbee_debug_print_config.h new file mode 100644 index 00000000..9c901f40 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_zigbee_debug_print_config.h @@ -0,0 +1,74 @@ +/***************************************************************************//** + * @brief ZigBee Debug Print component configuration header. + * + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +// ZigBee Debug Print configuration + +// Stack group enabled +// Default: 1 +// If this option is enabled, prints belonging to the "stack" group shall be included in the build. +#define SL_ZIGBEE_DEBUG_STACK_GROUP_ENABLED (1) + +// Stack group runtime default +// Default: 1 +// If this option is enabled, prints belonging to the "stack" group shall be runtime enabled by default. +#define SL_ZIGBEE_DEBUG_STACK_GROUP_RUNTIME_DEFAULT (1) + +// Core group enabled +// Default: 1 +// If this option is enabled, prints belonging to the "core" group shall be included in the build. +#define SL_ZIGBEE_DEBUG_CORE_GROUP_ENABLED (1) + +// Core group runtime default +// Default: 1 +// If this option is enabled, prints belonging to the "core" group shall be runtime enabled by default. +#define SL_ZIGBEE_DEBUG_CORE_GROUP_RUNTIME_DEFAULT (1) + +// App group enabled +// Default: 1 +// If this option is enabled, prints belonging to the "app" group shall be included in the build. +#define SL_ZIGBEE_DEBUG_APP_GROUP_ENABLED (1) + +// App group enabled +// Default: 1 +// If this option is enabled, prints belonging to the "app" group shall be runtime enabled by default. +#define SL_ZIGBEE_DEBUG_APP_GROUP_RUNTIME_DEFAULT (1) + +// ZCL group enabled +// Default: 1 +// If this option is enabled, prints belonging to the "zcl" group shall be included in the build. +#define SL_ZIGBEE_DEBUG_ZCL_GROUP_ENABLED (1) + +// ZCL group enabled +// Default: 1 +// If this option is enabled, prints belonging to the "zcl" group shall be runtime enabled by default. +#define SL_ZIGBEE_DEBUG_ZCL_GROUP_RUNTIME_DEFAULT (1) + +// Legacy App Framework Debug group enabled +// Default: 0 +// If both this option and ZIGBEE_DEBUG_ZCL_GROUP_ENABLED are enabled, prints belonging to the "legacy app framework debug" group shall be included in the build. +#define SL_ZIGBEE_DEBUG_PRINTS_ZCL_LEGACY_AF_DEBUG_ENABLED (0) + +// Legacy App Framework Debug runtime default +// Default: 0 +// If both this option and ZIGBEE_DEBUG_ZCL_GROUP_ENABLED are enabled, prints belonging to the "legacy app framework debug" group shall be runtime enabled by default. +#define SL_ZIGBEE_DEBUG_PRINTS_ZCL_LEGACY_AF_DEBUG_RUNTIME_DEFAULT (0) + +// + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_zigbee_green_power_config.h b/src/ncp-uart-hw/config/sl_zigbee_green_power_config.h new file mode 100644 index 00000000..3d62c926 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_zigbee_green_power_config.h @@ -0,0 +1,53 @@ +/***************************************************************************//** + * @brief Zigbee Green Power component configuration header. + *\n******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Zigbee Green Power Library configuration + +// Green Power Proxy Table Size <1-126> +// Default: 5 +// The maximum number of Green Power proxy table entries supported by the stack. +#define EMBER_GP_PROXY_TABLE_SIZE 5 + +// Green Power Sink Table Size <0-126> +// Default: 0 +// The maximum number of Green Power sink table entries supported by the stack. +#define EMBER_GP_SINK_TABLE_SIZE 0 + +// Green Power incoming FC (as part of proxy table) Token timeout <0-60> +// Default: 0 +// The timeout (seconds) to restore the GPD incoming security frame counter in the Flash (0 being never). +#define EMBER_GP_INCOMING_FC_TOKEN_TIMEOUT 7 + +// Green Power incoming FC (as part of proxy table) table token table size <0-126> +// Default: 0 +// The maximum table size to restore the GPD incoming security frame counter in the Flash (being either 0 or EMBER_GP_PROXY_TABLE_SIZE). +#define EMBER_GP_INCOMING_FC_TOKEN_TABLE_SIZE 0 + +// Green Power incoming FC (as part of sink table) token table token timeout <0-60> +// Default: 0 +// The timeout (seconds) to restore the GPD incoming security frame counter in the Flash (0 being never). +#define EMBER_GP_INCOMING_FC_IN_SINK_TOKEN_TIMEOUT 7 + +// Green Power incoming FC (as part of sink table)Token table size <0-126> +// Default: 0 +// The maximum table size to restore the GPD incoming security frame counter in the Flash (being either 0 or EMBER_GP_SINK_TABLE_SIZE). +#define EMBER_GP_INCOMING_FC_IN_SINK_TOKEN_TABLE_SIZE 0 + +// + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_zigbee_light_link_config.h b/src/ncp-uart-hw/config/sl_zigbee_light_link_config.h new file mode 100644 index 00000000..7be64b76 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_zigbee_light_link_config.h @@ -0,0 +1,38 @@ +/***************************************************************************//** + * @brief ZigBee Light Link component configuration header. + *\n******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Zigbee ZigBee Light Link Library configuration + +// Group addresses <0-255> +// Default: 0 +// The number of unique group identifiers that this device requires. +#define EMBER_ZLL_GROUP_ADDRESSES 0 + +// RSSI threshold <-128..127:1> +// Default: -40 +// The RSSI threshold applied to incoming scan requests. The stack will ignore scan requests with corrected RSSI values less than this threshold. +#define EMBER_ZLL_RSSI_THRESHOLD -40 + +// Apply RSSI threshold to all interpan messages +// Default: FALSE +// True if the RSSI threshold is to be applied to all incoming touchlink interpan messages. This is not required by the Zigbee 3.0 specifications, but may be useful for testing in a busy environment. +#define EMBER_ZLL_APPLY_THRESHOLD_TO_ALL_INTERPANS 0 + +// + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_zigbee_pro_stack_config.h b/src/ncp-uart-hw/config/sl_zigbee_pro_stack_config.h new file mode 100644 index 00000000..af7419ab --- /dev/null +++ b/src/ncp-uart-hw/config/sl_zigbee_pro_stack_config.h @@ -0,0 +1,101 @@ +/***************************************************************************//** + * @brief ZigBee PRO Full Stack component configuration header. + *\n******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +// <<< Use Configuration Wizard in Context Menu >>> + +// Zigbee PRO Stack Library configuration + +// Child Table Size <0-64> +// Default: 6 +// The maximum number of ZigBee PRO End Devices that can be supported by a single device. +#define EMBER_MAX_END_DEVICE_CHILDREN 32 + +// Packet Buffer Count <20-255> +// Default: 75 +// The maximum number of packet buffers supported by the system. This is limited by the amount of available RAM. +#define EMBER_PACKET_BUFFER_COUNT 255 + +// End Device keep alive support mode +// End Device keep alive support mode +// MAC Data Poll Keep Alive +// End Device Timeout Keep Alive +// Keep Alive Support All +// Default: EMBER_KEEP_ALIVE_SUPPORT_ALL +// End Device keep alive support mode on the coordinator/router could be set here. +#define EMBER_END_DEVICE_KEEP_ALIVE_SUPPORT_MODE EMBER_KEEP_ALIVE_SUPPORT_ALL + +// End Device Poll Timeout Value +// End Device Poll Timeout Value +// Seconds-10 +// Minutes-2 +// Minutes-4 +// Minutes-8 +// Minutes-16 +// Minutes-32 +// Minutes-64 +// Minutes-128 +// Minutes-256 +// Minutes-512 +// Minutes-1024 +// Minutes-2048 +// Minutes-4096 +// Minutes-8192 +// Minutes-16384 +// Default: MINUTES_256 +// The amount of time that must pass without hearing a MAC data poll from the device before the end device is removed from the child table. For a router device this applies to its children. For an end device, this is the amount of time before it automatically times itself out. +#define EMBER_END_DEVICE_POLL_TIMEOUT MINUTES_256 + +// Link Power Delta Request Interval <1-65535> +// Default: 300 +// The amount of time in seconds that pass between link power delta requests. +#define EMBER_LINK_POWER_DELTA_INTERVAL 300 + +// APS Unicast Message Queue Size <1-255> +// Default: 10 +// The maximum number of APS unicast messages that can be queued up by the stack. A message is considered queued when emberSendUnicast() is called and is de-queued when the emberMessageSentHandler() is called. +#define EMBER_APS_UNICAST_MESSAGE_COUNT 10 + +// APS unicast Message Duplicate Rejection table Size <1-255> +// Default: 5 +// The maximum number of APS unicast messages that can be stored in the stack, to reject duplicate processing/forwarding of APS messages. +// Size of 1 is basically the same thing as no duplicate rejection +#define SL_ZIGBEE_APS_DUPLICATE_REJECTION_MAX_ENTRIES 5 + +// Broadcast Table Size <15-254> +// Default: 15 +// The size of the broadcast table. +#define EMBER_BROADCAST_TABLE_SIZE 15 + +// Neighbor Table Size +// Neighbor Table Size +// <16=> 16 +// <26=> 26 +// Default: 16 +// The size of the neighbor table. +#define EMBER_NEIGHBOR_TABLE_SIZE 16 + +// Transient key timeout (in seconds) <0-65535> +// Default: 300 +// The amount of time a device will store a transient link key that can be used to join a network. +#define EMBER_TRANSIENT_KEY_TIMEOUT_S 300 + +// Binding Table Size <1-127> +// Default: 3 +// The number of entries that the binding table can hold. +#define EMBER_BINDING_TABLE_SIZE 32 + +// + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_zigbee_security_link_keys_config.h b/src/ncp-uart-hw/config/sl_zigbee_security_link_keys_config.h new file mode 100644 index 00000000..9a0c8488 --- /dev/null +++ b/src/ncp-uart-hw/config/sl_zigbee_security_link_keys_config.h @@ -0,0 +1,33 @@ +/***************************************************************************//** + * @brief Zigbee Security Link Keys component configuration header. + *\n******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Zigbee Security Link Keys Library configuration + +// Link Key Table Size <1-127> +// Default: 6 +// The maximum number of link key table entries supported by the stack. +#define EMBER_KEY_TABLE_SIZE 12 + +// Request Key Timeout <0-10> +// Default: 0 +// The length of time that a node will wait for a trust center to answer its Application Link Key request. +#define EMBER_REQUEST_KEY_TIMEOUT 0 + +// + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/sl_zigbee_source_route_config.h b/src/ncp-uart-hw/config/sl_zigbee_source_route_config.h new file mode 100644 index 00000000..41b5e4bb --- /dev/null +++ b/src/ncp-uart-hw/config/sl_zigbee_source_route_config.h @@ -0,0 +1,33 @@ +/***************************************************************************//** + * @brief Zigbee Source Route component configuration header. + *\n******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Zigbee Source Route Library configuration + +// Source route table Size (SoC or NCP) <2-255> +// Default: 7 +// The size of the source route table for storing source routes on the SOC or NCP. +#define EMBER_SOURCE_ROUTE_TABLE_SIZE 7 + +// Max source route relay counts <11-40> +// Default: 11 +// Max source route hops accepted or/and inserted in the source route table/header. +#define EMBER_MAX_SOURCE_ROUTE_RELAY_COUNT 11 + +// + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/zigbee_sleep_config.h b/src/ncp-uart-hw/config/zigbee_sleep_config.h new file mode 100644 index 00000000..fa4efd14 --- /dev/null +++ b/src/ncp-uart-hw/config/zigbee_sleep_config.h @@ -0,0 +1,42 @@ +/***************************************************************************//** + * @brief Zigbee Application Framework common component configuration header. + *\n******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Zigbee Sleep configuration + +// Minimum Sleep Duration <5-1000> +// Default: 5 +// The minimum duration in milliseconds that the application will attempt to sleep for. If the sleep duration would be less than this amount, the application will not sleep. +#define SL_ZIGBEE_APP_FRAMEWORK_MINIMUM_SLEEP_DURATION_MS 5 + +// Sleep Backoff time <0-10000> +// Default: 0 +// This setting will keep a device from going back to sleep immediately upon waking up +#define SL_ZIGBEE_APP_FRAMEWORK_BACKOFF_SLEEP_MS 0 + +// Stay awake when NOT joined +// Default: TRUE +// This will force a device to stay awake even when not joined to the network. This is often used for debugging and is not recommended for production devices since it cause the device to consume battery power even when not joined to a ZigBee network. +#define SL_ZIGBEE_APP_FRAMEWORK_STAY_AWAKE_WHEN_NOT_JOINED 1 + +// Use button to force wakeup or allow sleep +// Default: FALSE +// This will setup the hardware buttons to wake-up or allow the device to go to sleep. Button 0 will force the device to wake up and stay awake. Button 1 will turn off this behavior to allow the device to sleep normally. Please note that in order for this option to be fully functional, button 0 and button 1 have to be configured to wake the device from sleep. +#define SL_ZIGBEE_APP_FRAMEWORK_USE_BUTTON_TO_STAY_AWAKE 0 +// + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/config/zigbee_watchdog_periodic_refresh_config.h b/src/ncp-uart-hw/config/zigbee_watchdog_periodic_refresh_config.h new file mode 100644 index 00000000..e317fedb --- /dev/null +++ b/src/ncp-uart-hw/config/zigbee_watchdog_periodic_refresh_config.h @@ -0,0 +1,34 @@ +/***************************************************************************//** + * @brief Sample watchdog refresh event component configuration header. + ******************************************************************************** + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Zigbee Watchdog reset component configuration + +// Enable periodic watchdog refresh +// Default: TRUE +// This allows for enabling or disabling periodic watchdog refresh +#define SL_ZIGBEE_WATCHDOG_PERIODIC_REFRESH_ENABLE 1 + +// Watchdog refresh duration <50-5000> +// Default: 1000 +// Defines the periodic interval at which the watchdog timer is reset in the application +#define SL_ZIGBEE_WATCHDOG_REFRESH_DURATION_MS 1000 + +// +// + +// <<< end of configuration section >>> diff --git a/src/ncp-uart-hw/gbl_metadata.yaml b/src/ncp-uart-hw/gbl_metadata.yaml new file mode 100644 index 00000000..f74de2d4 --- /dev/null +++ b/src/ncp-uart-hw/gbl_metadata.yaml @@ -0,0 +1,3 @@ +baudrate: 115200 +dynamic: [ezsp_version] +fw_type: ncp-uart-hw diff --git a/src/ncp-uart-hw/main.c b/src/ncp-uart-hw/main.c new file mode 100644 index 00000000..996b1e0b --- /dev/null +++ b/src/ncp-uart-hw/main.c @@ -0,0 +1,74 @@ +/***************************************************************************//** + * @file main.c + * @brief main() function. + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#ifdef SL_COMPONENT_CATALOG_PRESENT +#include "sl_component_catalog.h" +#endif +#include "sl_system_init.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif +#if defined(SL_CATALOG_KERNEL_PRESENT) +#include "sl_system_kernel.h" +#else +#include "sl_system_process_action.h" +#endif // SL_CATALOG_KERNEL_PRESENT + +#ifdef EMBER_TEST +#define main nodeMain +#endif + +void app_init(void) +{ +} + +void app_process_action(void) +{ +} + +int main(void) +{ + // Initialize Silicon Labs device, system, service(s) and protocol stack(s). + // Note that if the kernel is present, processing task(s) will be created by + // this call. + sl_system_init(); + + // Initialize the application. For example, create periodic timer(s) or + // task(s) if the kernel is present. + app_init(); + +#if defined(SL_CATALOG_KERNEL_PRESENT) + // Start the kernel. Task(s) created in app_init() will start running. + sl_system_kernel_start(); +#else // SL_CATALOG_KERNEL_PRESENT + while (1) { + // Do not remove this call: Silicon Labs components process action routine + // must be called from the super loop. + sl_system_process_action(); + + // Application process. + app_process_action(); + + // Let the CPU go to sleep if the system allow it. +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + sl_power_manager_sleep(); +#endif // SL_CATALOG_POWER_MANAGER_PRESENT + } +#endif // SL_CATALOG_KERNEL_PRESENT + + return 0; +} diff --git a/src/ncp-uart-hw/ncp-uart-hw.pintool b/src/ncp-uart-hw/ncp-uart-hw.pintool new file mode 100644 index 00000000..d01f3a62 --- /dev/null +++ b/src/ncp-uart-hw/ncp-uart-hw.pintool @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/ncp-uart-hw/ncp-uart-hw.slcp b/src/ncp-uart-hw/ncp-uart-hw.slcp new file mode 100644 index 00000000..b213d594 --- /dev/null +++ b/src/ncp-uart-hw/ncp-uart-hw.slcp @@ -0,0 +1,76 @@ +# Silicon Labs Project Configuration Tools: slcp, v0, Component selection file. +project_name: ncp-uart-hw +label: ncp-uart-hw +author: Silicon Laboratories, Inc. +description: This network coprocessor (NCP) application supports communication with + a host application over a UART interface with hardware flow control. This NCP application + can be built as configured, or optionally can be augmented with customized extensions + for initialization, main loop processing, event definition/handling, and messaging + with the host. To create a ECC-enabled application for the Smart Energy Profile, + please download and extract the 'EmberZnet-Smart-Energy.zip' side-package over your + installed SDK and add, depending on use-case, one of two new components ('CBKE 163k1'; + 'CBKE 283k1') to your application. +category: Zigbee Application +filter: +- name: Device Type + value: [NCP] +- name: Project Difficulty + value: [Advanced] +- name: Wireless Technology + value: [Zigbee] +package: Zigbee +quality: production +readme: +- {path: readme.html} +source: +- {path: main.c} +- {path: app.c} +tag: [prebuilt_demo] +sdk: {id: gecko_sdk, version: 4.4.0} +toolchain_settings: [] +component: +- {id: zigbee_security_link_keys} +- {id: zigbee_gp} +- {id: zigbee_debug_basic} +- {id: zigbee_app_framework_common} +- {id: brd4001a} +- instance: [vcom] + id: iostream_usart +- {id: zigbee_source_route} +- {id: zigbee_zll} +- {id: zigbee_ncp_uart_hardware} +- {id: zigbee_pro_stack} +- {id: zigbee_mfglib} +- {id: token_manager} +- {id: brd4179b} +- {id: zigbee_r22_support} +- {id: zigbee_debug_print} +- {id: zigbee_token_interface} +- {id: zigbee_debug_extended} +- {id: EFR32MG21A010F1024IM32} +- {id: iostream_vuart} +define: +- {name: EMBER_CUSTOM_MAC_FILTER_TABLE_SIZE, value: '15'} +configuration: +- {name: SL_BOARD_ENABLE_VCOM, value: '1'} +- {name: SL_IOSTREAM_USART_VCOM_FLOW_CONTROL_TYPE, value: usartHwFlowControlCtsAndRts} +- {name: SL_CLI_MAX_INPUT_ARGUMENTS, value: '16'} +- {name: EMBER_BINDING_TABLE_SIZE, value: '32'} +- {name: EMBER_MAX_END_DEVICE_CHILDREN, value: '32'} +- {name: EMBER_PACKET_BUFFER_COUNT, value: '255'} +- {name: EMBER_AF_PLUGIN_ZIGBEE_PRO_STACK_CHILD_TABLE_SIZE, value: '32'} +- {name: EMBER_KEY_TABLE_SIZE, value: '12'} +- {name: SL_CLI_EXAMPLE_IOSTREAM_HANDLE, value: sl_iostream_vuart_handle} +- condition: [device_series_1] + name: NVM3_DEFAULT_NVM_SIZE + value: '36864' +- condition: [device_series_2] + name: NVM3_DEFAULT_NVM_SIZE + value: '32768' +- {name: SL_PSA_ITS_SUPPORT_V1_DRIVER, value: '0'} +- {name: SL_PSA_ITS_SUPPORT_V2_DRIVER, value: '0'} +- {name: SL_PSA_ITS_SUPPORT_V3_DRIVER, value: '1'} +ui_hints: + highlight: + - {path: readme.html} + diff --git a/src/ncp-uart-hw/ncp-uart-hw.slps b/src/ncp-uart-hw/ncp-uart-hw.slps new file mode 100644 index 00000000..c55f6b99 --- /dev/null +++ b/src/ncp-uart-hw/ncp-uart-hw.slps @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ncp-uart-hw/ncp-uart-hw_cmake/CMakeLists.txt b/src/ncp-uart-hw/ncp-uart-hw_cmake/CMakeLists.txt new file mode 100644 index 00000000..e1ed06f1 --- /dev/null +++ b/src/ncp-uart-hw/ncp-uart-hw_cmake/CMakeLists.txt @@ -0,0 +1,64 @@ +# Define minimal required version of CMake. +cmake_minimum_required(VERSION "3.25") + +# Project definition +project( + ncp-uart-hw + VERSION 1.0 + LANGUAGES C CXX ASM +) + +# Include the definition of the slc_ncp-uart-hw target, +# which contains the content of the SLC project +include(ncp-uart-hw.cmake) + +add_executable(ncp-uart-hw + # Add additional sources here +) + +target_include_directories(ncp-uart-hw PUBLIC + # Add additional include paths here +) + +target_compile_definitions(ncp-uart-hw PUBLIC + # Add additional macros here +) + +target_compile_options(ncp-uart-hw PUBLIC + # Set additional compiler flags here +) + +target_link_options(ncp-uart-hw PUBLIC + # Set additional linker flags here +) + +# Link with the content defined in the SLC project +target_link_libraries(ncp-uart-hw PRIVATE + slc_ncp-uart-hw +) + +# Include managed project content if available +include(ncp-uart-hw_project.cmake OPTIONAL RESULT_VARIABLE managed_project) +if(managed_project) + message(STATUS "Using managed project content from ${managed_project}") +endif() + +# Force the gcc linker command +set_target_properties(ncp-uart-hw PROPERTIES LINKER_LANGUAGE C) + +# Create .bin, .hex and .s37 artifacts after building the project +add_custom_command(TARGET ncp-uart-hw + POST_BUILD + COMMAND ${CMAKE_OBJCOPY} -O srec "$" "$/$.s37" + COMMAND ${CMAKE_OBJCOPY} -O ihex "$" "$/$.hex" + COMMAND ${CMAKE_OBJCOPY} -O binary "$" "$/$.bin" +) + +# Run post-build pipeline to perform additional post-processing +if(post_build_command) +add_custom_command(TARGET ncp-uart-hw + POST_BUILD + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/.. + COMMAND ${post_build_command} +) +endif() \ No newline at end of file diff --git a/src/ncp-uart-hw/ncp-uart-hw_cmake/CMakePresets.json b/src/ncp-uart-hw/ncp-uart-hw_cmake/CMakePresets.json new file mode 100644 index 00000000..2a4fd450 --- /dev/null +++ b/src/ncp-uart-hw/ncp-uart-hw_cmake/CMakePresets.json @@ -0,0 +1,38 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 + }, + "configurePresets": [ + { + "name": "project", + "displayName": "Configure ncp-uart-hw", + "generator": "Ninja Multi-Config", + "binaryDir": "${sourceDir}/build", + "toolchainFile": "${sourceDir}/toolchain.cmake", + "cacheVariables": { + "CMAKE_CONFIGURATION_TYPES": "default_config" + } + } + ], + "buildPresets": [ + { + "name": "default_config", + "displayName": "Build ncp-uart-hw", + "configurePreset": "project", + "configuration": "default_config", + "targets": ["ncp-uart-hw"] + } + ], + "workflowPresets": [ + { + "name": "project", + "steps": [ + {"type": "configure", "name": "project"}, + {"type": "build", "name": "default_config"} + ] + } + ] + } diff --git a/src/ncp-uart-hw/ncp-uart-hw_cmake/ncp-uart-hw.cmake b/src/ncp-uart-hw/ncp-uart-hw_cmake/ncp-uart-hw.cmake new file mode 100644 index 00000000..bb872853 --- /dev/null +++ b/src/ncp-uart-hw/ncp-uart-hw_cmake/ncp-uart-hw.cmake @@ -0,0 +1,405 @@ +set(SDK_PATH "/Users/nikita/SimplicityStudio/SDKs/gecko_sdk") +set(COPIED_SDK_PATH "gecko_sdk_4.4.0") + +add_library(slc_ncp-uart-hw OBJECT + "${SDK_PATH}/hardware/board/src/sl_board_control_gpio.c" + "${SDK_PATH}/hardware/board/src/sl_board_init.c" + "${SDK_PATH}/hardware/driver/configuration_over_swo/src/sl_cos.c" + "${SDK_PATH}/platform/bootloader/api/btl_interface.c" + "${SDK_PATH}/platform/bootloader/api/btl_interface_storage.c" + "${SDK_PATH}/platform/bootloader/app_properties/app_properties.c" + "${SDK_PATH}/platform/common/src/sl_assert.c" + "${SDK_PATH}/platform/common/src/sl_slist.c" + "${SDK_PATH}/platform/common/src/sl_string.c" + "${SDK_PATH}/platform/common/src/sl_syscalls.c" + "${SDK_PATH}/platform/common/toolchain/src/sl_memory.c" + "${SDK_PATH}/platform/Device/SiliconLabs/EFR32MG21/Source/startup_efr32mg21.c" + "${SDK_PATH}/platform/Device/SiliconLabs/EFR32MG21/Source/system_efr32mg21.c" + "${SDK_PATH}/platform/driver/debug/src/sl_debug_swo.c" + "${SDK_PATH}/platform/emdrv/dmadrv/src/dmadrv.c" + "${SDK_PATH}/platform/emdrv/nvm3/src/nvm3_default_common_linker.c" + "${SDK_PATH}/platform/emdrv/nvm3/src/nvm3_hal_flash.c" + "${SDK_PATH}/platform/emdrv/nvm3/src/nvm3_lock.c" + "${SDK_PATH}/platform/emlib/src/em_burtc.c" + "${SDK_PATH}/platform/emlib/src/em_cmu.c" + "${SDK_PATH}/platform/emlib/src/em_core.c" + "${SDK_PATH}/platform/emlib/src/em_emu.c" + "${SDK_PATH}/platform/emlib/src/em_gpio.c" + "${SDK_PATH}/platform/emlib/src/em_ldma.c" + "${SDK_PATH}/platform/emlib/src/em_msc.c" + "${SDK_PATH}/platform/emlib/src/em_prs.c" + "${SDK_PATH}/platform/emlib/src/em_rmu.c" + "${SDK_PATH}/platform/emlib/src/em_rtcc.c" + "${SDK_PATH}/platform/emlib/src/em_se.c" + "${SDK_PATH}/platform/emlib/src/em_system.c" + "${SDK_PATH}/platform/emlib/src/em_timer.c" + "${SDK_PATH}/platform/emlib/src/em_usart.c" + "${SDK_PATH}/platform/emlib/src/em_wdog.c" + "${SDK_PATH}/platform/radio/rail_lib/plugin/coexistence/protocol/ieee802154_uc/coexistence-802154.c" + "${SDK_PATH}/platform/radio/rail_lib/plugin/pa-conversions/pa_conversions_efr32.c" + "${SDK_PATH}/platform/radio/rail_lib/plugin/pa-conversions/pa_curves_efr32.c" + "${SDK_PATH}/platform/radio/rail_lib/plugin/rail_util_ant_div/sl_rail_util_ant_div.c" + "${SDK_PATH}/platform/radio/rail_lib/plugin/rail_util_power_manager_init/sl_rail_util_power_manager_init.c" + "${SDK_PATH}/platform/radio/rail_lib/plugin/rail_util_pti/sl_rail_util_pti.c" + "${SDK_PATH}/platform/radio/rail_lib/plugin/rail_util_rf_path/sl_rail_util_rf_path.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager_attestation.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager_cipher.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager_entropy.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager_hash.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager_key_derivation.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager_key_handling.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager_signature.c" + "${SDK_PATH}/platform/security/sl_component/se_manager/src/sl_se_manager_util.c" + "${SDK_PATH}/platform/security/sl_component/sl_mbedtls_support/src/sl_mbedtls.c" + "${SDK_PATH}/platform/security/sl_component/sl_mbedtls_support/src/sl_psa_crypto.c" + "${SDK_PATH}/platform/security/sl_component/sl_mbedtls_support/src/sli_psa_crypto.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_psa_driver_common.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_psa_driver_init.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_psa_trng.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_aead.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_builtin_keys.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_cipher.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_key_derivation.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_key_management.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_mac.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_signature.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_opaque_driver_aead.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_opaque_driver_cipher.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_opaque_driver_mac.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_opaque_key_derivation.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_transparent_driver_aead.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_transparent_driver_cipher.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_transparent_driver_hash.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_transparent_driver_mac.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_transparent_key_derivation.c" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/src/sli_se_version_dependencies.c" + "${SDK_PATH}/platform/service/device_init/src/sl_device_init_emu_s2.c" + "${SDK_PATH}/platform/service/device_init/src/sl_device_init_hfrco.c" + "${SDK_PATH}/platform/service/device_init/src/sl_device_init_hfxo_s2.c" + "${SDK_PATH}/platform/service/device_init/src/sl_device_init_lfxo_s2.c" + "${SDK_PATH}/platform/service/device_init/src/sl_device_init_nvic.c" + "${SDK_PATH}/platform/service/iostream/src/sl_iostream.c" + "${SDK_PATH}/platform/service/iostream/src/sl_iostream_debug.c" + "${SDK_PATH}/platform/service/iostream/src/sl_iostream_swo_itm_8.c" + "${SDK_PATH}/platform/service/iostream/src/sl_iostream_uart.c" + "${SDK_PATH}/platform/service/iostream/src/sl_iostream_usart.c" + "${SDK_PATH}/platform/service/iostream/src/sl_iostream_vuart.c" + "${SDK_PATH}/platform/service/legacy_common_ash/src/ash-common.c" + "${SDK_PATH}/platform/service/legacy_hal/src/base-replacement.c" + "${SDK_PATH}/platform/service/legacy_hal/src/bootloader-common.c" + "${SDK_PATH}/platform/service/legacy_hal/src/bootloader-interface-app.c" + "${SDK_PATH}/platform/service/legacy_hal/src/bootloader-interface-standalone.c" + "${SDK_PATH}/platform/service/legacy_hal/src/bootloader-interface.c" + "${SDK_PATH}/platform/service/legacy_hal/src/crc.c" + "${SDK_PATH}/platform/service/legacy_hal/src/diagnostic.c" + "${SDK_PATH}/platform/service/legacy_hal/src/ember-phy.c" + "${SDK_PATH}/platform/service/legacy_hal/src/faults.s" + "${SDK_PATH}/platform/service/legacy_hal/src/random.c" + "${SDK_PATH}/platform/service/legacy_hal/src/token_legacy.c" + "${SDK_PATH}/platform/service/legacy_hal_wdog/src/sl_legacy_hal_wdog.c" + "${SDK_PATH}/platform/service/legacy_ncp_ash/src/ash-ncp.c" + "${SDK_PATH}/platform/service/legacy_printf/src/sl_legacy_printf.c" + "${SDK_PATH}/platform/service/power_manager/src/sl_power_manager.c" + "${SDK_PATH}/platform/service/power_manager/src/sl_power_manager_debug.c" + "${SDK_PATH}/platform/service/power_manager/src/sl_power_manager_hal_s2.c" + "${SDK_PATH}/platform/service/sleeptimer/src/sl_sleeptimer.c" + "${SDK_PATH}/platform/service/sleeptimer/src/sl_sleeptimer_hal_burtc.c" + "${SDK_PATH}/platform/service/sleeptimer/src/sl_sleeptimer_hal_prortc.c" + "${SDK_PATH}/platform/service/sleeptimer/src/sl_sleeptimer_hal_rtcc.c" + "${SDK_PATH}/platform/service/sleeptimer/src/sl_sleeptimer_hal_timer.c" + "${SDK_PATH}/platform/service/system/src/sl_system_init.c" + "${SDK_PATH}/platform/service/system/src/sl_system_process_action.c" + "${SDK_PATH}/platform/service/token_manager/src/sl_token_def.c" + "${SDK_PATH}/platform/service/token_manager/src/sl_token_manager.c" + "${SDK_PATH}/platform/service/token_manager/src/sl_token_manufacturing.c" + "${SDK_PATH}/platform/service/token_manager/src/sl_token_manufacturing_generic.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-binding-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-green-power-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-messaging-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-mfglib-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-networking-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-security-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-token-interface-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-token-interface.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-trust-center-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/command-handlers-zll-generated.c" + "${SDK_PATH}/protocol/zigbee/app/em260/em260-common.c" + "${SDK_PATH}/protocol/zigbee/app/em260/ncp-stack-stub.c" + "${SDK_PATH}/protocol/zigbee/app/em260/serial-interface-uart.c" + "${SDK_PATH}/protocol/zigbee/app/framework/common/zigbee_app_framework_common.c" + "${SDK_PATH}/protocol/zigbee/app/framework/common/zigbee_app_framework_sleep.c" + "${SDK_PATH}/protocol/zigbee/app/framework/common/zigbee_app_framework_stack_cb.c" + "${SDK_PATH}/protocol/zigbee/app/framework/common/zigbee_enhanced_routing.c" + "${SDK_PATH}/protocol/zigbee/app/framework/common/zigbee_ncp_framework_cb.c" + "${SDK_PATH}/protocol/zigbee/app/framework/common/zigbee_token_interface.c" + "${SDK_PATH}/protocol/zigbee/app/framework/common/zigbee_token_interface_stub.c" + "${SDK_PATH}/protocol/zigbee/app/framework/plugin/debug-print/sl_zigbee_debug_print.c" + "${SDK_PATH}/protocol/zigbee/app/util/security/security-address-cache.c" + "${SDK_PATH}/protocol/zigbee/app/xncp/xncp-stubs.c" + "${SDK_PATH}/protocol/zigbee/stack/config/ember-configuration-access.c" + "${SDK_PATH}/protocol/zigbee/stack/config/ember-configuration.c" + "${SDK_PATH}/protocol/zigbee/stack/core/ember-multi-network-stub.c" + "${SDK_PATH}/protocol/zigbee/stack/core/multi-pan-common.c" + "${SDK_PATH}/protocol/zigbee/stack/core/multi-pan-stub.c" + "${SDK_PATH}/protocol/zigbee/stack/framework/aes-ecb.c" + "${SDK_PATH}/protocol/zigbee/stack/framework/strong-random-api.c" + "${SDK_PATH}/protocol/zigbee/stack/framework/zigbee-event-logger-stub-gen.c" + "${SDK_PATH}/protocol/zigbee/stack/security/cbke-crypto-engine-163k1-stub.c" + "${SDK_PATH}/protocol/zigbee/stack/security/cbke-crypto-engine-283k1-stub.c" + "${SDK_PATH}/protocol/zigbee/stack/security/cbke-crypto-engine-dsa-sign-stub.c" + "${SDK_PATH}/protocol/zigbee/stack/security/cbke-crypto-engine-dsa-verify-283k1-stub.c" + "${SDK_PATH}/protocol/zigbee/stack/security/cbke-crypto-engine-dsa-verify-stub.c" + "${SDK_PATH}/protocol/zigbee/stack/security/cbke-crypto-engine-stub.c" + "${SDK_PATH}/protocol/zigbee/stack/security/zigbee-security-manager-no-vault.c" + "${SDK_PATH}/protocol/zigbee/stack/security/zigbee-security-manager.c" + "${SDK_PATH}/protocol/zigbee/stack/stubs/sl_zigbee_dynamic_commissioning_stubs.c" + "${SDK_PATH}/protocol/zigbee/stack/stubs/sl_zigbee_fragmentation_stubs.c" + "${SDK_PATH}/protocol/zigbee/stack/stubs/sl_zigbee_r23_misc_support_stubs.c" + "${SDK_PATH}/protocol/zigbee/stack/zigbee/aps-keys-full.c" + "${SDK_PATH}/protocol/zigbee/stack/zigbee/sli_zigbee_zdo_cluster_filter.c" + "${SDK_PATH}/util/silicon_labs/silabs_core/memory_manager/sl_malloc.c" + "${SDK_PATH}/util/third_party/mbedtls/library/cipher.c" + "${SDK_PATH}/util/third_party/mbedtls/library/cipher_wrap.c" + "${SDK_PATH}/util/third_party/mbedtls/library/constant_time.c" + "${SDK_PATH}/util/third_party/mbedtls/library/platform.c" + "${SDK_PATH}/util/third_party/mbedtls/library/platform_util.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_aead.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_cipher.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_client.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_driver_wrappers_no_static.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_ecp.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_ffdh.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_hash.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_mac.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_pake.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_rsa.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_se.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_slot_management.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_crypto_storage.c" + "${SDK_PATH}/util/third_party/mbedtls/library/psa_util.c" + "${SDK_PATH}/util/third_party/mbedtls/library/threading.c" + "${SDK_PATH}/util/third_party/printf/printf.c" + "${SDK_PATH}/util/third_party/printf/src/iostream_printf.c" + "${SDK_PATH}/util/third_party/segger/systemview/SEGGER/SEGGER_RTT.c" + "../app.c" + "../autogen/sl_board_default_init.c" + "../autogen/sl_device_init_clocks.c" + "../autogen/sl_event_handler.c" + "../autogen/sl_iostream_handles.c" + "../autogen/sl_iostream_init_usart_instances.c" + "../autogen/sl_power_manager_handler.c" + "../autogen/sl_rail_util_ieee802154_phy_select.c" + "../autogen/sl_rail_util_ieee802154_stack_event.c" + "../autogen/zigbee_common_callback_dispatcher.c" + "../autogen/zigbee_ncp_callback_dispatcher.c" + "../autogen/zigbee_stack_callback_dispatcher.c" + "../main.c" + "../sl_zigbee_watchdog_periodic_refresh.c" +) + +target_include_directories(slc_ncp-uart-hw PUBLIC + "../config" + "../autogen" + "${SDK_PATH}/platform/Device/SiliconLabs/EFR32MG21/Include" + "${SDK_PATH}/platform/common/inc" + "${SDK_PATH}/hardware/board/inc" + "${SDK_PATH}/platform/bootloader" + "${SDK_PATH}/platform/bootloader/api" + "${SDK_PATH}/platform/CMSIS/Core/Include" + "${SDK_PATH}/hardware/driver/configuration_over_swo/inc" + "${SDK_PATH}/platform/driver/debug/inc" + "${SDK_PATH}/platform/service/device_init/inc" + "${SDK_PATH}/platform/emdrv/dmadrv/inc" + "${SDK_PATH}/platform/emdrv/common/inc" + "${SDK_PATH}/platform/emlib/inc" + "${SDK_PATH}/platform/service/iostream/inc" + "${SDK_PATH}/platform/service/legacy_hal/inc" + "${SDK_PATH}/platform/service/legacy_common_ash/inc" + "${SDK_PATH}/platform/service/legacy_hal_wdog/inc" + "${SDK_PATH}/platform/service/legacy_ncp_ash/inc" + "${SDK_PATH}/platform/service/legacy_printf/inc" + "${SDK_PATH}/platform/security/sl_component/sl_mbedtls_support/config" + "${SDK_PATH}/platform/security/sl_component/sl_mbedtls_support/config/preset" + "${SDK_PATH}/platform/security/sl_component/sl_mbedtls_support/inc" + "${SDK_PATH}/util/third_party/mbedtls/include" + "${SDK_PATH}/util/third_party/mbedtls/library" + "${SDK_PATH}/platform/emdrv/nvm3/inc" + "${SDK_PATH}/platform/service/power_manager/inc" + "${SDK_PATH}/util/third_party/printf" + "${SDK_PATH}/util/third_party/printf/inc" + "${SDK_PATH}/platform/security/sl_component/sl_psa_driver/inc" + "${SDK_PATH}/platform/radio/rail_lib/common" + "${SDK_PATH}/platform/radio/rail_lib/protocol/ble" + "${SDK_PATH}/platform/radio/rail_lib/protocol/ieee802154" + "${SDK_PATH}/platform/radio/rail_lib/protocol/wmbus" + "${SDK_PATH}/platform/radio/rail_lib/protocol/zwave" + "${SDK_PATH}/platform/radio/rail_lib/chip/efr32/efr32xg2x" + "${SDK_PATH}/platform/radio/rail_lib/protocol/sidewalk" + "${SDK_PATH}/platform/radio/rail_lib/plugin/rail_util_ieee802154" + "${SDK_PATH}/platform/radio/rail_lib/plugin/pa-conversions" + "${SDK_PATH}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg21" + "${SDK_PATH}/platform/radio/rail_lib/plugin/rail_util_power_manager_init" + "${SDK_PATH}/platform/radio/rail_lib/plugin/rail_util_pti" + "${SDK_PATH}/platform/radio/rail_lib/plugin/rail_util_rf_path" + "${SDK_PATH}/platform/security/sl_component/se_manager/inc" + "${SDK_PATH}/platform/security/sl_component/se_manager/src" + "${SDK_PATH}/util/third_party/segger/systemview/SEGGER" + "${SDK_PATH}/util/silicon_labs/silabs_core/memory_manager" + "${SDK_PATH}/platform/common/toolchain/inc" + "${SDK_PATH}/platform/service/system/inc" + "${SDK_PATH}/platform/service/sleeptimer/inc" + "${SDK_PATH}/platform/service/token_manager/inc" + "${SDK_PATH}/protocol/zigbee/app/framework/common" + "${SDK_PATH}/protocol/zigbee/stack/platform/micro" + "${SDK_PATH}/protocol/zigbee/stack/framework" + "${SDK_PATH}/protocol/zigbee/app/framework/plugin/debug-print" + "${SDK_PATH}/protocol/zigbee/stack/include" + "${SDK_PATH}/protocol/zigbee/stack/gp" + "${SDK_PATH}/protocol/zigbee/app/em260" + "${SDK_PATH}/protocol/zigbee/app/xncp" + "${SDK_PATH}/protocol/zigbee/app/util/ezsp" + "${SDK_PATH}/protocol/zigbee/app/framework/util" + "${SDK_PATH}/protocol/zigbee/app/util/security" + "${SDK_PATH}/protocol/zigbee/stack/zigbee" + "${SDK_PATH}/protocol/zigbee/stack/security" + "${SDK_PATH}/platform/radio/rail_lib/plugin" + "${SDK_PATH}/protocol/zigbee" + "${SDK_PATH}/protocol/zigbee/stack" + "${SDK_PATH}/platform/radio/mac/rail_mux" + "${SDK_PATH}/platform/radio/mac" + "${SDK_PATH}/util/silicon_labs/silabs_core" + "${SDK_PATH}/protocol/zigbee/stack/core" + "${SDK_PATH}/protocol/zigbee/stack/mac" + "${SDK_PATH}/protocol/zigbee/stack/zll" +) + +target_compile_definitions(slc_ncp-uart-hw PUBLIC + "EMBER_CUSTOM_MAC_FILTER_TABLE_SIZE=15" + "EFR32MG21A010F1024IM32=1" + "SL_APP_PROPERTIES=1" + "SL_BOARD_NAME=\"BRD4179B\"" + "SL_BOARD_REV=\"A05\"" + "HARDWARE_BOARD_DEFAULT_RF_BAND_2400=1" + "HARDWARE_BOARD_SUPPORTS_1_RF_BAND=1" + "HARDWARE_BOARD_SUPPORTS_RF_BAND_2400=1" + "HFXO_FREQ=38400000" + "SL_COMPONENT_CATALOG_PRESENT=1" + "SEGGER_RTT_ALIGNMENT=1024" + "EMBER_AF_API_BOOTLOADER_INTERFACE=1" + "CORTEXM3=1" + "CORTEXM3_EFM32_MICRO=1" + "CORTEXM3_EFR32=1" + "PHY_RAIL=1" + "PLATFORM_HEADER=\"platform-header.h\"" + "SL_LEGACY_HAL_ENABLE_WATCHDOG=1" + "MBEDTLS_CONFIG_FILE=" + "SL_LEGACY_LINKER=1" + "MBEDTLS_PSA_CRYPTO_CONFIG_FILE=" + "SL_RAIL_LIB_MULTIPROTOCOL_SUPPORT=0" + "SL_RAIL_UTIL_PA_CONFIG_HEADER=" + "RTT_USE_ASM=0" + "SEGGER_RTT_SECTION=\"SEGGER_RTT\"" + "CUSTOM_TOKEN_HEADER=\"sl_token_manager_af_token_header.h\"" + "USE_NVM3=1" + "UC_BUILD=1" + "EMBER_AF_NCP=1" + "EMBER_SERIAL1_RTSCTS=1" + "EZSP_UART=1" + "EMBER_MULTI_NETWORK_STRIPPED=1" + "SL_ZIGBEE_PHY_SELECT_STACK_SUPPORT=1" + "SL_ZIGBEE_STACK_COMPLIANCE_REVISION=22" +) + +target_link_libraries(slc_ncp-uart-hw PUBLIC + "-Wl,--start-group" + "gcc" + "c" + "m" + "nosys" + "${SDK_PATH}/platform/emdrv/nvm3/lib/libnvm3_CM33_gcc.a" + "${SDK_PATH}/platform/radio/rail_lib/autogen/librail_release/librail_efr32xg21_gcc_release.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-debug-basic/release_singlenetwork/libzigbee-debug-basic.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-debug-extended/release_singlenetwork/libzigbee-debug-extended.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/ncp-gp-library/release_singlenetwork/libncp-gp-library.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-gp/release_singlenetwork/libzigbee-gp.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/ncp-mfglib-library/release_singlenetwork/libncp-mfglib-library.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-mfglib/release_singlenetwork/libzigbee-mfglib.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-ncp-uart/release_singlenetwork/libzigbee-ncp-uart.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/ncp-pro-library/release_singlenetwork/libncp-pro-library.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-pro-stack/release_singlenetwork/libzigbee-pro-stack.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-r22-support/release_singlenetwork/libzigbee-r22-support.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/ncp-source-route-library/release_singlenetwork/libncp-source-route-library.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-source-route/release_singlenetwork/libzigbee-source-route.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/ncp-zll-library/release_singlenetwork/libncp-zll-library.a" + "${SDK_PATH}/protocol/zigbee/build/gcc/cortex-m33/zigbee-zll/release_singlenetwork/libzigbee-zll.a" + "-Wl,--end-group" +) +target_compile_options(slc_ncp-uart-hw PUBLIC + $<$:-mcpu=cortex-m33> + $<$:-mthumb> + $<$:-mfpu=fpv5-sp-d16> + $<$:-mfloat-abi=hard> + $<$:-Wall> + $<$:-Wextra> + $<$:-Os> + $<$:-fdata-sections> + $<$:-ffunction-sections> + $<$:-fomit-frame-pointer> + "$<$:SHELL:-imacros sl_gcc_preinclude.h>" + $<$:-mcmse> + $<$:-fno-builtin-printf> + $<$:-fno-builtin-sprintf> + $<$:--specs=nano.specs> + $<$:-Wno-unused-parameter> + $<$:-Wno-missing-field-initializers> + $<$:-Wno-missing-braces> + $<$:-g> + $<$:-mcpu=cortex-m33> + $<$:-mthumb> + $<$:-mfpu=fpv5-sp-d16> + $<$:-mfloat-abi=hard> + $<$:-fno-rtti> + $<$:-fno-exceptions> + $<$:-Wall> + $<$:-Wextra> + $<$:-Os> + $<$:-fdata-sections> + $<$:-ffunction-sections> + $<$:-fomit-frame-pointer> + "$<$:SHELL:-imacros sl_gcc_preinclude.h>" + $<$:-mcmse> + $<$:-fno-builtin-printf> + $<$:-fno-builtin-sprintf> + $<$:--specs=nano.specs> + $<$:-Wno-unused-parameter> + $<$:-Wno-missing-field-initializers> + $<$:-Wno-missing-braces> + $<$:-g> + $<$:-mcpu=cortex-m33> + $<$:-mthumb> + $<$:-mfpu=fpv5-sp-d16> + $<$:-mfloat-abi=hard> + "$<$:SHELL:-imacros sl_gcc_preinclude.h>" + "$<$:SHELL:-x assembler-with-cpp>" +) + +set(post_build_command ) +set_property(TARGET slc_ncp-uart-hw PROPERTY C_STANDARD 99) +set_property(TARGET slc_ncp-uart-hw PROPERTY CXX_STANDARD 11) +set_property(TARGET slc_ncp-uart-hw PROPERTY CXX_EXTENSIONS OFF) + +target_link_options(slc_ncp-uart-hw INTERFACE + -mcpu=cortex-m33 + -mthumb + -mfpu=fpv5-sp-d16 + -mfloat-abi=hard + -T${CMAKE_CURRENT_LIST_DIR}/../autogen/linkerfile_base.ld + --specs=nano.specs + -Xlinker -Map=$/ncp-uart-hw.map + -Wl,--gc-sections + -Wl,--no-warn-rwx-segments +) + +# BEGIN_SIMPLICITY_STUDIO_METADATA=eJzsvQmT3TaWJvpXHIqJF7MUk8pMy+Xy2NWhktNuTUuWnlKemp5RBwOXF/deOrkVl1zUMf/9ASC4g8R2wCvNm+iOsjKT+L4PB/t2zr8/e//h3X+7efUx+PDu3cdnPzz790/PPty8efnx9X+/CYZ/+vTsh0/PLi4+Pfvfz/7Upbl99/uHVze3JNmP//SYxN/c46KMsvSnT88uL55/evYNTsNsH6VH8ovfP/7iff/p2T/99VP6Y15kf+Cw+ob8N8dF9XQbkv+Sb/jvPz0jH33zzY+HLN7j4psUJfSPYZYeoiP/G/1rFOP2b2UcJDjJiqeg+eriRMjrIiJ/op/94P9eEmV+Gt1FFfLfNzTkZ7SrQ1Qiv4xitCu9Q1QkD6jA3q6OKLWfhrlXo6LyTg9+g+yLqHyRptubX3+9+RB8+PgxeEW+dChJwCRUlN4n18EeH1AdV+4NtcAmVJaXKAiLp7zK3OsScglVkaL+HB13GAclDomY6imIo/QuuMNP5SYVTYV9SXmMjyh8Ck4oDh722XETvcucQpU8ew+oCk/0c9IXRKS7CIMCHwpcntxr1lCwZOddhoo9/a4qsngTKy8xLinc4119DMqHDdrWApukdcXR8VQ1lXvDViVklSglA1RQVijcVKiIdElnld3hNEhQio642ETkEuOSwrAuqyzhyU4YEWS3AhcIJfpIhuoDCisiKz1ur3adXlJLmyaYk6QbDPMy2iWtZYxxXkXJRtVUSLekLc8eyHdbtqIlxuU+/T4KcRClEenCDo9bde2LpJIaeSwwqcBNJjeskWJaodZ9gvbFvXtxM54lyxUoioO6Iv9Dqu0mRltiXJu7sWa12TxtyiZUhvI84AvLCG8wT1/kWyrZKCurAqMkqEuCFNyHpL/fonzXeVV6GpzUm3c0Y07ZOi2rC5KwyOoKb7pCE/MK1Q4WSc4VCrkUepzRaMSKYeMOaE2ASk09nWNMPKmNiYNsoq3tirT0FQeSotpgHS5hVSvxIjxHkY9ZhUp3Fel80woXZEZPuoeDS31CLjVVQXkVXm4prSMU6sNJHO2IaYt2ZeG8bFcYl2pgssP7Kt5mN3DOJVPFa+qW4maU0lnQPQXbdgI0pVwbp8ksKcnSAG2xHblG2Wj80W8ORUQHJKiusiNOF09Imn3Ddkeedl8XIXxWuAp/kXCpQpB5dByFqIpI1qunHLuw80CciE4o7cPHm+BVluRZitOqdKlqzrS4SdV+FZAcoDhzUikHxhLyqYzKYZyFd6XjeiYmXJKH72k+Tijdx2428wbKZlxqotyaa8Yl7aKbb53W/QU6ZWluTSaik0pj9TFKywql4XbGm7OqCW02BfqEGxl0idtM9JY2FnBLzmJ3WVbFGd3E77usQ+ZYtJR7QXQ0mW8GHNOt3DVWVaFVgdLykBXJmSQL+dWOGrYZABY5Fy3M7kxsWg3EjKsCKWQVpWcQusws32OJMMbfP7+6fPFtkJ+eghLHRI/jCqDAriW8OZ1m84pzKJ/Qi1dzUXqHC/qbYIdKfBHv3ekUca0eojSH+yiOd/Qf+6jM6YUUt7NTFW4z0Q5rgAr3mmi+sj6PqdfJDWW7N/Y6+ZpsAnomU68wmwh2b+QV5jXB6DC6G+J0ArxCKZR4ERZhu39F/ulO2IxIvlV2xOFdFpT7u+Dbi2/pTeUuA6PP8hhVdCLX/X32xc9sLj34++yL2yiOiLg3JDujz2Yf3vzy4frq7a9Xl5PP5ojssHH21XSsfiornAT4UFxfJcery/VKfBsldDssqp5uq3ofZf7tz/9S+p2Z/NYSfpNhf5ArvxPuN8p8EbUvUVuRQq3z88gVcU/1jmrTYtG8TsO43kvLpmNCzy+fHy6fX30bJddX640XJstcoL+sQFJQXcIAhUl+Fskds7pU2daAM6XjfQGp0F19CM+jtGXWkFqg5FxaObWO2OpshuXUymLDpD6PVE6sLJRuJEk3sFyJHZCrC04QSVeGRZRXmWQe6kz3TIO6/DyOzySaMytLxeeqw1izDh/KIjxTDe6olcUeczK/PY/YjlpDbHQmw7bMWlKDPCuq8+nt6JVFs6tH5xHcUWuIfTyb1kc9qdHVmZoYJ1YXivbnUsqZ1aWGKDxJbnQ4E9txK8uNySB9HrEts5bUxx0602RmyK4tmd4MitJzLc1EKtSzgNlTojMp78nVBZ9vsIi1B4v4bINFrDtYxPfH/ZmkcmZlqUl5ptGCEysLzWX72K6E5oVeL0C+D8romKL4fIKHApSFF1V4prrQMitLLXGConiXPZ5H74heXfS5Vr+l5uq3fCqlzxGcae24leWecdDVH3LrM465tf6gy66znUltS60slnoXOY/WllkmNeHX7DZVOSSVHbhNz+g21CniVjpvE/xy9qv5L6ZupOh1hrUT2ygNZye140tQqMqSCGoEbQT5hNUfQfurEnC6j1BK1i1QU4+xjDG8TEoNdRA0FVELjnlmhVESKqiea1IYHfS6hCaVEwk99LqEsqKeQpxI6KElEuKodFMOHbLMBqiq3bSHHtpf63xmfUlZSPuSpo7BXHfgogmrP4JWqjsuJPTQEglkMojiWPLswFTEAFylCjvR0CLr1Z8qy+LwhKJ0/e7QvJoJHoUyr4WwmevktdnsSXzZyK0w7i5lIijwMYLucPu88DY/45rNUcQW3kKVipxjGAZ5gaNm1uVY1pxMWgG0p279G5a16dvYH8ta7zv+Eqhl9CInnmH8OZ1eX4DyaC03o+f1LjIT+TOKld50/Nq/rLICHbeQNaRakTd8/jsoFJhGMtG3zCWxHy6KjKzjwRqvwG4jCtXidCdnRKFcu3JUlGAbQ6uVq2fSrvobqBtQSeQVuMSVwvNDG11jjtW+Ttbzv3p7+/p2rdN/lRXTW7eKV3NHpgmTMirZa/dI+jhc2TRMvE8Vdjsgc57Vwbz5nDvXdq1qQLMqqvrMfNDiR6g1n0DRmEPBRkewg41F+xzFJxhjMdSHTJhcXzsUM6RYFZPkdYCK5P57d2JGFPATv30R3a9P+pi/Hvs1Uue8GGii0gj3GWy7RBpxuFkl9RQwJT7KBp/wjzjgi5zolL2sGbj9WC95NZPNfIjA2I5nxB8Q9CYUccqWdRPniNvKXLheK3XMtq3KxfuJMpeBW8sU3zZZUwl4N0ZR5dKdmDWV6T3Y8YiiypZRv0NVGxfGDknLK6ABQpS7bpwQceq3vE2FdpS6LW9zkw5Iddvf5lpjM62sTWwqtGXUnw/MB23ubMd+UtciAZuihW3tMKSRlVLnSYjNojYS1pMpy6NhPKIqCb7fSuKIUFkmfRG+lcKWS11cuaW6Ulfe/ZbGuxdbD2rd0zVB2KlHlx0+7xjSaLb0bYT1ZBJ5kajlOdW4xGjQJW1kSzOZNdxtOqnCeuH63HJhu1cnINPsMbcy3tLlQ0mPuZG8e23rwW37qDQNs92fWe/eByqwnO/15xAe9GFoa45eKxvflhhXC0yUyEN5vr3UllVfLnV8uUdxlp7BwBNyVfH8Nt1Wcnu69dOCAnqZNpHECdathErsFZhAhTiROvKzNpKAbVXePkLHlPQ74CvaibAxz6oknOxIGecnqDtVC4pGNKuCmJ/18qJ0qabnWJVSkNaZQa+4J1J6jvVzSuatrEnrVtCUCWqRMz0YiWaj5CzTzVfA84BBdtlMgHH4PZWZz6wwKyr8mFzLsjRomU6z1erxx4RmmZtPaGb5OrkuJ/rfk2YJyWZUTgUvMZrNqDaX2rJazai2Vz0m15xRbSV36TnEskCM8yKD3hFaFtjTrQpEpWNJnGDdSnVVOS+7jkM6BXbbq4u9F03eFybXV0EShQX0CnoiZkIkmWVePT567C6dt8cH6GsJU2UCNom8JmaWPDKSvbQx06qsLQZVqQjWtxZ1XpUeK3G3ikRsq/JiDOW6YkERJ1i/nEYbwSajyJRJQRaNC+W4wU2I5KI2kCMV0qJ4KhHRbSUJyFSWnk419RzrUtp+1LGaIc36PvFmy0L59WG6WPZGce49mhSXHtRj9AWBMmZT2Y77dxmzruzN1aqcYgwCFtPx7Fg0r2ZOWQZ+IXNabeXkcOccfYRHy+MOguB0U7sXyna4xnQODvEHBE5Ke5CfZpV0Up0R0E/J0q7KwsxRByrQNiQEPWVjfkzsr1ZNAJ1trzL09jaJgNTNdZIpkav+p8ndvBMS+5qxKXkaZgSm0yFIbkqbS+y6G07kqK+h6E6Ktc1G25I5EVxR5mRIrQ5gTbiBc1OkDfak+faEThsvp3FSxjxf44bbEwKU9ShSn31Zj+CAy3qE3Zb1jFA2/xuHJnRxO1auU/2e7DSQYgx/M1xBbs8rvQA2Tkiq6j2qoM8aRIpXmN20/nHFc5lB3vpnhCY1fWudGvdEtzaogBGgP208z9l3pNyDXRvSHtAWDfLAc9GQR1an+Odk1RDisgzIwjsCXxgKBc4Z3TTroT1g6yDPVuvua8xjZvcNBM4ZIRpJjHHO/J0CNJQOC7oadsC9h60hlbTIuq/Z+Mn8Em+ncMSpKZWUOY0otbHYnlVTbhP/amO1Hamm2K1r6phUOgiPE0J3MFOdIj5H3XrfdJ3lqXMlOaTSsLhrZVMugI68uY8Itnps4OgxE2wDGcls28iITNaKRwjbqdNY13YJBschW+oc0xqoDY44xQX47WtV1UN6N31QQ4ryCLihj3PIe6ERmV7t3kydxlp2lGAaIXpzxSIBJu1zS916p6SiBrJpzRVSm6huDrAD6BN/ZelDfgv90Ef/uvrlFwAk3eqZ5A/o4V1I4WRf3K86kErQ9Av9iVEDAjQsMsl+A9k8R+rQHYx6HBym7EfSaZH36ABTWUHUBv38YkBXqk12B07i8YITVZPcpvez5zC6eaUQdPpMn2uBZpkCswxPGVa7H/qxOxlK9MB9ncgai92ZSA7cCl4kReV+cvthcIhReXIrpueQS6Ku8ByqaeEduAobton2Pk8cpXdgq9JBfujwsM6nU/ju5I04FAvfnZoWXr/w42i3XvjkA0bx6u31NfMSi6BzQRh8EYuLudM0u3qBTXACuvHL5PDX0Eubu1P+MKldsHNYCXdWQDlFGJNz3HV27CbnWCXnLPa6A/IWd52dhU92wN7irrPTQKcOyDnsOjeNXeqAm8Oucxdu6luhUt8AD+7G5MLDuSl76aSVlwptvDkAdsLeIa8rgDwrGwlYOA+b8kP61RvxL/jQm/IDXnge0YvuNCu4y5wtCMXjMdS0mgpuXmX2wJIx8RRB3bUd0be48tmAC3KRP2wBN4v1gOBW4mMJA/QVJfSM0ZElxtDr1gCN1ziyhFK4RlZhod4STdqBLKYPm8EBPm4Z1wOVSJF0ZEPJoU6d9AQD6HUNsKFMRhoWw5cI5+hOyqGQReDhX4HvSE1UrGyvC1YMDkQIowUIVwwOyFtchRWDA/YWV75icEDOYaXcDkelMbp87eJAAoeVr11c9IQqNZ+tMVyQV6IQRYK1iwPuUqHvo/FYD1Dn62P2Dllp9eRGAUdWUeByBJgzqKznHAhZutImXM854F/w8CtczzmgF73iNAiHFBJZ1dPqliyLFp5nKU4lAZFoGNkd3ldxGZR1nmfF9HvB+St1uyP1OkiWAS0wCkMc4+YJPdj1gsYI/jCn/jwzfqPWX5MzPYhYyUmWpFFOfWykcI8OzDMyUaOQj7xEX0ppiKSYOVYUHcXNr7xwKWCXFhVz3AbD7tmlxcRMExZPeQUXsUdP7ViAYr06p+KpArOKJLpJsVyRNm46/OrUgF1SLgiTrg7sxoeWzgG1RGQYJucSOaCWiUxQeDaVA25ZQ8T8nl1yhuGpcfc0ESATfEKX57LrkFsu8+rFd2cUOmCXS31xeXVGqQN2idTj+Vr+Ubnl4/CPHN3hcwmd0GvNHM4zPI0F6M0czqJ4qkDNxvcorgHdQerbuBegNNVRutHWIAsCLIs+VplzN7atCsAHTguW6oWPJoQttWI9bBBgn/LrCZ4o0NMN7PzNSPlymBOBdjJf4Ec0wR7nON3jNIyw8yWaIAcrStTywbO/q6O4itLgDj+dKRsLQrRyQRINJ3LnzMdcinZOSK9FPcxAur8wzclYilZOEEb7s+pvBWipJouXs4rm/Fqay+iYoqoGu7VppnykQkt/GOUnwKfPJuJ7CWrKqwKlZY4Kgv0l5GJVjnGOTnB36+3zc1q4hK+cm/P1RytijHNztn5qWYt+Xr6EwW5dj1qeshz9oz7/ECKUoZWDL6FAFqWYlMU5O+UlJSb5OF/nJdbh8LhCtDpzvG0xyPlwj2WmQW91e8BsOuR802Vd/VCFxQp3+zysKNFfh5xF/kSAyZz4nLp7CTYr2HPmYC7FZlfh3DnRO6marSrPKZ/za4189DI2LbYz9T0iFVr6YeMvmWhfDMwkn5mf2fiLUvRzcsZiEMqAO/1oz65hjj6CHs/tRLOj6TxKjojlx1n990FdRfHZ1HbsWpK3WJGsidZYhwyTEdwiy+FiUGvrHgjQEu5+E2tNtfKu1TDRlqvwNfEGS/Bp8hNK9zGkv0ijTAxVaGVho531Nf162+rDlKiqcFmduQ5NRKiN323irAR0FKwkXUivLzrYkVE/wdXZ5Y+FuLxkOhjFN8py6xR5RKzVQvb4EKWuZ4crgocCtIRvMKldk62+sJhNl86muWXXa8zb7OFNdS9K0LI3i6mckj6AXak4m+FnMvRKoE1+xhIYStCb65+IAOj44toFMFWhl4VzizeUvcH26aps9b1T0SLnbLoHAvRXWWdTfVrwzqizyjqbeINN6sX1zVkzMVRhuMo6m/6RBONV1tnkT0SY7jFqv+wtEMnI2rPeAkVxMHc+qeIgeWJ1igRkYKbab6W1fpBbglUvnyxRcoB6fb+spCWRq2kcBwW4KDI6XO7BJqsr4sSccq2Q65YVecub7TNFwBP8FVHL83iV3f42mLZsr38XY9linakh37nJcivUJwz+kMpw8wFj/P3zq8sX3yplq//cce56Il9AbJbXh2RXl0rZZF86ziHj8Md0Zvn6/IDu1Wol+9JxvhiHP6YzfMYf7fEDiu+UstZ+7Dh3LY0/IwU7eKQ+C2XdED4U11dCu8w/ezxePQo+FRmRUgdljsPoAOZ3ZtplEwqf6fI7db6YXDBPXKg3pqZGdZUdsWhmNPXuzRQWOMaolDa19vM2f5fUFXebGMjx98SqPCP+RKkvlQJWa/O4PkZSSzIxdKswUB94yFRclCwgE/LwLsD3cHeHpo2eZckXkfuKouRLHSFKfnoiy48Yh19QzsaazHr0HHlhlvJrh+KhWNh/Xcr7r5HsHAVkjXfvatrJzTfOTdedXfrLWpS7tEnuKEhP1TRnoENHpbwt8Uvqd5f38yieUCuIneVxw/qzxK9o42ZVdh7ZIn7NqnEGxSti1bqzQSMfxqNnr7W1RrV5cqdNZY3YVxCmM6oJELYZ0gyyBlERqkiv5Ktoq6KuIl9ErVWYFVQcSSO1AOVTHMiAXJ20yoin2aicOJu/JEGnvNpk25TZqnKAskP0SWQ0jcm4bgGeZqOy42z+kgSdsmuTbVN2q8qNyy7M8GNUVjgNxYtmtS1YwbeDdUktuj01M+1Aicf3EV1WiQGdaE+TiPbFiuY1RCUrLuuIWVaEE8C11c7yMkjlKGvNSJtZh59GTKjBd7Hk8V4SNI/3Mu9Tk3q+LSjsjsiHQYHpL0FNSVT6Lb4v5lo9Xxok2USX8sHSQGOU7qMCh5X3jxrX8Oabw6+4sY7phNeDe6rWyxghqyjw9nhXQ12nEOjo8VfU0O/CUxRDvV7tdYyQZQpIp4FSRxp6bImKAwHwThjtwS51jZVM8CVqHApR1pCj8A47tcmMQaboBHVxbaLjJLiPNmOHv1rQ8i/cJhgrqOMqctJ3jZAlNmi+TXH1kBWwB42tLWYMK4rKEEFdiepFtKArvHWeOxpHRsg6IRGmP45nOydU7B9QMVyCTG91ZOQTi4i2ZJbAIAC27lqxPgNsX/yM0dcqRfttmNGrpjFAzNU1RVOW1UKbr+LW4xJOWezq2yQb/JLfjEDFtva7mGtiRFuR2jcHBU5bhVE76ibWQpAxF3MP2fq6QRrjnF2ptHR02dmGv/gWC23rIafTv/ElenYlygtMOa/nhZc/p5Pmxa47pFs7y11hdYpIHcxRsR5PhnsiXq8u7PZB8bRuZmKSsqI7TTQUkF3NoTnzBxnwuUqfC/FnXKsLzOpUkLmZ9etaqaoRz6qidsx0LGhIo6QHwFGAsqhFtwBjZSXaRNSAZlUPiqNjau/mRipoxLOqaJcGZLbpWE5Psq4Flfi7b4HeoslFzdnW1RGT1hAxQeXKxkwqqpLMcu9AVRQnUtQUFOhhM10tmYY2Uvr3qIxsb8NqihyxrqptHrgFDwWyjIstHxPHTOuqANwFKgzSS/4Al+cNASV1rktEqKNxm+5tmXRVKw7z/i2xdXgTqUoRnYK+TRrtlGpdV/OkM8iz2HXJTqlWdcVJVlmuXqSCOo5VJcmeOvByLKUnkWnZoE8dsKyryUsQF6xyQSMiqSb28GwDSR2PVFEBsA+vJKlY2I4XaKoKZHu6rCSp41lf8aB9nIWW29LyBU/Psq7mbqvhbsIkU7VB6x+wSNQ8FFHlugYNWJRWzJuVm4hv/UEpDRAbV8EJxzm2DQsv1SdgW7+OUMYBO3beSJ+QT6owjCP3mxBjIqmmJCotz5KUFLU0Uj0k4eX1VnNNMaGiRnvPQxr6lvwLzXqRJnZeWwPcb8DN+BRW1q43mhe9gC6u8rcQ1DEpluFmhaehCSBWg06tWozIsFTrt6heQj5VhdxnOK0KdNgI0ixgvk0so6roiF6VoJqPMs4qsKh0OuoFxMqaq6wgyTbU2hOqasSh685oTqaq7XDYW77D0BHXsqmqs/eFrKNuyffxkjrruEk64haiIy1po0GNtxPXsqmqI0uB7cRxMuUeZcvORG417gyRj00Azg3lMxsxo9Zswv1Kd8KmOZvYTN+yX8VFhe5PRQVsOuq22WFdJjWcl22nV0BsP5c8l/qxBJ05z2aKOZnWnGczcS2b1pxnM3VLnkiX1G20ibPAqKzS+UHdnExn1riZtoU4Vquzxs3EtWzKs0aU7rNki5sJy6Q6M9ztNCqc045nnZtJK7VKeLoRsJ3MObHuDsR2WntCo0vacb2fPx5Xuo08MwOyfcG0mG+us/sZKcUTQEXkqtnNBHEqmaIyvdxKEadSUOTymFQka/HAVHhtdSNhPZlMFbtyuJWqjkymqo5i+rblkG2lbEQoUReS/8TxZq1xSCdTFm5VlJxJpueEyP9fPd9K1IBOSVmexZbPZDW1tYRSdRgoVomGPqwTmMTpXtNMm2oAj9DdAmSmSS2MLo0ZgCrv6sLS7YS6rhGhVB0t7gDt/6jLKojxEYVP7SHrVnJXFZjoPxRkTePuDqlSDoYatPJA58IscQN0ljwINGjnoazp/hquzp0PgQ6tvJSlq/X4unbOq6X18cXzv5xFbEuspnbzpqncDgfPPTcTOOaUaayKYF/sNpsTDOgkygB89CjLWvDXI9C01Qp+IebKVM9pq9k5Z5LowaGzs4KpoJZKrmizzqHjkmr6w+HW8VzVH0tbx/MnTptpEh5BiZ82baVJOTaey+cpM1VLT1Qmmo6brdOPSuv0093+sJGglkqmiCyvthzqRnwSbXGy1bjCmSR6+Nfb7hfMSWUqXd2cmSkTXpqZqXmxmZwXKnpwkhVPwa4+HGgIwTjOttrIWGCW6E3JkqrMqE+6rdrChFGmLyLrkjtXXgVm2no2ia4s2qoZcCaJnhxvNRJxJpkeV28SZ3KEzxJnasLy0jLchIailkxB1Va9V8eloOnPG2r6s4qm1jPRRrIGdIrKttxrmHGqamQuizbW2HLKNGbx0+X1880aw4BOpozFkMYBCkNcbjVEzkllKluPVBvpG9BJlBURGS/2l99tdXQ44pNp22yPYuHy0/SJ5wltdQ+jpZIrunrx3XaaOJlc1fV2mq7VFL3YbH7Rk8lUbXbmoXbKwV6Io/C01Ug54lPRxo6nyzqqNttwFtGqKM2yu2hTM3aECuqqiK7uNlTXE0rU9U43txE34pNpi5INhXVkElU8ft5GsgZsEl0bnpEqnorSz4Kw2KrLHdKpKduqRQ7plJSVW23rD+lmV6fVYtmWSHbfeJNrN0SHr367hj9DbA75adToAKdoF2PXW1i9yiVyLeX8GsAdfiJ8UREARKcwyMKiCpO8lE9plj45P4dYzMWQ/0u5y0vF6t3jbXJG01RRSh9h5lm5wSRuYFUxt55usupPoiqyDmBtonvMraebtgTSRdItC/czBYH2Ob+a/uaG5XZ6ez5VfRscA470qd4ZHr3BdfrQWiBzRqupNq3wY1WepZdY12CWj3O1PrkOs/ycoxdc16CWD5KwcL2dOJDc0amp2+T27kCe+i1d/sx2myOegUKNU57umSivKNuJHFEqqow+b9l0OjpFdVVRhxuOuT2fmr6NlxSaa4d7FNdbyuv5lFbLRmFrSV+bVgfLCFRRRgoaoyRo0ICdIzWgLPaUgMjofbNedmALnGeHhp8SECllZ3xA6szii0YWCHBiI7FZ5JW6xMfjJBDb/JunssLJfYQfZA/db29+/fXmg2zfqfkq+PDxI3BhNJnxe71+Q+WPGSVdWPMxcDFJpCn0rIM8bCqtZQTrWGWxAcuIyM/SIEa7cjXoZUS/YO6s1usvv2/YOKSY1vXpqVBMvmM3Eu2r5jAj/kCtPxbkjzhXHWX0X9pXAX11qn3uOHZpc8tTyfjNXLyNPNykdJnTsTZ/iX61SJrPIAKoa2md0qpoBHUFoyl0zRuMSjXC9yRpwLK7XofYh+6LY6DHn1BKM2cXHzMvsioLs5UYmZ+j4w7jta4T5fl6l3koyH9pkGfZiN9sbslG/EZRQGiDDrndF7PqZ1tj+A2DTxj8joGH6vIl7JJxV5i6rBD1XbA7l/ohv5H+GGNLN8oW4ltyE+UQm7jWtUY+WxOmZh3FuaR35EZWJzOAHbIN32Nh9wG/mn6cnlAa4n1QZKQntw2Sq6NcxKymOQ1Hed6wdxExq2musjucNkFyDjQO1GaSBcRGiklfWm9o6SV2w1secX2MxMPvON46fcDusU0CwcfzVQYX2wTwYclcWqjJhT8Q6S9qmJexknqH/ZayenHftVDOSsVP56hSr4IHj7Ruj9U7l2Zg8+UpmemmgVpOZ3tZIclbNQ/oPq0h/DsP7fcFLkuvuXoLXsGbFQQn85dZZRdVeUL4whMLNL9zhj+X03XFLDf0G68V4yhLlMOfEcle7dPvsbVrQgVRWM0lIfuWtS+PAkRVZHuioqBNwAfWhnFy9d3z9dU7HStRuvfIDGofk5x5xwLj1MuzB1x4R5ziAlXYMrySyApMmq/OvrrdMoNJDsc42p1Bv4h4VTrD8VytzBuVU471HU9cRCj2uvmSV6PCwVykUbZItiqRDnhsPe65mUk22uYsSnWQ3xSB7zfGNW5Ao1WcrnSJeFQqPl9mOuhnR3V/SKPXlYQ7W8dAGt1HS2bS220msqfTk7mLUvre5Qy9spBZ08ZkAomO55G/wK2XgRRXdNVwnhwsketloZvQb58BMbWe/Kqoy8oLMe0iz5CFZXq9bHyOHawiFjRzLqN+ZjORAz6z+ryZ0tUF53qhM2y6utuu7EeUmk2NbocMppVnaG1rCqwyc64sGPUUZ7D8jFX/7PuRzP3Xl82Pzeqg3pXw+aLY/phg1e70U/hW2akwO2Gf7xXSpZTk2tvSdqLgUKEfkfm9By/NvHtUx8BrVSa737JTIV8trAWAc4g21dp0CSkCngYoWnpIbqSelZNX1nme2b57NszCTMF6t0rWhF5z69rDKVkGYAfbHhPlK5y6Wi+/u767PIviMbOu7qvvz6V7zKyre18i7x4X0eHpLOIF9CY5KKNjejb9I3IL+5+vCi2K0J8LrV1MGx564tLD0Bcomoz2J54DEoWunx8Fh2RmmGIng1WvbIlRZYRqzrHxY4XTva3fBTWdAkoVoc21yzijt9dZjaLzbLclLmNe3/uuiiw9ek0ITA/lkVutQjr9Bte+PpTGOIzCInMe4VCc6Vajz0QsRTc0PrdcjvI4yNox9wCe5Inz1z54G3KsVjUXW/BjKYq77m72lMZSlLeRlhYeDrWtUBqtFpxXMSnxqmw6IiYJ8KbcWOCAYr3mZXURYo/ewQQ+MJvUvgmP5JRxt0UhTmjWa1ocb1CrhiSqFnK6sBeYSn0tzxI5V6VoK4A4SComWgyBNJZEw5GQby1fuUoEDUnkcpxLke+ZnKLYyUy6ldERKNQXFLNaXmHPOnSlSr2Z0alU6ZqMPOFTGDvtuUVc67MqdvDtVNOAYl1KHVdRe47tVNCUSEFWfnI63xuRrN/MamR7dG0A4HRoXZaQTLIgpNe57P3USSYoI5ZVQcMzeZeSpjxq2xL3UYibK3AbTICndKsSC/TgbdA5TGjWn/w+Vc6uDY9VzZkUevjBroTzHn7MtSqOLGkLVDjtvQYU610pCr0YPbltiCOS9fqUZVWcIaezmCGH5j6308mVkE17h/II/fxG2G+JKKXrP8fNcECxXsf4vciKOt11WtGmRDKnG+2b1OblDoBrWcmQvcioKLSK75mbgm1EDtkUBe6fyK+ikL2njkrqSR38ityS2kVq/b3xo+RazpG/hPMgHKSK83fMfQHLaikc2bOoxyd37awRNSGRaSqj9M61pDGHfoE3kJKjx7z07vBT6R3qOHZxxNPdiprwrO/Mjr52YGChKnmHELXN8vM+C0hTLcmSICCfOFqBtD/IeJW3lpva5NX5HrnZZ25/WOO0sLG7+inl1W9+TQcn8f/D5vzNl3XRLMQdZLIh8BfYFFZAozQej5+2qdABqeQiravBi2tTHLeaQc7ZBgAXM2FRUORou2ukR2W3S1TEe3ygt/ucbACs1KwhrUkzn3n0E2Z1tDfp7GJT4+5rhVBlRxS5uz7W+Oyb0SiqcvHUV6hL8b2vwNBu6q64UFV3uEmGXM/sJ/bTmuJ3ydwLM2vi7CmB1BPn2ootcPDcgd9kpMCyBWNPr7jiLa6uA5I8DPhF6+30LzMrSj8U6Eg9N7K+fTvdC7QGq7ZY5DpmegfCcXMmHL6IRz87CZI45W7apqPTXQLrjwgAHuOwGErrj3GOoSjT02lDhR+95Ppa7g9rdPF0h8poji5IVeAYoxIHJekAYsyHDGHC+bnCnPECQZYOs6FPzOT3dvDnpL4wD/6iQKG7LbEzoLU/rFi/vfa7aQF0d403LoOWV7EYhjKdlAR91nfMPX4o5boIxmwb2H5MuGz0uTCX9V6wbQxs6I5ou/p9zKV1upHjrB5zZ0cb1uUx40b1eUy6XqfnAl3W64Zto7rNL6BvVr8bPmkd72W5tDQtW+qbaiNbt3TbWbtllNp7KM1Zz0KUb9mtDOg26lMGjOsdykSayzpOqUSv9MFNPuXbrpZ3lNJqPhLn0urF1VX7FHwjuw8Yt7P8gFRq+4lAZ73M6Ihvw+5GxLtRvyOiXu+AlsS6bBNDzo0axehV0WatYsgqbRZTic7aBd0127A5DOg2agUDxvXKP5Hmss6L9kyBjd0zbVfD6S6srGJzQRDWhYqRNvpx/MP4znAkOcp7X2R/4LAiP6NdHaIS8aBG3iEqkgdUYI9ZDxd+O7H2Tg9+i+vPKVEuCSNjxshhBYQFRvsEX5yqJIanHYELyPvDiQdUhad9dgxyXETZPgqDAh8KXJ5cWEORlgseHcW3yn9uTuSJNkKH49Fvdhkq9q9YzPdoR+/xP9E9+WL/7fPnl+iH5xf0/14+v/yG/uryz3/Zdb96QRLTGILTtElYX6AiuSDSrq8ukuPVZfNP+i/0/PL54fL51bdRcn1F0ldZFocnUsGmIGGWXDTGuSjLC/rZRbTHDLdLc3FM64twX/1weXVxdXF5cfX86uryiukiPcMa4v7uoplPk5kdLn749uJbkqPAI6lffPft99e9m/If97gMiyinxvzrj/7wp6YxjsxNfvcj7ZBoIZN/P/vTs9vXb9+/ef3q9cd/DW4//v7z63fB23c///7m5vbZD8/+1783Zx9VlN48snuq5adnP/yvf/sTreZJdk83xX84oLjEf+o+vGXDbvddku3rmMxKfvj07EfO+8Pbt+yX3zwmcVr+wH/706dPn56dqir/wfcfHh5aQxCb+GXZ1ssLzO5efKKVoqFjyaqibn4Z7dnPdXjR8F6UuKrzi1fsbJ9jvM/K6m+0El8MqvAFPb+hCPk+GUH+9ROzIrumS49WS1KhKvpikH118Z/p//r0o86sbfb++ulZbxViAIr4v//0f4hF/w+wZXtxbBBGNHhFfkPPDP/U/ZGGeSJiSBukr4eC/ly0/2RXxYN4OeFB9uegvAovx9/sE7Qv7oXoOCEjP7u+3rrLEXzURIbk0b8CVJ7WvjqhWPjn9D65DvjNKOEHeYkCHs9a9GcyCrCemv6xKjIxCfkorMsqS2gAxpqYpCJjUXrkYYdOZHxrLriKUqx+0xinfFjU1ryYI0URVQFOapXPTociVMI7HR6VvotXvusiSNclaUfBPSlM6af3tMktfTUo7gc6JC98xqOWy/7Ms7H0VROTdeGvLEBFG3Fz6aMCRXFA3+kFOVL4ZgTJjCtPU0Xyj4oD4a/EDYh8yGIDVlGynI+mlkoy217d6aMvSb5kkT54rte/jKPjidS0KL2TfEi6tTZO4+p3ra+VBpNenpclYJ0sCy8nrjDtd9SWax8sziYHib6YIbEOXzWivsahENVVdsSp/+HjTUCnpVmK0+Z67J/6P9LyJ8MYWTUEO7JAvaB3YgZ/JhWAjJZkJdxciKI+SyYA3QjRjjK03dKVwfibsBUQECgUZ8c5zLBTDeOMhqqYwTQhcLmjY9mfZwxdH9t8IcCffbGMwXRGKWltaSj/sBkA+s+XmYWfz9D5QNA+XyU9SGe+5tXe+PNx17pov77LjDDG3z+/unzxbZCfnkh/EdNWpJag6YCa2J/TFNFkbAr4n2aSZx9WBUpL6uhgJQmdzfCmIMdnU5+1j9r3kIfRLGVaGPwrPk9rw6wE+6jMaVc3M7P8eyE+jZapDL70sRCZjxeq2Muff1k990ecUB99+Ovsu5u9KPLXbs8xYPsF/on0tXTTxme9Ln1rOpuk82LWSck6baVkZTEnDI55lKnpHSUfDBWLyfZFdI+L8Y5HQCxY0HVBm4kwK2Xq13G4LIoj1tO5e3z19vb1rf+K3kd/3T7WT8qoZCNc1A87+gCkbhqnJfkoufsX3fR0FRom19cGaZO8DlCR3H9vkLb6HAwCeK0l/pkNbP5tRKYhWfqGdBH+zS8frq/e/np12cF1e30BCpMcGhIvVS9TxF19kBa2NmSBEnjMClpnmNTAiHTm0896wFATFLQ7r5m0VeuC5/FSN20KicHteiC9IrRVj3lYQNcoNvrAQwZtbAJAXLb7BI75CA0ZXUGXUYT24JBNMGNY0Jg0eweQjzsE3YW0sHThHaXgI1SM2Y4YNKqD+h/D1//4/rgHhkxK6PqfF9BlThADGvmBLEyAkck0Ajr7JU5QFO+yR2hc8HG0fCr7EyQoUBets3bRPNlWFjAmPfuAhRxdEYCBTviWHAgaqUMVQez0WoE2Ww30cWVR1fkAVLL2VQKdCpVg9juYPsojf7jb3J/RynI7AaHHs8xLcpjtpeYXpB0F/DNOa8Eb5Kgo5c17FaIkqxbqtdMiCx2Gvo4Cl7gKVJZlo8TDg/nJj7KMNBuq7Y4QKon9pN3OJE2VJZF0mBqn4S4mtNLgdB/R8DiltF5P09XSBf44RRlHpaYRSKdQ1ZrCyqrg/uwU0vCtNl5AaoXK0zTZ0UvSSNNLQ8ZrFMeqNa67Gdaa4xiGpN5i7gZQ0SwzlOb43S41aYZHhW3BGQg3BJcgMQPfWWXn3i19d3NDRj1KzGn7xBJmnOyL+2FdxCodfpOquZ7DUjX/1EpGlfJkShrpPRzGRf+hxjRK0p6umiRlkWDl/Zoo6QlJd6kWkgWHGJUnk8T05FcjHX0gSa+q06Sv3l5fs210pJycFuTkkhQ7l2vOxTUKtwPqM2+QmGVemo7mmVX3RHGcGyVR2tSdpJAOCKPvw1Mk3YIfJ5Cvuabfs/MWpJdztcF6kqRQ6FAmCdSb3CChwv7t6HuVXc9RApWtrVEChS2L6fcmpaKwjzH6vkDJoU71pBWaxlXZrxglKPVqidqWwDQJWVgZJDGqjUrbC6MUSuv8UQrFQ8tRGpWVf5+AXvPQ6V5oP9z1kErdME9BGbS+p92KTgKsSbByIi9OwHoHnQS0d9D5njZzne8LzRyzJquToNQrAd7+dJI0jUgnRdOIdFKwBiFJUCD6hI160aJO6AscVt4/alxLu6w+XUzvj1HvW31MLs2E6kkoSxdcSiMJGdxRqpmITNQqb3T7XDGhSZqZ10f1pDkK77CZUu7GVT1BFzRPMcnQMZtaEnZrMKkfuxuE5N92qclClz46UwchK3zpwNN/Xee5Ti1mqmgb7W/Z7tjv+DPQ7me2S/rIDpzDsP2rbPUy4aCT7WYf22/hHpu/0r8EZY7D6CAf/aeozaKa/myekq9Omr3YgK7NFeuVEOyAUVUXVhDJQTqBWkmt0TC69HlcH6OUwODHiIwfaYhbyMGv7DG798iDa7h1OPzEa36rNlTAUBnlKkfUUSWfGpZdlb6cPyepi3vT4piQNI9T2h+bVmlmKBVgKMU0/02ddAAMbYUhppHOvuxRWgX76H5cIfgvzfQqYlvq7tuLylV792TDa/qWbPOXW7KXXbYFZcBom8cqmj09s86FCNNSJ3/sJnwBZ6t3FVtTdzuM7GLc/JZHyDHBGNR29sf+Z1PEMtrjBxTfNX9qfzJFe0h2ddn8nv3TFOfzA7rn1mL/lOG0z/xGL7DIb9uG0R3gdb+BRwzoQ4qy6sKTAqOHJzx97QgKH+UnJ1ZxpljxOqABMqaPPXLpatIA+aRwVmQA2wZXZw9cHeATWGLuIrp3VbkpAXusp3C8bgDP7vrRNZUDbKXFkgEuHXKAYKMhrurq0gS7rYfW2O0Fhb67lgzo+oij7hoenfen8MBt5wSPfFI4yzWAnXQebgi6zgMevu884LFZI4eBHTXErARrhDPcYIcKnODKmKH3y9F6Ce28MPSPoWn8tBgXNgOOEk+WpFFOL/HJF4cmNPTttZOs0N4XYWKnGE43xQzDBB4zQSE4KA7/yNEdBsc9OjBA14ISyGrGkE/oEl7uCV29+M4F7IvLK3jY7tfQsL3PKBfI9yiujadhS8iRC9HtLUluZbPxahF2IBgWOYKAphD87ubQws2vFC9aGYJbztSF8KQn4ugII+kZshmy1VaCBBtkJarAAdBdr3IoHLFqAmc5+keNA3pjjJoGutZweJvV7hI0c3iTk0llWjmTP+RwkQd+BkTqZk6DSqWhwmMeFYphTzbucwA6NAG4ypGFLnRVGK/LhJiTPswJcutciW2oOWGw2iCQYIMsuRU4Br2kEw7aSzoBtl3TL8HzXtJd9RwTOKlDYwr4IuD4TuvosLt3VxgCFiclIuCx2KvTYIEv/CGJ0xogHJClFAV79ztw0Ni/85r5bJSO7kpgCq8hFJGUXK4oY8ldTShCqXitUIRK7+XX+0RQ3XO7sRPlUnrrRxGssTwU1mMGpywGRWP2V4Rq3Xy25dj+rFp+S+kDpXvZUhSFF5sqGEFUJYHUK5wUqVZ4USIHUXmXIkW5t9ASwdkmsjQOr71drdOttZP0vNbZovRWsUWqFZ5PyEFUHmFIUe51tMyc/TcHGeXJU91Kk+G0d4jMkWgGB4r0cnZCMZei3NVNUvZ+IsxsIsDBmFgFQE/nMMOjflsB4aj75z2KyZwOENUUqq4qY6M3UbGSa38foWNKmoj6jGWKJHcfuJASH5LrqyCJwkJ5jJsiJFePjx5zbeLt8UF5rjuDacJ/qF0AE0IoPMxfTmmRmlWios6r0mPmNISJscIeuzAlKz67DqCBUNztXEYwTNv+XfEt1wIKWS7ujXuurgIbpie/joxrUJPYEmMUCIXWySN36HzKMvUl6ASVOXn3RiFsPCoTl57U3ZY+pGnTEUAaINGxnMZ7IJ0Z+SxU3KsUw8zGZWuc8XgKCDcYT+FQDaHoQGaWcjCGmgHgZEcyQB+GmqVnnlLKi9IoMe+6zJibQAzNL/Uh2GNpQQ+i4lRgCY1P+6doetpovIbhZJ38rKmnRWgn6RRBTwOLWHSYWKf5paYWjjS2DEdS1DR6vtPdDhn+UlWTHElv60SEF0FIa699jJCMzCVC0lupK+DRmq6+gyYCnFiN1pB7Gq9D0Xp91K7ulnj3G2OMyA6k81PXYSjaZw2DmVrJJYkyGln2QsKpuN5QBrOzWzSBUy5E5t2jq0mN4xyVZ4OrAMTOIS7prV21azkjqN4bYadF1SoigIkWRahR5Ls2d80vUS59q6iAotlnypGm8ZpgkPVn26p4cHYcYCq6fNLGbRYvgfJ6SBdYeVU0BuY1vfklXdga1e4RiuYIvI40qD3AeF1JL+BO4tST9RTdxfruuc/d5XiSIDzS9DyWXOntqG8hsr5lgsg4vnirQBvSXlu4u1ucV6ijsHidHpu0QOYyIb0yOgKbLjkc42gHj2hvRe7/CDi/7TUIF5j2eW42bfp9CECRE2gAwKIuKy/EFBFSaPMFPYeyt+fnOAaVthyMaRGE/a/XhkFc3HOUpV/dMVtMTEMaMvcd5H/rnXbyZvN1UB/XjiqVUTRMcChQgmkv0DpDakNt5nnQ/a2LMQkPrGt1LVhotaseWoxR2TIJ3AQ8OKhOlVwCxumJxr7ds5jTKzMnDUi6STYoLgiVzZTMpPtVRAw0W3gPy723sI0fj22/0TnkPEq5W3CTekuf//roQDcxm/FNA4WlxZ/LnP2PtxYzQZ6aSfLoL6O1MCRyINntiyWE/nZnO79B+31BJoxeE/xMvejEcBp6HklpsP9hY87ipdG1lIps9JHB3j+G7bUBL7m+ZkPeMfeY58Tiyee+EoOS9Awx5nNK5gh+9N2SL0VVRj6NVmIdf2vLTD5Uox18aMtZshA+Hu1wsRq5KIWtCjq5UyIffGjDySemTVe2Q2UULtPOvwVjJotweiN7r0jefg7Af8ylnMccgKdpIFIuvtC052sDf0sZ2w8BOGlrZJMgKWn3JQBrcXXltY98ZbyDbwGYhx2AlHr4MQA3af9SSrq0U2NqSo37qFi/nLWWsjlbH4UZ96ini1J1xJSi8UglqrMRGZ6JrGbTYcWztDxxU/X1kheYZ2DkSVtnDbyOpC+nSZ6jVG8lL0Qwy0afvrGrUc0d4mgl7efsCJceVl5STVOXVZGlR6+5G+LRExEzHPEQaZYjjsWW316cHY+kutAyojtPVvL4+ig80SBwqkuCBooM1Uc25Xt88iq04jFzJTXpKu+MExtXsogHsqT1hLQUo7TtEYO++A6B398yS/xU6S8GxxD0IMJrXG+QpSlZQZtlYzU8wmrKptdDMXNIR7Kz4nBBAWf15oxK+pqsaMOn0LA0G5BBp2EOwq4DezJHfapA5unNUlL/+msXeuWpjVLS/sA4u+3KzSQtDVMRoydDczUHbmZVTusUbJLUeKoxRtCddrWp2+kSPWdedROzilKgB8/GgJo7T5PE3RYj3wZbjTCrCLV/SlESsdBlSVTS19HqZ85LmFV8vxo6bh1muEwyAmBHQ8amGZ4AGgF0szB6lcFgpj/BGc3Ajsq7wUKsbh+VX62w6MAWEM2w4th4AKNp9XOhFLpHmLK7q8KewdAJnVbybg96PhfyLr+7vrvUXwitQV59Dw65L5FHPaXAo97jIjo8udLM0UFxzcGWGqTRHEyKmmbePQugC6qVQXa7aZCC9XTSAxnZiBboHNuIcclC9khfCjVvrezxiqvrgAgMWweFBpDdMVPpUZ9U3qGOFz0HqwPolGT7Qxy12fq8zwLSNZcVdVYY0aWWiaJ1QBOFw7MatoT26ny/cuNeDBbHzYgj3whojhzJcjmkAZURLfqI/ofNjPxdfTgM3gQ0P3pSB4MmoGvBDrXwmrcsbTS+5o9GuGxKEzBdzb8tNPJQ791d0Zj8M46zpSuhhmAryqpTVOyDHBWkO+MuR/slC/95eZagDlFES/GL1THKdOnushbGA+mrV0tLBYg+wPxuKUKNOgqZiSzecVBHoecsa6spZaQQJTiO7YsqDK0zFZ4Q+f+r5zA4eRYvrVo1kLAsWo061po/WXWU5em/OgYL+u1dXSxF8dRAopYhq/s/yGjXPh1cddtsB30osoR6SoMFp67XGDJ/qAoOTuZLuChx5YSgLJcmQIaAjy+e/wUIEaao6DPwij00swarimBf7Kzb8tpGugaI9Ri7P1l3ujjcL8Vy0sGwL2geCcEeZunemjrEauAsdZiVjXplkKP9sHq62y+dNKhj0NgXEC0nTqwrfesmH2ZYTpYO5jQQXlhDNNN4vnwBmcGnZLgpM7rwsTZ4GpFR4e7BFiaLrE2dY+vWkC/tbWsghOXl0stHLRTrekNB/mwNwjeIoXBARuoObCWAnDoYWQpcXj+3N3fj8iDgF8Rs0cjMECJ3RUSaxf7yO+t1U2E/iNNAPgAYVy++A0C5BsB4Yd/SASboJfUWzV4QQACxhWhZR5X9BJThZdldBKKsiuh4ZYtUnQqMVh4iqwNFCQAKd+FtCwOxKqMYZHluXR05jnVJNTil8SSZ9KAAO2EUxW7Pokdo19CoJv/GKd21N570zFH5qpp6nM9RtB601Ry+fEqz9Ml8nj4AbuOPME/3pU2HIwBVCqJkAkyG+SSqonsQtc1mGwiQzXJnAKQS9MsIj3mmKGELewoOXuhTAtDCJ4iF8ZxqgGO3bzgAsp3rD6C6MDQQWNFnEHuXVVGHEI0NqmddjY64CNQ+p0NxdExlh6trAM2RlSygtRyGnVmt3ZBThUgy7eFwjhAUSHszQoxCLHOPSlKJjeHSIKmN7cqPl2z69w5qLWKPYurgoUBLPga0IEzzYDQi9amHBwWmuRiCBFGSm5ftGMmyBeIw7zBWQs8q4tjVeb49HuTZ4tUbKUacZPr7km3iZG9ysDRIbVNJk7w0nDoNEYzOBoYAxZqzPCUEMjNZdAIjBcjRnoaPMk5+Z90iCIRNMeZ3RndCuuTtPMqwnxlvb5qCyOICayCsBZbThjE1ag9jN5zNgQAUxdGy03UtIItZ1ATGsiMaoPFVEG1R9KoCPGKQ0tk5WnaCDoNtrxsveuLWRbHXcjjsl8IjasPYq1kJ1qgNY6/GdhYzhDKfigxQlqNM6qLYa2EXKezFmNzHEMA0Lz6tZtNDNDL1s8+awVmXAKWEsHIJYeMyzip5IGMbRACNVVbQd4gA2jiShSbbiRf9yHoSS2ohXc0FJxzbDLvsFK6Zn1ggNG4OAKTQNyI26cnPl9fWHXyPxKKfG6L0h4mKdWUQl6OLLbgalmMJYTUChySRHhN1Vz3Vqkhb4iN7d8B81t9H+MG/vfn115sP/D+qQiQwwYePH4EUMahGVYKi1jEILWN6Z6VKYvZz/+bpAVXhaZ8dA9IoomwfhWTlfShwMxP6N4qS7esYf3r2w6dnP+ZF9gcOqx/evmW//OYxidPyB/7bnz59+vTsVFX5D77/8PBw0TzjuCBTeFJV/ffNRxeYzuvpl9/w0yiWrCrq5pfRnv1chxcN70WJqzq/6CJJ37IfWwdZ3unh4hiGLGW+T0ZQf/30Kf3mmx/ZnjU9ny6/yVFFezP21cV/pv/r049+9CfZ+iszEZdHMk4R//ef/r371c0j2wYvyZ/+178x4ybZPd6THw8oLnGf9pa9cOq++yIsyb01ETtSJ6blV2jKT8/o4fMRp/5FWITttjL55xdUX+uwTX8G+/7bsz89u3399v2b169ef/zX4Pbj7z+/fhe8//nt7bMfnv34T8QInz59w29t/PTp2eXF80/PyG9wGmZ0ICC/+v3jL973n579E+EkpJyTfJKiBP80z+0rtkrnOX5POtq/0TsLs6xTEoJFOprq6TYk/yVQLfYzRkU+IP//Y04g2LWH2wrnfyWZHv38aWgI9tM3LjJllx3fnbA6fNVUeWP7HrJ4j4ueoWlCo2/aLyPSlLrv6NSnucjbn+WQv3aez3/iVZr+Mo7SO/Yb1pBbg6yA98NXQPMHip3eJ9cB7/lcaB9tW4Gj94N1+yo7oBhs2ueIbxI+zgWLbP7hKGe7DJGpFL0NUWSxI45moUGjiDutDXF0PFVNVXDKQ/qQ1pG6E5pxuCQ3HGFNltTJLBCTA4pxOByXhCPvfWxZ48h4gxBmbgjGgfdcNUrq/YfFLQviw6Pjtsli8/B8OSDaJ2hf3DvKQoGiuNn+IYXusOtn1coFPo0BwSdCNIiXGyt1Gwp1SeZgwT1ZN2xQc3FSO55isIUWC3KBXTANZhbOa++oV2Hmc19AJ3ddyyBnyDlFcSAslatZ2NhiRejEZLsqHsQtCQ+O0YPyKrwEpcBJHO2ag3DuotdJYfAtYcfovMgdd8b3dEHssN9qLiTQ0NaWJD/6zSp8+Ct+v/Y9aXfkRzKBpJmr6n2U/dDud/jtWt3fah+kDj/ihF7nwXAbDnwDT2nHoVmwtYv3Nuws+aTbj+sNPi8FlcpDpgtxFDZOxOi9aF6kMPgfPt4Er9rd6xIUmj1N48gB0Y/i7AhNMOyoQ3ojroS2fuN6ise+g5Y/BgdW3nU6DT544c7wXelnpRux67yhw2wwmma23JM5zdOUDDhnfExonbizqPa8uTSv9QDJoskwHfA+1DVNVaC0ZDc53RBOZulummrEvBQ5Nhyl6N8DOqQazNIjjPH3z68uX3wb5KenoMQxPXMCblNCumZDsIkFCcnH5kwF/V1AH/dcxHtA8HaN22xm8nCewT4qc7oLDTz8SMkgzcbJ+PR0o6ytsDnIG42WuVHGlqgc5AodRnvExmOU6Xqim4pvtqCQ3OUwXlRMbs4IFxeTJO0rBcG3Cyl+ZgP84vcLqW4b96Zv0K6UJF0AuPnlw/XV21+vLpWSL6lgW3saCMJ621w8CvChuL5KjleXvFGMaxcphd4ve2Mzf2AEv8uP34jyRajzJqQntCK1qs7BlYpg1aUK2qlmMb5uWrVtOXb60fPL54fL51ffRsn1Fe9+TG30uo3hsghuWagdcIDCJIdW24HCqexWHYAiG0wwjbv6EIKLbEEBVRYocSCTo0LqrFyYk6OC6QyTGlwlxwTTSJfT/VIaTucAF05rgghuGRZRXmUFvOQZPJzyvHnnDKuXg4KpxA7qKwaur4eyCOFra4cKpvOYhwV8H9WhAuqM4M3ZgoKqDNqIK+BSO2QwvezAFVxrhwqo89GFzEdYldEVfEvimHAa0d6BSA4Kp7LzAAmrs4MFUxqT0RhcZwsKqvJxh+DnIkNgcLX0qDdKHSybRARw6jG7HwkvuseF0+qk/4/B+//YRf8fQ/f/8f1xD6+Sg4KpTEr4AYBjgmnMC/hGzzEhNQY01iKKnWgdYoNpLqoQvvBbUDCVJU5QFO+yR3CpI2Q4vQ7WoyXwerR8Kvtrj4AyO1gwpW5GT/ixs3YzeNbwoye7+wIvtEUF00nfl4HLbEFtVSb8Rg+UwCGe7fHW9MQMRqII1snpltKnko9kf54/dKUXFnRPb6M0VDy1nd0srbIkUhh7G13Mp8YolYrhBZce032E0pRH8NBhHqc0Za8VjmmmvLXyIYzAymWJVbq6iZW7VGasvWs6HdY+lRlrWRU8ZIMOa5/KkDWOSm0Dd4lMc4qqWrsG96nWWdV6n2lPUBbGPUFT26Q3EHhuqMeaUSqr2qLJ2qcyZCXTQxTHpTbvIJ1NPdWlbRO5qDFVlsXhCUWyQceywi0ZpHHXoGyRTm1rmz69UoFojP6mg+x6ToMCHyONXrnPMO8/ZjAac58l61uKsVVxDMMgLzC/DGiuZo4DVieAp3n9hXzdqd745bBJXz9GkLe8Xqs/TurPkVx0UCiPTLI5ev2omcvIn6U26O7H7y8HrhfNlQxRDBQN35ENCk7a4CaSlmEMrcR8sYeZStsXWGeU2racjBSMUlvXlBwVpcpW02pF6UHAaq6doAGKoaIC0wDeatetBFLGya16Kt3u/tXb29e3uj39K+rWzWhOpn//dmLtMCmjJopUFKvURJY/nwrudmnmEMYzhAZqEMTPUMwAwVhL9bmNU2UkZJzc0iJHlUOTRWscdU9HphqY9/vk+tpMwzC1sYYkrwNUJPffG2kYpf5SZ4qNo33dvoM5YzjPgq5zLSaf6TR581mKdj03Sv6lL+l6sdL6N8orX6+Mkn+pFZDMIkweFA2e5ZvVQ/uymfkFkBYSz6s/SNuXlQjOZtU7cZoEpk77yrCC8xswcQZ3MOXejADV6V69WRendj9IUZz+vaB1cem9ysGPorgWzHWPbT86jT2VlVfyYUpkgm60EsHBNj0ofR0aZNODNOAAD7IBQkqM4SWylgOlrwXbajKx0EpbHyfnmYG27OpWbVO0Jh0i2JRz5+uFzfTs9fQ4IKqo/9+oSoLvAZSNsEDU0Sf3AMJaGBhNJZCoElLVPZCp7nVsdc51V9c+lacvXZ753GWIANjCrfX0OBaqIlGzNJW2BAbcA9lbDl5drXQ/USqs1r6QuFaiVqIEOID9IoCp9C9vSvtFe1X3oLZS2i5Sqe1b7hq1uZp05L2v5DNM9fozHk/joLe1bC+djYNLYMZFLgL0UJ6DKmwBYVVSZ4R7FGcprDknuBCa+WVFAJU9kvmJSKGxkJso4WnNbYJK7BWY0IRd9EkzkwiAjFXtI3RMSY+ls8Kd6BlDGCvByY4Ucn5SuGm2IGSEYKyD+QguL0pDEX1yYwVNKFhjM/TJzc9QmTe5BtdYxxTkS1uyzE9RIsVBcsVyDYr67GFgMzZ/YMn9HmVLp2BhVlT4Mbm2tcGgQzC1QyvFH2NtaQ3VGdOKIU4WNYH+97RBHZDP10xzsAQGP1+DVNgCOpuvgYod4wLO1wBU6j1TkenCOC8yje2kZV09krEuVJor4WnNbVJXlU0BdcmtZtHGHbuud6fZm8/k+ipIorDQWKJPNEwwLGasV4+PHru06O3xQeP2wlSQAMhCVRPwZRBYxETRGMRYjeUQaMXNusmizqvSY0VuLEQEZKwqxgquPhaE8LTmt/Fonbft4qcglmpotBTzpjPBsNNip8KKv2XwRmEe9ZUIcGzXoaZS+uTmCtou0VzEEMF8cxhiVWd3q5kupr1RXFCPwuLSU3i1v6BLBupCrXkvLAOFVAsp0vZYYhDtkA5Ex6J51nPKMp0Lk9MqKcf9Mg4u+mBpZzi/IKymG9i9brYZNkb60rbCljKtW7sGmW6WOieIeQKFIUu2Kgsz/T5YIGmI9WVU8jZG+nluY01EmGz4soTtbRUB3hdd4QWSDbrVxgTzvlXHjZD7mkaj0pyvLyXs2rWLK+56UY7xRdeoVqduNWrz2vZUHOPLqDosOvzhrF1UI0G7CjXJJt1Tj/VFV6WZYN06xTM/7ph6rDPXrVHkvvPUrZEE9bo1StbWrRmWzcR/HNVQ84KyXB7MVeVp6MVY6zK/gsoe0up23hiU1P97Go1YuTGJhK6AfuldyrieGlqBdykzLOg6DygP6PIuoPkEYGfukhvvjefpi7nnyEGEbgWzNokGHsCGEDaVkUOR9WKIyzJAId0gsdQ1B/vS+4qhQZWrOs9761FvDAFfJna65mDnboIxxjlzPHymZtjxa9T2Lk3vFG+IYlXoHRKbDjC/4SDCRnCACkmNorHW4DT2gIAqm4BwcCI7PECNgLVwjGc1ARiDanQ/U3kiqC9+QOjbtUnGO9euQxSg0rAQNIU58xDQ3J4968K4kUDPTpWb30h12wJHODZdwwgdRBTQSr0DG5z6AckbIwKLDFg8cJ27/6pih8hfen/WyEd5pN57jM3Ae7QRDlw9hxAFtDofgU3DzkMKFWFDN1AguXAH/aJmBFUrhajQYpvbGIHGhRRlxUNoR7I1bqboyra7nyLpYeFVD5C/VJ9nONkX99oezxIkT7WQ1moy1RDLR1mWK7/5unlb1yX8ogdRLlNaE0f5oxWwT3jm6bZSVBcXpsNqTpUbyw3iVGAtd8ruDJfeKz4YgzUbpaVLCvraUtV6NA2z3TSxcc9MgYzYrVnVe39R3jU7+GUVSpsfIgW2d/tbkOAQo/JkrKFPbqeEups0E9Gm/KLd8g0bTHujLo7SO5VV+CDTdERbh4KqD0aqRskB6oORiDal6/oQRzvz+kASM7Gv3l5fMzfVSCOrJLEvAvhyp5pyW0FFecKJ6qY8U8XdHuhtvM8pw6TWJOQpDOmyQsFtyZiPJzEjxNr5wzb5O+aRgk/QEV+bxIyQRX3XI2yTmBHSqM16fDyFGR0NwKxHx1OY0RXa1aWwqS5qp5ljPo0Tyzlhqdv6Sou21xyx6xJ2icxIFQ8NR5xaB4NzSkW/kyNKLR+Tc0q1y/ojRrX7+IYuZRXXc0tDnsL0meakeZ7cpzEcg06RwvXsEWObxHyM1eRT9xIvpGOhXZDS6njMOkhoQE5PUvXzO05llmfVGK6j/FqFcGX1UOER3qTmmgbiYhMhtYdZ4zK1CRhLhxuUHOpUt4UOUpnRKscTGtFqxhBamJ7qGrgwDZvFU+vs50yItbfrhfNjPV6NCBYL82M9vjaJxfxYj7BNYj4/1uPjKYzpzDr7cULzybkeK09hPjnX7Ids6iqbaWvyVepxu4STcz260qLnodGSDwon4WPCLpHVikCblCeyITXsZeeJbZYletx699EWliV6lFounheWJXqMam9kwcNmhURf9aS9tRezPjNLcWoYOIuGZd7hfRWXQVnneVao4SygNV6arB1Xkgl4KwqFIY5x4w9C5XpBY0d/aBh/nke/EeqvManvukszkSVplFP3L6nSswXzPEyIALKQl2iDMhCxbOlgU+9EasFYbQZVbjAqmqgNW98DWxcps3VYPOWVUrAoPaFjbKDq50jsFHzL+qZ330BW3+CaJL+INQC2LEOESceqci1CS+IA1VJfGCYO9A1QbfUlKHQhcABr20oxv8aXwI5ujbOyCbat1hO6dGDNIay9wqsX37nROAC2V/ni8sqNygGwpcqjk7Z9BGvbOPwjR3fYgcYJMuicAXywGWPDzhmgxU7BYSx7j+Jaze+ovmV7bCfzG6trYI1CpZjl60AQs/emaKtC7bnUQkH0+RlNMltUoMrdMCh7JtDTOgGHlazuwNBItElYnkXZZPLBz2+CPc5xusdpGGGb1Z1A/AoJTBa4ZXZ1FFdRGtzhJ/gcLHCAZoCADueCjrIwZwHPBOm5qGseRe8dppkYs4BmAmG0dyW9xQYVTNY6rvRyaFC5ZXRMUVWr3Es0Ez0iAJUeRvlJ7TW0ie4eHUZ0VaC0zFFBuB1nYJXJWWZOSrfP7bNy0r6mrpkRJz3OCo+zjLjoiZZp4LPhePxap4LJTpajf9ROhwYhA6h4x8WwyOKiBBz1uEskLrLgpHsSU3x1ZxSi5Zn5PsfAVMP9mBk87KL1gNlsyWaDZl34kMDhwhVU/goJ/GoDWvkE28Uc2JHkHt3lwtSR+DmLyy0Ch5mAPZSarSgdKefQoEMgvVVNCxO+dxERgEpXDvZlItsgCtia5OHM2J3JF1ngM+HG+EKGL+/coz3VPv+hR9BrMZ7Bdgidl8sRpv0RWY8X1FUUuxDaAYOqtVzbrOkFXNEMYQlvkeVKcda1JQ+wQTVbbXOtCQbb1xqCAq3d13Q7WLhP4U8o3ceKniWN9A8JQNXb766vSYfdWh8io6rCZeWu0kzwYUb8Fjwr1RwTK6kWIsPrDXZkHpHgyqXyMcdXt7kzHOntbdT6Yh5hgrahPT5EqcW0c0XrEBtUs91EeU0x3BJlNpFyIbcFhm3p1nt7U8mL6KBWZlHAU9KBsLsWLsw9Y4C1ewvvxu5DdNgZ/QmHdxoB7bXNPiWAVe9QtyPFdpupq4rhdlJFqxwXkgfY8CsoF4JP2g4NFdQC7VWv6XawUb24wHGlf0jgaAXlQvoI3dkKyoXyCf75th2B3yYXiJhH92FygaI4UPXraOMBWVjwlF1exixjfqu0dWjcpjV2uskAk4OCV4FlAW16OxGNP6EAF0VGR+i9yjR3RZMYzk6i4vJmRZXJPr9AiPpCYEWL7nzf5hShjRxvc4awI2aw3AVg+SY42nZr9fsksT9E2XQbBGP8/fOryxffgtihhzM3R4/hCzC3NM5DsqtLELswJHOTsOT+GGlLQ3x+QPcwDYUhmRuCJffHSJu6SYj2+AHFdyC2aMHMzdEi+DO8L+7MlzpstOmp8aG4vjIwuwjm8Xj1qA21XI40a0GZ4zA6qHgzmg6fJLXPZPmdOF+Mq70a0K7v29QFVFfZEetNb+ce05mNChxjVFr3TS1cWwKX1A96Cy53qD4pUp4/fyLSl7J8ca02j+tjZFVQLMN06zqAm2qQZacINiCLz/AuwPdKl9+mfSrLqS/C9RX57BfrQpb89ERW2TEOt8nUmG7LwTVHXpil/FKtybxroa+/hOnrRwbLURDWxb3BcomXyTizXdd/6S/TOO/+hdmmEnqhTd8lP4BXyvQStGVD6owGLnaCCqBzln2Y6rQEDWTZZs8BXLEIGrguwIo10mnfUQ76h+yB3WtuT/0iHeeFQoONu58ZvGljWsP0FTghx1YBg/XAapCr81WaKoKtJVUEUC2qyBehghZ8pRC/1Ujo2cqyOJA5QnUCLU+OaV+mHMhfQocs2xbWunxXRZ+tnBF93ByphUtVNRnHtC9nDuQvoUOWcwtrXc6rojcu5zDDj1FZ4TQ02cmwPxdZxRusDWv9O5Mr5TrItcc3+A2r4gBJdI5AdPtiMt2aqZcbwzpqlhuDubJh9bVLZn3UrVYGEMbnJ5sT1K9uF9YsglSCVCNIiQatpNbZYV/o8AlIUGD6S9XSJKL9NqkvhjE+JR/A2cpxcjw+Ehul+6jAYeX9o8a1lvnmKQ0iD8R0ueMpPeXtmUeJbEi9Pd7VChfLBNR9UgMBNH14imKF9/o99SiRKSnpqFCqT9snMyQ+EGDvhNFe5Y7qmHyS1FCAGbc1bY7CO2ya81liUxEnhVu2E+qT8uVZAaHWXaWWUut60pS0jqtItxsZJTLMaYOR4uohK5TP59sczxIbiChDpHBJs+dtvzegqvNcv68eJXITKWb5D9MZxwkV+wdULK+d5ve+MpJkozDSZNxndOv7p20efPZt+z5xnNCkHrUYYUbvzsfr8ZDXREwBrAp9wcKGUUunGhcr8iR//ArzLK2NnVe3k9f41faEga82K7meXghyVDeRaoKMudR8kN2QtmxUS1YPs2V3vp25uaMMse62mnMk19dW9R6eijMsrV/rGeb1jiOBZdh9R0/36NQ7+eoUkXaVo0I/rBj3J29Wpdk1n0LGuVLKpNjKim5F0nhzi7WbGsMf5NHnon3O789gjJe+1akgk9U1dwdSMSMIYyHtTMRcxxDBWsa6OxZlLQbOV6aCSmSrZYBgLAPF0TFd9T0m1TGCMBaySwMyCzdX0ac3l4BK/N238ne+ci1zIHNRxLi1JKqyXNAYxFZMki1vXKhq4RgAUoICPUDIaXGAJJHiv0dltHJ3XlPbCNBYZPOGOHgoUG4ubAJiLmbdu6rCeKnvPnVt5A6iJLdo92IsKGnW3dIynrFEHOa924W1oFBScSIkS1m2zW+KYi6neQQf5FlsUXxTFGM5cZJVyysSqY4uubGAZE+dIZor6NPbSLDrAgcA5iLyUuZgWq5jhGElhb2StVPSQVgJKdY36ZWUFFp79YtSqgKtnEwrKekgzNcKaB9n4fKutnyp0AOYi7gDGIImIDZi7JrvAMBCxEMRVRa1YwBgvY6EKBwRlPkTdRofO66CE45zXFiMNwIg8xsBZRyw82J7WUIoK2FhHFktxMcYVlKSqFw+XFIS0iJYySCgl9cAMzkxFoC0VV9mGrL0PZYJuoEmxmdbBaz2lWZQlutNiy1RA6/BK0teSx0dCEBBQZQQkJT1eDA6NcYg6styRbasOkIoCGE8OAGtC7TjD9IsYF6UlgMz6WhdRYeQX8ZZpRKYUke0ABNEapUVBBJGYo8FIQ2HFr3JHAdC0uGwX34DoqOpBYIQterrXEeUvm/zZVFrQdR0NGmHSluWRKOfg2hqgSBEkbk3iCaOA9IlAPUGdjbiTk/56LLupFQ+txCDgQ3sVivCCRDgwA4hy8Ql6oowq1M2ARCUKOttwmU8BxMiEJkCTLdzNweix+hQsw4IoRwHbNYBoakFApt1QIjS9we8LMp+I2MBDESczZnQHAdqlgYhSTuKnGSWBqGpBQKZpaF0nyWWh9fLeFATSRBplud+4xkghKISrBina2gQdXNMyHU5iMQea4ObvHG913mxbXXPdMWWaOVZzqLxuPzuZwQSpgMVkUHbnGnhKLZiyvQSQAxHARBjeMQnUmRw2CeU1VwvtNfU49gKYvfUAAR1OLaC6iim7zMOGYCoEZalsJD8J44h2tsQyVZUCFB2HMRWygmR/796DqBngAQiKs/i5cebmrJaLGthCqF9NKSBxvEx3eSZyYIKehMaLSdmcmBCUtMAHajyri6WPROoSxphWQuj5R+g/R91WQUxPqLwqT1sBFC6Cu5C+qEgKxmj24ZK4ofwoPLpBJmBN0TQ8gXw4PLLmu6B4cphFgQUoNkoS4MV9bpsDgkq8/HF879A62wxYYRCtkCw5jZ4awehbQxnK68qgn2xgxjXB0iWota9tCgr0vLYsioHYBGtHRNILOUEMIfmIJZScGiyHz/V0qLYi4Fo+R2MtZw/zHZw54L+0N/BXZBkcKIzl6N5nCOWIgkEqS4HLOqj4ZuEmSD9dwlCOUeIpfIRZKl8utsf7LW0KLZiyKoIaLgaQVnKihOAAYKDWErhaGCr9TmerUCDeyIzUZpXRBaEvIBQ8gJCCk6y4inY1YcDjZYZxxnADsICqKXUlCyCyoy6KQOo8hMwW2kRWU7cGbzRnsnqgSwlZRFAbecgllJyDDCkcBBbKQZPzGZKNF+ZLQgJy8vl0A8aYlocAEEAvVIHAyDnzzBy/gwhp/XQYq9ogAQkCmh9P4ODksdcuMDJa+Fs5WXx0+X1c4g6P0CyFcXCm+MAhSEuAYa5OZ6twNYlj720AZKlqCIio8P+8juAQ7URlK0siH0B7etAQinlCQFcOmhR7MVcvfgORA7HsRd0DSLnGkbMC4iZQY9jKwjihADmTIC9/0XhCWC0G0FByGKHuGUdVRBbtiJECJFZdhdBGa/DAhBWRXQpBiOsx7IU1rsHtNY1grKVFSUwmjocS0E8BJ29ogGQpSSY40KgA0IKE4QFQC86RIIRBdDmhkggokqA7fAhksZ1YPt4sSWyvThrexWFSPDhbpzwt3HNiTkNIh3gFO1ibLG71AtcwgUVzc/U7/AT0RMVwXrEAAP1iwQuslE+pVn6ZLPrv5iBIfQXcD2V6oS9mtpkmmJWUUofCOZZaTdfG9hSDAsrmSznk6iK1kI8m0gew8JKpq2C9JB0G8JqjiCQPYeGkd7cNgSR2kNBSbM7WxtJg7oGO3oYavqMV6BwhggsNK3wY1VC9wPr8G6y4KCRySncZAW4i1uHh8kCAS4sdvoGajskGGG2t1IHyuBun/LHodYHKgNxgGcq3ZNHXnNA9I3QgARGn4FaSIcEJKwq6hBm8OyhYKTBTfyBZ/j3KK6BlPVQTla9DmN7kp45rQ5nCNgTZaSiYZQEjQJ13zvN9yxUjwBjg5e+cHlWrno8zzRajwADPM/Tw1GT8tEsEiGnrn1UTWLWVEp8PEojZC2lfSornNxH+MHmjfjtza+/3nyw3elqUIIPHz+qF2qTd7/Pht+g+GMwy465AVMvdokqgKFikD0oVS3YFztS6EaOK6M4IjP9IEY7mfsCUVqSirmOMmtY/NJj44lCrXEKC5p6Fm6uTK62iWFe/YF4f6zDH8EZO8boUVYrn74oF4PGNK5mcw3VumCaJVAbKbdBNTTHWJK/hGxcXA2EJM62lsQpoq00VScwmvr0/cDY1Cx8T4gCZhPzasVArIpqIMOfoIFZwH0cxbzIqizMNGIpfo6OOyyz/CwVynOzDv5QkP/S8Mk2E6dmM9N24tTkPCBZCTpV7T7p0qjR2tdvEvsksd8l5nGmfAmw5RxGiF5WiDpl2DkQPoR2Ij3GeNlFsoXuFteFaMkGvXU1sZ/qCtFZx+ZAdYfrxNZkkrNDK3FtLKw9gIaRjtMTSkO8D4qMjDcrcVV1RItAYeSm4cgcMP2HCBRGbpXd4bSJO3Og0ZIg1AownYglHWkNY98l4E2v6MT1MTIZgqdxyukbf4/t9GiDCY1PVkXcTE3UHQZtaPYmk/5Ao78Ir1tnNMSb9XvK4k36Pu36Y13h6Ozd2pviwSN9k8faj6FV2SJiinO+vR8YYwn2RkNiGGl0dXl95jge2u8LXJZec1lcpzU2qzaO4y8D2t6f5sBa1UKsbevbkvhzqbYYW8k+xfDaLOrbgCb3Zxi2Ph0oHl7zGKmgB8N4imRYrBfwKEFURStHjQqyBFBfXCeCk6vvnptvydA5C0r3Hpm67mNclN6xwDj18uwBF94Rp7hAFV6OJiUyIlPkqwMb76/NKJLDMY52sLJFmMaKGYdnsHvRiJsmN9/jxkWEYq+bnHo1KvSmX42gRRxjZXTEZnsZnvZEvJE0B7CuX/xGlVZPMq5NAwSwMjOQI4Kwrct8ba7Xz46q8xABri8IdyueoTTaf4sD3UtBaOuR4NTtopQ+3oLtRIWggBYlc0x0BFe9AAunO8UVXa6AC1/ChVPezfBBdYtR4VRXRV1WXohp/werfBkZTv3nWG/OvyCVw4D3GBDaBlDwdRVCoOHqUVayjJeuykAKeIQG2HroRspgrgfbgNbAneXBgXLwNg9r5xmg64sDj2RCbr48fWym8/Wu1Mo8TeaP0xqXCYXRapYd+Za3Ehasz1ZChrcn9XcXhScs/ajOL7B4aebdozpWX3CyXPRbeCq4xsW9AA6s1YXEpg9KkfosQdGuQ1xw0azEvLLO82zlhb6h8hm4ec9MloFe8/DAwylZFGC9DYqJ4BU4SImX313fXUILHYNCyr363oHcMSik3H2JvHtcRIcnaM0CZGjhZXRMXcge4TqytpN6sojveoZkdtlufGSKSw9r3AtprNGflw7SW3bw/Mw6JBPOFOuORL2gJTDb4ac5Z8ePFU73K3491OQJ0Gz1NXda44w+ZmAVkE7WjYtVBmq+F10VWXr0mtCiHsojY4lCJNctrn1EaxU6MgqLzGXgSLHlWuk+49cPGrnRqaRJbM6RZY65t/6GVWye9pnoMLlxLdfcqB8rANib1964GisA2ataWr+YSVpBA19Y2FQfKaaxWjrSJon6Pt9Y1yC1ea3K6iLEHr2kqn5ANqlZEwiLM8SdZUlNEMxrURzb1Zhhegh7mK7mBYaBWcAzQBsxAJZZD1mlYhCDaFVTJTT6DMFZfikt0TFMb6fCRoHdbsgpinVnzy17l9ayLqCYVeoKe2uhQFXqxAzJtpbWZMgIn8LYtH8VwZjPYtgptqmUQWpzBXVcRe2htKmOKYalmvxkOq0apTe/59TkxKNz+XVPVutqhDgW6zp6cWrVl6FkZjACMNYxPE43VDKFsN85uI9C3Fwts5tVTpGMlRXowbNr3RME85fOT5XJlduxmDmIZT882FSw6YfHMMaayGqwQIVprzNIbd7zodCL0ZNxkxqlN68rWVbFGTKdPgyTA24vm05mhECgu4BHjVcwwv5GhGa1TjJvUIPU5vWH3yWsqAtl00o0xbDxFtK+WW3euqx7ApaMnotgAPqq+J75ULDWNgQC0LV/Ir+KQvamOiqpU3ydy2RLIhdRXe8tHy1uuxz5azVP4vtWbIRj7gsAjEvoyJ4JPT4ZNbRGyyS9jZQySu8slIyTu64DjQCL47y89O7wU+kd6jjWPFrpLiJNIMx3LEdIesYXirHrNqK2hX/eZwFp9SWZ3wfkI/2VQvuDDBJkp7WpfF6d75H2tmv7wxqcI4sa1T0ppOv21/R+Fn6K2Ly/QamLZlmtZ4kmrb8AZLmuGeF5PN4dlL4BnsU1VoPhi0sCGLmaIdBkpc41TAAshehvNY1k2O40icp4jw/0ZpzuSn2l1gwR3TdvRceFK/YY7SeaXCVq3JGtYNluUCKj61mNC8IZAoAYzVerQjkAT1cFJteuxeKSg9hVJnm0mMFPrAU2le8grfRs0bTZdX0rh6Jr679A7yUBvzNI08hWlj0ywIq4uLoOCHQY8IvLILKXQQEUHwp0pJ4o2VgAIncB0fnKLdbzyDK/Q2De+klyXwThOs8JsvCu3vQO+iewJIU/SnvmhzIs+pbZQ5ljqGe/+Wymwo9ecn1t76drdC91h8pIR9kqcoFjjEoclKSzizEfMQ3BhRUpjnZz9RdIsVKx4vNJSfi9Of05ni/Mhr/IbeguTNdZkF2y1UrQXk7+autBd7sariq0kIq1Yajgq6wQ9B3kMff4EeLXVBPGyu2qwBhrueznnF9lofMqrHUccfby7kSDtPZjLm3hDdNXWcC0nnLnVF9pyx6rt2/dY7z1Fj7n/iorAa/GTW6+pvIfCQdp7Q2UtMX3jF9zgdMqTH2tfYVF3koHKfQWTFrsQ9avsuBpBohlvta+fiDdvqMfgK338hPWr7LgeQWmWVH35vGFlPxUO0ib79CkjX7E+zUXfnF11Xqx+AqLf6AepAIM8KRVYML9VVYC5sdoePnjKx0DRHmwHwxEqOujwpKOr7JytE9VB3n6muqFQD5IHzEElHYSU/avsiLQmk2Pj77SzmEg3b5PGICtdwUT1q+y4Hkl1ju6PHuZ96pB2js9PJU1c871ZRfylxJ3VvAH0a+mL4yi9oZQHKV3eE9+d0BxiQclTFP84P9e4qL00+guqpD/vsj+wGFFfka7OkQl4jEfvUNUJA+owB4relz47TLeOz34LZm/rAfl+WZyONeKmgKjfYIvTlUSb6RpxLiirL938YCq8LTPjkGOiyjbR2FQ4EOByxO3Y+c79Cf2ShMLMzJi4m8z3qPqJG7lrUebn9m7SP+2if35hob+vPnlw/XV21+vLv3XrUMZM2wemosFktdCOKFiT83r7zLyLwOATkL7cI3G5bVFIJUtMkV59fb29a3/il7tMjNqZ5J9Ed0TLaOLoEFGfhWUD5mNqTgwO361wSENiFWp5sVtEKVRZQOHk31x7+8TRP9jjWNcJQc4dMMbwD5RVlakq0ggsJoAz8EJxYBoja0CVJ5gJQYPpKsDhKQxFWFFsuBvBzvANvJVTO2YZylugswlO7yv4rK9EOi3ryY2oSGTO1ziyjmbvuFYDKjqFBX7ICfD6JPPIdtHhlBw3TrNphNJ75NriNrGwjJ1EcYBjNbUWxgUJ7U/L1HAxxkL+AKR35H/jeKA9sVtyGsQsG75s4uN5z1LkBHG+PvnV5cvvoVGfkh2dQkN+vkB3UPZIDxFuU/mtNdXzf8+Hq8eofWW0R4/oPgOCrcJEsp+pm0kgC++hiFH9N4xaRP0WjtYKYqwO9tfurLRqEtjcz9nTJXxZFwGXRxIT1idgHs/bNHTq2OXhfUoUuIjQ3oqK5zcR/jBv7359debDya4ZbOuDOiqmS+eg+aBC06y4qmVbbnCrLIsDk8osprYt6Nyk28QpBhjUk0T2yJv0JrQ1hZ1SBA1YxpG2xJS5C0XBHLgrRswz/Mw0CBizaasS44UAHLMo5Va4zRRZaxhunivoIXZxHWGEddHYQEowtYvBQCUqa7Vgc9OGUS+7LJDHzWxLCW15ZSSvcmCG+NAihwMSD9ziw/mJjgEuch+xgc62yOzzE/dBvfN27/dfAhe/X778d3b4O3LV8Evr998JL/5+PJvb26C29f/84ZtZN+juKafX75QBm53qF8+v3z+y+Xzq29fv72+Uk19+yZ4+f598P7Du/c3Hz6+vrnVSPi3dy8//Bz89vLtWPr/8486q/7r3z78/O3z55cvm5+0UT/c/HcB6Mvn13p4/0yw/v7yww1H/fnml5e/v/kYfPgl+NvL334OrohEQ6jb39+/f/fh421w2aLZAhmJ+uV/vAt++XDz/46Mdf09gXiujqJSlpd//svfgMvyhTbeq3dv37/77ea3j8Grlx9fvnn3K6m4N7fkZ2UMNnkPPnz8GLx88/rX396ytMN2R9qPXpN++QtpQa9JVt99fPPu5c/kN69/Iw37l5evblSBXpHyv/kfb691vw9ufiFNPXj7+tWHdwZpP6h3E+//+V+DDy9fv1H+/s3Lj7+8+/A2+OcbahJB8bfDjXfC9Dzp4qRdGd7c/Pry1b8G//zyTXDzG+tF//7y46t//vndr+MSVYUkpfnzxze3pJL99svrX2n/PGkLcfVfB/u77fPov+pLfvP6t3+ZLSGlut7fvgxeffjX9x/frUqk24qNP0gjibSUicC/BW9JR/majAsf371696btpUZsOv0Lg/39I/mf9y9b+aK60dh4sLOB9HNBW/fvtzfBy9u3hnr7XuL25tXH1+9+E1Tg/iO9msunAB/f/cvNb8vNgxhhtMYN0IH/wqy9UHv89t/Vu5jfXwV/+/31G+VBresLf3v13qz5NQi3Nx9ev3xDxtSPt68+Kk9Gbv7n7fvg95cflMeBhoxV8eC3m49/f/fhX4Lbjx9ev39/o5xlUqv/5+tf/3ZzE9De8fbmDakqBOTlq38RthZlQ/S4DRgd9N68fvnbqxs6kr6+nVbHq2kvzs91fmkuWKid4NAlEL2RRv4dvHp7fR0cw9n7c3XgydoK1VV2xGlz4ET3FJtrUt3P3U4sZW3/KmEfuj6Qf6b0UaLyUZqVT9N9aaldtvcV4EAT0KN1GGUwb6lBrWT02BfOGnBvT0GtYvUoElSJ9Us9uLKCeD4GahuAF02geoAe2MCVmJs3HqA2A3twAGc1iFvwoDYyvKT9Iz1Ue5fzeRr94TW7ftr99qIOL7qDNzY7y9jv1z67CPN6NJEb+mFyz36YsB/y+xfe7BzCDXWcoSpAu2gkgN7qNGCnJ7+kahTr5O1XF3mBuzOpAdWA8E1UVh1pK46sx+jctE899Rj2o98T6mYBlSVOdtI8dJ99kZlgV7AlOWi+4f+5DYsor0ZV4D/kzSXzwYqBfkmvigc7uiaIN6ghhzoNG59/mP23HElsrpy71rBHFQLl1yidFKVZENKF2zlyniVRFbCTzCDPWNjAM4ggBsCPIc7PVfyEv6iqaOOCb19WvEU5G2y3z3cYkKllumcDwXBg/MtfNuB+fFxg/y//5XK6eeOA/wEV1I9reYHi+Aym7+jJur1A5xSQ4z1Kqygcz04E73qcFkKBAxalsjyHDPpFEn1m71lG/GX0WY0+QXeYDpskI8kF3curUHHE1ZR/4bPZ1NRLyG9+0pygWmqoTnWym6jgv3NPPp0dewn5zU98juztL7/bRIRwnkyk0N975Pc/Kc+ZZxR9vydV03+61EF7ZbX/SbWXXsHPcw0x9LXjUp/dCFLuuIEliYZv75BmXvPbswhamM8wWcO/bVeX2r42mA543t/R7F6NczO5VWNkl/lI7P2d/+5MtnGmSMc+i4Oj9866/upaxqUWHZssrxe9A/2b1/9tWwNtJkzHWusrfO/Q/v1sVttcoFb7W1+hewf6gcc+8LoPNm6W20vUseCXsX0HaO8vNEOL+6rLX36pWRFv4yx8trzBarmvaimL7SzO9hU9sqLCYfkT/esF++cWWtrNrqD5OUhQPlb1Pzjep2+8tyj/6T/8x3e/f3z/+8fg59cf/pP/H/7j+w/v/tvNq4/0xux/umCJFTQ3x1YXEakefKd7Kpc7isjy8XSC3ZBJjleX6Pnl8wO9pBols9ubms18ZqmoFAXrWK7zXhIm090QaRq63qAndFWUeqIn2loApRGCpL5J0/+dKKjTusR7L0d0DJkNH0oQLHZTevQOEY73HrsGhuLoMy5M9LRguwKFWBdg6nJBq6si1emieejB6nUZXV811WxfXTSXF/fsRJad/10c0/piMHjQzmdaDweAk6+bjy5oRb3IqhMuYpKd/1tl//9YZYWRuNaKIMFlSeqiF+P0WJ1+mt4Fdl3l6UaMTqUffn+mav9/69yXVOciVFzgh5yN4ksj+Osbuhfzrt3K0yrseQXR10e10V/w6y1t/b1/cfHtxeVU7EoCXuHRfs+uRqOYOqI7T7ZUZ5nac6e/x3/yvGO4sIJXS04q9P9X3tX9NAgD8X/F9BlwzG1BYrIHF5MlJj4wTYyYBVvcCDgIFN2y8L97VwqyOeNgH3FxDwyO9rje9eN6pT8wNKfGH3PgI75WuO47NyvsNEz4nn3F/9abHGzqWlvzc7go2akfHp+qYoJ/XJdPTrt+GfvqsqNeTNPAiZkb4cvmM7potnL9d0o0g6bHvs2Rt193buabbO7VduF1Aqb5SluMOAF7DZxJzTHmIF3xTqrf0sGslvyI5b46l7EPcXV21Z+/Bcg3x2UCzrrWEtJDnQkZ9K9Auh/dqIZN+jmDInZSbspJqfYWshT6z8TlaaTJb8FbLufibY4KIq0mdgxBVmASuTFfWBT+gUcZkDk/nFwplSi69SSqanMdKVtG9DaZbhVhV6MxLfZS0jh/opyUls3R3gSvu2rMCgDzqiGJQqwh7lS7Ho4ex9bofjC8q+AKEJMsc4h4WWybmDaQbJskzrvLLB5S/8GJPQeGqQTJJh4wAf6g/kYepGL+bUjz5TZ5wyxOJi71w3HC/HEH/M1WQVaKEwR0uou+5/shtibvZvkB2JBBXqtOTPAMDJPLgC/1JWCHpyU+U5oZ+KGZlbK6CQgMLGIRK5a4zIgsSp0geHGoP2ZeEiFOM25EFboJY2/igade5hZU2XaAoCuoiRl3EVfI1Ls946LX7nbambJXYWgTYTq6cdHu6rVlqcKOgTTcCcJJI3WoRqfXbRmXbT17JtknoRLeIw===END_SIMPLICITY_STUDIO_METADATA diff --git a/src/ncp-uart-hw/ncp-uart-hw_cmake/toolchain.cmake b/src/ncp-uart-hw/ncp-uart-hw_cmake/toolchain.cmake new file mode 100644 index 00000000..3ba54449 --- /dev/null +++ b/src/ncp-uart-hw/ncp-uart-hw_cmake/toolchain.cmake @@ -0,0 +1,72 @@ +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR arm) +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +if(WIN32) + set(EXE_SUFFIX ".exe") +else() + set(EXE_SUFFIX "") +endif() + +if(DEFINED ENV{ARM_GCC_DIR}) + set(TOOLCHAIN_DIR "$ENV{ARM_GCC_DIR}/bin/") +elseif(WIN32) + set(TOOLCHAIN_DIR "/bin/") +elseif(APPLE) + set(TOOLCHAIN_DIR "/Applications/Simplicity Studio.app/Contents/Eclipse/developer/toolchains/gnu_arm/12.2.rel1_2023.7/bin/") +else() + set(TOOLCHAIN_DIR "/bin/") +endif() + +if(DEFINED ENV{POST_BUILD_EXE}) + set(POST_BUILD_EXE "$ENV{POST_BUILD_EXE}") +elseif(WIN32) + set(POST_BUILD_EXE "") +elseif(APPLE) + set(POST_BUILD_EXE "/Applications/Simplicity Studio.app/Contents/Eclipse/developer/adapter_packs/commander/Commander.app/Contents/MacOS/commander") +else() + set(POST_BUILD_EXE "") +endif() + +if(DEFINED ENV{NINJA_EXE_PATH}) + set(CMAKE_MAKE_PROGRAM "$ENV{NINJA_EXE_PATH}" CACHE FILEPATH "" FORCE) +elseif(WIN32) + set(NINJA_RUNTIME_PATH "") +elseif(APPLE) + set(NINJA_RUNTIME_PATH "/Applications/Simplicity Studio.app/Contents/Eclipse/developer/adapter_packs/ninja/ninja") +else() + set(NINJA_RUNTIME_PATH "") +endif() +# Use default lookup mechanisms if the OS specific values are not set above +if (NINJA_RUNTIME_PATH) + set(CMAKE_MAKE_PROGRAM ${NINJA_RUNTIME_PATH} CACHE FILEPATH "" FORCE) +endif() + +set(TARGET_TRIPLET "arm-none-eabi-") +set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}${TARGET_TRIPLET}gcc${EXE_SUFFIX}) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}${TARGET_TRIPLET}g++${EXE_SUFFIX}) +set(CMAKE_ASM_COMPILER ${TOOLCHAIN_DIR}${TARGET_TRIPLET}gcc${EXE_SUFFIX}) +set(CMAKE_LINKER ${TOOLCHAIN_DIR}${TARGET_TRIPLET}gcc${EXE_SUFFIX}) +set(CMAKE_AR ${TOOLCHAIN_DIR}${TARGET_TRIPLET}ar${EXE_SUFFIX}) +set(CMAKE_SIZE_UTIL ${TOOLCHAIN_DIR}${TARGET_TRIPLET}size${EXE_SUFFIX}) +set(CMAKE_STRIP ${TOOLCHAIN_DIR}${TARGET_TRIPLET}strip${EXE_SUFFIX}) +set(CMAKE_OBJCOPY ${TOOLCHAIN_DIR}${TARGET_TRIPLET}objcopy${EXE_SUFFIX}) +set(CMAKE_OBJDUMP ${TOOLCHAIN_DIR}${TARGET_TRIPLET}objdump${EXE_SUFFIX}) +set(CMAKE_NM_UTIL ${TOOLCHAIN_DIR}${TARGET_TRIPLET}gcc-nm${EXE_SUFFIX}) +set(CMAKE_RANLIB ${TOOLCHAIN_DIR}${TARGET_TRIPLET}gcc-ranlib${EXE_SUFFIX}) +set(CMAKE_GCOV ${TOOLCHAIN_DIR}${TARGET_TRIPLET}gcov${EXE_SUFFIX}) + +set(CMAKE_C_STANDARD_REQUIRED OFF) +set(CMAKE_CXX_STANDARD_REQUIRED OFF) +set(CMAKE_C_EXTENSIONS OFF) + +set(CMAKE_C_FLAGS_RELEASE "" CACHE STRING "") +set(CMAKE_CXX_FLAGS_RELEASE "" CACHE STRING "") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_EXECUTABLE_SUFFIX .out) +set(CMAKE_EXECUTABLE_SUFFIX_C .out) +set(CMAKE_EXECUTABLE_SUFFIX_CXX .out) diff --git a/src/ncp-uart-hw/readme.html b/src/ncp-uart-hw/readme.html new file mode 100644 index 00000000..055d0cfc --- /dev/null +++ b/src/ncp-uart-hw/readme.html @@ -0,0 +1,562 @@ + + + + +readme + + +

NCP UART Application

+

This network coprocessor (NCP) application supports communication with a host application over a UART interface with hardware flow control. This NCP application can be built as configured, or optionally can be augmented with customizations for target hardware, initialization, main loop processing, event definition/handling, and messaging with the host. + +As configured, this NCP UART application is the basis for building the corresponding binary ncp-uart images delivered with the Silicon Labs Zigbee stack. + +Due to thread safety concerns with EZSP, this application cannot include an RTOS unless CPC (Co-Processor Communication) components are also added. + +Refer to the Silicon Labs Zigbee documentation for more information about NCP customization. +

+
+ + \ No newline at end of file diff --git a/src/ncp-uart-hw/sl_zigbee_watchdog_periodic_refresh.c b/src/ncp-uart-hw/sl_zigbee_watchdog_periodic_refresh.c new file mode 100644 index 00000000..e3251c3c --- /dev/null +++ b/src/ncp-uart-hw/sl_zigbee_watchdog_periodic_refresh.c @@ -0,0 +1,59 @@ +/***************************************************************************//** + * @file + * @brief Sample watchdog refresh event implementation and related configuration + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include PLATFORM_HEADER +#include "hal.h" +#include "ember.h" +#include "zigbee_app_framework_event.h" +#include "zigbee_app_framework_common.h" +#include "zigbee_watchdog_periodic_refresh_config.h" + +#if (SL_ZIGBEE_WATCHDOG_PERIODIC_REFRESH_ENABLE == 1) + +static sl_zigbee_event_t watchdog_refresh_event; +static void watchdog_refresh_event_handler(sl_zigbee_event_t *event); + +// Initialization of watchdog refresh event +void sli_zigbee_watchdog_refresh_handler_init(uint8_t init_level) +{ + switch (init_level) { + case SL_ZIGBEE_INIT_LEVEL_EVENT: + { + sl_zigbee_event_init(&watchdog_refresh_event, watchdog_refresh_event_handler); + sl_zigbee_event_set_active(&watchdog_refresh_event); + break; + } + default: + break; + } +} + +// In RTOS-based applications, the Zigbee task refreshes the watchdog. +// However, when the node is not on a network the Zigbee task does not run. +// Therefore, there needs to be a way to ensure that the watchdog does not fire +// and reset the node unnecessarily. Below we provide an example of an application +// event that periodically resets the watchdog. +// Note, such a periodic event gets the node out of EM1/EM2 low power modes, +// which may result in unnecessary energy consumption. +// The application should ultimately own the refreshing of the watchdog and tailor +// it based on the specific use case. +// In the bare-metal case, this is done in the zigbee stack and app framework ticks +static void watchdog_refresh_event_handler(sl_zigbee_event_t *event) +{ + halResetWatchdog(); + sl_zigbee_event_set_delay_ms(&watchdog_refresh_event, SL_ZIGBEE_WATCHDOG_REFRESH_DURATION_MS); +} +#endif //(SL_ZIGBEE_WATCHDOG_PERIODIC_REFRESH_ENABLE == 1) diff --git a/src/ot-rcp/.cproject b/src/ot-rcp/.cproject new file mode 100644 index 00000000..4adc9653 --- /dev/null +++ b/src/ot-rcp/.cproject @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ot-rcp/README-OT-RCP.md b/src/ot-rcp/README-OT-RCP.md new file mode 100644 index 00000000..2263b410 --- /dev/null +++ b/src/ot-rcp/README-OT-RCP.md @@ -0,0 +1,15 @@ +# Openthread RCP + +This is a Radio Co-Processor (RCP) application that can be used in tandem with an OpenThread POSIX host application, to demonstrate the Co-Processor design of the OpenThread stack. + +In an RCP design, the core of OpenThread lives on the host processor with only a minimal MAC layer "controller" on the device with the Thread radio. The host processor typically doesn’t sleep in this design, in part to ensure reliability of the Thread network. + +Communication between the RCP and the host processor is managed by the OpenThread Daemon through a SPI or UART interface over the Spinel protocol. + +The advantage of this design is that OpenThread can utilize the resources on the more powerful processor. + +This design is useful for devices that are less sensitive to power constraints. For example, the host processor on a video camera is always on to process video. + +OpenThread Border Router supports an RCP design. For more information, refer to *AN1256: Using the Silicon Labs RCP with the OpenThread Border Router*. + +The corresponding host application is located at `util/third_party/ot-br-posix` \ No newline at end of file diff --git a/src/ot-rcp/app.c b/src/ot-rcp/app.c new file mode 100644 index 00000000..b3af0528 --- /dev/null +++ b/src/ot-rcp/app.c @@ -0,0 +1,99 @@ +/***************************************************************************//** + * @file + * @brief Core application logic. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include +#include +#include + +#include +#include +#include + +#include "openthread-system.h" +#include "app.h" + +#include "reset_util.h" + +/** + * This function initializes the NCP app. + * + * @param[in] aInstance The OpenThread instance structure. + * + */ +extern void otAppNcpInit(otInstance *aInstance); + +static otInstance* sInstance = NULL; + +otInstance *otGetInstance(void) +{ + return sInstance; +} + +void sl_ot_create_instance(void) +{ +#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE + size_t otInstanceBufferLength = 0; + uint8_t *otInstanceBuffer = NULL; + + // Call to query the buffer size + (void)otInstanceInit(NULL, &otInstanceBufferLength); + + // Call to allocate the buffer + otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength); + assert(otInstanceBuffer); + + // Initialize OpenThread with the buffer + sInstance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength); +#else + sInstance = otInstanceInitSingle(); +#endif + assert(sInstance); +} + +void sl_ot_ncp_init(void) +{ + otAppNcpInit(sInstance); +} + +/**************************************************************************//** + * Application Init. + *****************************************************************************/ + +void app_init(void) +{ + OT_SETUP_RESET_JUMP(argv); +} + +/**************************************************************************//** + * Application Process Action. + *****************************************************************************/ +void app_process_action(void) +{ + otTaskletsProcess(sInstance); + otSysProcessDrivers(sInstance); +} + +/**************************************************************************//** + * Application Exit. + *****************************************************************************/ +void app_exit(void) +{ + otInstanceFinalize(sInstance); +#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE + free(otInstanceBuffer); +#endif + // TO DO : pseudo reset? +} diff --git a/src/ot-rcp/app.h b/src/ot-rcp/app.h new file mode 100644 index 00000000..4a8493a9 --- /dev/null +++ b/src/ot-rcp/app.h @@ -0,0 +1,36 @@ +/***************************************************************************//** + * @file + * @brief Application interface provided to main(). + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#ifndef APP_H +#define APP_H + +/**************************************************************************//** + * Application Init. + *****************************************************************************/ +void app_init(void); + +/**************************************************************************//** + * Application Exit. + *****************************************************************************/ +void app_exit(void); + +/**************************************************************************//** + * Application Process Action. + *****************************************************************************/ +void app_process_action(void); + +#endif \ No newline at end of file diff --git a/src/ot-rcp/config/app_properties_config.h b/src/ot-rcp/config/app_properties_config.h new file mode 100644 index 00000000..6a6b9766 --- /dev/null +++ b/src/ot-rcp/config/app_properties_config.h @@ -0,0 +1,65 @@ +/***************************************************************************//** + * @file + * @brief Application Properties Header File + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef APP_PROPERTIES_CONFIG_H +#define APP_PROPERTIES_CONFIG_H + +#include "sl_application_type.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// App Properties settings + +// Type of signature this application is signed with +// Default: APPLICATION_SIGNATURE_NONE(0) +#define SL_APPLICATION_SIGNATURE 0 + +// Location of the signature +// Default: 0xFFFFFFFF +#define SL_APPLICATION_SIGNATURE_LOCATION 0xFFFFFFFF + +// Bitfield representing type of application +#define SL_APPLICATION_TYPE APPLICATION_TYPE + +// Version number for this application +// <0-4294967295:1> +// Default: 1 [0-4294967295] +#define SL_APPLICATION_VERSION 1 + +// Capabilities of this application +// Default: 0 +#define SL_APPLICATION_CAPABILITIES 0 + +//Product ID of the device for which the application is built +#define SL_APPLICATION_PRODUCT_ID { 0 } + +// + +#endif // APP_PROPERTIES_CONFIG_H diff --git a/src/ot-rcp/config/btl_interface_cfg.h b/src/ot-rcp/config/btl_interface_cfg.h new file mode 100644 index 00000000..8e246f80 --- /dev/null +++ b/src/ot-rcp/config/btl_interface_cfg.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_H +#define BTL_INTERFACE_CFG_H + +#if !defined(BOOTLOADER_APPLOADER) + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1) +#include "btl_interface_cfg_s2c1.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_2) +#include "btl_interface_cfg_s2c2.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_3) +#include "btl_interface_cfg_s2c3.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4) +#include "btl_interface_cfg_s2c4.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_8) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#endif // !BOOTLOADER_APPLOADER + +#endif // BTL_INTERFACE_CFG_H diff --git a/src/ot-rcp/config/btl_interface_cfg_s2c1.h b/src/ot-rcp/config/btl_interface_cfg_s2c1.h new file mode 100644 index 00000000..c72c27b0 --- /dev/null +++ b/src/ot-rcp/config/btl_interface_cfg_s2c1.h @@ -0,0 +1,281 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_S2C1_H +#define BTL_INTERFACE_CFG_S2C1_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Bootloader Interface Trust Zone Security State Configuration + +// Disable multi tiered fallback logic +// The fault handling logic as well as the USART auto-detection logic will be disabled. +// The re-configuration of SMU will be handled by querying the running bootloader +// for the peripheral list. Querying the peripheral list is supported from the bootloader +// version 2.0.0. Check for the BOOTLOADER_CAPABILITY_PERIPHERAL_LIST capability to +// see if the running bootloader supports querying the peripheral list. +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 0 + +// Disable peripheral access fault handling +// The fault handling triggered by an erroneous access of peripherals will be disabled. +// +// This should be disabled iff all the peripherals that are in use by the bootloader +// have been properly configured by the "Manually override security state of peripherals" option. +#define BOOTLOADER_DISABLE_NVM3_FAULT_HANDLING 0 + +// Manually override the security state of peripherals in use by the bootloader +// Default: 0. +// Manually override the security state of peripherals. Choose the peripherals touched +// by the customized code to have a valid secure access state before interacting with the bootloader +// In practice, this means that the chosen peripherals will be available at the secure address, +// which is accessible by the bootloader. Once the application is entered back the secure access state +// is changed back to the original state. +// +// The USART auto-detection logic that detects which, if any, USART is in use by the bootloader +// will be disabled. Make sure to choose the correct USART used by the bootloader. +#define BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE 0 +// EMU +// Update secure access state of EMU before calling into bootloader +#define BOOTLOADER_PPUSATD0_EMU 0 + +// CMU +// Update secure access state of CMU before calling into bootloader +#define BOOTLOADER_PPUSATD0_CMU 0 + +// HFXO0 +// Update secure access state of HFXO0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_HFXO0 0 + +// HFRCO0 +// Update secure access state of HFRCO0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_HFRCO0 0 + +// FSRCO +// Update secure access state of FSRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_FSRCO 0 + +// DPLL0 +// Update secure access state of DPLL0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_DPLL0 0 + +// LFXO +// Update secure access state of LFXO before calling into bootloader +#define BOOTLOADER_PPUSATD0_LFXO 0 + +// LFRCO +// Update secure access state of LFRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_LFRCO 0 + +// ULFRCO +// Update secure access state of ULFRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_ULFRCO 0 + +// MSC +// Update secure access state of MSC before calling into bootloader +#define BOOTLOADER_PPUSATD0_MSC 0 + +// ICACHE0 +// Update secure access state of ICACHE0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_ICACHE0 0 + +// PRS +// Update secure access state of PRS before calling into bootloader +#define BOOTLOADER_PPUSATD0_PRS 0 + +// GPIO +// Update secure access state of GPIO before calling into bootloader +#define BOOTLOADER_PPUSATD0_GPIO 0 + +// LDMA +// Update secure access state of LDMA before calling into bootloader +#define BOOTLOADER_PPUSATD0_LDMA 0 + +// LDMAXBAR +// Update secure access state of LDMAXBAR before calling into bootloader +#define BOOTLOADER_PPUSATD0_LDMAXBAR 0 + +// TIMER0 +// Update secure access state of TIMER0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER0 0 + +// TIMER1 +// Update secure access state of TIMER1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER1 0 + +// TIMER2 +// Update secure access state of TIMER2 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER2 0 + +// TIMER3 +// Update secure access state of TIMER3 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER3 0 + +// USART0 +// Update secure access state of USART0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART0 0 + +// USART1 +// Update secure access state of USART1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART1 0 + +// USART2 +// Update secure access state of USART2 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART2 0 + +// BURTC +// Update secure access state of BURTC before calling into bootloader +#define BOOTLOADER_PPUSATD0_BURTC 0 + +// I2C1 +// Update secure access state of I2C1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_I2C1 0 + +// CHIPTESTCTRL +// Update secure access state of CHIPTESTCTRL before calling into bootloader +#define BOOTLOADER_PPUSATD0_CHIPTESTCTRL 0 + +// LVGD +// Update secure access state of LVGD before calling into bootloader +#define BOOTLOADER_PPUSATD0_LVGD 0 + +// SYSCFG +// Update secure access state of SYSCFG before calling into bootloader +#define BOOTLOADER_PPUSATD0_SYSCFG 0 + +// BURAM +// Update secure access state of BURAM before calling into bootloader +#define BOOTLOADER_PPUSATD0_BURAM 0 + +// IFADCDEBUG +// Update secure access state of IFADCDEBUG before calling into bootloader +#define BOOTLOADER_PPUSATD0_IFADCDEBUG 0 + +// GPCRC +// Update secure access state of GPCRC before calling into bootloader +#define BOOTLOADER_PPUSATD0_GPCRC 0 + +// RTCC +// Update secure access state of RTCC before calling into bootloader +#define BOOTLOADER_PPUSATD0_RTCC 0 + +// LETIMER0 +// Update secure access state of LETIMER0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_LETIMER0 0 + +// IADC0 +// Update secure access state of IADC0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_IADC0 0 + +// ACMP0 +// Update secure access state of ACMP0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_ACMP0 0 + +// ACMP1 +// Update secure access state of ACMP1 before calling into bootloader +#define BOOTLOADER_PPUSATD1_ACMP1 0 + +// I2C0 +// Update secure access state of I2C0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_I2C0 0 + +// HFRCOEM23 +// Update secure access state of HFRCOEM23 before calling into bootloader +#define BOOTLOADER_PPUSATD1_HFRCOEM23 0 + +// WDOG0 +// Update secure access state of WDOG0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_WDOG0 0 + +// WDOG1 +// Update secure access state of WDOG1 before calling into bootloader +#define BOOTLOADER_PPUSATD1_WDOG1 0 + +// AMUXCP0 +// Update secure access state of AMUXCP0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_AMUXCP0 0 + +// RADIOAES +// Update secure access state of RADIOAES before calling into bootloader +#define BOOTLOADER_PPUSATD1_RADIOAES 0 + +// BUFC +// Update secure access state of BUFC before calling into bootloader +#define BOOTLOADER_PPUSATD1_BUFC 0 + +// SMU +// Update secure access state of SMU before calling into bootloader +#define BOOTLOADER_PPUSATD1_SMU 0 + +// AHBRADIO +// Update secure access state of AHBRADIO before calling into bootloader +#define BOOTLOADER_PPUSATD1_AHBRADIO 0 + +// SEMAILBOX +// Update secure access state of SEMAILBOX before calling into bootloader +#define BOOTLOADER_PPUSATD1_SEMAILBOX 0 +// + +// +// <<< end of configuration section >>> + +#if BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE == 1 +#define BOOTLOADER_PPUSATD0_MASK ((BOOTLOADER_PPUSATD0_EMU << _SMU_PPUSATD0_EMU_SHIFT) \ + | (BOOTLOADER_PPUSATD0_CMU << _SMU_PPUSATD0_CMU_SHIFT) \ + | (BOOTLOADER_PPUSATD0_HFXO0 << _SMU_PPUSATD0_HFXO0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_HFRCO0 << _SMU_PPUSATD0_HFRCO0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_FSRCO << _SMU_PPUSATD0_FSRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_DPLL0 << _SMU_PPUSATD0_DPLL0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LFXO << _SMU_PPUSATD0_LFXO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LFRCO << _SMU_PPUSATD0_LFRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_ULFRCO << _SMU_PPUSATD0_ULFRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_MSC << _SMU_PPUSATD0_MSC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_ICACHE0 << _SMU_PPUSATD0_ICACHE0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_PRS << _SMU_PPUSATD0_PRS_SHIFT) \ + | (BOOTLOADER_PPUSATD0_GPIO << _SMU_PPUSATD0_GPIO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LDMA << _SMU_PPUSATD0_LDMA_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LDMAXBAR << _SMU_PPUSATD0_LDMAXBAR_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER0 << _SMU_PPUSATD0_TIMER0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER1 << _SMU_PPUSATD0_TIMER1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER2 << _SMU_PPUSATD0_TIMER2_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER3 << _SMU_PPUSATD0_TIMER3_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART0 << _SMU_PPUSATD0_USART0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART1 << _SMU_PPUSATD0_USART1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART2 << _SMU_PPUSATD0_USART2_SHIFT) \ + | (BOOTLOADER_PPUSATD0_BURTC << _SMU_PPUSATD0_BURTC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_I2C1 << _SMU_PPUSATD0_I2C1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_CHIPTESTCTRL << _SMU_PPUSATD0_CHIPTESTCTRL_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LVGD << _SMU_PPUSATD0_LVGD_SHIFT) \ + | (BOOTLOADER_PPUSATD0_SYSCFG << _SMU_PPUSATD0_SYSCFG_SHIFT) \ + | (BOOTLOADER_PPUSATD0_BURAM << _SMU_PPUSATD0_BURAM_SHIFT) \ + | (BOOTLOADER_PPUSATD0_IFADCDEBUG << _SMU_PPUSATD0_IFADCDEBUG_SHIFT) \ + | (BOOTLOADER_PPUSATD0_GPCRC << _SMU_PPUSATD0_GPCRC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_RTCC << _SMU_PPUSATD0_RTCC_SHIFT)) +#define BOOTLOADER_PPUSATD1_MASK ((BOOTLOADER_PPUSATD1_LETIMER0 << _SMU_PPUSATD1_LETIMER0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_IADC0 << _SMU_PPUSATD1_IADC0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_ACMP0 << _SMU_PPUSATD1_ACMP0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_ACMP1 << _SMU_PPUSATD1_ACMP1_SHIFT) \ + | (BOOTLOADER_PPUSATD1_I2C0 << _SMU_PPUSATD1_I2C0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_HFRCOEM23 << _SMU_PPUSATD1_HFRCOEM23_SHIFT) \ + | (BOOTLOADER_PPUSATD1_WDOG0 << _SMU_PPUSATD1_WDOG0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_WDOG1 << _SMU_PPUSATD1_WDOG1_SHIFT) \ + | (BOOTLOADER_PPUSATD1_AMUXCP0 << _SMU_PPUSATD1_AMUXCP0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_RADIOAES << _SMU_PPUSATD1_RADIOAES_SHIFT) \ + | (BOOTLOADER_PPUSATD1_BUFC << _SMU_PPUSATD1_BUFC_SHIFT) \ + | (BOOTLOADER_PPUSATD1_SMU << _SMU_PPUSATD1_SMU_SHIFT) \ + | (BOOTLOADER_PPUSATD1_AHBRADIO << _SMU_PPUSATD1_AHBRADIO_SHIFT) \ + | (BOOTLOADER_PPUSATD1_SEMAILBOX << _SMU_PPUSATD1_SEMAILBOX_SHIFT)) +#endif // BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE + +#endif // BTL_INTERFACE_CFG_S2C1_H diff --git a/src/ot-rcp/config/dmadrv_config.h b/src/ot-rcp/config/dmadrv_config.h new file mode 100644 index 00000000..ed105e4f --- /dev/null +++ b/src/ot-rcp/config/dmadrv_config.h @@ -0,0 +1,26 @@ +#ifndef DMADRV_CONFIG_H +#define DMADRV_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// DMA interrupt priority <0-15> +// Priority of the DMA interrupt. Smaller number equals higher priority. +// Default: 8 +#define EMDRV_DMADRV_DMA_IRQ_PRIORITY 8 + +// Number of available channels <1-8> +// Number of DMA channels supported by the driver. A lower channel count +// will reduce RAM memory footprint. The default is to support all channels +// on the device. +// Default: 8 +#define EMDRV_DMADRV_DMA_CH_COUNT 8 + +// Number of fixed priority channels +// This will configure channels [0, CH_PRIORITY - 1] as fixed priority, +// and channels [CH_PRIORITY, CH_COUNT] as round-robin. +// Default: 0 +#define EMDRV_DMADRV_DMA_CH_PRIORITY 0 + +// <<< end of configuration section >>> + +#endif // DMADRV_CONFIG_H diff --git a/src/ot-rcp/config/emlib_core_debug_config.h b/src/ot-rcp/config/emlib_core_debug_config.h new file mode 100644 index 00000000..07ee9b9e --- /dev/null +++ b/src/ot-rcp/config/emlib_core_debug_config.h @@ -0,0 +1,45 @@ +/***************************************************************************//** + * @file + * @brief emlib_core Configuration + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef EM_CORE_DEBUG_CONFIG_H +#define EM_CORE_DEBUG_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Core Configuration + +// Enables measuring of interrupt disable time for debugging purposes. +// Default: 0 +#define SL_EMLIB_CORE_ENABLE_INTERRUPT_DISABLED_TIMING 0 + +// + +// <<< end of configuration section >>> +#endif // EM_CORE_CONFIG_H diff --git a/src/ot-rcp/config/nvm3_default_config.h b/src/ot-rcp/config/nvm3_default_config.h new file mode 100644 index 00000000..48eb5896 --- /dev/null +++ b/src/ot-rcp/config/nvm3_default_config.h @@ -0,0 +1,45 @@ +#ifndef NVM3_DEFAULT_CONFIG_H +#define NVM3_DEFAULT_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// NVM3 Default Instance Configuration + +#ifndef NVM3_DEFAULT_CACHE_SIZE +// NVM3 Default Instance Cache Size +// Number of NVM3 objects to cache. To reduce access times this number +// should be equal to or higher than the number of NVM3 objects in the +// default NVM3 instance. +// Default: 200 +#define NVM3_DEFAULT_CACHE_SIZE 200 +#endif + +#ifndef NVM3_DEFAULT_MAX_OBJECT_SIZE +// NVM3 Default Instance Max Object Size +// Max NVM3 object size that can be stored. +// Default: 254 +#define NVM3_DEFAULT_MAX_OBJECT_SIZE 254 +#endif + +#ifndef NVM3_DEFAULT_REPACK_HEADROOM +// NVM3 Default Instance User Repack Headroom +// Headroom determining how many bytes below the forced repack limit the user +// repack limit should be placed. The default is 0, which means the user and +// forced repack limits are equal. +// Default: 0 +#define NVM3_DEFAULT_REPACK_HEADROOM 0 +#endif + +#ifndef NVM3_DEFAULT_NVM_SIZE +// NVM3 Default Instance Size +// Size of the NVM3 storage region in flash. This size should be aligned with +// the flash page size of the device. +// Default: 40960 +#define NVM3_DEFAULT_NVM_SIZE 40960 +#endif + +// + +// <<< end of configuration section >>> + +#endif // NVM3_DEFAULT_CONFIG_H diff --git a/src/ot-rcp/config/pin_config.h b/src/ot-rcp/config/pin_config.h new file mode 100644 index 00000000..ceb0ee66 --- /dev/null +++ b/src/ot-rcp/config/pin_config.h @@ -0,0 +1,173 @@ +#ifndef PIN_CONFIG_H +#define PIN_CONFIG_H + +// $[CMU] +// [CMU]$ + +// $[LFXO] +// [LFXO]$ + +// $[PRS.ASYNCH0] +// [PRS.ASYNCH0]$ + +// $[PRS.ASYNCH1] +// [PRS.ASYNCH1]$ + +// $[PRS.ASYNCH2] +// [PRS.ASYNCH2]$ + +// $[PRS.ASYNCH3] +// [PRS.ASYNCH3]$ + +// $[PRS.ASYNCH4] +// [PRS.ASYNCH4]$ + +// $[PRS.ASYNCH5] +// [PRS.ASYNCH5]$ + +// $[PRS.ASYNCH6] +// [PRS.ASYNCH6]$ + +// $[PRS.ASYNCH7] +// [PRS.ASYNCH7]$ + +// $[PRS.ASYNCH8] +// [PRS.ASYNCH8]$ + +// $[PRS.ASYNCH9] +// [PRS.ASYNCH9]$ + +// $[PRS.ASYNCH10] +// [PRS.ASYNCH10]$ + +// $[PRS.ASYNCH11] +// [PRS.ASYNCH11]$ + +// $[PRS.SYNCH0] +// [PRS.SYNCH0]$ + +// $[PRS.SYNCH1] +// [PRS.SYNCH1]$ + +// $[PRS.SYNCH2] +// [PRS.SYNCH2]$ + +// $[PRS.SYNCH3] +// [PRS.SYNCH3]$ + +// $[GPIO] +// GPIO SWV on PA03 +#ifndef GPIO_SWV_PORT +#define GPIO_SWV_PORT gpioPortA +#endif +#ifndef GPIO_SWV_PIN +#define GPIO_SWV_PIN 3 +#endif + +// [GPIO]$ + +// $[TIMER0] +// [TIMER0]$ + +// $[TIMER1] +// [TIMER1]$ + +// $[TIMER2] +// [TIMER2]$ + +// $[TIMER3] +// [TIMER3]$ + +// $[USART0] +// USART0 CTS on PC03 +#ifndef USART0_CTS_PORT +#define USART0_CTS_PORT gpioPortC +#endif +#ifndef USART0_CTS_PIN +#define USART0_CTS_PIN 3 +#endif + +// USART0 RTS on PC02 +#ifndef USART0_RTS_PORT +#define USART0_RTS_PORT gpioPortC +#endif +#ifndef USART0_RTS_PIN +#define USART0_RTS_PIN 2 +#endif + +// USART0 RX on PA06 +#ifndef USART0_RX_PORT +#define USART0_RX_PORT gpioPortA +#endif +#ifndef USART0_RX_PIN +#define USART0_RX_PIN 6 +#endif + +// USART0 TX on PA05 +#ifndef USART0_TX_PORT +#define USART0_TX_PORT gpioPortA +#endif +#ifndef USART0_TX_PIN +#define USART0_TX_PIN 5 +#endif + +// [USART0]$ + +// $[USART1] +// [USART1]$ + +// $[USART2] +// [USART2]$ + +// $[I2C1] +// [I2C1]$ + +// $[LETIMER0] +// [LETIMER0]$ + +// $[IADC0] +// [IADC0]$ + +// $[ACMP0] +// [ACMP0]$ + +// $[ACMP1] +// [ACMP1]$ + +// $[I2C0] +// [I2C0]$ + +// $[PTI] +// PTI DFRAME on PC05 +#ifndef PTI_DFRAME_PORT +#define PTI_DFRAME_PORT gpioPortC +#endif +#ifndef PTI_DFRAME_PIN +#define PTI_DFRAME_PIN 5 +#endif + +// PTI DOUT on PC04 +#ifndef PTI_DOUT_PORT +#define PTI_DOUT_PORT gpioPortC +#endif +#ifndef PTI_DOUT_PIN +#define PTI_DOUT_PIN 4 +#endif + +// [PTI]$ + +// $[MODEM] +// [MODEM]$ + +// $[CUSTOM_PIN_NAME] +#ifndef _PORT +#define _PORT gpioPortA +#endif +#ifndef _PIN +#define _PIN 0 +#endif + +// [CUSTOM_PIN_NAME]$ + +#endif // PIN_CONFIG_H + diff --git a/src/ot-rcp/config/psa_crypto_config.h b/src/ot-rcp/config/psa_crypto_config.h new file mode 100644 index 00000000..7d9144b3 --- /dev/null +++ b/src/ot-rcp/config/psa_crypto_config.h @@ -0,0 +1,134 @@ +#ifndef PSA_CRYPTO_CONFIG_H +#define PSA_CRYPTO_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// Key management configuration + +// PSA User Maximum Open Keys Count <0-128> +// Maximum amount of keys that the user application will have open +// simultaneously. In context of PSA Crypto, an open key means any key +// either stored in RAM (lifetime set to PSA_KEY_LIFETIME_VOLATILE), or +// used as part of a cryptographic operation. +// When using a key for a multi-part (setup/update/finish) operation, a key +// is considered to be open from the moment the operation is successfully +// setup, until it finishes or aborts. +// When an application tries to open more keys than this value accounts for, +// the PSA API may return PSA_ERROR_INSUFFICIENT_MEMORY. Keep in mind that +// other software included in the application (e.g. wireless protocol stacks) +// also can have a need to have open keys in PSA Crypto. This could lead to +// a race condition when the application key slot count is set too low for +// the actual usage of the application, as a software stack may not fail +// gracefully in case an application opens more than its declared amount of +// keys, thereby precluding the stack from functioning. +// Default: 4 +#define SL_PSA_KEY_USER_SLOT_COUNT (4) + +// PSA Maximum User Persistent Keys Count <0-1024> +// Maximum amount of keys (or other files) that can be stored persistently +// by the application through the PSA interface, when persistent storage +// support for PSA Crypto is included in the project. +// Due to caching logic, this setting does have an impact on static RAM usage. +// Note that this number is added to the potential requirements from other +// software components in the project, such that the total amount of keys +// which can be stored through the ITS backend can be higher than what is +// configured here. +// +// WARNING: When changing this setting on an application that is already +// deployed, and thus will get the change through an application upgrade, +// care should be taken to ensure that the setting is only ever increased, +// and never decreased. Decreasing this setting might cause previously +// stored keys/files to become inaccessible. +// +// It is not possible to change this setting when using V3 ITS Driver. +// The file-storage indexing is dependent on the maximum number of files, +// and if SL_PSA_ITS_USER_MAX_FILES is changed, ITS should be cleared and +// all files need to be stored again. +// Default: 128 +#define SL_PSA_ITS_USER_MAX_FILES (128) + +// Enable V1 Format Support For ITS Files <0-1> +// Devices that used PSA ITS together with gecko_sdk_3.1.x or earlier +// might have keys (or other files) stored in V1 format. +// If no v1 files are used, its support can be disabled for space +// optimization. +// Default: 0 +#define SL_PSA_ITS_SUPPORT_V1_DRIVER 0 + +// Enable V2 ITS Driver Support <0-1> +// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys +// (or other files) stored using different address range. Enabling this +// config option adds upgrade code which converts V2 (and V1 if +// supported) format ITS keys/files to the latest V3 format. Update is +// fully automatic, needs to be run once and require extra flash space of +// approximately the size of the largest key. +// V1 ITS driver support can be disabled if the device has never used ITS +// driver before in GSDK 4.1.x and earlier, or the keys has been already +// migrated. +// Default: 0 +#define SL_PSA_ITS_SUPPORT_V2_DRIVER 0 + +// Enable support for V3 ITS Driver <0-1> +// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys +// (or other files) stored using different address range. In rare case +// that those devices have full nvm3 and not enough space for the +// upgrade, (that requires an extra space to store largest key in memory +// twice), this config option can disable v3 driver and use v2 one. +// To upgrade the device, make space for the upgrade, and enable v3 driver again. +// +// WARNING: When using V3 driver, it is not possible to increase or decrease +// the value of SL_PSA_ITS_USER_MAX_FILES. If the change of +// SL_PSA_ITS_USER_MAX_FILES is required, ITS should be cleared and +// all files need to be stored again. +// Default: 1 +#define SL_PSA_ITS_SUPPORT_V3_DRIVER 1 + +// Built-in AES Key Mode of Operation +// CTR Mode +// CFB Mode +// OFB Mode +// ECB Mode +// CBC Mode (no padding) +// CBC Mode (PKCS#7 padding) +// PSA Crypto only allows one specific usage algorithm per built-in key ID. +// Default: PSA_ALG_CTR +#define SL_SE_BUILTIN_KEY_AES128_ALG_CONFIG (PSA_ALG_CTR) + +#ifndef SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG +// Built-in PUF Key Algorithm +// PBKDF2 (CMAC-AES-128-PRF) +// CMAC +// PSA Crypto only allows one specific usage algorithm per built-in key ID. +// It is recommended to only use the PUF key for deriving further key +// material. +// Default: PSA_ALG_PBKDF2_AES_CMAC_PRF_128 +#define SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG (PSA_ALG_PBKDF2_AES_CMAC_PRF_128) +#endif // SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Sub-files + +#if defined(SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE) + #include SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE +#else + #include "sli_psa_config_autogen.h" +#endif + +#if defined(TFM_CONFIG_SL_SECURE_LIBRARY) + #include "sli_psa_tfm_translation.h" +#endif + +#if SL_MBEDTLS_DRIVERS_ENABLED + #include "sli_psa_acceleration.h" +#endif + +#include "sli_psa_builtin_config_autogen.h" + +#endif // PSA_CRYPTO_CONFIG_H diff --git a/src/ot-rcp/config/sl_board_control_config.h b/src/ot-rcp/config/sl_board_control_config.h new file mode 100644 index 00000000..f1804587 --- /dev/null +++ b/src/ot-rcp/config/sl_board_control_config.h @@ -0,0 +1,56 @@ +/***************************************************************************//** + * @file + * @brief Board Control + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_BOARD_CONTROL_CONFIG_H +#define SL_BOARD_CONTROL_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Enable Virtual COM UART +// Default: 0 +#define SL_BOARD_ENABLE_VCOM 1 + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +// SL_BOARD_ENABLE_VCOM +// $[GPIO_SL_BOARD_ENABLE_VCOM] +#ifndef SL_BOARD_ENABLE_VCOM_PORT +#define SL_BOARD_ENABLE_VCOM_PORT gpioPortD +#endif +#ifndef SL_BOARD_ENABLE_VCOM_PIN +#define SL_BOARD_ENABLE_VCOM_PIN 4 +#endif +// [GPIO_SL_BOARD_ENABLE_VCOM]$ + +// <<< sl:end pin_tool >>> + +#endif // SL_BOARD_CONTROL_CONFIG_H diff --git a/src/ot-rcp/config/sl_debug_swo_config.h b/src/ot-rcp/config/sl_debug_swo_config.h new file mode 100644 index 00000000..fee7e65d --- /dev/null +++ b/src/ot-rcp/config/sl_debug_swo_config.h @@ -0,0 +1,106 @@ +/***************************************************************************//** + * @file + * @brief SWO configuration + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEBUG_SWO_CONFIG_H +#define SL_DEBUG_SWO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// SWO Configuration + +// SWO Frequency +// Must be 875 kHz for communication with Silicon Labs debuggers +// Default: 875000 +#define SL_DEBUG_SWO_FREQ 875000 + +// Enable interrupt event trace +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_IRQ 0 + +// Enable Program Counter samples +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_PC 0 + +// SWO debug sample intervals +// <64=> 64 +// <128=> 128 +// <192=> 192 +// <256=> 256 +// <320=> 320 +// <384=> 384 +// <448=> 448 +// <512=> 512 +// <576=> 576 +// <640=> 640 +// <704=> 704 +// <768=> 768 +// <832=> 832 +// <896=> 896 +// <960=> 960 +// <1024=> 1024 +// <2048=> 2048 +// <3072=> 3072 +// <4096=> 4096 +// <5102=> 5102 +// <6144=> 6144 +// <7168=> 7168 +// <8192=> 8192 +// <9216=> 9216 +// <10240=> 10240 +// <11264=> 11264 +// <12288=> 12288 +// <13312=> 13312 +// <14336=> 14336 +// <15360=> 15360 +// Must be 64, 128, 192, [ n * 64 ], 1024, 2048, 3072, [ n * 1024 ] , 15360 +// Default: 15360 +#define SL_DEBUG_SWO_SAMPLE_INTERVAL 15360 +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_DEBUG +// $[GPIO_SL_DEBUG] +#ifndef SL_DEBUG_PERIPHERAL +#define SL_DEBUG_PERIPHERAL GPIO +#endif + +// GPIO SWV on PA03 +#ifndef SL_DEBUG_SWV_PORT +#define SL_DEBUG_SWV_PORT gpioPortA +#endif +#ifndef SL_DEBUG_SWV_PIN +#define SL_DEBUG_SWV_PIN 3 +#endif +// [GPIO_SL_DEBUG]$ +// <<< sl:end pin_tool >>> + +#endif // SL_DEBUG_SWO_CONFIG_H diff --git a/src/ot-rcp/config/sl_device_init_emu_config.h b/src/ot-rcp/config/sl_device_init_emu_config.h new file mode 100644 index 00000000..4ac96bac --- /dev/null +++ b/src/ot-rcp/config/sl_device_init_emu_config.h @@ -0,0 +1,53 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_EMU Config + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_EMU_CONFIG_H +#define SL_DEVICE_INIT_EMU_CONFIG_H + +#include "em_emu.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// Allow debugger to remain connected in EM2 +// Force PD0B to stay on on EM2 entry. This allows the debugger to remain connected in EM2 and EM3. +// Enabling debug connectivity results in an increased power consumption in EM2/EM3. +// Default: 1 +#define SL_DEVICE_INIT_EMU_EM2_DEBUG_ENABLE 1 + +// EM4 pin retention mode +// No Retention: Pads enter reset state when entering EM4. +// Retention through EM4: Pads enter reset state when exiting EM4. +// Retention through EM4 and wakeup. +// Default: emuPinRetentionDisable +#define SL_DEVICE_INIT_EMU_EM4_PIN_RETENTION_MODE emuPinRetentionDisable + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_EMU_CONFIG_H diff --git a/src/ot-rcp/config/sl_device_init_hfrco_config.h b/src/ot-rcp/config/sl_device_init_hfrco_config.h new file mode 100644 index 00000000..d2d99400 --- /dev/null +++ b/src/ot-rcp/config/sl_device_init_hfrco_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFRCO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFRCO_CONFIG_H +#define SL_DEVICE_INIT_HFRCO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Frequency Band +// RC Oscillator Frequency Band +// 1 MHz +// 2 MHz +// 4 MHz +// 7 MHz +// 13 MHz +// 16 MHz +// 19 MHz +// 26 MHz +// 32 MHz +// 38 MHz +// 48 MHz +// 56 MHz +// 64 MHz +// 80 MHz +// Default: cmuHFRCODPLLFreq_80M0Hz +#define SL_DEVICE_INIT_HFRCO_BAND cmuHFRCODPLLFreq_80M0Hz + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFRCO_CONFIG_H diff --git a/src/ot-rcp/config/sl_device_init_hfxo_config.h b/src/ot-rcp/config/sl_device_init_hfxo_config.h new file mode 100644 index 00000000..6a35767e --- /dev/null +++ b/src/ot-rcp/config/sl_device_init_hfxo_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFXO_CONFIG_H +#define SL_DEVICE_INIT_HFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// External sine wave +// Default: cmuHfxoOscMode_Crystal +#define SL_DEVICE_INIT_HFXO_MODE cmuHfxoOscMode_Crystal + +// Frequency <38000000-40000000> +// Default: 38400000 +#define SL_DEVICE_INIT_HFXO_FREQ 38400000 + +// HFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_HFXO_PRECISION 50 + +// CTUNE <0-255> +// Default: 140 +#define SL_DEVICE_INIT_HFXO_CTUNE 133 + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFXO_CONFIG_H diff --git a/src/ot-rcp/config/sl_device_init_lfxo_config.h b/src/ot-rcp/config/sl_device_init_lfxo_config.h new file mode 100644 index 00000000..6bd763ba --- /dev/null +++ b/src/ot-rcp/config/sl_device_init_lfxo_config.h @@ -0,0 +1,66 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_LFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_LFXO_CONFIG_H +#define SL_DEVICE_INIT_LFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// AC-coupled buffer +// External digital clock +// Default: cmuLfxoOscMode_Crystal +#define SL_DEVICE_INIT_LFXO_MODE cmuLfxoOscMode_Crystal + +// CTUNE <0-127> +// Default: 63 +#define SL_DEVICE_INIT_LFXO_CTUNE 79 + +// LFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_LFXO_PRECISION 50 + +// Startup Timeout Delay +// +// 2 cycles +// 256 cycles +// 1K cycles +// 2K cycles +// 4K cycles +// 8K cycles +// 16K cycles +// 32K cycles +// Default: cmuLfxoStartupDelay_4KCycles +#define SL_DEVICE_INIT_LFXO_TIMEOUT cmuLfxoStartupDelay_4KCycles +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_LFXO_CONFIG_H diff --git a/src/ot-rcp/config/sl_mbedtls_config.h b/src/ot-rcp/config/sl_mbedtls_config.h new file mode 100644 index 00000000..39b51496 --- /dev/null +++ b/src/ot-rcp/config/sl_mbedtls_config.h @@ -0,0 +1,118 @@ +#ifndef SL_MBEDTLS_CONFIG_H +#define SL_MBEDTLS_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// TLS/DTLS configuration + +// Complete list of ciphersuites to use, in order of preference. +// Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 +// Complete list of ciphersuites to use, in order of preference. +// The value of this configuration should be updated for the application needs. +#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + +// Maximum TLS/DTLS fragment length in bytes (input). +// Default: 768 +// The size configured here determines the size of the internal I/O +// buffer used in mbedTLS when receiving data. +#define SL_MBEDTLS_SSL_IN_CONTENT_LEN 768 + +// Maximum TLS/DTLS fragment length in bytes (output). +// Default: 768 +// The size configured here determines the size of the internal I/O +// buffer used in mbedTLS when sending data. +#define SL_MBEDTLS_SSL_OUT_CONTENT_LEN 768 + +// Enable support for RFC 6066 max_fragment_length extension in SSL. +// Default: 1 +// Enable support for RFC 6066 max_fragment_length extension in SSL. +#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1 + +// Enable support for exporting key block and master secret. +// Default: 1 +// Enable support for exporting key block and master secret. +// This is required for certain users of TLS, e.g. EAP-TLS. +#define SL_MBEDTLS_SSL_EXPORT_KEYS 1 + +// Enable the PSK based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the PSK based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 0 + +// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0 + +// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 0 + +// Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED 0 + +// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0 + +// Enable parsing of the compressed curves. +// Default: 0 +// Enable parsing of the compressed curves. +#define SL_MBEDTLS_ECP_ENABLE_COMPRESSED_CURVE_PARSING 0 + +// + +// RSA configuration + +// Disable use of the Chinese Remainder Theorem for RSA. +// Default: 0 +// Disable use of the Chinese Remainder Theorem for RSA private key +// computations. +#define SL_MBEDTLS_RSA_NO_CRT 0 + +// + +// Miscellaneous configuration + +// Enable Silicon Labs' Mbed TLS- and PSA Crypto drivers. +// Default: 1 +// Enable drivers for hardware acceleration (Mbed TLS and PSA Crypto) and +// secure key handling (PSA Crypto). +#define SL_MBEDTLS_DRIVERS_ENABLED 1 + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Sub-files + +#if defined(SLI_MBEDTLS_CONFIG_AUTOGEN_OVERRIDE_FILE) + #include SLI_MBEDTLS_CONFIG_AUTOGEN_OVERRIDE_FILE +#else + #include "sli_mbedtls_config_autogen.h" +#endif + +#include "sli_mbedtls_omnipresent.h" + +#if SL_MBEDTLS_DRIVERS_ENABLED + #include "sli_mbedtls_acceleration.h" +#endif + +#include "sl_mbedtls_device_config.h" + +// Include transformation logic to apply CMSIS-config configuration options to +// the correct Mbed TLS / PSA Crypto options. +#include "sli_mbedtls_config_transform_autogen.h" + +// Included for backward compatibility reasons. +#include "mbedtls/build_info.h" + +#endif // SL_MBEDTLS_CONFIG_H diff --git a/src/ot-rcp/config/sl_mbedtls_device_config.h b/src/ot-rcp/config/sl_mbedtls_device_config.h new file mode 100644 index 00000000..33c34c42 --- /dev/null +++ b/src/ot-rcp/config/sl_mbedtls_device_config.h @@ -0,0 +1,72 @@ +#ifndef SL_MBEDTLS_DEVICE_CONFIG_H +#define SL_MBEDTLS_DEVICE_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// Secure Engine (SE) version configuration + +// Support SE firmware versions older than 1.2.2 <0-1> +// Enable software fallback for ECDH and ECC public key validation on xG21 +// devices running SE firmware versions lower than 1.2.2. +// +// Due to other stability concerns, it is strongly recommended to upgrade +// these devices to the latest firmware revision instead of turning on +// software fallback support. +// +// Not having fallback support will make ECDH operations, as well as PSA +// Crypto public key import, return an error code on affected devices. +// +// Default: 0 +#define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 0 + +// Assume an SE firmware version newer than 1.2.2 <0-1> +// For enhanced performance: if it is guaranteed that all devices on which +// this library will run are updated to at least SE FW 1.2.2, then turning +// on this option will remove certain fallback checks, thereby reducing the +// amount of processing required for ECDH and public key verification +// operations. +// Default: 0 +#define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 0 + +// Assume an SE firmware version that is unaffected by Ed25519 errata <0-1> +// For minimal code size and performance savings: if it is guaranteed that +// none of the devices running this library has SE FWs in the range +// [1.2.2, 1.2.8], then enabling this option will disable runtime version +// checks. +// Default: 0 +#define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 0 + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Additional SE version related logic (DO NOT MODIFY) + +// SL_SE_ASSUME_FW_AT_LEAST_1_2_10 is no longer in use, however, it is kept here +// for backwards compatibility. */ +#if defined(SL_SE_ASSUME_FW_AT_LEAST_1_2_10) + #undef SL_SE_ASSUME_FW_AT_LEAST_1_2_2 + #define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1 + #undef SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA + #define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 1 +#endif + +// SLI_SE_SUPPORT_FW_PRIOR_TO_1_2_2 is no longer in use, however, it is kept +// here for backwards compatibility. */ +#if defined(SLI_SE_SUPPORT_FW_PRIOR_TO_1_2_2) + #undef SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 + #define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 1 +#endif + +// SLI_SE_ASSUME_FW_AT_LEAST_1_2_2 is no longer in use, however, it is kept +// here for backwards compatibility. */ +#if defined(SLI_SE_ASSUME_FW_AT_LEAST_1_2_2) + #undef SL_SE_ASSUME_FW_AT_LEAST_1_2_2 + #define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1 +#endif + +#endif // SL_MBEDTLS_DEVICE_CONFIG_H diff --git a/src/ot-rcp/config/sl_memory_config.h b/src/ot-rcp/config/sl_memory_config.h new file mode 100644 index 00000000..b43ebcba --- /dev/null +++ b/src/ot-rcp/config/sl_memory_config.h @@ -0,0 +1,28 @@ +#ifndef SL_MEMORY_CONFIG_H +#define SL_MEMORY_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Memory configuration + +// Stack size for the application. +// Default: 4096 +// The stack size configured here will be used by the stack that the +// application uses when coming out of a reset. +#ifndef SL_STACK_SIZE + #define SL_STACK_SIZE 4096 +#endif + +// Minimum heap size for the application. +// Default: 2048 +// Note that this value will configure the c heap which is normally used by +// malloc() and free() from the c library. The value defines a minimum heap +// size that is guaranteed to be available. The available heap may be larger +// to make use of any memory that would otherwise remain unused. +#ifndef SL_HEAP_SIZE + #define SL_HEAP_SIZE 2048 +#endif + +// +// <<< end of configuration section >>> + +#endif diff --git a/src/ot-rcp/config/sl_openthread_features_config.h b/src/ot-rcp/config/sl_openthread_features_config.h new file mode 100644 index 00000000..ed8934af --- /dev/null +++ b/src/ot-rcp/config/sl_openthread_features_config.h @@ -0,0 +1,327 @@ +#ifndef _SL_OPENTHREAD_FEATURES_CONFIG_H +#define _SL_OPENTHREAD_FEATURES_CONFIG_H +//-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- +// +// Default OpenThread Stack Configuration + +// Thread Stack Protocol Version +// +// Thread 1.1 +// Thread 1.2 +// Thread 1.3 +// Thread 1.2 and Thread 1.3 are compatible with Thread 1.1. +// Current Default: OT_THREAD_VERSION_1_3 +#ifndef OPENTHREAD_CONFIG_THREAD_VERSION +#define OPENTHREAD_CONFIG_THREAD_VERSION OT_THREAD_VERSION_1_3 +#endif +// + +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) +// The following features require at least Thread Stack Protocol Version 1.2 +// Backbone Router +#ifndef OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE +#define OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE 0 +#endif +// CSL Auto Synchronization using data polling +#ifndef OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE +#define OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE 1 +#endif +// CSL (Coordinated Sampled Listening) Debug +#ifndef OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE +#define OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE 0 +#endif +// CSL (Coordinated Sampled Listening) Receiver +#ifndef OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE +#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1 +#endif +// CSL Scheduling Uncertainty (±10 us units) <12..999:1> +#ifndef SL_OPENTHREAD_CSL_TX_UNCERTAINTY +#if OPENTHREAD_RADIO + #define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 175 +#elif OPENTHREAD_FTD + #define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 20 +#else + #define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 12 +#endif +#endif +// DUA (Domain Unicast Address) +#ifndef OPENTHREAD_CONFIG_DUA_ENABLE +#define OPENTHREAD_CONFIG_DUA_ENABLE 1 +#endif +// Link Metrics Initiator +#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1 +#endif +// Link Metrics Subject +#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1 +#endif +// Multicast Listener Registration +#ifndef OPENTHREAD_CONFIG_MLR_ENABLE +#define OPENTHREAD_CONFIG_MLR_ENABLE 1 +#endif +// DNS Client (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1 +#endif +// DNS-SD Server (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE +#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 0 +#endif +// Service Registration Protocol (SRP) Client (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1 +#endif +// Service Registration Protocol (SRP) Server (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_SRP_SERVER_ENABLE +#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 0 +#endif +// TCPlp (Low power TCP over OpenThread) (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_TCP_ENABLE +#define OPENTHREAD_CONFIG_TCP_ENABLE 0 +#endif +// Thread over Infrastructure (Thread 1.3: NCP only) +#ifndef OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE +#define OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE 0 +#endif +// +#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 + +// Border Agent +#ifndef OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE +#define OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE 0 +#endif +// +// Border Router +#ifndef OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE +#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 0 +#endif +// +// Channel Manager +#ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE +#define OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE 0 +#endif +// +// Channel Monitor +#ifndef OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE +#define OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE 0 +#endif +// + +// Commissioner +#ifndef OPENTHREAD_CONFIG_COMMISSIONER_ENABLE +#define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 0 +#endif + +// Max Joiner Entries +// The maximum number of Joiner entries maintained by the Commissioner. +// 2 +#ifndef OPENTHREAD_CONFIG_COMMISSIONER_MAX_JOINER_ENTRIES +#define OPENTHREAD_CONFIG_COMMISSIONER_MAX_JOINER_ENTRIES 2 +#endif +// + +// COAP API +#ifndef OPENTHREAD_CONFIG_COAP_API_ENABLE +#define OPENTHREAD_CONFIG_COAP_API_ENABLE 0 +#endif +// +// COAP Observe (RFC7641) API +#ifndef OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE +#define OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE 0 +#endif +// +// COAP Secure API +#ifndef OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE +#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 0 +#endif +// +// DHCP6 Client +#ifndef OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 0 +#endif +// +// DHCP6 Server +#ifndef OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE +#define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 0 +#endif +// +// Diagnostic +#ifndef OPENTHREAD_CONFIG_DIAG_ENABLE +#define OPENTHREAD_CONFIG_DIAG_ENABLE 0 +#endif +// +// ECDSA (Elliptic Curve Digital Signature Algorithm) (Required for Matter support) +#ifndef OPENTHREAD_CONFIG_ECDSA_ENABLE +#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1 +#endif +// +// External Heap +#ifndef OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE +#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 0 +#endif +// +// IPv6 Fragmentation +#ifndef OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE +#define OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE 0 +#endif +// +// Maximum number of IPv6 unicast addresses allowed to be externally added +#ifndef OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS +#define OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS 4 +#endif +// +// Maximum number of IPv6 multicast addresses allowed to be externally added +#ifndef OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS +#define OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS 4 +#endif +// +// Jam Detection +#ifndef OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE +#define OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE 0 +#endif +// +// Joiner +#ifndef OPENTHREAD_CONFIG_JOINER_ENABLE +#define OPENTHREAD_CONFIG_JOINER_ENABLE 0 +#endif +// +// Link Raw Service +#ifndef OPENTHREAD_CONFIG_LINK_RAW_ENABLE +#define OPENTHREAD_CONFIG_LINK_RAW_ENABLE 0 +#endif +// +// MAC Filter +#ifndef OPENTHREAD_CONFIG_MAC_FILTER_ENABLE +#define OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 0 +#endif +// +// MLE Long Routes extension (experimental) +#ifndef OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE +#define OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE 0 +#endif +// +// MultiPAN RCP +#ifndef OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE +#define OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE 0 +#endif +// +// Multiple OpenThread Instances +#ifndef OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE +#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 0 +#endif +// +// OTNS (OpenThread Network Simulator) +#ifndef OPENTHREAD_CONFIG_OTNS_ENABLE +#define OPENTHREAD_CONFIG_OTNS_ENABLE 0 +#endif +// +// Ping Sender Module +#ifndef OPENTHREAD_CONFIG_PING_SENDER_ENABLE +#define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1 +#endif +// +// Platform UDP +#ifndef OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE +#define OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE 0 +#endif +// +// Reference Device for Thread Test Harness +#ifndef OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE +#define OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE 0 +#endif +// +// Service Entries in Thread Network Data +#ifndef OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE +#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 0 +#endif +// +// RAM (volatile-only storage) +#ifndef OPENTHREAD_SETTINGS_RAM +#define OPENTHREAD_SETTINGS_RAM 0 +#endif +// +// SLAAC Addresses +#ifndef OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE +#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1 +#endif +// +// SNTP Client +#ifndef OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE 0 +#endif +// +// TMF Network Diagnostic client API +#ifndef OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE 1 +#endif +// +// Time Synchronization Service +#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0 +// +// UDP Forward +#ifndef OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE +#define OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 0 +#endif +// +// Enable Mac beacon payload parsing support +#ifndef OPENTHREAD_CONFIG_MAC_BEACON_PAYLOAD_PARSING_ENABLE +#define OPENTHREAD_CONFIG_MAC_BEACON_PAYLOAD_PARSING_ENABLE 1 +#endif +// +// +// Logging +// LOG_OUTPUT +// NONE +// APP +// PLATFORM_DEFINED +// Default: OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED +#ifndef OPENTHREAD_CONFIG_LOG_OUTPUT +#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_APP +#endif + +// DYNAMIC_LOG_LEVEL +#ifndef OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE +#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 0 +#endif + +// Enable Logging +#define OPENTHREAD_FULL_LOGS_ENABLE 0 +#if OPENTHREAD_FULL_LOGS_ENABLE + +// Note: Enabling higher log levels, which include logging packet details, can cause delays which may result in join failures. +// LOG_LEVEL +// NONE +// CRIT +// WARN +// NOTE +// INFO +// DEBG +// Default: OT_LOG_LEVEL_DEBG +#ifndef OPENTHREAD_CONFIG_LOG_LEVEL +#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG +#endif +// CLI +#ifndef OPENTHREAD_CONFIG_LOG_CLI +#define OPENTHREAD_CONFIG_LOG_CLI 1 +#endif +// PKT_DUMP +#ifndef OPENTHREAD_CONFIG_LOG_PKT_DUMP +#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 +#endif +// PLATFORM +#ifndef OPENTHREAD_CONFIG_LOG_PLATFORM +#define OPENTHREAD_CONFIG_LOG_PLATFORM 1 +#endif +// PREPEND_LEVEL +#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL +#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 +#endif + +#endif +// +// +// + +// <<< end of configuration section >>> +#endif // _SL_OPENTHREAD_FEATURES_CONFIG_H diff --git a/src/ot-rcp/config/sl_openthread_generic_config.h b/src/ot-rcp/config/sl_openthread_generic_config.h new file mode 100644 index 00000000..fd057a7f --- /dev/null +++ b/src/ot-rcp/config/sl_openthread_generic_config.h @@ -0,0 +1,148 @@ +/* include/openthread-config-generic.h. Generated from openthread-config-generic.h.in by configure. */ +/* include/openthread-config-generic.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define to 1 if your C++ compiler doesn't accept -c and -o together. */ +/* #undef CXX_NO_MINUS_C_MINUS_O */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `edit' library (-ledit). */ +/* #undef HAVE_LIBEDIT */ + +/* Define to 1 if you have the `readline' library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `memcpy' function. */ +/* #undef HAVE_MEMCPY */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if stdbool.h conforms to C99. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define HAVE__BOOL 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Name of package */ +#define PACKAGE "openthread" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "openthread-devel@googlegroups.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "SL-OPENTHREAD" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "SL-OPENTHREAD/2.4.0.0_GitHub-7074a43e4" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "openthread" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://github.com/openthread/openthread" + +/* Define to the version of this package. + * Note: When adding the label below with OpenThread version, please make + * sure it is a valid GitHub version. Avoid merge or local commit hashes. + */ +#define PACKAGE_VERSION "2.4.0.0_GitHub-7074a43e4" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "2.4.0.0_GitHub-7074a43e4" + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT8_T */ + +/* Define to the type of a signed integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int16_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to the type of a signed integer type of width exactly 8 bits if such + a type exists and the standard includes do not define it. */ +/* #undef int8_t */ + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint16_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint8_t */ diff --git a/src/ot-rcp/config/sl_rail_util_pa_config.h b/src/ot-rcp/config/sl_rail_util_pa_config.h new file mode 100644 index 00000000..357f4296 --- /dev/null +++ b/src/ot-rcp/config/sl_rail_util_pa_config.h @@ -0,0 +1,81 @@ +/***************************************************************************//** + * @file + * @brief Power Amplifier configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_PA_CONFIG_H +#define SL_RAIL_UTIL_PA_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// PA Configuration +// Initial PA Power (deci-dBm, 100 = 10.0 dBm) +// Default: 100 +#define SL_RAIL_UTIL_PA_POWER_DECI_DBM 100 +// PA Ramp Time (microseconds) +// <0-65535:1> +// Default: 10 +#define SL_RAIL_UTIL_PA_RAMP_TIME_US 10 +// Milli-volts on PA supply pin (PA_VDD) +// <0-65535:1> +// Default: 3300 +#define SL_RAIL_UTIL_PA_VOLTAGE_MV 1800 +// 2.4 GHz PA Selection +// Highest Possible +// High Power (chip-specific) +// Medium Power (chip-specific) +// Low Power +// Disable +// Default: RAIL_TX_POWER_MODE_2P4GIG_HIGHEST +#define SL_RAIL_UTIL_PA_SELECTION_2P4GHZ RAIL_TX_POWER_MODE_2P4GIG_HIGHEST +// Sub-1 GHz PA Selection +// Disable +// Default: RAIL_TX_POWER_MODE_NONE +#define SL_RAIL_UTIL_PA_SELECTION_SUBGHZ RAIL_TX_POWER_MODE_NONE +// + +// PA Curve Configuration +// Header file containing custom PA curves +// Default: "pa_curves_efr32.h" +#define SL_RAIL_UTIL_PA_CURVE_HEADER "pa_curves_efr32.h" +// Header file containing PA curve types +// Default: "pa_curve_types_efr32.h" +#define SL_RAIL_UTIL_PA_CURVE_TYPES "pa_curve_types_efr32.h" +// + +// PA Calibration Configuration +// Apply PA Calibration Factory Offset +// Default: 1 +#define SL_RAIL_UTIL_PA_CALIBRATION_ENABLE 1 +// + +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_PA_CONFIG_H diff --git a/src/ot-rcp/config/sl_rail_util_pti_config.h b/src/ot-rcp/config/sl_rail_util_pti_config.h new file mode 100644 index 00000000..de9d71ae --- /dev/null +++ b/src/ot-rcp/config/sl_rail_util_pti_config.h @@ -0,0 +1,82 @@ +/***************************************************************************//** + * @file + * @brief Packet Trace Information configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_PTI_CONFIG_H +#define SL_RAIL_UTIL_PTI_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> +// PTI Configuration + +// PTI mode +// UART +// UART onewire +// SPI +// Disabled +// Default: RAIL_PTI_MODE_UART +#define SL_RAIL_UTIL_PTI_MODE RAIL_PTI_MODE_UART + +// PTI Baud Rate (Hertz) +// <147800-20000000:1> +// Default: 1600000 +#define SL_RAIL_UTIL_PTI_BAUD_RATE_HZ 1600000 + +// +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_RAIL_UTIL_PTI +// $[PTI_SL_RAIL_UTIL_PTI] +#ifndef SL_RAIL_UTIL_PTI_PERIPHERAL +#define SL_RAIL_UTIL_PTI_PERIPHERAL PTI +#endif + +// PTI DOUT on PC04 +#ifndef SL_RAIL_UTIL_PTI_DOUT_PORT +#define SL_RAIL_UTIL_PTI_DOUT_PORT gpioPortC +#endif +#ifndef SL_RAIL_UTIL_PTI_DOUT_PIN +#define SL_RAIL_UTIL_PTI_DOUT_PIN 4 +#endif + +// PTI DFRAME on PC05 +#ifndef SL_RAIL_UTIL_PTI_DFRAME_PORT +#define SL_RAIL_UTIL_PTI_DFRAME_PORT gpioPortC +#endif +#ifndef SL_RAIL_UTIL_PTI_DFRAME_PIN +#define SL_RAIL_UTIL_PTI_DFRAME_PIN 5 +#endif + +// [PTI_SL_RAIL_UTIL_PTI]$ + +// <<< sl:end pin_tool >>> + +#endif // SL_RAIL_UTIL_PTI_CONFIG_H diff --git a/src/ot-rcp/config/sl_rail_util_rf_path_config.h b/src/ot-rcp/config/sl_rail_util_rf_path_config.h new file mode 100644 index 00000000..ca5be91c --- /dev/null +++ b/src/ot-rcp/config/sl_rail_util_rf_path_config.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_RF_PATH_CONFIG_H +#define SL_RAIL_UTIL_RF_PATH_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// Chip-internal RF Path Configuration +// RF Path Mode +// Path 0 +// Path 1 +// Default: RAIL_ANTENNA_1 +#define SL_RAIL_UTIL_RF_PATH_INT_RF_PATH_MODE RAIL_ANTENNA_1 +// + +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_RF_PATH_CONFIG_H diff --git a/src/ot-rcp/config/sl_rail_util_rssi_config.h b/src/ot-rcp/config/sl_rail_util_rssi_config.h new file mode 100644 index 00000000..15a55646 --- /dev/null +++ b/src/ot-rcp/config/sl_rail_util_rssi_config.h @@ -0,0 +1,44 @@ +/***************************************************************************//** + * @file + * @brief RSSI configuration header file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_RSSI_CONFIG_H +#define SL_RAIL_UTIL_RSSI_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// RSSI Offset Configuration + +// Software RSSI offset value +// Default: -11 +#define SL_RAIL_UTIL_RSSI_OFFSET -11 + +// +// <<< end of configuration section >>> +#endif // SL_RAIL_UTIL_RSSI_CONFIG_H diff --git a/src/ot-rcp/config/sl_sleeptimer_config.h b/src/ot-rcp/config/sl_sleeptimer_config.h new file mode 100644 index 00000000..8344ef5f --- /dev/null +++ b/src/ot-rcp/config/sl_sleeptimer_config.h @@ -0,0 +1,82 @@ +/***************************************************************************//** + * @file + * @brief Sleep Timer configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_SLEEPTIMER_CONFIG_H +#define SL_SLEEPTIMER_CONFIG_H + +#define SL_SLEEPTIMER_PERIPHERAL_DEFAULT 0 +#define SL_SLEEPTIMER_PERIPHERAL_RTCC 1 +#define SL_SLEEPTIMER_PERIPHERAL_PRORTC 2 +#define SL_SLEEPTIMER_PERIPHERAL_RTC 3 +#define SL_SLEEPTIMER_PERIPHERAL_SYSRTC 4 +#define SL_SLEEPTIMER_PERIPHERAL_BURTC 5 +#define SL_SLEEPTIMER_PERIPHERAL_WTIMER 6 +#define SL_SLEEPTIMER_PERIPHERAL_TIMER 7 + +// Timer Peripheral Used by Sleeptimer +// Default (auto select) +// RTCC +// Radio internal RTC (PRORTC) +// RTC +// SYSRTC +// Back-Up RTC (BURTC) +// WTIMER +// TIMER +// Selection of the Timer Peripheral Used by the Sleeptimer +#define SL_SLEEPTIMER_PERIPHERAL SL_SLEEPTIMER_PERIPHERAL_DEFAULT + +// TIMER/WTIMER Instance Used by Sleeptimer (not applicable for other peripherals) +// Make sure TIMER instance size is 32bits. Check datasheet for 32bits TIMERs. +// Default: 0 +#define SL_SLEEPTIMER_TIMER_INSTANCE 0 + +// Enable wallclock functionality +// Enable or disable wallclock functionalities (get_time, get_date, etc). +// Default: 0 +#define SL_SLEEPTIMER_WALLCLOCK_CONFIG 0 + +// Timer frequency divider (not applicable for WTIMER/TIMER) +// WTIMER/TIMER peripherals are always prescaled to 1024. +// Default: 1 +#define SL_SLEEPTIMER_FREQ_DIVIDER 1 + +// If Radio internal RTC (PRORTC) HAL is used, determines if it owns the IRQ handler. Enable, if no wireless stack is used. +// Default: 0 +#define SL_SLEEPTIMER_PRORTC_HAL_OWNS_IRQ_HANDLER 0 + +// Enable DEBUGRUN functionality on hardware RTC. +// Default: 0 +#define SL_SLEEPTIMER_DEBUGRUN 0 + +#endif /* SLEEPTIMER_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/ot-rcp/config/sl_uartdrv_usart_vcom_config.h b/src/ot-rcp/config/sl_uartdrv_usart_vcom_config.h new file mode 100644 index 00000000..56faf848 --- /dev/null +++ b/src/ot-rcp/config/sl_uartdrv_usart_vcom_config.h @@ -0,0 +1,133 @@ +/***************************************************************************//** + * @file + * @brief UARTDRV_USART Config + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_UARTDRV_USART_VCOM_CONFIG_H +#define SL_UARTDRV_USART_VCOM_CONFIG_H + +#include "em_usart.h" +// <<< Use Configuration Wizard in Context Menu >>> + +// UART settings +// Baud rate +// Default: 115200 +#define SL_UARTDRV_USART_VCOM_BAUDRATE 460800 + +// Parity mode to use +// No Parity +// Even parity +// Odd parity +// Default: usartNoParity +#define SL_UARTDRV_USART_VCOM_PARITY usartNoParity + +// Number of stop bits to use. +// 0.5 stop bits +// 1 stop bits +// 1.5 stop bits +// 2 stop bits +// Default: usartStopbits1 +#define SL_UARTDRV_USART_VCOM_STOP_BITS usartStopbits1 + +// Flow control method +// None +// Software XON/XOFF +// nRTS/nCTS hardware handshake +// UART peripheral controls nRTS/nCTS +// Default: uartdrvFlowControlHwUart +#define SL_UARTDRV_USART_VCOM_FLOW_CONTROL_TYPE uartdrvFlowControlHwUart + +// Oversampling selection +// 16x oversampling +// 8x oversampling +// 6x oversampling +// 4x oversampling +// Default: usartOVS16 +#define SL_UARTDRV_USART_VCOM_OVERSAMPLING usartOVS4 + +// Majority vote disable for 16x, 8x and 6x oversampling modes +// True +// False +#define SL_UARTDRV_USART_VCOM_MVDIS false + +// Size of the receive operation queue +// Default: 6 +#define SL_UARTDRV_USART_VCOM_RX_BUFFER_SIZE 6 + +// Size of the transmit operation queue +// Default: 6 +#define SL_UARTDRV_USART_VCOM_TX_BUFFER_SIZE 6 + +// +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_UARTDRV_USART_VCOM +// $[USART_SL_UARTDRV_USART_VCOM] +#ifndef SL_UARTDRV_USART_VCOM_PERIPHERAL +#define SL_UARTDRV_USART_VCOM_PERIPHERAL USART0 +#endif +#ifndef SL_UARTDRV_USART_VCOM_PERIPHERAL_NO +#define SL_UARTDRV_USART_VCOM_PERIPHERAL_NO 0 +#endif + +// USART0 TX on PA05 +#ifndef SL_UARTDRV_USART_VCOM_TX_PORT +#define SL_UARTDRV_USART_VCOM_TX_PORT gpioPortA +#endif +#ifndef SL_UARTDRV_USART_VCOM_TX_PIN +#define SL_UARTDRV_USART_VCOM_TX_PIN 5 +#endif + +// USART0 RX on PA06 +#ifndef SL_UARTDRV_USART_VCOM_RX_PORT +#define SL_UARTDRV_USART_VCOM_RX_PORT gpioPortA +#endif +#ifndef SL_UARTDRV_USART_VCOM_RX_PIN +#define SL_UARTDRV_USART_VCOM_RX_PIN 6 +#endif + +// USART0 CTS on PC03 +#ifndef SL_UARTDRV_USART_VCOM_CTS_PORT +#define SL_UARTDRV_USART_VCOM_CTS_PORT gpioPortC +#endif +#ifndef SL_UARTDRV_USART_VCOM_CTS_PIN +#define SL_UARTDRV_USART_VCOM_CTS_PIN 3 +#endif + +// USART0 RTS on PC02 +#ifndef SL_UARTDRV_USART_VCOM_RTS_PORT +#define SL_UARTDRV_USART_VCOM_RTS_PORT gpioPortC +#endif +#ifndef SL_UARTDRV_USART_VCOM_RTS_PIN +#define SL_UARTDRV_USART_VCOM_RTS_PIN 2 +#endif +// [USART_SL_UARTDRV_USART_VCOM]$ +// <<< sl:end pin_tool >>> + +#endif // SL_UARTDRV_USART_VCOM_CONFIG_H diff --git a/src/ot-rcp/config/uartdrv_config.h b/src/ot-rcp/config/uartdrv_config.h new file mode 100644 index 00000000..e1d0a85d --- /dev/null +++ b/src/ot-rcp/config/uartdrv_config.h @@ -0,0 +1,114 @@ +/***************************************************************************//** + * @file + * @brief UARTDRV configuration file. + ******************************************************************************* + * # License + * Copyright 2018 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ +#ifndef __SILICON_LABS_UARTDRV_CONFIG_H__ +#define __SILICON_LABS_UARTDRV_CONFIG_H__ + +/***************************************************************************//** + * @addtogroup uartdrv + * @{ + ******************************************************************************/ +/// Size of the receive operation queue. +/// @details +/// The maximum number of receive operations that can be queued up for one +/// driver instance before @ref UARTDRV_Receive() returns +/// @ref ECODE_EMDRV_UARTDRV_QUEUE_FULL. +/// @note +/// This macro is not used by the UARTDRV itself, but is intended to be used +/// with the @ref DEFINE_BUF_QUEUE macro by the user of the driver to allocate +/// instances of the @ref UARTDRV_Buffer_FifoQueue_t struct. +#if !defined(EMDRV_UARTDRV_MAX_CONCURRENT_RX_BUFS) +#define EMDRV_UARTDRV_MAX_CONCURRENT_RX_BUFS 6 +#endif + +/// Size of the transmit operation queue. +/// @details +/// The maximum number of transmit operations that can be queued up for one +/// driver instance before @ref UARTDRV_Transmit() returns +/// @ref ECODE_EMDRV_UARTDRV_QUEUE_FULL. +/// @note +/// This macro is not used by the UARTDRV itself, but is intended to be used +/// with the @ref DEFINE_BUF_QUEUE macro by the user of the driver to allocate +/// instances of the @ref UARTDRV_Buffer_FifoQueue_t struct. +#if !defined(EMDRV_UARTDRV_MAX_CONCURRENT_TX_BUFS) +#define EMDRV_UARTDRV_MAX_CONCURRENT_TX_BUFS 6 +#endif + +// <<< Use Configuration Wizard in Context Menu >>> +// UARTDRV Settings + +/// Set to 1 to include flow control support +#if !defined(EMDRV_UARTDRV_FLOW_CONTROL_ENABLE) +// Flow control support +// <1=> Enable +// <0=> Disable +// Default: 1 +#define EMDRV_UARTDRV_FLOW_CONTROL_ENABLE 1 +#endif + +/// Maximum number of driver instances. +#if !defined(EMDRV_UARTDRV_MAX_DRIVER_INSTANCES) +// Maximum number of driver instances +// This maximum only applies when UARTDRV_FLOW_CONTROL_ENABLE = 1 +// Default: 4 +#define EMDRV_UARTDRV_MAX_DRIVER_INSTANCES 4 +#endif + +/// UART software flow control code: request peer to start TX +#if !defined(UARTDRV_FC_SW_XON) +// UART software flow control code: request peer to start TX +// Default: 0x11 +#define UARTDRV_FC_SW_XON 0x11 +#endif + +/// UART software flow control code: request peer to stop TX +#if !defined(UARTDRV_FC_SW_XOFF) +// UART software flow control code: request peer to stop TX +// Default: 0x13 +#define UARTDRV_FC_SW_XOFF 0x13 +#endif + +/// UART enable reception when sleeping. +#if !defined(UARTDRV_RESTRICT_ENERGY_MODE_TO_ALLOW_RECEPTION) +// Enable reception when sleeping +// Enable reception when sleeping will use the power manager and add EM1 +// requirement during receive operations that use DMA. +// <1=> Enable +// <0=> Disable +// Default: 1 +#define UARTDRV_RESTRICT_ENERGY_MODE_TO_ALLOW_RECEPTION 1 +#endif + +// + +// <<< end of configuration section >>> + +/** @} (end addtogroup uartdrv) */ + +#endif /* __SILICON_LABS_UARTDRV_CONFIG_H__ */ diff --git a/src/ot-rcp/gbl_metadata.yaml b/src/ot-rcp/gbl_metadata.yaml new file mode 100644 index 00000000..219ce851 --- /dev/null +++ b/src/ot-rcp/gbl_metadata.yaml @@ -0,0 +1,3 @@ +baudrate: 460800 +dynamic: [ot_rcp_version] +fw_type: ot-rcp diff --git a/src/ot-rcp/main.c b/src/ot-rcp/main.c new file mode 100644 index 00000000..143e4cdf --- /dev/null +++ b/src/ot-rcp/main.c @@ -0,0 +1,60 @@ +/***************************************************************************//** + * @file + * @brief main() function. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include "sl_component_catalog.h" +#include "sl_system_init.h" +#include "app.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif // SL_CATALOG_POWER_MANAGER_PRESENT +#if defined(SL_CATALOG_KERNEL_PRESENT) +#include "sl_system_kernel.h" +#else // !SL_CATALOG_KERNEL_PRESENT +#include "sl_system_process_action.h" +#endif // SL_CATALOG_KERNEL_PRESENT + +int main(void) +{ + // Initialize Silicon Labs device, system, service(s) and protocol stack(s). + // Note that if the kernel is present, processing task(s) will be created by + // this call. + sl_system_init(); + + // Initialize the application. For example, create periodic timer(s) or + // task(s) if the kernel is present. + app_init(); + +#if defined(SL_CATALOG_KERNEL_PRESENT) + // Start the kernel. Task(s) created in app_init() will start running. + sl_system_kernel_start(); +#else // SL_CATALOG_KERNEL_PRESENT + while (1) { + // Do not remove this call: Silicon Labs components process action routine + // must be called from the super loop. + sl_system_process_action(); + + // Application process. + app_process_action(); + +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + // Let the CPU go to sleep if the system allows it. + sl_power_manager_sleep(); +#endif + } + // Clean-up when exiting the application. + app_exit(); +#endif // SL_CATALOG_KERNEL_PRESENT +} \ No newline at end of file diff --git a/src/ot-rcp/ot-rcp.pintool b/src/ot-rcp/ot-rcp.pintool new file mode 100644 index 00000000..ab04183a --- /dev/null +++ b/src/ot-rcp/ot-rcp.pintool @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ot-rcp/ot-rcp.slcp b/src/ot-rcp/ot-rcp.slcp new file mode 100644 index 00000000..bd60ae4d --- /dev/null +++ b/src/ot-rcp/ot-rcp.slcp @@ -0,0 +1,57 @@ +# Silicon Labs Project Configuration Tools: slcp, v0, Component selection file. +project_name: ot-rcp +label: ot-rcp +description: | + This is a simple OpenThread RCP application. This is equivalent to the ot-rcp application in the OpenThread GitHub repo. +category: OpenThread Examples +filter: +- name: Device Type + value: [RCP] +- name: Project Difficulty + value: [Advanced] +- name: Wireless Technology + value: [Thread] +package: OpenThread +quality: production +readme: +- {path: README-OT-RCP.md} +source: +- {path: main.c} +- {path: app.c} +tag: [prebuilt_demo] +include: +- path: '' + file_list: + - {path: app.h} + - {path: reset_util.h} +sdk: {id: gecko_sdk, version: 4.4.0} +toolchain_settings: [] +component: +- {id: rail_util_pti} +- instance: [vcom] + id: uartdrv_usart +- {id: brd4001a} +- {id: ot_stack_rcp} +- {id: ot_crash_handler} +- {id: brd4179b} +- {id: bootloader_interface} +- {id: EFR32MG21A010F1024IM32} +configuration: +- {name: SL_BOARD_ENABLE_VCOM, value: '1'} +- {name: OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE, value: '0'} +- condition: [ot_rtt_log] + name: OPENTHREAD_CONFIG_LOG_OUTPUT + value: OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED +- condition: [ot_rtt_log] + name: BUFFER_SIZE_UP + value: '768' +- condition: [ot_rtt_log, device_family_efr32mg1] + name: BUFFER_SIZE_UP + value: '128' +- condition: [ot_rtt_log] + name: BUFFER_SIZE_DOWN + value: '0' +ui_hints: + highlight: + - {path: ./README-OT-RCP.md, focus: true} + diff --git a/src/ot-rcp/ot-rcp.slps b/src/ot-rcp/ot-rcp.slps new file mode 100644 index 00000000..0ebcba93 --- /dev/null +++ b/src/ot-rcp/ot-rcp.slps @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ot-rcp/reset_util.h b/src/ot-rcp/reset_util.h new file mode 100644 index 00000000..52f56813 --- /dev/null +++ b/src/ot-rcp/reset_util.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022, The OpenThread Authors. + * All rights reserved. + * + * 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 the copyright holder 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. + */ + +#ifndef OT_LIB_PLATFORM_RESET_UTIL_H_ +#define OT_LIB_PLATFORM_RESET_UTIL_H_ + +#if defined(OPENTHREAD_ENABLE_COVERAGE) && OPENTHREAD_ENABLE_COVERAGE && defined(__GNUC__) +#if __GNUC__ >= 11 || (defined(__clang__) && (defined(__APPLE__) && (__clang_major__ >= 13)) || \ + (!defined(__APPLE__) && (__clang_major__ >= 12))) +void __gcov_dump(); +void __gcov_reset(); + +static void flush_gcov(void) +{ + __gcov_dump(); + __gcov_reset(); +} +#else +void __gcov_flush(void); +#define flush_gcov __gcov_flush +#endif /* __GNUC__ >= 11 || (defined(__clang__) && (defined(__APPLE__) && (__clang_major__ >= 13)) || \ + (!defined(__APPLE__) && (__clang_major__ >= 12))) */ +#else +#define flush_gcov() +#endif // defined(OPENTHREAD_ENABLE_COVERAGE) && OPENTHREAD_ENABLE_COVERAGE && defined(__GNUC__) + +#if defined(__linux__) || defined(__APPLE__) +#include +#include +jmp_buf gResetJump; + +#define OT_SETUP_RESET_JUMP(kArgv) \ + if (setjmp(gResetJump)) \ + { \ + alarm(0); \ + flush_gcov(); \ + execvp(kArgv[0], kArgv); \ + } + +#else +#define OT_SETUP_RESET_JUMP(ARGV) +#endif // defined(__linux__) || defined(__APPLE__) + +#endif // OT_LIB_PLATFORM_RESET_UTIL_H_ diff --git a/src/rcp-uart-802154/.cproject b/src/rcp-uart-802154/.cproject new file mode 100644 index 00000000..d726bd0c --- /dev/null +++ b/src/rcp-uart-802154/.cproject @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/rcp-uart-802154/README-MP-RCP.md b/src/rcp-uart-802154/README-MP-RCP.md new file mode 100644 index 00000000..6cfaa080 --- /dev/null +++ b/src/rcp-uart-802154/README-MP-RCP.md @@ -0,0 +1,8 @@ +# Multiprotocol (OpenThread+Zigbee) RCP + +This multiprotocol radio co-processor (RCP) application supports running OpenThread and Zigbee stacks simultaneously on a host processor. It uses concurrent multiprotocol (CMP) / multi-PAN functionality to run the 802.15.4 networks simultaneously on the same channel. + +The host stacks and the RCP communicate using the Co-Processor Communication protocol (CPC), which acts as a protocol multiplexer and serial transport layer. The host applications connect to the CPC daemon, which in turn connects to the EFR via a SPI or UART link. + +Refer to *AN1333: Running Zigbee, OpenThread, and Bluetooth Concurrently on a Linux Host with a Multiprotocol Co-processor* for more information on running the multiprotocol RCP with different host applications. + diff --git a/src/rcp-uart-802154/app.c b/src/rcp-uart-802154/app.c new file mode 100644 index 00000000..9f3b75ab --- /dev/null +++ b/src/rcp-uart-802154/app.c @@ -0,0 +1,122 @@ +/***************************************************************************//** + * @file + * @brief Core application logic. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include +#include +#include + +#include +#include +#include + +#include "openthread-system.h" +#include "app.h" + +#include "reset_util.h" + +#include "sl_gsdk_version.h" +#include "config/internal_app_config.h" + +void otPlatAssertFail(const char *aFilename, int aLineNumber) +{ +#if OPENTHREAD_CONFIG_LOG_PLATFORM && OPENTHREAD_CONFIG_LOG_LEVEL < OT_LOG_LEVEL_CRIT + OT_UNUSED_VARIABLE(aFilename); + OT_UNUSED_VARIABLE(aLineNumber); +#else + otLogCritPlat("assert failed at %s:%d", aFilename, aLineNumber); +#endif + // For debug build, use assert to generate a core dump + assert(false); +} + +const char* sl_cpc_secondary_app_version(void) +{ + return ( + SL_GSDK_VERSION_STR + CPC_SECONDARY_APP_VERSION_SUFFIX + ); +} + +/** + * This function initializes the NCP app. + * + * @param[in] aInstance The OpenThread instance structure. + * + */ +extern void otAppNcpInit(otInstance *aInstance); + +static otInstance* sInstance = NULL; + +otInstance *otGetInstance(void) +{ + return sInstance; +} + +void sl_ot_create_instance(void) +{ +#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE + size_t otInstanceBufferLength = 0; + uint8_t *otInstanceBuffer = NULL; + + // Call to query the buffer size + (void)otInstanceInit(NULL, &otInstanceBufferLength); + + // Call to allocate the buffer + otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength); + assert(otInstanceBuffer); + + // Initialize OpenThread with the buffer + sInstance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength); +#else + sInstance = otInstanceInitSingle(); +#endif + assert(sInstance); +} + +void sl_ot_ncp_init(void) +{ + otAppNcpInit(sInstance); +} + +/**************************************************************************//** + * Application Init. + *****************************************************************************/ + +void app_init(void) +{ + OT_SETUP_RESET_JUMP(argv); +} + +/**************************************************************************//** + * Application Process Action. + *****************************************************************************/ +void app_process_action(void) +{ + otTaskletsProcess(sInstance); + otSysProcessDrivers(sInstance); +} + +/**************************************************************************//** + * Application Exit. + *****************************************************************************/ +void app_exit(void) +{ + otInstanceFinalize(sInstance); +#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE + free(otInstanceBuffer); +#endif + // TO DO : pseudo reset? +} diff --git a/src/rcp-uart-802154/app.h b/src/rcp-uart-802154/app.h new file mode 100644 index 00000000..4a8493a9 --- /dev/null +++ b/src/rcp-uart-802154/app.h @@ -0,0 +1,36 @@ +/***************************************************************************//** + * @file + * @brief Application interface provided to main(). + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#ifndef APP_H +#define APP_H + +/**************************************************************************//** + * Application Init. + *****************************************************************************/ +void app_init(void); + +/**************************************************************************//** + * Application Exit. + *****************************************************************************/ +void app_exit(void); + +/**************************************************************************//** + * Application Process Action. + *****************************************************************************/ +void app_process_action(void); + +#endif \ No newline at end of file diff --git a/src/rcp-uart-802154/config/app_properties_config.h b/src/rcp-uart-802154/config/app_properties_config.h new file mode 100644 index 00000000..6a6b9766 --- /dev/null +++ b/src/rcp-uart-802154/config/app_properties_config.h @@ -0,0 +1,65 @@ +/***************************************************************************//** + * @file + * @brief Application Properties Header File + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef APP_PROPERTIES_CONFIG_H +#define APP_PROPERTIES_CONFIG_H + +#include "sl_application_type.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// App Properties settings + +// Type of signature this application is signed with +// Default: APPLICATION_SIGNATURE_NONE(0) +#define SL_APPLICATION_SIGNATURE 0 + +// Location of the signature +// Default: 0xFFFFFFFF +#define SL_APPLICATION_SIGNATURE_LOCATION 0xFFFFFFFF + +// Bitfield representing type of application +#define SL_APPLICATION_TYPE APPLICATION_TYPE + +// Version number for this application +// <0-4294967295:1> +// Default: 1 [0-4294967295] +#define SL_APPLICATION_VERSION 1 + +// Capabilities of this application +// Default: 0 +#define SL_APPLICATION_CAPABILITIES 0 + +//Product ID of the device for which the application is built +#define SL_APPLICATION_PRODUCT_ID { 0 } + +// + +#endif // APP_PROPERTIES_CONFIG_H diff --git a/src/rcp-uart-802154/config/btl_interface_cfg.h b/src/rcp-uart-802154/config/btl_interface_cfg.h new file mode 100644 index 00000000..8e246f80 --- /dev/null +++ b/src/rcp-uart-802154/config/btl_interface_cfg.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_H +#define BTL_INTERFACE_CFG_H + +#if !defined(BOOTLOADER_APPLOADER) + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1) +#include "btl_interface_cfg_s2c1.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_2) +#include "btl_interface_cfg_s2c2.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_3) +#include "btl_interface_cfg_s2c3.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4) +#include "btl_interface_cfg_s2c4.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_8) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#endif // !BOOTLOADER_APPLOADER + +#endif // BTL_INTERFACE_CFG_H diff --git a/src/rcp-uart-802154/config/btl_interface_cfg_s2c1.h b/src/rcp-uart-802154/config/btl_interface_cfg_s2c1.h new file mode 100644 index 00000000..c72c27b0 --- /dev/null +++ b/src/rcp-uart-802154/config/btl_interface_cfg_s2c1.h @@ -0,0 +1,281 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_S2C1_H +#define BTL_INTERFACE_CFG_S2C1_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Bootloader Interface Trust Zone Security State Configuration + +// Disable multi tiered fallback logic +// The fault handling logic as well as the USART auto-detection logic will be disabled. +// The re-configuration of SMU will be handled by querying the running bootloader +// for the peripheral list. Querying the peripheral list is supported from the bootloader +// version 2.0.0. Check for the BOOTLOADER_CAPABILITY_PERIPHERAL_LIST capability to +// see if the running bootloader supports querying the peripheral list. +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 0 + +// Disable peripheral access fault handling +// The fault handling triggered by an erroneous access of peripherals will be disabled. +// +// This should be disabled iff all the peripherals that are in use by the bootloader +// have been properly configured by the "Manually override security state of peripherals" option. +#define BOOTLOADER_DISABLE_NVM3_FAULT_HANDLING 0 + +// Manually override the security state of peripherals in use by the bootloader +// Default: 0. +// Manually override the security state of peripherals. Choose the peripherals touched +// by the customized code to have a valid secure access state before interacting with the bootloader +// In practice, this means that the chosen peripherals will be available at the secure address, +// which is accessible by the bootloader. Once the application is entered back the secure access state +// is changed back to the original state. +// +// The USART auto-detection logic that detects which, if any, USART is in use by the bootloader +// will be disabled. Make sure to choose the correct USART used by the bootloader. +#define BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE 0 +// EMU +// Update secure access state of EMU before calling into bootloader +#define BOOTLOADER_PPUSATD0_EMU 0 + +// CMU +// Update secure access state of CMU before calling into bootloader +#define BOOTLOADER_PPUSATD0_CMU 0 + +// HFXO0 +// Update secure access state of HFXO0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_HFXO0 0 + +// HFRCO0 +// Update secure access state of HFRCO0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_HFRCO0 0 + +// FSRCO +// Update secure access state of FSRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_FSRCO 0 + +// DPLL0 +// Update secure access state of DPLL0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_DPLL0 0 + +// LFXO +// Update secure access state of LFXO before calling into bootloader +#define BOOTLOADER_PPUSATD0_LFXO 0 + +// LFRCO +// Update secure access state of LFRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_LFRCO 0 + +// ULFRCO +// Update secure access state of ULFRCO before calling into bootloader +#define BOOTLOADER_PPUSATD0_ULFRCO 0 + +// MSC +// Update secure access state of MSC before calling into bootloader +#define BOOTLOADER_PPUSATD0_MSC 0 + +// ICACHE0 +// Update secure access state of ICACHE0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_ICACHE0 0 + +// PRS +// Update secure access state of PRS before calling into bootloader +#define BOOTLOADER_PPUSATD0_PRS 0 + +// GPIO +// Update secure access state of GPIO before calling into bootloader +#define BOOTLOADER_PPUSATD0_GPIO 0 + +// LDMA +// Update secure access state of LDMA before calling into bootloader +#define BOOTLOADER_PPUSATD0_LDMA 0 + +// LDMAXBAR +// Update secure access state of LDMAXBAR before calling into bootloader +#define BOOTLOADER_PPUSATD0_LDMAXBAR 0 + +// TIMER0 +// Update secure access state of TIMER0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER0 0 + +// TIMER1 +// Update secure access state of TIMER1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER1 0 + +// TIMER2 +// Update secure access state of TIMER2 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER2 0 + +// TIMER3 +// Update secure access state of TIMER3 before calling into bootloader +#define BOOTLOADER_PPUSATD0_TIMER3 0 + +// USART0 +// Update secure access state of USART0 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART0 0 + +// USART1 +// Update secure access state of USART1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART1 0 + +// USART2 +// Update secure access state of USART2 before calling into bootloader +#define BOOTLOADER_PPUSATD0_USART2 0 + +// BURTC +// Update secure access state of BURTC before calling into bootloader +#define BOOTLOADER_PPUSATD0_BURTC 0 + +// I2C1 +// Update secure access state of I2C1 before calling into bootloader +#define BOOTLOADER_PPUSATD0_I2C1 0 + +// CHIPTESTCTRL +// Update secure access state of CHIPTESTCTRL before calling into bootloader +#define BOOTLOADER_PPUSATD0_CHIPTESTCTRL 0 + +// LVGD +// Update secure access state of LVGD before calling into bootloader +#define BOOTLOADER_PPUSATD0_LVGD 0 + +// SYSCFG +// Update secure access state of SYSCFG before calling into bootloader +#define BOOTLOADER_PPUSATD0_SYSCFG 0 + +// BURAM +// Update secure access state of BURAM before calling into bootloader +#define BOOTLOADER_PPUSATD0_BURAM 0 + +// IFADCDEBUG +// Update secure access state of IFADCDEBUG before calling into bootloader +#define BOOTLOADER_PPUSATD0_IFADCDEBUG 0 + +// GPCRC +// Update secure access state of GPCRC before calling into bootloader +#define BOOTLOADER_PPUSATD0_GPCRC 0 + +// RTCC +// Update secure access state of RTCC before calling into bootloader +#define BOOTLOADER_PPUSATD0_RTCC 0 + +// LETIMER0 +// Update secure access state of LETIMER0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_LETIMER0 0 + +// IADC0 +// Update secure access state of IADC0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_IADC0 0 + +// ACMP0 +// Update secure access state of ACMP0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_ACMP0 0 + +// ACMP1 +// Update secure access state of ACMP1 before calling into bootloader +#define BOOTLOADER_PPUSATD1_ACMP1 0 + +// I2C0 +// Update secure access state of I2C0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_I2C0 0 + +// HFRCOEM23 +// Update secure access state of HFRCOEM23 before calling into bootloader +#define BOOTLOADER_PPUSATD1_HFRCOEM23 0 + +// WDOG0 +// Update secure access state of WDOG0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_WDOG0 0 + +// WDOG1 +// Update secure access state of WDOG1 before calling into bootloader +#define BOOTLOADER_PPUSATD1_WDOG1 0 + +// AMUXCP0 +// Update secure access state of AMUXCP0 before calling into bootloader +#define BOOTLOADER_PPUSATD1_AMUXCP0 0 + +// RADIOAES +// Update secure access state of RADIOAES before calling into bootloader +#define BOOTLOADER_PPUSATD1_RADIOAES 0 + +// BUFC +// Update secure access state of BUFC before calling into bootloader +#define BOOTLOADER_PPUSATD1_BUFC 0 + +// SMU +// Update secure access state of SMU before calling into bootloader +#define BOOTLOADER_PPUSATD1_SMU 0 + +// AHBRADIO +// Update secure access state of AHBRADIO before calling into bootloader +#define BOOTLOADER_PPUSATD1_AHBRADIO 0 + +// SEMAILBOX +// Update secure access state of SEMAILBOX before calling into bootloader +#define BOOTLOADER_PPUSATD1_SEMAILBOX 0 +// + +// +// <<< end of configuration section >>> + +#if BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE == 1 +#define BOOTLOADER_PPUSATD0_MASK ((BOOTLOADER_PPUSATD0_EMU << _SMU_PPUSATD0_EMU_SHIFT) \ + | (BOOTLOADER_PPUSATD0_CMU << _SMU_PPUSATD0_CMU_SHIFT) \ + | (BOOTLOADER_PPUSATD0_HFXO0 << _SMU_PPUSATD0_HFXO0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_HFRCO0 << _SMU_PPUSATD0_HFRCO0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_FSRCO << _SMU_PPUSATD0_FSRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_DPLL0 << _SMU_PPUSATD0_DPLL0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LFXO << _SMU_PPUSATD0_LFXO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LFRCO << _SMU_PPUSATD0_LFRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_ULFRCO << _SMU_PPUSATD0_ULFRCO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_MSC << _SMU_PPUSATD0_MSC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_ICACHE0 << _SMU_PPUSATD0_ICACHE0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_PRS << _SMU_PPUSATD0_PRS_SHIFT) \ + | (BOOTLOADER_PPUSATD0_GPIO << _SMU_PPUSATD0_GPIO_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LDMA << _SMU_PPUSATD0_LDMA_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LDMAXBAR << _SMU_PPUSATD0_LDMAXBAR_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER0 << _SMU_PPUSATD0_TIMER0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER1 << _SMU_PPUSATD0_TIMER1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER2 << _SMU_PPUSATD0_TIMER2_SHIFT) \ + | (BOOTLOADER_PPUSATD0_TIMER3 << _SMU_PPUSATD0_TIMER3_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART0 << _SMU_PPUSATD0_USART0_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART1 << _SMU_PPUSATD0_USART1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_USART2 << _SMU_PPUSATD0_USART2_SHIFT) \ + | (BOOTLOADER_PPUSATD0_BURTC << _SMU_PPUSATD0_BURTC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_I2C1 << _SMU_PPUSATD0_I2C1_SHIFT) \ + | (BOOTLOADER_PPUSATD0_CHIPTESTCTRL << _SMU_PPUSATD0_CHIPTESTCTRL_SHIFT) \ + | (BOOTLOADER_PPUSATD0_LVGD << _SMU_PPUSATD0_LVGD_SHIFT) \ + | (BOOTLOADER_PPUSATD0_SYSCFG << _SMU_PPUSATD0_SYSCFG_SHIFT) \ + | (BOOTLOADER_PPUSATD0_BURAM << _SMU_PPUSATD0_BURAM_SHIFT) \ + | (BOOTLOADER_PPUSATD0_IFADCDEBUG << _SMU_PPUSATD0_IFADCDEBUG_SHIFT) \ + | (BOOTLOADER_PPUSATD0_GPCRC << _SMU_PPUSATD0_GPCRC_SHIFT) \ + | (BOOTLOADER_PPUSATD0_RTCC << _SMU_PPUSATD0_RTCC_SHIFT)) +#define BOOTLOADER_PPUSATD1_MASK ((BOOTLOADER_PPUSATD1_LETIMER0 << _SMU_PPUSATD1_LETIMER0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_IADC0 << _SMU_PPUSATD1_IADC0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_ACMP0 << _SMU_PPUSATD1_ACMP0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_ACMP1 << _SMU_PPUSATD1_ACMP1_SHIFT) \ + | (BOOTLOADER_PPUSATD1_I2C0 << _SMU_PPUSATD1_I2C0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_HFRCOEM23 << _SMU_PPUSATD1_HFRCOEM23_SHIFT) \ + | (BOOTLOADER_PPUSATD1_WDOG0 << _SMU_PPUSATD1_WDOG0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_WDOG1 << _SMU_PPUSATD1_WDOG1_SHIFT) \ + | (BOOTLOADER_PPUSATD1_AMUXCP0 << _SMU_PPUSATD1_AMUXCP0_SHIFT) \ + | (BOOTLOADER_PPUSATD1_RADIOAES << _SMU_PPUSATD1_RADIOAES_SHIFT) \ + | (BOOTLOADER_PPUSATD1_BUFC << _SMU_PPUSATD1_BUFC_SHIFT) \ + | (BOOTLOADER_PPUSATD1_SMU << _SMU_PPUSATD1_SMU_SHIFT) \ + | (BOOTLOADER_PPUSATD1_AHBRADIO << _SMU_PPUSATD1_AHBRADIO_SHIFT) \ + | (BOOTLOADER_PPUSATD1_SEMAILBOX << _SMU_PPUSATD1_SEMAILBOX_SHIFT)) +#endif // BOOTLOADER_MANUAL_OVERRIDE_SECURITY_STATE + +#endif // BTL_INTERFACE_CFG_S2C1_H diff --git a/src/rcp-uart-802154/config/dmadrv_config.h b/src/rcp-uart-802154/config/dmadrv_config.h new file mode 100644 index 00000000..ed105e4f --- /dev/null +++ b/src/rcp-uart-802154/config/dmadrv_config.h @@ -0,0 +1,26 @@ +#ifndef DMADRV_CONFIG_H +#define DMADRV_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// DMA interrupt priority <0-15> +// Priority of the DMA interrupt. Smaller number equals higher priority. +// Default: 8 +#define EMDRV_DMADRV_DMA_IRQ_PRIORITY 8 + +// Number of available channels <1-8> +// Number of DMA channels supported by the driver. A lower channel count +// will reduce RAM memory footprint. The default is to support all channels +// on the device. +// Default: 8 +#define EMDRV_DMADRV_DMA_CH_COUNT 8 + +// Number of fixed priority channels +// This will configure channels [0, CH_PRIORITY - 1] as fixed priority, +// and channels [CH_PRIORITY, CH_COUNT] as round-robin. +// Default: 0 +#define EMDRV_DMADRV_DMA_CH_PRIORITY 0 + +// <<< end of configuration section >>> + +#endif // DMADRV_CONFIG_H diff --git a/src/rcp-uart-802154/config/emlib_core_debug_config.h b/src/rcp-uart-802154/config/emlib_core_debug_config.h new file mode 100644 index 00000000..07ee9b9e --- /dev/null +++ b/src/rcp-uart-802154/config/emlib_core_debug_config.h @@ -0,0 +1,45 @@ +/***************************************************************************//** + * @file + * @brief emlib_core Configuration + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef EM_CORE_DEBUG_CONFIG_H +#define EM_CORE_DEBUG_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Core Configuration + +// Enables measuring of interrupt disable time for debugging purposes. +// Default: 0 +#define SL_EMLIB_CORE_ENABLE_INTERRUPT_DISABLED_TIMING 0 + +// + +// <<< end of configuration section >>> +#endif // EM_CORE_CONFIG_H diff --git a/src/rcp-uart-802154/config/internal_app_config.h b/src/rcp-uart-802154/config/internal_app_config.h new file mode 100644 index 00000000..327b57c8 --- /dev/null +++ b/src/rcp-uart-802154/config/internal_app_config.h @@ -0,0 +1,8 @@ +#ifndef CONFIG_INTERNAL_APP_CONFIG_H_ +#define CONFIG_INTERNAL_APP_CONFIG_H_ + +#ifndef CPC_SECONDARY_APP_VERSION_SUFFIX +#define CPC_SECONDARY_APP_VERSION_SUFFIX "" +#endif + +#endif /* CONFIG_INTERNAL_APP_CONFIG_H_ */ diff --git a/src/rcp-uart-802154/config/nvm3_default_config.h b/src/rcp-uart-802154/config/nvm3_default_config.h new file mode 100644 index 00000000..48eb5896 --- /dev/null +++ b/src/rcp-uart-802154/config/nvm3_default_config.h @@ -0,0 +1,45 @@ +#ifndef NVM3_DEFAULT_CONFIG_H +#define NVM3_DEFAULT_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// NVM3 Default Instance Configuration + +#ifndef NVM3_DEFAULT_CACHE_SIZE +// NVM3 Default Instance Cache Size +// Number of NVM3 objects to cache. To reduce access times this number +// should be equal to or higher than the number of NVM3 objects in the +// default NVM3 instance. +// Default: 200 +#define NVM3_DEFAULT_CACHE_SIZE 200 +#endif + +#ifndef NVM3_DEFAULT_MAX_OBJECT_SIZE +// NVM3 Default Instance Max Object Size +// Max NVM3 object size that can be stored. +// Default: 254 +#define NVM3_DEFAULT_MAX_OBJECT_SIZE 254 +#endif + +#ifndef NVM3_DEFAULT_REPACK_HEADROOM +// NVM3 Default Instance User Repack Headroom +// Headroom determining how many bytes below the forced repack limit the user +// repack limit should be placed. The default is 0, which means the user and +// forced repack limits are equal. +// Default: 0 +#define NVM3_DEFAULT_REPACK_HEADROOM 0 +#endif + +#ifndef NVM3_DEFAULT_NVM_SIZE +// NVM3 Default Instance Size +// Size of the NVM3 storage region in flash. This size should be aligned with +// the flash page size of the device. +// Default: 40960 +#define NVM3_DEFAULT_NVM_SIZE 40960 +#endif + +// + +// <<< end of configuration section >>> + +#endif // NVM3_DEFAULT_CONFIG_H diff --git a/src/rcp-uart-802154/config/pin_config.h b/src/rcp-uart-802154/config/pin_config.h new file mode 100644 index 00000000..ceb0ee66 --- /dev/null +++ b/src/rcp-uart-802154/config/pin_config.h @@ -0,0 +1,173 @@ +#ifndef PIN_CONFIG_H +#define PIN_CONFIG_H + +// $[CMU] +// [CMU]$ + +// $[LFXO] +// [LFXO]$ + +// $[PRS.ASYNCH0] +// [PRS.ASYNCH0]$ + +// $[PRS.ASYNCH1] +// [PRS.ASYNCH1]$ + +// $[PRS.ASYNCH2] +// [PRS.ASYNCH2]$ + +// $[PRS.ASYNCH3] +// [PRS.ASYNCH3]$ + +// $[PRS.ASYNCH4] +// [PRS.ASYNCH4]$ + +// $[PRS.ASYNCH5] +// [PRS.ASYNCH5]$ + +// $[PRS.ASYNCH6] +// [PRS.ASYNCH6]$ + +// $[PRS.ASYNCH7] +// [PRS.ASYNCH7]$ + +// $[PRS.ASYNCH8] +// [PRS.ASYNCH8]$ + +// $[PRS.ASYNCH9] +// [PRS.ASYNCH9]$ + +// $[PRS.ASYNCH10] +// [PRS.ASYNCH10]$ + +// $[PRS.ASYNCH11] +// [PRS.ASYNCH11]$ + +// $[PRS.SYNCH0] +// [PRS.SYNCH0]$ + +// $[PRS.SYNCH1] +// [PRS.SYNCH1]$ + +// $[PRS.SYNCH2] +// [PRS.SYNCH2]$ + +// $[PRS.SYNCH3] +// [PRS.SYNCH3]$ + +// $[GPIO] +// GPIO SWV on PA03 +#ifndef GPIO_SWV_PORT +#define GPIO_SWV_PORT gpioPortA +#endif +#ifndef GPIO_SWV_PIN +#define GPIO_SWV_PIN 3 +#endif + +// [GPIO]$ + +// $[TIMER0] +// [TIMER0]$ + +// $[TIMER1] +// [TIMER1]$ + +// $[TIMER2] +// [TIMER2]$ + +// $[TIMER3] +// [TIMER3]$ + +// $[USART0] +// USART0 CTS on PC03 +#ifndef USART0_CTS_PORT +#define USART0_CTS_PORT gpioPortC +#endif +#ifndef USART0_CTS_PIN +#define USART0_CTS_PIN 3 +#endif + +// USART0 RTS on PC02 +#ifndef USART0_RTS_PORT +#define USART0_RTS_PORT gpioPortC +#endif +#ifndef USART0_RTS_PIN +#define USART0_RTS_PIN 2 +#endif + +// USART0 RX on PA06 +#ifndef USART0_RX_PORT +#define USART0_RX_PORT gpioPortA +#endif +#ifndef USART0_RX_PIN +#define USART0_RX_PIN 6 +#endif + +// USART0 TX on PA05 +#ifndef USART0_TX_PORT +#define USART0_TX_PORT gpioPortA +#endif +#ifndef USART0_TX_PIN +#define USART0_TX_PIN 5 +#endif + +// [USART0]$ + +// $[USART1] +// [USART1]$ + +// $[USART2] +// [USART2]$ + +// $[I2C1] +// [I2C1]$ + +// $[LETIMER0] +// [LETIMER0]$ + +// $[IADC0] +// [IADC0]$ + +// $[ACMP0] +// [ACMP0]$ + +// $[ACMP1] +// [ACMP1]$ + +// $[I2C0] +// [I2C0]$ + +// $[PTI] +// PTI DFRAME on PC05 +#ifndef PTI_DFRAME_PORT +#define PTI_DFRAME_PORT gpioPortC +#endif +#ifndef PTI_DFRAME_PIN +#define PTI_DFRAME_PIN 5 +#endif + +// PTI DOUT on PC04 +#ifndef PTI_DOUT_PORT +#define PTI_DOUT_PORT gpioPortC +#endif +#ifndef PTI_DOUT_PIN +#define PTI_DOUT_PIN 4 +#endif + +// [PTI]$ + +// $[MODEM] +// [MODEM]$ + +// $[CUSTOM_PIN_NAME] +#ifndef _PORT +#define _PORT gpioPortA +#endif +#ifndef _PIN +#define _PIN 0 +#endif + +// [CUSTOM_PIN_NAME]$ + +#endif // PIN_CONFIG_H + diff --git a/src/rcp-uart-802154/config/psa_crypto_config.h b/src/rcp-uart-802154/config/psa_crypto_config.h new file mode 100644 index 00000000..7d9144b3 --- /dev/null +++ b/src/rcp-uart-802154/config/psa_crypto_config.h @@ -0,0 +1,134 @@ +#ifndef PSA_CRYPTO_CONFIG_H +#define PSA_CRYPTO_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// Key management configuration + +// PSA User Maximum Open Keys Count <0-128> +// Maximum amount of keys that the user application will have open +// simultaneously. In context of PSA Crypto, an open key means any key +// either stored in RAM (lifetime set to PSA_KEY_LIFETIME_VOLATILE), or +// used as part of a cryptographic operation. +// When using a key for a multi-part (setup/update/finish) operation, a key +// is considered to be open from the moment the operation is successfully +// setup, until it finishes or aborts. +// When an application tries to open more keys than this value accounts for, +// the PSA API may return PSA_ERROR_INSUFFICIENT_MEMORY. Keep in mind that +// other software included in the application (e.g. wireless protocol stacks) +// also can have a need to have open keys in PSA Crypto. This could lead to +// a race condition when the application key slot count is set too low for +// the actual usage of the application, as a software stack may not fail +// gracefully in case an application opens more than its declared amount of +// keys, thereby precluding the stack from functioning. +// Default: 4 +#define SL_PSA_KEY_USER_SLOT_COUNT (4) + +// PSA Maximum User Persistent Keys Count <0-1024> +// Maximum amount of keys (or other files) that can be stored persistently +// by the application through the PSA interface, when persistent storage +// support for PSA Crypto is included in the project. +// Due to caching logic, this setting does have an impact on static RAM usage. +// Note that this number is added to the potential requirements from other +// software components in the project, such that the total amount of keys +// which can be stored through the ITS backend can be higher than what is +// configured here. +// +// WARNING: When changing this setting on an application that is already +// deployed, and thus will get the change through an application upgrade, +// care should be taken to ensure that the setting is only ever increased, +// and never decreased. Decreasing this setting might cause previously +// stored keys/files to become inaccessible. +// +// It is not possible to change this setting when using V3 ITS Driver. +// The file-storage indexing is dependent on the maximum number of files, +// and if SL_PSA_ITS_USER_MAX_FILES is changed, ITS should be cleared and +// all files need to be stored again. +// Default: 128 +#define SL_PSA_ITS_USER_MAX_FILES (128) + +// Enable V1 Format Support For ITS Files <0-1> +// Devices that used PSA ITS together with gecko_sdk_3.1.x or earlier +// might have keys (or other files) stored in V1 format. +// If no v1 files are used, its support can be disabled for space +// optimization. +// Default: 0 +#define SL_PSA_ITS_SUPPORT_V1_DRIVER 0 + +// Enable V2 ITS Driver Support <0-1> +// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys +// (or other files) stored using different address range. Enabling this +// config option adds upgrade code which converts V2 (and V1 if +// supported) format ITS keys/files to the latest V3 format. Update is +// fully automatic, needs to be run once and require extra flash space of +// approximately the size of the largest key. +// V1 ITS driver support can be disabled if the device has never used ITS +// driver before in GSDK 4.1.x and earlier, or the keys has been already +// migrated. +// Default: 0 +#define SL_PSA_ITS_SUPPORT_V2_DRIVER 0 + +// Enable support for V3 ITS Driver <0-1> +// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys +// (or other files) stored using different address range. In rare case +// that those devices have full nvm3 and not enough space for the +// upgrade, (that requires an extra space to store largest key in memory +// twice), this config option can disable v3 driver and use v2 one. +// To upgrade the device, make space for the upgrade, and enable v3 driver again. +// +// WARNING: When using V3 driver, it is not possible to increase or decrease +// the value of SL_PSA_ITS_USER_MAX_FILES. If the change of +// SL_PSA_ITS_USER_MAX_FILES is required, ITS should be cleared and +// all files need to be stored again. +// Default: 1 +#define SL_PSA_ITS_SUPPORT_V3_DRIVER 1 + +// Built-in AES Key Mode of Operation +// CTR Mode +// CFB Mode +// OFB Mode +// ECB Mode +// CBC Mode (no padding) +// CBC Mode (PKCS#7 padding) +// PSA Crypto only allows one specific usage algorithm per built-in key ID. +// Default: PSA_ALG_CTR +#define SL_SE_BUILTIN_KEY_AES128_ALG_CONFIG (PSA_ALG_CTR) + +#ifndef SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG +// Built-in PUF Key Algorithm +// PBKDF2 (CMAC-AES-128-PRF) +// CMAC +// PSA Crypto only allows one specific usage algorithm per built-in key ID. +// It is recommended to only use the PUF key for deriving further key +// material. +// Default: PSA_ALG_PBKDF2_AES_CMAC_PRF_128 +#define SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG (PSA_ALG_PBKDF2_AES_CMAC_PRF_128) +#endif // SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Sub-files + +#if defined(SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE) + #include SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE +#else + #include "sli_psa_config_autogen.h" +#endif + +#if defined(TFM_CONFIG_SL_SECURE_LIBRARY) + #include "sli_psa_tfm_translation.h" +#endif + +#if SL_MBEDTLS_DRIVERS_ENABLED + #include "sli_psa_acceleration.h" +#endif + +#include "sli_psa_builtin_config_autogen.h" + +#endif // PSA_CRYPTO_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_board_control_config.h b/src/rcp-uart-802154/config/sl_board_control_config.h new file mode 100644 index 00000000..f1804587 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_board_control_config.h @@ -0,0 +1,56 @@ +/***************************************************************************//** + * @file + * @brief Board Control + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_BOARD_CONTROL_CONFIG_H +#define SL_BOARD_CONTROL_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Enable Virtual COM UART +// Default: 0 +#define SL_BOARD_ENABLE_VCOM 1 + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +// SL_BOARD_ENABLE_VCOM +// $[GPIO_SL_BOARD_ENABLE_VCOM] +#ifndef SL_BOARD_ENABLE_VCOM_PORT +#define SL_BOARD_ENABLE_VCOM_PORT gpioPortD +#endif +#ifndef SL_BOARD_ENABLE_VCOM_PIN +#define SL_BOARD_ENABLE_VCOM_PIN 4 +#endif +// [GPIO_SL_BOARD_ENABLE_VCOM]$ + +// <<< sl:end pin_tool >>> + +#endif // SL_BOARD_CONTROL_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_cpc_config.h b/src/rcp-uart-802154/config/sl_cpc_config.h new file mode 100644 index 00000000..f27f4ccd --- /dev/null +++ b/src/rcp-uart-802154/config/sl_cpc_config.h @@ -0,0 +1,83 @@ +/***************************************************************************//** + * @file + * @brief CPC configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_CPC_CONFIG_H +#define SL_CPC_CONFIG_H + +// CPC Configuration + +// Max Rx Payload Length<1-4087> +// Default: 256 +// Maximum size of the payload in bytes of each RX buffer +#define SL_CPC_RX_PAYLOAD_MAX_LENGTH (256) + +// Tx Queue Size +// Default: 20 +// The maximum number of outgoing messages capable of being queued for transmission. +#define SL_CPC_TX_QUEUE_ITEM_MAX_COUNT 15 + +// Total Number of Rx Buffers +// Default: 20 +// Total number of CPC RX buffers available across all endpoints +// Multiple RX buffers can be associated with a single endpoint +#define SL_CPC_RX_BUFFER_MAX_COUNT 15 + +// Max Number of User Endpoints<0-10> +// Default: 1 +// Maximum number of CPC user endpoints that can be opened at once. +#define SL_CPC_USER_ENDPOINT_MAX_COUNT 0 + +// Enable debug core tracing with system view +// Default: 0 +#define SL_CPC_DEBUG_SYSTEM_VIEW_LOG_CORE_EVENT 0 + +// Enable debug endpoint tracing with system view +// Default: 0 +#define SL_CPC_DEBUG_SYSTEM_VIEW_LOG_ENDPOINT_EVENT 0 + +// Enable debug counters for core events +// Default: 0 +#define SL_CPC_DEBUG_CORE_EVENT_COUNTERS 0 + +// Enable debug counters for endpoint events +// Default: 0 +#define SL_CPC_DEBUG_ENDPOINT_EVENT_COUNTERS 0 + +// Enable debug counters for memory allocation +// Default: 0 +#define SL_CPC_DEBUG_MEMORY_ALLOCATOR_COUNTERS 0 + +// + +// <<< end of configuration section >>> + +#endif /* SL_CPC_CONFIG_H */ diff --git a/src/rcp-uart-802154/config/sl_cpc_drv_uart_usart_vcom_config.h b/src/rcp-uart-802154/config/sl_cpc_drv_uart_usart_vcom_config.h new file mode 100644 index 00000000..381b2e02 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_cpc_drv_uart_usart_vcom_config.h @@ -0,0 +1,102 @@ +/***************************************************************************//** + * @file + * @brief CPC UART driver configuration file. + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> +#ifndef SL_CPC_DRV_UART_USART_VCOM_CONFIG_H +#define SL_CPC_DRV_UART_USART_VCOM_CONFIG_H + +// CPC - UART Driver Configuration + +// Number of frame that can be queued in the driver receive queue +// Default: 10 +#define SL_CPC_DRV_UART_VCOM_RX_QUEUE_SIZE 10 + +// Number of frame that can be queued in the driver transmit queue +// Default: 10 +#define SL_CPC_DRV_UART_VCOM_TX_QUEUE_SIZE 10 + +// UART Baudrate +// Default: 115200 +#define SL_CPC_DRV_UART_VCOM_BAUDRATE 460800 + +// Flow control +// None +// CTS/RTS +// Default: usartHwFlowControlCtsAndRts +#define SL_CPC_DRV_UART_VCOM_FLOW_CONTROL_TYPE usartHwFlowControlCtsAndRts +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_CPC_DRV_UART_VCOM +// $[USART_SL_CPC_DRV_UART_VCOM] +#ifndef SL_CPC_DRV_UART_VCOM_PERIPHERAL +#define SL_CPC_DRV_UART_VCOM_PERIPHERAL USART0 +#endif +#ifndef SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO +#define SL_CPC_DRV_UART_VCOM_PERIPHERAL_NO 0 +#endif + +// USART0 TX on PA05 +#ifndef SL_CPC_DRV_UART_VCOM_TX_PORT +#define SL_CPC_DRV_UART_VCOM_TX_PORT gpioPortA +#endif +#ifndef SL_CPC_DRV_UART_VCOM_TX_PIN +#define SL_CPC_DRV_UART_VCOM_TX_PIN 5 +#endif + +// USART0 RX on PA06 +#ifndef SL_CPC_DRV_UART_VCOM_RX_PORT +#define SL_CPC_DRV_UART_VCOM_RX_PORT gpioPortA +#endif +#ifndef SL_CPC_DRV_UART_VCOM_RX_PIN +#define SL_CPC_DRV_UART_VCOM_RX_PIN 6 +#endif + +// USART0 CTS on PC03 +#ifndef SL_CPC_DRV_UART_VCOM_CTS_PORT +#define SL_CPC_DRV_UART_VCOM_CTS_PORT gpioPortC +#endif +#ifndef SL_CPC_DRV_UART_VCOM_CTS_PIN +#define SL_CPC_DRV_UART_VCOM_CTS_PIN 3 +#endif + +// USART0 RTS on PC02 +#ifndef SL_CPC_DRV_UART_VCOM_RTS_PORT +#define SL_CPC_DRV_UART_VCOM_RTS_PORT gpioPortC +#endif +#ifndef SL_CPC_DRV_UART_VCOM_RTS_PIN +#define SL_CPC_DRV_UART_VCOM_RTS_PIN 2 +#endif +// [USART_SL_CPC_DRV_UART_VCOM]$ +// <<< sl:end pin_tool >>> + +#endif /* SL_CPC_DRV_UART_VCOM_CONFIG_H */ diff --git a/src/rcp-uart-802154/config/sl_debug_swo_config.h b/src/rcp-uart-802154/config/sl_debug_swo_config.h new file mode 100644 index 00000000..fee7e65d --- /dev/null +++ b/src/rcp-uart-802154/config/sl_debug_swo_config.h @@ -0,0 +1,106 @@ +/***************************************************************************//** + * @file + * @brief SWO configuration + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEBUG_SWO_CONFIG_H +#define SL_DEBUG_SWO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// SWO Configuration + +// SWO Frequency +// Must be 875 kHz for communication with Silicon Labs debuggers +// Default: 875000 +#define SL_DEBUG_SWO_FREQ 875000 + +// Enable interrupt event trace +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_IRQ 0 + +// Enable Program Counter samples +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_PC 0 + +// SWO debug sample intervals +// <64=> 64 +// <128=> 128 +// <192=> 192 +// <256=> 256 +// <320=> 320 +// <384=> 384 +// <448=> 448 +// <512=> 512 +// <576=> 576 +// <640=> 640 +// <704=> 704 +// <768=> 768 +// <832=> 832 +// <896=> 896 +// <960=> 960 +// <1024=> 1024 +// <2048=> 2048 +// <3072=> 3072 +// <4096=> 4096 +// <5102=> 5102 +// <6144=> 6144 +// <7168=> 7168 +// <8192=> 8192 +// <9216=> 9216 +// <10240=> 10240 +// <11264=> 11264 +// <12288=> 12288 +// <13312=> 13312 +// <14336=> 14336 +// <15360=> 15360 +// Must be 64, 128, 192, [ n * 64 ], 1024, 2048, 3072, [ n * 1024 ] , 15360 +// Default: 15360 +#define SL_DEBUG_SWO_SAMPLE_INTERVAL 15360 +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_DEBUG +// $[GPIO_SL_DEBUG] +#ifndef SL_DEBUG_PERIPHERAL +#define SL_DEBUG_PERIPHERAL GPIO +#endif + +// GPIO SWV on PA03 +#ifndef SL_DEBUG_SWV_PORT +#define SL_DEBUG_SWV_PORT gpioPortA +#endif +#ifndef SL_DEBUG_SWV_PIN +#define SL_DEBUG_SWV_PIN 3 +#endif +// [GPIO_SL_DEBUG]$ +// <<< sl:end pin_tool >>> + +#endif // SL_DEBUG_SWO_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_device_init_emu_config.h b/src/rcp-uart-802154/config/sl_device_init_emu_config.h new file mode 100644 index 00000000..4ac96bac --- /dev/null +++ b/src/rcp-uart-802154/config/sl_device_init_emu_config.h @@ -0,0 +1,53 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_EMU Config + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_EMU_CONFIG_H +#define SL_DEVICE_INIT_EMU_CONFIG_H + +#include "em_emu.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// Allow debugger to remain connected in EM2 +// Force PD0B to stay on on EM2 entry. This allows the debugger to remain connected in EM2 and EM3. +// Enabling debug connectivity results in an increased power consumption in EM2/EM3. +// Default: 1 +#define SL_DEVICE_INIT_EMU_EM2_DEBUG_ENABLE 1 + +// EM4 pin retention mode +// No Retention: Pads enter reset state when entering EM4. +// Retention through EM4: Pads enter reset state when exiting EM4. +// Retention through EM4 and wakeup. +// Default: emuPinRetentionDisable +#define SL_DEVICE_INIT_EMU_EM4_PIN_RETENTION_MODE emuPinRetentionDisable + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_EMU_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_device_init_hfrco_config.h b/src/rcp-uart-802154/config/sl_device_init_hfrco_config.h new file mode 100644 index 00000000..d2d99400 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_device_init_hfrco_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFRCO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFRCO_CONFIG_H +#define SL_DEVICE_INIT_HFRCO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Frequency Band +// RC Oscillator Frequency Band +// 1 MHz +// 2 MHz +// 4 MHz +// 7 MHz +// 13 MHz +// 16 MHz +// 19 MHz +// 26 MHz +// 32 MHz +// 38 MHz +// 48 MHz +// 56 MHz +// 64 MHz +// 80 MHz +// Default: cmuHFRCODPLLFreq_80M0Hz +#define SL_DEVICE_INIT_HFRCO_BAND cmuHFRCODPLLFreq_80M0Hz + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFRCO_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_device_init_hfxo_config.h b/src/rcp-uart-802154/config/sl_device_init_hfxo_config.h new file mode 100644 index 00000000..6a35767e --- /dev/null +++ b/src/rcp-uart-802154/config/sl_device_init_hfxo_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFXO_CONFIG_H +#define SL_DEVICE_INIT_HFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// External sine wave +// Default: cmuHfxoOscMode_Crystal +#define SL_DEVICE_INIT_HFXO_MODE cmuHfxoOscMode_Crystal + +// Frequency <38000000-40000000> +// Default: 38400000 +#define SL_DEVICE_INIT_HFXO_FREQ 38400000 + +// HFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_HFXO_PRECISION 50 + +// CTUNE <0-255> +// Default: 140 +#define SL_DEVICE_INIT_HFXO_CTUNE 133 + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFXO_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_device_init_lfxo_config.h b/src/rcp-uart-802154/config/sl_device_init_lfxo_config.h new file mode 100644 index 00000000..6bd763ba --- /dev/null +++ b/src/rcp-uart-802154/config/sl_device_init_lfxo_config.h @@ -0,0 +1,66 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_LFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_LFXO_CONFIG_H +#define SL_DEVICE_INIT_LFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// AC-coupled buffer +// External digital clock +// Default: cmuLfxoOscMode_Crystal +#define SL_DEVICE_INIT_LFXO_MODE cmuLfxoOscMode_Crystal + +// CTUNE <0-127> +// Default: 63 +#define SL_DEVICE_INIT_LFXO_CTUNE 79 + +// LFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_LFXO_PRECISION 50 + +// Startup Timeout Delay +// +// 2 cycles +// 256 cycles +// 1K cycles +// 2K cycles +// 4K cycles +// 8K cycles +// 16K cycles +// 32K cycles +// Default: cmuLfxoStartupDelay_4KCycles +#define SL_DEVICE_INIT_LFXO_TIMEOUT cmuLfxoStartupDelay_4KCycles +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_LFXO_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_mbedtls_config.h b/src/rcp-uart-802154/config/sl_mbedtls_config.h new file mode 100644 index 00000000..39b51496 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_mbedtls_config.h @@ -0,0 +1,118 @@ +#ifndef SL_MBEDTLS_CONFIG_H +#define SL_MBEDTLS_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// TLS/DTLS configuration + +// Complete list of ciphersuites to use, in order of preference. +// Default: MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 +// Complete list of ciphersuites to use, in order of preference. +// The value of this configuration should be updated for the application needs. +#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + +// Maximum TLS/DTLS fragment length in bytes (input). +// Default: 768 +// The size configured here determines the size of the internal I/O +// buffer used in mbedTLS when receiving data. +#define SL_MBEDTLS_SSL_IN_CONTENT_LEN 768 + +// Maximum TLS/DTLS fragment length in bytes (output). +// Default: 768 +// The size configured here determines the size of the internal I/O +// buffer used in mbedTLS when sending data. +#define SL_MBEDTLS_SSL_OUT_CONTENT_LEN 768 + +// Enable support for RFC 6066 max_fragment_length extension in SSL. +// Default: 1 +// Enable support for RFC 6066 max_fragment_length extension in SSL. +#define SL_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1 + +// Enable support for exporting key block and master secret. +// Default: 1 +// Enable support for exporting key block and master secret. +// This is required for certain users of TLS, e.g. EAP-TLS. +#define SL_MBEDTLS_SSL_EXPORT_KEYS 1 + +// Enable the PSK based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the PSK based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED 0 + +// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED 0 + +// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 0 + +// Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED 0 + +// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. +// Default: 0 +// Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. +#define SL_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED 0 + +// Enable parsing of the compressed curves. +// Default: 0 +// Enable parsing of the compressed curves. +#define SL_MBEDTLS_ECP_ENABLE_COMPRESSED_CURVE_PARSING 0 + +// + +// RSA configuration + +// Disable use of the Chinese Remainder Theorem for RSA. +// Default: 0 +// Disable use of the Chinese Remainder Theorem for RSA private key +// computations. +#define SL_MBEDTLS_RSA_NO_CRT 0 + +// + +// Miscellaneous configuration + +// Enable Silicon Labs' Mbed TLS- and PSA Crypto drivers. +// Default: 1 +// Enable drivers for hardware acceleration (Mbed TLS and PSA Crypto) and +// secure key handling (PSA Crypto). +#define SL_MBEDTLS_DRIVERS_ENABLED 1 + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Sub-files + +#if defined(SLI_MBEDTLS_CONFIG_AUTOGEN_OVERRIDE_FILE) + #include SLI_MBEDTLS_CONFIG_AUTOGEN_OVERRIDE_FILE +#else + #include "sli_mbedtls_config_autogen.h" +#endif + +#include "sli_mbedtls_omnipresent.h" + +#if SL_MBEDTLS_DRIVERS_ENABLED + #include "sli_mbedtls_acceleration.h" +#endif + +#include "sl_mbedtls_device_config.h" + +// Include transformation logic to apply CMSIS-config configuration options to +// the correct Mbed TLS / PSA Crypto options. +#include "sli_mbedtls_config_transform_autogen.h" + +// Included for backward compatibility reasons. +#include "mbedtls/build_info.h" + +#endif // SL_MBEDTLS_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_mbedtls_device_config.h b/src/rcp-uart-802154/config/sl_mbedtls_device_config.h new file mode 100644 index 00000000..33c34c42 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_mbedtls_device_config.h @@ -0,0 +1,72 @@ +#ifndef SL_MBEDTLS_DEVICE_CONFIG_H +#define SL_MBEDTLS_DEVICE_CONFIG_H + +// ----------------------------------------------------------------------------- +// User exposed config options + +// <<< Use Configuration Wizard in Context Menu >>> + +// Secure Engine (SE) version configuration + +// Support SE firmware versions older than 1.2.2 <0-1> +// Enable software fallback for ECDH and ECC public key validation on xG21 +// devices running SE firmware versions lower than 1.2.2. +// +// Due to other stability concerns, it is strongly recommended to upgrade +// these devices to the latest firmware revision instead of turning on +// software fallback support. +// +// Not having fallback support will make ECDH operations, as well as PSA +// Crypto public key import, return an error code on affected devices. +// +// Default: 0 +#define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 0 + +// Assume an SE firmware version newer than 1.2.2 <0-1> +// For enhanced performance: if it is guaranteed that all devices on which +// this library will run are updated to at least SE FW 1.2.2, then turning +// on this option will remove certain fallback checks, thereby reducing the +// amount of processing required for ECDH and public key verification +// operations. +// Default: 0 +#define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 0 + +// Assume an SE firmware version that is unaffected by Ed25519 errata <0-1> +// For minimal code size and performance savings: if it is guaranteed that +// none of the devices running this library has SE FWs in the range +// [1.2.2, 1.2.8], then enabling this option will disable runtime version +// checks. +// Default: 0 +#define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 0 + +// + +// <<< end of configuration section >>> + +// ----------------------------------------------------------------------------- +// Additional SE version related logic (DO NOT MODIFY) + +// SL_SE_ASSUME_FW_AT_LEAST_1_2_10 is no longer in use, however, it is kept here +// for backwards compatibility. */ +#if defined(SL_SE_ASSUME_FW_AT_LEAST_1_2_10) + #undef SL_SE_ASSUME_FW_AT_LEAST_1_2_2 + #define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1 + #undef SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA + #define SL_SE_ASSUME_FW_UNAFFECTED_BY_ED25519_ERRATA 1 +#endif + +// SLI_SE_SUPPORT_FW_PRIOR_TO_1_2_2 is no longer in use, however, it is kept +// here for backwards compatibility. */ +#if defined(SLI_SE_SUPPORT_FW_PRIOR_TO_1_2_2) + #undef SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 + #define SL_SE_SUPPORT_FW_PRIOR_TO_1_2_2 1 +#endif + +// SLI_SE_ASSUME_FW_AT_LEAST_1_2_2 is no longer in use, however, it is kept +// here for backwards compatibility. */ +#if defined(SLI_SE_ASSUME_FW_AT_LEAST_1_2_2) + #undef SL_SE_ASSUME_FW_AT_LEAST_1_2_2 + #define SL_SE_ASSUME_FW_AT_LEAST_1_2_2 1 +#endif + +#endif // SL_MBEDTLS_DEVICE_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_memory_config.h b/src/rcp-uart-802154/config/sl_memory_config.h new file mode 100644 index 00000000..3710cf90 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_memory_config.h @@ -0,0 +1,28 @@ +#ifndef SL_MEMORY_CONFIG_H +#define SL_MEMORY_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Memory configuration + +// Stack size for the application. +// Default: 4096 +// The stack size configured here will be used by the stack that the +// application uses when coming out of a reset. +#ifndef SL_STACK_SIZE + #define SL_STACK_SIZE 2752 +#endif + +// Minimum heap size for the application. +// Default: 2048 +// Note that this value will configure the c heap which is normally used by +// malloc() and free() from the c library. The value defines a minimum heap +// size that is guaranteed to be available. The available heap may be larger +// to make use of any memory that would otherwise remain unused. +#ifndef SL_HEAP_SIZE + #define SL_HEAP_SIZE 2048 +#endif + +// +// <<< end of configuration section >>> + +#endif diff --git a/src/rcp-uart-802154/config/sl_openthread_coex_config.h b/src/rcp-uart-802154/config/sl_openthread_coex_config.h new file mode 100644 index 00000000..8ab012b2 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_openthread_coex_config.h @@ -0,0 +1,11 @@ +//-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- +// +// Coexistence Configurations +// Synch MAC to GRANT (MAC holdoff) +#define SL_OPENTHREAD_COEX_MAC_HOLDOFF_ENABLE 0 + +// Counters +#define SL_OPENTHREAD_COEX_COUNTER_ENABLE 1 + +// +// <<< end of configuration section >>> diff --git a/src/rcp-uart-802154/config/sl_openthread_features_config.h b/src/rcp-uart-802154/config/sl_openthread_features_config.h new file mode 100644 index 00000000..b3493cdf --- /dev/null +++ b/src/rcp-uart-802154/config/sl_openthread_features_config.h @@ -0,0 +1,327 @@ +#ifndef _SL_OPENTHREAD_FEATURES_CONFIG_H +#define _SL_OPENTHREAD_FEATURES_CONFIG_H +//-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- +// +// Default OpenThread Stack Configuration + +// Thread Stack Protocol Version +// +// Thread 1.1 +// Thread 1.2 +// Thread 1.3 +// Thread 1.2 and Thread 1.3 are compatible with Thread 1.1. +// Current Default: OT_THREAD_VERSION_1_3 +#ifndef OPENTHREAD_CONFIG_THREAD_VERSION +#define OPENTHREAD_CONFIG_THREAD_VERSION OT_THREAD_VERSION_1_3 +#endif +// + +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) +// The following features require at least Thread Stack Protocol Version 1.2 +// Backbone Router +#ifndef OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE +#define OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE 0 +#endif +// CSL Auto Synchronization using data polling +#ifndef OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE +#define OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE 0 +#endif +// CSL (Coordinated Sampled Listening) Debug +#ifndef OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE +#define OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE 0 +#endif +// CSL (Coordinated Sampled Listening) Receiver +#ifndef OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE +#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 0 +#endif +// CSL Scheduling Uncertainty (±10 us units) <12..999:1> +#ifndef SL_OPENTHREAD_CSL_TX_UNCERTAINTY +#if OPENTHREAD_RADIO + #define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 175 +#elif OPENTHREAD_FTD + #define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 20 +#else + #define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 12 +#endif +#endif +// DUA (Domain Unicast Address) +#ifndef OPENTHREAD_CONFIG_DUA_ENABLE +#define OPENTHREAD_CONFIG_DUA_ENABLE 1 +#endif +// Link Metrics Initiator +#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1 +#endif +// Link Metrics Subject +#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1 +#endif +// Multicast Listener Registration +#ifndef OPENTHREAD_CONFIG_MLR_ENABLE +#define OPENTHREAD_CONFIG_MLR_ENABLE 1 +#endif +// DNS Client (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1 +#endif +// DNS-SD Server (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE +#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 0 +#endif +// Service Registration Protocol (SRP) Client (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1 +#endif +// Service Registration Protocol (SRP) Server (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_SRP_SERVER_ENABLE +#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 0 +#endif +// TCPlp (Low power TCP over OpenThread) (Thread 1.3) +#ifndef OPENTHREAD_CONFIG_TCP_ENABLE +#define OPENTHREAD_CONFIG_TCP_ENABLE 0 +#endif +// Thread over Infrastructure (Thread 1.3: NCP only) +#ifndef OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE +#define OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE 0 +#endif +// +#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 + +// Border Agent +#ifndef OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE +#define OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE 0 +#endif +// +// Border Router +#ifndef OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE +#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 0 +#endif +// +// Channel Manager +#ifndef OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE +#define OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE 0 +#endif +// +// Channel Monitor +#ifndef OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE +#define OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE 0 +#endif +// + +// Commissioner +#ifndef OPENTHREAD_CONFIG_COMMISSIONER_ENABLE +#define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 0 +#endif + +// Max Joiner Entries +// The maximum number of Joiner entries maintained by the Commissioner. +// 2 +#ifndef OPENTHREAD_CONFIG_COMMISSIONER_MAX_JOINER_ENTRIES +#define OPENTHREAD_CONFIG_COMMISSIONER_MAX_JOINER_ENTRIES 2 +#endif +// + +// COAP API +#ifndef OPENTHREAD_CONFIG_COAP_API_ENABLE +#define OPENTHREAD_CONFIG_COAP_API_ENABLE 0 +#endif +// +// COAP Observe (RFC7641) API +#ifndef OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE +#define OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE 0 +#endif +// +// COAP Secure API +#ifndef OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE +#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 0 +#endif +// +// DHCP6 Client +#ifndef OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 0 +#endif +// +// DHCP6 Server +#ifndef OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE +#define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 0 +#endif +// +// Diagnostic +#ifndef OPENTHREAD_CONFIG_DIAG_ENABLE +#define OPENTHREAD_CONFIG_DIAG_ENABLE 1 +#endif +// +// ECDSA (Elliptic Curve Digital Signature Algorithm) (Required for Matter support) +#ifndef OPENTHREAD_CONFIG_ECDSA_ENABLE +#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1 +#endif +// +// External Heap +#ifndef OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE +#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 0 +#endif +// +// IPv6 Fragmentation +#ifndef OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE +#define OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE 0 +#endif +// +// Maximum number of IPv6 unicast addresses allowed to be externally added +#ifndef OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS +#define OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS 4 +#endif +// +// Maximum number of IPv6 multicast addresses allowed to be externally added +#ifndef OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS +#define OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS 4 +#endif +// +// Jam Detection +#ifndef OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE +#define OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE 0 +#endif +// +// Joiner +#ifndef OPENTHREAD_CONFIG_JOINER_ENABLE +#define OPENTHREAD_CONFIG_JOINER_ENABLE 0 +#endif +// +// Link Raw Service +#ifndef OPENTHREAD_CONFIG_LINK_RAW_ENABLE +#define OPENTHREAD_CONFIG_LINK_RAW_ENABLE 0 +#endif +// +// MAC Filter +#ifndef OPENTHREAD_CONFIG_MAC_FILTER_ENABLE +#define OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 0 +#endif +// +// MLE Long Routes extension (experimental) +#ifndef OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE +#define OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE 0 +#endif +// +// MultiPAN RCP +#ifndef OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE +#define OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE 1 +#endif +// +// Multiple OpenThread Instances +#ifndef OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE +#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 0 +#endif +// +// OTNS (OpenThread Network Simulator) +#ifndef OPENTHREAD_CONFIG_OTNS_ENABLE +#define OPENTHREAD_CONFIG_OTNS_ENABLE 0 +#endif +// +// Ping Sender Module +#ifndef OPENTHREAD_CONFIG_PING_SENDER_ENABLE +#define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1 +#endif +// +// Platform UDP +#ifndef OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE +#define OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE 0 +#endif +// +// Reference Device for Thread Test Harness +#ifndef OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE +#define OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE 0 +#endif +// +// Service Entries in Thread Network Data +#ifndef OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE +#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 0 +#endif +// +// RAM (volatile-only storage) +#ifndef OPENTHREAD_SETTINGS_RAM +#define OPENTHREAD_SETTINGS_RAM 0 +#endif +// +// SLAAC Addresses +#ifndef OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE +#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1 +#endif +// +// SNTP Client +#ifndef OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE 0 +#endif +// +// TMF Network Diagnostic client API +#ifndef OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE +#define OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE 1 +#endif +// +// Time Synchronization Service +#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0 +// +// UDP Forward +#ifndef OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE +#define OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 0 +#endif +// +// Enable Mac beacon payload parsing support +#ifndef OPENTHREAD_CONFIG_MAC_BEACON_PAYLOAD_PARSING_ENABLE +#define OPENTHREAD_CONFIG_MAC_BEACON_PAYLOAD_PARSING_ENABLE 1 +#endif +// +// +// Logging +// LOG_OUTPUT +// NONE +// APP +// PLATFORM_DEFINED +// Default: OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED +#ifndef OPENTHREAD_CONFIG_LOG_OUTPUT +#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_NONE +#endif + +// DYNAMIC_LOG_LEVEL +#ifndef OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE +#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 0 +#endif + +// Enable Logging +#define OPENTHREAD_FULL_LOGS_ENABLE 0 +#if OPENTHREAD_FULL_LOGS_ENABLE + +// Note: Enabling higher log levels, which include logging packet details, can cause delays which may result in join failures. +// LOG_LEVEL +// NONE +// CRIT +// WARN +// NOTE +// INFO +// DEBG +// Default: OT_LOG_LEVEL_DEBG +#ifndef OPENTHREAD_CONFIG_LOG_LEVEL +#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG +#endif +// CLI +#ifndef OPENTHREAD_CONFIG_LOG_CLI +#define OPENTHREAD_CONFIG_LOG_CLI 1 +#endif +// PKT_DUMP +#ifndef OPENTHREAD_CONFIG_LOG_PKT_DUMP +#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 +#endif +// PLATFORM +#ifndef OPENTHREAD_CONFIG_LOG_PLATFORM +#define OPENTHREAD_CONFIG_LOG_PLATFORM 1 +#endif +// PREPEND_LEVEL +#ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL +#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 +#endif + +#endif +// +// +// + +// <<< end of configuration section >>> +#endif // _SL_OPENTHREAD_FEATURES_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_openthread_generic_config.h b/src/rcp-uart-802154/config/sl_openthread_generic_config.h new file mode 100644 index 00000000..fd057a7f --- /dev/null +++ b/src/rcp-uart-802154/config/sl_openthread_generic_config.h @@ -0,0 +1,148 @@ +/* include/openthread-config-generic.h. Generated from openthread-config-generic.h.in by configure. */ +/* include/openthread-config-generic.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define to 1 if your C++ compiler doesn't accept -c and -o together. */ +/* #undef CXX_NO_MINUS_C_MINUS_O */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `edit' library (-ledit). */ +/* #undef HAVE_LIBEDIT */ + +/* Define to 1 if you have the `readline' library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `memcpy' function. */ +/* #undef HAVE_MEMCPY */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if stdbool.h conforms to C99. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define HAVE__BOOL 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Name of package */ +#define PACKAGE "openthread" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "openthread-devel@googlegroups.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "SL-OPENTHREAD" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "SL-OPENTHREAD/2.4.0.0_GitHub-7074a43e4" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "openthread" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://github.com/openthread/openthread" + +/* Define to the version of this package. + * Note: When adding the label below with OpenThread version, please make + * sure it is a valid GitHub version. Avoid merge or local commit hashes. + */ +#define PACKAGE_VERSION "2.4.0.0_GitHub-7074a43e4" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "2.4.0.0_GitHub-7074a43e4" + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT8_T */ + +/* Define to the type of a signed integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int16_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to the type of a signed integer type of width exactly 8 bits if such + a type exists and the standard includes do not define it. */ +/* #undef int8_t */ + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint16_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint8_t */ diff --git a/src/rcp-uart-802154/config/sl_rail_util_coex_common_config.h b/src/rcp-uart-802154/config/sl_rail_util_coex_common_config.h new file mode 100644 index 00000000..7cddee03 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rail_util_coex_common_config.h @@ -0,0 +1,254 @@ +/***************************************************************************//** + * @file + * @brief Common coexistence configuration header file + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_COEX_COMMON_CONFIG_H +#define SL_RAIL_UTIL_COEX_COMMON_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Coexistence Configuration + +// IEEE802.15.4 Only Configuration +// Disable ACKing when GRANT deasserted, RHO asserted, or REQUEST deasserted +// Disable ACKing when GNT deasserted, RHO asserted, or REQ not secured (shared REQ only) +// Default: 1 +#define SL_RAIL_UTIL_COEX_ACKHOLDOFF 1 + +// Abort transmission mid-packet if Grant when GRANT deasserted, RHO asserted, or REQUEST not secured (shared REQUEST only) +// Abort transmission mid-packet if Grant when GRANT deasserted, RHO asserted, or REQUEST not secured (shared REQUEST only) +// Default: 0 +#define SL_RAIL_UTIL_COEX_IEEE802154_TX_ABORT 0 +// + +// BLE Only Configuration +// Abort transmission mid-packet if Grant when GRANT deasserted, RHO asserted, or REQUEST not secured (shared REQUEST only) +// Abort transmission mid-packet if Grant when GRANT deasserted, RHO asserted, or REQUEST not secured (shared REQUEST only) +// Default: 0 +#define SL_RAIL_UTIL_COEX_BLE_TX_ABORT 0 +// + +// REQUEST +// Enable REQUEST signal +// Default: 0 +#define SL_RAIL_UTIL_COEX_REQ_ENABLED 0 + +// REQUEST assert signal level +// <1=> High +// <0=> Low +// Polarity of REQUEST signal +// Default: 1 +#define SL_RAIL_UTIL_COEX_REQ_ASSERT_LEVEL 1 + +// Enable REQUEST shared mode +// Configure the REQUEST signal for shared mode +// Default: 0 +#define SL_RAIL_UTIL_COEX_REQ_SHARED 0 + +// Max REQUEST backoff mask [0-255] +// <0-255:1> +// Maximum backoff time in microseconds after REQUEST was deasserted +// Default: 15 +#define SL_RAIL_UTIL_COEX_REQ_BACKOFF 15 + +// BLE Only Request Configuration +// Specify the number of microseconds between asserting Request and starting RX/TX +// <0-5000:1> +// Specify the number of microseconds between asserting REQUEST and starting RX/TX (BLE only) +// Default: 500 +#define SL_RAIL_UTIL_COEX_REQ_WINDOW 500 +// + +// IEEE802.15.4 Only Request Configuration +// Enable REQUEST receive retry +// Enable the receive retry +// Default: 0 +#define SL_RAIL_UTIL_COEX_RETRYRX_ENABLE 0 + +// REQUEST receive retry timeout(ms) +// <0-255:1> +// Receive retry REQ timeout in milliseconds +// Default: 16 +#define SL_RAIL_UTIL_COEX_RETRYRX_TIMEOUT 16 + +// REQUEST receive retry assert PRIORITY +// Enable the receive retry high priority +// Default: 0 +#define SL_RAIL_UTIL_COEX_RETRYRX_HIPRI 0 +// +// +// + +// GRANT +// Enable GRANT signal +// Default: 0 +#define SL_RAIL_UTIL_COEX_GNT_ENABLED 0 + +// GRANT assert signal level +// <1=> High +// <0=> Low +// Polarity of grant (GNT) signal +// Default: 1 +#define SL_RAIL_UTIL_COEX_GNT_ASSERT_LEVEL 1 +// + +// PRIORITY +// Enable PRIORITY signal +// Default: 0 +#define SL_RAIL_UTIL_COEX_PRI_ENABLED 0 + +// PRIORITY assert signal level +// <1=> High +// <0=> Low +// Polarity of priority(PRI) signal +// Default: 1 +#define SL_RAIL_UTIL_COEX_PRI_ASSERT_LEVEL 1 + +// Enable PRIORITY shared mode +// Configure the PRIORITY signal for shared mode +// Default: 0 +#define SL_RAIL_UTIL_COEX_PRI_SHARED 0 + +// BLE Only Priority Configuration +// Default Enabled/Disabled +// Enable/Disable BLE PRIORITY by default +// Default: 0 +#define SL_RAIL_UTIL_COEX_PRIORITY_DEFAULT 0 +// + +// IEEE802.15.4 Only Priority Configuration +// Assert PRIORITY when transmitting packet +// Assert a high priority when the local device is transmitting a packet +// Default: 0 +#define SL_RAIL_UTIL_COEX_TX_HIPRI 0 + +// Assert PRIORITY when receiving packet +// Assert a high priority when the local device is receiving a packet +// Default: 0 +#define SL_RAIL_UTIL_COEX_RX_HIPRI 0 + +// Include TX PRIORITY escalation +// Compile-time include TX PRIORITY escalation feature +// Default: 0 +#define SL_RAIL_UTIL_COEX_PRIORITY_ESCALATION_ENABLE 0 + +// CCA/GRANT TX PRIORITY escalation threshold +// <0-255:1> +// Sets the threshold for escalating TX PRIORITY to high priority due to MAC failures from CCA/GRANT denials (five consecutive CCA/GRANT denials is one MAC failure) +// Default: 4 +#define SL_RAIL_UTIL_COEX_CCA_THRESHOLD 4 + +// MAC Fail TX PRIORITY escalation threshold +// <0-3:1> +// Sets the threshold for escalating TX PRIORITY to high priority due to MAC failures from CCA/GRANT denials (five consecutive CCA/GRANT denials is one MAC failure) or no RX_ACK received (four consecutive RX_ACK failures is one MAC failure) +// Default: 0 +#define SL_RAIL_UTIL_COEX_MAC_FAIL_THRESHOLD 0 +// +// + +// PWM REQUEST +// Enable PWM REQUEST signal +// Default: 0 +#define SL_RAIL_UTIL_COEX_PWM_REQ_ENABLED 0 + +// PWM REQUEST signal level (shared REQUEST only) +// <1=> High +// <0=> Low +// Polarity of PWM request (PWM_REQ) signal +// Default: 1 +#define SL_RAIL_UTIL_COEX_PWM_REQ_ASSERT_LEVEL 1 + +// Enable PWM REQUEST at startup +// Enable PWM REQUEST at startup (also run-time controllable) +// Default: 1 +#define SL_RAIL_UTIL_COEX_PWM_DEFAULT_ENABLED 1 + +// PWM Request Period (0.5ms steps) +// <5-109> +// PWM REQUEST Period (5ms to 109ms in 0.5ms steps) +// Default: 78 +#define SL_RAIL_UTIL_COEX_PWM_REQ_PERIOD 78 + +// PWM Request Duty-Cycle (%) +// <1-95:1> +// PWM REQUEST Duty-Cycle (1% to 95% in 1% steps) +// Default: 20 +#define SL_RAIL_UTIL_COEX_PWM_REQ_DUTYCYCLE 20 + +// Assert priority when PWM REQUEST asserted +// Assert a high priority when local device is asserting PWM +// Default: 0 +#define SL_RAIL_UTIL_COEX_PWM_PRIORITY 0 + +// BLE Only PWM Configuration +// Enable PWM only when local device is scanning +// Enable PWM only when local device is scanning +// Default: 0 +#define SL_RAIL_UTIL_COEX_SCANPWM_DEFAULT_ENABLED 0 +// +// + +// Radio Hold-off +// Default: 0 +#define SL_RAIL_UTIL_COEX_RHO_ENABLED 0 +// RHO assert signal level +// <1=> High +// <0=> Low +// Polarity of radio hold-off (RHO) signal +// Default: 1 +#define SL_RAIL_UTIL_COEX_RHO_ASSERT_LEVEL 1 +// + +// Directional PRIORITY +// Enable Directional PRIORITY signal +// Default: 0 +#define SL_RAIL_UTIL_COEX_DP_ENABLED 0 +// Directional PRIORITY pulse width +// <0-255:1> +// Microseconds to hold Directional PRIORITY priority pulse +// Default: 20 +#define SL_RAIL_UTIL_COEX_DP_PULSE_WIDTH_US 20 +// + +// RX active +// Enable RX active signal +// Default: 0 +#define SL_RAIL_UTIL_COEX_RX_ACTIVE_ENABLED 0 + +// RX active assert signal level +// <1=> High +// <0=> Low +// Polarity of RX active signal +// Default: 1 +#define SL_RAIL_UTIL_COEX_RX_ACTIVE_ASSERT_LEVEL 1 +// + +// +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_COEX_COMMON_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_rail_util_coex_config.h b/src/rcp-uart-802154/config/sl_rail_util_coex_config.h new file mode 100644 index 00000000..368ddb3a --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rail_util_coex_config.h @@ -0,0 +1,190 @@ +/***************************************************************************//** + * @file + * @brief Coexistence configuration header file + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_COEX_CONFIG_H +#define SL_RAIL_UTIL_COEX_CONFIG_H + +#include "sl_rail_util_coex_common_config.h" + +// <<< Use Configuration Wizard in Context Menu >>> +// Coexistence signal identifier configuration +// IEEE802.15.4 only configuration +// Enable coexistence IEEE802.15.4 signal identifier +// Default: 0 +#define SL_RAIL_UTIL_COEX_IEEE802154_SIGNAL_IDENTIFIER_ENABLED 0 +// +// BLE only Configuration +// Enable coexistence BLE signal identifier +// Default: 0 +#define SL_RAIL_UTIL_COEX_BLE_SIGNAL_IDENTIFIER_ENABLED 0 +// BLE signal identifier mode +// <1=> BLE 1Mbps +// <2=> BLE 2Mbps +// 1: Signal identifier detects BLE 1Mbps signals 2: Signal identifier detects BLE 2Mbps signals +// Default: 1 +#define SL_RAIL_UTIL_COEX_BLE_SIGNAL_IDENTIFIER_MODE 1 +// Minimum number of microseconds that should be available in the scanning window for hopping to next channel when signal identifier is enabled +// <300-2000:1> +// Default: 300 +#define SL_RAIL_UTIL_COEX_BLE_MIN_TIME_FOR_HOPPING 300 +// +// Polarity of Wifi Tx signal +// <1=> High +// <0=> Low +// Polarity of WiFi Tx signal +// Default: 1 +#define SL_RAIL_UTIL_COEX_WIFI_TX_ASSERT_LEVEL 1 +// +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +#if SL_RAIL_UTIL_COEX_GNT_ENABLED +// Pin used for grant (GNT) signal +// SL_RAIL_UTIL_COEX_GNT +// $[GPIO_SL_RAIL_UTIL_COEX_GNT] +// #define SL_RAIL_UTIL_COEX_GNT_PORT gpioPortC +// #define SL_RAIL_UTIL_COEX_GNT_PIN 9 +// [GPIO_SL_RAIL_UTIL_COEX_GNT]$ +#ifndef SL_RAIL_UTIL_COEX_GNT_PORT +#error "SL_RAIL_UTIL_COEX_GNT undefined" +#endif //SL_RAIL_UTIL_COEX_GNT_PORT +#endif //SL_RAIL_UTIL_COEX_GNT_ENABLED + +#if SL_RAIL_UTIL_COEX_PRI_ENABLED +// Pin used for PRIORITY signal +// SL_RAIL_UTIL_COEX_PRI +// $[GPIO_SL_RAIL_UTIL_COEX_PRI] +// #define SL_RAIL_UTIL_COEX_PRI_PORT gpioPortD +// #define SL_RAIL_UTIL_COEX_PRI_PIN 13 +// [GPIO_SL_RAIL_UTIL_COEX_PRI]$ +#if !defined(SL_RAIL_UTIL_COEX_PRI_PORT) && !SL_RAIL_UTIL_COEX_DP_ENABLED +#error "SL_RAIL_UTIL_COEX_PRI undefined" +#endif //!defined(SL_RAIL_UTIL_COEX_PRI_PORT) && !SL_RAIL_UTIL_COEX_DP_ENABLED +#endif //SL_RAIL_UTIL_COEX_PRI_ENABLED + +#if SL_RAIL_UTIL_COEX_REQ_ENABLED +// Pin used for Request signal +// SL_RAIL_UTIL_COEX_REQ +// $[GPIO_SL_RAIL_UTIL_COEX_REQ] +// #define SL_RAIL_UTIL_COEX_REQ_PORT gpioPortC +// #define SL_RAIL_UTIL_COEX_REQ_PIN 10 +// [GPIO_SL_RAIL_UTIL_COEX_REQ]$ +#ifndef SL_RAIL_UTIL_COEX_REQ_PORT +#error "SL_RAIL_UTIL_COEX_REQ undefined" +#endif //SL_RAIL_UTIL_COEX_REQ_PORT +#endif //SL_RAIL_UTIL_COEX_REQ_ENABLED + +#if SL_RAIL_UTIL_COEX_PWM_REQ_ENABLED && SL_RAIL_UTIL_COEX_REQ_SHARED +// Pin used for PWM Request signal +// SL_RAIL_UTIL_COEX_PWM_REQ +// $[GPIO_SL_RAIL_UTIL_COEX_PWM_REQ] +// #define SL_RAIL_UTIL_COEX_PWM_REQ_PORT gpioPortC +// #define SL_RAIL_UTIL_COEX_PWM_REQ_PIN 11 +// [GPIO_SL_RAIL_UTIL_COEX_PWM_REQ]$ +#ifndef SL_RAIL_UTIL_COEX_PWM_REQ_PORT +#error "SL_RAIL_UTIL_COEX_PWM_REQ undefined" +#endif //SL_RAIL_UTIL_COEX_PWM_REQ_PORT +#endif //SL_RAIL_UTIL_COEX_PWM_REQ_ENABLED && SL_RAIL_UTIL_COEX_REQ_SHARED + +#if SL_RAIL_UTIL_COEX_RHO_ENABLED +// Pin used for Radio Holdoff signal +// SL_RAIL_UTIL_COEX_RHO +// $[GPIO_SL_RAIL_UTIL_COEX_RHO] +// #define SL_RAIL_UTIL_COEX_RHO_PORT gpioPortC +// #define SL_RAIL_UTIL_COEX_RHO_PIN 8 +// [GPIO_SL_RAIL_UTIL_COEX_RHO]$ +#ifndef SL_RAIL_UTIL_COEX_RHO_PORT +#error "SL_RAIL_UTIL_COEX_RHO undefined" +#endif //SL_RAIL_UTIL_COEX_RHO_PORT +#endif //SL_RAIL_UTIL_COEX_RHO_ENABLED + +#if SL_RAIL_UTIL_COEX_DP_ENABLED +// Pin used for Directional Priority signal +// SL_RAIL_UTIL_COEX_DP_OUT +// $[PRS_SL_RAIL_UTIL_COEX_DP_OUT] +// #define SL_RAIL_UTIL_COEX_DP_OUT_CHANNEL 3 + +// PRS CH3 on PD12 +// #define SL_RAIL_UTIL_COEX_DP_OUT_PORT gpioPortD +// #define SL_RAIL_UTIL_COEX_DP_OUT_PIN 12 +// [PRS_SL_RAIL_UTIL_COEX_DP_OUT]$ + +// Directional Priority timer module +// SL_RAIL_UTIL_COEX_DP_TIMER +// $[TIMER_SL_RAIL_UTIL_COEX_DP_TIMER] +// #define SL_RAIL_UTIL_COEX_DP_TIMER_PERIPHERAL TIMER1 +// #define SL_RAIL_UTIL_COEX_DP_TIMER_PERIPHERAL_NO 1 +#ifndef SL_RAIL_UTIL_COEX_DP_TIMER_PERIPHERAL +#error "SL_RAIL_UTIL_COEX_DP_TIMER_PERIPHERAL undefined" +#endif //SL_RAIL_UTIL_COEX_DP_TIMER_PERIPHERAL + +// #define SL_RAIL_UTIL_COEX_DP_TIMER_CC0_CHANNEL 1 +// [TIMER_SL_RAIL_UTIL_COEX_DP_TIMER]$ +#ifndef SL_RAIL_UTIL_COEX_DP_TIMER_PERIPHERAL +#error "SL_RAIL_UTIL_COEX_DP_TIMER_PERIPHERAL undefined" +#endif //SL_RAIL_UTIL_COEX_DP_TIMER_PERIPHERAL +#endif //SL_RAIL_UTIL_COEX_DP_ENABLED + +#if SL_RAIL_UTIL_COEX_RX_ACTIVE_ENABLED +// Pin used for RX active signal +// SL_RAIL_UTIL_COEX_RX_ACTIVE +// $[PRS_SL_RAIL_UTIL_COEX_RX_ACTIVE] +// #define SL_RAIL_UTIL_COEX_RX_ACTIVE_CHANNEL 8 + +// PRS CH8 on PD13 +// #define SL_RAIL_UTIL_COEX_RX_ACTIVE_PORT gpioPortD +// #define SL_RAIL_UTIL_COEX_RX_ACTIVE_PIN 13 +// [PRS_SL_RAIL_UTIL_COEX_RX_ACTIVE]$ +#ifndef SL_RAIL_UTIL_COEX_RX_ACTIVE_PORT +#error "SL_RAIL_UTIL_COEX_RX_ACTIVE_PORT undefined" +#endif //SL_RAIL_UTIL_COEX_RX_ACTIVE_PORT +#ifndef SL_RAIL_UTIL_COEX_RX_ACTIVE_CHANNEL +#error "SL_RAIL_UTIL_COEX_RX_ACTIVE_CHANNEL undefined" +#endif //SL_RAIL_UTIL_COEX_RX_ACTIVE_CHANNEL +#endif //SL_RAIL_UTIL_COEX_RX_ACTIVE_ENABLED + +#if (SL_RAIL_UTIL_COEX_IEEE802154_SIGNAL_IDENTIFIER_ENABLED || SL_RAIL_UTIL_COEX_BLE_SIGNAL_IDENTIFIER_ENABLED) +// Pin used for WiFi Tx +// SL_RAIL_UTIL_COEX_WIFI_TX +// $[PRS_SL_RAIL_UTIL_COEX_WIFI_TX] +// #define SL_RAIL_UTIL_COEX_WIFI_TX_CHANNEL 4 + +// #define SL_RAIL_UTIL_COEX_WIFI_TX_PORT gpioPortC +// #define SL_RAIL_UTIL_COEX_WIFI_TX_PIN 9 +// [PRS_SL_RAIL_UTIL_COEX_WIFI_TX]$ +#ifndef SL_RAIL_UTIL_COEX_WIFI_TX_PORT +#error "SL_RAIL_UTIL_COEX_WIFI_TX_PORT undefined" +#endif // SL_RAIL_UTIL_COEX_WIFI_TX_PORT +#endif // SL_RAIL_UTIL_COEX_IEEE802154_SIGNAL_IDENTIFIER_ENABLED || SL_RAIL_UTIL_COEX_BLE_SIGNAL_IDENTIFIER_ENABLED + +// <<< sl:end pin_tool >>> + +#endif // SL_RAIL_UTIL_COEX_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_rail_util_dma_config.h b/src/rcp-uart-802154/config/sl_rail_util_dma_config.h new file mode 100644 index 00000000..dcf7171c --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rail_util_dma_config.h @@ -0,0 +1,52 @@ +/***************************************************************************//** + * @file + * @brief + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_DMA_CONFIG_H +#define SL_RAIL_UTIL_DMA_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// DMA Configuration +// Allocate DMA channel to RAIL (to decrease channel config switching time) +// Default: 1 +#define SL_RAIL_UTIL_DMA_ENABLE 1 +// Use DMA Driver (i.e., auto-select DMA channel) +// Default: 1 +#define SL_RAIL_UTIL_DMA_DMADRV_ENABLE 1 +// Use Specific DMA Channel (if DMA driver not used) +// <0-16:1> +// Default: 0 +#define SL_RAIL_UTIL_DMA_CHANNEL 0 +// +// + +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_DMA_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_rail_util_ieee802154_fast_channel_switching_config.h b/src/rcp-uart-802154/config/sl_rail_util_ieee802154_fast_channel_switching_config.h new file mode 100644 index 00000000..a4470069 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rail_util_ieee802154_fast_channel_switching_config.h @@ -0,0 +1,49 @@ +/***************************************************************************//** + * @file + * @brief IEEE802.15.4 fast channel switching configuration file. + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UITL_IEEE802154_FAST_CHANNEL_SWITCHING_CONFIG_H +#define SL_RAIL_UITL_IEEE802154_FAST_CHANNEL_SWITCHING_CONFIG_H + +#include "rail_features.h" + +#if RAIL_IEEE802154_SUPPORTS_RX_CHANNEL_SWITCHING == 0 +#error "IEEE.802.15.4 RX channel switching unsupported on this platform!" +#endif //RAIL_IEEE802154_SUPPORTS_RX_CHANNEL_SWITCHING + +#define sl_rail_util_ieee802154_is_fast_channel_switching_phy_selected() SL_RAIL_UTIL_IEEE802154_FAST_CHANNEL_SWITCHING_ENABLED + +// <<< Use Configuration Wizard in Context Menu >>> +// IEEE802.15.4 Fast Channel Switching Configuration +// Enable fast channel switching +// Default: 1 +#define SL_RAIL_UTIL_IEEE802154_FAST_CHANNEL_SWITCHING_ENABLED 1 +// +// <<< end of configuration section >>> +#endif //SL_RAIL_UITL_IEEE802154_FAST_CHANNEL_SWITCHING_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_rail_util_pa_config.h b/src/rcp-uart-802154/config/sl_rail_util_pa_config.h new file mode 100644 index 00000000..357f4296 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rail_util_pa_config.h @@ -0,0 +1,81 @@ +/***************************************************************************//** + * @file + * @brief Power Amplifier configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_PA_CONFIG_H +#define SL_RAIL_UTIL_PA_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// PA Configuration +// Initial PA Power (deci-dBm, 100 = 10.0 dBm) +// Default: 100 +#define SL_RAIL_UTIL_PA_POWER_DECI_DBM 100 +// PA Ramp Time (microseconds) +// <0-65535:1> +// Default: 10 +#define SL_RAIL_UTIL_PA_RAMP_TIME_US 10 +// Milli-volts on PA supply pin (PA_VDD) +// <0-65535:1> +// Default: 3300 +#define SL_RAIL_UTIL_PA_VOLTAGE_MV 1800 +// 2.4 GHz PA Selection +// Highest Possible +// High Power (chip-specific) +// Medium Power (chip-specific) +// Low Power +// Disable +// Default: RAIL_TX_POWER_MODE_2P4GIG_HIGHEST +#define SL_RAIL_UTIL_PA_SELECTION_2P4GHZ RAIL_TX_POWER_MODE_2P4GIG_HIGHEST +// Sub-1 GHz PA Selection +// Disable +// Default: RAIL_TX_POWER_MODE_NONE +#define SL_RAIL_UTIL_PA_SELECTION_SUBGHZ RAIL_TX_POWER_MODE_NONE +// + +// PA Curve Configuration +// Header file containing custom PA curves +// Default: "pa_curves_efr32.h" +#define SL_RAIL_UTIL_PA_CURVE_HEADER "pa_curves_efr32.h" +// Header file containing PA curve types +// Default: "pa_curve_types_efr32.h" +#define SL_RAIL_UTIL_PA_CURVE_TYPES "pa_curve_types_efr32.h" +// + +// PA Calibration Configuration +// Apply PA Calibration Factory Offset +// Default: 1 +#define SL_RAIL_UTIL_PA_CALIBRATION_ENABLE 1 +// + +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_PA_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_rail_util_pti_config.h b/src/rcp-uart-802154/config/sl_rail_util_pti_config.h new file mode 100644 index 00000000..de9d71ae --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rail_util_pti_config.h @@ -0,0 +1,82 @@ +/***************************************************************************//** + * @file + * @brief Packet Trace Information configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_PTI_CONFIG_H +#define SL_RAIL_UTIL_PTI_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> +// PTI Configuration + +// PTI mode +// UART +// UART onewire +// SPI +// Disabled +// Default: RAIL_PTI_MODE_UART +#define SL_RAIL_UTIL_PTI_MODE RAIL_PTI_MODE_UART + +// PTI Baud Rate (Hertz) +// <147800-20000000:1> +// Default: 1600000 +#define SL_RAIL_UTIL_PTI_BAUD_RATE_HZ 1600000 + +// +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_RAIL_UTIL_PTI +// $[PTI_SL_RAIL_UTIL_PTI] +#ifndef SL_RAIL_UTIL_PTI_PERIPHERAL +#define SL_RAIL_UTIL_PTI_PERIPHERAL PTI +#endif + +// PTI DOUT on PC04 +#ifndef SL_RAIL_UTIL_PTI_DOUT_PORT +#define SL_RAIL_UTIL_PTI_DOUT_PORT gpioPortC +#endif +#ifndef SL_RAIL_UTIL_PTI_DOUT_PIN +#define SL_RAIL_UTIL_PTI_DOUT_PIN 4 +#endif + +// PTI DFRAME on PC05 +#ifndef SL_RAIL_UTIL_PTI_DFRAME_PORT +#define SL_RAIL_UTIL_PTI_DFRAME_PORT gpioPortC +#endif +#ifndef SL_RAIL_UTIL_PTI_DFRAME_PIN +#define SL_RAIL_UTIL_PTI_DFRAME_PIN 5 +#endif + +// [PTI_SL_RAIL_UTIL_PTI]$ + +// <<< sl:end pin_tool >>> + +#endif // SL_RAIL_UTIL_PTI_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_rail_util_rf_path_config.h b/src/rcp-uart-802154/config/sl_rail_util_rf_path_config.h new file mode 100644 index 00000000..ca5be91c --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rail_util_rf_path_config.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_RF_PATH_CONFIG_H +#define SL_RAIL_UTIL_RF_PATH_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// Chip-internal RF Path Configuration +// RF Path Mode +// Path 0 +// Path 1 +// Default: RAIL_ANTENNA_1 +#define SL_RAIL_UTIL_RF_PATH_INT_RF_PATH_MODE RAIL_ANTENNA_1 +// + +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_RF_PATH_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_rail_util_rssi_config.h b/src/rcp-uart-802154/config/sl_rail_util_rssi_config.h new file mode 100644 index 00000000..15a55646 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rail_util_rssi_config.h @@ -0,0 +1,44 @@ +/***************************************************************************//** + * @file + * @brief RSSI configuration header file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_RSSI_CONFIG_H +#define SL_RAIL_UTIL_RSSI_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// RSSI Offset Configuration + +// Software RSSI offset value +// Default: -11 +#define SL_RAIL_UTIL_RSSI_OFFSET -11 + +// +// <<< end of configuration section >>> +#endif // SL_RAIL_UTIL_RSSI_CONFIG_H diff --git a/src/rcp-uart-802154/config/sl_rcp_gp_interface_config.h b/src/rcp-uart-802154/config/sl_rcp_gp_interface_config.h new file mode 100644 index 00000000..cbf00dd5 --- /dev/null +++ b/src/rcp-uart-802154/config/sl_rcp_gp_interface_config.h @@ -0,0 +1,14 @@ +//-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- + +// Rx Offset time +// The rx offset time for the bidirectional message. +// +#define GP_RX_OFFSET_IN_MICRO_SECONDS 21000 +// + +// TX Timeout +// Tx timeout after which the gp outgoing packet is invalid. +// +#define GP_TX_MAX_TIMEOUT_IN_MICRO_SECONDS 5000000 +// +// <<< end of configuration section >>> diff --git a/src/rcp-uart-802154/config/sl_sleeptimer_config.h b/src/rcp-uart-802154/config/sl_sleeptimer_config.h new file mode 100644 index 00000000..8344ef5f --- /dev/null +++ b/src/rcp-uart-802154/config/sl_sleeptimer_config.h @@ -0,0 +1,82 @@ +/***************************************************************************//** + * @file + * @brief Sleep Timer configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_SLEEPTIMER_CONFIG_H +#define SL_SLEEPTIMER_CONFIG_H + +#define SL_SLEEPTIMER_PERIPHERAL_DEFAULT 0 +#define SL_SLEEPTIMER_PERIPHERAL_RTCC 1 +#define SL_SLEEPTIMER_PERIPHERAL_PRORTC 2 +#define SL_SLEEPTIMER_PERIPHERAL_RTC 3 +#define SL_SLEEPTIMER_PERIPHERAL_SYSRTC 4 +#define SL_SLEEPTIMER_PERIPHERAL_BURTC 5 +#define SL_SLEEPTIMER_PERIPHERAL_WTIMER 6 +#define SL_SLEEPTIMER_PERIPHERAL_TIMER 7 + +// Timer Peripheral Used by Sleeptimer +// Default (auto select) +// RTCC +// Radio internal RTC (PRORTC) +// RTC +// SYSRTC +// Back-Up RTC (BURTC) +// WTIMER +// TIMER +// Selection of the Timer Peripheral Used by the Sleeptimer +#define SL_SLEEPTIMER_PERIPHERAL SL_SLEEPTIMER_PERIPHERAL_DEFAULT + +// TIMER/WTIMER Instance Used by Sleeptimer (not applicable for other peripherals) +// Make sure TIMER instance size is 32bits. Check datasheet for 32bits TIMERs. +// Default: 0 +#define SL_SLEEPTIMER_TIMER_INSTANCE 0 + +// Enable wallclock functionality +// Enable or disable wallclock functionalities (get_time, get_date, etc). +// Default: 0 +#define SL_SLEEPTIMER_WALLCLOCK_CONFIG 0 + +// Timer frequency divider (not applicable for WTIMER/TIMER) +// WTIMER/TIMER peripherals are always prescaled to 1024. +// Default: 1 +#define SL_SLEEPTIMER_FREQ_DIVIDER 1 + +// If Radio internal RTC (PRORTC) HAL is used, determines if it owns the IRQ handler. Enable, if no wireless stack is used. +// Default: 0 +#define SL_SLEEPTIMER_PRORTC_HAL_OWNS_IRQ_HANDLER 0 + +// Enable DEBUGRUN functionality on hardware RTC. +// Default: 0 +#define SL_SLEEPTIMER_DEBUGRUN 0 + +#endif /* SLEEPTIMER_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/rcp-uart-802154/config/ustimer_config.h b/src/rcp-uart-802154/config/ustimer_config.h new file mode 100644 index 00000000..b50a57f7 --- /dev/null +++ b/src/rcp-uart-802154/config/ustimer_config.h @@ -0,0 +1,55 @@ +/***************************************************************************//** + * @file + * @brief USTIMER configuration file. + ******************************************************************************* + * # License + * Copyright 2018 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ +#ifndef __SILICON_LABS_USTIMER_CONFIG_H__ +#define __SILICON_LABS_USTIMER_CONFIG_H__ + +/***************************************************************************//** + * @addtogroup ustimer + * @{ + ******************************************************************************/ + +// <<< sl:start pin_tool >>> +// USTIMER +// $[TIMER_USTIMER] +#ifndef USTIMER_PERIPHERAL +#define USTIMER_PERIPHERAL TIMER0 +#endif +#ifndef USTIMER_PERIPHERAL_NO +#define USTIMER_PERIPHERAL_NO 0 +#endif +// [TIMER_USTIMER]$ + +// <<< sl:end pin_tool >>> + +#define USTIMER_TIMER USTIMER_PERIPHERAL_NO + +/** @} (end addtogroup ustimer) */ + +#endif /* __SILICON_LABS_USTIMER_CONFIG_H__ */ diff --git a/src/rcp-uart-802154/gbl_metadata.yaml b/src/rcp-uart-802154/gbl_metadata.yaml new file mode 100644 index 00000000..3ece2e36 --- /dev/null +++ b/src/rcp-uart-802154/gbl_metadata.yaml @@ -0,0 +1,3 @@ +baudrate: 460800 +dynamic: [ezsp_version, ot_rcp_version, cpc_version] +fw_type: rcp-uart-802154 diff --git a/src/rcp-uart-802154/main.c b/src/rcp-uart-802154/main.c new file mode 100644 index 00000000..143e4cdf --- /dev/null +++ b/src/rcp-uart-802154/main.c @@ -0,0 +1,60 @@ +/***************************************************************************//** + * @file + * @brief main() function. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include "sl_component_catalog.h" +#include "sl_system_init.h" +#include "app.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif // SL_CATALOG_POWER_MANAGER_PRESENT +#if defined(SL_CATALOG_KERNEL_PRESENT) +#include "sl_system_kernel.h" +#else // !SL_CATALOG_KERNEL_PRESENT +#include "sl_system_process_action.h" +#endif // SL_CATALOG_KERNEL_PRESENT + +int main(void) +{ + // Initialize Silicon Labs device, system, service(s) and protocol stack(s). + // Note that if the kernel is present, processing task(s) will be created by + // this call. + sl_system_init(); + + // Initialize the application. For example, create periodic timer(s) or + // task(s) if the kernel is present. + app_init(); + +#if defined(SL_CATALOG_KERNEL_PRESENT) + // Start the kernel. Task(s) created in app_init() will start running. + sl_system_kernel_start(); +#else // SL_CATALOG_KERNEL_PRESENT + while (1) { + // Do not remove this call: Silicon Labs components process action routine + // must be called from the super loop. + sl_system_process_action(); + + // Application process. + app_process_action(); + +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + // Let the CPU go to sleep if the system allows it. + sl_power_manager_sleep(); +#endif + } + // Clean-up when exiting the application. + app_exit(); +#endif // SL_CATALOG_KERNEL_PRESENT +} \ No newline at end of file diff --git a/src/rcp-uart-802154/rcp-uart-802154.pintool b/src/rcp-uart-802154/rcp-uart-802154.pintool new file mode 100644 index 00000000..69bed34a --- /dev/null +++ b/src/rcp-uart-802154/rcp-uart-802154.pintool @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rcp-uart-802154/rcp-uart-802154.slcp b/src/rcp-uart-802154/rcp-uart-802154.slcp new file mode 100644 index 00000000..02f8b1d8 --- /dev/null +++ b/src/rcp-uart-802154/rcp-uart-802154.slcp @@ -0,0 +1,67 @@ +# Silicon Labs Project Configuration Tools: slcp, v0, Component selection file. +project_name: rcp-uart-802154 +label: rcp-uart-802154 +description: | + This multiprotocol radio co-processor (RCP) application supports running OpenThread and Zigbee stacks simultaneously on a host processor. It uses concurrent multiprotocol (CMP) / multi-PAN functionality to run the 802.15.4 networks simultaneously on the same channel. The host stacks and the RCP communicate using the Co-Processor Communication protocol (CPC), which acts as a protocol multiplexer and serial transport layer. The host applications connect to the CPC daemon, which in turn connects to the EFR via a UART link. Refer to *AN1333: Running Zigbee, OpenThread, and Bluetooth Concurrently on a Linux Host with a Multiprotocol Co-processor* for more information on running the multiprotocol RCP with different host applications. +category: OpenThread Examples +filter: +- name: Capability + value: [Multiprotocol] +- name: Device Type + value: [RCP] +- name: Project Difficulty + value: [Advanced] +- name: Wireless Technology + value: [Thread, Zigbee] +package: OpenThread +quality: production +readme: +- {path: README-MP-RCP.md} +source: +- {path: main.c} +- {path: app.c} +tag: [prebuilt_demo] +include: +- path: '' + file_list: + - {path: app.h} + - {path: reset_util.h} +sdk: {id: gecko_sdk, version: 4.4.0} +toolchain_settings: [] +component: +- {id: cpc_security_secondary_none} +- instance: [vcom] + id: cpc_secondary_driver_uart_usart +- {id: ot_rcp_gp_interface} +- {id: rail_util_pti} +- {id: brd4001a} +- {id: ot_stack_rcp} +- {id: ot_ncp_cpc} +- {id: ot_crash_handler} +- {id: brd4179b} +- {from: nc_efr32_watchdog, id: nc_efr32_watchdog} +- {id: bootloader_interface} +- {id: EFR32MG21A010F1024IM32} +define: +- {name: OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT, value: '1'} +configuration: +- {name: SL_STACK_SIZE, value: '2752'} +- {name: SL_BOARD_ENABLE_VCOM, value: '1'} +- {name: SL_CPC_DRV_UART_VCOM_BAUDRATE, value: '460800'} +- {name: SL_CPC_DRV_UART_VCOM_FLOW_CONTROL_TYPE, value: usartHwFlowControlCtsAndRts} +- {name: OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE, value: '0'} +- {name: OPENTHREAD_CONFIG_DIAG_ENABLE, value: '1'} +- {name: OPENTHREAD_CONFIG_LOG_OUTPUT, value: OPENTHREAD_CONFIG_LOG_OUTPUT_NONE} +- {name: OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE, value: '1'} +- {name: OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE, value: '0'} +- {name: OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE, value: '0'} +- {name: OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE, value: '0'} +- {name: SL_CPC_RX_BUFFER_MAX_COUNT, value: '15'} +- {name: SL_CPC_TX_QUEUE_ITEM_MAX_COUNT, value: '15'} +- {name: SL_CPC_USER_ENDPOINT_MAX_COUNT, value: '0'} +ui_hints: + highlight: + - {path: ./README-MP-RCP.md, focus: true} +sdk_extension: +- {id: nc_efr32_watchdog, version: 1.0.0} + diff --git a/src/rcp-uart-802154/rcp-uart-802154.slps b/src/rcp-uart-802154/rcp-uart-802154.slps new file mode 100644 index 00000000..bf77a189 --- /dev/null +++ b/src/rcp-uart-802154/rcp-uart-802154.slps @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/rcp-uart-802154/reset_util.h b/src/rcp-uart-802154/reset_util.h new file mode 100644 index 00000000..52f56813 --- /dev/null +++ b/src/rcp-uart-802154/reset_util.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022, The OpenThread Authors. + * All rights reserved. + * + * 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 the copyright holder 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. + */ + +#ifndef OT_LIB_PLATFORM_RESET_UTIL_H_ +#define OT_LIB_PLATFORM_RESET_UTIL_H_ + +#if defined(OPENTHREAD_ENABLE_COVERAGE) && OPENTHREAD_ENABLE_COVERAGE && defined(__GNUC__) +#if __GNUC__ >= 11 || (defined(__clang__) && (defined(__APPLE__) && (__clang_major__ >= 13)) || \ + (!defined(__APPLE__) && (__clang_major__ >= 12))) +void __gcov_dump(); +void __gcov_reset(); + +static void flush_gcov(void) +{ + __gcov_dump(); + __gcov_reset(); +} +#else +void __gcov_flush(void); +#define flush_gcov __gcov_flush +#endif /* __GNUC__ >= 11 || (defined(__clang__) && (defined(__APPLE__) && (__clang_major__ >= 13)) || \ + (!defined(__APPLE__) && (__clang_major__ >= 12))) */ +#else +#define flush_gcov() +#endif // defined(OPENTHREAD_ENABLE_COVERAGE) && OPENTHREAD_ENABLE_COVERAGE && defined(__GNUC__) + +#if defined(__linux__) || defined(__APPLE__) +#include +#include +jmp_buf gResetJump; + +#define OT_SETUP_RESET_JUMP(kArgv) \ + if (setjmp(gResetJump)) \ + { \ + alarm(0); \ + flush_gcov(); \ + execvp(kArgv[0], kArgv); \ + } + +#else +#define OT_SETUP_RESET_JUMP(ARGV) +#endif // defined(__linux__) || defined(__APPLE__) + +#endif // OT_LIB_PLATFORM_RESET_UTIL_H_ diff --git a/src/zwave_ncp_serial_api_controller/.cproject b/src/zwave_ncp_serial_api_controller/.cproject new file mode 100644 index 00000000..57aedd30 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/.cproject @@ -0,0 +1,383 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/README.md b/src/zwave_ncp_serial_api_controller/README.md new file mode 100644 index 00000000..860340a6 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/README.md @@ -0,0 +1,59 @@ +# Serial API + +The Serial Applications Programming Interface (Serial API) allows a host to communicate with a Z-Wave +chip. The host may be PC or a less powerful embedded host CPU, e.g., in a remote control or in a +gateway device. Depending on the chip family, the Serial API may be accessed via RS-232 or USB +physical interfaces. + +There are 2 available versions of SerialAPI: + + - SerialAPI Controller + - SerialAPI End Device + +The following host-based sample applications are available in the SDK: + +- Z/IP Gateway – Gateway application using Serial API features of the bridge controller API +- PC Controller – Demonstrates Serial API features of the bridge controller API + +The host-based sample applications are described in the respective SDK overview documents. + +The Serial API leverages the Z-Wave Protocol API. The Serial API introduces additional messages related +to inter-host communications. + +## Known Issues + +### OTW Update + +The following update paths for Serial API Controller are not possible using the +pre-built binaries because the defines `ZAF_CONFIG_GENERIC_TYPE` and +`ZAF_CONFIG_SPECIFIC_TYPE` differ across these versions: + +- 7.19 or lower to 7.20 +- 7.20 to 7.21 or higher + +However, it is possible to create a custom firmware that is compatible with +earlier versions of the application by building the application manually after +editing `application_properties_config.h`. + +If you want to update a device running the pre-built 7.19 or lower version +firmware to 7.20, +change both `PRODUCT_ID_GENERIC_TYPE` and `PRODUCT_ID_SPECIFIC_TYPE` to +`0`. + +If you want to update a device running the pre-built 7.20 version firmware +to 7.21 or higher, +remove the following conditional block from the file: + +``` +#if (ZAF_CONFIG_GENERIC_TYPE == GENERIC_TYPE_STATIC_CONTROLLER && \ + ZAF_CONFIG_SPECIFIC_TYPE == SPECIFIC_TYPE_PC_CONTROLLER) +(...) +#endif +``` + +Changing these values will only affect the Product ID, stored in the struct +`sl_app_properties`. +The application will still report the values specified in the defines +`ZAF_CONFIG_GENERIC_TYPE` and `ZAF_CONFIG_SPECIFIC_TYPE` in its +Node Information Frame.\ +Note that these values can be changed on the fly using the Serial API command `SERIAL_API_APPL_NODE_INFORMATION`. diff --git a/src/zwave_ncp_serial_api_controller/app.c b/src/zwave_ncp_serial_api_controller/app.c new file mode 100644 index 00000000..a39f90c2 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/app.c @@ -0,0 +1,1272 @@ +/** + * @file + * Serial API implementation for Enhanced Z-Wave module + * + * @copyright 2019 Silicon Laboratories Inc. + */ + +#include +#include +#include "Assert.h" +#include "SyncEvent.h" +#ifdef ZW_CONTROLLER +#include "ZW_controller_api.h" +#endif /* ZW_CONTROLLER */ +#include "AppTimer.h" +#include "ZW_system_startup_api.h" +/* Include app header file - containing version and */ +/* SerialAPI functionality support definitions */ +#ifdef ZW_SECURITY_PROTOCOL +#include "ZW_security_api.h" +#include "ZW_TransportSecProtocol.h" +#endif +#include "DebugPrintConfig.h" +// SerialAPI uses SWO for debug output. +// For example SWO Terminal in Studio commander can be used to get the output. +//#define DEBUGPRINT +#include "DebugPrint.h" +#include "app_node_info.h" +#include "virtual_slave_node_info.h" +#include "serialapi_file.h" +#include "cmd_handlers.h" +#include "cmds_management.h" +#include "ZAF_Common_interface.h" +#include "utils.h" +#include "zpal_watchdog.h" +#include "app_hw.h" +#include "SerialAPI_hw.h" +#include "board_indicator.h" +#include "zaf_event_distributor_ncp.h" +#include "zpal_misc.h" +#include "zw_build_no.h" +#include "zaf_protocol_config.h" +#ifdef DEBUGPRINT +#include "ZAF_PrintAppInfo.h" +#endif +#include "ZAF_AppName.h" + +#include + +/* Basic level definitions */ +#define BASIC_ON 0xFF +#define BASIC_OFF 0x00 + +#define TX_POWER_LR_20_DBM 200 +#define TX_POWER_LR_14_DBM 140 + +#ifdef JP_DK +/* Define RSSI threshold so JP can be tested in DK */ +#define JP_DK_RSSI_THRESHOLD 52 +#endif + +#ifdef ZW_SECURITY_PROTOCOL +#define REQUESTED_SECURITY_KEYS ( SECURITY_KEY_S0_BIT | SECURITY_KEY_S2_UNAUTHENTICATED_BIT | SECURITY_KEY_S2_AUTHENTICATED_BIT | SECURITY_KEY_S2_ACCESS_BIT) +#else +#define REQUESTED_SECURITY_KEYS 0 +#endif /* ZW_SECURITY_PROTOCOL */ + +/* Accept all incoming command classes, regardless of NIF contents. */ +#define ACCEPT_ALL_CMD_CLASSES + +/** + * + */ +typedef struct _S_TRANSPORT_REQUESTED_SECURITY_SETTINGS_ +{ + uint8_t requestedSecurityKeysBits; +} S_TRANSPORT_REQUESTED_SECURITY_SETTINGS; + +static TaskHandle_t g_AppTaskHandle; + +extern SSyncEvent SetDefaultCB; +extern SSyncEventArg1 LearnModeStatusCb; + +/* State vars for ApplicationPoll */ +static uint8_t state = 0xff; +static uint8_t retry = 0; + +static uint8_t lastRetVal = 0; /* Used to store retVal for retransmissions */ +uint8_t compl_workbuf[BUF_SIZE_TX]; /* Used for frames send to remote side. */ + +/* Queue for frames transmitted to PC - callback, ApplicationCommandHandler, ApplicationControllerUpdate... */ +#if !defined(MAX_CALLBACK_QUEUE) +#define MAX_CALLBACK_QUEUE 8 +#endif /* !defined(MAX_CALLBACK_QUEUE) */ + +#if !defined(MAX_UNSOLICITED_QUEUE) +#define MAX_UNSOLICITED_QUEUE 8 +#endif /* !defined(MAX_UNSOLICITED_QUEUE) */ + +typedef struct _callback_element_ +{ + uint8_t wCmd; + uint8_t wLen; + uint8_t wBuf[BUF_SIZE_TX]; +} CALLBACK_ELEMENT; + +typedef struct _request_queue_ +{ + uint8_t requestOut; + uint8_t requestIn; + uint8_t requestCnt; + CALLBACK_ELEMENT requestQueue[MAX_CALLBACK_QUEUE]; +} REQUEST_QUEUE; + +REQUEST_QUEUE callbackQueue = {0}; + +typedef struct _request_unsolicited_queue_ +{ + uint8_t requestOut; + uint8_t requestIn; + uint8_t requestCnt; + CALLBACK_ELEMENT requestQueue[MAX_UNSOLICITED_QUEUE]; +} REQUEST_UNSOLICITED_QUEUE; + +REQUEST_UNSOLICITED_QUEUE commandQueue = {0}; + +eSerialAPISetupNodeIdBaseType nodeIdBaseType = SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT; + +#if SUPPORT_ZW_WATCHDOG_START | SUPPORT_ZW_WATCHDOG_STOP +extern uint8_t bWatchdogStarted; +#endif + +/* Last system wakeup reason - is set in ApplicationInit */ +EResetReason_t g_eApplResetReason; + +#ifdef APPL_PROD_TEST +#define PRODTEST_NR_1 1 +#define PRODTEST_NR_2 2 +#define PRODTEST_NR_3 3 +#define PRODTEST_NR_4 4 +#define PRODTEST_NR_5 5 +#define PRODTEST_NR_6 6 +#define PRODTEST_NR_7 7 + +#define POWERON_MAGIC_VALUE 0x4242 +extern uint8_t bProdtestState; +/* Production test pin definition */ +static uint8_t testRun; +#define SET_PRODUCTIONTEST_PIN PIN_IN(P21, 1) +#define IN_PRODUCTIONTEST (!PIN_GET(P21)) +#endif /* APPL_PROD_TEST */ + +zpal_pm_handle_t radio_power_lock; +zpal_pm_handle_t io_power_lock; +SSwTimer mWakeupTimer; +bool bTxStatusReportEnabled; + +static void ApplicationInitSW(void); +static void ApplicationTask(SApplicationHandles *pAppHandles); + +#ifdef ZW_CONTROLLER_BRIDGE +static void ApplicationCommandHandler_Bridge(SReceiveMulti *pReciveMulti); +#else +void ApplicationCommandHandler(void *pSubscriberContext, SZwaveReceivePackage* pRxPackage); +#endif + +void ApplicationNodeUpdate(uint8_t bStatus, uint16_t nodeID, uint8_t *pCmd, uint8_t bLen); + +#if SUPPORT_ZW_SET_PROMISCUOUS_MODE +static void SetPromiscuousMode(uint8_t mode); +#endif + +#if SUPPORT_ZW_REMOVE_FAILED_NODE_ID +extern void ZCB_ComplHandler_ZW_RemoveFailedNodeID(uint8_t bStatus); +#endif + +#if SUPPORT_ZW_REPLACE_FAILED_NODE +extern void ZCB_ComplHandler_ZW_ReplaceFailedNode(uint8_t bStatus); +#endif + +#if SUPPORT_ZW_SET_SLAVE_LEARN_MODE +extern void ZCB_ComplHandler_ZW_SetSlaveLearnMode(uint8_t bStatus, uint8_t orgID, uint8_t newID); +#endif + +#if SUPPORT_ZW_SET_RF_RECEIVE_MODE +extern uint8_t SetRFReceiveMode(uint8_t mode); +#endif + +#ifdef UZB + +#if 1 // 0 - test UZB on ZDP03A, 1 - normal mode (UZB on UZB :) +#define LEDxPort P0 +#define LEDxSHADOW P0Shadow +#define LEDxSHADOWDIR P0ShadowDIR +#define LEDxDIR P0DIR +#define LEDxDIR_PAGE P0DIR_PAGE +#define LEDx 4 +#else // 0 - test UZB on ZDP03A, 1 - normal mode (UZB on UZB :) +#define LEDxPort P0 +#define LEDxSHADOW P0Shadow +#define LEDxSHADOWDIR P0ShadowDIR +#define LEDxDIR P0DIR +#define LEDxDIR_PAGE P0DIR_PAGE +#define LEDx 7 +#endif // 0 - test UZB on ZDP03A, 1 - normal mode (UZB on UZB :) + +void /*RET Nothing */ +set_state_and_notify(uint8_t st) +{ + + if (state != st) + { + xTaskNotify(g_AppTaskHandle, + 1< (uint8_t)BUF_SIZE_TX) + { + ASSERT((uint8_t)BUF_SIZE_TX >= len); + len = (uint8_t)BUF_SIZE_TX; + } + callbackQueue.requestQueue[callbackQueue.requestIn].wLen = len; + memcpy(&callbackQueue.requestQueue[callbackQueue.requestIn].wBuf[0], pData, len); + if (++callbackQueue.requestIn >= MAX_CALLBACK_QUEUE) + { + callbackQueue.requestIn = 0; + } + xTaskNotify(g_AppTaskHandle, + 1< (uint8_t)BUF_SIZE_TX) + { + ASSERT((uint8_t)BUF_SIZE_TX >= len); + len = (uint8_t)BUF_SIZE_TX; + } + commandQueue.requestQueue[commandQueue.requestIn].wLen = len; + memcpy(&commandQueue.requestQueue[commandQueue.requestIn].wBuf[0], pData, len); + if (++commandQueue.requestIn >= MAX_UNSOLICITED_QUEUE) + { + commandQueue.requestIn = 0; + } + taskEXIT_CRITICAL(); + xTaskNotify(g_AppTaskHandle, + 1<cmd, &lastRetVal, 1); +} + +void +DoRespond_workbuf( + uint8_t cnt +) +{ + Respond(serial_frame->cmd, compl_workbuf, cnt); +} + +void zaf_event_distributor_app_zw_rx(SZwaveReceivePackage *RxPackage) +{ + switch (RxPackage->eReceiveType) { + case EZWAVERECEIVETYPE_SINGLE: +#ifndef ZW_CONTROLLER_BRIDGE + ApplicationCommandHandler(NULL, RxPackage); +#endif + break; + +#ifdef ZW_CONTROLLER_BRIDGE + case EZWAVERECEIVETYPE_MULTI: + ApplicationCommandHandler_Bridge(&RxPackage->uReceiveParams.RxMulti); + break; +#endif // #ifdef ZW_CONTROLLER_BRIDGE + + case EZWAVERECEIVETYPE_NODE_UPDATE: + ApplicationNodeUpdate( + RxPackage->uReceiveParams.RxNodeUpdate.Status, + RxPackage->uReceiveParams.RxNodeUpdate.NodeId, + RxPackage->uReceiveParams.RxNodeUpdate.aPayload, + RxPackage->uReceiveParams.RxNodeUpdate.iLength); + break; + default: + break; + } +} + + +/** +* @brief Triggered when protocol puts a message on the ZwCommandStatusQueue. +*/ +void zaf_event_distributor_app_zw_command_status(SZwaveCommandStatusPackage *Status) +{ + DPRINTF("Incoming Status msg %x\r\n", Status->eStatusType); + + switch (Status->eStatusType) { + case EZWAVECOMMANDSTATUS_LEARN_MODE_STATUS: + SyncEventArg1Invoke(&LearnModeStatusCb, Status->Content.LearnModeStatus.Status); + break; + + case EZWAVECOMMANDSTATUS_SET_DEFAULT: + // Received when protocol is started (not implemented yet), and when SetDefault command is completed + SyncEventInvoke(&SetDefaultCB); + break; + +#ifdef ZW_CONTROLLER + case EZWAVECOMMANDSTATUS_REPLACE_FAILED_NODE_ID: + ZCB_ComplHandler_ZW_ReplaceFailedNode(Status->Content.FailedNodeIDStatus.result); + break; + case EZWAVECOMMANDSTATUS_REMOVE_FAILED_NODE_ID: + ZCB_ComplHandler_ZW_RemoveFailedNodeID(Status->Content.FailedNodeIDStatus.result); + break; + case EZWAVECOMMANDSTATUS_NETWORK_MANAGEMENT: + { + LEARN_INFO_T mLearnInfo; + mLearnInfo.bStatus = Status->Content.NetworkManagementStatus.statusInfo[0]; + mLearnInfo.bSource = (uint16_t)(((uint16_t)Status->Content.NetworkManagementStatus.statusInfo[1] << 8) // nodeID MSB + | (uint16_t)Status->Content.NetworkManagementStatus.statusInfo[2]); // nodeID LSB + mLearnInfo.bLen = Status->Content.NetworkManagementStatus.statusInfo[3]; + mLearnInfo.pCmd = &Status->Content.NetworkManagementStatus.statusInfo[4]; + ZCB_ComplHandler_ZW_NodeManagement(&mLearnInfo); + break; + } +#if SUPPORT_ZW_SET_SLAVE_LEARN_MODE + case EZWAVECOMMANDSTATUS_SET_SLAVE_LEARN_MODE: + { + uint8_t bStatus; + uint16_t orgID; + uint16_t newID; + bStatus = Status->Content.NetworkManagementStatus.statusInfo[0]; + orgID = (uint16_t)((uint16_t)(Status->Content.NetworkManagementStatus.statusInfo[1] << 8) // org nodeID MSB + | Status->Content.NetworkManagementStatus.statusInfo[2]); // org nodeID LSB + newID = (uint16_t)((uint16_t)(Status->Content.NetworkManagementStatus.statusInfo[3] << 8) // new nodeID MSB + | Status->Content.NetworkManagementStatus.statusInfo[4]); // new nodeID LSB + ZCB_ComplHandler_ZW_SetSlaveLearnMode(bStatus, (uint8_t)orgID, (uint8_t)newID); // orgID and newID are always (8-bit) IDs + break; + } +#endif +#endif + default: + break; + } +} + +static void +appFileSystemInit(void) +{ + SAppNodeInfo_t *AppNodeInfo; + SRadioConfig_t *RadioConfig; + + AppNodeInfo = zaf_get_app_node_info(); + RadioConfig = zaf_get_radio_config(); + + /* + * Handle file system init inside Application Task + * This reduces the default stack needed during initialization + */ + if (SerialApiFileInit()) + { + ReadApplicationSettings(&AppNodeInfo->DeviceOptionsMask, &AppNodeInfo->NodeType.generic, &AppNodeInfo->NodeType.specific); + ReadApplicationCCInfo(&CommandClasses.UnSecureIncludedCC.iListLength, + (uint8_t*)CommandClasses.UnSecureIncludedCC.pCommandClasses, + &CommandClasses.SecureIncludedUnSecureCC.iListLength, + (uint8_t*)CommandClasses.SecureIncludedUnSecureCC.pCommandClasses, + &CommandClasses.SecureIncludedSecureCC.iListLength, + (uint8_t*)CommandClasses.SecureIncludedSecureCC.pCommandClasses); + ReadApplicationRfRegion(&RadioConfig->eRegion); + ReadApplicationTxPowerlevel(&RadioConfig->iTxPowerLevelMax, &RadioConfig->iTxPowerLevelAdjust); + ReadApplicationMaxLRTxPwr(&RadioConfig->iTxPowerLevelMaxLR); + ReadApplicationEnablePTI(&RadioConfig->radio_debug_enable); + ReadApplicationNodeIdBaseType(&nodeIdBaseType); + } + else + { + /* + * We end up here on the first boot after initializing the flash file system + */ + + zpal_radio_region_t mfgRegionConfig; + // Check for a valid RF Region value in the manufacturing user data configuration + ZW_GetMfgTokenDataCountryFreq(&mfgRegionConfig); + if ( (mfgRegionConfig <= REGION_US_LR) || (mfgRegionConfig == REGION_JP) || (mfgRegionConfig == REGION_KR) ) + { + // Valid RF Region configuration found. Use instead of the app default setting + RadioConfig->eRegion = mfgRegionConfig; + } + + // Save the setting to flash + SaveApplicationRfRegion(RadioConfig->eRegion); + // Save the default Tx powerlevel + SaveApplicationTxPowerlevel(RadioConfig->iTxPowerLevelMax, RadioConfig->iTxPowerLevelAdjust); + // write defualt values + SaveApplicationSettings(AppNodeInfo->DeviceOptionsMask, AppNodeInfo->NodeType.generic, AppNodeInfo->NodeType.specific); + // change the 20dBm tx power setting according to the application configuration + SaveApplicationMaxLRTxPwr(RadioConfig->iTxPowerLevelMaxLR); + + SaveApplicationEnablePTI(RadioConfig->radio_debug_enable); + SaveApplicationNodeIdBaseType(SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT); + } + + ZAF_AppName_Write(); +} +/* + * The below function must be implemented as hardware specific function in a separate source + * file if required. + */ +ZW_WEAK void SerialAPI_hw_psu_init(void) +{ + // Do nothing +} + +/*=============================== ApplicationPoll ======================= +** Application poll function, handling the receiving and transmitting +** communication with the PC. +** +**--------------------------------------------------------------------------*/ +static void /*RET Nothing */ +ApplicationTask(SApplicationHandles* pAppHandles) +{ + + SerialAPI_hw_psu_init(); // Must be invoked after the file system is initialized. + + // Init + g_AppTaskHandle = xTaskGetCurrentTaskHandle(); + + SetTaskHandle(g_AppTaskHandle); + ZAF_setAppHandle(pAppHandles); + ZW_system_startup_SetCCSet(&CommandClasses); + + AppTimerInit(EAPPLICATIONEVENT_TIMER, (void *) g_AppTaskHandle); + radio_power_lock = zpal_pm_register(ZPAL_PM_TYPE_USE_RADIO); + zpal_pm_stay_awake(radio_power_lock, 0); + io_power_lock = zpal_pm_register(ZPAL_PM_TYPE_DEEP_SLEEP); + zpal_pm_stay_awake(io_power_lock, 0); + + zaf_event_distributor_init(); + + set_state_and_notify(stateStartup); + // Wait for and process events + DPRINT("SerialApi Event processor Started\r\n"); + for (;;) + { + if (!zaf_event_distributor_distribute()) + { + return; + } + } +} + +static void SerialAPICommandHandler(void) +{ + const bool handler_invoked = invoke_cmd_handler(serial_frame); + if (!handler_invoked) + { + /* TODO - send a "Not Supported" respond frame */ + /* UNKNOWN - just drop it */ + set_state_and_notify(stateIdle); + } +} + + +static void SerialAPIStateHandler(void) +{ + comm_interface_parse_result_t conVal; + + /* ApplicationPoll is controlled by a statemachine with the four states: + stateIdle, stateFrameParse, stateTxSerial, stateCbTxSerial. + + stateIdle: If there is anything to transmit do so. -> stateCbTxSerial + If not, check if anything is received. -> stateFrameParse + If neither, stay in the state + Note: frames received while we are transmitting are lost + and must be retransmitted by PC + + stateFrameParse: Parse received frame. + If the request has no response -> stateIdle + If there is an immediate response send it. -> stateTxSerial + + stateTxSerial: Waits for ack on responses send in stateFrameParse. + Retransmit frame as needed. + -> stateIdle + + stateCbTxSerial: Waits for ack on requests send in stateIdle + (callback, ApplicationCommandHandler etc). + Retransmit frame as needed and remove from callbackqueue when done. + -> stateIdle + + stateAppSuspend: Added for the uzb suspend function. The resume is through the suspend signal goes high in UZB stick + The wakeup from deep sleep suspend causes system reboot + + */ + + { + switch (state) + { + case stateStartup: + { + ApplicationInitSW(); + SetRFReceiveMode(1); + set_state_and_notify(stateIdle); + } + break; + + case stateIdle: + { +#if SUPPORT_SERIAL_API_READY + /* Only empty callback queue for HOST if SERIAL LINK has been established */ + if (callbackQueue.requestCnt && (SERIAL_LINK_DETACHED != serialLinkState)) +#else + /* Check if there is anything to transmit. If so do it */ + if (callbackQueue.requestCnt) +#endif + { + comm_interface_transmit_frame( + callbackQueue.requestQueue[callbackQueue.requestOut].wCmd, + REQUEST, + (uint8_t *)callbackQueue.requestQueue[callbackQueue.requestOut].wBuf, + callbackQueue.requestQueue[callbackQueue.requestOut].wLen, + NULL + ); + set_state_and_notify(stateCallbackTxSerial); + /* callbackCnt decremented when frame is acknowledged from PC - or timed out after retries */ + } + else + { +#if SUPPORT_SERIAL_API_READY + /* Only empty command queue for HOST if SERIAL LINK has been established */ + if (commandQueue.requestCnt && (SERIAL_LINK_DETACHED != serialLinkState)) +#else + /* Check if there is anything to transmit. If so do it */ + if (commandQueue.requestCnt) +#endif + { + comm_interface_transmit_frame( + commandQueue.requestQueue[commandQueue.requestOut].wCmd, + REQUEST, + (uint8_t *)commandQueue.requestQueue[commandQueue.requestOut].wBuf, + commandQueue.requestQueue[commandQueue.requestOut].wLen, + NULL + ); + set_state_and_notify(stateCommandTxSerial); + /* commandCnt decremented when frame is acknowledged from PC - or timed out after retries */ + } + else + { + /* Nothing to transmit. Check if we received anything */ + if (comm_interface_parse_data(true) == PARSE_FRAME_RECEIVED) + { +#if SUPPORT_SERIAL_API_READY + /* We have received a frame from HOST so we must assume we are connected */ + serialLinkState = SERIAL_LINK_CONNECTED; +#endif + /* We got a frame... */ + set_state_and_notify(stateFrameParse); + } + } + } + } + break; + + case stateFrameParse: + { + SerialAPICommandHandler(); + } + break; + + case stateTxSerial: + { + /* Wait for ACK on send respond. Retransmit as needed */ + if ((conVal = comm_interface_parse_data(false)) == PARSE_FRAME_SENT) + { + /* One more RES transmitted succesfully */ + retry = 0; + set_state_and_notify(stateIdle); + } + else if (conVal == PARSE_TX_TIMEOUT) + { + /* Either a NAK has been received or we timed out waiting for ACK */ + if (retry++ < MAX_SERIAL_RETRY) + { + comm_interface_transmit_frame(0, REQUEST, NULL, 0, NULL); /* Retry... */ + } + else + { + /* Drop RES as HOST could not be reached */ + retry = 0; + set_state_and_notify(stateIdle); + } + } + /* All other states are ignored, as for now the only thing we are looking for is ACK/NAK! */ + } + break; + + case stateCallbackTxSerial: + { + /* Wait for ack on unsolicited event (callback etc.) */ + /* Retransmit as needed. Remove frame from callbackQueue when done */ + if ((conVal = comm_interface_parse_data(false)) == PARSE_FRAME_SENT) + { + /* One more REQ transmitted succesfully */ + PopCallBackQueue(); + } + else if (conVal == PARSE_TX_TIMEOUT) + { + /* Either a NAK has been received or we timed out waiting for ACK */ + if (retry++ < MAX_SERIAL_RETRY) + { + comm_interface_transmit_frame(0, REQUEST, NULL, 0, NULL); /* Retry... */ + } + else + { + /* Drop REQ as HOST could not be reached */ + PopCallBackQueue(); + } + } + /* All other states are ignored, as for now the only thing we are looking for is ACK/NAK! */ + } + break; + + case stateCommandTxSerial: + { + /* Wait for ack on unsolicited ApplicationCommandHandler event */ + /* Retransmit as needed. Remove frame from comamndQueue when done */ + if ((conVal = comm_interface_parse_data(false)) == PARSE_FRAME_SENT) + { + /* One more REQ transmitted succesfully */ + PopCommandQueue(); + } + else if (conVal == PARSE_TX_TIMEOUT) + { + /* Either a NAK has been received or we timed out waiting for ACK */ + if (retry++ < MAX_SERIAL_RETRY) + { + comm_interface_transmit_frame(0, REQUEST, NULL, 0, NULL); /* Retry... */ + } + else + { + /* Drop REQ as HOST could not be reached */ + PopCommandQueue(); + } + } + /* All other states are ignored, as for now the only thing we are looking for is ACK/NAK! */ + } + break; + #ifdef USB_SUSPEND_SUPPORT + case stateAppSuspend: + SerialAPI_hw_usb_suspend_handler(); + break; +#endif + default: + set_state_and_notify(stateIdle); + break; + } + + } // For loop - task loop +} + + +void +zaf_event_distributor_app_state_change(void) +{ + SerialAPIStateHandler(); +} + +void +zaf_event_distributor_app_serial_data_rx(void) +{ + SerialAPIStateHandler(); +} + +void +zaf_event_distributor_app_serial_timeout(void) +{ + SerialAPIStateHandler(); +} + +void +PopCallBackQueue(void) +{ + if (callbackQueue.requestCnt) + { + callbackQueue.requestCnt--; + if (++callbackQueue.requestOut >= MAX_CALLBACK_QUEUE) + { + callbackQueue.requestOut = 0; + } + } + else + { + callbackQueue.requestOut = callbackQueue.requestIn; + } + retry = 0; + set_state_and_notify(stateIdle); +} + + +void +PopCommandQueue(void) +{ + if (commandQueue.requestCnt) + { + commandQueue.requestCnt--; + if (++commandQueue.requestOut >= MAX_UNSOLICITED_QUEUE) + { + commandQueue.requestOut = 0; + } + } + else + { + commandQueue.requestOut = commandQueue.requestIn; + } + retry = 0; + set_state_and_notify(stateIdle); +} + +/** + * @brief wakeup after sleep timeout event + * + * @param pTimer Timer connected to this method + */ +void +ZCB_WakeupTimeout(__attribute__((unused)) SSwTimer *pTimer) +{ + DPRINT("ZCB_WakeupTimeout\n"); +} + +/*============================== ApplicationInitSW ====================== +** Initialization of the Application Software +** +**--------------------------------------------------------------------------*/ +void +ApplicationInitSW(void) +{ + SAppNodeInfo_t *AppNodeInfo; + SRadioConfig_t *RadioConfig; + + AppNodeInfo = zaf_get_app_node_info(); + RadioConfig = zaf_get_radio_config(); + + comm_interface_init(); + + // FIXME load any saved node configuration and prepare to feed it to protocol +/* Do we together with the bTxStatus uint8_t also transmit a sTxStatusReport struct on ZW_SendData callback to HOST */ +#if SUPPORT_SEND_DATA_TIMING + bTxStatusReportEnabled = true; +#else + bTxStatusReportEnabled = false; +#endif + +#if SUPPORT_SERIAL_API_STARTUP_NOTIFICATION + /* ZW->HOST: bWakeupReason | bWatchdogStarted | deviceOptionMask | */ + /* nodeType_generic | nodeType_specific | cmdClassLength | cmdClass[] */ + + // FIXME send startup notification via serial port if we are supposed to + SCommandClassList_t *const apCCLists[3] = + { + &CommandClasses.UnSecureIncludedCC, + &CommandClasses.SecureIncludedUnSecureCC, + &CommandClasses.SecureIncludedSecureCC + }; + + compl_workbuf[0] = g_eApplResetReason; +#if SUPPORT_ZW_WATCHDOG_START || SUPPORT_ZW_WATCHDOG_STOP + compl_workbuf[1] = bWatchdogStarted; +#else + compl_workbuf[1] = false; +#endif + compl_workbuf[2] = AppNodeInfo->DeviceOptionsMask; + compl_workbuf[3] = AppNodeInfo->NodeType.generic; + compl_workbuf[4] = AppNodeInfo->NodeType.specific; + compl_workbuf[5] = apCCLists[0]->iListLength; + uint8_t i = 0; + if (0 < apCCLists[0]->iListLength) + { + for (i = 0; i < apCCLists[0]->iListLength; i++) + { + compl_workbuf[6 + i] = apCCLists[0]->pCommandClasses[i]; + } + } + eSerialAPIStartedCapabilities capabilities = (RadioConfig->eRegion == REGION_US_LR) ? SERIAL_API_STARTED_CAPABILITIES_L0NG_RANGE : 0; + compl_workbuf[6 + i] = capabilities; + + Request(FUNC_ID_SERIAL_API_STARTED, compl_workbuf, 7 + i); + +#endif /* #if SUPPORT_STARTUP_NOTIFICATION */ + AppTimerDeepSleepPersistentRegister(&mWakeupTimer, false, ZCB_WakeupTimeout); // register for event jobs timeout event +} + +#ifdef USB_SUSPEND_SUPPORT +void UsbSuspendCallback(void) +{ + set_state(stateAppSuspend); +} +#endif + +/*============================== ApplicationInit ====================== +** Init UART and setup port pins for LEDs +** +**--------------------------------------------------------------------------*/ +ZW_APPLICATION_STATUS +ApplicationInit( + EResetReason_t eResetReason) +{ + // Serial API can control hardware with information + // set in the file system therefore it should be the first + // step in the Initialization + appFileSystemInit(); + + app_hw_init(); + +#ifdef USB_SUSPEND_SUPPORT + SerialAPI_set_usb_supend_callback(UsbSuspendCallback); +#endif + +#if SUPPORT_SERIAL_API_READY + if (ERESETREASON_SLEEP == eResetReason) + { + /* We have been waken from sleep by timer or external pin event - we must assume we are connected. */ + serialLinkState = SERIAL_LINK_CONNECTED; + } + else + { + /* We have been waken either by ERESETREASON_POWER_ON or ERESETREASON_PIN or similar. Initially we are DETACHED */ + serialLinkState = SERIAL_LINK_CONNECTED; + } +#endif + /* g_eApplResetReason now contains lastest System Reset reason */ + g_eApplResetReason = eResetReason; + +#ifdef DEBUGPRINT + static uint8_t m_aDebugPrintBuffer[96]; + zpal_debug_init(); + DebugPrintConfig(m_aDebugPrintBuffer, sizeof(m_aDebugPrintBuffer), zpal_debug_output); + DebugPrintf("ApplicationInit eResetReason = %d\n", eResetReason); + ZAF_PrintAppInfo(); +#endif + + /************************************************************************************* + * CREATE USER TASKS - ZW_ApplicationRegisterTask() and ZW_UserTask_CreateTask() + ************************************************************************************* + * Register the main APP task function. + * + * ATTENTION: This function is the only task that can call ZAF API functions!!! + * Failure to follow guidelines will result in undefined behavior. + * + * Furthermore, this function is the only way to register Event Notification + * Bit Numbers for associating to given event handlers. + * + * ZW_UserTask_CreateTask() can be used to create additional tasks. + * @see zwave_soc_sensor_pir example for more info. + *************************************************************************************/ + bool bWasTaskCreated = ZW_ApplicationRegisterTask( + ApplicationTask, + EAPPLICATIONEVENT_ZWRX, + EAPPLICATIONEVENT_ZWCOMMANDSTATUS, + zaf_get_protocol_config() + ); + ASSERT(bWasTaskCreated); + + return (APPLICATION_RUNNING); /*Return false to enter production test mode*/ +} + + +#ifndef ZW_CONTROLLER_BRIDGE +/*========================== ApplicationCommandHandler ================== +** Handling of received application commands and requests +** +**--------------------------------------------------------------------------*/ +void /*RET Nothing */ +ApplicationCommandHandler(__attribute__((unused)) void *pSubscriberContext, SZwaveReceivePackage* pRxPackage) +{ + ZW_APPLICATION_TX_BUFFER *pCmd = (ZW_APPLICATION_TX_BUFFER *)&pRxPackage->uReceiveParams.Rx.Payload; + uint8_t cmdLength = pRxPackage->uReceiveParams.Rx.iLength; + RECEIVE_OPTIONS_TYPE *rxOpt = &pRxPackage->uReceiveParams.Rx.RxOptions; + /* ZW->PC: REQ | 0x04 | rxStatus | sourceNode | cmdLength | pCmd[] | rssiVal | securityKey */ + uint8_t offset = 0; + BYTE_IN_AR(compl_workbuf, 0) = rxOpt->rxStatus; + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(rxOpt->sourceNode >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)(rxOpt->sourceNode & 0xFF); // LSB + offset++; // 16 bit nodeID means the command fields that follow are offset by one byte + } + else + { + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(rxOpt->sourceNode & 0xFF); // Legacy 8 bit nodeID + } +#if defined(ZW_CONTROLLER) && !defined(ZW_CONTROLLER_STATIC) + if (cmdLength > (uint8_t)(BUF_SIZE_TX - (offset + (rxOpt->rxStatus & RECEIVE_STATUS_FOREIGN_FRAME ? 5 : 4)))) + { + cmdLength = (uint8_t)(BUF_SIZE_TX - (offset + (rxOpt->rxStatus & RECEIVE_STATUS_FOREIGN_FRAME ? 5 : 4))); + } +#else + if (cmdLength > (uint8_t)(BUF_SIZE_TX - (offset + 5))) + { + cmdLength = (uint8_t)(BUF_SIZE_TX - (offset + 5)); + } +#endif + BYTE_IN_AR(compl_workbuf, offset + 2) = cmdLength; + for (uint8_t i = 0; i < cmdLength; i++) + { + BYTE_IN_AR(compl_workbuf, offset + 3 + i) = *((uint8_t*)pCmd + i); + } + /* Syntax when a promiscuous frame is received (i.e. RECEIVE_STATUS_FOREIGN_FRAME is set): */ + /* ZW->PC: REQ | 0xD1 | rxStatus | sourceNode | cmdLength | pCmd[] | destNode | rssiVal + * | securityKey | bSourceTxPower | bSourceNoiseFloor */ +#if defined(ZW_CONTROLLER) && !defined(ZW_CONTROLLER_STATIC) + /* For libraries supporting promiscuous mode... */ + BYTE_IN_AR(compl_workbuf, offset + 3 + cmdLength) = (uint8_t)(rxOpt->destNode & 0xFF); + uint8_t index = (uint8_t)(offset + 3 + ((rxOpt->rxStatus & RECEIVE_STATUS_FOREIGN_FRAME) ? 1 : 0) + cmdLength); + BYTE_IN_AR(compl_workbuf, index++) = (uint8_t)rxOpt->rxRSSIVal; + BYTE_IN_AR(compl_workbuf, index++) = rxOpt->securityKey; + BYTE_IN_AR(compl_workbuf, index++) = (uint8_t)rxOpt->bSourceTxPower; + BYTE_IN_AR(compl_workbuf, index) = (uint8_t)rxOpt->bSourceNoiseFloor; + RequestUnsolicited((rxOpt->rxStatus & RECEIVE_STATUS_FOREIGN_FRAME ? + FUNC_ID_PROMISCUOUS_APPLICATION_COMMAND_HANDLER : FUNC_ID_APPLICATION_COMMAND_HANDLER), + compl_workbuf, + index); +#else + BYTE_IN_AR(compl_workbuf, offset + 3 + cmdLength) = (uint8_t)rxOpt->rxRSSIVal; + BYTE_IN_AR(compl_workbuf, offset + 4 + cmdLength) = rxOpt->securityKey; + BYTE_IN_AR(compl_workbuf, offset + 5 + cmdLength) = (uint8_t)rxOpt->bSourceTxPower; + BYTE_IN_AR(compl_workbuf, offset + 6 + cmdLength) = (uint8_t)rxOpt->bSourceNoiseFloor; + + /* Less code space-consuming version for libraries without promiscuous support */ + RequestUnsolicited(FUNC_ID_APPLICATION_COMMAND_HANDLER, compl_workbuf, (uint8_t)(offset + 7 + cmdLength)); +#endif +} +#endif + +#ifdef ZW_CONTROLLER_BRIDGE + +// Struct describing Multicast nodemask header for SerialAPI +typedef struct SMultiCastNodeMaskHeaderSerial +{ + uint8_t iNodemaskLength : 5; // Bits 0-4 is length. Length of Nodemask in bytes - Valid values [0-29] + uint8_t iNodeMaskOffset : 3; // Bits 5-7 is offset. Denotes which node the first bit in the nodemask describes + // First node in nodemask is (Value * 32) + 1 - e.g. 2 -> first node is 65 + // In reality - we always give a full nodemask -> length 29, offset 0. +} SMultiCastNodeMaskHeaderSerial; + +/*====================== ApplicationCommandHandler_Bridge ================ +** Handling of received application commands and requests +** +**--------------------------------------------------------------------------*/ +static void /*RET Nothing */ +ApplicationCommandHandler_Bridge(SReceiveMulti* pReceiveMulti) +{ +#if SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE + /* ZW->HOST: REQ | 0xA8 | rxStatus | destNode | sourceNode | cmdLength + * | pCmd[] | multiDestsOffset_NodeMaskLen | multiDestsNodeMask[] | rssiVal + * | securityKey | bSourceTxPower | bSourceNoiseFloor */ + uint8_t offset = 0; + BYTE_IN_AR(compl_workbuf, 0) = pReceiveMulti->RxOptions.rxStatus; + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(pReceiveMulti->RxOptions.destNode >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)(pReceiveMulti->RxOptions.destNode & 0xFF); // LSB + BYTE_IN_AR(compl_workbuf, 3) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 4) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode & 0xFF); // LSB + offset = 6; // 16 bit nodeIDs means the command fields that follow are offset by two bytes + } + else + { + // Legacy 8 bit nodeIDs + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)pReceiveMulti->RxOptions.destNode; + BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)pReceiveMulti->RxOptions.sourceNode; + offset = 4; + } + + uint32_t cmdLength = pReceiveMulti->iCommandLength; + uint8_t i; + + if (cmdLength > sizeof(pReceiveMulti->Payload)) + { + cmdLength = sizeof(pReceiveMulti->Payload); + } + if (cmdLength > (uint8_t)(BUF_SIZE_TX - offset) ) + { + cmdLength = (uint8_t)(BUF_SIZE_TX - offset) ; + } + BYTE_IN_AR(compl_workbuf, offset - 1 ) = (uint8_t)cmdLength; + + memcpy(compl_workbuf + offset, (uint8_t*)&pReceiveMulti->Payload, cmdLength); + + if (pReceiveMulti->RxOptions.rxStatus & RECEIVE_STATUS_TYPE_MULTI) + { + /* Its a Multicast frame */ + + // Create NodeMaskHeader to comply with SerialAPI + const SMultiCastNodeMaskHeaderSerial NodeMaskHeader = { + .iNodemaskLength = 29, // Always offset full nodemask. Hardwired to 29 (and not + // nodemask define) since SerialAPI is not supposed to change. + .iNodeMaskOffset = 0 // Always full nodemask -> No offset + }; + + i = NodeMaskHeader.iNodemaskLength + 1; // + 1 for node mask headers own size. + if (i > (uint8_t)(BUF_SIZE_TX - (offset + cmdLength))) + { + i = (uint8_t)(BUF_SIZE_TX - (offset + cmdLength + 1)); + } + if (i > 0) + { + *(compl_workbuf + offset + cmdLength) = i - 1; + memcpy(compl_workbuf + offset + 1 + cmdLength, (uint8_t*)pReceiveMulti->NodeMask, i - 1); // +- 1 as we already copied node mask header + i += (uint8_t)cmdLength; + } + } + else + { + if (cmdLength >= (uint8_t)(BUF_SIZE_TX - offset) ) + { + cmdLength = (uint8_t)(BUF_SIZE_TX - offset -1); + i = (uint8_t)cmdLength; + } + else + { + i = (uint8_t)(cmdLength + 1); + } + BYTE_IN_AR(compl_workbuf, (uint8_t)(offset + cmdLength)) = 0; + } + BYTE_IN_AR(compl_workbuf, offset + i) = (uint8_t)pReceiveMulti->RxOptions.rxRSSIVal; + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, offset + ++i) = pReceiveMulti->RxOptions.securityKey; //inclusion fails without this + BYTE_IN_AR(compl_workbuf, offset + ++i) = (uint8_t)pReceiveMulti->RxOptions.bSourceTxPower; + BYTE_IN_AR(compl_workbuf, offset + ++i) = (uint8_t)pReceiveMulti->RxOptions.bSourceNoiseFloor; + } + /* Unified Application Command Handler for Bridge and Virtual nodes */ + RequestUnsolicited(FUNC_ID_APPLICATION_COMMAND_HANDLER_BRIDGE, compl_workbuf, (uint8_t)(offset + 1 + i)); +#else + /* Simulate old split Application Command Handlers */ + uint8_t offset = 0; + if (!IsNodeVirtual(destNode)) + { + /* ZW->PC: REQ | 0x04 | rxStatus | sourceNode | cmdLength | Payload */ + BYTE_IN_AR(compl_workbuf, 0) = pReceiveMulti->RxOptions.rxStatus; + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, offset + 1) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode >> 8); // MSB + BYTE_IN_AR(compl_workbuf, offset + 2) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode & 0xFF); // LSB + offset = 4; // 16 bit nodeID means the command fields that follow are offset by one byte + } + else + { + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)pReceiveMulti->RxOptions.sourceNode; // Legacy 8 bit + offset = 3; + } + if (cmdLength > (uint8_t)(BUF_SIZE_TX - offset) ) + { + cmdLength = (uint8_t)(BUF_SIZE_TX - offset) ; + } + BYTE_IN_AR(compl_workbuf, offset - 1 ) = (uint8_t)cmdLength; + for (i = 0; i < cmdLength; i++) + { + BYTE_IN_AR(compl_workbuf, offset + i) = *((uint8_t*)&pReceiveMulti->Payload + i); + } + RequestUnsolicited(FUNC_ID_APPLICATION_COMMAND_HANDLER, compl_workbuf, offset + cmdLength); + } + else + { + /* ZW->PC: REQ | 0xA1 | rxStatus | destNode | sourceNode | cmdLength | Payload */ + BYTE_IN_AR(compl_workbuf, 0) = pReceiveMulti->RxOptions.rxStatus; + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(pReceiveMulti->RxOptions.destNode >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)(pReceiveMulti->RxOptions.destNode & 0xFF); // LSB + BYTE_IN_AR(compl_workbuf, 3) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 4) = (uint8_t)(pReceiveMulti->RxOptions.sourceNode & 0xFF); // LSB + offset = 6; // 16 bit nodeIDs means the command fields that follow are offset by two bytes + } + else + { + // Legacy 8 bit nodeIDs + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)pReceiveMulti->RxOptions.destNode; + BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)pReceiveMulti->RxOptions.sourceNode; + offset = 4; + } + if (cmdLength > (uint8_t)(BUF_SIZE_TX - offset)) + { + cmdLength = (uint8_t)(BUF_SIZE_TX - offset) ; + } + BYTE_IN_AR(compl_workbuf, offset - 1) = cmdLength; + for (i = 0; i < cmdLength; i++) + { + BYTE_IN_AR(compl_workbuf, offset + i) = *((uint8_t*)&pReceiveMulti->Payload + i); + } + + RequestUnsolicited(FUNC_ID_APPLICATION_SLAVE_COMMAND_HANDLER, compl_workbuf, offset + cmdLength); + } +#endif +} +#endif + + +/*====================== ApplicationNodeUpdate ========================= +** Inform the static controller/slave of node information received +** +**--------------------------------------------------------------------------*/ +void /* RET Nothing */ +ApplicationNodeUpdate( + uint8_t bStatus, /* IN Status of learn mode */ + uint16_t nodeID, /* IN Node id of node sending nodeinfo*/ + uint8_t *pCmd, /* IN Pointer to appl. node info */ + uint8_t bLen /* IN Node info length */ +) +{ + uint8_t offset = 0; + BYTE_IN_AR(compl_workbuf, 0) = bStatus; + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(nodeID >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)(nodeID & 0xFF); // LSB + offset++; // 16 bit nodeID means the command fields that follow are offset by one byte + } + else + { + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(nodeID & 0xFF); // Legacy 8 bit nodeID + } + + /* - Buffer boundary check */ + if (bLen > (uint8_t)(BUF_SIZE_TX - (offset + 3))) + { + bLen = (uint8_t)(BUF_SIZE_TX - (offset + 3)); + } + BYTE_IN_AR(compl_workbuf, offset + 2) = bLen; + for (uint8_t i = 0; i < bLen; i++) + { + BYTE_IN_AR(compl_workbuf, offset + 3 + i) = *(pCmd + i); + } + RequestUnsolicited(FUNC_ID_ZW_APPLICATION_UPDATE, compl_workbuf, (uint8_t)(offset + bLen + 3)); +} + +ZW_WEAK const void * SerialAPI_get_uart_config_ext(void) +{ + return NULL; +} + +#ifdef USB_SUSPEND_SUPPORT + +ZW_WEAK void SerialAPI_set_usb_supend_callback(__attribute__((unused)) SerialAPI_hw_usb_suspend_callback_t callback) +{ +} + +ZW_WEAK void SerialAPI_hw_usb_suspend_handler(void) +{ + +} + +#endif diff --git a/src/zwave_ncp_serial_api_controller/app.h b/src/zwave_ncp_serial_api_controller/app.h new file mode 100644 index 00000000..4ab412ef --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/app.h @@ -0,0 +1,663 @@ +/** + * @file + * Header file for Serial API implementation. + * + * Contains various application definitions and SerialAPI + * functionality support definitions. + * + * @copyright 2019 Silicon Laboratories Inc. + */ +#ifndef _SERIALAPPL_H_ +#define _SERIALAPPL_H_ +#include + +#ifndef UNIT_TEST +/* Z-Wave library functionality support definitions */ +#ifdef ZW_SLAVE +#include +#else +#include +#endif +#endif /*#ifndef UNIT_TEST*/ + +#include + +#include + +#ifdef ZW_SLAVE +#include +#endif +#ifdef ZW_SECURITY_PROTOCOL +#include +#endif + +#ifdef ZW_CONTROLLER +#include +#endif + +/* Serial API version */ +#define SERIAL_API_VER 10 + +/* Max number of times a frame will be transmitted to PC */ +#define MAX_SERIAL_RETRY 3 + +/* Number of bytes in a homeID */ +#define HOMEID_LENGTH 4 + +/* Max number of nodes in a multi cast (group) */ +#define MAX_GROUP_NODES 64 + +/* Macro for accessing the byte in byte_array at the index indx */ +#define BYTE_IN_AR(byte_array, indx) (*(byte_array + indx)) + +/* Macro for getting HIGH uint8_t in wVar uint16_t variable */ +#define BYTE_GET_HIGH_BYTE_IN_WORD(wVar) *((uint8_t*)&wVar) + +/* Macro for getting LOW uint8_t in wVar uint16_t variable */ +#define BYTE_GET_LOW_BYTE_IN_WORD(wVar) *((uint8_t*)&wVar + 1) + +/* Macro for setting HIGH uint8_t and LOW uint8_t in wVar uint16_t variable */ +#define WORD_SET_HIGH_LOW_BYTES(wVar, bHIGHByte, bLOWByte) BYTE_GET_HIGH_BYTE_IN_WORD(wVar) = bHIGHByte; \ + BYTE_GET_LOW_BYTE_IN_WORD(wVar) = bLOWByte + +/* States for ApplicationPoll function */ +enum +{ + stateStartup, + stateIdle, + stateTxSerial, + stateFrameParse, + stateCallbackTxSerial, + stateCommandTxSerial, + stateAppSuspend +}; + +/* States for FUNC_ID_NVM_BACKUP_RESTORE operation */ +typedef enum +{ + NVMBackupRestoreOperationOpen, + NVMBackupRestoreOperationRead, + NVMBackupRestoreOperationWrite, + NVMBackupRestoreOperationClose +} eNVMBackupRestoreOperation; + +/* Return values for FUNC_ID_NVM_BACKUP_RESTORE operation */ +typedef enum +{ + NVMBackupRestoreReturnValueOK = false, /* Everything is OK, so far */ + NVMBackupRestoreReturnValueError = true, /* Non specific error */ + NVMBackupRestoreReturnValueOperationMismatch, /* Error mixing read and write */ + NVMBackupRestoreReturnValueOperationDisturbed, /* Error read operation disturbed by other write */ + NVMBackupRestoreReturnValueEOF = EOF /* Not really an error. Just an indication of EndOfFile */ +} eNVMBackupRestoreReturnValue; + +#ifndef ZW_SECURITY_PROTOCOL +/* params used by ApplicationNodeInformation */ +#define APPL_NODEPARM_MAX 35 +#endif +#define APPL_SLAVENODEPARM_MAX APPL_NODEPARM_MAX + + +typedef enum _E_SERIALAPI_SET_LEARN_MODE_ +{ + SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_DISABLE = ZW_SET_LEARN_MODE_DISABLE, + SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_CLASSIC = ZW_SET_LEARN_MODE_CLASSIC, + SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_NWI = ZW_SET_LEARN_MODE_NWI, + SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_NWE = ZW_SET_LEARN_MODE_NWE, + SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_MAX = SERIALPI_SET_LEARN_MODE_ZW_SET_LEARN_MODE_NWE, + + /* slave_learn_plus/ctrl_learn extensions */ + SERIALPI_SET_LEARN_MODE_LEARN_PLUS_OFFSET = 0x80, + +} E_SERIALAPI_SET_LEARN_MODE; + +#ifdef ZW_SLAVE_ROUTING +/* SerialAPI only used state - used when ZW_RequestNodeInfo transmit fails */ +/* It is then assumed that the destination node did not receive the request. */ +#define UPDATE_STATE_NODE_INFO_REQ_FAILED 0x81 +#endif + +/* SerialAPI functionality support definitions */ +#define SUPPORT_SEND_DATA_TIMING 1 +/* Definitions for SerialAPI startup */ +typedef enum +{ + SERIALAPI_CONFIG_STARTUP_NOTIFICATION_ENABLED = 1, + SERIALAPI_CONFIG_UNDEFINED = 0xFE +} SERIALAPI_CONFIG_T; + +#if defined(NUNIT_TEST) && !defined(ZW_CONTROLLER_BRIDGE) +#define SUPPORT_ZW_NUNIT 1 +#else +#define SUPPORT_ZW_NUNIT 0 +#endif + +#ifdef PORT_STATUS +#define SUPPORT_ZW_PORT_STATUS 1 +#else +#define SUPPORT_ZW_PORT_STATUS 0 +#endif +#define SUPPORT_ZW_SET_SECURITY_S0_NETWORK_KEY 0 /*deprecated*/ +/* Enable support for SerialAPI Startup Notification */ +#define SUPPORT_SERIAL_API_STARTUP_NOTIFICATION 1 + +/* Security in Protocol SerialAPI functionality support definitions */ +#ifdef ZW_SECURITY_PROTOCOL +#define SUPPORT_APPLICATION_SECURITY_EVENT 0 +#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES 1 +#if (SUPPORT_ZW_GET_SECURITY_KEYS | \ + SUPPORT_ZW_SET_SECURITY_S0_NETWORK_KEY | \ + SUPPORT_ZW_GET_SECURITY_S2_PUBLIC_DSK | \ + SUPPORT_ZW_SET_SECURITY_S2_CRITICAL_NODE_ID) +#define SUPPORT_ZW_SECURITY_SETUP 1 +#else +#define SUPPORT_ZW_SECURITY_SETUP 0 +#endif +#else /*#ifdef ZW_SECURITY_PROTOCOL*/ +#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES 0 +#define SUPPORT_ZW_SECURITY_SETUP 0 +#define SUPPORT_APPLICATION_SECURITY_EVENT 0 +#endif + +/* Common SerialAPI functionality support definitions */ +#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION 1 + +#define SUPPORT_SERIAL_API_GET_CAPABILITIES 1 +#define SUPPORT_SERIAL_API_SOFT_RESET 1 + +#define SUPPORT_SERIAL_API_POWER_MANAGEMENT 0 +#define SUPPORT_SERIAL_API_READY 0 + +#define SUPPORT_SERIAL_API_EXT 1 +#ifdef ZW_SECURITY_PROTOCOL +/* Only libraries with SECURITY buildin should supports this (slave_enhanced_232) */ +#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES 1 +#else +#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES 0 +#endif + +#ifdef ZW_ENABLE_RTC +#define SUPPORT_CLOCK_SET 1 +#define SUPPORT_CLOCK_GET 1 +#define SUPPORT_CLOCK_CMP 1 +#define SUPPORT_RTC_TIMER_CREATE 1 +#define SUPPORT_RTC_TIMER_READ 1 +#define SUPPORT_RTC_TIMER_DELETE 1 +#define SUPPORT_RTC_TIMER_CALL 1 +#else +#define SUPPORT_CLOCK_SET 0 +#define SUPPORT_CLOCK_GET 0 +#define SUPPORT_CLOCK_CMP 0 +#define SUPPORT_RTC_TIMER_CREATE 0 +#define SUPPORT_RTC_TIMER_READ 0 +#define SUPPORT_RTC_TIMER_DELETE 0 +#define SUPPORT_RTC_TIMER_CALL 0 +#endif + +#define SUPPORT_ZW_AUTO_PROGRAMMING 1 + +#ifdef TIMER_SUPPORT +#define SUPPORT_TIMER_START 1 +#define SUPPORT_TIMER_RESTART 1 +#define SUPPORT_TIMER_CANCEL 1 +#define SUPPORT_TIMER_CALL 1 +#else +#define SUPPORT_TIMER_START 0 +#define SUPPORT_TIMER_RESTART 0 +#define SUPPORT_TIMER_CANCEL 0 +#define SUPPORT_TIMER_CALL 0 +#endif + +#if defined(NUNIT_TEST) && !defined(ZW_CONTROLLER_BRIDGE) +#define SUPPORT_ZW_NUNIT 1 +#else +#define SUPPORT_ZW_NUNIT 0 +#endif + +#ifdef PORT_STATUS +#define SUPPORT_ZW_PORT_STATUS 1 +#else +#define SUPPORT_ZW_PORT_STATUS 0 +#endif +/* ZW_EnableSUC() no longer exists in the library */ + +/* */ +#define SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET 0 + + +#define FID_BM_OFFS(FUNCID) ((FUNCID - 1) / 8) +#define FID_BM(FUNCID) (1 << ((FUNCID - 1) & 0x07)) +#define CAP_FID(OFFSET, FUNCID) (((FUNCID != 0) && (FID_BM_OFFS(FUNCID) == OFFSET)) ? FID_BM(FUNCID) : 0) +#ifdef ZW_CONTROLLER_SINGLE +#define CAP_BM(OFFSET) (CAP_FID(OFFSET, (SUPPORT_SERIAL_API_POWER_MANAGEMENT == 0) ? 0 : FUNC_ID_SERIAL_API_POWER_MANAGEMENT) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_READY == 0) ? 0 : FUNC_ID_SERIAL_API_READY) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_INIT_DATA == 0) ? 0 : FUNC_ID_SERIAL_API_GET_INIT_DATA) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_NODE_INFORMATION == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION) | \ + CAP_FID(OFFSET, (SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE == 0) ? 0 : FUNC_ID_APPLICATION_COMMAND_HANDLER_BRIDGE) | \ + CAP_FID(OFFSET, (SUPPORT_APPLICATION_COMMAND_HANDLER == 0) ? 0 : FUNC_ID_APPLICATION_COMMAND_HANDLER) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES == 0) ? 0 : FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SET_TIMEOUTS == 0) ? 0 : FUNC_ID_SERIAL_API_SET_TIMEOUTS) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_CAPABILITIES == 0) ? 0 : FUNC_ID_SERIAL_API_GET_CAPABILITIES) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SOFT_RESET == 0) ? 0 : FUNC_ID_SERIAL_API_SOFT_RESET) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_STARTUP_NOTIFICATION == 0) ? 0 : FUNC_ID_SERIAL_API_STARTED) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SETUP == 0) ? 0 : FUNC_ID_SERIAL_API_SETUP) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_PROTOCOL_VERSION == 0) ? 0 : FUNC_ID_ZW_GET_PROTOCOL_VERSION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_RF_RECEIVE_MODE == 0) ? 0 : FUNC_ID_ZW_SET_RF_RECEIVE_MODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_SLEEP_MODE == 0) ? 0 : FUNC_ID_ZW_SET_SLEEP_MODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_NODE_INFORMATION == 0) ? 0 : FUNC_ID_ZW_SEND_NODE_INFORMATION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA == 0) ? 0 : FUNC_ID_ZW_SEND_DATA) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_BRIDGE)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_EX == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_EX) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_META_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_META_BRIDGE)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI_BRIDGE)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI_EX == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI_EX) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SECURITY_SETUP == 0) ? 0 : FUNC_ID_ZW_SECURITY_SETUP) | \ + CAP_FID(OFFSET, (SUPPORT_APPLICATION_SECURITY_EVENT == 0) ? 0 : FUNC_ID_APPLICATION_SECURITY_EVENT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_VERSION == 0) ? 0 : FUNC_ID_ZW_GET_VERSION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_ABORT == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_ABORT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_RF_POWER_LEVEL_SET == 0) ? 0 : FUNC_ID_ZW_RF_POWER_LEVEL_SET) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_RF_POWER_LEVEL_GET == 0) ? 0 : FUNC_ID_ZW_RF_POWER_LEVEL_GET) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_TYPE_LIBRARY == 0) ? 0 : FUNC_ID_ZW_TYPE_LIBRARY) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_PROTOCOL_STATUS == 0) ? 0 : FUNC_ID_ZW_GET_PROTOCOL_STATUS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_ENABLE == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_ENABLE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_DISABLE == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_DISABLE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_KICK == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_KICK) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_START == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_START)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_STOP == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_STOP)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_WUT_TIMEOUT == 0) ? 0 : FUNC_ID_ZW_SET_WUT_TIMEOUT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_IS_WUT_KICKED == 0) ? 0 : FUNC_ID_ZW_IS_WUT_KICKED) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_EXT_INT_LEVEL == 0) ? 0 : FUNC_ID_ZW_SET_EXT_INT_LEVEL) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_META == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_META) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_TEST_FRAME == 0) ? 0 : FUNC_ID_ZW_SEND_TEST_FRAME) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_RANDOM == 0) ? 0 : FUNC_ID_ZW_GET_RANDOM) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_ID == 0) ? 0 : FUNC_ID_MEMORY_GET_ID) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_BYTE == 0) ? 0 : FUNC_ID_MEMORY_GET_BYTE) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_PUT_BYTE == 0) ? 0 : FUNC_ID_MEMORY_PUT_BYTE) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_BUFFER == 0) ? 0 : FUNC_ID_MEMORY_GET_BUFFER) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_PUT_BUFFER == 0) ? 0 : FUNC_ID_MEMORY_PUT_BUFFER) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_BACKUP_RESTORE == 0) ? 0 : FUNC_ID_NVM_BACKUP_RESTORE) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_GET_ID == 0) ? 0 : FUNC_ID_NVM_GET_ID) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_EXT_READ_LONG_BYTE == 0) ? 0 : FUNC_ID_NVM_EXT_READ_LONG_BYTE) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_EXT_WRITE_LONG_BYTE == 0) ? 0 : FUNC_ID_NVM_EXT_WRITE_LONG_BYTE) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_EXT_READ_LONG_BUFFER == 0) ? 0 : FUNC_ID_NVM_EXT_READ_LONG_BUFFER) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_EXT_WRITE_LONG_BUFFER == 0) ? 0 : FUNC_ID_NVM_EXT_WRITE_LONG_BUFFER) | \ + CAP_FID(OFFSET, (SUPPORT_CLOCK_SET == 0) ? 0 : FUNC_ID_CLOCK_SET) | \ + CAP_FID(OFFSET, (SUPPORT_CLOCK_GET == 0) ? 0 : FUNC_ID_CLOCK_GET) | \ + CAP_FID(OFFSET, (SUPPORT_CLOCK_CMP == 0) ? 0 : FUNC_ID_CLOCK_CMP) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_NVR_GET_VALUE == 0) ? 0 : FUNC_ID_NVR_GET_VALUE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_AUTO_PROGRAMMING == 0) ? 0 : FUNC_ID_AUTO_PROGRAMMING) | \ + CAP_FID(OFFSET, (SUPPORT_PWR_SETSTOPMODE == 0) ? 0 : FUNC_ID_PWR_SETSTOPMODE) | \ + CAP_FID(OFFSET, (SUPPORT_PWR_CLK_PD == 0) ? 0 : FUNC_ID_PWR_CLK_PD) | \ + CAP_FID(OFFSET, (SUPPORT_PWR_CLK_PUP == 0) ? 0 : FUNC_ID_PWR_CLK_PUP) | \ + CAP_FID(OFFSET, (SUPPORT_PWR_SELECT_CLK == 0) ? 0 : FUNC_ID_PWR_SELECT_CLK) | \ + CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_CREATE == 0) ? 0 : FUNC_ID_RTC_TIMER_CREATE) | \ + CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_READ == 0) ? 0 : FUNC_ID_RTC_TIMER_READ) | \ + CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_DELETE == 0) ? 0 : FUNC_ID_RTC_TIMER_DELETE) | \ + CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_CALL == 0) ? 0 : FUNC_ID_RTC_TIMER_CALL) | \ + CAP_FID(OFFSET, (SUPPORT_FUNC_ID_CLEAR_TX_TIMERS == 0) ? 0 : FUNC_ID_CLEAR_TX_TIMERS) | \ + CAP_FID(OFFSET, (SUPPORT_FUNC_ID_GET_TX_TIMERS == 0) ? 0 : FUNC_ID_GET_TX_TIMERS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_CLEAR_NETWORK_STATS == 0) ? 0 : FUNC_ID_ZW_CLEAR_NETWORK_STATS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_NETWORK_STATS == 0) ? 0 : FUNC_ID_ZW_GET_NETWORK_STATS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_BACKGROUND_RSSI == 0) ? 0 : FUNC_ID_ZW_GET_BACKGROUND_RSSI) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK == 0) ? 0 : FUNC_ID_ZW_REMOVE_NODE_ID_FROM_NETWORK) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_LEARN_NODE_STATE == 0) ? 0 : FUNC_ID_ZW_SET_LEARN_NODE_STATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_NODE_PROTOCOL_INFO == 0) ? 0 : FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_DEFAULT == 0) ? 0 : FUNC_ID_ZW_SET_DEFAULT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_NEW_CONTROLLER == 0) ? 0 : FUNC_ID_ZW_NEW_CONTROLLER) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE == 0) ? 0 : FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REPLICATION_SEND_DATA == 0) ? 0 : FUNC_ID_ZW_REPLICATION_SEND_DATA) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_DELETE_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_DELETE_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE == 0) ? 0 : FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_NEIGHBOR_COUNT == 0) ? 0 : FUNC_ID_ZW_GET_NEIGHBOR_COUNT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ARE_NODES_NEIGHBOURS == 0) ? 0 : FUNC_ID_ZW_ARE_NODES_NEIGHBOURS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE == 0) ? 0 : FUNC_ID_ZW_APPLICATION_UPDATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ADD_NODE_TO_NETWORK == 0) ? 0 : FUNC_ID_ZW_ADD_NODE_TO_NETWORK) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_NODE_FROM_NETWORK == 0) ? 0 : FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_CREATE_NEW_PRIMARY == 0) ? 0 : FUNC_ID_ZW_CREATE_NEW_PRIMARY) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_CONTROLLER_CHANGE == 0) ? 0 : FUNC_ID_ZW_CONTROLLER_CHANGE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NODE_INFO == 0) ? 0 : FUNC_ID_ZW_REQUEST_NODE_INFO) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_FAILED_NODE_ID == 0) ? 0 : FUNC_ID_ZW_REMOVE_FAILED_NODE_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_IS_FAILED_NODE_ID == 0) ? 0 : FUNC_ID_ZW_IS_FAILED_NODE_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REPLACE_FAILED_NODE == 0) ? 0 : FUNC_ID_ZW_REPLACE_FAILED_NODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_ROUTING_MAX == 0) ? 0 : FUNC_ID_ZW_GET_ROUTING_MAX) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_ROUTING_MAX == 0) ? 0 : FUNC_ID_ZW_SET_ROUTING_MAX) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_IS_PRIMARY_CTRL == 0) ? 0 : FUNC_ID_ZW_IS_PRIMARY_CTRL) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_AES_ECB == 0) ? 0 : FUNC_ID_ZW_AES_ECB) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_APPLICATION_UPDATE == 0) ? 0 : FUNC_ID_ZW_APPLICATION_UPDATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_LEARN_MODE == 0) ? 0 : FUNC_ID_ZW_SET_LEARN_MODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION == 0) ? 0 : FUNC_ID_ZW_EXPLORE_REQUEST_INCLUSION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION == 0) ? 0 : FUNC_ID_ZW_EXPLORE_REQUEST_EXCLUSION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_SUC_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ENABLE_SUC == 0) ? 0 : FUNC_ID_ZW_ENABLE_SUC) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NETWORK_UPDATE == 0) ? 0 : FUNC_ID_ZW_REQUEST_NETWORK_UPDATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_SUC_NODE_ID == 0) ? 0 : FUNC_ID_ZW_SET_SUC_NODE_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_DELETE_SUC_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_SUC_NODE_ID == 0) ? 0 : FUNC_ID_ZW_GET_SUC_NODE_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SUC_ID == 0) ? 0 : FUNC_ID_ZW_SEND_SUC_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_PRIORITY_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_TIMER_START == 0) ? 0 : FUNC_ID_TIMER_START) | \ + CAP_FID(OFFSET, (SUPPORT_TIMER_RESTART == 0) ? 0 : FUNC_ID_TIMER_RESTART) | \ + CAP_FID(OFFSET, (SUPPORT_TIMER_CANCEL == 0) ? 0 : FUNC_ID_TIMER_CANCEL) | \ + CAP_FID(OFFSET, (SUPPORT_TIMER_CALL == 0) ? 0 : FUNC_ID_TIMER_CALL) | \ + CAP_FID(OFFSET, (SUPPORT_GET_ROUTING_TABLE_LINE == 0) ? 0 : FUNC_ID_GET_ROUTING_TABLE_LINE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_ROUTING_INFO == 0) ? 0 : FUNC_ID_ZW_SET_ROUTING_INFO) | \ + CAP_FID(OFFSET, (SUPPORT_GET_TX_COUNTER == 0) ? 0 : FUNC_ID_GET_TX_COUNTER) | \ + CAP_FID(OFFSET, (SUPPORT_RESET_TX_COUNTER == 0) ? 0 : FUNC_ID_RESET_TX_COUNTER) | \ + CAP_FID(OFFSET, (SUPPORT_STORE_NODEINFO == 0) ? 0 : FUNC_ID_STORE_NODEINFO) | \ + CAP_FID(OFFSET, (SUPPORT_STORE_HOMEID == 0) ? 0 : FUNC_ID_STORE_HOMEID) | \ + CAP_FID(OFFSET, (SUPPORT_LOCK_ROUTE_RESPONSE == 0) ? 0 : FUNC_ID_LOCK_ROUTE_RESPONSE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_PRIORITY_ROUTE == 0) ? 0 : FUNC_ID_ZW_GET_PRIORITY_ROUTE)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_PRIORITY_ROUTE == 0) ? 0 : FUNC_ID_ZW_SET_PRIORITY_ROUTE)|\ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_SLAVE_NODE_INFORMATION) | \ + CAP_FID(OFFSET, (SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER == 0) ? 0 : FUNC_ID_APPLICATION_SLAVE_COMMAND_HANDLER) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION == 0) ? 0 : FUNC_ID_ZW_SEND_SLAVE_NODE_INFORMATION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SLAVE_DATA == 0) ? 0 : FUNC_ID_ZW_SEND_SLAVE_DATA) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_SLAVE_LEARN_MODE == 0) ? 0 : FUNC_ID_ZW_SET_SLAVE_LEARN_MODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_VIRTUAL_NODES == 0) ? 0 : FUNC_ID_ZW_GET_VIRTUAL_NODES) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_IS_VIRTUAL_NODE == 0) ? 0 : FUNC_ID_ZW_IS_VIRTUAL_NODE) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_TEST == 0) ? 0 : FUNC_ID_SERIAL_API_TEST) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_EXT == 0) ? 0 : FUNC_ID_SERIAL_API_EXT) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET == 0) ? 0 : FUNC_ID_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_CMD) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_INIT) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_LIST) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_RUN) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_END) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD == 0) ? 0 : FUNC_ID_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD)| \ + CAP_FID(OFFSET, (SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS == 0) ? 0 : FUNC_ID_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS) \ + ) +#else +#define CAP_BM(OFFSET) (CAP_FID(OFFSET, (SUPPORT_SERIAL_API_POWER_MANAGEMENT == 0) ? 0 : FUNC_ID_SERIAL_API_POWER_MANAGEMENT) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_READY == 0) ? 0 : FUNC_ID_SERIAL_API_READY) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_INIT_DATA == 0) ? 0 : FUNC_ID_SERIAL_API_GET_INIT_DATA) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_NODE_INFORMATION == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION) | \ + CAP_FID(OFFSET, (SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE == 0) ? 0 : FUNC_ID_APPLICATION_COMMAND_HANDLER_BRIDGE) | \ + CAP_FID(OFFSET, (SUPPORT_APPLICATION_COMMAND_HANDLER == 0) ? 0 : FUNC_ID_APPLICATION_COMMAND_HANDLER) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES == 0) ? 0 : FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SET_TIMEOUTS == 0) ? 0 : FUNC_ID_SERIAL_API_SET_TIMEOUTS) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_CAPABILITIES == 0) ? 0 : FUNC_ID_SERIAL_API_GET_CAPABILITIES) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SOFT_RESET == 0) ? 0 : FUNC_ID_SERIAL_API_SOFT_RESET) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_STARTUP_NOTIFICATION == 0) ? 0 : FUNC_ID_SERIAL_API_STARTED) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_SETUP == 0) ? 0 : FUNC_ID_SERIAL_API_SETUP) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_PROTOCOL_VERSION == 0) ? 0 : FUNC_ID_ZW_GET_PROTOCOL_VERSION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_RF_RECEIVE_MODE == 0) ? 0 : FUNC_ID_ZW_SET_RF_RECEIVE_MODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_SLEEP_MODE == 0) ? 0 : FUNC_ID_ZW_SET_SLEEP_MODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_NODE_INFORMATION == 0) ? 0 : FUNC_ID_ZW_SEND_NODE_INFORMATION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA == 0) ? 0 : FUNC_ID_ZW_SEND_DATA) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_BRIDGE)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_EX == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_EX) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_META_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_META_BRIDGE)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI_BRIDGE)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_MULTI_EX == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_MULTI_EX) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SECURITY_SETUP == 0) ? 0 : FUNC_ID_ZW_SECURITY_SETUP) | \ + CAP_FID(OFFSET, (SUPPORT_APPLICATION_SECURITY_EVENT == 0) ? 0 : FUNC_ID_APPLICATION_SECURITY_EVENT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_VERSION == 0) ? 0 : FUNC_ID_ZW_GET_VERSION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_ABORT == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_ABORT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_RF_POWER_LEVEL_SET == 0) ? 0 : FUNC_ID_ZW_RF_POWER_LEVEL_SET) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_RF_POWER_LEVEL_GET == 0) ? 0 : FUNC_ID_ZW_RF_POWER_LEVEL_GET) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_TYPE_LIBRARY == 0) ? 0 : FUNC_ID_ZW_TYPE_LIBRARY) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_PROTOCOL_STATUS == 0) ? 0 : FUNC_ID_ZW_GET_PROTOCOL_STATUS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_ENABLE == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_ENABLE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_DISABLE == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_DISABLE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_KICK == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_KICK) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_START == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_START)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_WATCHDOG_STOP == 0) ? 0 : FUNC_ID_ZW_WATCHDOG_STOP)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_WUT_TIMEOUT == 0) ? 0 : FUNC_ID_ZW_SET_WUT_TIMEOUT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_IS_WUT_KICKED == 0) ? 0 : FUNC_ID_ZW_IS_WUT_KICKED) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_EXT_INT_LEVEL == 0) ? 0 : FUNC_ID_ZW_SET_EXT_INT_LEVEL) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_DATA_META == 0) ? 0 : FUNC_ID_ZW_SEND_DATA_META) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_TEST_FRAME == 0) ? 0 : FUNC_ID_ZW_SEND_TEST_FRAME) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_RANDOM == 0) ? 0 : FUNC_ID_ZW_GET_RANDOM) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_ID == 0) ? 0 : FUNC_ID_MEMORY_GET_ID) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_BYTE == 0) ? 0 : FUNC_ID_MEMORY_GET_BYTE) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_PUT_BYTE == 0) ? 0 : FUNC_ID_MEMORY_PUT_BYTE) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_GET_BUFFER == 0) ? 0 : FUNC_ID_MEMORY_GET_BUFFER) | \ + CAP_FID(OFFSET, (SUPPORT_MEMORY_PUT_BUFFER == 0) ? 0 : FUNC_ID_MEMORY_PUT_BUFFER) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_BACKUP_RESTORE == 0) ? 0 : FUNC_ID_NVM_BACKUP_RESTORE) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_GET_ID == 0) ? 0 : FUNC_ID_NVM_GET_ID) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_EXT_READ_LONG_BYTE == 0) ? 0 : FUNC_ID_NVM_EXT_READ_LONG_BYTE) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_EXT_WRITE_LONG_BYTE == 0) ? 0 : FUNC_ID_NVM_EXT_WRITE_LONG_BYTE) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_EXT_READ_LONG_BUFFER == 0) ? 0 : FUNC_ID_NVM_EXT_READ_LONG_BUFFER) | \ + CAP_FID(OFFSET, (SUPPORT_NVM_EXT_WRITE_LONG_BUFFER == 0) ? 0 : FUNC_ID_NVM_EXT_WRITE_LONG_BUFFER) | \ + CAP_FID(OFFSET, (SUPPORT_CLOCK_SET == 0) ? 0 : FUNC_ID_CLOCK_SET) | \ + CAP_FID(OFFSET, (SUPPORT_CLOCK_GET == 0) ? 0 : FUNC_ID_CLOCK_GET) | \ + CAP_FID(OFFSET, (SUPPORT_CLOCK_CMP == 0) ? 0 : FUNC_ID_CLOCK_CMP) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_NVR_GET_VALUE == 0) ? 0 : FUNC_ID_NVR_GET_VALUE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_AUTO_PROGRAMMING == 0) ? 0 : FUNC_ID_AUTO_PROGRAMMING) | \ + CAP_FID(OFFSET, (SUPPORT_PWR_SETSTOPMODE == 0) ? 0 : FUNC_ID_PWR_SETSTOPMODE) | \ + CAP_FID(OFFSET, (SUPPORT_PWR_CLK_PD == 0) ? 0 : FUNC_ID_PWR_CLK_PD) | \ + CAP_FID(OFFSET, (SUPPORT_PWR_CLK_PUP == 0) ? 0 : FUNC_ID_PWR_CLK_PUP) | \ + CAP_FID(OFFSET, (SUPPORT_PWR_SELECT_CLK == 0) ? 0 : FUNC_ID_PWR_SELECT_CLK) | \ + CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_CREATE == 0) ? 0 : FUNC_ID_RTC_TIMER_CREATE) | \ + CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_READ == 0) ? 0 : FUNC_ID_RTC_TIMER_READ) | \ + CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_DELETE == 0) ? 0 : FUNC_ID_RTC_TIMER_DELETE) | \ + CAP_FID(OFFSET, (SUPPORT_RTC_TIMER_CALL == 0) ? 0 : FUNC_ID_RTC_TIMER_CALL) | \ + CAP_FID(OFFSET, (SUPPORT_FUNC_ID_CLEAR_TX_TIMERS == 0) ? 0 : FUNC_ID_CLEAR_TX_TIMERS) | \ + CAP_FID(OFFSET, (SUPPORT_FUNC_ID_GET_TX_TIMERS == 0) ? 0 : FUNC_ID_GET_TX_TIMERS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_CLEAR_NETWORK_STATS == 0) ? 0 : FUNC_ID_ZW_CLEAR_NETWORK_STATS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_NETWORK_STATS == 0) ? 0 : FUNC_ID_ZW_GET_NETWORK_STATS) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_BACKGROUND_RSSI == 0) ? 0 : FUNC_ID_ZW_GET_BACKGROUND_RSSI) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK == 0) ? 0 : FUNC_ID_ZW_REMOVE_NODE_ID_FROM_NETWORK) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_LEARN_NODE_STATE == 0) ? 0 : FUNC_ID_ZW_SET_LEARN_NODE_STATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_NODE_PROTOCOL_INFO == 0) ? 0 : FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_DEFAULT == 0) ? 0 : FUNC_ID_ZW_SET_DEFAULT) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_NEW_CONTROLLER == 0) ? 0 : FUNC_ID_ZW_NEW_CONTROLLER) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE == 0) ? 0 : FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REPLICATION_SEND_DATA == 0) ? 0 : FUNC_ID_ZW_REPLICATION_SEND_DATA) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_DELETE_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_DELETE_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE == 0) ? 0 : FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE == 0) ? 0 : FUNC_ID_ZW_APPLICATION_UPDATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ADD_NODE_TO_NETWORK == 0) ? 0 : FUNC_ID_ZW_ADD_NODE_TO_NETWORK) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_NODE_FROM_NETWORK == 0) ? 0 : FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_CREATE_NEW_PRIMARY == 0) ? 0 : FUNC_ID_ZW_CREATE_NEW_PRIMARY) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_CONTROLLER_CHANGE == 0) ? 0 : FUNC_ID_ZW_CONTROLLER_CHANGE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NODE_INFO == 0) ? 0 : FUNC_ID_ZW_REQUEST_NODE_INFO) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REMOVE_FAILED_NODE_ID == 0) ? 0 : FUNC_ID_ZW_REMOVE_FAILED_NODE_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_IS_FAILED_NODE_ID == 0) ? 0 : FUNC_ID_ZW_IS_FAILED_NODE_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REPLACE_FAILED_NODE == 0) ? 0 : FUNC_ID_ZW_REPLACE_FAILED_NODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_ROUTING_MAX == 0) ? 0 : FUNC_ID_ZW_GET_ROUTING_MAX) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_ROUTING_MAX == 0) ? 0 : FUNC_ID_ZW_SET_ROUTING_MAX) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_IS_PRIMARY_CTRL == 0) ? 0 : FUNC_ID_ZW_IS_PRIMARY_CTRL) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_AES_ECB == 0) ? 0 : FUNC_ID_ZW_AES_ECB) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_APPLICATION_UPDATE == 0) ? 0 : FUNC_ID_ZW_APPLICATION_UPDATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_LEARN_MODE == 0) ? 0 : FUNC_ID_ZW_SET_LEARN_MODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION == 0) ? 0 : FUNC_ID_ZW_EXPLORE_REQUEST_INCLUSION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION == 0) ? 0 : FUNC_ID_ZW_EXPLORE_REQUEST_EXCLUSION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_SUC_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ENABLE_SUC == 0) ? 0 : FUNC_ID_ZW_ENABLE_SUC) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_REQUEST_NETWORK_UPDATE == 0) ? 0 : FUNC_ID_ZW_REQUEST_NETWORK_UPDATE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_SUC_NODE_ID == 0) ? 0 : FUNC_ID_ZW_SET_SUC_NODE_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_DELETE_SUC_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_SUC_NODE_ID == 0) ? 0 : FUNC_ID_ZW_GET_SUC_NODE_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SUC_ID == 0) ? 0 : FUNC_ID_ZW_SEND_SUC_ID) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE == 0) ? 0 : FUNC_ID_ZW_ASSIGN_PRIORITY_RETURN_ROUTE) | \ + CAP_FID(OFFSET, (SUPPORT_TIMER_START == 0) ? 0 : FUNC_ID_TIMER_START) | \ + CAP_FID(OFFSET, (SUPPORT_TIMER_RESTART == 0) ? 0 : FUNC_ID_TIMER_RESTART) | \ + CAP_FID(OFFSET, (SUPPORT_TIMER_CANCEL == 0) ? 0 : FUNC_ID_TIMER_CANCEL) | \ + CAP_FID(OFFSET, (SUPPORT_TIMER_CALL == 0) ? 0 : FUNC_ID_TIMER_CALL) | \ + CAP_FID(OFFSET, (SUPPORT_GET_ROUTING_TABLE_LINE == 0) ? 0 : FUNC_ID_GET_ROUTING_TABLE_LINE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_ROUTING_INFO == 0) ? 0 : FUNC_ID_ZW_SET_ROUTING_INFO) | \ + CAP_FID(OFFSET, (SUPPORT_GET_TX_COUNTER == 0) ? 0 : FUNC_ID_GET_TX_COUNTER) | \ + CAP_FID(OFFSET, (SUPPORT_RESET_TX_COUNTER == 0) ? 0 : FUNC_ID_RESET_TX_COUNTER) | \ + CAP_FID(OFFSET, (SUPPORT_STORE_NODEINFO == 0) ? 0 : FUNC_ID_STORE_NODEINFO) | \ + CAP_FID(OFFSET, (SUPPORT_STORE_HOMEID == 0) ? 0 : FUNC_ID_STORE_HOMEID) | \ + CAP_FID(OFFSET, (SUPPORT_LOCK_ROUTE_RESPONSE == 0) ? 0 : FUNC_ID_LOCK_ROUTE_RESPONSE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_PRIORITY_ROUTE == 0) ? 0 : FUNC_ID_ZW_GET_PRIORITY_ROUTE)|\ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_PRIORITY_ROUTE == 0) ? 0 : FUNC_ID_ZW_SET_PRIORITY_ROUTE)|\ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION == 0) ? 0 : FUNC_ID_SERIAL_API_APPL_SLAVE_NODE_INFORMATION) | \ + CAP_FID(OFFSET, (SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER == 0) ? 0 : FUNC_ID_APPLICATION_SLAVE_COMMAND_HANDLER) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION == 0) ? 0 : FUNC_ID_ZW_SEND_SLAVE_NODE_INFORMATION) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SEND_SLAVE_DATA == 0) ? 0 : FUNC_ID_ZW_SEND_SLAVE_DATA) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_SLAVE_LEARN_MODE == 0) ? 0 : FUNC_ID_ZW_SET_SLAVE_LEARN_MODE) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_GET_VIRTUAL_NODES == 0) ? 0 : FUNC_ID_ZW_GET_VIRTUAL_NODES) | \ + CAP_FID(OFFSET, (SUPPORT_ZW_IS_VIRTUAL_NODE == 0) ? 0 : FUNC_ID_ZW_IS_VIRTUAL_NODE) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_EXT == 0) ? 0 : FUNC_ID_SERIAL_API_EXT) | \ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET == 0) ? 0 : FUNC_ID_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_PROMISCUOUS_MODE == 0) ? 0 : FUNC_ID_ZW_SET_PROMISCUOUS_MODE) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_CMD) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_INIT) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_LIST) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_RUN) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_NUNIT == 0) ? 0 : FUNC_ID_ZW_NUNIT_END) |\ + CAP_FID(OFFSET, (SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD == 0) ? 0 : FUNC_ID_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD)| \ + CAP_FID(OFFSET, (SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS == 0) ? 0 : FUNC_ID_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS)| \ + CAP_FID(OFFSET, (SUPPORT_ZW_INITIATE_SHUTDOWN == 0) ? 0 : FUNC_ID_ZW_INITIATE_SHUTDOWN) |\ + CAP_FID(OFFSET, (SUPPORT_SERIAL_API_GET_LR_NODES == 0) ? 0 : FUNC_ID_SERIAL_API_GET_LR_NODES) |\ + CAP_FID(OFFSET, (SUPPORT_SERIAL_GET_LR_CHANNEL == 0) ? 0 : FUNC_ID_GET_LR_CHANNEL) |\ + CAP_FID(OFFSET, (SUPPORT_SERIAL_SET_LR_CHANNEL == 0) ? 0 : FUNC_ID_SET_LR_CHANNEL) |\ + CAP_FID(OFFSET, (SUPPORT_SERIAL_SET_LR_VIRTUAL_IDS == 0) ? 0 : FUNC_ID_ZW_SET_LR_VIRTUAL_IDS) |\ + CAP_FID(OFFSET, (SUPPORT_SERIAL_ENABLE_RADIO_PTI == 0) ? 0 : FUNC_ID_ENABLE_RADIO_PTI) |\ + CAP_FID(OFFSET, (SUPPORT_SERIAL_ENABLE_RADIO_PTI == 0) ? 0 : FUNC_ID_GET_RADIO_PTI) \ + ) +#endif /* ZW_CONTROLLER_SINGLE */ + + +#if SUPPORT_SERIAL_API_READY +enum +{ + /* SERIAL_LINK_IDLE = Ready for incomming Serial communication, but */ + /* do not transmit anything via the serial link even if application */ + /* frames is received on the RF, which normally should be transmitted */ + /* to the HOST. */ + SERIAL_LINK_DETACHED = 0, + /* SERIAL_LINK_CONNECTED = There exists a HOST so transmit on serial */ + /* link if needed. */ + SERIAL_LINK_CONNECTED = 1 +}; + +extern uint8_t serialLinkState; +#endif /* SUPPORT_SERIAL_API_READY */ + +extern void DoRespond_workbuf( + uint8_t cnt); + +extern void set_state_and_notify( + uint8_t st +); + +extern void set_state( + uint8_t st +); + +extern bool Request( + uint8_t cmd, /*IN Command */ + uint8_t *pData, /*IN pointer to data */ + uint8_t len /*IN Length of data */ +); + +extern bool RequestUnsolicited( + uint8_t cmd, /*IN Command */ + uint8_t *pData, /*IN pointer to data */ + uint8_t len /*IN Length of data */ +); + +extern void Respond( + uint8_t cmd, /*IN Command */ + uint8_t const * pData, /*IN pointer to data */ + uint8_t len /*IN Length of data */ +); +extern void DoRespond(uint8_t retVal); + +extern void PopCallBackQueue(void); + +extern void PopCommandQueue(void); + +extern uint8_t GetCallbackCnt(void); + +extern void ZW_GetMfgTokenDataCountryFreq(void *data); + +#ifdef ZW_CONTROLLER_SINGLE +#if SUPPORT_SERIAL_API_TEST + +extern void +SendTestReport( + uint8_t txStatus); + +extern void +TestStartRound(void); + +extern void +SendTestRoundReport( + uint8_t txStatus); + +extern void +ZCB_TestDelayNextSendTimeout(void); + +extern void +ZCB_TestDelayTimeout(void); + +extern bool +TestFindNextNode(void); + +extern void +ZCB_TestSendComplete( + uint8_t bStatus, + TX_STATUS_TYPE *txStatusReport); + +extern void +TestSend(void); + +#endif /* SUPPORT_SERIAL_API_TEST */ +#endif /* ZW_CONTROLLER_SINGLE */ + +#if SUPPORT_SERIAL_API_POWER_MANAGEMENT +extern void +ZCB_PowerManagementWakeUpOnExternalActive(void); + +extern void +ZCB_PowerManagementWakeUpOnTimerHandler(void); + +extern void +ZCB_powerManagementPoweredUpPinActive(void); + +extern void +PowerManagementSetPowerDown(void); + +extern void +PowerManagementSetPowerUp(void); + +extern void +PowerManagementCheck(void); + +extern void +PurgeCallbackQueue(void); + +extern void +PurgeCommandQueue(void); +#endif /* SUPPORT_SERIAL_API_POWER_MANAGEMENT */ + +// Prioritized events that can wakeup protocol thread. +typedef enum EApplicationEvent +{ + EAPPLICATIONEVENT_ZWRX = 0, + EAPPLICATIONEVENT_ZWCOMMANDSTATUS, + EAPPLICATIONEVENT_STATECHANGE, + EAPPLICATIONEVENT_SERIALDATARX, + EAPPLICATIONEVENT_SERIALTIMEOUT, + EAPPLICATIONEVENT_TIMER +} EApplicationEvent; + +/* FUNC_ID_SERIAL_API_STARTED Capabilities bit field definitions */ +typedef enum +{ + SERIAL_API_STARTED_CAPABILITIES_L0NG_RANGE = 1<<0 // Controller is Z-Wave Long Range capable + /* Can be extended with future capability bits here */ +} eSerialAPIStartedCapabilities; + +extern void ApplicationNodeUpdate(uint8_t bStatus, uint16_t nodeID, uint8_t *pCmd, uint8_t bLen); + +/* Should be enough */ +#define BUF_SIZE_RX 168 +#define BUF_SIZE_TX 168 + +extern uint8_t compl_workbuf[BUF_SIZE_TX]; + +#endif /* _SERIALAPPL_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/app_node_info.c b/src/zwave_ncp_serial_api_controller/app_node_info.c new file mode 100644 index 00000000..c2da5788 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/app_node_info.c @@ -0,0 +1,26 @@ +/** + * @file app_node_info.c + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include "app_node_info.h" + +uint8_t aAppNodeInfoCCUnSecureIncluded[APPL_NODEPARM_MAX]; +uint8_t aAppNodeInfoCCSecureIncludedUnSecure[APPL_NODEPARM_MAX]; +uint8_t aAppNodeInfoCCSecureIncludedSecure[APPL_NODEPARM_MAX]; + +SCommandClassSet_t CommandClasses = { + .UnSecureIncludedCC.iListLength = 0, + .UnSecureIncludedCC.pCommandClasses = aAppNodeInfoCCUnSecureIncluded, + .SecureIncludedUnSecureCC.iListLength = 0, + .SecureIncludedUnSecureCC.pCommandClasses = aAppNodeInfoCCSecureIncludedUnSecure, + .SecureIncludedSecureCC.iListLength = 0, + .SecureIncludedSecureCC.pCommandClasses = aAppNodeInfoCCSecureIncludedSecure +}; + +const uint8_t CCListSizes[3] = +{ + sizeof(aAppNodeInfoCCUnSecureIncluded), + sizeof(aAppNodeInfoCCSecureIncludedUnSecure), + sizeof(aAppNodeInfoCCSecureIncludedSecure) +}; diff --git a/src/zwave_ncp_serial_api_controller/app_node_info.h b/src/zwave_ncp_serial_api_controller/app_node_info.h new file mode 100644 index 00000000..b628e38e --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/app_node_info.h @@ -0,0 +1,15 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef APP_NODE_INFO_H_ +#define APP_NODE_INFO_H_ + +#include "app.h" +#include + +extern SCommandClassSet_t CommandClasses; +extern const uint8_t CCListSizes[3]; + +#endif /* APP_NODE_INFO_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/cmd_get_capabilities.c b/src/zwave_ncp_serial_api_controller/cmd_get_capabilities.c new file mode 100644 index 00000000..4ce912c9 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmd_get_capabilities.c @@ -0,0 +1,49 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ +#include +#include "cmd_handlers.h" +#include "app.h" +#include "zaf_config.h" +#include "zw_version_config.h" + +#define CAPABILITIES_SIZE (8 + 32) // Info + supported commands + +/* Serial API application manufacturer_id */ +#define SERIALAPI_MANUFACTURER_ID1 (uint8_t)((ZAF_CONFIG_MANUFACTURER_ID & 0xFF00) >> 8) /* MSB */ +#define SERIALAPI_MANUFACTURER_ID2 (uint8_t)( ZAF_CONFIG_MANUFACTURER_ID & 0x00FF) /* LSB */ +/* Serial API application manufacturer product type */ +#define SERIALAPI_MANUFACTURER_PRODUCT_TYPE1 (uint8_t)((ZAF_CONFIG_PRODUCT_TYPE_ID & 0xFF00) >> 8) /* MSB */ +#define SERIALAPI_MANUFACTURER_PRODUCT_TYPE2 (uint8_t) (ZAF_CONFIG_PRODUCT_TYPE_ID & 0x00FF) /* LSB */ +/* Serial API application manufacturer product id */ +#define SERIALAPI_MANUFACTURER_PRODUCT_ID1 (uint8_t)((ZAF_CONFIG_PRODUCT_ID & 0xFF00) >> 8) /* MSB */ +#define SERIALAPI_MANUFACTURER_PRODUCT_ID2 (uint8_t) (ZAF_CONFIG_PRODUCT_ID & 0x00FF) /* LSB */ + +static uint8_t SERIALAPI_CAPABILITIES[CAPABILITIES_SIZE] = { + APP_VERSION, + APP_REVISION, + SERIALAPI_MANUFACTURER_ID1, + SERIALAPI_MANUFACTURER_ID2, + SERIALAPI_MANUFACTURER_PRODUCT_TYPE1, + SERIALAPI_MANUFACTURER_PRODUCT_TYPE2, + SERIALAPI_MANUFACTURER_PRODUCT_ID1, + SERIALAPI_MANUFACTURER_PRODUCT_ID2 +}; + +static bool add_cmd_to_capabilities(cmd_handler_map_t const * const p_cmd_entry, cmd_context_t context) +{ + ZW_NodeMaskSetBit(context, p_cmd_entry->cmd); + return false; +} + +ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_CAPABILITIES) +{ + cmd_foreach(add_cmd_to_capabilities, &SERIALAPI_CAPABILITIES[8]); + /* HOST->ZW: no params defined */ + /* ZW->HOST: RES | 0x07 | */ + /* SERIAL_APPL_VERSION | SERIAL_APPL_REVISION | SERIALAPI_MANUFACTURER_ID1 | SERIALAPI_MANUFACTURER_ID2 | */ + /* SERIALAPI_MANUFACTURER_PRODUCT_TYPE1 | SERIALAPI_MANUFACTURER_PRODUCT_TYPE2 | */ + /* SERIALAPI_MANUFACTURER_PRODUCT_ID1 | SERIALAPI_MANUFACTURER_PRODUCT_ID2 | FUNCID_SUPPORTED_BITMASK[] */ + Respond(frame->cmd, SERIALAPI_CAPABILITIES, sizeof(SERIALAPI_CAPABILITIES)); +} diff --git a/src/zwave_ncp_serial_api_controller/cmd_handlers.c b/src/zwave_ncp_serial_api_controller/cmd_handlers.c new file mode 100644 index 00000000..496eee8a --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmd_handlers.c @@ -0,0 +1,3635 @@ +/** + * @file cmd_handlers.c + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#define DEBUGPRINT +#include + +#include "app_node_info.h" +#include "virtual_slave_node_info.h" +#include "cmd_handlers.h" +#include "cmds_management.h" +#include "cmds_security.h" +#include "cmds_rf.h" +#include "ZW_SerialAPI.h" +#include "app.h" +#include "serialapi_file.h" +#include "utils.h" +#include "nvm_backup_restore.h" +#include "zaf_protocol_config.h" + +#if SUPPORT_ZW_AES_ECB +#include +#endif + +extern bool bTxStatusReportEnabled; + +SSyncEventArg1 LearnModeStatusCb = {.uFunctor.pFunction = 0}; // Ensure function pointer is initialized +SSyncEvent SetDefaultCB = {.uFunctor.pFunction = 0}; // Ensure function pointer is initialized + +#ifdef ZW_CONTROLLER +static uint8_t addState = 0; +uint8_t funcID_ComplHandler_ZW_NodeManagement; +uint8_t nodeManagement_Func_ID; +#endif + + +#ifdef ZW_CONTROLLER +static void SetupNodeManagement(const comm_interface_frame_ptr frame, uint8_t funcID_offet) +{ + nodeManagement_Func_ID = frame->cmd; + funcID_ComplHandler_ZW_NodeManagement = *(frame->payload + funcID_offet); + set_state_and_notify(stateIdle); + addState = 0; +} +#endif + + +#if SUPPORT_ZW_INITIATE_SHUTDOWN +/* + This callback function called from protocol just before going into deep sleep (Deep Sleep) + The function itself sends a respond to the host notifying it that the device is ready to go into deep sleep. +*/ +static void Initiate_shutdown_cb(void) +{ + // 0x1 0x03 0x00 0xd9 + const uint8_t status = 0x01; + comm_interface_transmit_frame(FUNC_ID_ZW_INITIATE_SHUTDOWN, RESPONSE, &status, sizeof(status), NULL); + comm_interface_wait_transmit_done(); +} + +/* + HOST->ZW + ZW-HOST 0x01 +*/ +ZW_ADD_CMD(FUNC_ID_ZW_INITIATE_SHUTDOWN) +{ + AppTimerStopAll(); + if (InitiateShutdown(&Initiate_shutdown_cb)) + { + set_state_and_notify(stateIdle); + } + else + { + // somthing went wrong we failed to start the graceful shutdown + DoRespond(0); + } +} + +#endif + + +#if SUPPORT_FUNC_ID_CLEAR_TX_TIMERS +static void ClearTxTimers(void) +{ + SZwaveCommandPackage CommandPackage = { .eCommandType = EZWAVECOMMANDTYPE_CLEAR_TX_TIMERS }; + + // Put the package on queue (and DO wait for it, since there is no feedback to serial master) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&CommandPackage, 500); + + if (EQUEUENOTIFYING_STATUS_SUCCESS != QueueStatus) + { + DPRINT("Warning: Failed to clear Tx timers"); + } +} + +ZW_ADD_CMD(FUNC_ID_CLEAR_TX_TIMERS) +{ + /* HOST->ZW: */ + ClearTxTimers(); + set_state(stateIdle); +} +#endif /* SUPPORT_FUNC_ID_CLEAR_TX_TIMERS */ + + +#if SUPPORT_FUNC_ID_GET_TX_TIMERS +ZW_ADD_CMD(FUNC_ID_GET_TX_TIMERS) +{ + /* HOST->ZW: */ + /* ZW->HOST: channel0TxTimer_MSB | channel0TxTimer_Next_MSB | channel0TxTimer_Next_LSB | channel0TxTimerLSB | */ + /* channel1TxTimer_MSB | channel1TxTimer_Next_MSB | channel1TxTimer_Next_LSB | channel1TxTimerLSB | */ + /* channel2TxTimer_MSB | channel2TxTimer_Next_MSB | channel2TxTimer_Next_LSB | channel2TxTimerLSB | */ + /* channel3TxTimer_MSB | channel3TxTimer_Next_MSB | channel3TxTimer_Next_LSB | channel3TxTimerLSB | */ + /* channel4TxTimer_MSB | channel4TxTimer_Next_MSB | channel4TxTimer_Next_LSB | channel4TxTimerLSB */ + + // Copy current Network Statistic counters + const zpal_radio_network_stats_t *sRFStats = ZAF_getNetworkStatistics(); + + uint8_t i = 0; + // Copy with endian swap + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_0 >> 24) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_0 >> 16) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_0 >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_0 >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_1 >> 24) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_1 >> 16) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_1 >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_1 >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_2 >> 24) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_2 >> 16) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_2 >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_2 >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_3 >> 24) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_3 >> 16) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_3 >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_3 >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_4 >> 24) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_4 >> 16) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_4 >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_time_channel_4 >> 0) & 0xff); + + DoRespond_workbuf(i); +} +#endif /* SUPPORT_FUNC_ID_GET_TX_TIMERS */ + + +#if SUPPORT_ZW_GET_BACKGROUND_RSSI +static void GetBackgroundRSSI(RSSI_LEVELS *noise_levels) +{ + SZwaveCommandPackage cmdPackage = {.eCommandType = EZWAVECOMMANDTYPE_GET_BACKGROUND_RSSI}; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_BACKGROUND_RSSI)) + { + memcpy((uint8_t *)noise_levels, cmdStatus.Content.GetBackgroundRssiStatus.rssi, sizeof(RSSI_LEVELS)); + return; + } + ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. +} + +ZW_ADD_CMD(FUNC_ID_ZW_GET_BACKGROUND_RSSI) +{ + /* HOST->ZW: (no arguments) */ + /* ZW->HOST: RES | RSSI Ch0 | RSSI Ch1 | RSSI Ch2 */ + GetBackgroundRSSI((RSSI_LEVELS*)&compl_workbuf[0]); + DoRespond_workbuf(sizeof(RSSI_LEVELS)); +} +#endif + + +#if SUPPORT_ZW_CLEAR_NETWORK_STATS +static void ClearNetworkStats(void) +{ + SZwaveCommandPackage CommandPackage = {.eCommandType = EZWAVECOMMANDTYPE_CLEAR_NETWORK_STATISTICS}; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&CommandPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); +} + +ZW_ADD_CMD(FUNC_ID_ZW_CLEAR_NETWORK_STATS) +{ + /* HOST->ZW: */ + /* ZW->HOST: 0x01 */ + ClearNetworkStats(); + DoRespond(1); +} +#endif /* SUPPORT_ZW_CLEAR_NETWORK_STATS */ + + +#if SUPPORT_ZW_GET_NETWORK_STATS +ZW_ADD_CMD(FUNC_ID_ZW_GET_NETWORK_STATS) +{ + /* HOST->ZW: */ + /* ZW->HOST: wRFTxFrames_MSB | wRFTxFrames_LSB | */ + /* wRFTxLBTBackOffs_MSB | wRFTxLBTBackOffs_LSB | */ + /* wRFRxFrames_MSB | wRFRxFrames_LSB */ + /* wRFRxLRCErrors_MSB | wRFRxLRCErrors_LSB */ + /* wRFRxCRCErrors_MSB | wRFRxCRCErrors_LSB */ + /* wRFRxForeignHomeID_MSB | wRFRxForeignHomeID_LSB */ + + // Copy current Network Statistic counters + const zpal_radio_network_stats_t *sRFStats = ZAF_getNetworkStatistics(); + + int i = 0; + // Copy with endian swap + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_frames >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_frames >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_lbt_back_offs >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->tx_lbt_back_offs >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->rx_frames >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->rx_frames >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->rx_lrc_errors >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->rx_lrc_errors >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->rx_crc_errors >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->rx_crc_errors >> 0) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->rx_foreign_home_id >> 8) & 0xff); + compl_workbuf[i++] = (uint8_t)((sRFStats->rx_foreign_home_id >> 0) & 0xff); + + DoRespond_workbuf((uint8_t)i); +} +#endif /* SUPPORT_ZW_GET_NETWORK_STATS */ + + +#if SUPPORT_ZW_SET_RF_RECEIVE_MODE +uint8_t SetRFReceiveMode(uint8_t mode) +{ + SZwaveCommandPackage pCmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_SET_RF_RECEIVE_MODE, + .uCommandParams.SetRfReceiveMode.mode = mode}; + + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_SET_RF_RECEIVE_MODE)) + { + return cmdStatus.Content.SetRFReceiveModeStatus.result; + } + ASSERT(0); + return 0; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_RF_RECEIVE_MODE) +{ + /* HOST->ZW: mode */ + /* ZW->HOST: retVal */ + const uint8_t retVal = SetRFReceiveMode(frame->payload[0]); + DoRespond(retVal); +} +#endif /* SUPPORT_ZW_SET_RF_RECEIVE_MODE */ + + +#if SUPPORT_ZW_SEND_NODE_INFORMATION +uint8_t funcID_ComplHandler_ZW_SendNodeInformation; + +static uint8_t SendNodeInformation(uint16_t destID, uint8_t txOptions, ZW_TX_Callback_t pCallBack) +{ + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.NodeInfo.DestNodeId = destID, + .uTransmitParams.NodeInfo.TransmitOptions = txOptions, + .uTransmitParams.NodeInfo.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_NODEINFORMATION + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus; + QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +/*===================== ComplHandler_ZW_SendNodeInformation ============= +** Completion handler for ZW_SendNodeInformation +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_SendNodeInformation( + uint8_t txStatus, /* IN Transmit completion status */ + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendNodeInformation; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_SEND_NODE_INFORMATION, compl_workbuf, 2); +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_NODE_INFORMATION) +{ + /* HOST->ZW: destNode | txOptions | funcID */ + /* ZW->HOST: retVal */ + uint8_t offset = 0; + node_id_t destNode = (node_id_t)GET_NODEID(&frame->payload[0], offset); + funcID_ComplHandler_ZW_SendNodeInformation = frame->payload[offset + 2]; + const uint8_t retVal = SendNodeInformation(destNode, frame->payload[offset + 1], (frame->payload[offset + 2] != 0) ? &ZCB_ComplHandler_ZW_SendNodeInformation : NULL); + DoRespond(retVal); +} +#endif /* SUPPORT_ZW_SEND_NODE_INFORMATION */ + + +#if SUPPORT_ZW_SECURITY_SETUP +ZW_ADD_CMD(FUNC_ID_ZW_SECURITY_SETUP) +{ + uint8_t length; + func_id_zw_security_setup(frame_payload_len(frame), frame->payload, compl_workbuf, &length); + DoRespond_workbuf(length); +} +#endif + + +#if SUPPORT_ZW_SEND_DATA || SUPPORT_ZW_SEND_DATA_BRIDGE +uint8_t funcID_ComplHandler_ZW_SendData; +#endif + +#if SUPPORT_ZW_SEND_DATA || SUPPORT_ZW_SEND_DATA_EX || SUPPORT_ZW_SEND_DATA_BRIDGE +static void +GenerateTxStatusRequest( + uint8_t cmd, + uint8_t txStatusfuncID, + uint8_t txStatus, + TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ +{ + uint8_t bIdx = 0; + BYTE_IN_AR(compl_workbuf, bIdx++) = txStatusfuncID; + BYTE_IN_AR(compl_workbuf, bIdx++) = txStatus; + if (bTxStatusReportEnabled /* Do HOST want txStatusReport */ + && txStatusReport) /* Check if detailed info is available from protocol */ + { + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)((((txStatusReport->TransmitTicks / 10) & 0xFFFFFF) >> 8) & 0xFF); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(((txStatusReport->TransmitTicks / 10) & 0xFFFFFF) & 0xFF); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bRepeaters); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[0]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[1]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[2]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[3]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->rssi_values.incoming[4]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bACKChannelNo); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bLastTxChannelNo); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bRouteSchemeState); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[0]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[1]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[2]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[3]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->pLastUsedRoute[4]); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bRouteTries); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bLastFailedLink.from); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bLastFailedLink.to); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bUsedTxpower); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bMeasuredNoiseFloor); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bDestinationAckUsedTxPower); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bDestinationAckMeasuredRSSI); + BYTE_IN_AR(compl_workbuf, bIdx++) = (uint8_t)(txStatusReport->bDestinationAckMeasuredNoiseFloor); + } + Request(cmd, compl_workbuf, bIdx); +} +#endif + +#if SUPPORT_ZW_SEND_DATA +/*====================== ComplHandler_ZW_SendData ======================== +** Completion handler for ZW_SendData +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_SendData( + uint8_t txStatus, + TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ +{ + GenerateTxStatusRequest(FUNC_ID_ZW_SEND_DATA, funcID_ComplHandler_ZW_SendData, txStatus, txStatusReport); +} + +static uint8_t SendData(uint16_t nodeID, const uint8_t *pData, uint8_t dataLength, uint8_t txOptions, ZW_TX_Callback_t pCallBack) +{ + SZwaveTransmitPackage FramePackage = { 0 }; + +#ifndef ZW_SECURITY_PROTOCOL + SSendData *pSendData = &FramePackage.uTransmitParams.SendData; + memset(&pSendData->FrameConfig.aFrame, 0, sizeof(pSendData->FrameConfig.aFrame)); + pSendData->DestNodeId = nodeID; + pSendData->FrameConfig.TransmitOptions = txOptions; + memcpy(&pSendData->FrameConfig.aFrame, pData, dataLength); + pSendData->FrameConfig.Handle = pCallBack; + FramePackage.eTransmitType = EZWAVETRANSMITTYPE_STD; + pSendData->FrameConfig.iFrameLength = dataLength; + +#else + { + SSendDataEx *pSendDataEx = &FramePackage.uTransmitParams.SendDataEx; + pSendDataEx->DestNodeId = nodeID; + pSendDataEx->FrameConfig.TransmitOptions = txOptions; + memcpy(&pSendDataEx->FrameConfig.aFrame, pData, dataLength); + pSendDataEx->FrameConfig.Handle = pCallBack; + FramePackage.eTransmitType = EZWAVETRANSMITTYPE_EX; + FramePackage.uTransmitParams.SendDataEx.FrameConfig.iFrameLength = dataLength; + } +#endif /* !ZW_SLAVE_ENHANCED_232 */ + + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA) +{ + /* HOST->ZW: nodeID | dataLength | pData[] | txOptions | funcID */ + /* ZW->HOST: RetVal */ + /* If RetVal == false -> no callback */ + /* If RetVal == true then callback returns with */ + /* ZW->HOST: funcID | txStatus | wTransmitTicksMSB | wTransmitTicksLSB | bRepeaters | rssi_values.incoming[0] | + * rssi_values.incoming[1] | rssi_values.incoming[2] | rssi_values.incoming[3] | rssi_values.incoming[4] | + * bRouteSchemeState | repeater0 | repeater1 | repeater2 | repeater3 | routespeed | + * bRouteTries | bLastFailedLink.from | bLastFailedLink.to | + * bUsedTxpower | bMeasuredNoiseFloor | bAckDestinationUsedTxPower | bDestinationAckMeasuredRSSI | + * bDestinationckMeasuredNoiseFloor */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + uint8_t dataLength = frame->payload[offset + 1]; + ASSERT(dataLength <= BUF_SIZE_RX); + if (dataLength > BUF_SIZE_RX) + { + dataLength = BUF_SIZE_RX; + } + + const uint8_t * const pSerInData = frame->payload + offset + 2; + funcID_ComplHandler_ZW_SendData = frame->payload[offset + 3 + dataLength]; + + // Create transmit frame package + const uint8_t retVal = SendData(nodeId, pSerInData, dataLength, frame->payload[offset + 2 + dataLength], + (funcID_ComplHandler_ZW_SendData) ? &ZCB_ComplHandler_ZW_SendData : NULL); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_SEND_DATA_EX +uint8_t funcID_ComplHandler_ZW_SendDataEx; + +/*====================== ComplHandler_ZW_SendDataEx ======================== +** Completion handler for ZW_SendDataEx +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_SendDataEx( + uint8_t txStatus, + TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ +{ + GenerateTxStatusRequest(FUNC_ID_ZW_SEND_DATA_EX, funcID_ComplHandler_ZW_SendDataEx, txStatus, txStatusReport); +} + +static uint8_t SendDataEx(uint16_t nodeID, uint8_t *pData, uint8_t dataLength, + uint8_t txOptions, uint8_t txSecOptions, uint8_t txOptions2, uint8_t secKeyType, + ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.SendDataEx.DestNodeId = nodeID, + .uTransmitParams.SendDataEx.TransmitSecurityOptions = txSecOptions, + .uTransmitParams.SendDataEx.TransmitOptions2 = txOptions2, + .uTransmitParams.SendDataEx.eKeyType = secKeyType, + .uTransmitParams.SendDataEx.FrameConfig.TransmitOptions = txOptions, + .uTransmitParams.SendDataEx.FrameConfig.Handle = pCallBack, + .uTransmitParams.SendDataEx.FrameConfig.iFrameLength = dataLength, + .eTransmitType = EZWAVETRANSMITTYPE_EX + }; + memcpy(&FramePackage.uTransmitParams.SendDataEx.FrameConfig.aFrame, pData, dataLength); + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_EX) +{ + /* HOST->ZW: nodeID | dataLength | pData[] | txOptions | txSecOptions | securityKey | txOptions2 | funcID */ + /* ZW->HOST: RetVal */ + /* If "RetVal != 1" -> no callback */ + /* If "RetVal == 1" and "funcID != 0" then callback returns with */ + /* ZW->HOST: funcID | txStatus | wTransmitTicksMSB | wTransmitTicksLSB | bRepeaters | rssi_values.incoming[0] | */ + /* rssi_values.incoming[1] | rssi_values.incoming[2] | rssi_values.incoming[3] | rssi_values.incoming[4] | */ + /* bRouteSchemeState | repeater0 | repeater1 | repeater2 | repeater3 | routespeed | */ + /* bRouteTries | bLastFailedLink.from | bLastFailedLink.to */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + uint8_t dataLength; + + dataLength = frame->payload[offset + 1]; + ASSERT(dataLength <= BUF_SIZE_RX); + if (dataLength > BUF_SIZE_RX) + { + dataLength = BUF_SIZE_RX; + } + funcID_ComplHandler_ZW_SendDataEx = frame->payload[offset + 6 + dataLength]; + + const uint8_t retVal = SendDataEx(nodeId, &frame->payload[offset + 2], dataLength, frame->payload[offset + 2 + dataLength], + frame->payload[offset + 3 + dataLength], frame->payload[offset + 5 + dataLength], + frame->payload[offset + 4 + dataLength], (funcID_ComplHandler_ZW_SendDataEx != 0) ? ZCB_ComplHandler_ZW_SendDataEx : NULL); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_SEND_DATA_MULTI || SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE +uint8_t funcID_ComplHandler_ZW_SendDataMulti; +#endif + +#if SUPPORT_ZW_SEND_DATA_MULTI +/*===================== ComplHandler_ZW_SendDataMulti ==================== +** Completion handler for ZW_SendDataMulti +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_SendDataMulti( + uint8_t txStatus, + __attribute__((unused)) TX_STATUS_TYPE *txStatusType) /* IN Transmit completion status */ +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendDataMulti; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_SEND_DATA_MULTI, compl_workbuf, 2); +} + +static uint8_t SendDataMulti(uint8_t numberOfNodes, const uint8_t *pNodeList, const uint8_t *pData, uint8_t dataLength, uint8_t txOptions, ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage; + SSendDataMulti *pSendDataMulti = &FramePackage.uTransmitParams.SendDataMulti; + memset(&pSendDataMulti->FrameConfig.aFrame, 0, sizeof(pSendDataMulti->FrameConfig.aFrame)); + /* clear the destination node mask */ + memset(&pSendDataMulti->NodeMask, 0, sizeof(pSendDataMulti->NodeMask)); + /* Set the destination node mask bits */ + for (uint8_t i = 0; i < numberOfNodes && i < MAX_GROUP_NODES; i++) + { + ZW_NodeMaskSetBit(pSendDataMulti->NodeMask, pNodeList[i]); + } + pSendDataMulti->FrameConfig.TransmitOptions = txOptions; + ASSERT(dataLength <= BUF_SIZE_RX); + if (dataLength > BUF_SIZE_RX) + { + dataLength = BUF_SIZE_RX; + } + memcpy(&pSendDataMulti->FrameConfig.aFrame, pData, dataLength); + pSendDataMulti->FrameConfig.Handle = pCallBack; + FramePackage.eTransmitType = EZWAVETRANSMITTYPE_MULTI; + FramePackage.uTransmitParams.SendDataMulti.FrameConfig.iFrameLength = dataLength; + + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_MULTI) +{ + /* numberNodes | pNodeIDList[] | dataLength | pData[] | txOptions | funcId */ + // Create transmit frame package + uint8_t numOfNodes = frame->payload[0]; + uint8_t tLength = frame->payload[1 + numOfNodes]; + uint8_t tOptions = frame->payload[2 + numOfNodes + tLength]; + funcID_ComplHandler_ZW_SendDataMulti = frame->payload[3 + numOfNodes + tLength]; + + const uint8_t retVal = SendDataMulti(numOfNodes, &frame->payload[1], &frame->payload[2 + numOfNodes], tLength, tOptions, + (funcID_ComplHandler_ZW_SendDataMulti != 0) ? &ZCB_ComplHandler_ZW_SendDataMulti : NULL); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_SEND_DATA_MULTI_EX +uint8_t funcID_ComplHandler_ZW_SendDataMultiEx; + +/*===================== ComplHandler_ZW_SendDataMulti ==================== +** Completion handler for ZW_SendDataMulti +** +**--------------------------------------------------------------------------*/ +static void +ZCB_ComplHandler_ZW_SendDataMultiEx( + uint8_t txStatus, /* IN Transmit completion status */ + __attribute__((unused)) TX_STATUS_TYPE* extendedTxStatus) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendDataMultiEx; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_SEND_DATA_MULTI_EX, compl_workbuf, 2); +} + +static uint8_t SendDataMultiEx(uint8_t dataLength, uint8_t *pData, uint8_t txOptions, uint8_t secKeyType, uint8_t groupID, ZW_TX_Callback_t pCallBack) +{ + ASSERT(dataLength <= BUF_SIZE_RX); + if (dataLength > BUF_SIZE_RX) + { + dataLength = BUF_SIZE_RX; + } + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.SendDataMultiEx.FrameConfig.Handle = pCallBack, + .uTransmitParams.SendDataMultiEx.FrameConfig.TransmitOptions = txOptions, + .uTransmitParams.SendDataMultiEx.FrameConfig.iFrameLength = dataLength, + .uTransmitParams.SendDataMultiEx.GroupId = groupID, + .uTransmitParams.SendDataMultiEx.eKeyType = secKeyType, + .eTransmitType = EZWAVETRANSMITTYPE_MULTI_EX + }; + memcpy(&FramePackage.uTransmitParams.SendDataMultiEx.FrameConfig.aFrame, pData, dataLength); + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_MULTI_EX) +{ + /* dataLength | pData[] | txOptions | securityKey | groupId | funcId */ + uint8_t dataLength = frame->payload[0]; + funcID_ComplHandler_ZW_SendDataMultiEx = frame->payload[4 + dataLength]; + uint8_t tOptions = frame->payload[1 + dataLength]; + uint8_t tGID = frame->payload[3 + dataLength]; + uint8_t tKey = frame->payload[2 + dataLength]; + + const uint8_t retVal = SendDataMultiEx(dataLength, &frame->payload[1], tOptions, tKey, tGID, (funcID_ComplHandler_ZW_SendDataMultiEx != 0) ? ZCB_ComplHandler_ZW_SendDataMultiEx : NULL); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_SEND_DATA_ABORT +static void SendDataAbort(void) +{ + // FIXME - we need to change the implementation of abort + // What makes sense? aborting based on frame context? + // We cant peek into FreeRtos queue... + // We could also reset the queue on abort. and stop any ongoing frame. + SZwaveCommandPackage CommandPackage = { .eCommandType = EZWAVECOMMANDTYPE_SEND_DATA_ABORT }; + // Put the package on queue (and DO wait for it, since there is no feedback to serial master) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&CommandPackage, 500); + + if (EQUEUENOTIFYING_STATUS_SUCCESS != QueueStatus) + { + DPRINT("Warning: Failed to To call ZW_SendDataAbort"); + } +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_ABORT) +{ + /* If we are in middle of transmitting an application frame then STOP the transmission as soon as possible. */ + SendDataAbort(); + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_ZW_SEND_DATA_BRIDGE +/*================= ComplHandler_ZW_SendData_Bridge ====================== +** Completion handler for ZW_SendData_Bridge +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_SendData_Bridge( + uint8_t txStatus, + TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ +{ + GenerateTxStatusRequest(FUNC_ID_ZW_SEND_DATA_BRIDGE, funcID_ComplHandler_ZW_SendData, txStatus, txStatusReport); +} + +static uint8_t SendDataBridge(uint16_t srcNode, uint16_t destNode, uint8_t dataLength, const uint8_t *pData, uint8_t txOptions, ZW_TX_Callback_t pCallBack) +{ + ASSERT(dataLength <= BUF_SIZE_RX); + if (dataLength > BUF_SIZE_RX) + { + dataLength = BUF_SIZE_RX; + } + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.SendDataBridge.FrameConfig.Handle = pCallBack, + .uTransmitParams.SendDataBridge.FrameConfig.TransmitOptions = txOptions, + .uTransmitParams.SendDataBridge.FrameConfig.iFrameLength = dataLength, + .uTransmitParams.SendDataBridge.DestNodeId = destNode, + .uTransmitParams.SendDataBridge.SourceNodeId = srcNode, + .eTransmitType = EZWAVETRANSMITTYPE_BRIDGE + }; + memcpy(&FramePackage.uTransmitParams.SendDataBridge.FrameConfig.aFrame, pData, dataLength); + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_BRIDGE) +{ + /* HOST->ZW: srcNodeID | destNodeID | dataLength | pData[] | txOptions | pRoute[4] | funcID */ + /* Devkit 6.0x pRoute[4] not used... Use [0,0,0,0] */ + uint8_t offset = 0; + node_id_t sourceNodeId; + node_id_t destNodeId; + sourceNodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + destNodeId = (node_id_t)GET_NODEID(&frame->payload[1 + offset], offset); + uint8_t dataLength = frame->payload[offset + 2]; + funcID_ComplHandler_ZW_SendData = frame->payload[offset + 3 + 1 + 4 + dataLength]; + uint8_t tOptions = frame->payload[offset + 3 + dataLength]; + const uint8_t retVal = SendDataBridge(sourceNodeId, destNodeId, dataLength, &frame->payload[offset + 3], tOptions, + (funcID_ComplHandler_ZW_SendData != 0) ? &ZCB_ComplHandler_ZW_SendData_Bridge : NULL); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE +/*================ ComplHandler_ZW_SendDataMulti_Bridge ================== +** Completion handler for ZW_SendDataMulti +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_SendDataMulti_Bridge( + uint8_t txStatus, /* IN Transmit completion status */ + __attribute__((unused)) TX_STATUS_TYPE* extendedTxStatus) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendDataMulti; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_SEND_DATA_MULTI_BRIDGE, compl_workbuf, 2); +} + +static uint8_t SendDataMultiBridge(node_id_t srcNode, uint8_t numOfNodes, uint8_t *pNodeIDList, + uint8_t dataLength, const uint8_t *pData, uint8_t txOptions, ZW_TX_Callback_t pCallBack) +{ + // when nodeIdBaseType is 2 then we handle the FramePackage.uTransmitParams.SendDataMultiBridge.NodeMask as node list + // when nodeIdBaseType is 1 then we handle the FramePackage.uTransmitParams.SendDataMultiBridge.NodeMask as node mask + // Create transmit frame package + ASSERT(dataLength <= BUF_SIZE_RX); + + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.SendDataMultiBridge.FrameConfig.Handle = pCallBack, + .uTransmitParams.SendDataMultiBridge.FrameConfig.TransmitOptions = txOptions, + .uTransmitParams.SendDataMultiBridge.FrameConfig.iFrameLength = dataLength, + .uTransmitParams.SendDataMultiBridge.SourceNodeId = srcNode, + .eTransmitType = EZWAVETRANSMITTYPE_MULTI_BRIDGE + }; + + memcpy(&FramePackage.uTransmitParams.SendDataMultiBridge.FrameConfig.aFrame, pData, dataLength); + + bool lr_list = false; + bool classic_list = false; + + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) { + /*if nodeIdBaseType 2 then we should check if the list contain lr only nodes or classic only nodes mixed list is not allowed*/ + if ((MULTICAST_NODE_LIST_SIZE>>1) < numOfNodes) { + /*maximum allowed nodes are 32 */ + numOfNodes = MULTICAST_NODE_LIST_SIZE>>1; + } + for (uint8_t i = 0; i < numOfNodes; i++) + { + node_id_t curNode = (node_id_t) (((node_id_t)pNodeIDList[i<<1] << 8) | // index = i *2 + (pNodeIDList[(i<<1) +1] & 0xFF)); // index = (i *2) +1 + + if ((LOWEST_LONG_RANGE_NODE_ID <= curNode) && (HIGHEST_LONG_RANGE_NODE_ID >= curNode)) { + lr_list = true; + } else { + classic_list = true; + } + if (lr_list && classic_list) { + /* mixed list we bail out*/ + return false; + } + } + if (lr_list) { + /*lr nodes are 16-bit and the list is in bytes then we copy 2 * numOfNodes*/ + memcpy(FramePackage.uTransmitParams.SendDataMultiBridge.NodeMask, pNodeIDList , numOfNodes * 2); + } + } else { + classic_list = true; + if (MAX_GROUP_NODES < numOfNodes) { + numOfNodes = MAX_GROUP_NODES; + } + } + + FramePackage.uTransmitParams.SendDataMultiBridge.lr_nodeid_list = lr_list; + if (classic_list) { + uint8_t tmpNode; + for (uint8_t i = 0; i < numOfNodes; i++) + { + // if the list of classic nodes then the node ID is located in the lsb bytes of the 16-bit nodeID list. + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) { + tmpNode = pNodeIDList[(i<<1) +1]; + } else { + /* Set the destination node mask bits */ + tmpNode = pNodeIDList[i]; + } + ZW_NodeMaskSetBit(FramePackage.uTransmitParams.SendDataMultiBridge.NodeMask, tmpNode); + } + } + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_DATA_MULTI_BRIDGE) +{ + /* HOST->ZW: srcNodeID | numberNodes | pNodeIDList[] | dataLength | pData[] | txOptions | funcId */ + uint8_t numberNodes; + uint8_t dataLength; + uint8_t txOptions; + uint8_t offset = 0; + node_id_t srcNodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + uint8_t nodeid_list_size; + + numberNodes = frame->payload[offset + 1]; + uint8_t *pNodeList = &frame->payload[offset + 2]; + + if (nodeIdBaseType == SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT) { + nodeid_list_size = numberNodes * 2; + } else { + nodeid_list_size = numberNodes; + } + + dataLength = frame->payload[offset + 2 + nodeid_list_size]; + txOptions = frame->payload[offset + 2 + 1 + nodeid_list_size + dataLength]; + funcID_ComplHandler_ZW_SendDataMulti = frame->payload[offset + 2 + 1 + 1 + nodeid_list_size + dataLength]; + uint8_t *pDataBuf = &frame->payload[offset + 3 + nodeid_list_size]; + + const uint8_t retVal = SendDataMultiBridge(srcNodeId, numberNodes, pNodeList, + dataLength, pDataBuf, txOptions, + (funcID_ComplHandler_ZW_SendDataMulti != 0) ? &ZCB_ComplHandler_ZW_SendDataMulti_Bridge : NULL); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_MEMORY_GET_ID +ZW_ADD_CMD(FUNC_ID_MEMORY_GET_ID) +{ + uint8_t i = 0; + node_id_t node_id; + uint32_t home_id; + + node_id = ZAF_GetNodeID(); + home_id = ZAF_GetHomeID(); + + /* */ + compl_workbuf[i++] = (uint8_t) ((home_id & 0xff000000) >> 24); + compl_workbuf[i++] = (uint8_t) ((home_id & 0x00ff0000) >> 16); + compl_workbuf[i++] = (uint8_t) ((home_id & 0x0000ff00) >> 8); + compl_workbuf[i++] = (uint8_t) (home_id & 0x000000ff); + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + // 16 bit nodeID + compl_workbuf[i++] = (uint8_t)(node_id >> 8); // MSB(16bit) + } + compl_workbuf[i++] = (uint8_t)(node_id & 0xFF); // LSB(16bit)/8bit + DoRespond_workbuf(i); +} +#endif + + +#if SUPPORT_MEMORY_GET_BYTE +ZW_ADD_CMD(FUNC_ID_MEMORY_GET_BYTE) +{ + /* offset (MSB) | offset (LSB) */ + uint8_t retVal = 0; + if ((FRAME_LENGTH_MIN + 2) < frame->len) + { + uint16_t offset = ((uint16_t)(frame->payload[0] << 8)) + frame->payload[1]; + if (! SerialApiNvmReadAppData(offset, &retVal, 1)) + { + retVal = 0; + } + } + DoRespond(retVal); +} +#endif + + +#if SUPPORT_MEMORY_PUT_BYTE +ZW_ADD_CMD(FUNC_ID_MEMORY_PUT_BYTE) +{ + uint8_t retVal = 0; + if ((FRAME_LENGTH_MIN + 3) < frame->len) + { + uint16_t offset = ((uint16_t)(frame->payload[0] << 8)) + frame->payload[1]; + retVal = SerialApiNvmWriteAppData(offset, &frame->payload[2], 1); + } + DoRespond(retVal); +} +#endif + + +#if SUPPORT_MEMORY_GET_BUFFER +ZW_ADD_CMD(FUNC_ID_MEMORY_GET_BUFFER) +{ + uint8_t dataLength = 0; + dataLength = frame->payload[2]; + /* Make sure the length isn't larger than the available buffer size */ + if (dataLength > (uint8_t)BUF_SIZE_TX) + { + dataLength = (uint8_t)BUF_SIZE_TX; + } + uint16_t offset = ((uint16_t)(frame->payload[0] << 8)) + frame->payload[1]; + if (!SerialApiNvmReadAppData(offset, compl_workbuf, dataLength)) + { + dataLength = 0; + } + DoRespond_workbuf(dataLength); +} +#endif + + +#if SUPPORT_MEMORY_PUT_BUFFER +uint8_t funcID_ComplHandler_MemoryPutBuffer; + +/*===================== ComplHandler_MemoryPutBuffer ============= +** Completion handler for MemoryPutBuffer +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_MemoryPutBuffer(void) /* IN Nothing */ +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_MemoryPutBuffer; + Request(FUNC_ID_MEMORY_PUT_BUFFER, compl_workbuf, 1); +} + +ZW_ADD_CMD(FUNC_ID_MEMORY_PUT_BUFFER) +{ + /* HOST->ZW: + offset(MSB) offset into host application NVM memory array + offset(LSB) + length(MSB) desired length of write operation + length(LSB) + buffer[] buffer + funcID + */ + /* ZW->HOST: + retVal [retVal=0 ==> error| + retVal=1 ==> OK (NVM no change)| + retVal>=2 ==> OK (NVM data bytes written + 1)] + */ + uint16_t length; + uint8_t retVal = 0; + ///* Ignore if frame has no data to write */ + length = ((uint16_t)(frame->payload[2] << 8)) + frame->payload[3]; + /* Ignore write if length exceeds specified data-array */ + if (length < BUF_SIZE_RX ) + { + /* ignore request if length is larger than available buffer */ + if (length < BUF_SIZE_RX) + { + const uint8_t * const pSerInData = frame->payload + 4; + uint16_t offset = ((uint16_t)(frame->payload[0] << 8)) + frame->payload[1]; + retVal = SerialApiNvmWriteAppData(offset, pSerInData, length); + } + } + DoRespond(retVal); + funcID_ComplHandler_MemoryPutBuffer = frame->payload[4 + length]; + if ((0 != retVal) && (0 != funcID_ComplHandler_MemoryPutBuffer) ) + { + ZCB_ComplHandler_MemoryPutBuffer(); + } +} +#endif + + +#if SUPPORT_NVM_BACKUP_RESTORE +ZW_ADD_CMD(FUNC_ID_NVM_BACKUP_RESTORE) +{ + uint8_t length = 0; + func_id_serial_api_nvm_backup_restore(frame_payload_len(frame), frame->payload, compl_workbuf, &length); + DoRespond_workbuf(length); +} +#endif + + +#if SUPPORT_NVM_GET_ID +ZW_ADD_CMD(FUNC_ID_NVM_GET_ID) +{ +} +#endif + + +#if SUPPORT_NVM_EXT_READ_LONG_BYTE +ZW_ADD_CMD(FUNC_ID_NVM_EXT_READ_LONG_BYTE) +{ + /* HOST->ZW: offset3byte(MSB) | offset3byte | offset3byte(LSB) */ + /* ZW->HOST: dataread */ + uint8_t retVal = 0; + if ((FRAME_LENGTH_MIN + 2) < frame->len) + { + uint32_t offset = (((uint32_t)frame->payload[0] << 16) + ((uint32_t)((uint16_t)frame->payload[1] << 8)) + frame->payload[2]); + if (! SerialApiNvmReadAppData(offset, &retVal, 1)) + { + retVal = 0; + } + } + DoRespond(retVal); +} +#endif + + +#if SUPPORT_NVM_EXT_WRITE_LONG_BYTE +ZW_ADD_CMD(FUNC_ID_NVM_EXT_WRITE_LONG_BYTE) +{ + /* HOST->ZW: offset3byte(MSB) | offset3byte | offset3byte(LSB) | data */ + /* ZW->HOST: writestatus */ + uint8_t retVal = 0; + if ((FRAME_LENGTH_MIN + 3) < frame->len) + { + uint32_t offset = (((uint32_t)frame->payload[0] << 16) + ((uint32_t)((uint16_t)frame->payload[1] << 8)) + frame->payload[2]); + const uint8_t retVal = SerialApiNvmWriteAppData(offset, &frame->payload[3], 1); + } + DoRespond(retVal); +} +#endif + + +#if SUPPORT_NVM_EXT_READ_LONG_BUFFER +ZW_ADD_CMD(FUNC_ID_NVM_EXT_READ_LONG_BUFFER) +{ + /* HOST->ZW: offset3byte(MSB) | offset3byte | offset3byte(LSB) | length2byte(MSB) | length2byte(LSB) */ + /* ZW->HOST: data[] */ + uint16_t dataLength = 0; + ///* Ignore if frame is to short */ + if ((FRAME_LENGTH_MIN + 3 + 1) < frame->len) + { + dataLength = ((uint16_t)(frame->payload[3] << 8)) + frame->payload[4]; + /* Make sure the length isn't larger than the available buffer size */ + if (dataLength > (uint8_t)BUF_SIZE_TX) + { + dataLength = (uint8_t)BUF_SIZE_TX; + } + uint32_t offset = (((uint32_t)frame->payload[0] << 16) + ((uint32_t)((uint16_t)frame->payload[1] << 8)) + frame->payload[2]); + if (!SerialApiNvmReadAppData(offset, compl_workbuf, dataLength)) + { + dataLength = 0; + } + } + DoRespond_workbuf((uint8_t)dataLength); +} +#endif + + +#if SUPPORT_NVM_EXT_WRITE_LONG_BUFFER +ZW_ADD_CMD(FUNC_ID_NVM_EXT_WRITE_LONG_BUFFER) +{ + /* HOST->ZW: offset3byte(MSB) | offset3byte | offset2byte(LSB) | length2byte(MSB) | length2byte(LSB) | buffer[] */ + /* ZW->HOST: retVal */ + uint16_t length; + uint8_t retVal = 0; + ///* Ignore if frame has no data to write */ + if ((FRAME_LENGTH_MIN + 5) < frame->len) + { + length = ((uint16_t)(frame->payload[3] << 8)) + frame->payload[4]; + /* Ignore write if length exceeds specified data-array */ + if (length <= frame->len - FRAME_LENGTH_MIN) + { + /* ignore request if length is larger than available buffer */ + if (length < BUF_SIZE_RX) + { + const uint8_t * const pSerInData = frame->payload + 5; + uint32_t offset = (((uint32_t)frame->payload[0] << 16) + ((uint32_t)((uint16_t)frame->payload[1] << 8)) + frame->payload[2]); + const uint8_t retVal = SerialApiNvmWriteAppData(offset, pSerInData, length); + } + } + } + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_NVR_GET_VALUE +ZW_ADD_CMD(FUNC_ID_NVR_GET_VALUE) +{ + /* HOST->ZW: offset | length */ + /* ZW->HOST: NVRdata[] */ + uint8_t dataLength = 0; + /* Ignore if frame is too short */ + if ((FRAME_LENGTH_MIN + 1) < frame->len) + { + /*inputLength paramter is nout used*/ + func_id_serial_api_get_nvr(0, frame->payload, compl_workbuf, &dataLength); + } + DoRespond_workbuf(dataLength); +} +#endif + + +#if SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET +ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET) +{ + DoRespond(0); +} +#endif + + +#if defined(ZW_SLAVE_ROUTING) || defined(ZW_CONTROLLER) +uint8_t funcID_ComplHandler_netWork_Management; +uint8_t management_Func_ID; + +/*===================== ComplHandler_ZW_netWork_Management =============== +** Completion handler for the network management functionality +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_netWork_Management( + uint8_t bStatus, /* IN Transmit completion status */ + TX_STATUS_TYPE *txStatusReport) /* IN Detailed transmit information */ +{ + uint8_t bIdx = 0; + BYTE_IN_AR(compl_workbuf, bIdx++) = funcID_ComplHandler_netWork_Management; + BYTE_IN_AR(compl_workbuf, bIdx++) = bStatus; + if (bTxStatusReportEnabled && txStatusReport) /* Check if detailed info is available from protocol */ + { + memcpy(&compl_workbuf[bIdx], (uint8_t *)txStatusReport, sizeof(TX_STATUS_TYPE)); + bIdx += sizeof(TX_STATUS_TYPE); + } + Request(management_Func_ID, compl_workbuf, bIdx); +} +#endif /*ZW_SLAVE_32 ZW_CONTROLLER*/ + + +#if SUPPORT_ZW_REQUEST_NETWORK_UPDATE +static uint8_t RequestNetworkUpdate(ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .eTransmitType = EZWAVETRANSMITTYPE_NETWORKUPDATEREQUEST, + .uTransmitParams.NetworkUpdateRequest.Handle = (ZW_Void_Callback_t)pCallBack + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_REQUEST_NETWORK_UPDATE) +{ + /* funcID */ + funcID_ComplHandler_netWork_Management = frame->payload[0]; + management_Func_ID = frame->cmd; + const uint8_t retVal = RequestNetworkUpdate((frame->payload[0] != 0) ? &ZCB_ComplHandler_ZW_netWork_Management : NULL); + DoRespond(retVal); +} +#endif /* SUPPORT_ZW_REQUEST_NETWORK_UPDATE */ + + +#if SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE +uint8_t funcID_ComplHandler_ZW_RequestNodeNeighborUpdate; + +/*=============== ComplHandler_ZW_RequestNodeNeighborUpdate =============== +** Completion handler for ZW_REQUEST_NODE_NEIGHBOR_UPDATE +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_RequestNodeNeighborUpdate( + uint8_t txStatus, /* IN Transmit completion status */ + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_RequestNodeNeighborUpdate; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE, compl_workbuf, 2); +} + +static uint8_t RequestNodeNeighborUpdate(uint16_t nodeID, ZW_TX_Callback_t pCallBack) +{ + + SZwaveCommandPackage Request = { + .eCommandType = EZWAVECOMMANDTYPE_REQUESTNODENEIGHBORUPDATE, + .uCommandParams.RequestNodeNeighborUpdate.NodeId = nodeID, + .uCommandParams.RequestNodeNeighborUpdate.Handle = (ZW_Void_Callback_t)pCallBack}; + + // Put the Command on queue (and dont wait for it, queue must be empty) + if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Request, 0)) + { + // Wait for protocol to handle command + SZwaveCommandStatusPackage status = { 0 }; + if (GetCommandResponse(&status, EZWAVECOMMANDSTATUS_ZW_REQUESTNODENEIGHBORUPDATE)) + { + return status.Content.RequestNodeNeigborUpdateStatus.result; + } + } + return false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_REQUEST_NODE_NEIGHBOR_UPDATE) +{ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + + funcID_ComplHandler_ZW_RequestNodeNeighborUpdate = frame->payload[1 + offset]; + + // Put the package on queue (and dont wait for it) + if (!RequestNodeNeighborUpdate(nodeId, + funcID_ComplHandler_ZW_RequestNodeNeighborUpdate ? &ZCB_ComplHandler_ZW_RequestNodeNeighborUpdate : NULL)) + { + ZCB_ComplHandler_ZW_RequestNodeNeighborUpdate(REQUEST_NEIGHBOR_UPDATE_FAILED, NULL); + } + set_state_and_notify(stateIdle); +} + +uint8_t funcID_ComplHandler_ZW_RequestNodeTypeNeighborUpdate; + +/*=============== ComplHandler_ZW_RequestNodeTypeNeighborUpdate =============== +** Completion handler for ZW_REQUEST_NODE_NEIGHBOR_UPDATE +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_RequestNodeTypeNeighborUpdate( + uint8_t txStatus, /* IN Transmit completion status */ + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_RequestNodeTypeNeighborUpdate; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_REQUEST_NODETYPE_NEIGHBOR_UPDATE, compl_workbuf, 2); +} + +static uint8_t RequestNodeTypeNeighborUpdate(uint16_t nodeID, uint8_t nodeType, ZW_TX_Callback_t pCallBack) +{ + + SZwaveCommandPackage Request = { + .eCommandType = EZWAVECOMMANDTYPE_REQUESTNODETYPE_NEIGHBORUPDATE, + .uCommandParams.RequestNodeTypeNeighborUpdate.NodeId = nodeID, + .uCommandParams.RequestNodeTypeNeighborUpdate.NodeType = nodeType, + .uCommandParams.RequestNodeTypeNeighborUpdate.Handle = (ZW_Void_Callback_t)pCallBack}; + + // Put the Command on queue (and dont wait for it, queue must be empty) + if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Request, 0)) + { + // Wait for protocol to handle command + SZwaveCommandStatusPackage status = { 0 }; + if (GetCommandResponse(&status, EZWAVECOMMANDSTATUS_ZW_REQUESTNODETYPE_NEIGHBORUPDATE)) + { + return status.Content.RequestNodeTypeNeigborUpdateStatus.result; + } + } + return false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_REQUEST_NODETYPE_NEIGHBOR_UPDATE) +{ + uint8_t offset = 0; + E_SYSTEM_TYPE nodeType = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + nodeType = frame->payload[1 + offset]; + ++offset; + + funcID_ComplHandler_ZW_RequestNodeTypeNeighborUpdate = frame->payload[1 + offset]; + + // Put the package on queue (and dont wait for it) + if (!RequestNodeTypeNeighborUpdate(nodeId, nodeType, + funcID_ComplHandler_ZW_RequestNodeTypeNeighborUpdate ? &ZCB_ComplHandler_ZW_RequestNodeTypeNeighborUpdate : NULL)) + { + ZCB_ComplHandler_ZW_RequestNodeTypeNeighborUpdate(REQUEST_NEIGHBOR_UPDATE_FAILED, NULL); + } + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_ZW_GET_NODE_PROTOCOL_INFO +ZW_ADD_CMD(FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO) +{ + /* bNodeID */ + volatile uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + GetNodeInfo(nodeId, (t_ExtNodeInfo *)compl_workbuf); + STATIC_ASSERT(sizeof(t_ExtNodeInfo) == 7, STATIC_ASSERT_FAILED_size_mismatch); + DoRespond_workbuf(7); +} +#endif + + +#if SUPPORT_ZW_SET_DEFAULT +uint8_t funcID_ComplHandler_ZW_SetDefault; + +/*===================== ComplHandler_ZW_SetDefault ============= +** Completion handler for ZW_SetDefault +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_SetDefault(void) /* IN Nothing */ +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SetDefault; + Request(FUNC_ID_ZW_SET_DEFAULT, compl_workbuf, 1); +} + +static void SetDefault(ZW_Void_Callback_t pCallBack) +{ + /* funcID */ + SyncEventUnbind(&SetDefaultCB); + if (0 != pCallBack) + { + SyncEventBind(&SetDefaultCB, pCallBack); + } + SZwaveCommandPackage CommandPackage = { .eCommandType = EZWAVECOMMANDTYPE_SET_DEFAULT }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&CommandPackage, 500); + if (EQUEUENOTIFYING_STATUS_SUCCESS != QueueStatus) + { + DPRINT("Warning: Failed to perform SetDefault"); + } +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_DEFAULT) +{ + /* funcID */ + funcID_ComplHandler_ZW_SetDefault = frame->payload[0]; + SetDefault((0 != funcID_ComplHandler_ZW_SetDefault) ? &ZCB_ComplHandler_ZW_SetDefault : NULL); + set_state_and_notify(stateIdle); +} +#endif + +#ifdef ZW_CONTROLLER +/*======================= ComplHandler_ZW_NodeManagement ================= +** Completion handler for ZW_AddNodeToNetwork, ZW_RemoveNodeFromNetwork +** ZW_CreateNewPrimary, ZW_ControllerChange and ZW_SetLearnMode for +** controller based applications +** +**--------------------------------------------------------------------------*/ + +void /* RET Nothing */ +ZCB_ComplHandler_ZW_NodeManagement( + LEARN_INFO_T *statusInfo) +{ + if (0 == funcID_ComplHandler_ZW_NodeManagement) + { + return; + } + + uint8_t offset = 0; + addState = (*statusInfo).bStatus; + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_NodeManagement; + BYTE_IN_AR(compl_workbuf, 1) = (*statusInfo).bStatus; + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)((*statusInfo).bSource >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 3) = (uint8_t)((*statusInfo).bSource & 0xFF); // LSB + offset++; // 16 bit nodeID means the command fields that follow are offset by one byte + } + else + { + BYTE_IN_AR(compl_workbuf, 2) = (uint8_t)((*statusInfo).bSource & 0xFF); // Legacy 8 bit nodeID + } + /* - Buffer boundary check */ + if ((*statusInfo).bLen > (uint8_t)(BUF_SIZE_TX - (offset + 4))) + { + (*statusInfo).bLen = (uint8_t)(BUF_SIZE_TX - (offset + 4)); + } + BYTE_IN_AR(compl_workbuf, offset + 3) = (*statusInfo).bLen; + for (uint8_t i = 0; i < (*statusInfo).bLen; i++) + { + BYTE_IN_AR(compl_workbuf, offset + 4 + i) = (*statusInfo).pCmd[i]; + } + Request(nodeManagement_Func_ID, compl_workbuf, (uint8_t)(offset + (*statusInfo).bLen + 4)); +} + +bool ZW_NodeManagementRunning(void) +{ + return (addState == ADD_NODE_STATUS_NODE_FOUND || + addState == ADD_NODE_STATUS_ADDING_SLAVE || + addState == ADD_NODE_STATUS_ADDING_CONTROLLER); +} +#endif + + +#if SUPPORT_ZW_ADD_NODE_TO_NETWORK +static void AddNodeToNetwork(uint8_t mode, void (*pCallBack)(LEARN_INFO_T *statusInfo)) +{ + SZwaveCommandPackage pCmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_ADD_NODE_TO_NETWORK, + .uCommandParams.NetworkManagement.mode = mode, + .uCommandParams.NetworkManagement.pHandle = (ZW_Void_Callback_t)pCallBack + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); +} + +static void AddNodeDskToNetwork(uint8_t mode, const uint8_t* pDsk, void (*pCallBack)(LEARN_INFO_T *statusInfo)) +{ + SZwaveCommandPackage pCmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_ADD_NODE_DSK_TO_NETWORK, + .uCommandParams.NetworkManagementDSK.mode = mode, + .uCommandParams.NetworkManagementDSK.pHandle = (ZW_Void_Callback_t)pCallBack + }; + memcpy(&pCmdPackage.uCommandParams.NetworkManagementDSK.dsk[0], pDsk, 8); + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); +} + +ZW_ADD_CMD(FUNC_ID_ZW_ADD_NODE_TO_NETWORK) +{ + /* HOST->ZW: mode | funcID */ + /* HOST->ZW: mode = 0x07 | funcID | DSK[0] | DSK[1] | DSK[2] | DSK[3] | DSK[4] | DSK[5] | DSK[6] | DSK[7] */ + if (ZW_NodeManagementRunning() && ((frame->payload[0] & ADD_NODE_MODE_MASK) != ADD_NODE_STOP)) + { + // A previous node management request is still in progress. Drop this request and go back to idle state. + set_state_and_notify(stateIdle); + return; + } + SetupNodeManagement(frame, 1); + if ((frame->payload[0] & ADD_NODE_MODE_MASK) == ADD_NODE_HOME_ID) + { + AddNodeDskToNetwork(frame->payload[0], + &frame->payload[2], + (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); + } + else + { + AddNodeToNetwork(frame->payload[0], + (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); + } +} +#endif + +#if defined (SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK) && (SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK == 1) +static void RemoveNodeFromNetwork(uint8_t mode, node_id_t node_id, void (*pCallBack)(LEARN_INFO_T *statusInfo)) +{ + SZwaveCommandPackage pCmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_REMOVE_NODE_FROM_NETWORK, + .uCommandParams.NetworkManagement.mode = mode, + .uCommandParams.NetworkManagement.pHandle = (ZW_Void_Callback_t)pCallBack + }; + + if (0 != node_id) { + pCmdPackage.eCommandType = EZWAVECOMMANDTYPE_REMOVE_NODEID_FROM_NETWORK; + pCmdPackage.uCommandParams.NetworkManagement.nodeID = node_id; + } + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + +} +#endif + +#if SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK +ZW_ADD_CMD(FUNC_ID_ZW_REMOVE_NODE_FROM_NETWORK) +{ + /* HOST->ZW: mode | funcID */ + if (ZW_NodeManagementRunning()) + { + // A previous node management request is still in progress. Drop this request and go back to idle state. + set_state_and_notify(stateIdle); + return; + } + SetupNodeManagement(frame, 1); + RemoveNodeFromNetwork(frame->payload[0], 0, + (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); +} +#endif + + +#ifdef ZW_CONTROLLER +ZW_ADD_CMD(FUNC_ID_ZW_REMOVE_NODE_ID_FROM_NETWORK) +{ + /* HOST->ZW: mode | nodeID | funcID */ + uint8_t offset = 0; + uint16_t nodeId = (uint16_t)GET_NODEID(&frame->payload[1], offset); + if (ZW_NodeManagementRunning()) + { + // A previous node management request is still in progress. Drop this request and go back to idle state. + set_state_and_notify(stateIdle); + return; + } + SetupNodeManagement(frame, offset + 2); + + RemoveNodeFromNetwork(frame->payload[0], nodeId, + (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); +} +#endif + + +#if SUPPORT_ZW_CONTROLLER_CHANGE +static void ControllerChange(uint8_t mode, void (*pCallBack)(LEARN_INFO_T *statusInfo)) +{ + SZwaveCommandPackage pCmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_CONTROLLER_CHANGE, + .uCommandParams.NetworkManagement.mode = mode, + .uCommandParams.NetworkManagement.pHandle = (ZW_Void_Callback_t)pCallBack}; + + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&pCmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); +} + +ZW_ADD_CMD(FUNC_ID_ZW_CONTROLLER_CHANGE) +{ + /* HOST->ZW: mode | funcID */ + if (ZW_NodeManagementRunning()) + { + // A previous node management request is still in progress. Drop this request and go back to idle state. + set_state_and_notify(stateIdle); + return; + } + SetupNodeManagement(frame, 1); + ControllerChange(frame->payload[0], + (funcID_ComplHandler_ZW_NodeManagement != 0) ? &ZCB_ComplHandler_ZW_NodeManagement : NULL); +} +#endif + + +#if SUPPORT_ZW_SET_LEARN_MODE +#ifdef ZW_SLAVE +uint8_t funcID_ComplHandler_ZW_SetLearnMode; + +/*========================= ComplHandler_ZW_SetLearnMode ================= +** Completion handler for ZW_SetLearnMode +** +**--------------------------------------------------------------------------*/ +static void /*RET Nothing */ +ZCB_ComplHandler_ZW_SetLearnMode( + uint32_t bStatus) /*IN ZW_SetLearnMode status */ +{ + uint8_t i = 0; + node_id_t node_id; + + node_id = ZAF_GetNodeID(); + BYTE_IN_AR(compl_workbuf, i++) = funcID_ComplHandler_ZW_SetLearnMode; + BYTE_IN_AR(compl_workbuf, i++) = (uint8_t)bStatus; + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, i++) = (uint8_t)(node_id >> 8); // MSB 16bit node Id + } + BYTE_IN_AR(compl_workbuf, i++) = (uint8_t)(node_id & 0xFF); // LSB(16bit)/Legacy 8 bit node Id + /* For safty we transmit len = 0, to indicate that no data follows */ + BYTE_IN_AR(compl_workbuf, i++) = 0; + Request(FUNC_ID_ZW_SET_LEARN_MODE, compl_workbuf, i); +} +#endif /* ZW_SLAVE */ + +#ifdef ZW_CONTROLLER +static void ZCB_ZW_NodeManagementLearnStatusRelay(uint32_t Status) +{ + node_id_t node_id; + + node_id = ZAF_GetNodeID(); + + LEARN_INFO_T Info = { + .bStatus = (uint8_t)Status, + .bSource = node_id, + 0}; + + ZCB_ComplHandler_ZW_NodeManagement(&Info); +} +#endif /* ZW_CONTROLLER */ + +static uint8_t NetworkLearnModeStart( E_NETWORK_LEARN_MODE_ACTION eLearnMode) +{ + SZwaveCommandPackage learnModeStart = { + .eCommandType = EZWAVECOMMANDTYPE_NETWORK_LEARN_MODE_START, + .uCommandParams.SetSmartStartLearnMode.eLearnMode = eLearnMode}; + // Put the Command on queue (and dont wait for it, queue must be empty) + if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&learnModeStart, 0)) + { + // Wait for protocol to handle command + SZwaveCommandStatusPackage result = { 0 }; + if (GetCommandResponse(&result, EZWAVECOMMANDSTATUS_NETWORK_LEARN_MODE_START)) + { + return result.Content.NetworkManagementStatus.statusInfo[0]; + } + } + return false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_LEARN_MODE) +{ + /* HOST->ZW: mode | funcID */ + /* ZW->HOST: retVal */ + uint8_t retVal = 1; +#ifdef ZW_CONTROLLER + SetupNodeManagement(frame, 1); +#endif /* ZW_CONTROLLER */ +#ifdef ZW_SLAVE + funcID_ComplHandler_ZW_SetLearnMode = frame->payload[1]; +#endif +#ifdef ZW_CONTROLLER_SINGLE + SyncEventArg1Unbind(&LearnModeStatusCb); + if (frame->payload[1] != 0) + { + SyncEventArg1bind(&LearnModeStatusCb, ZCB_ZW_NodeManagementLearnStatusRelay); + } + SZwaveCommandPackage Command = { + .eCommandType = EZWAVECOMMANDTYPE_SET_LEARN_MODE, + .uCommandParams.SetLearnMode.eLearnMode = frame->payload[0], + .uCommandParams.SetLearnMode.useCB = frame->payload[1] != 0 + }; + QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); + +#else + SyncEventArg1Unbind(&LearnModeStatusCb); + if (frame->payload[1] != 0) + { +#ifdef ZW_CONTROLLER + SyncEventArg1Bind(&LearnModeStatusCb, ZCB_ZW_NodeManagementLearnStatusRelay); +#endif +#ifdef ZW_SLAVE + SyncEventArg1Bind(&LearnModeStatusCb, ZCB_ComplHandler_ZW_SetLearnMode); +#endif + } + + if (SERIALPI_SET_LEARN_MODE_LEARN_PLUS_OFFSET > frame->payload[0]) + { + /* Plain ZW_SetLearnMode */ + /* ZW_SET_LEARN_MODE_DISABLE 0x00 */ + /* ZW_SET_LEARN_MODE_CLASSIC 0x01 */ + /* ZW_SET_LEARN_MODE_NWI 0x02 */ + /* ZW_SET_LEARN_MODE_NWE 0x03 */ + SZwaveCommandPackage Command = { + .eCommandType = EZWAVECOMMANDTYPE_SET_LEARN_MODE, + .uCommandParams.SetLearnMode.eLearnMode = frame->payload[0], + .uCommandParams.SetLearnMode.useCB = frame->payload[1] != 0 + }; + QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); + } + else + { + /* HOST want to use Network Management for inclusion/exclusion */ + /* We need to substract the SERIALPI_SET_LEARN_MODE_LEARN_PLUS_OFFSET to get: */ + /* E_NETWORK_LEARN_MODE_DISABLE = 0, Disable learn process */ + /* E_NETWORK_LEARN_MODE_INCLUSION = 1, Enable the learn process to do an inclusion */ + /* E_NETWORK_LEARN_MODE_EXCLUSION = 2, Enable the learn process to do an exclusion */ + /* E_NETWORK_LEARN_MODE_EXCLUSION_NWE = 3 Enable the learn process to do a network wide exclusion */ + /* E_NETWORK_LEARN_MODE_INCLUSION_SMARTSTART = 4 Enable the learn process to initiate SMARTSTART inclusion */ + retVal = NetworkLearnModeStart(frame->payload[0] - SERIALPI_SET_LEARN_MODE_LEARN_PLUS_OFFSET); + } +#endif /* ZW_CONTROLLER_SINGLE */ + DoRespond(retVal); +} +#endif /* SUPPORT_ZW_SET_LEARN_MODE */ + + +#if SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION +static uint8_t ExploreRequestInclusion(void) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .eTransmitType = EZWAVETRANSMITTYPE_EXPLOREINCLUSIONREQUEST + }; + + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_EXPLORE_REQUEST_INCLUSION) +{ + const uint8_t retVal = ExploreRequestInclusion(); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION +static uint8_t ExploreRequestExclusion(void) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .eTransmitType = EZWAVETRANSMITTYPE_EXPLOREEXCLUSIONREQUEST + }; + + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_EXPLORE_REQUEST_EXCLUSION) +{ + const uint8_t retVal = ExploreRequestExclusion(); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE +static void ReplicationComplete(void) +{ + /* */ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .eTransmitType = EZWAVETRANSMITTYPE_SENDREPLICATIONRECEIVECOMPLETE + }; + // Put the package on queue (and dont wait for it) + QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); +} + +ZW_ADD_CMD(FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE) +{ + ReplicationComplete(); + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_ZW_REPLICATION_SEND_DATA +uint8_t funcID_ComplHandler_ZW_ReplicationSendData; + +/*===================== ComplHandler_ZW_ReplicationSendData ============= +** Completion handler for ZW_ReplicationSendData +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_ReplicationSendData( + uint8_t txStatus, __attribute__((unused)) TX_STATUS_TYPE* extendedTxStatus) /* IN Transmit completion status */ +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_ReplicationSendData; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_REPLICATION_SEND_DATA, compl_workbuf, 2); +} + +static uint8_t ReplicationSendData(uint16_t nodeID, uint8_t dataLength, const uint8_t* pData, uint8_t txOptions, ZW_TX_Callback_t pCallBack) +{ + ASSERT(dataLength <= BUF_SIZE_RX); + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.SendReplication.DestNodeId = nodeID, + .uTransmitParams.SendReplication.FrameConfig.TransmitOptions = txOptions, + .uTransmitParams.SendReplication.FrameConfig.Handle = pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_SENDREPLICATION, + .uTransmitParams.SendReplication.FrameConfig.iFrameLength = dataLength + }; + memcpy(&FramePackage.uTransmitParams.SendReplication.FrameConfig.aFrame, pData, dataLength); + + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_REPLICATION_SEND_DATA) +{ + /* nodeID | dataLength | pData[] | txOptions | funcID */ + uint8_t dataLength; + uint8_t txOptions; + uint8_t offset = 0; + node_id_t nodeID; + nodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); + dataLength = frame->payload[offset + 1]; + txOptions = frame->payload[offset + 2 + dataLength]; + funcID_ComplHandler_ZW_ReplicationSendData = frame->payload[offset + 3 + dataLength]; + const uint8_t retVal = ReplicationSendData(nodeID, dataLength, &frame->payload[offset + 2], txOptions, + (funcID_ComplHandler_ZW_ReplicationSendData != 0) ? &ZCB_ComplHandler_ZW_ReplicationSendData : NULL ); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_ASSIGN_RETURN_ROUTE +uint8_t funcID_ComplHandler_ZW_AssignReturnRoute; + +/*===================== ComplHandler_ZW_AssignReturnRoute ============= +** Completion handler for ZW_AssignReturnRoute +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_AssignReturnRoute( + uint8_t bStatus, + TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ +{ + uint8_t bIdx = 0; + BYTE_IN_AR(compl_workbuf, bIdx++) = funcID_ComplHandler_ZW_AssignReturnRoute; + BYTE_IN_AR(compl_workbuf, bIdx++) = bStatus; + if (bTxStatusReportEnabled && txStatusReport) /* Check if detailed info is available from protocol */ + { + memcpy(&compl_workbuf[bIdx], (uint8_t *)txStatusReport, sizeof(TX_STATUS_TYPE)); + bIdx += sizeof(TX_STATUS_TYPE); + } + Request(FUNC_ID_ZW_ASSIGN_RETURN_ROUTE, compl_workbuf, bIdx); +} + +static uint8_t AssignReturnRoute(uint16_t srcNode, uint16_t destNode, ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.AssignReturnRoute.ReturnRouteReceiverNodeId = srcNode, + .uTransmitParams.AssignReturnRoute.RouteDestinationNodeId = destNode, + .uTransmitParams.AssignReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_ASSIGNRETURNROUTE + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_ASSIGN_RETURN_ROUTE) +{ + /* srcNodeID | destNodeID | funcID */ + uint8_t offset = 0; + node_id_t srcNodeID; + node_id_t destNodeID; + srcNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); + destNodeID = (node_id_t)GET_NODEID(&frame->payload[1 + offset], offset); + funcID_ComplHandler_ZW_AssignReturnRoute = frame->payload[2 + offset]; + const uint8_t retVal = AssignReturnRoute(srcNodeID, destNodeID, + (funcID_ComplHandler_ZW_AssignReturnRoute != 0) ? &ZCB_ComplHandler_ZW_AssignReturnRoute : NULL); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE +uint8_t funcID_ComplHandler_ZW_AssignPriorityReturnRoute; + +/*=============== ZCB_ComplHandler_ZW_AssignPriorityReturnRoute ========= +** Completion handler for ZW_AssignPriorityReturnRoute +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_AssignPriorityReturnRoute( + uint8_t bStatus, /* IN Transmit completion status */ + TX_STATUS_TYPE *txStatusReport) +{ + uint8_t bIdx = 0; + BYTE_IN_AR(compl_workbuf, bIdx++) = funcID_ComplHandler_ZW_AssignPriorityReturnRoute; + BYTE_IN_AR(compl_workbuf, bIdx++) = bStatus; + if (bTxStatusReportEnabled && txStatusReport) /* Check if detailed info is available from protocol */ + { + memcpy(&compl_workbuf[bIdx], (uint8_t *)txStatusReport, sizeof(TX_STATUS_TYPE)); + bIdx += sizeof(TX_STATUS_TYPE); + } + Request(FUNC_ID_ZW_ASSIGN_PRIORITY_RETURN_ROUTE, compl_workbuf, bIdx); +} + +static uint8_t AssignPriorityReturnRoute(uint16_t srcNode, uint16_t destNode, const uint8_t* pRoute, uint8_t routeSpeed, ZW_TX_Callback_t pCallBack) +{ + /* srcNodeID | destNodeID | route[5] | funcID */ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.AssignReturnRoute.ReturnRouteReceiverNodeId = srcNode, + .uTransmitParams.AssignReturnRoute.RouteDestinationNodeId = destNode, + .uTransmitParams.AssignReturnRoute.PriorityRouteSpeed = routeSpeed, + .uTransmitParams.AssignReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_ASSIGNRETURNROUTE + }; + memcpy(FramePackage.uTransmitParams.AssignReturnRoute.aPriorityRouteRepeaters, pRoute, + sizeof(FramePackage.uTransmitParams.AssignReturnRoute.aPriorityRouteRepeaters)); + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_ASSIGN_PRIORITY_RETURN_ROUTE) +{ + /* srcNodeID | destNodeID | route[5] | funcID */ + uint8_t offset = 0; + node_id_t srcNodeID; + node_id_t destNodeID; + srcNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); + destNodeID = (node_id_t)GET_NODEID(&frame->payload[1 + offset], offset); + funcID_ComplHandler_ZW_AssignPriorityReturnRoute = frame->payload[offset + 7]; + // Put the package on queue (and dont wait for it) + const uint8_t retVal = AssignPriorityReturnRoute(srcNodeID, destNodeID, &frame->payload[offset + 2], frame->payload[offset + 6], + (funcID_ComplHandler_ZW_AssignPriorityReturnRoute != 0) ? &ZCB_ComplHandler_ZW_AssignPriorityReturnRoute : NULL ); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_DELETE_RETURN_ROUTE +uint8_t funcID_ComplHandler_ZW_DeleteReturnRoute; + +/*===================== ComplHandler_ZW_DeleteReturnRoute ============= +** Completion handler for ZW_DeleteReturnRoute +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_DeleteReturnRoute( + uint8_t bStatus, + TX_STATUS_TYPE *txStatusReport) /* IN Transmit completion status */ +{ + uint8_t bIdx = 0; + BYTE_IN_AR(compl_workbuf, bIdx++) = funcID_ComplHandler_ZW_DeleteReturnRoute; + BYTE_IN_AR(compl_workbuf, bIdx++) = bStatus; + if (bTxStatusReportEnabled /* Do HOST want txStatusReport */ + && txStatusReport) /* Check if detailed info is available from protocol */ + { + memcpy(&compl_workbuf[bIdx], (uint8_t *)txStatusReport, sizeof(TX_STATUS_TYPE)); + bIdx += sizeof(TX_STATUS_TYPE); + } + Request(FUNC_ID_ZW_DELETE_RETURN_ROUTE, compl_workbuf, bIdx); +} + +static uint8_t DeleteReturnNode(uint16_t nodeID, ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.DeleteReturnRoute.DestNodeId = nodeID, + .uTransmitParams.DeleteReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_DELETERETURNROUTE + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_DELETE_RETURN_ROUTE) +{ + /* nodeID | funcID */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + funcID_ComplHandler_ZW_DeleteReturnRoute = frame->payload[1 + offset]; + const uint8_t retVal = DeleteReturnNode(nodeId, (funcID_ComplHandler_ZW_DeleteReturnRoute != 0) ? &ZCB_ComplHandler_ZW_DeleteReturnRoute : NULL); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE +static uint8_t AssignSucReturnRoute(uint16_t srcNodeID, uint8_t sucNode, ZW_TX_Callback_t pCallBack) +{ + /* srcNodeID | funcID */ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.AssignReturnRoute.ReturnRouteReceiverNodeId = srcNodeID, + .uTransmitParams.AssignReturnRoute.RouteDestinationNodeId = sucNode, + .uTransmitParams.AssignReturnRoute.isSucRoute = true, + .uTransmitParams.AssignReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_ASSIGNRETURNROUTE + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_ASSIGN_SUC_RETURN_ROUTE) +{ + /* srcNodeID | funcID */ + uint8_t retVal = 0; + uint8_t SUCNodeId = (uint8_t)(ZAF_GetSucNodeId() & 0xFF); + uint8_t offset = 0; + node_id_t srcNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); + if (SUCNodeId != 0) + { + funcID_ComplHandler_netWork_Management = frame->payload[1 + offset]; + retVal = AssignSucReturnRoute(srcNodeID, SUCNodeId, (funcID_ComplHandler_netWork_Management != 0) ? &ZCB_ComplHandler_ZW_netWork_Management : NULL); + management_Func_ID = frame->cmd; + } + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE +uint8_t funcID_ComplHandler_ZW_AssignPrioritySUCReturnRoute; + +static uint8_t AssignPrioritySucReturnRoute(uint16_t srcNode, uint8_t sucNode, const uint8_t* pRoute, uint8_t routeSpeed, ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.AssignReturnRoute.ReturnRouteReceiverNodeId = srcNode, + .uTransmitParams.AssignReturnRoute.RouteDestinationNodeId = sucNode, + .uTransmitParams.AssignReturnRoute.PriorityRouteSpeed = routeSpeed, + .uTransmitParams.AssignReturnRoute.isSucRoute = true, + .uTransmitParams.AssignReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_ASSIGNRETURNROUTE + }; + memcpy(FramePackage.uTransmitParams.AssignReturnRoute.aPriorityRouteRepeaters, pRoute, sizeof(FramePackage.uTransmitParams.AssignReturnRoute.aPriorityRouteRepeaters)); + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE) +{ + /* srcNodeID | route[5] | funcID */ + uint8_t retVal = 0; + uint8_t SUCNodeId = (uint8_t)(ZAF_GetSucNodeId() & 0xFF); + uint8_t offset = 0; + node_id_t srcNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); + if (SUCNodeId != 0) + { + funcID_ComplHandler_netWork_Management = frame->payload[offset + 6]; + retVal = AssignPrioritySucReturnRoute(srcNodeID, SUCNodeId, &frame->payload[offset + 1], frame->payload[offset + 1 + 4], + (funcID_ComplHandler_netWork_Management != 0) ? &ZCB_ComplHandler_ZW_netWork_Management : NULL); + + management_Func_ID = frame->cmd; + } + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE +static uint8_t DeleteSucReturnRoute(uint16_t srcNode, ZW_TX_Callback_t pCallBack) +{ + /* srcNodeID | funcID */ + + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.DeleteReturnRoute.DestNodeId = srcNode, + .uTransmitParams.DeleteReturnRoute.bDeleteSuc = true, + .uTransmitParams.DeleteReturnRoute.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_DELETERETURNROUTE + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_DELETE_SUC_RETURN_ROUTE) +{ + /* srcNodeID | funcID */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + funcID_ComplHandler_netWork_Management = frame->payload[1 + offset]; + const uint8_t retVal = DeleteSucReturnRoute(nodeId, + (funcID_ComplHandler_netWork_Management != 0) ? &ZCB_ComplHandler_ZW_netWork_Management : NULL); + management_Func_ID = frame->cmd; + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_SEND_SUC_ID +uint8_t funcID_ComplHandler_ZW_SendSUC_ID; + +static void +ZCB_ComplHandler_ZW_SendSUC_ID( + uint8_t bStatus, + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendSUC_ID; + BYTE_IN_AR(compl_workbuf, 1) = bStatus; + Request(FUNC_ID_ZW_SEND_SUC_ID, compl_workbuf, 2); +} + +static uint8_t SendSucID(uint16_t destNode, uint8_t txOptions, ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.SendSucNodeId.DestNodeId = destNode, + .uTransmitParams.SendSucNodeId.TransmitOptions = txOptions, + .uTransmitParams.SendSucNodeId.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_SENDSUCNODEID + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_SUC_ID) +{ + /* destNodeID | txOptions | funcID */ + uint8_t offset = 0; + node_id_t destNodeID = (node_id_t)GET_NODEID(&frame->payload[0], offset); + funcID_ComplHandler_ZW_SendSUC_ID = frame->payload[offset + 2]; + + const uint8_t retVal = SendSucID(destNodeID, frame->payload[offset + 2], + (funcID_ComplHandler_ZW_SendSUC_ID != 0) ? &ZCB_ComplHandler_ZW_SendSUC_ID : NULL); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_SET_SUC_NODE_ID +uint8_t funcID_ComplHandler_ZW_SetSUCNodeID; + +/*==================== ComplHandler_ZW_SetSUCNodeID ====================== +** Function description +** ZW_SUC_SET_SUCCEEDED +** Side effects: +** +**--------------------------------------------------------------------------*/ +static void +ZCB_ComplHandler_ZW_SetSUCNodeID( + uint8_t txStatus, /*IN Completion status*/ + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SetSUCNodeID; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_SET_SUC_NODE_ID, compl_workbuf, 2); +} + +static uint8_t SetSucNodeID(uint16_t nodeID, uint8_t sucState, uint8_t txOptions, uint8_t capabilities, ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.SetSucNodeId.SucNodeId = nodeID, + .uTransmitParams.SetSucNodeId.bSucEnable = sucState, + .uTransmitParams.SetSucNodeId.bTxLowPower = txOptions, + .uTransmitParams.SetSucNodeId.Capabilities = capabilities, + .uTransmitParams.SetSucNodeId.Handle = (ZW_Void_Callback_t)pCallBack, + .eTransmitType = EZWAVETRANSMITTYPE_SETSUCNODEID + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_SUC_NODE_ID) +{ + /* nodeID | SUCState | txOptions | capabilities | funcID */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + funcID_ComplHandler_ZW_SetSUCNodeID = frame->payload[offset + 4]; + const uint8_t retVal = SetSucNodeID(nodeId, frame->payload[offset + 1], frame->payload[offset + 2], frame->payload[offset + 3], + (funcID_ComplHandler_ZW_SetSUCNodeID != 0) ? &ZCB_ComplHandler_ZW_SetSUCNodeID : NULL); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_GET_SUC_NODE_ID +ZW_ADD_CMD(FUNC_ID_ZW_GET_SUC_NODE_ID) +{ + uint8_t cmdLength = 0; + node_id_t suc_node_id; + + suc_node_id = ZAF_GetSucNodeId(); + + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(suc_node_id >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(suc_node_id & 0xFF); // LSB + cmdLength = 2; + } + else + { + BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(suc_node_id & 0xFF); + cmdLength = 1; + } + DoRespond_workbuf(cmdLength); +} +#endif + + +#if SUPPORT_ZW_REMOVE_FAILED_NODE_ID +uint8_t funcID_ComplHandler_ZW_RemoveFailedNodeID; + +/*===================== ComplHandler_ZW_RemoveFailedNodeID ============== +** Completion handler for ZW_RemoveFailedNodeID +** +**--------------------------------------------------------------------------*/ +void /* RET Nothing */ +ZCB_ComplHandler_ZW_RemoveFailedNodeID( + uint8_t bStatus) +{ + if (0 == funcID_ComplHandler_ZW_RemoveFailedNodeID) + { + return; + } + + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_RemoveFailedNodeID; + BYTE_IN_AR(compl_workbuf, 1) = bStatus; + Request(FUNC_ID_ZW_REMOVE_FAILED_NODE_ID, compl_workbuf, 2); +} + +static uint8_t RemoveFailedNode(uint16_t nodeID) +{ + + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_REMOVE_FAILED_NODE_ID, + .uCommandParams.FailedNodeIDCmd.nodeID = nodeID + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_REMOVE_FAILED_NODE_ID)) + { + return cmdStatus.Content.FailedNodeIDStatus.result; + } + ASSERT(0); + return 0; +} + +ZW_ADD_CMD(FUNC_ID_ZW_REMOVE_FAILED_NODE_ID) +{ + /* nodeID | funcID */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + funcID_ComplHandler_ZW_RemoveFailedNodeID = frame->payload[1 + offset]; + const uint8_t retVal = RemoveFailedNode(nodeId); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_IS_FAILED_NODE_ID +static uint8_t IsNodeIDFailed(uint16_t nodeID) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_IS_FAILED_NODE_ID, + .uCommandParams.IsFailedNodeID.nodeID = nodeID}; + + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + + // Wait for protocol to handle command (it shouldnt take long) + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_IS_FAILED_NODE_ID)) + { + return cmdStatus.Content.IsFailedNodeIDStatus.result; + } + ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. + return 0; +} + +ZW_ADD_CMD(FUNC_ID_ZW_IS_FAILED_NODE_ID) +{ + /* nodeID */ + volatile uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + const uint8_t retVal = IsNodeIDFailed(nodeId); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_REPLACE_FAILED_NODE +uint8_t funcID_ComplHandler_ZW_ReplaceFailedNode; + +/*===================== ComplHandler_ZW_RemoveFailedNodeID ============== +** Completion handler for ZW_RemoveFailedNodeID +** +**--------------------------------------------------------------------------*/ +void /* RET Nothing */ +ZCB_ComplHandler_ZW_ReplaceFailedNode( + uint8_t bStatus) /* IN Transmit completion status */ +{ + if (0 == funcID_ComplHandler_ZW_ReplaceFailedNode) + { + return; + } + + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_ReplaceFailedNode; + BYTE_IN_AR(compl_workbuf, 1) = bStatus; + Request(FUNC_ID_ZW_REPLACE_FAILED_NODE, compl_workbuf, 2); +} + +static uint8_t ReplaceFailedNode(uint16_t nodeID, uint8_t normalPower) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_REPLACE_FAILED_NODE_ID, + .uCommandParams.FailedNodeIDCmd.nodeID = nodeID, + .uCommandParams.FailedNodeIDCmd.normalPower = normalPower + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_REPLACE_FAILED_NODE_ID)) + { + return cmdStatus.Content.FailedNodeIDStatus.result; + } + ASSERT(0); + return 0; + +} + +ZW_ADD_CMD(FUNC_ID_ZW_REPLACE_FAILED_NODE) +{ + /* nodeID | funcID */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + funcID_ComplHandler_ZW_ReplaceFailedNode = frame->payload[1 + offset]; + const uint8_t retVal = ReplaceFailedNode(nodeId, true); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_GET_ROUTING_TABLE_LINE +static void GetRoutingInfo(uint16_t nodeID, uint8_t options, uint8_t *pRoutingInfo) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_GET_ROUTING_TABLE_LINE, + .uCommandParams.GetRoutingInfo.nodeID = nodeID, + .uCommandParams.GetRoutingInfo.options = options}; + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + + // Wait for protocol to handle command (it shouldnt take long) + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_ROUTING_TABLE_LINE)) + { + memcpy(pRoutingInfo, cmdStatus.Content.GetRoutingInfoStatus.RoutingInfo, MAX_NODEMASK_LENGTH); + return; + } + ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. +} + +ZW_ADD_CMD(FUNC_ID_GET_ROUTING_TABLE_LINE) +{ + /* HOST->ZW: bLine | bRemoveBad | bRemoveNonReps */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + GetRoutingInfo(nodeId, + (uint8_t)(((frame->payload[offset + 1]) ? GET_ROUTING_INFO_REMOVE_BAD : 0) | + ((frame->payload[offset + 2]) ? GET_ROUTING_INFO_REMOVE_NON_REPS : 0)), + compl_workbuf); + DoRespond_workbuf(MAX_NODEMASK_LENGTH); +} +#endif + + +#if SUPPORT_GET_TX_COUNTER +ZW_ADD_CMD(FUNC_ID_GET_TX_COUNTER) +{ + /* */ + /* Get the transmit counter */ + /* Not usedin 700 series - Obsoleted */ + DoRespond(0); +} +#endif + + +#if SUPPORT_RESET_TX_COUNTER +ZW_ADD_CMD(FUNC_ID_RESET_TX_COUNTER) +{ + /* */ + /* Reset the transmit counter */ + /* Not usedin 700 series - Obsoleted */ + DoRespond(0); +} +#endif + + +#if SUPPORT_STORE_HOMEID +static void StoreHomeID(uin8_t *pHomeID, uint16_t nodeID) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_STORE_HOMEID, + .uCommandParams.StoreHomeID.nodeID = nodeID, + }; + memcpy(cmdPackage.uCommandParams.StoreHomeID.homeID, pHomeID, sizeof(cmdPackage.uCommandParams.StoreHomeID.homeID)); + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); +} + +ZW_ADD_CMD(FUNC_ID_STORE_HOMEID) +{ + /* homeID1 | homeID2 | homeID3 | homeID4 | nodeID */ + /* Store homeID and Node ID. */ + uint8_t offset = 0; + StoreHomeID(frame->payload, GET_NODEID(&frame->payload[4], offset)); + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_LOCK_ROUTE_RESPONSE +static void LockResponseRoute(uint8_t lockID) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_LOCK_ROUTE_RESPONSE, + .uCommandParams.LockRouteResponse.value = lockID, + }; + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); +} + +ZW_ADD_CMD(FUNC_ID_LOCK_ROUTE_RESPONSE) +{ + /* HOST->ZW: lockID */ + /* Lock response routes / Last Working Routes. lockID == nodeID for locking. lockID == 0x00 to unlock */ + LockResponseRoute(frame->payload[0]); + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_ZW_GET_PRIORITY_ROUTE +static uint8_t GetPriorityRoute(uint16_t nodeID, uint8_t *priRoute) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_GET_PRIORITY_ROUTE, + .uCommandParams.GetPriorityRoute.nodeID = nodeID, + .uCommandParams.GetPriorityRoute.pPriRouteBuffer = priRoute, + }; + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + + // Wait for protocol to handle command (it shouldnt take long) + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_PRIORITY_ROUTE)) + { + memcpy(priRoute, cmdStatus.Content.GetPriorityRouteStatus.repeaters, MAX_REPEATERS); + priRoute[4] = cmdStatus.Content.GetPriorityRouteStatus.routeSpeed; + return cmdStatus.Content.GetPriorityRouteStatus.bAnyRouteFound; + } + ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. + return 0; +} + +ZW_ADD_CMD(FUNC_ID_ZW_GET_PRIORITY_ROUTE) +{ + /* HOST->ZW: nodeID */ + /* ZW->HOST: nodeID | anyRouteFound | repeater0 | repeater1 | repeater2 | repeater3 | routespeed */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(nodeId >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(nodeId & 0xFF); // LSB + } + else + { + BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(nodeId & 0xFF); // Legacy 8 bit nodeIDs + } + BYTE_IN_AR(compl_workbuf, offset + 1) = GetPriorityRoute(nodeId, &compl_workbuf[offset + 2]); + DoRespond_workbuf(offset + 7); +} +#endif + + +#if SUPPORT_ZW_SET_PRIORITY_ROUTE +static uint8_t SetPriorityRoute(uint16_t nodeID, const uint8_t *routeInfo) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_SET_PRIORITY_ROUTE, + .uCommandParams.SetPriorityRoute.nodeID = nodeID, + }; + if (NULL != routeInfo) + { + memcpy(cmdPackage.uCommandParams.SetPriorityRoute.repeaters, routeInfo, MAX_REPEATERS); + cmdPackage.uCommandParams.SetPriorityRoute.routeSpeed = routeInfo[4]; + } + else + { + cmdPackage.uCommandParams.SetPriorityRoute.clearGolden = true; + } + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + + // Wait for protocol to handle command (it shouldnt take long) + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_SET_PRIORITY_ROUTE)) + { + return cmdStatus.Content.SetPriorityRouteStatus.bRouteUpdated; + } + ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. + return 0; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_PRIORITY_ROUTE) +{ + /* HOST->ZW: nodeID | repeater0 | repeater1 | repeater2 | repeater3 | routespeed */ + /* ZW->HOST: nodeID | routeUpdated */ + uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + if (SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT == nodeIdBaseType) + { + BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(nodeId >> 8); // MSB + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(nodeId & 0xFF); // LSB + } + else + { + BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(nodeId & 0xFF); // Legacy 8 bit nodeIDs + } + if ((offset + 9) <= frame->len) + { + /* Set Priority Route Devkit 6.6x */ + BYTE_IN_AR(compl_workbuf, offset + 1) = SetPriorityRoute(nodeId, &frame->payload[offset + 1]); + } + else + { + /* Clear/Release Golden Route - Devkit 6.6x+ */ + BYTE_IN_AR(compl_workbuf, offset + 1) = SetPriorityRoute(nodeId, NULL); + } + DoRespond_workbuf(2); +} +#endif + + +#if SUPPORT_ZW_GET_VERSION +ZW_ADD_CMD(FUNC_ID_ZW_GET_VERSION) +{ + /* */ + const SProtocolInfo* protocol_info = ZAF_getProtocolInfo(); + uint8_t versionMinor = protocol_info->ProtocolVersion.Minor; + if (255 == zpal_get_app_version_major()) + { + // Special case when running the custom v255 file that is used for testing OTW firmware update. + // Make ZW_GET_VERSION return a unique version string "Z-Wave 7.99" so that test tools can distinguish it from the normal builds. + versionMinor = 99; + } + volatile int32_t iCharacters = snprintf((char *)(&compl_workbuf[0]), 12, "Z-Wave %1d.%02d", protocol_info->ProtocolVersion.Major, versionMinor); + ASSERT(iCharacters == 11); // Serial API must deliver 13 bytes reply. 11 byte string (no zero termination) followed by zero and 1 byte lib type + // We use SNPRINTF zero termination to produce the zero. + STATIC_ASSERT(sizeof(compl_workbuf) >= 13, STATIC_ASSERT_compl_workbuf_to_small); + compl_workbuf[12] = protocol_info->eLibraryType; + DoRespond_workbuf(13); +} +#endif + + +#if SUPPORT_ZW_GET_PROTOCOL_VERSION +ZW_ADD_CMD(FUNC_ID_ZW_GET_PROTOCOL_VERSION) +{ + /* */ + uint8_t len; + func_id_zw_get_protocol_version(0, NULL, compl_workbuf, &len); + DoRespond_workbuf(len); +} +#endif + + +#if SUPPORT_SERIAL_API_APPL_NODE_INFORMATION +#ifdef ZW_CONTROLLER +static void ZW_UpdateCtrlNodeInformation_API_IF(void) +{ + // Create transmit frame package + SZwaveCommandPackage FramePackage ={ + .eCommandType = EZWAVECOMMANDTYPE_ZW_UPDATE_CTRL_NODE_INFORMATION, + .uCommandParams.UpdateCtrlNodeInformation.value = true + }; + // Put the package on queue (and dont wait for it) + QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&FramePackage, 0); +} +#endif + +ZW_ADD_CMD(FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION) +{ + /* listening | generic | specific | parmLength | nodeParms[] */ + SAppNodeInfo_t *AppNodeInfo; + + AppNodeInfo = zaf_get_app_node_info(); + + AppNodeInfo->DeviceOptionsMask = frame->payload[0]; + AppNodeInfo->NodeType.generic = frame->payload[1]; + AppNodeInfo->NodeType.specific = frame->payload[2]; + + // As this serial API command only supports one set of command classes, + // we use the same list for the entire CC set + + // Data for loopifying CC list writes + SCommandClassList_t *const apCCLists[3] = + { + &CommandClasses.UnSecureIncludedCC, + &CommandClasses.SecureIncludedUnSecureCC, + &CommandClasses.SecureIncludedSecureCC + }; + + uint32_t iListLength = frame->payload[3]; + for (uint32_t i = 0; i < 3; i++) + { + // NOTE: These are not really supposed to be edited run time. + // So set list lengths to 0 at first to reduce chaos if protocol + // accesses them while we edit them. + apCCLists[i]->iListLength = 0; + + memset((uint8_t *)(apCCLists[i]->pCommandClasses), 0, CCListSizes[i]); // Clear CCList + memcpy((uint8_t *)(apCCLists[i]->pCommandClasses), &frame->payload[4], Minimum2(iListLength, CCListSizes[i])); + + // Set new list length after finishing CCList + apCCLists[i]->iListLength = (uint8_t)Minimum2(iListLength, CCListSizes[i]); + } + + SaveApplicationSettings(frame->payload[0], frame->payload[1], + frame->payload[2]); + SaveApplicationCCInfo(apCCLists[0]->iListLength, (uint8_t*)apCCLists[0]->pCommandClasses, + 0, NULL, 0, NULL); +#ifdef ZW_CONTROLLER + ZW_UpdateCtrlNodeInformation_API_IF(); +#endif + + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES +ZW_ADD_CMD(FUNC_ID_SERIAL_API_APPL_NODE_INFORMATION_CMD_CLASSES) +{ + /* unincluded_parmLength | unincluded_nodeParm[] | */ + /* included_unsecure_parmLength | included_unsecure_nodeParm[] |*/ + /* included_secure_parmLength | included_secure_nodeParm[] */ + + // Data for loopifying CC list writes + SCommandClassList_t *const apCCLists[3] = + { + &CommandClasses.UnSecureIncludedCC, + &CommandClasses.SecureIncludedUnSecureCC, + &CommandClasses.SecureIncludedSecureCC + }; + + uint32_t iOffset = 0; + for (uint32_t i = 0; i < 3; i++) + { + // NOTE: These are not really supposed to be edited run time. + // So set list lengths to 0 at first to reduce chaos if protocol + // accesses them while we edit them. + apCCLists[i]->iListLength = 0; + + memset((uint8_t *)(apCCLists[i]->pCommandClasses), 0, CCListSizes[i]); // Clear CCList + uint32_t iListLength = frame->payload[iOffset]; + memcpy((uint8_t*)apCCLists[i]->pCommandClasses, &frame->payload[iOffset + 1], Minimum2(iListLength, CCListSizes[i])); + // Set new list length after finishing CCList + apCCLists[i]->iListLength = (uint8_t)iListLength; + + iOffset += iListLength + 1; + } + + const uint8_t retVal = SaveApplicationCCInfo(apCCLists[0]->iListLength, (uint8_t*)apCCLists[0]->pCommandClasses, + apCCLists[1]->iListLength, (uint8_t*)apCCLists[1]->pCommandClasses, + apCCLists[2]->iListLength, (uint8_t*)apCCLists[2]->pCommandClasses + ); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION +uint8_t funcID_ComplHandler_ZW_SendSlaveNodeInformation; + +/*================= ComplHandler_ZW_SendSlaveNodeInformation ============ +** Completion handler for ZW_SendSlaveNodeInformation +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_SendSlaveNodeInformation( + uint8_t txStatus, /* IN Transmit completion status */ + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendSlaveNodeInformation; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_SEND_SLAVE_NODE_INFORMATION, compl_workbuf, 2); +} + +static uint8_t SendSlaveNodeInfo(uint16_t srcNode, uint16_t destNode, uint8_t txOptions, ZW_TX_Callback_t pCallBack) +{ + SZwaveTransmitPackage FramePackage = { + .eTransmitType = EZWAVETRANSMITTYPE_SEND_SLAVE_NODE_INFORMATION, + .uTransmitParams.SendSlaveNodeInformation.Handle = (ZW_Void_Callback_t)pCallBack, + .uTransmitParams.SendSlaveNodeInformation.sourceId = srcNode, + .uTransmitParams.SendSlaveNodeInformation.destinationId = destNode, + .uTransmitParams.SendSlaveNodeInformation.txOptions = txOptions, + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_SLAVE_NODE_INFORMATION) +{ + /* srcNode | destNode | txOptions | funcID */ + node_id_t srcNodeId, destNodeId; + srcNodeId = (node_id_t)frame->payload[0]; + destNodeId = (node_id_t)frame->payload[1]; + funcID_ComplHandler_ZW_SendSlaveNodeInformation = frame->payload[3]; + const uint8_t retVal = SendSlaveNodeInfo(srcNodeId, destNodeId, frame->payload[2], + (funcID_ComplHandler_ZW_SendSlaveNodeInformation != 0) ? &ZCB_ComplHandler_ZW_SendSlaveNodeInformation : NULL); + DoRespond(retVal); +} + +ZW_ADD_CMD(FUNC_ID_SERIAL_API_APPL_SLAVE_NODE_INFORMATION) +{ + /* srcNodeID | listening | generic | specific | parmLength | nodeParms[] */ + /* frame->payload[0] = srcNodeID */ + + uint32_t iVirtualSlaveIndex = 0; // Choose which Virtual Slave node slot to use + uint8_t offset = 0; + + // Start by removing reference to current configuration - so protocol never sees a partially modified config + apVirtualSlaveNodeInfo[iVirtualSlaveIndex] = NULL; + + // Modify config + aVirtualSlaveNodeInfo[iVirtualSlaveIndex].NodeId = (node_id_t)frame->payload[0]; + aVirtualSlaveNodeInfo[iVirtualSlaveIndex].bListening = frame->payload[offset + 1]; + aVirtualSlaveNodeInfo[iVirtualSlaveIndex].NodeType.generic = frame->payload[offset + 2]; + aVirtualSlaveNodeInfo[iVirtualSlaveIndex].NodeType.specific = frame->payload[offset + 3]; + aVirtualSlaveNodeInfo[iVirtualSlaveIndex].CommandClasses.iListLength = (uint8_t)Minimum2(frame->payload[offset + 4], sizeof(aVirtualSlaveCommandClasses[0])); + + memset(&aVirtualSlaveCommandClasses[iVirtualSlaveIndex][0], 0, sizeof(aVirtualSlaveCommandClasses[0])); + memcpy(&aVirtualSlaveCommandClasses[iVirtualSlaveIndex][0], &frame->payload[offset + 5], aVirtualSlaveNodeInfo[0].CommandClasses.iListLength); + + // Re-activate config + apVirtualSlaveNodeInfo[iVirtualSlaveIndex] = &aVirtualSlaveNodeInfo[iVirtualSlaveIndex]; + + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_ZW_SET_SLAVE_LEARN_MODE +uint8_t funcID_ComplHandler_ZW_SetSlaveLearnMode; + +/*================= ComplHandler_ZW_SetSlaveLearnMode ==================== +** Completion handler for ZW_SetSlaveLearnMode +** +**--------------------------------------------------------------------------*/ +void /* RET Nothing */ +ZCB_ComplHandler_ZW_SetSlaveLearnMode( + uint8_t bStatus, + uint8_t orgID, + uint8_t newID) /* IN Node ID */ +{ + if (0 == funcID_ComplHandler_ZW_SetSlaveLearnMode) + { + return; + } + + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SetSlaveLearnMode; + BYTE_IN_AR(compl_workbuf, 1) = bStatus; + BYTE_IN_AR(compl_workbuf, 2) = orgID; + BYTE_IN_AR(compl_workbuf, 3) = newID; + Request(FUNC_ID_ZW_SET_SLAVE_LEARN_MODE, compl_workbuf, 4); +} + +static uint8_t SetSlaveLearnMode(uint16_t nodeID, uint8_t mode) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_SET_SLAVE_LEARN_MODE, + .uCommandParams.SetSlaveLearnMode.nodeID = nodeID, + .uCommandParams.SetSlaveLearnMode.mode = mode, + }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_SET_SLAVE_LEARN_MODE_RESULT)) + { + return cmdStatus.Content.SetSlaveLearnModeStatus.result; + } + return false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_SLAVE_LEARN_MODE) +{ + /* node | mode | funcID */ + uint8_t offset = 0; + node_id_t nodeID = (node_id_t)frame->payload[0]; + funcID_ComplHandler_ZW_SetSlaveLearnMode = frame->payload[offset + 2]; + const uint8_t retVal = SetSlaveLearnMode(nodeID, frame->payload[offset + 1]); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_SEND_TEST_FRAME +uint8_t funcID_ComplHandler_ZW_SendTestFrame; + +/*================= ComplHandler_ZW_SendTestFrame ==================== +** Completion handler for ZW_SendTestFrame +** +**--------------------------------------------------------------------------*/ +static void +ZCB_ComplHandler_ZW_SendTestFrame( + uint8_t txStatus, + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) +{ + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_ZW_SendTestFrame; + BYTE_IN_AR(compl_workbuf, 1) = txStatus; + Request(FUNC_ID_ZW_SEND_TEST_FRAME, compl_workbuf, 2); +} + +static uint8_t SendTestFrame(uint16_t nodeID, uint8_t powerLevel, ZW_TX_Callback_t pCallBack) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .eTransmitType = EZWAVETRANSMITTYPE_TESTFRAME, + .uTransmitParams.Test.DestNodeId = nodeID, + .uTransmitParams.Test.PowerLevel = powerLevel, + .uTransmitParams.Test.Handle = pCallBack + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_SEND_TEST_FRAME) +{ + /* node | powerlevel | funcID */ + uint8_t offset = 0; + node_id_t node = (node_id_t)GET_NODEID(&frame->payload[0], offset); + funcID_ComplHandler_ZW_SendTestFrame = frame->payload[offset + 2]; + const uint8_t retVal = SendTestFrame(node, frame->payload[offset + 1], + (funcID_ComplHandler_ZW_SendTestFrame != 0) ? &ZCB_ComplHandler_ZW_SendTestFrame : NULL); + + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_IS_VIRTUAL_NODE +static uint8_t IsNodeVirtual(uint16_t nodeID) +{ + if(!nodeID || (ZW_MAX_NODES < nodeID)) //Virtual nodes are not implemented for Long Range nodes + { + return false; + } + + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_IS_VIRTUAL_NODE, + .uCommandParams.IsVirtualNode.value = nodeID, + }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_IS_VIRTUAL_NODE)) + { + return cmdStatus.Content.IsVirtualNodeStatus.result; + } + + ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. + return 0; +} + +ZW_ADD_CMD(FUNC_ID_ZW_IS_VIRTUAL_NODE) +{ + /* node */ + node_id_t nodeId = (node_id_t)frame->payload[0]; + const uint8_t retVal = IsNodeVirtual(nodeId); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_GET_VIRTUAL_NODES +static void GetVirtualNodes(uint8_t *vNodesMask) +{ + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_GET_VIRTUAL_NODES}; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_VIRTUAL_NODES)) + { + memcpy(vNodesMask, cmdStatus.Content.GetVirtualNodesStatus.vNodesMask, MAX_NODEMASK_LENGTH); + return; + } + + ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. +} + +ZW_ADD_CMD(FUNC_ID_ZW_GET_VIRTUAL_NODES) +{ + /* */ + GetVirtualNodes(compl_workbuf); + DoRespond_workbuf(ZW_MAX_NODES / 8); +} +#endif + +#if SUPPORT_SERIAL_API_GET_INIT_DATA +ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_INIT_DATA) +{ + uint8_t length = 0; + func_id_serial_api_get_init_data(frame_payload_len(frame), frame->payload, compl_workbuf, &length); + DoRespond_workbuf(length); +} +#endif +#if SUPPORT_SERIAL_API_GET_LR_NODES +#ifdef ZW_CONTROLLER +ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_LR_NODES) +{ + uint8_t length = 0; + func_id_serial_api_get_LR_nodes(frame_payload_len(frame), frame->payload, compl_workbuf, &length); + DoRespond_workbuf(length); +} +#endif +#endif + +#if SUPPORT_SERIAL_GET_LR_CHANNEL +ZW_ADD_CMD(FUNC_ID_GET_LR_CHANNEL) +{ + GetLongRangeChannel(&compl_workbuf[0], &compl_workbuf[1]); + DoRespond_workbuf(2); +} +#endif + + +#if SUPPORT_SERIAL_SET_LR_CHANNEL +ZW_ADD_CMD(FUNC_ID_SET_LR_CHANNEL) +{ + const uint8_t retVal = SetLongRangeChannel(frame->payload[0]); + DoRespond(retVal); +} +#endif + +#if SUPPORT_SERIAL_SET_LR_VIRTUAL_IDS +ZW_ADD_CMD(FUNC_ID_ZW_SET_LR_VIRTUAL_IDS) +{ + SetLongRangeVirtualNodes(frame->payload[0]); + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_SERIAL_ENABLE_RADIO_PTI +ZW_ADD_CMD(FUNC_ID_ENABLE_RADIO_PTI) +{ + const uint8_t retVal = SaveApplicationEnablePTI(frame->payload[0]); + DoRespond(retVal); +} + +ZW_ADD_CMD(FUNC_ID_GET_RADIO_PTI) +{ + const uint8_t retVal = GetPTIConfig(); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES +ZW_ADD_CMD(FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES) +{ + /* HOST->ZW: no params defined */ + const uint8_t retVal = GetControllerCapabilities(); + DoRespond(retVal); +} +#endif + + +#if SUPPORT_ZW_REQUEST_NODE_INFO +/*====================== ComplHandler_ZW_RequestNodeInfo ===================== +** Completion handler for ZW_RequestNodeInfo +** +**--------------------------------------------------------------------------*/ +static void /* RET Nothing */ +ZCB_ComplHandler_ZW_RequestNodeInfo( + uint8_t txStatus, /* IN Transmit completion status */ + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport) +{ + /* */ + if (txStatus != TRANSMIT_COMPLETE_OK) + { + ApplicationNodeUpdate(UPDATE_STATE_NODE_INFO_REQ_FAILED, 0, NULL, 0); + } +} + +static uint8_t RequestNodeID(uint16_t nodeID) +{ + // Create transmit frame package + SZwaveTransmitPackage FramePackage = { + .eTransmitType = EZWAVETRANSMITTYPE_NODEINFORMATIONREQUEST, + .uTransmitParams.NodeInfoRequest.DestNodeId = nodeID, + .uTransmitParams.NodeInfoRequest.Handle = (ZW_Void_Callback_t)ZCB_ComplHandler_ZW_RequestNodeInfo + }; + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + return (EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus) ? true : false; +} +#if SUPPORT_ZW_REQUEST_NODE_INFO +ZW_ADD_CMD(FUNC_ID_ZW_REQUEST_NODE_INFO) +{ + /* HOST->ZW: nodeID */ + volatile uint8_t offset = 0; + node_id_t nodeId = (node_id_t)GET_NODEID(&frame->payload[0], offset); + const uint8_t retVal = RequestNodeID(nodeId); + DoRespond(retVal); +} +#endif +#endif /*SUPPORT_ZW_REQUEST_NODE_INFO*/ + +#if SUPPORT_SERIAL_API_SET_TIMEOUTS +ZW_ADD_CMD(FUNC_ID_SERIAL_API_SET_TIMEOUTS) +{ + /* HOST->ZW: RX_ACK_timeout | RX_BYTE_timeout */ + /* ZW->HOST: RES | oldRX_ACK_timeout | oldRX_BYTE_timeout */ + BYTE_IN_AR(compl_workbuf, 0) = (uint8_t)(comm_interface_get_ack_timeout_ms() / 10); /* Respond with the old timeout settings */ + BYTE_IN_AR(compl_workbuf, 1) = (uint8_t)(comm_interface_get_byte_timeout_ms() / 10); + comm_interface_set_ack_timeout_ms(frame->payload[0] * 10); /* Max time to wait for ACK after frame transmission in 10ms ticks */ + comm_interface_set_byte_timeout_ms(frame->payload[1] * 10); /* Max time to wait for next byte when collecting a new frame in 10ms ticks */ + /* Respond with the old timeout settings */ + DoRespond_workbuf(2); +} +#endif + + +#if SUPPORT_SERIAL_API_SOFT_RESET +ZW_ADD_CMD(FUNC_ID_SERIAL_API_SOFT_RESET) +{ + //Enqueue soft reset command to protocol + SZwaveCommandPackage Command = { + .eCommandType = EZWAVECOMMANDTYPE_SOFT_RESET + }; + QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); +} +#endif + + +#if SUPPORT_SERIAL_API_SETUP +ZW_ADD_CMD(FUNC_ID_SERIAL_API_SETUP) +{ + /* HOST->ZW: Cmd | [CmdData[]] */ + /* ZW->HOST: Cmd | CmdRes[] */ + uint8_t length; + func_id_serial_api_setup(frame_payload_len(frame), frame->payload, compl_workbuf, &length); + DoRespond_workbuf(length); +} +#endif + +#if SUPPORT_SERIAL_API_READY +ZW_ADD_CMD(FUNC_ID_SERIAL_API_READY) +{ + /* HOST->ZW: [serialLinkState] */ + /* serialLinkState is OPTIONAL, if not present then the READY command, means "READY" */ + if ((FRAME_LENGTH_MIN < frame->len) && (SERIAL_LINK_DETACHED == frame->payload[0])) + { + /* HOST want Serial link to be shutdown - SerialAPI will not transmit anything */ + /* via serial link as long as HOST do not reestablish the Serial Link by */ + /* transmitting a valid SerialAPI frame. */ + serialLinkState = SERIAL_LINK_DETACHED; + /* Purge Callback queue */ + PurgeCallbackQueue(); + PurgeCommandQueue(); + } + else + { + /* Missing serialLinkState parameter or Every other serialLinkState value means */ + /* HOST Ready for Serial Communication */ + serialLinkState = SERIAL_LINK_CONNECTED; + } + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_ZW_TYPE_LIBRARY +ZW_ADD_CMD(FUNC_ID_ZW_TYPE_LIBRARY) +{ + const SProtocolInfo* protocol_info = ZAF_getProtocolInfo(); + DoRespond(protocol_info->eLibraryType); +} +#endif + + +#if SUPPORT_ZW_WATCHDOG_START | SUPPORT_ZW_WATCHDOG_STOP +uint8_t bWatchdogStarted; +#endif + + +#if SUPPORT_ZW_WATCHDOG_START +ZW_ADD_CMD(FUNC_ID_ZW_WATCHDOG_START) +{ + bWatchdogStarted = true; + zpal_enable_watchdog(true); + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_ZW_WATCHDOG_STOP +ZW_ADD_CMD(FUNC_ID_ZW_WATCHDOG_STOP) +{ + zpal_enable_watchdog(false); + bWatchdogStarted = false; + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_ZW_SET_ROUTING_MAX +static void zw_set_routing_max_handler(const comm_interface_frame_ptr frame) +{ + SZwaveCommandPackage Command = { + .eCommandType = EZWAVECOMMANDTYPE_SET_ROUTING_MAX, + .uCommandParams.SetRoutingMax.value = frame->payload[0] + }; + QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); + DoRespond(1); +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_ROUTING_MAX) +{ + zw_set_routing_max_handler(frame); +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_ROUTING_MAX_6_00) +{ + zw_set_routing_max_handler(frame); +} +#endif + + +#if SUPPORT_ZW_SET_PROMISCUOUS_MODE +static void SetPromiscuousMode(uint8_t mode) +{ + SZwaveCommandPackage PromiscuousMode = { + .eCommandType = EZWAVECOMMANDTYPE_SET_PROMISCUOUS_MODE, + .uCommandParams.SetPromiscuousMode.Enable = mode; + }; + + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t*)&PromiscuousMode, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); +} + +ZW_ADD_CMD(FUNC_ID_ZW_SET_PROMISCUOUS_MODE) +{ + /* HOST->ZW: promiscuousMode */ + SetPromiscuousMode(frame->payload[0]); + set_state_and_notify(stateIdle); +} +#endif + + +#if SUPPORT_SERIAL_API_TEST +ZW_APPLICATION_META_TX_BUFFER txBuffer; + +uint8_t funcID_ComplHandler_Serial_API_Test; +uint8_t testnodemask[ZW_MAX_NODES / 8]; +uint8_t testresultnodemask[ZW_MAX_NODES / 8]; + +uint8_t testnodemasklen = 0; +uint8_t timerTestHandle = 0xff; +uint8_t testCmd; +bool setON = true; +uint8_t testNodeID = 0; +uint16_t testDelay; +uint16_t testCurrentDelay; +uint8_t testPayloadLen; +uint16_t testCount; +uint16_t testSuccessCount; +uint16_t testFailedCount; +uint8_t testState = 0; +uint8_t testTxOptions; + +void +SendTestReport( + uint8_t txStatus) +{ + if (funcID_ComplHandler_Serial_API_Test != 0) + { + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_Serial_API_Test; + BYTE_IN_AR(compl_workbuf, 1) = testCmd; + BYTE_IN_AR(compl_workbuf, 2) = testState; + BYTE_IN_AR(compl_workbuf, 3) = testNodeID; + BYTE_IN_AR(compl_workbuf, 4) = txStatus; + BYTE_IN_AR(compl_workbuf, 5) = BYTE_GET_LOW_BYTE_IN_WORD(testCount); + Request(FUNC_ID_SERIAL_API_TEST, compl_workbuf, 6); + } +} + + +void +SendTestRoundReport( + __attribute__((unused)) uint8_t txStatus) +{ + if (funcID_ComplHandler_Serial_API_Test != 0) + { + BYTE_IN_AR(compl_workbuf, 0) = funcID_ComplHandler_Serial_API_Test; + BYTE_IN_AR(compl_workbuf, 1) = testCmd; + BYTE_IN_AR(compl_workbuf, 2) = testState; + BYTE_IN_AR(compl_workbuf, 3) = BYTE_GET_HIGH_BYTE_IN_WORD(testCount); + BYTE_IN_AR(compl_workbuf, 4) = BYTE_GET_LOW_BYTE_IN_WORD(testCount); + /* Initialy we assume every node acked, so we assume no nodemask is to be send */ + uint8_t i = 0; + if (ZW_NODE_MASK_BITS_IN(testresultnodemask, testnodemasklen)) + { + for (; i < testnodemasklen; i++) + { + BYTE_IN_AR(compl_workbuf, 6 + i) = testresultnodemask[i]; + } + BYTE_IN_AR(compl_workbuf, 5) = testnodemasklen; + i++; + } + Request(FUNC_ID_SERIAL_API_TEST, compl_workbuf, 5 + i); + } +} + + +void +ZCB_TestDelayNextSendTimeout(void) +{ + if (--testCurrentDelay == 0) + { + if (timerTestHandle != 0xff) + { + TimerCancel(timerTestHandle); + } + timerTestHandle = 0xff; + TestSend(); + } +} + + +void +ZCB_TestDelayTimeout(void) +{ + if (--testCurrentDelay == 0) + { + if (timerTestHandle != 0xff) + { + TimerCancel(timerTestHandle); + } + timerTestHandle = 0xff; + setON = !setON; + TestStartRound(); + } +} + + +bool +TestFindNextNode(void) +{ + do + { + if (ZW_NodeMaskNodeIn(testnodemask, ++testNodeID)) + { + return true; + } + } while (testNodeID < ZW_MAX_NODES); + return false; +} + + +/*=========================== MetaDataSendComplete ========================= +** Function description +** +** +** +** Side effects: +** +**--------------------------------------------------------------------------*/ +void +ZCB_TestSendComplete( + uint8_t bStatus, + __attribute__((unused)) TX_STATUS_TYPE *txStatusReport +) +{ + DPRINT("C"); + DPRINTF("%u", bStatus); + + if (bStatus == TRANSMIT_COMPLETE_OK) + { + testSuccessCount++; + } + else + { + /* Set bit indicating that node failed to acknowledge */ + ZW_NODE_MASK_SET_BIT(testresultnodemask, testNodeID); + testFailedCount++; + } + /* Should we transmit result (to host) after every transmit or do we send one frame after every round? */ + if (testCmd < 0x05) + { + /* One result frame after every transmit */ + SendTestReport(bStatus); + } + if (testState == POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_INPROGRESS) + { + if (TestFindNextNode()) + { + { + testCurrentDelay = testDelay; + if (timerTestHandle != 0xff) + { + TimerCancel(timerTestHandle); + } + timerTestHandle = 0xff; + if (!testCurrentDelay) + { + testCurrentDelay++; + ZCB_TestDelayNextSendTimeout(); + } + else + { + timerTestHandle = TimerStart(ZCB_TestDelayNextSendTimeout, 1, TIMER_FOREVER); + } + } + } + else + { + if (testCmd >= 0x05) + { + /* One result frame after every round */ + SendTestRoundReport(0); + } + /* No more nodes in this round - delay (if any delay to be done) before starting next round */ + if (testCount && (--testCount != 0)) + { + testCurrentDelay = testDelay; + if (timerTestHandle != 0xff) + { + TimerCancel(timerTestHandle); + } + timerTestHandle = 0xff; + if (!testCurrentDelay) + { + testCurrentDelay++; + ZCB_TestDelayTimeout(); + } + else + { + timerTestHandle = TimerStart(ZCB_TestDelayTimeout, 1, TIMER_FOREVER); + } + } + else + { + testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_SUCCES; + SendTestReport(0); + } + } + } + else + { + if (timerTestHandle != 0xff) + { + TimerCancel(timerTestHandle); + } + timerTestHandle = 0xff; + SendTestReport(0); + } +} + + +/*================================= TestSend =============================== +** Function description +** Send the next data frame +** +** +** Side effects: +** +**--------------------------------------------------------------------------*/ +void +TestSend(void) +{ + uint8_t payLoadLen; + + DPRINT("N"); + + if ((testCmd == 0x03) || (testCmd == 0x04) || (testCmd == 0x07) || (testCmd == 0x08)) + { + txBuffer.ZW_BasicSetFrame.cmdClass = COMMAND_CLASS_BASIC; + txBuffer.ZW_BasicSetFrame.cmd = BASIC_SET; + txBuffer.ZW_BasicSetFrame.value = setON ? BASIC_ON : BASIC_OFF; + payLoadLen = sizeof(txBuffer.ZW_BasicSetFrame); + } + else + { + txBuffer.ZW_ManufacturerSpecificReportFrame.cmdClass = COMMAND_CLASS_MANUFACTURER_PROPRIETARY; + txBuffer.ZW_ManufacturerSpecificReportFrame.manufacturerId1 = 0x00; + txBuffer.ZW_ManufacturerSpecificReportFrame.manufacturerId2 = 0x00; + txBuffer.ZW_ManufacturerSpecificReportFrame.productId1 = 0x04; + txBuffer.ZW_ManufacturerSpecificReportFrame.productId2 = 0x81; + *(&(txBuffer.ZW_ManufacturerSpecificReportFrame.productId2) + 1) = 0x00; + *(&(txBuffer.ZW_ManufacturerSpecificReportFrame.productId2) + 2) = BYTE_GET_HIGH_BYTE_IN_WORD(testCount); //data1 + *(&(txBuffer.ZW_ManufacturerSpecificReportFrame.productId2) + 3) = BYTE_GET_LOW_BYTE_IN_WORD(testCount); //data1+1 + payLoadLen = sizeof(txBuffer.ZW_ManufacturerSpecificReportFrame); + } + /* Send meta data frame */ + // Create transmit frame package + uint8_t iFrameLength = (testPayloadLen > payLoadLen) ? testPayloadLen : payLoadLen; + SZwaveTransmitPackage FramePackage = { + .uTransmitParams.SendData.DestNodeId = testNodeID, + .uTransmitParams.SendData.FrameConfig.TransmitOptions = testTxOptions, + .uTransmitParams.SendData.FrameConfig.Handle = &ZCB_TestSendComplete, + .eTransmitType = EZWAVETRANSMITTYPE_STD, + .uTransmitParams.SendData.FrameConfig.iFrameLength = iFrameLength + }; + memcpy(&FramePackage.uTransmitParams.SendData.FrameConfig.aFrame, &txBuffer, iFrameLength); + // Put the package on queue (and dont wait for it) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwTxQueue(), (uint8_t *)&FramePackage, 0); + + if (EQUEUENOTIFYING_STATUS_SUCCESS != QueueStatus) + { + ZCB_TestSendComplete(TRANSMIT_COMPLETE_NO_ACK, NULL); + } +} + + +/*============================ TestStartRound ============================ +** Start a Test round +** +** This is an application function example +** +**--------------------------------------------------------------------------*/ +void +TestStartRound(void) +{ + uint8_t bTemp; + + ZW_NODE_MASK_CLEAR(testresultnodemask, ZW_MAX_NODES / 8); + /* Fill the meta data frame with data */ + for (bTemp = 0; bTemp < (META_DATA_MAX_DATA_SIZE - sizeof(ZW_MANUFACTURER_SPECIFIC_REPORT_FRAME)); bTemp++) + { + *(&(txBuffer.ZW_ManufacturerSpecificReportFrame.productId2) + 1 + bTemp) = bTemp + 1; + } + testNodeID = 0; + /* Find first node to transmit to */ + if ((testState == POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_INPROGRESS) && TestFindNextNode()) + { + /* Found a node */ + TestSend(); + } + else + { + testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_FAILED; + SendTestReport(0); + } +} + +ZW_ADD_CMD(FUNC_ID_SERIAL_API_TEST) +{ + /* HOST->ZW: testCmd | testDelay(MSB) | testDelay(LSB) | testPayloadLen | */ + /* testCount(MSB) | testCount(LSB) | testTxOptions | nodemasklen | testnodemask[] | funcID */ + /* testCmd = 0x01 - use sendData */ + /* testCmd = 0x02 - use sendDataMeta */ + /* testCmd = 0x03 - use sendData with Basic Set toggle ON/OFF between rounds */ + /* testCmd = 0x04 - use sendDataMeta with Basic Set toggle ON/OFF between rounds */ + /* testCmd = 0x05 - use sendData with one group result frame (serial) at every round end */ + /* testCmd = 0x06 - use sendDataMeta with one group result frame (serial) at every round end */ + /* testCmd = 0x07 - use sendData with Basic Set toggle ON/OFF and one group result frame (serial) between rounds */ + /* testCmd = 0x08 - use sendDataMeta with Basic Set toggle ON/OFF and one group result frame (serial) between rounds */ + /* ZW->HOST: RES | testStarted */ + uint8_t retVal = 0; + testCmd = frame->payload[0]; + if (testCmd && (testState != POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_INPROGRESS)) + { + WORD_SET_HIGH_LOW_BYTES(testDelay, frame->payload[1], frame->payload[2]); + + testPayloadLen = frame->payload[3]; + WORD_SET_HIGH_LOW_BYTES(testCount, frame->payload[4], frame->payload[5]); + testTxOptions = frame->payload[6]; + testnodemasklen = frame->payload[7]; + /* - Boundary Check */ + if (testnodemasklen > MAX_NODEMASK_LENGTH) + { + testnodemasklen = MAX_NODEMASK_LENGTH; + } + ZW_NODE_MASK_CLEAR(testnodemask, MAX_NODEMASK_LENGTH); + for (uint8_t i = 0; i < testnodemasklen; i++) + { + BYTE_IN_AR(testnodemask, i) = frame->payload[i + 8]; + } + funcID_ComplHandler_Serial_API_Test = frame->payload[frame->payload[7] + 8]; + if (testCount != 0) + { + testFailedCount = 0; + testSuccessCount = 0; + testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_INPROGRESS; + TestStartRound(); + retVal = 1; + } + else + { + testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_FAILED; + SendTestReport(0); + return; + } + } + else + { + /* STOP test ??? */ + if (!testCmd) + { + testState = POWERLEVEL_TEST_NODE_REPORT_ZW_TEST_FAILED; + SendTestReport(0); + retVal = 1; + } + } + DoRespond(retVal); +} +#endif + + +#if SUPPORT_SERIAL_API_EXT +ZW_ADD_CMD(FUNC_ID_SERIAL_API_EXT) +{ + /* HOST->ZW: mode | data */ + /* not used in 700 series - Obsolete */ + if (frame->len > FRAME_LENGTH_MIN) + { + switch (frame->payload[0]) + { + /* since the 700 / 800 series targets don't support the command, + then all values of the mode parameters should return zero*/ + case 0: + case 1: + { + BYTE_IN_AR(compl_workbuf, 0) = 0; + DoRespond_workbuf(1); + } + break; + default: + { + DoRespond(0); + } + break; + } + } +} +#endif + + +#if SUPPORT_ZW_GET_RANDOM +static uint8_t GetRandom(uint8_t noOfRndBytes, uint8_t* rndBytes) +{ + SZwaveCommandPackage GetRandom = { + .eCommandType = EZWAVECOMMANDTYPE_GENERATE_RANDOM, + .uCommandParams.GenerateRandom.iLength = noOfRndBytes}; + + // Put the Command on queue (and dont wait for it, queue must be empty) + if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&GetRandom, 0)) + { + // Wait for protocol to handle command + SZwaveCommandStatusPackage Random = { 0 }; + if (GetCommandResponse(&Random, EZWAVECOMMANDSTATUS_GENERATE_RANDOM)) + { + memcpy(rndBytes, Random.Content.GenerateRandomStatus.aRandomNumber, Random.Content.GenerateRandomStatus.iLength); + return Random.Content.GenerateRandomStatus.iLength; + } + } + return false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_GET_RANDOM) +{ + /* HOST->ZW: noRandomBytes - Optional if not present or equal ZERO then */ + /* 2 random bytes are returned. */ + /* Range 1..32 random bytes are supported */ + /* ZW->HOST: RES | randomGenerationSuccess | noRandomBytesGenerated | noRandomGenerated[] */ + uint8_t noRndBytes = frame->payload[0]; + if ((frame->len > FRAME_LENGTH_MIN) && (noRndBytes != 0)) + { + if (noRndBytes > 32) + { + noRndBytes = 32; + } + } + else + { + noRndBytes = 2; + } + // Prepare failed return + BYTE_IN_AR(compl_workbuf, 0) = false; + BYTE_IN_AR(compl_workbuf, 1) = 0; + uint8_t rndBytes = GetRandom(noRndBytes, &compl_workbuf[2]); + if (rndBytes) + { + BYTE_IN_AR(compl_workbuf, 0) = true; + BYTE_IN_AR(compl_workbuf, 1) = rndBytes; + } + rndBytes += 2; + DoRespond_workbuf(rndBytes); +} +#endif + + +#if SUPPORT_ZW_AES_ECB +static void AesEcb(uint8_t *key, uint8_t *InputData, uint8_t *outData) +{ + SZwaveCommandPackage cmdPackage = {.eCommandType = EZWAVECOMMANDTYPE_AES_ECB}; + memcpy(cmdPackage.uCommandParams.AesEcb.key, key, sizeof(cmdPackage.uCommandParams.AesEcb.key)); + memcpy(cmdPackage.uCommandParams.AesEcb.inputData, InputData, sizeof(cmdPackage.uCommandParams.AesEcb.inputData)); + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_AES_ECB)) + { + memcpy(outData, cmdStatus.Content.AesEcbStatus.outputData, 16); + return; + + } + ASSERT(false); // FIXME We should have more intelligent error handling, we shouldnt assert here. +} + +ZW_ADD_CMD(FUNC_ID_ZW_AES_ECB) +{ + /* HOST->ZW: key[] (16 bytes) | inputDat[] (16 bytes) */ + /* ZW->HOST: RES | outdata[] (16 bytes) */ + AesEcb(&frame->payload[0], &frame->payload[16], compl_workbuf); + DoRespond_workbuf(16); +} +#endif + + +#if SUPPORT_ZW_AUTO_PROGRAMMING +ZW_ADD_CMD(FUNC_ID_AUTO_PROGRAMMING) +{ + //Reboot into bootloader. Calls zpal_bootloader_reboot_and_install(); + SZwaveCommandPackage Command = { + .eCommandType = EZWAVECOMMANDTYPE_BOOTLOADER_REBOOT + }; + QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&Command, 0); +} +#endif + + +#ifdef SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD +ZW_ADD_CMD(FUNC_ID_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD) +{ + /* HOST->ZW: bChannel | bThreshold */ + /* ZW->HOST: RES | true */ + uint8_t length; + func_id_set_listen_before_talk(frame_payload_len(frame), frame->payload, compl_workbuf, &length); + DoRespond_workbuf(length); +} +#endif + + +#ifdef SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS +static bool SetMaxInclReqIntervals( uint32_t maxInclReqIntervals) +{ + SZwaveCommandPackage setMaxInclusionRequestIntervals = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_SET_MAX_INCL_REQ_INTERVALS, + .uCommandParams.SetMaxInclReqInterval.inclusionRequestInterval = maxInclReqIntervals}; + + // Put the Command on queue (and dont wait for it, queue must be empty) + if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(ZAF_getZwCommandQueue(), (uint8_t *)&setMaxInclusionRequestIntervals, 0)) + { + // Wait for protocol to handle command + SZwaveCommandStatusPackage result = { 0 }; + if (GetCommandResponse(&result, EZWAVECOMMANDSTATUS_ZW_SET_MAX_INCL_REQ_INTERVALS)) + { + if(result.Content.NetworkManagementStatus.statusInfo[0]) + { + return true; + } + } + } + return false; +} + +ZW_ADD_CMD(FUNC_ID_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS) +{ + /* HOST->ZW: bChannel | bThreshold */ + /* ZW->HOST: RES | true */ + const uint8_t retVal = SetMaxInclReqIntervals(frame->payload[0]); + DoRespond(retVal); +} +#endif + +// Added to make sure that capabilities is correct. +ZW_ADD_CMD(FUNC_ID_SERIAL_API_STARTED) +{ +} + +// Added to make sure that capabilities is correct. +ZW_ADD_CMD(FUNC_ID_ZW_APPLICATION_UPDATE) +{ +} + +// Added to make sure that capabilities is correct. +ZW_ADD_CMD(FUNC_ID_APPLICATION_COMMAND_HANDLER_BRIDGE) +{ +} + +// Added to make sure that capabilities is correct. +ZW_ADD_CMD(FUNC_ID_ZW_GET_PROTOCOL_STATUS) +{ +} diff --git a/src/zwave_ncp_serial_api_controller/cmd_handlers.h b/src/zwave_ncp_serial_api_controller/cmd_handlers.h new file mode 100644 index 00000000..a76f2717 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmd_handlers.h @@ -0,0 +1,70 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef CMD_HANDLER_H_ +#define CMD_HANDLER_H_ + +#include +#include + +#ifdef ZW_CONTROLLER +#include +#endif + +/** + * @addtogroup Apps + * @{ + * @addtogroup SerialAPI + * @{ + */ + +typedef void (*cmd_handler_t)(const comm_interface_frame_ptr); + +typedef struct +{ + uint8_t cmd; + cmd_handler_t pHandler; +} +cmd_handler_map_t; + +#define CMD_HANDLER_SECTION "_cmd_handlers" + +#define ZW_ADD_CMD(cmd) \ + static void cmd_handler_fcn_##cmd(__attribute__((unused)) const comm_interface_frame_ptr frame); /* Prototype */ \ + static const cmd_handler_map_t cmd_handler_##cmd __attribute__((__used__, __section__( CMD_HANDLER_SECTION ))) = {cmd,cmd_handler_fcn_##cmd}; \ + static void cmd_handler_fcn_##cmd(__attribute__((unused)) const comm_interface_frame_ptr frame) + +/** + * Invoke command handler. + * + * @param[in] frame Frame + * @return true if handler for given @p frame was invoked, false if no handler was found + */ +bool invoke_cmd_handler(const comm_interface_frame_ptr frame); + +typedef void * cmd_context_t; + +typedef bool (*cmd_foreach_callback_t)(cmd_handler_map_t const * const p_cmd_entry, cmd_context_t context); + +/** + * Invokes callback for each registered command. + * + * Will stop if the callback returns true. + * + * @param callback Callback function to invoke. + * @param context Context to pass on to the callback function. + */ +void cmd_foreach(cmd_foreach_callback_t callback, cmd_context_t context); + +#ifdef ZW_CONTROLLER +void ZCB_ComplHandler_ZW_NodeManagement(LEARN_INFO_T *statusInfo); +#endif + +/** + * @} + * @} + */ + +#endif /* CMD_HANDLER_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/cmd_handlers_invoker.c b/src/zwave_ncp_serial_api_controller/cmd_handlers_invoker.c new file mode 100644 index 00000000..2fdc8244 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmd_handlers_invoker.c @@ -0,0 +1,47 @@ +/** + * @file cmd_handlers_invoker.c + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include "cmd_handlers.h" +#include "Assert.h" + +/** + * This is the first of the registered handlers + */ +extern const cmd_handler_map_t __start__cmd_handlers; +#define cmd_handlers_start __start__cmd_handlers +/** + * This marks the end of the handlers. The element + * after the last element. This means that this element + * is not valid. + */ +extern const cmd_handler_map_t __stop__cmd_handlers; +#define cmd_handlers_stop __stop__cmd_handlers + + +bool invoke_cmd_handler(const comm_interface_frame_ptr frame) +{ + cmd_handler_map_t const * iter = &cmd_handlers_start; + for ( ; iter < &cmd_handlers_stop; ++iter) + { + if (iter->cmd == frame->cmd) { + iter->pHandler(frame); + return true; + } + } + + return false; +} + +void cmd_foreach(cmd_foreach_callback_t callback, cmd_context_t context) +{ + ASSERT(callback != NULL); + cmd_handler_map_t const * iter = &cmd_handlers_start; + for ( ; iter < &cmd_handlers_stop; ++iter) + { + if (true == callback(iter, context)) { + break; + } + } +} diff --git a/src/zwave_ncp_serial_api_controller/cmds_dcdc.c b/src/zwave_ncp_serial_api_controller/cmds_dcdc.c new file mode 100644 index 00000000..bc9c76af --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmds_dcdc.c @@ -0,0 +1,72 @@ +/** + * @file + * Offers DCDC configuration for Silabs targets only. + * @attention Must be linked for Silabs build targets only. + * @copyright 2022 Silicon Laboratories Inc. + */ +#include +#include "cmd_handlers.h" +#include "app.h" +#include "sl_dcdc.h" +#include "ZW_typedefs.h" +#include "ZW_SerialAPI.h" +#include "zpal_nvm.h" +#include "serialapi_file.h" +#include "ZAF_nvm_app.h" + +#define DCDC_CONFIG_UNALTERED 0xff + +// 0x00 Auto, 0x01 Bypass, 0x02 LowNoise, 0xFF Original default + +#define FILE_ID_DCDC_CONFIGURATION FILE_ID_PROPRIETARY_1 + +typedef struct +{ + uint8_t dcdc_config; +} +dcdc_configuration_file_t; + +#define DCDC_CONFIGURATION_FILE_SIZE (sizeof(dcdc_configuration_file_t)) + +static dcdc_configuration_file_t dcdc_configuration_file; + +bool SetDcDcConfig(uint8_t DcdcConfig) +{ + bool result = sl_dcdc_config_set(DcdcConfig); + if (true == result) + { + dcdc_configuration_file.dcdc_config = DcdcConfig; + zpal_status_t status = ZAF_nvm_app_write( FILE_ID_DCDC_CONFIGURATION, + &dcdc_configuration_file, + DCDC_CONFIGURATION_FILE_SIZE); + return (ZPAL_STATUS_OK == status); + } + return false; +} + +uint8_t GetDcDcConfig(void) +{ + ZAF_nvm_app_read(FILE_ID_DCDC_CONFIGURATION, &dcdc_configuration_file, DCDC_CONFIGURATION_FILE_SIZE); + return dcdc_configuration_file.dcdc_config; +} + +void SerialAPI_hw_psu_init(void) +{ + uint8_t dcdcConfig = GetDcDcConfig(); + if (DCDC_CONFIG_UNALTERED != dcdcConfig) + { + sl_dcdc_config_set(dcdcConfig); + } +} + +ZW_ADD_CMD(FUNC_ID_GET_DCDC_CONFIG) +{ + uint8_t retVal = GetDcDcConfig(); + DoRespond(retVal); +} + +ZW_ADD_CMD(FUNC_ID_SET_DCDC_CONFIG) +{ + uint8_t retVal = SetDcDcConfig(frame->payload[0]); + DoRespond(retVal); +} diff --git a/src/zwave_ncp_serial_api_controller/cmds_management.c b/src/zwave_ncp_serial_api_controller/cmds_management.c new file mode 100644 index 00000000..86527977 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmds_management.c @@ -0,0 +1,515 @@ +/** + * @file cmds_management.c + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#define DEBUGPRINT +#include +#include "zw_build_no.h" + +#ifdef ZW_CONTROLLER +#include +#endif // ZW_CONTROLLER + +#define PUK_OFFSET 0x23 +#define PRK_OFFSET 0x43 +#define HW_VER_OFFSET 0x70 +#define HW_VER_SIZE 1 + +/** Find the byte in which SERIAL_API_SETUP command will be written */ +#define BYTE_INDEX(x) ((x - 1) / 8) +/** Find the offset in the byte of SERIAL_API_SETUP command */ +#define BYTE_OFFSET(x) (1 << ((x - 1) % 8)) +/** Add the SERIAL_API_SETUP command to the bitmask array */ +#define BITMASK_ADD_CMD(bitmask, cmd) (bitmask[BYTE_INDEX(cmd)] |= BYTE_OFFSET(cmd)) + +#ifndef MAX +/** Return the larger of two values. + * + * \param x An integer-valued expression without side effects. + * \param y An integer-valued expression without side effects. + * + * \return The larger of \p x and \p y. + */ +#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif // MAX + +void func_id_serial_api_get_init_data(__attribute__((unused)) uint8_t inputLength, + __attribute__((unused)) const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength) +{ + *pOutputLength = 5; + BYTE_IN_AR(pOutputBuffer, 0) = SERIAL_API_VER; + BYTE_IN_AR(pOutputBuffer, 1) = 0; /* Flag byte - default: controller api, no timer support, no primary, no SUC */ +#ifdef ZW_CONTROLLER + if (!IsPrimaryController()) + { + BYTE_IN_AR(pOutputBuffer, 1) |= GET_INIT_DATA_FLAG_SECONDARY_CTRL; /* Set Primary/secondary bit */ + } + if (GetControllerCapabilities() & CONTROLLER_IS_SUC) /* if (ZW_IS_SUC_ACTIVE()) */ + { + BYTE_IN_AR(pOutputBuffer, 1) |= GET_INIT_DATA_FLAG_IS_SUC; /* Set SUC bit if active */ + } + + /* compl_workbuf[1] is already set to controller api*/ + BYTE_IN_AR(pOutputBuffer, 2) = ZW_MAX_NODES / 8; /* node bitmask length */ + + /* Clear the buffer */ + memset(pOutputBuffer + 3, 0, ZW_MAX_NODES / 8); + + /* Next ZW_MAX_NODES/8 = 29 bytes of compl_workbuf reserved for node bitmask */ + + Get_included_nodes(pOutputBuffer + 3); + + BYTE_IN_AR(pOutputBuffer, 3 + (ZW_MAX_NODES / 8)) = zpal_get_chip_type(); + BYTE_IN_AR(pOutputBuffer, 4 + (ZW_MAX_NODES / 8)) = zpal_get_chip_revision(); + *pOutputLength += (ZW_MAX_NODES / 8); + ASSERT(*pOutputLength <= 34); // Elsewhere, like in zwapi_init.c, the pOutputBuffer is hardcoded to 34 bytes in lenght. +#else + BYTE_IN_AR(pOutputBuffer, 1) |= GET_INIT_DATA_FLAG_SLAVE_API; /* Flag byte */ + BYTE_IN_AR(pOutputBuffer, 2) = 0; /* node bitmask length */ + BYTE_IN_AR(pOutputBuffer, 3) = zpal_get_chip_type(); + BYTE_IN_AR(pOutputBuffer, 4) = zpal_get_chip_revision(); +#endif +} + +#ifdef ZW_CONTROLLER +void func_id_serial_api_get_LR_nodes(__attribute__((unused)) uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength) +{ + //RES | 0xDA | MORE_NODES | BITMASK_OFFSET | BITMASK_LEN | BITMASK_ARRAY + + /* + * The current implementation of this function is made on the fact + * that there is no support in the Z-Wave protocol code for more than 1024 Long Range nodes in total. + * This Assert is here to remind us to update this function, if in the future the number of supported nodes increases. + * In which case the MAX_LR_NODEMASK_LENGTH define will become greater than 128 + */ + STATIC_ASSERT(MAX_LR_NODEMASK_LENGTH <= 128, STATIC_ASSERT_MAX_LR_NODEMASK_LENGTH_to_big); + + uint8_t bitmaskOffset = pInputBuffer[0]; + *pOutputLength = 3 + MAX_LR_NODEMASK_LENGTH; + BYTE_IN_AR(pOutputBuffer, 0) = 0; // MORE_NODES - No more nodes for now. + // Allowed values for bitmaskOffset are 0, 1, 2, 3 + if (bitmaskOffset > 3) + { + bitmaskOffset = 3; + } + BYTE_IN_AR(pOutputBuffer, 1) = bitmaskOffset; + + // Clean output buffer first + memset(pOutputBuffer + 3, 0, MAX_LR_NODEMASK_LENGTH); + + BYTE_IN_AR(pOutputBuffer, 2) = MAX_LR_NODEMASK_LENGTH; // BITMASK_LEN hardcoded + if (bitmaskOffset < 1) + { + Get_included_lr_nodes(pOutputBuffer + 3); + } +} +#endif + +extern bool bTxStatusReportEnabled; + +zpal_tx_power_t +GetMaxSupportedTxPower(void) +{ + const SApplicationHandles *pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage CommandPackage = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_TX_POWER_MAX_SUPPORTED + }; + // Put the Command on queue (and dont wait for it, queue must be empty) + if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(pAppHandles->pZwCommandQueue, (uint8_t *)&CommandPackage, 0)) + { + // Wait for protocol to handle command + SZwaveCommandStatusPackage result = { 0 }; + if (GetCommandResponse(&result, EZWAVECOMMANDSTATUS_ZW_GET_TX_POWER_MAX_SUPPORTED)) + { + return result.Content.GetTxPowerMaximumSupported.tx_power_max_supported; + } + } + return ZW_TX_POWER_14DBM; +} + +void func_id_serial_api_setup(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength) +{ + uint8_t i=0; + uint8_t cmdRes; + zpal_radio_region_t rfRegion; + zpal_tx_power_t iPowerLevel, iPower0dbmMeasured; + + /* We assume operation is nonesuccessful */ + cmdRes = false; + + if (1 > inputLength) + { + /* Command length must be at least 1 byte. Return with negative response in the out buffer */ + BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; + *pOutputLength = i; + return; + } + + BYTE_IN_AR(pOutputBuffer, i++) = pInputBuffer[0]; /* Set output command ID equal input command ID */ + switch (pInputBuffer[0]) + { + + /* Report which SerialAPI Setup commands are supported beside the SERIAL_API_SETUP_CMD_SUPPORTED */ + case SERIAL_API_SETUP_CMD_SUPPORTED: + /* HOST->ZW: SERIAL_API_SETUP_CMD_SUPPORTED */ + /* ZW->HOST: SERIAL_API_SETUP_CMD_SUPPORTED | + * (SERIAL_API_SETUP_CMD_TX_STATUS_REPORT + SERIAL_API_SETUP_CMD_RF_REGION_GET + SERIAL_API_SETUP_CMD_RF_REGION_SET + + * SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET + SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET + + * SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE + SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET) | */ + /* supportedBitmask */ + + BYTE_IN_AR(pOutputBuffer, i++) = SERIAL_API_SETUP_CMD_TX_STATUS_REPORT | SERIAL_API_SETUP_CMD_RF_REGION_GET | + SERIAL_API_SETUP_CMD_RF_REGION_SET | SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET | + SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET | SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE | + SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET | SERIAL_API_SETUP_CMD_SUPPORTED; + + /* Report all supported commands as bitmask of their values */ + uint8_t supportedBitmask[32]; + memset(supportedBitmask, 0, sizeof(supportedBitmask)); + /* For each command in eSerialAPISetupCmd, find a byte number in supportedBitmask where it should be, + * and position (offset) in it and then add it to the array. */ + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_SUPPORTED); // (1) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_STATUS_REPORT); // (2) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET); // (4) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET); // (8) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE); // (16) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_RF_REGION_GET); // (32) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_RF_REGION_SET); // (64) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET); // (128) + + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET); // (3) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET); // (5) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_GET_MAX_LR_PAYLOAD_SIZE); // (17) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_16_BIT); // (18) + BITMASK_ADD_CMD(supportedBitmask, SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET_16_BIT); // (19) + + /* Currently supported command with the highest value is SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET. + No commands after it. */ + for (int j = 0; j <= SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET/8; j++) + { + BYTE_IN_AR(pOutputBuffer, i++) = supportedBitmask[j]; + } + break; + + case SERIAL_API_SETUP_CMD_TX_STATUS_REPORT: + /* HOST->ZW: SERIAL_API_SETUP_CMD_TX_STATUS_REPORT | EnableTxStatusReport */ + /* ZW->HOST: SERIAL_API_SETUP_CMD_TX_STATUS_REPORT | cmdRes */ + if (SERIAL_API_SETUP_CMD_TX_STATUS_REPORT_CMD_LENGTH_MIN <= inputLength) + { + /* Do we enable or disable */ + bTxStatusReportEnabled = (0 != pInputBuffer[1]); + /* Operation successful */ + cmdRes = true; + } + BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; + break; + + /* Report RF region configuration */ + case SERIAL_API_SETUP_CMD_RF_REGION_GET: + /* HOST->ZW: SERIAL_API_SETUP_CMD_RF_REGION_GET */ + /* ZW->HOST: SERIAL_API_SETUP_CMD_RF_REGION_GET | rfRRegion */ + if (false == ReadApplicationRfRegion(&rfRegion)) + { + /* Error reading value from flash. (Should not happen). Return undefined value. */ + rfRegion = REGION_UNDEFINED; + } + BYTE_IN_AR(pOutputBuffer, i++) = rfRegion; + break; + + /* Set RF region configuration */ + case SERIAL_API_SETUP_CMD_RF_REGION_SET: + /* HOST->ZW: SERIAL_API_SETUP_CMD_RF_REGION_SET | rfRegion */ + /* ZW->HOST: SERIAL_API_SETUP_CMD_RF_REGION_SET | cmdRes */ + if (SERIAL_API_SETUP_CMD_RF_REGION_SET_CMD_LENGTH_MIN <= inputLength) + { + rfRegion = pInputBuffer[1]; + /* Check if the RF Region value is valid, and then store it in flash */ + if ((rfRegion <= REGION_US_LR) || (rfRegion == REGION_JP) || (rfRegion == REGION_KR)) + { + /* Save into nvm */ + cmdRes = SaveApplicationRfRegion(rfRegion); + } + } + BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; + break; + + case SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET: + { + zpal_tx_power_t iTxPower, iAdjust; + /** + * HOST->ZW: SERIAL_API_SETUP_CMD_TX_POWER_SET | NormalTxPowerLevel | Measured0dBmPower + * ZW->HOST: SERIAL_API_SETUP_CMD_TX_POWER_SET | cmdRes + */ + if (SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_CMD_LENGTH_MIN <= inputLength) + { + iTxPower = (int8_t)pInputBuffer[1]; + iAdjust = (int8_t)pInputBuffer[2]; + /** + * The min and max boundaries of int8_t are valid boundaries of the parameters that are being stored. + * However, this command does not support a higher value than 127 deci dBm or lower than -127 deci dBm + * for the parameters as a limitation of this SerialAPI command. + * + * Please use SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_16_BIT which support our entire tx power range. + */ + cmdRes = SaveApplicationTxPowerlevel(iTxPower, iAdjust); + } + BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; // true if success + break; + } + + case SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET: + /** + * HOST->ZW: SERIAL_API_SETUP_CMD_TX_POWER_GET + * ZW->HOST: SERIAL_API_SETUP_CMD_TX_POWER_GET | NormalTxPowerLevel | Measured0dBmPower + */ + ReadApplicationTxPowerlevel(&iPowerLevel, &iPower0dbmMeasured); + + /** + * This SerialAPI command has the following limitation that it cannot retrieve stored tx power values that are + * larger than 127 deci dBm or lower than -127 deci dBm. + */ + + // Clamp values to fit into the return parameter type of int8_t. + if (iPowerLevel > INT8_MAX) { + iPowerLevel = INT8_MAX; + } else if (iPowerLevel < INT8_MIN) { + iPowerLevel = INT8_MIN; + } + + if (iPower0dbmMeasured > INT8_MAX) { + iPower0dbmMeasured = INT8_MAX; + } else if (iPower0dbmMeasured < INT8_MIN) { + iPower0dbmMeasured = INT8_MIN; + } + + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)iPowerLevel; + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)iPower0dbmMeasured; + break; + + case SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_16_BIT: + { + zpal_tx_power_t iTxPower, iAdjust; + zpal_tx_power_t iTxPowerMaxSupported; + /** + * HOST->ZW: SERIAL_API_SETUP_CMD_TX_POWER_SET | NormalTxPowerLevel (MSB) |NormalTxPowerLevel (LSB) | Measured0dBmPower (MSB)| Measured0dBmPower (LSB) + * ZW->HOST: SERIAL_API_SETUP_CMD_TX_POWER_SET | cmdRes + */ + if (SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_CMD_LENGTH_MIN <= inputLength) + { + iTxPower = (zpal_tx_power_t)GET_16BIT_VALUE(&pInputBuffer[1]); + iAdjust = (zpal_tx_power_t)GET_16BIT_VALUE(&pInputBuffer[3]); + iTxPowerMaxSupported = GetMaxSupportedTxPower(); + + /** + * Only allow power level between -10dBm and 14 or 20dBm if 20dBm OPN used (API is in deci dBm) + * Only allow measured0dBmPower level between -10dBm and 10dBm + */ + if (( iTxPower >= -ZW_TX_POWER_10DBM) + && (iTxPower <= iTxPowerMaxSupported) + && (iAdjust >= -ZW_TX_POWER_10DBM) + && (iAdjust <= ZW_TX_POWER_10DBM) + ) + { + cmdRes = SaveApplicationTxPowerlevel(iTxPower, iAdjust); + } + } + BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; // true if success + break; + } + + case SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET_16_BIT: + /** + * HOST->ZW: SERIAL_API_SETUP_CMD_TX_POWER_GET_2 + * ZW->HOST: SERIAL_API_SETUP_CMD_TX_POWER_GET_2 | NormalTxPowerLevel (16bit) | Measured0dBmPower (16bit) + */ + ReadApplicationTxPowerlevel(&iPowerLevel, &iPower0dbmMeasured); + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)((iPowerLevel >> 8) & 0xFF); // Big-endian + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)(iPowerLevel & 0xFF); + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)((iPower0dbmMeasured >> 8) & 0xFF); + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)(iPower0dbmMeasured & 0xFF); + break; + + case SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE: + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)ZAF_getAppHandle()->pNetworkInfo->MaxPayloadSize; + break; + + case SERIAL_API_SETUP_CMD_TX_GET_MAX_LR_PAYLOAD_SIZE: + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)ZAF_getAppHandle()->pLongRangeInfo->MaxLongRangePayloadSize; + break; + + /* Set the Node ID base type */ + case SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET: + /* HOST->ZW: SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET | type */ + /* ZW->HOST: SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET | cmdRes */ + nodeIdBaseType = SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT; + if ( (SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET_CMD_LENGTH_MIN <= inputLength) && + (0 < pInputBuffer[1]) && + (SERIAL_API_SETUP_NODEID_BASE_TYPE_LAST > pInputBuffer[1]) ) + { + /* Set the global Node ID base type if input value is valid */ + nodeIdBaseType = pInputBuffer[1]; + SaveApplicationNodeIdBaseType(nodeIdBaseType); + cmdRes = true; + } + BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; + break; + case SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET: + { + /** + * HOST->ZW: SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET | maxtxpower (16-bit) + * ZW->HOST: SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET | cmdRes + */ + zpal_tx_power_t iTxPower; + zpal_tx_power_t iTxPowerMaxSupported; + + if (SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_CMD_LENGTH_MIN <= inputLength) + { + iTxPower = (zpal_tx_power_t)GET_16BIT_VALUE(&pInputBuffer[1]); + iTxPowerMaxSupported = GetMaxSupportedTxPower(); + + /** + * Only allow power level between -10dBm and 14 or 20dBm if 20dBm OPN used (API is in deci dBm) + */ + if (( iTxPower >= -ZW_TX_POWER_10DBM) + && (iTxPower <= iTxPowerMaxSupported) + ) + { + cmdRes = SaveApplicationMaxLRTxPwr(iTxPower); + } + } + BYTE_IN_AR(pOutputBuffer, i++) = cmdRes; // true if success + break; + } + + case SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET: + /** + * HOST->ZW: SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET + * ZW->HOST: SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET | maxtxpower (16-bit) + */ + { + int16_t readout; + ReadApplicationMaxLRTxPwr(&readout); + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)((readout >> 8) & 0xFF); + BYTE_IN_AR(pOutputBuffer, i++) = (uint8_t)(readout & 0xFF); + } + break; + + default: + /* HOST->ZW: [SomeUnsupportedCmd] | [SomeData] */ + /* ZW->HOST: SERIAL_API_SETUP_CMD_UNSUPPORTED | [SomeUnsupportedCmd] */ + /* All other commands are unsupported */ + BYTE_IN_AR(pOutputBuffer, 0) = SERIAL_API_SETUP_CMD_UNSUPPORTED; + BYTE_IN_AR(pOutputBuffer, i++) = pInputBuffer[0]; + break; + } + + *pOutputLength = i; +} + +void func_id_serial_api_get_nvr(__attribute__((unused)) uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength) +{ + uint8_t offset = pInputBuffer[0]; + uint8_t bLength = pInputBuffer[1]; + uint8_t dataLen = 0; + if (PUK_OFFSET == offset) + { + dataLen = bLength; + if (TOKEN_MFG_ZW_PUK_SIZE < bLength) + { + dataLen = TOKEN_MFG_ZW_PUK_SIZE; + } + ZW_GetMfgTokenData(pOutputBuffer, TOKEN_MFG_ZW_PUK_ID, dataLen); + } + else if (PRK_OFFSET == offset) + { + dataLen = bLength; + if (TOKEN_MFG_ZW_PRK_SIZE < bLength) + { + dataLen = TOKEN_MFG_ZW_PRK_SIZE; + } + ZW_GetMfgTokenData(pOutputBuffer, TOKEN_MFG_ZW_PRK_ID, dataLen); + } + else if (HW_VER_OFFSET == offset) + { + dataLen = bLength; + if (HW_VER_SIZE < bLength) + { + dataLen = HW_VER_SIZE; + } + *pOutputBuffer = 0xFF; + } + *pOutputLength = dataLen; +} + +void func_id_zw_get_protocol_version(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength) +{ + (void)inputLength; + (void)pInputBuffer; + // Defined in the specs to be the max size of the git hash + const uint8_t git_hash_max_size = 16; + uint8_t len = 0; +#if defined(GIT_HASH_ID) + uint8_t git_hash_id[40] = GIT_HASH_ID; +#else /* defined(GIT_HASH_ID) */ + uint8_t *git_hash_id = ZW_GetProtocolGitHash(); +#endif /* defined(GIT_HASH_ID) */ + + const SApplicationHandles *pAppHandles = ZAF_getAppHandle(); + pOutputBuffer[len++] = pAppHandles->pProtocolInfo->eProtocolType; + pOutputBuffer[len++] = pAppHandles->pProtocolInfo->ProtocolVersion.Major; + pOutputBuffer[len++] = pAppHandles->pProtocolInfo->ProtocolVersion.Minor; + pOutputBuffer[len++] = pAppHandles->pProtocolInfo->ProtocolVersion.Revision; + pOutputBuffer[len++] = (uint8_t)(ZAF_BUILD_NO >> 8); + pOutputBuffer[len++] = (uint8_t)(ZAF_BUILD_NO ); + for (uint32_t i = 0 ; i < git_hash_max_size; i++,len++) + { + pOutputBuffer[len] = git_hash_id[i]; + } + *pOutputLength = len; +} + +bool InitiateShutdown( ZW_Void_Callback_t pCallback) +{ + const SApplicationHandles *pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage shutdown = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_INITIATE_SHUTDOWN, + .uCommandParams.InitiateShutdown.Handle = pCallback}; + + // Put the Command on queue (and dont wait for it, queue must be empty) + if (EQUEUENOTIFYING_STATUS_SUCCESS == QueueNotifyingSendToBack(pAppHandles->pZwCommandQueue, (uint8_t *)&shutdown, 0)) + { + // Wait for protocol to handle command + SZwaveCommandStatusPackage result = { 0 }; + if (GetCommandResponse(&result, EZWAVECOMMANDSTATUS_ZW_INITIATE_SHUTDOWN)) + { + return result.Content.InitiateShutdownStatus.result; + } + } + return false; +} diff --git a/src/zwave_ncp_serial_api_controller/cmds_management.h b/src/zwave_ncp_serial_api_controller/cmds_management.h new file mode 100644 index 00000000..d6845457 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmds_management.h @@ -0,0 +1,162 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef APPS_SERIALAPI_CMD_MANAGEMENT_H_ +#define APPS_SERIALAPI_CMD_MANAGEMENT_H_ + +#include +#include +/* FUNC_ID_SERIAL_API_SETUP command definitions */ +typedef enum +{ + /** + * The first 8 commands are given as bit-flags, and when all bits were consumed, a byte-array was created to give + * more room. + * The first 8 flags are the only ones that shall be used to fill the first byte when generating the response in + * pOutputBuffer for the command, SERIAL_API_SETUP_CMD_SUPPORTED. + * This is kept for backwards compatibility. + */ + SERIAL_API_SETUP_CMD_UNSUPPORTED, + SERIAL_API_SETUP_CMD_SUPPORTED = 1, //1<<0 + SERIAL_API_SETUP_CMD_TX_STATUS_REPORT = 2, //1<<1 + SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET = 4, //1<<2 @Deprecated + SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET = 8, //1<<3 @Deprecated + SERIAL_API_SETUP_CMD_TX_GET_MAX_PAYLOAD_SIZE = 16, //1<<4 + SERIAL_API_SETUP_CMD_RF_REGION_GET = 32, //1<<5 + SERIAL_API_SETUP_CMD_RF_REGION_SET = 64, //1<<6 + SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET = 128, //1<<7 + /** + * The below values are not flags and shall only be used with BITMASK_ADD_CMD() when generating + * the response for the command, SERIAL_API_SETUP_CMD_SUPPORTED. + */ + SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET = 3, + SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_GET = 5, + // The values 6 and 7 are unused, but not reserved. + SERIAL_API_SETUP_CMD_TX_GET_MAX_LR_PAYLOAD_SIZE = 17, + SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_16_BIT = 18, + SERIAL_API_SETUP_CMD_TX_POWERLEVEL_GET_16_BIT = 19, +} eSerialAPISetupCmd; + +/* SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET definitions */ +typedef enum +{ + SERIAL_API_SETUP_NODEID_BASE_TYPE_8_BIT = 1, + SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT, + SERIAL_API_SETUP_NODEID_BASE_TYPE_LAST, + SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT = SERIAL_API_SETUP_NODEID_BASE_TYPE_8_BIT +} eSerialAPISetupNodeIdBaseType; + +/* Global variable for specifying if the SerialAPI command Node ID fields are 8 or 16 bits */ +extern eSerialAPISetupNodeIdBaseType nodeIdBaseType; + +/* Macro for retrieving a SerialAPI command nodeID value (8 or 16 bit) at address "pData" */ +/* Increments the input argument "idx" if nodeID is two bytes wide (i.e. 16 bit) */ +#define GET_NODEID(pData, idx) \ + ( (nodeIdBaseType == SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT) ? \ + ((((uint8_t*)pData)[0] << 8) | ((uint8_t*)pData)[1]) : /* 16 bit, MSB | LSB */ \ + ((uint8_t*)pData)[0] ); /* 8 bit */ \ + do { \ + if (nodeIdBaseType == SERIAL_API_SETUP_NODEID_BASE_TYPE_16_BIT) \ + { \ + idx++; \ + } \ + } while (0) + +#define GET_16BIT_VALUE(pData) \ + ( ( (uint16_t)((uint8_t*)pData)[0] << 8) | (uint16_t)((uint8_t*)pData)[1] ) /* 16 bit, MSB | LSB */ + +/* Commands minimum length (bytes) */ +#define SERIAL_API_SETUP_CMD_TX_STATUS_REPORT_CMD_LENGTH_MIN 2 +#define SERIAL_API_SETUP_CMD_RF_REGION_SET_CMD_LENGTH_MIN 2 +#define SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET_CMD_LENGTH_MIN 3 +#define SERIAL_API_SETUP_CMD_NODEID_BASETYPE_SET_CMD_LENGTH_MIN 2 +#define SERIAL_API_SETUP_CMD_MAX_LR_TX_PWR_SET_CMD_LENGTH_MIN 3 + +/** + * Must be called upon receiving a "Node List Command". + * @param inputLength Length of data in input buffer. + * @param pInputBuffer Input buffer + * @param pOutputBuffer Output buffer + * @param pOutputLength Length of data in output buffer. + */ +void func_id_serial_api_get_init_data(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength); + +/** + * Returns bitmask of LR node IDs + * @param inputLength Length of data in input buffer. + * @param pInputBuffer Input buffer. First byte should be requested range of nodes. + * Supported values: 0, 1, 2, 3 that corresponds to offset 0, 128, 256, 384. + * @param pOutputBuffer Output buffer, contained of: MORE_NODES | BITMASK_OFFSET | BITMASK_LEN | BITMASK_ARRAY + * @param pOutputLength Length of data in output buffer. + */ +void func_id_serial_api_get_LR_nodes(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength); + +/** + * Must be called upon receiving a "Serial API Setup Command". + * @param inputLength Length of data in input buffer. + * @param pInputBuffer Input buffer + * @param pOutputBuffer Output buffer + * @param pOutputLength Length of data in output buffer. + */ +void func_id_serial_api_setup(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength); + +/** + * Must be called upon receiving a "Serial API NVR get". + * @param inputLength Length of data in input buffer. + * @param pInputBuffer Input buffer + * @param pOutputBuffer Output buffer + * @param pOutputLength Length of data in output buffer. + */ + +void +func_id_serial_api_get_nvr(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength); + +/** + * Must be called upon receiving a "Serial API ZW Get protocol version". + * @param inputLength Length of data in input buffer. + * @param pInputBuffer Input buffer + * @param pOutputBuffer Output buffer + * @param pOutputLength Length of data in output buffer. + */ + +void +func_id_zw_get_protocol_version(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength); + +/** + * Remove a specific node from the network + * The node is identified by node ID + * @param inputLength Length of data in input buffer. + * @param pInputBuffer Input buffer + * @param pOutputBuffer Output buffer + * @param pOutputLength Length of data in output buffer. + */ +void func_id_ZW_RemoveNodeIDFromNetwork (uint8_t inputLength, + uint8_t *pInputBuffer, + const uint8_t *pOutputBuffer, + const uint8_t *pOutputLength); + +/** + * Initiate device graceful shutdown + * + * @param pCallback pointer to notifcation callback function. Function is called just before deice go into deepsleep + * @return true if Shutdown process start, else false + */ +bool InitiateShutdown( ZW_Void_Callback_t pCallback); +#endif /* APPS_SERIALAPI_CMD_MANAGEMENT_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/cmds_power_management.c b/src/zwave_ncp_serial_api_controller/cmds_power_management.c new file mode 100644 index 00000000..0502891e --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmds_power_management.c @@ -0,0 +1,63 @@ +/** + * @file + * Offers Power Management commands for Silabs targets only. + * @attention Must be linked for Silabs build targets only. + * @copyright 2022 Silicon Laboratories Inc. + */ +#include +#include "cmd_handlers.h" +#include "ZW_SerialAPI.h" +#include "app.h" +#include "zpal_power_manager.h" +#include "SwTimer.h" +#include "AppTimer.h" + +extern zpal_pm_handle_t radio_power_lock; +extern zpal_pm_handle_t io_power_lock; +extern SSwTimer mWakeupTimer; + +ZW_ADD_CMD(FUNC_ID_PM_STAY_AWAKE) +{ + /* HOST->ZW: PowerLock Type, timeout of stay awake, timeout of wakeup */ + /* Power locks type 0 for radio and 1 for peripheral*/ + uint32_t timeout = (uint32_t)(frame->payload[1]<<24); + timeout |= (uint32_t)(frame->payload[2]<<16); + timeout |= (uint32_t)(frame->payload[3]<<8); + timeout |= (uint32_t)(frame->payload[4]); + + uint32_t timeoutwakeup = (uint32_t)(frame->payload[5]<<24); + timeoutwakeup |= (uint32_t)(frame->payload[6]<<16); + timeoutwakeup |= (uint32_t)(frame->payload[7]<<8); + timeoutwakeup |= (uint32_t)(frame->payload[8]); + + if (0 == frame->payload[0]) + { + zpal_pm_stay_awake(radio_power_lock, timeout); + } + else if (1 == frame->payload[0]) + { + zpal_pm_stay_awake(io_power_lock, timeout); + } + + if (timeout && timeoutwakeup) + { + AppTimerDeepSleepPersistentStart(&mWakeupTimer, timeoutwakeup); + } + set_state_and_notify(stateIdle); +} + + +ZW_ADD_CMD(FUNC_ID_PM_CANCEL) +{ + /* HOST->ZW: PowerLock Type*/ + /*Power locks type 0 for radio and 1 for peripheral*/ + if (0 == frame->payload[0]) + { + zpal_pm_cancel(radio_power_lock); + } + else if (1 == frame->payload[0]) + { + zpal_pm_cancel(io_power_lock); + } + set_state_and_notify(stateIdle); +} diff --git a/src/zwave_ncp_serial_api_controller/cmds_rf.c b/src/zwave_ncp_serial_api_controller/cmds_rf.c new file mode 100644 index 00000000..19dec5b5 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmds_rf.c @@ -0,0 +1,32 @@ +/**************************************************************************//** + * @file cmds_rf.c + * @brief The source file for command handling of RF related serialAPI + * commands + * @copyright 2022 Silicon Laboratories Inc. + *****************************************************************************/ + +#include +#include +#include +#include + +#ifdef SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD +void func_id_set_listen_before_talk(__attribute__((unused)) uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength) +{ + uint8_t bReturn; + SZwaveCommandPackage setLBTMode = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_SET_LBT_THRESHOLD, + .uCommandParams.SetLBTThreshold.channel = pInputBuffer[0], + .uCommandParams.SetLBTThreshold.level = (int8_t)pInputBuffer[1] + }; + + bReturn = QueueProtocolCommand((uint8_t*)&setLBTMode); + + pOutputBuffer[0] = ((EQUEUENOTIFYING_STATUS_SUCCESS == bReturn) ? true : false); + *pOutputLength = 1; +} +#endif + diff --git a/src/zwave_ncp_serial_api_controller/cmds_rf.h b/src/zwave_ncp_serial_api_controller/cmds_rf.h new file mode 100644 index 00000000..9a85b50d --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmds_rf.h @@ -0,0 +1,22 @@ +/**************************************************************************//** + * @file + * @brief The header file for command handling of RF related serialAPI + * commands + * @copyright 2022 Silicon Laboratories Inc. + *****************************************************************************/ + +#ifndef APPS_SERIALAPI_CMD_RF_H_ +#define APPS_SERIALAPI_CMD_RF_H_ + +#include + +void func_id_set_listen_before_talk(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength); +void func_id_set_powerlevel(uint8_t inputLength, + uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength); + +#endif /* APPS_SERIALAPI_CMD_RF_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/cmds_security.c b/src/zwave_ncp_serial_api_controller/cmds_security.c new file mode 100644 index 00000000..bd0a077b --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmds_security.c @@ -0,0 +1,136 @@ +/** + * @file cmds_security.c + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include +#include +#include +#include +#include + +//#define DEBUGPRINT +#include + +#define SUPPORT_ZW_GET_SECURITY_S2_PUBLIC_DSK 1 + +/* FUNC_ID_ZW_SECURITY_SETUP command definitions. */ +typedef enum +{ + E_SECURITY_SETUP_CMD_ZW_GET_SECURITY_KEYS = 0, + E_SECURITY_SETUP_CMD_ZW_SET_SECURITY_S0_NETWORK_KEY, // OBSOLETE + E_SECURITY_SETUP_CMD_ZW_GET_SECURITY_S2_PUBLIC_DSK, + E_SECURITY_SETUP_CMD_ZW_SET_SECURITY_S2_CRITICAL_NODE_ID, // OBSOLETE + E_SECURITY_SETUP_CMD_ZW_SET_SECURITY_S2_INCLUSION_PUBLIC_DSK_CSA, // OBSOLETE + E_SECURITY_SETUP_CMD_SET_SECURITY_INCLUSION_REQUESTED_KEYS, + E_SECURITY_SETUP_CMD_SET_SECURITY_INCLUSION_REQUESTED_AUTHENTICATION, // OBSOLETE + E_SECURITY_SETUP_CMD_GET_SECURITY_CAPABILITIES = 0xFE, + E_SECURITY_SETUP_CMD_UNKNOWN = 0xFF +} eSecuritySetupCmd_t; + +/* FUNC_ID_ZW_SECURITY_SETUP command supported definitions. */ +/* Used together with the Security Setup command GetSecurityCapabilities */ +/* returned supported command bitmask to determine if a specific command are supported */ +typedef enum +{ + E_SECURITY_SETUP_SUPPORT_CMD_ZW_GET_SECURITY_KEYS = (1<ZW: securityFuncID [| bDataLen | abData[bDataLen]] */ + /* ZW->HOST: securityFuncID | bretValLen | retVal[bretValLen] */ + *pOutputBuffer = *pInputBuffer; + switch ((eSecuritySetupCmd_t)*pInputBuffer) + { +#if SUPPORT_ZW_GET_SECURITY_KEYS + case E_SECURITY_SETUP_CMD_ZW_GET_SECURITY_KEYS: + { + /* HOST->ZW: */ + /* ZW->HOST: securityKeys_bitmaskLen(1) | securityKeys_bitmask[securityKeys_bitmaskLen] */ + *(pOutputBuffer + 1) = 1; + *(pOutputBuffer + 2) = ZAF_GetSecurityKeys(); + *pOutputLength = 3; + } + break; + + case E_SECURITY_SETUP_CMD_SET_SECURITY_INCLUSION_REQUESTED_KEYS: + { + /* HOST->ZW: registeredSecurityKeysLen(1) | registeredSecurityKeys */ + /* ZW->HOST: retValLen(1) | retVal[retValLen] */ + bool retVal = false; + if (1 == *(pInputBuffer + 1)) + { + /* Set the requestedSecurityKeysBits requested by protocol when doing S2 inclusion */ + //SecureKeysRequested = serial_frame->payload[2]; + SZwaveCommandPackage Package = { + .eCommandType = EZWAVECOMMANDTYPE_SET_SECURITY_KEYS, + .uCommandParams.SetSecurityKeys.keys = *(pInputBuffer + 2) + }; + QueueNotifyingSendToBack(ZAF_getAppHandle()->pZwCommandQueue, (uint8_t *)&Package, 0); + /* sRequestedSecuritySettings.requestedSecurityKeysBits are either the initialized */ + /* define value (REQUESTED_SECURITY_KEYS) or the value set through the FUNC_ID_ZW_SECURITY_SETUP */ + /* function E_SECURITY_SETUP_CMD_SET_SECURITY_INCLUSION_REQUESTED_AUTHENTICATION */ + // FIXME insert check of if protocol has been started yet. + // if it has - return false. + retVal = true; + } + *(pOutputBuffer + 1) = 1; + *(pOutputBuffer + 2) = retVal; + *pOutputLength = 3; + } + break; +#endif +#if SUPPORT_ZW_GET_SECURITY_S2_PUBLIC_DSK + case E_SECURITY_SETUP_CMD_ZW_GET_SECURITY_S2_PUBLIC_DSK: + { + /* HOST->ZW: */ + /* ZW->HOST: retValLen(SECURITY_KEY_S2_PUBLIC_DSK_LENGTH) | retVal[retValLen] */ + *(pOutputBuffer + 1) = SECURITY_KEY_S2_PUBLIC_DSK_LENGTH; + ZW_GetMfgTokenData(pOutputBuffer + 2, TOKEN_MFG_ZW_PUK_ID, SECURITY_KEY_S2_PUBLIC_DSK_LENGTH); + *pOutputLength = 2 + SECURITY_KEY_S2_PUBLIC_DSK_LENGTH; + } + break; +#endif + + case E_SECURITY_SETUP_CMD_GET_SECURITY_CAPABILITIES: + { + /* HOST->ZW: */ + /* ZW->HOST: securitySetup_bitmaskLen | securityKeys_bitmask[securitySetup_bitmaskLen] */ + *(pOutputBuffer + 1) = 1; + /* LSB first if more than one byte in securityKeys_bitmask[] */ + *(pOutputBuffer + 2) = 0 +#if SUPPORT_ZW_GET_SECURITY_KEYS + | E_SECURITY_SETUP_SUPPORT_CMD_ZW_GET_SECURITY_KEYS + | E_SECURITY_SETUP_SUPPORT_CMD_SET_SECURITY_INCLUSION_REQUESTED_KEYS +#endif +#if SUPPORT_ZW_GET_SECURITY_S2_PUBLIC_DSK + | E_SECURITY_SETUP_SUPPORT_CMD_ZW_GET_SECURITY_S2_PUBLIC_DSK +#endif + ; + *pOutputLength = 3; + } + break; + + default: + { + /* ZW->HOST: E_SECURITY_SETUP_UNKNOWN_COMMAND | retValLen | securityFuncID(called)[retValLen] */ + *(pOutputBuffer + 0) = E_SECURITY_SETUP_CMD_UNKNOWN; + *(pOutputBuffer + 1) = 1; + /* Return the called Unknown FUNC_ID_ZW_SECURITY_SETUP Command */ + *(pOutputBuffer + 2) = *pInputBuffer; + *pOutputLength = 3; + } + break; + } + } +} diff --git a/src/zwave_ncp_serial_api_controller/cmds_security.h b/src/zwave_ncp_serial_api_controller/cmds_security.h new file mode 100644 index 00000000..54ac23be --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/cmds_security.h @@ -0,0 +1,16 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef APPS_SERIALAPI_CMDS_SECURITY_H_ +#define APPS_SERIALAPI_CMDS_SECURITY_H_ + +#include + +void func_id_zw_security_setup(uint8_t inputLength, + const uint8_t *pInputBuffer, + uint8_t *pOutputBuffer, + uint8_t *pOutputLength); + +#endif /* APPS_SERIALAPI_CMDS_SECURITY_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/comm_interface.c b/src/zwave_ncp_serial_api_controller/comm_interface.c new file mode 100644 index 00000000..880d3e29 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/comm_interface.c @@ -0,0 +1,519 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include "comm_interface.h" +#include "zpal_uart.h" +#include "ZW_SerialAPI.h" +#include "SwTimer.h" +#include "utils.h" +#include +#include "AppTimer.h" +#include "Assert.h" +#include "SerialAPI_hw.h" + +#define BUFFER_CHECK_TIME_MS 250 +#define DEFAULT_ACK_TIMEOUT_MS 1500 +#define DEFAULT_BYTE_TIMEOUT_MS 150 +#define HEADER_LEN 4 +#define ACK_LEN 1 +#define CRC_LEN 1 + +#define COMM_INT_TX_BUFFER_SIZE 200 +#define COMM_INT_RX_BUFFER_SIZE 200 +#define TRANSMIT_BUFFER_SIZE COMM_INT_TX_BUFFER_SIZE + + +typedef enum +{ + COMM_INTERFACE_STATE_SOF = 0, + COMM_INTERFACE_STATE_LEN = 1, + COMM_INTERFACE_STATE_TYPE = 2, + COMM_INTERFACE_STATE_CMD = 3, + COMM_INTERFACE_STATE_DATA = 4, + COMM_INTERFACE_STATE_CHECKSUM = 5, +} comm_interface_state_t; + +typedef struct +{ + transport_t transport; + SSwTimer ack_timer; + bool ack_timeout; + uint32_t ack_timeout_ms; + SSwTimer byte_timer; + bool byte_timeout; + uint32_t byte_timeout_ms; + SSwTimer buffer_check_timer; + comm_interface_state_t state; + uint8_t expect_bytes; + bool ack_needed; + uint8_t buffer_len; + uint8_t buffer[RECEIVE_BUFFER_SIZE]; + bool rx_active; + uint8_t rx_wait_count; +} comm_interface_t; + +typedef struct +{ + uint8_t sof; + uint8_t len; + uint8_t type; + uint8_t cmd; + uint8_t payload[UINT8_MAX]; +} tx_frame_t; + + +static comm_interface_t comm_interface = { 0 }; +comm_interface_frame_ptr const serial_frame = (comm_interface_frame_ptr)comm_interface.buffer; + +static uint8_t tx_data[COMM_INT_TX_BUFFER_SIZE]; +static uint8_t rx_data[COMM_INT_RX_BUFFER_SIZE]; + +static void set_expect_bytes(uint8_t level) +{ + vPortEnterCritical(); + + if (zpal_uart_get_available(comm_interface.transport.handle) >= level) + { + comm_interface.expect_bytes = 0; + TriggerNotification(EAPPLICATIONEVENT_SERIALDATARX); + } + else + { + comm_interface.expect_bytes = level; + } + + vPortExitCritical(); +} + +static void receive_callback(__attribute__((unused)) const zpal_uart_handle_t handle, size_t available) +{ + if (available >= comm_interface.expect_bytes) + { + comm_interface.expect_bytes = 0; + TriggerNotification(EAPPLICATIONEVENT_SERIALDATARX); + } +} + +static void ack_timer_cb(__attribute__((unused)) SSwTimer *timer) +{ + comm_interface.ack_timeout = true; + TriggerNotification(EAPPLICATIONEVENT_SERIALTIMEOUT); +} + +static void byte_timer_cb(__attribute__((unused)) SSwTimer *timer) +{ + comm_interface.byte_timeout = true; + TriggerNotification(EAPPLICATIONEVENT_SERIALTIMEOUT); +} + +static void buffer_check_timer_cb(__attribute__((unused)) SSwTimer *timer) +{ + if(zpal_uart_get_available(comm_interface.transport.handle)) + { + TriggerNotification(EAPPLICATIONEVENT_SERIALDATARX); + } +} + +static uint8_t xor_checksum(uint8_t init, const uint8_t *data, uint8_t len) +{ + uint8_t checksum = init; + + for (int i = 0; i < len; i++) + { + checksum ^= data[i]; + } + + return checksum; +} + +static zpal_status_t comm_interface_transmit(transport_t *transport, const uint8_t *data, size_t len, transmit_done_cb_t cb) +{ + if (transport) + { + switch (transport->type) + { + case TRANSPORT_TYPE_UART: + return zpal_uart_transmit(transport->handle, data, len, cb); + + default: + break; + } + } + + return ZPAL_STATUS_FAIL; +} + +void comm_interface_transmit_frame(uint8_t cmd, uint8_t type, const uint8_t *payload, uint8_t len, transmit_done_cb_t cb) +{ + tx_frame_t frame = { + .sof = SOF + }; + static uint8_t _len, _type, _cmd, _checksum; + static const uint8_t *_payload; + + TimerStop(&comm_interface.ack_timer); + TimerStop(&comm_interface.byte_timer); + TimerStop(&comm_interface.buffer_check_timer); + + comm_interface.byte_timeout = false; + comm_interface.ack_timeout = false; + + if (payload != NULL) + { + frame.len = len + 3; + frame.type = type; + frame.cmd = cmd; + memcpy(frame.payload, payload, len); + frame.payload[len] = xor_checksum(0xFF, &frame.len, frame.len); + + /* store input arguments for retransmission */ + _len = len; + _type = type; + _cmd = cmd; + _payload = payload; + _checksum = frame.payload[len]; + } + else + { + /* retransmit last frame */ + frame.len = _len + 3; + frame.type = _type; + frame.cmd = _cmd; + if(_payload) { + memcpy(frame.payload, _payload, _len); + } + frame.payload[_len] = _checksum; + } + + comm_interface.ack_needed = true; + set_expect_bytes(ACK_LEN); + comm_interface_transmit(&comm_interface.transport, (uint8_t *)&frame, frame.len + 2, cb); + TimerStart(&comm_interface.ack_timer, comm_interface_get_ack_timeout_ms()); + TimerStart(&comm_interface.buffer_check_timer, BUFFER_CHECK_TIME_MS); +} + +void comm_interface_wait_transmit_done(void) +{ + while(zpal_uart_transmit_in_progress(comm_interface.transport.handle)); +} + +void comm_interface_init(void) +{ + const zpal_uart_config_t uart_config = + { + .tx_buffer = tx_data, + .tx_buffer_len = COMM_INT_TX_BUFFER_SIZE, + .rx_buffer = rx_data, + .rx_buffer_len = COMM_INT_RX_BUFFER_SIZE, + .id = ZPAL_UART0, + .baud_rate = 115200, + .data_bits = 8, + .parity_bit = ZPAL_UART_NO_PARITY, + .stop_bits = ZPAL_UART_STOP_BITS_1, + .receive_callback = receive_callback, + .ptr = SerialAPI_get_uart_config_ext(), + }; + + comm_interface_set_ack_timeout_ms(DEFAULT_ACK_TIMEOUT_MS); + comm_interface_set_byte_timeout_ms(DEFAULT_BYTE_TIMEOUT_MS); + + zpal_status_t status = zpal_uart_init(&uart_config, &comm_interface.transport.handle); + ASSERT(status == ZPAL_STATUS_OK); + status = zpal_uart_enable(comm_interface.transport.handle); + ASSERT(status == ZPAL_STATUS_OK); + comm_interface.transport.type = TRANSPORT_TYPE_UART; + + AppTimerRegister(&comm_interface.ack_timer, false, ack_timer_cb); + TimerStop(&comm_interface.ack_timer); + + AppTimerRegister(&comm_interface.byte_timer, false, byte_timer_cb); + TimerStop(&comm_interface.byte_timer); + + AppTimerRegister(&comm_interface.buffer_check_timer, true, buffer_check_timer_cb); + TimerStop(&comm_interface.buffer_check_timer); + + comm_interface.state = COMM_INTERFACE_STATE_SOF; + comm_interface.buffer_len = 0; + set_expect_bytes(HEADER_LEN); +} + +uint32_t comm_interface_get_ack_timeout_ms(void) +{ + return comm_interface.ack_timeout_ms; +} + +void comm_interface_set_ack_timeout_ms(uint32_t t) +{ + comm_interface.ack_timeout_ms = t; +} + +uint32_t comm_interface_get_byte_timeout_ms(void) +{ + return comm_interface.byte_timeout_ms; +} + +void comm_interface_set_byte_timeout_ms(uint32_t t) +{ + comm_interface.byte_timeout_ms = t; +} + +static void store_byte(uint8_t byte) +{ + if (TimerIsActive(&comm_interface.byte_timer)) + TimerRestart(&comm_interface.byte_timer); + else + TimerStart(&comm_interface.byte_timer, comm_interface_get_byte_timeout_ms()); + + comm_interface.byte_timeout = false; + comm_interface.buffer[comm_interface.buffer_len] = byte; + comm_interface.buffer_len++; +} + +static comm_interface_parse_result_t handle_sof(uint8_t input) +{ + comm_interface_parse_result_t result = PARSE_IDLE; + + if (input == SOF) + { + comm_interface.state = COMM_INTERFACE_STATE_LEN; + comm_interface.buffer_len = 0; + comm_interface.rx_active = true; // now we're receiving - check for timeout + store_byte(input); + } + else + { + if (comm_interface.ack_needed) + { + if ((input == ACK) || (input == NAK)) + { + comm_interface.ack_needed = false; // Done + comm_interface.ack_timeout = false; + comm_interface.byte_timeout = false; + TimerStop(&comm_interface.ack_timer); + TimerStop(&comm_interface.byte_timer); + TimerStop(&comm_interface.buffer_check_timer); + } + if (input == ACK) + { + result = PARSE_FRAME_SENT; + } + else if (input == NAK) + { + result = PARSE_TX_TIMEOUT; + } + else + { + // Bogus character received... + } + } + else + { + comm_interface.ack_timeout = false; + TimerStop(&comm_interface.ack_timer); + TimerStop(&comm_interface.buffer_check_timer); + } + } + return result; +} + +static void handle_len(uint8_t input) +{ + // Check for length to be inside valid range + if ((input < FRAME_LENGTH_MIN) || (input > FRAME_LENGTH_MAX)) + { + comm_interface.state = COMM_INTERFACE_STATE_SOF; // Restart looking for SOF + comm_interface.rx_active = false; // Not really active now... + TimerStop(&comm_interface.byte_timer); + comm_interface.byte_timeout = false; + } + else + { + comm_interface.state = COMM_INTERFACE_STATE_TYPE; + store_byte(input); + } +} + +static void handle_type(uint8_t input) +{ + if (input > RESPONSE) + { + comm_interface.state = COMM_INTERFACE_STATE_SOF; // Restart looking for SOF + comm_interface.rx_active = false; // Not really active now... + TimerStop(&comm_interface.byte_timer); + comm_interface.byte_timeout = false; + } + else + { + comm_interface.state = COMM_INTERFACE_STATE_CMD; + store_byte(input); + } +} + +static void handle_cmd(uint8_t input) +{ + store_byte(input); + + if(serial_frame->len > 3) + { + comm_interface.rx_wait_count = serial_frame->len - 3; + comm_interface.state = COMM_INTERFACE_STATE_DATA; + } + else + { + comm_interface.rx_wait_count = 1; + comm_interface.state = COMM_INTERFACE_STATE_CHECKSUM; + } +} + +static void handle_data(uint8_t input) +{ + comm_interface.rx_wait_count--; + store_byte(input); + + if ((comm_interface.buffer_len >= RECEIVE_BUFFER_SIZE) || + (comm_interface.buffer_len > serial_frame->len)) //buffer_len - sizeof(sof) >= serial_frame->len + { + comm_interface.state = COMM_INTERFACE_STATE_CHECKSUM; + } +} + +static comm_interface_parse_result_t handle_checksum(uint8_t input, bool ack) +{ + TimerStop(&comm_interface.byte_timer); + comm_interface.byte_timeout = false; + comm_interface.state = COMM_INTERFACE_STATE_SOF; // Restart looking for SOF + comm_interface.rx_active = false; // Not really active + + /* Default values for ack == false */ + /* It means we are in the process of looking for an acknowledge to a callback request */ + /* Drop the new frame we received - we don't have time to handle it. */ + comm_interface_parse_result_t result = PARSE_IDLE; + uint8_t response = CAN; + + /* Do we send ACK/NAK according to checksum... */ + /* if not then the received frame is dropped! */ + if (ack) + { + uint8_t checksum = xor_checksum(0xFF, &serial_frame->len, serial_frame->len); + result = (input == checksum) ? PARSE_FRAME_RECEIVED : PARSE_FRAME_ERROR; + response = (input == checksum) ? ACK : NAK; + } + + comm_interface_transmit(&comm_interface.transport, &response, sizeof(response), NULL); + + return result; +} + +static void handle_default(void) +{ + comm_interface.state = COMM_INTERFACE_STATE_SOF; // Restart looking for SOF + comm_interface.rx_active = false; // Not really active now... + comm_interface.ack_timeout = false; + comm_interface.byte_timeout = false; + TimerStop(&comm_interface.ack_timer); + TimerStop(&comm_interface.buffer_check_timer); + TimerStop(&comm_interface.byte_timer); +} + +comm_interface_parse_result_t comm_interface_parse_data(bool ack) +{ + uint8_t rx_byte; + comm_interface_parse_result_t result = PARSE_IDLE; + + while ((result == PARSE_IDLE) && zpal_uart_get_available(comm_interface.transport.handle)) + { + zpal_uart_receive(comm_interface.transport.handle, &rx_byte, sizeof(rx_byte)); + + switch (comm_interface.state) + { + case COMM_INTERFACE_STATE_SOF: + result = handle_sof(rx_byte); + break; + + case COMM_INTERFACE_STATE_LEN: + handle_len(rx_byte); + break; + + case COMM_INTERFACE_STATE_TYPE: + handle_type(rx_byte); + break; + + case COMM_INTERFACE_STATE_CMD: + handle_cmd(rx_byte); + break; + + case COMM_INTERFACE_STATE_DATA: + handle_data(rx_byte); + break; + + case COMM_INTERFACE_STATE_CHECKSUM: + result = handle_checksum(rx_byte, ack); + break; + + default : + handle_default(); + break; + } + } + + /* Check for timeouts - if no other events detected */ + if (result == PARSE_IDLE) + { + /* Are we in the middle of collecting a frame and have we timed out? */ + if (comm_interface.rx_active && comm_interface.byte_timeout) + { + comm_interface.byte_timeout = false; + /* Reset to SOF hunting */ + comm_interface.state = COMM_INTERFACE_STATE_SOF; + comm_interface.rx_active = false; /* Not inframe anymore */ + result = PARSE_RX_TIMEOUT; + } + + /* Are we waiting for ACK and have we timed out? */ + if (comm_interface.ack_needed && comm_interface.ack_timeout) + { + comm_interface.ack_timeout = false; + /* Reset to SOF hunting */ + comm_interface.state = COMM_INTERFACE_STATE_SOF; + /* Not waiting for ACK anymore */ + comm_interface.ack_needed = false; + /* Tell upper layer we could not get the frame through */ + result = PARSE_TX_TIMEOUT; + } + } + + /*Check how many bytes we need depending on state.*/ + switch(comm_interface.state) + { + case COMM_INTERFACE_STATE_SOF: + set_expect_bytes(comm_interface.ack_needed ? ACK_LEN : HEADER_LEN); + break; + + case COMM_INTERFACE_STATE_LEN: + set_expect_bytes(HEADER_LEN - 1); + break; + + case COMM_INTERFACE_STATE_TYPE: + set_expect_bytes(HEADER_LEN - 2); + break; + + case COMM_INTERFACE_STATE_CMD: + set_expect_bytes(HEADER_LEN - 3); + break; + + case COMM_INTERFACE_STATE_DATA: + set_expect_bytes(comm_interface.rx_wait_count); + break; + + case COMM_INTERFACE_STATE_CHECKSUM: + set_expect_bytes(CRC_LEN); + break; + + default: + break; + } + + return result; +} diff --git a/src/zwave_ncp_serial_api_controller/comm_interface.h b/src/zwave_ncp_serial_api_controller/comm_interface.h new file mode 100644 index 00000000..be594396 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/comm_interface.h @@ -0,0 +1,81 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef __COMM_INTERFACE__ +#define __COMM_INTERFACE__ + +#include +#include +#include + +/** + * @addtogroup Apps + * @{ + * @addtogroup SerialAPI + * @{ + */ + +#define RECEIVE_BUFFER_SIZE 180 +#define FRAME_LENGTH_MIN 3 +#define FRAME_LENGTH_MAX RECEIVE_BUFFER_SIZE + +typedef enum +{ + TRANSPORT_TYPE_UART, + TRANSPORT_TYPE_SPI, + TRANSPORT_TYPE_ETHERNET, +} transport_type_t; + +typedef enum +{ + PARSE_IDLE, // returned if nothing special has happened + PARSE_FRAME_RECEIVED, // returned when a valid frame has been received + PARSE_FRAME_SENT, // returned if frame was ACKed by the other end + PARSE_FRAME_ERROR, // returned if frame has error in Checksum + PARSE_RX_TIMEOUT, // returned if Rx timeout has happened + PARSE_TX_TIMEOUT // returned if Tx timeout (waiting for ACK) ahs happened +} comm_interface_parse_result_t; + +typedef void * transport_handle_t; + +typedef void (*transmit_done_cb_t)(transport_handle_t transport); + +typedef struct _transport_t +{ + transport_type_t type; + transport_handle_t handle; +} transport_t; + +typedef struct +{ + uint8_t sof; + uint8_t len; + uint8_t type; + uint8_t cmd; + uint8_t payload[RECEIVE_BUFFER_SIZE]; //size defined to fix SonarQube errors +} * comm_interface_frame_ptr; + +extern comm_interface_frame_ptr const serial_frame; + +static inline uint8_t frame_payload_len(const comm_interface_frame_ptr frame) +{ + return frame->len - 3; +} + +void comm_interface_transmit_frame(uint8_t cmd, uint8_t type, const uint8_t *payload, uint8_t len, transmit_done_cb_t cb); +void comm_interface_wait_transmit_done(void); +void comm_interface_init(void); +uint32_t comm_interface_get_ack_timeout_ms(void); +void comm_interface_set_ack_timeout_ms(uint32_t t); +uint32_t comm_interface_get_byte_timeout_ms(void); +void comm_interface_set_byte_timeout_ms(uint32_t t); +comm_interface_parse_result_t comm_interface_parse_data(bool ack); + +/** + * @} + * @} + */ + +#endif /* __COMM_INTERFACE__ */ diff --git a/src/zwave_ncp_serial_api_controller/config/FreeRTOSConfig.h b/src/zwave_ncp_serial_api_controller/config/FreeRTOSConfig.h new file mode 100644 index 00000000..25512304 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/FreeRTOSConfig.h @@ -0,0 +1,271 @@ +/* -------------------------------------------------------------------------- + * Copyright (c) 2013-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * -------------------------------------------------------------------------- + * + * $Revision: V10.2.0 + * + * Project: CMSIS-FreeRTOS + * Title: FreeRTOS configuration definitions + * + * --------------------------------------------------------------------------*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- +* Application specific definitions. +* +* These definitions should be adjusted for your particular hardware and +* application requirements. +* +* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE +* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. +* +* See http://www.freertos.org/a00110.html +*----------------------------------------------------------*/ + +#if !defined(__IAR_SYSTEMS_ASM__) +#if (defined(__ARMCC_VERSION) || defined(__GNUC__) || defined(__ICCARM__)) +#include + +#include "RTE_Components.h" +#include CMSIS_device_header +#endif + +#include "em_assert.h" +#include "em_device.h" + +#if defined(SL_COMPONENT_CATALOG_PRESENT) +#include "sl_component_catalog.h" +#endif +#endif + +#if defined(SL_CATALOG_SYSTEMVIEW_TRACE_PRESENT) +#include "SEGGER_SYSVIEW_FreeRTOS.h" +#endif + +//-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- + +// Minimal stack size [words] <0-65535> +// Stack for idle task and default task stack in words. +// Default: 160 +#define configMINIMAL_STACK_SIZE 160 + +// Total heap size [bytes] <0-0xFFFFFFFF> +// Heap memory size in bytes. +// Default: 8192 +#define configTOTAL_HEAP_SIZE 8192 + +// Kernel tick frequency [Hz] <0-0xFFFFFFFF> +// Kernel tick rate in Hz. +// Default: 1000 +#define configTICK_RATE_HZ 1000 + +// Timer task stack depth [words] <0-65535> +// Stack for timer task in words. +// Default: 160 +#define configTIMER_TASK_STACK_DEPTH 160 + +// Timer task priority <0-56> +// Timer task priority. +// Default: 40 (High) +#define configTIMER_TASK_PRIORITY 55 + +// Timer queue length <0-1024> +// Timer command queue length. +// Default: 10 +#define configTIMER_QUEUE_LENGTH 8 + +// Preemption interrupt priority +// Maximum priority of interrupts that are safe to call FreeRTOS API. +// Default: 96 +#define configMAX_SYSCALL_INTERRUPT_PRIORITY 32 + +// Use time slicing +// Enable setting to use timeslicing. +// Default: 1 +#define configUSE_TIME_SLICING 1 + +// Idle should yield +// Control Yield behaviour of the idle task. +// Default: 1 +#define configIDLE_SHOULD_YIELD 1 + +// Check for stack overflow +// <0=>Disable <1=>Method one <2=>Method two +// Enable or disable stack overflow checking. +// Callback function vApplicationStackOverflowHook implementation is required when stack checking is enabled. +// Default: 2 +#define configCHECK_FOR_STACK_OVERFLOW 2 + +// Use idle hook +// Enable callback function call on each idle task iteration. +// Callback function vApplicationIdleHook implementation is required when idle hook is enabled. +// Default: 0 +#define configUSE_IDLE_HOOK 1 + +// Use tick hook +// Enable callback function call during each tick interrupt. +// Callback function vApplicationTickHook implementation is required when tick hook is enabled. +// Default: 0 +#define configUSE_TICK_HOOK 0 + +// Use deamon task startup hook +// Enable callback function call when timer service starts. +// Callback function vApplicationDaemonTaskStartupHook implementation is required when deamon task startup hook is enabled. +// Default: 0 +#define configUSE_DAEMON_TASK_STARTUP_HOOK 0 + +// Use malloc failed hook +// Enable callback function call when out of dynamic memory. +// Callback function vApplicationMallocFailedHook implementation is required when malloc failed hook is enabled. +// Default: 0 +#define configUSE_MALLOC_FAILED_HOOK 0 + +// Queue registry size +// Define maximum number of queue objects registered for debug purposes. +// The queue registry is used by kernel aware debuggers to locate queue and semaphore structures and display associated text names. +// Default: 10 +#define configQUEUE_REGISTRY_SIZE 10 + +// Port Specific Features +// Enable and configure port specific features. +// Check FreeRTOS documentation for definitions that apply for the used port. + +// Use Floating Point Unit +// Using Floating Point Unit (FPU) affects context handling. +// Enable FPU when application uses floating point operations. +// Default: 1 +#define configENABLE_FPU 1 + +// Use Memory Protection Unit +// Using Memory Protection Unit (MPU) requires detailed memory map definition. +// This setting is only releavant for MPU enabled ports. +// Default: 0 +#define configENABLE_MPU 0 + +// Minimal secure stack size [words] <0-65535> +// Stack for idle task Secure side context in words. +// This setting is only relevant when TrustZone extension is enabled. +// Default: 128 +#define configMINIMAL_SECURE_STACK_SIZE 128 +// + +// Thread Local Storage Settings +// Thread local storage pointers +// Thread local storage (or TLS) allows the application writer to store +// values inside a task's control block, making the value specific to +// (local to) the task itself. +// Default: 0 +#define configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS 0 +// + +// Use Threadsafe Errno +// Enable Threadsafe Errno support. +// Default: 0 +#define configUSE_POSIX_ERRNO 0 + +//------------- <<< end of configuration section >>> --------------------------- + +/* Defines needed by FreeRTOS to implement CMSIS RTOS2 API. Do not change! */ +#define configCPU_CLOCK_HZ (SystemCoreClock) +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_PREEMPTION 1 +#define configUSE_TIMERS 1 +#define configUSE_MUTEXES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configUSE_TRACE_FACILITY 1 +#define configUSE_16_BIT_TICKS 0 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configMAX_PRIORITIES 56 +#define configKERNEL_INTERRUPT_PRIORITY 224 + +/* Defines that include FreeRTOS functions which implement CMSIS RTOS2 API. Do not change! */ +#define INCLUDE_xEventGroupSetBitsFromISR 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_xTimerPendFunctionCall 1 + +/* Map the FreeRTOS port interrupt handlers to their CMSIS standard names. */ +#define xPortPendSVHandler PendSV_Handler +#define vPortSVCHandler SVC_Handler + +/* Ensure Cortex-M port compatibility. */ +#define SysTick_Handler xPortSysTickHandler + +/* Implement FreeRTOS configASSERT as emlib assert. */ +#define configASSERT(x) EFM_ASSERT(x) + +/* Energy saving modes. */ +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#define configUSE_TICKLESS_IDLE 1 +#else +#define configUSE_TICKLESS_IDLE 0 +#endif + +/* Definition used by Keil to replace default system clock source. */ +#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1 + +/* Maximum size of task name. */ +#define configMAX_TASK_NAME_LEN 10 + +/* Use queue sets? */ +#define configUSE_QUEUE_SETS 0 + +/* Generate run-time statistics? */ +#define configGENERATE_RUN_TIME_STATS 0 + +/* Co-routine related definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES 1 + +/* Optional resume from ISR functionality. */ +#define INCLUDE_xResumeFromISR 1 + +/* FreeRTOS Secure Side Only and TrustZone Security Extension */ +#define configRUN_FREERTOS_SECURE_ONLY 0 +#define configENABLE_TRUSTZONE 1 + +/* Thread local storage pointers used by the SDK */ +#ifndef configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS + #define configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS 0 +#endif + +/* PRINT_STRING implementation. iostream_retarget_stdio or third party + printf should be added if this is used */ +#define configPRINT_STRING(X) printf(X) + +#define configNUM_THREAD_LOCAL_STORAGE_POINTERS (configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS \ + + configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS) + +//#if defined(SL_CATALOG_SYSTEMVIEW_TRACE_PRESENT) +//#include "SEGGER_SYSVIEW_FreeRTOS.h" +//#endif +#endif /* FREERTOS_CONFIG_H */ diff --git a/src/zwave_ncp_serial_api_controller/config/app_properties_config.h b/src/zwave_ncp_serial_api_controller/config/app_properties_config.h new file mode 100644 index 00000000..6a6b9766 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/app_properties_config.h @@ -0,0 +1,65 @@ +/***************************************************************************//** + * @file + * @brief Application Properties Header File + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef APP_PROPERTIES_CONFIG_H +#define APP_PROPERTIES_CONFIG_H + +#include "sl_application_type.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// App Properties settings + +// Type of signature this application is signed with +// Default: APPLICATION_SIGNATURE_NONE(0) +#define SL_APPLICATION_SIGNATURE 0 + +// Location of the signature +// Default: 0xFFFFFFFF +#define SL_APPLICATION_SIGNATURE_LOCATION 0xFFFFFFFF + +// Bitfield representing type of application +#define SL_APPLICATION_TYPE APPLICATION_TYPE + +// Version number for this application +// <0-4294967295:1> +// Default: 1 [0-4294967295] +#define SL_APPLICATION_VERSION 1 + +// Capabilities of this application +// Default: 0 +#define SL_APPLICATION_CAPABILITIES 0 + +//Product ID of the device for which the application is built +#define SL_APPLICATION_PRODUCT_ID { 0 } + +// + +#endif // APP_PROPERTIES_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/btl_interface_cfg.h b/src/zwave_ncp_serial_api_controller/config/btl_interface_cfg.h new file mode 100644 index 00000000..8e246f80 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/btl_interface_cfg.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief Configuration header of Bootloader Interface + ******************************************************************************* + * # License + * Copyright 2021 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#ifndef BTL_INTERFACE_CFG_H +#define BTL_INTERFACE_CFG_H + +#if !defined(BOOTLOADER_APPLOADER) + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_1) +#include "btl_interface_cfg_s2c1.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_2) +#include "btl_interface_cfg_s2c2.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_3) +#include "btl_interface_cfg_s2c3.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_4) +#include "btl_interface_cfg_s2c4.h" +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_5) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#if defined(_SILICON_LABS_32B_SERIES_2_CONFIG_8) +#define BOOTLOADER_DISABLE_OLD_BOOTLOADER_MITIGATION 1 +#endif + +#endif // !BOOTLOADER_APPLOADER + +#endif // BTL_INTERFACE_CFG_H diff --git a/src/zwave_ncp_serial_api_controller/config/emlib_core_debug_config.h b/src/zwave_ncp_serial_api_controller/config/emlib_core_debug_config.h new file mode 100644 index 00000000..07ee9b9e --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/emlib_core_debug_config.h @@ -0,0 +1,45 @@ +/***************************************************************************//** + * @file + * @brief emlib_core Configuration + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef EM_CORE_DEBUG_CONFIG_H +#define EM_CORE_DEBUG_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Core Configuration + +// Enables measuring of interrupt disable time for debugging purposes. +// Default: 0 +#define SL_EMLIB_CORE_ENABLE_INTERRUPT_DISABLED_TIMING 0 + +// + +// <<< end of configuration section >>> +#endif // EM_CORE_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13.h b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13.h new file mode 100644 index 00000000..d2796745 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13.h @@ -0,0 +1,48 @@ +/** + * Provides support for BRD8029A (Buttons and LEDs EXP Board) + * + * @copyright 2018 Silicon Laboratories Inc. + */ + +#ifndef EXTENSION_BOARD_8029A_EFR32XG13_H +#define EXTENSION_BOARD_8029A_EFR32XG13_H + +#include "extension_board_8029a_efr32xg13_button.h" +#include "extension_board_8029a_efr32xg13_led.h" +#include "extension_board_8029a_efr32xg13_slider.h" + +/*************************************************************************/ +/* Map physical board IO devices to application LEDs and buttons */ +/*************************************************************************/ + +/* Map application LEDs to board LEDs */ +#define APP_LED_A BOARD_LED1 +#define APP_LED_INDICATOR BOARD_LED2 // Positioned opposite APP_BUTTON_LEARN_RESET +#define APP_LED_B BOARD_LED4 +#define APP_LED_C BOARD_LED3 + +#define APP_RGB_R BOARD_RGB1_R +#define APP_RGB_G BOARD_RGB1_G +#define APP_RGB_B BOARD_RGB1_B + +/* Mapping application buttons to board buttons */ +#if defined(RADIO_BOARD_EFR32ZG13P32) || defined(RADIO_BOARD_EFR32ZG13L) || defined(RADIO_BOARD_EFR32ZG13S) +// The EFR32ZG13P32 device has reduced number of GPIO pins and therefore +// supports only two of our buttons +#define APP_BUTTON_A BOARD_BUTTON_PB4 +#define APP_BUTTON_LEARN_RESET BOARD_BUTTON_PB3 // Supports EM4 wakeup +#else +#define APP_BUTTON_A BOARD_BUTTON_PB1 +#define APP_BUTTON_LEARN_RESET BOARD_BUTTON_PB2 // Supports EM4 wakeup +#define APP_BUTTON_B BOARD_BUTTON_PB3 // Supports EM4 wakeup +#define APP_BUTTON_C BOARD_BUTTON_PB4 +#define APP_SLIDER_A BOARD_BUTTON_SLIDER1 +#endif + +/* The next two are identical since on the BRD8029A only PB2 and PB3 + * can trigger a wakeup from EM4. PB2 is already used for learn/reset + */ +#define APP_WAKEUP_BTN_SLDR BOARD_BUTTON_PB3 // Use this one when wakeup capability is required and button is preferred to slider +#define APP_WAKEUP_SLDR_BTN BOARD_BUTTON_PB3 // Use this one when wakeup capability is required and slider is preferred to button + +#endif /* EXTENSION_BOARD_8029A_EFR32XG13_H */ diff --git a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_button.h b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_button.h new file mode 100644 index 00000000..8e4dcc1b --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_button.h @@ -0,0 +1,133 @@ +/** + * Provides support for BRD8029A (Buttons on EXP Board) + * + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef EXTENSION_BOARD_8029A_EFR32XG13_BUTTON_H +#define EXTENSION_BOARD_8029A_EFR32XG13_BUTTON_H + +/*************************************************************************/ +/* Configure push buttons */ +/*************************************************************************/ + +/* NB: BTN0 on BRD8029A is connected in parallel with PB0 on BRD4001A + * (Wireless Starter Kit mainboard). Not a problem, the two buttons + * simply provide the same functionality. + */ + +// <<< Use Configuration Wizard in Context Menu >>> +// Button Configuration +#define PB1_LABEL "BTN0" + +// Button1 ON value +// <1=> Active high +// <0=> Active low +// 0 +#define PB1_ON_VALUE 0 + +// Button1 interrupt pin number +// 6 +#define PB1_INT_NO 6 + +// Button1 wake up from EM4 +// 0 +#define PB1_CAN_WAKEUP_EM4 0 + +#define PB2_LABEL "BTN1" + +// Button2 ON value +// <1=> Active high +// <0=> Active low +// 0 +#define PB2_ON_VALUE 0 + +// Button2 interrupt pin number +// 7 +#define PB2_INT_NO 7 + +// Button2 wake up from EM4 +// 1 +#define PB2_CAN_WAKEUP_EM4 1 + +#define PB3_LABEL "BTN2" + +// Button3 ON value +// <1=> Active high +// <0=> Active low +// 0 +#define PB3_ON_VALUE 0 + +// Button3 interrupt pin number +// 10 +#define PB3_INT_NO 10 + +// Button3 wake up from EM4 +// 1 +#define PB3_CAN_WAKEUP_EM4 1 + +#define PB4_LABEL "BTN3" + +// Button4 ON value +// <1=> Active high +// <0=> Active low +// 0 +#define PB4_ON_VALUE 0 + +// Button4 interrupt pin number +// 11 +#define PB4_INT_NO 11 + +// Button4 wake up from EM4 +// 0 +#define PB4_CAN_WAKEUP_EM4 0 + +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +// PB1_GPIO +// $[GPIO_PB1_GPIO] +#ifndef PB1_GPIO_PORT +#define PB1_GPIO_PORT gpioPortF +#endif +#ifndef PB1_GPIO_PIN +#define PB1_GPIO_PIN 6 +#endif +// [GPIO_PB1_GPIO]$ + +// PB2_GPIO +// $[GPIO_PB2_GPIO] +#ifndef PB2_GPIO_PORT +#define PB2_GPIO_PORT gpioPortF +#endif +#ifndef PB2_GPIO_PIN +#define PB2_GPIO_PIN 7 +#endif +// [GPIO_PB2_GPIO]$ + +// PB3_GPIO +// $[GPIO_PB3_GPIO] +#ifndef PB3_GPIO_PORT +#define PB3_GPIO_PORT gpioPortC +#endif +#ifndef PB3_GPIO_PIN +#define PB3_GPIO_PIN 10 +#endif +// [GPIO_PB3_GPIO]$ + +// PB4_GPIO +// $[GPIO_PB4_GPIO] +#ifndef PB4_GPIO_PORT +#define PB4_GPIO_PORT gpioPortC +#endif +#ifndef PB4_GPIO_PIN +#define PB4_GPIO_PIN 11 +#endif +// [GPIO_PB4_GPIO]$ + +// <<< sl:end pin_tool >>> + +#endif /* EXTENSION_BOARD_8029A_EFR32XG13_BUTTON_H */ diff --git a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_led.h b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_led.h new file mode 100644 index 00000000..e6717eac --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_led.h @@ -0,0 +1,107 @@ +/** + * Provides support for BRD8029A (LEDs on EXP Board) + * + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef EXTENSION_BOARD_8029A_EFR32XG13_LED_H +#define EXTENSION_BOARD_8029A_EFR32XG13_LED_H + +/*************************************************************************/ +/* Configure LEDs */ +/*************************************************************************/ + +/* NB: Mounted in parallel with "LED0" on the mainboard. + * + * EFR32 peripheral: (none) + */ + +// <<< Use Configuration Wizard in Context Menu >>> +// LED Configuration +// LED1 ON value +// <0=> Active low +// <1=> Active high +// 1 +#define LED1_ON_VALUE 1 + +// LED2 ON value +// <0=> Active low +// <1=> Active high +// 1 +#define LED2_ON_VALUE 1 + +// LED3 ON value +// <0=> Active low +// <1=> Active high +// 1 +#define LED3_ON_VALUE 1 + +// LED4 ON value +// <0=> Active low +// <1=> Active high +// 1 +#define LED4_ON_VALUE 1 + +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +#define LED1_LABEL "LED0" +// LED1_GPIO +// $[GPIO_LED1_GPIO] +#ifndef LED1_GPIO_PORT +#define LED1_GPIO_PORT gpioPortF +#endif +#ifndef LED1_GPIO_PIN +#define LED1_GPIO_PIN 4 +#endif +// [GPIO_LED1_GPIO]$ + +#define LED2_LABEL "LED1" +// LED2_GPIO +// $[GPIO_LED2_GPIO] +#ifndef LED2_GPIO_PORT +#define LED2_GPIO_PORT gpioPortF +#endif +#ifndef LED2_GPIO_PIN +#define LED2_GPIO_PIN 3 +#endif +// [GPIO_LED2_GPIO]$ + +#define LED3_LABEL "LED2" +// LED3_GPIO +// $[GPIO_LED3_GPIO] +#ifndef LED3_GPIO_PORT +#define LED3_GPIO_PORT gpioPortA +#endif +#ifndef LED3_GPIO_PIN +#define LED3_GPIO_PIN 2 +#endif +// [GPIO_LED3_GPIO]$ + +/* NB: EFR32 peripheral: US0_CS#0 + */ +#define LED4_LABEL "LED3" +// LED4_GPIO +// $[GPIO_LED4_GPIO] +#ifndef LED4_GPIO_PORT +#define LED4_GPIO_PORT gpioPortA +#endif +#ifndef LED4_GPIO_PIN +#define LED4_GPIO_PIN 3 +#endif +// [GPIO_LED4_GPIO]$ + +// <<< sl:end pin_tool >>> + +/*************************************************************************/ +/* Configure RGB LEDs */ +/*************************************************************************/ + +/* BRD8029A does not have any RGB led! + * If paired with radio board ZGM13 then the RGB on that board can be used + */ + +#endif /* EXTENSION_BOARD_8029A_EFR32XG13_LED_H */ diff --git a/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_slider.h b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_slider.h new file mode 100644 index 00000000..7b13ffee --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/extension_board_8029a_efr32xg13_slider.h @@ -0,0 +1,50 @@ +/** + * Provides support for BRD8029A (Slider on EXP Board) + * + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef EXTENSION_BOARD_8029A_EFR32XG13_SLIDER_H +#define EXTENSION_BOARD_8029A_EFR32XG13_SLIDER_H + +/*************************************************************************/ +/* Configure slider button */ +/*************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> +// Slider Configuration +#define SLIDER1_LABEL "SW1" + +// Slider ON value +// <1=> Active high +// <0=> Active low +// 0 +#define SLIDER1_ON_VALUE 0 + +// Interrupt pin number +// 9 +#define SLIDER1_INT_NO 9 + +// Wake up from EM4 +// 0 +#define SLIDER1_CAN_WAKEUP_EM4 0 + +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +// SLIDER1_GPIO +// $[GPIO_SLIDER1_GPIO] +#ifndef SLIDER1_GPIO_PORT +#define SLIDER1_GPIO_PORT gpioPortC +#endif +#ifndef SLIDER1_GPIO_PIN +#define SLIDER1_GPIO_PIN 9 +#endif +// [GPIO_SLIDER1_GPIO]$ + +// <<< sl:end pin_tool >>> + +#endif /* EXTENSION_BOARD_8029A_EFR32XG13_SLIDER_H */ diff --git a/src/zwave_ncp_serial_api_controller/config/nvm3_default_config.h b/src/zwave_ncp_serial_api_controller/config/nvm3_default_config.h new file mode 100644 index 00000000..0f63c6ea --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/nvm3_default_config.h @@ -0,0 +1,45 @@ +#ifndef NVM3_DEFAULT_CONFIG_H +#define NVM3_DEFAULT_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// NVM3 Default Instance Configuration + +#ifndef NVM3_DEFAULT_CACHE_SIZE +// NVM3 Default Instance Cache Size +// Number of NVM3 objects to cache. To reduce access times this number +// should be equal to or higher than the number of NVM3 objects in the +// default NVM3 instance. +// Default: 200 +#define NVM3_DEFAULT_CACHE_SIZE 100 +#endif + +#ifndef NVM3_DEFAULT_MAX_OBJECT_SIZE +// NVM3 Default Instance Max Object Size +// Max NVM3 object size that can be stored. +// Default: 254 +#define NVM3_DEFAULT_MAX_OBJECT_SIZE 1900 +#endif + +#ifndef NVM3_DEFAULT_REPACK_HEADROOM +// NVM3 Default Instance User Repack Headroom +// Headroom determining how many bytes below the forced repack limit the user +// repack limit should be placed. The default is 0, which means the user and +// forced repack limits are equal. +// Default: 0 +#define NVM3_DEFAULT_REPACK_HEADROOM 0 +#endif + +#ifndef NVM3_DEFAULT_NVM_SIZE +// NVM3 Default Instance Size +// Size of the NVM3 storage region in flash. This size should be aligned with +// the flash page size of the device. +// Default: 36864 +#define NVM3_DEFAULT_NVM_SIZE 36864 +#endif + +// + +// <<< end of configuration section >>> + +#endif // NVM3_DEFAULT_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/pin_config.h b/src/zwave_ncp_serial_api_controller/config/pin_config.h new file mode 100644 index 00000000..740e8856 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/pin_config.h @@ -0,0 +1,159 @@ +#ifndef PIN_CONFIG_H +#define PIN_CONFIG_H + +// $[ACMP0] +// [ACMP0]$ + +// $[ACMP1] +// [ACMP1]$ + +// $[ADC0] +// [ADC0]$ + +// $[CMU] +// [CMU]$ + +// $[CSEN] +// [CSEN]$ + +// $[DBG] +// DBG SWV on PF2 +#ifndef DBG_SWV_PORT +#define DBG_SWV_PORT gpioPortF +#endif +#ifndef DBG_SWV_PIN +#define DBG_SWV_PIN 2 +#endif +#ifndef DBG_SWV_LOC +#define DBG_SWV_LOC 0 +#endif + +// [DBG]$ + +// $[ETM] +// [ETM]$ + +// $[PTI] +// [PTI]$ + +// $[GPIO] +// [GPIO]$ + +// $[I2C0] +// [I2C0]$ + +// $[I2C1] +// [I2C1]$ + +// $[IDAC0] +// [IDAC0]$ + +// $[LESENSE] +// [LESENSE]$ + +// $[LETIMER0] +// [LETIMER0]$ + +// $[LEUART0] +// [LEUART0]$ + +// $[LFXO] +// [LFXO]$ + +// $[MODEM] +// [MODEM]$ + +// $[PCNT0] +// [PCNT0]$ + +// $[PRS.CH0] +// [PRS.CH0]$ + +// $[PRS.CH1] +// [PRS.CH1]$ + +// $[PRS.CH2] +// [PRS.CH2]$ + +// $[PRS.CH3] +// [PRS.CH3]$ + +// $[PRS.CH4] +// [PRS.CH4]$ + +// $[PRS.CH5] +// [PRS.CH5]$ + +// $[PRS.CH6] +// [PRS.CH6]$ + +// $[PRS.CH7] +// [PRS.CH7]$ + +// $[PRS.CH8] +// [PRS.CH8]$ + +// $[PRS.CH9] +// [PRS.CH9]$ + +// $[PRS.CH10] +// [PRS.CH10]$ + +// $[PRS.CH11] +// [PRS.CH11]$ + +// $[TIMER0] +// [TIMER0]$ + +// $[TIMER1] +// [TIMER1]$ + +// $[USART0] +// USART0 RX on PA1 +#ifndef USART0_RX_PORT +#define USART0_RX_PORT gpioPortA +#endif +#ifndef USART0_RX_PIN +#define USART0_RX_PIN 1 +#endif +#ifndef USART0_RX_LOC +#define USART0_RX_LOC 0 +#endif + +// USART0 TX on PA0 +#ifndef USART0_TX_PORT +#define USART0_TX_PORT gpioPortA +#endif +#ifndef USART0_TX_PIN +#define USART0_TX_PIN 0 +#endif +#ifndef USART0_TX_LOC +#define USART0_TX_LOC 0 +#endif + +// [USART0]$ + +// $[USART1] +// [USART1]$ + +// $[USART2] +// [USART2]$ + +// $[VDAC0] +// [VDAC0]$ + +// $[WTIMER0] +// [WTIMER0]$ + +// $[CUSTOM_PIN_NAME] +#ifndef _PORT +#define _PORT gpioPortA +#endif +#ifndef _PIN +#define _PIN 0 +#endif + +// [CUSTOM_PIN_NAME]$ + +#endif // PIN_CONFIG_H + diff --git a/src/zwave_ncp_serial_api_controller/config/serial_api_config.h b/src/zwave_ncp_serial_api_controller/config/serial_api_config.h new file mode 100644 index 00000000..0d025455 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/serial_api_config.h @@ -0,0 +1,48 @@ +/** + * @file + * Serial API Configuration + * @copyright 2022 Silicon Laboratories Inc. + */ +#ifndef SERIAL_API_CONFIG_H +#define SERIAL_API_CONFIG_H + +#include + +// <<< sl:start pin_tool >>> + +// SERIAL_API + +// $[USART_SERIAL_API] +#ifndef SERIAL_API_PERIPHERAL +#define SERIAL_API_PERIPHERAL USART0 +#endif +#ifndef SERIAL_API_PERIPHERAL_NO +#define SERIAL_API_PERIPHERAL_NO 0 +#endif + +// USART0 TX on PA0 +#ifndef SERIAL_API_TX_PORT +#define SERIAL_API_TX_PORT gpioPortA +#endif +#ifndef SERIAL_API_TX_PIN +#define SERIAL_API_TX_PIN 0 +#endif +#ifndef SERIAL_API_TX_LOC +#define SERIAL_API_TX_LOC 0 +#endif + +// USART0 RX on PA1 +#ifndef SERIAL_API_RX_PORT +#define SERIAL_API_RX_PORT gpioPortA +#endif +#ifndef SERIAL_API_RX_PIN +#define SERIAL_API_RX_PIN 1 +#endif +#ifndef SERIAL_API_RX_LOC +#define SERIAL_API_RX_LOC 0 +#endif +// [USART_SERIAL_API]$ + +// <<< sl:end pin_tool >>> + +#endif // SERIAL_API_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_board_control_config.h b/src/zwave_ncp_serial_api_controller/config/sl_board_control_config.h new file mode 100644 index 00000000..3faa30a6 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_board_control_config.h @@ -0,0 +1,84 @@ +/***************************************************************************//** + * @file + * @brief Board Control + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_BOARD_CONTROL_CONFIG_H +#define SL_BOARD_CONTROL_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Enable Virtual COM UART +// Default: 0 +#define SL_BOARD_ENABLE_VCOM 1 + +// Enable Display +// Default: 0 +#define SL_BOARD_ENABLE_DISPLAY 0 + +// Enable Relative Humidity and Temperature sensor +// Default: 0 +#define SL_BOARD_ENABLE_SENSOR_RHT 0 + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> + +// SL_BOARD_ENABLE_VCOM +// $[GPIO_SL_BOARD_ENABLE_VCOM] +#ifndef SL_BOARD_ENABLE_VCOM_PORT +#define SL_BOARD_ENABLE_VCOM_PORT gpioPortA +#endif +#ifndef SL_BOARD_ENABLE_VCOM_PIN +#define SL_BOARD_ENABLE_VCOM_PIN 5 +#endif +// [GPIO_SL_BOARD_ENABLE_VCOM]$ + +// SL_BOARD_ENABLE_DISPLAY +// $[GPIO_SL_BOARD_ENABLE_DISPLAY] +#ifndef SL_BOARD_ENABLE_DISPLAY_PORT +#define SL_BOARD_ENABLE_DISPLAY_PORT gpioPortD +#endif +#ifndef SL_BOARD_ENABLE_DISPLAY_PIN +#define SL_BOARD_ENABLE_DISPLAY_PIN 15 +#endif +// [GPIO_SL_BOARD_ENABLE_DISPLAY]$ + +// SL_BOARD_ENABLE_SENSOR_RHT +// $[GPIO_SL_BOARD_ENABLE_SENSOR_RHT] +#ifndef SL_BOARD_ENABLE_SENSOR_RHT_PORT +#define SL_BOARD_ENABLE_SENSOR_RHT_PORT gpioPortD +#endif +#ifndef SL_BOARD_ENABLE_SENSOR_RHT_PIN +#define SL_BOARD_ENABLE_SENSOR_RHT_PIN 15 +#endif +// [GPIO_SL_BOARD_ENABLE_SENSOR_RHT]$ + +// <<< sl:end pin_tool >>> + +#endif // SL_BOARD_CONTROL_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_debug_swo_config.h b/src/zwave_ncp_serial_api_controller/config/sl_debug_swo_config.h new file mode 100644 index 00000000..75896a71 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_debug_swo_config.h @@ -0,0 +1,109 @@ +/***************************************************************************//** + * @file + * @brief SWO configuration + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEBUG_SWO_CONFIG_H +#define SL_DEBUG_SWO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// SWO Configuration + +// SWO Frequency +// Must be 875 kHz for communication with Silicon Labs debuggers +// Default: 875000 +#define SL_DEBUG_SWO_FREQ 875000 + +// Enable interrupt event trace +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_IRQ 0 + +// Enable Program Counter samples +// Default: 0 +#define SL_DEBUG_SWO_SAMPLE_PC 0 + +// SWO debug sample intervals +// <64=> 64 +// <128=> 128 +// <192=> 192 +// <256=> 256 +// <320=> 320 +// <384=> 384 +// <448=> 448 +// <512=> 512 +// <576=> 576 +// <640=> 640 +// <704=> 704 +// <768=> 768 +// <832=> 832 +// <896=> 896 +// <960=> 960 +// <1024=> 1024 +// <2048=> 2048 +// <3072=> 3072 +// <4096=> 4096 +// <5102=> 5102 +// <6144=> 6144 +// <7168=> 7168 +// <8192=> 8192 +// <9216=> 9216 +// <10240=> 10240 +// <11264=> 11264 +// <12288=> 12288 +// <13312=> 13312 +// <14336=> 14336 +// <15360=> 15360 +// Must be 64, 128, 192, [ n * 64 ], 1024, 2048, 3072, [ n * 1024 ] , 15360 +// Default: 15360 +#define SL_DEBUG_SWO_SAMPLE_INTERVAL 15360 +// + +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_DEBUG +// $[DBG_SL_DEBUG] +#ifndef SL_DEBUG_PERIPHERAL +#define SL_DEBUG_PERIPHERAL DBG +#endif + +// DBG SWV on PF2 +#ifndef SL_DEBUG_SWV_PORT +#define SL_DEBUG_SWV_PORT gpioPortF +#endif +#ifndef SL_DEBUG_SWV_PIN +#define SL_DEBUG_SWV_PIN 2 +#endif +#ifndef SL_DEBUG_SWV_LOC +#define SL_DEBUG_SWV_LOC 0 +#endif +// [DBG_SL_DEBUG]$ +// <<< sl:end pin_tool >>> + +#endif // SL_DEBUG_SWO_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_device_init_dcdc_config.h b/src/zwave_ncp_serial_api_controller/config/sl_device_init_dcdc_config.h new file mode 100644 index 00000000..6294af87 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_device_init_dcdc_config.h @@ -0,0 +1,58 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_DCDC Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_DCDC_CONFIG_H +#define SL_DEVICE_INIT_DCDC_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Enable DC/DC Converter +// +// Default: 1 +#define SL_DEVICE_INIT_DCDC_ENABLE 1 + +// Set DC/DC Converter in Bypass Mode +// +// Default: 0 +#define SL_DEVICE_INIT_DCDC_BYPASS 1 + +// Override for DCDC PFMX Mode Peak Current Setting +// +// Default: 0 +#define SL_DEVICE_INIT_DCDC_PFMX_IPKVAL_OVERRIDE 0 + +// DCDC PFMX Mode Peak Current Setting <0-15> +// +// Default: DCDC_PFMXCTRL_IPKVAL_DEFAULT +#define SL_DEVICE_INIT_DCDC_PFMX_IPKVAL DCDC_PFMXCTRL_IPKVAL_DEFAULT + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_DCDC_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_device_init_emu_config.h b/src/zwave_ncp_serial_api_controller/config/sl_device_init_emu_config.h new file mode 100644 index 00000000..c3ff963e --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_device_init_emu_config.h @@ -0,0 +1,68 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_EMU Config + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_EMU_CONFIG_H +#define SL_DEVICE_INIT_EMU_CONFIG_H + +#include "em_emu.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// EM4H Voltage scaling level +// Fast-wakeup voltage level +// Low-power optimized voltage level +// Default: emuVScaleEM4H_LowPower +#define SL_DEVICE_INIT_EMU_EM4_VSCALE emuVScaleEM4H_LowPower + +// Retain LFXO in EM4 +#define SL_DEVICE_INIT_EMU_EM4_RETAIN_LFXO 0 + +// Retain LFRCO in EM4 +#define SL_DEVICE_INIT_EMU_EM4_RETAIN_LFRCO 1 + +// Retain ULFRCO in EM4S +#define SL_DEVICE_INIT_EMU_EM4_RETAIN_ULFRCO 0 + +// Hibernate or shutoff EM4 state +// EM4 Shutoff +// EM4 Hibernate +// Default: emuEM4Shutoff +#define SL_DEVICE_INIT_EMU_EM4_STATE emuEM4Hibernate + +// EM4 pin retention mode +// No Retention: Pads enter reset state when entering EM4. +// Retention through EM4: Pads enter reset state when exiting EM4. +// Retention through EM4 and wakeup. +// Default: emuPinRetentionDisable +#define SL_DEVICE_INIT_EMU_EM4_PIN_RETENTION_MODE emuPinRetentionLatch + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_EMU_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_device_init_hfxo_config.h b/src/zwave_ncp_serial_api_controller/config/sl_device_init_hfxo_config.h new file mode 100644 index 00000000..12150df1 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_device_init_hfxo_config.h @@ -0,0 +1,72 @@ +/***************************************************************************//** + * @file + * @brief DEVICE_INIT_HFXO Config + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_DEVICE_INIT_HFXO_CONFIG_H +#define SL_DEVICE_INIT_HFXO_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// Mode +// +// Crystal oscillator +// External digital clock +// Default: cmuOscMode_Crystal +#define SL_DEVICE_INIT_HFXO_MODE cmuOscMode_Crystal + +// Frequency <38000000-40000000> +// Default: 39000000 +#define SL_DEVICE_INIT_HFXO_FREQ 39000000 + +// HFXO precision in PPM <0-65535> +// Default: 50 +#define SL_DEVICE_INIT_HFXO_PRECISION 50 + +// CTUNE <0-511> +// Default: 360 +#define SL_DEVICE_INIT_HFXO_CTUNE 319 + +// Advanced Configurations +// Auto-start HFXO. This feature is incompatible with Power Manager and can only be enabled in applications that do not use Power Manager or a radio protocol stack. - DEPRECATED +// True +// False +// Default: false +#define SL_DEVICE_INIT_HFXO_AUTOSTART false + +// Auto-select HFXO. This feature is incompatible with Power Manager and can only be enabled in applications that do not use Power Manager or a radio protocol stack. - DEPRECATED +// True +// False +// Default: false +#define SL_DEVICE_INIT_HFXO_AUTOSELECT false + +// + +// <<< end of configuration section >>> + +#endif // SL_DEVICE_INIT_HFXO_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_fem_util_config.h b/src/zwave_ncp_serial_api_controller/config/sl_fem_util_config.h new file mode 100644 index 00000000..7cf4f4fb --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_fem_util_config.h @@ -0,0 +1,95 @@ +/***************************************************************************//** + * @file + * @brief Front End Module configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_FEM_UTIL_CONFIG_H +#define SL_FEM_UTIL_CONFIG_H + +#include "em_gpio.h" + +// <<< Use Configuration Wizard in Context Menu >>> +// FEM Configuration +// Enable RX Mode +// Default: 0 +#define SL_FEM_UTIL_RX_ENABLE 0 +// Enable TX Mode +// Default: 0 +#define SL_FEM_UTIL_TX_ENABLE 0 +// Enable Bypass Mode +// Default: 0 +#define SL_FEM_UTIL_BYPASS_ENABLE 0 +// Enable TX High Power Mode +// Default: 0 +#define SL_FEM_UTIL_TX_HIGH_POWER_ENABLE 0 +// +// <<< end of configuration section >>> + +// <<< sl:start pin_tool >>> +// SL_FEM_UTIL_RX +// $[PRS_SL_FEM_UTIL_RX] +//#define SL_FEM_UTIL_RX_CHANNEL 5 + +// PRS CH5 on PD10 +//#define SL_FEM_UTIL_RX_PORT gpioPortD +//#define SL_FEM_UTIL_RX_PIN 10 +//#define SL_FEM_UTIL_RX_LOC 0 + +// [PRS_SL_FEM_UTIL_RX]$ + +// SL_FEM_UTIL_TX +// $[PRS_SL_FEM_UTIL_TX] + +// [PRS_SL_FEM_UTIL_TX]$ + +// SL_FEM_UTIL_SLEEP +// $[PRS_SL_FEM_UTIL_SLEEP] +//#define SL_FEM_UTIL_SLEEP_CHANNEL 6 + +// PRS CH6 on PD11 +//#define SL_FEM_UTIL_SLEEP_PORT gpioPortD +//#define SL_FEM_UTIL_SLEEP_PIN 11 +//#define SL_FEM_UTIL_SLEEP_LOC 13 + +// [PRS_SL_FEM_UTIL_SLEEP]$ + +// SL_FEM_UTIL_BYPASS +// $[GPIO_SL_FEM_UTIL_BYPASS] + +// [GPIO_SL_FEM_UTIL_BYPASS]$ + +// SL_FEM_UTIL_TX_HIGH_POWER +// $[GPIO_SL_FEM_UTIL_TX_HIGH_POWER] + +// [GPIO_SL_FEM_UTIL_TX_HIGH_POWER]$ +// <<< sl:end pin_tool >>> + +#define SL_FEM_UTIL_OPTIMIZED_PHY_ENABLE 0 +#define SL_FEM_UTIL_RUNTIME_PHY_SELECT 0 + +#endif // SL_FEM_UTIL_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_memory_config.h b/src/zwave_ncp_serial_api_controller/config/sl_memory_config.h new file mode 100644 index 00000000..1c580349 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_memory_config.h @@ -0,0 +1,28 @@ +#ifndef SL_MEMORY_CONFIG_H +#define SL_MEMORY_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> +// Memory configuration + +// Stack size for the application. +// Default: 4096 +// The stack size configured here will be used by the stack that the +// application uses when coming out of a reset. +#ifndef SL_STACK_SIZE + #define SL_STACK_SIZE 1280 +#endif + +// Minimum heap size for the application. +// Default: 2048 +// Note that this value will configure the c heap which is normally used by +// malloc() and free() from the c library. The value defines a minimum heap +// size that is guaranteed to be available. The available heap may be larger +// to make use of any memory that would otherwise remain unused. +#ifndef SL_HEAP_SIZE + #define SL_HEAP_SIZE 128 +#endif + +// +// <<< end of configuration section >>> + +#endif diff --git a/src/zwave_ncp_serial_api_controller/config/sl_power_manager_config.h b/src/zwave_ncp_serial_api_controller/config/sl_power_manager_config.h new file mode 100644 index 00000000..a97fb038 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_power_manager_config.h @@ -0,0 +1,64 @@ +/***************************************************************************//** + * @file + * @brief Power Manager configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_POWER_MANAGER_CONFIG_H +#define SL_POWER_MANAGER_CONFIG_H + +// Power Manager Configuration + +// Enable custom IRQ handler for external HF oscillator. +// Enable if CMU_IRQHandler/HFXO0_IRQHandler is needed from your application. +// The function sl_power_manager_irq_handler() will have to be called from you custom handler if this is enabled. +// Default: 0 +#define SL_POWER_MANAGER_CUSTOM_HF_OSCILLATOR_IRQ_HANDLER 0 + +// Enable fast wakeup (disable voltage scaling in EM2/3 mode) +// Enable or disable voltage scaling in EM2/3 modes (when available). This decreases wakeup time by about 30 us. +// Deprecated. It is replaced by the function sl_power_manager_em23_voltage_scaling_enable_fast_wakeup() +// Default: 0 +#define SL_POWER_MANAGER_CONFIG_VOLTAGE_SCALING_FAST_WAKEUP 0 + +// Enable debugging feature +// Enable or disable debugging features (trace the different modules that have requirements). +// Default: 0 +#define SL_POWER_MANAGER_DEBUG 0 + +// Maximum numbers of requirements that can be logged +// Default: 10 +#define SL_POWER_MANAGER_DEBUG_POOL_SIZE 10 +// + +// + +#endif /* SL_POWER_MANAGER_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_pa_config.h b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_pa_config.h new file mode 100644 index 00000000..34adb6e5 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_pa_config.h @@ -0,0 +1,80 @@ +/***************************************************************************//** + * @file + * @brief Power Amplifier configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_PA_CONFIG_H +#define SL_RAIL_UTIL_PA_CONFIG_H + +#include "rail_types.h" + +// <<< Use Configuration Wizard in Context Menu >>> + +// PA Configuration +// Initial PA Power (deci-dBm, 100 = 10.0 dBm) +// Default: 100 +#define SL_RAIL_UTIL_PA_POWER_DECI_DBM 100 +// PA Ramp Time (microseconds) +// <0-65535:1> +// Default: 10 +#define SL_RAIL_UTIL_PA_RAMP_TIME_US 10 +// Milli-volts on PA supply pin (PA_VDD) +// <0-65535:1> +// Default: 3300 +#define SL_RAIL_UTIL_PA_VOLTAGE_MV 1800 +// 2.4 GHz PA Selection +// High Power +// Low Power +// Disable +// Default: RAIL_TX_POWER_MODE_2P4GIG_HP +#define SL_RAIL_UTIL_PA_SELECTION_2P4GHZ RAIL_TX_POWER_MODE_NONE +// Sub-1 GHz PA Selection +// Enable +// Disable +// Default: RAIL_TX_POWER_MODE_SUBGIG +#define SL_RAIL_UTIL_PA_SELECTION_SUBGHZ RAIL_TX_POWER_MODE_SUBGIG +// + +// PA Curve Configuration +// Header file containing custom PA curves +// Default: "pa_curves_efr32.h" +#define SL_RAIL_UTIL_PA_CURVE_HEADER "pa_curves_efr32.h" +// Header file containing PA curve types +// Default: "pa_curve_types_efr32.h" +#define SL_RAIL_UTIL_PA_CURVE_TYPES "pa_curve_types_efr32.h" +// + +// PA Calibration Configuration +// Apply PA Calibration Factory Offset +// Default: 1 +#define SL_RAIL_UTIL_PA_CALIBRATION_ENABLE 1 +// + +// <<< end of configuration section >>> + +#endif // SL_RAIL_UTIL_PA_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_power_manager_init_config.h b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_power_manager_init_config.h new file mode 100644 index 00000000..08dc1fe8 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_power_manager_init_config.h @@ -0,0 +1,44 @@ +/***************************************************************************//** + * @file + * @brief RAIL power manager configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H +#define SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H + +// <<< Use Configuration Wizard in Context Menu >>> + +// RAIL power manager configuration + +// Enable RAIL power manager initialization +// Default: 1 +#define SL_RAIL_UTIL_RAIL_POWER_MANAGER_INIT 0 + +// +// <<< end of configuration section >>> +#endif // SL_RAIL_UTIL_POWER_MANAGER_INIT_CONFIG_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_rail_util_sequencer_config.h b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_sequencer_config.h new file mode 100644 index 00000000..3701c8af --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_rail_util_sequencer_config.h @@ -0,0 +1,48 @@ +/***************************************************************************//** + * @file + * @brief + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_SEQUENCER_H +#define SL_RAIL_UTIL_SEQUENCER_H + +#include "rail.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define SL_RAIL_UTIL_SEQUENCER_RUNTIME_IMAGE_SELECTION 0 + +#define SL_RAIL_UTIL_SEQUENCER_IMAGE RAIL_SEQ_IMAGE_ZWAVE + +#ifdef __cplusplus +} +#endif + +#endif // SL_RAIL_UTIL_SEQUENCER_H diff --git a/src/zwave_ncp_serial_api_controller/config/sl_sleeptimer_config.h b/src/zwave_ncp_serial_api_controller/config/sl_sleeptimer_config.h new file mode 100644 index 00000000..8344ef5f --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/sl_sleeptimer_config.h @@ -0,0 +1,82 @@ +/***************************************************************************//** + * @file + * @brief Sleep Timer configuration file. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// <<< Use Configuration Wizard in Context Menu >>> + +#ifndef SL_SLEEPTIMER_CONFIG_H +#define SL_SLEEPTIMER_CONFIG_H + +#define SL_SLEEPTIMER_PERIPHERAL_DEFAULT 0 +#define SL_SLEEPTIMER_PERIPHERAL_RTCC 1 +#define SL_SLEEPTIMER_PERIPHERAL_PRORTC 2 +#define SL_SLEEPTIMER_PERIPHERAL_RTC 3 +#define SL_SLEEPTIMER_PERIPHERAL_SYSRTC 4 +#define SL_SLEEPTIMER_PERIPHERAL_BURTC 5 +#define SL_SLEEPTIMER_PERIPHERAL_WTIMER 6 +#define SL_SLEEPTIMER_PERIPHERAL_TIMER 7 + +// Timer Peripheral Used by Sleeptimer +// Default (auto select) +// RTCC +// Radio internal RTC (PRORTC) +// RTC +// SYSRTC +// Back-Up RTC (BURTC) +// WTIMER +// TIMER +// Selection of the Timer Peripheral Used by the Sleeptimer +#define SL_SLEEPTIMER_PERIPHERAL SL_SLEEPTIMER_PERIPHERAL_DEFAULT + +// TIMER/WTIMER Instance Used by Sleeptimer (not applicable for other peripherals) +// Make sure TIMER instance size is 32bits. Check datasheet for 32bits TIMERs. +// Default: 0 +#define SL_SLEEPTIMER_TIMER_INSTANCE 0 + +// Enable wallclock functionality +// Enable or disable wallclock functionalities (get_time, get_date, etc). +// Default: 0 +#define SL_SLEEPTIMER_WALLCLOCK_CONFIG 0 + +// Timer frequency divider (not applicable for WTIMER/TIMER) +// WTIMER/TIMER peripherals are always prescaled to 1024. +// Default: 1 +#define SL_SLEEPTIMER_FREQ_DIVIDER 1 + +// If Radio internal RTC (PRORTC) HAL is used, determines if it owns the IRQ handler. Enable, if no wireless stack is used. +// Default: 0 +#define SL_SLEEPTIMER_PRORTC_HAL_OWNS_IRQ_HANDLER 0 + +// Enable DEBUGRUN functionality on hardware RTC. +// Default: 0 +#define SL_SLEEPTIMER_DEBUGRUN 0 + +#endif /* SLEEPTIMER_CONFIG_H */ + +// <<< end of configuration section >>> diff --git a/src/zwave_ncp_serial_api_controller/config/zaf_appname_config.h b/src/zwave_ncp_serial_api_controller/config/zaf_appname_config.h new file mode 100644 index 00000000..5c72c673 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/zaf_appname_config.h @@ -0,0 +1,30 @@ +/***************************************************************************//** + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of the Silicon Labs Master Software License + * Agreement (MSLA) available at + * https://www.silabs.com/about-us/legal/master-software-license-agreement + * By installing, copying or otherwise using this software, you agree to the + * terms of the MSLA. + * + ******************************************************************************/ + +#ifndef _ZAF_APPNAME_CONFIG_H_ +#define _ZAF_APPNAME_CONFIG_H_ + +// <<< Use Configuration Wizard in Context Menu >>> + +// ZAF Application Name Configuration + +// Application Name +// "zwave_application" +#define ZAF_APP_NAME "serial_api_controller" + +// + +// <<< end of configuration section >>> + +#endif /* _ZAF_APPNAME_CONFIG_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/config/zaf_config.h b/src/zwave_ncp_serial_api_controller/config/zaf_config.h new file mode 100644 index 00000000..cb666a0d --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/zaf_config.h @@ -0,0 +1,400 @@ +/***************************************************************************//** + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of the Silicon Labs Master Software License + * Agreement (MSLA) available at + * https://www.silabs.com/about-us/legal/master-software-license-agreement + * By installing, copying or otherwise using this software, you agree to the + * terms of the MSLA. + * + ******************************************************************************/ + +#ifndef _ZAF_CONFIG_H_ +#define _ZAF_CONFIG_H_ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Command Class Firmware Update - Bootloader update + +// The bootloader target id <1..255:1> +// If the bootloader update is enabled +// This determines which target id should be used by the bootloader firmware +// Default: 1 +#define ZAF_CONFIG_BOOTLOADER_TARGET_ID 1 + +// Indicates if the bootloader can be updated +// Includes the bootloader as a target +// Default: 0 +#define ZAF_CONFIG_BOOTLOADER_UPGRADABLE 0 + +// +// Command Class Firmware Update - Firmware targets + +// Number of firmware targets <0..10:1> +// Defines the number of supported firmware targets. Setting this number to more than 1 requires +// the application to implement CC_Version_GetFirmwareVersion_handler(). The default value is 1 +// because firmware target 0 is the Z-Wave application firmware (including Z-Wave stack). +// Default: 1 +#define ZAF_CONFIG_FIRMWARE_TARGET_COUNT 1 + +// +// Command Class ZwavePlusInfo Configuration + +// User Icon Type +// User Icon Type reported in Z-Wave Plus Info Report Command +// GENERIC_BARRIER +// GENERIC_CENTRAL_CONTROLLER +// GENERIC_DIMMER_WALL_SWITCH +// GENERIC_DISPLAY_SIMPLE +// GENERIC_DOOR_LOCK_KEYPAD +// GENERIC_ENTRY_CONTROL +// GENERIC_FAN_SWITCH +// GENERIC_GATEWAY +// GENERIC_IRRIGATION +// GENERIC_LIGHT_DIMMER_SWITCH +// GENERIC_ON_OFF_POWER_SWITCH +// GENERIC_ON_OFF_WALL_SWITCH +// GENERIC_POWER_STRIP +// GENERIC_REMOTE_CONTROL_AV +// GENERIC_REMOTE_CONTROL_MULTI_PURPOSE +// GENERIC_REMOTE_CONTROL_SIMPLE +// GENERIC_REPEATER +// GENERIC_SENSOR_MULTILEVEL +// GENERIC_SENSOR_NOTIFICATION +// GENERIC_SET_TOP_BOX +// GENERIC_SIREN +// GENERIC_SUB_ENERGY_METER +// GENERIC_SUB_SYSTEM_CONTROLLER +// GENERIC_THERMOSTAT +// GENERIC_THERMOSTAT_SETBACK_OBSOLETED +// GENERIC_TV +// GENERIC_VALVE_OPEN_CLOSE +// GENERIC_WALL_CONTROLLER +// GENERIC_WHOLE_HOME_METER_SIMPLE +// GENERIC_WINDOW_COVERING_ENDPOINT_AWARE +// GENERIC_WINDOW_COVERING_NO_POSITION_ENDPOINT +// GENERIC_WINDOW_COVERING_POSITION_ENDPOINT_AWARE +// SPECIFIC_DIMMER_WALL_SWITCH_FOUR_BUTTONS +// SPECIFIC_DIMMER_WALL_SWITCH_ONE_BUTTON +// SPECIFIC_DIMMER_WALL_SWITCH_ONE_ROTARY +// SPECIFIC_DIMMER_WALL_SWITCH_THREE_BUTTONS +// SPECIFIC_DIMMER_WALL_SWITCH_TWO_BUTTONS +// SPECIFIC_ENTRY_CONTROL_KEYPAD_0_9 +// SPECIFIC_ENTRY_CONTROL_RFID_TAG_READER_NO_BUTTON +// SPECIFIC_LIGHT_DIMMER_SWITCH_CEILING_OUTLET +// SPECIFIC_LIGHT_DIMMER_SWITCH_LAMP_POST_HIGH +// SPECIFIC_LIGHT_DIMMER_SWITCH_LAMP_POST_LOW +// SPECIFIC_LIGHT_DIMMER_SWITCH_PLUGIN +// SPECIFIC_LIGHT_DIMMER_SWITCH_WALL_LAMP +// SPECIFIC_LIGHT_DIMMER_SWITCH_WALL_OUTLET +// SPECIFIC_ON_OFF_POWER_SWITCH_CEILING_OUTLET +// SPECIFIC_ON_OFF_POWER_SWITCH_LAMP_POST_HIGH +// SPECIFIC_ON_OFF_POWER_SWITCH_LAMP_POST_LOW +// SPECIFIC_ON_OFF_POWER_SWITCH_PLUGIN +// SPECIFIC_ON_OFF_POWER_SWITCH_WALL_LAMP +// SPECIFIC_ON_OFF_POWER_SWITCH_WALL_OUTLET +// SPECIFIC_ON_OFF_WALL_SWITCH_DOOR_BELL +// SPECIFIC_ON_OFF_WALL_SWITCH_FOUR_BUTTONS +// SPECIFIC_ON_OFF_WALL_SWITCH_ONE_BUTTON +// SPECIFIC_ON_OFF_WALL_SWITCH_ONE_ROTARY +// SPECIFIC_ON_OFF_WALL_SWITCH_THREE_BUTTONS +// SPECIFIC_ON_OFF_WALL_SWITCH_TWO_BUTTONS +// SPECIFIC_POWER_STRIP_INDIVIDUAL_OUTLET +// SPECIFIC_REMOTE_CONTROL_SIMPLE_KEYFOB +// SPECIFIC_SENSOR_MULTILEVEL_AIR_FLOW +// SPECIFIC_SENSOR_MULTILEVEL_AIR_TEMPERATURE +// SPECIFIC_SENSOR_MULTILEVEL_ANGLE_POSITION +// SPECIFIC_SENSOR_MULTILEVEL_ATMOSPHERIC_PRESSURE +// SPECIFIC_SENSOR_MULTILEVEL_BAROMETRIC_PRESSURE +// SPECIFIC_SENSOR_MULTILEVEL_CO2_LEVEL +// SPECIFIC_SENSOR_MULTILEVEL_CURRENT +// SPECIFIC_SENSOR_MULTILEVEL_DEW_POINT +// SPECIFIC_SENSOR_MULTILEVEL_DIRECTION +// SPECIFIC_SENSOR_MULTILEVEL_DISTANCE +// SPECIFIC_SENSOR_MULTILEVEL_ELECTRICAL_CONDUCTIVITY +// SPECIFIC_SENSOR_MULTILEVEL_ELECTRICAL_RESISTIVITY +// SPECIFIC_SENSOR_MULTILEVEL_FREQUENCY +// SPECIFIC_SENSOR_MULTILEVEL_GENERAL_PURPOSE_VALUE +// SPECIFIC_SENSOR_MULTILEVEL_HUMIDITY +// SPECIFIC_SENSOR_MULTILEVEL_LOUDNESS +// SPECIFIC_SENSOR_MULTILEVEL_LUMINANCE +// SPECIFIC_SENSOR_MULTILEVEL_MOISTURE +// SPECIFIC_SENSOR_MULTILEVEL_MULTIDEVICE +// SPECIFIC_SENSOR_MULTILEVEL_POWER +// SPECIFIC_SENSOR_MULTILEVEL_RAIN_RATE +// SPECIFIC_SENSOR_MULTILEVEL_ROTATION +// SPECIFIC_SENSOR_MULTILEVEL_SEISMIC_INTENSITY +// SPECIFIC_SENSOR_MULTILEVEL_SEISMIC_MAGNITUDE +// SPECIFIC_SENSOR_MULTILEVEL_SOIL_TEMPERATURE +// SPECIFIC_SENSOR_MULTILEVEL_SOLOR_RADIATION +// SPECIFIC_SENSOR_MULTILEVEL_TANK_CAPACITY +// SPECIFIC_SENSOR_MULTILEVEL_TARGET_TEMPERATURE +// SPECIFIC_SENSOR_MULTILEVEL_TIDE_LEVEL +// SPECIFIC_SENSOR_MULTILEVEL_TIME +// SPECIFIC_SENSOR_MULTILEVEL_ULTRAVIOLET +// SPECIFIC_SENSOR_MULTILEVEL_VELOCITY +// SPECIFIC_SENSOR_MULTILEVEL_VOLTAGE +// SPECIFIC_SENSOR_MULTILEVEL_WATER_TEMPERATURE +// SPECIFIC_SENSOR_MULTILEVEL_WEIGHT +// SPECIFIC_SENSOR_NOTIFICATION_ACCESS_CONTROL +// SPECIFIC_SENSOR_NOTIFICATION_APPLIANCE +// SPECIFIC_SENSOR_NOTIFICATION_CLOCK +// SPECIFIC_SENSOR_NOTIFICATION_CO2_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_CO_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_EMERGENCY_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_GAS_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_HEAT_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_HOME_HEALTH +// SPECIFIC_SENSOR_NOTIFICATION_HOME_SECURITY +// SPECIFIC_SENSOR_NOTIFICATION_IRRIGATION +// SPECIFIC_SENSOR_NOTIFICATION_MULTIDEVICE +// SPECIFIC_SENSOR_NOTIFICATION_POWER_MANAGEMENT +// SPECIFIC_SENSOR_NOTIFICATION_SIREN +// SPECIFIC_SENSOR_NOTIFICATION_SMOKE_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_SYSTEM +// SPECIFIC_SENSOR_NOTIFICATION_WATER_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_WATER_VALVE +// SPECIFIC_SENSOR_NOTIFICATION_WEATHER_ALARM +// SPECIFIC_THERMOSTAT_LINE_VOLTAGE +// SPECIFIC_THERMOSTAT_SETBACK +// Default: ICON_TYPE_GENERIC_ON_OFF_POWER_SWITCH +#define ZAF_CONFIG_USER_ICON_TYPE ICON_TYPE_GENERIC_ON_OFF_POWER_SWITCH + +// Installer Icon Type +// Installer Icon Type reported in Z-Wave Plus Info Report Command +// GENERIC_BARRIER +// GENERIC_CENTRAL_CONTROLLER +// GENERIC_DIMMER_WALL_SWITCH +// GENERIC_DISPLAY_SIMPLE +// GENERIC_DOOR_LOCK_KEYPAD +// GENERIC_ENTRY_CONTROL +// GENERIC_FAN_SWITCH +// GENERIC_GATEWAY +// GENERIC_IRRIGATION +// GENERIC_LIGHT_DIMMER_SWITCH +// GENERIC_ON_OFF_POWER_SWITCH +// GENERIC_ON_OFF_WALL_SWITCH +// GENERIC_POWER_STRIP +// GENERIC_REMOTE_CONTROL_AV +// GENERIC_REMOTE_CONTROL_MULTI_PURPOSE +// GENERIC_REMOTE_CONTROL_SIMPLE +// GENERIC_REPEATER +// GENERIC_SENSOR_MULTILEVEL +// GENERIC_SENSOR_NOTIFICATION +// GENERIC_SET_TOP_BOX +// GENERIC_SIREN +// GENERIC_SUB_ENERGY_METER +// GENERIC_SUB_SYSTEM_CONTROLLER +// GENERIC_THERMOSTAT +// GENERIC_THERMOSTAT_SETBACK_OBSOLETED +// GENERIC_TV +// GENERIC_VALVE_OPEN_CLOSE +// GENERIC_WALL_CONTROLLER +// GENERIC_WHOLE_HOME_METER_SIMPLE +// GENERIC_WINDOW_COVERING_ENDPOINT_AWARE +// GENERIC_WINDOW_COVERING_NO_POSITION_ENDPOINT +// GENERIC_WINDOW_COVERING_POSITION_ENDPOINT_AWARE +// SPECIFIC_DIMMER_WALL_SWITCH_FOUR_BUTTONS +// SPECIFIC_DIMMER_WALL_SWITCH_ONE_BUTTON +// SPECIFIC_DIMMER_WALL_SWITCH_ONE_ROTARY +// SPECIFIC_DIMMER_WALL_SWITCH_THREE_BUTTONS +// SPECIFIC_DIMMER_WALL_SWITCH_TWO_BUTTONS +// SPECIFIC_ENTRY_CONTROL_KEYPAD_0_9 +// SPECIFIC_ENTRY_CONTROL_RFID_TAG_READER_NO_BUTTON +// SPECIFIC_LIGHT_DIMMER_SWITCH_CEILING_OUTLET +// SPECIFIC_LIGHT_DIMMER_SWITCH_LAMP_POST_HIGH +// SPECIFIC_LIGHT_DIMMER_SWITCH_LAMP_POST_LOW +// SPECIFIC_LIGHT_DIMMER_SWITCH_PLUGIN +// SPECIFIC_LIGHT_DIMMER_SWITCH_WALL_LAMP +// SPECIFIC_LIGHT_DIMMER_SWITCH_WALL_OUTLET +// SPECIFIC_ON_OFF_POWER_SWITCH_CEILING_OUTLET +// SPECIFIC_ON_OFF_POWER_SWITCH_LAMP_POST_HIGH +// SPECIFIC_ON_OFF_POWER_SWITCH_LAMP_POST_LOW +// SPECIFIC_ON_OFF_POWER_SWITCH_PLUGIN +// SPECIFIC_ON_OFF_POWER_SWITCH_WALL_LAMP +// SPECIFIC_ON_OFF_POWER_SWITCH_WALL_OUTLET +// SPECIFIC_ON_OFF_WALL_SWITCH_DOOR_BELL +// SPECIFIC_ON_OFF_WALL_SWITCH_FOUR_BUTTONS +// SPECIFIC_ON_OFF_WALL_SWITCH_ONE_BUTTON +// SPECIFIC_ON_OFF_WALL_SWITCH_ONE_ROTARY +// SPECIFIC_ON_OFF_WALL_SWITCH_THREE_BUTTONS +// SPECIFIC_ON_OFF_WALL_SWITCH_TWO_BUTTONS +// SPECIFIC_POWER_STRIP_INDIVIDUAL_OUTLET +// SPECIFIC_REMOTE_CONTROL_SIMPLE_KEYFOB +// SPECIFIC_SENSOR_MULTILEVEL_AIR_FLOW +// SPECIFIC_SENSOR_MULTILEVEL_AIR_TEMPERATURE +// SPECIFIC_SENSOR_MULTILEVEL_ANGLE_POSITION +// SPECIFIC_SENSOR_MULTILEVEL_ATMOSPHERIC_PRESSURE +// SPECIFIC_SENSOR_MULTILEVEL_BAROMETRIC_PRESSURE +// SPECIFIC_SENSOR_MULTILEVEL_CO2_LEVEL +// SPECIFIC_SENSOR_MULTILEVEL_CURRENT +// SPECIFIC_SENSOR_MULTILEVEL_DEW_POINT +// SPECIFIC_SENSOR_MULTILEVEL_DIRECTION +// SPECIFIC_SENSOR_MULTILEVEL_DISTANCE +// SPECIFIC_SENSOR_MULTILEVEL_ELECTRICAL_CONDUCTIVITY +// SPECIFIC_SENSOR_MULTILEVEL_ELECTRICAL_RESISTIVITY +// SPECIFIC_SENSOR_MULTILEVEL_FREQUENCY +// SPECIFIC_SENSOR_MULTILEVEL_GENERAL_PURPOSE_VALUE +// SPECIFIC_SENSOR_MULTILEVEL_HUMIDITY +// SPECIFIC_SENSOR_MULTILEVEL_LOUDNESS +// SPECIFIC_SENSOR_MULTILEVEL_LUMINANCE +// SPECIFIC_SENSOR_MULTILEVEL_MOISTURE +// SPECIFIC_SENSOR_MULTILEVEL_MULTIDEVICE +// SPECIFIC_SENSOR_MULTILEVEL_POWER +// SPECIFIC_SENSOR_MULTILEVEL_RAIN_RATE +// SPECIFIC_SENSOR_MULTILEVEL_ROTATION +// SPECIFIC_SENSOR_MULTILEVEL_SEISMIC_INTENSITY +// SPECIFIC_SENSOR_MULTILEVEL_SEISMIC_MAGNITUDE +// SPECIFIC_SENSOR_MULTILEVEL_SOIL_TEMPERATURE +// SPECIFIC_SENSOR_MULTILEVEL_SOLOR_RADIATION +// SPECIFIC_SENSOR_MULTILEVEL_TANK_CAPACITY +// SPECIFIC_SENSOR_MULTILEVEL_TARGET_TEMPERATURE +// SPECIFIC_SENSOR_MULTILEVEL_TIDE_LEVEL +// SPECIFIC_SENSOR_MULTILEVEL_TIME +// SPECIFIC_SENSOR_MULTILEVEL_ULTRAVIOLET +// SPECIFIC_SENSOR_MULTILEVEL_VELOCITY +// SPECIFIC_SENSOR_MULTILEVEL_VOLTAGE +// SPECIFIC_SENSOR_MULTILEVEL_WATER_TEMPERATURE +// SPECIFIC_SENSOR_MULTILEVEL_WEIGHT +// SPECIFIC_SENSOR_NOTIFICATION_ACCESS_CONTROL +// SPECIFIC_SENSOR_NOTIFICATION_APPLIANCE +// SPECIFIC_SENSOR_NOTIFICATION_CLOCK +// SPECIFIC_SENSOR_NOTIFICATION_CO2_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_CO_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_EMERGENCY_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_GAS_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_HEAT_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_HOME_HEALTH +// SPECIFIC_SENSOR_NOTIFICATION_HOME_SECURITY +// SPECIFIC_SENSOR_NOTIFICATION_IRRIGATION +// SPECIFIC_SENSOR_NOTIFICATION_MULTIDEVICE +// SPECIFIC_SENSOR_NOTIFICATION_POWER_MANAGEMENT +// SPECIFIC_SENSOR_NOTIFICATION_SIREN +// SPECIFIC_SENSOR_NOTIFICATION_SMOKE_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_SYSTEM +// SPECIFIC_SENSOR_NOTIFICATION_WATER_ALARM +// SPECIFIC_SENSOR_NOTIFICATION_WATER_VALVE +// SPECIFIC_SENSOR_NOTIFICATION_WEATHER_ALARM +// SPECIFIC_THERMOSTAT_LINE_VOLTAGE +// SPECIFIC_THERMOSTAT_SETBACK +// Default: ICON_TYPE_GENERIC_ON_OFF_POWER_SWITCH +#define ZAF_CONFIG_INSTALLER_ICON_TYPE 0 + +// +// Version Configuration + +// Hardware version <0..255:1> +// The Hardware Version field MUST report a value which is unique to this particular +// version of the product. It MUST be possible to uniquely determine the hardware +// characteristics from the Hardware Version field in combination with the Manufacturer +// ID, Product Type ID and Product ID fields of Manufacturer Specific Info Report +// of the Manufacturer Specific Command Class. +// This information allows a user to pick a firmware image version that is guaranteed +// to work with this particular version of the product. +// Note that the Hardware Version field is intended for the hardware version of the +// entire product, not just the version of the Z-Wave radio chip. +// Default: 1 +#define ZAF_CONFIG_HARDWARE_VERSION 1 + +// +// Command Class Manufacturer Specific + +// Manufacturer ID <0x0000..0xFFFF:0x1> +// The default value is set to 0x0000 which is Silicon Labs. +// The value must be updated according to the official list of manufacturers in the Z-Wave Alliance. +// Default: 0x0000 +#define ZAF_CONFIG_MANUFACTURER_ID 0x0000 + +// Product Type ID <0x0000..0xFFFF:0x1> +// Default is 4 which is a value chosen by Silabs. +// Silabs consider this to indicate that the device is a Z-Wave Plus Version 2 device. +// Default: 0x0004 +#define ZAF_CONFIG_PRODUCT_TYPE_ID 0x0004 + +// Product ID <0x0000..0xFFFF:0x1> +// Default is 0 which is invalid in the context of Silicon Labs Z-Wave apps. According to CC +// Manufacturer Specific specification, zero is a valid value and can be used as a product ID. +// Default: 0x0000 +#define ZAF_CONFIG_PRODUCT_ID 4 + +// +// Device type + +// The generic type of a device. +// The generic type of a device. A certain device type requires a generic type, e.g., the Lock device type requires the generic type to be Entry Control. +// Find more info in the Z-Wave Plus v2 Device Type specification. +// AV Control Point +// Entry Control +// Generic Controller +// Meter +// Repeater End Device +// Sensor Multilevel +// Switch Binary +// Switch Multilevel +// Thermostat +// Wall Controller +// Sensor Notification +// Default: 0 +#define ZAF_CONFIG_GENERIC_TYPE 0 + +// The specific type of a device. +// The specific type of a device. A certain device type requires a specific type, e.g., the Lock device type requires the specific type to be Door Lock. +// Find more info in the Z-Wave Plus v2 Device Type specification. +// Specific type not used +// Door Lock +// Secure Gate +// Secure Barrier (open only) +// Secure Barrier (close only) +// Color Tunable Binary +// Color Tunable Multilevel +// Class A Motor Control +// Class B Motor Control +// Class C Motor Control +// Thermostat General Version 2 +// Sound Switch +// Secure Keypad +// Routing Sensor Multilevel +// Notification Sensor +// Repeater End Device +// Infrared Repeater +// Default: SPECIFIC_TYPE_NOT_USED +#define ZAF_CONFIG_SPECIFIC_TYPE 0 + +// +// Multi Channel Configuration + +// Number of end points <0..255:1> +// Default: 0 +#define ZAF_CONFIG_NUMBER_OF_END_POINTS 0 + +// +// Security Configuration + +// Request S0 network key +// Default: 0 +#define ZAF_CONFIG_REQUEST_KEY_S0 0 + +// Request S2 Unauthenticated network key +// Default: 0 +#define ZAF_CONFIG_REQUEST_KEY_S2_UNAUTHENTICATED 0 + +// Request S2 Authenticated network key +// Default: 0 +#define ZAF_CONFIG_REQUEST_KEY_S2_AUTHENTICATED 0 + +// Request S2 Access network key +// Default: 0 +#define ZAF_CONFIG_REQUEST_KEY_S2_ACCESS 0 + +// Application can only be controlled when included securely +// Default: 0 +#define ZAF_CONFIG_SECURE_ONLY 0 + +// + +// <<< end of configuration section >>> + +#endif /* _ZAF_CONFIG_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/config/zaf_event_distributor_core_config.h b/src/zwave_ncp_serial_api_controller/config/zaf_event_distributor_core_config.h new file mode 100644 index 00000000..1f217b82 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/zaf_event_distributor_core_config.h @@ -0,0 +1,30 @@ +/***************************************************************************//** + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of the Silicon Labs Master Software License + * Agreement (MSLA) available at + * https://www.silabs.com/about-us/legal/master-software-license-agreement + * By installing, copying or otherwise using this software, you agree to the + * terms of the MSLA. + * + ******************************************************************************/ + +#ifndef _ZAF_EVENT_DISTRIBUTOR_CORE_CONFIG_H_ +#define _ZAF_EVENT_DISTRIBUTOR_CORE_CONFIG_H_ + +// <<< Use Configuration Wizard in Context Menu >>> + +// ZAF Event Distributor Core Configuration + +// Timeout (in mS) when waiting for event <1..4294967295:1> +// Default: 4294967295 +#define ZAF_EVENT_DISTRIBUTOR_CORE_CONFIG_TIMEOUT 4294967295 + +// + +// <<< end of configuration section >>> + +#endif /* _ZAF_EVENT_DISTRIBUTOR_CORE_CONFIG_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/config/zpal_zwave_nvm_instance_config.h b/src/zwave_ncp_serial_api_controller/config/zpal_zwave_nvm_instance_config.h new file mode 100644 index 00000000..4fa19a15 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/zpal_zwave_nvm_instance_config.h @@ -0,0 +1,57 @@ +/***************************************************************************//** + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of the Silicon Labs Master Software License + * Agreement (MSLA) available at + * https://www.silabs.com/about-us/legal/master-software-license-agreement + * By installing, copying or otherwise using this software, you agree to the + * terms of the MSLA. + * + ******************************************************************************/ + +#ifndef _ZPAL_ZWAVE_NVM_INSTANCE_CONFIG_H_ +#define _ZPAL_ZWAVE_NVM_INSTANCE_CONFIG_H_ + +// <<< Use Configuration Wizard in Context Menu >>> + +// ZAF NVM3 config + +#ifndef ZPAL_ZW_NVM_CACHE_SIZE +// NVM3 Z-Wave Instance Cache Size +// Number of NVM3 objects to cache. To reduce access times this number +// should be equal to or higher than the number of NVM3 objects in the +// Z-Wave NVM3 instance (all ZAF and application NVM3 objects). +// Count of objects stored by ZAF depend on the application. At least +// 11 object should be reserved for ZAF. +// see [TODO add a user documentation] for more details +// Default: 11 +#define ZPAL_ZW_NVM_CACHE_SIZE 11 +#endif + +#ifndef ZPAL_ZW_NVM_MAX_OBJECT_SIZE +// NVM3 Z-Wave Instance Max Object Size +// Size of the largest object that can be stored by ZAF or application. +// For ZAF, it should be at least the largest of: +// - CC_NOTIFICATION_MAX_NOTIFICATIONS +// - 3 * CC_ASSOCIATION_MAX_NODES_IN_GROUP * (1+ZAF_CONFIG_NUMBER_OF_END_POINTS) + CC_ASSOCIATION_MAX_GROUPS_PER_ENDPOINT +// - 204 (minimum required by nvm3 library) +// Default: 204 +#define ZPAL_ZW_NVM_MAX_OBJECT_SIZE 204 +#endif + +#ifndef ZPAL_ZW_NVM_INSTANCE_REPACK_HEADROOM +// NVM3 Z-Wave Instance User Repack Headroom +// Headroom determining how many bytes below the forced repack limit the user +// repack limit should be placed. +// Default: 12 +#define ZPAL_ZW_NVM_INSTANCE_REPACK_HEADROOM 12 +#endif + +// + +// <<< end of configuration section >>> + +#endif /* _ZPAL_ZWAVE_NVM_INSTANCE_CONFIG_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/config/zw_build_no.h b/src/zwave_ncp_serial_api_controller/config/zw_build_no.h new file mode 100644 index 00000000..7fd9752e --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/zw_build_no.h @@ -0,0 +1,17 @@ +/** + * @file + * @copyright 2021 Silicon Laboratories Inc. + */ + +#ifndef _ZW_BUILD_NO_H_ +#define _ZW_BUILD_NO_H_ + +#include + +// Application Framework Build number. +// If not otherwise specified, it is the same as Z-Wave Protocol Build number +#ifndef ZAF_BUILD_NO +#define ZAF_BUILD_NO ZW_GetProtocolBuildNumber() +#endif + +#endif /* _ZW_BUILD_NO_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/config/zw_config_rf.h b/src/zwave_ncp_serial_api_controller/config/zw_config_rf.h new file mode 100644 index 00000000..67df8127 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/zw_config_rf.h @@ -0,0 +1,46 @@ +/***************************************************************************//** + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of the Silicon Labs Master Software License + * Agreement (MSLA) available at + * https://www.silabs.com/about-us/legal/master-software-license-agreement + * By installing, copying or otherwise using this software, you agree to the + * terms of the MSLA. + * + ******************************************************************************/ + +#ifndef _ZW_CONFIG_RF_H_ +#define _ZW_CONFIG_RF_H_ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Max Tx Power Configuration + +// The maximum allowed Tx power in deci dBm for Z-Wave Long Range network <140..200:1> +// The maximum allowed Tx power in deci dBm for Z-Wave Long Range network +// Default: 140 +#define APP_MAX_TX_POWER_LR 140 + +// The maximum allowed Tx power in deci dBm for Z-Wave network <-100..140:1> +// The maximum allowed Tx power in deci dBm for Z-Wave network +// Default: 0 +#define APP_MAX_TX_POWER 0 + +// The deci dBmoutput measured at a PA setting of 0dBm <-50..50:1> +// The deci dBm output measured at a PA setting of 0dBm +// Default: 0 +#define APP_MEASURED_0DBM_TX_POWER 0 + +// Enable Radio Debug +// Enable Radio Debug +// Default: 0 +#define ENABLE_RADIO_DEBUG 0 + +// + +// <<< end of configuration section >>> + +#endif /* _ZW_CONFIG_RF_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/config/zw_region_config.h b/src/zwave_ncp_serial_api_controller/config/zw_region_config.h new file mode 100644 index 00000000..a8ee344d --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/zw_region_config.h @@ -0,0 +1,43 @@ +/***************************************************************************//** + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of the Silicon Labs Master Software License + * Agreement (MSLA) available at + * https://www.silabs.com/about-us/legal/master-software-license-agreement + * By installing, copying or otherwise using this software, you agree to the + * terms of the MSLA. + * + ******************************************************************************/ + +#ifndef _ZW_REGION_CONFIG_H_ +#define _ZW_REGION_CONFIG_H_ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Z-Wave Radio Configuration + +// The supported region of the device. Used only if region value is not previously written in MFG_ZWAVE_COUNTRY_FREQ token. To delete value from MFG token, run: commander flash --tokengroup znet --token MFG_ZWAVE_COUNTRY_FREQ:0xFF +// The supported region of the device. Used only if region value is not previously written in MFG_ZWAVE_COUNTRY_FREQ token. To delete value from MFG token, run: commander flash --tokengroup znet --token MFG_ZWAVE_COUNTRY_FREQ:0xFF +// Default (Europe) +// Australia / New Zealand +// China +// Europe +// Hong Kong +// Israel +// India +// Japan +// Korea +// Russia +// United States +// United States Long Range +// Default: REGION_DEFAULT +#define ZW_REGION REGION_DEFAULT + +// + +// <<< end of configuration section >>> + +#endif /* _ZW_REGION_CONFIG_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/config/zw_version_config.h b/src/zwave_ncp_serial_api_controller/config/zw_version_config.h new file mode 100644 index 00000000..819bd2fd --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/config/zw_version_config.h @@ -0,0 +1,60 @@ +/***************************************************************************//** + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of the Silicon Labs Master Software License + * Agreement (MSLA) available at + * https://www.silabs.com/about-us/legal/master-software-license-agreement + * By installing, copying or otherwise using this software, you agree to the + * terms of the MSLA. + * + ******************************************************************************/ + +#ifndef _ZW_VERSION_CONFIG_H_ +#define _ZW_VERSION_CONFIG_H_ + +// <<< Use Configuration Wizard in Context Menu >>> + +// Override the default application version with USER_APP_* defines" + +// false: Use Default Z-Wave version numbering, true: Use Application Version Configuration numbering +// Default: 0 +#define USE_USER_APP_VERSION 0 + +// +// Application Version Configuration + +// Application Major Version <1..255:1> +// Default: 1 +#define USER_APP_VERSION 1 + +// Application Minor Version <1..255:1> +// Default: 0 +#define USER_APP_REVISION 0 + +// Application Patch Version <1..255:1> +// Default: 0 +#define USER_APP_PATCH 0 + +// + +// <<< end of configuration section >>> + +#if USE_USER_APP_VERSION + #define APP_VERSION USER_APP_VERSION + #define APP_REVISION USER_APP_REVISION + #define APP_PATCH USER_APP_PATCH +#else + #ifdef ZW_SLAVE + #define APP_VERSION ZAF_VERSION_MAJOR + #define APP_REVISION ZAF_VERSION_MINOR + #define APP_PATCH ZAF_VERSION_PATCH + #else + #define APP_VERSION SDK_VERSION_MAJOR + #define APP_REVISION SDK_VERSION_MINOR + #define APP_PATCH SDK_VERSION_PATCH + #endif +#endif +#endif /* _ZW_VERSION_CONFIG_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/controller_supported_func.h b/src/zwave_ncp_serial_api_controller/controller_supported_func.h new file mode 100644 index 00000000..d2789b5a --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/controller_supported_func.h @@ -0,0 +1,211 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +/* Generated file copied from Sdk670 with std. functions supported by static controller. */ +/* Following defines has been disable for build purposes: + * SUPPORT_ZW_AES_ECB + * SUPPORT_ZW_SET_EXT_INT_LEVEL + */ +#define SUPPORT_GET_ROUTING_TABLE_LINE 1 /* ZW_GetRoutingInfo */ +#define SUPPORT_LOCK_ROUTE_RESPONSE 1 /* ZW_LockRoute */ +#define SUPPORT_MEMORY_GET_BUFFER 1 /* MemoryGetBuffer */ +#define SUPPORT_MEMORY_GET_BYTE 1 /* MemoryGetByte */ +#define SUPPORT_MEMORY_GET_ID 1 /* MemoryGetID */ +#define SUPPORT_MEMORY_PUT_BUFFER 1 /* MemoryPutBuffer */ +#define SUPPORT_MEMORY_PUT_BYTE 1 /* MemoryPutByte */ +#define SUPPORT_NVM_GET_ID 1 /* NVM_get_id */ +#define SUPPORT_NVM_EXT_READ_LONG_BUFFER 1 /* NVM_ext_read_long_buffer */ +#define SUPPORT_NVM_EXT_READ_LONG_BYTE 1 /* NVM_ext_read_long_byte */ +#define SUPPORT_NVM_EXT_WRITE_LONG_BYTE 0 /* NVM_ext_write_long_byte */ +#define SUPPORT_NVM_EXT_WRITE_LONG_BUFFER 0 /* NVM_ext_write_long_buffer*/ +#define SUPPORT_NVM_BACKUP_RESTORE 1 /* NVM_backup_restore */ +#define SUPPORT_PWR_CLK_PD 0 /* PWR_Clk_PD */ +#define SUPPORT_PWR_CLK_PUP 0 /* PWR_Clk_PUp */ +#define SUPPORT_PWR_SELECT_CLK 0 /* PWR_Select_Clk */ +#define SUPPORT_PWR_SETSTOPMODE 0 /* PWR_SetStopMode */ +#define SUPPORT_STORE_HOMEID 0 /* ZW_StoreHomeID */ +#define SUPPORT_STORE_NODEINFO 0 /* notUsed */ +#define SUPPORT_ZW_ADD_NODE_TO_NETWORK 1 /* ZW_AddNodeToNetwork */ +#define SUPPORT_ZW_AES_ECB 0 /* ZW_AES_ECB */ +#define SUPPORT_ZW_ARE_NODES_NEIGHBOURS 0 /* notUsed */ +#define SUPPORT_ZW_ASSIGN_RETURN_ROUTE 1 /* ZW_AssignReturnRoute */ +#define SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE 1 /* ZW_AssignPriorityReturnRoute */ +#define SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE 1 /* ZW_AssignSUCReturnRoute */ +#define SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE 1 /* ZW_AssignPrioritySUCReturnRoute */ +#define SUPPORT_ZW_CONTROLLER_CHANGE 1 /* ZW_ControllerChange */ +#define SUPPORT_ZW_CREATE_NEW_PRIMARY 0 /* NotUsed */ +#define SUPPORT_ZW_DELETE_RETURN_ROUTE 1 /* ZW_DeleteReturnRoute */ +#define SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE 1 /* ZW_DeleteSUCReturnRoute */ +#define SUPPORT_ZW_ENABLE_SUC 0 /* ZW_EnableSUC */ +#define SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION 1 /* ZW_ExploreRequestInclusion */ +#define SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION 1 /* ZW_ExploreRequestExclusion */ +#define SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES 1 /* ZW_GetControllerCapabilities */ +#define SUPPORT_ZW_GET_PRIORITY_ROUTE 1 /* ZW_GetPriorityRoute */ +#define SUPPORT_ZW_SET_PRIORITY_ROUTE 1 /* ZW_SetPriorityRoute */ +#define SUPPORT_ZW_GET_NEIGHBOR_COUNT 0 /*notUsed */ +#define SUPPORT_ZW_GET_NODE_PROTOCOL_INFO 1 /* ZW_GetNodeProtocolInfo */ +#define SUPPORT_ZW_GET_PROTOCOL_STATUS 1 /* ZW_GetProtocolStatus */ +#define SUPPORT_ZW_GET_PROTOCOL_VERSION 1 /* ZW_GetProtocolVersion */ +#define SUPPORT_ZW_GET_RANDOM 1 /* ZW_GetRandomWord */ +#define SUPPORT_ZW_GET_ROUTING_MAX 0 /* ZW_GetRoutingMAX */ +#define SUPPORT_ZW_GET_SUC_NODE_ID 1 /* ZW_GetSUCNodeID */ +#define SUPPORT_ZW_GET_VERSION 1 /* ZW_Version */ +#define SUPPORT_ZW_IS_FAILED_NODE_ID 1 /* ZW_isFailedNode */ +#define SUPPORT_ZW_IS_NODE_WITHIN_DIRECT_RANGE 0 /* NotUsed */ +#define SUPPORT_ZW_IS_PRIMARY_CTRL 0 /* NotUsed */ +#define SUPPORT_ZW_IS_WUT_KICKED 0 /* ZW_IsWutKicked */ +#define SUPPORT_ZW_NEW_CONTROLLER 0 /* ZW_NewController */ +#define SUPPORT_ZW_RANDOM 0 /* NotUsed */ +#define SUPPORT_ZW_REDISCOVERY_NEEDED 0 /* ZW_RediscoveryNeeded */ +#define SUPPORT_ZW_REMOVE_FAILED_NODE_ID 1 /* ZW_RemoveFailedNode */ +#define SUPPORT_ZW_REMOVE_NODE_FROM_NETWORK 1 /* ZW_RemoveNodeFromNetwork */ +#define SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK 1 /* ZW_RemoveNodeIDFromNetwork */ +#define SUPPORT_ZW_REPLACE_FAILED_NODE 1 /* ZW_ReplaceFailedNode */ +#define SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE 1 /* ZW_ReplicationReceiveComplete */ +#define SUPPORT_ZW_REPLICATION_SEND_DATA 1 /* ZW_ReplicationSend */ +#define SUPPORT_ZW_REQUEST_NETWORK_UPDATE 1 /* ZW_RequestNetWorkUpdate */ +#define SUPPORT_ZW_REQUEST_NEW_ROUTE_DESTINATIONS 0 /* NotUsed */ +#define SUPPORT_ZW_REQUEST_NODE_INFO 1 /* ZW_RequestNodeInfo */ +#define SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE 1 /* ZW_RequestNodeNeighborUpdate */ +#define SUPPORT_ZW_RF_POWER_LEVEL_GET 0 /* ZW_RFPowerLevelGet */ +#define SUPPORT_ZW_RF_POWER_LEVEL_REDISCOVERY_SET 0 /* NotUsed */ +#define SUPPORT_ZW_RF_POWER_LEVEL_SET 0 /* ZW_RFPowerLevelSet */ +#define SUPPORT_ZW_SEND_DATA 1 /* ZW_SendData */ +#define SUPPORT_ZW_SEND_DATA_EX 0 /* ZW_SendDataEx */ +#define SUPPORT_ZW_SEND_DATA_ABORT 1 /* ZW_SendDataAbort */ +#define SUPPORT_ZW_SEND_DATA_META 0 /* ZW_SendDataMeta */ +#define SUPPORT_ZW_SEND_DATA_META_BRIDGE 0 /* ZW_SendDataMeta_Bridge */ +#define SUPPORT_ZW_SEND_DATA_META_MR 0 /* NotUsed */ +#define SUPPORT_ZW_SEND_DATA_MR 0 /* NotUsed */ +#define SUPPORT_ZW_SEND_DATA_MULTI 1 /* ZW_SendDataMulti */ +#define SUPPORT_ZW_SEND_DATA_MULTI_EX 0 /* ZW_SendDataMultiEx */ +#define SUPPORT_ZW_SET_NETWORK_KEY_S0 0 /* ZW_SetNetworkKeyS0 */ +#define SUPPORT_ZW_GET_SECURITY_KEYS 0 /* ZW_GetSecurityKeys */ +#define SUPPORT_ZW_SEND_NODE_INFORMATION 1 /* ZW_SendNodeInformation */ +#define SUPPORT_ZW_SEND_SLAVE_DATA 0 /* ZW_SendSlaveData */ +#define SUPPORT_ZW_SEND_SUC_ID 1 /* ZW_SendSUCID */ +#define SUPPORT_ZW_SEND_TEST_FRAME 1 /* ZW_SendTestFrame */ +#define SUPPORT_ZW_SET_DEFAULT 1 /* ZW_SetDefault */ +#define SUPPORT_ZW_SET_EXT_INT_LEVEL 0 /* ZW_SetExtIntLevel */ +#define SUPPORT_ZW_SET_LEARN_MODE 1 /* ZW_SetLearnMode */ +#define SUPPORT_ZW_SET_LEARN_NODE_STATE 0 /* ZW_SetLearnNodeState */ +#define SUPPORT_ZW_SET_PROMISCUOUS_MODE 0 /* ZW_SetPromiscuousMode */ +#define SUPPORT_ZW_SET_RF_RECEIVE_MODE 1 /* ZW_SetRFReceiveMode */ +#define SUPPORT_ZW_SET_ROUTING_INFO 0 /* NotUsed */ +#define SUPPORT_ZW_SET_ROUTING_MAX 1 /* ZW_SetRoutingMAX*/ +#define SUPPORT_ZW_SET_SLEEP_MODE 0 /* ZW_SetSleepMode */ +#define SUPPORT_ZW_SET_SUC_NODE_ID 1 /* ZW_SetSUCNodeID */ +#define SUPPORT_ZW_SET_WUT_TIMEOUT 0 /* ZW_SetWutTimeout */ +#define SUPPORT_ZW_SUPPORT9600_ONLY 0 /* ZW_Support9600Only */ +#define SUPPORT_ZW_TYPE_LIBRARY 1 /* ZW_Type_Library */ +#define SUPPORT_ZW_WATCHDOG_DISABLE 0 /* ZW_WatchDogDisable */ +#define SUPPORT_ZW_WATCHDOG_ENABLE 0 /* ZW_WatchDogEnable */ +#define SUPPORT_ZW_WATCHDOG_KICK 0 /* ZW_WatchDogKick */ +#define SUPPORT_ZW_WATCHDOG_START 1 /* ZW_WatchDogEnable */ +#define SUPPORT_ZW_WATCHDOG_STOP 1 /* ZW_WatchDogDisable */ +#define SUPPORT_ZW_NVR_GET_VALUE 1 /* ZW_NVRGetValue */ +#define SUPPORT_FUNC_ID_CLEAR_TX_TIMERS 1 /* ZW_ClearTxTimers */ +#define SUPPORT_FUNC_ID_GET_TX_TIMERS 1 /* ZW_GetTxTimer */ +#define SUPPORT_ZW_CLEAR_NETWORK_STATS 1 /* ZW_ClearNetworkStats */ +#define SUPPORT_ZW_GET_NETWORK_STATS 1 /* ZW_GetNetworkStats */ +#define SUPPORT_ZW_GET_BACKGROUND_RSSI 1 /* ZW_GetBackgroundRSSI */ +#define SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD 1 + +#define SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS 1 + +/* SerialAPI functionality support definitions */ +#define SUPPORT_SEND_DATA_TIMING 1 +/* Only Controllers can Add/Remove other nodes */ + +/* Enable support for SerialAPI Startup Notification */ +#define SUPPORT_SERIAL_API_STARTUP_NOTIFICATION 1 + +/* Common SerialAPI functionality support definitions */ +#define SUPPORT_SERIAL_API_GET_INIT_DATA 1 +#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION 1 +#define SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE 1 +#define SUPPORT_APPLICATION_COMMAND_HANDLER 0 +#define SUPPORT_SERIAL_API_SET_TIMEOUTS 1 + +#define SUPPORT_SERIAL_API_SOFT_RESET 1 +#define SUPPORT_SERIAL_API_SETUP 1 +#define SUPPORT_ZW_INITIATE_SHUTDOWN 1 +#define SUPPORT_SERIAL_API_GET_LR_NODES 1 +#define SUPPORT_SERIAL_GET_LR_CHANNEL 1 +#define SUPPORT_SERIAL_SET_LR_CHANNEL 1 +#define SUPPORT_SERIAL_SET_LR_VIRTUAL_IDS 1 +#define SUPPORT_SERIAL_ENABLE_RADIO_PTI 1 + +/* */ +#define SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET 0 + +/**************************************************************************/ +/* Common for all Controllers */ +/* SerialAPI functionality support definitions */ +#define SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE 1 +#define SUPPORT_ZW_APPLICATION_UPDATE 1 + + +/**************************************************************************/ +/* Controller */ +/* Specific SerialAPI functionality support definitions */ +/**************************************************************************/ +/* Installer Controller */ +/* Specific SerialAPI functionality support definitions */ +#if defined(ZW_INSTALLER) + +#define SUPPORT_GET_TX_COUNTER 1 +#define SUPPORT_RESET_TX_COUNTER 1 + +#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 +#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 +#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 0 + +/* Not supported by any controllers except controller portable and installer libs */ + +#endif /* ZW_INSTALLER */ + +/**************************************************************************/ +/* Bridge Controller */ +/* specific SerialAPI functionality support definitions */ +#ifdef ZW_CONTROLLER_BRIDGE +#define SUPPORT_ZW_SEND_DATA 1 /* ZW_SendData */ +#define SUPPORT_GET_TX_COUNTER 0 +#define SUPPORT_RESET_TX_COUNTER 0 +#define SUPPORT_ZW_GET_VIRTUAL_NODES 1 /* ZW_GetVirtualNodes */ +#define SUPPORT_ZW_IS_VIRTUAL_NODE 1 /* ZW_IsVirtualNode */ +#define SUPPORT_ZW_SEND_DATA_BRIDGE 1 /* ZW_SendData_Bridge */ +#define SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE 1 /* ZW_SendDataMulti_Bridge */ +#define SUPPORT_ZW_SET_SLAVE_LEARN_MODE 1 /* ZW_SetSlaveLearnMode */ +#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 1 + +#if SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE +#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 +#else +#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 1 +#endif +#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 1 + +/* Not supported by any controllers except controller portable and installer libs */ +#else +#define SUPPORT_ZW_SEND_DATA 1 /* ZW_SendData */ +#define SUPPORT_GET_TX_COUNTER 0 +#define SUPPORT_RESET_TX_COUNTER 0 +#define SUPPORT_ZW_GET_VIRTUAL_NODES 0 /* ZW_GetVirtualNodes */ +#define SUPPORT_ZW_IS_VIRTUAL_NODE 0 /* ZW_IsVirtualNode */ +#define SUPPORT_ZW_SEND_DATA_BRIDGE 0 /* ZW_SendData_Bridge */ +#define SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE 0 /* ZW_SendDataMulti_Bridge */ +#define SUPPORT_ZW_SET_SLAVE_LEARN_MODE 0 /* ZW_SetSlaveLearnMode */ +#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 +#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 +#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 1 + +#endif /* ZW_CONTROLLER_BRIDGE */ + +#ifdef ZW_CONTROLLER_SINGLE +#define SUPPORT_SERIAL_API_TEST 1 +#else +#define SUPPORT_SERIAL_API_TEST 0 +#endif diff --git a/src/zwave_ncp_serial_api_controller/gbl_metadata.yaml b/src/zwave_ncp_serial_api_controller/gbl_metadata.yaml new file mode 100644 index 00000000..33221b6e --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/gbl_metadata.yaml @@ -0,0 +1,6 @@ +baudrate: 115200 +dynamic: [zwave_version] +fw_type: z-wave +compression: lz4 +sign_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key" +encrypt_key: "{SDK_DIR}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key" \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/main.c b/src/zwave_ncp_serial_api_controller/main.c new file mode 100644 index 00000000..d760d1b2 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/main.c @@ -0,0 +1,29 @@ +/***************************************************************************//** + * @file main.c + * @brief main() function. + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#include "sl_component_catalog.h" +#include "sl_system_init.h" +#include "sl_system_kernel.h" + +int main(void) +{ + // Initialize Silicon Labs device, system, service(s) and protocol stack(s). + // Note that processing task(s) will be created by this call. + sl_system_init(); + + // Start the kernel. Task(s) created in app_init() will start running. + sl_system_kernel_start(); +} \ No newline at end of file diff --git a/src/zwave_ncp_serial_api_controller/nvm_backup_restore.c b/src/zwave_ncp_serial_api_controller/nvm_backup_restore.c new file mode 100644 index 00000000..7c0b848b --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/nvm_backup_restore.c @@ -0,0 +1,292 @@ +/** + * @file nvm_backup_restore.c + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#define DEBUGPRINT +#include "DebugPrint.h" + +/*WARNING: The backup/restore feature is based on the thesis that the NVM area is one continuous block even if it consist of two blocks, + A protocol and an application block. These blocks are defined in the linker script. The blocks are addressed using the data structure below. + The definition of the NVM blocks should not be changed, changing the definition will result in breaking the backup/restore feature*/ + +#define WORK_BUFFER_SIZE 64 + +/* HOST->ZW: +operation [open=0|read=1|write=2|close=3] +length desired length of read/write operation +offset(MSB) pointer to NVM memory +offset(LSB) +buffer[] buffer only sent for operation=write +*/ +/* ZW->HOST: +retVal [OK=0|error=1|EOF=-1] +length actual length of read/written data +offset(MSB) pointer to NVM memory (EOF ptr for operation=open) +offset(LSB) +buffer[] buffer only returned for operation=read +*/ + +static eNVMBackupRestoreOperation NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationClose; + +/** + * Must be called to open the backup restore feature + * The function will shut down the RF, Z-Wave timer system , close the NVM system, and disable the watchdog timer + * + * @return true if backup/resotre is opened else false + */ +static bool NvmBackupOpen(void) +{ + SZwaveCommandPackage nvmOpen = { + .eCommandType = EZWAVECOMMANDTYPE_NVM_BACKUP_OPEN, + .uCommandParams.NvmBackupRestore.offset = 0, + .uCommandParams.NvmBackupRestore.length = 0, + }; + zpal_enable_watchdog(false); + uint8_t bReturn = QueueProtocolCommand((uint8_t*)&nvmOpen); + if (EQUEUENOTIFYING_STATUS_SUCCESS == bReturn) + { + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_NVM_BACKUP_RESTORE)) + { + if (cmdStatus.Content.NvmBackupRestoreStatus.status) + { + return true; + } + } + } + return false; +} + +/** + * Read data from the NVM area + * + * @param offset[in] The offset of the NVM area to read from + * @param length[in] the length of the NVM area to read + * @param pNvmData[out] the data read from the NVM area + * + * @return true if data is read else false + */ +static uint8_t NvmBackupRead( uint32_t offset, uint8_t length, uint8_t* pNvmData) +{ + SZwaveCommandPackage nvmRead = { + .eCommandType = EZWAVECOMMANDTYPE_NVM_BACKUP_READ, + .uCommandParams.NvmBackupRestore.offset = offset, + .uCommandParams.NvmBackupRestore.length = length, + .uCommandParams.NvmBackupRestore.nvmData = pNvmData + }; + DPRINTF("NVM_Read_ 0x%08x, 0x%08x, 0x%08x\r\n",offset, length, (uint32_t)pNvmData); + uint8_t bReturn = QueueProtocolCommand((uint8_t*)&nvmRead); + if (EQUEUENOTIFYING_STATUS_SUCCESS == bReturn) + { + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_NVM_BACKUP_RESTORE)) + { + if (cmdStatus.Content.NvmBackupRestoreStatus.status) + { + DPRINT("NVM_READ_OK\r\n"); + return true; + } + } + } + DPRINT("NVM_READ_ERR\r\n"); + return false; +} + +/** + * Close the open/restore feature + * + * @return true if backup/retore feature is closed else false + */ + +static uint8_t NvmBackupClose(void) +{ + SZwaveCommandPackage nvmClose = { + .eCommandType = EZWAVECOMMANDTYPE_NVM_BACKUP_CLOSE + }; + uint8_t bReturn = QueueProtocolCommand((uint8_t*)&nvmClose); + + return ((EQUEUENOTIFYING_STATUS_SUCCESS == bReturn)? true: false); +} + +/** + * Restore the NVM data + * + * @param offset[in] The offset of the NVM area to wite backup data to + * @param length[in] the length of the backup data + * @param pNvmData[out] the data to be written to the NVM + * + * @return true if data is written else false + */ +static uint8_t NvmBackupRestore( uint32_t offset, uint8_t length, uint8_t* pNvmData) +{ + SZwaveCommandPackage nvmWrite = { + .eCommandType = EZWAVECOMMANDTYPE_NVM_BACKUP_WRITE, + .uCommandParams.NvmBackupRestore.offset = offset, + .uCommandParams.NvmBackupRestore.length = length, + .uCommandParams.NvmBackupRestore.nvmData = pNvmData + }; + uint8_t bReturn = QueueProtocolCommand((uint8_t*)&nvmWrite); + if (EQUEUENOTIFYING_STATUS_SUCCESS == bReturn) + { + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_NVM_BACKUP_RESTORE)) + { + if (cmdStatus.Content.NvmBackupRestoreStatus.status) + { + DPRINT("NVM_WRITE_OK\r\n"); + return true; + } + } + } + DPRINT("NVM_WRITE_ERR\r\n"); + return false; +} + +void func_id_serial_api_nvm_backup_restore(__attribute__((unused)) uint8_t inputLength, uint8_t *pInputBuffer, uint8_t *pOutputBuffer, uint8_t *pOutputLength) +{ + uint32_t NVM_WorkPtr; + uint8_t dataLength; + const uint32_t nvm_storage_size = zpal_nvm_backup_get_size(); + + dataLength = 0; /* Assume nothing is read or written */ + pOutputBuffer[0] = NVMBackupRestoreReturnValueOK; /* Assume not at EOF and no ERROR */ + pOutputBuffer[1] = 0; /* Assume no data */ + pOutputBuffer[2] = 0; + pOutputBuffer[3] = 0; + switch (pInputBuffer[0]) /* operation */ + { + case NVMBackupRestoreOperationOpen: /* open */ + { + if (NVMBackupRestoreOperationClose == NVMBackupRestoreOperationInProgress) + { + /* Lock everyone else out from making changes to the NVM content */ + /* Remember to have some kind of dead-mans-pedal to release lock again. */ + /* TODO */ + // here we have to shut down RF and disable power management and close NVM subsystem + if (NvmBackupOpen()) + { + NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationOpen; + NVM_WorkPtr = 0; + + /* Set the size of the backup/restore. (Number of bytes in flash used for file systems) */ + /* Please note that the special case where nvm_storage_size == 0x10000 is indicated by 0x00 0x00 */ + pOutputBuffer[2] = (uint8_t)(nvm_storage_size >> 8); + pOutputBuffer[3] = (uint8_t)nvm_storage_size; + } + else + { + pOutputBuffer[0] = NVMBackupRestoreReturnValueError; /*Report error we can't open backup restore feature*/ + } + } + } + break; + + case NVMBackupRestoreOperationRead: /* read */ + { + /* Validate input */ + DPRINT("NVM_Read_ \r\n"); + if ((NVMBackupRestoreOperationInProgress != NVMBackupRestoreOperationRead) && + (NVMBackupRestoreOperationInProgress != NVMBackupRestoreOperationOpen)) + { + DPRINT("NVM_Read_Mis \r\n"); + pOutputBuffer[0] = NVMBackupRestoreReturnValueOperationMismatch; + break; + } + NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationRead; + dataLength = pInputBuffer[1]; /* Requested dataLength */ + NVM_WorkPtr = (((uint32_t)pInputBuffer[2] << 8) + pInputBuffer[3]); + /* Make sure that length isn't larger than the available buffer size */ + if (dataLength > WORK_BUFFER_SIZE) + { + dataLength = WORK_BUFFER_SIZE; + } + /* Make sure that we don't go beyond valid NVM content */ + if ((NVM_WorkPtr + dataLength) >= nvm_storage_size) + { + DPRINT("NVM_Read_EOF \r\n"); + dataLength = (uint8_t)(nvm_storage_size - NVM_WorkPtr); + pOutputBuffer[0] = (uint8_t)NVMBackupRestoreReturnValueEOF; /* Indicate at EOF */ + } + pOutputBuffer[1] = dataLength; + pOutputBuffer[2] = pInputBuffer[2]; + pOutputBuffer[3] = pInputBuffer[3]; + NvmBackupRead(NVM_WorkPtr, dataLength, &pOutputBuffer[4]); + } + break; + + case NVMBackupRestoreOperationWrite: /* write */ + { + /* Validate input */ + if ((NVMBackupRestoreOperationInProgress != NVMBackupRestoreOperationWrite) && + (NVMBackupRestoreOperationInProgress != NVMBackupRestoreOperationOpen)) + { + DPRINT("NVM_Write_mis \r\n"); + pOutputBuffer[0] = NVMBackupRestoreReturnValueOperationMismatch; + break; + } + NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationWrite; + dataLength = pInputBuffer[1]; /* Requested dataLength */ + NVM_WorkPtr = (uint32_t)(((uint16_t)pInputBuffer[2] << 8) + pInputBuffer[3]); + if (dataLength > WORK_BUFFER_SIZE) + { + DPRINT("NVM_Write_buff_err \r\n"); + pOutputBuffer[0] = NVMBackupRestoreReturnValueError; /* ERROR: ignore request if length is larger than available buffer */ + } + else + { + /* Make sure that we don't go beyond valid NVM content */ + uint8_t tmp_buf[WORK_BUFFER_SIZE]; + if ((NVM_WorkPtr + dataLength) >= nvm_storage_size) + { + DPRINT("NVM_Write_EOF \r\n"); + dataLength = (uint8_t)(nvm_storage_size - NVM_WorkPtr); + pOutputBuffer[0] = (uint8_t)NVMBackupRestoreReturnValueEOF; /* Indicate at EOF */ + } + memcpy(tmp_buf, (uint8_t*)&pInputBuffer[4], dataLength); + NvmBackupRestore(NVM_WorkPtr , dataLength, tmp_buf); + pOutputBuffer[1] = dataLength; /* Data written */ + pOutputBuffer[2] = pInputBuffer[2]; + pOutputBuffer[3] = pInputBuffer[3]; + + } + dataLength = 0; + } + break; + + case NVMBackupRestoreOperationClose: /* close */ + { + /* Unlock NVM content, so everyone else can make changes again */ + // here we have to shut down RF and disable power management + /* TODO */ + if (NVMBackupRestoreOperationInProgress == NVMBackupRestoreOperationClose) + { + break; + } + if (NvmBackupClose()) + { + NVMBackupRestoreOperationInProgress = NVMBackupRestoreOperationClose; + } + else + { + pOutputBuffer[0] = NVMBackupRestoreReturnValueError; /*repoert error we canot close backup restore feature*/ + } + } + break; + + default: + break; + } + *pOutputLength = dataLength + 4; + +} diff --git a/src/zwave_ncp_serial_api_controller/nvm_backup_restore.h b/src/zwave_ncp_serial_api_controller/nvm_backup_restore.h new file mode 100644 index 00000000..a7967c97 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/nvm_backup_restore.h @@ -0,0 +1,23 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef APPS_SERIALAPI_NVM_BACKUP_RESTROE_H_ +#define APPS_SERIALAPI_NVM_BACKUP_RESTROE_H_ + +#include + +/** + * Must be called upon receiving a "Serial API NVM Backup/restore commands". + * @param inputLength Length of data in input buffer. + * @param pInputBuffer Input buffer + * @param pOutputBuffer Output buffer + * @param pOutputLength Length of data in output buffer. + */ +void func_id_serial_api_nvm_backup_restore(uint8_t inputLength, + uint8_t* pInputBuffer, + uint8_t* pOutputBuffer, + uint8_t* pOutputLength); + +#endif /* APPS_SERIALAPI_NVM_BACKUP_RESTROE_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/postbuild.sh b/src/zwave_ncp_serial_api_controller/postbuild.sh new file mode 100644 index 00000000..46a8a27b --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/postbuild.sh @@ -0,0 +1,174 @@ +#!/bin/bash + +# Usage: bash postbuild.sh BOOTLOADER APPLICATION SERIES SDK +# BOOTLOADER: path/to/bootloader.s37 +# APPLICATION: path/to/application/hex (don't include .hex in your argument) +# SERIES: 1 | 2 +# SDK: path/to/sdk +# BUILD_GBL: True of False, depepending on should gbl file should be generated +# APPLICATION_GBL: Name of gbl file to be generated + +# Functions are kept above all global variables to ensure that they are pure +check_return() +{ + ret=$1 + message=$2 + if [ $ret -ne 0 ]; then + echo $message + exit $ret + fi +} +sign_verify_btl() +{ + bootloader="$1" + sign_key="$2" + + echo "Signing bootloader with ECDSA signature" + commander convert ${bootloader} --secureboot --keyfile ${sign_key} --outfile ${bootloader} + check_return $? "Signing bootloader failed" + + echo "Verifying bootloader signature" + commander util verifysign ${bootloader} --verify ${sign_key} + check_return $? "Bootloader signature verification failed" +} + +sign_verify_app() +{ + hex_file="$1" + sign_key="$2" + + echo "Signing application with ECDSA signature" + commander convert ${hex_file} --secureboot --keyfile ${sign_key} --outfile ${hex_file} + check_return $? "Signing application failed" + + echo "Verifying application signature" + commander util verifysign ${hex_file} --verify ${sign_key} + check_return $? "Verifying application signature failed" +} + +generate_gbl_files() +{ + build_gbl="$1" + series="$2" + gbl_file="$3" + hex_file="$4" + sign_key="$5" + encr_key="$6" + + if [[ "$build_gbl" == "False" ]]; then + # Nothing to do + return + fi + + if [[ "$series" == "1" ]]; then + compression="lz4" + fi + + if [[ "$series" == "2" ]]; then + compression="lzma" + fi + + commander gbl create ${gbl_file} --app ${hex_file} --sign ${sign_key} --encrypt ${encr_key} --compress ${compression} + check_return $? "Failed to generate GBL file" +} + +BOOTLOADER=$1 +APPLICATION=$2 +SERIES=$3 +SDK=$4 +BUILD_GBL=$5 +APPLICATION_GBL=$6 + +if [ $# -lt 5 ]; then + # If argument 5 and 6 are not provided, assume that gbl file should be created + # and use the same name as for application + BUILD_GBL="True" + APPLICATION_GBL=$APPLICATION +fi + +# Set this to YES if we want to enable secure boot on ocelot(series2) +# using ECDSA signature verification during startup and EM4 wakeup. +# SL_APPLICATION_SIGNATURE must be set to APPLICATION_SIGNATURE_ECDSA_P256 in the +# application_properties_config.h + +SECURE_BOOT="NO" + +# Use controller keys for Serial API Controller apps (series 2 and series 1, ZG14) and +# sample keys for other apps. +# We have shipped Serial API Controller signed with sample key for other variants than ZG14. +# We must continue doing that so that customers can firmware upgrade existing Serial API +# Controller apps running on ZG13 / ZGM13. +# To check for the variant we must use the bootloader since the application name might not +# contain the OPN name +if [[ "$SERIES" == "2" && $APPLICATION == *"zwave_ncp_serial_api_controller"* ]]; then + SIGN_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key + ENCR_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key +elif [[ "$SERIES" == "1" && $APPLICATION == *"zwave_ncp_serial_api_controller"* && $BOOTLOADER == *"EFR32ZG14"* ]]; then + SIGN_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_sign.key + ENCR_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/controller-keys/controller_encrypt.key +else + SIGN_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/sample-keys/sample_sign.key + ENCR_KEY=${SDK}/protocol/z-wave/platform/SiliconLabs/PAL/BootLoader/sample-keys/sample_encrypt.key +fi + + +# Make a local copy of the bootloader +APPLICATION_DIR="$(dirname "${APPLICATION}")" +BOOTLOADER_NAME="$(basename "${BOOTLOADER}")" +cp -v ${BOOTLOADER} ${APPLICATION_DIR}/${BOOTLOADER_NAME} +BOOTLOADER=${APPLICATION_DIR}/${BOOTLOADER_NAME} + +# Enable secure boot by signing(ECDSA) the application and bootloader images. +if [[ "$SERIES" == "2" && "$SECURE_BOOT" == "YES" ]]; then + # SL_APPLICATION_SIGNATURE must be set to APPLICATION_SIGNATURE_ECDSA_P256 in the + # application_properties_config.h + sign_verify_btl ${BOOTLOADER} ${SIGN_KEY} + sign_verify_app "${APPLICATION}.hex" ${SIGN_KEY} +fi + +echo "Generating gbl file" +generate_gbl_files ${BUILD_GBL} ${SERIES} "${APPLICATION_GBL}.gbl" "${APPLICATION}.hex" ${SIGN_KEY} ${ENCR_KEY} + +# Check if make-v255-file.py exists +if [[ -e "${SDK}/protocol/z-wave/DevTools/internal/make-v255-file.py" ]]; then + echo "Making v255 hex and gbl file" + python ${SDK}/protocol/z-wave/DevTools/internal/make-v255-file.py ${APPLICATION}.out ${APPLICATION}_v255.out + check_return $? "Failed to run make-v255-file.py" + + ${ARM_GCC_DIR}/bin/arm-none-eabi-objcopy -O ihex ${APPLICATION}_v255.out ${APPLICATION}_v255.hex + check_return $? "Failed to run arm-none-eabi-objcopy" + + if [[ "$SERIES" == "2" && "$SECURE_BOOT" == "YES" ]]; then + sign_verify_app "${APPLICATION}_v255.hex" ${SIGN_KEY} + fi + + generate_gbl_files ${BUILD_GBL} ${SERIES} "${APPLICATION_GBL}_v255.gbl" "${APPLICATION}_v255.hex" ${SIGN_KEY} ${ENCR_KEY} + # Cleanup temporary file that was used to generate v255.gbl only + rm "${APPLICATION}_v255.out" +fi + +# Merge is only done for series 2 devices +if [[ "$SERIES" == "2" ]]; then + echo "Combining bootloader and application into one file" + commander convert $BOOTLOADER $APPLICATION.hex --outfile $APPLICATION.hex + check_return $? "Failed to merge bootloader and application" + + # Also merge the _v255 binary if it exists + if [[ -e "${APPLICATION}_v255.hex" ]]; then + echo "Combining bootloader and application v255 into one file" + commander convert $BOOTLOADER ${APPLICATION}_v255.hex --outfile ${APPLICATION}_v255.hex + check_return $? "Failed to merge bootloader and application v255" + fi +fi + +# Generate size report +echo "Generating size report" +${ARM_GCC_DIR}/bin/arm-none-eabi-size -A -x ${APPLICATION}.out > ${APPLICATION}_size.txt +check_return $? "Failed to run arm-none-eabi-size" + +python $SDK/protocol/z-wave/DevTools/size_info_gen.py -i ${APPLICATION}_size.txt +check_return $? "Failed to run size_info_gen.py" + +exit 0 + +# EOF diff --git a/src/zwave_ncp_serial_api_controller/serialapi_file.c b/src/zwave_ncp_serial_api_controller/serialapi_file.c new file mode 100644 index 00000000..e0c4dab8 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/serialapi_file.c @@ -0,0 +1,795 @@ +/** + * @file serialapi_file.c + * @copyright 2022 Silicon Laboratories Inc. + * @brief Z-Wave Switch On/Off Sample Application + * @details This sample application is a Z-Wave slave node which has an LED (D2 + * on ZDP03A) that can be turned on or off from another Z-Wave node by sending + * a Basic Set On or a Basic Set Off command. + * + * It can be included and excluded from a Z-Wave network by pressing S1 switch + * on the ZDP03A board 3 times. S2 switch toggles LED D2. S3 switch transmits + * a Node Information Frame (NIF). + * @author Someone who started this sample application at some point in time. + * @author Thomas Roll (TRO) + * @author Christian Salmony Olsen (COLSEN) + */ + +/****************************************************************************/ +/* INCLUDE FILES */ +/****************************************************************************/ + +#include +#include +#include "SizeOf.h" +#include "Assert.h" +#include "DebugPrintConfig.h" +//#define DEBUGPRINT +//#include "DebugPrint.h" +#include "SyncEvent.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "zw_version_config.h" + +#define APPLICATIONSIZE (4*1024) + +#define APPL_DATA_FILE_SIZE 512 + +#define APP_VERSION_7_15_3 0x00070F03 // 7.15.3 (NO_20DBM_SUPPORT) +#define APP_VERSION_7_18_1 0x00071201 /* 7.18.1 - The changes include the capability to set tx power to + * 20+ dBm over the serial link. */ +#define APP_VERSION_7_21_0 0x00071500 /* 7.21.0 - [FIX] save the node ID type. */ + +// Used by the application data file. +typedef struct SApplicationData +{ + uint8_t extNvm[APPL_DATA_FILE_SIZE]; +} SApplicationData; + /* listening | generic | specific | parmLength | nodeParms[] */ +typedef struct SApplicationSettings +{ + uint8_t listening; + uint8_t generic; + uint8_t specific; +} SApplicationSettings; + +typedef struct SApplicationCmdClassInfo +{ + uint8_t UnSecureIncludedCCLen; + uint8_t UnSecureIncludedCC[APPL_NODEPARM_MAX]; + uint8_t SecureIncludedUnSecureCCLen; + uint8_t SecureIncludedUnSecureCC[APPL_NODEPARM_MAX]; + uint8_t SecureIncludedSecureCCLen; + uint8_t SecureIncludedSecureCC[APPL_NODEPARM_MAX]; + +} SApplicationCmdClassInfo; + +typedef struct SApplicationConfiguration_v7_15_3 // Cannot pack this (change size) as it is already in the field. +{ + zpal_radio_region_t rfRegion; + int8_t iTxPower; // changed to zpal_tx_power_t { aka int16_t } in APP_VERSION_7_18_1 + int8_t ipower0dbmMeasured; // changed to zpal_tx_power_t { aka int16_t } in APP_VERSION_7_18_1 + uint8_t radio_debug_enable; + int16_t maxTxPower; // changed to zpal_tx_power_t { aka int16_t } in APP_VERSION_7_18_1 +} SApplicationConfiguration_v7_15_3; + +//declare the old structure only for the migration process. +//No variable should be declared with this type (excepted for migration process). +typedef struct __attribute__((packed)) SApplicationConfiguration_V7_18_1 +{ + zpal_radio_region_t rfRegion; + zpal_tx_power_t iTxPower; + zpal_tx_power_t ipower0dbmMeasured; + uint8_t radio_debug_enable; + zpal_tx_power_t maxTxPower; // For LR only +}SApplicationConfiguration_V7_18_1; + +typedef struct __attribute__((packed)) SApplicationConfiguration // Must be packet as it is saved on NVM. +{ + zpal_radio_region_t rfRegion; + zpal_tx_power_t iTxPower; + zpal_tx_power_t ipower0dbmMeasured; + uint8_t radio_debug_enable; + zpal_tx_power_t maxTxPower; // For LR only + eSerialAPISetupNodeIdBaseType nodeIdBaseType; +} SApplicationConfiguration; + +#define FILE_SIZE_APPLICATIONDATA (sizeof(SApplicationData)) +#define FILE_SIZE_APPLICATIONSETTINGS (sizeof(SApplicationSettings)) +#define FILE_SIZE_APPLICATIONCMDINFO (sizeof(SApplicationCmdClassInfo)) +#define FILE_SIZE_APPLICATIONCONFIGURATION (sizeof(SApplicationConfiguration)) + +static void WriteDefault(void); + +// Application file system +static zpal_nvm_handle_t pFileSystemApplication; + + +static void WriteDefaultApplicationConfiguration(void); +static bool ObjectExist(zpal_nvm_object_key_t key); + +bool SerialAPI_GetZWVersion(uint32_t * appVersion) +{ + return ZAF_nvm_read(ZAF_FILE_ID_APP_VERSION, appVersion, ZAF_FILE_SIZE_APP_VERSION) == ZPAL_STATUS_OK; +} + +bool SerialAPI_SetZWVersion(const uint32_t * appVersion) +{ + return ZAF_nvm_write(ZAF_FILE_ID_APP_VERSION, appVersion, sizeof(appVersion)) == ZPAL_STATUS_OK; +} + +static void +SerialAPI_FileSystemMigrationManagement(void) +{ + //Read present file system version file + uint32_t presentFilesysVersion; + uint32_t expectedFilesysVersion; // This will hold the file system version that current SW will support. + + SerialAPI_GetZWVersion(&presentFilesysVersion); + + expectedFilesysVersion = zpal_get_app_version(); + + if(expectedFilesysVersion < presentFilesysVersion) + { + //System downgrade. Should not be allowed. + ASSERT(false); + } + else if(expectedFilesysVersion > presentFilesysVersion) // File system upgrade needed. Initiating file system migration... + { + /** + * Continuous migration until all needed migrations are performed, + * to lift from any version to the latest file system version. + */ + + // If current version is 7.15.2 or older then update the FILE_ID_APPLICATIONCONFIGURATION file to the current format + if ( presentFilesysVersion < APP_VERSION_7_15_3 ) + { + // Add code for migration of file system to version APP_VERSION_7_15_3 (7.15.3). + + //Get length of legacy file + size_t dataLen; + zpal_nvm_get_object_size(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &dataLen); + + //Read legacy file to first members of tApplicationConfiguration + SApplicationConfiguration_v7_15_3 tApplicationConfiguration = { 0 }; + // Initialize, since zpal_nvm_read() might fail. + zpal_nvm_read(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, dataLen); + + //Write default values to new members of tApplicationConfiguration and update the file. + tApplicationConfiguration.radio_debug_enable = 0; + tApplicationConfiguration.maxTxPower = 140; + zpal_status_t status = zpal_nvm_write(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, + sizeof(tApplicationConfiguration)); + if (ZPAL_STATUS_OK == status) + { + presentFilesysVersion = APP_VERSION_7_15_3; + } + } + + // Migrate files from file system version APP_VERSION_7_15_3 to APP_VERSION_7_18_1. + if ( presentFilesysVersion < APP_VERSION_7_18_1 ) + { + SApplicationConfiguration_v7_15_3 tApplicationConfiguration_v7_15_3 = { 0 }; + SApplicationConfiguration_V7_18_1 tApplicationConfiguration = { 0 }; + zpal_status_t status; + + status = zpal_nvm_read(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration_v7_15_3, + sizeof(tApplicationConfiguration_v7_15_3)); + if (ZPAL_STATUS_OK != status) + { + WriteDefaultApplicationConfiguration(); + } + else + { + tApplicationConfiguration.rfRegion = tApplicationConfiguration_v7_15_3.rfRegion; + tApplicationConfiguration.iTxPower = tApplicationConfiguration_v7_15_3.iTxPower; + tApplicationConfiguration.ipower0dbmMeasured = tApplicationConfiguration_v7_15_3.ipower0dbmMeasured; + tApplicationConfiguration.radio_debug_enable = tApplicationConfiguration_v7_15_3.radio_debug_enable; + tApplicationConfiguration.maxTxPower = tApplicationConfiguration_v7_15_3.maxTxPower; + + status = zpal_nvm_write(pFileSystemApplication, FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, + sizeof(tApplicationConfiguration)); /* Do not use FILE_SIZE_APPLICATIONCONFIGURATION in + * migration functions, instead hard-code the size as + * sizes do change with FW upgrades. */ + if (ZPAL_STATUS_OK == status) + { + presentFilesysVersion = APP_VERSION_7_18_1; + } + } + + // Lifted to version APP_VERSION_7_18_1 + } + +#ifdef ZW_MIGRATION_FROM_7_20 + // Migrate files from file system version APP_VERSION_7_20_0 (same as 7_18_1) to APP_VERSION_7_21_0. + if ( presentFilesysVersion < APP_VERSION_7_21_0 ) + { + SApplicationConfiguration sAppCfgMigration = { 0 }; + zpal_status_t status; + + //cannot migrate if the file system is older than V7.18.1. Other migration script should have been called before. + ASSERT(APP_VERSION_7_18_1 <= presentFilesysVersion); + + /*New application configuration has only a new member (no change in the legacy part). So read the + legacy structure directly in the new one, then just set value for new member.*/ + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &sAppCfgMigration, + sizeof(SApplicationConfiguration_V7_18_1)); + if (ZPAL_STATUS_OK != status) + { + WriteDefaultApplicationConfiguration(); + } + else + { + //default value for new member. + sAppCfgMigration.nodeIdBaseType = SERIAL_API_SETUP_NODEID_BASE_TYPE_DEFAULT; + + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &sAppCfgMigration, + sizeof(sAppCfgMigration)); /* Do not use FILE_SIZE_APPLICATIONCONFIGURATION in + * migration functions, instead hard-code the size as + * sizes do change with FW upgrades. */ + if (ZPAL_STATUS_OK == status) + { + presentFilesysVersion = APP_VERSION_7_21_0; + } + } + } +#endif /* ZW_MIGRATION_FROM_7_20 */ + + /* + * If this fails, some of the migrations were not performed due to earlier migrations that have failed. + */ + ASSERT(APP_VERSION_7_21_0 <= presentFilesysVersion); + + /** + * @attention This implementation assumes that the build is going to update the ZAF_FILE_ID_APP_VERSION to the current! + */ + + /** + * Write the new file system version number to NMV. + */ + SerialAPI_SetZWVersion(&expectedFilesysVersion); + } +} + +uint8_t SerialApiFileInit(void) +{ + // Init application filesystem + bool initStatus = ZAF_nvm_app_init(); + if (!initStatus) + { + ASSERT(false); //Assert has been kept for debugging , can be removed from production code. This error can only be caused by some internal flash HW failure + } + + initStatus = ZAF_nvm_init(); + if (!initStatus) + { + ASSERT(false); //Assert has been kept for debugging , can be removed from production code. This error can only be caused by some internal flash HW failure + } + + uint32_t appVersion; + bool status = SerialAPI_GetZWVersion(&appVersion); + + if (status) + { + if (zpal_get_app_version() != appVersion) + { + /** + * In case the file-system is older than supported by this version of the FW, then upgrade. + */ + SerialAPI_FileSystemMigrationManagement(); + } + } + else + { + //There are no files on first boot up. Write default files. + WriteDefault(); + return false; + } + + return true; +} + +static +bool ObjectExist(zpal_nvm_object_key_t key) +{ + zpal_status_t status; + size_t tDataLen; + + status = ZAF_nvm_app_get_object_size(key, &tDataLen); + if (ZPAL_STATUS_OK != status) + { + return false; + } + return true; +} + +/** + * @brief Reads application data from file system. + */ +uint8_t SerialApiNvmReadAppData(uint32_t offset, uint8_t* pAppData, uint32_t iLength) +{ + SApplicationData tApplicationData = { 0 }; + + uint8_t dataIsRead = false; + zpal_status_t status; + + if (ObjectExist(FILE_ID_APPLICATIONDATA)) + { + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONDATA, &tApplicationData, FILE_SIZE_APPLICATIONDATA); + if (ZPAL_STATUS_OK == status) + { + dataIsRead = true; + for (uint32_t i = 0; i < iLength; i++) + { + pAppData[i] = tApplicationData.extNvm[i+ offset]; + } + } + } + return dataIsRead; + +} + +/** + * @brief Writes application data to file system. + */ +uint8_t SerialApiNvmWriteAppData(uint32_t offset, const uint8_t* pAppData, uint32_t iLength) +{ + SApplicationData tApplicationData = { 0 }; + uint8_t dataIsWritten = false; + zpal_status_t status; + + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONDATA, &tApplicationData, FILE_SIZE_APPLICATIONDATA); + if (ZPAL_STATUS_OK == status) + { + memcpy((uint8_t *)&tApplicationData + offset, pAppData, iLength); + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONDATA, &tApplicationData, FILE_SIZE_APPLICATIONDATA); + if (ZPAL_STATUS_OK == status) + { + dataIsWritten = true; + } + } + return dataIsWritten; +} + +uint8_t +SaveApplicationSettings(uint8_t bListening, + uint8_t bGeneric, + uint8_t bSpecific + ) +{ + SApplicationSettings tApplicationSettings = { 0 }; + uint8_t dataIsWritten = false; + zpal_status_t status; + + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONSETTINGS, &tApplicationSettings, FILE_SIZE_APPLICATIONSETTINGS); + if (ZPAL_STATUS_OK == status) + { + tApplicationSettings.listening = bListening; + tApplicationSettings.generic = bGeneric; + tApplicationSettings.specific = bSpecific; + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONSETTINGS, &tApplicationSettings, FILE_SIZE_APPLICATIONSETTINGS); + if (ZPAL_STATUS_OK == status) + { + dataIsWritten = true; + } + } + return dataIsWritten; +} + + +uint8_t +ReadApplicationSettings(uint8_t* pListening, + uint8_t* pGeneric, + uint8_t* pSpecific + ) +{ + SApplicationSettings tApplicationSettings = { 0 }; + uint8_t dataIsRead = false; + zpal_status_t status; + + if (ObjectExist(FILE_ID_APPLICATIONSETTINGS)) + { + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONSETTINGS, &tApplicationSettings, FILE_SIZE_APPLICATIONSETTINGS); + if (ZPAL_STATUS_OK == status) + { + *pListening = tApplicationSettings.listening; + *pGeneric = tApplicationSettings.generic ; + *pSpecific = tApplicationSettings.specific; + dataIsRead = true; + } + } + return dataIsRead; + +} + + +uint8_t +SaveApplicationCCInfo (uint8_t bUnSecureIncludedCCLen, + const uint8_t* pUnSecureIncludedCC, + uint8_t bSecureIncludedUnSecureCCLen, + const uint8_t* pSecureIncludedUnSecureCC, + uint8_t bSecureIncludedSecureCCLen, + const uint8_t* pSecureIncludedSecureCC) +{ + SApplicationCmdClassInfo tApplicationCmdClassInfo = { 0 }; + uint8_t dataIsWritten = false; + zpal_status_t status; + + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCMDINFO, &tApplicationCmdClassInfo, FILE_SIZE_APPLICATIONCMDINFO); + if (ZPAL_STATUS_OK == status) + { + + tApplicationCmdClassInfo.UnSecureIncludedCCLen = bUnSecureIncludedCCLen; + tApplicationCmdClassInfo.SecureIncludedUnSecureCCLen = bSecureIncludedUnSecureCCLen; + tApplicationCmdClassInfo.SecureIncludedSecureCCLen = bSecureIncludedSecureCCLen; + + for (uint8_t i = 0; i < APPL_NODEPARM_MAX; i++) + { + if (i < bUnSecureIncludedCCLen) + { + tApplicationCmdClassInfo.UnSecureIncludedCC[i] = pUnSecureIncludedCC[i]; + } + else + { + tApplicationCmdClassInfo.UnSecureIncludedCC[i] = 0; + } + + if (i < bSecureIncludedUnSecureCCLen) + { + tApplicationCmdClassInfo.SecureIncludedUnSecureCC[i] = pSecureIncludedUnSecureCC[i]; + } + else + { + tApplicationCmdClassInfo.SecureIncludedUnSecureCC[i] = 0; + } + + if (i < bSecureIncludedSecureCCLen) + { + tApplicationCmdClassInfo.SecureIncludedSecureCC[i] = pSecureIncludedSecureCC[i]; + } + else + { + tApplicationCmdClassInfo.SecureIncludedSecureCC[i] = 0; + } + + } + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCMDINFO, &tApplicationCmdClassInfo, FILE_SIZE_APPLICATIONCMDINFO); + if (ZPAL_STATUS_OK == status) + { + dataIsWritten = true; + } + } + return dataIsWritten; + +} + + +uint8_t +ReadApplicationCCInfo (uint8_t* pUnSecureIncludedCCLen, + uint8_t* pUnSecureIncludedCC, + uint8_t* pSecureIncludedUnSecureCCLen, + uint8_t* pSecureIncludedUnSecureCC, + uint8_t* pSecureIncludedSecureCCLen, + uint8_t* pSecureIncludedSecureCC) +{ + SApplicationCmdClassInfo tApplicationCmdClassInfo = { 0 }; + uint8_t dataIsRead = false; + zpal_status_t status; + + if (ObjectExist(FILE_ID_APPLICATIONCMDINFO)) + { + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCMDINFO, &tApplicationCmdClassInfo, FILE_SIZE_APPLICATIONCMDINFO); + if (ZPAL_STATUS_OK == status) + { + dataIsRead = true; + *pUnSecureIncludedCCLen = tApplicationCmdClassInfo.UnSecureIncludedCCLen; + *pSecureIncludedUnSecureCCLen = tApplicationCmdClassInfo.SecureIncludedUnSecureCCLen; + *pSecureIncludedSecureCCLen = tApplicationCmdClassInfo.SecureIncludedSecureCCLen; + for (uint8_t i = 0; i < APPL_NODEPARM_MAX; i++) + { + if (i < *pUnSecureIncludedCCLen) + { + pUnSecureIncludedCC[i] = tApplicationCmdClassInfo.UnSecureIncludedCC[i] ; + } + else + { + pUnSecureIncludedCC[i] = 0; + } + + if (i < *pSecureIncludedUnSecureCCLen) + { + pSecureIncludedUnSecureCC[i] = tApplicationCmdClassInfo.SecureIncludedUnSecureCC[i]; + } + else + { + pSecureIncludedUnSecureCC[i] = 0; + } + + if (i < *pSecureIncludedSecureCCLen) + { + pSecureIncludedSecureCC[i] = tApplicationCmdClassInfo.SecureIncludedSecureCC[i]; + } + else + { + pSecureIncludedSecureCC[i] = 0; + } + + } + } + } + return dataIsRead; + +} + +uint8_t +SaveApplicationRfRegion(zpal_radio_region_t rfRegion) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsWritten = false; + zpal_status_t status; + + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + tApplicationConfiguration.rfRegion = rfRegion; + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + dataIsWritten = true; + } + } + return dataIsWritten; +} + +uint8_t +ReadApplicationRfRegion(zpal_radio_region_t* rfRegion) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsRead = false; + zpal_status_t status; + + if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) + { + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + *rfRegion = tApplicationConfiguration.rfRegion; + dataIsRead = true; + } + } + return dataIsRead; + +} + +uint8_t +SaveApplicationNodeIdBaseType(eSerialAPISetupNodeIdBaseType nodeIdBaseType) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsWritten = false; + zpal_status_t status; + + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + tApplicationConfiguration.nodeIdBaseType = nodeIdBaseType; + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + dataIsWritten = true; + } + } + return dataIsWritten; +} + +uint8_t +ReadApplicationNodeIdBaseType(eSerialAPISetupNodeIdBaseType* nodeIdBaseType) +{ + SApplicationConfiguration tApplicationConfiguration; + uint8_t dataIsRead = false; + zpal_status_t status; + + if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) + { + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + *nodeIdBaseType = tApplicationConfiguration.nodeIdBaseType; + dataIsRead = true; + } + } + return dataIsRead; + +} + +uint8_t +SaveApplicationTxPowerlevel(zpal_tx_power_t ipower, zpal_tx_power_t power0dbmMeasured) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsWritten = false; + zpal_status_t status; + + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + tApplicationConfiguration.iTxPower = ipower; + tApplicationConfiguration.ipower0dbmMeasured = power0dbmMeasured; + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + dataIsWritten = true; + } + } + return dataIsWritten; +} + + +uint8_t +ReadApplicationTxPowerlevel(zpal_tx_power_t *ipower, zpal_tx_power_t *power0dbmMeasured) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsRead = false; + zpal_status_t status; + + if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) + { + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + *ipower = tApplicationConfiguration.iTxPower; + *power0dbmMeasured = tApplicationConfiguration.ipower0dbmMeasured; + dataIsRead = true; + } + } + return dataIsRead; +} + + +uint8_t +SaveApplicationMaxLRTxPwr(zpal_tx_power_t maxTxPwr) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsWritten = false; + zpal_status_t status; + + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + tApplicationConfiguration.maxTxPower = maxTxPwr; + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + dataIsWritten = true; + } + } + return dataIsWritten; +} + + +uint8_t +ReadApplicationMaxLRTxPwr(zpal_tx_power_t *maxTxPwr) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsRead = false; + zpal_status_t status; + + if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) + { + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + *maxTxPwr = tApplicationConfiguration.maxTxPower; + dataIsRead = true; + } + } + return dataIsRead; +} + + +uint8_t +SaveApplicationEnablePTI(uint8_t radio_debug_enable) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsWritten = false; + zpal_status_t status; + + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + tApplicationConfiguration.radio_debug_enable = radio_debug_enable; + status = ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + dataIsWritten = true; + } + } + return dataIsWritten; +} + + +uint8_t +ReadApplicationEnablePTI(uint8_t *radio_debug_enable) +{ + SApplicationConfiguration tApplicationConfiguration = { 0 }; + uint8_t dataIsRead = false; + zpal_status_t status; + + if (ObjectExist(FILE_ID_APPLICATIONCONFIGURATION)) + { + status = ZAF_nvm_app_read(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, FILE_SIZE_APPLICATIONCONFIGURATION); + if (ZPAL_STATUS_OK == status) + { + *radio_debug_enable = tApplicationConfiguration.radio_debug_enable; + dataIsRead = true; + } + } + return dataIsRead; +} + + +uint32_t +ReadApplicationVersion(void) +{ + uint32_t appVersion; + SerialAPI_GetZWVersion(&appVersion); + + return appVersion; +} + +static void +WriteDefaultApplicationSettings(void) +{ + //Write default Application Settings file + SApplicationSettings tApplicationSettings = { 0 }; + ZAF_nvm_app_write(FILE_ID_APPLICATIONSETTINGS, &tApplicationSettings, sizeof(SApplicationSettings)); +} + +static void +WriteDefaultApplicationCmdClassInfo(void) +{ + //Write default ApplicationCmdClassInfo file + SApplicationCmdClassInfo tApplicationCmdClassInfo = { 0 }; + ZAF_nvm_app_write(FILE_ID_APPLICATIONCMDINFO, &tApplicationCmdClassInfo, sizeof(SApplicationCmdClassInfo)); +} + +static void +WriteDefaultApplicationData(void) +{ + //Write default Controller Info file + SApplicationData tApplicationData = { 0 }; + ZAF_nvm_app_write(FILE_ID_APPLICATIONDATA, &tApplicationData, sizeof(SApplicationData)); +} + +static void +WriteDefaultApplicationConfiguration(void) +{ + //Write default Application Configuration file + SApplicationConfiguration tApplicationConfiguration = { 0 }; + ZAF_nvm_app_write(FILE_ID_APPLICATIONCONFIGURATION, &tApplicationConfiguration, sizeof(SApplicationConfiguration)); +} + +static void +WriteDefaultApplicationFileSystemVersion(void) +{ + //Write Application filesystem version + uint32_t appVersion = (APP_VERSION << 16) | (APP_REVISION << 8) | APP_PATCH; + SerialAPI_SetZWVersion(&appVersion); +} + +static void +WriteDefault(void) +{ + WriteDefaultApplicationSettings(); + + WriteDefaultApplicationCmdClassInfo(); + + WriteDefaultApplicationData(); + + WriteDefaultApplicationConfiguration(); + + WriteDefaultApplicationFileSystemVersion(); +} diff --git a/src/zwave_ncp_serial_api_controller/serialapi_file.h b/src/zwave_ncp_serial_api_controller/serialapi_file.h new file mode 100644 index 00000000..42051aa2 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/serialapi_file.h @@ -0,0 +1,136 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + * @brief module that handle SerialAPI application data + * @details This module implement SerialAPI filesystem functions + */ + +#include +#include +#include +#include +#include "cmds_management.h" + +#define FILE_ID_APPLICATIONSETTINGS 102 +#define FILE_ID_APPLICATIONCMDINFO 103 +#define FILE_ID_APPLICATIONCONFIGURATION 104 +#define FILE_ID_APPLICATIONDATA 200 +#define FILE_ID_PROPRIETARY_1 300 + +/** + * @brief Initailize the serialAPI file system + * + * return false if application files was corrupted or didn't exist already, otherwise true + */ +uint8_t SerialApiFileInit(void); + +/** + * @brief Reads application data from file system. + */ +uint8_t SerialApiNvmReadAppData(uint32_t offset, uint8_t* pAppData, uint32_t iLength); + +/** + * @brief Writes application data to file system. + */ +uint8_t SerialApiNvmWriteAppData(uint32_t offset, const uint8_t* pAppData, uint32_t iLength); + +uint8_t +SaveApplicationSettings(uint8_t bListening, + uint8_t bGeneric, + uint8_t bSpecific); + +uint8_t +ReadApplicationSettings(uint8_t* pListening, + uint8_t* pGeneric, + uint8_t* pSpecific); + +/** + * @brief Writes the node cmd class information setting + */ +uint8_t +SaveApplicationCCInfo (uint8_t bUnSecureIncludedCCLen, + const uint8_t* pUnSecureIncludedCC, + uint8_t bSecureIncludedUnSecureCCLen, + const uint8_t* pSecureIncludedUnSecureCC, + uint8_t bSecureIncludedSecureCCLen, + const uint8_t* pSecureIncludedSecureCC); + +/** + * @brief read the node cmd class information setting + */ +uint8_t +ReadApplicationCCInfo (uint8_t* pUnSecureIncludedCCLen, + uint8_t* pUnSecureIncludedCC, + uint8_t* pSecureIncludedUnSecureCCLen, + uint8_t* pSecureIncludedUnSecureCC, + uint8_t* pSecureIncludedSecureCCLen, + uint8_t* pSecureIncludedSecureCC); + +/** + * @brief Writes the application configuration to file system + */ +uint8_t +SaveApplicationRfRegion(zpal_radio_region_t rfRegion); + +/** + * @brief Reads the application configuration from file system + */ +uint8_t +ReadApplicationRfRegion(zpal_radio_region_t* rfRegion); + +uint8_t +SaveApplicationNodeIdBaseType(eSerialAPISetupNodeIdBaseType nodeIdBaseType); + + +uint8_t +ReadApplicationNodeIdBaseType(eSerialAPISetupNodeIdBaseType* nodeIdBaseType); + + +/** + * @brief Writes the application Tx power configuration to file system + */ +uint8_t +SaveApplicationTxPowerlevel(zpal_tx_power_t ipower, zpal_tx_power_t power0dbmMeasured); + +/** + * @brief Reads the application Tx power configuration from file system + */ +uint8_t +ReadApplicationTxPowerlevel(zpal_tx_power_t *ipower, zpal_tx_power_t *power0dbmMeasured); + + +/** + * Writes the application Max LR tx power value configuration to file system + * + * @param maxTxPwr the LR max tx power value in deci + * @return value was saved correctly + */ +uint8_t +SaveApplicationMaxLRTxPwr(zpal_tx_power_t maxTxPwr); + +/** + * Reads the application Max LR tx power value configuration from file system + * + * @param maxTxPwr pointer to the LR max tx power value in deci + * @return value was read correctly + */ +uint8_t +ReadApplicationMaxLRTxPwr(zpal_tx_power_t *maxTxPwr); + +/** + * @brief Writes radio_debug_enable to file system + */ +uint8_t +SaveApplicationEnablePTI(uint8_t radio_debug_enable); + +/** + * @brief Reads radio_debug_enable from file system + */ +uint8_t +ReadApplicationEnablePTI(uint8_t *radio_debug_enable); + +/** + * @brief Reads the application version from NVM + */ +uint32_t +ReadApplicationVersion(void); diff --git a/src/zwave_ncp_serial_api_controller/slave_supported_func.h b/src/zwave_ncp_serial_api_controller/slave_supported_func.h new file mode 100644 index 00000000..2ed9c2ab --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/slave_supported_func.h @@ -0,0 +1,181 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +/* Generated file copied from Sdk670 with std. functions supported by static controller. */ +/* Following defines has been disable for build purposes: + * SUPPORT_ZW_AES_ECB + * SUPPORT_ZW_SET_EXT_INT_LEVEL + */ +#define SUPPORT_GET_ROUTING_TABLE_LINE 0 /* ZW_GetRoutingInfo */ +#define SUPPORT_LOCK_ROUTE_RESPONSE 1 /* ZW_LockRoute */ +#define SUPPORT_MEMORY_GET_BUFFER 1 /* MemoryGetBuffer */ +#define SUPPORT_MEMORY_GET_BYTE 1 /* MemoryGetByte */ +#define SUPPORT_MEMORY_GET_ID 1 /* MemoryGetID */ +#define SUPPORT_MEMORY_PUT_BUFFER 1 /* MemoryPutBuffer */ +#define SUPPORT_MEMORY_PUT_BYTE 1 /* MemoryPutByte */ +#define SUPPORT_NVM_GET_ID 1 /* NVM_get_id */ +#define SUPPORT_NVM_EXT_READ_LONG_BUFFER 1 /* NVM_ext_read_long_buffer */ +#define SUPPORT_NVM_EXT_READ_LONG_BYTE 1 /* NVM_ext_read_long_byte */ +#define SUPPORT_NVM_EXT_WRITE_LONG_BYTE 0 /* NVM_ext_write_long_byte */ +#define SUPPORT_NVM_EXT_WRITE_LONG_BUFFER 0 /* NVM_ext_write_long_buffer*/ +#define SUPPORT_NVM_BACKUP_RESTORE 0 /* MemoryGetBuffer */ +#define SUPPORT_PWR_CLK_PD 0 /* PWR_Clk_PD */ +#define SUPPORT_PWR_CLK_PUP 0 /* PWR_Clk_PUp */ +#define SUPPORT_PWR_SELECT_CLK 0 /* PWR_Select_Clk */ +#define SUPPORT_PWR_SETSTOPMODE 0 /* PWR_SetStopMode */ +#define SUPPORT_STORE_HOMEID 0 /* ZW_StoreHomeID */ +#define SUPPORT_STORE_NODEINFO 0 /* notUsed */ +#define SUPPORT_ZW_ADD_NODE_TO_NETWORK 0 /* ZW_AddNodeToNetwork */ +#define SUPPORT_ZW_AES_ECB 0 /* ZW_AES_ECB */ +#define SUPPORT_ZW_ARE_NODES_NEIGHBOURS 0 /* notUsed */ +#define SUPPORT_ZW_ASSIGN_RETURN_ROUTE 0 /* ZW_AssignReturnRoute */ +#define SUPPORT_ZW_ASSIGN_PRIORITY_RETURN_ROUTE 0 /* ZW_AssignPriorityReturnRoute */ +#define SUPPORT_ZW_ASSIGN_SUC_RETURN_ROUTE 0 /* ZW_AssignSUCReturnRoute */ +#define SUPPORT_ZW_ASSIGN_PRIORITY_SUC_RETURN_ROUTE 0 /* ZW_AssignPrioritySUCReturnRoute */ +#define SUPPORT_ZW_CONTROLLER_CHANGE 0 /* ZW_ControllerChange */ +#define SUPPORT_ZW_CREATE_NEW_PRIMARY 0 /* NotUsed */ +#define SUPPORT_ZW_DELETE_RETURN_ROUTE 0 /* ZW_DeleteReturnRoute */ +#define SUPPORT_ZW_DELETE_SUC_RETURN_ROUTE 0 /* ZW_DeleteSUCReturnRoute */ +#define SUPPORT_ZW_ENABLE_SUC 0 /* ZW_EnableSUC */ +#define SUPPORT_ZW_EXPLORE_REQUEST_INCLUSION 1 /* ZW_ExploreRequestInclusion */ +#define SUPPORT_ZW_EXPLORE_REQUEST_EXCLUSION 1 /* ZW_ExploreRequestExclusion */ +#define SUPPORT_ZW_GET_CONTROLLER_CAPABILITIES 0 /* ZW_GetControllerCapabilities */ +#define SUPPORT_ZW_GET_PRIORITY_ROUTE 0 /* ZW_GetPriorityRoute */ +#define SUPPORT_ZW_SET_PRIORITY_ROUTE 0 /* ZW_SetPriorityRoute */ +#define SUPPORT_ZW_GET_NEIGHBOR_COUNT 0 /*notUsed */ +#define SUPPORT_ZW_GET_NODE_PROTOCOL_INFO 1 /* ZW_GetNodeProtocolInfo */ +#define SUPPORT_ZW_GET_PROTOCOL_STATUS 1 /* ZW_GetProtocolStatus */ +#define SUPPORT_ZW_GET_PROTOCOL_VERSION 1 /* ZW_GetProtocolVersion */ +#define SUPPORT_ZW_GET_RANDOM 1 /* ZW_GetRandomWord */ +#define SUPPORT_ZW_GET_ROUTING_MAX 0 /* ZW_GetRoutingMAX */ +#define SUPPORT_ZW_GET_SUC_NODE_ID 1 /* ZW_GetSUCNodeID */ +#define SUPPORT_ZW_GET_VERSION 1 /* ZW_Version */ +#define SUPPORT_ZW_IS_FAILED_NODE_ID 0 /* ZW_isFailedNode */ +#define SUPPORT_ZW_IS_NODE_WITHIN_DIRECT_RANGE 0 /* NotUsed */ +#define SUPPORT_ZW_IS_PRIMARY_CTRL 0 /* NotUsed */ +#define SUPPORT_ZW_IS_WUT_KICKED 0 /* ZW_IsWutKicked */ +#define SUPPORT_ZW_NEW_CONTROLLER 0 /* ZW_NewController */ +#define SUPPORT_ZW_RANDOM 0 /* NotUsed */ +#define SUPPORT_ZW_REDISCOVERY_NEEDED 0 /* ZW_RediscoveryNeeded */ +#define SUPPORT_ZW_REMOVE_FAILED_NODE_ID 0 /* ZW_RemoveFailedNode */ +#define SUPPORT_ZW_REMOVE_NODE_FROM_NETWORK 0 /* ZW_RemoveNodeFromNetwork */ +#define SUPPORT_ZW_REMOVE_NODE_ID_FROM_NETWORK 0 /* ZW_RemoveNodeIDFromNetwork */ +#define SUPPORT_ZW_REPLACE_FAILED_NODE 0 /* ZW_ReplaceFailedNode */ +#define SUPPORT_ZW_REPLICATION_COMMAND_COMPLETE 0 /* ZW_ReplicationReceiveComplete */ +#define SUPPORT_ZW_REPLICATION_SEND_DATA 0 /* ZW_ReplicationSend */ +#define SUPPORT_ZW_REQUEST_NETWORK_UPDATE 1 /* ZW_RequestNetWorkUpdate */ +#define SUPPORT_ZW_REQUEST_NEW_ROUTE_DESTINATIONS 0 /* NotUsed */ +#define SUPPORT_ZW_REQUEST_NODE_INFO 0 /* ZW_RequestNodeInfo */ +#define SUPPORT_ZW_REQUEST_NODE_NEIGHBOR_UPDATE 0 /* ZW_RequestNodeNeighborUpdate */ +#define SUPPORT_ZW_RF_POWER_LEVEL_GET 0 /* ZW_RFPowerLevelGet */ +#define SUPPORT_ZW_RF_POWER_LEVEL_REDISCOVERY_SET 0 /* NotUsed */ +#define SUPPORT_ZW_RF_POWER_LEVEL_SET 0 /* ZW_RFPowerLevelSet */ +#define SUPPORT_ZW_SEND_DATA 1 /* ZW_SendData */ +#define SUPPORT_ZW_SEND_DATA_EX 1 /* ZW_SendDataEx */ +#define SUPPORT_ZW_SEND_DATA_ABORT 1 /* ZW_SendDataAbort */ +#define SUPPORT_ZW_SEND_DATA_META 0 /* ZW_SendDataMeta */ +#define SUPPORT_ZW_SEND_DATA_META_BRIDGE 0 /* ZW_SendDataMeta_Bridge */ +#define SUPPORT_ZW_SEND_DATA_META_MR 0 /* NotUsed */ +#define SUPPORT_ZW_SEND_DATA_MR 0 /* NotUsed */ +#define SUPPORT_ZW_SEND_DATA_MULTI 1 /* ZW_SendDataMulti */ +#define SUPPORT_ZW_SEND_DATA_MULTI_EX 1 /* ZW_SendDataMultiEx */ +#define SUPPORT_ZW_SET_NETWORK_KEY_S0 0 /* ZW_SetNetworkKeyS0 */ +#define SUPPORT_ZW_GET_SECURITY_KEYS 1 /* ZW_GetSecurityKeys */ +#define SUPPORT_ZW_SEND_NODE_INFORMATION 1 /* ZW_SendNodeInformation */ +#define SUPPORT_ZW_SEND_SLAVE_DATA 0 /* ZW_SendSlaveData */ +#define SUPPORT_ZW_SEND_SUC_ID 0 /* ZW_SendSUCID */ +#define SUPPORT_ZW_SEND_TEST_FRAME 0 /* ZW_SendTestFrame */ +#define SUPPORT_ZW_SET_DEFAULT 1 /* ZW_SetDefault */ +#define SUPPORT_ZW_SET_EXT_INT_LEVEL 0 /* ZW_SetExtIntLevel */ +#define SUPPORT_ZW_SET_LEARN_MODE 1 /* ZW_SetLearnMode */ +#define SUPPORT_ZW_SET_LEARN_NODE_STATE 0 /* ZW_SetLearnNodeState */ +#define SUPPORT_ZW_SET_PROMISCUOUS_MODE 0 /* ZW_SetPromiscuousMode */ +#define SUPPORT_ZW_SET_RF_RECEIVE_MODE 1 /* ZW_SetRFReceiveMode */ +#define SUPPORT_ZW_SET_ROUTING_INFO 0 /* NotUsed */ +#define SUPPORT_ZW_SET_ROUTING_MAX 0 /*notUsed*/ +#define SUPPORT_ZW_SET_SLEEP_MODE 0 /* ZW_SetSleepMode */ +#define SUPPORT_ZW_SET_SUC_NODE_ID 1 /* ZW_SetSUCNodeID */ +#define SUPPORT_ZW_SET_WUT_TIMEOUT 0 /* ZW_SetWutTimeout */ +#define SUPPORT_ZW_SUPPORT9600_ONLY 0 /* ZW_Support9600Only */ +#define SUPPORT_ZW_TYPE_LIBRARY 1 /* ZW_Type_Library */ +#define SUPPORT_ZW_WATCHDOG_DISABLE 0 /* ZW_WatchDogDisable */ +#define SUPPORT_ZW_WATCHDOG_ENABLE 0 /* ZW_WatchDogEnable */ +#define SUPPORT_ZW_WATCHDOG_KICK 0 /* ZW_WatchDogKick */ +#define SUPPORT_ZW_WATCHDOG_START 1 /* ZW_WatchDogEnable */ +#define SUPPORT_ZW_WATCHDOG_STOP 1 /* ZW_WatchDogDisable */ +#define SUPPORT_ZW_NVR_GET_VALUE 0 /* ZW_NVRGetValue */ +#define SUPPORT_FUNC_ID_CLEAR_TX_TIMERS 1 /* ZW_ClearTxTimers */ +#define SUPPORT_FUNC_ID_GET_TX_TIMERS 1 /* ZW_GetTxTimer */ +#define SUPPORT_ZW_CLEAR_NETWORK_STATS 1 /* ZW_ClearNetworkStats */ +#define SUPPORT_ZW_GET_NETWORK_STATS 1 /* ZW_GetNetworkStats */ +#define SUPPORT_ZW_GET_BACKGROUND_RSSI 1 /* ZW_GetBackgroundRSSI */ +/* SerialAPI functionality support definitions */ +#define SUPPORT_SEND_DATA_TIMING 1 +/* Enable support for SerialAPI Startup Notification */ +#define SUPPORT_SERIAL_API_STARTUP_NOTIFICATION 1 + +/* Common SerialAPI functionality support definitions */ +#define SUPPORT_SERIAL_API_GET_INIT_DATA 1 +#define SUPPORT_SERIAL_API_APPL_NODE_INFORMATION 1 + +#define SUPPORT_APPLICATION_COMMAND_HANDLER_BRIDGE 0 +#define SUPPORT_APPLICATION_COMMAND_HANDLER 1 + + +#define SUPPORT_SERIAL_API_SET_TIMEOUTS 1 + +#define SUPPORT_SERIAL_API_SOFT_RESET 1 +#define SUPPORT_SERIAL_API_SETUP 1 +#define SUPPORT_ZW_INITIATE_SHUTDOWN 0 +#define SUPPORT_SERIAL_API_GET_LR_NODES 0 +#define SUPPORT_SERIAL_GET_LR_CHANNEL 0 +#define SUPPORT_SERIAL_SET_LR_CHANNEL 0 +#define SUPPORT_SERIAL_SET_LR_VIRTUAL_IDS 0 +#define SUPPORT_SERIAL_ENABLE_RADIO_PTI 0 + +/* ZW_EnableSUC() no longer exists in the library */ + +/* */ +#define SUPPORT_SERIAL_API_GET_APPL_HOST_MEMORY_OFFSET 0 + +#define SUPPORT_ZW_SET_LISTEN_BEFORE_TALK_THRESHOLD 1 + +#define SUPPORT_ZW_NETWORK_MANAGEMENT_SET_MAX_INCLUSION_REQUEST_INTERVALS 1 + +/**************************************************************************/ +/* Common for all slaves */ +/* SerialAPI functionality support definitions */ +#define SUPPORT_ZW_APPLICATION_UPDATE 1 +#define SUPPORT_APPLICATION_RF_NOTIFY 0 + +#define SUPPORT_ZW_GET_VIRTUAL_NODES 0 /* ZW_GetVirtualNodes */ +#define SUPPORT_ZW_IS_VIRTUAL_NODE 0 /* ZW_IsVirtualNode */ +#define SUPPORT_ZW_SEND_DATA_BRIDGE 0 /* ZW_SendData_Bridge */ +#define SUPPORT_ZW_SEND_DATA_MULTI_BRIDGE 0 /* ZW_SendDataMulti_Bridge */ +#define SUPPORT_ZW_SET_SLAVE_LEARN_MODE 0 /* ZW_SetSlaveLearnMode */ +#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 +/**************************************************************************/ +/* Slave enhanced */ +/* Specific SerialAPI functionality support definitions */ + +#define SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE 0 + +#define SUPPORT_GET_TX_COUNTER 0 +#define SUPPORT_RESET_TX_COUNTER 0 + +#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 +#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 +#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 0 + + +#define SUPPORT_SERIAL_API_TEST 0 +#define SUPPORT_ZW_APPLICATION_CONTROLLER_UPDATE 0 + +#define SUPPORT_GET_TX_COUNTER 0 +#define SUPPORT_RESET_TX_COUNTER 0 + +#define SUPPORT_SERIAL_API_APPL_SLAVE_NODE_INFORMATION 0 +#define SUPPORT_APPLICATION_SLAVE_COMMAND_HANDLER 0 +#define SUPPORT_ZW_SEND_SLAVE_NODE_INFORMATION 0 diff --git a/src/zwave_ncp_serial_api_controller/utils.c b/src/zwave_ncp_serial_api_controller/utils.c new file mode 100644 index 00000000..bec51e15 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/utils.c @@ -0,0 +1,286 @@ +/** + * @file utils.c + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include +#include +#include +#include + +static TaskHandle_t task_handle; + +uint8_t GetCommandResponse(SZwaveCommandStatusPackage *pCmdStatus, EZwaveCommandStatusType cmdType) +{ + const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); + TaskHandle_t m_pAppTaskHandle = GetTaskHandle(); + QueueHandle_t Queue = m_pAppHandles->ZwCommandStatusQueue; + for (uint8_t delayCount = 0; delayCount < 100; delayCount++) + { + for (UBaseType_t QueueElmCount = uxQueueMessagesWaiting(Queue); QueueElmCount > 0; QueueElmCount--) + { + if (xQueueReceive(Queue, (uint8_t*)pCmdStatus, 0)) + { + if (pCmdStatus->eStatusType == cmdType) + { + if (m_pAppTaskHandle && (0 < uxQueueMessagesWaiting(Queue))) + { + /* More elements in queue call xTaskNotify */ + BaseType_t Status = xTaskNotify(m_pAppTaskHandle, 1 << EAPPLICATIONEVENT_ZWCOMMANDSTATUS, eSetBits); + ASSERT(Status == pdPASS); // We probably received a bad Task handle + } + return true; + } + else + { + /* Re-insert none-matching message into Queue */ + BaseType_t result = xQueueSendToBack(Queue, (uint8_t*)pCmdStatus, 0); + ASSERT(pdTRUE == result); + } + } + } + vTaskDelay(10); + } + if (m_pAppTaskHandle && (0 < uxQueueMessagesWaiting(Queue))) + { + /* Only call xTaskNotify if still elements in queue */ + BaseType_t Status = xTaskNotify(m_pAppTaskHandle, 1 << EAPPLICATIONEVENT_ZWCOMMANDSTATUS, eSetBits); + ASSERT(Status == pdPASS); // We probably received a bad Task handle + } + return false; +} + +uint8_t IsPrimaryController(void) +{ + const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_IS_PRIMARY_CTRL + }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_IS_PRIMARY_CTRL)) + { + return cmdStatus.Content.IsPrimaryCtrlStatus.result; + } + ASSERT(false); + return 0; +} + +uint8_t GetControllerCapabilities(void) +{ + const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_GET_CONTROLLER_CAPABILITIES + }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_GET_CONTROLLER_CAPABILITIES)) + { + return cmdStatus.Content.GetControllerCapabilitiesStatus.result; + } + ASSERT(false); + return 0; +} + +uint8_t QueueProtocolCommand(uint8_t *pCommand) +{ + const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); + // Put the Command on queue (and dont wait for it, queue must be empty) + return (QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, pCommand, 0)); +} + +/** +* Aquire node information from protocol +* +* Method requires CommandStatus queue from protocol to be empty. +* Method requires CommandQueue to protocol to be empty. +* Method will cause assert on failure. +* +* @param[in] NodeId ID of node to get information about. +* @param[out] pNodeInfo Pointer to t_extNodeInfo struct where aquired node info can be stored. +*/ +void GetNodeInfo(uint16_t NodeId, t_ExtNodeInfo* pNodeInfo) +{ + const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage GetNodeInfoCommand = { + .eCommandType = EZWAVECOMMANDTYPE_NODE_INFO, + .uCommandParams.NodeInfo.NodeId = NodeId + }; + + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&GetNodeInfoCommand, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + // Wait for protocol to handle command (it shouldnt take long) + SZwaveCommandStatusPackage NodeInfo = { 0 }; + if (GetCommandResponse(&NodeInfo, EZWAVECOMMANDSTATUS_NODE_INFO)) + { + if (NodeInfo.Content.NodeInfoStatus.NodeId == NodeId) + { + memcpy(pNodeInfo, (uint8_t*)&NodeInfo.Content.NodeInfoStatus.extNodeInfo, sizeof(NodeInfo.Content.NodeInfoStatus.extNodeInfo)); + return; + } + } + ASSERT(false); +} + +/** +* Aquire a list of included nodes IDS in the network from protocol +* +* Method requires CommandStatus queue from protocol to be empty. +* Method requires CommandQueue to protocol to be empty. +* Method will cause assert on failure. +* +* @param[out] node_id_list Pointer to bitmask list where aquired included nodes IDs saved +*/ +void Get_included_nodes(uint8_t* node_id_list) +{ + const SApplicationHandles *m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage GetIncludedNodesCommand = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_INCLUDED_NODES}; + + // Put the Command on queue (and dont wait for it, queue must be empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&GetIncludedNodesCommand, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + // Wait for protocol to handle command (it shouldnt take long) + SZwaveCommandStatusPackage includedNodes = { 0 }; + if (GetCommandResponse(&includedNodes, EZWAVECOMMANDSTATUS_ZW_GET_INCLUDED_NODES)) + { + memcpy(node_id_list, (uint8_t*)includedNodes.Content.GetIncludedNodes.node_id_list, sizeof(NODE_MASK_TYPE)); + return; + } + ASSERT(false); +} + + +/** +* Acquire a list of included long range nodes IDS in the network from protocol. +* +* Method requires CommandStatus queue from protocol to be empty. +* Method requires CommandQueue to protocol to be empty. +* Method will cause assert on failure. +* +* @param[out] node_id_list Pointer to bitmask list where aquired included nodes IDs saved +*/ +void Get_included_lr_nodes(uint8_t* node_id_list) +{ + const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage GetIncludedNodesCommand = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_INCLUDED_LR_NODES + }; + + // Put the Command on queue (and don't wait for it, queue is most likely empty) + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&GetIncludedNodesCommand, 0); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + // Wait for protocol to handle command (it shouldn't take long) + SZwaveCommandStatusPackage includedNodes = { 0 }; + if (GetCommandResponse(&includedNodes, EZWAVECOMMANDSTATUS_ZW_GET_INCLUDED_LR_NODES)) + { + memcpy(node_id_list, (uint8_t*)includedNodes.Content.GetIncludedNodesLR.node_id_list, sizeof(LR_NODE_MASK_TYPE)); + return; + } + ASSERT(false); +} + + +void TriggerNotification(EApplicationEvent event) +{ + TaskHandle_t m_pAppTaskHandle = GetTaskHandle(); + if (m_pAppTaskHandle) + { + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + + xTaskNotifyFromISR(m_pAppTaskHandle, + 1 << event, + eSetBits, + &xHigherPriorityTaskWoken + ); + /* If xHigherPriorityTaskWoken is now set to pdTRUE then a context switch + should be performed to ensure the interrupt returns directly to the highest + priority task. The macro used for this purpose is dependent on the port in + use and may be called portEND_SWITCHING_ISR(). */ + portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); + } + +} + +#define LR_AUTO_CHANNEL_CONFIG_MASK 0xF0 +#define LR_CURRENT_ACTIVE_CHANNEL_MASK 0x0F + +void GetLongRangeChannel(uint8_t * channel_n, uint8_t *auto_channel_config) +{ + const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_LR_CHANNEL + }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + *auto_channel_config = 0; + *channel_n = 0; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_ZW_GET_LR_CHANNEL)) + { + *channel_n = cmdStatus.Content.GetLRChannel.result & LR_CURRENT_ACTIVE_CHANNEL_MASK; + *auto_channel_config = cmdStatus.Content.GetLRChannel.result & LR_AUTO_CHANNEL_CONFIG_MASK; + return; + } + ASSERT(false); +} + +bool SetLongRangeChannel(uint8_t channel) +{ + const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_SET_LR_CHANNEL, + .uCommandParams.SetLRChannel.value = channel + }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus = { 0 }; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_ZW_SET_LR_CHANNEL)) + { + return cmdStatus.Content.SetLRChannel.result; + } + ASSERT(false); + return 0; + +} + +void SetLongRangeVirtualNodes(uint8_t bitmask) +{ + const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_SET_LR_VIRTUAL_IDS, + .uCommandParams.SetLRVirtualNodeIDs.value = bitmask + }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); +} + +uint8_t GetPTIConfig(void) +{ + const SApplicationHandles * m_pAppHandles = ZAF_getAppHandle(); + SZwaveCommandPackage cmdPackage = { + .eCommandType = EZWAVECOMMANDTYPE_ZW_GET_PTI_CONFIG + }; + EQueueNotifyingStatus QueueStatus = QueueNotifyingSendToBack(m_pAppHandles->pZwCommandQueue, (uint8_t *)&cmdPackage, 500); + ASSERT(EQUEUENOTIFYING_STATUS_SUCCESS == QueueStatus); + SZwaveCommandStatusPackage cmdStatus; + if (GetCommandResponse(&cmdStatus, EZWAVECOMMANDSTATUS_ZW_GET_PTI_CONFIG)) + { + return cmdStatus.Content.GetPTIconfig.result; + } + ASSERT(false); + return 0; +} + +void SetTaskHandle(TaskHandle_t new_task_handle) +{ + task_handle = new_task_handle; +} + +TaskHandle_t GetTaskHandle(void) +{ + return task_handle; +} diff --git a/src/zwave_ncp_serial_api_controller/utils.h b/src/zwave_ncp_serial_api_controller/utils.h new file mode 100644 index 00000000..bf34be70 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/utils.h @@ -0,0 +1,38 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef APPS_SERIALAPI_UTILS_H_ +#define APPS_SERIALAPI_UTILS_H_ + +#include +#include +#include + +uint8_t QueueProtocolCommand(uint8_t *pCommand); + +uint8_t GetCommandResponse(SZwaveCommandStatusPackage *pCmdStatus, EZwaveCommandStatusType cmdType); + +uint8_t IsPrimaryController(void); + +uint8_t GetControllerCapabilities(void); + +void GetNodeInfo(uint16_t NodeId, t_ExtNodeInfo* pNodeInfo); + +void Get_included_nodes(uint8_t* node_id_list); +void Get_included_lr_nodes(uint8_t* node_id_list); + +void TriggerNotification(EApplicationEvent event); + +void GetLongRangeChannel(uint8_t * channel_n, uint8_t *auto_channel_config); +bool SetLongRangeChannel(uint8_t channel); + +void SetLongRangeVirtualNodes(uint8_t bitmask); + +uint8_t GetPTIConfig(void); + +void SetTaskHandle(TaskHandle_t new_task_handle); +TaskHandle_t GetTaskHandle(void); + +#endif /* APPS_SERIALAPI_UTILS_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.c b/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.c new file mode 100644 index 00000000..3853b093 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.c @@ -0,0 +1,25 @@ +/** + * @file virtual_slave_node_info.c + * @copyright 2022 Silicon Laboratories Inc. + */ + +#include "virtual_slave_node_info.h" + +#ifdef ZW_CONTROLLER_BRIDGE + +uint8_t aVirtualSlaveCommandClasses[MAX_VIRTUAL_SLAVE_NODES][APPL_SLAVENODEPARM_MAX]; + +SVirtualSlaveNodeInfo_t aVirtualSlaveNodeInfo[MAX_VIRTUAL_SLAVE_NODES] = {{.bListening = true, + .NodeType.generic = GENERIC_TYPE_SWITCH_MULTILEVEL, + .NodeType.specific = SPECIFIC_TYPE_NOT_USED, + .CommandClasses.iListLength = 0, + .CommandClasses.pCommandClasses = &aVirtualSlaveCommandClasses[0][0]}}; +SVirtualSlaveNodeInfo_t *apVirtualSlaveNodeInfo[sizeof_array(aVirtualSlaveNodeInfo)] = {&aVirtualSlaveNodeInfo[0]}; + +const SVirtualSlaveNodeInfoTable_t VirtualSlaveNodeInfoTable = +{ + .iTableLength = sizeof_array(apVirtualSlaveNodeInfo), + .ppNodeInfo = (const SVirtualSlaveNodeInfo_t **)apVirtualSlaveNodeInfo +}; + +#endif // ifdef ZW_CONTROLLER_BRIDGE diff --git a/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.h b/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.h new file mode 100644 index 00000000..32fa8611 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/virtual_slave_node_info.h @@ -0,0 +1,26 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ + +#ifndef VIRTUAL_SLAVE_NODE_INFO_H_ +#define VIRTUAL_SLAVE_NODE_INFO_H_ + +#include +#include +#include "app.h" + +#ifdef ZW_CONTROLLER_BRIDGE +// Virtual slave node info storage +// array size is number of simultaneous virtual slaves supported + +#define MAX_VIRTUAL_SLAVE_NODES (1) + +extern uint8_t aVirtualSlaveCommandClasses[MAX_VIRTUAL_SLAVE_NODES][APPL_SLAVENODEPARM_MAX]; +extern SVirtualSlaveNodeInfo_t aVirtualSlaveNodeInfo[MAX_VIRTUAL_SLAVE_NODES]; +extern SVirtualSlaveNodeInfo_t *apVirtualSlaveNodeInfo[sizeof_array(aVirtualSlaveNodeInfo)]; +extern const SVirtualSlaveNodeInfoTable_t VirtualSlaveNodeInfoTable; + +#endif // ifdef ZW_CONTROLLER_BRIDGE + +#endif /* VIRTUAL_SLAVE_NODE_INFO_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/zaf_config_security.h b/src/zwave_ncp_serial_api_controller/zaf_config_security.h new file mode 100644 index 00000000..ebe22e80 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/zaf_config_security.h @@ -0,0 +1,37 @@ +/** + * @file + * @copyright 2022 Silicon Laboratories Inc. + */ +#ifndef ZAF_CONFIG_SECURITY_H_ +#define ZAF_CONFIG_SECURITY_H_ + +#include "zaf_config.h" +#include "ZW_security_api.h" + +#if ZAF_CONFIG_REQUEST_KEY_S0==1 +#define S0_BIT SECURITY_KEY_S0_BIT +#else +#define S0_BIT 0 +#endif + +#if ZAF_CONFIG_REQUEST_KEY_S2_UNAUTHENTICATED==1 +#define S2_UNAUTHENTICATED_BIT SECURITY_KEY_S2_UNAUTHENTICATED_BIT +#else +#define S2_UNAUTHENTICATED_BIT 0 +#endif + +#if ZAF_CONFIG_REQUEST_KEY_S2_AUTHENTICATED==1 +#define S2_AUTHENTICATED_BIT SECURITY_KEY_S2_AUTHENTICATED_BIT +#else +#define S2_AUTHENTICATED_BIT 0 +#endif + +#if ZAF_CONFIG_REQUEST_KEY_S2_ACCESS==1 +#define S2_ACCESS_BIT SECURITY_KEY_S2_ACCESS_BIT +#else +#define S2_ACCESS_BIT 0 +#endif + +#define ZAF_CONFIG_REQUESTED_SECURITY_KEYS (S0_BIT | S2_UNAUTHENTICATED_BIT | S2_AUTHENTICATED_BIT | S2_ACCESS_BIT) + +#endif /* ZAF_CONFIG_SECURITY_H_ */ diff --git a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.pintool b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.pintool new file mode 100644 index 00000000..6b657b04 --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.pintool @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slcp b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slcp new file mode 100644 index 00000000..0cce363f --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slcp @@ -0,0 +1,147 @@ +# Silicon Labs Project Configuration Tools: slcp, v0, Component selection file. +project_name: zwave_ncp_serial_api_controller +label: zwave_ncp_serial_api_controller +description: | + The Serial Applications Programming Interface (Serial API) allows a host to communicate with a Z-Wave chip. The host may be a PC or a less powerful embedded host CPU, such as in a remote control or in a gateway device, and so on. +category: Z-Wave|Apps +filter: +- name: Device Type + value: [NCP] +- name: Project Difficulty + value: [Beginner] +- name: Wireless Technology + value: [Z-Wave] +package: Z-Wave +quality: production +readme: +- {path: README.md} +source: +- {path: app_node_info.c} +- {path: cmd_handlers_invoker.c} +- {path: cmd_handlers.c} +- {path: cmd_get_capabilities.c} +- {path: cmds_dcdc.c} +- {path: cmds_power_management.c} +- {path: cmds_management.c} +- {path: cmds_rf.c} +- {path: cmds_security.c} +- {path: comm_interface.c} +- {path: nvm_backup_restore.c} +- {path: serialapi_file.c} +- {path: app.c} +- {path: utils.c} +- {path: virtual_slave_node_info.c} +- {path: main.c} +tag: [prebuilt_demo] +include: +- path: '' + file_list: + - {path: app_node_info.h} + - {path: cmd_handlers.h} + - {path: cmds_management.h} + - {path: cmds_rf.h} + - {path: cmds_security.h} + - {path: comm_interface.h} + - {path: controller_supported_func.h} + - {path: nvm_backup_restore.h} + - {path: serialapi_file.h} + - {path: app.h} + - {path: slave_supported_func.h} + - {path: utils.h} + - {path: virtual_slave_node_info.h} + - {path: zaf_config_security.h} +sdk: {id: gecko_sdk, version: 4.4.0} +toolchain_settings: [] +component: +- {id: zw_api_serialapi} +- {id: zaf_ncp} +- {id: mpu} +- {id: brd4207a} +- {id: zw_app_timer_deep_sleep} +- {id: zw_dcdc_override} +- {id: zw_role_type_central_static_controller} +- {id: zw_core} +- {id: device_init} +- {id: zw_api_zw} +- {id: zw_apputilities_minimal} +- {id: gpiointerrupt} +- {id: zw_api_controller} +- {id: zw_appshw_serialapi} +- {id: ZW_MIGRATION_FROM_7_20} +- {id: sl_system} +- {id: ZGM130S037HGN} +- {id: emlib_msc} +- {id: emlib_letimer} +- {id: emlib_timer} +other_file: +- {path: postbuild.sh} +define: +- {name: APP_PROPERTIES_CONFIG_FILE, value: } +- condition: [device_sdid_95] + name: MAX_CALLBACK_QUEUE + value: '4' +- condition: [device_sdid_95] + name: MAX_UNSOLICITED_QUEUE + value: '4' +config_file: +- {path: config/zaf_config.h} +- {path: config/zaf_config.h} +configuration: +- {name: ZAF_CONFIG_GENERIC_TYPE, value: '0'} +- {name: ZAF_CONFIG_SPECIFIC_TYPE, value: '0'} +- {name: ZAF_CONFIG_PRODUCT_ID, value: '4'} +- {name: NVM3_DEFAULT_MAX_OBJECT_SIZE, value: '1900'} +- {name: NVM3_DEFAULT_CACHE_SIZE, value: '100'} +- {name: SL_BOARD_ENABLE_VCOM, value: '1'} +- {name: SL_DEVICE_INIT_EMU_EM4_STATE, value: emuEM4Hibernate} +- {name: SL_DEVICE_INIT_EMU_EM4_RETAIN_LFRCO, value: '1'} +- {name: SL_DEVICE_INIT_EMU_EM4_PIN_RETENTION_MODE, value: emuPinRetentionLatch} +- {name: SL_IOSTREAM_USART_VCOM_CONVERT_BY_DEFAULT_LF_TO_CRLF, value: '1'} +- {name: SL_IOSTREAM_USART_VCOM_RESTRICT_ENERGY_MODE_TO_ALLOW_RECEPTION, value: '0'} +- {name: SL_IOSTREAM_EUSART_VCOM_CONVERT_BY_DEFAULT_LF_TO_CRLF, value: '1'} +- {name: SL_IOSTREAM_EUSART_VCOM_RESTRICT_ENERGY_MODE_TO_ALLOW_RECEPTION, value: '0'} +- {name: configUSE_IDLE_HOOK, value: '1'} +- {name: configTIMER_TASK_PRIORITY, value: '55'} +- condition: [device_series_1] + name: configMAX_SYSCALL_INTERRUPT_PRIORITY + value: '32' +- condition: [device_series_1] + name: configKERNEL_INTERRUPT_PRIORITY + value: '224' +- condition: [device_series_2] + name: configMAX_SYSCALL_INTERRUPT_PRIORITY + value: '16' +- condition: [device_series_2] + name: configKERNEL_INTERRUPT_PRIORITY + value: '112' +- {name: configTIMER_QUEUE_LENGTH, value: '8'} +- {name: SL_DEVICE_INIT_DCDC_BYPASS, value: '1'} +- condition: [device_series_2, device_security_vault] + name: SL_PSA_ITS_USER_MAX_FILES + value: '32' +- condition: [device_series_2, device_security_vault] + name: SL_PSA_KEY_USER_SLOT_COUNT + value: '14' +- condition: [device_series_2] + name: SL_SLEEPTIMER_PERIPHERAL + value: SL_SLEEPTIMER_PERIPHERAL_BURTC +- condition: [device_sdid_95] + name: configTIMER_QUEUE_LENGTH + value: '4' +- condition: [device_sdid_95] + name: configTOTAL_HEAP_SIZE + value: '0' +- condition: [device_sdid_95] + name: SL_STACK_SIZE + value: '1024' +- unless: [device_sdid_95] + name: SL_STACK_SIZE + value: '1280' +- {name: SL_HEAP_SIZE, value: '128'} +- {name: ZAF_CONFIG_INSTALLER_ICON_TYPE, value: '0'} +- {name: ZAF_APP_NAME, value: '"serial_api_controller"'} +- {name: SL_RAIL_UTIL_RAIL_POWER_MANAGER_INIT, value: '0'} +ui_hints: + highlight: + - {path: README.md, focus: true} + diff --git a/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slps b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slps new file mode 100644 index 00000000..0f9b201b --- /dev/null +++ b/src/zwave_ncp_serial_api_controller/zwave_ncp_serial_api_controller.slps @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/build_project.py b/tools/build_project.py new file mode 100755 index 00000000..d677cb27 --- /dev/null +++ b/tools/build_project.py @@ -0,0 +1,597 @@ +#!/usr/bin/env python3 +"""Tool to retarget and build a SLCP project based on a manifest.""" + +from __future__ import annotations + +import os +import re +import ast +import sys +import copy +import json +import shlex +import shutil +import hashlib +import logging +import pathlib +import argparse +import itertools +import contextlib +import subprocess +import multiprocessing + +from xml.etree import ElementTree +from ruamel.yaml import YAML + +# Matches all known chip and board names. Some varied examples: +# MGM210PB32JIA EFM32GG890F512 MGM12P22F1024GA EZR32WG330F128R69 EFR32FG14P231F256GM32 +CHIP_SPECIFIC_REGEX = re.compile( + r""" + ^ + (?: + # Chips + (?:[a-z]+\d+){2,5}[a-z]* + | + # Boards and board-specific config + brd\d+[a-z](?:_.+)? + ) + $ +""", + flags=re.IGNORECASE | re.VERBOSE, +) +LOGGER = logging.getLogger(__name__) + +yaml = YAML(typ="safe") + + +def ensure_folder(path: str | pathlib.Path) -> pathlib.Path: + """Ensure that the path exists and is a folder.""" + path = pathlib.Path(path) + + if not path.is_dir(): + raise argparse.ArgumentTypeError(f"Folder {path} does not exist") + + return path + + +def get_toolchain_default_paths() -> list[pathlib.Path]: + """Return the path to the toolchain.""" + if sys.platform == "darwin": + return list( + pathlib.Path( + "/Applications/Simplicity Studio.app/Contents/Eclipse/developer/toolchains/gnu_arm/" + ).glob("*") + ) + + return [] + + +def get_sdk_default_paths() -> list[pathlib.Path]: + """Return the path to the SDK.""" + if sys.platform == "darwin": + return list( + pathlib.Path("~/SimplicityStudio/SDKs").expanduser().glob("gecko_sdk*") + ) + + return [] + + +def parse_override(override: str) -> tuple[str, dict | list]: + """Parse a config override.""" + if "=" not in override: + raise argparse.ArgumentTypeError("Override must be of the form `key=json`") + + key, value = override.split("=", 1) + + try: + return key, json.loads(value) + except json.JSONDecodeError as exc: + raise argparse.ArgumentTypeError(f"Invalid JSON: {exc}") + + +def parse_prefixed_output(output: str) -> tuple[str, pathlib.Path]: + """Parse a prefixed output parameter.""" + if ":" not in output: + raise argparse.ArgumentTypeError( + "Override must be of the form (e.g.) `gbl=output.gbl`" + ) + + prefix, _, path = output.partition(":") + return prefix, pathlib.Path(path) + + +def get_git_commit_id(repo: pathlib.Path) -> str: + """Get a commit hash for the current git repository.""" + + def git(*args: str) -> str: + result = subprocess.run( + ["git", "-C", str(repo)] + list(args), + text=True, + capture_output=True, + check=True, + ) + return result.stdout.strip() + + # Get the current commit ID + commit_id = git("rev-parse", "HEAD")[:8] + + # Check if the repository is dirty + is_dirty = git("status", "--porcelain") + + # If dirty, append the SHA256 hash of the git diff to the commit ID + if is_dirty: + dirty_diff = git("diff") + sha256_hash = hashlib.sha256(dirty_diff.encode()).hexdigest()[:8] + commit_id += f"-dirty-{sha256_hash}" + + return commit_id + + +def main(): + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + parser.add_argument( + "--manifest", + type=pathlib.Path, + required=True, + help="Firmware build manifest", + ) + parser.add_argument( + "--output", + action="append", + dest="outputs", + type=parse_prefixed_output, + required=True, + help="Output file prefixed with its file type", + ) + parser.add_argument( + "--no-clean-build-dir", + action="store_false", + dest="clean_build_dir", + default=True, + help="Do not clean the build directory", + ) + parser.add_argument( + "--build-dir", + type=pathlib.Path, + required=True, + help="Temporary build directory", + ) + parser.add_argument( + "--build-system", + choices=["cmake", "makefile"], + default="cmake", + help="Build system", + ) + parser.add_argument( + "--sdk", + action="append", + dest="sdks", + type=ensure_folder, + default=get_sdk_default_paths(), + required=len(get_sdk_default_paths()) == 0, + help="Path to a Gecko SDK", + ) + parser.add_argument( + "--toolchain", + action="append", + dest="toolchains", + type=ensure_folder, + default=get_toolchain_default_paths(), + required=len(get_toolchain_default_paths()) == 0, + help="Path to a GCC toolchain", + ) + parser.add_argument( + "--postbuild", + default=pathlib.Path(__file__).parent / "create_gbl.py", + required=False, + help="Postbuild executable", + ) + parser.add_argument( + "--override", + action="append", + dest="overrides", + required=False, + type=parse_override, + default=[], + help="Override config key with JSON.", + ) + + args = parser.parse_args() + + # argparse defaults should be replaced, not extended + if args.sdks != get_sdk_default_paths(): + args.sdks = args.sdks[len(get_sdk_default_paths()) :] + + if args.toolchains != get_toolchain_default_paths(): + args.toolchains = args.toolchains[len(get_toolchain_default_paths()) :] + + # Template variables for C defines + value_template_env = { + "git_repo_hash": get_git_commit_id(repo=pathlib.Path(__file__).parent.parent), + } + + manifest = yaml.load(args.manifest.read_text()) + + for key, override in args.overrides: + manifest[key] = override + + # First, load the base project + projects_root = args.manifest.parent.parent + base_project_path = projects_root / manifest["base_project"] + assert base_project_path.is_relative_to(projects_root) + (base_project_slcp,) = base_project_path.glob("*.slcp") + base_project = yaml.load(base_project_slcp.read_text()) + base_project_name = base_project_path.stem + + output_project = copy.deepcopy(base_project) + + # Strip chip- and board-specific components to modify the base device type + output_project["component"] = [ + c for c in output_project["component"] if not CHIP_SPECIFIC_REGEX.match(c["id"]) + ] + output_project["component"].append({"id": manifest["device"]}) + + # Add new components + output_project["component"].extend(manifest.get("add_components", [])) + output_project["toolchain_settings"].extend(manifest.get("toolchain_settings", [])) + + # Remove components + for component in manifest.get("remove_components", []): + try: + output_project["component"].remove(component) + except ValueError: + LOGGER.warning( + "Component %s is not present in manifest, cannot remove", component + ) + + # Extend configuration and C defines + for input_config, output_config in [ + (manifest.get("configuration", {}), output_project.get("configuration", [])), + (manifest.get("slcp_defines", {}), output_project.get("define", [])), + ]: + for name, value in input_config.items(): + # Values are always strings + value = str(value) + + # First try to replace any existing config entries + for config in output_config: + if config["name"] == name: + config["value"] = value + break + else: + # Otherwise, append it + output_config.append({"name": name, "value": value}) + + # Copy the base project into the output directory + if args.clean_build_dir: + with contextlib.suppress(OSError): + shutil.rmtree(args.build_dir) + + args.build_dir.mkdir(exist_ok=True) + + shutil.copytree( + base_project_path, + args.build_dir, + dirs_exist_ok=True, + ignore=lambda dir, contents: [ + # XXX: pruning `autogen` is extremely important! + "autogen", + ".git", + ".settings", + ".projectlinkstore", + ".project", + ".pdm", + ".cproject", + ".uceditor", + ], + ) + + # Delete the original project file + (args.build_dir / base_project_slcp.name).unlink() + + # Delete config files that must be regenerated by the SDK. + # XXX: This is fragile: you cannot force `slc` to always overwrite these files! + for filename in itertools.chain( + # RAIL config + (args.build_dir / "config").glob("sl_rail_*.h"), + [ + # Z-Wave board and stack config + args.build_dir / "config/sl_memory_config.h", + args.build_dir / "config/sl_board_control_config.h", + args.build_dir / "config/FreeRTOSConfig.h", + ], + ): + try: + filename.unlink() + except FileNotFoundError: + pass + + # Write the new project SLCP file + with (args.build_dir / f"{base_project_name}.slcp").open("w") as f: + yaml.dump(output_project, f) + + # Create a GBL metadata file + with pathlib.Path(args.build_dir / "gbl_metadata.yaml").open("w") as f: + yaml.dump(manifest["gbl"], f) + + # Generate a build directory + args.build_dir = args.build_dir + cmake_build_root = args.build_dir / f"{base_project_name}_cmake" + shutil.rmtree(cmake_build_root, ignore_errors=True) + + # On macOS `slc` doesn't execute properly + slc = shutil.which("slc-cli") or shutil.which("slc") + + if not slc: + print("`slc` and/or `slc-cli` not found in PATH") + sys.exit(1) + + # Find the SDK version required by the project + for sdk in args.sdks: + try: + sdk_meta = yaml.load((sdk / "gecko_sdk.slcs").read_text()) + except FileNotFoundError: + print(f"SDK {sdk} is not valid, skipping") + continue + + assert base_project["sdk"]["id"] == "gecko_sdk" + + print(f"SDK {sdk} has version {sdk_meta['sdk_version']}") + + if base_project["sdk"]["version"] == sdk_meta["sdk_version"]: + print(f"Version is correct, picking {sdk}") + break + else: + print(f"Project SDK version {base_project['sdk']['version']} not found") + sys.exit(1) + + # Find the toolchain required by the project + slps_path = (args.build_dir / base_project_name).with_suffix(".slps") + slps_xml = ElementTree.parse(slps_path) + slps_toolchain_id = ( + slps_xml.getroot() + .find(".//properties[@key='projectCommon.toolchainId']") + .attrib["value"] + .split(":")[-1] + ) + + # Find the correct toolchain + for toolchain in args.toolchains: + gcc_plugin_version_h = next( + toolchain.glob("lib/gcc/arm-none-eabi/*/plugin/include/plugin-version.h") + ) + version_info = {} + + for line in gcc_plugin_version_h.read_text().split("\n"): + # static char basever[] = "10.3.1"; + if line.startswith("static char") and line.endswith(";"): + name = line.split("[]", 1)[0].split()[-1] + value = ast.literal_eval(line.split(" = ", 1)[1][:-1]) + version_info[name] = value + + toolchain_id = version_info["basever"] + "." + version_info["datestamp"] + + print(f"Toolchain {toolchain} has version {toolchain_id}") + + if toolchain_id == slps_toolchain_id: + print(f"Version is correct, picking {toolchain}") + break + else: + print(f"Project toolchain version {slps_toolchain_id} not found") + sys.exit(1) + + # Make sure all extensions are valid + for sdk_extension in base_project.get("sdk_extension", []): + expected_dir = sdk / f"extension/{sdk_extension['id']}_extension" + + if not expected_dir.is_dir(): + print(f"Referenced extension not present in SDK: {expected_dir}") + sys.exit(1) + + subprocess.run( + [ + slc, + "generate", + "--project-file", + (args.build_dir / f"{base_project_name}.slcp").resolve(), + "--export-destination", + args.build_dir.resolve(), + "--sdk", + sdk, + "--toolchain", + "toolchain_gcc", + "--output-type", + args.build_system, + ], + check=True, + ) + + # Actually search for C defines within config + unused_defines = set(manifest.get("c_defines", {}).keys()) + + for config_root in [args.build_dir / "autogen", args.build_dir / "config"]: + for config_f in config_root.glob("*.h"): + config_h_lines = config_f.read_text().split("\n") + written_config = {} + new_config_h_lines = [] + + for index, line in enumerate(config_h_lines): + for define, value_template in manifest.get("c_defines", {}).items(): + if f"#define {define} " not in line: + continue + + define_with_whitespace = line.split(f"#define {define}", 1)[1] + alignment = define_with_whitespace[ + : define_with_whitespace.index(define_with_whitespace.strip()) + ] + + prev_line = config_h_lines[index - 1] + if "#ifndef" in prev_line: + assert ( + re.match(r"#ifndef\s+([A-Z0-9_]+)", prev_line).group(1) + == define + ) + + # Make sure that we do not have conflicting defines provided over the command line + assert not any( + c["name"] == define + for c in output_project.get("define", []) + ) + new_config_h_lines[index - 1] = "#if 1" + elif "#warning" in prev_line: + assert re.match(r'#warning ".*? not configured"', prev_line) + new_config_h_lines.pop(index - 1) + + value_template = str(value_template) + + if value_template.startswith("template:"): + value = value_template.replace("template:", "", 1).format( + **value_template_env + ) + else: + value = value_template + + new_config_h_lines.append(f"#define {define}{alignment}{value}") + written_config[define] = value + + if define not in unused_defines: + print(f"Define {define!r} used twice!") + sys.exit(1) + + unused_defines.remove(define) + break + else: + new_config_h_lines.append(line) + + if written_config: + print(f"Patching {config_f} with {written_config}") + config_f.write_text("\n".join(new_config_h_lines)) + + if unused_defines: + print(f"Defines were unused, aborting: {unused_defines}") + sys.exit(1) + + if args.build_system == "makefile": + output_artifact = ( + args.build_dir / "build/debug" / base_project_name + ).with_suffix(".gbl") + + # Inject a postbuild step into the makefile + with (args.build_dir / f"{base_project_name}.Makefile").open("a") as f: + f.write("\n") + f.write("post-build:\n") + f.write( + f"\t-{args.postbuild}" + f' postbuild "{(args.build_dir / base_project_name).resolve()}.slpb"' + f' --parameter build_dir:"{output_artifact.parent.resolve()}"' + f' --parameter sdk_dir:"{sdk}"' + "\n" + ) + f.write(f"\t-@echo ' '") + + subprocess.run( + [ + "make", + "-C", + args.build_dir, + "-f", + f"{base_project_name}.Makefile", + f"-j{multiprocessing.cpu_count()}", + f"ARM_GCC_DIR={toolchain}", + f"POST_BUILD_EXE={args.postbuild}", + ], + check=True, + ) + elif args.build_system == "cmake": + cmake_build_root = args.build_dir / f"{base_project_name}_cmake" + cmake_config = cmake_build_root / f"{base_project_name}.cmake" + fixed_cmake = [] + + # Strip all compile-time absolute paths + fixed_cmake.append("add_compile_options(") + + for src, dst in { + sdk: "/gecko_sdk", + args.build_dir: "/src", + toolchain: "/toolchain", + }.items(): + assert '"' not in str(src.absolute()) # TODO: fix this + fixed_cmake.append(f' "-ffile-prefix-map={str(src.absolute())}={dst}"') + + fixed_cmake.append(")") + + # Fix CMake config quoting bug + for line in cmake_config.read_text().split("\n"): + if ">:SHELL:" not in line and (":-imacros " in line or ":-x " in line): + line = ' "' + line.replace(">:", ">:SHELL:").strip() + '"' + + fixed_cmake.append(line) + + cmake_config.write_text("\n".join(fixed_cmake)) + + # Insert our postbuild step + cmakelists_txt = cmake_build_root / "CMakeLists.txt" + cmakelists = cmakelists_txt.read_text() + s37_line = next(l for l in cmakelists.split("\n") if "-O srec" in l) + s37_output_file = s37_line.split(" ")[-1] + s37_build_folder = s37_output_file.split("/", 1)[0] + '"' + + cmakelists_txt.write_text( + cmakelists.replace( + s37_line, + ( + f" COMMAND {args.postbuild} postbuild" + f' "{(args.build_dir / base_project_name).resolve()}.slpb"' + f" --parameter build_dir:{s37_build_folder}" + f' --parameter sdk_dir:"{sdk}"\n' + ) + + s37_line, + ) + ) + + # Generate the build system + subprocess.run( + [ + "cmake", + "-G", + "Ninja", + "-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake", + ".", + ], + cwd=cmake_build_root, + env={ + **os.environ, + "ARM_GCC_DIR": toolchain, + "POST_BUILD_EXE": args.postbuild, + }, + check=True, + ) + + # Build it! + subprocess.run( + [ + "ninja", + "-C", + cmake_build_root, + ], + check=True, + ) + + output_artifact = (cmake_build_root / base_project_name).with_suffix(".gbl") + + # Copy the output artifacts + for extension, path in args.outputs: + shutil.copy( + src=output_artifact.with_suffix(f".{extension}"), + dst=path, + ) + + if args.clean_build_dir: + with contextlib.suppress(OSError): + shutil.rmtree(args.build_dir) + + +if __name__ == "__main__": + main() diff --git a/tools/create_gbl.py b/tools/create_gbl.py new file mode 100755 index 00000000..ca603117 --- /dev/null +++ b/tools/create_gbl.py @@ -0,0 +1,290 @@ +#!/usr/bin/env python3 +"""Tool to create a GBL image in a Simplicity Studio build directory.""" + +from __future__ import annotations + +import os +import ast +import sys +import json +import pathlib +import argparse +import subprocess + +from ruamel.yaml import YAML +from xml.etree import ElementTree + + +def parse_c_header_defines(file_content: str) -> dict[str, str]: + """ + Parses a C header file's `#define`s. + """ + config = {} + + for line in file_content.split("\n"): + if not line.startswith("#define"): + continue + + _, *key_value = line.split(None, 2) + + if len(key_value) == 2: + key, value = key_value + else: + key, value = key_value + [None] + + try: + config[key] = ast.literal_eval(value) + except (ValueError, SyntaxError): + pass + + return config + + +def parse_properties_file(file_content: str) -> dict[str, str | list[str]]: + """ + Parses custom .properties file format into a dictionary. + Handles double backslashes as escape characters for spaces. + """ + properties = {} + + for line in file_content.split("\n"): + line = line.strip() + + if not line or line.startswith("#"): + continue + + key, value = line.split("=", 1) + key = key.strip() + + properties[key] = [] + current_value = "" + i = 0 + + while i < len(value): + if value[i : i + 2] == "\\\\": + current_value += " " + i += 2 + elif value[i] == " ": + properties[key].append(current_value) + current_value = "" + i += 1 + else: + current_value += value[i] + i += 1 + + if current_value: + properties[key].append(current_value) + + return properties + + +def find_file_in_parent_dirs(root: pathlib.Path, filename: str) -> pathlib.Path: + """ + Finds a file in the given directory or any of its parents. + """ + root = root.resolve() + + while True: + if (root / filename).exists(): + return root / filename + + if root.parent == root: + raise FileNotFoundError( + f"Could not find {filename} in any parent directory" + ) + + root = root.parent + + +def main(): + # Run as a Simplicity Studio post-build step + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + parser.add_argument("command", type=str, help="Command to execute: postbuild") + parser.add_argument("slpb_file", type=pathlib.Path, help="Path to the .slpb file") + parser.add_argument( + "--parameter", + action="append", + type=lambda kv: kv.split(":"), + dest="parameters", + help="Parameters in the format key:value", + ) + + args = parser.parse_args() + args.parameters = dict(args.parameters) + + project_name = args.slpb_file.stem + build_dir = pathlib.Path(args.parameters["build_dir"]) + out_file = build_dir / f"{project_name}.out" + + artifact_root = out_file.parent + project_name = out_file.stem + slcp_path = find_file_in_parent_dirs( + root=artifact_root, + filename=project_name + ".slcp", + ) + + project_root = slcp_path.parent + slps_path = (project_root / project_name).with_suffix(".slps") + + if "sdk_dir" in args.parameters: + gsdk_path = pathlib.Path(args.parameters["sdk_dir"]) + elif "cmake" in str(build_dir): + gsdk_path = pathlib.Path( + pathlib.Path(build_dir / f"{project_name}.cmake") + .read_text() + .split('set(SDK_PATH "', 1)[1] + .split('"', 1)[0] + ) + else: + raise RuntimeError("Cannot determine SDK directory") + + # Parse the main Simplicity Studio project config + slcp = YAML(typ="safe").load(slcp_path.read_text()) + + # Extract the chip ID from the SLPS file, `commander` needs it + slps_xml = ElementTree.parse(slps_path) + device_part_id = ( + slps_xml.getroot() + .find(".//properties[@key='projectCommon.partId']") + .attrib["value"] + .split(".")[-1] + .upper() + ) + print("Detected device part ID:", device_part_id, flush=True) + + gbl_metadata = YAML(typ="safe").load( + (project_root / "gbl_metadata.yaml").read_text() + ) + + # Only create GBL metadata JSON if there is something to create + if "fw_type" in gbl_metadata or "baudrate" in gbl_metadata: + # Prepare the GBL metadata + metadata = { + "metadata_version": 1, + "sdk_version": slcp["sdk"]["version"], + "fw_type": gbl_metadata["fw_type"], + "baudrate": gbl_metadata["baudrate"], + } + + # Compute the dynamic metadata + gbl_dynamic = gbl_metadata.get("dynamic", []) + + if "ezsp_version" in gbl_dynamic: + gbl_dynamic.remove("ezsp_version") + zigbee_esf_props = parse_properties_file( + (gsdk_path / "protocol/zigbee/esf.properties").read_text() + ) + metadata["ezsp_version"] = zigbee_esf_props["version"][0] + + if "cpc_version" in gbl_dynamic: + gbl_dynamic.remove("cpc_version") + sl_gsdk_version_h = parse_c_header_defines( + (gsdk_path / "platform/common/inc/sl_gsdk_version.h").read_text() + ) + metadata["cpc_version"] = ".".join( + [ + str(sl_gsdk_version_h["SL_GSDK_MAJOR_VERSION"]), + str(sl_gsdk_version_h["SL_GSDK_MINOR_VERSION"]), + str(sl_gsdk_version_h["SL_GSDK_PATCH_VERSION"]), + ] + ) + + try: + internal_app_config_h = parse_c_header_defines( + (project_root / "config/internal_app_config.h").read_text() + ) + except FileNotFoundError: + internal_app_config_h = {} + + if "CPC_SECONDARY_APP_VERSION_SUFFIX" in internal_app_config_h: + metadata["cpc_version"] += internal_app_config_h[ + "CPC_SECONDARY_APP_VERSION_SUFFIX" + ] + + if "zwave_version" in gbl_dynamic: + gbl_dynamic.remove("zwave_version") + zwave_esf_props = parse_properties_file( + (gsdk_path / "protocol/z-wave/esf.properties").read_text() + ) + metadata["zwave_version"] = zwave_esf_props["version"][0] + + if "ot_rcp_version" in gbl_dynamic: + gbl_dynamic.remove("ot_rcp_version") + openthread_config_h = parse_c_header_defines( + (project_root / "config/sl_openthread_generic_config.h").read_text() + ) + metadata["ot_rcp_version"] = openthread_config_h["PACKAGE_STRING"] + + if "gecko_bootloader_version" in gbl_dynamic: + gbl_dynamic.remove("gecko_bootloader_version") + btl_config_h = parse_c_header_defines( + (gsdk_path / "platform/bootloader/config/btl_config.h").read_text() + ) + + metadata["gecko_bootloader_version"] = ".".join( + [ + str(btl_config_h["BOOTLOADER_VERSION_MAIN_MAJOR"]), + str(btl_config_h["BOOTLOADER_VERSION_MAIN_MINOR"]), + str(btl_config_h["BOOTLOADER_VERSION_MAIN_CUSTOMER"]), + ] + ) + + if gbl_dynamic: + raise ValueError(f"Unknown dynamic metadata: {gbl_dynamic}") + + print("Generated GBL metadata:", metadata, flush=True) + + # Write it to a file for `commander` to read + (artifact_root / "gbl_metadata.json").write_text( + json.dumps(metadata, sort_keys=True) + ) + + # Make sure the Commander binary is included in the PATH on macOS + if sys.platform == "darwin": + os.environ["PATH"] += ( + os.pathsep + + "/Applications/Simplicity Studio.app/Contents/Eclipse/developer/adapter_packs/commander/Commander.app/Contents/MacOS" + ) + + commander_args = [ + "commander", + "gbl", + "create", + out_file.with_suffix(".gbl"), + ( + "--app" + if gbl_metadata.get("fw_type", None) != "gecko-bootloader" + else "--bootloader" + ), + out_file, + "--device", + device_part_id, + ] + ( + [ + "--metadata", + (artifact_root / "gbl_metadata.json"), + ] + if gbl_metadata + else [] + ) + + if gbl_metadata.get("compression", None) is not None: + commander_args += ["--compress", gbl_metadata["compression"]] + + if gbl_metadata.get("sign_key", None) is not None: + commander_args += ["--sign", gbl_metadata["sign_key"].format(SDK_DIR=gsdk_path)] + + if gbl_metadata.get("encrypt_key", None) is not None: + commander_args += [ + "--encrypt", + gbl_metadata["encrypt_key"].format(SDK_DIR=gsdk_path), + ] + + # Finally, generate the GBL + subprocess.run(commander_args, check=True) + + +if __name__ == "__main__": + main()