diff --git a/.github/workflows/compile-platform-examples.yml b/.github/workflows/compile-platform-examples.yml new file mode 100644 index 00000000..63e9f7c7 --- /dev/null +++ b/.github/workflows/compile-platform-examples.yml @@ -0,0 +1,184 @@ + +name: Compile Examples + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-platform-examples.ya?ml" + - "cores/**" + - "libraries/**" + - "variants/**" + - "boards.txt" + - "platform.txt" + pull_request: + paths: + - ".github/workflows/compile-platform-examples.ya?ml" + - "cores/**" + - "libraries/**" + - "variants/**" + - "boards.txt" + - "platform.txt" + workflow_dispatch: + repository_dispatch: + +jobs: + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + env: + SKETCHES_REPORTS_PATH: sketches-reports + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: Infineon:arm:XMC1100_Boot_Kit + i2s: true + dieTemp: true + heapMem: true + sleep1100: true + sleep4700 : false + stackMem: true + multiSerial: false + dma: false + alarmRtc: false + - fqbn: Infineon:arm:XMC1100_XMC2GO + i2s: true + dieTemp: true + heapMem: true + sleep1100: true + sleep4700 : false + stackMem: true + multiSerial: false + dma: false + alarmRtc: false + - fqbn: Infineon:arm:XMC1100_H_BRIDGE2GO + i2s: false + dieTemp: true + heapMem: true + sleep1100: true + sleep4700 : false + stackMem: true + multiSerial: false + dma: false + alarmRtc: false + - fqbn: Infineon:arm:XMC1300_Boot_Kit + i2s: false + dieTemp: true + heapMem: true + sleep1100: true + sleep4700 : false + stackMem: true + multiSerial: false + dma: false + alarmRtc: false + # - fqbn: Infineon:arm:XMC1300_Sense2GoL + # serial: true + - fqbn: Infineon:arm:XMC4400_Platform2GO + i2s: false + dieTemp: false + heapMem: false + sleep1100: false + sleep4700 : false + stackMem: true + multiSerial: false + dma: false + alarmRtc: true + - fqbn: Infineon:arm:XMC4700_Relax_Kit + i2s: true + dieTemp: true + heapMem: true + sleep1100: false + sleep4700 : true + stackMem: true + multiSerial: true + dma: true + alarmRtc: true + + # Make board type-specific customizations to the matrix jobs + include: + - board: + i2s: true + i2s-sketch-paths: | + - libraries/I2S + - board: + dieTemp: true + dieTemp-sketch-paths: | + - libraries/DeviceControlXMC/examples/DieTemperatureMeasurement + - board: + heapMem: true + heapMem-sketch-paths: | + - libraries/DeviceControlXMC/examples/HeapMemoryMeasurement + - board: + sleep1100: true + sleep1100-sketch-paths: | + - libraries/DeviceControlXMC/examples/SleepModeXMC1100 + - board: + sleep4700: true + sleep4700-sketch-paths: | + - libraries/DeviceControlXMC/examples/SleepModeXMC4700 + - board: + stackMem: true + stackMem-sketch-paths: | + - libraries/DeviceControlXMC/examples/StackMemoryMeasurement + - board: + multiSerial: true + multiSerial-sketch-paths: | + - libraries/Multi-Serial + - board: + dma: true + dma-sketch-paths: | + - libraries/DMA + - board: + alarmRtc: true + alarmRtc-sketch-paths: | + - libraries/RTC/examples/AlarmRTC + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Compile examples + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: | + # Use Boards Manager to install the latest release of the platform to get the toolchain. + - name: Infineon:arm + source-url: https://github.com/Infineon/XMC-for-Arduino/releases/latest/download/package_infineon_index.json + + - source-path: ./ + name: Infineon:arm + sketch-paths: | + # Compile these sketches for all boards + - libraries/IFX9201 + - libraries/LED + - libraries/OneWire + - libraries/RTC/examples/SimpleRTC + - libraries/SPI + - libraries/Sense2Go + - libraries/Ultrasonic + - libraries/Wire + # Board-specific sketches + ${{ matrix.i2s-sketch-paths }} + ${{ matrix.dieTemp-sketch-paths }} + ${{ matrix.heapMem-sketch-paths }} + ${{ matrix.sleep1100-sketch-paths }} + ${{ matrix.sleep4700-sketch-paths }} + ${{ matrix.stackMem-sketch-paths }} + ${{ matrix.multiSerial-sketch-paths }} + ${{ matrix.dma-sketch-paths }} + ${{ matrix.alarmRtc-sketch-paths }} + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v2 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 94ac05ce..00000000 --- a/.travis.yml +++ /dev/null @@ -1,86 +0,0 @@ -language: bash -os: linux -dist: bionic - -git: - depth: 1 - -script: - - echo "Build test coming soon..." -# jobs: -# include: - -# - stage: develop -# if: branch = develop -# addons: -# apt: -# packages: -# - libc6-i386 -# cache: -# directories: -# - /home/travis/.arduino15/ -# - $HOME/arduino-ci/ - -# before_install: -# - sudo mkdir -p /home/travis/arduino-ci/ -# - PATH=$PATH:$HOME/arduino-ci -# - export PATH -# - if ! [ "$(ls /home/travis/arduino-ci/arduino-cli)" ]; then sudo curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/home/travis/arduino-ci sudo sh; fi; -# - echo /home/travis/arduino-ci -# - sudo /home/travis/arduino-ci/arduino-cli core update-index --additional-urls https://github.com/Infineon/Assets/releases/download/current/package_infineon_index.json; -# - sudo /home/travis/arduino-ci/arduino-cli core install Infineon:arm --additional-urls https://github.com/Infineon/Assets/releases/download/current/package_infineon_index.json -# - PACKAGE_PATH=$(ls /home/travis/.arduino15/packages/Infineon/hardware/arm/) -# - sudo rm /home/travis/.arduino15/packages/Infineon/hardware/arm/* -rf -# - sudo mkdir /home/travis/.arduino15/packages/Infineon/hardware/arm/${PACKAGE_PATH} -# - sudo mv ./arm/* /home/travis/.arduino15/packages/Infineon/hardware/arm/${PACKAGE_PATH} -# script: -# - BOARDS=(XMC1100_Boot_Kit XMC1100_XMC2GO XMC1100_H_BRIDGE2GO XMC1300_Boot_Kit XMC1300_Sense2GoL XMC4700_Radar_Baseboard XMC4700_Relax_Kit) -# - sudo /home/travis/arduino-ci/arduino-cli sketch new ci-build -# - for BOARD in ${BOARDS[@]}; do sudo /home/travis/arduino-ci/arduino-cli compile --verbose --fqbn Infineon:arm:$BOARD ci-build; done - -# notifications: -# email: -# on_success: change -# on_failure: change - -# - stage: master -# if: branch = master -# addons: -# apt: -# packages: -# - libc6-i386 -# cache: -# directories: -# - /home/travis/.arduino15/ -# - $HOME/arduino-ci/ - -# before_install: -# - sudo mkdir -p /home/travis/arduino-ci/ -# - PATH=$PATH:$HOME/arduino-ci -# - export PATH -# - if ! [ "$(ls /home/travis/arduino-ci/arduino-cli)" ]; then sudo curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/home/travis/arduino-ci sudo sh; fi; -# - echo /home/travis/arduino-ci -# - sudo /home/travis/arduino-ci/arduino-cli core update-index --additional-urls https://github.com/Infineon/Assets/releases/download/current/package_infineon_index.json; -# - sudo /home/travis/arduino-ci/arduino-cli core install Infineon:arm --additional-urls https://github.com/Infineon/Assets/releases/download/current/package_infineon_index.json -# - PACKAGE_PATH=$(ls /home/travis/.arduino15/packages/Infineon/hardware/arm/) -# - echo ${PACKAGE_PATH} -# - sudo rm /home/travis/.arduino15/packages/Infineon/hardware/arm/* -rf -# - sudo mkdir /home/travis/.arduino15/packages/Infineon/hardware/arm/${PACKAGE_PATH} -# - sudo mv ./arm/* /home/travis/.arduino15/packages/Infineon/hardware/arm/${PACKAGE_PATH} -# - ls /home/travis/.arduino15/packages/Infineon/hardware/arm/${PACKAGE_PATH} -# script: -# - BOARDS=(XMC1100_Boot_Kit XMC1100_XMC2GO XMC1100_H_BRIDGE2GO XMC1300_Boot_Kit XMC1300_Sense2GoL XMC4700_Radar_Baseboard XMC4700_Relax_Kit) -# - sudo /home/travis/arduino-ci/arduino-cli sketch new ci-build -# - for BOARD in ${BOARDS[@]}; do sudo /home/travis/arduino-ci/arduino-cli compile --fqbn Infineon:arm:$BOARD ci-build; done - -# - EXCLUDED_LIBRARIES=(DMA DSP LED I2S USB RTC BGT24LTR11-Pulsed-Doppler-Radar Radar) -# - echo "Libraries which are excluded for the following build:" -# - echo ${EXCLUDED_LIBRARIES[@]} -# - OPTIONS=() -# - for EXLIB in ${EXCLUDED_LIBRARIES[@]}; do OPTIONS=("${OPTIONS[@]}" '-not' '-path' '/home/travis/.arduino15/packages/Infineon/hardware/arm/*/libraries/'${EXLIB}'/*'); done -# - for BOARD in ${BOARDS[@]}; do for d in $(find /home/travis/.arduino15/packages/Infineon/hardware/arm/*/libraries/* -name '*.ino' "${OPTIONS[@]}" -printf '%h\n' | sort -u); do sudo /home/travis/arduino-ci/arduino-cli compile --verbose --fqbn Infineon:arm:$BOARD $d; done; done - -# notifications: -# email: -# on_success: change -# on_failure: change diff --git a/Contributors.md b/Contributors.md new file mode 100644 index 00000000..74cfde06 --- /dev/null +++ b/Contributors.md @@ -0,0 +1,15 @@ +# XMC-for-Arduino +## Contributing to XMC-for-Arduino Project +First important point **All Contributions** are welcomed. + +Please contribute and raise issues via the [github repository](https://github.com/Infineon/XMC-for-Arduino/tree/develop) + +Check the **develop** branch for any Beta releases fixes for any issues you may find. + +General points on repository branches and flow + +1. _master_ branch is intended to be copy of release version +2. Please make Pull Requests to _develop_ branch for review, inclusion and availability for others +3. At next release _develop_ is merged into _master_ for release +4. Other branches are for other tests and not to be treated as anything but work in progress for now +5. Check [XMC-for-Arduino Wiki](https://github.com/Infineon/XMC-for-Arduino/wiki) for any additional information diff --git a/Libraries.md b/Libraries.md new file mode 100644 index 00000000..5390c8fc --- /dev/null +++ b/Libraries.md @@ -0,0 +1,36 @@ +# XMC-for-Arduino +## Creating and Maintaining Third Party Libraries +### Background +The Arduino IDE allows for external libraries to be added to support devices and functions +not in the core setup. For details on creating libraries see the +[Arduino Library Specifications](https://arduino.github.io/arduino-cli/library-specification/) +### XMC-for-Arduino Configuration +In order that a library, that is specific to one architecture or board type is only +compiled when a supporting board is setup, this specification has a setting for the +*architecture* the library will work on. The *library.properties* file *architecture* +setting is shortly going to be changed from a confusing *arm* name to a less confusing +name of *xmc*, to avoid any confusions for those using multiple boards and architectures +for third party libraries compatibility. +### XMC-for-Arduino Architecture Settings to use +Currently third party and other external libraries use the *library.properties* +*architecture* setting to define which board architecture the library is compiled for +The XMC-for-Arduino **current** setting for **up to V1.50** is - +~~~ +architecture=arm +~~~ + +When creating or maintaining third party or external libraries please use *library.properties* +*architecture* setting for versions **V1.5.0 and above** - +~~~ +architecture=xmc,arm +~~~ +The Arduino IDE on compilation will work out which one to use automatically, avoiding any strange updating issues. +At a later stage to be announced, it will be recommended to change to +~~~ +architecture=xmc +~~~ +As all newer versions will be using architecture *xmc*. + +If your library ALSO supports other boards and architectures, obviously leave those in as well. + +Check [XMC-for-Arduino Wiki](https://github.com/Infineon/XMC-for-Arduino/wiki) for any additional information \ No newline at end of file diff --git a/README.md b/README.md index ea58a610..9c7e7d7d 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ In the boards list **Tools** > **Board**, the XMC microcontroller boards are add * The XMC1100 Boot Kit has limitations if compared to the official Arduino boards (consult the [XMC-for-Arduino Wiki](https://github.com/Infineon/XMC-for-Arduino/wiki) for more information) * Refer also to the LICENSE.md/txt file for further information * Arduino 1.8.0 IDE might have problems with the XMC-for-Arduino releases +* XMC-for-Arduino support for 'arm-linux-gnueabihf' only until version 1.1. ### Using PlatformIO IDE @@ -97,6 +98,13 @@ In the boards list **Tools** > **Board**, the XMC microcontroller boards are add Cloud9, Codeanywhere, Eclipse Che (Codenvy), Atom, CLion, Eclipse, Emacs, NetBeans, Qt Creator, Sublime Text, VIM, Visual Studio, and VSCode - [Project Examples](https://github.com/Infineon/platformio-infineonxmc/tree/master/examples) +## Contributing and Third Party Libraries +To contribute enhancements, fixes and the like see *Contributors.md*. in root folder + +Third Party or external library maintainers see *Libraries.md*. in root folder + +Also see [Wiki](https://github.com/Infineon/XMC-for-Arduino/wiki) for any additional information + ## Additional Contributors * [Paul Carpenter](https://github.com/techpaul) diff --git a/boards.txt b/boards.txt index e4935ccc..d071a1e3 100644 --- a/boards.txt +++ b/boards.txt @@ -39,7 +39,7 @@ XMC1100_Boot_Kit.menu.UART.onBoard.uart.selected=-DSERIAL_ONBOARD XMC1100_Boot_Kit.menu.LIB.NONE=None XMC1100_Boot_Kit.menu.LIB.NONE.library.selected= -XMC1100_Boot_Kit.menu.LIB.NN=ARM NN Framework +XMC1100_Boot_Kit.menu.LIB.NN=ARM NN Framework XMC1100_Boot_Kit.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN XMC1100_Boot_Kit.menu.LIB.DSP=ARM DSP XMC1100_Boot_Kit.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -83,7 +83,7 @@ XMC1100_XMC2GO.menu.UART.onBoard.uart.selected=-DSERIAL_ONBOARD XMC1100_XMC2GO.menu.LIB.NONE=None XMC1100_XMC2GO.menu.LIB.NONE.library.selected= -XMC1100_XMC2GO.menu.LIB.NN=ARM NN Framework +XMC1100_XMC2GO.menu.LIB.NN=ARM NN Framework XMC1100_XMC2GO.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN XMC1100_XMC2GO.menu.LIB.DSP=ARM DSP XMC1100_XMC2GO.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -121,13 +121,13 @@ XMC1100_H_BRIDGE2GO.build.flash_ld=linker_script.ld XMC1100_H_BRIDGE2GO.build.extra_flags=-DARM_MATH_CM0 -DXMC1_SERIES XMC1100_H_BRIDGE2GO.menu.UART.debug=PC -XMC1100_H_BRIDGE2GO.menu.UART.debug.uart.selected=-DSERIAL_HOSTPC +XMC1100_H_BRIDGE2GO.menu.UART.debug.uart.selected=-DSERIAL_ONBOARD XMC1100_H_BRIDGE2GO.menu.UART.onBoard=On Board XMC1100_H_BRIDGE2GO.menu.UART.onBoard.uart.selected=-DSERIAL_ONBOARD XMC1100_H_BRIDGE2GO.menu.LIB.NONE=None XMC1100_H_BRIDGE2GO.menu.LIB.NONE.library.selected= -XMC1100_H_BRIDGE2GO.menu.LIB.NN=ARM NN Framework +XMC1100_H_BRIDGE2GO.menu.LIB.NN=ARM NN Framework XMC1100_H_BRIDGE2GO.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN XMC1100_H_BRIDGE2GO.menu.LIB.DSP=ARM DSP XMC1100_H_BRIDGE2GO.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -139,7 +139,7 @@ XMC1300_Boot_Kit.name=XMC1300 Boot Kit XMC1300_Boot_Kit.upload.tool=xmcprog XMC1300_Boot_Kit.upload.speed=115200 XMC1300_Boot_Kit.upload.resetmethod=ck -XMC1300_Boot_Kit.upload.maximum_size=65536 +XMC1300_Boot_Kit.upload.maximum_size=204800 XMC1300_Boot_Kit.upload.wait_for_upload_port=true XMC1300_Boot_Kit.communication=usb @@ -160,8 +160,8 @@ XMC1300_Boot_Kit.build.board.v=0200 XMC1300_Boot_Kit.build.core=./ XMC1300_Boot_Kit.build.variant=XMC1300 XMC1300_Boot_Kit.build.board_variant=XMC1300_Boot_Kit -XMC1300_Boot_Kit.build.flash_size=64K -XMC1300_Boot_Kit.build.flash_ld=linker_script.ld +XMC1300_Boot_Kit.build.flash_size=200K +XMC1300_Boot_Kit.build.flash_ld=linker_script_200k.ld XMC1300_Boot_Kit.build.extra_flags=-DARM_MATH_CM0 -DXMC1_SERIES XMC1300_Boot_Kit.menu.UART.debug=PC @@ -171,7 +171,7 @@ XMC1300_Boot_Kit.menu.UART.onBoard.uart.selected=-DSERIAL_ONBOARD XMC1300_Boot_Kit.menu.LIB.NONE=None XMC1300_Boot_Kit.menu.LIB.NONE.library.selected= -XMC1300_Boot_Kit.menu.LIB.NN=ARM NN Framework +XMC1300_Boot_Kit.menu.LIB.NN=ARM NN Framework XMC1300_Boot_Kit.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN XMC1300_Boot_Kit.menu.LIB.DSP=ARM DSP XMC1300_Boot_Kit.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -183,7 +183,7 @@ XMC1300_Sense2GoL.name=XMC1300 Sense2GoL XMC1300_Sense2GoL.upload.tool=xmcprog XMC1300_Sense2GoL.upload.speed=115200 XMC1300_Sense2GoL.upload.resetmethod=ck -XMC1300_Sense2GoL.upload.maximum_size=125160 +XMC1300_Sense2GoL.upload.maximum_size=32768 XMC1300_Sense2GoL.upload.wait_for_upload_port=true XMC1300_Sense2GoL.communication=usb @@ -199,20 +199,20 @@ XMC1300_Sense2GoL.build.mcu=cortex-m0 XMC1300_Sense2GoL.build.f_cpu=32000000L XMC1300_Sense2GoL.build.board=ARM_XMC XMC1300_Sense2GoL.build.board.version=1302 -XMC1300_Sense2GoL.build.board.type=T038x0064 +XMC1300_Sense2GoL.build.board.type=T016x0032 XMC1300_Sense2GoL.build.board.v=0032 XMC1300_Sense2GoL.build.core=./ XMC1300_Sense2GoL.build.variant=XMC1300 XMC1300_Sense2GoL.build.board_variant=XMC1300_Sense2GoL -XMC1300_Sense2GoL.build.flash_size=64K -XMC1300_Sense2GoL.build.flash_ld=linker_script.ld +XMC1300_Sense2GoL.build.flash_size=32K +XMC1300_Sense2GoL.build.flash_ld=linker_script_32k.ld XMC1300_Sense2GoL.build.extra_flags=-DARM_MATH_CM0 -DXMC1_SERIES XMC1300_Sense2GoL.menu.LIB.DSPNN=ARM DSP / ARM NN Framework XMC1300_Sense2GoL.menu.LIB.DSPNN.library.selected=-DARM_LIB_CMSIS_DSP -DARM_LIB_CMSIS_NN XMC1300_Sense2GoL.menu.LIB.NONE=None XMC1300_Sense2GoL.menu.LIB.NONE.library.selected= -XMC1300_Sense2GoL.menu.LIB.NN=ARM NN Framework +XMC1300_Sense2GoL.menu.LIB.NN=ARM NN Framework XMC1300_Sense2GoL.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN XMC1300_Sense2GoL.menu.LIB.DSP=ARM DSP XMC1300_Sense2GoL.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -222,7 +222,7 @@ XMC1300_Sense2GoL.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP #XMC1400_Boot_Kit.upload.tool=xmcprog #XMC1400_Boot_Kit.upload.speed=115200 #XMC1400_Boot_Kit.upload.resetmethod=ck -#XMC1400_Boot_Kit.upload.maximum_size=2048000 +#XMC1400_Boot_Kit.upload.maximum_size=204800 #XMC1400_Boot_Kit.upload.wait_for_upload_port=true #XMC1400_Boot_Kit.communication=usb @@ -244,7 +244,7 @@ XMC1300_Sense2GoL.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP #XMC1400_Boot_Kit.build.variant=XMC1400 #XMC1400_Boot_Kit.build.board_variant=XMC1400_Boot_Kit #XMC1400_Boot_Kit.build.flash_size=200K -#XMC1400_Boot_Kit.build.flash_ld=linker_script.ld +#XMC1400_Boot_Kit.build.flash_ld=linker_script_200k.ld #XMC1400_Boot_Kit.build.extra_flags=-DARM_MATH_CM0 -DXMC1_SERIES #XMC1400_Boot_Kit.menu.UART.debug=PC @@ -254,7 +254,7 @@ XMC1300_Sense2GoL.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP #XMC1400_Boot_Kit.menu.LIB.NONE=None #XMC1400_Boot_Kit.menu.LIB.NONE.library.selected= -#XMC1400_Boot_Kit.menu.LIB.NN=ARM NN Framework +#XMC1400_Boot_Kit.menu.LIB.NN=ARM NN Framework #XMC1400_Boot_Kit.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN #XMC1400_Boot_Kit.menu.LIB.DSP=ARM DSP #XMC1400_Boot_Kit.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -269,16 +269,16 @@ XMC4400_Platform2GO.upload.speed=115200 XMC4400_Platform2GO.upload.resetmethod=ck XMC4400_Platform2GO.upload.maximum_size=512000 XMC4400_Platform2GO.upload.wait_for_upload_port=true - + XMC4400_Platform2GO.communication=usb XMC4400_Platform2GO.protocol=dragon_isp XMC4400_Platform2GO.program.protocol=dragon_isp XMC4400_Platform2GO.program.tool=xmcprog XMC4400_Platform2GO.program.extra_params=-Pusb - + XMC4400_Platform2GO.serial.disableDTR=true XMC4400_Platform2GO.serial.disableRTS=true - + XMC4400_Platform2GO.build.mcu=cortex-m4 XMC4400_Platform2GO.build.f_cpu=144000000L XMC4400_Platform2GO.build.board=ARM_XMC @@ -290,7 +290,7 @@ XMC4400_Platform2GO.build.variant=XMC4400 XMC4400_Platform2GO.build.board_variant=XMC4400_Platform2GO XMC4400_Platform2GO.build.flash_size=500K XMC4400_Platform2GO.build.flash_ld=linker_script.ld -XMC4400_Platform2GO.build.extra_flags=-DARM_MATH_CM4 -DARM_MATH_DSP +XMC4400_Platform2GO.build.extra_flags=-DARM_MATH_CM4 -DARM_MATH_DSP #-DUSB0 XMC4400_Platform2GO.menu.UART.debug=PC @@ -302,7 +302,7 @@ XMC4400_Platform2GO.menu.LIB.NONE=None XMC4400_Platform2GO.menu.LIB.NONE.library.selected= XMC4400_Platform2GO.menu.LIB.DSPNN=ARM DSP / ARM NN Framework XMC4400_Platform2GO.menu.LIB.DSPNN.library.selected=-DARM_LIB_CMSIS_DSP -DARM_LIB_CMSIS_NN -XMC4400_Platform2GO.menu.LIB.NN=ARM NN Framework +XMC4400_Platform2GO.menu.LIB.NN=ARM NN Framework XMC4400_Platform2GO.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN XMC4400_Platform2GO.menu.LIB.DSP=ARM DSP XMC4400_Platform2GO.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -314,16 +314,16 @@ XMC4700_Radar_Baseboard.upload.speed=115200 XMC4700_Radar_Baseboard.upload.resetmethod=ck XMC4700_Radar_Baseboard.upload.maximum_size=2048000 XMC4700_Radar_Baseboard.upload.wait_for_upload_port=true - + XMC4700_Radar_Baseboard.communication=usb XMC4700_Radar_Baseboard.protocol=dragon_isp XMC4700_Radar_Baseboard.program.protocol=dragon_isp XMC4700_Radar_Baseboard.program.tool=xmcprog XMC4700_Radar_Baseboard.program.extra_params=-Pusb - + XMC4700_Radar_Baseboard.serial.disableDTR=true XMC4700_Radar_Baseboard.serial.disableRTS=true - + XMC4700_Radar_Baseboard.build.mcu=cortex-m4 XMC4700_Radar_Baseboard.build.f_cpu=144000000L XMC4700_Radar_Baseboard.build.board=ARM_XMC @@ -341,7 +341,7 @@ XMC4700_Radar_Baseboard.menu.LIB.DSPNN=ARM DSP / ARM NN Framework XMC4700_Radar_Baseboard.menu.LIB.DSPNN.library.selected=-DARM_LIB_CMSIS_DSP -DARM_LIB_CMSIS_NN XMC4700_Radar_Baseboard.menu.LIB.NONE=None XMC4700_Radar_Baseboard.menu.LIB.NONE.library.selected= -XMC4700_Radar_Baseboard.menu.LIB.NN=ARM NN Framework +XMC4700_Radar_Baseboard.menu.LIB.NN=ARM NN Framework XMC4700_Radar_Baseboard.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN XMC4700_Radar_Baseboard.menu.LIB.DSP=ARM DSP XMC4700_Radar_Baseboard.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -353,16 +353,16 @@ XMC4700_Relax_Kit.upload.speed=115200 XMC4700_Relax_Kit.upload.resetmethod=ck XMC4700_Relax_Kit.upload.maximum_size=2048000 XMC4700_Relax_Kit.upload.wait_for_upload_port=true - + XMC4700_Relax_Kit.communication=usb XMC4700_Relax_Kit.protocol=dragon_isp XMC4700_Relax_Kit.program.protocol=dragon_isp XMC4700_Relax_Kit.program.tool=xmcprog XMC4700_Relax_Kit.program.extra_params=-Pusb - + XMC4700_Relax_Kit.serial.disableDTR=true XMC4700_Relax_Kit.serial.disableRTS=true - + XMC4700_Relax_Kit.build.mcu=cortex-m4 XMC4700_Relax_Kit.build.f_cpu=144000000L XMC4700_Relax_Kit.build.board=ARM_XMC @@ -380,7 +380,7 @@ XMC4700_Relax_Kit.menu.LIB.DSPNN=ARM DSP / ARM NN Framework XMC4700_Relax_Kit.menu.LIB.DSPNN.library.selected=-DARM_LIB_CMSIS_DSP -DARM_LIB_CMSIS_NN XMC4700_Relax_Kit.menu.LIB.NONE=None XMC4700_Relax_Kit.menu.LIB.NONE.library.selected= -XMC4700_Relax_Kit.menu.LIB.NN=ARM NN Framework +XMC4700_Relax_Kit.menu.LIB.NN=ARM NN Framework XMC4700_Relax_Kit.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN XMC4700_Relax_Kit.menu.LIB.DSP=ARM DSP XMC4700_Relax_Kit.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP @@ -421,7 +421,7 @@ XMC4700_Relax_Kit.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP #XMC4800_Relax_Kit.menu.LIB.DSPNN.library.selected=-DARM_LIB_CMSIS_DSP -DARM_LIB_CMSIS_NN #XMC4800_Relax_Kit.menu.LIB.NONE=None #XMC4800_Relax_Kit.menu.LIB.NONE.library.selected= -#XMC4800_Relax_Kit.menu.LIB.NN=ARM NN Framework +#XMC4800_Relax_Kit.menu.LIB.NN=ARM NN Framework #XMC4800_Relax_Kit.menu.LIB.NN.library.selected=-DARM_LIB_CMSIS_NN #XMC4800_Relax_Kit.menu.LIB.DSP=ARM DSP #XMC4800_Relax_Kit.menu.LIB.DSP.library.selected=-DARM_LIB_CMSIS_DSP diff --git a/cores/Arduino.h b/cores/Arduino.h index 2baf4b40..37bd3177 100644 --- a/cores/Arduino.h +++ b/cores/Arduino.h @@ -212,7 +212,7 @@ extern "C" { /* * \brief Arduino yield function. - */ + */ void yield( void ); /* @@ -225,7 +225,7 @@ extern "C" { */ extern void loop(void); - + //**************************************************************************** // @Arduino Core Includes //**************************************************************************** diff --git a/cores/WMath.h b/cores/WMath.h index 1c00fa9d..498c1a28 100644 --- a/cores/WMath.h +++ b/cores/WMath.h @@ -22,13 +22,12 @@ //**************************************************************************** // @External Prototypes //**************************************************************************** - extern long random( long ) ; - extern long random( long, long ) ; - extern void randomSeed(uint32_t dwSeed) ; -//extern long map( long, long, long, long, long ) ; +extern long random( long ) ; +extern long random( long, long ) ; +extern void randomSeed(uint32_t dwSeed) ; - extern uint16_t makeWord( uint16_t w ) ; - extern uint16_t makeWord( uint8_t h, uint8_t l ) ; +extern uint16_t makeWord( uint16_t w ) ; +extern uint16_t makeWord( uint8_t h, uint8_t l ) ; //**************************************************************************** // @Defines diff --git a/cores/wiring_analog.c b/cores/wiring_analog.c index f5f72f41..643d4a3d 100644 --- a/cores/wiring_analog.c +++ b/cores/wiring_analog.c @@ -117,13 +117,13 @@ for( uint8_t chan = 0; chan < NUM_ANALOG_INPUTS; chan++ ) } -/* Set the resolution of analogRead return values in number of bits. +/* Set the resolution of analogRead return values in number of bits. Default is 10 bits (range from 0 to 1023) Maximum is 12 bits (range from 0 to 4095) PC Sept-2019 Change flow to trap invalid input first and leave at old setting if Invalid and return valid value or 255 for error, else return setting used - + Add set maximum value for resolution */ uint8_t analogReadResolution( uint8_t res ) @@ -137,14 +137,14 @@ return res; } -/* Set the resolution of analogWrite parameters in number of bits. +/* Set the resolution of analogWrite parameters in number of bits. Default (minimum) is 8 bits (range from 0 to 255). Maximum is 16 bits (range 0 to 65535) PC Sept-2019 Change flow to trap invalid input first and leave at old setting if Invalid and return valid value or 255 for error, else return setting used - + Add set maximum value for resolution */ uint8_t analogWriteResolution( uint8_t res ) @@ -217,7 +217,7 @@ return value; } -/* Helper function for analogWrite and setAnalogWriteFrequency to scan +/* Helper function for analogWrite and setAnalogWriteFrequency to scan mapping tables to determine for a given pin which PWM4, PWM8 or DAC channel to use Returns valid channel index or -1 for not listed @@ -262,7 +262,6 @@ int16_t analogWrite( uint8_t pin, uint16_t value ) { uint32_t compare_reg = 0; int16_t resource; -int16_t ret = 0; if( value > _writeMaximum ) return -1; @@ -288,7 +287,7 @@ if( ( resource = scan_map_table( mapping_pin_PWM4, pin ) ) >= 0 ) } if( value != 0 ) - compare_reg = ( ( value + 1 ) * ( pwm4->period_timer_val + 1 ) ) >> _writeResolution; + compare_reg = ( ( value + 1 ) * ( pwm4->period_timer_val + 1 ) ) >> _writeResolution; XMC_CCU4_SLICE_SetTimerCompareMatch( pwm4->slice, compare_reg ); XMC_CCU4_EnableShadowTransfer( pwm4->ccu, ( CCU4_GCSS_S0SE_Msk << ( 4 * pwm4->slice_num ) ) ); @@ -321,7 +320,7 @@ else } if( value != 0 ) - compare_reg = ( ( value + 1 ) * ( pwm8->period_timer_val + 1 ) ) >> _writeResolution; + compare_reg = ( ( value + 1 ) * ( pwm8->period_timer_val + 1 ) ) >> _writeResolution; XMC_CCU8_SLICE_SetTimerCompareMatch( pwm8->slice, pwm8->slice_channel, compare_reg ); XMC_CCU8_EnableShadowTransfer( pwm8->ccu, CCU8_GCSS_S0SE_Msk << ( 4 * pwm8->slice_num ) ); @@ -343,9 +342,9 @@ else XMC_DAC_CH_Write( dac->group, dac->channel, dacValue ); } #endif -else - ret = -2; -return ret; + else + return -2; +return 0; } @@ -418,8 +417,8 @@ return ret; /* PC Sept-2019 Add helper functions to get Read and Write resolution as bits or maximum value -*/ -/* Get the current resolution of analogRead in number of bits. +*/ +/* Get the current resolution of analogRead in number of bits. Return Current resolution in bits (8 to 12) */ uint8_t getAnalogReadBits( ) @@ -428,7 +427,7 @@ return _readResolution; } -/* Get the current resolution of analogWrite in number of bits. +/* Get the current resolution of analogWrite in number of bits. Return Current resolution in bits (8 to 16) */ uint8_t getAnalogWriteBits( ) @@ -437,7 +436,7 @@ return _writeResolution; } -/* Get the maximum value for current resolution for analogRead. +/* Get the maximum value for current resolution for analogRead. Default is 1023 Maximum is 4095 */ @@ -447,7 +446,7 @@ return _readMaximum; } -/* Get the maximum value for current resolution for analogWrite. +/* Get the maximum value for current resolution for analogWrite. Default is 255 Maximum is 65535 */ diff --git a/cores/wiring_analog.h b/cores/wiring_analog.h index da8605c2..3da40ccc 100644 --- a/cores/wiring_analog.h +++ b/cores/wiring_analog.h @@ -59,10 +59,10 @@ extern "C" { * \return 0 = success, -1 = invalid value, -2 = wrong pin */ extern int16_t analogWrite( uint8_t pin, uint16_t value ) ; - + /* * \brief Sets the frequency for analogWrite PWM. - * + * * Returns -2 invalid pin * -1 invalid frequency * 0 success @@ -77,7 +77,7 @@ extern "C" { extern int16_t setAnalogWriteFrequency( uint8_t pin, uint32_t frequency ) ; /* - * \brief Reads the value from the specified analog channel. + * \brief Reads the value from the specified analogue channel. * * \param channel * @@ -96,7 +96,7 @@ extern "C" { extern uint8_t analogReadResolution( uint8_t res ); /* - * \brief Set the resolution of analogWrite parameters in number of bits. + * \brief Set the resolution of analogWrite parameters in number of bits. * \note Default (minimum) is 8 bits (range from 0 to 16). * Maximum is 16 bits (range 0 to 65535) * @@ -112,21 +112,21 @@ extern "C" { \brief Additional helper functions for other libraries **********************************************************/ /* - * \brief Get the current resolution of analogRead in number of bits. + * \brief Get the current resolution of analogRead in number of bits. * * \return Current resolution in bits (8 to 12) */ extern uint8_t getAnalogReadBits( ); /* - * \brief Get the current resolution of analogWrite in number of bits. + * \brief Get the current resolution of analogWrite in number of bits. * * \return Current resolution in bits (8 to 16) */ extern uint8_t getAnalogWriteBits( ); /* - * \brief Get the maximum value for current resolution for analogRead. + * \brief Get the maximum value for current resolution for analogRead. * \note Default is 1023 * \note Maximum is 4095 * @@ -135,7 +135,7 @@ extern "C" { extern uint16_t getAnalogReadMaximum( ); /* - * \brief Get the maximum value for current resolution for analogWrite. + * \brief Get the maximum value for current resolution for analogWrite. * \note Default is 255 * \note Maximum is 65535 * diff --git a/cores/wiring_constants.h b/cores/wiring_constants.h index dd0d1aa3..0c315181 100644 --- a/cores/wiring_constants.h +++ b/cores/wiring_constants.h @@ -84,7 +84,7 @@ extern "C" { #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) -#define map( x, in_min, in_max, out_min, out_max) ((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min) +#define map( x, in_min, in_max, out_min, out_max) ( ( (x - in_min) * (out_max - out_min) ) / (in_max - in_min) + out_min) #define interrupts() __enable_irq() #define noInterrupts() __disable_irq() diff --git a/keywords.txt b/keywords.txt index cd5133a3..e5fdacd6 100644 --- a/keywords.txt +++ b/keywords.txt @@ -1,5 +1,5 @@ ####################################### -# Syntax Coloring Map For Core +# Syntax Colouring Map For Core ####################################### ####################################### @@ -12,6 +12,10 @@ digitalToggle KEYWORD2 setAnalogWriteFrequency KEYWORD2 +getAnalogReadBits KEYWORD2 +getAnalogWriteBits KEYWORD2 +getAnalogReadMaximum KEYWORD2 +getAnalogWriteMaximum KEYWORD2 ####################################### # Instances (KEYWORD2) diff --git a/libraries/BGT24LTR11-Pulsed-Doppler-Radar/library.properties b/libraries/BGT24LTR11-Pulsed-Doppler-Radar/library.properties index e7dfb916..833a7736 100644 --- a/libraries/BGT24LTR11-Pulsed-Doppler-Radar/library.properties +++ b/libraries/BGT24LTR11-Pulsed-Doppler-Radar/library.properties @@ -6,7 +6,7 @@ sentence=This library provides Pulsed Doppler functionality with XMC4700 Radar B paragraph=Infineon's 24 GHz Sense2GoL Pulse radar system platform, is made up of the Radar Baseboard XMC4700 and BGT24LTR11 radar shield. category=Sensors url=https://www.infineon.com/cms/en/product/sensor/radar-image-sensors/radar-sensors/radar-sensors-for-consumer-and-iot/ -architectures=arm +architectures=xmc,arm includes=IFXRadarPulsedDoppler.h precompiled=true #ldflags=-lRadar_S2GL_Pulsed_Doppler_lib diff --git a/libraries/DMA/library.properties b/libraries/DMA/library.properties index b1352abd..4628d3aa 100644 --- a/libraries/DMA/library.properties +++ b/libraries/DMA/library.properties @@ -6,4 +6,5 @@ sentence=This library helps you to manage DMA for XMC microcontrollers [EXPERIME paragraph= The General Purposes Direct Memory Access (GPDMA) is a module within the XMC4000 series to transfer data without any CPU interference. When a DMA transfer request is generated, the GPDMA transfers data stored at the source address to the destination address. category=Device Control url = https://www.infineon.com/dgdl/Infineon-GPDMA-XMC4000-AP32290-AN-v01_00-EN.pdf?fileId=5546d4624e765da5014ed9145c601e95 -architectures=arm \ No newline at end of file +architectures=xmc,arm + diff --git a/libraries/DSP/library.properties b/libraries/DSP/library.properties index 66502ab3..cde742a4 100644 --- a/libraries/DSP/library.properties +++ b/libraries/DSP/library.properties @@ -5,5 +5,5 @@ maintainer=Infineon Technologies sentence=Library for digital signal processing paragraph=This library provides APIs for computing both floating- and fixed-point FFT, as well as computing MFCC (speech features). category=Data Processing -architectures=* +architectures=xmc,arm url= diff --git a/libraries/DeviceControlXMC/examples/DieTemperatureMeasurement/DieTemperatureMeasurement.ino b/libraries/DeviceControlXMC/examples/DieTemperatureMeasurement/DieTemperatureMeasurement.ino index f8da1c2f..44fe1d4f 100644 --- a/libraries/DeviceControlXMC/examples/DieTemperatureMeasurement/DieTemperatureMeasurement.ino +++ b/libraries/DeviceControlXMC/examples/DieTemperatureMeasurement/DieTemperatureMeasurement.ino @@ -3,12 +3,14 @@ Demonstrates the measure temperature of die using sensor. 05 July 2017 + Amended July 2020 to allow negative die temperature + Amended February 2020 in line with PR for XMC_BOARD tidy up Amended April 2018 Paul Carpenter, PC Services Needs first serial port to display results at 115,200 baud - Add signon message + Add sign on message Take initial reading to avoid high reading as first reading Make board agnostic Simplify code @@ -21,7 +23,7 @@ XMCClass devCtrl; -uint32_t temperature = 0; +int32_t temperature = 0; void setup( ) @@ -38,11 +40,11 @@ temperature = devCtrl.getTemperature(); void loop( ) { - delay( 1000 ); +delay( 1000 ); - /* If UC_FAMILY = XMC4 you can also calibrate temperature for finer measurements */ - temperature = devCtrl.getTemperature(); +/* If UC_FAMILY = XMC4 you can also calibrate temperature for finer measurements */ +temperature = devCtrl.getTemperature(); - Serial.print( "Die Temperature\t" ); - Serial.println( temperature ); +Serial.print( "Die Temperature\t" ); +Serial.println( temperature ); } diff --git a/libraries/DeviceControlXMC/examples/SleepModeXMC4700/SleepModeXMC4700.ino b/libraries/DeviceControlXMC/examples/SleepModeXMC4700/SleepModeXMC4700.ino index 0777bb0e..b76c63d5 100644 --- a/libraries/DeviceControlXMC/examples/SleepModeXMC4700/SleepModeXMC4700.ino +++ b/libraries/DeviceControlXMC/examples/SleepModeXMC4700/SleepModeXMC4700.ino @@ -8,7 +8,6 @@ #include #include #include "utility/timer.h" -#include // Create an rtc object RTCClass rtc; diff --git a/libraries/DeviceControlXMC/keywords.txt b/libraries/DeviceControlXMC/keywords.txt index 67967e56..0ec49cdd 100644 --- a/libraries/DeviceControlXMC/keywords.txt +++ b/libraries/DeviceControlXMC/keywords.txt @@ -17,8 +17,6 @@ XMCClass KEYWORD1 begin KEYWORD2 enterActiveMode KEYWORD2 reset KEYWORD2 -configureHibernate KEYWORD2 -enterHibernate KEYWORD2 configureSleepMode KEYWORD2 enterSleepMode KEYWORD2 getTemperature KEYWORD2 diff --git a/libraries/DeviceControlXMC/library.properties b/libraries/DeviceControlXMC/library.properties index c459b58a..6833b5a2 100644 --- a/libraries/DeviceControlXMC/library.properties +++ b/libraries/DeviceControlXMC/library.properties @@ -6,5 +6,5 @@ sentence=This library helps you to manage low power modes of XMC microcontroller paragraph= . category=Device Control url= -architectures=arm +architectures=xmc,arm diff --git a/libraries/DeviceControlXMC/src/DeviceControlXMC.cpp b/libraries/DeviceControlXMC/src/DeviceControlXMC.cpp index e306f591..ffebd590 100644 --- a/libraries/DeviceControlXMC/src/DeviceControlXMC.cpp +++ b/libraries/DeviceControlXMC/src/DeviceControlXMC.cpp @@ -29,6 +29,7 @@ * 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. */ +#include #include "DeviceControlXMC.h" extern caddr_t Heap_Bank1_Start; @@ -54,50 +55,54 @@ void XMCClass::begin( ) /* Wake up from sleep mode */ void XMCClass::enterActiveMode( ) { - SCB->SCR = 0x00; +SCB->SCR = 0x00; } /* Software Reset of MCU */ void XMCClass::reset( ) { - NVIC_SystemReset( ); +NVIC_SystemReset( ); } /** * Get Die temperature in Celsius * @return temp_celsius: Die temperature in Celsius + * + * Modified July 2020 Paul Carpenter - to allow negative temperatures + * to be returned */ -uint32_t XMCClass::getTemperature( ) +int32_t XMCClass::getTemperature( ) { - uint32_t temp_calc = 0, temp_celsius = 0; - temp_measurement_s = XMC_SCU_STATUS_ERROR; +uint32_t temp_calc = 0; +int32_t temp_celsius; +temp_measurement_s = XMC_SCU_STATUS_ERROR; #if (UC_FAMILY == XMC4) - while( temp_calc == 0 ) - { - if( temp_measurement_s == XMC_SCU_STATUS_OK ) - temp_calc = XMC_SCU_GetTemperatureMeasurement( ); - else - if( temp_measurement_s == XMC_SCU_STATUS_ERROR ) - XMC_SCU_EnableTemperatureSensor( ); - else - if( temp_measurement_s == XMC_SCU_STATUS_BUSY ) - while( XMC_SCU_IsTemperatureSensorBusy( ) ); - temp_measurement_s = XMC_SCU_StartTemperatureMeasurement( ); - } - temp_celsius = ( temp_calc - 605 ) / 2.05; +while( temp_calc == 0 ) + { + if( temp_measurement_s == XMC_SCU_STATUS_OK ) + temp_calc = XMC_SCU_GetTemperatureMeasurement( ); + else + if( temp_measurement_s == XMC_SCU_STATUS_ERROR ) + XMC_SCU_EnableTemperatureSensor( ); + else + if( temp_measurement_s == XMC_SCU_STATUS_BUSY ) + while( XMC_SCU_IsTemperatureSensorBusy( ) ); + temp_measurement_s = XMC_SCU_StartTemperatureMeasurement( ); + } +temp_celsius = ( temp_calc - 605 ) / 2.05; #elif(UC_FAMILY == XMC1) - while( temp_calc == 0 ) - { - XMC_SCU_StartTempMeasurement( ); - temp_calc = XMC_SCU_CalcTemperature( ); - } - temp_celsius = temp_calc - 273; +while( temp_calc == 0 ) + { + XMC_SCU_StartTempMeasurement( ); + temp_calc = XMC_SCU_CalcTemperature( ); + } +temp_celsius = temp_calc - 273; #endif - return temp_celsius; +return temp_celsius; } @@ -118,93 +123,26 @@ uint32_t XMCClass::getTemperature( ) */ size_t XMCClass::freeHeapRAM( ) { - size_t heap_free_s; - char *pnt; - - // Set to initial total size - heap_free_s = total_heap_s; - heap_free_s &= ~0x03; // align as last bytes probably not available - - // loop in 4 byte (at least) multiples to satisfy alignment requirements - for( ; heap_free_s > 0; heap_free_s -= 4 ) - { - pnt = (char*)malloc( heap_free_s ); - if( pnt != NULL ) - break; - } - free( pnt ); - return heap_free_s; +size_t heap_free_s; +char *pnt; + +// Set to initial total size +heap_free_s = total_heap_s; +heap_free_s &= ~0x03; // align as last bytes probably not available + +// loop in 4 byte (at least) multiples to satisfy alignment requirements +for( ; heap_free_s > 0; heap_free_s -= 4 ) + { + pnt = (char*)malloc( heap_free_s ); + if( pnt != NULL ) + break; + } +free( pnt ); +return heap_free_s; } #if (UC_FAMILY == XMC4) -/** - * Configure hibernate. Set the wakeup source. - * @param wkpsrc: - * -RTC event (example is already given) - * -Watchdog of RTC external crystal oscillator - * -Digital Input Signal (HIB_IO_0 or HIB_IO_1) - * -Analog Input Signal (HIB_IO_0 or HIB_IO_1) - * -VBAT Supply Level Detection (VBAT) -*/ -void XMCClass::configureHibernate( WakeupSource wkpsrc ) -{ - /* Enable Hibernate Domain & Release reset of Hibernate Domain (if asserted) */ - XMC_SCU_HIB_EnableHibernateDomain( ); - /* Configure the 32khz Ultra Low Power oscillator */ - XMC_SCU_CLOCK_EnableLowPowerOscillator( ); - /* Select fSTDBY */ - XMC_SCU_HIB_SetStandbyClockSource( XMC_SCU_HIB_STDBYCLKSRC_OSCULP ); - - switch( wkpsrc ) - { - case ( WAKEUP_ON_RTC ): - /* Enable the RTC with Ultra Low Power Clock */ - XMC_SCU_HIB_SetRtcClockSource( XMC_SCU_HIB_RTCCLKSRC_ULP ); - delay( 3 ); - /* Configure wake-up on RTC event */ - XMC_SCU_HIB_EnableEvent( XMC_SCU_HIB_EVENT_WAKEUP_ON_RTC ); - break; - // TODO: Implement wake up on these other methods - case ( WAKEUP_ON_WATCHDOG ): break; - case ( WAKEUP_ON_IN_SIGNAL_POS_EDGE ): break; - case ( WAKEUP_ON_IN_SIGNAL_NEG_EDGE ): break; -#if (defined(DOXYGEN) || (UC_SERIES == XMC44) || (UC_SERIES == XMC42) || (UC_SERIES == XMC41)) - case ( WAKEUP_ON_VBAT_POSEDGE ): break; - case ( WAKEUP_ON_VBAT_NEGEDGE ): break; -#endif - } - /*Digital outputs polarity*/ - XMC_SCU_HIB_SetPinOutputLevel( XMC_SCU_HIB_IO_0, XMC_SCU_HIB_IO_OUTPUT_LEVEL_LOW ); - - /*Select hibernate control output and driver properties*/ - XMC_SCU_HIB_SetPinMode( XMC_SCU_HIB_IO_0, - XMC_SCU_HIB_PIN_MODE_OUTPUT_PUSH_PULL_HIBCTRL ); - - /*If necessary store data in retention memory */ -} - - -/** - * Enter hibernate mode. - * @param: mode: (check which one is supported on device) - * EXTERNAL "1" - * INTERNAL "2" - */ -void XMCClass::enterHibernate( int mode ) -{ - hibernate = true; - if( mode == 1 ) - hibernate_mode = XMC_SCU_HIB_HIBERNATE_MODE_EXTERNAL; -#if ((UC_SERIES == XMC44) || (UC_SERIES == XMC42) || (UC_SERIES == XMC41)) - else - if( mode == 2 ) - hibernate_mode = XMC_SCU_HIB_HIBERNATE_MODE_INTERNAL; -#endif - XMC_SCU_HIB_EnterHibernateStateEx( hibernate_mode ); -} - - /** * Configure sleep mode. * @param type (SLEEP_MODE or DEEP_SLEEP_MODE) @@ -223,47 +161,47 @@ void XMCClass::configureSleepMode( sleepMode_t type, sysclock_t clk, usb_t usb, ccu_t ccu , wdt_t wdt, flash_t flash, clkpll_t pll, vco_t vco ) { - sleep_config |= clk; +sleep_config |= clk; #if defined(USB0) - sleep_config |= usb; +sleep_config |= usb; #endif #if defined(SDMMC) - sleep_config |= sdmmc; +sleep_config |= sdmmc; #endif #if defined(ETH0) - sleep_config |= ethernet; +sleep_config |= ethernet; #endif #if defined(EBU) - sleep_config |= ebu; +sleep_config |= ebu; #endif - sleep_config |= ccu; - sleep_config |= wdt; - - if( type == SLEEP_MODE ) - { - power_mode = XMC_SCU_POWER_MODE_SLEEP; - XMC_SCU_CLOCK_SetSleepConfig( sleep_config ); - } - else - if( type == DEEP_SLEEP_MODE ) - { - if( flash == FLASH_OFF ) - sleep_config |= flash; - if( pll == PLL_OFF ) - sleep_config |= pll; - if( vco == VCO_OFF ) - sleep_config |=vco; - power_mode = XMC_SCU_POWER_MODE_DEEPSLEEP; - XMC_SCU_CLOCK_SetDeepSleepConfig( sleep_config ); - } +sleep_config |= ccu; +sleep_config |= wdt; + +if( type == SLEEP_MODE ) + { + power_mode = XMC_SCU_POWER_MODE_SLEEP; + XMC_SCU_CLOCK_SetSleepConfig( sleep_config ); + } +else + if( type == DEEP_SLEEP_MODE ) + { + if( flash == FLASH_OFF ) + sleep_config |= flash; + if( pll == PLL_OFF ) + sleep_config |= pll; + if( vco == VCO_OFF ) + sleep_config |=vco; + power_mode = XMC_SCU_POWER_MODE_DEEPSLEEP; + XMC_SCU_CLOCK_SetDeepSleepConfig( sleep_config ); + } } /* Device sleeps on exit of this function*/ void XMCClass::enterSleepMode( ) { - XMC_SCU_POWER_WaitForInterrupt( power_mode, 1 ); +XMC_SCU_POWER_WaitForInterrupt( power_mode, 1 ); } @@ -277,12 +215,12 @@ void XMCClass::enterSleepMode( ) */ void XMCClass::calibrateTemperatureSensor( uint32_t offset, uint32_t gain ) { - /* Stop measurement */ - SCU_GENERAL-> DTSCON &= (uint32_t)~SCU_GENERAL_DTSCON_START_Msk; - /* Calibrate */ - XMC_SCU_CalibrateTemperatureSensor( offset, gain ); - /* Start measurements */ - XMC_SCU_StartTemperatureMeasurement( ); +/* Stop measurement */ +SCU_GENERAL-> DTSCON &= (uint32_t)~SCU_GENERAL_DTSCON_START_Msk; +/* Calibrate */ +XMC_SCU_CalibrateTemperatureSensor( offset, gain ); +/* Start measurements */ +XMC_SCU_StartTemperatureMeasurement( ); } #endif @@ -300,31 +238,31 @@ void XMCClass::calibrateTemperatureSensor( uint32_t offset, uint32_t gain ) void XMCClass::configureSleepMode( sleepMode_t type, usic_t usic, ledt_t ledt, ccu_t ccu, wdt_t wdt, flash_t flash ) { - sleep_config |= usic; +sleep_config |= usic; #if (defined (LEDTS0) || ( LEDTS1 )|| ( LEDTS2)) - sleep_config |= ledt; +sleep_config |= ledt; #else - XMC_UNUSED_ARG( ledt ); +XMC_UNUSED_ARG( ledt ); #endif - sleep_config |= wdt; - sleep_config |= ccu; +sleep_config |= wdt; +sleep_config |= ccu; - if( type == DEEP_SLEEP_MODE ) - if( flash == FLASH_OFF ) - SCU_CLK -> PWRSVCR |= flash; +if( type == DEEP_SLEEP_MODE ) + if( flash == FLASH_OFF ) + SCU_CLK -> PWRSVCR |= flash; - SCU_CLK->CGATSET0 = sleep_config; // Set sleep configuration - VADC->CLC &= ~VADC_CLC_EDIS_Msk; // Enable sleep control - sleep_mode = type; // Store sleep type +SCU_CLK->CGATSET0 = sleep_config; // Set sleep configuration +VADC->CLC &= ~VADC_CLC_EDIS_Msk; // Enable sleep control +sleep_mode = type; // Store sleep type } /* Device sleeps on exit of this function */ void XMCClass::enterSleepMode( ) { - SCB->SCR = sleep_mode | SCB_SCR_SLEEPONEXIT_Msk; - __WFI(); +SCB->SCR = sleep_mode | SCB_SCR_SLEEPONEXIT_Msk; +__WFI(); } #endif diff --git a/libraries/DeviceControlXMC/src/DeviceControlXMC.h b/libraries/DeviceControlXMC/src/DeviceControlXMC.h index 26ecb941..35351681 100644 --- a/libraries/DeviceControlXMC/src/DeviceControlXMC.h +++ b/libraries/DeviceControlXMC/src/DeviceControlXMC.h @@ -35,7 +35,6 @@ //**************************************************************************** // @Project Includes //**************************************************************************** -#include #include extern const size_t total_heap_s; @@ -143,40 +142,34 @@ class XMCClass /* Constructor */ XMCClass() { + temp_measurement_s = XMC_SCU_STATUS_ERROR; sleep = false; deep_sleep = false; sleep_config = 0x00; - temp_measurement_s = XMC_SCU_STATUS_ERROR; sleep_mode = SLEEP_MODE; #if (UC_FAMILY == XMC4) power_mode = XMC_SCU_POWER_MODE_SLEEP; - hibernate = false; - hibernate_mode = XMC_SCU_HIB_HIBERNATE_MODE_EXTERNAL; #endif } void begin(); // Nothing in this function yet + /* State Control*/ + int32_t getTemperature(); // Device Temperature control /*Power Control*/ void enterActiveMode(); // Wake up from sleep. This function should be called in interrupt handler. void reset(); // Software reset of device - /* State Control*/ - uint32_t getTemperature(); // Device Temperature control size_t freeHeapRAM(); #if (UC_FAMILY == XMC4) - /*Power Control*/ - void configureHibernate(WakeupSource wkpsrc); // Configure Hibernate & choose a waking up source - void enterHibernate(int mode); // Enter Hibernate, EXTERNAL or INTERNAL - void configureSleepMode(sleepMode_t type, sysclock_t clk, usb_t usb0, sdmmc_t sdmmc, eth0_t ethernet, ebu_t ebu, ccu_t ccu , wdt_t wdt, flash_t flash, clkpll_t pll, vco_t vco); // Configure sleep mode type & peripherals status on sleep/deep sleep mode - void enterSleepMode(); // Enter Sleep Mode, called after sleep mode is configured /* State Control*/ void calibrateTemperatureSensor(uint32_t offset, uint32_t gain); // Calibrate temperature - + /*Power Control*/ + void configureSleepMode(sleepMode_t type, sysclock_t clk, usb_t usb0, sdmmc_t sdmmc, eth0_t ethernet, ebu_t ebu, ccu_t ccu , wdt_t wdt, flash_t flash, clkpll_t pll, vco_t vco); // Configure sleep mode type & peripherals status on sleep/deep sleep mode #elif(UC_FAMILY == XMC1) void configureSleepMode(sleepMode_t type, usic_t usic, ledt_t ledt, ccu_t ccu,wdt_t wdt, flash_t flash); // Configure sleep mode type & peripherals status on sleep/deep sleep mode - void enterSleepMode(); // Enter Sleep Mode, called after sleep mode is configured #endif + void enterSleepMode(); // Enter Sleep Mode, called after sleep mode is configured private: void init(); // Nothing in this function yet @@ -188,8 +181,6 @@ class XMCClass #if (UC_FAMILY == XMC4) XMC_SCU_POWER_MODE_t power_mode; - XMC_SCU_HIB_HIBERNATE_MODE_t hibernate_mode; // Stores type of hibernate mode, EXTERNAL or INTERNAL - bool hibernate; // Set if hibernate mode is active #endif }; diff --git a/libraries/I2S/library.properties b/libraries/I2S/library.properties index 9819857c..b3350fd8 100644 --- a/libraries/I2S/library.properties +++ b/libraries/I2S/library.properties @@ -6,5 +6,5 @@ sentence=This library allows the XMC µC to interface audio input devices with t paragraph=The I2S protocol is a synchronous serial communication protocol mainly for audio and infotainment applications. This library allows the microcontroller to work as the master device and read audio input from another device such as a microphone. USIC interrupts are used for sampling. category=Communication url=https://www.infineon.com/cms/en/product/promopages/microphones/ -architectures=arm +architectures=xmc,arm diff --git a/libraries/LED/library.properties b/libraries/LED/library.properties index a81bcb0d..2632fc93 100644 --- a/libraries/LED/library.properties +++ b/libraries/LED/library.properties @@ -6,5 +6,5 @@ sentence=This library allows you to enable as well as control the on board LEDs paragraph= This library allows you to enable as well as control the on boards LEDs on Infineon XMC boards, in a way that works across ANY board. category=Other url=https://github.com/Infineon/XMC-for-Arduino/tree/master/arm/libraries/LED -architectures=arm +architectures=xmc,arm diff --git a/libraries/Mouse/library.properties b/libraries/Mouse/library.properties index 7347b9de..ddb8491b 100644 --- a/libraries/Mouse/library.properties +++ b/libraries/Mouse/library.properties @@ -6,4 +6,5 @@ sentence=Allows an Arduino/Genuino board with USB capabilites to act as a Mouse. paragraph=This library plugs on the HID library. Can be used with or without other HID-based libraries (Keyboard, Gamepad etc) category=Device Control url=http://www.arduino.cc/en/Reference/Mouse -architectures=* +architectures=xmc,arm + diff --git a/libraries/Multi-Serial/Readme.md b/libraries/Multi-Serial/Readme.md index 50ee01e8..d7bd75b9 100644 --- a/libraries/Multi-Serial/Readme.md +++ b/libraries/Multi-Serial/Readme.md @@ -1,7 +1,6 @@ # Multiple Serial Ports Examples -Simple examples that use multiple serial ports of XMC boards to measure -distances. Uses internal functions without requiring extra libraries. +Simple examples that use multiple serial ports of XMC boards. Uses internal functions without requiring extra libraries. | | | | |:---|:---:|:---| diff --git a/libraries/Multi-Serial/library.properties b/libraries/Multi-Serial/library.properties index 13bac964..e97bb0df 100644 --- a/libraries/Multi-Serial/library.properties +++ b/libraries/Multi-Serial/library.properties @@ -6,5 +6,5 @@ sentence=Add examples for multiple Serial ports on XMC boards paragraph=Simple echo of multiple serial ports cureently two serial ports on XMC series boards category=Communication url=https://github.com/Infineon/XMC-for-Arduino/tree/master/arm/libraries/Multi-Serial/ -architectures=arm +architectures=xmc,arm diff --git a/libraries/OneWire/library.properties b/libraries/OneWire/library.properties index bdb66a7f..d77b41a9 100644 --- a/libraries/OneWire/library.properties +++ b/libraries/OneWire/library.properties @@ -6,5 +6,5 @@ sentence=Access 1-wire temperature sensors, memory and other chips. paragraph=Add Dallas one wire interface for single wire peripherals like DS18B20 (temperature), memory and other devices category=Communication url=http://www.pjrc.com/teensy/td_libs_OneWire.html -architectures=arm +architectures=xmc,arm diff --git a/libraries/RTC/library.properties b/libraries/RTC/library.properties index 42bfe8d4..1828547e 100644 --- a/libraries/RTC/library.properties +++ b/libraries/RTC/library.properties @@ -6,5 +6,5 @@ sentence=This library allows you to enable as well as controll the RTC (Real Tim paragraph= This library allows you to enable as well as controll the RTC (Real Time Clock) module of the XMC microcontrollers. Real-time clock (RTC) is a clock that keeps track of the current time. RTCs are present in almost any electronic device which needs to keep accurate time in a digital format for clock displays and computer systems. category=Timing url=http://www.arduino.cc/en/Reference/RTC -architectures=arm +architectures=xmc,arm diff --git a/libraries/RTC/src/RTC.cpp b/libraries/RTC/src/RTC.cpp index bf33c3d8..10aabc6d 100644 --- a/libraries/RTC/src/RTC.cpp +++ b/libraries/RTC/src/RTC.cpp @@ -31,7 +31,7 @@ /*! \file RTC.cpp * \brief This file defines functions and predefined instances from RTC.h */ - +#include #include "RTC.h" //**************************************************************************** diff --git a/libraries/RTC/src/RTC.h b/libraries/RTC/src/RTC.h index 4749ce38..ecafc47f 100644 --- a/libraries/RTC/src/RTC.h +++ b/libraries/RTC/src/RTC.h @@ -31,11 +31,12 @@ /*! \file RTC.h * \brief This file has to be included in projects that use Infineon's XMC RTC module */ - #ifndef _RTC_H_INCLUDED #define _RTC_H_INCLUDED #include "xmc_device.h" +#include "utility/xmc_rtc_conf.h" + //**************************************************************************** // @Board Check //**************************************************************************** @@ -43,12 +44,6 @@ #error Only XMC microcontrollers are supported by this library #endif -//**************************************************************************** -// @Project Includes -//**************************************************************************** -#include -#include "utility/xmc_rtc_conf.h" - //**************************************************************************** // @Defines //**************************************************************************** diff --git a/libraries/RTC/src/utility/xmc_rtc_conf.c b/libraries/RTC/src/utility/xmc_rtc_conf.c index c5003337..49d41b35 100644 --- a/libraries/RTC/src/utility/xmc_rtc_conf.c +++ b/libraries/RTC/src/utility/xmc_rtc_conf.c @@ -29,10 +29,10 @@ * 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. */ - +#include #include "xmc_rtc_conf.h" -#if (defined (XMC1100_XMC2GO) || (XMC1100_H_BRIDGE2GO) || (XMC1300_Sense2GoL) || (XMC1100_Boot_Kit) || (XMC1300_Boot_Kit) || (XMC4700_Relax_Kit) ) +#if defined HAS_RTC XMC_RTC_CONFIG_t XMC_RTC_default_t = { .prescaler = 0x7fffU, .time = { diff --git a/libraries/RTC/src/utility/xmc_rtc_conf.h b/libraries/RTC/src/utility/xmc_rtc_conf.h index fb885d9f..ceb24501 100644 --- a/libraries/RTC/src/utility/xmc_rtc_conf.h +++ b/libraries/RTC/src/utility/xmc_rtc_conf.h @@ -29,14 +29,12 @@ * 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 XMC_RTC_CONF_H #define XMC_RTC_CONF_H -#include #include -#if (defined (XMC1100_XMC2GO) || (XMC1100_H_BRIDGE2GO) || (XMC1300_Sense2GoL) || (XMC1100_Boot_Kit) || (XMC1300_Boot_Kit) || (XMC4700_Relax_Kit) ) +#if defined HAS_RTC extern XMC_RTC_CONFIG_t XMC_RTC_default_t; #else #error XMC Board not supported diff --git a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor/BarometricPressureSensor.ino b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor/BarometricPressureSensor.ino deleted file mode 100644 index 9c9c9b6c..00000000 --- a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor/BarometricPressureSensor.ino +++ /dev/null @@ -1,143 +0,0 @@ -/* - SCP1000 Barometric Pressure Sensor Display - - Shows the output of a Barometric Pressure Sensor on a - Uses the SPI library. For details on the sensor, see: - http://www.sparkfun.com/commerce/product_info.php?products_id=8161 - http://www.vti.fi/en/support/obsolete_products/pressure_sensors/ - - This sketch adapted from Nathan Seidle's SCP1000 example for PIC: - http://www.sparkfun.com/datasheets/Sensors/SCP1000-Testing.zip - - Circuit: - SCP1000 sensor attached to pins 6, 7, 10 - 13: - DRDY: pin 6 - CSB: pin 7 - MOSI: pin 11 - MISO: pin 12 - SCK: pin 13 - - created 31 July 2010 - modified 14 August 2010 - by Tom Igoe - */ - -// the sensor communicates using SPI, so include the library: -#include - -//Sensor's memory register addresses: -const int PRESSURE = 0x1F; //3 most significant bits of pressure -const int PRESSURE_LSB = 0x20; //16 least significant bits of pressure -const int TEMPERATURE = 0x21; //16 bit temperature reading -cont byte READ = 0b00000000; // SCP1000's read command -const byte WRITE = 0b00000010; // SCP1000's write command -// pins used for the connection with the sensor -// the other you need are controlled by the SPI library): -const int dataReadyPin = 6; -const int chipSelectPin = 7; - -void setup() { - Serial.begin(9600); - - // start the SPI library: - SPI.begin(); - - // initalize the data ready and chip select pins: - pinMode(dataReadyPin, INPUT); - pinMode(chipSelectPin, OUTPUT); - - //Configure SCP1000 for low noise configuration: - writeRegister(0x02, 0x2D); - writeRegister(0x01, 0x03); - writeRegister(0x03, 0x02); - // give the sensor time to set up: - delay(100); -} - -void loop() { - //Select High Resolution Mode - writeRegister(0x03, 0x0A); - - // don't do anything until the data ready pin is high: - if (digitalRead(dataReadyPin) == HIGH) { - //Read the temperature data - int tempData = readRegister(0x21, 2); - - // convert the temperature to celsius and display it: - float realTemp = (float)tempData / 20.0; - Serial.print("Temp[C]="); - Serial.print(realTemp); - - - //Read the pressure data highest 3 bits: - byte pressure_data_high = readRegister(0x1F, 1); - pressure_data_high &= 0b00000111; //you only needs bits 2 to 0 - - //Read the pressure data lower 16 bits: - unsigned int pressure_data_low = readRegister(0x20, 2); - //combine the two parts into one 19-bit number: - long pressure = ((pressure_data_high << 16) | pressure_data_low)/4; - - // display the temperature: - Serial.println("\tPressure [Pa]=" + String(pressure)); - } -} - -//Read from or write to register from the SCP1000: -unsigned int readRegister(byte thisRegister, int bytesToRead ) { - byte inByte = 0; // incoming byte from the SPI - unsigned int result = 0; // result to return - - // SCP1000 expects the register name in the upper 6 bits - // of the byte. So shift the bits left by two bits: - thisRegister = thisRegister << 2; - // now combine the address and the command into one byte - dataToSend = thisRegister & READ; - - // take the chip select low to select the device: - digitalWrite(chipSelectPin, LOW); - // send the device the register you want to read: - SPI.transfer(dataToSend); - // send a value of 0 to read the first byte returned: - result = SPI.transfer(0x00); - // decrement the number of bytes left to read: - bytesToRead--; - // if you still have another byte to read: - if (bytesToRead > 0) { - // shift the first byte left, then get the second byte: - result = result << 8; - inByte = SPI.transfer(0x00); - // combine the byte you just got with the previous one: - result = result | inByte; - // decrement the number of bytes left to read: - bytesToRead--; - } - // take the chip select high to de-select: - digitalWrite(chipSelectPin, HIGH); - // return the result: - return(result); -} - - -//Sends a write command to SCP1000 - -void writeRegister(byte thisRegister, byte thisValue) { - - // SCP1000 expects the register address in the upper 6 bits - // of the byte. So shift the bits left by two bits: - thisRegister = thisRegister << 2; - // now combine the register address and the command into one byte: - dataToSend = thisRegister | WRITE; - - // take the chip select low to select the device: - digitalWrite(chipSelectPin, LOW); - - SPI.transfer(dataToSend); //Send register location - SPI.transfer(thisValue); //Send value to record into register - - // take the chip select high to de-select: - digitalWrite(chipSelectPin, HIGH); -} - - - diff --git a/libraries/SPI/library.properties b/libraries/SPI/library.properties index 47194b45..4b51f77b 100644 --- a/libraries/SPI/library.properties +++ b/libraries/SPI/library.properties @@ -1,10 +1,10 @@ name=SPI -version=1.2 +version=1.3 author=Infineon Technologies AG maintainer=Infineon Technologies AG sentence=This library allows you to communicate with SPI for the XMC microcontroller series. paragraph= . category=Communication url=http://www.arduino.cc/en/Reference/SPI -architectures=arm +architectures=xmc,arm diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index b62a80bd..b20b3c17 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -164,6 +164,9 @@ class SPIClass void attachInterrupt(); void detachInterrupt(); + static void usingInterrupt(uint8_t interruptNumber){}; + static void notUsingInterrupt(uint8_t interruptNumber){}; + void begin(); void end(); diff --git a/libraries/Sense2Go/examples/configure_radar/configure_radar.ino b/libraries/Sense2Go/examples/configure_radar/configure_radar.ino index f447e010..1c1c8758 100644 --- a/libraries/Sense2Go/examples/configure_radar/configure_radar.ino +++ b/libraries/Sense2Go/examples/configure_radar/configure_radar.ino @@ -6,41 +6,43 @@ #define SPECTRUM_SIZE SENSE2GO_BUFFER_SIZE / 2 -int16_t magnitudes[SPECTRUM_SIZE]; +int16_t magnitudes[SPECTRUM_SIZE ]; bool available = false; -BGT_RADAR_CONFIG_t user_config = { +BGT_RADAR_CONFIG_t user_config = + { fft_size : 128, fft_threshold : DETECTING_MAG_THRESH, cycle_time : 100, sampling_rate : 3000 -}; + }; + // this routine shouldn't take too long -void callback(RESULT_t *result) +void callback( RESULT_t *result ) { - for (int i = 0; i < SPECTRUM_SIZE; i++) - { - magnitudes[i] = result->magnitudes[i]; - } - available = true; +for( int i = 0; i < SPECTRUM_SIZE; i++ ) + magnitudes[ i ] = result->magnitudes[ i ]; +available = true; } -void setup() + +void setup( ) { - Serial.begin(9600); - RadarDataProcessor.begin(RADAR_BGT24LTR11, callback); - RadarDataProcessor.enableFft(); - RadarDataProcessor.configureRadar(user_config); - Serial.println("Init done!"); +Serial.begin( 9600 ); +RadarDataProcessor.begin( RADAR_BGT24LTR11, callback ); +RadarDataProcessor.enableFft( ); +RadarDataProcessor.configureRadar( user_config ); +Serial.println( "Init done!" ); } -void loop() + +void loop( ) { - if (available) +if( available ) { - for (int i = 0; i < SPECTRUM_SIZE; i++) - Serial.println(magnitudes[i]); - available = false; + for( int i = 0; i < SPECTRUM_SIZE; i++ ) + Serial.println( magnitudes[ i ] ); + available = false; } } \ No newline at end of file diff --git a/libraries/Sense2Go/examples/doppler_speed/doppler_speed.ino b/libraries/Sense2Go/examples/doppler_speed/doppler_speed.ino index 2e0afb5e..e7d381ce 100644 --- a/libraries/Sense2Go/examples/doppler_speed/doppler_speed.ino +++ b/libraries/Sense2Go/examples/doppler_speed/doppler_speed.ino @@ -1,40 +1,40 @@ #include -#define SPECTRUM_SIZE SENSE2GO_BUFFER_SIZE / 2 +#define SPECTRUM_SIZE ( SENSE2GO_BUFFER_SIZE / 2 ) -int16_t magnitudes[SPECTRUM_SIZE]; +int16_t magnitudes[ SPECTRUM_SIZE ]; bool available = false; int max_mag; float speed; + // this routine shouldn't take too long -void callback(RESULT_t *result) +void callback( RESULT_t *result ) { - for (int i = 0; i < SPECTRUM_SIZE; i++) - { - magnitudes[i] = result->magnitudes[i]; - } - max_mag = result->max_magnitude; - speed = result->speed; - available = true; +for( int i = 0; i < SPECTRUM_SIZE; i++ ) + magnitudes[ i ] = result->magnitudes[ i ]; +max_mag = result->max_magnitude; +speed = result->speed; +available = true; } -void setup() + +void setup( ) { - Serial.begin(9600); - RadarDataProcessor.begin(RADAR_BGT24LTR11, callback); - RadarDataProcessor.enableFft(); - Serial.println("Init done!"); +Serial.begin( 9600 ); +RadarDataProcessor.begin( RADAR_BGT24LTR11, callback ); +RadarDataProcessor.enableFft( ); +Serial.println( "Init done!" ); } -void loop() +void loop( ) { - if (available) +if( available ) { - Serial.println(speed); + Serial.println( speed ); - // for (int i = 0; i < SPECTRUM_SIZE; i++) - // Serial.println(magnitudes[i]); - available = false; + // for ( int i = 0; i < SPECTRUM_SIZE; i++ ) + // Serial.println( magnitudes[ i ] ); + available = false; } -} \ No newline at end of file +} diff --git a/libraries/Sense2Go/examples/motion_detection/motion_detection.ino b/libraries/Sense2Go/examples/motion_detection/motion_detection.ino index ea6066fc..c5a7f788 100644 --- a/libraries/Sense2Go/examples/motion_detection/motion_detection.ino +++ b/libraries/Sense2Go/examples/motion_detection/motion_detection.ino @@ -2,32 +2,37 @@ bool available = false; int motion; + + // this routine shouldn't take too long -void callback(RESULT_t *result) +void callback( RESULT_t *result ) { - motion = result->motion; - available = true; +motion = result->motion; +available = true; } -void setup() + +void setup( ) { - Serial.begin(9600); - RadarDataProcessor.begin(RADAR_BGT24LTR11, callback); - // you can try out both versions of motion detection algorithms +Serial.begin( 9600 ); +RadarDataProcessor.begin( RADAR_BGT24LTR11, callback ); +// you can try out both versions of motion detection algorithms - // RadarDataProcessor.enableSimpleMotionDetection(); - RadarDataProcessor.enableFftMotionDetection(); - Serial.println("Init done!"); +// RadarDataProcessor.enableSimpleMotionDetection( ); +RadarDataProcessor.enableFftMotionDetection( ); +Serial.println( "Init done!" ); } -void loop() + +void loop( ) { - if (available) +if( available ) { - if (motion == APPROACHING) - Serial.println("approching"); - else if (motion == DEPARTING) - Serial.println("departing"); - available = false; + if( motion == APPROACHING ) + Serial.println( "approching" ); + else + if( motion == DEPARTING ) + Serial.println( "departing" ); + available = false; } } \ No newline at end of file diff --git a/libraries/Sense2Go/library.properties b/libraries/Sense2Go/library.properties index 59a4fd32..028a8a48 100644 --- a/libraries/Sense2Go/library.properties +++ b/libraries/Sense2Go/library.properties @@ -1,10 +1,10 @@ name=Sense2Go -version=1.0.1 +version=1.0.2 author=Infineon Technologies maintainer=Infineon Technologies sentence=Library for Radar2Go Series paragraph=Radar support for Infineon XMC1300 Sense2Go using BGT24LTR11 chip category=Sensors url=https://www.infineon.com/cms/en/product/sensor/radar-sensor-ics/24ghz-radar/ -architectures=arm +architectures=xmc,arm diff --git a/libraries/Sense2Go/src/RadarDataProcessor.cpp b/libraries/Sense2Go/src/RadarDataProcessor.cpp index 8c8d6bf4..f1f5d4da 100644 --- a/libraries/Sense2Go/src/RadarDataProcessor.cpp +++ b/libraries/Sense2Go/src/RadarDataProcessor.cpp @@ -1,323 +1,324 @@ #include #include "RadarDataProcessor.h" -RadarDataProcessorClass::RadarDataProcessorClass() -{ - _fft = FFTAnalyzer(); - _maxMagFreq = {0, 0}; - _algo = {false, false, false}; - _result.speed = 0.0; - _result.max_magnitude = 0; - _result.motion = 0; -} -RadarDataProcessorClass::~RadarDataProcessorClass() +RadarDataProcessorClass::RadarDataProcessorClass( ) { - end(); +_fft = FFTAnalyzer( ); +_maxMagFreq = { 0, 0 }; +_algo = { false, false, false }; +_result.speed = 0.0; +_result.max_magnitude = 0; +_result.motion = 0; } -bool RadarDataProcessorClass::available() + +RadarDataProcessorClass::~RadarDataProcessorClass( ) { - return _available; +end( ); } -void RadarDataProcessorClass::initHanningWindow(uint8_t windowLength) + +bool RadarDataProcessorClass::available( ) { - // w(n) = 0.5 (1-cos(2*pi*n/(N-1))), 0<=n<=(N-1) - float frac = TWO_PI / (windowLength - 1); - for (int i = 0; i < windowLength; i++) - _hanningWindow[i] = round(32767 * (1 - cos(i * frac))) >> 1; +return _available; } -void RadarDataProcessorClass::begin() + +void RadarDataProcessorClass::initHanningWindow( uint8_t windowLength ) { - // check initialization - if (!_radar) - return; +// w( n ) = 0.5 ( 1-cos( 2*pi*n/( N-1 ) ) ), 0 <= n <= ( N-1 ) +float frac = TWO_PI / ( windowLength - 1 ); +for( int i = 0; i < windowLength; i++ ) + _hanningWindow[ i ] = round( 32767 * ( 1 - cos( i * frac ) ) ) >> 1; +} - _radar->begin(); - _radarFftSize = (_radar->_config).fft_size; - if (_radarFftSize > RADAR_MAX_BUFFER_SIZE) - _radarFftSize = RADAR_MAX_BUFFER_SIZE; +void RadarDataProcessorClass::begin( ) +{ +// check initialization +if( !_radar ) + return; - _fftOrder = log2(_radarFftSize); - if (_radarFftSize <= 0) - return; +_radar->begin( ); +_radarFftSize = ( _radar->_config ).fft_size; +if( _radarFftSize > RADAR_MAX_BUFFER_SIZE ) + _radarFftSize = RADAR_MAX_BUFFER_SIZE; - initHanningWindow(_radarFftSize); - _freqWidth = (_radar->_config).sampling_rate / _radarFftSize; +_fftOrder = log2( _radarFftSize ); +if( _radarFftSize <= 0 ) + return; - // configure task to be executed periodically - _timer = addTask(RadarDataProcessorClass::samplingTask); +initHanningWindow( _radarFftSize ); +_freqWidth = ( _radar->_config ).sampling_rate / _radarFftSize; - if (_timer < 0 || _timer > NUM_TASKS_VARIANT) - { - // error: too many tasks - return; - } +// configure task to be executed periodically +_timer = addTask( RadarDataProcessorClass::samplingTask ); - setParam(_timer, _timer); - setInterval(_timer, (_radar->_config).cycle_time); - startTask(_timer); +if( _timer < 0 || _timer > NUM_TASKS_VARIANT ) + return; // error: too many tasks - _interruptTimer = addTask(RadarDataProcessorClass::algoTask); +setParam( _timer, _timer ); +setInterval( _timer, ( _radar->_config ).cycle_time ); +startTask( _timer ); +_interruptTimer = addTask( RadarDataProcessorClass::algoTask ); - // use as an interrupt - setParam(_interruptTimer, _interruptTimer); - setInterval(_interruptTimer, 1); +// use as an interrupt +setParam( _interruptTimer, _interruptTimer ); +setInterval( _interruptTimer, 1 ); } -void RadarDataProcessorClass::begin(RADAR_t radarType, void (*cb)(RESULT_t *result)) + +void RadarDataProcessorClass::begin( RADAR_t radarType, void ( *cb )( RESULT_t *result ) ) { - // set callback - if (cb) - _cb = cb; - _radarType = radarType; +// set callback +if( cb ) + _cb = cb; +_radarType = radarType; - switch (_radarType) +switch( _radarType ) { case RADAR_BGT24LTR11: - _bgt24ltr11 = BGT24LTR11(); + _bgt24ltr11 = BGT24LTR11( ); _radar = &_bgt24ltr11; break; default: // error: wrong data type return; } - begin(); +begin( ); } -void RadarDataProcessorClass::end() + +void RadarDataProcessorClass::end( ) { - deleteTask(RadarDataProcessorClass::samplingTask); - deleteTask(RadarDataProcessorClass::algoTask); +deleteTask( RadarDataProcessorClass::samplingTask ); +deleteTask( RadarDataProcessorClass::algoTask ); } -void RadarDataProcessorClass::startAcq(void) + +void RadarDataProcessorClass::startAcq( void ) { - // check if these functions are necessary for future radars - _radar->startAcq(); +// check if these functions are necessary for future radars +_radar->startAcq( ); } -void RadarDataProcessorClass::endAcq(void) + +void RadarDataProcessorClass::endAcq( void ) { - _radar->endAcq(); +_radar->endAcq( ); - // finished sampling, run the detection algorithm algoTask - startTask(_interruptTimer); +// finished sampling, run the detection algorithm algoTask +startTask( _interruptTimer ); } -void RadarDataProcessorClass::sampleInQ(void) -{ - // only need to sum up I data - _radar->sampleInQ(_result.dataI, _result.dataQ); -} -void RadarDataProcessorClass::runAlgorithm(void) +void RadarDataProcessorClass::sampleInQ( void ) { - // be sure that the time for running all the enabled algorithms plus time for ADC conversion should be shorter than cycle time - if (_algo.fft) - computeFft(); - if (_algo.detectMotionSimple) - detectMotionWithRawData(); - - // user callback - if (_cb) - { - _cb(&_result); - } +// only need to sum up I data +_radar->sampleInQ( _result.dataI, _result.dataQ ); +} - // the interrupt time must be deleted in every cycle! - deleteTask( RadarDataProcessorClass::algoTask ); - _available = true; +void RadarDataProcessorClass::runAlgorithm( void ) +{ +// be sure that the time for running all the enabled algorithms plus time for ADC conversion should be shorter than cycle time +if( _algo.fft ) + computeFft( ); +if( _algo.detectMotionSimple ) + detectMotionWithRawData( ); + +// user callback +if( _cb ) + _cb( &_result ); + +// the interrupt time must be deleted in every cycle! +deleteTask( RadarDataProcessorClass::algoTask ); +_available = true; } -int RadarDataProcessorClass::algoTask(int taskId, int16_t param) + +int RadarDataProcessorClass::algoTask( int taskId, int16_t param ) { -RadarDataProcessor.runAlgorithm(); +RadarDataProcessor.runAlgorithm( ); return 1; - } -void RadarDataProcessorClass::computeFft() + +void RadarDataProcessorClass::computeFft( ) { - // mean removal - int sum = 0; - for (int i = 0; i < _radarFftSize; i++) +// mean removal +int sum = 0; +for( int i = 0; i < _radarFftSize; i++ ) + sum += _result.dataI[ i ]; +sum = sum >> _fftOrder; + +// windowing -> move to fft analyzer +for( int i = 0; i < _radarFftSize; i++ ) + { + _result.realI[ i ] = FIX_MPY( ( _result.dataI[ i ] - sum ), _hanningWindow[ i ] ); + _result.imagI[ i ] = 0; + } +// in-place fft +_fft.fix_fft( _result.realI, _result.imagI, _fftOrder, 0 ); + +// the first half of real fft values replaced by power spectrum +_maxMagFreq = _fft.compute_magnitude( _result.realI, _result.imagI, _result.magnitudes, _radarFftSize / 2 ); +bool detected = _maxMagFreq.mag > ( _radar->_config ).fft_threshold; +if( _algo.detectMotionFft ) + { + float maxImagI = ( float ) _result.imagI[ _maxMagFreq.freq ]; + float maxRealI = ( float ) _result.realI[ _maxMagFreq.freq ]; + + for( int i = 0; i < _radarFftSize; i++ ) + { + _result.realQ[ i ] = FIX_MPY( ( _result.dataQ[ i ] - sum ), _hanningWindow[ i ] ); + _result.imagQ[ i ] = 0; + } + + // TODO: only one-point fft needed for the Q data + _fft.fix_fft( _result.realQ, _result.imagQ, _fftOrder, 0 ); + + float maxImagQ = ( float ) _result.imagQ[ _maxMagFreq.freq ]; + float maxRealQ = ( float ) _result.realQ[ _maxMagFreq.freq ]; + + // TODO use integer atan2, e.g. CORDIC version from xmc_math + if( maxRealQ && maxRealI && detected ) { - sum += _result.dataI[i]; - } - sum = sum >> _fftOrder; + float phase_shift = atan2( maxImagI, maxRealI ) - atan2( maxImagQ, maxRealQ ); + if( phase_shift < -3.14 ) + phase_shift += 6.28; + else + if( phase_shift > 3.14 ) + phase_shift -= 6.28; + + if( phase_shift > 0 ) + _result.motion = 1; + else + if( phase_shift < 0 ) + _result.motion = 0; + else + _result.motion = 2; - // windowing -> move to fft analyzer - for (int i = 0; i < _radarFftSize; i++) - { - _result.realI[i] = FIX_MPY((_result.dataI[i] - sum), _hanningWindow[i]); - _result.imagI[i] = 0; + _result.phase_shift = phase_shift; } - - // in-place fft - _fft.fix_fft(_result.realI, _result.imagI, _fftOrder, 0); - - //the first half of real fft values replaced by power spectrum - _maxMagFreq = _fft.compute_magnitude(_result.realI, _result.imagI, _result.magnitudes, _radarFftSize / 2); - bool detected = _maxMagFreq.mag > (_radar->_config).fft_threshold; - if (_algo.detectMotionFft) + else { - float maxImagI = (float) _result.imagI[_maxMagFreq.freq]; - float maxRealI = (float) _result.realI[_maxMagFreq.freq]; - - for (int i = 0; i < _radarFftSize; i++) - { - _result.realQ[i] = FIX_MPY((_result.dataQ[i] - sum), _hanningWindow[i]); - _result.imagQ[i] = 0; - } - - // TODO: only one-point fft needed for the Q data - _fft.fix_fft(_result.realQ, _result.imagQ, _fftOrder, 0); - - float maxImagQ = (float) _result.imagQ[_maxMagFreq.freq]; - float maxRealQ = (float) _result.realQ[_maxMagFreq.freq]; - - // TODO use integer atan2, e.g. CORDIC version from xmc_math - if (maxRealQ && maxRealI && detected) - { - float phase_shift = atan2(maxImagI, maxRealI) - atan2(maxImagQ, maxRealQ); - if (phase_shift < -3.14) - phase_shift += 6.28; - else if (phase_shift > 3.14) - phase_shift -= 6.28; - - if (phase_shift > 0) - _result.motion = 1; - else if (phase_shift < 0) - _result.motion = 0; - else - _result.motion = 2; - - _result.phase_shift = phase_shift; - } - else - { - _result.phase_shift = 0; - _result.motion = 2; - } + _result.phase_shift = 0; + _result.motion = 2; } + } +if( detected ) + _result.speed = ( RATIO_FREQ_TO_SPEED * _freqWidth * _maxMagFreq.freq ); +else + _result.speed = 0; - if (detected) - _result.speed = (RATIO_FREQ_TO_SPEED * _freqWidth * _maxMagFreq.freq); - else - _result.speed = 0; - _result.max_magnitude = _maxMagFreq.mag; +_result.max_magnitude = _maxMagFreq.mag; } -void RadarDataProcessorClass::detectMotionWithRawData(void) -{ - int8_t motion = 0; - - bool next_is_max = true; - - if (_result.dataI[0] > _result.dataI[1]) - { - next_is_max = false; - } - for (uint16_t i = 0; i < (_radarFftSize - 1) / 2; i++) - { - if ((_result.dataI[i] < (2048 - 200)) || - (_result.dataI[i] > (2048 + 200))) - { - if (next_is_max) - { - if (_result.dataI[i] > _result.dataI[i + 1]) - { - if (_result.dataQ[i] > _result.dataQ[i + 1]) - { - motion++; - } - else if (_result.dataQ[i] < _result.dataQ[i + 1]) - { - motion--; - } - next_is_max = false; - } - } - else - { - if (_result.dataI[i] < _result.dataI[i + 1]) - { - if (_result.dataQ[i] > _result.dataQ[i + 1]) - { - motion--; - } - else if (_result.dataQ[i] < _result.dataQ[i + 1]) - { - motion++; - } - next_is_max = true; - } - } - } - - if (motion < -2) - { - _result.motion = 1; - return; - } - else if (motion > 2) - { - _result.motion = 0; - return; - } - } - _result.motion = 2; - return; +void RadarDataProcessorClass::detectMotionWithRawData( void ) +{ +int8_t motion = 0; + +bool next_is_max = true; + +if( _result.dataI[ 0 ] > _result.dataI[ 1 ] ) + next_is_max = false; + +for( uint16_t i = 0; i < ( _radarFftSize - 1 ) / 2; i++ ) + { + if( ( _result.dataI[ i ] < ( 2048 - 200 ) ) || + ( _result.dataI[ i ] > ( 2048 + 200 ) ) ) + { + if( next_is_max ) + if( _result.dataI[ i ] > _result.dataI[ i + 1 ] ) + { + if( _result.dataQ[ i ] > _result.dataQ[ i + 1 ] ) + motion++; + else + if( _result.dataQ[ i ] < _result.dataQ[ i + 1 ] ) + motion--; + next_is_max = false; + } + else + if( _result.dataI[ i ] < _result.dataI[ i + 1 ] ) + { + if( _result.dataQ[ i ] > _result.dataQ[ i + 1 ] ) + motion--; + else + if( _result.dataQ[ i ] < _result.dataQ[ i + 1 ] ) + motion++; + next_is_max = true; + } + } + if( motion < -2 ) + { + _result.motion = 1; + return; + } + else + if( motion > 2 ) + { + _result.motion = 0; + return; + } + } +_result.motion = 2; +return; } -int RadarDataProcessorClass::samplingTask(int taskId, int16_t param) + +int RadarDataProcessorClass::samplingTask( int taskId, int16_t param ) { -RadarDataProcessor.startAcq(); -RadarDataProcessor.sampleInQ(); -RadarDataProcessor.endAcq(); +RadarDataProcessor.startAcq( ); +RadarDataProcessor.sampleInQ( ); +RadarDataProcessor.endAcq( ); return 1; } -void RadarDataProcessorClass::enableSimpleMotionDetection() + +void RadarDataProcessorClass::enableSimpleMotionDetection( ) { - _algo.detectMotionSimple = 1; - _algo.detectMotionFft = 0; +_algo.detectMotionSimple = 1; +_algo.detectMotionFft = 0; } -void RadarDataProcessorClass::enableFftMotionDetection() + +void RadarDataProcessorClass::enableFftMotionDetection( ) { - if (!_algo.fft) - _algo.fft = 1; - _algo.detectMotionFft = 1; - _algo.detectMotionSimple = 0; +if( !_algo.fft ) + _algo.fft = 1; +_algo.detectMotionFft = 1; +_algo.detectMotionSimple = 0; } -void RadarDataProcessorClass::disableMotionDetection() + +void RadarDataProcessorClass::disableMotionDetection( ) { - _algo.detectMotionSimple = 0; - _algo.detectMotionFft = 0; +_algo.detectMotionSimple = 0; +_algo.detectMotionFft = 0; } -void RadarDataProcessorClass::enableFft() + + +void RadarDataProcessorClass::enableFft( ) { - _algo.fft = 1; +_algo.fft = 1; } -void RadarDataProcessorClass::disableFft() + + +void RadarDataProcessorClass::disableFft( ) { - _algo.fft = 0; +_algo.fft = 0; } -void RadarDataProcessorClass::configureRadar(BGT_RADAR_CONFIG_t config) + +void RadarDataProcessorClass::configureRadar( BGT_RADAR_CONFIG_t config ) { - end(); - _radar->setConfig(config); - _freqWidth = config.sampling_rate / config.fft_size; - begin(); +end( ); +_radar->setConfig( config ); +_freqWidth = config.sampling_rate / config.fft_size; +begin( ); } -RadarDataProcessorClass RadarDataProcessor = RadarDataProcessorClass(); +RadarDataProcessorClass RadarDataProcessor = RadarDataProcessorClass( ); diff --git a/libraries/Sense2Go/src/RadarDataProcessor.h b/libraries/Sense2Go/src/RadarDataProcessor.h index be311c6c..64abc735 100644 --- a/libraries/Sense2Go/src/RadarDataProcessor.h +++ b/libraries/Sense2Go/src/RadarDataProcessor.h @@ -5,7 +5,7 @@ * @date 2018-07-23 * * @bug LED1 LOW/HIGH reversed on the sense2gol board - * @bug Serial print cannot be used in the callback (USIC interrupts possibly mess up Systick interrupts) + * @bug Serial print cannot be used in the callback ( USIC interrupts possibly mess up Systick interrupts ) * @bug ADC settling takes unusually long */ @@ -16,24 +16,24 @@ #include "radars/BGT24LTR11.h" #include "FixedFFTAnalyzer.h" -/** Constant for convert Doppler frequency to speed. (10 km/h)/(444.4 Hz) = 0.0225 */ +/** Constant for convert Doppler frequency to speed. ( 10 km/h )/( 444.4 Hz ) = 0.0225 */ #define RATIO_FREQ_TO_SPEED 0.0225 #define RADAR_MAX_BUFFER_SIZE 256 typedef struct -{ + { // two versions of motion detection are implemented bool detectMotionSimple; bool detectMotionFft; bool fft; -} ALGORITHM_t; + } ALGORITHM_t; typedef enum -{ + { APPROACHING = 0, DEPARTING = 1, NO_MOTION = 2 -} MOTION_t; + } MOTION_t; /** @@ -41,35 +41,35 @@ typedef enum * */ typedef struct -{ - int16_t dataI[RADAR_MAX_BUFFER_SIZE]; - int16_t dataQ[RADAR_MAX_BUFFER_SIZE]; + { + int16_t dataI[ RADAR_MAX_BUFFER_SIZE ]; + int16_t dataQ[ RADAR_MAX_BUFFER_SIZE ]; /** real parts of I data's FFT spectrum*/ - int16_t realI[RADAR_MAX_BUFFER_SIZE]; + int16_t realI[ RADAR_MAX_BUFFER_SIZE ]; /** imaginary parts of I data's FFT spectrum*/ - int16_t imagI[RADAR_MAX_BUFFER_SIZE]; - int16_t realQ[RADAR_MAX_BUFFER_SIZE]; - int16_t imagQ[RADAR_MAX_BUFFER_SIZE]; + int16_t imagI[ RADAR_MAX_BUFFER_SIZE ]; + int16_t realQ[ RADAR_MAX_BUFFER_SIZE ]; + int16_t imagQ[ RADAR_MAX_BUFFER_SIZE ]; /** power spectrum*/ - int16_t magnitudes[RADAR_MAX_BUFFER_SIZE]; + int16_t magnitudes[ RADAR_MAX_BUFFER_SIZE ]; float speed; float phase_shift; int max_magnitude; int motion; -} RESULT_t; + } RESULT_t; /** * @enum Radar types * */ typedef enum -{ + { /** Sense2GoL*/ RADAR_BGT24LTR11 = 0, /** Distance2Go*/ RADAR_BGT24MTR11 = 1 // add more types here -} RADAR_t; + } RADAR_t; class RadarDataProcessorClass { @@ -83,26 +83,19 @@ class RadarDataProcessorClass // TODO: pre-define all classes, BGT24MTR11 etc. BGT24LTR11 _bgt24ltr11; BGTRadar *_radar; - RADAR_t _radarType; - ALGORITHM_t _algo; - RESULT_t _result; - FFTAnalyzer _fft; - int _fftOrder; - int _radarFftSize; - float _freqWidth; /** * @brief Hanning window for pre-FFT processing * */ - int16_t _hanningWindow[RADAR_MAX_BUFFER_SIZE]; + int16_t _hanningWindow[ RADAR_MAX_BUFFER_SIZE ]; int _timer; @@ -112,48 +105,40 @@ class RadarDataProcessorClass */ MAX_MAG_FRQ_t _maxMagFreq; - void (*_cb)(RESULT_t *result); - - void startAcq(void); - - void endAcq(void); - - void sampleInQ(void); - - void initHanningWindow(uint8_t); + void ( *_cb )( RESULT_t *result ); + void startAcq( void ); + void endAcq( void ); + void sampleInQ( void ); + void initHanningWindow( uint8_t ); /** - * @brief Sampling task that runs every cycle time (defined in radar child classes) + * @brief Sampling task that runs every cycle time ( defined in radar child classes ) * */ - static int samplingTask(int, int16_t); + static int samplingTask( int, int16_t ); - void runAlgorithm(void); + void runAlgorithm( void ); /** * @brief Task to execute algorithms on the sampled data, runs once after every sampling task is finished. * */ - static int algoTask(int, int16_t); + static int algoTask( int, int16_t ); /** * @brief This algorithm works by comparing the phase shifts of I and Q data * */ - void detectMotionWithRawData(void); + void detectMotionWithRawData( void ); - void computeFft(); - - void begin(); + void computeFft( ); + void begin( ); public: bool _available; - - RadarDataProcessorClass(); - - ~RadarDataProcessorClass(); - - bool available(); + RadarDataProcessorClass( ); + ~RadarDataProcessorClass( ); + bool available( ); /** * @brief Turns on the radar chip and starts sampling @@ -161,26 +146,25 @@ class RadarDataProcessorClass * @param radarType Type of the radar, e.g., RADAR_BGT24LTR11. * @param cb Callback function whose argument is the pointer to the computation results */ - void begin(RADAR_t radarType, void (*cb)(RESULT_t *result) = nullptr); + void begin( RADAR_t radarType, void ( *cb )( RESULT_t *result ) = nullptr ); /** * @brief Stops the radar. Needs to be called before reconfigure radar parameters. * */ - void end(); + void end( ); /** * @brief Enables the motion detection algorithm, which is called in runAlgorithm * */ - void enableSimpleMotionDetection(); - void enableFftMotionDetection(); - void disableMotionDetection(); - void enableFft(); - void disableFft(); - void configureRadar(BGT_RADAR_CONFIG_t config); + void enableSimpleMotionDetection( ); + void enableFftMotionDetection( ); + void disableMotionDetection( ); + void enableFft( ); + void disableFft( ); + void configureRadar( BGT_RADAR_CONFIG_t config ); }; extern RadarDataProcessorClass RadarDataProcessor; - #endif \ No newline at end of file diff --git a/libraries/Sense2Go/src/radars/BGT24LTR11.cpp b/libraries/Sense2Go/src/radars/BGT24LTR11.cpp index 5dd7b02e..0d6c081e 100644 --- a/libraries/Sense2Go/src/radars/BGT24LTR11.cpp +++ b/libraries/Sense2Go/src/radars/BGT24LTR11.cpp @@ -1,56 +1,62 @@ #include #include "BGT24LTR11.h" -BGT_RADAR_CONFIG_t BGT24LTR11::default_config = {fft_size : SENSE2GO_BUFFER_SIZE, +BGT_RADAR_CONFIG_t BGT24LTR11::default_config = { fft_size : SENSE2GO_BUFFER_SIZE, fft_threshold : SENSE2GO_MAG_THRESH, cycle_time : SENSE2GO_CYCLE_TIME, sampling_rate : SENSE2GO_SAMPLING_RATE, - settle_time : SENSE2GO_SETTLE_TIME}; + settle_time : SENSE2GO_SETTLE_TIME }; -BGT24LTR11::BGT24LTR11(BGT_RADAR_CONFIG_t radarConfig) + +BGT24LTR11::BGT24LTR11( BGT_RADAR_CONFIG_t radarConfig ) { - _config = radarConfig; +_config = radarConfig; - // sampling time (us) needs to be computed from sampling rate. - _samplingTime = int(1000000 / _config.sampling_rate); +// sampling time ( us ) needs to be computed from sampling rate. +_samplingTime = int( 1000000 / _config.sampling_rate ); } -BGT24LTR11::~BGT24LTR11() + +BGT24LTR11::~BGT24LTR11( ) { } -void BGT24LTR11::begin() + +void BGT24LTR11::begin( ) { - // turn on radar +// turn on radar #ifdef XMC1300_Sense2GoL - pinMode(SENSE2GO_ON_PIN, OUTPUT); - digitalWrite(SENSE2GO_ON_PIN, LOW); +pinMode( SENSE2GO_ON_PIN, OUTPUT ); +digitalWrite( SENSE2GO_ON_PIN, LOW ); #endif - analogReadResolution(12u); +analogReadResolution( 12u ); } -void BGT24LTR11::startAcq(void) + +void BGT24LTR11::startAcq( void ) { #ifdef XMC1300_Sense2GoL - digitalWrite(SENSE2GO_ON_PIN, LOW); - // timing of this delay reveals that the actual delay is much less than specified - delayMicroseconds(SENSE2GO_SETTLE_TIME); +digitalWrite( SENSE2GO_ON_PIN, LOW ); +// timing of this delay reveals that the actual delay is much less than specified +delayMicroseconds( SENSE2GO_SETTLE_TIME ); #endif } -void BGT24LTR11::endAcq(void) + +void BGT24LTR11::endAcq( void ) { #ifdef XMC1300_Sense2GoL - digitalWrite(SENSE2GO_ON_PIN, HIGH); +digitalWrite( SENSE2GO_ON_PIN, HIGH ); #endif } -void BGT24LTR11::sampleInQ(int16_t *bufferI, int16_t *bufferQ) + +void BGT24LTR11::sampleInQ( int16_t *bufferI, int16_t *bufferQ ) { - for (uint16_t i = 0; i < _config.fft_size; i++) - { - bufferI[i] = analogRead(CH_I); - bufferQ[i] = analogRead(CH_Q); - delayMicroseconds(_samplingTime); - } +for( uint16_t i = 0; i < _config.fft_size; i++ ) + { + bufferI[i] = analogRead( CH_I ); + bufferQ[i] = analogRead( CH_Q ); + delayMicroseconds( _samplingTime ); + } } \ No newline at end of file diff --git a/libraries/Sense2Go/src/radars/BGT24LTR11.h b/libraries/Sense2Go/src/radars/BGT24LTR11.h index 778c2b74..ed1e1fd1 100644 --- a/libraries/Sense2Go/src/radars/BGT24LTR11.h +++ b/libraries/Sense2Go/src/radars/BGT24LTR11.h @@ -1,5 +1,3 @@ -/** @file */ - #ifndef BGT24LTR11_H #define BGT24LTR11_H #include "BGTRadar.h" @@ -10,7 +8,7 @@ #ifdef XMC1300_Sense2GoL /** The pin to turn on the radar chip. This is used when you are using the original Sense2GoL board */ -#define SENSE2GO_ON_PIN BGT_ON +#define SENSE2GO_ON_PIN BGT_ON #endif #define SENSE2GO_BUFFER_SIZE 128 @@ -21,7 +19,7 @@ #define SENSE2GO_SAMPLING_RATE 1408 /** Time (us) for the ADC of one single sample; e.g: f_adc = 1.408kHz -> 1/f_adc = 710 us, with a buffer size of 128: 710*128 = 90880 us = 90.88 ms */ -#define SENSE2GO_SAMPLING_TIME int(1000000 / SENSE2GO_SAMPLING_RATE) +#define SENSE2GO_SAMPLING_TIME int( 1000000 / SENSE2GO_SAMPLING_RATE ) /** A delay is needed for the chip to settle after being turned on. You might turn on/off the chip only for a fraction of the duty cycle in order to save energy, in which case you need to make sure that * this constant, as well as the cycle time, is set appropriately (from my experiments it should be around 200 ms, then the cycle time should be more than 300 ms). This has no effect if the chip is left on all time. */ @@ -30,19 +28,15 @@ #define SENSE2GO_MAG_THRESH 100 class BGT24LTR11 : public BGTRadar -{ - static BGT_RADAR_CONFIG_t default_config; + { + static BGT_RADAR_CONFIG_t default_config; public: - BGT24LTR11(BGT_RADAR_CONFIG_t radarConfig = default_config); - ~BGT24LTR11(); - void begin(); - - void startAcq(void); - - void endAcq(void); - - void sampleInQ(int16_t *bufferI, int16_t *bufferQ); -}; - + BGT24LTR11( BGT_RADAR_CONFIG_t radarConfig = default_config ); + ~BGT24LTR11( ); + void begin( ); + void startAcq( ); + void endAcq( ); + void sampleInQ( int16_t *bufferI, int16_t *bufferQ ); + }; #endif \ No newline at end of file diff --git a/libraries/Sense2Go/src/radars/BGTRadar.cpp b/libraries/Sense2Go/src/radars/BGTRadar.cpp index 8f5b2796..b3b7f8ac 100644 --- a/libraries/Sense2Go/src/radars/BGTRadar.cpp +++ b/libraries/Sense2Go/src/radars/BGTRadar.cpp @@ -1,23 +1,31 @@ #include #include "BGTRadar.h" -BGTRadar::BGTRadar() + +BGTRadar::BGTRadar( ) { } -BGTRadar::~BGTRadar() + +BGTRadar::~BGTRadar( ) { } + // turn on -void BGTRadar::startAcq(void) {} +void BGTRadar::startAcq( ) +{ +} -// turn off -void BGTRadar::endAcq(void) {} -void BGTRadar::setConfig(BGT_RADAR_CONFIG_t config) +// turn off +void BGTRadar::endAcq( ) { - _config = config; +} + - _samplingTime = int(1000000 / _config.sampling_rate); -} \ No newline at end of file +void BGTRadar::setConfig( BGT_RADAR_CONFIG_t config ) +{ +_config = config; +_samplingTime = int( 1000000 / _config.sampling_rate ); +} diff --git a/libraries/Sense2Go/src/radars/BGTRadar.h b/libraries/Sense2Go/src/radars/BGTRadar.h index 3bc9a2af..1b8784b7 100644 --- a/libraries/Sense2Go/src/radars/BGTRadar.h +++ b/libraries/Sense2Go/src/radars/BGTRadar.h @@ -3,42 +3,36 @@ /** Radar configuration. Default values should be defined by child classes of BGTRadar.*/ typedef struct -{ - int fft_size; - /** threshold of the FFT spectrum for motion detection */ - int fft_threshold; - /** one cycle includes ADC sampling, running algorithms, user code, and some idle time*/ - int cycle_time; - /** Rate of ADC sampling*/ - int sampling_rate; - /** Time needed for the radar chip to settle after being turned on*/ - int settle_time; -} BGT_RADAR_CONFIG_t; + { + int fft_size; + /** threshold of the FFT spectrum for motion detection */ + int fft_threshold; + /** one cycle includes ADC sampling, running algorithms, user code, and some idle time*/ + int cycle_time; + /** Rate of ADC sampling*/ + int sampling_rate; + /** Time needed for the radar chip to settle after being turned on*/ + int settle_time; + } BGT_RADAR_CONFIG_t; class RadarDataProcessorClass; /** @class BGTRadar Base class for different types of radars */ class BGTRadar -{ + { public: - BGTRadar(); - ~BGTRadar(); - virtual void begin() = 0; - - virtual void startAcq(void) = 0; - - virtual void endAcq(void) = 0; - - virtual void sampleInQ(int16_t *bufferI, int16_t *bufferQ) = 0; - + BGTRadar( ); + ~BGTRadar( ); + virtual void begin( ) = 0; + virtual void startAcq( ) = 0; + virtual void endAcq( ) = 0; + virtual void sampleInQ( int16_t *bufferI, int16_t *bufferQ ) = 0; // TODO: set algorithm parameters - void setConfig(BGT_RADAR_CONFIG_t config); + void setConfig( BGT_RADAR_CONFIG_t config ); protected: friend class RadarDataProcessorClass; - - BGT_RADAR_CONFIG_t _config{}; - + BGT_RADAR_CONFIG_t _config{ }; int _samplingTime; -}; -#endif \ No newline at end of file + }; +#endif diff --git a/libraries/USB/library.properties b/libraries/USB/library.properties index 3ff1ad84..2898edbb 100644 --- a/libraries/USB/library.properties +++ b/libraries/USB/library.properties @@ -6,5 +6,5 @@ paragraph= category=Device Control url=http://www.arduino.cc/en/Reference/USBHost maintainer=Infineon Technologies AG -architectures=arm +architectures=xmc,arm diff --git a/libraries/Ultrasonic/library.properties b/libraries/Ultrasonic/library.properties index 8b5eaf5a..a33db9bf 100644 --- a/libraries/Ultrasonic/library.properties +++ b/libraries/Ultrasonic/library.properties @@ -6,5 +6,5 @@ sentence=Add examples for Ultrasonic range finder HC-SR04 on XMC boards paragraph=Simple and better echo examples and handling of errors on XMC1 and XMC4 series boards category=Other url=https://github.com/Infineon/XMC-for-Arduino/tree/master/arm/libraries/Ultrasonic -architectures=arm +architectures=xmc,arm diff --git a/libraries/Wire/library.properties b/libraries/Wire/library.properties index 090b0e63..e8c66af3 100644 --- a/libraries/Wire/library.properties +++ b/libraries/Wire/library.properties @@ -6,5 +6,5 @@ sentence=This library allows you to communicate with I2C and Two Wire Interface paragraph=It allows the communication with I2C devices like temperature sensors, realtime clocks and many others using SDA (Data Line) and SCL (Clock Line) in combination with the XMC microcontrollers. category=Communication url=http://www.arduino.cc/en/Reference/Wire -architectures=arm +architectures=xmc,arm diff --git a/package.json b/package.json index c0455c5f..89405e99 100644 --- a/package.json +++ b/package.json @@ -2,5 +2,5 @@ "name": "framework-arduinoxmc", "description": "Integration of Infineon's XMC microcontrollers with the Arduino framework", "url": "https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/", - "version": "1.5.0" + "version": "1.6.0" } diff --git a/platform.txt b/platform.txt index 740463fd..2cbb830b 100644 --- a/platform.txt +++ b/platform.txt @@ -1,12 +1,12 @@ # XMC platform # ------------------------------ # For more info: -# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification +# https://arduino.github.io/arduino-cli/platform-specification/ # The information about this Arduino compatible environment # --------- name=XMC Family -version=1.5.0 +version=1.6.0 # Build related core definitions # --------- diff --git a/tests/PCLKTest/PCLKTest.ino b/tests/PCLKTest/PCLKTest.ino new file mode 100644 index 00000000..aa8aff9f --- /dev/null +++ b/tests/PCLKTest/PCLKTest.ino @@ -0,0 +1,76 @@ +/* PCLK temp variation observations + +Sets PWM Output to 10 kHz 50% PWM to measure accuracy +Reads out Die temp every 10 seconds + +If both LED1 and LED2 are permanently ON then an invalid pin for PWM has been +attempted to be attached to a invalid pin + +Wiring + Default PWM pin are 3 + + Some Board variant PWM Pins + XMC1100 Boot Kit 3, 4, 6, 9 + XMC1100 XMC2Go 8, 3, 2, 1 + XMC1300 Boot Kit 31, 26, 32, 33 + XMC4700 Relax 3, 10, 11, 95, 72, 96, 63, 36, 78, 90, 91, + 5, 6, 9, 53, 39, 64, 38, 68, 79, 83, 82, 81 + */ +#include +#include + +// For library macro printing +#define str(x) Serial.println( #x ) +#define str1(x) str(x) + +// Adjust the following defines to match your setup +// Pins for Servos and pot +//#define PWM_A_PIN 3 +// XMC1300 Boot Kit pins +#define PWM_A_PIN 31 + +#define RESOLUTION 16 +#define REFRESH_FREQUENCY 10000 +#define DUTY_50 32767 + +LED Led; /* Create an LED object */ +XMCClass devCtrl; + +int32_t temperature; + + +void setup( ) +{ +Led.Add( LED1 ); // Configure the LEDs +Led.Add( LED2 ); +Led.Off( LED1 ); // Set default state of LEDs +Led.Off( LED2 ); +Serial.begin( 115200 ); +delay( 100 ); +Serial.println( "XMC PCLK Temp test" ); +Serial.print( "Running on " ); +str1( XMC_BOARD ); +// dummy read to ensure first value which may be erroneous is ignored +temperature = devCtrl.getTemperature(); + +// Setup the PWM pins +analogWriteResolution( RESOLUTION ); +if( setAnalogWriteFrequency( PWM_A_PIN, REFRESH_FREQUENCY ) < 0 ) + { // Invalid pin trap for non-PWM pin + Led.On( LED1 ); + Led.On( LED2 ); + while( 1 ); // Stick in error loop + } +analogWrite( PWM_A_PIN, DUTY_50 ); // Duty for mid (1500) = 4915 +} + + +void loop( ) +{ +/* If UC_FAMILY = XMC4 you can also calibrate temperature for finer measurements */ +temperature = devCtrl.getTemperature(); + +Serial.print( "Die Temp:\t" ); +Serial.println( temperature ); +delay( 10000 ); +} diff --git a/tests/PWMtest/PWMtest.ino b/tests/PWMtest/PWMtest.ino new file mode 100644 index 00000000..65a5d464 --- /dev/null +++ b/tests/PWMtest/PWMtest.ino @@ -0,0 +1,69 @@ +/* PWM test (Duty) + Controlling TWO PWM positions using Fixed values + Copyright (c) 2020 Paul Carpenter - PC Services. All right reserved. + + Drive two PWMs for measurement purposes at fixed values + + If both LED1 and LED2 are permanently ON then an invalid pin for PWM has been + attempted to be attached to a invalid pin + + Wiring + Default PWM pins are 3 and 4 + + Some Board variant PWM Pins + XMC1100 Boot Kit 3, 4, 6, 9 + XMC1100 XMC2Go 8, 3, 2, 1 + XMC1300 Boot Kit 31, 26, 32, 33 + XMC4700 Relax 3, 10, 11, 95, 72, 96, 63, 36, 78, 90, 91, + 5, 6, 9, 53, 39, 64, 38, 68, 79, 83, 82, 81 + */ +#include + +// Adjust the following defines to match your setup +// Pins for Servos and pot +//#define PWM_A_PIN 3 +//#define PWM_B_PIN 4 +// XMC1300 Boot Kit pins +#define PWM_A_PIN 31 +#define PWM_B_PIN 26 + +#define RESOLUTION 16 +#define REFRESH_FREQUENCY 50 + + +LED Led; /* Create an LED object */ + +int val; + + +void setup( ) +{ +Led.Add( LED1 ); // Configure the LEDs +Led.Add( LED2 ); +Led.Off( LED1 ); // Set default state of LEDs +Led.Off( LED2 ); + +// Setup the PWM pins to the servo objects +analogWriteResolution( RESOLUTION ); +val = 0; +if( setAnalogWriteFrequency( PWM_A_PIN, REFRESH_FREQUENCY ) < 0 ) + val++; +else + if( setAnalogWriteFrequency( PWM_B_PIN, REFRESH_FREQUENCY ) < 0 ) + val++; + +if( val ) // Invalid pin trap for non-PWM pin + { + Led.On( LED1 ); + Led.On( LED2 ); + while( 1 ); // Stick in error loop + } + +analogWrite( PWM_A_PIN, 4915 ); // Duty for mid (1500) = 4915 +analogWrite( PWM_B_PIN, 1782 ); // Duty for Min (544) = 1782 +} + + +void loop( ) +{ +// Do nothing loop} diff --git a/tests/Servotest/Servotest.ino b/tests/Servotest/Servotest.ino new file mode 100644 index 00000000..e892af3a --- /dev/null +++ b/tests/Servotest/Servotest.ino @@ -0,0 +1,95 @@ +/* Knob to 2 channels RC Servo (time) Demo - XMC_Servo + Controlling TWO servo positions using a potentiometer (variable resistor) + Copyright (c) 2020 Paul Carpenter - PC Services. All right reserved. + + Repeat at 10 Hz (10 times a second) + One pot is read, and two Servos controlled anti-phase by time control + ServoA is driven direct value mapped from pot 600-2400 + ServoB is driven as reversed angle 2400-600 + PWM output will continue between updates + + LED1 the Built-in LED is used when Pot is at centre position (1490-1510 microseconds) The LED + is turned ON. + + If both LED1 and LED2 are permanently ON then an invalid pin for PWM has been + attempted to be attached to a Servo class + + Wiring + Pot is connected to analogue input A1 + (XMC1300 Boot Kit has on-board pot on this pin) + Default PWM pins are 3 and 4 + + Some Board variant PWM Pins + XMC1100 Boot Kit 3, 4, 6, 9 + XMC1100 XMC2Go 8, 3, 2, 1 + XMC1300 Boot Kit 31, 26, 32, 33 + XMC4700 Relax 3, 10, 11, 95, 72, 96, 63, 36, 78, 90, 91, + 5, 6, 9, 53, 39, 64, 38, 68, 79, 83, 82, 81 + */ +#include +#include + +// Adjust the following defines to match your setup +// Pins for Servos and pot +//#define SERVO_A_PIN 3 +//#define SERVO_B_PIN 4 +#define SERVO_A_PIN 31 +#define SERVO_B_PIN 26 +#define POT_PIN A1 + +#define MIN_TIME 600 +#define MAX_TIME 2400 + +Servo ServoA; +Servo ServoB; + +/* Create an LED object */ +LED Led; + +int val; // the analogue pin value + + +void setup( ) +{ +Led.Add( LED1 ); // Configure the LEDs +Led.Off( LED1 ); // Set default state of LEDs +Led.Add( LED2 ); +Led.Off( LED2 ); + +// attaches the PWM pins to the servo objects +val = 0; +if( (ServoA.attach( SERVO_A_PIN ) ) == INVALID_SERVO ) + val++; +else + if( (ServoB.attach( SERVO_B_PIN ) ) == INVALID_SERVO ) + val++; + +if( val ) // Invalid pin trap + { + Led.On( LED1 ); + Led.On( LED2 ); + while( 1 ); // Stick in error loop + } +ServoA.writeMicroseconds( 1500 ); +ServoB.writeMicroseconds( 1500 ); +} + + +void loop( ) +{ +val = analogRead( POT_PIN ); // reads potentiometer (value 0 - 1023) +val = map( val, 0, getAnalogReadMaximum(), MIN_TIME, MAX_TIME ); // scale to time us + +if( val >= 1490 && val <= 1510 ) // When 1490 to 1510 microseconds light LED + { + Led.On( LED1 ); + val = 1500; + } +else + Led.Off( LED1 ); + +//ServoA.writeMicroseconds( val ); // sets servo position to scaled value +//ServoB.writeMicroseconds( MAX_TIME - val + MIN_TIME );// sets servo position to Reversed scaled value + +delay( 100 ); +} diff --git a/tests/testdefines/testdefines.ino b/tests/testdefines/testdefines.ino index e584a88c..c56d9dbc 100644 --- a/tests/testdefines/testdefines.ino +++ b/tests/testdefines/testdefines.ino @@ -1,6 +1,7 @@ /* Example of how to access XMC defines and use for debug * * Updated 8-Feb-2020 Paul Carpenter + * Updated 1-Jul-2020 Paul Carpenter - Prepare architecture change to xmc */ // Linker symbols to get flash/RAM usage #if( UC_FAMILY == XMC1 ) @@ -56,10 +57,16 @@ str1( F_CPU ); str2( ARDUINO ); Serial.print( "\t\t" ); str1( ARDUINO ); +#if defined ARDUINO_ARCH_ARM str2( ARDUINO_ARCH_ARM ); Serial.write( ' ' ); str1( ARDUINO_ARCH_ARM ); - +#endif +#if defined ARDUINO_ARCH_XMC +str2( ARDUINO_ARCH_XMC ); +Serial.write( ' ' ); +str1( ARDUINO_ARCH_XMC ); +#endif Serial.print( "Library Version\t" ); Serial.print( XMC_LIB_MAJOR_VERSION ); Serial.print( '.' ); diff --git a/variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h b/variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h index 5fc0881b..348033e6 100644 --- a/variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h +++ b/variants/XMC1100/config/XMC1100_Boot_Kit/pins_arduino.h @@ -115,40 +115,40 @@ const uint8_t mapping_pin_PWM4[][ 2 ] = { { 255, 255 } }; const XMC_PORT_PIN_t mapping_port_pin[] = -{ - /* 0 */ {XMC_GPIO_PORT1, 2}, // RX / LED 3 output P1.2 - /* 1 */ {XMC_GPIO_PORT1 , 3}, // TX / LED 4 output P1.3 - /* 2 */ {XMC_GPIO_PORT1 , 4}, // External int 0 / LED 5 output P1.4 - /* 3 */ {XMC_GPIO_PORT0 , 0}, // External int 1 / PWM40-0 output P0.0 - /* 4 */ {XMC_GPIO_PORT0 , 1}, // PWM40-1 output P0.1 - /* 5 */ {XMC_GPIO_PORT0 , 2}, // GPIO P0.2 - /* 6 */ {XMC_GPIO_PORT0 , 3}, // PWM40-3 output P0.3 - /* 7 */ {XMC_GPIO_PORT0 , 4}, // GPIO P0.4 - /* 8 */ {XMC_GPIO_PORT0 , 12},// GPIO P0.12 - /* 9 */ {XMC_GPIO_PORT0 , 8}, // PWM40-2 output P0.8 - /* 10 */ {XMC_GPIO_PORT0 , 9}, // SPI-SS P0.9 - /* 11 */ {XMC_GPIO_PORT1 , 1}, // SPI-MOSI P1.1 - /* 12 */ {XMC_GPIO_PORT1 , 0}, // SPI-MISO P1.0 - /* 13 */ {XMC_GPIO_PORT0 , 7}, // SPI-SCK / LED BUILTIN output P0.7 - /* 14 */ {XMC_GPIO_PORT2 , 3}, // AREF P2.3 (INPUT ONLY) - /* 15 */ {XMC_GPIO_PORT2 , 1}, // I2C Data / Address SDA / A7 ADC P2.1 - /* 16 */ {XMC_GPIO_PORT2 , 0}, // I2C Clock SCL / A6 ADC P2.0 - /* 17 */ {XMC_GPIO_PORT2 , 6}, // A0 / ADC Input P2.6 (INPUT ONLY) - /* 18 */ {XMC_GPIO_PORT2 , 8}, // A1 / ADC Input P2.8 (INPUT ONLY) - /* 19 */ {XMC_GPIO_PORT2 , 9}, // A2 / ADC Input P2.9 (INPUT ONLY) - /* 20 */ {XMC_GPIO_PORT2 , 10},// A3 / ADC Input P2.10 - /* 21 */ {XMC_GPIO_PORT2 , 11},// A4 / ADC Input P2.11 - /* 22 */ {XMC_GPIO_PORT2 , 2}, // A5 / ADC Input P2.2 (INPUT ONLY) - /* 23 */ {XMC_GPIO_PORT2 , 4}, // RESET input ( DO NOT USE as GPIO ) P2.4 (INPUT ONLY) - /* 24 */ {XMC_GPIO_PORT2 , 5}, // AD_AUX P2.5 (INPUT ONLY) - /* 25 */ {XMC_GPIO_PORT2 , 7}, // AD_AUX P2.7 (INPUT ONLY) - /* 26 */ {XMC_GPIO_PORT0 , 5}, // AUX / GPIO / LED 1 output P0.5 - /* 27 */ {XMC_GPIO_PORT0 , 6}, // AUX / GPIO / LED 2 output P0.6 - /* 28 */ {XMC_GPIO_PORT0 , 10},// AUX / GPIO P0.10 - /* 29 */ {XMC_GPIO_PORT0 , 11},// AUX / GPIO P0.11 - /* 30 */ {XMC_GPIO_PORT0 , 13},// AUX / GPIO P0.13 - /* 31 */ {XMC_GPIO_PORT1 , 5} // LED 6 output P1.5 -}; + { + /* 0 */ {XMC_GPIO_PORT1, 2}, // RX / LED 3 output P1.2 + /* 1 */ {XMC_GPIO_PORT1, 3}, // TX / LED 4 output P1.3 + /* 2 */ {XMC_GPIO_PORT1, 4}, // External int 0 / LED 5 output P1.4 + /* 3 */ {XMC_GPIO_PORT0, 0}, // External int 1 / PWM40-0 output P0.0 + /* 4 */ {XMC_GPIO_PORT0, 1}, // PWM40-1 output P0.1 + /* 5 */ {XMC_GPIO_PORT0, 2}, // GPIO P0.2 + /* 6 */ {XMC_GPIO_PORT0, 3}, // PWM40-3 output P0.3 + /* 7 */ {XMC_GPIO_PORT0, 4}, // GPIO P0.4 + /* 8 */ {XMC_GPIO_PORT0, 12},// GPIO P0.12 + /* 9 */ {XMC_GPIO_PORT0, 8}, // PWM40-2 output P0.8 + /* 10 */ {XMC_GPIO_PORT0, 9}, // SPI-SS P0.9 + /* 11 */ {XMC_GPIO_PORT1, 1}, // SPI-MOSI P1.1 + /* 12 */ {XMC_GPIO_PORT1, 0}, // SPI-MISO P1.0 + /* 13 */ {XMC_GPIO_PORT0, 7}, // SPI-SCK / LED BUILTIN output P0.7 + /* 14 */ {XMC_GPIO_PORT2, 3}, // AREF ** DO NOT USE as GPIO or REF ** P2.3 + /* 15 */ {XMC_GPIO_PORT2, 1}, // I2C Data / Address SDA / A7 ADC P2.1 + /* 16 */ {XMC_GPIO_PORT2, 0}, // I2C Clock SCL / A6 ADC P2.0 + /* 17 */ {XMC_GPIO_PORT2, 6}, // A0 / ADC Input P2.6 (INPUT ONLY) + /* 18 */ {XMC_GPIO_PORT2, 8}, // A1 / ADC Input P2.8 (INPUT ONLY) + /* 19 */ {XMC_GPIO_PORT2, 9}, // A2 / ADC Input P2.9 (INPUT ONLY) + /* 20 */ {XMC_GPIO_PORT2, 10},// A3 / ADC Input P2.10 + /* 21 */ {XMC_GPIO_PORT2, 11},// A4 / ADC Input P2.11 + /* 22 */ {XMC_GPIO_PORT2, 2}, // A5 / ADC Input P2.2 (INPUT ONLY) + /* 23 */ {XMC_GPIO_PORT2, 4}, // RESET input ( DO NOT USE as GPIO ) P2.4 (INPUT ONLY) + /* 24 */ {XMC_GPIO_PORT2, 5}, // AD_AUX P2.5 (INPUT ONLY) + /* 25 */ {XMC_GPIO_PORT2, 7}, // AD_AUX P2.7 (INPUT ONLY) + /* 26 */ {XMC_GPIO_PORT0, 5}, // AUX / GPIO / LED 1 output P0.5 + /* 27 */ {XMC_GPIO_PORT0, 6}, // AUX / GPIO / LED 2 output P0.6 + /* 28 */ {XMC_GPIO_PORT0, 10},// AUX / GPIO P0.10 + /* 29 */ {XMC_GPIO_PORT0, 11},// AUX / GPIO P0.11 + /* 30 */ {XMC_GPIO_PORT0, 13},// AUX / GPIO P0.13 + /* 31 */ {XMC_GPIO_PORT1, 5} // LED 6 output P1.5 + }; const XMC_PIN_INTERRUPT_t mapping_interrupt[] = { @@ -211,7 +211,7 @@ XMC_UART_t XMC_UART_0 = #ifdef SERIAL_DEBUG .input_source_dx0 = (XMC_USIC_INPUT_t)USIC0_C1_DX0_P1_3, #else - .input_source_dx0 = (XMC_USIC_INPUT_t)USIC0_C0_DX0_P1_2, + .input_source_dx0 = (XMC_USIC_INPUT_t)USIC0_C1_DX0_P1_2, #endif .input_source_dx1 = XMC_INPUT_INVALID, .input_source_dx2 = XMC_INPUT_INVALID, diff --git a/variants/XMC1300/config/XMC1300_Sense2GoL/pins_arduino.h b/variants/XMC1300/config/XMC1300_Sense2GoL/pins_arduino.h index b70427e0..73e8a37b 100644 --- a/variants/XMC1300/config/XMC1300_Sense2GoL/pins_arduino.h +++ b/variants/XMC1300/config/XMC1300_Sense2GoL/pins_arduino.h @@ -18,7 +18,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - + Copyright (c) 2018 Infineon Technologies AG This file has been modified for the XMC microcontroller series. */ @@ -33,17 +33,17 @@ // @Defines //**************************************************************************** // XMC_BOARD for stringifying into serial or other text outputs/logs -// Note the actual name XMC and number MUST have a character between +// Note the actual name XMC and number MUST have a character between // to avoid issues with other defined macros e.g. XMC1100 #define XMC_BOARD XMC 1300 Sense2GoL /* On board LED is ON when digital output is 0, LOW, False, OFF */ #define XMC_LED_ON 0 -#define NUM_ANALOG_INPUTS 2 -#define NUM_PWM 4 -#define NUM_LEDS 3 -#define NUM_INTERRUPT 2 -#define NUM_SERIAL 1 +#define NUM_ANALOG_INPUTS 2 +#define NUM_PWM 2 +#define NUM_LEDS 3 +#define NUM_INTERRUPT 0 +#define NUM_SERIAL 1 // Following could be 4 unless add/delete task has issues #define NUM_TONE_PINS 0 #define NUM_TASKS_VARIANT 8 @@ -53,48 +53,31 @@ #define PWM4_TIMER_PERIOD (2041U) // Generate 490Hz @fCCU=1MHz -#define PCLK 64000000u - -#define PIN_SPI_SS 10 -#define PIN_SPI_MOSI 11 -#define PIN_SPI_MISO 12 -#define PIN_SPI_SCK 13 +#define PCLK 64000000u -extern uint8_t SS; +extern uint8_t SS; extern uint8_t MOSI; extern uint8_t MISO; extern uint8_t SCK; -#define PIN_AREF 14 - #define A0 0 #define A1 1 // These 2 lines should be defined in higher level or examples -#define CH_I A0 -#define CH_Q A1 -// These 2 lines should also be defined at higher level -// TX_ON defined but only used in .h file to set BGT24LTR11_TX_ON_PIN that is NEVER used -//#define TX_ON 3 -#define BGT_ON 27 - -#define PIN_SPI_SS_2 23 - -#define AD_AUX_1 24 // AD_AUX -#define AD_AUX_2 25 // AD_AUX -#define AUX_1 26 // AUX -#define AUX_2 27 // AUX -#define AUX_3 28 // AUX -#define AUX_4 29 // AUX -#define AUX_5 30 // AUX - -#define LED_BUILTIN 10 // Standard Arduino LED -#define LED1 10 // Extended LEDs P0.7 -#define LED2 13 // Extended LEDs P0.9 -#define LED3 26 // Extended LEDs P0.5 -#define GND 32 // GND - -#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT)) +#define CH_I A0 +#define CH_Q A1 +// Actual on board signal is TX_ON +#define BGT_ON 2 + +#define LED_BUILTIN 3 // Standard Arduino LED +#define LED1 3 // Extended LEDs P0.5 D5 +#define LED2 5 // Extended LEDs P0.7 D4 +#define LED3 7 // Extended LEDs P0.9 D3 +#define GND 16 // GND + +// Disable interrupts +//#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT)) +#define digitalPinToInterrupt(p) NOT_AN_INTERRUPT #ifdef ARDUINO_MAIN /* Mapping of Arduino Pins to PWM4 channels as pin and PWM4 channel @@ -102,76 +85,45 @@ extern uint8_t SCK; Putting both parts in array means if a PWM4 channel gets reassigned for another function later a gap in channel numbers will not mess things up */ const uint8_t mapping_pin_PWM4[][ 2 ] = { - { 3, 0 }, - { 4, 1 }, - { 6, 2 }, - { 9, 3 }, + { 0, 6 }, + { 0, 8 }, { 255, 255 } }; - const uint8_t mapping_pin_PWM8[][ 2 ] = { { 255, 255 } }; - - // these arrays map port names (e.g. port B) to the // appropriate addresses for various functions (e.g. reading // and writing) - -// These mappings look more like XMC1100 Boot Kit mappings -// Has 6 Analog inputs defined but apparently NUM_ANALOG_INPUTS is 2 - const XMC_PORT_PIN_t mapping_port_pin[] = { - /* 0 */ {XMC_GPIO_PORT1, 2}, // PIN_RX / LED output P1.2 - /* 1 */ {XMC_GPIO_PORT1 ,3}, // PIN_TX / LED output P1.3 - /* 2 */ {XMC_GPIO_PORT1 ,4}, // External interrupt/ LED output P1.4 - /* 3 */ {XMC_GPIO_PORT0 ,0}, // External interrupt/ PWM output P0.0 - /* 4 */ {XMC_GPIO_PORT0 ,1}, // PWM output P0.1 - /* 5 */ {XMC_GPIO_PORT0 ,2}, // GPIO P0.2 - /* 6 */ {XMC_GPIO_PORT0 ,3}, // PWM output P0.3 - /* 7 */ {XMC_GPIO_PORT0 ,4}, // GPIO P0.4 - /* 8 */ {XMC_GPIO_PORT0 ,12}, // GPIO P0.12 - /* 9 */ {XMC_GPIO_PORT0 ,8}, // PWM output P0.8 - /* 10 */ {XMC_GPIO_PORT0 ,9}, // SPI-SS P0.9 - /* 11 */ {XMC_GPIO_PORT1 ,1}, // SPI-MOSI P1.1 - /* 12 */ {XMC_GPIO_PORT1 ,0}, // SPI-MISO P1.0 - /* 13 */ {XMC_GPIO_PORT0 ,7}, // SPI-SCK / LED output P0.7 - /* 14 */ {XMC_GPIO_PORT2 ,3}, // AREF P2.3 (INPUT ONLY) - /* 15 */ {XMC_GPIO_PORT2 ,1}, // I2C Data / Address SDA P2.1 - /* 16 */ {XMC_GPIO_PORT2 ,0}, // I2C Clock SCL P2.0 - /* 17 */ {XMC_GPIO_PORT2 ,6}, // A0 / ADC Input P2.6 (INPUT ONLY) - /* 18 */ {XMC_GPIO_PORT2 ,8}, // A1 / ADC Input P2.8 (INPUT ONLY) - /* 19 */ {XMC_GPIO_PORT2 ,9}, // A2 / ADC Input P2.9 (INPUT ONLY) - /* 20 */ {XMC_GPIO_PORT2 ,10}, // A3 / ADC Input P2.10 - /* 21 */ {XMC_GPIO_PORT2 ,11}, // A4 / ADC Input P2.11 - /* 22 */ {XMC_GPIO_PORT2 ,2}, // A5 / ADC Input P2.2 (INPUT ONLY) - /* 23 */ {XMC_GPIO_PORT2 ,4}, // SPI_SS_2 P2.4 (INPUT ONLY) - /* 24 */ {XMC_GPIO_PORT2 ,5}, // AD_AUX P2.5 (INPUT ONLY) - /* 25 */ {XMC_GPIO_PORT2 ,7}, // AD_AUX P2.7 (INPUT ONLY) - /* 26 */ {XMC_GPIO_PORT0 ,5}, // AUX / GPIO / LED output P0.5 - /* 27 */ {XMC_GPIO_PORT0 ,6}, // AUX / GPIO / LED output P0.6 - /* 28 */ {XMC_GPIO_PORT0 ,10}, // AUX / GPIO P0.10 - /* 29 */ {XMC_GPIO_PORT0 ,11}, // AUX / GPIO P0.11 - /* 30 */ {XMC_GPIO_PORT0 ,13}, // AUX / GPIO P0.13 - /* 31 */ {XMC_GPIO_PORT1 ,5} // LED output P1.5 + /* 0 */ { XMC_GPIO_PORT2, 6 }, // PIN_RX P2.6 + /* 1 */ { XMC_GPIO_PORT2 ,0 }, // PIN_TX P2.0 + /* 2 */ { XMC_GPIO_PORT0 ,0 }, // TX_ON P0.0 + /* 3 */ { XMC_GPIO_PORT0 ,5 }, // LED output D5 P0.5 + /* 4 */ { XMC_GPIO_PORT0 ,6 }, // PWM1 P0.6 + /* 5 */ { XMC_GPIO_PORT0 ,7 }, // LED output D4 P0.7 + /* 6 */ { XMC_GPIO_PORT0 ,8 }, // PWM 2 P0.8 + /* 7 */ { XMC_GPIO_PORT0 ,9 }, // LED output D2 P0.9 + /* 8 */ { XMC_GPIO_PORT0 ,14 }, // GPIO - SWDIO P0.14 + /* 9 */ { XMC_GPIO_PORT0 ,15 }, // GPIO - SWDCLK P0.15 + /* 10 */ { XMC_GPIO_PORT2 ,8 }, // NOT CONNECTED P2.8 (also P2.7) + /* 11 */ { XMC_GPIO_PORT2 ,9 }, // A0 / ADC Input P2.9 (INPUT ONLY) + /* 12 */ { XMC_GPIO_PORT2 ,10 }, // NOT CONNECTED P2.10 + /* 13 */ { XMC_GPIO_PORT2 ,11 } // A1 / ADC Input P2.11 }; const XMC_PIN_INTERRUPT_t mapping_interrupt[] = { - /* 0 */ {CCU40, CCU40_CC40, 0, 0, CCU40_IN0_U0C0_DX2INS}, - /* 1 */ {CCU40, CCU40_CC40, 0, 1, CCU40_IN0_P0_0} +// /* 0 */ { CCU40, CCU40_CC40, 0, 0, CCU40_IN0_U0C0_DX2INS }, +// /* 1 */ { CCU40, CCU40_CC40, 0, 1, CCU40_IN0_P0_0 } }; XMC_PWM4_t mapping_pwm4[] = { - {CCU40, CCU40_CC40, 0, mapping_port_pin[3], P0_0_AF_CCU40_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 3 P0.0 - {CCU40, CCU40_CC41, 1, mapping_port_pin[4], P0_1_AF_CCU40_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 4 P0.1 - {CCU40, CCU40_CC43, 3, mapping_port_pin[6], P0_3_AF_CCU40_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 6 P0.3 - {CCU40, CCU40_CC42, 2, mapping_port_pin[9], P0_8_AF_CCU40_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED} // PWM disabled 9 P0.8 + { CCU40, CCU40_CC40, 0, mapping_port_pin[ 4 ], P0_6_AF_CCU40_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED }, // PWM disabled 3 P0.6 + { CCU40, CCU40_CC42, 2, mapping_port_pin[ 6 ], P0_8_AF_CCU40_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED } // PWM disabled 9 P0.8 }; -XMC_PWM8_t mapping_pwm8[1]; - XMC_ADC_t mapping_adc[] = { - {VADC, 2, VADC_G0, 0, 10, DISABLED}, // CH_I - {VADC, 4, VADC_G0, 0, 11, DISABLED} // CH_Q + { VADC, 2, VADC_G0, 2, 2, DISABLED }, // A0 - CH_I + { VADC, 4, VADC_G0, 4, 4, DISABLED } // A1 - CH_Q }; - + /* * UART objects */ @@ -179,29 +131,29 @@ RingBuffer rx_buffer_0; RingBuffer tx_buffer_0; XMC_UART_t XMC_UART_0 = -{ - .channel = XMC_UART0_CH0, - .rx = { .port = (XMC_GPIO_PORT_t *)PORT2_BASE, - .pin = (uint8_t)6 - }, - .rx_config = { .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .tx = { .port = (XMC_GPIO_PORT_t *)PORT2_BASE, - .pin = (uint8_t)0 - }, - .tx_config = { .mode = (XMC_GPIO_MODE_t) XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD - }, - .input_source_dx0 = (XMC_USIC_INPUT_t)USIC0_C0_DX0_DX3INS, - .input_source_dx1 = XMC_INPUT_INVALID, - .input_source_dx2 = XMC_INPUT_INVALID, - .input_source_dx3 = (XMC_USIC_INPUT_t)USIC0_C0_DX3_P2_6, - .irq_num = USIC0_0_IRQn, - .irq_service_request = 0 -}; + { + .channel = XMC_UART0_CH0, + .rx = { .port = (XMC_GPIO_PORT_t *)PORT2_BASE, + .pin = (uint8_t)6 + }, + .rx_config = { .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .tx = { .port = (XMC_GPIO_PORT_t *)PORT2_BASE, + .pin = (uint8_t)0 + }, + .tx_config = { .mode = (XMC_GPIO_MODE_t) XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD + }, + .input_source_dx0 = (XMC_USIC_INPUT_t)USIC0_C0_DX0_DX3INS, + .input_source_dx1 = XMC_INPUT_INVALID, + .input_source_dx2 = XMC_INPUT_INVALID, + .input_source_dx3 = (XMC_USIC_INPUT_t)USIC0_C0_DX3_P2_6, + .irq_num = USIC0_0_IRQn, + .irq_service_request = 0 + }; HardwareSerial Serial( &XMC_UART_0, &rx_buffer_0, &tx_buffer_0 ); diff --git a/variants/XMC1300/linker_script_128k.ld b/variants/XMC1300/linker_script_128k.ld new file mode 100644 index 00000000..8e2773c6 --- /dev/null +++ b/variants/XMC1300/linker_script_128k.ld @@ -0,0 +1,288 @@ +/** + * @file XMC1300x0128.ld + * @date 2021-01-11 + ~ + * @cond + ********************************************************************************************************************* + * Linker file for the GNU C Compiler v1.10 + * Supported devices: XMC130x-ANY package with 128kB Flash and 16kB RAM + * + * Updated January 2021 for any 128kB Flash device + * + * Copyright (c) 2015-2016, Infineon Technologies AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the + * following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following + * disclaimer. + * + * 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. + * + * Neither the name of the copyright holders 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. + * + * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with + * Infineon Technologies AG dave@infineon.com). + ********************************************************************************************************************* + * + * Change History + * -------------- + * + * 2015-07-07: + * - Product splitting + * - Copyright notice update + * + * 2015-11-24: + * - Compatibility with GCC 4.9 2015q2 + * + * 2016-03-15: + * - Add assertion to check that region SRAM_combined does not overflowed no_init section + * + * 2016-06-07: + * - Add XMC1302-Q040X0200 + * + * 2018-03-08: + * - Change default XMC1xxx stack size + * - Move Stack to top of RAM below no_init for more standard and safer location + * - Could mean startup_XMC1xxx.S could be shortened + * + * 2021-01-11: + * - Split script to different flash size files for Boot Kit and Sense2GoL + * + * @endcond + * + */ + +OUTPUT_FORMAT("elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(Reset_Handler) + +MEMORY +{ + FLASH(RX) : ORIGIN = 0x10001000, LENGTH = 0x20000 + SRAM(!RX) : ORIGIN = 0x20000000, LENGTH = 0x4000 +} + +stack_size = DEFINED(stack_size) ? stack_size : 1024; +no_init_size = 4; + +SECTIONS +{ + /* TEXT section */ + + .text : + { + sText = .; + KEEP(*(.reset)); + *(.text .text.* .gnu.linkonce.t.*); + + /* C++ Support */ + KEEP(*(.init)) + KEEP(*(.fini)) + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.rodata .rodata.*) + *(.gnu.linkonce.r*) + . = ALIGN(4); + } > FLASH + + .eh_frame_hdr : ALIGN (4) + { + KEEP (*(.eh_frame_hdr)) + } > FLASH + + .eh_frame : ALIGN (4) + { + KEEP (*(.eh_frame)) + } > FLASH + + /* Exception handling, exidx needs a dedicated section */ + .ARM.extab : ALIGN(4) + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + . = ALIGN(4); + __exidx_start = .; + .ARM.exidx : ALIGN(4) + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + . = ALIGN(4); + + /* End of RO-DATA and start of LOAD region for the veneers */ + eROData = . ; + + /* DSRAM layout (Lowest to highest)*/ + /* Veneer <-> DATA <-> ram_code <-> BSS <-> HEAP <-> memory gap <-> Stack <-> no_init */ + + .VENEER_Code ABSOLUTE(0x2000000C): AT(eROData) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + VeneerStart = .; + KEEP(*(.XmcVeneerCode)); + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + VeneerEnd = .; + } > SRAM + + VeneerSize = ABSOLUTE(VeneerEnd) - ABSOLUTE(VeneerStart); + + /* Standard DATA and user defined DATA/BSS/CONST sections */ + DataLoadAddr = eROData + VeneerSize; + .data : AT(DataLoadAddr) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __data_start = .; + *(vtable) + * (.data); + * (.data*); + *(*.data); + *(.gnu.linkonce.d*) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __data_end = .; + } > SRAM + __data_size = __data_end - __data_start; + + .ram_code : AT(DataLoadAddr + __data_size) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __ram_code_start = .; + /* functions with __attribute__ ((section (".ram_code")))*/ + *(.ram_code) + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __ram_code_end = .; + } > SRAM + __ram_code_load = LOADADDR (.ram_code); + __ram_code_size = __ram_code_end - __ram_code_start; + + /* BSS section */ + .bss (NOLOAD) : + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __bss_start = .; + * (.bss); + * (.bss*); + * (COMMON); + *(.gnu.linkonce.b*) + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __bss_end = .; + Heap_Bank1_Start = .; + } > SRAM + __bss_size = __bss_end - __bss_start; + + _stack_begin = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); + + /* Dummy section for stack */ + Stack _stack_begin (NOLOAD) : + { + . = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); + Heap_Bank1_End = .; + end = Heap_Bank1_End; + __stack_start = .; + . = . + stack_size; + __stack_end = .; + __initial_sp = .; + } > SRAM + + /* Heap - Bank1*/ + + Heap_Bank1_Size = Heap_Bank1_End - Heap_Bank1_Start; + + ASSERT(Heap_Bank1_Start <= Heap_Bank1_End, "bss section SRAM overflowed stack section") + + /* .no_init section contains SystemCoreClock. See system_XMC_xxxx.c file */ + .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : + { + * (.no_init); + } > SRAM + + + /DISCARD/ : + { + *(.comment) + } + + .stab 0 (NOLOAD) : { *(.stab) } + .stabstr 0 (NOLOAD) : { *(.stabstr) } + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_pubtypes 0 : { *(.debug_pubtypes) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + + /* DWARF 2.1 */ + .debug_ranges 0 : { *(.debug_ranges) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + + /* Build attributes */ + .build_attributes 0 : { *(.ARM.attributes) } +} diff --git a/variants/XMC1300/linker_script.ld b/variants/XMC1300/linker_script_200k.ld similarity index 81% rename from variants/XMC1300/linker_script.ld rename to variants/XMC1300/linker_script_200k.ld index 602e5593..2854dd14 100644 --- a/variants/XMC1300/linker_script.ld +++ b/variants/XMC1300/linker_script_200k.ld @@ -1,38 +1,39 @@ /** * @file XMC1300x0200.ld - * @date 2018-03-08 - * + * @date 2021-01-11 + ~ * @cond ********************************************************************************************************************* * Linker file for the GNU C Compiler v1.10 - * Supported devices: XMC1302-T038X0200 - * XMC1302-Q040X0200 + * Supported devices: XMC130x-ANY package with 200kB Flash and 16kB RAM + * + * Updated January 2021 for any 200kB Flash device * * Copyright (c) 2015-2016, Infineon Technologies AG - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * 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. - * - * Neither the name of the copyright holders 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. - * - * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with - * Infineon Technologies AG dave@infineon.com). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the + * following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following + * disclaimer. + * + * 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. + * + * Neither the name of the copyright holders 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. + * + * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with + * Infineon Technologies AG dave@infineon.com). ********************************************************************************************************************* * * Change History @@ -41,22 +42,25 @@ * 2015-07-07: * - Product splitting * - Copyright notice update - * + * * 2015-11-24: * - Compatibility with GCC 4.9 2015q2 - * + * * 2016-03-15: - * - Add assertion to check that region SRAM_combined does not overflowed no_init section + * - Add assertion to check that region SRAM_combined does not overflowed no_init section * * 2016-06-07: - * - Add XMC1302-Q040X0200 + * - Add XMC1302-Q040X0200 * * 2018-03-08: * - Change default XMC1xxx stack size * - Move Stack to top of RAM below no_init for more standard and safer location * - Could mean startup_XMC1xxx.S could be shortened * - * @endcond + * 2021-01-11: + * - Split script to different flash size files for Boot Kit and Sense2GoL + * + * @endcond * */ @@ -77,7 +81,7 @@ SECTIONS { /* TEXT section */ - .text : + .text : { sText = .; KEEP(*(.reset)); @@ -103,7 +107,7 @@ SECTIONS *(.rodata .rodata.*) *(.gnu.linkonce.r*) - . = ALIGN(4); + . = ALIGN(4); } > FLASH .eh_frame_hdr : ALIGN (4) @@ -154,12 +158,12 @@ SECTIONS { . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ __data_start = .; - *(vtable) + *(vtable) * (.data); * (.data*); *(*.data); *(.gnu.linkonce.d*) - + . = ALIGN(4); /* preinit data */ PROVIDE_HIDDEN (__preinit_array_start = .); @@ -191,13 +195,13 @@ SECTIONS . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ __ram_code_start = .; /* functions with __attribute__ ((section (".ram_code")))*/ - *(.ram_code) + *(.ram_code) . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ __ram_code_end = .; } > SRAM __ram_code_load = LOADADDR (.ram_code); __ram_code_size = __ram_code_end - __ram_code_start; - + /* BSS section */ .bss (NOLOAD) : { @@ -212,7 +216,7 @@ SECTIONS Heap_Bank1_Start = .; } > SRAM __bss_size = __bss_end - __bss_start; - + _stack_begin = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); /* Dummy section for stack */ @@ -220,7 +224,7 @@ SECTIONS { . = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); Heap_Bank1_End = .; - end = Heap_Bank1_End; + end = Heap_Bank1_End; __stack_start = .; . = . + stack_size; __stack_end = .; @@ -232,14 +236,14 @@ SECTIONS Heap_Bank1_Size = Heap_Bank1_End - Heap_Bank1_Start; ASSERT(Heap_Bank1_Start <= Heap_Bank1_End, "bss section SRAM overflowed stack section") - + /* .no_init section contains SystemCoreClock. See system_XMC_xxxx.c file */ - .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : + .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : { * (.no_init); } > SRAM - + /DISCARD/ : { *(.comment) diff --git a/variants/XMC1300/linker_script_32k.ld b/variants/XMC1300/linker_script_32k.ld new file mode 100644 index 00000000..4520c188 --- /dev/null +++ b/variants/XMC1300/linker_script_32k.ld @@ -0,0 +1,288 @@ +/** + * @file XMC1300x0032.ld + * @date 2021-01-11 + ~ + * @cond + ********************************************************************************************************************* + * Linker file for the GNU C Compiler v1.10 + * Supported devices: XMC130x-ANY package with 32kB Flash and 16kB RAM + * + * Updated January 2021 for any 32kB Flash device + * + * Copyright (c) 2015-2016, Infineon Technologies AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the + * following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following + * disclaimer. + * + * 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. + * + * Neither the name of the copyright holders 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. + * + * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with + * Infineon Technologies AG dave@infineon.com). + ********************************************************************************************************************* + * + * Change History + * -------------- + * + * 2015-07-07: + * - Product splitting + * - Copyright notice update + * + * 2015-11-24: + * - Compatibility with GCC 4.9 2015q2 + * + * 2016-03-15: + * - Add assertion to check that region SRAM_combined does not overflowed no_init section + * + * 2016-06-07: + * - Add XMC1302-Q040X0200 + * + * 2018-03-08: + * - Change default XMC1xxx stack size + * - Move Stack to top of RAM below no_init for more standard and safer location + * - Could mean startup_XMC1xxx.S could be shortened + * + * 2021-01-11: + * - Split script to different flash size files for Boot Kit and Sense2GoL + * + * @endcond + * + */ + +OUTPUT_FORMAT("elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(Reset_Handler) + +MEMORY +{ + FLASH(RX) : ORIGIN = 0x10001000, LENGTH = 0x8000 + SRAM(!RX) : ORIGIN = 0x20000000, LENGTH = 0x4000 +} + +stack_size = DEFINED(stack_size) ? stack_size : 1024; +no_init_size = 4; + +SECTIONS +{ + /* TEXT section */ + + .text : + { + sText = .; + KEEP(*(.reset)); + *(.text .text.* .gnu.linkonce.t.*); + + /* C++ Support */ + KEEP(*(.init)) + KEEP(*(.fini)) + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.rodata .rodata.*) + *(.gnu.linkonce.r*) + . = ALIGN(4); + } > FLASH + + .eh_frame_hdr : ALIGN (4) + { + KEEP (*(.eh_frame_hdr)) + } > FLASH + + .eh_frame : ALIGN (4) + { + KEEP (*(.eh_frame)) + } > FLASH + + /* Exception handling, exidx needs a dedicated section */ + .ARM.extab : ALIGN(4) + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + . = ALIGN(4); + __exidx_start = .; + .ARM.exidx : ALIGN(4) + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + . = ALIGN(4); + + /* End of RO-DATA and start of LOAD region for the veneers */ + eROData = . ; + + /* DSRAM layout (Lowest to highest)*/ + /* Veneer <-> DATA <-> ram_code <-> BSS <-> HEAP <-> memory gap <-> Stack <-> no_init */ + + .VENEER_Code ABSOLUTE(0x2000000C): AT(eROData) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + VeneerStart = .; + KEEP(*(.XmcVeneerCode)); + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + VeneerEnd = .; + } > SRAM + + VeneerSize = ABSOLUTE(VeneerEnd) - ABSOLUTE(VeneerStart); + + /* Standard DATA and user defined DATA/BSS/CONST sections */ + DataLoadAddr = eROData + VeneerSize; + .data : AT(DataLoadAddr) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __data_start = .; + *(vtable) + * (.data); + * (.data*); + *(*.data); + *(.gnu.linkonce.d*) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __data_end = .; + } > SRAM + __data_size = __data_end - __data_start; + + .ram_code : AT(DataLoadAddr + __data_size) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __ram_code_start = .; + /* functions with __attribute__ ((section (".ram_code")))*/ + *(.ram_code) + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __ram_code_end = .; + } > SRAM + __ram_code_load = LOADADDR (.ram_code); + __ram_code_size = __ram_code_end - __ram_code_start; + + /* BSS section */ + .bss (NOLOAD) : + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __bss_start = .; + * (.bss); + * (.bss*); + * (COMMON); + *(.gnu.linkonce.b*) + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __bss_end = .; + Heap_Bank1_Start = .; + } > SRAM + __bss_size = __bss_end - __bss_start; + + _stack_begin = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); + + /* Dummy section for stack */ + Stack _stack_begin (NOLOAD) : + { + . = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); + Heap_Bank1_End = .; + end = Heap_Bank1_End; + __stack_start = .; + . = . + stack_size; + __stack_end = .; + __initial_sp = .; + } > SRAM + + /* Heap - Bank1*/ + + Heap_Bank1_Size = Heap_Bank1_End - Heap_Bank1_Start; + + ASSERT(Heap_Bank1_Start <= Heap_Bank1_End, "bss section SRAM overflowed stack section") + + /* .no_init section contains SystemCoreClock. See system_XMC_xxxx.c file */ + .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : + { + * (.no_init); + } > SRAM + + + /DISCARD/ : + { + *(.comment) + } + + .stab 0 (NOLOAD) : { *(.stab) } + .stabstr 0 (NOLOAD) : { *(.stabstr) } + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_pubtypes 0 : { *(.debug_pubtypes) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + + /* DWARF 2.1 */ + .debug_ranges 0 : { *(.debug_ranges) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + + /* Build attributes */ + .build_attributes 0 : { *(.ARM.attributes) } +} diff --git a/variants/XMC1300/linker_script_64k.ld b/variants/XMC1300/linker_script_64k.ld new file mode 100644 index 00000000..38fe4ae7 --- /dev/null +++ b/variants/XMC1300/linker_script_64k.ld @@ -0,0 +1,288 @@ +/** + * @file XMC1300x0064.ld + * @date 2021-01-11 + ~ + * @cond + ********************************************************************************************************************* + * Linker file for the GNU C Compiler v1.10 + * Supported devices: XMC130x-ANY package with 64kB Flash and 16kB RAM + * + * Updated January 2021 for any 64kB Flash device + * + * Copyright (c) 2015-2016, Infineon Technologies AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the + * following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following + * disclaimer. + * + * 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. + * + * Neither the name of the copyright holders 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. + * + * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with + * Infineon Technologies AG dave@infineon.com). + ********************************************************************************************************************* + * + * Change History + * -------------- + * + * 2015-07-07: + * - Product splitting + * - Copyright notice update + * + * 2015-11-24: + * - Compatibility with GCC 4.9 2015q2 + * + * 2016-03-15: + * - Add assertion to check that region SRAM_combined does not overflowed no_init section + * + * 2016-06-07: + * - Add XMC1302-Q040X0200 + * + * 2018-03-08: + * - Change default XMC1xxx stack size + * - Move Stack to top of RAM below no_init for more standard and safer location + * - Could mean startup_XMC1xxx.S could be shortened + * + * 2021-01-11: + * - Split script to different flash size files for Boot Kit and Sense2GoL + * + * @endcond + * + */ + +OUTPUT_FORMAT("elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(Reset_Handler) + +MEMORY +{ + FLASH(RX) : ORIGIN = 0x10001000, LENGTH = 0x10000 + SRAM(!RX) : ORIGIN = 0x20000000, LENGTH = 0x4000 +} + +stack_size = DEFINED(stack_size) ? stack_size : 1024; +no_init_size = 4; + +SECTIONS +{ + /* TEXT section */ + + .text : + { + sText = .; + KEEP(*(.reset)); + *(.text .text.* .gnu.linkonce.t.*); + + /* C++ Support */ + KEEP(*(.init)) + KEEP(*(.fini)) + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.rodata .rodata.*) + *(.gnu.linkonce.r*) + . = ALIGN(4); + } > FLASH + + .eh_frame_hdr : ALIGN (4) + { + KEEP (*(.eh_frame_hdr)) + } > FLASH + + .eh_frame : ALIGN (4) + { + KEEP (*(.eh_frame)) + } > FLASH + + /* Exception handling, exidx needs a dedicated section */ + .ARM.extab : ALIGN(4) + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + . = ALIGN(4); + __exidx_start = .; + .ARM.exidx : ALIGN(4) + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + . = ALIGN(4); + + /* End of RO-DATA and start of LOAD region for the veneers */ + eROData = . ; + + /* DSRAM layout (Lowest to highest)*/ + /* Veneer <-> DATA <-> ram_code <-> BSS <-> HEAP <-> memory gap <-> Stack <-> no_init */ + + .VENEER_Code ABSOLUTE(0x2000000C): AT(eROData) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + VeneerStart = .; + KEEP(*(.XmcVeneerCode)); + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + VeneerEnd = .; + } > SRAM + + VeneerSize = ABSOLUTE(VeneerEnd) - ABSOLUTE(VeneerStart); + + /* Standard DATA and user defined DATA/BSS/CONST sections */ + DataLoadAddr = eROData + VeneerSize; + .data : AT(DataLoadAddr) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __data_start = .; + *(vtable) + * (.data); + * (.data*); + *(*.data); + *(.gnu.linkonce.d*) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __data_end = .; + } > SRAM + __data_size = __data_end - __data_start; + + .ram_code : AT(DataLoadAddr + __data_size) + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __ram_code_start = .; + /* functions with __attribute__ ((section (".ram_code")))*/ + *(.ram_code) + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __ram_code_end = .; + } > SRAM + __ram_code_load = LOADADDR (.ram_code); + __ram_code_size = __ram_code_end - __ram_code_start; + + /* BSS section */ + .bss (NOLOAD) : + { + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __bss_start = .; + * (.bss); + * (.bss*); + * (COMMON); + *(.gnu.linkonce.b*) + . = ALIGN(4); /* section size must be multiple of 4. See startup_XMC_xxxx.S file */ + __bss_end = .; + Heap_Bank1_Start = .; + } > SRAM + __bss_size = __bss_end - __bss_start; + + _stack_begin = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); + + /* Dummy section for stack */ + Stack _stack_begin (NOLOAD) : + { + . = ORIGIN(SRAM) + LENGTH(SRAM) - stack_size - (2 * no_init_size); + Heap_Bank1_End = .; + end = Heap_Bank1_End; + __stack_start = .; + . = . + stack_size; + __stack_end = .; + __initial_sp = .; + } > SRAM + + /* Heap - Bank1*/ + + Heap_Bank1_Size = Heap_Bank1_End - Heap_Bank1_Start; + + ASSERT(Heap_Bank1_Start <= Heap_Bank1_End, "bss section SRAM overflowed stack section") + + /* .no_init section contains SystemCoreClock. See system_XMC_xxxx.c file */ + .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : + { + * (.no_init); + } > SRAM + + + /DISCARD/ : + { + *(.comment) + } + + .stab 0 (NOLOAD) : { *(.stab) } + .stabstr 0 (NOLOAD) : { *(.stabstr) } + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_pubtypes 0 : { *(.debug_pubtypes) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + + /* DWARF 2.1 */ + .debug_ranges 0 : { *(.debug_ranges) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + + /* Build attributes */ + .build_attributes 0 : { *(.ARM.attributes) } +} diff --git a/variants/XMC1400/config/XMC1400_Boot_Kit/pins_arduino.h b/variants/XMC1400/config/XMC1400_Boot_Kit/pins_arduino.h index fad0e290..acf05c28 100644 --- a/variants/XMC1400/config/XMC1400_Boot_Kit/pins_arduino.h +++ b/variants/XMC1400/config/XMC1400_Boot_Kit/pins_arduino.h @@ -30,7 +30,11 @@ //**************************************************************************** // @Defines //**************************************************************************** -#define XMC_BOARD XMC1400 Boot Kit +#define XMC_BOARD XMC 1400 Boot Kit + +/* On board LED is ON when digital output is 0, LOW, FALSE, OFF */ +#define XMC_LED_ON 0 + #define NUM_ANALOG_INPUTS 6 #define NUM_PWM 4 #define NUM_LEDS 4 diff --git a/variants/XMC1400/linker_script.ld b/variants/XMC1400/linker_script_200k.ld similarity index 80% rename from variants/XMC1400/linker_script.ld rename to variants/XMC1400/linker_script_200k.ld index 3e85b3c7..29fdf06d 100644 --- a/variants/XMC1400/linker_script.ld +++ b/variants/XMC1400/linker_script_200k.ld @@ -5,42 +5,34 @@ * @cond ********************************************************************************************************************* * Linker file for the GNU C Compiler v1.6 - * Supported devices: XMC1402-Q064X0200 - * XMC1402-T038X0200 - * XMC1402-Q040X0200 - * XMC1402-Q048X0200 - * XMC1403-Q040X0200 - * XMC1403-Q048X0200 - * XMC1403-Q064X0200 - * XMC1404-Q048X0200 - * XMC1404-Q064X0200 - * XMC1404-F064X0200 + * Supported devices: XMC1402- ANY Package 200kB Flash 16kB RAM + * * * Copyright (c) 2015-2017, Infineon Technologies AG - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the - * following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. - * - * 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. - * - * Neither the name of the copyright holders 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. - * - * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with - * Infineon Technologies AG dave@infineon.com). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the + * following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following + * disclaimer. + * + * 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. + * + * Neither the name of the copyright holders 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. + * + * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with + * Infineon Technologies AG dave@infineon.com). ********************************************************************************************************************* * * Change History @@ -49,12 +41,12 @@ * 2015-07-07: * - Product splitting * - Copyright notice update - * + * * 2015-11-24: * - Compatibility with GCC 4.9 2015q2 * * 2016-03-15: - * - Add assertion to check that region SRAM_combined does not overflowed no_init section + * - Add assertion to check that region SRAM_combined does not overflowed no_init section * * 2016-06-07: * - Add XMC1403-Q040X0200 @@ -69,9 +61,9 @@ * - Added new symbols __text_size and eText * * 2017-04-20: - * - Change vtable location to flash area to save ram + * - Change vtable location to flash area to save ram * - * @endcond + * @endcond * */ @@ -92,7 +84,7 @@ SECTIONS { /* TEXT section */ - .text : + .text : { sText = .; KEEP(*(.reset)); @@ -119,7 +111,7 @@ SECTIONS *(.rodata .rodata.*) *(.gnu.linkonce.r*) - *(vtable) + *(vtable) . = ALIGN(4); } > FLASH @@ -180,7 +172,7 @@ SECTIONS * (.data*); *(*.data); *(.gnu.linkonce.d*) - + . = ALIGN(4); /* preinit data */ PROVIDE_HIDDEN (__preinit_array_start = .); @@ -213,13 +205,13 @@ SECTIONS . = ALIGN(4); /* section size must be multiply of 4. See startup.S file */ __ram_code_start = .; /* functions with __attribute__ ((section (".ram_code")))*/ - *(.ram_code) + *(.ram_code) . = ALIGN(4); /* section size must be multiply of 4. See startup.S file */ __ram_code_end = .; } > SRAM AT > FLASH __ram_code_load = LOADADDR (.ram_code); __ram_code_size = __ram_code_end - __ram_code_start; - + __text_size = (__exidx_end - sText) + VeneerSize + __data_size + __ram_code_size; eText = sText + __text_size; @@ -238,14 +230,14 @@ SECTIONS Heap_Bank1_Start = .; } > SRAM __bss_size = __bss_end - __bss_start; - + /* .no_init section contains SystemCoreClock. See system.c file */ - .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : + .no_init ORIGIN(SRAM) + LENGTH(SRAM) - no_init_size (NOLOAD) : { Heap_Bank1_End = .; * (.no_init); } > SRAM - + /* Heap - Bank1*/ Heap_Bank1_Size = Heap_Bank1_End - Heap_Bank1_Start; diff --git a/variants/XMC4400/config/XMC4400_Platform2GO/pins_arduino.h b/variants/XMC4400/config/XMC4400_Platform2GO/pins_arduino.h old mode 100755 new mode 100644 index a442bf5c..ac7617b5 --- a/variants/XMC4400/config/XMC4400_Platform2GO/pins_arduino.h +++ b/variants/XMC4400/config/XMC4400_Platform2GO/pins_arduino.h @@ -18,12 +18,11 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - + Copyright (c) 2019 Infineon Technologies AG This file has been modified for the XMC microcontroller series. */ - #ifndef PINS_ARDUINO_H_ #define PINS_ARDUINO_H_ @@ -35,66 +34,62 @@ //**************************************************************************** // @Defines //**************************************************************************** - -#define XMC_BOARD XMC 4400 Platform 2GO +#define XMC_BOARD XMC 4400 Platform 2GO /* On board LED is ON when digital output is 0, LOW, False, OFF */ -#define XMC_LED_ON 0 - -#define NUM_ANALOG_INPUTS 17 -#define NUM_PWM 17 -#define NUM_INTERRUPT 2 -#define NUM_SERIAL 1 -#define NUM_TONE_PINS 16 -#define NUM_TASKS_VARIANT 32 +#define XMC_LED_ON 0 +#define NUM_ANALOG_INPUTS 17 +#define NUM_PWM 17 +#define NUM_INTERRUPT 2 +#define NUM_SERIAL 1 +#define NUM_TONE_PINS 16 +#define NUM_TASKS_VARIANT 32 // Indicate unit has RTC/Alarm -#define HAS_RTC 1 - -//Serial ports +#define HAS_RTC 1 -#define PWM4_TIMER_PERIOD (0x11EF) //Generate 490Hz @fCCU=144MHz +#define PWM4_TIMER_PERIOD (0x11EF) //Generate 490Hz @fCCU=144MHz #define PWM8_TIMER_PERIOD (0x11EF) // Generate 490Hz @fCCU=144MHz #define PCLK 64000000u -#define PIN_SPI_SS 10 -#define PIN_SPI_MOSI 11 -#define PIN_SPI_MISO 12 -#define PIN_SPI_SCK 13 +#define PIN_SPI_SS 10 +#define PIN_SPI_MOSI 11 +#define PIN_SPI_MISO 12 +#define PIN_SPI_SCK 13 -extern uint8_t SS; +extern uint8_t SS; extern uint8_t MOSI; extern uint8_t MISO; extern uint8_t SCK; -#define A0 0 //ADC G0CH0 P14.0 -#define A1 1 //ADC G0CH1 P14.1 -#define A2 2 //ADC G0CH2 P14.2 -#define A3 3 //ADC G0CH3 P14.3 -#define A4 4 //ADC G0CH4 P14.4 -#define A5 5 //ADC G0CH5 P14.5 +#define A0 0 //ADC G0CH0 P14.0 +#define A1 1 //ADC G0CH1 P14.1 +#define A2 2 //ADC G0CH2 P14.2 +#define A3 3 //ADC G0CH3 P14.3 +#define A4 4 //ADC G0CH4 P14.4 +#define A5 5 //ADC G0CH5 P14.5 //Additional ADC ports starting here -#define A6 6 // ADC G0CH6 on P14.6 -#define A7 7 // ADC G0CH7 on P14.7 -#define A8 8 // ADC G1CH4 on P14.12 -#define A9 9 // ADC G1CH5 on P14.13 -#define A10 10 // ADC G1CH6 on P14.14 -#define A11 11 // ADC G1CH7 on P14.15 -#define A12 12 // ADC G2CH2 on P15.2 -#define A13 13 // ADC G2CH3 on P15.3 -#define A14 14 // ADC G1CH0 on P14.8 -#define A15 15 // ADC G1CH1 on P14.9 -#define A16 16 // ADC G3CH0 on P15.8 -#define A17 17 // ADC G3CH1 on P15.9 - -#define LED_BUILTIN 82 //Standard Arduino LED: Used LED1 -#define LED1 82 //Additional LED1 -#define LED2 77 //Additional LED2 -#define BUTTON1 87 //Additional BUTTON1 -#define BUTTON2 69 //Additional BUTTON2 -#define GND 94 //GND +#define A6 6 // ADC G0CH6 on P14.6 +#define A7 7 // ADC G0CH7 on P14.7 +#define A8 8 // ADC G1CH4 on P14.12 +#define A9 9 // ADC G1CH5 on P14.13 +#define A10 10 // ADC G1CH6 on P14.14 +#define A11 11 // ADC G1CH7 on P14.15 +#define A12 12 // ADC G2CH2 on P15.2 +#define A13 13 // ADC G2CH3 on P15.3 +#define A14 14 // ADC G1CH0 on P14.8 +#define A15 15 // ADC G1CH1 on P14.9 +#define A16 16 // ADC G3CH0 on P15.8 +#define A17 17 // ADC G3CH1 on P15.9 + +#define LED_BUILTIN 82 // Standard Arduino LED: Used LED1 +#define LED1 82 // Additional LED1 +#define LED2 77 // Additional LED2 +#define BUTTON1 87 // Additional BUTTON1 +#define BUTTON2 69 // Additional BUTTON2 +#define GND 94 // GND #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT)) @@ -111,133 +106,130 @@ const uint8_t mapping_pin_PWM4[][ 2 ] = { { 27, 4 }, { 28, 5 }, { 57, 6 }, - { 58, 7 }, + { 58, 7 }, { 255, 255 } }; const uint8_t mapping_pin_PWM8[][ 2 ] = { { 9, 0 }, { 10, 1 }, - { 26, 2 }, + { 26, 2 }, { 29, 3 }, - { 30, 4 }, + { 30, 4 }, { 54, 5 }, - { 55, 6 }, - { 59, 7 }, + { 55, 6 }, + { 59, 7 }, { 86, 8 }, { 255, 255 } }; - + const uint8_t mapping_pin_DAC[][ 2 ] = { { 61, 0 }, { 94, 1 }, { 255, 255 } }; - + const XMC_PORT_PIN_t mapping_port_pin[]= { - /* 0 */ {XMC_GPIO_PORT2 , 15}, //RX P2.15 - /* 1 */ {XMC_GPIO_PORT2 , 14}, //TX P2.14 - /* 2 */ {XMC_GPIO_PORT1 , 0}, // GPIO / External INT 0 P1.0 - /* 3 */ {XMC_GPIO_PORT3 , 6}, // PWM42-0 / External INT 1 P3.6 - /* 4 */ {XMC_GPIO_PORT1 , 6}, // GPIO P1.6 - /* 5 */ {XMC_GPIO_PORT3 , 3}, // PWM42-3 output P3.3 - /* 6 */ {XMC_GPIO_PORT3 , 4}, // PWM42-2 output P3.4 - /* 7 */ {XMC_GPIO_PORT1 , 14}, // GPIO P1.14 - /* 8 */ {XMC_GPIO_PORT4 , 1}, // GPIO P4.1 - /* 9 */ {XMC_GPIO_PORT0 , 11}, // PWM80-31 output P0.11 - /* 10 */ {XMC_GPIO_PORT0 , 2}, // SPI-SS / PWM80-01 output P0.2 - /* 11 */ {XMC_GPIO_PORT1 , 9}, // SPI-MOSI / PWM41-2 output P1.9 - /* 12 */ {XMC_GPIO_PORT0 , 0}, // SPI-MISO P0.0 - /* 13 */ {XMC_GPIO_PORT1 , 8}, // SPI-SCK P1.8 - /* 14 */ {XMC_GPIO_PORT2 , 3}, // AREF TODO: P2.3 - /* 15 */ {XMC_GPIO_PORT2 , 5}, // I2C Data / Address SDA P2.5 - /* 16 */ {XMC_GPIO_PORT3 , 0}, // I2C Clock SCL P3.0 - /* 17 */ {XMC_GPIO_PORT14 , 0}, // A0 / ADC Input P14.0 (INPUT ONLY) - /* 18 */ {XMC_GPIO_PORT14 , 1}, // A1 / ADC Input P14.1 (INPUT ONLY) - /* 19 */ {XMC_GPIO_PORT14 , 2}, // A2 / ADC Input P14.2 (INPUT ONLY) - /* 20 */ {XMC_GPIO_PORT14 , 3}, // A3 / ADC Input P14.3 (INPUT ONLY) - /* 21 */ {XMC_GPIO_PORT14 , 4}, // A4 / ADC Input P14.4 (INPUT ONLY) - /* 22 */ {XMC_GPIO_PORT14 , 5}, // A5 / ADC Input P14.5 (INPUT ONLY) - /* 23 */ {XMC_GPIO_PORT1 , 15}, // USB Debug RX P1.15 - /* 24 */ {XMC_GPIO_PORT0 , 5}, // USB Debug TX P0.5 - - - - //Additional pins for port X1 starting here - /* 25 */ {XMC_GPIO_PORT2 , 10}, - /* 26 */ {XMC_GPIO_PORT2 , 8}, - /* 27 */ {XMC_GPIO_PORT2 , 4}, - /* 28 */ {XMC_GPIO_PORT2 , 2}, - /* 29 */ {XMC_GPIO_PORT2 , 0}, - /* 30 */ {XMC_GPIO_PORT2 , 6}, - /* 31 */ {XMC_GPIO_PORT5 , 2}, - /* 32 */ {XMC_GPIO_PORT5 , 0}, - /* 33 */ {XMC_GPIO_PORT1 , 14}, - /* 34 */ {XMC_GPIO_PORT1 , 12}, - /* 35 */ {XMC_GPIO_PORT1 , 10}, - /* 36 */ {XMC_GPIO_PORT1 , 4}, - /* 37 */ {XMC_GPIO_PORT1 , 2}, - /* 38 */ {XMC_GPIO_PORT1 , 0}, - /* 39 */ {XMC_GPIO_PORT1 , 8}, - /* 40 */ {XMC_GPIO_PORT1 , 6}, - /* 41 */ {XMC_GPIO_PORT4 , 0}, - /* 42 */ {XMC_GPIO_PORT2 , 14}, - /* 43 */ {XMC_GPIO_PORT2 , 15}, - /* 44 */ {XMC_GPIO_PORT4 , 1}, - /* 45 */ {XMC_GPIO_PORT1 , 7}, - /* 46 */ {XMC_GPIO_PORT1 , 9}, - /* 47 */ {XMC_GPIO_PORT1 , 1}, - /* 48 */ {XMC_GPIO_PORT1 , 3}, - /* 49 */ {XMC_GPIO_PORT1 , 5}, - /* 50 */ {XMC_GPIO_PORT1 , 11}, - /* 51 */ {XMC_GPIO_PORT1 , 13}, - /* 52 */ {XMC_GPIO_PORT1 , 15}, - /* 53 */ {XMC_GPIO_PORT5 , 1}, - /* 54 */ {XMC_GPIO_PORT5 , 7}, - /* 55 */ {XMC_GPIO_PORT2 , 7}, - /* 56 */ {XMC_GPIO_PORT2 , 1}, - /* 57 */ {XMC_GPIO_PORT2 , 3}, - /* 58 */ {XMC_GPIO_PORT2 , 5}, - /* 59 */ {XMC_GPIO_PORT2 , 9}, - /* 60 */ {XMC_GPIO_PORT2 , 8}, - - //Additional pins for port X2 starting here - /* 61 */ {XMC_GPIO_PORT14 , 8}, - /* 62 */ {XMC_GPIO_PORT15 , 2}, - /* 63 */ {XMC_GPIO_PORT14 , 15}, - /* 64 */ {XMC_GPIO_PORT15 , 9}, - /* 65 */ {XMC_GPIO_PORT14 , 6}, - /* 66 */ {XMC_GPIO_PORT14 , 12}, - /* 67 */ {XMC_GPIO_PORT14 , 14}, - /* 68 */ {XMC_GPIO_PORT3 , 0}, - /* 69 */ {XMC_GPIO_PORT3 , 2}, - /* 70 */ {XMC_GPIO_PORT0 , 10}, - /* 71 */ {XMC_GPIO_PORT0 , 1}, - /* 72 */ {XMC_GPIO_PORT0 , 3}, - /* 73 */ {XMC_GPIO_PORT0 , 5}, - /* 74 */ {XMC_GPIO_PORT0 , 11}, - /* 75 */ {XMC_GPIO_PORT3 , 3}, - /* 76 */ {XMC_GPIO_PORT3 , 5}, - /* 77 */ {XMC_GPIO_PORT0 , 7}, - /* 78 */ {XMC_GPIO_PORT0 , 8}, - /* 79 */ {XMC_GPIO_PORT3 , 6}, - /* 80 */ {XMC_GPIO_PORT3 , 4}, - /* 81 */ {XMC_GPIO_PORT0 , 12}, - /* 82 */ {XMC_GPIO_PORT0 , 6}, - /* 83 */ {XMC_GPIO_PORT0 , 4}, - /* 84 */ {XMC_GPIO_PORT0 , 2}, - /* 85 */ {XMC_GPIO_PORT0 , 0}, - /* 86 */ {XMC_GPIO_PORT0 , 9}, - /* 87 */ {XMC_GPIO_PORT3 , 1}, - /* 88 */ {XMC_GPIO_PORT14 , 4}, - /* 89 */ {XMC_GPIO_PORT14 , 13}, - /* 90 */ {XMC_GPIO_PORT14 , 7}, - /* 91 */ {XMC_GPIO_PORT14 , 5}, - /* 92 */ {XMC_GPIO_PORT14 , 3}, - /* 93 */ {XMC_GPIO_PORT15 , 3}, - /* 94 */ {XMC_GPIO_PORT14 , 9} - -// //Define extra pins for Slot 1 & Slot 2 here - -// /* 95 */ {XMC_GPIO_PORT3 , 5}, // Chip Select - Slot 1 P3.5 -// /* 96 */ {XMC_GPIO_PORT1 , 7}, // Chip Select - Slot 2 P1.7 + /* 0 */ {XMC_GPIO_PORT2, 15}, // RX P2.15 + /* 1 */ {XMC_GPIO_PORT2, 14}, // TX P2.14 + /* 2 */ {XMC_GPIO_PORT1, 0}, // GPIO / External INT 0 P1.0 + /* 3 */ {XMC_GPIO_PORT3, 6}, // PWM42-0 / External INT 1 P3.6 + /* 4 */ {XMC_GPIO_PORT1, 6}, // GPIO P1.6 + /* 5 */ {XMC_GPIO_PORT3, 3}, // PWM42-3 output P3.3 + /* 6 */ {XMC_GPIO_PORT3, 4}, // PWM42-2 output P3.4 + /* 7 */ {XMC_GPIO_PORT1, 14}, // GPIO P1.14 + /* 8 */ {XMC_GPIO_PORT4, 1}, // GPIO P4.1 + /* 9 */ {XMC_GPIO_PORT0, 11}, // PWM80-31 output P0.11 + /* 10 */ {XMC_GPIO_PORT0, 2}, // SPI-SS / PWM80-01 output P0.2 + /* 11 */ {XMC_GPIO_PORT1, 9}, // SPI-MOSI / PWM41-2 output P1.9 + /* 12 */ {XMC_GPIO_PORT0, 0}, // SPI-MISO P0.0 + /* 13 */ {XMC_GPIO_PORT1, 8}, // SPI-SCK P1.8 + /* 14 */ {XMC_GPIO_PORT2, 3}, // AREF TODO: P2.3 + /* 15 */ {XMC_GPIO_PORT2, 5}, // I2C Data / Address SDA / A4 P2.5 (Hardwired to A4) + /* 16 */ {XMC_GPIO_PORT3, 0}, // I2C Clock SCL / A5 P3.0 (Hardwired to A5) + /* 17 */ {XMC_GPIO_PORT14, 0}, // A0 / ADC Input P14.0 (INPUT ONLY) + /* 18 */ {XMC_GPIO_PORT14, 1}, // A1 / ADC Input P14.1 (INPUT ONLY) + /* 19 */ {XMC_GPIO_PORT14, 2}, // A2 / ADC Input P14.2 (INPUT ONLY) + /* 20 */ {XMC_GPIO_PORT14, 3}, // A3 / ADC Input P14.3 (INPUT ONLY) + /* 21 */ {XMC_GPIO_PORT14, 4}, // A4 / ADC Input / SDA P14.4 (Hardwired to SDA) + /* 22 */ {XMC_GPIO_PORT14, 5}, // A5 / ADC Input / SCL P14.5 (Hardwired to SCL) + /* 23 */ {XMC_GPIO_PORT1, 15}, // USB Debug RX P1.15 + /* 24 */ {XMC_GPIO_PORT0, 5}, // USB Debug TX P0.5 + + //Additional pins for port X1 starting here + /* 25 */ {XMC_GPIO_PORT2, 10}, + /* 26 */ {XMC_GPIO_PORT2, 8}, + /* 27 */ {XMC_GPIO_PORT2, 4}, + /* 28 */ {XMC_GPIO_PORT2, 2}, + /* 29 */ {XMC_GPIO_PORT2, 0}, + /* 30 */ {XMC_GPIO_PORT2, 6}, + /* 31 */ {XMC_GPIO_PORT5, 2}, + /* 32 */ {XMC_GPIO_PORT5, 0}, + /* 33 */ {XMC_GPIO_PORT1, 14}, + /* 34 */ {XMC_GPIO_PORT1, 12}, + /* 35 */ {XMC_GPIO_PORT1, 10}, + /* 36 */ {XMC_GPIO_PORT1, 4}, + /* 37 */ {XMC_GPIO_PORT1, 2}, + /* 38 */ {XMC_GPIO_PORT1, 0}, + /* 39 */ {XMC_GPIO_PORT1, 8}, + /* 40 */ {XMC_GPIO_PORT1, 6}, + /* 41 */ {XMC_GPIO_PORT4, 0}, + /* 42 */ {XMC_GPIO_PORT2, 14}, + /* 43 */ {XMC_GPIO_PORT2, 15}, + /* 44 */ {XMC_GPIO_PORT4, 1}, + /* 45 */ {XMC_GPIO_PORT1, 7}, + /* 46 */ {XMC_GPIO_PORT1, 9}, + /* 47 */ {XMC_GPIO_PORT1, 1}, + /* 48 */ {XMC_GPIO_PORT1, 3}, + /* 49 */ {XMC_GPIO_PORT1, 5}, + /* 50 */ {XMC_GPIO_PORT1, 11}, + /* 51 */ {XMC_GPIO_PORT1, 13}, + /* 52 */ {XMC_GPIO_PORT1, 15}, + /* 53 */ {XMC_GPIO_PORT5, 1}, + /* 54 */ {XMC_GPIO_PORT5, 7}, + /* 55 */ {XMC_GPIO_PORT2, 7}, + /* 56 */ {XMC_GPIO_PORT2, 1}, + /* 57 */ {XMC_GPIO_PORT2, 3}, + /* 58 */ {XMC_GPIO_PORT2, 5}, + /* 59 */ {XMC_GPIO_PORT2, 9}, + /* 60 */ {XMC_GPIO_PORT2, 8}, + + //Additional pins for port X2 starting here + /* 61 */ {XMC_GPIO_PORT14, 8}, + /* 62 */ {XMC_GPIO_PORT15, 2}, + /* 63 */ {XMC_GPIO_PORT14, 15}, + /* 64 */ {XMC_GPIO_PORT15, 9}, + /* 65 */ {XMC_GPIO_PORT14, 6}, + /* 66 */ {XMC_GPIO_PORT14, 12}, + /* 67 */ {XMC_GPIO_PORT14, 14}, + /* 68 */ {XMC_GPIO_PORT3, 0}, + /* 69 */ {XMC_GPIO_PORT3, 2}, + /* 70 */ {XMC_GPIO_PORT0, 10}, + /* 71 */ {XMC_GPIO_PORT0, 1}, + /* 72 */ {XMC_GPIO_PORT0, 3}, + /* 73 */ {XMC_GPIO_PORT0, 5}, + /* 74 */ {XMC_GPIO_PORT0, 11}, + /* 75 */ {XMC_GPIO_PORT3, 3}, + /* 76 */ {XMC_GPIO_PORT3, 5}, + /* 77 */ {XMC_GPIO_PORT0, 7}, + /* 78 */ {XMC_GPIO_PORT0, 8}, + /* 79 */ {XMC_GPIO_PORT3, 6}, + /* 80 */ {XMC_GPIO_PORT3, 4}, + /* 81 */ {XMC_GPIO_PORT0, 12}, + /* 82 */ {XMC_GPIO_PORT0, 6}, + /* 83 */ {XMC_GPIO_PORT0, 4}, + /* 84 */ {XMC_GPIO_PORT0, 2}, + /* 85 */ {XMC_GPIO_PORT0, 0}, + /* 86 */ {XMC_GPIO_PORT0, 9}, + /* 87 */ {XMC_GPIO_PORT3, 1}, + /* 88 */ {XMC_GPIO_PORT14, 4}, + /* 89 */ {XMC_GPIO_PORT14, 13}, + /* 90 */ {XMC_GPIO_PORT14, 7}, + /* 91 */ {XMC_GPIO_PORT14, 5}, + /* 92 */ {XMC_GPIO_PORT14, 3}, + /* 93 */ {XMC_GPIO_PORT15, 3}, + /* 94 */ {XMC_GPIO_PORT14, 9} + +// //Define extra pins for Slot 1 & Slot 2 here +// /* 95 */ {XMC_GPIO_PORT3, 5}, // Chip Select - Slot 1 P3.5 +// /* 96 */ {XMC_GPIO_PORT1, 7}, // Chip Select - Slot 2 P1.7 }; const XMC_PIN_INTERRUPT_t mapping_interrupt[] = @@ -248,64 +240,62 @@ const XMC_PIN_INTERRUPT_t mapping_interrupt[] = XMC_PWM4_t mapping_pwm4[] = { - {CCU42, CCU42_CC40, 0, mapping_port_pin[3] , P3_6_AF_CCU42_OUT0 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 3 P3.6 - {CCU42, CCU42_CC43, 3, mapping_port_pin[5] , P3_3_AF_CCU42_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 5 P3.3 - {CCU42, CCU42_CC42, 2, mapping_port_pin[6] , P3_4_AF_CCU42_OUT2 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 6 P3.4 - - //additional pwm outputs starting here - {CCU41, CCU41_CC41, 1, mapping_port_pin[27] , P2_4_AF_CCU41_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 27 P2.4 - {CCU41, CCU41_CC43, 3, mapping_port_pin[28] , P2_2_AF_CCU41_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 28 P2.2 - {CCU41, CCU41_CC42, 2, mapping_port_pin[57] , P2_3_AF_CCU41_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 57 P2.3 - {CCU41, CCU41_CC41, 0, mapping_port_pin[58] , P2_5_AF_CCU41_OUT0 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 58 P2.5 - + {CCU42, CCU42_CC40, 0, mapping_port_pin[3], P3_6_AF_CCU42_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 3 P3.6 + {CCU42, CCU42_CC43, 3, mapping_port_pin[5], P3_3_AF_CCU42_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 5 P3.3 + {CCU42, CCU42_CC42, 2, mapping_port_pin[6], P3_4_AF_CCU42_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 6 P3.4 + + //additional pwm outputs starting here + {CCU41, CCU41_CC41, 1, mapping_port_pin[27], P2_4_AF_CCU41_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 27 P2.4 + {CCU41, CCU41_CC43, 3, mapping_port_pin[28], P2_2_AF_CCU41_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 28 P2.2 + {CCU41, CCU41_CC42, 2, mapping_port_pin[57], P2_3_AF_CCU41_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 57 P2.3 + {CCU41, CCU41_CC41, 0, mapping_port_pin[58], P2_5_AF_CCU41_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 58 P2.5 }; XMC_PWM8_t mapping_pwm8[] = { - {CCU80, CCU80_CC83, 3, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[9], P0_11_AF_CCU80_OUT31, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 9 P0.11 - {CCU80, CCU80_CC80, 0, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[10], P0_2_AF_CCU80_OUT01, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 10 P0.2 - - //additional pwm outputs starting here - {CCU80, CCU80_CC80, 0, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[55], P2_7_AF_CCU80_OUT03, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 55 P2.7 - {CCU80, CCU80_CC81, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[86], P0_9_AF_CCU80_OUT12, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 86 P0.9 - {CCU80, CCU80_CC81, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[30], P2_6_AF_CCU80_OUT13, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 30 P2.6 - {CCU80, CCU80_CC82, 2, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[59], P2_9_AF_CCU80_OUT22, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 59 P2.9 - {CCU80, CCU80_CC83, 3, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[26], P2_8_AF_CCU80_OUT32, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 26 P2.8 - {CCU81, CCU81_CC80, 0, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[54], P5_7_AF_CCU81_OUT02, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 54 P5.7 - {CCU81, CCU81_CC82, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[29], P2_0_AF_CCU81_OUT21, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED} // PWM disabled 29 P2.0 -/* {CCU81, CCU81_CC81, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[82], P5_5_AF_CCU81_OUT12, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 82 P5.5 - {CCU81, CCU81_CC82, 2, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[81], P5_3_AF_CCU81_OUT22, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED} // PWM disabled 81 P5.3*/ + {CCU80, CCU80_CC83, 3, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[9], P0_11_AF_CCU80_OUT31, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 9 P0.11 + {CCU80, CCU80_CC80, 0, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[10], P0_2_AF_CCU80_OUT01, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 10 P0.2 + + //additional pwm outputs starting here + {CCU80, CCU80_CC80, 0, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[55], P2_7_AF_CCU80_OUT03, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 55 P2.7 + {CCU80, CCU80_CC81, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[86], P0_9_AF_CCU80_OUT12, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 86 P0.9 + {CCU80, CCU80_CC81, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[30], P2_6_AF_CCU80_OUT13, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 30 P2.6 + {CCU80, CCU80_CC82, 2, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[59], P2_9_AF_CCU80_OUT22, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 59 P2.9 + {CCU80, CCU80_CC83, 3, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[26], P2_8_AF_CCU80_OUT32, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 26 P2.8 + {CCU81, CCU81_CC80, 0, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[54], P5_7_AF_CCU81_OUT02, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 54 P5.7 + {CCU81, CCU81_CC82, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[29], P2_0_AF_CCU81_OUT21, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED} // PWM disabled 29 P2.0 +/* {CCU81, CCU81_CC81, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[82], P5_5_AF_CCU81_OUT12, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED}, // PWM disabled 82 P5.5 + {CCU81, CCU81_CC82, 2, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[81], P5_3_AF_CCU81_OUT22, XMC_CCU8_SLICE_PRESCALER_64, PWM8_TIMER_PERIOD, DISABLED} // PWM disabled 81 P5.3*/ }; XMC_ARD_DAC_t mapping_dac[] = { - {XMC_DAC0, 1, 12}, - {XMC_DAC0, 0, 12} + {XMC_DAC0, 1, 12}, + {XMC_DAC0, 0, 12} }; XMC_ADC_t mapping_adc[] = { - //Result reg numbers are now equal to channel numbers - {VADC, 0, VADC_G0, 0, 0, DISABLED}, + //Result reg numbers are now equal to channel numbers + {VADC, 0, VADC_G0, 0, 0, DISABLED}, {VADC, 1, VADC_G0, 0, 1, DISABLED}, {VADC, 2, VADC_G1, 1, 2, DISABLED}, {VADC, 3, VADC_G1, 1, 3, DISABLED}, {VADC, 0, VADC_G2, 2, 0, DISABLED}, {VADC, 1, VADC_G2, 2, 1, DISABLED}, - //Additional ADC channels starting here - {VADC, 6, VADC_G2, 2, 6, DISABLED}, - {VADC, 5, VADC_G2, 2, 5, DISABLED}, - {VADC, 3, VADC_G2, 2, 3, DISABLED}, - {VADC, 7, VADC_G1, 1, 7, DISABLED}, - {VADC, 5, VADC_G1, 1, 5, DISABLED}, - {VADC, 7, VADC_G0, 0, 7, DISABLED}, - {VADC, 7, VADC_G3, 3, 7, DISABLED}, - {VADC, 1, VADC_G1, 1, 1, DISABLED}, - {VADC, 0, VADC_G1, 1, 0, DISABLED}, - {VADC, 6, VADC_G3, 3, 6, DISABLED}, - {VADC, 6, VADC_G0, 0, 6, DISABLED}, - {VADC, 4, VADC_G1, 1, 4, DISABLED}, - + //Additional ADC channels starting here + {VADC, 6, VADC_G2, 2, 6, DISABLED}, + {VADC, 5, VADC_G2, 2, 5, DISABLED}, + {VADC, 3, VADC_G2, 2, 3, DISABLED}, + {VADC, 7, VADC_G1, 1, 7, DISABLED}, + {VADC, 5, VADC_G1, 1, 5, DISABLED}, + {VADC, 7, VADC_G0, 0, 7, DISABLED}, + {VADC, 7, VADC_G3, 3, 7, DISABLED}, + {VADC, 1, VADC_G1, 1, 1, DISABLED}, + {VADC, 0, VADC_G1, 1, 0, DISABLED}, + {VADC, 6, VADC_G3, 3, 6, DISABLED}, + {VADC, 6, VADC_G0, 0, 6, DISABLED}, + {VADC, 4, VADC_G1, 1, 4, DISABLED}, }; /* @@ -431,7 +421,7 @@ Serial1.IrqHandler(); #ifdef __cplusplus } -#endif +#endif #endif /* ARDUINO_MAIN*/ #ifdef __cplusplus @@ -440,4 +430,3 @@ extern HardwareSerial Serial1; #endif /* cplusplus */ #endif - diff --git a/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h b/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h index 63c46073..9cfac3db 100644 --- a/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h +++ b/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h @@ -155,108 +155,108 @@ const uint8_t mapping_pin_DAC[][ 2 ] = { const XMC_PORT_PIN_t mapping_port_pin[] = { - /* 0 */ {XMC_GPIO_PORT2, 15}, // RX P2.15 - /* 1 */ {XMC_GPIO_PORT2 , 14}, // TX P2.14 - /* 2 */ {XMC_GPIO_PORT1 , 0}, // GPIO / External INT 0 P1.0 - /* 3 */ {XMC_GPIO_PORT1 , 1}, // PWM40-2 / External INT 1 P1.1 - /* 4 */ {XMC_GPIO_PORT1 , 8}, // GPIO P1.8 - /* 5 */ {XMC_GPIO_PORT2 , 12}, // PWM81-3 output P2.12 - /* 6 */ {XMC_GPIO_PORT2 , 11}, // PWM80-2 output P2.11 - /* 7 */ {XMC_GPIO_PORT1 , 9}, // GPIO P1.9 - /* 8 */ {XMC_GPIO_PORT1 , 10}, // GPIO P1.10 - /* 9 */ {XMC_GPIO_PORT1 , 11}, // PWM81-1 output P1.11 - /* 10 */ {XMC_GPIO_PORT3 , 10}, // SPI-SS / PWM41-0 output P3.10 - /* 11 */ {XMC_GPIO_PORT3 , 8}, // SPI-MOSI / PWM41-2 output P3.8 - /* 12 */ {XMC_GPIO_PORT3 , 7}, // SPI-MISO P3.7 - /* 13 */ {XMC_GPIO_PORT3 , 9}, // SPI-SCK P3.9 - /* 14 */ {XMC_GPIO_PORT2 , 3}, // AREF TODO: P2.3 - /* 15 */ {XMC_GPIO_PORT3 , 15}, // I2C Data / Address SDA P3.15 - /* 16 */ {XMC_GPIO_PORT0 , 13}, // I2C Clock SCL P0.13 - /* 17 */ {XMC_GPIO_PORT14 , 0}, // A0 / ADC Input P14.0 (INPUT ONLY) - /* 18 */ {XMC_GPIO_PORT14 , 1}, // A1 / ADC Input P14.1 (INPUT ONLY) - /* 19 */ {XMC_GPIO_PORT14 , 2}, // A2 / ADC Input P14.2 (INPUT ONLY) - /* 20 */ {XMC_GPIO_PORT14 , 3}, // A3 / ADC Input P14.3 (INPUT ONLY) - /* 21 */ {XMC_GPIO_PORT14 , 4}, // A4 / ADC Input P14.4 (INPUT ONLY) - /* 22 */ {XMC_GPIO_PORT14 , 5}, // A5 / ADC Input P14.5 (INPUT ONLY) - /* 23 */ {XMC_GPIO_PORT3 , 12}, // SPI_SS_2 P3.12 - /* 24 */ {XMC_GPIO_PORT5 , 9}, // Additional LED1 P5.9 - /* 25 */ {XMC_GPIO_PORT5 , 8}, // Additional LED2 P5.8 - /* 26 */ {XMC_GPIO_PORT15 , 13}, // Additional BUTTON1 P15.13 (INPUT ONLY) - /* 27 */ {XMC_GPIO_PORT15 , 12}, // Additional BUTTON2 P15.12 (INPUT ONLY) - /* 28 */ {XMC_GPIO_PORT4 , 1}, // SPI_SS_3 (SD CARD) P4.1 - /* 29 */ {XMC_GPIO_PORT3 , 5}, // SPI-MOSI (SD CARD) P3.5 - /* 30 */ {XMC_GPIO_PORT4 , 0}, // SPI-MISO (SD CARD) P4.0 - /* 31 */ {XMC_GPIO_PORT3 , 6}, // SPI-SCK (SD CARD) P3.6 - /* 32 */ {XMC_GPIO_PORT1 , 6}, // P1.6 - /* 33 */ {XMC_GPIO_PORT1 , 7}, // P1.7 - /* 34 */ {XMC_GPIO_PORT1 , 4}, // USB Debug RX P1.4 - /* 35 */ {XMC_GPIO_PORT1 , 5}, // USB Debug TX P1.5 + /* 0 */ {XMC_GPIO_PORT2, 15}, // RX P2.15 + /* 1 */ {XMC_GPIO_PORT2, 14}, // TX P2.14 + /* 2 */ {XMC_GPIO_PORT1, 0}, // GPIO / External INT 0 P1.0 + /* 3 */ {XMC_GPIO_PORT1, 1}, // PWM40-2 / External INT 1 P1.1 + /* 4 */ {XMC_GPIO_PORT1, 8}, // GPIO P1.8 + /* 5 */ {XMC_GPIO_PORT2, 12}, // PWM81-3 output P2.12 + /* 6 */ {XMC_GPIO_PORT2, 11}, // PWM80-2 output P2.11 + /* 7 */ {XMC_GPIO_PORT1, 9}, // GPIO P1.9 + /* 8 */ {XMC_GPIO_PORT1, 10}, // GPIO P1.10 + /* 9 */ {XMC_GPIO_PORT1, 11}, // PWM81-1 output P1.11 + /* 10 */ {XMC_GPIO_PORT3, 10}, // SPI-SS / PWM41-0 output P3.10 + /* 11 */ {XMC_GPIO_PORT3, 8}, // SPI-MOSI / PWM41-2 output P3.8 + /* 12 */ {XMC_GPIO_PORT3, 7}, // SPI-MISO P3.7 + /* 13 */ {XMC_GPIO_PORT3, 9}, // SPI-SCK P3.9 + /* 14 */ {XMC_GPIO_PORT2, 3}, // AREF TODO: P2.3 + /* 15 */ {XMC_GPIO_PORT3, 15}, // I2C Data / Address SDA / A4 P3.15 (Hardwired to A4) + /* 16 */ {XMC_GPIO_PORT0, 13}, // I2C Clock SCL / A5 P0.13 (Hardwired to A5) + /* 17 */ {XMC_GPIO_PORT14, 0}, // A0 / ADC Input P14.0 (INPUT ONLY) + /* 18 */ {XMC_GPIO_PORT14, 1}, // A1 / ADC Input P14.1 (INPUT ONLY) + /* 19 */ {XMC_GPIO_PORT14, 2}, // A2 / ADC Input P14.2 (INPUT ONLY) + /* 20 */ {XMC_GPIO_PORT14, 3}, // A3 / ADC Input P14.3 (INPUT ONLY) + /* 21 */ {XMC_GPIO_PORT14, 4}, // A4 / ADC Input / SDA P14.4 (Hardwired to SDA) + /* 22 */ {XMC_GPIO_PORT14, 5}, // A5 / ADC Input / SCL P14.5 (Hardwired to SCL) + /* 23 */ {XMC_GPIO_PORT3, 12}, // SPI_SS_2 P3.12 + /* 24 */ {XMC_GPIO_PORT5, 9}, // Additional LED1 P5.9 + /* 25 */ {XMC_GPIO_PORT5, 8}, // Additional LED2 P5.8 + /* 26 */ {XMC_GPIO_PORT15, 13}, // Additional BUTTON1 P15.13 (INPUT ONLY) + /* 27 */ {XMC_GPIO_PORT15, 12}, // Additional BUTTON2 P15.12 (INPUT ONLY) + /* 28 */ {XMC_GPIO_PORT4, 1}, // SPI_SS_3 (SD CARD) P4.1 + /* 29 */ {XMC_GPIO_PORT3, 5}, // SPI-MOSI (SD CARD) P3.5 + /* 30 */ {XMC_GPIO_PORT4, 0}, // SPI-MISO (SD CARD) P4.0 + /* 31 */ {XMC_GPIO_PORT3, 6}, // SPI-SCK (SD CARD) P3.6 + /* 32 */ {XMC_GPIO_PORT1, 6}, // P1.6 + /* 33 */ {XMC_GPIO_PORT1, 7}, // P1.7 + /* 34 */ {XMC_GPIO_PORT1, 4}, // USB Debug RX P1.4 + /* 35 */ {XMC_GPIO_PORT1, 5}, // USB Debug TX P1.5 //Additional pins for port X1 starting here - /* 36 */ {XMC_GPIO_PORT3 , 4}, // PWM42-2 P3.4 - /* 37 */ {XMC_GPIO_PORT0 , 5}, // I2C_1 SDA // SPI_4 MOSI P0.5 - /* 38 */ {XMC_GPIO_PORT0 , 3}, // PWM80-2 P0.3 - /* 39 */ {XMC_GPIO_PORT0 , 1}, // PWM80-1 P0.1 - /* 40 */ {XMC_GPIO_PORT0 , 10}, // P0.10 - /* 41 */ {XMC_GPIO_PORT3 , 2}, // P3.2 - /* 42 */ {XMC_GPIO_PORT3 , 1}, // P3.1 - /* 43 */ {XMC_GPIO_PORT15 , 6}, // A6 / ADC Input P15.6 (INPUT ONLY) - /* 44 */ {XMC_GPIO_PORT15 , 5}, // A7 / ADC Input P15.5 (INPUT ONLY) - /* 45 */ {XMC_GPIO_PORT15 , 3}, // A8 / ADC Input P15.3 (INPUT ONLY) - /* 46 */ {XMC_GPIO_PORT14 , 15}, // A9 / ADC Input P14.15 (INPUT ONLY) - /* 47 */ {XMC_GPIO_PORT14 , 13}, // A10 / ADC Input P14.13 (INPUT ONLY) - /* 48 */ {XMC_GPIO_PORT14 , 7}, // A11 / ADC Input P14.7 (INPUT ONLY) - /* 49 */ {XMC_GPIO_PORT15 , 15}, // A12 / ADC Input P15.15 (INPUT ONLY) - /* 50 */ {XMC_GPIO_PORT14 , 9}, // DAC0 // A13 / ADC Input P14.9 (INPUT ONLY) - /* 51 */ {XMC_GPIO_PORT2 , 13}, // P2.13 - /* 52 */ {XMC_GPIO_PORT5 , 10}, // P5.10 - /* 53 */ {XMC_GPIO_PORT5 , 11}, // PWM80-0 P5.11 - /* 54 */ {XMC_GPIO_PORT1 , 14}, // P1.14 - /* 55 */ {XMC_GPIO_PORT14 , 8}, // DAC1 // A14 / ADC Input P14.8 (INPUT ONLY) - /* 56 */ {XMC_GPIO_PORT15 , 14}, // A15 / ADC Input P15.14 (INPUT ONLY) - /* 57 */ {XMC_GPIO_PORT14 , 6}, // A16 / ADC Input P14.6 (INPUT ONLY) - /* 58 */ {XMC_GPIO_PORT14 , 12}, // A17 / ADC Input P14.12 (INPUT ONLY) - /* 59 */ {XMC_GPIO_PORT14 , 14}, // A18 / ADC Input P14.14 (INPUT ONLY) - /* 60 */ {XMC_GPIO_PORT15 , 2}, // A19 / ADC Input P15.2 (INPUT ONLY) - /* 61 */ {XMC_GPIO_PORT15 , 4}, // A20 / ADC Input P15.4 (INPUT ONLY) - /* 62 */ {XMC_GPIO_PORT15 , 7}, // A21 / ADC Input P15.7 (INPUT ONLY) - /* 63 */ {XMC_GPIO_PORT3 , 0}, // PWM42-0 P3.0 - /* 64 */ {XMC_GPIO_PORT0 , 9}, // PWM80-1 P0.9 - /* 65 */ {XMC_GPIO_PORT0 , 0}, // P0.0 - /* 66 */ {XMC_GPIO_PORT0 , 2}, // P0.2 - /* 67 */ {XMC_GPIO_PORT0 , 4}, // SPI_4 MISO P0.4 - /* 68 */ {XMC_GPIO_PORT0 , 6}, // PWM80-3 P0.6 - /* 69 */ {XMC_GPIO_PORT0 , 11}, // I2C_1 SCL // SPI_4 SCLK P0.11 + /* 36 */ {XMC_GPIO_PORT3, 4}, // PWM42-2 P3.4 + /* 37 */ {XMC_GPIO_PORT0, 5}, // I2C_1 SDA // SPI_4 MOSI P0.5 + /* 38 */ {XMC_GPIO_PORT0, 3}, // PWM80-2 P0.3 + /* 39 */ {XMC_GPIO_PORT0, 1}, // PWM80-1 P0.1 + /* 40 */ {XMC_GPIO_PORT0, 10}, // P0.10 + /* 41 */ {XMC_GPIO_PORT3, 2}, // P3.2 + /* 42 */ {XMC_GPIO_PORT3, 1}, // P3.1 + /* 43 */ {XMC_GPIO_PORT15, 6}, // A6 / ADC Input P15.6 (INPUT ONLY) + /* 44 */ {XMC_GPIO_PORT15, 5}, // A7 / ADC Input P15.5 (INPUT ONLY) + /* 45 */ {XMC_GPIO_PORT15, 3}, // A8 / ADC Input P15.3 (INPUT ONLY) + /* 46 */ {XMC_GPIO_PORT14, 15}, // A9 / ADC Input P14.15 (INPUT ONLY) + /* 47 */ {XMC_GPIO_PORT14, 13}, // A10 / ADC Input P14.13 (INPUT ONLY) + /* 48 */ {XMC_GPIO_PORT14, 7}, // A11 / ADC Input P14.7 (INPUT ONLY) + /* 49 */ {XMC_GPIO_PORT15, 15}, // A12 / ADC Input P15.15 (INPUT ONLY) + /* 50 */ {XMC_GPIO_PORT14, 9}, // DAC0 // A13 / ADC Input P14.9 (INPUT ONLY) + /* 51 */ {XMC_GPIO_PORT2, 13}, // P2.13 + /* 52 */ {XMC_GPIO_PORT5, 10}, // P5.10 + /* 53 */ {XMC_GPIO_PORT5, 11}, // PWM80-0 P5.11 + /* 54 */ {XMC_GPIO_PORT1, 14}, // P1.14 + /* 55 */ {XMC_GPIO_PORT14, 8}, // DAC1 // A14 / ADC Input P14.8 (INPUT ONLY) + /* 56 */ {XMC_GPIO_PORT15, 14}, // A15 / ADC Input P15.14 (INPUT ONLY) + /* 57 */ {XMC_GPIO_PORT14, 6}, // A16 / ADC Input P14.6 (INPUT ONLY) + /* 58 */ {XMC_GPIO_PORT14, 12}, // A17 / ADC Input P14.12 (INPUT ONLY) + /* 59 */ {XMC_GPIO_PORT14, 14}, // A18 / ADC Input P14.14 (INPUT ONLY) + /* 60 */ {XMC_GPIO_PORT15, 2}, // A19 / ADC Input P15.2 (INPUT ONLY) + /* 61 */ {XMC_GPIO_PORT15, 4}, // A20 / ADC Input P15.4 (INPUT ONLY) + /* 62 */ {XMC_GPIO_PORT15, 7}, // A21 / ADC Input P15.7 (INPUT ONLY) + /* 63 */ {XMC_GPIO_PORT3, 0}, // PWM42-0 P3.0 + /* 64 */ {XMC_GPIO_PORT0, 9}, // PWM80-1 P0.9 + /* 65 */ {XMC_GPIO_PORT0, 0}, // P0.0 + /* 66 */ {XMC_GPIO_PORT0, 2}, // P0.2 + /* 67 */ {XMC_GPIO_PORT0, 4}, // SPI_4 MISO P0.4 + /* 68 */ {XMC_GPIO_PORT0, 6}, // PWM80-3 P0.6 + /* 69 */ {XMC_GPIO_PORT0, 11}, // I2C_1 SCL // SPI_4 SCLK P0.11 //Additional pins for port X2 starting here - /* 70 */ {XMC_GPIO_PORT3 , 13}, // SPI_2 SCLK P3.13 - /* 71 */ {XMC_GPIO_PORT3 , 11}, // SPI_2 MOSI P3.11 - /* 72 */ {XMC_GPIO_PORT0 , 14}, // PWM40-1 P0.14 - /* 73 */ {XMC_GPIO_PORT3 , 14}, // P3.14 - /* 74 */ {XMC_GPIO_PORT0 , 7}, // P0.7 - /* 75 */ {XMC_GPIO_PORT1 , 2}, // P1.2 - /* 76 */ {XMC_GPIO_PORT6 , 1}, // P6.1 - /* 77 */ {XMC_GPIO_PORT5 , 3}, // P5.3 - /* 78 */ {XMC_GPIO_PORT6 , 5}, // PWM43-0 P6.5 - /* 79 */ {XMC_GPIO_PORT1 , 15}, // PWM81-0 P1.15 - /* 80 */ {XMC_GPIO_PORT5 , 1}, // SPI_3 MOSI P5.1 - /* 81 */ {XMC_GPIO_PORT5 , 3}, // PWM81-2 P5.3 - /* 82 */ {XMC_GPIO_PORT5 , 5}, // PWM81-1 P5.5 - /* 83 */ {XMC_GPIO_PORT5 , 7}, // PWM81-0 P5.7 - /* 84 */ {XMC_GPIO_PORT2 , 6}, // P2.6 - /* 85 */ {XMC_GPIO_PORT5 , 6}, // P5.6 - /* 86 */ {XMC_GPIO_PORT5 , 4}, // P5.4 - /* 87 */ {XMC_GPIO_PORT5 , 2}, // P5.2 - /* 88 */ {XMC_GPIO_PORT5 , 0}, // SPI_3 MISO P5.0 - /* 89 */ {XMC_GPIO_PORT6 , 6}, // P6.6 - /* 90 */ {XMC_GPIO_PORT6 , 4}, // PWM43-1 P6.4 - /* 91 */ {XMC_GPIO_PORT6 , 2}, // PWM43-3 P6.2 - /* 92 */ {XMC_GPIO_PORT6 , 0}, // P6.0 - /* 93 */ {XMC_GPIO_PORT0 , 8}, // SPI_3 SCLK P0.8 - /* 94 */ {XMC_GPIO_PORT3 , 3}, // P3.3 - /* 95 */ {XMC_GPIO_PORT0 , 15}, // PWM40-0 P0.15 - /* 96 */ {XMC_GPIO_PORT0 , 12}, // PWM40-3 P0.12 - /* 97 */ {XMC_GPIO_PORT3 , 12} // SPI_2 MISO P3.12 + /* 70 */ {XMC_GPIO_PORT3, 13}, // SPI_2 SCLK P3.13 + /* 71 */ {XMC_GPIO_PORT3, 11}, // SPI_2 MOSI P3.11 + /* 72 */ {XMC_GPIO_PORT0, 14}, // PWM40-1 P0.14 + /* 73 */ {XMC_GPIO_PORT3, 14}, // P3.14 + /* 74 */ {XMC_GPIO_PORT0, 7}, // P0.7 + /* 75 */ {XMC_GPIO_PORT1, 2}, // P1.2 + /* 76 */ {XMC_GPIO_PORT6, 1}, // P6.1 + /* 77 */ {XMC_GPIO_PORT5, 3}, // P5.3 + /* 78 */ {XMC_GPIO_PORT6, 5}, // PWM43-0 P6.5 + /* 79 */ {XMC_GPIO_PORT1, 15}, // PWM81-0 P1.15 + /* 80 */ {XMC_GPIO_PORT5, 1}, // SPI_3 MOSI P5.1 + /* 81 */ {XMC_GPIO_PORT5, 3}, // PWM81-2 P5.3 + /* 82 */ {XMC_GPIO_PORT5, 5}, // PWM81-1 P5.5 + /* 83 */ {XMC_GPIO_PORT5, 7}, // PWM81-0 P5.7 + /* 84 */ {XMC_GPIO_PORT2, 6}, // P2.6 + /* 85 */ {XMC_GPIO_PORT5, 6}, // P5.6 + /* 86 */ {XMC_GPIO_PORT5, 4}, // P5.4 + /* 87 */ {XMC_GPIO_PORT5, 2}, // P5.2 + /* 88 */ {XMC_GPIO_PORT5, 0}, // SPI_3 MISO P5.0 + /* 89 */ {XMC_GPIO_PORT6, 6}, // P6.6 + /* 90 */ {XMC_GPIO_PORT6, 4}, // PWM43-1 P6.4 + /* 91 */ {XMC_GPIO_PORT6, 2}, // PWM43-3 P6.2 + /* 92 */ {XMC_GPIO_PORT6, 0}, // P6.0 + /* 93 */ {XMC_GPIO_PORT0, 8}, // SPI_3 SCLK P0.8 + /* 94 */ {XMC_GPIO_PORT3, 3}, // P3.3 + /* 95 */ {XMC_GPIO_PORT0, 15}, // PWM40-0 P0.15 + /* 96 */ {XMC_GPIO_PORT0, 12}, // PWM40-3 P0.12 + /* 97 */ {XMC_GPIO_PORT3, 12} // SPI_2 MISO P3.12 }; const XMC_PIN_INTERRUPT_t mapping_interrupt[] = @@ -267,18 +267,18 @@ const XMC_PIN_INTERRUPT_t mapping_interrupt[] = XMC_PWM4_t mapping_pwm4[] = { - {CCU40, CCU40_CC42, 2, mapping_port_pin[3] , P1_1_AF_CCU40_OUT2 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 3 P1.1 + {CCU40, CCU40_CC42, 2, mapping_port_pin[3], P1_1_AF_CCU40_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 3 P1.1 {CCU41, CCU41_CC40, 0, mapping_port_pin[10], P3_10_AF_CCU41_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 10 P3.10 - {CCU41, CCU41_CC42, 2, mapping_port_pin[11], P3_8_AF_CCU41_OUT2 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 11 P3.8 + {CCU41, CCU41_CC42, 2, mapping_port_pin[11], P3_8_AF_CCU41_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 11 P3.8 //additional pwm outputs starting here - {CCU40, CCU40_CC40, 0, mapping_port_pin[95] , P0_15_AF_CCU40_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 95 P0.15 - {CCU40, CCU40_CC41, 1, mapping_port_pin[72] , P0_14_AF_CCU40_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 72 P0.14 - {CCU40, CCU40_CC43, 3, mapping_port_pin[96] , P0_12_AF_CCU40_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 96 P0.12 - {CCU42, CCU42_CC40, 0, mapping_port_pin[63] , P3_0_AF_CCU42_OUT0 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 63 P3.0 - {CCU42, CCU42_CC42, 2, mapping_port_pin[36] , P3_4_AF_CCU42_OUT2 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 36 P3.4 - {CCU43, CCU43_CC40, 0, mapping_port_pin[78] , P6_5_AF_CCU43_OUT0 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 78 P6.5 - {CCU43, CCU43_CC41, 1, mapping_port_pin[90] , P6_4_AF_CCU43_OUT1 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 90 P6.4 - {CCU43, CCU43_CC43, 3, mapping_port_pin[91] , P6_2_AF_CCU43_OUT3 , XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED} // PWM disabled 91 P6.2 + {CCU40, CCU40_CC40, 0, mapping_port_pin[95], P0_15_AF_CCU40_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 95 P0.15 + {CCU40, CCU40_CC41, 1, mapping_port_pin[72], P0_14_AF_CCU40_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 72 P0.14 + {CCU40, CCU40_CC43, 3, mapping_port_pin[96], P0_12_AF_CCU40_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 96 P0.12 + {CCU42, CCU42_CC40, 0, mapping_port_pin[63], P3_0_AF_CCU42_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 63 P3.0 + {CCU42, CCU42_CC42, 2, mapping_port_pin[36], P3_4_AF_CCU42_OUT2, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 36 P3.4 + {CCU43, CCU43_CC40, 0, mapping_port_pin[78], P6_5_AF_CCU43_OUT0, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 78 P6.5 + {CCU43, CCU43_CC41, 1, mapping_port_pin[90], P6_4_AF_CCU43_OUT1, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED}, // PWM disabled 90 P6.4 + {CCU43, CCU43_CC43, 3, mapping_port_pin[91], P6_2_AF_CCU43_OUT3, XMC_CCU4_SLICE_PRESCALER_64, PWM4_TIMER_PERIOD, DISABLED} // PWM disabled 91 P6.2 }; XMC_PWM8_t mapping_pwm8[] = diff --git a/variants/XMC4800/config/XMC4800_Relax_Kit/pins_arduino.h b/variants/XMC4800/config/XMC4800_Relax_Kit/pins_arduino.h index 04e6ec70..892865a5 100644 --- a/variants/XMC4800/config/XMC4800_Relax_Kit/pins_arduino.h +++ b/variants/XMC4800/config/XMC4800_Relax_Kit/pins_arduino.h @@ -31,7 +31,7 @@ Boston, MA 02111-1307 USA // @Defines //**************************************************************************** // XMC_BOARD for stringifying into serial or other text outputs/logs -// Note the actual name XMC and number MUST have a character between +// Note the actual name XMC and number MUST have a character between // to avoid issues with other defined macros e.g. XMC1100 #define XMC_BOARD XMC 4800 Relax Kit /* On board LED is ON when digital output is 0, LOW, False, OFF */ @@ -53,14 +53,14 @@ Boston, MA 02111-1307 USA #define PWM4_TIMER_PERIOD (0x11EF) // Generate 490Hz @fCCU=144MHz #define PWM8_TIMER_PERIOD (0x11EF) // Generate 490Hz @fCCU=144MHz -#define PCLK 144000000u - +#define PCLK 144000000u + #define PIN_SPI_SS 10 #define PIN_SPI_MOSI 11 #define PIN_SPI_MISO 12 #define PIN_SPI_SCK 13 -extern uint8_t SS; +extern uint8_t SS; extern uint8_t MOSI; extern uint8_t MISO; extern uint8_t SCK; @@ -82,12 +82,12 @@ static const uint8_t SCK_SD = PIN_SPI_SCK_SD; #define A4 4 #define A5 5 -#define LED_BUILTIN 13 // Standard Arduino LED -#define LED1 24 // Additional LED1 -#define LED2 25 // Additional LED2 -#define BUTTON1 26 // Additional BUTTON1 -#define BUTTON2 27 // Additional BUTTON2 -#define GND 50 // GND +#define LED_BUILTIN 13 // Standard Arduino LED +#define LED1 24 // Additional LED1 +#define LED2 25 // Additional LED2 +#define BUTTON1 26 // Additional BUTTON1 +#define BUTTON2 27 // Additional BUTTON2 +#define GND 50 // GND #define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0)) @@ -116,67 +116,68 @@ const uint8_t mapping_pin_PWM8[][ 2 ] = { // appropriate addresses for various functions (e.g. reading // and writing) -const XMC_PORT_PIN_t mapping_port_pin[] = { - /* 0 */ {XMC_GPIO_PORT2, 15}, // RX P2.15 - /* 1 */ {XMC_GPIO_PORT2 ,14}, // TX P2.14 - /* 2 */ {XMC_GPIO_PORT1 ,0}, // GPIO / External INT 0 P1.0 - /* 3 */ {XMC_GPIO_PORT1 ,1}, // PWM40-0 output / External INT 1 P1.1 - /* 4 */ {XMC_GPIO_PORT1 ,8}, // GPIO P1.8 - /* 5 */ {XMC_GPIO_PORT2 ,12}, // PWM8-0 output P2.12 - /* 6 */ {XMC_GPIO_PORT2 ,11}, // PWM8-1 output P2.11 - /* 7 */ {XMC_GPIO_PORT1 ,9}, // GPIO P1.9 - /* 8 */ {XMC_GPIO_PORT1 ,10}, // GPIO P1.10 - /* 9 */ {XMC_GPIO_PORT1 ,11}, // PWM8-2 output P1.11 - /* 10 */ {XMC_GPIO_PORT3 ,10}, // SPI-SS / PWM4-1 output // TODO: SPI_SS_1 P3.10 - /* 11 */ {XMC_GPIO_PORT3 ,8}, // SPI-MOSI / PWM4-2 output P3.8 - /* 12 */ {XMC_GPIO_PORT3 ,7}, // SPI-MISO P3.7 - /* 13 */ {XMC_GPIO_PORT3 ,9}, // SPI-SCK / LED BUILTIN P3.9 - /* 14 */ {XMC_GPIO_PORT2 ,3}, // AREF TODO: P2.3 - /* 15 */ {XMC_GPIO_PORT3 ,15}, // I2C Data / Address SDA P3.15 - /* 16 */ {XMC_GPIO_PORT0 ,13}, // I2C Clock SCL P3.13 - /* 17 */ {XMC_GPIO_PORT14 ,0}, // A0 / ADC Input P14.0 (INPUT ONLY) - /* 18 */ {XMC_GPIO_PORT14 ,1}, // A1 / ADC Input P14.1 (INPUT ONLY) - /* 19 */ {XMC_GPIO_PORT14 ,2}, // A2 / ADC Input P14.2 (INPUT ONLY) - /* 20 */ {XMC_GPIO_PORT14 ,3}, // A3 / ADC Input P14.3 (INPUT ONLY) - /* 21 */ {XMC_GPIO_PORT14 ,4}, // A4 / ADC Input P14.4 (INPUT ONLY) - /* 22 */ {XMC_GPIO_PORT14 ,5}, // A5 / ADC Input P14.5 (INPUT ONLY) - /* 23 */ {XMC_GPIO_PORT3 ,10}, // SPI_SS_2 P3.10 - /* 24 */ {XMC_GPIO_PORT5 ,9}, // Additional LED1 P5.9 - /* 25 */ {XMC_GPIO_PORT5 ,8}, // Additional LED2 P5.8 - /* 26 */ {XMC_GPIO_PORT15 ,13}, // Additional BUTTON1 P15.13 (INPUT ONLY) - /* 27 */ {XMC_GPIO_PORT15 ,12}, // Additional BUTTON2 P15.12 (INPUT ONLY) - /* 28 */ {XMC_GPIO_PORT4 ,1}, // SPI_SS_3 (SD CARD) P4.1 - /* 29 */ {XMC_GPIO_PORT3 ,5}, // SPI-MOSI (SD CARD) P3.5 - /* 30 */ {XMC_GPIO_PORT4 ,0}, // SPI-MISO (SD CARD) P4.0 - /* 31 */ {XMC_GPIO_PORT3 ,6}, // SPI-SCK (SD CARD) P3.6 - /* 32 */ {XMC_GPIO_PORT1 ,6}, // P1.6 - /* 33 */ {XMC_GPIO_PORT1 ,7} // P1.7 +const XMC_PORT_PIN_t mapping_port_pin[] = +{ + /* 0 */ {XMC_GPIO_PORT2, 15}, // RX P2.15 + /* 1 */ {XMC_GPIO_PORT2 ,14}, // TX P2.14 + /* 2 */ {XMC_GPIO_PORT1 ,0}, // GPIO / External INT 0 P1.0 + /* 3 */ {XMC_GPIO_PORT1 ,1}, // PWM40-0 / External INT 1 P1.1 + /* 4 */ {XMC_GPIO_PORT1 ,8}, // GPIO P1.8 + /* 5 */ {XMC_GPIO_PORT2 ,12}, // PWM8-0 P2.12 + /* 6 */ {XMC_GPIO_PORT2 ,11}, // PWM8-1 P2.11 + /* 7 */ {XMC_GPIO_PORT1 ,9}, // GPIO P1.9 + /* 8 */ {XMC_GPIO_PORT1 ,10}, // GPIO P1.10 + /* 9 */ {XMC_GPIO_PORT1 ,11}, // PWM8-2 output P1.11 + /* 10 */ {XMC_GPIO_PORT3 ,10}, // SPI-SS / PWM4-1 // TODO: SPI_SS_1 P3.10 + /* 11 */ {XMC_GPIO_PORT3 ,8}, // SPI-MOSI / PWM4-2 P3.8 + /* 12 */ {XMC_GPIO_PORT3 ,7}, // SPI-MISO P3.7 + /* 13 */ {XMC_GPIO_PORT3 ,9}, // SPI-SCK / LED BUILTIN P3.9 + /* 14 */ {XMC_GPIO_PORT2 ,3}, // AREF TODO: P2.3 + /* 15 */ {XMC_GPIO_PORT3 ,15}, // I2C Data / Address SDA / A4 P3.15 (Hardwired to A4) + /* 16 */ {XMC_GPIO_PORT0 ,13}, // I2C Clock SCL / A5 P0.13 (Hardwired to A5) + /* 17 */ {XMC_GPIO_PORT14 ,0}, // A0 / ADC Input P14.0 (INPUT ONLY) + /* 18 */ {XMC_GPIO_PORT14 ,1}, // A1 / ADC Input P14.1 (INPUT ONLY) + /* 19 */ {XMC_GPIO_PORT14 ,2}, // A2 / ADC Input P14.2 (INPUT ONLY) + /* 20 */ {XMC_GPIO_PORT14 ,3}, // A3 / ADC Input P14.3 (INPUT ONLY) + /* 21 */ {XMC_GPIO_PORT14 ,4}, // A4 / ADC Input / SDA P14.4 (Hardwired to SDA) + /* 22 */ {XMC_GPIO_PORT14 ,5}, // A5 / ADC Input / SCL P14.5 (Hardwired to SCL) + /* 23 */ {XMC_GPIO_PORT3 ,10}, // SPI_SS_2 P3.10 + /* 24 */ {XMC_GPIO_PORT5 ,9}, // Additional LED1 P5.9 + /* 25 */ {XMC_GPIO_PORT5 ,8}, // Additional LED2 P5.8 + /* 26 */ {XMC_GPIO_PORT15 ,13}, // Additional BUTTON1 P15.13 (INPUT ONLY) + /* 27 */ {XMC_GPIO_PORT15 ,12}, // Additional BUTTON2 P15.12 (INPUT ONLY) + /* 28 */ {XMC_GPIO_PORT4 ,1}, // SPI_SS_3 (SD CARD) P4.1 + /* 29 */ {XMC_GPIO_PORT3 ,5}, // SPI-MOSI (SD CARD) P3.5 + /* 30 */ {XMC_GPIO_PORT4 ,0}, // SPI-MISO (SD CARD) P4.0 + /* 31 */ {XMC_GPIO_PORT3 ,6}, // SPI-SCK (SD CARD) P3.6 + /* 32 */ {XMC_GPIO_PORT1 ,6}, // P1.6 + /* 33 */ {XMC_GPIO_PORT1 ,7} // P1.7 }; const XMC_PIN_INTERRUPT_t mapping_interrupt[] = { - /* 0 */ {CCU40, CCU40_CC43, 3, 0, CCU40_IN3_P1_0}, - /* 1 */ {CCU40, CCU40_CC42, 2, 1, CCU40_IN2_P1_1} + /* 0 */ {CCU40, CCU40_CC43, 3, 0, CCU40_IN3_P1_0}, + /* 1 */ {CCU40, CCU40_CC42, 2, 1, CCU40_IN2_P1_1} }; XMC_PWM4_t mapping_pwm4[] ={ - {CCU40, CCU40_CC42, 2, mapping_port_pin[3], P1_1_AF_CCU40_OUT2, DISABLED}, // PWM disabled 3 P1.1 - {CCU41, CCU41_CC40, 0, mapping_port_pin[10], P3_10_AF_CCU41_OUT0, DISABLED}, // PWM disabled 10 P3.10 - {CCU41, CCU41_CC42, 2, mapping_port_pin[11], P3_8_AF_CCU41_OUT2, DISABLED} // PWM disabled 11 P3.8 + {CCU40, CCU40_CC42, 2, mapping_port_pin[3], P1_1_AF_CCU40_OUT2, DISABLED}, // PWM disabled 3 P1.1 + {CCU41, CCU41_CC40, 0, mapping_port_pin[10], P3_10_AF_CCU41_OUT0, DISABLED}, // PWM disabled 10 P3.10 + {CCU41, CCU41_CC42, 2, mapping_port_pin[11], P3_8_AF_CCU41_OUT2, DISABLED} // PWM disabled 11 P3.8 }; XMC_PWM8_t mapping_pwm8[] ={ - {CCU81, CCU81_CC83, 3, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[5], P2_12_AF_CCU81_OUT33, DISABLED}, // PWM disabled 5 P2.12 - {CCU80, CCU80_CC82, 2, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[6], P2_11_AF_CCU80_OUT22, DISABLED}, // PWM disabled 6 P2.11 - {CCU81, CCU81_CC81, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[9], P1_11_AF_CCU81_OUT11, DISABLED} // PWM disabled 9 P1.11 + {CCU81, CCU81_CC83, 3, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[5], P2_12_AF_CCU81_OUT33, DISABLED}, // PWM disabled 5 P2.12 + {CCU80, CCU80_CC82, 2, XMC_CCU8_SLICE_COMPARE_CHANNEL_2, mapping_port_pin[6], P2_11_AF_CCU80_OUT22, DISABLED}, // PWM disabled 6 P2.11 + {CCU81, CCU81_CC81, 1, XMC_CCU8_SLICE_COMPARE_CHANNEL_1, mapping_port_pin[9], P1_11_AF_CCU81_OUT11, DISABLED} // PWM disabled 9 P1.11 }; XMC_ADC_t mapping_adc[] ={ - {VADC, 0, VADC_G0, 0, 4 , DISABLED}, - {VADC, 1, VADC_G0, 0, 15, DISABLED}, - {VADC, 2, VADC_G1, 1, 15, DISABLED}, - {VADC, 3, VADC_G1, 1, 3 , DISABLED}, - {VADC, 0, VADC_G2, 2, 1 , DISABLED}, - {VADC, 1, VADC_G2, 2, 0 , DISABLED} + {VADC, 0, VADC_G0, 0, 4 , DISABLED}, + {VADC, 1, VADC_G0, 0, 15, DISABLED}, + {VADC, 2, VADC_G1, 1, 15, DISABLED}, + {VADC, 3, VADC_G1, 1, 3 , DISABLED}, + {VADC, 0, VADC_G2, 2, 1 , DISABLED}, + {VADC, 1, VADC_G2, 2, 0 , DISABLED} }; /* @@ -192,46 +193,46 @@ RingBuffer tx_buffer_on_board; XMC_UART_t XMC_UART_debug = { - .channel = XMC_UART0_CH0, - .rx = { .port = (XMC_GPIO_PORT_t *)PORT1_BASE, - .pin = (uint8_t)4 - }, - .rx_config = { .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE - }, - .tx = { .port = (XMC_GPIO_PORT_t *)PORT1_BASE, - .pin = (uint8_t)5 - }, - .tx_config = { .mode = (XMC_GPIO_MODE_t) XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE - }, - .input_source = (XMC_USIC_CH_INPUT_t)USIC0_C0_DX0_P1_4, - .irq_num = USIC0_0_IRQn, - .irq_service_request = 0 + .channel = XMC_UART0_CH0, + .rx = { .port = (XMC_GPIO_PORT_t *)PORT1_BASE, + .pin = (uint8_t)4 + }, + .rx_config = { .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE + }, + .tx = { .port = (XMC_GPIO_PORT_t *)PORT1_BASE, + .pin = (uint8_t)5 + }, + .tx_config = { .mode = (XMC_GPIO_MODE_t) XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE + }, + .input_source = (XMC_USIC_CH_INPUT_t)USIC0_C0_DX0_P1_4, + .irq_num = USIC0_0_IRQn, + .irq_service_request = 0 }; XMC_UART_t XMC_UART_1 = { - .channel = XMC_UART1_CH0, - .rx = { .port = (XMC_GPIO_PORT_t *)PORT2_BASE, - .pin = (uint8_t)15 - }, - .rx_config = { .mode = XMC_GPIO_MODE_INPUT_TRISTATE, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE - }, - .tx = { .port = (XMC_GPIO_PORT_t *)PORT2_BASE, - .pin = (uint8_t)14 - }, - .tx_config = { .mode = (XMC_GPIO_MODE_t) XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, - .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, - .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE - }, - .input_source = (XMC_USIC_CH_INPUT_t)USIC1_C0_DX0_P2_15, - .irq_num = USIC1_0_IRQn, - .irq_service_request = 0 + .channel = XMC_UART1_CH0, + .rx = { .port = (XMC_GPIO_PORT_t *)PORT2_BASE, + .pin = (uint8_t)15 + }, + .rx_config = { .mode = XMC_GPIO_MODE_INPUT_TRISTATE, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE + }, + .tx = { .port = (XMC_GPIO_PORT_t *)PORT2_BASE, + .pin = (uint8_t)14 + }, + .tx_config = { .mode = (XMC_GPIO_MODE_t) XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2, + .output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH, + .output_strength = XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE + }, + .input_source = (XMC_USIC_CH_INPUT_t)USIC1_C0_DX0_P2_15, + .irq_num = USIC1_0_IRQn, + .irq_service_request = 0 }; // Debug port