diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index ca5b922e2..66322215c 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -7,27 +7,30 @@ jobs: strategy: fail-fast: false matrix: - arduino-platform: ['metro_m0', 'hallowing', 'circuitplayground_m0', - 'metro_m4', 'pybadge_m4', 'pygamer_m4', 'hallowing_m4', 'pyportal_m4', 'pyportal_m4_titano'] + board: + # Alphabetical order + - 'circuitplayground_m0' + - 'feather_m4_can' + - 'hallowing' + - 'hallowing_m4' + - 'metro_m0' + - 'metro_m4' + - 'pybadge_m4' + - 'pygamer_m4' + - 'pyportal_m4' + - 'pyportal_m4_titano' + # with TinyUSB + - 'metro_m0:usbstack=tinyusb' + - 'metro_m4:speed=120,usbstack=tinyusb' runs-on: ubuntu-latest steps: - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: 'true' - - name: Checkout submodules - shell: bash - run: | - auth_header="$(git config --local --get http.https://github.com/.extraheader)" - git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive - - name: Install Arduino CLI and Tools run: | # make all our directories we need for files and libraries @@ -36,24 +39,23 @@ jobs: mkdir $HOME/Arduino mkdir $HOME/Arduino/libraries curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh - echo "::add-path::$GITHUB_WORKSPACE/bin" + echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH - name: Install BSP and Libraries env: BSP_URL: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json BSP_PATH: .arduino15/packages/adafruit/hardware/samd - LIB_DEPS: FlashStorage SD run: | arduino-cli config init arduino-cli core update-index arduino-cli core update-index --additional-urls $BSP_URL arduino-cli core install arduino:samd --additional-urls $BSP_URL arduino-cli core install adafruit:samd --additional-urls $BSP_URL - # Repalce release BSP with our code + # Replace release BSP with our code BSP_VERSION=`eval ls $HOME/$BSP_PATH` rm -r $HOME/$BSP_PATH/* ln -s $GITHUB_WORKSPACE $HOME/$BSP_PATH/$BSP_VERSION - arduino-cli lib install $LIB_DEPS + arduino-cli lib install "Adafruit NeoPixel" "Adafruit seesaw Library" "Adafruit SPIFlash" "FlashStorage" "MIDI Library" "SD" "SdFat - Adafruit Fork" - name: Build examples - run: python3 extras/build_all.py ${{ matrix.arduino-platform }} + run: python3 tools/build_all.py ${{ matrix.board }} diff --git a/.gitignore b/.gitignore index 22b823b91..ef8f29944 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.atsuo bootloaders/*/build/ -*~ \ No newline at end of file +*~ +/libraries/**/build/ diff --git a/.gitmodules b/.gitmodules index 293215518..8e657daeb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ -[submodule "cores/arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore"] - path = cores/arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore - url = https://github.com/adafruit/Adafruit_TinyUSB_ArduinoCore.git +[submodule "libraries/Adafruit_TinyUSB_Arduino"] + path = libraries/Adafruit_TinyUSB_Arduino + url = https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git +[submodule "libraries/Adafruit_ZeroDMA"] + path = libraries/Adafruit_ZeroDMA + url = https://github.com/adafruit/Adafruit_ZeroDMA diff --git a/boards.txt b/boards.txt index 9c68368b1..23b2fcddd 100644 --- a/boards.txt +++ b/boards.txt @@ -21,411 +21,1314 @@ menu.maxqspi=Max QSPI menu.usbstack=USB Stack menu.debug=Debug +# ----------------------------------- # Adafruit Feather M0 (SAMD21) -# ------------------------------ -adafruit_feather_m0.name=Adafruit Feather M0 +# ----------------------------------- +adafruit_feather_m0.name=Adafruit Feather M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_feather_m0.vid.0=0x239A adafruit_feather_m0.pid.0=0x800B adafruit_feather_m0.vid.1=0x239A adafruit_feather_m0.pid.1=0x000B adafruit_feather_m0.vid.2=0x239A adafruit_feather_m0.pid.2=0x0015 -adafruit_feather_m0.upload.tool=bossac + +# Upload +adafruit_feather_m0.upload.tool=bossac18 adafruit_feather_m0.upload.protocol=sam-ba adafruit_feather_m0.upload.maximum_size=262144 adafruit_feather_m0.upload.offset=0x2000 adafruit_feather_m0.upload.use_1200bps_touch=true adafruit_feather_m0.upload.wait_for_upload_port=true adafruit_feather_m0.upload.native_usb=true + +# Build adafruit_feather_m0.build.mcu=cortex-m0plus adafruit_feather_m0.build.f_cpu=48000000L adafruit_feather_m0.build.usb_product="Feather M0" adafruit_feather_m0.build.usb_manufacturer="Adafruit" adafruit_feather_m0.build.board=SAMD_ZERO adafruit_feather_m0.build.core=arduino -adafruit_feather_m0.build.extra_flags=-DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS -DADAFRUIT_FEATHER_M0 -D__SAMD21G18A__ {build.usb_flags} +adafruit_feather_m0.build.extra_flags=-D__SAMD21G18A__ -DADAFRUIT_FEATHER_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_feather_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_feather_m0.build.openocdscript=openocd_scripts/feather_m0.cfg +adafruit_feather_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_feather_m0.build.variant=feather_m0 adafruit_feather_m0.build.variant_system_lib= adafruit_feather_m0.build.vid=0x239A adafruit_feather_m0.build.pid=0x800B adafruit_feather_m0.bootloader.tool=openocd adafruit_feather_m0.bootloader.file=featherM0/bootloader-feather_m0-v2.0.0-adafruit.5.bin + +# Menu: Optimization +adafruit_feather_m0.menu.opt.small=Small (-Os) (standard) +adafruit_feather_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_feather_m0.menu.opt.fast=Fast (-O2) +adafruit_feather_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_feather_m0.menu.opt.faster=Faster (-O3) +adafruit_feather_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_feather_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_feather_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_feather_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_feather_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_feather_m0.menu.usbstack.arduino=Arduino adafruit_feather_m0.menu.usbstack.tinyusb=TinyUSB adafruit_feather_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_feather_m0.menu.debug.off=Off adafruit_feather_m0.menu.debug.on=On adafruit_feather_m0.menu.debug.on.build.flags.debug=-g +# ----------------------------------- # Adafruit Feather M0 Express (SAMD21) -# ------------------------------ -adafruit_feather_m0_express.name=Adafruit Feather M0 Express +# ----------------------------------- +adafruit_feather_m0_express.name=Adafruit Feather M0 Express (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_feather_m0_express.vid.0=0x239A adafruit_feather_m0_express.pid.0=0x801B adafruit_feather_m0_express.vid.1=0x239A adafruit_feather_m0_express.pid.1=0x001B -adafruit_feather_m0_express.upload.tool=bossac + +# Upload +adafruit_feather_m0_express.upload.tool=bossac18 adafruit_feather_m0_express.upload.protocol=sam-ba adafruit_feather_m0_express.upload.maximum_size=262144 adafruit_feather_m0_express.upload.offset=0x2000 adafruit_feather_m0_express.upload.use_1200bps_touch=true adafruit_feather_m0_express.upload.wait_for_upload_port=true adafruit_feather_m0_express.upload.native_usb=true + +# Build adafruit_feather_m0_express.build.mcu=cortex-m0plus adafruit_feather_m0_express.build.f_cpu=48000000L adafruit_feather_m0_express.build.usb_product="Feather M0 Express" adafruit_feather_m0_express.build.usb_manufacturer="Adafruit" adafruit_feather_m0_express.build.board=SAMD_FEATHER_M0_EXPRESS adafruit_feather_m0_express.build.core=arduino -adafruit_feather_m0_express.build.extra_flags=-DARDUINO_SAMD_ZERO -DARDUINO_SAMD_FEATHER_M0 -DARM_MATH_CM0PLUS -DADAFRUIT_FEATHER_M0_EXPRESS -D__SAMD21G18A__ {build.usb_flags} +adafruit_feather_m0_express.build.extra_flags=-D__SAMD21G18A__ -DARDUINO_SAMD_FEATHER_M0 -DADAFRUIT_FEATHER_M0_EXPRESS -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_feather_m0_express.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_feather_m0_express.build.openocdscript=openocd_scripts/feather_m0_express.cfg +adafruit_feather_m0_express.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_feather_m0_express.build.variant=feather_m0_express adafruit_feather_m0_express.build.variant_system_lib= adafruit_feather_m0_express.build.vid=0x239A adafruit_feather_m0_express.build.pid=0x801B adafruit_feather_m0_express.bootloader.tool=openocd adafruit_feather_m0_express.bootloader.file=featherM0/bootloader-feather_m0-v2.0.0-adafruit.5.bin + +# Menu: Optimization +adafruit_feather_m0_express.menu.opt.small=Small (-Os) (standard) +adafruit_feather_m0_express.menu.opt.small.build.flags.optimize=-Os +adafruit_feather_m0_express.menu.opt.fast=Fast (-O2) +adafruit_feather_m0_express.menu.opt.fast.build.flags.optimize=-O2 +adafruit_feather_m0_express.menu.opt.faster=Faster (-O3) +adafruit_feather_m0_express.menu.opt.faster.build.flags.optimize=-O3 +adafruit_feather_m0_express.menu.opt.fastest=Fastest (-Ofast) +adafruit_feather_m0_express.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_feather_m0_express.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_feather_m0_express.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_feather_m0_express.menu.usbstack.arduino=Arduino adafruit_feather_m0_express.menu.usbstack.tinyusb=TinyUSB adafruit_feather_m0_express.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_feather_m0_express.menu.debug.off=Off adafruit_feather_m0_express.menu.debug.on=On adafruit_feather_m0_express.menu.debug.on.build.flags.debug=-g -#adafruit_radio_m0.name=Adafruit M0 Radio (Native USB Port) -#adafruit_radio_m0.vid.0=0x239A -#adafruit_radio_m0.pid.0=0x8014 -#adafruit_radio_m0.vid.1=0x239A -#adafruit_radio_m0.pid.1=0x0014 -#adafruit_radio_m0.upload.tool=bossac -#adafruit_radio_m0.upload.protocol=sam-ba -#adafruit_radio_m0.upload.maximum_size=262144 -#adafruit_radio_m0.upload.use_1200bps_touch=true -#adafruit_radio_m0.upload.wait_for_upload_port=true -#adafruit_radio_m0.upload.native_usb=true -#adafruit_radio_m0.build.mcu=cortex-m0plus -#adafruit_radio_m0.build.f_cpu=48000000L -#adafruit_radio_m0.build.usb_product="Radio M0" -#adafruit_radio_m0.build.usb_manufacturer="Adafruit" -#adafruit_radio_m0.build.board=SAMD_ZERO -#adafruit_radio_m0.build.core=arduino -#adafruit_radio_m0.build.extra_flags=-D__SAMR21G18A__ -DARM_MATH_CM0PLUS {build.usb_flags} -#adafruit_radio_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -#adafruit_radio_m0.build.openocdscript=openocd_scripts/zero_radio.cfg -#adafruit_radio_m0.build.variant=zero_radio -#adafruit_radio_m0.build.variant_system_lib= -#adafruit_radio_m0.build.vid=0x239A -#adafruit_radio_m0.build.pid=0x8014 -#adafruit_radio_m0.bootloader.tool=openocd -#adafruit_radio_m0.bootloader.file=feather/samr21_sam_ba.bin - +# ----------------------------------- # Adafruit Metro M0 Express (SAMD21) -# ------------------------------ -adafruit_metro_m0.name=Adafruit Metro M0 Express +# ----------------------------------- +adafruit_metro_m0.name=Adafruit Metro M0 Express (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_metro_m0.vid.0=0x239A adafruit_metro_m0.pid.0=0x8013 adafruit_metro_m0.vid.1=0x239A adafruit_metro_m0.pid.1=0x0013 -adafruit_metro_m0.upload.tool=bossac + +# Upload +adafruit_metro_m0.upload.tool=bossac18 adafruit_metro_m0.upload.protocol=sam-ba adafruit_metro_m0.upload.maximum_size=262144 adafruit_metro_m0.upload.offset=0x2000 adafruit_metro_m0.upload.use_1200bps_touch=true adafruit_metro_m0.upload.wait_for_upload_port=true adafruit_metro_m0.upload.native_usb=true + +# Build adafruit_metro_m0.build.mcu=cortex-m0plus adafruit_metro_m0.build.f_cpu=48000000L adafruit_metro_m0.build.usb_product="Metro M0 Express" adafruit_metro_m0.build.usb_manufacturer="Adafruit" adafruit_metro_m0.build.board=SAMD_ZERO adafruit_metro_m0.build.core=arduino -adafruit_metro_m0.build.extra_flags=-D__SAMD21G18A__ -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS -DADAFRUIT_METRO_M0_EXPRESS {build.usb_flags} +adafruit_metro_m0.build.extra_flags=-D__SAMD21G18A__ -DADAFRUIT_METRO_M0_EXPRESS -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_metro_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_metro_m0.build.openocdscript=openocd_scripts/metro_m0.cfg +adafruit_metro_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_metro_m0.build.variant=metro_m0 adafruit_metro_m0.build.variant_system_lib= adafruit_metro_m0.build.vid=0x239A adafruit_metro_m0.build.pid=0x8013 adafruit_metro_m0.bootloader.tool=openocd adafruit_metro_m0.bootloader.file=metroM0/bootloader-metro_m0-v2.0.0-adafruit.5.bin + +# Menu: Optimization +adafruit_metro_m0.menu.opt.small=Small (-Os) (standard) +adafruit_metro_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_metro_m0.menu.opt.fast=Fast (-O2) +adafruit_metro_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_metro_m0.menu.opt.faster=Faster (-O3) +adafruit_metro_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_metro_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_metro_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_metro_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_metro_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_metro_m0.menu.usbstack.arduino=Arduino adafruit_metro_m0.menu.usbstack.tinyusb=TinyUSB adafruit_metro_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_metro_m0.menu.debug.off=Off adafruit_metro_m0.menu.debug.on=On adafruit_metro_m0.menu.debug.on.build.flags.debug=-g +# ----------------------------------- # Adafruit Circuit Playground Express (SAMD21) -# ------------------------------ -adafruit_circuitplayground_m0.name=Adafruit Circuit Playground Express +# ----------------------------------- +adafruit_circuitplayground_m0.name=Adafruit Circuit Playground Express (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_circuitplayground_m0.vid.0=0x239A adafruit_circuitplayground_m0.pid.0=0x8018 adafruit_circuitplayground_m0.vid.1=0x239A adafruit_circuitplayground_m0.pid.1=0x0019 -adafruit_circuitplayground_m0.upload.tool=bossac + +# Upload +adafruit_circuitplayground_m0.upload.tool=bossac18 adafruit_circuitplayground_m0.upload.protocol=sam-ba adafruit_circuitplayground_m0.upload.maximum_size=262144 adafruit_circuitplayground_m0.upload.offset=0x2000 adafruit_circuitplayground_m0.upload.use_1200bps_touch=true adafruit_circuitplayground_m0.upload.wait_for_upload_port=true adafruit_circuitplayground_m0.upload.native_usb=true + +# Build adafruit_circuitplayground_m0.build.mcu=cortex-m0plus adafruit_circuitplayground_m0.build.f_cpu=48000000L adafruit_circuitplayground_m0.build.usb_product="Circuit Playground Express" adafruit_circuitplayground_m0.build.usb_manufacturer="Adafruit" adafruit_circuitplayground_m0.build.board=SAMD_CIRCUITPLAYGROUND_EXPRESS adafruit_circuitplayground_m0.build.core=arduino -adafruit_circuitplayground_m0.build.extra_flags=-DCRYSTALLESS -DARDUINO_SAMD_ZERO -D__SAMD21G18A__ -DARM_MATH_CM0PLUS -DADAFRUIT_CIRCUITPLAYGROUND_M0 {build.usb_flags} +adafruit_circuitplayground_m0.build.extra_flags=-D__SAMD21G18A__ -DCRYSTALLESS -DADAFRUIT_CIRCUITPLAYGROUND_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_circuitplayground_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_circuitplayground_m0.build.openocdscript=openocd_scripts/circuit_play.cfg +adafruit_circuitplayground_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_circuitplayground_m0.build.variant=circuitplay adafruit_circuitplayground_m0.build.variant_system_lib= adafruit_circuitplayground_m0.build.vid=0x239A adafruit_circuitplayground_m0.build.pid=0x8018 adafruit_circuitplayground_m0.bootloader.tool=openocd adafruit_circuitplayground_m0.bootloader.file=circuitplayM0/bootloader-circuitplay_m0-v2.0.0-adafruit.5.bin + +# Menu: Optimization +adafruit_circuitplayground_m0.menu.opt.small=Small (-Os) (standard) +adafruit_circuitplayground_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_circuitplayground_m0.menu.opt.fast=Fast (-O2) +adafruit_circuitplayground_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_circuitplayground_m0.menu.opt.faster=Faster (-O3) +adafruit_circuitplayground_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_circuitplayground_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_circuitplayground_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_circuitplayground_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_circuitplayground_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_circuitplayground_m0.menu.usbstack.arduino=Arduino adafruit_circuitplayground_m0.menu.usbstack.tinyusb=TinyUSB adafruit_circuitplayground_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_circuitplayground_m0.menu.debug.off=Off adafruit_circuitplayground_m0.menu.debug.on=On adafruit_circuitplayground_m0.menu.debug.on.build.flags.debug=-g +# ----------------------------------- # Adafruit Gemma M0 (SAMD21) -# ------------------------------ -adafruit_gemma_m0.name=Adafruit Gemma M0 +# ----------------------------------- +adafruit_gemma_m0.name=Adafruit Gemma M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_gemma_m0.vid.0=0x239A adafruit_gemma_m0.pid.0=0x801C adafruit_gemma_m0.vid.1=0x239A adafruit_gemma_m0.pid.1=0x001C -adafruit_gemma_m0.upload.tool=bossac + +# Upload +adafruit_gemma_m0.upload.tool=bossac18 adafruit_gemma_m0.upload.protocol=sam-ba adafruit_gemma_m0.upload.maximum_size=262144 adafruit_gemma_m0.upload.offset=0x2000 adafruit_gemma_m0.upload.use_1200bps_touch=true adafruit_gemma_m0.upload.wait_for_upload_port=true adafruit_gemma_m0.upload.native_usb=true + +# Build adafruit_gemma_m0.build.mcu=cortex-m0plus adafruit_gemma_m0.build.f_cpu=48000000L adafruit_gemma_m0.build.usb_product="Gemma M0" adafruit_gemma_m0.build.usb_manufacturer="Adafruit" adafruit_gemma_m0.build.board=GEMMA_M0 adafruit_gemma_m0.build.core=arduino -adafruit_gemma_m0.build.extra_flags=-DCRYSTALLESS -DADAFRUIT_GEMMA_M0 -D__SAMD21E18A__ -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_gemma_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_GEMMA_M0 -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_gemma_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_gemma_m0.build.openocdscript=openocd_scripts/gemma_m0.cfg +adafruit_gemma_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_gemma_m0.build.variant=gemma_m0 adafruit_gemma_m0.build.variant_system_lib= adafruit_gemma_m0.build.vid=0x239A adafruit_gemma_m0.build.pid=0x801C adafruit_gemma_m0.bootloader.tool=openocd adafruit_gemma_m0.bootloader.file=gemmaM0/bootloader-gemma_m0-v2.0.0-adafruit.5.bin + +# Menu: Optimization +adafruit_gemma_m0.menu.opt.small=Small (-Os) (standard) +adafruit_gemma_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_gemma_m0.menu.opt.fast=Fast (-O2) +adafruit_gemma_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_gemma_m0.menu.opt.faster=Faster (-O3) +adafruit_gemma_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_gemma_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_gemma_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_gemma_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_gemma_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_gemma_m0.menu.usbstack.arduino=Arduino adafruit_gemma_m0.menu.usbstack.tinyusb=TinyUSB adafruit_gemma_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_gemma_m0.menu.debug.off=Off adafruit_gemma_m0.menu.debug.on=On adafruit_gemma_m0.menu.debug.on.build.flags.debug=-g + +# ----------------------------------- # Adafruit Trinket M0 (SAMD21) -# ------------------------------ -adafruit_trinket_m0.name=Adafruit Trinket M0 +# ----------------------------------- +adafruit_trinket_m0.name=Adafruit Trinket M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_trinket_m0.vid.0=0x239A adafruit_trinket_m0.pid.0=0x801E adafruit_trinket_m0.vid.1=0x239A adafruit_trinket_m0.pid.1=0x001E -adafruit_trinket_m0.upload.tool=bossac + +# Upload +adafruit_trinket_m0.upload.tool=bossac18 adafruit_trinket_m0.upload.protocol=sam-ba adafruit_trinket_m0.upload.maximum_size=262144 adafruit_trinket_m0.upload.offset=0x2000 adafruit_trinket_m0.upload.use_1200bps_touch=true adafruit_trinket_m0.upload.wait_for_upload_port=true adafruit_trinket_m0.upload.native_usb=true + +# Build adafruit_trinket_m0.build.mcu=cortex-m0plus adafruit_trinket_m0.build.f_cpu=48000000L adafruit_trinket_m0.build.usb_product="Trinket M0" adafruit_trinket_m0.build.usb_manufacturer="Adafruit" adafruit_trinket_m0.build.board=TRINKET_M0 adafruit_trinket_m0.build.core=arduino -adafruit_trinket_m0.build.extra_flags=-DCRYSTALLESS -DADAFRUIT_TRINKET_M0 -D__SAMD21E18A__ -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_trinket_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_TRINKET_M0 -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_trinket_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_trinket_m0.build.openocdscript=openocd_scripts/trinket_m0.cfg +adafruit_trinket_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_trinket_m0.build.variant=trinket_m0 adafruit_trinket_m0.build.variant_system_lib= adafruit_trinket_m0.build.vid=0x239A adafruit_trinket_m0.build.pid=0x801E adafruit_trinket_m0.bootloader.tool=openocd adafruit_trinket_m0.bootloader.file=trinketm0/bootloader-trinket_m0-v2.0.0-adafruit.5.bin + +# Menu: Optimization +adafruit_trinket_m0.menu.opt.small=Small (-Os) (standard) +adafruit_trinket_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_trinket_m0.menu.opt.fast=Fast (-O2) +adafruit_trinket_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_trinket_m0.menu.opt.faster=Faster (-O3) +adafruit_trinket_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_trinket_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_trinket_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_trinket_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_trinket_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_trinket_m0.menu.usbstack.arduino=Arduino adafruit_trinket_m0.menu.usbstack.tinyusb=TinyUSB adafruit_trinket_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_trinket_m0.menu.debug.off=Off adafruit_trinket_m0.menu.debug.on=On adafruit_trinket_m0.menu.debug.on.build.flags.debug=-g -# Adafruit ItsyBitsy M0 (SAMD21) -# ------------------------------ -adafruit_itsybitsy_m0.name=Adafruit ItsyBitsy M0 +# ----------------------------------- +# Adafruit QT Py M0 (SAMD21) +# ----------------------------------- +adafruit_qtpy_m0.name=Adafruit QT Py M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_qtpy_m0.vid.0=0x239A +adafruit_qtpy_m0.pid.0=0x80CB +adafruit_qtpy_m0.vid.1=0x239A +adafruit_qtpy_m0.pid.1=0x00CB +adafruit_qtpy_m0.vid.2=0x239A +adafruit_qtpy_m0.pid.2=0x00CC + +# Upload +adafruit_qtpy_m0.upload.tool=bossac18 +adafruit_qtpy_m0.upload.protocol=sam-ba +adafruit_qtpy_m0.upload.maximum_size=262144 +adafruit_qtpy_m0.upload.offset=0x2000 +adafruit_qtpy_m0.upload.use_1200bps_touch=true +adafruit_qtpy_m0.upload.wait_for_upload_port=true +adafruit_qtpy_m0.upload.native_usb=true + +# Build +adafruit_qtpy_m0.build.mcu=cortex-m0plus +adafruit_qtpy_m0.build.f_cpu=48000000L +adafruit_qtpy_m0.build.usb_product="QT Py M0" +adafruit_qtpy_m0.build.usb_manufacturer="Adafruit" +adafruit_qtpy_m0.build.board=QTPY_M0 +adafruit_qtpy_m0.build.core=arduino +adafruit_qtpy_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_QTPY_M0 -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_qtpy_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_qtpy_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_qtpy_m0.build.variant=qtpy_m0 +adafruit_qtpy_m0.build.variant_system_lib= +adafruit_qtpy_m0.build.vid=0x239A +adafruit_qtpy_m0.build.pid=0x80CB +adafruit_qtpy_m0.bootloader.tool=openocd +adafruit_qtpy_m0.bootloader.file=qtpyM0/bootloader-qtpy_m0.bin + +# Menu: Optimization +adafruit_qtpy_m0.menu.opt.small=Small (-Os) (standard) +adafruit_qtpy_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_qtpy_m0.menu.opt.fast=Fast (-O2) +adafruit_qtpy_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_qtpy_m0.menu.opt.faster=Faster (-O3) +adafruit_qtpy_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_qtpy_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_qtpy_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_qtpy_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_qtpy_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_qtpy_m0.menu.usbstack.arduino=Arduino +adafruit_qtpy_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_qtpy_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_qtpy_m0.menu.debug.off=Off +adafruit_qtpy_m0.menu.debug.on=On +adafruit_qtpy_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit NeoPixel Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_neotrinkey_m0.name=Adafruit NeoPixel Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_neotrinkey_m0.vid.0=0x239A +adafruit_neotrinkey_m0.pid.0=0x80EF +adafruit_neotrinkey_m0.vid.1=0x239A +adafruit_neotrinkey_m0.pid.1=0x00EF +adafruit_neotrinkey_m0.vid.2=0x239A +adafruit_neotrinkey_m0.pid.2=0x80F0 + +# Upload +adafruit_neotrinkey_m0.upload.tool=bossac18 +adafruit_neotrinkey_m0.upload.protocol=sam-ba +adafruit_neotrinkey_m0.upload.maximum_size=262144 +adafruit_neotrinkey_m0.upload.offset=0x2000 +adafruit_neotrinkey_m0.upload.use_1200bps_touch=true +adafruit_neotrinkey_m0.upload.wait_for_upload_port=true +adafruit_neotrinkey_m0.upload.native_usb=true + +# Build +adafruit_neotrinkey_m0.build.mcu=cortex-m0plus +adafruit_neotrinkey_m0.build.f_cpu=48000000L +adafruit_neotrinkey_m0.build.usb_product="NeoPixel Trinkey M0" +adafruit_neotrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_neotrinkey_m0.build.board=NEOTRINKEY_M0 +adafruit_neotrinkey_m0.build.core=arduino +adafruit_neotrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_NEOTRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_neotrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_neotrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_neotrinkey_m0.build.variant=neotrinkey_m0 +adafruit_neotrinkey_m0.build.variant_system_lib= +adafruit_neotrinkey_m0.build.vid=0x239A +adafruit_neotrinkey_m0.build.pid=0x80EF +adafruit_neotrinkey_m0.bootloader.tool=openocd +adafruit_neotrinkey_m0.bootloader.file=neotrinkey_m0/bootloader-neotrinkey_m0.bin + +# Menu: Optimization +adafruit_neotrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_neotrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_neotrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_neotrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_neotrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_neotrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_neotrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_neotrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_neotrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_neotrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_neotrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_neotrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_neotrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_neotrinkey_m0.menu.debug.off=Off +adafruit_neotrinkey_m0.menu.debug.on=On +adafruit_neotrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit Rotary Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_rotarytrinkey_m0.name=Adafruit Rotary Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_rotarytrinkey_m0.vid.0=0x239A +adafruit_rotarytrinkey_m0.pid.0=0x80FB +adafruit_rotarytrinkey_m0.vid.1=0x239A +adafruit_rotarytrinkey_m0.pid.1=0x00FB +adafruit_rotarytrinkey_m0.vid.2=0x239A +adafruit_rotarytrinkey_m0.pid.2=0x80FC + +# Upload +adafruit_rotarytrinkey_m0.upload.tool=bossac18 +adafruit_rotarytrinkey_m0.upload.protocol=sam-ba +adafruit_rotarytrinkey_m0.upload.maximum_size=262144 +adafruit_rotarytrinkey_m0.upload.offset=0x2000 +adafruit_rotarytrinkey_m0.upload.use_1200bps_touch=true +adafruit_rotarytrinkey_m0.upload.wait_for_upload_port=true +adafruit_rotarytrinkey_m0.upload.native_usb=true + +# Build +adafruit_rotarytrinkey_m0.build.mcu=cortex-m0plus +adafruit_rotarytrinkey_m0.build.f_cpu=48000000L +adafruit_rotarytrinkey_m0.build.usb_product="Rotary Trinkey M0" +adafruit_rotarytrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_rotarytrinkey_m0.build.board=ROTARYTRINKEY_M0 +adafruit_rotarytrinkey_m0.build.core=arduino +adafruit_rotarytrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_ROTARYTRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_rotarytrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_rotarytrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_rotarytrinkey_m0.build.variant=rotarytrinkey_m0 +adafruit_rotarytrinkey_m0.build.variant_system_lib= +adafruit_rotarytrinkey_m0.build.vid=0x239A +adafruit_rotarytrinkey_m0.build.pid=0x80FB +adafruit_rotarytrinkey_m0.bootloader.tool=openocd +adafruit_rotarytrinkey_m0.bootloader.file=rotarytrinkey_m0/bootloader-rotarytrinkey_m0.bin + +# Menu: Optimization +adafruit_rotarytrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_rotarytrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_rotarytrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_rotarytrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_rotarytrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_rotarytrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_rotarytrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_rotarytrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_rotarytrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_rotarytrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_rotarytrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_rotarytrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_rotarytrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_rotarytrinkey_m0.menu.debug.off=Off +adafruit_rotarytrinkey_m0.menu.debug.on=On +adafruit_rotarytrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit NeoKey Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_neokeytrinkey_m0.name=Adafruit NeoKey Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_neokeytrinkey_m0.vid.0=0x239A +adafruit_neokeytrinkey_m0.pid.0=0x80FF +adafruit_neokeytrinkey_m0.vid.1=0x239A +adafruit_neokeytrinkey_m0.pid.1=0x00FF +adafruit_neokeytrinkey_m0.vid.2=0x239A +adafruit_neokeytrinkey_m0.pid.2=0x8100 + +# Upload +adafruit_neokeytrinkey_m0.upload.tool=bossac18 +adafruit_neokeytrinkey_m0.upload.protocol=sam-ba +adafruit_neokeytrinkey_m0.upload.maximum_size=262144 +adafruit_neokeytrinkey_m0.upload.offset=0x2000 +adafruit_neokeytrinkey_m0.upload.use_1200bps_touch=true +adafruit_neokeytrinkey_m0.upload.wait_for_upload_port=true +adafruit_neokeytrinkey_m0.upload.native_usb=true + +# Build +adafruit_neokeytrinkey_m0.build.mcu=cortex-m0plus +adafruit_neokeytrinkey_m0.build.f_cpu=48000000L +adafruit_neokeytrinkey_m0.build.usb_product="NeoKey Trinkey M0" +adafruit_neokeytrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_neokeytrinkey_m0.build.board=NEOKEYTRINKEY_M0 +adafruit_neokeytrinkey_m0.build.core=arduino +adafruit_neokeytrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_NEOKEYTRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_neokeytrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_neokeytrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_neokeytrinkey_m0.build.variant=neokeytrinkey_m0 +adafruit_neokeytrinkey_m0.build.variant_system_lib= +adafruit_neokeytrinkey_m0.build.vid=0x239A +adafruit_neokeytrinkey_m0.build.pid=0x80FF +adafruit_neokeytrinkey_m0.bootloader.tool=openocd +adafruit_neokeytrinkey_m0.bootloader.file=neokeytrinkey_m0/bootloader-neokeytrinkey_m0.bin + +# Menu: Optimization +adafruit_neokeytrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_neokeytrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_neokeytrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_neokeytrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_neokeytrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_neokeytrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_neokeytrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_neokeytrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_neokeytrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_neokeytrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_neokeytrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_neokeytrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_neokeytrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_neokeytrinkey_m0.menu.debug.off=Off +adafruit_neokeytrinkey_m0.menu.debug.on=On +adafruit_neokeytrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit Slide Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_slidetrinkey_m0.name=Adafruit Slide Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_slidetrinkey_m0.vid.0=0x239A +adafruit_slidetrinkey_m0.pid.0=0x8101 +adafruit_slidetrinkey_m0.vid.1=0x239A +adafruit_slidetrinkey_m0.pid.1=0x0101 +adafruit_slidetrinkey_m0.vid.2=0x239A +adafruit_slidetrinkey_m0.pid.2=0x8102 + +# Upload +adafruit_slidetrinkey_m0.upload.tool=bossac18 +adafruit_slidetrinkey_m0.upload.protocol=sam-ba +adafruit_slidetrinkey_m0.upload.maximum_size=262144 +adafruit_slidetrinkey_m0.upload.offset=0x2000 +adafruit_slidetrinkey_m0.upload.use_1200bps_touch=true +adafruit_slidetrinkey_m0.upload.wait_for_upload_port=true +adafruit_slidetrinkey_m0.upload.native_usb=true + +# Build +adafruit_slidetrinkey_m0.build.mcu=cortex-m0plus +adafruit_slidetrinkey_m0.build.f_cpu=48000000L +adafruit_slidetrinkey_m0.build.usb_product="Slide Trinkey M0" +adafruit_slidetrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_slidetrinkey_m0.build.board=SLIDETRINKEY_M0 +adafruit_slidetrinkey_m0.build.core=arduino +adafruit_slidetrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_SLIDETRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_slidetrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_slidetrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_slidetrinkey_m0.build.variant=slidetrinkey_m0 +adafruit_slidetrinkey_m0.build.variant_system_lib= +adafruit_slidetrinkey_m0.build.vid=0x239A +adafruit_slidetrinkey_m0.build.pid=0x8101 +adafruit_slidetrinkey_m0.bootloader.tool=openocd +adafruit_slidetrinkey_m0.bootloader.file=slidetrinkey_m0/bootloader-slidetrinkey_m0.bin + +# Menu: Optimization +adafruit_slidetrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_slidetrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_slidetrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_slidetrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_slidetrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_slidetrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_slidetrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_slidetrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_slidetrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_slidetrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_slidetrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_slidetrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_slidetrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_slidetrinkey_m0.menu.debug.off=Off +adafruit_slidetrinkey_m0.menu.debug.on=On +adafruit_slidetrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit ProxLight Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_proxlighttrinkey_m0.name=Adafruit ProxLight Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_proxlighttrinkey_m0.vid.0=0x239A +adafruit_proxlighttrinkey_m0.pid.0=0x8103 +adafruit_proxlighttrinkey_m0.vid.1=0x239A +adafruit_proxlighttrinkey_m0.pid.1=0x0103 +adafruit_proxlighttrinkey_m0.vid.2=0x239A +adafruit_proxlighttrinkey_m0.pid.2=0x8104 + +# Upload +adafruit_proxlighttrinkey_m0.upload.tool=bossac18 +adafruit_proxlighttrinkey_m0.upload.protocol=sam-ba +adafruit_proxlighttrinkey_m0.upload.maximum_size=262144 +adafruit_proxlighttrinkey_m0.upload.offset=0x2000 +adafruit_proxlighttrinkey_m0.upload.use_1200bps_touch=true +adafruit_proxlighttrinkey_m0.upload.wait_for_upload_port=true +adafruit_proxlighttrinkey_m0.upload.native_usb=true + +# Build +adafruit_proxlighttrinkey_m0.build.mcu=cortex-m0plus +adafruit_proxlighttrinkey_m0.build.f_cpu=48000000L +adafruit_proxlighttrinkey_m0.build.usb_product="ProxLight Trinkey M0" +adafruit_proxlighttrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_proxlighttrinkey_m0.build.board=PROXLIGHTTRINKEY_M0 +adafruit_proxlighttrinkey_m0.build.core=arduino +adafruit_proxlighttrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_PROXLIGHTTRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_proxlighttrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_proxlighttrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_proxlighttrinkey_m0.build.variant=proxlighttrinkey_m0 +adafruit_proxlighttrinkey_m0.build.variant_system_lib= +adafruit_proxlighttrinkey_m0.build.vid=0x239A +adafruit_proxlighttrinkey_m0.build.pid=0x8103 +adafruit_proxlighttrinkey_m0.bootloader.tool=openocd +adafruit_proxlighttrinkey_m0.bootloader.file=proxlighttrinkey_m0/bootloader-proxlighttrinkey_m0.bin + +# Menu: Optimization +adafruit_proxlighttrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_proxlighttrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_proxlighttrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_proxlighttrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_proxlighttrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_proxlighttrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_proxlighttrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_proxlighttrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_proxlighttrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_proxlighttrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_proxlighttrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_proxlighttrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_proxlighttrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_proxlighttrinkey_m0.menu.debug.off=Off +adafruit_proxlighttrinkey_m0.menu.debug.on=On +adafruit_proxlighttrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit SHT4x Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_sht4xtrinkey_m0.name=Adafruit SHT4x Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_sht4xtrinkey_m0.vid.0=0x239A +adafruit_sht4xtrinkey_m0.pid.0=0x8153 +adafruit_sht4xtrinkey_m0.vid.1=0x239A +adafruit_sht4xtrinkey_m0.pid.1=0x0153 +adafruit_sht4xtrinkey_m0.vid.2=0x239A +adafruit_sht4xtrinkey_m0.pid.2=0x8154 + +# Upload +adafruit_sht4xtrinkey_m0.upload.tool=bossac18 +adafruit_sht4xtrinkey_m0.upload.protocol=sam-ba +adafruit_sht4xtrinkey_m0.upload.maximum_size=262144 +adafruit_sht4xtrinkey_m0.upload.offset=0x2000 +adafruit_sht4xtrinkey_m0.upload.use_1200bps_touch=true +adafruit_sht4xtrinkey_m0.upload.wait_for_upload_port=true +adafruit_sht4xtrinkey_m0.upload.native_usb=true + +# Build +adafruit_sht4xtrinkey_m0.build.mcu=cortex-m0plus +adafruit_sht4xtrinkey_m0.build.f_cpu=48000000L +adafruit_sht4xtrinkey_m0.build.usb_product="SHT4x Trinkey M0" +adafruit_sht4xtrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_sht4xtrinkey_m0.build.board=SHT4XTRINKEY_M0 +adafruit_sht4xtrinkey_m0.build.core=arduino +adafruit_sht4xtrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_SHT4XTRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_sht4xtrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_sht4xtrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_sht4xtrinkey_m0.build.variant=sht4xtrinkey_m0 +adafruit_sht4xtrinkey_m0.build.variant_system_lib= +adafruit_sht4xtrinkey_m0.build.vid=0x239A +adafruit_sht4xtrinkey_m0.build.pid=0x8153 +adafruit_sht4xtrinkey_m0.bootloader.tool=openocd +adafruit_sht4xtrinkey_m0.bootloader.file=sht4xtrinkey_m0/bootloader-sht4xtrinkey_m0.bin + +# Menu: Optimization +adafruit_sht4xtrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_sht4xtrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_sht4xtrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_sht4xtrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_sht4xtrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_sht4xtrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_sht4xtrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_sht4xtrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_sht4xtrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_sht4xtrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_sht4xtrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_sht4xtrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_sht4xtrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_sht4xtrinkey_m0.menu.debug.off=Off +adafruit_sht4xtrinkey_m0.menu.debug.on=On +adafruit_sht4xtrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit Pixel Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_pixeltrinkey_m0.name=Adafruit Pixel Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_pixeltrinkey_m0.vid.0=0x239A +adafruit_pixeltrinkey_m0.pid.0=0x8155 +adafruit_pixeltrinkey_m0.vid.1=0x239A +adafruit_pixeltrinkey_m0.pid.1=0x0155 +adafruit_pixeltrinkey_m0.vid.2=0x239A +adafruit_pixeltrinkey_m0.pid.2=0x8156 + +# Upload +adafruit_pixeltrinkey_m0.upload.tool=bossac18 +adafruit_pixeltrinkey_m0.upload.protocol=sam-ba +adafruit_pixeltrinkey_m0.upload.maximum_size=262144 +adafruit_pixeltrinkey_m0.upload.offset=0x2000 +adafruit_pixeltrinkey_m0.upload.use_1200bps_touch=true +adafruit_pixeltrinkey_m0.upload.wait_for_upload_port=true +adafruit_pixeltrinkey_m0.upload.native_usb=true + +# Build +adafruit_pixeltrinkey_m0.build.mcu=cortex-m0plus +adafruit_pixeltrinkey_m0.build.f_cpu=48000000L +adafruit_pixeltrinkey_m0.build.usb_product="Pixel Trinkey M0" +adafruit_pixeltrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_pixeltrinkey_m0.build.board=PIXELTRINKEY_M0 +adafruit_pixeltrinkey_m0.build.core=arduino +adafruit_pixeltrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_PIXELTRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_pixeltrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_pixeltrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_pixeltrinkey_m0.build.variant=pixeltrinkey_m0 +adafruit_pixeltrinkey_m0.build.variant_system_lib= +adafruit_pixeltrinkey_m0.build.vid=0x239A +adafruit_pixeltrinkey_m0.build.pid=0x8155 +adafruit_pixeltrinkey_m0.bootloader.tool=openocd +adafruit_pixeltrinkey_m0.bootloader.file=pixeltrinkey_m0/bootloader-pixeltrinkey_m0.bin + +# Menu: Optimization +adafruit_pixeltrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_pixeltrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_pixeltrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_pixeltrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_pixeltrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_pixeltrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_pixeltrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_pixeltrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_pixeltrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_pixeltrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_pixeltrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_pixeltrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_pixeltrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_pixeltrinkey_m0.menu.debug.off=Off +adafruit_pixeltrinkey_m0.menu.debug.on=On +adafruit_pixeltrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit TRRS Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_TRRStrinkey_m0.name=Adafruit TRRS Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_TRRStrinkey_m0.vid.0=0x239A +adafruit_TRRStrinkey_m0.pid.0=0x8157 +adafruit_TRRStrinkey_m0.vid.1=0x239A +adafruit_TRRStrinkey_m0.pid.1=0x0157 +adafruit_TRRStrinkey_m0.vid.2=0x239A +adafruit_TRRStrinkey_m0.pid.2=0x8158 + +# Upload +adafruit_TRRStrinkey_m0.upload.tool=bossac18 +adafruit_TRRStrinkey_m0.upload.protocol=sam-ba +adafruit_TRRStrinkey_m0.upload.maximum_size=262144 +adafruit_TRRStrinkey_m0.upload.offset=0x2000 +adafruit_TRRStrinkey_m0.upload.use_1200bps_touch=true +adafruit_TRRStrinkey_m0.upload.wait_for_upload_port=true +adafruit_TRRStrinkey_m0.upload.native_usb=true + +# Build +adafruit_TRRStrinkey_m0.build.mcu=cortex-m0plus +adafruit_TRRStrinkey_m0.build.f_cpu=48000000L +adafruit_TRRStrinkey_m0.build.usb_product="TRRS Trinkey M0" +adafruit_TRRStrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_TRRStrinkey_m0.build.board=TRRSTRINKEY_M0 +adafruit_TRRStrinkey_m0.build.core=arduino +adafruit_TRRStrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_TRRSTRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_TRRStrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_TRRStrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_TRRStrinkey_m0.build.variant=trrstrinkey_m0 +adafruit_TRRStrinkey_m0.build.variant_system_lib= +adafruit_TRRStrinkey_m0.build.vid=0x239A +adafruit_TRRStrinkey_m0.build.pid=0x8157 +adafruit_TRRStrinkey_m0.bootloader.tool=openocd +adafruit_TRRStrinkey_m0.bootloader.file=trrstrinkey_m0/bootloader-TRRStrinkey_m0.bin + +# Menu: Optimization +adafruit_TRRStrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_TRRStrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_TRRStrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_TRRStrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_TRRStrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_TRRStrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_TRRStrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_TRRStrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_TRRStrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_TRRStrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_TRRStrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_TRRStrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_TRRStrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_TRRStrinkey_m0.menu.debug.off=Off +adafruit_TRRStrinkey_m0.menu.debug.on=On +adafruit_TRRStrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit Thumbstick Trinkey M0 (SAMD21) +# ----------------------------------- +adafruit_thumbsticktrinkey_m0.name=Adafruit Thumbstick Trinkey M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_thumbsticktrinkey_m0.vid.0=0x239A +adafruit_thumbsticktrinkey_m0.pid.0=0x8159 +adafruit_thumbsticktrinkey_m0.vid.1=0x239A +adafruit_thumbsticktrinkey_m0.pid.1=0x0159 +adafruit_thumbsticktrinkey_m0.vid.2=0x239A +adafruit_thumbsticktrinkey_m0.pid.2=0x8160 + +# Upload +adafruit_thumbsticktrinkey_m0.upload.tool=bossac18 +adafruit_thumbsticktrinkey_m0.upload.protocol=sam-ba +adafruit_thumbsticktrinkey_m0.upload.maximum_size=262144 +adafruit_thumbsticktrinkey_m0.upload.offset=0x2000 +adafruit_thumbsticktrinkey_m0.upload.use_1200bps_touch=true +adafruit_thumbsticktrinkey_m0.upload.wait_for_upload_port=true +adafruit_thumbsticktrinkey_m0.upload.native_usb=true + +# Build +adafruit_thumbsticktrinkey_m0.build.mcu=cortex-m0plus +adafruit_thumbsticktrinkey_m0.build.f_cpu=48000000L +adafruit_thumbsticktrinkey_m0.build.usb_product="Thumbstick Trinkey M0" +adafruit_thumbsticktrinkey_m0.build.usb_manufacturer="Adafruit" +adafruit_thumbsticktrinkey_m0.build.board=THUMBSTICKTRINKEY_M0 +adafruit_thumbsticktrinkey_m0.build.core=arduino +adafruit_thumbsticktrinkey_m0.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_THUMBSTICKTRINKEY_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_thumbsticktrinkey_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_thumbsticktrinkey_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_thumbsticktrinkey_m0.build.variant=thumbsticktrinkey_m0 +adafruit_thumbsticktrinkey_m0.build.variant_system_lib= +adafruit_thumbsticktrinkey_m0.build.vid=0x239A +adafruit_thumbsticktrinkey_m0.build.pid=0x8159 +adafruit_thumbsticktrinkey_m0.bootloader.tool=openocd +adafruit_thumbsticktrinkey_m0.bootloader.file=thumbsticktrinkey_m0/bootloader-thumbsticktrinkey_m0.bin + +# Menu: Optimization +adafruit_thumbsticktrinkey_m0.menu.opt.small=Small (-Os) (standard) +adafruit_thumbsticktrinkey_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_thumbsticktrinkey_m0.menu.opt.fast=Fast (-O2) +adafruit_thumbsticktrinkey_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_thumbsticktrinkey_m0.menu.opt.faster=Faster (-O3) +adafruit_thumbsticktrinkey_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_thumbsticktrinkey_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_thumbsticktrinkey_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_thumbsticktrinkey_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_thumbsticktrinkey_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_thumbsticktrinkey_m0.menu.usbstack.arduino=Arduino +adafruit_thumbsticktrinkey_m0.menu.usbstack.tinyusb=TinyUSB +adafruit_thumbsticktrinkey_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_thumbsticktrinkey_m0.menu.debug.off=Off +adafruit_thumbsticktrinkey_m0.menu.debug.on=On +adafruit_thumbsticktrinkey_m0.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit ItsyBitsy M0 Express (SAMD21) +# ----------------------------------- +adafruit_itsybitsy_m0.name=Adafruit ItsyBitsy M0 Express (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_itsybitsy_m0.vid.0=0x239A adafruit_itsybitsy_m0.pid.0=0x800F adafruit_itsybitsy_m0.vid.1=0x239A adafruit_itsybitsy_m0.pid.1=0x000F adafruit_itsybitsy_m0.vid.2=0x239A adafruit_itsybitsy_m0.pid.2=0x8012 -adafruit_itsybitsy_m0.upload.tool=bossac + +# Upload +adafruit_itsybitsy_m0.upload.tool=bossac18 adafruit_itsybitsy_m0.upload.protocol=sam-ba adafruit_itsybitsy_m0.upload.maximum_size=262144 adafruit_itsybitsy_m0.upload.offset=0x2000 adafruit_itsybitsy_m0.upload.use_1200bps_touch=true adafruit_itsybitsy_m0.upload.wait_for_upload_port=true adafruit_itsybitsy_m0.upload.native_usb=true + +# Build adafruit_itsybitsy_m0.build.mcu=cortex-m0plus adafruit_itsybitsy_m0.build.f_cpu=48000000L adafruit_itsybitsy_m0.build.usb_product="ItsyBitsy M0 Express" adafruit_itsybitsy_m0.build.usb_manufacturer="Adafruit" adafruit_itsybitsy_m0.build.board=ITSYBITSY_M0 adafruit_itsybitsy_m0.build.core=arduino -adafruit_itsybitsy_m0.build.extra_flags=-DCRYSTALLESS -DADAFRUIT_ITSYBITSY_M0 -D__SAMD21G18A__ -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_itsybitsy_m0.build.extra_flags=-D__SAMD21G18A__ -DCRYSTALLESS -DADAFRUIT_ITSYBITSY_M0 -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_itsybitsy_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_itsybitsy_m0.build.openocdscript=openocd_scripts/itsybitsy_m0.cfg +adafruit_itsybitsy_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_itsybitsy_m0.build.variant=itsybitsy_m0 adafruit_itsybitsy_m0.build.variant_system_lib= adafruit_itsybitsy_m0.build.vid=0x239A adafruit_itsybitsy_m0.build.pid=0x800F adafruit_itsybitsy_m0.bootloader.tool=openocd adafruit_itsybitsy_m0.bootloader.file=itsybitsyM0/bootloader-itsybitsy_m0-v2.0.0-adafruit.5.bin + +# Menu: Optimization +adafruit_itsybitsy_m0.menu.opt.small=Small (-Os) (standard) +adafruit_itsybitsy_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_itsybitsy_m0.menu.opt.fast=Fast (-O2) +adafruit_itsybitsy_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_itsybitsy_m0.menu.opt.faster=Faster (-O3) +adafruit_itsybitsy_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_itsybitsy_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_itsybitsy_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_itsybitsy_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_itsybitsy_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_itsybitsy_m0.menu.usbstack.arduino=Arduino adafruit_itsybitsy_m0.menu.usbstack.tinyusb=TinyUSB adafruit_itsybitsy_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_itsybitsy_m0.menu.debug.off=Off adafruit_itsybitsy_m0.menu.debug.on=On adafruit_itsybitsy_m0.menu.debug.on.build.flags.debug=-g -# Adafruit PIRkey (SAMD21) -# ------------------------------ -adafruit_pirkey.name=Adafruit pIRkey +# ----------------------------------- +# Adafruit pIRKey (SAMD21) +# ----------------------------------- +adafruit_pirkey.name=Adafruit pIRKey (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_pirkey.vid.0=0x239A -adafruit_pirkey.pid.0=0x801E +adafruit_pirkey.pid.0=0x8027 adafruit_pirkey.vid.1=0x239A -adafruit_pirkey.pid.1=0x001E -adafruit_pirkey.upload.tool=bossac +adafruit_pirkey.pid.1=0x0027 +adafruit_pirkey.vid.2=0x239A +adafruit_pirkey.pid.2=0x8028 + +# Upload +adafruit_pirkey.upload.tool=bossac18 adafruit_pirkey.upload.protocol=sam-ba adafruit_pirkey.upload.maximum_size=262144 adafruit_pirkey.upload.offset=0x2000 adafruit_pirkey.upload.use_1200bps_touch=true adafruit_pirkey.upload.wait_for_upload_port=true adafruit_pirkey.upload.native_usb=true + +# Build adafruit_pirkey.build.mcu=cortex-m0plus adafruit_pirkey.build.f_cpu=48000000L adafruit_pirkey.build.usb_product="pIRKey" adafruit_pirkey.build.usb_manufacturer="Adafruit" adafruit_pirkey.build.board=PIRKEY adafruit_pirkey.build.core=arduino -adafruit_pirkey.build.extra_flags=-DCRYSTALLESS -DADAFRUIT_PIRKEY -D__SAMD21E18A__ -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_pirkey.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_PIRKEY -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_pirkey.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_pirkey.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_pirkey.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_pirkey.build.variant=pirkey adafruit_pirkey.build.variant_system_lib= adafruit_pirkey.build.vid=0x239A -adafruit_pirkey.build.pid=0x801E +adafruit_pirkey.build.pid=0x8027 adafruit_pirkey.bootloader.tool=openocd adafruit_pirkey.bootloader.file=pirkey/bootloader-pirkey-v2.0.0-adafruit.5.bin + +# Menu: Optimization +adafruit_pirkey.menu.opt.small=Small (-Os) (standard) +adafruit_pirkey.menu.opt.small.build.flags.optimize=-Os +adafruit_pirkey.menu.opt.fast=Fast (-O2) +adafruit_pirkey.menu.opt.fast.build.flags.optimize=-O2 +adafruit_pirkey.menu.opt.faster=Faster (-O3) +adafruit_pirkey.menu.opt.faster.build.flags.optimize=-O3 +adafruit_pirkey.menu.opt.fastest=Fastest (-Ofast) +adafruit_pirkey.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_pirkey.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_pirkey.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_pirkey.menu.usbstack.arduino=Arduino adafruit_pirkey.menu.usbstack.tinyusb=TinyUSB adafruit_pirkey.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB -# Adafruit HalloWing M0 (SAMD21) -# ------------------------------ -adafruit_hallowing.name=Adafruit Hallowing M0 +# Menu: Debug +adafruit_pirkey.menu.debug.off=Off +adafruit_pirkey.menu.debug.on=On +adafruit_pirkey.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit Hallowing M0 (SAMD21) +# ----------------------------------- +adafruit_hallowing.name=Adafruit Hallowing M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_hallowing.vid.0=0x239A adafruit_hallowing.pid.0=0xDEAD adafruit_hallowing.vid.1=0x239A adafruit_hallowing.pid.1=0xD1ED -adafruit_hallowing.vid.1=0x239A -adafruit_hallowing.pid.1=0xB000 -adafruit_hallowing.upload.tool=bossac +adafruit_hallowing.vid.2=0x239A +adafruit_hallowing.pid.2=0xB000 + +# Upload +adafruit_hallowing.upload.tool=bossac18 adafruit_hallowing.upload.protocol=sam-ba adafruit_hallowing.upload.maximum_size=262144 adafruit_hallowing.upload.offset=0x2000 adafruit_hallowing.upload.use_1200bps_touch=true adafruit_hallowing.upload.wait_for_upload_port=true adafruit_hallowing.upload.native_usb=true + +# Build adafruit_hallowing.build.mcu=cortex-m0plus adafruit_hallowing.build.f_cpu=48000000L adafruit_hallowing.build.usb_product="Hallowing M0" adafruit_hallowing.build.usb_manufacturer="Adafruit" adafruit_hallowing.build.board=SAMD_HALLOWING adafruit_hallowing.build.core=arduino -adafruit_hallowing.build.extra_flags=-DCRYSTALLESS -DARDUINO_SAMD_ZERO -DARDUINO_SAMD_HALLOWING_M0 -DARM_MATH_CM0PLUS -DADAFRUIT_HALLOWING -D__SAMD21G18A__ {build.usb_flags} +adafruit_hallowing.build.extra_flags=-D__SAMD21G18A__ -DCRYSTALLESS -DARDUINO_SAMD_HALLOWING_M0 -DADAFRUIT_HALLOWING -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_hallowing.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_hallowing.build.openocdscript=openocd_scripts/hallowing_m0_express.cfg +adafruit_hallowing.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_hallowing.build.variant=hallowing_m0_express adafruit_hallowing.build.variant_system_lib= adafruit_hallowing.build.vid=0x239A adafruit_hallowing.build.pid=0xDEAD adafruit_hallowing.bootloader.tool=openocd adafruit_hallowing.bootloader.file=hallowingM0/bootloader-hallowing_m0-v2.0.0-adafruit.0-21-g887cc30.bin + +# Menu: Optimization +adafruit_hallowing.menu.opt.small=Small (-Os) (standard) +adafruit_hallowing.menu.opt.small.build.flags.optimize=-Os +adafruit_hallowing.menu.opt.fast=Fast (-O2) +adafruit_hallowing.menu.opt.fast.build.flags.optimize=-O2 +adafruit_hallowing.menu.opt.faster=Faster (-O3) +adafruit_hallowing.menu.opt.faster.build.flags.optimize=-O3 +adafruit_hallowing.menu.opt.fastest=Fastest (-Ofast) +adafruit_hallowing.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_hallowing.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_hallowing.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_hallowing.menu.usbstack.arduino=Arduino adafruit_hallowing.menu.usbstack.tinyusb=TinyUSB adafruit_hallowing.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_hallowing.menu.debug.off=Off adafruit_hallowing.menu.debug.on=On adafruit_hallowing.menu.debug.on.build.flags.debug=-g + +# ----------------------------------- # Adafruit Crickit M0 (SAMD21) -# ------------------------------ -adafruit_crickit_m0.name=Adafruit Crickit M0 +# ----------------------------------- +adafruit_crickit_m0.name=Adafruit Crickit M0 (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_crickit_m0.vid.0=0x239A adafruit_crickit_m0.pid.0=0x802D adafruit_crickit_m0.vid.1=0x239A adafruit_crickit_m0.pid.1=0x002D adafruit_crickit_m0.vid.2=0x239A adafruit_crickit_m0.pid.2=0x802D -adafruit_crickit_m0.upload.tool=bossac + +# Upload +adafruit_crickit_m0.upload.tool=bossac18 adafruit_crickit_m0.upload.protocol=sam-ba adafruit_crickit_m0.upload.maximum_size=262144 adafruit_crickit_m0.upload.offset=0x2000 adafruit_crickit_m0.upload.use_1200bps_touch=true adafruit_crickit_m0.upload.wait_for_upload_port=true adafruit_crickit_m0.upload.native_usb=true + +# Build adafruit_crickit_m0.build.mcu=cortex-m0plus adafruit_crickit_m0.build.f_cpu=48000000L adafruit_crickit_m0.build.usb_product="Crickit M0" adafruit_crickit_m0.build.usb_manufacturer="Adafruit" adafruit_crickit_m0.build.board=CRICKIT_M0 adafruit_crickit_m0.build.core=arduino -adafruit_crickit_m0.build.extra_flags=-DCRYSTALLESS -DADAFRUIT_CRICKIT_M0 -D__SAMD21G18A__ -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_crickit_m0.build.extra_flags=-D__SAMD21G18A__ -DCRYSTALLESS -DADAFRUIT_CRICKIT_M0 -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} adafruit_crickit_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_crickit_m0.build.openocdscript=openocd_scripts/crickit_m0.cfg +adafruit_crickit_m0.build.openocdscript=scripts/openocd/daplink_samd21.cfg adafruit_crickit_m0.build.variant=crickit_m0 adafruit_crickit_m0.build.variant_system_lib= adafruit_crickit_m0.build.vid=0x239A adafruit_crickit_m0.build.pid=0x802D adafruit_crickit_m0.bootloader.tool=openocd adafruit_crickit_m0.bootloader.file=crickit/samd21_sam_ba.bin + +# Menu: Optimization +adafruit_crickit_m0.menu.opt.small=Small (-Os) (standard) +adafruit_crickit_m0.menu.opt.small.build.flags.optimize=-Os +adafruit_crickit_m0.menu.opt.fast=Fast (-O2) +adafruit_crickit_m0.menu.opt.fast.build.flags.optimize=-O2 +adafruit_crickit_m0.menu.opt.faster=Faster (-O3) +adafruit_crickit_m0.menu.opt.faster.build.flags.optimize=-O3 +adafruit_crickit_m0.menu.opt.fastest=Fastest (-Ofast) +adafruit_crickit_m0.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_crickit_m0.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_crickit_m0.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack adafruit_crickit_m0.menu.usbstack.arduino=Arduino adafruit_crickit_m0.menu.usbstack.tinyusb=TinyUSB adafruit_crickit_m0.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_crickit_m0.menu.debug.off=Off adafruit_crickit_m0.menu.debug.on=On adafruit_crickit_m0.menu.debug.on.build.flags.debug=-g + +# ----------------------------------- +# Adafruit BLM Badge (SAMD21) +# ----------------------------------- +adafruit_blm_badge.name=Adafruit BLM Badge (SAMD21) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_blm_badge.vid.0=0x239A +adafruit_blm_badge.pid.0=0x80BF +adafruit_blm_badge.vid.1=0x239A +adafruit_blm_badge.pid.1=0x00BF +adafruit_blm_badge.vid.2=0x239A +adafruit_blm_badge.pid.2=0x80C0 + +# Upload +adafruit_blm_badge.upload.tool=bossac18 +adafruit_blm_badge.upload.protocol=sam-ba +adafruit_blm_badge.upload.maximum_size=262144 +adafruit_blm_badge.upload.offset=0x2000 +adafruit_blm_badge.upload.use_1200bps_touch=true +adafruit_blm_badge.upload.wait_for_upload_port=true +adafruit_blm_badge.upload.native_usb=true + +# Build +adafruit_blm_badge.build.mcu=cortex-m0plus +adafruit_blm_badge.build.f_cpu=48000000L +adafruit_blm_badge.build.usb_product="BLM Badge" +adafruit_blm_badge.build.usb_manufacturer="Adafruit" +adafruit_blm_badge.build.board=BLM_BADGE_M0 +adafruit_blm_badge.build.core=arduino +adafruit_blm_badge.build.extra_flags=-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_BLM_BADGE -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS {build.usb_flags} +adafruit_blm_badge.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_blm_badge.build.openocdscript=scripts/openocd/daplink_samd21.cfg +adafruit_blm_badge.build.variant=blm_badge +adafruit_blm_badge.build.variant_system_lib= +adafruit_blm_badge.build.vid=0x239A +adafruit_blm_badge.build.pid=0x80BF +adafruit_blm_badge.bootloader.tool=openocd +adafruit_blm_badge.bootloader.file=blmbadge/bootloader-blm_badge.bin + +# Menu: Optimization +adafruit_blm_badge.menu.opt.small=Small (-Os) (standard) +adafruit_blm_badge.menu.opt.small.build.flags.optimize=-Os +adafruit_blm_badge.menu.opt.fast=Fast (-O2) +adafruit_blm_badge.menu.opt.fast.build.flags.optimize=-O2 +adafruit_blm_badge.menu.opt.faster=Faster (-O3) +adafruit_blm_badge.menu.opt.faster.build.flags.optimize=-O3 +adafruit_blm_badge.menu.opt.fastest=Fastest (-Ofast) +adafruit_blm_badge.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_blm_badge.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_blm_badge.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: USB Stack +adafruit_blm_badge.menu.usbstack.arduino=Arduino +adafruit_blm_badge.menu.usbstack.tinyusb=TinyUSB +adafruit_blm_badge.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_blm_badge.menu.debug.off=Off +adafruit_blm_badge.menu.debug.on=On +adafruit_blm_badge.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- # Adafruit Metro M4 (SAMD51) -# ------------------------------ +# ----------------------------------- adafruit_metro_m4.name=Adafruit Metro M4 (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_metro_m4.vid.0=0x239A adafruit_metro_m4.pid.0=0x8020 adafruit_metro_m4.vid.1=0x239A adafruit_metro_m4.pid.1=0x0020 +adafruit_metro_m4.vid.2=0x239A +adafruit_metro_m4.pid.2=0x8021 +adafruit_metro_m4.vid.3=0x239A +adafruit_metro_m4.pid.3=0x0021 + +# Upload adafruit_metro_m4.upload.tool=bossac18 adafruit_metro_m4.upload.protocol=sam-ba adafruit_metro_m4.upload.maximum_size=507904 @@ -433,26 +1336,32 @@ adafruit_metro_m4.upload.offset=0x4000 adafruit_metro_m4.upload.use_1200bps_touch=true adafruit_metro_m4.upload.wait_for_upload_port=true adafruit_metro_m4.upload.native_usb=true + +# Build adafruit_metro_m4.build.mcu=cortex-m4 -#adafruit_metro_m4.build.f_cpu=120000000L -adafruit_metro_m4.build.usb_product="Adafruit Metro M4" -adafruit_metro_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_metro_m4.build.f_cpu=120000000L +adafruit_metro_m4.build.usb_product="Metro M4" +adafruit_metro_m4.build.usb_manufacturer="Adafruit" adafruit_metro_m4.build.board=METRO_M4 adafruit_metro_m4.build.core=arduino -adafruit_metro_m4.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_METRO_M4_EXPRESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_metro_m4.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_METRO_M4_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_metro_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_metro_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_metro_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_metro_m4.build.variant=metro_m4 adafruit_metro_m4.build.variant_system_lib= adafruit_metro_m4.build.vid=0x239A adafruit_metro_m4.build.pid=0x8020 adafruit_metro_m4.bootloader.tool=openocd adafruit_metro_m4.bootloader.file=metroM4/bootloader-metro_m4-v2.0.0-adafruit.5.bin -adafruit_metro_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_metro_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_metro_m4.menu.cache.on=Enabled adafruit_metro_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_metro_m4.menu.cache.off=Disabled adafruit_metro_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_metro_m4.menu.speed.120=120 MHz (standard) adafruit_metro_m4.menu.speed.120.build.f_cpu=120000000L adafruit_metro_m4.menu.speed.150=150 MHz (overclock) @@ -461,6 +1370,8 @@ adafruit_metro_m4.menu.speed.180=180 MHz (overclock) adafruit_metro_m4.menu.speed.180.build.f_cpu=180000000L adafruit_metro_m4.menu.speed.200=200 MHz (overclock) adafruit_metro_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_metro_m4.menu.opt.small=Small (-Os) (standard) adafruit_metro_m4.menu.opt.small.build.flags.optimize=-Os adafruit_metro_m4.menu.opt.fast=Fast (-O2) @@ -471,27 +1382,38 @@ adafruit_metro_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_metro_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_metro_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_metro_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_metro_m4.menu.maxqspi.50=50 MHz (standard) adafruit_metro_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_metro_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_metro_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_metro_m4.menu.usbstack.arduino=Arduino adafruit_metro_m4.menu.usbstack.tinyusb=TinyUSB adafruit_metro_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_metro_m4.menu.debug.off=Off adafruit_metro_m4.menu.debug.on=On adafruit_metro_m4.menu.debug.on.build.flags.debug=-g +# ----------------------------------- # Adafruit Grand Central M4 (SAMD51) -# ------------------------------ +# ----------------------------------- adafruit_grandcentral_m4.name=Adafruit Grand Central M4 (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_grandcentral_m4.vid.0=0x239A adafruit_grandcentral_m4.pid.0=0x8031 adafruit_grandcentral_m4.vid.1=0x239A adafruit_grandcentral_m4.pid.1=0x0031 -adafruit_grandcentral_m4.vid.1=0x239A -adafruit_grandcentral_m4.pid.1=0x0032 +adafruit_grandcentral_m4.vid.2=0x239A +adafruit_grandcentral_m4.pid.2=0x0032 + +# Upload adafruit_grandcentral_m4.upload.tool=bossac18 adafruit_grandcentral_m4.upload.protocol=sam-ba adafruit_grandcentral_m4.upload.maximum_size=1032192 @@ -499,26 +1421,32 @@ adafruit_grandcentral_m4.upload.offset=0x4000 adafruit_grandcentral_m4.upload.use_1200bps_touch=true adafruit_grandcentral_m4.upload.wait_for_upload_port=true adafruit_grandcentral_m4.upload.native_usb=true + +# Build adafruit_grandcentral_m4.build.mcu=cortex-m4 -#adafruit_grandcentral_m4.build.f_cpu=120000000L -adafruit_grandcentral_m4.build.usb_product="Adafruit Grand Central M4" -adafruit_grandcentral_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_grandcentral_m4.build.f_cpu=120000000L +adafruit_grandcentral_m4.build.usb_product="Grand Central M4" +adafruit_grandcentral_m4.build.usb_manufacturer="Adafruit" adafruit_grandcentral_m4.build.board=GRAND_CENTRAL_M4 adafruit_grandcentral_m4.build.core=arduino -adafruit_grandcentral_m4.build.extra_flags=-D__SAMD51P20A__ -DADAFRUIT_GRAND_CENTRAL_M4 -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_grandcentral_m4.build.extra_flags=-D__SAMD51P20A__ -DADAFRUIT_GRAND_CENTRAL_M4 -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_grandcentral_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_grandcentral_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_grandcentral_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_grandcentral_m4.build.variant=grand_central_m4 adafruit_grandcentral_m4.build.variant_system_lib= adafruit_grandcentral_m4.build.vid=0x239A adafruit_grandcentral_m4.build.pid=0x8031 adafruit_grandcentral_m4.bootloader.tool=openocd -adafruit_grandcentral_m4.bootloader.file=grand_central_m4/bootloader-grandcentralM4-v2.0.0-adafruit.5.bin -adafruit_grandcentral_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_grandcentral_m4.bootloader.file=grand_central_m4/bootloader-grandcentral_m4.bin +adafruit_grandcentral_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_grandcentral_m4.menu.cache.on=Enabled adafruit_grandcentral_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_grandcentral_m4.menu.cache.off=Disabled adafruit_grandcentral_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_grandcentral_m4.menu.speed.120=120 MHz (standard) adafruit_grandcentral_m4.menu.speed.120.build.f_cpu=120000000L adafruit_grandcentral_m4.menu.speed.150=150 MHz (overclock) @@ -527,6 +1455,8 @@ adafruit_grandcentral_m4.menu.speed.180=180 MHz (overclock) adafruit_grandcentral_m4.menu.speed.180.build.f_cpu=180000000L adafruit_grandcentral_m4.menu.speed.200=200 MHz (overclock) adafruit_grandcentral_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_grandcentral_m4.menu.opt.small=Small (-Os) (standard) adafruit_grandcentral_m4.menu.opt.small.build.flags.optimize=-Os adafruit_grandcentral_m4.menu.opt.fast=Fast (-O2) @@ -537,24 +1467,36 @@ adafruit_grandcentral_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_grandcentral_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_grandcentral_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_grandcentral_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_grandcentral_m4.menu.maxqspi.50=50 MHz (standard) adafruit_grandcentral_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_grandcentral_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_grandcentral_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_grandcentral_m4.menu.usbstack.arduino=Arduino adafruit_grandcentral_m4.menu.usbstack.tinyusb=TinyUSB adafruit_grandcentral_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_grandcentral_m4.menu.debug.off=Off adafruit_grandcentral_m4.menu.debug.on=On adafruit_grandcentral_m4.menu.debug.on.build.flags.debug=-g + +# ----------------------------------- # Adafruit ItsyBitsy M4 (SAMD51) -# ------------------------------ +# ----------------------------------- adafruit_itsybitsy_m4.name=Adafruit ItsyBitsy M4 (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_itsybitsy_m4.vid.0=0x239A adafruit_itsybitsy_m4.pid.0=0x802B adafruit_itsybitsy_m4.vid.1=0x239A adafruit_itsybitsy_m4.pid.1=0x002B + +# Upload adafruit_itsybitsy_m4.upload.tool=bossac18 adafruit_itsybitsy_m4.upload.protocol=sam-ba adafruit_itsybitsy_m4.upload.maximum_size=507904 @@ -562,26 +1504,32 @@ adafruit_itsybitsy_m4.upload.offset=0x4000 adafruit_itsybitsy_m4.upload.use_1200bps_touch=true adafruit_itsybitsy_m4.upload.wait_for_upload_port=true adafruit_itsybitsy_m4.upload.native_usb=true + +# Build adafruit_itsybitsy_m4.build.mcu=cortex-m4 -#adafruit_itsybitsy_m4.build.f_cpu=120000000L -adafruit_itsybitsy_m4.build.usb_product="Adafruit ItsyBitsy M4" -adafruit_itsybitsy_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_itsybitsy_m4.build.f_cpu=120000000L +adafruit_itsybitsy_m4.build.usb_product="ItsyBitsy M4" +adafruit_itsybitsy_m4.build.usb_manufacturer="Adafruit" adafruit_itsybitsy_m4.build.board=ITSYBITSY_M4 adafruit_itsybitsy_m4.build.core=arduino -adafruit_itsybitsy_m4.build.extra_flags=-D__SAMD51G19A__ -DADAFRUIT_ITSYBITSY_M4_EXPRESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -DCRYSTALLESS -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_itsybitsy_m4.build.extra_flags=-D__SAMD51G19A__ -DCRYSTALLESS -DADAFRUIT_ITSYBITSY_M4_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_itsybitsy_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_itsybitsy_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_itsybitsy_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_itsybitsy_m4.build.variant=itsybitsy_m4 adafruit_itsybitsy_m4.build.variant_system_lib= adafruit_itsybitsy_m4.build.vid=0x239A adafruit_itsybitsy_m4.build.pid=0x802B adafruit_itsybitsy_m4.bootloader.tool=openocd adafruit_itsybitsy_m4.bootloader.file=itsybitsyM4/bootloader-itsybitsy_m4-v2.0.0-adafruit.5.bin -adafruit_itsybitsy_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_itsybitsy_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_itsybitsy_m4.menu.cache.on=Enabled adafruit_itsybitsy_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_itsybitsy_m4.menu.cache.off=Disabled adafruit_itsybitsy_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_itsybitsy_m4.menu.speed.120=120 MHz (standard) adafruit_itsybitsy_m4.menu.speed.120.build.f_cpu=120000000L adafruit_itsybitsy_m4.menu.speed.150=150 MHz (overclock) @@ -590,6 +1538,8 @@ adafruit_itsybitsy_m4.menu.speed.180=180 MHz (overclock) adafruit_itsybitsy_m4.menu.speed.180.build.f_cpu=180000000L adafruit_itsybitsy_m4.menu.speed.200=200 MHz (overclock) adafruit_itsybitsy_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_itsybitsy_m4.menu.opt.small=Small (-Os) (standard) adafruit_itsybitsy_m4.menu.opt.small.build.flags.optimize=-Os adafruit_itsybitsy_m4.menu.opt.fast=Fast (-O2) @@ -600,24 +1550,38 @@ adafruit_itsybitsy_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_itsybitsy_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_itsybitsy_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_itsybitsy_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_itsybitsy_m4.menu.maxqspi.50=50 MHz (standard) adafruit_itsybitsy_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_itsybitsy_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_itsybitsy_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_itsybitsy_m4.menu.usbstack.arduino=Arduino adafruit_itsybitsy_m4.menu.usbstack.tinyusb=TinyUSB adafruit_itsybitsy_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_itsybitsy_m4.menu.debug.off=Off adafruit_itsybitsy_m4.menu.debug.on=On adafruit_itsybitsy_m4.menu.debug.on.build.flags.debug=-g + +# ----------------------------------- # Adafruit Feather M4 Express (SAMD51) -# ------------------------------ +# ----------------------------------- adafruit_feather_m4.name=Adafruit Feather M4 Express (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_feather_m4.vid.0=0x239A adafruit_feather_m4.pid.0=0x8022 adafruit_feather_m4.vid.1=0x239A adafruit_feather_m4.pid.1=0x0022 +adafruit_feather_m4.vid.2=0x239A +adafruit_feather_m4.pid.2=0x8026 + +# Upload adafruit_feather_m4.upload.tool=bossac18 adafruit_feather_m4.upload.protocol=sam-ba adafruit_feather_m4.upload.maximum_size=507904 @@ -625,26 +1589,32 @@ adafruit_feather_m4.upload.offset=0x4000 adafruit_feather_m4.upload.use_1200bps_touch=true adafruit_feather_m4.upload.wait_for_upload_port=true adafruit_feather_m4.upload.native_usb=true + +# Build adafruit_feather_m4.build.mcu=cortex-m4 -#adafruit_feather_m4.build.f_cpu=120000000L -adafruit_feather_m4.build.usb_product="Adafruit Feather M4" -adafruit_feather_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_feather_m4.build.f_cpu=120000000L +adafruit_feather_m4.build.usb_product="Feather M4 Express" +adafruit_feather_m4.build.usb_manufacturer="Adafruit" adafruit_feather_m4.build.board=FEATHER_M4 adafruit_feather_m4.build.core=arduino -adafruit_feather_m4.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_FEATHER_M4_EXPRESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_feather_m4.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_FEATHER_M4_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_feather_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_feather_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_feather_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_feather_m4.build.variant=feather_m4 adafruit_feather_m4.build.variant_system_lib= adafruit_feather_m4.build.vid=0x239A adafruit_feather_m4.build.pid=0x8022 adafruit_feather_m4.bootloader.tool=openocd adafruit_feather_m4.bootloader.file=featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin -adafruit_feather_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_feather_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_feather_m4.menu.cache.on=Enabled adafruit_feather_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_feather_m4.menu.cache.off=Disabled adafruit_feather_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_feather_m4.menu.speed.120=120 MHz (standard) adafruit_feather_m4.menu.speed.120.build.f_cpu=120000000L adafruit_feather_m4.menu.speed.150=150 MHz (overclock) @@ -653,6 +1623,8 @@ adafruit_feather_m4.menu.speed.180=180 MHz (overclock) adafruit_feather_m4.menu.speed.180.build.f_cpu=180000000L adafruit_feather_m4.menu.speed.200=200 MHz (overclock) adafruit_feather_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_feather_m4.menu.opt.small=Small (-Os) (standard) adafruit_feather_m4.menu.opt.small.build.flags.optimize=-Os adafruit_feather_m4.menu.opt.fast=Fast (-O2) @@ -663,26 +1635,121 @@ adafruit_feather_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_feather_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_feather_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_feather_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_feather_m4.menu.maxqspi.50=50 MHz (standard) adafruit_feather_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_feather_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_feather_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_feather_m4.menu.usbstack.arduino=Arduino adafruit_feather_m4.menu.usbstack.tinyusb=TinyUSB adafruit_feather_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_feather_m4.menu.debug.off=Off adafruit_feather_m4.menu.debug.on=On adafruit_feather_m4.menu.debug.on.build.flags.debug=-g + +# ----------------------------------- +# Adafruit Feather M4 CAN (SAME51) +# ----------------------------------- +adafruit_feather_m4_can.name=Adafruit Feather M4 CAN (SAME51) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_feather_m4_can.vid.0=0x239A +adafruit_feather_m4_can.pid.0=0x80CD +adafruit_feather_m4_can.vid.1=0x239A +adafruit_feather_m4_can.pid.1=0x00CD + +# Upload +adafruit_feather_m4_can.upload.tool=bossac18 +adafruit_feather_m4_can.upload.protocol=sam-ba +adafruit_feather_m4_can.upload.maximum_size=507904 +adafruit_feather_m4_can.upload.offset=0x4000 +adafruit_feather_m4_can.upload.use_1200bps_touch=true +adafruit_feather_m4_can.upload.wait_for_upload_port=true +adafruit_feather_m4_can.upload.native_usb=true + +# Build +adafruit_feather_m4_can.build.mcu=cortex-m4 +adafruit_feather_m4_can.build.f_cpu=120000000L +adafruit_feather_m4_can.build.usb_product="Feather M4 CAN" +adafruit_feather_m4_can.build.usb_manufacturer="Adafruit" +adafruit_feather_m4_can.build.board=FEATHER_M4_CAN +adafruit_feather_m4_can.build.core=arduino +adafruit_feather_m4_can.build.extra_flags=-D__SAME51J19A__ -DADAFRUIT_FEATHER_M4_EXPRESS -DADAFRUIT_FEATHER_M4_CAN -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} +adafruit_feather_m4_can.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_feather_m4_can.build.openocdscript=scripts/openocd/daplink_samd51.cfg +adafruit_feather_m4_can.build.variant=feather_m4_can +adafruit_feather_m4_can.build.variant_system_lib= +adafruit_feather_m4_can.build.vid=0x239A +adafruit_feather_m4_can.build.pid=0x80CD +adafruit_feather_m4_can.bootloader.tool=openocd +adafruit_feather_m4_can.bootloader.file=featherM4/bootloader-feather_m4_express-v2.0.0-adafruit.5.bin +adafruit_feather_m4_can.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache +adafruit_feather_m4_can.menu.cache.on=Enabled +adafruit_feather_m4_can.menu.cache.on.build.cache_flags=-DENABLE_CACHE +adafruit_feather_m4_can.menu.cache.off=Disabled +adafruit_feather_m4_can.menu.cache.off.build.cache_flags= + +# Menu: Speed +adafruit_feather_m4_can.menu.speed.120=120 MHz (standard) +adafruit_feather_m4_can.menu.speed.120.build.f_cpu=120000000L +adafruit_feather_m4_can.menu.speed.150=150 MHz (overclock) +adafruit_feather_m4_can.menu.speed.150.build.f_cpu=150000000L +adafruit_feather_m4_can.menu.speed.180=180 MHz (overclock) +adafruit_feather_m4_can.menu.speed.180.build.f_cpu=180000000L +adafruit_feather_m4_can.menu.speed.200=200 MHz (overclock) +adafruit_feather_m4_can.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization +adafruit_feather_m4_can.menu.opt.small=Small (-Os) (standard) +adafruit_feather_m4_can.menu.opt.small.build.flags.optimize=-Os +adafruit_feather_m4_can.menu.opt.fast=Fast (-O2) +adafruit_feather_m4_can.menu.opt.fast.build.flags.optimize=-O2 +adafruit_feather_m4_can.menu.opt.faster=Faster (-O3) +adafruit_feather_m4_can.menu.opt.faster.build.flags.optimize=-O3 +adafruit_feather_m4_can.menu.opt.fastest=Fastest (-Ofast) +adafruit_feather_m4_can.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_feather_m4_can.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_feather_m4_can.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed +adafruit_feather_m4_can.menu.maxqspi.50=50 MHz (standard) +adafruit_feather_m4_can.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 +adafruit_feather_m4_can.menu.maxqspi.fcpu=CPU Speed / 2 +adafruit_feather_m4_can.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack +adafruit_feather_m4_can.menu.usbstack.arduino=Arduino +adafruit_feather_m4_can.menu.usbstack.tinyusb=TinyUSB +adafruit_feather_m4_can.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_feather_m4_can.menu.debug.off=Off +adafruit_feather_m4_can.menu.debug.on=On +adafruit_feather_m4_can.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- # Adafruit Trellis M4 (SAMD51) -# ------------------------------ +# ----------------------------------- adafruit_trellis_m4.name=Adafruit Trellis M4 (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_trellis_m4.vid.0=0x239A adafruit_trellis_m4.pid.0=0x802F adafruit_trellis_m4.vid.1=0x239A adafruit_trellis_m4.pid.1=0x002F adafruit_trellis_m4.vid.2=0x239A adafruit_trellis_m4.pid.2=0x0030 + +# Upload adafruit_trellis_m4.upload.tool=bossac18 adafruit_trellis_m4.upload.protocol=sam-ba adafruit_trellis_m4.upload.maximum_size=507904 @@ -690,26 +1757,32 @@ adafruit_trellis_m4.upload.offset=0x4000 adafruit_trellis_m4.upload.use_1200bps_touch=true adafruit_trellis_m4.upload.wait_for_upload_port=true adafruit_trellis_m4.upload.native_usb=true + +# Build adafruit_trellis_m4.build.mcu=cortex-m4 -#adafruit_trellis_m4.build.f_cpu=120000000L -adafruit_trellis_m4.build.usb_product="Adafruit Trellis M4" -adafruit_trellis_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_trellis_m4.build.f_cpu=120000000L +adafruit_trellis_m4.build.usb_product="Trellis M4" +adafruit_trellis_m4.build.usb_manufacturer="Adafruit" adafruit_trellis_m4.build.board=TRELLIS_M4 adafruit_trellis_m4.build.core=arduino -adafruit_trellis_m4.build.extra_flags=-D__SAMD51G19A__ -DADAFRUIT_TRELLIS_M4_EXPRESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -DCRYSTALLESS -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_trellis_m4.build.extra_flags=-D__SAMD51G19A__ -DCRYSTALLESS -DADAFRUIT_TRELLIS_M4_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_trellis_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_trellis_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_trellis_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_trellis_m4.build.variant=trellis_m4 adafruit_trellis_m4.build.variant_system_lib= adafruit_trellis_m4.build.vid=0x239A adafruit_trellis_m4.build.pid=0x802F adafruit_trellis_m4.bootloader.tool=openocd adafruit_trellis_m4.bootloader.file=trellisM4/bootloader-trellis_m4-v2.0.0-adafruit.5.bin -adafruit_trellis_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_trellis_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_trellis_m4.menu.cache.on=Enabled adafruit_trellis_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_trellis_m4.menu.cache.off=Disabled adafruit_trellis_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_trellis_m4.menu.speed.120=120 MHz (standard) adafruit_trellis_m4.menu.speed.120.build.f_cpu=120000000L adafruit_trellis_m4.menu.speed.150=150 MHz (overclock) @@ -718,6 +1791,8 @@ adafruit_trellis_m4.menu.speed.180=180 MHz (overclock) adafruit_trellis_m4.menu.speed.180.build.f_cpu=180000000L adafruit_trellis_m4.menu.speed.200=200 MHz (overclock) adafruit_trellis_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_trellis_m4.menu.opt.small=Small (-Os) (standard) adafruit_trellis_m4.menu.opt.small.build.flags.optimize=-Os adafruit_trellis_m4.menu.opt.fast=Fast (-O2) @@ -728,24 +1803,38 @@ adafruit_trellis_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_trellis_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_trellis_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_trellis_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_trellis_m4.menu.maxqspi.50=50 MHz (standard) adafruit_trellis_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_trellis_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_trellis_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_trellis_m4.menu.usbstack.arduino=Arduino adafruit_trellis_m4.menu.usbstack.tinyusb=TinyUSB adafruit_trellis_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_trellis_m4.menu.debug.off=Off adafruit_trellis_m4.menu.debug.on=On adafruit_trellis_m4.menu.debug.on.build.flags.debug=-g + +# ----------------------------------- # Adafruit PyPortal M4 (SAMD51) -# ------------------------------ +# ----------------------------------- adafruit_pyportal_m4.name=Adafruit PyPortal M4 (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_pyportal_m4.vid.0=0x239A adafruit_pyportal_m4.pid.0=0x8035 adafruit_pyportal_m4.vid.1=0x239A adafruit_pyportal_m4.pid.1=0x0035 +adafruit_pyportal_m4.vid.2=0x239A +adafruit_pyportal_m4.pid.2=0x8036 + +# Upload adafruit_pyportal_m4.upload.tool=bossac18 adafruit_pyportal_m4.upload.protocol=sam-ba adafruit_pyportal_m4.upload.maximum_size=1032192 @@ -753,26 +1842,32 @@ adafruit_pyportal_m4.upload.offset=0x4000 adafruit_pyportal_m4.upload.use_1200bps_touch=true adafruit_pyportal_m4.upload.wait_for_upload_port=true adafruit_pyportal_m4.upload.native_usb=true + +# Build adafruit_pyportal_m4.build.mcu=cortex-m4 -#adafruit_pyportal_m4.build.f_cpu=120000000L -adafruit_pyportal_m4.build.usb_product="Adafruit PyPortal M4" -adafruit_pyportal_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_pyportal_m4.build.f_cpu=120000000L +adafruit_pyportal_m4.build.usb_product="PyPortal M4" +adafruit_pyportal_m4.build.usb_manufacturer="Adafruit" adafruit_pyportal_m4.build.board=PYPORTAL_M4 adafruit_pyportal_m4.build.core=arduino -adafruit_pyportal_m4.build.extra_flags=-D__SAMD51J20A__ -DADAFRUIT_PYPORTAL -DCRYSTALLESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pyportal_m4.build.extra_flags=-D__SAMD51J20A__ -DCRYSTALLESS -DADAFRUIT_PYPORTAL -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_pyportal_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_pyportal_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_pyportal_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_pyportal_m4.build.variant=pyportal_m4 adafruit_pyportal_m4.build.variant_system_lib= adafruit_pyportal_m4.build.vid=0x239A adafruit_pyportal_m4.build.pid=0x8035 adafruit_pyportal_m4.bootloader.tool=openocd adafruit_pyportal_m4.bootloader.file=metroM4/bootloader-metro_m4-v2.0.0-adafruit.5.bin -adafruit_pyportal_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pyportal_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_pyportal_m4.menu.cache.on=Enabled adafruit_pyportal_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_pyportal_m4.menu.cache.off=Disabled adafruit_pyportal_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_pyportal_m4.menu.speed.120=120 MHz (standard) adafruit_pyportal_m4.menu.speed.120.build.f_cpu=120000000L adafruit_pyportal_m4.menu.speed.150=150 MHz (overclock) @@ -781,6 +1876,8 @@ adafruit_pyportal_m4.menu.speed.180=180 MHz (overclock) adafruit_pyportal_m4.menu.speed.180.build.f_cpu=180000000L adafruit_pyportal_m4.menu.speed.200=200 MHz (overclock) adafruit_pyportal_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_pyportal_m4.menu.opt.small=Small (-Os) (standard) adafruit_pyportal_m4.menu.opt.small.build.flags.optimize=-Os adafruit_pyportal_m4.menu.opt.fast=Fast (-O2) @@ -791,24 +1888,36 @@ adafruit_pyportal_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_pyportal_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_pyportal_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_pyportal_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_pyportal_m4.menu.maxqspi.50=50 MHz (standard) adafruit_pyportal_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_pyportal_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_pyportal_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_pyportal_m4.menu.usbstack.arduino=Arduino adafruit_pyportal_m4.menu.usbstack.tinyusb=TinyUSB adafruit_pyportal_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_pyportal_m4.menu.debug.off=Off adafruit_pyportal_m4.menu.debug.on=On adafruit_pyportal_m4.menu.debug.on.build.flags.debug=-g + +# ----------------------------------- # Adafruit PyPortal M4 Titano (SAMD51) -# ------------------------------ +# ----------------------------------- adafruit_pyportal_m4_titano.name=Adafruit PyPortal M4 Titano (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_pyportal_m4_titano.vid.0=0x239A adafruit_pyportal_m4_titano.pid.0=0x8053 adafruit_pyportal_m4_titano.vid.1=0x239A adafruit_pyportal_m4_titano.pid.1=0x8053 + +# Upload adafruit_pyportal_m4_titano.upload.tool=bossac18 adafruit_pyportal_m4_titano.upload.protocol=sam-ba adafruit_pyportal_m4_titano.upload.maximum_size=1032192 @@ -816,26 +1925,32 @@ adafruit_pyportal_m4_titano.upload.offset=0x4000 adafruit_pyportal_m4_titano.upload.use_1200bps_touch=true adafruit_pyportal_m4_titano.upload.wait_for_upload_port=true adafruit_pyportal_m4_titano.upload.native_usb=true + +# Build adafruit_pyportal_m4_titano.build.mcu=cortex-m4 -#adafruit_pyportal_m4_titano.build.f_cpu=120000000L -adafruit_pyportal_m4_titano.build.usb_product="Adafruit PyPortal M4 Titano" -adafruit_pyportal_m4_titano.build.usb_manufacturer="Adafruit LLC" +adafruit_pyportal_m4_titano.build.f_cpu=120000000L +adafruit_pyportal_m4_titano.build.usb_product="PyPortal M4 Titano" +adafruit_pyportal_m4_titano.build.usb_manufacturer="Adafruit" adafruit_pyportal_m4_titano.build.board=PYPORTAL_M4_TITANO adafruit_pyportal_m4_titano.build.core=arduino -adafruit_pyportal_m4_titano.build.extra_flags=-D__SAMD51J20A__ -DADAFRUIT_PYPORTAL_M4_TITANO -DCRYSTALLESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pyportal_m4_titano.build.extra_flags=-D__SAMD51J20A__ -DCRYSTALLESS -DADAFRUIT_PYPORTAL_M4_TITANO -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_pyportal_m4_titano.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_pyportal_m4_titano.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_pyportal_m4_titano.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_pyportal_m4_titano.build.variant=pyportal_m4_titano adafruit_pyportal_m4_titano.build.variant_system_lib= adafruit_pyportal_m4_titano.build.vid=0x239A -adafruit_pyportal_m4_titano.build.pid=0x8035 +adafruit_pyportal_m4_titano.build.pid=0x8053 adafruit_pyportal_m4_titano.bootloader.tool=openocd adafruit_pyportal_m4_titano.bootloader.file=metroM4/bootloader-metro_m4-v2.0.0-adafruit.5.bin -adafruit_pyportal_m4_titano.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pyportal_m4_titano.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_pyportal_m4_titano.menu.cache.on=Enabled adafruit_pyportal_m4_titano.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_pyportal_m4_titano.menu.cache.off=Disabled adafruit_pyportal_m4_titano.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_pyportal_m4_titano.menu.speed.120=120 MHz (standard) adafruit_pyportal_m4_titano.menu.speed.120.build.f_cpu=120000000L adafruit_pyportal_m4_titano.menu.speed.150=150 MHz (overclock) @@ -844,6 +1959,8 @@ adafruit_pyportal_m4_titano.menu.speed.180=180 MHz (overclock) adafruit_pyportal_m4_titano.menu.speed.180.build.f_cpu=180000000L adafruit_pyportal_m4_titano.menu.speed.200=200 MHz (overclock) adafruit_pyportal_m4_titano.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_pyportal_m4_titano.menu.opt.small=Small (-Os) (standard) adafruit_pyportal_m4_titano.menu.opt.small.build.flags.optimize=-Os adafruit_pyportal_m4_titano.menu.opt.fast=Fast (-O2) @@ -854,26 +1971,40 @@ adafruit_pyportal_m4_titano.menu.opt.fastest=Fastest (-Ofast) adafruit_pyportal_m4_titano.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_pyportal_m4_titano.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_pyportal_m4_titano.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_pyportal_m4_titano.menu.maxqspi.50=50 MHz (standard) adafruit_pyportal_m4_titano.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_pyportal_m4_titano.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_pyportal_m4_titano.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_pyportal_m4_titano.menu.usbstack.arduino=Arduino adafruit_pyportal_m4_titano.menu.usbstack.tinyusb=TinyUSB adafruit_pyportal_m4_titano.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_pyportal_m4_titano.menu.debug.off=Off adafruit_pyportal_m4_titano.menu.debug.on=On adafruit_pyportal_m4_titano.menu.debug.on.build.flags.debug=-g -# Adafruit pyBadge M4 (SAMD51) -# ------------------------------ + +# ----------------------------------- +# Adafruit pyBadge M4 Express (SAMD51) +# ----------------------------------- adafruit_pybadge_m4.name=Adafruit pyBadge M4 Express (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_pybadge_m4.vid.0=0x239A adafruit_pybadge_m4.pid.0=0x8033 adafruit_pybadge_m4.vid.1=0x239A adafruit_pybadge_m4.pid.1=0x0033 -adafruit_pybadge_m4.vid.1=0x239A -adafruit_pybadge_m4.pid.1=0x8033 +adafruit_pybadge_m4.vid.2=0x239A +adafruit_pybadge_m4.pid.2=0x8034 +adafruit_pybadge_m4.vid.3=0x239A +adafruit_pybadge_m4.pid.3=0x0034 + +# Upload adafruit_pybadge_m4.upload.tool=bossac18 adafruit_pybadge_m4.upload.protocol=sam-ba adafruit_pybadge_m4.upload.maximum_size=507904 @@ -881,26 +2012,32 @@ adafruit_pybadge_m4.upload.offset=0x4000 adafruit_pybadge_m4.upload.use_1200bps_touch=true adafruit_pybadge_m4.upload.wait_for_upload_port=true adafruit_pybadge_m4.upload.native_usb=true + +# Build adafruit_pybadge_m4.build.mcu=cortex-m4 -#adafruit_pybadge_m4.build.f_cpu=120000000L -adafruit_pybadge_m4.build.usb_product="Adafruit pyBadge M4" -adafruit_pybadge_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_pybadge_m4.build.f_cpu=120000000L +adafruit_pybadge_m4.build.usb_product="pyBadge M4 Express" +adafruit_pybadge_m4.build.usb_manufacturer="Adafruit" adafruit_pybadge_m4.build.board=PYBADGE_M4 adafruit_pybadge_m4.build.core=arduino -adafruit_pybadge_m4.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_PYBADGE_M4_EXPRESS -DCRYSTALLESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pybadge_m4.build.extra_flags=-D__SAMD51J19A__ -DCRYSTALLESS -DADAFRUIT_PYBADGE_M4_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_pybadge_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_pybadge_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_pybadge_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_pybadge_m4.build.variant=pybadge_m4 adafruit_pybadge_m4.build.variant_system_lib= adafruit_pybadge_m4.build.vid=0x239A adafruit_pybadge_m4.build.pid=0x8033 adafruit_pybadge_m4.bootloader.tool=openocd adafruit_pybadge_m4.bootloader.file=featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin -adafruit_pybadge_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pybadge_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_pybadge_m4.menu.cache.on=Enabled adafruit_pybadge_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_pybadge_m4.menu.cache.off=Disabled adafruit_pybadge_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_pybadge_m4.menu.speed.120=120 MHz (standard) adafruit_pybadge_m4.menu.speed.120.build.f_cpu=120000000L adafruit_pybadge_m4.menu.speed.150=150 MHz (overclock) @@ -909,6 +2046,8 @@ adafruit_pybadge_m4.menu.speed.180=180 MHz (overclock) adafruit_pybadge_m4.menu.speed.180.build.f_cpu=180000000L adafruit_pybadge_m4.menu.speed.200=200 MHz (overclock) adafruit_pybadge_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_pybadge_m4.menu.opt.small=Small (-Os) (standard) adafruit_pybadge_m4.menu.opt.small.build.flags.optimize=-Os adafruit_pybadge_m4.menu.opt.fast=Fast (-O2) @@ -919,25 +2058,36 @@ adafruit_pybadge_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_pybadge_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_pybadge_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_pybadge_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_pybadge_m4.menu.maxqspi.50=50 MHz (standard) adafruit_pybadge_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_pybadge_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_pybadge_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_pybadge_m4.menu.usbstack.arduino=Arduino adafruit_pybadge_m4.menu.usbstack.tinyusb=TinyUSB adafruit_pybadge_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_pybadge_m4.menu.debug.off=Off adafruit_pybadge_m4.menu.debug.on=On adafruit_pybadge_m4.menu.debug.on.build.flags.debug=-g -# Adafruit Metro M4 AirLift lite (SAMD51) -# ------------------------------ +# ----------------------------------- +# Adafruit Metro M4 AirLift Lite (SAMD51) +# ----------------------------------- adafruit_metro_m4_airliftlite.name=Adafruit Metro M4 AirLift Lite (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_metro_m4_airliftlite.vid.0=0x239A adafruit_metro_m4_airliftlite.pid.0=0x8037 adafruit_metro_m4_airliftlite.vid.1=0x239A adafruit_metro_m4_airliftlite.pid.1=0x0037 + +# Upload adafruit_metro_m4_airliftlite.upload.tool=bossac18 adafruit_metro_m4_airliftlite.upload.protocol=sam-ba adafruit_metro_m4_airliftlite.upload.maximum_size=507904 @@ -945,26 +2095,32 @@ adafruit_metro_m4_airliftlite.upload.offset=0x4000 adafruit_metro_m4_airliftlite.upload.use_1200bps_touch=true adafruit_metro_m4_airliftlite.upload.wait_for_upload_port=true adafruit_metro_m4_airliftlite.upload.native_usb=true + +# Build adafruit_metro_m4_airliftlite.build.mcu=cortex-m4 -#adafruit_metro_m4_airliftlite.build.f_cpu=120000000L -adafruit_metro_m4_airliftlite.build.usb_product="Adafruit Metro M4 Airlift Lite" -adafruit_metro_m4_airliftlite.build.usb_manufacturer="Adafruit LLC" +adafruit_metro_m4_airliftlite.build.f_cpu=120000000L +adafruit_metro_m4_airliftlite.build.usb_product="Metro M4 AirLift Lite" +adafruit_metro_m4_airliftlite.build.usb_manufacturer="Adafruit" adafruit_metro_m4_airliftlite.build.board=METRO_M4_AIRLIFT_LITE adafruit_metro_m4_airliftlite.build.core=arduino -adafruit_metro_m4_airliftlite.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_METRO_M4_AIRLIFT_LITE -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_metro_m4_airliftlite.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_METRO_M4_AIRLIFT_LITE -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_metro_m4_airliftlite.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_metro_m4_airliftlite.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_metro_m4_airliftlite.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_metro_m4_airliftlite.build.variant=metro_m4_airlift adafruit_metro_m4_airliftlite.build.variant_system_lib= adafruit_metro_m4_airliftlite.build.vid=0x239A adafruit_metro_m4_airliftlite.build.pid=0x8037 adafruit_metro_m4_airliftlite.bootloader.tool=openocd adafruit_metro_m4_airliftlite.bootloader.file=metroM4/bootloader-metro_m4-v2.0.0-adafruit.5.bin -adafruit_metro_m4_airliftlite.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_metro_m4_airliftlite.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_metro_m4_airliftlite.menu.cache.on=Enabled adafruit_metro_m4_airliftlite.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_metro_m4_airliftlite.menu.cache.off=Disabled adafruit_metro_m4_airliftlite.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_metro_m4_airliftlite.menu.speed.120=120 MHz (standard) adafruit_metro_m4_airliftlite.menu.speed.120.build.f_cpu=120000000L adafruit_metro_m4_airliftlite.menu.speed.150=150 MHz (overclock) @@ -973,6 +2129,8 @@ adafruit_metro_m4_airliftlite.menu.speed.180=180 MHz (overclock) adafruit_metro_m4_airliftlite.menu.speed.180.build.f_cpu=180000000L adafruit_metro_m4_airliftlite.menu.speed.200=200 MHz (overclock) adafruit_metro_m4_airliftlite.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_metro_m4_airliftlite.menu.opt.small=Small (-Os) (standard) adafruit_metro_m4_airliftlite.menu.opt.small.build.flags.optimize=-Os adafruit_metro_m4_airliftlite.menu.opt.fast=Fast (-O2) @@ -983,26 +2141,38 @@ adafruit_metro_m4_airliftlite.menu.opt.fastest=Fastest (-Ofast) adafruit_metro_m4_airliftlite.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_metro_m4_airliftlite.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_metro_m4_airliftlite.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_metro_m4_airliftlite.menu.maxqspi.50=50 MHz (standard) adafruit_metro_m4_airliftlite.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_metro_m4_airliftlite.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_metro_m4_airliftlite.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_metro_m4_airliftlite.menu.usbstack.arduino=Arduino adafruit_metro_m4_airliftlite.menu.usbstack.tinyusb=TinyUSB adafruit_metro_m4_airliftlite.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_metro_m4_airliftlite.menu.debug.off=Off adafruit_metro_m4_airliftlite.menu.debug.on=On adafruit_metro_m4_airliftlite.menu.debug.on.build.flags.debug=-g -# Adafruit pyGamer M4 Express (SAMD51) -# ------------------------------ + +# ----------------------------------- +# Adafruit PyGamer M4 Express (SAMD51) +# ----------------------------------- adafruit_pygamer_m4.name=Adafruit PyGamer M4 Express (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_pygamer_m4.vid.0=0x239A adafruit_pygamer_m4.pid.0=0x803D adafruit_pygamer_m4.vid.1=0x239A adafruit_pygamer_m4.pid.1=0x003D -adafruit_pygamer_m4.vid.1=0x239A -adafruit_pygamer_m4.pid.1=0x803E +adafruit_pygamer_m4.vid.2=0x239A +adafruit_pygamer_m4.pid.2=0x803E + +# Upload adafruit_pygamer_m4.upload.tool=bossac18 adafruit_pygamer_m4.upload.protocol=sam-ba adafruit_pygamer_m4.upload.maximum_size=507904 @@ -1010,26 +2180,32 @@ adafruit_pygamer_m4.upload.offset=0x4000 adafruit_pygamer_m4.upload.use_1200bps_touch=true adafruit_pygamer_m4.upload.wait_for_upload_port=true adafruit_pygamer_m4.upload.native_usb=true + +# Build adafruit_pygamer_m4.build.mcu=cortex-m4 -#adafruit_pygamer_m4.build.f_cpu=120000000L -adafruit_pygamer_m4.build.usb_product="Adafruit PyGamer M4" -adafruit_pygamer_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_pygamer_m4.build.f_cpu=120000000L +adafruit_pygamer_m4.build.usb_product="PyGamer M4 Express" +adafruit_pygamer_m4.build.usb_manufacturer="Adafruit" adafruit_pygamer_m4.build.board=PYGAMER_M4 adafruit_pygamer_m4.build.core=arduino -adafruit_pygamer_m4.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_PYGAMER_M4_EXPRESS -DCRYSTALLESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pygamer_m4.build.extra_flags=-D__SAMD51J19A__ -DCRYSTALLESS -DADAFRUIT_PYGAMER_M4_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_pygamer_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_pygamer_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_pygamer_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_pygamer_m4.build.variant=pygamer_m4 adafruit_pygamer_m4.build.variant_system_lib= adafruit_pygamer_m4.build.vid=0x239A adafruit_pygamer_m4.build.pid=0x803D adafruit_pygamer_m4.bootloader.tool=openocd adafruit_pygamer_m4.bootloader.file=featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin -adafruit_pygamer_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pygamer_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_pygamer_m4.menu.cache.on=Enabled adafruit_pygamer_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_pygamer_m4.menu.cache.off=Disabled adafruit_pygamer_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_pygamer_m4.menu.speed.120=120 MHz (standard) adafruit_pygamer_m4.menu.speed.120.build.f_cpu=120000000L adafruit_pygamer_m4.menu.speed.150=150 MHz (overclock) @@ -1038,6 +2214,8 @@ adafruit_pygamer_m4.menu.speed.180=180 MHz (overclock) adafruit_pygamer_m4.menu.speed.180.build.f_cpu=180000000L adafruit_pygamer_m4.menu.speed.200=200 MHz (overclock) adafruit_pygamer_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_pygamer_m4.menu.opt.small=Small (-Os) (standard) adafruit_pygamer_m4.menu.opt.small.build.flags.optimize=-Os adafruit_pygamer_m4.menu.opt.fast=Fast (-O2) @@ -1048,91 +2226,38 @@ adafruit_pygamer_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_pygamer_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_pygamer_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_pygamer_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_pygamer_m4.menu.maxqspi.50=50 MHz (standard) adafruit_pygamer_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_pygamer_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_pygamer_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_pygamer_m4.menu.usbstack.arduino=Arduino adafruit_pygamer_m4.menu.usbstack.tinyusb=TinyUSB adafruit_pygamer_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_pygamer_m4.menu.debug.off=Off adafruit_pygamer_m4.menu.debug.on=On adafruit_pygamer_m4.menu.debug.on.build.flags.debug=-g -# Adafruit pyGamer M4 Express (SAMD51) -# ------------------------------ -adafruit_pygamer_advance_m4.name=Adafruit PyGamer Advance M4 (SAMD51) -adafruit_pygamer_advance_m4.vid.0=0x239A -adafruit_pygamer_advance_m4.pid.0=0x8041 -adafruit_pygamer_advance_m4.vid.1=0x239A -adafruit_pygamer_advance_m4.pid.1=0x0041 -adafruit_pygamer_advance_m4.vid.1=0x239A -adafruit_pygamer_advance_m4.pid.1=0x8042 -adafruit_pygamer_advance_m4.upload.tool=bossac18 -adafruit_pygamer_advance_m4.upload.protocol=sam-ba -adafruit_pygamer_advance_m4.upload.maximum_size=1032192 -adafruit_pygamer_advance_m4.upload.offset=0x4000 -adafruit_pygamer_advance_m4.upload.use_1200bps_touch=true -adafruit_pygamer_advance_m4.upload.wait_for_upload_port=true -adafruit_pygamer_advance_m4.upload.native_usb=true -adafruit_pygamer_advance_m4.build.mcu=cortex-m4 -adafruit_pygamer_advance_m4.build.usb_product="Adafruit PyGamer Advance M4" -adafruit_pygamer_advance_m4.build.usb_manufacturer="Adafruit LLC" -adafruit_pygamer_advance_m4.build.board=PYGAMER_ADVANCE_M4 -adafruit_pygamer_advance_m4.build.core=arduino -adafruit_pygamer_advance_m4.build.extra_flags=-D__SAMD51J20A__ -DADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS -DCRYSTALLESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -adafruit_pygamer_advance_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_pygamer_advance_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg -adafruit_pygamer_advance_m4.build.variant=pygamer_advance_m4 -adafruit_pygamer_advance_m4.build.variant_system_lib= -adafruit_pygamer_advance_m4.build.vid=0x239A -adafruit_pygamer_advance_m4.build.pid=0x8041 -adafruit_pygamer_advance_m4.bootloader.tool=openocd -adafruit_pygamer_advance_m4.bootloader.file=featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin -adafruit_pygamer_advance_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 -adafruit_pygamer_advance_m4.menu.cache.on=Enabled -adafruit_pygamer_advance_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE -adafruit_pygamer_advance_m4.menu.cache.off=Disabled -adafruit_pygamer_advance_m4.menu.cache.off.build.cache_flags= -adafruit_pygamer_advance_m4.menu.speed.120=120 MHz (standard) -adafruit_pygamer_advance_m4.menu.speed.120.build.f_cpu=120000000L -adafruit_pygamer_advance_m4.menu.speed.150=150 MHz (overclock) -adafruit_pygamer_advance_m4.menu.speed.150.build.f_cpu=150000000L -adafruit_pygamer_advance_m4.menu.speed.180=180 MHz (overclock) -adafruit_pygamer_advance_m4.menu.speed.180.build.f_cpu=180000000L -adafruit_pygamer_advance_m4.menu.speed.200=200 MHz (overclock) -adafruit_pygamer_advance_m4.menu.speed.200.build.f_cpu=200000000L -adafruit_pygamer_advance_m4.menu.opt.small=Small (-Os) (standard) -adafruit_pygamer_advance_m4.menu.opt.small.build.flags.optimize=-Os -adafruit_pygamer_advance_m4.menu.opt.fast=Fast (-O2) -adafruit_pygamer_advance_m4.menu.opt.fast.build.flags.optimize=-O2 -adafruit_pygamer_advance_m4.menu.opt.faster=Faster (-O3) -adafruit_pygamer_advance_m4.menu.opt.faster.build.flags.optimize=-O3 -adafruit_pygamer_advance_m4.menu.opt.fastest=Fastest (-Ofast) -adafruit_pygamer_advance_m4.menu.opt.fastest.build.flags.optimize=-Ofast -adafruit_pygamer_advance_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) -adafruit_pygamer_advance_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops -adafruit_pygamer_advance_m4.menu.maxqspi.50=50 MHz (standard) -adafruit_pygamer_advance_m4.menu.maxqspi.fcpu=CPU Speed / 2 -adafruit_pygamer_advance_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 -adafruit_pygamer_advance_m4.menu.maxqspi.fcpu=CPU Speed / 2 -adafruit_pygamer_advance_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) -adafruit_pygamer_advance_m4.menu.usbstack.arduino=Arduino -adafruit_pygamer_advance_m4.menu.usbstack.tinyusb=TinyUSB -adafruit_pygamer_advance_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB -adafruit_pygamer_advance_m4.menu.debug.off=Off -adafruit_pygamer_advance_m4.menu.debug.on=On -adafruit_pygamer_advance_m4.menu.debug.on.build.flags.debug=-g +# ----------------------------------- # Adafruit pyBadge AirLift M4 (SAMD51) -# ------------------------------ +# ----------------------------------- adafruit_pybadge_airlift_m4.name=Adafruit pyBadge AirLift M4 (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_pybadge_airlift_m4.vid.0=0x239A adafruit_pybadge_airlift_m4.pid.0=0x8043 adafruit_pybadge_airlift_m4.vid.1=0x239A -adafruit_pybadge_airlift_m4.pid.1=0x0033 -adafruit_pybadge_airlift_m4.vid.1=0x239A -adafruit_pybadge_airlift_m4.pid.1=0x8043 +adafruit_pybadge_airlift_m4.pid.1=0x0043 +adafruit_pybadge_airlift_m4.vid.2=0x239A +adafruit_pybadge_airlift_m4.pid.2=0x8044 + +# Upload adafruit_pybadge_airlift_m4.upload.tool=bossac18 adafruit_pybadge_airlift_m4.upload.protocol=sam-ba adafruit_pybadge_airlift_m4.upload.maximum_size=1032192 @@ -1140,26 +2265,32 @@ adafruit_pybadge_airlift_m4.upload.offset=0x4000 adafruit_pybadge_airlift_m4.upload.use_1200bps_touch=true adafruit_pybadge_airlift_m4.upload.wait_for_upload_port=true adafruit_pybadge_airlift_m4.upload.native_usb=true + +# Build adafruit_pybadge_airlift_m4.build.mcu=cortex-m4 -#adafruit_pybadge_airlift_m4.build.f_cpu=120000000L -adafruit_pybadge_airlift_m4.build.usb_product="Adafruit pyBadge AirLift M4" -adafruit_pybadge_airlift_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_pybadge_airlift_m4.build.f_cpu=120000000L +adafruit_pybadge_airlift_m4.build.usb_product="pyBadge AirLift M4" +adafruit_pybadge_airlift_m4.build.usb_manufacturer="Adafruit" adafruit_pybadge_airlift_m4.build.board=PYBADGE_AIRLIFT_M4 adafruit_pybadge_airlift_m4.build.core=arduino -adafruit_pybadge_airlift_m4.build.extra_flags=-D__SAMD51J20A__ -DADAFRUIT_PYBADGE_AIRLIFT_M4 -DCRYSTALLESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pybadge_airlift_m4.build.extra_flags=-D__SAMD51J20A__ -DCRYSTALLESS -DADAFRUIT_PYBADGE_AIRLIFT_M4 -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_pybadge_airlift_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_pybadge_airlift_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_pybadge_airlift_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_pybadge_airlift_m4.build.variant=pybadge_airlift_m4 adafruit_pybadge_airlift_m4.build.variant_system_lib= adafruit_pybadge_airlift_m4.build.vid=0x239A adafruit_pybadge_airlift_m4.build.pid=0x8043 adafruit_pybadge_airlift_m4.bootloader.tool=openocd adafruit_pybadge_airlift_m4.bootloader.file=featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin -adafruit_pybadge_airlift_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_pybadge_airlift_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_pybadge_airlift_m4.menu.cache.on=Enabled adafruit_pybadge_airlift_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_pybadge_airlift_m4.menu.cache.off=Disabled adafruit_pybadge_airlift_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_pybadge_airlift_m4.menu.speed.120=120 MHz (standard) adafruit_pybadge_airlift_m4.menu.speed.120.build.f_cpu=120000000L adafruit_pybadge_airlift_m4.menu.speed.150=150 MHz (overclock) @@ -1168,6 +2299,8 @@ adafruit_pybadge_airlift_m4.menu.speed.180=180 MHz (overclock) adafruit_pybadge_airlift_m4.menu.speed.180.build.f_cpu=180000000L adafruit_pybadge_airlift_m4.menu.speed.200=200 MHz (overclock) adafruit_pybadge_airlift_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_pybadge_airlift_m4.menu.opt.small=Small (-Os) (standard) adafruit_pybadge_airlift_m4.menu.opt.small.build.flags.optimize=-Os adafruit_pybadge_airlift_m4.menu.opt.fast=Fast (-O2) @@ -1178,27 +2311,38 @@ adafruit_pybadge_airlift_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_pybadge_airlift_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_pybadge_airlift_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_pybadge_airlift_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_pybadge_airlift_m4.menu.maxqspi.50=50 MHz (standard) adafruit_pybadge_airlift_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_pybadge_airlift_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_pybadge_airlift_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_pybadge_airlift_m4.menu.usbstack.arduino=Arduino adafruit_pybadge_airlift_m4.menu.usbstack.tinyusb=TinyUSB adafruit_pybadge_airlift_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_pybadge_airlift_m4.menu.debug.off=Off adafruit_pybadge_airlift_m4.menu.debug.on=On adafruit_pybadge_airlift_m4.menu.debug.on.build.flags.debug=-g -# Adafruit MONSTER M4SK Express (SAMD51) -# ------------------------------ +# ----------------------------------- +# Adafruit MONSTER M4SK (SAMD51) +# ----------------------------------- adafruit_monster_m4sk.name=Adafruit MONSTER M4SK (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_monster_m4sk.vid.0=0x239A adafruit_monster_m4sk.pid.0=0x8047 adafruit_monster_m4sk.vid.1=0x239A adafruit_monster_m4sk.pid.1=0x0047 -adafruit_monster_m4sk.vid.1=0x239A -adafruit_monster_m4sk.pid.1=0x8048 +adafruit_monster_m4sk.vid.2=0x239A +adafruit_monster_m4sk.pid.2=0x8048 + +# Upload adafruit_monster_m4sk.upload.tool=bossac18 adafruit_monster_m4sk.upload.protocol=sam-ba adafruit_monster_m4sk.upload.maximum_size=507904 @@ -1206,26 +2350,32 @@ adafruit_monster_m4sk.upload.offset=0x4000 adafruit_monster_m4sk.upload.use_1200bps_touch=true adafruit_monster_m4sk.upload.wait_for_upload_port=true adafruit_monster_m4sk.upload.native_usb=true + +# Build adafruit_monster_m4sk.build.mcu=cortex-m4 -#adafruit_monster_m4sk.build.f_cpu=120000000L -adafruit_monster_m4sk.build.usb_product="Adafruit MONSTER M4SK" -adafruit_monster_m4sk.build.usb_manufacturer="Adafruit LLC" +adafruit_monster_m4sk.build.f_cpu=120000000L +adafruit_monster_m4sk.build.usb_product="MONSTER M4SK" +adafruit_monster_m4sk.build.usb_manufacturer="Adafruit" adafruit_monster_m4sk.build.board=MONSTER_M4SK adafruit_monster_m4sk.build.core=arduino -adafruit_monster_m4sk.build.extra_flags=-D__SAMD51G19A__ -DADAFRUIT_MONSTER_M4SK_EXPRESS -DCRYSTALLESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_monster_m4sk.build.extra_flags=-D__SAMD51G19A__ -DCRYSTALLESS -DADAFRUIT_MONSTER_M4SK_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_monster_m4sk.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_monster_m4sk.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_monster_m4sk.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_monster_m4sk.build.variant=monster_m4sk adafruit_monster_m4sk.build.variant_system_lib= adafruit_monster_m4sk.build.vid=0x239A adafruit_monster_m4sk.build.pid=0x8047 adafruit_monster_m4sk.bootloader.tool=openocd adafruit_monster_m4sk.bootloader.file=featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin -adafruit_monster_m4sk.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_monster_m4sk.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_monster_m4sk.menu.cache.on=Enabled adafruit_monster_m4sk.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_monster_m4sk.menu.cache.off=Disabled adafruit_monster_m4sk.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_monster_m4sk.menu.speed.120=120 MHz (standard) adafruit_monster_m4sk.menu.speed.120.build.f_cpu=120000000L adafruit_monster_m4sk.menu.speed.150=150 MHz (overclock) @@ -1234,6 +2384,8 @@ adafruit_monster_m4sk.menu.speed.180=180 MHz (overclock) adafruit_monster_m4sk.menu.speed.180.build.f_cpu=180000000L adafruit_monster_m4sk.menu.speed.200=200 MHz (overclock) adafruit_monster_m4sk.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_monster_m4sk.menu.opt.small=Small (-Os) (standard) adafruit_monster_m4sk.menu.opt.small.build.flags.optimize=-Os adafruit_monster_m4sk.menu.opt.fast=Fast (-O2) @@ -1244,27 +2396,38 @@ adafruit_monster_m4sk.menu.opt.fastest=Fastest (-Ofast) adafruit_monster_m4sk.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_monster_m4sk.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_monster_m4sk.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_monster_m4sk.menu.maxqspi.50=50 MHz (standard) adafruit_monster_m4sk.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_monster_m4sk.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_monster_m4sk.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_monster_m4sk.menu.usbstack.arduino=Arduino adafruit_monster_m4sk.menu.usbstack.tinyusb=TinyUSB adafruit_monster_m4sk.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_monster_m4sk.menu.debug.off=Off adafruit_monster_m4sk.menu.debug.on=On adafruit_monster_m4sk.menu.debug.on.build.flags.debug=-g -# Adafruit Hallowing M4 Express (SAMD51) -# ------------------------------ +# ----------------------------------- +# Adafruit Hallowing M4 (SAMD51) +# ----------------------------------- adafruit_hallowing_m4.name=Adafruit Hallowing M4 (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython adafruit_hallowing_m4.vid.0=0x239A adafruit_hallowing_m4.pid.0=0x8049 adafruit_hallowing_m4.vid.1=0x239A adafruit_hallowing_m4.pid.1=0x0049 -adafruit_hallowing_m4.vid.1=0x239A -adafruit_hallowing_m4.pid.1=0x804A +adafruit_hallowing_m4.vid.2=0x239A +adafruit_hallowing_m4.pid.2=0x804A + +# Upload adafruit_hallowing_m4.upload.tool=bossac18 adafruit_hallowing_m4.upload.protocol=sam-ba adafruit_hallowing_m4.upload.maximum_size=507904 @@ -1272,26 +2435,32 @@ adafruit_hallowing_m4.upload.offset=0x4000 adafruit_hallowing_m4.upload.use_1200bps_touch=true adafruit_hallowing_m4.upload.wait_for_upload_port=true adafruit_hallowing_m4.upload.native_usb=true + +# Build adafruit_hallowing_m4.build.mcu=cortex-m4 -#adafruit_hallowing_m4.build.f_cpu=120000000L -adafruit_hallowing_m4.build.usb_product="Adafruit Hallowing M4" -adafruit_hallowing_m4.build.usb_manufacturer="Adafruit LLC" +adafruit_hallowing_m4.build.f_cpu=120000000L +adafruit_hallowing_m4.build.usb_product="Hallowing M4" +adafruit_hallowing_m4.build.usb_manufacturer="Adafruit" adafruit_hallowing_m4.build.board=HALLOWING_M4 adafruit_hallowing_m4.build.core=arduino -adafruit_hallowing_m4.build.extra_flags=-D__SAMD51J19A__ -DADAFRUIT_HALLOWING_M4_EXPRESS -DCRYSTALLESS -D__SAMD51__ {build.usb_flags} -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_hallowing_m4.build.extra_flags=-D__SAMD51J19A__ -DCRYSTALLESS -DADAFRUIT_HALLOWING_M4_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} adafruit_hallowing_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld -adafruit_hallowing_m4.build.openocdscript=openocd_scripts/arduino_zero.cfg +adafruit_hallowing_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg adafruit_hallowing_m4.build.variant=hallowing_m4 adafruit_hallowing_m4.build.variant_system_lib= adafruit_hallowing_m4.build.vid=0x239A adafruit_hallowing_m4.build.pid=0x8049 adafruit_hallowing_m4.bootloader.tool=openocd adafruit_hallowing_m4.bootloader.file=featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin -adafruit_hallowing_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 +adafruit_hallowing_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache adafruit_hallowing_m4.menu.cache.on=Enabled adafruit_hallowing_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE adafruit_hallowing_m4.menu.cache.off=Disabled adafruit_hallowing_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed adafruit_hallowing_m4.menu.speed.120=120 MHz (standard) adafruit_hallowing_m4.menu.speed.120.build.f_cpu=120000000L adafruit_hallowing_m4.menu.speed.150=150 MHz (overclock) @@ -1300,6 +2469,8 @@ adafruit_hallowing_m4.menu.speed.180=180 MHz (overclock) adafruit_hallowing_m4.menu.speed.180.build.f_cpu=180000000L adafruit_hallowing_m4.menu.speed.200=200 MHz (overclock) adafruit_hallowing_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization adafruit_hallowing_m4.menu.opt.small=Small (-Os) (standard) adafruit_hallowing_m4.menu.opt.small.build.flags.optimize=-Os adafruit_hallowing_m4.menu.opt.fast=Fast (-O2) @@ -1310,13 +2481,105 @@ adafruit_hallowing_m4.menu.opt.fastest=Fastest (-Ofast) adafruit_hallowing_m4.menu.opt.fastest.build.flags.optimize=-Ofast adafruit_hallowing_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) adafruit_hallowing_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed adafruit_hallowing_m4.menu.maxqspi.50=50 MHz (standard) adafruit_hallowing_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 adafruit_hallowing_m4.menu.maxqspi.fcpu=CPU Speed / 2 adafruit_hallowing_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack adafruit_hallowing_m4.menu.usbstack.arduino=Arduino adafruit_hallowing_m4.menu.usbstack.tinyusb=TinyUSB adafruit_hallowing_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug adafruit_hallowing_m4.menu.debug.off=Off adafruit_hallowing_m4.menu.debug.on=On adafruit_hallowing_m4.menu.debug.on.build.flags.debug=-g + + +# ----------------------------------- +# Adafruit Matrix Portal M4 (SAMD51) +# ----------------------------------- +adafruit_matrixportal_m4.name=Adafruit Matrix Portal M4 (SAMD51) + +# VID/PID for Bootloader, Arduino & CircuitPython +adafruit_matrixportal_m4.vid.0=0x239A +adafruit_matrixportal_m4.pid.0=0x80C9 +adafruit_matrixportal_m4.vid.1=0x239A +adafruit_matrixportal_m4.pid.1=0x00C9 +adafruit_matrixportal_m4.vid.2=0x239A +adafruit_matrixportal_m4.pid.2=0x80CA + +# Upload +adafruit_matrixportal_m4.upload.tool=bossac18 +adafruit_matrixportal_m4.upload.protocol=sam-ba +adafruit_matrixportal_m4.upload.maximum_size=507904 +adafruit_matrixportal_m4.upload.offset=0x4000 +adafruit_matrixportal_m4.upload.use_1200bps_touch=true +adafruit_matrixportal_m4.upload.wait_for_upload_port=true +adafruit_matrixportal_m4.upload.native_usb=true + +# Build +adafruit_matrixportal_m4.build.mcu=cortex-m4 +adafruit_matrixportal_m4.build.f_cpu=120000000L +adafruit_matrixportal_m4.build.usb_product="Matrix Portal M4" +adafruit_matrixportal_m4.build.usb_manufacturer="Adafruit" +adafruit_matrixportal_m4.build.board=MATRIXPORTAL_M4 +adafruit_matrixportal_m4.build.core=arduino +adafruit_matrixportal_m4.build.extra_flags=-D__SAMD51J19A__ -DCRYSTALLESS -DADAFRUIT_MATRIXPORTAL_M4_EXPRESS -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 {build.usb_flags} +adafruit_matrixportal_m4.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld +adafruit_matrixportal_m4.build.openocdscript=scripts/openocd/daplink_samd51.cfg +adafruit_matrixportal_m4.build.variant=matrixportal_m4 +adafruit_matrixportal_m4.build.variant_system_lib= +adafruit_matrixportal_m4.build.vid=0x239A +adafruit_matrixportal_m4.build.pid=0x80C9 +adafruit_matrixportal_m4.bootloader.tool=openocd +adafruit_matrixportal_m4.bootloader.file=matrixportalM4/bootloader-matrixportal_m4.bin +adafruit_matrixportal_m4.compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" "-L{build.variant.path}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16 + +# Menu: Cache +adafruit_matrixportal_m4.menu.cache.on=Enabled +adafruit_matrixportal_m4.menu.cache.on.build.cache_flags=-DENABLE_CACHE +adafruit_matrixportal_m4.menu.cache.off=Disabled +adafruit_matrixportal_m4.menu.cache.off.build.cache_flags= + +# Menu: Speed +adafruit_matrixportal_m4.menu.speed.120=120 MHz (standard) +adafruit_matrixportal_m4.menu.speed.120.build.f_cpu=120000000L +adafruit_matrixportal_m4.menu.speed.150=150 MHz (overclock) +adafruit_matrixportal_m4.menu.speed.150.build.f_cpu=150000000L +adafruit_matrixportal_m4.menu.speed.180=180 MHz (overclock) +adafruit_matrixportal_m4.menu.speed.180.build.f_cpu=180000000L +adafruit_matrixportal_m4.menu.speed.200=200 MHz (overclock) +adafruit_matrixportal_m4.menu.speed.200.build.f_cpu=200000000L + +# Menu: Optimization +adafruit_matrixportal_m4.menu.opt.small=Small (-Os) (standard) +adafruit_matrixportal_m4.menu.opt.small.build.flags.optimize=-Os +adafruit_matrixportal_m4.menu.opt.fast=Fast (-O2) +adafruit_matrixportal_m4.menu.opt.fast.build.flags.optimize=-O2 +adafruit_matrixportal_m4.menu.opt.faster=Faster (-O3) +adafruit_matrixportal_m4.menu.opt.faster.build.flags.optimize=-O3 +adafruit_matrixportal_m4.menu.opt.fastest=Fastest (-Ofast) +adafruit_matrixportal_m4.menu.opt.fastest.build.flags.optimize=-Ofast +adafruit_matrixportal_m4.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops) +adafruit_matrixportal_m4.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops + +# Menu: QSPI Speed +adafruit_matrixportal_m4.menu.maxqspi.50=50 MHz (standard) +adafruit_matrixportal_m4.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000 +adafruit_matrixportal_m4.menu.maxqspi.fcpu=CPU Speed / 2 +adafruit_matrixportal_m4.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({build.f_cpu}) + +# Menu: USB Stack +adafruit_matrixportal_m4.menu.usbstack.arduino=Arduino +adafruit_matrixportal_m4.menu.usbstack.tinyusb=TinyUSB +adafruit_matrixportal_m4.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB + +# Menu: Debug +adafruit_matrixportal_m4.menu.debug.off=Off +adafruit_matrixportal_m4.menu.debug.on=On +adafruit_matrixportal_m4.menu.debug.on.build.flags.debug=-g + diff --git a/bootloaders/blmbadge/bootloader-blm_badge.bin b/bootloaders/blmbadge/bootloader-blm_badge.bin new file mode 100644 index 000000000..2e30fc17f Binary files /dev/null and b/bootloaders/blmbadge/bootloader-blm_badge.bin differ diff --git a/bootloaders/grand_central_m4/bootloader-grandcentral_m4.bin b/bootloaders/grand_central_m4/bootloader-grandcentral_m4.bin new file mode 100644 index 000000000..f341a2d60 Binary files /dev/null and b/bootloaders/grand_central_m4/bootloader-grandcentral_m4.bin differ diff --git a/bootloaders/matrixportalM4/bootloader-matrixportal_m4.bin b/bootloaders/matrixportalM4/bootloader-matrixportal_m4.bin new file mode 100644 index 000000000..9a2223ee8 Binary files /dev/null and b/bootloaders/matrixportalM4/bootloader-matrixportal_m4.bin differ diff --git a/bootloaders/neokeytrinkey_m0/bootloader-neokeytrinkey_m0.bin b/bootloaders/neokeytrinkey_m0/bootloader-neokeytrinkey_m0.bin new file mode 100644 index 000000000..ea8af4d4e Binary files /dev/null and b/bootloaders/neokeytrinkey_m0/bootloader-neokeytrinkey_m0.bin differ diff --git a/bootloaders/neotrinkey_m0/bootloader-neotrinkey_m0.bin b/bootloaders/neotrinkey_m0/bootloader-neotrinkey_m0.bin new file mode 100644 index 000000000..faf74ac7d Binary files /dev/null and b/bootloaders/neotrinkey_m0/bootloader-neotrinkey_m0.bin differ diff --git a/bootloaders/proxlighttrinkey_m0/bootloader-proxlighttrinkey_m0.bin b/bootloaders/proxlighttrinkey_m0/bootloader-proxlighttrinkey_m0.bin new file mode 100644 index 000000000..7b1a0b938 Binary files /dev/null and b/bootloaders/proxlighttrinkey_m0/bootloader-proxlighttrinkey_m0.bin differ diff --git a/bootloaders/qtpyM0/bootloader-qtpy_m0.bin b/bootloaders/qtpyM0/bootloader-qtpy_m0.bin new file mode 100644 index 000000000..930069d6c Binary files /dev/null and b/bootloaders/qtpyM0/bootloader-qtpy_m0.bin differ diff --git a/bootloaders/rotarytrinkey_m0/bootloader-rotarytrinkey_m0.bin b/bootloaders/rotarytrinkey_m0/bootloader-rotarytrinkey_m0.bin new file mode 100644 index 000000000..b879d7ef8 Binary files /dev/null and b/bootloaders/rotarytrinkey_m0/bootloader-rotarytrinkey_m0.bin differ diff --git a/bootloaders/slidetrinkey_m0/bootloader-slidetrinkey_m0.bin b/bootloaders/slidetrinkey_m0/bootloader-slidetrinkey_m0.bin new file mode 100644 index 000000000..e894a13e3 Binary files /dev/null and b/bootloaders/slidetrinkey_m0/bootloader-slidetrinkey_m0.bin differ diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 9331c901c..175dcf705 100644 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -46,7 +46,6 @@ extern "C"{ // Include Atmel headers #include "sam.h" - #include "wiring_constants.h" #define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) @@ -151,12 +150,13 @@ void loop( void ) ; // USB #ifdef USE_TINYUSB -#include "Adafruit_TinyUSB_Core.h" + // Needed for declaring Serial + #include "Adafruit_USBD_CDC.h" #else -#include "USB/USBDesc.h" -#include "USB/USBCore.h" -#include "USB/USBAPI.h" -#include "USB/USB_host.h" + #include "USB/USBDesc.h" + #include "USB/USBCore.h" + #include "USB/USBAPI.h" + #include "USB/USB_host.h" #endif #endif // Arduino_h diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 6257542cd..ad02662c3 100644 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -94,6 +94,28 @@ size_t Print::print(unsigned long n, int base) else return printNumber(n, base); } +size_t Print::print(long long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printULLNumber(n, 10) + t; + } + return printULLNumber(n, 10); + } else { + return printULLNumber(n, base); + } +} + +size_t Print::print(unsigned long long n, int base) +{ + if (base == 0) return write(n); + else return printULLNumber(n, base); +} + size_t Print::print(double n, int digits) { return printFloat(n, digits); @@ -172,6 +194,20 @@ size_t Print::println(unsigned long num, int base) return n; } +size_t Print::println(long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + size_t Print::println(double num, int digits) { size_t n = print(num, digits); @@ -218,6 +254,81 @@ size_t Print::printNumber(unsigned long n, uint8_t base) return write(str); } +// REFERENCE IMPLEMENTATION FOR ULL +// size_t Print::printULLNumber(unsigned long long n, uint8_t base) +// { + // // if limited to base 10 and 16 the bufsize can be smaller + // char buf[65]; + // char *str = &buf[64]; + + // *str = '\0'; + + // // prevent crash if called with base == 1 + // if (base < 2) base = 10; + + // do { + // unsigned long long t = n / base; + // char c = n - t * base; // faster than c = n%base; + // n = t; + // *--str = c < 10 ? c + '0' : c + 'A' - 10; + // } while(n); + + // return write(str); +// } + +// FAST IMPLEMENTATION FOR ULL +size_t Print::printULLNumber(unsigned long long n64, uint8_t base) +{ + // if limited to base 10 and 16 the bufsize can be 20 + char buf[64]; + uint8_t i = 0; + uint8_t innerLoops = 0; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + // process chunks that fit in "16 bit math". + uint16_t top = 0xFFFF / base; + uint16_t th16 = 1; + while (th16 < top) + { + th16 *= base; + innerLoops++; + } + + while (n64 > th16) + { + // 64 bit math part + uint64_t q = n64 / th16; + uint16_t r = n64 - q*th16; + n64 = q; + + // 16 bit math loop to do remainder. (note buffer is filled reverse) + for (uint8_t j=0; j < innerLoops; j++) + { + uint16_t qq = r/base; + buf[i++] = r - qq*base; + r = qq; + } + } + + uint16_t n16 = n64; + while (n16 > 0) + { + uint16_t qq = n16/base; + buf[i++] = n16 - qq*base; + n16 = qq; + } + + size_t bytes = i; + for (; i > 0; i--) + write((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + + return bytes; +} + size_t Print::printFloat(double number, uint8_t digits) { size_t n = 0; @@ -262,3 +373,4 @@ size_t Print::printFloat(double number, uint8_t digits) return n; } + diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index 1577ceb14..43db88b3d 100644 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -37,6 +37,7 @@ class Print private: int write_error; size_t printNumber(unsigned long, uint8_t); + size_t printULLNumber(unsigned long long, uint8_t); size_t printFloat(double, uint8_t); protected: void setWriteError(int err = 1) { write_error = err; } @@ -69,6 +70,8 @@ class Print size_t print(unsigned int, int = DEC); size_t print(long, int = DEC); size_t print(unsigned long, int = DEC); + size_t print(long long, int = DEC); + size_t print(unsigned long long, int = DEC); size_t print(double, int = 2); size_t print(const Printable&); @@ -81,6 +84,8 @@ class Print size_t println(unsigned int, int = DEC); size_t println(long, int = DEC); size_t println(unsigned long, int = DEC); + size_t println(long long, int = DEC); + size_t println(unsigned long long, int = DEC); size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); diff --git a/cores/arduino/Reset.cpp b/cores/arduino/Reset.cpp index a16a7296a..9bde4a8c0 100644 --- a/cores/arduino/Reset.cpp +++ b/cores/arduino/Reset.cpp @@ -29,7 +29,7 @@ extern "C" { #if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10610) extern const uint32_t __text_start__; -#define APP_START ((volatile uint32_t)(&__text_start__) + 4) +#define APP_START ((uint32_t)(&__text_start__) + 4) #else diff --git a/cores/arduino/RingBuffer.h b/cores/arduino/RingBuffer.h index 0241155d2..deecb733c 100644 --- a/cores/arduino/RingBuffer.h +++ b/cores/arduino/RingBuffer.h @@ -29,7 +29,7 @@ // location from which to read. #ifndef SERIAL_BUFFER_SIZE -#define SERIAL_BUFFER_SIZE 256 +#define SERIAL_BUFFER_SIZE 350 #endif template diff --git a/cores/arduino/SERCOM.cpp b/cores/arduino/SERCOM.cpp index 9a75730fd..732393ebc 100644 --- a/cores/arduino/SERCOM.cpp +++ b/cores/arduino/SERCOM.cpp @@ -556,29 +556,35 @@ bool SERCOM::startTransmissionWIRE(uint8_t address, SercomWireReadWriteFlag flag // Address Transmitted if ( flag == WIRE_WRITE_FLAG ) // Write mode { - while( !sercom->I2CM.INTFLAG.bit.MB ) - { + while( !sercom->I2CM.INTFLAG.bit.MB ) { // Wait transmission complete + + // If certain errors occur, the MB bit may never be set (RFTM: SAMD21 sec:28.10.6; SAMD51 sec:36.10.7). + // The data transfer errors that can occur (including BUSERR) are all + // rolled up into INTFLAG.bit.ERROR from STATUS.reg + if (sercom->I2CM.INTFLAG.bit.ERROR) { + return false; + } } } else // Read mode { - while( !sercom->I2CM.INTFLAG.bit.SB ) - { - // If the slave NACKS the address, the MB bit will be set. - // In that case, send a stop condition and return false. - if (sercom->I2CM.INTFLAG.bit.MB) { - sercom->I2CM.CTRLB.bit.CMD = 3; // Stop condition - return false; - } + while( !sercom->I2CM.INTFLAG.bit.SB ) { // Wait transmission complete + + // If the slave NACKS the address, the MB bit will be set. + // A variety of errors in the STATUS register can set the ERROR bit in the INTFLAG register + // In that case, send a stop condition and return false. + if (sercom->I2CM.INTFLAG.bit.MB || sercom->I2CM.INTFLAG.bit.ERROR) { + sercom->I2CM.CTRLB.bit.CMD = 3; // Stop condition + return false; + } } // Clean the 'Slave on Bus' flag, for further usage. //sercom->I2CM.INTFLAG.bit.SB = 0x1ul; } - //ACK received (0: ACK, 1: NACK) if(sercom->I2CM.STATUS.bit.RXNACK) { @@ -597,10 +603,11 @@ bool SERCOM::sendDataMasterWIRE(uint8_t data) //Wait transmission successful while(!sercom->I2CM.INTFLAG.bit.MB) { - - // If a bus error occurs, the MB bit may never be set. - // Check the bus error bit and bail if it's set. - if (sercom->I2CM.STATUS.bit.BUSERR) { + // If a data transfer error occurs, the MB bit may never be set. + // Check the error bit and bail if it's set. + // The data transfer errors that can occur (including BUSERR) are all + // rolled up into INTFLAG.bit.ERROR from STATUS.reg + if (sercom->I2CM.INTFLAG.bit.ERROR) { return false; } } @@ -701,9 +708,17 @@ uint8_t SERCOM::readDataWIRE( void ) { if(isMasterWIRE()) { - while( sercom->I2CM.INTFLAG.bit.SB == 0 ) - { + while (sercom->I2CM.INTFLAG.bit.SB == 0) { // Waiting complete receive + // A variety of errors in the STATUS register can set the ERROR bit in the INTFLAG register + // In that case, send a stop condition and return false. + // readDataWIRE should really be able to indicate an error (which would never be used + // because the readDataWIRE callers (in Wire.cpp) should have checked availableWIRE() first and timed it + // out if the data never showed up + if (sercom->I2CM.INTFLAG.bit.MB || sercom->I2CM.INTFLAG.bit.ERROR) { + sercom->I2CM.CTRLB.bit.CMD = 3; // Stop condition + return 0xFF; + } } return sercom->I2CM.DATA.bit.DATA ; diff --git a/cores/arduino/SERCOM.h b/cores/arduino/SERCOM.h index b60c245f9..c717e78b6 100644 --- a/cores/arduino/SERCOM.h +++ b/cores/arduino/SERCOM.h @@ -248,7 +248,7 @@ class SERCOM uint32_t getFreqRef(void) { return freqRef; }; #else // The equivalent SAMD21 dummy functions... - void setClockSource(__attribute__((unused)) int8_t idx, __attribute__((unused)) SercomClockSource src, __attribute__((unused)) bool core) { }; + void setClockSource(int8_t idx, SercomClockSource src, bool core) { (void)idx; (void)src; (void)core; }; SercomClockSource getClockSource(void) { return SERCOM_CLOCK_SOURCE_FCPU; }; uint32_t getFreqRef(void) { return F_CPU; }; #endif diff --git a/cores/arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore b/cores/arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore deleted file mode 160000 index f96bfb250..000000000 --- a/cores/arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f96bfb250c06c447600e1befbc6601b49672d381 diff --git a/cores/arduino/TinyUSB/Adafruit_TinyUSB_SAMD.cpp b/cores/arduino/TinyUSB/Adafruit_TinyUSB_SAMD.cpp deleted file mode 100644 index 0cf315b58..000000000 --- a/cores/arduino/TinyUSB/Adafruit_TinyUSB_SAMD.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019, hathach for Adafruit - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifdef USE_TINYUSB - -#include "Arduino.h" -#include "Adafruit_TinyUSB_Core.h" -#include // Needed for auto-reset with 1200bps port touch - -//--------------------------------------------------------------------+ -// Forward USB interrupt events to TinyUSB IRQ Handler -//--------------------------------------------------------------------+ -extern "C" -{ -#if defined(__SAMD51__) - -void USB_0_Handler (void) { tud_int_handler(0); } -void USB_1_Handler (void) { tud_int_handler(0); } -void USB_2_Handler (void) { tud_int_handler(0); } -void USB_3_Handler (void) { tud_int_handler(0); } - -#else - -void USB_Handler(void) { tud_int_handler(0); } - -#endif -} // extern C - - - -//--------------------------------------------------------------------+ -// MACRO TYPEDEF CONSTANT ENUM DECLARATION -//--------------------------------------------------------------------+ -static void usb_hardware_init(void); - -#if CFG_TUSB_DEBUG -extern "C" int serial1_printf(const char *__restrict format, ...) -{ - char buf[PRINTF_BUF]; - va_list ap; - va_start(ap, format); - vsnprintf(buf, sizeof(buf), format, ap); - Serial1.write(buf); - va_end(ap); - -} -#endif - -//--------------------------------------------------------------------+ -// Core Init & Touch1200 -//--------------------------------------------------------------------+ -void Adafruit_TinyUSB_Core_init(void) -{ -#if CFG_TUSB_DEBUG - Serial1.begin(115200); - serial1_printf("TinyUSB debugging with Serial1\n"); -#endif - - USBDevice.addInterface( (Adafruit_USBD_Interface&) Serial); - USBDevice.setID(USB_VID, USB_PID); - USBDevice.begin(); - - usb_hardware_init(); - - // Init tinyusb stack - tusb_init(); -} - -void Adafruit_TinyUSB_Core_touch1200(void) -{ - initiateReset(250); -} - -//--------------------------------------------------------------------+ -// Adafruit_USBD_Device platform dependent -//--------------------------------------------------------------------+ - -uint8_t Adafruit_USBD_Device::getSerialDescriptor(uint16_t* serial_str) -{ - enum { SERIAL_BYTE_LEN = 16 }; - -#ifdef __SAMD51__ - uint32_t* id_addresses[4] = {(uint32_t *) 0x008061FC, (uint32_t *) 0x00806010, - (uint32_t *) 0x00806014, (uint32_t *) 0x00806018}; -#else // samd21 - uint32_t* id_addresses[4] = {(uint32_t *) 0x0080A00C, (uint32_t *) 0x0080A040, - (uint32_t *) 0x0080A044, (uint32_t *) 0x0080A048}; - -#endif - - uint8_t raw_id[SERIAL_BYTE_LEN]; - - for (int i=0; i<4; i++) { - for (int k=0; k<4; k++) { - raw_id[4 * i + (3 - k)] = (*(id_addresses[i]) >> k * 8) & 0xff; - } - } - - static const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - - for (unsigned int i = 0; i < sizeof(raw_id); i++) { - for (int j = 0; j < 2; j++) { - uint8_t nibble = (raw_id[i] >> (j * 4)) & 0xf; - // Strings are UTF-16-LE encoded. - serial_str[i * 2 + (1 - j)] = nibble_to_hex[nibble]; - } - } - - return sizeof(raw_id)*2; -} - -//--------------------------------------------------------------------+ -// Helpers -//--------------------------------------------------------------------+ - -// Init usb hardware when starting up. Softdevice is not enabled yet -static void usb_hardware_init(void) -{ -#ifdef PIN_LED_TXL -// txLEDPulse = 0; - pinMode(PIN_LED_TXL, OUTPUT); - digitalWrite(PIN_LED_TXL, HIGH); -#endif - -#ifdef PIN_LED_RXL -// rxLEDPulse = 0; - pinMode(PIN_LED_RXL, OUTPUT); - digitalWrite(PIN_LED_RXL, HIGH); -#endif - - /* Enable USB clock */ -#if defined(__SAMD51__) - MCLK->APBBMASK.reg |= MCLK_APBBMASK_USB; - MCLK->AHBMASK.reg |= MCLK_AHBMASK_USB; - - // Set up the USB DP/DN pins - PORT->Group[0].PINCFG[PIN_PA24H_USB_DM].bit.PMUXEN = 1; - PORT->Group[0].PMUX[PIN_PA24H_USB_DM/2].reg &= ~(0xF << (4 * (PIN_PA24H_USB_DM & 0x01u))); - PORT->Group[0].PMUX[PIN_PA24H_USB_DM/2].reg |= MUX_PA24H_USB_DM << (4 * (PIN_PA24H_USB_DM & 0x01u)); - PORT->Group[0].PINCFG[PIN_PA25H_USB_DP].bit.PMUXEN = 1; - PORT->Group[0].PMUX[PIN_PA25H_USB_DP/2].reg &= ~(0xF << (4 * (PIN_PA25H_USB_DP & 0x01u))); - PORT->Group[0].PMUX[PIN_PA25H_USB_DP/2].reg |= MUX_PA25H_USB_DP << (4 * (PIN_PA25H_USB_DP & 0x01u)); - - - GCLK->PCHCTRL[USB_GCLK_ID].reg = GCLK_PCHCTRL_GEN_GCLK1_Val | (1 << GCLK_PCHCTRL_CHEN_Pos); -#else - PM->APBBMASK.reg |= PM_APBBMASK_USB; - - // Set up the USB DP/DN pins - PORT->Group[0].PINCFG[PIN_PA24G_USB_DM].bit.PMUXEN = 1; - PORT->Group[0].PMUX[PIN_PA24G_USB_DM/2].reg &= ~(0xF << (4 * (PIN_PA24G_USB_DM & 0x01u))); - PORT->Group[0].PMUX[PIN_PA24G_USB_DM/2].reg |= MUX_PA24G_USB_DM << (4 * (PIN_PA24G_USB_DM & 0x01u)); - PORT->Group[0].PINCFG[PIN_PA25G_USB_DP].bit.PMUXEN = 1; - PORT->Group[0].PMUX[PIN_PA25G_USB_DP/2].reg &= ~(0xF << (4 * (PIN_PA25G_USB_DP & 0x01u))); - PORT->Group[0].PMUX[PIN_PA25G_USB_DP/2].reg |= MUX_PA25G_USB_DP << (4 * (PIN_PA25G_USB_DP & 0x01u)); - - // Put Generic Clock Generator 0 as source for Generic Clock Multiplexer 6 (USB reference) - GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID(6) | // Generic Clock Multiplexer 6 - GCLK_CLKCTRL_GEN_GCLK0 | // Generic Clock Generator 0 is source - GCLK_CLKCTRL_CLKEN; - while (GCLK->STATUS.bit.SYNCBUSY) - ; -#endif -} - -#endif // USE_TINYUSB diff --git a/cores/arduino/TinyUSB/tusb_config.h b/cores/arduino/TinyUSB/tusb_config.h deleted file mode 100644 index 70ddbeb64..000000000 --- a/cores/arduino/TinyUSB/tusb_config.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach for Adafruit - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef _TUSB_CONFIG_H_ -#define _TUSB_CONFIG_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -//-------------------------------------------------------------------- -// COMMON CONFIGURATION -//-------------------------------------------------------------------- -#ifdef __SAMD51__ - #define CFG_TUSB_MCU OPT_MCU_SAMD51 -#else - #define CFG_TUSB_MCU OPT_MCU_SAMD21 -#endif - -#ifdef USE_TINYUSB - #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE -#else - #define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE -#endif - -#define CFG_TUSB_OS OPT_OS_NONE - -#define CFG_TUSB_DEBUG 0 -#if CFG_TUSB_DEBUG - #define tu_printf serial1_printf - extern int serial1_printf(const char *__restrict __format, ...); -#endif - -#define CFG_TUSB_MEM_SECTION -#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) - -//-------------------------------------------------------------------- -// DEVICE CONFIGURATION -//-------------------------------------------------------------------- - -#define CFG_TUD_ENDOINT0_SIZE 64 - -//------------- CLASS -------------// -#define CFG_TUD_CDC 1 -#define CFG_TUD_MSC 1 -#define CFG_TUD_HID 1 -#define CFG_TUD_MIDI 1 -#define CFG_TUD_VENDOR 1 - -// CDC FIFO size of TX and RX -#define CFG_TUD_CDC_RX_BUFSIZE 256 -#define CFG_TUD_CDC_TX_BUFSIZE 256 - -// MSC Buffer size of Device Mass storage -#define CFG_TUD_MSC_BUFSIZE 512 - -// HID buffer size Should be sufficient to hold ID (if any) + Data -#define CFG_TUD_HID_BUFSIZE 64 - -// MIDI FIFO size of TX and RX -#define CFG_TUD_MIDI_RX_BUFSIZE 128 -#define CFG_TUD_MIDI_TX_BUFSIZE 128 - -// Vendor FIFO size of TX and RX -#define CFG_TUD_VENDOR_RX_BUFSIZE 64 -#define CFG_TUD_VENDOR_TX_BUFSIZE 64 - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_CONFIG_H_ */ diff --git a/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp index 058c2148b..1d4ddc406 100644 --- a/cores/arduino/Tone.cpp +++ b/cores/arduino/Tone.cpp @@ -20,12 +20,6 @@ #include "Tone.h" #include "variant.h" -#if defined(__SAMD51__) -#define WAIT_TC16_REGS_SYNC(x) while(x->COUNT16.SYNCBUSY.bit.ENABLE); -#else -#define WAIT_TC16_REGS_SYNC(x) while(x->COUNT16.STATUS.bit.SYNCBUSY); -#endif - uint32_t toneMaxFrequency = F_CPU / 2; uint32_t lastOutputPin = 0xFFFFFFFF; @@ -37,22 +31,24 @@ volatile bool toneIsActive = false; volatile bool firstTimeRunning = false; #if defined(__SAMD51__) -#define TONE_TC TC0 -#define TONE_TC_IRQn TC0_IRQn -#define TONE_TC_GCLK_ID TC0_GCLK_ID + #define TONE_TC TC0 + #define TONE_TC_IRQn TC0_IRQn + #define TONE_TC_GCLK_ID TC0_GCLK_ID + #define Tone_Handler TC0_Handler + + #define WAIT_TC16_REGS_SYNC(x) while(x->COUNT16.SYNCBUSY.bit.ENABLE); + #else -#define TONE_TC TC5 -#define TONE_TC_IRQn TC5_IRQn + #define TONE_TC TC5 + #define TONE_TC_IRQn TC5_IRQn + #define Tone_Handler TC5_Handler + + #define WAIT_TC16_REGS_SYNC(x) while(x->COUNT16.STATUS.bit.SYNCBUSY); #endif + #define TONE_TC_TOP 0xFFFF #define TONE_TC_CHANNEL 0 -#if defined(__SAMD51__) -void TC0_Handler (void) __attribute__ ((weak, alias("Tone_Handler"))); -#else -void TC5_Handler (void) __attribute__ ((weak, alias("Tone_Handler"))); -#endif - static inline void resetTC (Tc* TCx) { // Disable TCx @@ -72,6 +68,14 @@ void toneAccurateClock (uint32_t accurateSystemCoreClockFrequency) void tone (uint32_t outputPin, uint32_t frequency, uint32_t duration) { + + // Avoid divide by zero error by calling 'noTone' instead + if (frequency == 0) + { + noTone(outputPin); + return; + } + // Configure interrupt request NVIC_DisableIRQ(TONE_TC_IRQn); NVIC_ClearPendingIRQ(TONE_TC_IRQn); @@ -90,9 +94,6 @@ void tone (uint32_t outputPin, uint32_t frequency, uint32_t duration) while (GCLK->STATUS.bit.SYNCBUSY); #endif } - - //if it's a rest, set to 1Hz (below audio range) - frequency = (frequency > 0 ? frequency : 1); if (toneIsActive && (outputPin != lastOutputPin)) noTone(lastOutputPin); @@ -167,8 +168,8 @@ void tone (uint32_t outputPin, uint32_t frequency, uint32_t duration) lastOutputPin = outputPin; digitalWrite(outputPin, LOW); pinMode(outputPin, OUTPUT); + toneIsActive = true; } - toneIsActive = true; // Enable TONE_TC TONE_TC->COUNT16.CTRLA.reg |= TC_CTRLA_ENABLE; @@ -179,9 +180,19 @@ void tone (uint32_t outputPin, uint32_t frequency, uint32_t duration) void noTone (uint32_t outputPin) { - resetTC(TONE_TC); - digitalWrite(outputPin, LOW); - toneIsActive = false; + /* 'tone' need to run at least once in order to enable GCLK for + * the timers used for the tone-functionality. If 'noTone' is called + * without ever calling 'tone' before then 'WAIT_TC16_REGS_SYNC(TCx)' + * will wait infinitely. The variable 'firstTimeRunning' is set the + * 1st time 'tone' is set so it can be used to detect wether or not + * 'tone' has been called before. + */ + if(firstTimeRunning) + { + resetTC(TONE_TC); + digitalWrite(outputPin, LOW); + toneIsActive = false; + } } #ifdef __cplusplus diff --git a/cores/arduino/USB/CDC.cpp b/cores/arduino/USB/CDC.cpp index 9bc234c58..10710417c 100644 --- a/cores/arduino/USB/CDC.cpp +++ b/cores/arduino/USB/CDC.cpp @@ -259,6 +259,50 @@ Serial_::operator bool() return result; } +int32_t Serial_::readBreak() { + uint8_t enableInterrupts = ((__get_PRIMASK() & 0x1) == 0); + + // disable interrupts, + // to avoid clearing a breakValue that might occur + // while processing the current break value + __disable_irq(); + + int32_t ret = breakValue; + + breakValue = -1; + + if (enableInterrupts) { + // re-enable the interrupts + __enable_irq(); + } + + return ret; +} + +unsigned long Serial_::baud() { + return _usbLineInfo.dwDTERate; +} + +uint8_t Serial_::stopbits() { + return _usbLineInfo.bCharFormat; +} + +uint8_t Serial_::paritytype() { + return _usbLineInfo.bParityType; +} + +uint8_t Serial_::numbits() { + return _usbLineInfo.bDataBits; +} + +bool Serial_::dtr() { + return _usbLineInfo.lineState & 0x1; +} + +bool Serial_::rts() { + return _usbLineInfo.lineState & 0x2; +} + Serial_ Serial(USBDevice); #endif diff --git a/cores/arduino/USB/USBAPI.h b/cores/arduino/USB/USBAPI.h index 6c235867e..f45051148 100644 --- a/cores/arduino/USB/USBAPI.h +++ b/cores/arduino/USB/USBAPI.h @@ -85,7 +85,7 @@ class USBDeviceClass { uint32_t sendControl(int /* ep */, const void *data, uint32_t len) { return sendControl(data, len); } uint32_t recvControl(void *data, uint32_t len); uint32_t sendConfiguration(uint32_t maxlen); - bool sendStringDescriptor(const uint8_t *string, uint8_t maxlen); + bool sendStringDescriptor(const uint8_t *string, uint32_t maxlen); void initControl(int end); uint8_t SendInterfaces(uint32_t* total); void packMessages(bool val); diff --git a/cores/arduino/USB/USBCore.cpp b/cores/arduino/USB/USBCore.cpp index 2154fe589..83a3e5d32 100644 --- a/cores/arduino/USB/USBCore.cpp +++ b/cores/arduino/USB/USBCore.cpp @@ -110,12 +110,12 @@ static EPHandler *epHandlers[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; // Send a USB descriptor string. The string is stored as a // plain ASCII string but is sent out as UTF-16 with the // correct 2-byte prefix -bool USBDeviceClass::sendStringDescriptor(const uint8_t *string, uint8_t maxlen) +bool USBDeviceClass::sendStringDescriptor(const uint8_t *string, uint32_t maxlen) { if (maxlen < 2) return false; - uint8_t buffer[maxlen]; + uint8_t* buffer = (uint8_t*)malloc(maxlen); buffer[0] = strlen((const char*)string) * 2 + 2; buffer[1] = 0x03; @@ -126,7 +126,9 @@ bool USBDeviceClass::sendStringDescriptor(const uint8_t *string, uint8_t maxlen) buffer[i] = 0; } - return USBDevice.sendControl(buffer, i); + bool ret = USBDevice.sendControl(buffer, i); + free(buffer); + return ret; } bool _dry_run = false; diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index e0abc2d7d..85b744673 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -250,8 +250,9 @@ void detachInterrupt(uint32_t pin) * External Interrupt Controller NVIC Interrupt Handler */ #if defined(__SAMD51__) -void InterruptHandler(uint32_t i) +void InterruptHandler(uint32_t unused_i) { + (void)unused_i; // Calling the routine directly from -here- takes about 1us // Depending on where you are in the list it will take longer diff --git a/cores/arduino/WInterrupts.h b/cores/arduino/WInterrupts.h index 5d2b24a0d..daf02afe5 100644 --- a/cores/arduino/WInterrupts.h +++ b/cores/arduino/WInterrupts.h @@ -31,7 +31,7 @@ extern "C" { #define FALLING 3 #define RISING 4 -#define DEFAULT 1 +//#define DEFAULT 1 #define EXTERNAL 0 typedef void (*voidFuncPtr)(void); diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index 71bbc07d1..ed4e706df 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -693,12 +693,21 @@ void String::remove(unsigned int index){ } void String::remove(unsigned int index, unsigned int count){ - if (index >= len) { return; } - if (count <= 0) { return; } - if (count > len - index) { count = len - index; } - char *writeTo = buffer + index; + // removes characters from the middle of a string. + if (count <= 0) { return; } // exit if nothing to remove + if (index >= len) { return; } // ensure start is within string length; thus, ensures (len-index >= 1) + if (count > len - index) { // ensure characters to remove is no larger than total length remaining + count = len - index; + } + char *writeTo = buffer + index; + char *copyFrom = buffer + index + count; len = len - count; - strncpy(writeTo, buffer + index + count,len - index); + + // strncpy() cannot be used with overlapping buffers, so copy one char at a time + unsigned int charactersToMove = len - index; // yes, uses post-adjusted length + for (unsigned int i = 0; i < charactersToMove; i++, writeTo++, copyFrom++) { + *writeTo = *copyFrom; + } buffer[len] = 0; } diff --git a/cores/arduino/WVariant.h b/cores/arduino/WVariant.h index fff0ed389..8e0d473b8 100644 --- a/cores/arduino/WVariant.h +++ b/cores/arduino/WVariant.h @@ -90,7 +90,7 @@ typedef enum _ETCChannel TC3_CH0 = (6<<8)|(0), TC3_CH1 = (6<<8)|(1), } ETCChannel ; -#elif defined(__SAMD51J19A__) || defined(__SAMD51J20A__) +#elif defined(__SAMD51J19A__) || defined(__SAMD51J20A__) || defined(__SAME51J19A__) typedef enum _ETCChannel { @@ -136,7 +136,7 @@ typedef enum _ETCChannel TC7_CH1 = (12<<8)|(1), } ETCChannel ; -#elif defined(__SAMD51P19A__) || defined(__SAMD51P20A__) +#elif defined(__SAME53N20A__) || defined(__SAME53N19A__) || defined(__SAME54P20A__) || defined(__SAME54P19A__) || defined(__SAME54N20A__) || defined(__SAME54N19A__) || defined(__SAMD51P20A__) || defined(__SAMD51P19A__) || defined(__SAMD51N20A__) || defined(__SAMD51N19A__) || defined(__SAME51N20A__) || defined(__SAME51N19A__) typedef enum _ETCChannel { diff --git a/cores/arduino/cortex_handlers.c b/cores/arduino/cortex_handlers.c index f47ddee38..953d1a6e1 100644 --- a/cores/arduino/cortex_handlers.c +++ b/cores/arduino/cortex_handlers.c @@ -127,10 +127,13 @@ void SERCOM7_0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Han void SERCOM7_1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); void SERCOM7_2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); void SERCOM7_3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); +void CAN0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); +void CAN1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); void USB_0_Handler ( void ) __attribute__ ((weak)); void USB_1_Handler ( void ) __attribute__ ((weak)); void USB_2_Handler ( void ) __attribute__ ((weak)); void USB_3_Handler ( void ) __attribute__ ((weak)); +void GMAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); void TCC0_0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); void TCC0_1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); void TCC0_2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); @@ -193,6 +196,7 @@ extern uint32_t __bss_end__; extern uint32_t __StackTop; /* Exception Table */ +__attribute__ ((used)) __attribute__ ((section(".isr_vector"))) const DeviceVectors exception_table = { /* Configure Initial Stack Pointer, using linker-generated symbols */ @@ -294,13 +298,13 @@ __attribute__ ((section(".isr_vector"))) const DeviceVectors exception_table = (void*) SERCOM7_1_Handler, /* 75 Serial Communication Interface 7 IRQ 1 */ (void*) SERCOM7_2_Handler, /* 76 Serial Communication Interface 7 IRQ 2 */ (void*) SERCOM7_3_Handler, /* 77 Serial Communication Interface 7 IRQ 3 */ - (void*) (0UL), - (void*) (0UL), + (void*) CAN0_Handler, /* 78 Control Area Network 0 (SAM E5x) */ + (void*) CAN1_Handler, /* 79 Control Area Network 0 (SAM E5x) */ (void*) USB_0_Handler, /* 80 Universal Serial Bus IRQ 0 */ (void*) USB_1_Handler, /* 81 Universal Serial Bus IRQ 1 */ (void*) USB_2_Handler, /* 82 Universal Serial Bus IRQ 2 */ (void*) USB_3_Handler, /* 83 Universal Serial Bus IRQ 3 */ - (void*) (0UL), + (void*) GMAC_Handler, /* 84 Ethernet MAC */ (void*) TCC0_0_Handler, /* 85 Timer Counter Control 0 IRQ 0 */ (void*) TCC0_1_Handler, /* 86 Timer Counter Control 0 IRQ 1 */ (void*) TCC0_2_Handler, /* 87 Timer Counter Control 0 IRQ 2 */ @@ -404,6 +408,7 @@ extern uint32_t __bss_end__; extern uint32_t __StackTop; /* Exception Table */ +__attribute__ ((used)) __attribute__ ((section(".isr_vector"))) const DeviceVectors exception_table = { /* Configure Initial Stack Pointer, using linker-generated symbols */ diff --git a/cores/arduino/delay.c b/cores/arduino/delay.c index 7833512a6..773ce39e9 100644 --- a/cores/arduino/delay.c +++ b/cores/arduino/delay.c @@ -117,6 +117,17 @@ void SysTick_DefaultHandler(void) tickReset(); } +#if defined(USE_TINYUSB) + +// run TinyUSB background task when yield() +void yield(void) +{ + TinyUSB_Device_Task(); + TinyUSB_Device_FlushCDC(); +} + +#endif + #ifdef __cplusplus } #endif diff --git a/cores/arduino/main.cpp b/cores/arduino/main.cpp index 10db6a9af..3ea8ad3b3 100644 --- a/cores/arduino/main.cpp +++ b/cores/arduino/main.cpp @@ -41,7 +41,7 @@ int main( void ) delay(1); #if defined(USE_TINYUSB) - Adafruit_TinyUSB_Core_init(); + TinyUSB_Device_Init(0); #elif defined(USBCON) USBDevice.init(); USBDevice.attach(); @@ -59,14 +59,3 @@ int main( void ) return 0; } - -#if defined(USE_TINYUSB) - -// run TinyUSB background task when yield() -extern "C" void yield(void) -{ - tud_task(); - tud_cdc_write_flush(); -} - -#endif diff --git a/cores/arduino/math_helper.c b/cores/arduino/math_helper.c index 477d46164..60887c708 100644 --- a/cores/arduino/math_helper.c +++ b/cores/arduino/math_helper.c @@ -165,18 +165,18 @@ uint32_t arm_compare_fixed_q15(q15_t *pIn, q15_t * pOut, uint32_t numSamples) { uint32_t i; int32_t diff; - uint32_t diffCrnt; + uint32_t diffCrnt = 0; uint32_t maxDiff = 0; for (i = 0; i < numSamples; i++) { - diff = pIn[i] - pOut[i]; - diffCrnt = (diff > 0) ? diff : -diff; + diff = pIn[i] - pOut[i]; + diffCrnt = (uint32_t)( (diff > 0) ? diff : -diff ); - if(diffCrnt > maxDiff) - { - maxDiff = diffCrnt; - } + if(diffCrnt > maxDiff) + { + maxDiff = diffCrnt; + } } return(maxDiff); @@ -194,18 +194,18 @@ uint32_t arm_compare_fixed_q31(q31_t *pIn, q31_t * pOut, uint32_t numSamples) { uint32_t i; int32_t diff; - uint32_t diffCrnt; + uint32_t diffCrnt = 0; uint32_t maxDiff = 0; for (i = 0; i < numSamples; i++) { - diff = pIn[i] - pOut[i]; - diffCrnt = (diff > 0) ? diff : -diff; + diff = pIn[i] - pOut[i]; + diffCrnt = (uint32_t)( (diff > 0) ? diff : -diff ); - if(diffCrnt > maxDiff) - { - maxDiff = diffCrnt; - } + if(diffCrnt > maxDiff) + { + maxDiff = diffCrnt; + } } return(maxDiff); diff --git a/cores/arduino/startup.c b/cores/arduino/startup.c index 8816eb549..c493b1af9 100644 --- a/cores/arduino/startup.c +++ b/cores/arduino/startup.c @@ -63,7 +63,7 @@ void SystemInit( void ) * 1) Enable XOSC32K clock (External on-board 32.768Hz oscillator) */ - OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE | OSC32KCTRL_XOSC32K_EN32K | OSC32KCTRL_XOSC32K_EN32K | OSC32KCTRL_XOSC32K_CGM_XT | OSC32KCTRL_XOSC32K_XTALEN; + OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE | OSC32KCTRL_XOSC32K_EN1K | OSC32KCTRL_XOSC32K_EN32K | OSC32KCTRL_XOSC32K_CGM_XT | OSC32KCTRL_XOSC32K_XTALEN; while( (OSC32KCTRL->STATUS.reg & OSC32KCTRL_STATUS_XOSC32KRDY) == 0 ){ /* Wait for oscillator to be ready */ diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index f809c32a4..40f5a6424 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -375,6 +375,9 @@ uint32_t analogRead(uint32_t pin) syncADC(); ADC->SWTRIG.bit.START = 1; + // Waiting for the 1st conversion to complete + while (ADC->INTFLAG.bit.RESRDY == 0); + // Clear the Data Ready flag ADC->INTFLAG.reg = ADC_INTFLAG_RESRDY; diff --git a/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c index 0e35ffe42..c62fdebfb 100644 --- a/cores/arduino/wiring_digital.c +++ b/cores/arduino/wiring_digital.c @@ -39,39 +39,39 @@ void pinMode( uint32_t ulPin, uint32_t ulMode ) { case INPUT: // Set pin to input mode - PORT->Group[port].PINCFG[pin].reg=(uint8_t)(PORT_PINCFG_INEN) ; - PORT->Group[port].DIRCLR.reg = pinMask ; - break ; + PORT->Group[port].PINCFG[pin].reg = (uint8_t) (PORT_PINCFG_INEN); + PORT->Group[port].DIRCLR.reg = pinMask; + break; case INPUT_PULLUP: // Set pin to input mode with pull-up resistor enabled - PORT->Group[port].PINCFG[pin].reg=(uint8_t)(PORT_PINCFG_INEN|PORT_PINCFG_PULLEN) ; - PORT->Group[port].DIRCLR.reg = pinMask ; + PORT->Group[port].PINCFG[pin].reg = (uint8_t) (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); + PORT->Group[port].DIRCLR.reg = pinMask; // Enable pull level (cf '22.6.3.2 Input Configuration' and '22.8.7 Data Output Value Set') - PORT->Group[port].OUTSET.reg = pinMask ; - break ; + PORT->Group[port].OUTSET.reg = pinMask; + break; case INPUT_PULLDOWN: // Set pin to input mode with pull-down resistor enabled - PORT->Group[port].PINCFG[pin].reg=(uint8_t)(PORT_PINCFG_INEN|PORT_PINCFG_PULLEN) ; - PORT->Group[port].DIRCLR.reg = pinMask ; + PORT->Group[port].PINCFG[pin].reg = (uint8_t) (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); + PORT->Group[port].DIRCLR.reg = pinMask; // Enable pull level (cf '22.6.3.2 Input Configuration' and '22.8.6 Data Output Value Clear') - PORT->Group[port].OUTCLR.reg = pinMask ; - break ; + PORT->Group[port].OUTCLR.reg = pinMask; + break; case OUTPUT: // enable input, to support reading back values, with pullups disabled - PORT->Group[port].PINCFG[pin].reg=(uint8_t)(PORT_PINCFG_INEN) ; + PORT->Group[port].PINCFG[pin].reg = (uint8_t) (PORT_PINCFG_INEN | PORT_PINCFG_DRVSTR); // Set pin to output mode - PORT->Group[port].DIRSET.reg = pinMask ; - break ; + PORT->Group[port].DIRSET.reg = pinMask; + break; default: // do nothing - break ; + break; } } diff --git a/cores/arduino/wiring_digital.h b/cores/arduino/wiring_digital.h index 9895390f2..d7dff21df 100644 --- a/cores/arduino/wiring_digital.h +++ b/cores/arduino/wiring_digital.h @@ -25,6 +25,8 @@ #include "WVariant.h" +typedef int PinStatus; + /** * \brief Configures the specified pin to behave either as an input or an output. See the description of digital pins for details. * diff --git a/extras/build_all.py b/extras/build_all.py deleted file mode 100644 index 83f0e19e9..000000000 --- a/extras/build_all.py +++ /dev/null @@ -1,109 +0,0 @@ -import os -import glob -import sys -import subprocess -import time - -all_warnings = False -exit_status = 0 -success_count = 0 -fail_count = 0 -skip_count = 0 - -build_format = '| {:22} | {:30} | {:9} ' -build_separator = '-' * 80 - -default_boards = [ 'metro_m0', 'metro_m4', 'circuitplayground_m0'] - -build_boards = [] - -# build all variants if input not existed -if len(sys.argv) > 1: - build_boards.append(sys.argv[1]) -else: - build_boards = default_boards - -def errorOutputFilter(line): - if len(line) == 0: - return False - if line.isspace(): # Note: empty string does not match here! - return False - # TODO: additional items to remove? - return True - - -def build_examples(variant): - global exit_status, success_count, fail_count, skip_count, build_format, build_separator - - print('\n') - print(build_separator) - print('| {:^76} |'.format('Board ' + variant)) - print(build_separator) - print((build_format + '| {:6} |').format('Library', 'Example', 'Result', 'Time')) - print(build_separator) - - fqbn = "adafruit:samd:adafruit_{}".format(variant) - - for sketch in glob.iglob('libraries/**/*.ino', recursive=True): - start_time = time.monotonic() - - # Skip if contains: ".board.test.skip" or ".all.test.skip" - # Skip if not contains: ".board.test.only" for a specific board - sketchdir = os.path.dirname(sketch) - if os.path.exists(sketchdir + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'): - success = "\033[33mskipped\033[0m " - elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.build.' + variant): - success = "\033[33mskipped\033[0m " - else: - # TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR. - # preferably, would use Python logging handler to get both distinct outputs and one merged output - # for now, split STDERR when building with all warnings enabled, so can detect warning/error output. - if all_warnings: - build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - else: - build_result = subprocess.run("arduino-cli compile --warnings default --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - - # get stderr into a form where len(warningLines) indicates a true warning was output to stderr - warningLines = []; - if all_warnings and build_result.stderr: - tmpWarningLines = build_result.stderr.decode("utf-8").splitlines() - warningLines = list(filter(errorOutputFilter, (tmpWarningLines))) - - if build_result.returncode != 0: - exit_status = build_result.returncode - success = "\033[31mfailed\033[0m " - fail_count += 1 - elif len(warningLines) != 0: - exit_status = -1 - success = "\033[31mwarnings\033[0m " - fail_count += 1 - else: - success = "\033[32msucceeded\033[0m" - success_count += 1 - - build_duration = time.monotonic() - start_time - - print((build_format + '| {:5.2f}s |').format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, build_duration)) - - if success != "\033[33mskipped\033[0m ": - if build_result.returncode != 0: - print(build_result.stdout.decode("utf-8")) - if (build_result.stderr): - print(build_result.stderr.decode("utf-8")) - if len(warningLines) != 0: - for line in warningLines: - print(line) - else: - skip_count += 1 - -build_time = time.monotonic() - -for board in build_boards: - build_examples(board) - -print(build_separator) -build_time = time.monotonic() - build_time -print("Build Summary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m, {} \033[33mskipped\033[0m and took {:.2f}s".format(success_count, fail_count, skip_count, build_time)) -print(build_separator) - -sys.exit(exit_status) diff --git a/libraries/Adafruit_TinyUSB_Arduino b/libraries/Adafruit_TinyUSB_Arduino new file mode 160000 index 000000000..c953968c4 --- /dev/null +++ b/libraries/Adafruit_TinyUSB_Arduino @@ -0,0 +1 @@ +Subproject commit c953968c468218d8968138b5ed8482fa565373df diff --git a/libraries/Adafruit_ZeroDMA b/libraries/Adafruit_ZeroDMA new file mode 160000 index 000000000..acc5dadb4 --- /dev/null +++ b/libraries/Adafruit_ZeroDMA @@ -0,0 +1 @@ +Subproject commit acc5dadb458b2c329757a61dc4f18dda945a0c36 diff --git a/libraries/Adafruit_ZeroDMA/Adafruit_ZeroDMA.cpp b/libraries/Adafruit_ZeroDMA/Adafruit_ZeroDMA.cpp deleted file mode 100644 index 0adb78470..000000000 --- a/libraries/Adafruit_ZeroDMA/Adafruit_ZeroDMA.cpp +++ /dev/null @@ -1,654 +0,0 @@ -#include -#include // memalign() function - -#include "utility/dma.h" -static volatile uint32_t _channelMask = 0; // Bitmask of allocated channels - -// DMA descriptor list entry point (and writeback buffer) per channel -__attribute__((__aligned__(16))) static DmacDescriptor // 128 bit alignment - _descriptor[DMAC_CH_NUM] SECTION_DMAC_DESCRIPTOR, - _writeback[DMAC_CH_NUM] SECTION_DMAC_DESCRIPTOR; - -// Pointer to ZeroDMA object for each channel is needed for the -// ISR (in C, outside of class context) to access callbacks. -static Adafruit_ZeroDMA *_dmaPtr[DMAC_CH_NUM] = { 0 }; // Init to NULL - -// Adapted from ASF3 interrupt_sam_nvic.c: - -static volatile unsigned long cpu_irq_critical_section_counter = 0; -static volatile unsigned char cpu_irq_prev_interrupt_state = 0; - -static void cpu_irq_enter_critical(void) { - if(!cpu_irq_critical_section_counter) { - if(__get_PRIMASK() == 0) { // IRQ enabled? - __disable_irq(); // Disable it - __DMB(); - cpu_irq_prev_interrupt_state = 1; - } else { - // Make sure the to save the prev state as false - cpu_irq_prev_interrupt_state = 0; - } - } - - cpu_irq_critical_section_counter++; -} - -static void cpu_irq_leave_critical(void) { - // Check if the user is trying to leave a critical section - // when not in a critical section - if(cpu_irq_critical_section_counter > 0) { - cpu_irq_critical_section_counter--; - - // Only enable global interrupts when the counter - // reaches 0 and the state of the global interrupt flag - // was enabled when entering critical state */ - if((!cpu_irq_critical_section_counter) && - cpu_irq_prev_interrupt_state) { - __DMB(); - __enable_irq(); - } - } -} - -// CONSTRUCTOR ------------------------------------------------------------- - -// Constructor initializes Adafruit_ZeroDMA basics but does NOT allocate a -// DMA channel (that's done in allocate()) or start a job (that's done in -// startJob()). This is because constructors in a global context are called -// before a sketch's setup() function, which may have some other hardware -// initialization of its own, don't want it clobbering us. -Adafruit_ZeroDMA::Adafruit_ZeroDMA(void) { - channel = 0xFF; // Channel not yet allocated - jobStatus = DMA_STATUS_OK; - hasDescriptors = false; // No descriptors allocated yet - loopFlag = false; - peripheralTrigger = 0; // Software trigger only by default - triggerAction = DMA_TRIGGER_ACTON_TRANSACTION; - memset(callback, 0, sizeof(callback)); -} - -// TODO: add destructor? Should stop job, delete descriptors, free channel. - -// INTERRUPT SERVICE ROUTINE ----------------------------------------------- - -// This is a C function that exists outside the Adafruit_ZeroDMA context. -// DMA channel number is determined from the INTPEND register, from this -// we get a ZeroDMA object pointer through the _dmaPtr[] array. -// (It's done this way because jobStatus and callback[] are protected -// elements in the ZeroDMA object -- we can't touch them in C, but the -// next function after this, being part of the ZeroDMA class, can.) - -#ifdef __SAMD51__ -void DMAC_0_Handler(void) { -#else -void DMAC_Handler(void) { -#endif - cpu_irq_enter_critical(); - - uint8_t channel = DMAC->INTPEND.bit.ID; // Channel # causing interrupt - if(channel < DMAC_CH_NUM) { - Adafruit_ZeroDMA *dma; - if((dma = _dmaPtr[channel])) { // -> Channel's ZeroDMA object -#ifdef __SAMD51__ - // Call IRQ handler with channel # - dma->_IRQhandler(channel); -#else - DMAC->CHID.bit.ID = channel; - // Call IRQ handler with interrupt flag(s) - dma->_IRQhandler(DMAC->CHINTFLAG.reg); -#endif - } - } - - cpu_irq_leave_critical(); -} - -#ifdef __SAMD51__ -void DMAC_1_Handler(void) __attribute__((weak, alias("DMAC_0_Handler"))); -void DMAC_2_Handler(void) __attribute__((weak, alias("DMAC_0_Handler"))); -void DMAC_3_Handler(void) __attribute__((weak, alias("DMAC_0_Handler"))); -void DMAC_4_Handler(void) __attribute__((weak, alias("DMAC_0_Handler"))); -#endif - -void Adafruit_ZeroDMA::_IRQhandler(uint8_t flags) { -#ifdef __SAMD51__ - // 'flags' is initially passed in as channel number, - // from which we look up the actual interrupt flags... - flags = DMAC->Channel[flags].CHINTFLAG.reg; -#endif - if(flags & DMAC_CHINTENCLR_TERR) { - // Clear error flag -#ifdef __SAMD51__ - DMAC->Channel[channel].CHINTFLAG.reg = DMAC_CHINTENCLR_TERR; -#else - DMAC->CHINTFLAG.reg = DMAC_CHINTENCLR_TERR; -#endif - jobStatus = DMA_STATUS_ERR_IO; - if(callback[DMA_CALLBACK_TRANSFER_ERROR]) { - callback[DMA_CALLBACK_TRANSFER_ERROR](this); - } - } else if(flags & DMAC_CHINTENCLR_TCMPL) { - // Clear transfer complete flag -#ifdef __SAMD51__ - DMAC->Channel[channel].CHINTFLAG.reg = DMAC_CHINTENCLR_TCMPL; -#else - DMAC->CHINTFLAG.reg = DMAC_CHINTENCLR_TCMPL; -#endif - jobStatus = DMA_STATUS_OK; - if(callback[DMA_CALLBACK_TRANSFER_DONE]) { - callback[DMA_CALLBACK_TRANSFER_DONE](this); - } - } else if(flags & DMAC_CHINTENCLR_SUSP) { - // Clear channel suspend flag -#ifdef __SAMD51__ - DMAC->Channel[channel].CHINTFLAG.reg = DMAC_CHINTENCLR_SUSP; -#else - DMAC->CHINTFLAG.reg = DMAC_CHINTENCLR_SUSP; -#endif - jobStatus = DMA_STATUS_SUSPEND; - if(callback[DMA_CALLBACK_CHANNEL_SUSPEND]) { - callback[DMA_CALLBACK_CHANNEL_SUSPEND](this); - } - } -} - -// DMA CHANNEL FUNCTIONS --------------------------------------------------- - -// Allocates channel for ZeroDMA object -ZeroDMAstatus Adafruit_ZeroDMA::allocate(void) { - - if(channel < DMAC_CH_NUM) return DMA_STATUS_OK; // Already alloc'd! - - // Find index of first free DMA channel. As currently written, - // this "does not play well with others" as it assumes _channelMask - // is the final arbiter of channels in use (this is true only within - // this library -- but other DMA-driven code may have allocated its - // own channel(s) elsewhere, sometimes with an equally broken - // approach). A possible alternate approach, I haven't tested this - // yet, might be to loop through each channel, set DMAC->CHID.bit.ID - // and then test whether CHCTRLA.bit.ENABLE is set? But for now... - for(channel=0; (channel < DMAC_CH_NUM) && - (_channelMask & (1 << channel)); channel++); - // Doesn't help that code later does a software reset of the DMA - // controller, which would blow out other DMA-using libraries - // anyway (or they're just as likely to blow out this one). - // I think it's just an all-or-nothing affair...use one library - // for DMA everything, never mix and match. - - if(channel >= DMAC_CH_NUM) { // No free channel! - return DMA_STATUS_ERR_NOT_FOUND; - } - - cpu_irq_enter_critical(); - - if(!_channelMask) { // No channels allocated yet; initialize DMA! -#if (SAML21) || (SAML22) || (SAMC20) || (SAMC21) - PM->AHBMASK.bit.DMAC_ = 1; -#elif defined(__SAMD51__) - MCLK->AHBMASK.bit.DMAC_ = 1; // Initialize DMA clocks -#else - PM->AHBMASK.bit.DMAC_ = 1; // Initialize DMA clocks - PM->APBBMASK.bit.DMAC_ = 1; -#endif - DMAC->CTRL.bit.DMAENABLE = 0; // Disable DMA controller - DMAC->CTRL.bit.SWRST = 1; // Perform software reset - - // Initialize descriptor list addresses - DMAC->BASEADDR.bit.BASEADDR = (uint32_t)_descriptor; - DMAC->WRBADDR.bit.WRBADDR = (uint32_t)_writeback; - memset(_descriptor, 0, sizeof(_descriptor)); - memset(_writeback , 0, sizeof(_writeback)); - - // Re-enable DMA controller with all priority levels - DMAC->CTRL.reg = DMAC_CTRL_DMAENABLE | DMAC_CTRL_LVLEN(0xF); - - // Enable DMA interrupt at lowest priority -#ifdef __SAMD51__ - IRQn_Type irqs[] = { DMAC_0_IRQn, DMAC_1_IRQn, DMAC_2_IRQn, - DMAC_3_IRQn, DMAC_4_IRQn }; - for(uint8_t i=0; i<(sizeof irqs / sizeof irqs[0]); i++) { - NVIC_EnableIRQ(irqs[i]); - NVIC_SetPriority(irqs[i], (1<<__NVIC_PRIO_BITS)-1); - } -#else - NVIC_EnableIRQ(DMAC_IRQn); - NVIC_SetPriority(DMAC_IRQn, (1 << __NVIC_PRIO_BITS) - 1); -#endif - } - - _channelMask |= 1 << channel; // Mark channel as allocated - _dmaPtr[channel] = this; // Channel-index-to-object pointer - - // Reset the allocated channel -#ifdef __SAMD51__ - DMAC->Channel[channel].CHCTRLA.bit.ENABLE = 0; - DMAC->Channel[channel].CHCTRLA.bit.SWRST = 1; -#else - DMAC->CHID.bit.ID = channel; - DMAC->CHCTRLA.bit.ENABLE = 0; - DMAC->CHCTRLA.bit.SWRST = 1; -#endif - - // Clear software trigger - DMAC->SWTRIGCTRL.reg &= ~(1 << channel); - - // Configure default behaviors -#ifdef __SAMD51__ - DMAC->Channel[channel].CHPRILVL.bit.PRILVL = 0; - DMAC->Channel[channel].CHCTRLA.bit.TRIGSRC = peripheralTrigger; - DMAC->Channel[channel].CHCTRLA.bit.TRIGACT = triggerAction; - DMAC->Channel[channel].CHCTRLA.bit.BURSTLEN = - DMAC_CHCTRLA_BURSTLEN_SINGLE_Val; // Single-beat burst length -#else - DMAC->CHCTRLB.bit.LVL = 0; - DMAC->CHCTRLB.bit.TRIGSRC = peripheralTrigger; - DMAC->CHCTRLB.bit.TRIGACT = triggerAction; -#endif - - cpu_irq_leave_critical(); - - return DMA_STATUS_OK; -} - -void Adafruit_ZeroDMA::setPriority(dma_priority pri) const { -#ifdef __SAMD51__ - DMAC->Channel[channel].CHPRILVL.bit.PRILVL = pri; -#else - DMAC->CHCTRLB.bit.LVL = pri; -#endif -} - -// Deallocate DMA channel -// TODO: should this delete/deallocate the descriptor list? -ZeroDMAstatus Adafruit_ZeroDMA::free(void) { - - ZeroDMAstatus status = DMA_STATUS_OK; - - cpu_irq_enter_critical(); // jobStatus is volatile - - if(jobStatus == DMA_STATUS_BUSY) { - status = DMA_STATUS_BUSY; // Can't leave when busy - } else if((channel < DMAC_CH_NUM) && (_channelMask & (1 << channel))) { - // Valid in-use channel; release it - _channelMask &= ~(1 << channel); // Clear bit - if(!_channelMask) { // No more channels in use? -#ifdef __SAMD51__ - NVIC_DisableIRQ(DMAC_0_IRQn); // Disable DMA interrupt - DMAC->CTRL.bit.DMAENABLE = 0; // Disable DMA - MCLK->AHBMASK.bit.DMAC_ = 0; // Disable DMA clock -#else - NVIC_DisableIRQ(DMAC_IRQn); // Disable DMA interrupt - DMAC->CTRL.bit.DMAENABLE = 0; // Disable DMA - PM->APBBMASK.bit.DMAC_ = 0; // Disable DMA clocks - PM->AHBMASK.bit.DMAC_ = 0; -#endif - } - _dmaPtr[channel] = NULL; - channel = 0xFF; - } else { - status = DMA_STATUS_ERR_NOT_INITIALIZED; // Channel not in use - } - - cpu_irq_leave_critical(); - - return status; -} - -// Start DMA transfer job. Channel and descriptors should be allocated -// before calling this. -ZeroDMAstatus Adafruit_ZeroDMA::startJob(void) { - ZeroDMAstatus status = DMA_STATUS_OK; - - cpu_irq_enter_critical(); // Job status is volatile - - if(jobStatus == DMA_STATUS_BUSY) { - status = DMA_STATUS_BUSY; // Resource is busy - } else if(channel >= DMAC_CH_NUM) { - status = DMA_STATUS_ERR_NOT_INITIALIZED; // Channel not in use - } else if(!hasDescriptors || (_descriptor[channel].BTCNT.reg <= 0)) { - status = DMA_STATUS_ERR_INVALID_ARG; // Bad transfer size - } else { - uint8_t i, interruptMask = 0; - for(i=0; iChannel[channel].CHINTENSET.reg = - DMAC_CHINTENSET_MASK & interruptMask; - DMAC->Channel[channel].CHINTENCLR.reg = - DMAC_CHINTENCLR_MASK & ~interruptMask; - DMAC->Channel[channel].CHCTRLA.bit.ENABLE = 1; -#else - DMAC->CHID.bit.ID = channel; - DMAC->CHINTENSET.reg = DMAC_CHINTENSET_MASK & interruptMask; - DMAC->CHINTENCLR.reg = DMAC_CHINTENCLR_MASK & ~interruptMask; - DMAC->CHCTRLA.bit.ENABLE = 1; // Enable the transfer channel -#endif - } - - cpu_irq_leave_critical(); - - return status; -} - -// Set and enable callback function for ZeroDMA object. This can be called -// before or after channel and/or descriptors are allocated, but needs -// to be called before job is started. -void Adafruit_ZeroDMA::setCallback( - void (*cb)(Adafruit_ZeroDMA *), dma_callback_type type) { - callback[type] = cb; -} - -// Suspend/resume don't quite do what I thought -- avoid using for now. -void Adafruit_ZeroDMA::suspend(void) const { - cpu_irq_enter_critical(); -#ifdef __SAMD51__ - DMAC->Channel[channel].CHCTRLB.reg |= DMAC_CHCTRLB_CMD_SUSPEND; -#else - DMAC->CHID.bit.ID = channel; - DMAC->CHCTRLB.reg |= DMAC_CHCTRLB_CMD_SUSPEND; -#endif - cpu_irq_leave_critical(); -} - -#define MAX_JOB_RESUME_COUNT 10000 -void Adafruit_ZeroDMA::resume(void) { - cpu_irq_enter_critical(); // jobStatus is volatile - if(jobStatus == DMA_STATUS_SUSPEND) { - int count; - uint32_t bitMask = 1 << channel; -#ifdef __SAMD51__ - DMAC->Channel[channel].CHCTRLB.reg |= DMAC_CHCTRLB_CMD_RESUME; -#else - DMAC->CHID.bit.ID = channel; - DMAC->CHCTRLB.reg |= DMAC_CHCTRLB_CMD_RESUME; -#endif - - for(count = 0; (count < MAX_JOB_RESUME_COUNT) && - !(DMAC->BUSYCH.reg & bitMask); count++); - - jobStatus = (count < MAX_JOB_RESUME_COUNT) ? - DMA_STATUS_BUSY : DMA_STATUS_ERR_TIMEOUT; - } - cpu_irq_leave_critical(); -} - -// Abort is OK though. -void Adafruit_ZeroDMA::abort(void) { - if(channel <= DMAC_CH_NUM) { - cpu_irq_enter_critical(); -#ifdef __SAMD51__ - DMAC->Channel[channel].CHCTRLA.reg = 0; // Disable channel -#else - DMAC->CHID.bit.ID = channel; // Select channel - DMAC->CHCTRLA.reg = 0; // Disable -#endif - jobStatus = DMA_STATUS_ABORTED; - cpu_irq_leave_critical(); - } -} - -// Set DMA peripheral trigger. -// This can be done before or after channel is allocated. -void Adafruit_ZeroDMA::setTrigger(uint8_t trigger) { - peripheralTrigger = trigger; // Save value for allocate() - - // If channel already allocated, configure peripheral trigger - // (old lib required configure before alloc -- either way OK now) - if(channel < DMAC_CH_NUM) { - cpu_irq_enter_critical(); -#ifdef __SAMD51__ - DMAC->Channel[channel].CHCTRLA.bit.TRIGSRC = trigger; -#else - DMAC->CHID.bit.ID = channel; - DMAC->CHCTRLB.bit.TRIGSRC = trigger; -#endif - cpu_irq_leave_critical(); - } -} - -// Set DMA trigger action. -// This can be done before or after channel is allocated. -void Adafruit_ZeroDMA::setAction(dma_transfer_trigger_action action) { - triggerAction = action; // Save value for allocate() - - // If channel already allocated, configure trigger action - // (old lib required configure before alloc -- either way OK now) - if(channel < DMAC_CH_NUM) { - cpu_irq_enter_critical(); -#ifdef __SAMD51__ - DMAC->Channel[channel].CHCTRLA.bit.TRIGACT = action; -#else - DMAC->CHID.bit.ID = channel; - DMAC->CHCTRLB.bit.TRIGACT = action; -#endif - cpu_irq_leave_critical(); - } -} - -// Issue software trigger. Channel must be allocated & descriptors added! -void Adafruit_ZeroDMA::trigger(void) const { - if((channel <= DMAC_CH_NUM) & hasDescriptors) { - DMAC->SWTRIGCTRL.reg |= (1 << channel); - } -} - -// Returns true if DMA transfer in progress. -bool Adafruit_ZeroDMA::isActive(void) const { - return _writeback[channel].BTCTRL.bit.VALID; -} - -// DMA DESCRIPTOR FUNCTIONS ------------------------------------------------ - -// Allocates a new DMA descriptor (if needed) and appends it to the -// channel's descriptor list. Returns pointer to DmacDescriptor, -// or NULL on various errors. You'll want to keep the pointer for -// later if you need to modify or free the descriptor. -// Channel must be allocated first! -DmacDescriptor *Adafruit_ZeroDMA::addDescriptor( - void *src, - void *dst, - uint32_t count, - dma_beat_size size, - bool srcInc, - bool dstInc, - uint32_t stepSize, - bool stepSel) { - - // Channel must be allocated first - if(channel >= DMAC_CH_NUM) return NULL; - - // Can't do while job's busy - if(jobStatus == DMA_STATUS_BUSY) return NULL; - - DmacDescriptor *desc; - - // Scan descriptor list to find last entry. If an entry's - // DESCADDR value is 0, that's the end of the list and it's - // currently un-looped. If the DESCADDR value is the same - // as the first entry, that's the end of the list and it's - // looped. Either way, set the last entry's DESCADDR value - // to the new descriptor, and the descriptor's own DESCADDR - // will be set later either to 0 or the list head. - if(hasDescriptors) { - // DMA descriptors must be 128-bit (16 byte) aligned. - // memalign() is considered 'obsolete' but it's replacements - // (aligned_alloc() or posix_memalign()) are not currently - // available in the version of ARM GCC in use, but this is, - // so here we are. - if(!(desc = (DmacDescriptor *)memalign(16, sizeof(DmacDescriptor)))) { - return NULL; - } - DmacDescriptor *prev = &_descriptor[channel]; - while(prev->DESCADDR.reg && - (prev->DESCADDR.reg != (uint32_t)&_descriptor[channel])) { - prev = (DmacDescriptor *)prev->DESCADDR.reg; - } - prev->DESCADDR.reg = (uint32_t)desc; - } else { - desc = &_descriptor[channel]; - } - hasDescriptors = true; - - uint8_t bytesPerBeat; // Beat transfer size IN BYTES - switch(size) { - default: bytesPerBeat = 1; break; - case DMA_BEAT_SIZE_HWORD: bytesPerBeat = 2; break; - case DMA_BEAT_SIZE_WORD: bytesPerBeat = 4; break; - } - - desc->BTCTRL.bit.VALID = true; - desc->BTCTRL.bit.EVOSEL = DMA_EVENT_OUTPUT_DISABLE; - desc->BTCTRL.bit.BLOCKACT = DMA_BLOCK_ACTION_NOACT; - desc->BTCTRL.bit.BEATSIZE = size; - desc->BTCTRL.bit.SRCINC = srcInc; - desc->BTCTRL.bit.DSTINC = dstInc; - desc->BTCTRL.bit.STEPSEL = stepSel; - desc->BTCTRL.bit.STEPSIZE = stepSize; - desc->BTCNT.reg = count; - desc->SRCADDR.reg = (uint32_t)src; - - if(srcInc) { - if(stepSel) { - desc->SRCADDR.reg += bytesPerBeat * count * (1 << stepSize); - } else { - desc->SRCADDR.reg += bytesPerBeat * count; - } - } - - desc->DSTADDR.reg = (uint32_t)dst; - - if(dstInc) { - if(!stepSel) { - desc->DSTADDR.reg += bytesPerBeat * count * (1 << stepSize); - } else { - desc->DSTADDR.reg += bytesPerBeat * count; - } - } - - desc->DESCADDR.reg = loopFlag ? (uint32_t)&_descriptor[channel] : 0; - - return desc; -} - -// Modify DMA descriptor with a new source address, destination address & -// block transfer count. All other attributes (including increment enables, -// etc.) are unchanged. Mostly for changing the data being pushed to a -// peripheral (DAC, SPI, whatev.) -void Adafruit_ZeroDMA::changeDescriptor(DmacDescriptor *desc, - void *src, void *dst, uint32_t count) { - - uint8_t bytesPerBeat; // Beat transfer size IN BYTES - switch(desc->BTCTRL.bit.BEATSIZE) { - default: bytesPerBeat = 1; break; - case DMA_BEAT_SIZE_HWORD: bytesPerBeat = 2; break; - case DMA_BEAT_SIZE_WORD: bytesPerBeat = 4; break; - } - - if(count) desc->BTCNT.reg = count; - - if(src) { - desc->SRCADDR.reg = (uint32_t)src; - if(desc->BTCTRL.bit.SRCINC) { - if(desc->BTCTRL.bit.STEPSEL) { - desc->SRCADDR.reg += desc->BTCNT.reg * - bytesPerBeat * (1 << desc->BTCTRL.bit.STEPSIZE); - } else { - desc->SRCADDR.reg += desc->BTCNT.reg * bytesPerBeat; - } - } - } - - if(dst) { - desc->DSTADDR.reg = (uint32_t)dst; - if(desc->BTCTRL.bit.DSTINC) { - if(!desc->BTCTRL.bit.STEPSEL) { - desc->DSTADDR.reg += desc->BTCNT.reg * - bytesPerBeat * (1 << desc->BTCTRL.bit.STEPSIZE); - } else { - desc->DSTADDR.reg += desc->BTCNT.reg * bytesPerBeat; - } - } - } - -// I think this code is here by accident -- disabling for now. -#if 0 - cpu_irq_enter_critical(); - jobStatus = DMA_STATUS_OK; -#ifdef __SAMD51__ - DMAC->Channel[channel].CHCTRLA.bit.ENABLE = 1; -#else - DMAC->CHID.bit.ID = channel; - DMAC->CHCTRLA.reg |= DMAC_CHCTRLA_ENABLE; -#endif - cpu_irq_leave_critical(); -#endif -} - -// TODO: delete descriptor, delete whole descriptor chain - -// Select whether channel's descriptor list should repeat or not. -// This can be done before or after channel & any descriptors are allocated. -void Adafruit_ZeroDMA::loop(boolean flag) { - // The loop selection is 'sticky' -- that is, you can enable or - // disable looping before a descriptor list is built, or after - // the fact. This requires some extra steps in the library code - // but avoids a must-do-in-X-order constraint on user. - loopFlag = flag; - - if(hasDescriptors) { // Descriptor list already started? - // Scan descriptor list to find last entry. If an entry's - // DESCADDR value is 0, that's the end of the list and it's - // currently un-looped. If the DESCADDR value is the same - // as the first entry, that's the end of the list and it's - // already looped. - DmacDescriptor *desc = &_descriptor[channel]; - while(desc->DESCADDR.reg && - (desc->DESCADDR.reg != (uint32_t)&_descriptor[channel])) { - desc = (DmacDescriptor *)desc->DESCADDR.reg; - } - // Loop or unloop descriptor list as appropriate - desc->DESCADDR.reg = loopFlag ? (uint32_t)&_descriptor[channel] : 0; - } -} - -// MISCELLANY -------------------------------------------------------------- - -void Adafruit_ZeroDMA::printStatus(ZeroDMAstatus s) const { - if(s == DMA_STATUS_JOBSTATUS) s = jobStatus; - Serial.print("Status: "); - switch(s) { - case DMA_STATUS_OK: - Serial.println("OK"); - break; - case DMA_STATUS_ERR_NOT_FOUND: - Serial.println("NOT FOUND"); - break; - case DMA_STATUS_ERR_NOT_INITIALIZED: - Serial.println("NOT INITIALIZED"); - break; - case DMA_STATUS_ERR_INVALID_ARG: - Serial.println("INVALID ARGUMENT"); - break; - case DMA_STATUS_ERR_IO: - Serial.println("IO ERROR"); - break; - case DMA_STATUS_ERR_TIMEOUT: - Serial.println("TIMEOUT"); - break; - case DMA_STATUS_BUSY: - Serial.println("BUSY"); - break; - case DMA_STATUS_SUSPEND: - Serial.println("SUSPENDED"); - break; - case DMA_STATUS_ABORTED: - Serial.println("ABORTED"); - break; - default: - Serial.print("Unknown 0x"); - Serial.println((int)s); - break; - } -} diff --git a/libraries/Adafruit_ZeroDMA/Adafruit_ZeroDMA.h b/libraries/Adafruit_ZeroDMA/Adafruit_ZeroDMA.h deleted file mode 100644 index fc8461993..000000000 --- a/libraries/Adafruit_ZeroDMA/Adafruit_ZeroDMA.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _ADAFRUIT_ZERODMA_H_ -#define _ADAFRUIT_ZERODMA_H_ - -#include "Arduino.h" -#include "utility/dma.h" - -// Status codes returned by some DMA functions and/or held in -// a channel's jobStatus variable. -enum ZeroDMAstatus { - DMA_STATUS_OK = 0, - DMA_STATUS_ERR_NOT_FOUND, - DMA_STATUS_ERR_NOT_INITIALIZED, - DMA_STATUS_ERR_INVALID_ARG, - DMA_STATUS_ERR_IO, - DMA_STATUS_ERR_TIMEOUT, - DMA_STATUS_BUSY, - DMA_STATUS_SUSPEND, - DMA_STATUS_ABORTED, - DMA_STATUS_JOBSTATUS = -1 // For printStatus() function -}; - -class Adafruit_ZeroDMA { - public: - Adafruit_ZeroDMA(void); - - // DMA channel functions - ZeroDMAstatus allocate(void), // Allocates DMA channel - startJob(void), - free(void); // Deallocates DMA channel - void trigger(void) const, - setTrigger(uint8_t trigger), - setAction(dma_transfer_trigger_action action), - setCallback(void (*callback)(Adafruit_ZeroDMA *) = NULL, - dma_callback_type type = DMA_CALLBACK_TRANSFER_DONE), - loop(boolean flag), - suspend(void) const, - resume(void), - abort(void), - setPriority(dma_priority pri) const, - printStatus(ZeroDMAstatus s = DMA_STATUS_JOBSTATUS) const; - uint8_t getChannel(void) const { return channel; } - - // DMA descriptor functions - DmacDescriptor *addDescriptor(void *src, void *dst, uint32_t count = 0, - dma_beat_size size = DMA_BEAT_SIZE_BYTE, - bool srcInc = true, bool dstInc = true, - uint32_t stepSize = DMA_ADDRESS_INCREMENT_STEP_SIZE_1, - bool stepSel = DMA_STEPSEL_DST); - void changeDescriptor(DmacDescriptor *d, void *src = NULL, - void *dst = NULL, uint32_t count = 0); - bool isActive(void) const; - - void _IRQhandler(uint8_t flags); // DO NOT TOUCH - - - protected: - uint8_t channel; - volatile enum ZeroDMAstatus jobStatus; - bool hasDescriptors; - bool loopFlag; - uint8_t peripheralTrigger; - dma_transfer_trigger_action triggerAction; - void (*callback[DMA_CALLBACK_N])(Adafruit_ZeroDMA *); -}; - -#endif // _ADAFRUIT_ZERODMA_H_ diff --git a/libraries/Adafruit_ZeroDMA/LICENSE b/libraries/Adafruit_ZeroDMA/LICENSE deleted file mode 100644 index ee356f7b7..000000000 --- a/libraries/Adafruit_ZeroDMA/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Adafruit Industries - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/libraries/Adafruit_ZeroDMA/README.md b/libraries/Adafruit_ZeroDMA/README.md deleted file mode 100644 index cbc5441cc..000000000 --- a/libraries/Adafruit_ZeroDMA/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Adafruit_ZeroDMA -DMA helper/wrapped for ATSAMD21 such as Arduino Zero & Feather M0 - -Current version of this library no longer requires Adafruit_ASFcore as a prerequisite. However...IT BREAKS COMPATIBILITY WITH PRIOR VERSIONS. Function names, calling sequence and return types/values have changed. See examples! - -Item(s) in 'utility' directory are much pared-down derivatives of Atmel ASFcore 3 files. Please keep their original copyright and license intact when editing. diff --git a/libraries/Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino b/libraries/Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino deleted file mode 100644 index 191ab50ac..000000000 --- a/libraries/Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino +++ /dev/null @@ -1,94 +0,0 @@ -// Simple ZeroDMA example -- an equivalent to the memcpy() function. -// Decause it uses DMA, unlike memcpy(), your code could be doing other -// things simultaneously while the copy operation runs. - -#include -#include "utility/dma.h" - -Adafruit_ZeroDMA myDMA; -ZeroDMAstatus stat; // DMA status codes returned by some functions - -// The memory we'll be moving: -#define DATA_LENGTH 1024 -uint8_t source_memory[DATA_LENGTH], - destination_memory[DATA_LENGTH]; - -volatile bool transfer_is_done = false; // Done yet? - -// Callback for end-of-DMA-transfer -void dma_callback(Adafruit_ZeroDMA *dma) { - transfer_is_done = true; -} - -void setup() { - uint32_t t; - pinMode(LED_BUILTIN, OUTPUT); // Onboard LED can be used for precise - digitalWrite(LED_BUILTIN, LOW); // benchmarking with an oscilloscope - Serial.begin(115200); - while(!Serial); // Wait for Serial monitor before continuing - - Serial.println("DMA test: memory copy"); - - Serial.print("Allocating DMA channel..."); - stat = myDMA.allocate(); - myDMA.printStatus(stat); - - Serial.println("Setting up transfer"); - myDMA.addDescriptor(source_memory, destination_memory, DATA_LENGTH); - - Serial.println("Adding callback"); - // register_callback() can optionally take a second argument - // (callback type), default is DMA_CALLBACK_TRANSFER_DONE - myDMA.setCallback(dma_callback); - - // Fill the source buffer with incrementing bytes, dest buf with 0's - for(uint32_t i=0; i -#include -#include "utility/dma.h" - -Adafruit_ZeroDMA myDMA; -ZeroDMAstatus stat; // DMA status codes returned by some functions - -// The memory we'll be issuing to SPI: -#define DATA_LENGTH 2048 -uint8_t source_memory[DATA_LENGTH]; - -volatile bool transfer_is_done = false; // Done yet? - -// Callback for end-of-DMA-transfer -void dma_callback(Adafruit_ZeroDMA *dma) { - transfer_is_done = true; -} - -void setup() { - uint32_t t; - pinMode(LED_BUILTIN, OUTPUT); // Onboard LED can be used for precise - digitalWrite(LED_BUILTIN, LOW); // benchmarking with an oscilloscope - Serial.begin(115200); - while(!Serial); // Wait for Serial monitor before continuing - - Serial.println("DMA test: SPI data out"); - - SPI.begin(); - - Serial.println("Configuring DMA trigger"); -#ifdef __SAMD51__ - // SERCOM2 is the 'native' SPI SERCOM on Metro M4 - myDMA.setTrigger(SERCOM2_DMAC_ID_TX); -#else - // SERCOM4 is the 'native' SPI SERCOM on most M0 boards - myDMA.setTrigger(SERCOM4_DMAC_ID_TX); -#endif - myDMA.setAction(DMA_TRIGGER_ACTON_BEAT); - - Serial.print("Allocating DMA channel..."); - stat = myDMA.allocate(); - myDMA.printStatus(stat); - - Serial.println("Setting up transfer"); - myDMA.addDescriptor( - source_memory, // move data from here -#ifdef __SAMD51__ - (void *)(&SERCOM2->SPI.DATA.reg), // to here (M4) -#else - (void *)(&SERCOM4->SPI.DATA.reg), // to here (M0) -#endif - DATA_LENGTH, // this many... - DMA_BEAT_SIZE_BYTE, // bytes/hword/words - true, // increment source addr? - false); // increment dest addr? - - Serial.println("Adding callback"); - // register_callback() can optionally take a second argument - // (callback type), default is DMA_CALLBACK_TRANSFER_DONE - myDMA.setCallback(dma_callback); - - // Fill the source buffer with incrementing bytes - for(uint32_t i=0; i -#include -#include "utility/dma.h" -#include "wiring_private.h" // pinPeripheral() function - -// Declare our own SPI peripheral 'mySPI' on pins 11/12/13: -// (Do not call this SPI1; Arduino Zero and Metro M0 already -// have an SPI1 (the EDBG interface) and it won't compile.) -SPIClass mySPI( - &sercom1, // -> Sercom peripheral - 34, // MISO pin (also digital pin 12) - 37, // SCK pin (also digital pin 13) - 35, // MOSI pin (also digital pin 11) - SPI_PAD_0_SCK_1, // TX pad (MOSI, SCK pads) - SERCOM_RX_PAD_3); // RX pad (MISO pad) - -Adafruit_ZeroDMA myDMA; -ZeroDMAstatus stat; // DMA status codes returned by some functions - -// Data we'll issue to mySPI. There are TWO buffers; one being -// filled with new data while the other's being transmitted in -// the background. -#define DATA_LENGTH 512 -uint8_t source_memory[2][DATA_LENGTH], - buffer_being_filled = 0, // Index of 'filling' buffer - buffer_value = 0; // Value of fill - -volatile bool transfer_is_done = true; // Done yet? - -// Callback for end-of-DMA-transfer -void dma_callback(Adafruit_ZeroDMA *dma) { - transfer_is_done = true; -} - -DmacDescriptor *desc; // DMA descriptor address (so we can change contents) - -void setup() { - Serial.begin(115200); - while(!Serial); // Wait for Serial monitor before continuing - - Serial.println("DMA test: SPI data out"); - - mySPI.begin(); - // Assign pins 11, 12, 13 to SERCOM functionality - pinPeripheral(11, PIO_SERCOM); - pinPeripheral(12, PIO_SERCOM); - pinPeripheral(13, PIO_SERCOM); - - // Configure DMA for SERCOM1 (our 'mySPI' port on 11/12/13) - Serial.println("Configuring DMA trigger"); - myDMA.setTrigger(SERCOM1_DMAC_ID_TX); - myDMA.setAction(DMA_TRIGGER_ACTON_BEAT); - - Serial.print("Allocating DMA channel..."); - stat = myDMA.allocate(); - myDMA.printStatus(stat); - - desc = myDMA.addDescriptor( - source_memory[buffer_being_filled], // move data from here - (void *)(&SERCOM1->SPI.DATA.reg), // to here - DATA_LENGTH, // this many... - DMA_BEAT_SIZE_BYTE, // bytes/hword/words - true, // increment source addr? - false); // increment dest addr? - - Serial.println("Adding callback"); - // register_callback() can optionally take a second argument - // (callback type), default is DMA_CALLBACK_TRANSFER_DONE - myDMA.setCallback(dma_callback); -} - -void loop() { - // Fill buffer with new data. The other buffer might - // still be transmitting in the background via DMA. - memset(source_memory[buffer_being_filled], buffer_value, DATA_LENGTH); - - // Wait for prior transfer to complete before starting new one... - Serial.print("Waiting on prior transfer..."); - while(!transfer_is_done) Serial.write('.'); - mySPI.endTransaction(); - Serial.println("Done!"); - - // Modify the DMA descriptor using the newly-filled buffer as source... - myDMA.changeDescriptor(desc, // DMA descriptor address - source_memory[buffer_being_filled]); // New src; dst & count don't change - - // Begin new transfer... - Serial.println("Starting new transfer job"); - mySPI.beginTransaction(SPISettings(12000000, MSBFIRST, SPI_MODE0)); - transfer_is_done = false; // Reset 'done' flag - stat = myDMA.startJob(); // Go! - myDMA.printStatus(stat); - - // Switch buffer indices so the alternate buffer is filled/xfer'd - // on the next pass. - buffer_being_filled = 1 - buffer_being_filled; - buffer_value++; -} - diff --git a/libraries/Adafruit_ZeroDMA/library.properties b/libraries/Adafruit_ZeroDMA/library.properties deleted file mode 100644 index 32ce0a1c1..000000000 --- a/libraries/Adafruit_ZeroDMA/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=Adafruit Zero DMA Library -version=1.0.4 -author=Adafruit -maintainer=Adafruit -sentence=DMA helper/wrapped for ATSAMD21 such as Arduino Zero & Feather M0 -paragraph=DMA helper/wrapped for ATSAMD21 such as Arduino Zero & Feather M0 -category=Signal Input/Output -url=https://github.com/adafruit/Adafruit_ZeroDMA -architectures=samd diff --git a/libraries/Adafruit_ZeroDMA/utility/dma.h b/libraries/Adafruit_ZeroDMA/utility/dma.h deleted file mode 100644 index bafd36ae2..000000000 --- a/libraries/Adafruit_ZeroDMA/utility/dma.h +++ /dev/null @@ -1,145 +0,0 @@ -/** - * \file - * - * \brief SAM Direct Memory Access Controller Driver - * - * Copyright (C) 2014-2015 Atmel Corporation. All rights reserved. - * - * \asf_license_start - * - * \page License - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The name of Atmel may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 4. This software may only be redistributed and used in connection with an - * Atmel microcontroller product. - * - * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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. - * - * \asf_license_stop - * - */ -/* - * Support and FAQ: visit Atmel Support - */ -#ifndef DMA_H_INCLUDED -#define DMA_H_INCLUDED - -// THIS IS A PARED-DOWN VERSION OF DMA.H FROM ATMEL ASFCORE 3. -// Please keep original copyright and license intact! - -#ifdef __cplusplus -extern "C" { -#endif - -#if (SAML21) || (SAML22) || (SAMC20) || (SAMC21) || defined(__DOXYGEN__) || defined(__SAMD51__) -#define FEATURE_DMA_CHANNEL_STANDBY -#endif - -enum dma_transfer_trigger_action{ -#ifdef __SAMD51__ - // SAMD51 has a 'burst' transfer which can be set to one - // beat to accomplish same idea as SAMD21's 'beat' transfer. - // Trigger name is ACTON_BEAT for backward compatibility. - DMA_TRIGGER_ACTON_BLOCK = DMAC_CHCTRLA_TRIGACT_BLOCK_Val, - DMA_TRIGGER_ACTON_BEAT = DMAC_CHCTRLA_TRIGACT_BURST_Val, - DMA_TRIGGER_ACTON_TRANSACTION = DMAC_CHCTRLA_TRIGACT_TRANSACTION_Val, -#else - DMA_TRIGGER_ACTON_BLOCK = DMAC_CHCTRLB_TRIGACT_BLOCK_Val, - DMA_TRIGGER_ACTON_BEAT = DMAC_CHCTRLB_TRIGACT_BEAT_Val, - DMA_TRIGGER_ACTON_TRANSACTION = DMAC_CHCTRLB_TRIGACT_TRANSACTION_Val, -#endif -}; - -enum dma_callback_type { - // First item here is for any transfer errors. A transfer error is - // flagged if a bus error is detected during an AHB access or when - // the DMAC fetches an invalid descriptor - DMA_CALLBACK_TRANSFER_ERROR, - DMA_CALLBACK_TRANSFER_DONE, - DMA_CALLBACK_CHANNEL_SUSPEND, - DMA_CALLBACK_N, // Number of available callbacks -}; - -enum dma_beat_size { - DMA_BEAT_SIZE_BYTE = 0, // 8-bit - DMA_BEAT_SIZE_HWORD, // 16-bit - DMA_BEAT_SIZE_WORD, // 32-bit -}; - -enum dma_event_output_selection { - DMA_EVENT_OUTPUT_DISABLE = 0, // Disable event generation - DMA_EVENT_OUTPUT_BLOCK, // Event strobe when block xfer complete - DMA_EVENT_OUTPUT_RESERVED, - DMA_EVENT_OUTPUT_BEAT, // Event strobe when beat xfer complete -}; - -enum dma_block_action { - DMA_BLOCK_ACTION_NOACT = 0, - // Channel in normal operation and sets transfer complete interrupt - // flag after block transfer - DMA_BLOCK_ACTION_INT, - // Trigger channel suspend after block transfer and sets channel - // suspend interrupt flag once the channel is suspended - DMA_BLOCK_ACTION_SUSPEND, - // Sets transfer complete interrupt flag after a block transfer and - // trigger channel suspend. The channel suspend interrupt flag will - // be set once the channel is suspended. - DMA_BLOCK_ACTION_BOTH, -}; - -// DMA step selection. This bit determines whether the step size setting -// is applied to source or destination address. -enum dma_step_selection { - DMA_STEPSEL_DST = 0, - DMA_STEPSEL_SRC, -}; - -// Address increment step size. These bits select the address increment step -// size. The setting apply to source or destination address, depending on -// STEPSEL setting. -enum dma_address_increment_stepsize { - DMA_ADDRESS_INCREMENT_STEP_SIZE_1 = 0, // beat size * 1 - DMA_ADDRESS_INCREMENT_STEP_SIZE_2, // beat size * 2 - DMA_ADDRESS_INCREMENT_STEP_SIZE_4, // beat size * 4 - DMA_ADDRESS_INCREMENT_STEP_SIZE_8, // etc... - DMA_ADDRESS_INCREMENT_STEP_SIZE_16, - DMA_ADDRESS_INCREMENT_STEP_SIZE_32, - DMA_ADDRESS_INCREMENT_STEP_SIZE_64, - DMA_ADDRESS_INCREMENT_STEP_SIZE_128, -}; - -// higher numbers are higher priority -enum dma_priority { - DMA_PRIORITY_0, // lowest (default) - DMA_PRIORITY_1, - DMA_PRIORITY_2, - DMA_PRIORITY_3, // highest -}; - -#ifdef __cplusplus -} -#endif - -#endif // DMA_H_INCLUDED diff --git a/libraries/CI_Tests/examples/test_cmsis_fast_rfft.ino b/libraries/CI_Tests/examples/test_cmsis_fast_rfft/test_cmsis_fast_rfft.ino similarity index 100% rename from libraries/CI_Tests/examples/test_cmsis_fast_rfft.ino rename to libraries/CI_Tests/examples/test_cmsis_fast_rfft/test_cmsis_fast_rfft.ino diff --git a/libraries/I2S/src/I2S.cpp b/libraries/I2S/src/I2S.cpp index 4c8ab68e8..00837e202 100644 --- a/libraries/I2S/src/I2S.cpp +++ b/libraries/I2S/src/I2S.cpp @@ -37,6 +37,12 @@ static I2SDevice_SAMD21G18x i2sd(*I2S); #include "I2S.h" +#ifdef USE_TINYUSB +// For Serial when selecting TinyUSB +#include +#endif + + int I2SClass::_beginCount = 0; I2SClass::I2SClass(uint8_t deviceIndex, uint8_t clockGenerator, uint8_t sdPin, uint8_t sckPin, uint8_t fsPin) : diff --git a/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp b/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp index a83f7f050..e39ab43e3 100644 --- a/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp +++ b/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp @@ -19,6 +19,11 @@ #include "SAMD_AnalogCorrection.h" +#ifdef USE_TINYUSB +// For Serial when selecting TinyUSB +#include +#endif + void analogReadCorrection (int offset, uint16_t gain) { Adc *adc; diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp index 48ae32c95..0393752d7 100644 --- a/libraries/SPI/SPI.cpp +++ b/libraries/SPI/SPI.cpp @@ -22,6 +22,11 @@ #include #include +#ifdef USE_TINYUSB +// For Serial when selecting TinyUSB +#include +#endif + #define SPI_IMODE_NONE 0 #define SPI_IMODE_EXTINT 1 #define SPI_IMODE_GLOBAL 2 @@ -46,7 +51,16 @@ SPIClass::SPIClass(SERCOM *p_sercom, uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint void SPIClass::begin() { - init(); + if(!initialized) { + interruptMode = SPI_IMODE_NONE; + interruptSave = 0; + interruptMask = 0; + initialized = true; + } + + if(!use_dma) { + dmaAllocate(); + } // PIO init pinPeripheral(_uc_pinMiso, g_APinDescription[_uc_pinMiso].ulPinType); @@ -56,16 +70,6 @@ void SPIClass::begin() config(DEFAULT_SPI_SETTINGS); } -void SPIClass::init() -{ - if (initialized) - return; - interruptMode = SPI_IMODE_NONE; - interruptSave = 0; - interruptMask = 0; - initialized = true; -} - void SPIClass::config(SPISettings settings) { _p_sercom->disableSPI(); @@ -80,6 +84,7 @@ void SPIClass::end() { _p_sercom->resetSPI(); initialized = false; + // Add DMA deallocation here } #ifndef interruptsStatus @@ -235,157 +240,239 @@ void SPIClass::transfer(void *buf, size_t count) } } -// Pointer to SPIClass object, one per DMA channel. +// DMA-based SPI transfer() function --------------------------------------- + +// IMPORTANT: references to 65535 throughout the DMA code are INTENTIONAL. +// DO NOT try to 'fix' by changing to 65536, or large transfers will fail! +// The BTCNT value of a DMA descriptor is an unsigned 16-bit value with a +// max of 65535. Larger transfers are handled by linked descriptors. + +// Pointer to SPIClass object, one per DMA channel. This allows the +// DMA callback (which has to exist outside the class context) to have +// a reference back to the originating SPIClass object. static SPIClass *spiPtr[DMAC_CH_NUM] = { 0 }; // Legit inits list to NULL void SPIClass::dmaCallback(Adafruit_ZeroDMA *dma) { // dmaCallback() receives an Adafruit_ZeroDMA object. From this we can get // a channel number (0 to DMAC_CH_NUM-1, always unique per ZeroDMA object), // then locate the originating SPIClass object using array lookup, setting - // the dma_busy element 'false' to indicate end of transfer. + // the dma_busy element 'false' to indicate end of transfer. Doesn't matter + // if it's a read or write transfer...both channels get pointers to it. spiPtr[dma->getChannel()]->dma_busy = false; } -void SPIClass::transfer(const void* txbuf, void* rxbuf, size_t count, +// For read-only and read+write transfers, a callback is assigned only +// to the read channel to indicate end-of-transfer, and the write channel's +// callback is assigned to this nonsense function (for reasons I'm not +// entirely sure of, setting the callback to NULL doesn't work). +static void dmaDoNothingCallback(Adafruit_ZeroDMA *dma) { (void)dma; } + +// This could've gone in begin(), but for the sake of organization... +void SPIClass::dmaAllocate(void) { + // In order to support fully non-blocking SPI transfers, DMA descriptor + // lists must be created for the input and/or output data. Rather than + // do this dynamically with every transfer, the lists are allocated once + // on SPI init. Maximum list size is finite and knowable -- transfers to + // or from RAM or from flash memory will never exceed the corresponding + // memory size (if they do, you have bigger problems). Descriptors + // aren't large and there's usually only a handful to a dozen, so this + // isn't an excessive burden in exchange for big non-blocking transfers. + uint32_t maxWriteBytes = FLASH_SIZE; // Writes can't exceed all of flash +#if defined(__SAMD51__) + uint32_t maxReadBytes = HSRAM_SIZE; // Reads can't exceed all of RAM +#else + uint32_t maxReadBytes = HMCRAMC0_SIZE; +#endif + if(maxReadBytes > maxWriteBytes) { // I don't think any SAMD devices + maxWriteBytes = maxReadBytes; // have RAM > flash, but just in case + } + + // VITAL to alloc read channel first, assigns it a higher DMA priority! + if(readChannel.allocate() == DMA_STATUS_OK) { + if(writeChannel.allocate() == DMA_STATUS_OK) { + + // Both DMA channels (read and write) allocated successfully, + // set up transfer triggers and other basics... + + // readChannel callback only needs to be set up once. + // Unlike the write callback which may get switched on or off, + // read callback stays put. In certain cases the read DMA job + // just isn't started and the callback is a non-issue then. + readChannel.setTrigger(getDMAC_ID_RX()); + readChannel.setAction(DMA_TRIGGER_ACTON_BEAT); + readChannel.setCallback(dmaCallback); + spiPtr[readChannel.getChannel()] = this; + + writeChannel.setTrigger(getDMAC_ID_TX()); + writeChannel.setAction(DMA_TRIGGER_ACTON_BEAT); + spiPtr[writeChannel.getChannel()] = this; + + // One descriptor per channel has already been allocated + // in Adafruit_ZeroDMA, this just gets pointers to them... + firstReadDescriptor = readChannel.addDescriptor( + (void *)getDataRegister(), // Source address (SPI data reg) + NULL, // Dest address (set later) + 0, // Count (set later) + DMA_BEAT_SIZE_BYTE, // Bytes/hwords/words + false, // Don't increment source address + true); // Increment dest address + firstWriteDescriptor = writeChannel.addDescriptor( + NULL, // Source address (set later) + (void *)getDataRegister(), // Dest (SPI data register) + 0, // Count (set later) + DMA_BEAT_SIZE_BYTE, // Bytes/hwords/words + true, // Increment source address + false); // Don't increment dest address + // This is the number of EXTRA descriptors beyond the first. + int numReadDescriptors = ((maxReadBytes + 65534) / 65535) - 1; + int numWriteDescriptors = ((maxWriteBytes + 65534) / 65535) - 1; + int totalDescriptors = numReadDescriptors + numWriteDescriptors; + + if(totalDescriptors <= 0) { // Don't need extra descriptors, + use_dma = true; // channels are allocated, we're good. + } else { // Else allocate extra descriptor lists... + // Although DMA descriptors are technically a linked list, we just + // allocate a chunk all at once, and finesse the pointers later. + if((extraReadDescriptors = (DmacDescriptor *)malloc( + totalDescriptors * sizeof(DmacDescriptor)))) { + use_dma = true; // Everything allocated successfully + extraWriteDescriptors = &extraReadDescriptors[numReadDescriptors]; + + // Initialize descriptors (copy from first ones) + // cast to void* to suppress warning: with no trivial copy-assignment [-Wclass-memaccess] + for(int i=0; i= DMAC_CH_NUM)) { - if(readChannel.allocate() == DMA_STATUS_OK) { - readDescriptor = - readChannel.addDescriptor( - (void *)getDataRegister(), // Source address (SPI data reg) - NULL, // Dest address (set later) - 0, // Count (set later) - DMA_BEAT_SIZE_BYTE, // Bytes/hwords/words - false, // Don't increment source address - true); // Increment dest address - readChannel.setTrigger(getDMAC_ID_RX()); - readChannel.setAction(DMA_TRIGGER_ACTON_BEAT); - spiPtr[readChannel.getChannel()] = this; - // Since all RX transfers involve a TX, a - // separate callback here is not necessary. - } + if((!txbuf && !rxbuf) || !count) { // Validate inputs + return; + } + // OK to assume now that txbuf and/or rxbuf are non-NULL, an if/else is + // often sufficient, don't need else-ifs for everything buffer related. + + uint8_t *txbuf8 = (uint8_t *)txbuf; // Must cast to byte size + uint8_t *rxbuf8 = (uint8_t *)rxbuf; // for pointer math + + if(use_dma) { // DMA-BASED TRANSFER YAY ---------------------------------- + + static const uint8_t dum = 0xFF; // Dummy byte for read-only xfers + + // Set up DMA descriptor lists ----------------------------------------- + + DmacDescriptor *rDesc = firstReadDescriptor; + DmacDescriptor *wDesc = firstWriteDescriptor; + int descIdx = 0; // Index into extra descriptor lists + + while(count) { // Counts down to end of transfer + uint32_t bytesThisDescriptor = count; + if(bytesThisDescriptor > 65535) { // Limit each descriptor + bytesThisDescriptor = 65535; // to 65535 (not 65536) bytes + } + rDesc->BTCNT.reg = wDesc->BTCNT.reg = bytesThisDescriptor; + if(rxbuf) { // Read-only or read+write + // Auto-inc addresses in DMA descriptors must point to END of data. + // Buf pointers would advance at end of loop anyway, do it now... + rxbuf8 += bytesThisDescriptor; + rDesc->DSTADDR.reg = (uint32_t)rxbuf8; + } + if(txbuf) { // Write-only or read+write + txbuf8 += bytesThisDescriptor; // Same as above + wDesc->SRCADDR.reg = (uint32_t)txbuf8; + wDesc->BTCTRL.bit.SRCINC = 1; // Increment source pointer + } else { // Read-only requires dummy write + wDesc->SRCADDR.reg = (uint32_t)&dum; + wDesc->BTCTRL.bit.SRCINC = 0; // Don't increment source pointer + } + count -= bytesThisDescriptor; + if(count) { // Still more data? + // Link to next descriptors. Extra descriptors are IN ADDITION + // to first, so it's safe and correct that descIdx starts at 0. + rDesc->DESCADDR.reg = (uint32_t)&extraReadDescriptors[descIdx]; + wDesc->DESCADDR.reg = (uint32_t)&extraWriteDescriptors[descIdx]; + rDesc = &extraReadDescriptors[descIdx]; // Update pointers to + wDesc = &extraWriteDescriptors[descIdx]; // next descriptors + descIdx++; + // A write-only transfer doesn't use the read descriptor list, but + // it's quicker to build it (full of nonsense) anyway than to check. + } else { // No more data, end descriptor linked lists + rDesc->DESCADDR.reg = wDesc->DESCADDR.reg = 0; + } } - // Unlike the rxbuf check above, where a RX DMA channel is allocated - // only if receiving data (and channel not previously alloc'd), the - // TX DMA channel is always needed, because even RX-only SPI requires - // writing dummy bytes to the peripheral. - if(writeChannel.getChannel() >= DMAC_CH_NUM) { - if(writeChannel.allocate() == DMA_STATUS_OK) { - writeDescriptor = - writeChannel.addDescriptor( - NULL, // Source address (set later) - (void *)getDataRegister(), // Dest (SPI data register) - 0, // Count (set later) - DMA_BEAT_SIZE_BYTE, // Bytes/hwords/words - true, // Increment source address - false); // Don't increment dest address - writeChannel.setTrigger(getDMAC_ID_TX()); - writeChannel.setAction(DMA_TRIGGER_ACTON_BEAT); - writeChannel.setCallback(dmaCallback); - spiPtr[writeChannel.getChannel()] = this; - } + // Set up DMA transfer job(s) ------------------------------------------ + + if(rxbuf) { // Read+write or read-only + // End-of-read callback is already set up, disable write CB, start job + writeChannel.setCallback(dmaDoNothingCallback); + readChannel.startJob(); + } else { // Write-only, use end-of-write callback + writeChannel.setCallback(dmaCallback); } - if(writeDescriptor && (readDescriptor || !rxbuf)) { - static const uint8_t dum = 0xFF; // Dummy byte for read-only xfers - - // Initialize read descriptor dest address to rxbuf - if(rxbuf) readDescriptor->DSTADDR.reg = (uint32_t)rxbuf; - - // If reading only, set up writeDescriptor to issue dummy bytes - // (set SRCADDR to &dum and SRCINC to 0). Otherwise, set SRCADDR - // to txbuf and SRCINC to 1. Only needed once at start. - if(rxbuf && !txbuf) { - writeDescriptor->SRCADDR.reg = (uint32_t)&dum; - writeDescriptor->BTCTRL.bit.SRCINC = 0; - } else { - writeDescriptor->SRCADDR.reg = (uint32_t)txbuf; - writeDescriptor->BTCTRL.bit.SRCINC = 1; - } + // Run DMA jobs, blocking if requested --------------------------------- + + dma_busy = true; + writeChannel.startJob(); // All xfers, even read-only, need write job. + if(block) { // If blocking transfer requested, + while(dma_busy); // wait for job to finish + } + + } else { // NON-DMA FALLBACK --------------------------------------------- - while(count > 0) { - // Maximum bytes per DMA descriptor is 65,535 (NOT 65,536). - // We could set up a descriptor chain, but that gets more - // complex. For now, instead, break up long transfers into - // chunks of 65,535 bytes max...these transfers are all - // blocking, regardless of the "block" argument, except - // for the last one which will observe the background request. - // The fractional part is done first, so for any "partially - // blocking" transfers like these at least it's the largest - // single-descriptor transfer possible that occurs in the - // background, rather than the tail end. - int bytesThisPass; - bool blockThisPass; - if(count > 65535) { // Too big for 1 descriptor - blockThisPass = true; - bytesThisPass = count % 65535; // Fractional part - if(!bytesThisPass) bytesThisPass = 65535; - } else { - blockThisPass = block; - bytesThisPass = count; - } - - // Issue 'bytesThisPass' bytes... - if(rxbuf) { - // Reading, or reading + writing. - // Set up read descriptor. - // Src address doesn't change, only dest & count. - // DMA needs address set to END of buffer, so - // increment the address now, before the transfer. - readDescriptor->DSTADDR.reg += bytesThisPass; - readDescriptor->BTCNT.reg = bytesThisPass; - // Start the RX job BEFORE the TX job! - // That's the whole secret sauce to the two-channel transfer. - // Nothing will actually happen until the write channel job - // is also started. - readChannel.startJob(); - } - if(txbuf) { - // DMA needs address set to END of buffer, so - // increment the address now, before the transfer. - writeDescriptor->SRCADDR.reg += bytesThisPass; - } - writeDescriptor->BTCNT.reg = bytesThisPass; - dma_busy = true; - writeChannel.startJob(); - count -= bytesThisPass; - if(blockThisPass) { - while(dma_busy); - } + if(txbuf8) { + if(rxbuf8) { // Write + read simultaneously + while(count--) { + *rxbuf8++ = _p_sercom->transferDataSPI(*txbuf8++); } - } else { - // Non-DMA fallback. - uint8_t *txbuf8 = (uint8_t *)txbuf, - *rxbuf8 = (uint8_t *)rxbuf; - if(rxbuf8) { - if(txbuf8) { - // Writing and reading simultaneously - while(count--) { - *rxbuf8++ = _p_sercom->transferDataSPI(*txbuf8++); - } - } else { - // Reading only - while(count--) { - *rxbuf8++ = _p_sercom->transferDataSPI(0xFF); - } - } - } else if(txbuf) { - // Writing only - while(count--) { - (void)_p_sercom->transferDataSPI(*txbuf8++); - } + } else { // Write only + while(count--) { + (void)_p_sercom->transferDataSPI(*txbuf8++); } + } + } else { // Read only + while(count--) { + *rxbuf8++ = _p_sercom->transferDataSPI(0xFF); + } } + + } // end non-DMA } // Waits for a prior in-background DMA transfer to complete. void SPIClass::waitForTransfer(void) { - while(dma_busy); + while(dma_busy); +} + +/* returns the current DMA transfer status to allow non-blocking polling */ +bool SPIClass::isBusy(void) { + return dma_busy; } + +// End DMA-based SPI transfer() code --------------------------------------- + void SPIClass::attachInterrupt() { // Should be enableInterrupt() } @@ -481,4 +568,3 @@ void SPIClass::setClockSource(SercomClockSource clk) { #if SPI_INTERFACES_COUNT > 5 SPIClass SPI5(&PERIPH_SPI5, PIN_SPI5_MISO, PIN_SPI5_SCK, PIN_SPI5_MOSI, PAD_SPI5_TX, PAD_SPI5_RX); #endif - diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h index 48c3cb7b0..7c719f695 100644 --- a/libraries/SPI/SPI.h +++ b/libraries/SPI/SPI.h @@ -120,6 +120,7 @@ class SPIClass { void transfer(const void* txbuf, void* rxbuf, size_t count, bool block = true); void waitForTransfer(void); + bool isBusy(void); // Transaction Functions void usingInterrupt(int interruptNumber); @@ -149,11 +150,10 @@ class SPIClass { #else // On SAMD21, this compiles to nothing, so user code doesn't need to // check and conditionally compile lines for different architectures. - void setClockSource(__attribute__((unused)) SercomClockSource clk) { }; + void setClockSource(SercomClockSource clk) { (void)clk; }; #endif // end __SAMD51__ private: - void init(); void config(SPISettings settings); SERCOM *_p_sercom; @@ -169,12 +169,16 @@ class SPIClass { char interruptSave; uint32_t interruptMask; - // transfer(txbuf, rxbuf, count, block) uses DMA if possible - Adafruit_ZeroDMA readChannel, - writeChannel; - DmacDescriptor *readDescriptor = NULL, - *writeDescriptor = NULL; - volatile bool dma_busy = false; + // transfer(txbuf, rxbuf, count, block) uses DMA when possible + Adafruit_ZeroDMA readChannel; + Adafruit_ZeroDMA writeChannel; + DmacDescriptor *firstReadDescriptor = NULL; // List entry point + DmacDescriptor *firstWriteDescriptor = NULL; + DmacDescriptor *extraReadDescriptors = NULL; // Add'l descriptors + DmacDescriptor *extraWriteDescriptors = NULL; + bool use_dma = false; // true on successful alloc + volatile bool dma_busy = false; + void dmaAllocate(void); static void dmaCallback(Adafruit_ZeroDMA *dma); }; diff --git a/libraries/Servo/src/samd/Servo.cpp b/libraries/Servo/src/samd/Servo.cpp index 7030a57ac..ba07e70a7 100644 --- a/libraries/Servo/src/samd/Servo.cpp +++ b/libraries/Servo/src/samd/Servo.cpp @@ -21,6 +21,11 @@ #include #include +#ifdef USE_TINYUSB +// For Serial when selecting TinyUSB +#include +#endif + #if defined(__SAMD51__) // Different prescalers depending on FCPU (avoid overflowing 16-bit counter) #if(F_CPU > 200000000) @@ -174,6 +179,7 @@ static inline void resetTC (Tc* TCx) static void _initISR(Tc *tc, uint8_t channel, uint32_t id, IRQn_Type irqn, uint8_t gcmForTimer, uint8_t intEnableBit) { + (void)id; // Select GCLK0 as timer/counter input clock source #if defined(__SAMD51__) int idx = gcmForTimer; // see datasheet Table 14-9 @@ -265,6 +271,7 @@ static void initISR(timer16_Sequence_t timer) static void finISR(timer16_Sequence_t timer) { + (void)timer; #if defined (_useTimer1) // Disable the match channel interrupt request TC_FOR_TIMER1->COUNT16.INTENCLR.reg = INTENCLR_BIT_FOR_TIMER_1; diff --git a/libraries/Servo/src/samd/ServoTimers.h b/libraries/Servo/src/samd/ServoTimers.h index 81d87b4c3..c4da50694 100644 --- a/libraries/Servo/src/samd/ServoTimers.h +++ b/libraries/Servo/src/samd/ServoTimers.h @@ -38,50 +38,52 @@ // to manage more than one channel per timer on the SAMD architecture #if defined(__SAMD51__) - #if defined (_useTimer1) - #define TC_FOR_TIMER1 TC0 - #define CHANNEL_FOR_TIMER1 0 - #define INTENSET_BIT_FOR_TIMER_1 TC_INTENSET_MC0 - #define INTENCLR_BIT_FOR_TIMER_1 TC_INTENCLR_MC0 - #define INTFLAG_BIT_FOR_TIMER_1 TC_INTFLAG_MC0 - #define ID_TC_FOR_TIMER1 ID_TC0 - #define IRQn_FOR_TIMER1 TC0_IRQn - #define HANDLER_FOR_TIMER1 TC0_Handler - #define GCM_FOR_TIMER_1 9 // GCLK_TC0 - #endif - #if defined (_useTimer2) - #define TC_FOR_TIMER2 TC0 - #define CHANNEL_FOR_TIMER2 1 - #define INTENSET_BIT_FOR_TIMER_2 TC_INTENSET_MC1 - #define INTENCLR_BIT_FOR_TIMER_2 TC_INTENCLR_MC1 - #define INTFLAG_BIT_FOR_TIMER_2 TC_INTFLAG_MC1 - #define ID_TC_FOR_TIMER2 ID_TC0 - #define IRQn_FOR_TIMER2 TC0_IRQn - #define HANDLER_FOR_TIMER2 TC0_Handler - #define GCM_FOR_TIMER_2 9 // GCLK_TC0 - #endif + #if defined (_useTimer1) + #define TC_FOR_TIMER1 TC1 + #define CHANNEL_FOR_TIMER1 0 + #define INTENSET_BIT_FOR_TIMER_1 TC_INTENSET_MC0 + #define INTENCLR_BIT_FOR_TIMER_1 TC_INTENCLR_MC0 + #define INTFLAG_BIT_FOR_TIMER_1 TC_INTFLAG_MC0 + #define ID_TC_FOR_TIMER1 ID_TC1 + #define IRQn_FOR_TIMER1 TC1_IRQn + #define HANDLER_FOR_TIMER1 TC1_Handler + #define GCM_FOR_TIMER_1 TC1_GCLK_ID + #endif + + #if defined (_useTimer2) + #define TC_FOR_TIMER2 TC1 + #define CHANNEL_FOR_TIMER2 1 + #define INTENSET_BIT_FOR_TIMER_2 TC_INTENSET_MC1 + #define INTENCLR_BIT_FOR_TIMER_2 TC_INTENCLR_MC1 + #define INTFLAG_BIT_FOR_TIMER_2 TC_INTFLAG_MC1 + #define ID_TC_FOR_TIMER2 ID_TC1 + #define IRQn_FOR_TIMER2 TC1_IRQn + #define HANDLER_FOR_TIMER2 TC1_Handler + #define GCM_FOR_TIMER_2 TC1_GCLK_ID + #endif #else - #if defined (_useTimer1) - #define TC_FOR_TIMER1 TC4 - #define CHANNEL_FOR_TIMER1 0 - #define INTENSET_BIT_FOR_TIMER_1 TC_INTENSET_MC0 - #define INTENCLR_BIT_FOR_TIMER_1 TC_INTENCLR_MC0 - #define INTFLAG_BIT_FOR_TIMER_1 TC_INTFLAG_MC0 - #define ID_TC_FOR_TIMER1 ID_TC4 - #define IRQn_FOR_TIMER1 TC4_IRQn - #define HANDLER_FOR_TIMER1 TC4_Handler - #define GCM_FOR_TIMER_1 GCM_TC4_TC5 - #endif - #if defined (_useTimer2) - #define TC_FOR_TIMER2 TC4 - #define CHANNEL_FOR_TIMER2 1 - #define INTENSET_BIT_FOR_TIMER_2 TC_INTENSET_MC1 - #define INTENCLR_BIT_FOR_TIMER_2 TC_INTENCLR_MC1 - #define ID_TC_FOR_TIMER2 ID_TC4 - #define IRQn_FOR_TIMER2 TC4_IRQn - #define HANDLER_FOR_TIMER2 TC4_Handler - #define GCM_FOR_TIMER_2 GCM_TC4_TC5 - #endif + #if defined (_useTimer1) + #define TC_FOR_TIMER1 TC4 + #define CHANNEL_FOR_TIMER1 0 + #define INTENSET_BIT_FOR_TIMER_1 TC_INTENSET_MC0 + #define INTENCLR_BIT_FOR_TIMER_1 TC_INTENCLR_MC0 + #define INTFLAG_BIT_FOR_TIMER_1 TC_INTFLAG_MC0 + #define ID_TC_FOR_TIMER1 ID_TC4 + #define IRQn_FOR_TIMER1 TC4_IRQn + #define HANDLER_FOR_TIMER1 TC4_Handler + #define GCM_FOR_TIMER_1 GCM_TC4_TC5 + #endif + + #if defined (_useTimer2) + #define TC_FOR_TIMER2 TC4 + #define CHANNEL_FOR_TIMER2 1 + #define INTENSET_BIT_FOR_TIMER_2 TC_INTENSET_MC1 + #define INTENCLR_BIT_FOR_TIMER_2 TC_INTENCLR_MC1 + #define ID_TC_FOR_TIMER2 ID_TC4 + #define IRQn_FOR_TIMER2 TC4_IRQn + #define HANDLER_FOR_TIMER2 TC4_Handler + #define GCM_FOR_TIMER_2 GCM_TC4_TC5 + #endif #endif typedef enum { diff --git a/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino b/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino index ea7509cbc..21d6ef522 100644 --- a/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino +++ b/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino @@ -37,7 +37,7 @@ void setup(void) while (!SERIAL_PORT_MONITOR); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection SERIAL_PORT_MONITOR.println("\r\nADK demo start"); - if (usb.Init() == -1) + if (usb.Init() == (uint32_t)-1) SERIAL_PORT_MONITOR.println("OSC did not start."); delay(20); diff --git a/libraries/USBHost/examples/KeyboardController/KeyboardController.ino b/libraries/USBHost/examples/KeyboardController/KeyboardController.ino index 126bd4754..0daf7b02d 100644 --- a/libraries/USBHost/examples/KeyboardController/KeyboardController.ino +++ b/libraries/USBHost/examples/KeyboardController/KeyboardController.ino @@ -83,8 +83,7 @@ void setup() { SerialDebug.begin( 115200 ); SerialDebug.println("USB Host Keyboard Controller Program started"); - - if (usb.Init() == -1) + if (usb.Init() == (uint32_t)-1) SerialDebug.println("USB Host did not start."); SerialDebug.println("USB Host started"); diff --git a/libraries/USBHost/examples/MouseController/MouseController.ino b/libraries/USBHost/examples/MouseController/MouseController.ino index a7d7d6cba..90e6dce2b 100644 --- a/libraries/USBHost/examples/MouseController/MouseController.ino +++ b/libraries/USBHost/examples/MouseController/MouseController.ino @@ -91,7 +91,7 @@ void setup() SerialDebug.begin( 115200 ); SerialDebug.println("USB Host Mouse Controller Program started"); - if (usb.Init() == -1) + if (usb.Init() == (uint32_t)-1) SerialDebug.println("USB Host did not start."); SerialDebug.println("USB Host started"); diff --git a/libraries/USBHost/examples/USB_desc/USB_desc.ino b/libraries/USBHost/examples/USB_desc/USB_desc.ino index dc7b1569f..2af42b172 100644 --- a/libraries/USBHost/examples/USB_desc/USB_desc.ino +++ b/libraries/USBHost/examples/USB_desc/USB_desc.ino @@ -59,8 +59,8 @@ void setup() SerialDebug.println("Starting USB Descriptor test"); SerialDebug.println("Initializing USB"); - if (usb.Init() == -1) - SerialDebug.println("USBhost did not start."); + if (usb.Init() == (uint32_t)-1) + SerialDebug.println("USBhost did not start."); delay( 20 ); @@ -161,6 +161,7 @@ byte getdevdescr( byte addr, byte &num_conf ) void printhubdescr(uint8_t *descrptr, uint8_t addr) { + (void)addr; HubDescriptor *pHub = (HubDescriptor*) descrptr; uint8_t len = *((uint8_t*)descrptr); @@ -209,18 +210,22 @@ byte getconfdescr( byte addr, byte conf ) { uint8_t buf[ BUFSIZE ]; uint8_t* buf_ptr = buf; - byte rcode; + byte rcode; // FIXME -- code does not actually check return code (no error handling!) byte descr_length; byte descr_type; uint16_t total_length; + // FIXME -- no check of return code from usb.getConfDescr() rcode = usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length + (void) rcode; LOBYTE( total_length ) = buf[ 2 ]; HIBYTE( total_length ) = buf[ 3 ]; if( total_length > sizeof(buf)) { //check if total length is larger than buffer printProgStr(Conf_Trunc_str); total_length = sizeof(buf); } + // FIXME -- no check of return code from usb.getConfDescr() rcode = usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor + (void) rcode; while( buf_ptr < buf + total_length ) { //parsing descriptors descr_length = *( buf_ptr ); descr_type = *( buf_ptr + 1 ); diff --git a/libraries/USBHost/src/confdescparser.h b/libraries/USBHost/src/confdescparser.h index 4b2b41b4f..de69e2ccd 100644 --- a/libraries/USBHost/src/confdescparser.h +++ b/libraries/USBHost/src/confdescparser.h @@ -59,15 +59,15 @@ class ConfigDescParser : public USBReadParser { uint32_t ifaceNumber; // Interface number uint32_t ifaceAltSet; // Interface alternate settings - bool UseOr; + bool UseOr; bool ParseDescriptor(uint8_t **pp, uint32_t *pcntdn); void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); public: - void SetOR(void) { - UseOr = true; - } + void SetOR(void) { + UseOr = true; + } ConfigDescParser(UsbConfigXtracter *xtractor); virtual void Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset); }; @@ -98,8 +98,19 @@ void ConfigDescParser::Parse(const uin compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */ template bool ConfigDescParser::ParseDescriptor(uint8_t **pp, uint32_t *pcntdn) { - USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); - USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); + USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); + USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); + + +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" switch(stateParseDescr) { case 0: theBuffer.valueSize = 2; @@ -112,7 +123,7 @@ bool ConfigDescParser::ParseDescriptor dscrType = *((uint8_t*)theBuffer.pValue + 1); stateParseDescr = 2; case 2: - // This is a sort of hack. Assuming that two bytes are all ready in the buffer + // This is a sort of hack. Assuming that two bytes are all ready in the buffer // the pointer is positioned two bytes ahead in order for the rest of descriptor // to be read right after the size and the type fields. // This should be used carefully. varBuffer should be used directly to handle data @@ -120,14 +131,14 @@ bool ConfigDescParser::ParseDescriptor theBuffer.pValue = varBuffer + 2; stateParseDescr = 3; case 3: - switch(dscrType) { - case USB_DESCRIPTOR_INTERFACE: - isGoodInterface = false; - case USB_DESCRIPTOR_CONFIGURATION: - theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2; - break; - case USB_DESCRIPTOR_ENDPOINT: - theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2; + switch(dscrType) { + case USB_DESCRIPTOR_INTERFACE: + isGoodInterface = false; + case USB_DESCRIPTOR_CONFIGURATION: + theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2; + break; + case USB_DESCRIPTOR_ENDPOINT: + theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2; break; case HID_DESCRIPTOR_HID: theBuffer.valueSize = dscrLen - 2; @@ -136,37 +147,37 @@ bool ConfigDescParser::ParseDescriptor valParser.Initialize(&theBuffer); stateParseDescr = 4; case 4: - switch(dscrType) { + switch(dscrType) { case USB_DESCRIPTOR_CONFIGURATION: - if(!valParser.Parse(pp, pcntdn)) - return false; - confValue = ucd->bConfigurationValue; + if(!valParser.Parse(pp, pcntdn)) + return false; + confValue = ucd->bConfigurationValue; break; case USB_DESCRIPTOR_INTERFACE: - if(!valParser.Parse(pp, pcntdn)) - return false; - if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID) - break; - if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID) - break; - if(UseOr) { - if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol))) - break; - } else { - if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID) - break; - } - isGoodInterface = true; - ifaceNumber = uid->bInterfaceNumber; - ifaceAltSet = uid->bAlternateSetting; - protoValue = uid->bInterfaceProtocol; - break; - case USB_DESCRIPTOR_ENDPOINT: - if(!valParser.Parse(pp, pcntdn)) - return false; - if(isGoodInterface) - if(theXtractor) - theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer); + if(!valParser.Parse(pp, pcntdn)) + return false; + if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID) + break; + if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID) + break; + if(UseOr) { + if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol))) + break; + } else { + if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID) + break; + } + isGoodInterface = true; + ifaceNumber = uid->bInterfaceNumber; + ifaceAltSet = uid->bAlternateSetting; + protoValue = uid->bInterfaceProtocol; + break; + case USB_DESCRIPTOR_ENDPOINT: + if(!valParser.Parse(pp, pcntdn)) + return false; + if(isGoodInterface) + if(theXtractor) + theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer); break; //case HID_DESCRIPTOR_HID: // if (!valParser.Parse(pp, pcntdn)) @@ -180,44 +191,47 @@ bool ConfigDescParser::ParseDescriptor theBuffer.pValue = varBuffer; stateParseDescr = 0; } +#pragma GCC diagnostic pop + return true; } template void ConfigDescParser::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) { - Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); - Notify(PSTR("bDescLength:\t\t"), 0x80); - PrintHex (pDesc->bLength, 0x80); + Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); + Notify(PSTR("bDescLength:\t\t"), 0x80); + PrintHex (pDesc->bLength, 0x80); - Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); - PrintHex (pDesc->bDescriptorType, 0x80); + Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); + PrintHex (pDesc->bDescriptorType, 0x80); - Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); - PrintHex (pDesc->bcdHID, 0x80); + Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); + PrintHex (pDesc->bcdHID, 0x80); - Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); - PrintHex (pDesc->bCountryCode, 0x80); + Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); + PrintHex (pDesc->bCountryCode, 0x80); - Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); - PrintHex (pDesc->bNumDescriptors, 0x80); + Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); + PrintHex (pDesc->bNumDescriptors, 0x80); - //Notify(PSTR("\r\nbDescrType:\t\t")); - //PrintHex(pDesc->bDescrType); - // - //Notify(PSTR("\r\nwDescriptorLength:\t")); - //PrintHex(pDesc->wDescriptorLength); + //Notify(PSTR("\r\nbDescrType:\t\t")); + //PrintHex(pDesc->bDescrType); + // + //Notify(PSTR("\r\nwDescriptorLength:\t")); + //PrintHex(pDesc->wDescriptorLength); for (uint32_t i = 0; i < pDesc->bNumDescriptors; i++) { HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType); - Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); - PrintHex (pLT[i].bDescrType, 0x80); + Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); + PrintHex (pLT[i].bDescrType, 0x80); - Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); - PrintHex (pLT[i].wDescriptorLength, 0x80); - } - Notify(PSTR("\r\n"), 0x80); + Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); + PrintHex (pLT[i].wDescriptorLength, 0x80); + } + Notify(PSTR("\r\n"), 0x80); } + #endif // __CONFDESCPARSER_H__ diff --git a/libraries/USBHost/src/hidescriptorparser.cpp b/libraries/USBHost/src/hidescriptorparser.cpp index 353874300..b137cb8ab 100644 --- a/libraries/USBHost/src/hidescriptorparser.cpp +++ b/libraries/USBHost/src/hidescriptorparser.cpp @@ -994,7 +994,6 @@ void ReportDescParserBase::Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t cntdn = (uint32_t)len; uint8_t *p = (uint8_t*)pbuf; - totalSize = 0; while(cntdn) { @@ -1091,6 +1090,17 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) { uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { //uint8_t ret = enErrorSuccess; //reinterpret_cast<>(varBuffer); + + +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" switch(itemParseState) { case 0: if(**pp == HID_LONG_ITEM_PREFIX) @@ -1207,6 +1217,7 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) { } // switch (**pp & (TYPE_MASK | TAG_MASK)) } } // switch (itemParseState) +#pragma GCC diagnostic pop itemParseState = 0; return enErrorSuccess; } @@ -1236,18 +1247,18 @@ void ReportDescParserBase::SetUsagePage(uint16_t page) { if(VALUE_BETWEEN(page, 0x00, 0x11)) pfUsage = (usagePageFunctions[page - 1]); - // Dead code... - // - // pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]); - //else if (page > 0x7f && page < 0x84) - // E_Notify(pstrUsagePageMonitor); - //else if (page > 0x83 && page < 0x8c) - // E_Notify(pstrUsagePagePower); - //else if (page > 0x8b && page < 0x92) - // E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c])); - //else if (page > 0xfeff && page <= 0xffff) - // E_Notify(pstrUsagePageVendorDefined); - // + // Dead code... + // + // pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]); + //else if (page > 0x7f && page < 0x84) + // E_Notify(pstrUsagePageMonitor); + //else if (page > 0x83 && page < 0x8c) + // E_Notify(pstrUsagePagePower); + //else if (page > 0x8b && page < 0x92) + // E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c])); + //else if (page > 0xfeff && page <= 0xffff) + // E_Notify(pstrUsagePageVendorDefined); + // else switch(page) { case 0x14: @@ -1440,6 +1451,15 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) { uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { //uint8_t ret = enErrorSuccess; +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" switch(itemParseState) { case 0: if(**pp == HID_LONG_ITEM_PREFIX) @@ -1519,6 +1539,8 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) { } // switch (**pp & (TYPE_MASK | TAG_MASK)) } } // switch (itemParseState) +#pragma GCC diagnostic pop + itemParseState = 0; return enErrorSuccess; } @@ -1558,8 +1580,7 @@ void ReportDescParser2::OnInputItem(uint8_t itm) { // bits_to_copy - number of bits to copy to result buffer // for each bit in a field - for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left; - bits_left -= bits_to_copy) { + for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left; bits_left -= bits_to_copy) { bits_to_copy = (bits_left > bits_of_byte) ? bits_of_byte : bits_left; result.dwResult <<= bits_to_copy; // Result buffer is shifted by the number of bits to be copied into it diff --git a/libraries/USBHost/src/parsetools.cpp b/libraries/USBHost/src/parsetools.cpp index 00ca9e642..9867cbc46 100644 --- a/libraries/USBHost/src/parsetools.cpp +++ b/libraries/USBHost/src/parsetools.cpp @@ -17,14 +17,14 @@ e-mail : support@circuitsathome.com #include "Usb.h" bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { - if(!pBuf) { - Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); + if(!pBuf) { + Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); return false; } for (; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++) pBuf[valueSize - countDown] = (**pp); - if(countDown) + if(countDown) return false; countDown = valueSize; @@ -32,36 +32,48 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { } bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { - switch(nStage) { - case 0: - pBuf->valueSize = lenSize; - theParser.Initialize(pBuf); - nStage = 1; - case 1: - if(!theParser.Parse(pp, pcntdn)) - return false; +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" - arLen = 0; - arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); - arLenCntdn = arLen; - nStage = 2; + switch(nStage) { + case 0: + pBuf->valueSize = lenSize; + theParser.Initialize(pBuf); + nStage = 1; - case 2: - pBuf->valueSize = valSize; - theParser.Initialize(pBuf); - nStage = 3; - - case 3: - for(; arLenCntdn; arLenCntdn--) { + case 1: if(!theParser.Parse(pp, pcntdn)) return false; + arLen = 0; + arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); + arLenCntdn = arLen; + nStage = 2; + + case 2: + pBuf->valueSize = valSize; + theParser.Initialize(pBuf); + nStage = 3; + + case 3: + for(; arLenCntdn; arLenCntdn--) { + if(!theParser.Parse(pp, pcntdn)) + return false; + if(pf) pf(pBuf, (arLen - arLenCntdn), me); } - nStage = 0; } +#pragma GCC diagnostic pop + return true; } diff --git a/libraries/USBHost/src/parsetools.h b/libraries/USBHost/src/parsetools.h index d46335891..947ba02dc 100644 --- a/libraries/USBHost/src/parsetools.h +++ b/libraries/USBHost/src/parsetools.h @@ -35,12 +35,12 @@ class MultiByteValueParser { public: - MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) { - }; + MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) { + }; - const uint8_t* GetBuffer() { - return pBuf; - }; + const uint8_t* GetBuffer() { + return pBuf; + }; void Initialize(MultiValueBuffer * const pbuf) { pBuf = (uint8_t*)pbuf->pValue; @@ -58,7 +58,7 @@ class ByteSkipper { public: ByteSkipper() : pBuf(NULL), nStage(0), countDown(0) { - }; + }; void Initialize(MultiValueBuffer *pbuf) { pBuf = (uint8_t*)pbuf->pValue; @@ -66,16 +66,25 @@ class ByteSkipper { }; bool Skip(uint8_t **pp, uint32_t *pcntdn, uint32_t bytes_to_skip) { - switch(nStage) { - case 0: - countDown = bytes_to_skip; - nStage++; - case 1: - for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--); - - if(!countDown) - nStage = 0; +#pragma GCC diagnostic push // Available since GCC 4.6.4 +/* + * FIXME -- Enabled and review all `-Wimplicit-fallthrough` messages + * This code has multiple switch statements that "fall through" to the + * next case -- but it's not always clear if this is intentional or not. + * Review and commenting of code, and reducing cyclomatic complexity + * are highly recommended.... + */ +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + switch(nStage) { + case 0: + countDown = bytes_to_skip; + nStage++; + case 1: + for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--); + if(!countDown) + nStage = 0; }; +#pragma GCC diagnostic pop return (!countDown); }; }; @@ -86,9 +95,9 @@ typedef void (*PTP_ARRAY_EL_FUNC)(const MultiValueBuffer * const p, uint32_t cou class PTPListParser { public: - enum ParseMode { - modeArray, modeRange/*, modeEnum*/ - }; + enum ParseMode { + modeArray, modeRange/*, modeEnum*/ + }; private: uint32_t nStage; diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index ec3634133..da9732c59 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -24,6 +24,11 @@ extern "C" { #include #include +#ifdef USE_TINYUSB +// For Serial when selecting TinyUSB +#include +#endif + #include "Wire.h" TwoWire::TwoWire(SERCOM * s, uint8_t pinSDA, uint8_t pinSCL) diff --git a/libraries/Wire/examples/slave_receiver/slave_receiver.ino b/libraries/Wire/examples/slave_receiver/slave_receiver.ino index 60dd4bdde..a3103f8b9 100644 --- a/libraries/Wire/examples/slave_receiver/slave_receiver.ino +++ b/libraries/Wire/examples/slave_receiver/slave_receiver.ino @@ -28,6 +28,8 @@ void loop() // this function is registered as an event, see setup() void receiveEvent(int howMany) { + (void)howMany; // avoid compiler warning about unused parameter + while(1 < Wire.available()) // loop through all but the last { char c = Wire.read(); // receive byte as a character diff --git a/platform.txt b/platform.txt index 13d2ce5ab..747b7e16e 100644 --- a/platform.txt +++ b/platform.txt @@ -17,21 +17,21 @@ # Arduino SAMD Core and platform. # # For more info: -# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification +# https://arduino.github.io/arduino-cli/0.33/platform-specification/ name=Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards -version=1.5.14 +version=1.7.16 # Compile variables # ----------------- -compiler.warning_flags=-w -compiler.warning_flags.none=-w -compiler.warning_flags.default= -compiler.warning_flags.more=-Wall -Wno-expansion-to-defined -compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined +compiler.warning_flags=-Werror=return-type +compiler.warning_flags.none=-Werror=return-type +compiler.warning_flags.default=-Werror=return-type +compiler.warning_flags.more=-Wall -Werror=return-type -Wno-expansion-to-defined +compiler.warning_flags.all=-Wall -Wextra -Werror=return-type -Wno-expansion-to-defined -compiler.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ +compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ compiler.c.cmd=arm-none-eabi-gcc compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -D__SKETCH_NAME__="""{build.project_name}""" compiler.c.elf.cmd=arm-none-eabi-g++ @@ -70,14 +70,14 @@ compiler.S.extra_flags= compiler.ar.extra_flags= compiler.elf2hex.extra_flags= -compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.0.path}/CMSIS/Device/ATMEL/" -compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math +compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Core/Include/" "-I{runtime.tools.CMSIS-5.4.0.path}/CMSIS/DSP/Include/" "-I{runtime.tools.CMSIS-Atmel-1.2.2.path}/CMSIS/Device/ATMEL/" +compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-5.4.0.path}/CMSIS/Lib/GCC/" -larm_cortexM0l_math compiler.libraries.ldflags= # USB Flags # --------- -build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON -DUSB_CONFIG_POWER={build.usb_power} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' {build.flags.usbstack} {build.flags.debug} "-I{runtime.platform.path}/libraries/Adafruit_TinyUSB_Arduino/src/arduino" # Default advertised device power setting in mA build.usb_power=100 @@ -91,13 +91,13 @@ build.usb_manufacturer="Unknown" # ---------------- ## Compile c files -recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.c.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" ## Compile c++ files -recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.cpp.extra_flags} {build.extra_flags} {build.cache_flags} {build.flags.debug} {build.flags.optimize} {build.flags.maxspi} {build.flags.maxqspi} {build.extra_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" ## Compile S files -recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" +recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_SAMD_ADAFRUIT {compiler.S.extra_flags} {build.extra_flags} {build.cache_flags} {compiler.arm.cmsis.c.flags} {includes} "{source_file}" -o "{object_file}" ## Create archives # archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value @@ -143,6 +143,7 @@ tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port tools.bossac18.path={runtime.tools.bossac-1.8.0-48-gb176eee.path} tools.bossac18.cmd=bossac +tools.bossac18.cmd.windows=bossac.exe tools.bossac18.upload.params.verbose=-i -d tools.bossac18.upload.params.quiet= @@ -172,13 +173,13 @@ tools.bossacI.upload.network_pattern="{network_cmd}" -address {serial.port} -por # OpenOCD sketch upload # -tools.openocd.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd.path={runtime.tools.openocd-0.11.0-arduino2.path} tools.openocd.cmd=bin/openocd tools.openocd.cmd.windows=bin/openocd.exe tools.openocd.upload.params.verbose=-d2 tools.openocd.upload.params.quiet=-d0 -tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset 0x2000; shutdown" tools.openocd.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b @@ -186,7 +187,7 @@ tools.openocd.upload.network_pattern={network_cmd} -address {serial.port} -port # Program flashes the binary at 0x0000, so use the linker script without_bootloader tools.openocd.program.params.verbose=-d2 tools.openocd.program.params.quiet=-d0 -tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" tools.openocd.erase.params.verbose=-d3 tools.openocd.erase.params.quiet=-d0 @@ -194,25 +195,25 @@ tools.openocd.erase.pattern= tools.openocd.bootloader.params.verbose=-d2 tools.openocd.bootloader.params.quiet=-d0 -tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; init; halt; $_FLASHDRIVER bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" # # OpenOCD sketch upload - version with configurable bootloader size # FIXME: this programmer is a workaround for default options being overwritten by uploadUsingPreferences # -tools.openocd-withbootsize.path={runtime.tools.openocd-0.10.0-arduino7.path} +tools.openocd-withbootsize.path={runtime.tools.openocd-0.11.0-arduino2.path} tools.openocd-withbootsize.cmd=bin/openocd tools.openocd-withbootsize.cmd.windows=bin/openocd.exe tools.openocd-withbootsize.upload.params.verbose=-d2 tools.openocd-withbootsize.upload.params.quiet=-d0 -tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" +tools.openocd-withbootsize.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.bin} verify reset {bootloader.size}; shutdown" # Program flashes the binary at 0x0000, so use the linker script without_bootloader tools.openocd-withbootsize.program.params.verbose=-d2 tools.openocd-withbootsize.program.params.quiet=-d0 -tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" +tools.openocd-withbootsize.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; program {{build.path}/{build.project_name}.elf} verify reset; shutdown" tools.openocd-withbootsize.erase.params.verbose=-d3 tools.openocd-withbootsize.erase.params.quiet=-d0 @@ -220,4 +221,28 @@ tools.openocd-withbootsize.erase.pattern= tools.openocd-withbootsize.bootloader.params.verbose=-d2 tools.openocd-withbootsize.bootloader.params.quiet=-d0 -tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" +tools.openocd-withbootsize.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/{build.openocdscript}" -c "telnet_port disabled; init; halt; $_FLASHDRIVER bootloader 0; program {{runtime.platform.path}/bootloaders/{bootloader.file}} verify reset; shutdown" + +# ---------------------------------------- +# Debugger configuration (general options) +# ---------------------------------------- +# EXPERIMENTAL feature: +# - this is alpha and may be subject to change without notice +debug.executable={build.path}/{build.project_name}.elf +debug.toolchain=gcc +debug.toolchain.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ +debug.toolchain.prefix=arm-none-eabi- + +debug.server=openocd +debug.server.openocd.path={runtime.tools.openocd-0.11.0-arduino2.path}/bin/openocd +debug.server.openocd.scripts_dir={runtime.tools.openocd-0.11.0-arduino2.path}/share/openocd/scripts/ +debug.server.openocd.script={runtime.platform.path}/{build.openocdscript} + +# JLinkServer is not supported by arduino-cli yet +# https://github.com/arduino/arduino-cli/blob/eca9d9a8f00582a08fadea8a4b7e3ef01b40d082/commands/debug/debug.go#L160 +# use debug_custom.json to run JLinkGDBServer instead +# https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup +#debug.server=jlink +#debug.server.jlink.path=JLinkGDBServer +#debug.server.jlink.device=ATSAMD21G18 +#debug.server.jlink.script={runtime.platform.path}/{build.openocdscript} diff --git a/scripts/jlink/samd21/debug_custom.json b/scripts/jlink/samd21/debug_custom.json new file mode 100644 index 000000000..f5b625244 --- /dev/null +++ b/scripts/jlink/samd21/debug_custom.json @@ -0,0 +1,6 @@ +{ + "servertype": "jlink", + "device": "ATSAMD21G18A", + "interface": "SWD", + "serverpath": "JLinkGDBServer" +} diff --git a/scripts/jlink/samd51/debug_custom.json b/scripts/jlink/samd51/debug_custom.json new file mode 100644 index 000000000..13f573953 --- /dev/null +++ b/scripts/jlink/samd51/debug_custom.json @@ -0,0 +1,6 @@ +{ + "servertype": "jlink", + "device": "ATSAMD51G18", + "interface": "SWD", + "serverpath": "JLinkGDBServer" +} diff --git a/scripts/openocd/daplink_samd21.cfg b/scripts/openocd/daplink_samd21.cfg new file mode 100644 index 000000000..6c60b8832 --- /dev/null +++ b/scripts/openocd/daplink_samd21.cfg @@ -0,0 +1,29 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +source [find interface/cmsis-dap.cfg] +transport select swd + +# chip name +set CHIPNAME samd21 + +set _FLASHDRIVER at91samd + +source [find target/at91samdXX.cfg] diff --git a/scripts/openocd/daplink_samd51.cfg b/scripts/openocd/daplink_samd51.cfg new file mode 100644 index 000000000..6aa96d40b --- /dev/null +++ b/scripts/openocd/daplink_samd51.cfg @@ -0,0 +1,29 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +source [find interface/cmsis-dap.cfg] +transport select swd + +# chip name +set CHIPNAME samd51 + +set _FLASHDRIVER atsame5 + +source [find target/atsame5x.cfg] diff --git a/scripts/openocd/jlink_samd21.cfg b/scripts/openocd/jlink_samd21.cfg new file mode 100644 index 000000000..423a5e6bb --- /dev/null +++ b/scripts/openocd/jlink_samd21.cfg @@ -0,0 +1,29 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +source [find interface/jlink.cfg] +transport select swd + +# chip name +set CHIPNAME samd21 + +set _FLASHDRIVER at91samd + +source [find target/at91samdXX.cfg] diff --git a/scripts/openocd/jlink_samd51.cfg b/scripts/openocd/jlink_samd51.cfg new file mode 100644 index 000000000..8e9db6bdb --- /dev/null +++ b/scripts/openocd/jlink_samd51.cfg @@ -0,0 +1,29 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +source [find interface/jlink.cfg] +transport select swd + +# chip name +set CHIPNAME samd51 + +set _FLASHDRIVER atsame5 + +source [find target/atsame5x.cfg] diff --git a/tools/build_all.py b/tools/build_all.py new file mode 100644 index 000000000..f36fd45e2 --- /dev/null +++ b/tools/build_all.py @@ -0,0 +1,106 @@ +import os +import glob +import sys +import subprocess +from subprocess import Popen, PIPE +import time + +SUCCEEDED = "\033[32msucceeded\033[0m" +FAILED = "\033[31mfailed\033[0m" +SKIPPED = "\033[35mskipped\033[0m" +WARNING = "\033[33mwarnings\033[0m " + +exit_status = 0 +success_count = 0 +fail_count = 0 +skip_count = 0 + +build_format = '| {:25} | {:35} | {:18} | {:6} |' +build_separator = '-' * 88 + +FQBN_PREFIX='adafruit:samd:adafruit_' + +#default_boards = [ 'metro_m0', 'metro_m4', 'circuitplayground_m0', 'feather_m4_can', 'metro_m0:usbstack=tinyusb', 'metro_m4:speed=120,usbstack=tinyusb' ] +default_boards = [ 'metro_m0', 'metro_m0:usbstack=tinyusb' ] +build_boards = [] + +# build all variants if input not existed +if len(sys.argv) > 1: + build_boards.append(sys.argv[1]) +else: + build_boards = default_boards + +all_examples = list(glob.iglob('libraries/**/*.ino', recursive=True)) +all_examples.sort() + +def build_examples(variant): + global exit_status, success_count, fail_count, skip_count, build_format, build_separator + + print('\n') + print(build_separator) + print('| {:^84} |'.format('Board ' + variant)) + print(build_separator) + print(build_format.format('Library', 'Example', '\033[39mResult\033[0m', 'Time')) + print(build_separator) + + fqbn = "{}{}".format(FQBN_PREFIX, variant) + + for sketch in all_examples: + start_time = time.monotonic() + + # Skip if contains: ".board.test.skip" or ".all.test.skip" + # Skip if not contains: ".board.test.only" for a specific board + sketchdir = os.path.dirname(sketch) + if os.path.exists(sketchdir + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'): + success = SKIPPED + skip_count += 1 + elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'): + success = SKIPPED + skip_count += 1 + elif 'usbstack=tinyusb' not in variant and "libraries/Adafruit_TinyUSB_Arduino" in sketch: + # skip non-tinyusb variant for tinyusb examples + success = SKIPPED + skip_count += 1 + elif 'usbstack=tinyusb' in variant and "libraries/USBHost" in sketch: + # skip -tinyusb variant for USBHost examples + success = SKIPPED + skip_count += 1 + else: + build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=PIPE, stderr=PIPE) + + # get stderr into a form where warning/error was output to stderr + if build_result.returncode != 0: + exit_status = build_result.returncode + success = FAILED + fail_count += 1 + else: + success_count += 1 + if build_result.stderr: + success = WARNING + else: + success = SUCCEEDED + + build_duration = time.monotonic() - start_time + + print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, '{:5.2f}s'.format(build_duration))) + + if success != SKIPPED: + # Build failed + if build_result.returncode != 0: + print(build_result.stdout.decode("utf-8")) + + # Build with warnings + if build_result.stderr: + print(build_result.stderr.decode("utf-8")) + +build_time = time.monotonic() + +for board in build_boards: + build_examples(board) + +print(build_separator) +build_time = time.monotonic() - build_time +print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, build_time)) +print(build_separator) + +sys.exit(exit_status) diff --git a/tools/makeboards.py b/tools/makeboards.py new file mode 100755 index 000000000..fb5b8997b --- /dev/null +++ b/tools/makeboards.py @@ -0,0 +1,414 @@ +#!/usr/bin/env python3 + +print('''# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +''') + +mcu_dict = { + 'SAMD21': { + 'flash_size': 262144, + 'data_size': 0, + 'offset': '0x2000', + 'build_mcu': 'cortex-m0plus', + 'f_cpu': '48000000L', + 'extra_flags': '-DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS', + 'openocdscript': 'scripts/openocd/daplink_samd21.cfg', + }, + + 'SAMD51': { + 'flash_size': 507904, # SAMD51P20A and SAMD51J20A has 1032192 + 'data_size': 0, + 'offset': '0x4000', + 'build_mcu': 'cortex-m4', + 'f_cpu': '120000000L', + 'extra_flags': '-D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16', + 'openocdscript': 'scripts/openocd/daplink_samd51.cfg', + }, + + 'SAME51': { + 'flash_size': 507904, + 'data_size': 0, + 'offset': '0x4000', + 'build_mcu': 'cortex-m4', + 'f_cpu': '120000000L', + 'extra_flags': '-D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -mfloat-abi=hard -mfpu=fpv4-sp-d16', + 'openocdscript': 'scripts/openocd/daplink_samd51.cfg', + }, +} + + +def build_header(mcu, name, vendor, product, vid, pid_list): + prettyname = f"{vendor} {product} ({mcu})" + print() + print("# -----------------------------------") + print(f"# {prettyname}") + print("# -----------------------------------") + print(f"{name}.name={prettyname}") + print() + + print("# VID/PID for Bootloader, Arduino & CircuitPython") + for i in range(len(pid_list)): + print(f"{name}.vid.{i}={vid}") + print(f"{name}.pid.{i}={pid_list[i]}") + print() + + +def build_upload(mcu, name, extra_flags): + print("# Upload") + print(f"{name}.upload.tool=bossac18") + print(f"{name}.upload.protocol=sam-ba") + + if ('SAMD51P20A' in extra_flags) or ('SAMD51J20A' in extra_flags): + flash_size = 1032192 + else: + flash_size = mcu_dict[mcu]['flash_size'] + print(f"{name}.upload.maximum_size={flash_size}") + #print(f"{name}.upload.maximum_data_size={mcu_dict[mcu]['data_size']}") + + print(f"{name}.upload.offset={mcu_dict[mcu]['offset']}") + print(f"{name}.upload.use_1200bps_touch=true") + print(f"{name}.upload.wait_for_upload_port=true") + print(f"{name}.upload.native_usb=true") + print() + + +def build_build(mcu, name, variant, vendor, product, vid, pid_list, boarddefine, extra_flags, bootloader): + mcu_properties = mcu_dict[mcu] + + print("# Build") + print(f"{name}.build.mcu={mcu_properties['build_mcu']}") + print(f"{name}.build.f_cpu={mcu_properties['f_cpu']}") + print(f'{name}.build.usb_product="{product}"') + print(f'{name}.build.usb_manufacturer="{vendor}"') + print(f"{name}.build.board={boarddefine}") + print(f"{name}.build.core=arduino") + + # Due to fastLed issue https://github.com/FastLED/FastLED/issues/1363 + # although there is a simple fix already https://github.com/FastLED/FastLED/pull/1424 + # fastLED is not well maintained, and we need to skip ARDUINO_SAMD_ZERO for affected boards + # in the long run we should move all of our libraries away from ARDUINO_SAMD_ZERO + if variant in [ 'gemma_m0', 'trinket_m0', 'qtpy_m0', 'itsybitsy_m0' ]: + print(f"{name}.build.extra_flags={extra_flags} -DARM_MATH_CM0PLUS {{build.usb_flags}}") + else: + print(f"{name}.build.extra_flags={extra_flags} {mcu_properties['extra_flags']} {{build.usb_flags}}") + + print(f"{name}.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld") + print(f"{name}.build.openocdscript={mcu_properties['openocdscript']}") + print(f"{name}.build.variant={variant}") + print(f"{name}.build.variant_system_lib=") + print(f"{name}.build.vid={vid}") + print(f"{name}.build.pid={pid_list[0]}") + print(f"{name}.bootloader.tool=openocd") + print(f"{name}.bootloader.file={bootloader}") + if (mcu == 'SAMD51' or mcu == 'SAME51'): + print(f'{name}.compiler.arm.cmsis.ldflags="-L{{runtime.tools.CMSIS-5.4.0.path}}/CMSIS/Lib/GCC/" "-L{{build.variant.path}}" -larm_cortexM4lf_math -mfloat-abi=hard -mfpu=fpv4-sp-d16') + print() + + +def build_menu(mcu, name): + if (mcu == 'SAMD51' or mcu == 'SAME51'): + print("# Menu: Cache") + print(f"{name}.menu.cache.on=Enabled") + print(f"{name}.menu.cache.on.build.cache_flags=-DENABLE_CACHE") + print(f"{name}.menu.cache.off=Disabled") + print(f"{name}.menu.cache.off.build.cache_flags=") + print() + + print("# Menu: Speed") + print(f"{name}.menu.speed.120=120 MHz (standard)") + print(f"{name}.menu.speed.120.build.f_cpu=120000000L") + print(f"{name}.menu.speed.150=150 MHz (overclock)") + print(f"{name}.menu.speed.150.build.f_cpu=150000000L") + print(f"{name}.menu.speed.180=180 MHz (overclock)") + print(f"{name}.menu.speed.180.build.f_cpu=180000000L") + print(f"{name}.menu.speed.200=200 MHz (overclock)") + print(f"{name}.menu.speed.200.build.f_cpu=200000000L") + print() + + print("# Menu: Optimization") + print(f"{name}.menu.opt.small=Small (-Os) (standard)") + print(f"{name}.menu.opt.small.build.flags.optimize=-Os") + print(f"{name}.menu.opt.fast=Fast (-O2)") + print(f"{name}.menu.opt.fast.build.flags.optimize=-O2") + print(f"{name}.menu.opt.faster=Faster (-O3)") + print(f"{name}.menu.opt.faster.build.flags.optimize=-O3") + print(f"{name}.menu.opt.fastest=Fastest (-Ofast)") + print(f"{name}.menu.opt.fastest.build.flags.optimize=-Ofast") + print(f"{name}.menu.opt.dragons=Here be dragons (-Ofast -funroll-loops)") + print(f"{name}.menu.opt.dragons.build.flags.optimize=-Ofast -funroll-loops") + print() + + if (mcu == 'SAMD51' or mcu == 'SAME51'): + print("# Menu: QSPI Speed") + print(f"{name}.menu.maxqspi.50=50 MHz (standard)") + print(f"{name}.menu.maxqspi.50.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=50000000") + print(f"{name}.menu.maxqspi.fcpu=CPU Speed / 2") + print(f"{name}.menu.maxqspi.fcpu.build.flags.maxqspi=-DVARIANT_QSPI_BAUD_DEFAULT=({{build.f_cpu}})") + print() + + print("# Menu: USB Stack") + print(f"{name}.menu.usbstack.arduino=Arduino") + print(f"{name}.menu.usbstack.tinyusb=TinyUSB") + print(f"{name}.menu.usbstack.tinyusb.build.flags.usbstack=-DUSE_TINYUSB") + print() + + print("# Menu: Debug") + print(f"{name}.menu.debug.off=Off") + print(f"{name}.menu.debug.on=On") + print(f"{name}.menu.debug.on.build.flags.debug=-g") + print() + + # comment out for now since debugger selection does not work, debug does not pickup the right openocd script + # print("# Menu: Debugger") + # script_mcu = 'samd21' if mcu == 'SAMD21' else 'samd51' + # print(f"{name}.menu.debugger.daplink=CMSIS-DAP (DAPLink)") + # print(f"{name}.menu.debugger.daplink.build.openocdscript=scripts/openocd/daplink_{script_mcu}.cfg") + # print(f"{name}.menu.debugger.jlink=J-Link") + # print(f"{name}.menu.debugger.jlink.build.openocdscript=scripts/openocd/jlink_{script_mcu}.cfg") + + +def build_global_menu(): + print("menu.cache=Cache") + print("menu.speed=CPU Speed") + print("menu.opt=Optimize") + print("menu.maxqspi=Max QSPI") + print("menu.usbstack=USB Stack") + print("menu.debug=Debug") + #print("menu.debugger=Debugger") + + +def make_board(mcu, name, variant, vendor, product, vid, pid_list, boarddefine, extra_flags, bootloader): + build_header(mcu, name, vendor, product, vid, pid_list) + build_upload(mcu, name, extra_flags) + build_build(mcu, name, variant, vendor, product, vid, pid_list, boarddefine, extra_flags, bootloader) + build_menu(mcu, name) + + +# ------------------------------ +# main +# ------------------------------ + +build_global_menu() + +# ------------------------------ +# SAM D21 (M0) +# ------------------------------ + +# name, variant, vendor, product, vid, pid_list, boarddefine, extra_flags, bootloader +# try to sort in Alphabetical order +d21_board_list = [ + ["adafruit_feather_m0", "feather_m0", "Adafruit", "Feather M0", + "0x239A", ["0x800B", "0x000B", "0x0015"], + "SAMD_ZERO", "-D__SAMD21G18A__ -DADAFRUIT_FEATHER_M0", + "featherM0/bootloader-feather_m0-v2.0.0-adafruit.5.bin"], + + ["adafruit_feather_m0_express", "feather_m0_express", "Adafruit", "Feather M0 Express", + "0x239A", ["0x801B", "0x001B"], + "SAMD_FEATHER_M0_EXPRESS", "-D__SAMD21G18A__ -DARDUINO_SAMD_FEATHER_M0 -DADAFRUIT_FEATHER_M0_EXPRESS", + "featherM0/bootloader-feather_m0-v2.0.0-adafruit.5.bin"], + + ["adafruit_metro_m0", "metro_m0", "Adafruit", "Metro M0 Express", + "0x239A", ["0x8013", "0x0013"], + "SAMD_ZERO", "-D__SAMD21G18A__ -DADAFRUIT_METRO_M0_EXPRESS", + "metroM0/bootloader-metro_m0-v2.0.0-adafruit.5.bin"], + + ["adafruit_circuitplayground_m0", "circuitplay", "Adafruit", "Circuit Playground Express", + "0x239A", ["0x8018", "0x0019"], + "SAMD_CIRCUITPLAYGROUND_EXPRESS", "-D__SAMD21G18A__ -DCRYSTALLESS -DADAFRUIT_CIRCUITPLAYGROUND_M0", + "circuitplayM0/bootloader-circuitplay_m0-v2.0.0-adafruit.5.bin"], + + ["adafruit_gemma_m0", "gemma_m0", "Adafruit", "Gemma M0", + "0x239A", ["0x801C", "0x001C"], + "GEMMA_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_GEMMA_M0", + "gemmaM0/bootloader-gemma_m0-v2.0.0-adafruit.5.bin"], + + ["adafruit_trinket_m0", "trinket_m0", "Adafruit", "Trinket M0", + "0x239A", ["0x801E", "0x001E"], + "TRINKET_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_TRINKET_M0", + "trinketm0/bootloader-trinket_m0-v2.0.0-adafruit.5.bin"], + + ["adafruit_qtpy_m0", "qtpy_m0", "Adafruit", "QT Py M0", + "0x239A", ["0x80CB", "0x00CB", "0x00CC"], + "QTPY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_QTPY_M0", + "qtpyM0/bootloader-qtpy_m0.bin"], + + ["adafruit_neotrinkey_m0", "neotrinkey_m0", "Adafruit", "NeoPixel Trinkey M0", + "0x239A", ["0x80EF", "0x00EF", "0x80F0"], + "NEOTRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_NEOTRINKEY_M0", + "neotrinkey_m0/bootloader-neotrinkey_m0.bin"], + + ["adafruit_rotarytrinkey_m0", "rotarytrinkey_m0", "Adafruit", "Rotary Trinkey M0", + "0x239A", ["0x80FB", "0x00FB", "0x80FC"], + "ROTARYTRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_ROTARYTRINKEY_M0", + "rotarytrinkey_m0/bootloader-rotarytrinkey_m0.bin"], + + ["adafruit_neokeytrinkey_m0", "neokeytrinkey_m0", "Adafruit", "NeoKey Trinkey M0", + "0x239A", ["0x80FF", "0x00FF", "0x8100"], + "NEOKEYTRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_NEOKEYTRINKEY_M0", + "neokeytrinkey_m0/bootloader-neokeytrinkey_m0.bin"], + + ["adafruit_slidetrinkey_m0", "slidetrinkey_m0", "Adafruit", "Slide Trinkey M0", + "0x239A", ["0x8101", "0x0101", "0x8102"], + "SLIDETRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_SLIDETRINKEY_M0", + "slidetrinkey_m0/bootloader-slidetrinkey_m0.bin"], + + ["adafruit_proxlighttrinkey_m0", "proxlighttrinkey_m0", "Adafruit", "ProxLight Trinkey M0", + "0x239A", ["0x8103", "0x0103", "0x8104"], + "PROXLIGHTTRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_PROXLIGHTTRINKEY_M0", + "proxlighttrinkey_m0/bootloader-proxlighttrinkey_m0.bin"], + + ["adafruit_sht4xtrinkey_m0", "sht4xtrinkey_m0", "Adafruit", "SHT4x Trinkey M0", + "0x239A", ["0x8153", "0x0153", "0x8154"], + "SHT4XTRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_SHT4XTRINKEY_M0", + "sht4xtrinkey_m0/bootloader-sht4xtrinkey_m0.bin"], + + ["adafruit_pixeltrinkey_m0", "pixeltrinkey_m0", "Adafruit", "Pixel Trinkey M0", + "0x239A", ["0x8155", "0x0155", "0x8156"], + "PIXELTRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_PIXELTRINKEY_M0", + "pixeltrinkey_m0/bootloader-pixeltrinkey_m0.bin"], + + ["adafruit_TRRStrinkey_m0", "trrstrinkey_m0", "Adafruit", "TRRS Trinkey M0", + "0x239A", ["0x8157", "0x0157", "0x8158"], + "TRRSTRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_TRRSTRINKEY_M0", + "trrstrinkey_m0/bootloader-TRRStrinkey_m0.bin"], + + ["adafruit_thumbsticktrinkey_m0", "thumbsticktrinkey_m0", "Adafruit", "Thumbstick Trinkey M0", + "0x239A", ["0x8159", "0x0159", "0x8160"], + "THUMBSTICKTRINKEY_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_THUMBSTICKTRINKEY_M0", + "thumbsticktrinkey_m0/bootloader-thumbsticktrinkey_m0.bin"], + + ["adafruit_itsybitsy_m0", "itsybitsy_m0", "Adafruit", "ItsyBitsy M0 Express", + "0x239A", ["0x800F", "0x000F", "0x8012"], + "ITSYBITSY_M0", "-D__SAMD21G18A__ -DCRYSTALLESS -DADAFRUIT_ITSYBITSY_M0", + "itsybitsyM0/bootloader-itsybitsy_m0-v2.0.0-adafruit.5.bin"], + + ["adafruit_pirkey", "pirkey", "Adafruit", "pIRKey", + "0x239A", ["0x8027", "0x0027", "0x8028"], + "PIRKEY", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_PIRKEY", + "pirkey/bootloader-pirkey-v2.0.0-adafruit.5.bin"], + + ["adafruit_hallowing", "hallowing_m0_express", "Adafruit", "Hallowing M0", + "0x239A", ["0xDEAD", "0xD1ED", "0xB000"], + "SAMD_HALLOWING", "-D__SAMD21G18A__ -DCRYSTALLESS -DARDUINO_SAMD_HALLOWING_M0 -DADAFRUIT_HALLOWING", + "hallowingM0/bootloader-hallowing_m0-v2.0.0-adafruit.0-21-g887cc30.bin"], + + ["adafruit_crickit_m0", "crickit_m0", "Adafruit", "Crickit M0", + "0x239A", ["0x802D", "0x002D", "0x802D"], + "CRICKIT_M0", "-D__SAMD21G18A__ -DCRYSTALLESS -DADAFRUIT_CRICKIT_M0", + "crickit/samd21_sam_ba.bin"], + + ["adafruit_blm_badge", "blm_badge", "Adafruit", "BLM Badge", + "0x239A", ["0x80BF", "0x00BF", "0x80C0"], + "BLM_BADGE_M0", "-D__SAMD21E18A__ -DCRYSTALLESS -DADAFRUIT_BLM_BADGE", + "blmbadge/bootloader-blm_badge.bin"], +] + +for b in d21_board_list: + make_board("SAMD21", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8]) + + +# ---------------------------- +# SAM D51 and E51 (M4) +# ---------------------------- + +d51_board_list = [ + ["adafruit_metro_m4", "metro_m4", "Adafruit", "Metro M4", + "0x239A", ["0x8020", "0x0020", "0x8021", "0x0021"], + "METRO_M4", "-D__SAMD51J19A__ -DADAFRUIT_METRO_M4_EXPRESS", + "metroM4/bootloader-metro_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_grandcentral_m4", "grand_central_m4", "Adafruit", "Grand Central M4", + "0x239A", ["0x8031", "0x0031", "0x0032"], + "GRAND_CENTRAL_M4", "-D__SAMD51P20A__ -DADAFRUIT_GRAND_CENTRAL_M4", + "grand_central_m4/bootloader-grandcentral_m4.bin"], + + ["adafruit_itsybitsy_m4", "itsybitsy_m4", "Adafruit", "ItsyBitsy M4", + "0x239A", ["0x802B", "0x002B"], + "ITSYBITSY_M4", "-D__SAMD51G19A__ -DCRYSTALLESS -DADAFRUIT_ITSYBITSY_M4_EXPRESS", + "itsybitsyM4/bootloader-itsybitsy_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_feather_m4", "feather_m4", "Adafruit", "Feather M4 Express", + "0x239A", ["0x8022", "0x0022", "0x8026"], + "FEATHER_M4", "-D__SAMD51J19A__ -DADAFRUIT_FEATHER_M4_EXPRESS", + "featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_feather_m4_can", "feather_m4_can", "Adafruit", "Feather M4 CAN", + "0x239A", ["0x80CD", "0x00CD"], + "FEATHER_M4_CAN", "-D__SAME51J19A__ -DADAFRUIT_FEATHER_M4_EXPRESS -DADAFRUIT_FEATHER_M4_CAN", + "featherM4/bootloader-feather_m4_express-v2.0.0-adafruit.5.bin"], + + # ["adafruit_feather_m4_log", "feather_m4_log", "Adafruit", "Feather M4 Adalogger", + # "0x239A", ["0x8115", "0x0115", "0x8116"], + # "FEATHER_M4_ADALOGGER", "-D__SAME51J19A__ -DADAFRUIT_FEATHER_M4_ADALOGGER", + # "feather_m4_log/bootloader-feather_m4_log-v2.0.0-adafruit.5.bin"], + + ["adafruit_trellis_m4", "trellis_m4", + "Adafruit", "Trellis M4", "0x239A", ["0x802F", "0x002F", "0x0030"], + "TRELLIS_M4", "-D__SAMD51G19A__ -DCRYSTALLESS -DADAFRUIT_TRELLIS_M4_EXPRESS", + "trellisM4/bootloader-trellis_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_pyportal_m4", "pyportal_m4", "Adafruit", "PyPortal M4", + "0x239A", ["0x8035", "0x0035", "0x8036"], + "PYPORTAL_M4", "-D__SAMD51J20A__ -DCRYSTALLESS -DADAFRUIT_PYPORTAL", + "metroM4/bootloader-metro_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_pyportal_m4_titano", "pyportal_m4_titano", "Adafruit", "PyPortal M4 Titano", + "0x239A", ["0x8053", "0x8053"], + "PYPORTAL_M4_TITANO", "-D__SAMD51J20A__ -DCRYSTALLESS -DADAFRUIT_PYPORTAL_M4_TITANO", + "metroM4/bootloader-metro_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_pybadge_m4", "pybadge_m4", "Adafruit", "pyBadge M4 Express", + "0x239A", ["0x8033", "0x0033", "0x8034", "0x0034"], + "PYBADGE_M4", "-D__SAMD51J19A__ -DCRYSTALLESS -DADAFRUIT_PYBADGE_M4_EXPRESS", + "featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_metro_m4_airliftlite", "metro_m4_airlift", "Adafruit", "Metro M4 AirLift Lite", + "0x239A", ["0x8037", "0x0037"], + "METRO_M4_AIRLIFT_LITE", "-D__SAMD51J19A__ -DADAFRUIT_METRO_M4_AIRLIFT_LITE", + "metroM4/bootloader-metro_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_pygamer_m4", "pygamer_m4", "Adafruit", "PyGamer M4 Express", + "0x239A", ["0x803D", "0x003D", "0x803E"], + "PYGAMER_M4", "-D__SAMD51J19A__ -DCRYSTALLESS -DADAFRUIT_PYGAMER_M4_EXPRESS", + "featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_pybadge_airlift_m4", "pybadge_airlift_m4", "Adafruit", "pyBadge AirLift M4", + "0x239A", ["0x8043", "0x0043", "0x8044"], + "PYBADGE_AIRLIFT_M4", "-D__SAMD51J20A__ -DCRYSTALLESS -DADAFRUIT_PYBADGE_AIRLIFT_M4", + "featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_monster_m4sk", "monster_m4sk", "Adafruit", "MONSTER M4SK", + "0x239A", ["0x8047", "0x0047", "0x8048"], + "MONSTER_M4SK", "-D__SAMD51G19A__ -DCRYSTALLESS -DADAFRUIT_MONSTER_M4SK_EXPRESS", + "featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_hallowing_m4", "hallowing_m4", "Adafruit", "Hallowing M4", + "0x239A", ["0x8049", "0x0049", "0x804A"], + "HALLOWING_M4", "-D__SAMD51J19A__ -DCRYSTALLESS -DADAFRUIT_HALLOWING_M4_EXPRESS", + "featherM4/bootloader-feather_m4-v2.0.0-adafruit.5.bin"], + + ["adafruit_matrixportal_m4", "matrixportal_m4", "Adafruit", "Matrix Portal M4", + "0x239A", ["0x80C9", "0x00C9", "0x80CA"], + "MATRIXPORTAL_M4", "-D__SAMD51J19A__ -DCRYSTALLESS -DADAFRUIT_MATRIXPORTAL_M4_EXPRESS", + "matrixportalM4/bootloader-matrixportal_m4.bin"], +] + +for b in d51_board_list: + # M4 CAN is the only SAME51 + if b[0] == "adafruit_feather_m4_can": + make_board("SAME51", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8]) + else: + make_board("SAMD51", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8]) diff --git a/variants/blm_badge/debug_scripts/variant.gdb b/variants/blm_badge/debug_scripts/variant.gdb new file mode 100644 index 000000000..3c37ffde2 --- /dev/null +++ b/variants/blm_badge/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21g18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/blm_badge/linker_scripts/gcc/flash_with_bootloader.ld b/variants/blm_badge/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..4475f9511 --- /dev/null +++ b/variants/blm_badge/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,211 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/blm_badge/linker_scripts/gcc/flash_without_bootloader.ld b/variants/blm_badge/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..0162f0774 --- /dev/null +++ b/variants/blm_badge/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,212 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/blm_badge/openocd_scripts/gemma_m0.cfg b/variants/blm_badge/openocd_scripts/gemma_m0.cfg new file mode 100644 index 000000000..93d782d39 --- /dev/null +++ b/variants/blm_badge/openocd_scripts/gemma_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit Gemma M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21g18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/blm_badge/pins_arduino.h b/variants/blm_badge/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/blm_badge/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/blm_badge/variant.cpp b/variants/blm_badge/variant.cpp new file mode 100644 index 000000000..805b6e262 --- /dev/null +++ b/variants/blm_badge/variant.cpp @@ -0,0 +1,95 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#include "variant.h" + +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // GPIO 0 - I2S Data + { PORTA, 8, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel16, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_NMI }, + + // GPIO 1 - Cap touch 1 + { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // ADC/AIN[0] + + // GPIO 2 - Cap touch 2 + { PORTA, 4, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel4, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_4 }, // TCC0/WO[0] + + // GPIO 3 - Cap touch 3 + { PORTA, 6, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, // TCC1/WO[0] + + // GPIO 4 - Cap touch 4 + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // TCC1/WO[1] + + // GPIO 5 - Stemma I2C SDA + { PORTA, 0, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_0 }, // SDA + + // GPIO 6 - Stemma I2C SCL + { PORTA, 1, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // SCL + + // GPIO 7 - PDM clock + { PORTA, 10, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel18, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, + + // D8/A0 - CT1 + { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // ADC/AIN[0] + // D9/A1 - CT2 + { PORTA, 4, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel4, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_4 }, // TCC0/WO[0] + // D10/A2 - CT3 + { PORTA, 6, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, // TCC1/WO[0] + // D11/A3 - CT4 + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // TCC1/WO[1] + + // D12/A4 - Light + { PORTA, 11, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel19, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, + + // D13 - LED + { PORTA, 3, PIO_DIGITAL, 0, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // LED + + // GPIO 14 - NeoPixel + { PORTA, 5, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel5, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_5 }, + + // GPIO 15 & 16 (SWCLK & SWDIO) + // -------------------------- + { PORTA, 30, PIO_TIMER, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 31, PIO_TIMER, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + + // 17..19 - USB + // -------------------- + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; + +Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ; + +void SERCOM0_Handler() +{ + Serial1.IrqHandler(); +} + diff --git a/variants/blm_badge/variant.h b/variants/blm_badge/variant.h new file mode 100644 index 000000000..dbee168d1 --- /dev/null +++ b/variants/blm_badge/variant.h @@ -0,0 +1,192 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ADAFRUIT_BLMBADGE_ +#define _VARIANT_ADAFRUIT_BLMBADGE_ + +// The definitions here needs a SAMD core >=1.6.6 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10606 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (20u) +#define NUM_DIGITAL_PINS (17u) +#define NUM_ANALOG_INPUTS (5u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) ((p < 3u) ? (p) + PIN_A0 : -1) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_LED_13 (13u) +#define PIN_LED_RXL (13u) +#define PIN_LED_TXL (13u) +#define PIN_LED PIN_LED_13 +#define PIN_LED2 PIN_LED_RXL +#define PIN_LED3 PIN_LED_TXL +#define LED_BUILTIN PIN_LED_13 + +// Neopixel LED +#define PIN_NEOPIXEL 14 +#define NEOPIXEL_NUM 6 + +/* + * Analog pins + */ +#define PIN_A0 (8ul) +#define PIN_A1 (9ul) +#define PIN_A2 (10ul) +#define PIN_A3 (11ul) +#define PIN_A4 (12ul) + +#define PIN_DAC0 (PIN_A0) + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t DAC0 = PIN_DAC0; + +#define ADC_RESOLUTION 12 + +/* + * Serial interfaces + */ + +// Serial1 (sercom 0) +#define PIN_SERIAL1_RX (3ul) // captouch pad +#define PAD_SERIAL1_RX (SERCOM_RX_PAD_2) +#define PIN_SERIAL1_TX (2ul) // captouch pad +#define PAD_SERIAL1_TX (UART_TX_PAD_0) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 0 // we'll just have SPI CLK and MOSI on sercom 0, no MISO + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (5u) +#define PIN_WIRE_SCL (6u) +#define PERIPH_WIRE sercom1 +//#define WIRE_IT_HANDLER // hack! we call the i2c handler from within the serial handler! + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (17ul) +#define PIN_USB_DM (18ul) +#define PIN_USB_DP (19ul) + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; + +extern Uart Serial1; + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ADAFRUIT_BLMBADGE_ */ + diff --git a/variants/circuitplay/openocd_scripts/circuit_play.cfg b/variants/circuitplay/openocd_scripts/circuitplay.cfg similarity index 100% rename from variants/circuitplay/openocd_scripts/circuit_play.cfg rename to variants/circuitplay/openocd_scripts/circuitplay.cfg diff --git a/variants/circuitplay/variant.cpp b/variants/circuitplay/variant.cpp index 4562bca19..0e39cf35e 100644 --- a/variants/circuitplay/variant.cpp +++ b/variants/circuitplay/variant.cpp @@ -33,16 +33,16 @@ const PinDescription g_APinDescription[]= // Digital Low { PORTB, 2, PIO_SERCOM_ALT, 0, ADC_Channel10, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // GPIO D2 / A5 / SDA { PORTB, 3, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // GPIO D3 / A4 / SCL - { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // GPIO D4 / Left Button + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, // GPIO D4 / Left Button { PORTA, 14, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_14 }, // GPIO D5 / Right button { PORTA, 5, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel5, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_5 }, // GPIO D6 / A1 { PORTA, 15, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM3_CH1, TC3_CH1, EXTERNAL_INT_15 }, // GPIO D7 / Slide Switch // Digital High - { PORTB, 23, PIO_DIGITAL, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // GPIO D8 / NeoPixels + { PORTB, 23, PIO_DIGITAL, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // GPIO D8 / NeoPixels { PORTA, 6, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, // GPIO D9 / A2 { PORTA, 7, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // GPIO D10 / A3 - { PORTA, 30, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // GPIO D11 / Speaker Shutdown + { PORTA, 30, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, // GPIO D11 / Speaker Shutdown { PORTA, 2, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // GPIO D12 / VOut / A0 // 13 (LED) { PORTA, 17, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM2_CH1, TCC2_CH1, EXTERNAL_INT_1 }, // GPIO D13 / Red LED @@ -53,7 +53,7 @@ const PinDescription g_APinDescription[]= { PORTA, 5, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // A1 (Same as D6) { PORTA, 6, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, // A2 (Same as D9) { PORTA, 7, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // A3 (Same as D10 - { PORTB, 3, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel11, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // A4 (Same as D3) + { PORTB, 3, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel11, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // A4 (Same as D3) { PORTB, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel10, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A5 (Same as D2) { PORTB, 9, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel3, PWM4_CH1, TC4_CH1, EXTERNAL_INT_9 }, // A6 (Same as D0) { PORTB, 8, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel2, PWM4_CH0, TC4_CH0, EXTERNAL_INT_8 }, // A7 (Same as D1) @@ -71,8 +71,8 @@ const PinDescription g_APinDescription[]= { PORTA, 13, PIO_PWM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), No_ADC_Channel, PWM0_CH5, NOT_ON_TIMER, EXTERNAL_INT_13 }, // EIC/EXTINT[13] *TCC2/WO[1] TCC0/WO[7] // GPIO 28 & 29 internal I2C (original xtal pins) - { PORTA, 0, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // Internal SDA - { PORTA, 1, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // Internal SCL + { PORTA, 0, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_0 }, // Internal SDA + { PORTA, 1, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // Internal SCL // GPIO 30, 31, 32 Internal SPI { PORTA, 16, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // MISO: SERCOM3/PAD[0] diff --git a/variants/circuitplay/variant.h b/variants/circuitplay/variant.h index 10af1a15b..7a0a5a55c 100644 --- a/variants/circuitplay/variant.h +++ b/variants/circuitplay/variant.h @@ -51,7 +51,10 @@ #define portInputRegister(port) (&(port->IN.reg)) #define portModeRegister(port) (&(port->DIR.reg)) #define digitalPinHasPWM(P) (g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER) -#define digitalPinToInterrupt(P) (g_APinDescription[P].ulExtInt) + +#if (ARDUINO_SAMD_VARIANT_COMPLIANCE < 10606) + #define digitalPinToInterrupt(P) (g_APinDescription[P].ulExtInt) +#endif /* * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD @@ -63,12 +66,37 @@ // #define digitalPinToTimer(P) +// Digital pins +// ---- +#define PIN_D4 (4u) +#define PIN_D5 (5u) +#define PIN_D7 (7u) +#define PIN_D8 (8u) +#define PIN_D11 (25u) +#define PIN_D12 (26u) +#define PIN_D13 (13u) + +#define D4 PIN_D4 +#define D5 PIN_D5 +#define D7 PIN_D7 +#define D8 PIN_D8 +#define D11 PIN_D11 +#define D12 PIN_D12 +#define D13 PIN_D13 + // LEDs // ---- -#define PIN_LED_13 (13u) +#define PIN_LED_13 (D13) #define PIN_LED PIN_LED_13 #define LED_BUILTIN PIN_LED +// Neopixel +#define PIN_NEOPIXEL D8 +#define NEOPIXEL_NUM 10 + +#define PIN_BUTTON1 D4 // Left Button +#define PIN_BUTTON2 D5 // Right Button + //#define PIN_LED_RXL (25u) //#define PIN_LED_TXL (26u) @@ -239,10 +267,7 @@ extern Uart Serial1; // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. -#define SERIAL_PORT_USBVIRTUAL SerialUSB -#define SERIAL_PORT_MONITOR SerialUSB +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial #define SERIAL_PORT_HARDWARE Serial1 #define SERIAL_PORT_HARDWARE_OPEN Serial1 - -// Alias Serial to SerialUSB -#define Serial SerialUSB diff --git a/variants/crickit_m0/variant.cpp b/variants/crickit_m0/variant.cpp index 50bcc81da..944e731e4 100644 --- a/variants/crickit_m0/variant.cpp +++ b/variants/crickit_m0/variant.cpp @@ -72,7 +72,7 @@ const PinDescription g_APinDescription[]= { PORTA, 7, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // Captouch 4 // A13 - VIN sense pin - { PORTB, 3, PIO_ANALOG, 0, ADC_Channel11, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // VIN sense divider + { PORTB, 3, PIO_ANALOG, 0, ADC_Channel11, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // VIN sense divider /**************/ // 28..31 - 4 Motor PWM pins @@ -88,7 +88,7 @@ const PinDescription g_APinDescription[]= { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP // 35..36 - fake sercom 5 serial - { PORTB, 2, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // Sercom 5.0 UART TX + { PORTB, 2, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // Sercom 5.0 UART TX { PORTB, 23, PIO_SERCOM_ALT, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // Sercom 5.3 UART RX } ; diff --git a/variants/feather_m0_express/variant.h b/variants/feather_m0_express/variant.h index b666a281e..f4d3ae9bf 100644 --- a/variants/feather_m0_express/variant.h +++ b/variants/feather_m0_express/variant.h @@ -102,6 +102,7 @@ extern "C" #define PIN_A9 (PIN_A0 + 9) #define PIN_A10 (PIN_A0 + 10) #define PIN_A11 (PIN_A0 + 11) +#define PIN_A12 (41ul) // AREF #define PIN_DAC0 (14ul) static const uint8_t A0 = PIN_A0; @@ -116,6 +117,7 @@ static const uint8_t A8 = PIN_A8 ; static const uint8_t A9 = PIN_A9 ; static const uint8_t A10 = PIN_A10 ; static const uint8_t A11 = PIN_A11 ; +static const uint8_t A12 = PIN_A12 ; static const uint8_t DAC0 = PIN_DAC0; diff --git a/variants/feather_m4/linker_scripts/gcc/flash_with_bootloader.ld b/variants/feather_m4/linker_scripts/gcc/flash_with_bootloader.ld index 1bdea69ae..2c7e62a53 100644 --- a/variants/feather_m4/linker_scripts/gcc/flash_with_bootloader.ld +++ b/variants/feather_m4/linker_scripts/gcc/flash_with_bootloader.ld @@ -170,6 +170,10 @@ SECTIONS KEEP(*(.fini_array)) PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + /* Keep .ramfunc functions in RAM */ + KEEP(*(.ramfunc)) + KEEP(*(.jcr*)) . = ALIGN(16); /* All data end */ diff --git a/variants/feather_m4/variant.cpp b/variants/feather_m4/variant.cpp index 7f7dab2f6..88ba1ff6c 100644 --- a/variants/feather_m4/variant.cpp +++ b/variants/feather_m4/variant.cpp @@ -62,8 +62,8 @@ const PinDescription g_APinDescription[]= { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, { PORTB, 8, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel2, TC4_CH0, TC4_CH0, EXTERNAL_INT_8 }, { PORTB, 9, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel3, TC4_CH1, TC4_CH1, EXTERNAL_INT_9 }, - { PORTA, 4, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel4, TC0_CH0, TC0_CH0, EXTERNAL_INT_6 }, - { PORTA, 6, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel6, TC1_CH0, TC1_CH0, EXTERNAL_INT_10 }, + { PORTA, 4, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel4, TC0_CH0, TC0_CH0, EXTERNAL_INT_4 }, + { PORTA, 6, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel6, TC1_CH0, TC1_CH0, EXTERNAL_INT_6 }, // A6, D20 - VDiv! { PORTB, 1, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel13, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, diff --git a/variants/feather_m4_can/linker_scripts/gcc/flash_with_bootloader.ld b/variants/feather_m4_can/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..379e54ed3 --- /dev/null +++ b/variants/feather_m4_can/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,225 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x4000, LENGTH = 0x00080000-0x4000 /* First 16KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x4000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + /* Data accessed by the CAN peripheral must be in the first 64kB RAM */ + /* place it at the very start of RAM, before the .data section */ + /* *NOTE* it is not expliclty zeroed */ + .canram (NOLOAD) : + { + . = ALIGN(4); + *(.canram) + } > RAM + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/feather_m4_can/linker_scripts/gcc/flash_without_bootloader.ld b/variants/feather_m4_can/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..9e81bbab8 --- /dev/null +++ b/variants/feather_m4_can/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,223 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + /* Data accessed by the CAN peripheral must be in the first 64kB RAM */ + /* place it at the very start of RAM, before the .data section */ + /* *NOTE* it is not expliclty zeroed */ + .canram (NOLOAD) : + { + . = ALIGN(4); + *(.canram) + } > RAM + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/feather_m4_can/pins_arduino.h b/variants/feather_m4_can/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/feather_m4_can/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/feather_m4_can/variant.cpp b/variants/feather_m4_can/variant.cpp new file mode 100644 index 000000000..64d982e5e --- /dev/null +++ b/variants/feather_m4_can/variant.cpp @@ -0,0 +1,156 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" + +/* + * Pins descriptions + */ + +//TCC0 IOSET 6 +//TCC1 IOSET 1 +//TC0 IOSET 1 +//TC1 IOSET 1 +//TC2 IOSET 2 +//TC3 IOSET 1 +//TC4 IOSET 1 +const PinDescription g_APinDescription[PINS_COUNT]= +{ + // 0..13 - Digital pins + // ---------------------- + // 0/1 - SERCOM/UART (Serial1) + { PORTB, 17, PIO_SERCOM, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH4, NOT_ON_TIMER, EXTERNAL_INT_1 }, // RX: SERCOM5/PAD[1] + { PORTB, 16, PIO_SERCOM, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH5, NOT_ON_TIMER, EXTERNAL_INT_0 }, // TX: SERCOM5/PAD[0] + + // 2..12 + // Digital Low + { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 14, PIO_DIGITAL, PIN_ATTR_PWM_E, No_ADC_Channel, TC3_CH0, TC3_CH0, EXTERNAL_INT_14 }, + { PORTA, 16, PIO_TIMER_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH0, TC2_CH0, EXTERNAL_INT_0 }, + { PORTA, 18, PIO_TIMER_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH2, TC3_CH0, EXTERNAL_INT_2 }, + { PORTB, 3, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // 7: neopixel power + + // Digital High + { PORTB, 2, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // 8: neopixel + { PORTA, 19, PIO_TIMER_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH3, TC3_CH1, EXTERNAL_INT_3 }, + { PORTA, 20, PIO_TIMER_ALT, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH0, NOT_ON_TIMER, EXTERNAL_INT_4 }, + { PORTA, 21, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH1, NOT_ON_TIMER, EXTERNAL_INT_5 }, + { PORTA, 22, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH2, NOT_ON_TIMER, EXTERNAL_INT_6 }, + + // 13 (LED) + { PORTA, 23, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH3, TC4_CH1, EXTERNAL_INT_7 }, + + // 14..19 - Analog pins + // -------------------- + { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, + { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, + { PORTB, 8, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel2, TC4_CH0, TC4_CH0, EXTERNAL_INT_8 }, + { PORTB, 9, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel3, TC4_CH1, TC4_CH1, EXTERNAL_INT_9 }, + { PORTA, 4, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel4, TC0_CH0, TC0_CH0, EXTERNAL_INT_4 }, + { PORTA, 6, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel6, TC1_CH0, TC1_CH0, EXTERNAL_INT_6 }, + + // A6, D20 - VDiv! + { PORTB, 0, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel12, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_0 }, + + + // 21..22 I2C pins (SDA/SCL) + // ---------------------- + { PORTA, 12, PIO_SERCOM, PIN_ATTR_PWM_E, No_ADC_Channel, TC2_CH0, TC2_CH0, EXTERNAL_INT_12 }, // SDA: SERCOM2/PAD[0] + { PORTA, 13, PIO_SERCOM, PIN_ATTR_PWM_E, No_ADC_Channel, TC2_CH1, TC2_CH1, EXTERNAL_INT_13 }, // SCL: SERCOM2/PAD[1] + + // 23..25 - SPI pins (MISO,MOSI,SCK) + // ---------------------- + { PORTB, 22, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // MISO: SERCOM1/PAD[2] + { PORTB, 23, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // MOSI: SERCOM1/PAD[3] + { PORTA, 17, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // SCK: SERCOM1/PAD[1] + + // 26..27 - RX/TX LEDS -- unused + // -------------------- + { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + + // 28..30 - USB + // -------------------- + { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable DOES NOT EXIST ON THIS BOARD + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 27, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + + // 31 (AREF) + { PORTA, 3, PIO_ANALOG, PIN_ATTR_ANALOG, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // DAC/VREFP + + // ---------------------- + // 32..33 - Alternate use of A0 (DAC output) + { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, DAC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // DAC/VOUT0 + { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, DAC_Channel1, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // DAC/VOUT1 + + // ---------------------- + // 34..39 QSPI (SCK, CS, IO0, IO1, IO2, IO3) + { PORTB, 10, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTB, 11, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 8, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 9, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 10, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 11, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + + // ---------------------- + // 40..43 CAN (STANDBY, BOOST, TX, RX) + { PORTB, 12, PIO_DIGITAL, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTB, 13, PIO_DIGITAL, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTB, 14, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTB, 15, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TCC3, TCC4, TC0, TC1, TC2, TC3, TC4, TC5 } ; +const uint32_t GCLK_CLKCTRL_IDs[TCC_INST_NUM+TC_INST_NUM] = { TCC0_GCLK_ID, TCC1_GCLK_ID, TCC2_GCLK_ID, TCC3_GCLK_ID, TCC4_GCLK_ID, TC0_GCLK_ID, TC1_GCLK_ID, TC2_GCLK_ID, TC3_GCLK_ID, TC4_GCLK_ID, TC5_GCLK_ID } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; +SERCOM sercom4( SERCOM4 ) ; +SERCOM sercom5( SERCOM5 ) ; + +Uart Serial1( &sercom5, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ; + +void SERCOM5_0_Handler() +{ + Serial1.IrqHandler(); +} +void SERCOM5_1_Handler() +{ + Serial1.IrqHandler(); +} +void SERCOM5_2_Handler() +{ + Serial1.IrqHandler(); +} +void SERCOM5_3_Handler() +{ + Serial1.IrqHandler(); +} + +void initVariant(void) { + // special initialization code just for us + + // turn on neopixel + pinMode(7, OUTPUT); + digitalWrite(7, HIGH); +} diff --git a/variants/feather_m4_can/variant.h b/variants/feather_m4_can/variant.h new file mode 100644 index 000000000..853086c65 --- /dev/null +++ b/variants/feather_m4_can/variant.h @@ -0,0 +1,266 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_FEATHER_M4_ +#define _VARIANT_FEATHER_M4_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +#define VARIANT_GCLK0_FREQ (F_CPU) +#define VARIANT_GCLK1_FREQ (48000000UL) +#define VARIANT_GCLK2_FREQ (100000000UL) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (44u) +#define NUM_DIGITAL_PINS (23u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) ((p < 6u) ? (p) + 14u : -1) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_LED_13 (13u) +#define PIN_LED_RXL (25u) +#define PIN_LED_TXL (26u) +#define PIN_LED PIN_LED_13 +#define PIN_LED2 PIN_LED_RXL +#define PIN_LED3 PIN_LED_TXL +#define LED_BUILTIN PIN_LED_13 +#define PIN_NEOPIXEL (8) +#define PIN_NEOPIXEL_POWER (7) + +/* + * Analog pins + */ +#define PIN_A0 (14ul) +#define PIN_A1 (PIN_A0 + 1) +#define PIN_A2 (PIN_A0 + 2) +#define PIN_A3 (PIN_A0 + 3) +#define PIN_A4 (PIN_A0 + 4) +#define PIN_A5 (PIN_A0 + 5) +#define PIN_A6 (PIN_A0 + 6) + +#define PIN_DAC0 (14ul) +#define PIN_DAC1 PIN_A1 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t A5 = PIN_A5; +static const uint8_t A6 = PIN_A6 ; + +static const uint8_t DAC0 = PIN_DAC0; +static const uint8_t DAC1 = PIN_DAC1; + +#define ADC_RESOLUTION 12 + +// Other pins +#define PIN_ATN (31ul) +static const uint8_t ATN = PIN_ATN; + +/* + * Serial interfaces + */ + +// Serial1 +#define PIN_SERIAL1_RX (0ul) +#define PIN_SERIAL1_TX (1ul) +#define PAD_SERIAL1_RX (SERCOM_RX_PAD_1) +#define PAD_SERIAL1_TX (UART_TX_PAD_0) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (23u) +#define PIN_SPI_MOSI (24u) +#define PIN_SPI_SCK (25u) +#define PERIPH_SPI sercom1 +#define PAD_SPI_TX SPI_PAD_3_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_2 + +static const uint8_t SS = 9 ; // SERCOM1 last PAD is present on d9 but HW SS isn't used. Set here only for reference. +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (21u) +#define PIN_WIRE_SCL (22u) +#define PERIPH_WIRE sercom2 +#define WIRE_IT_HANDLER SERCOM2_Handler +#define WIRE_IT_HANDLER_0 SERCOM2_0_Handler +#define WIRE_IT_HANDLER_1 SERCOM2_1_Handler +#define WIRE_IT_HANDLER_2 SERCOM2_2_Handler +#define WIRE_IT_HANDLER_3 SERCOM2_3_Handler + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (28ul) +#define PIN_USB_DM (29ul) +#define PIN_USB_DP (30ul) + +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 1 + +#define I2S_DEVICE 0 +#define I2S_CLOCK_GENERATOR 3 + +#define PIN_I2S_SDO (11u) +#define PIN_I2S_SDI (12u) +#define PIN_I2S_SCK PIN_SERIAL1_TX +#define PIN_I2S_FS (10u) +#define PIN_I2S_MCK PIN_SERIAL1_RX + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +//QSPI Pins +#define PIN_QSPI_SCK (34u) +#define PIN_QSPI_CS (35u) +#define PIN_QSPI_IO0 (36u) +#define PIN_QSPI_IO1 (37u) +#define PIN_QSPI_IO2 (38u) +#define PIN_QSPI_IO3 (39u) + +#if !defined(VARIANT_QSPI_BAUD_DEFAULT) + // TODO: meaningful value for this + #define VARIANT_QSPI_BAUD_DEFAULT 5000000 +#endif + +/* + * CAN + */ +#define PIN_CAN_STANDBY (40) +#define PIN_CAN_BOOSTEN (41) +#define PIN_CAN_TX (42) +#define PIN_CAN_RX (43) + +#define PIN_CAN1_TX (12) +#define PIN_CAN1_RX (13) + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + +extern Uart Serial1; + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_FEATHER_M4_ */ + diff --git a/variants/gemma_m0/variant.cpp b/variants/gemma_m0/variant.cpp index 862453301..c0fa9700e 100644 --- a/variants/gemma_m0/variant.cpp +++ b/variants/gemma_m0/variant.cpp @@ -36,8 +36,8 @@ const PinDescription g_APinDescription[]= // GPIO 3 & 4 - DotStar internal data/clock // ---------------------------------------- - { PORTA, 0, PIO_DIGITAL, 0, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // ADC/AIN[4] - { PORTA, 1, PIO_DIGITAL, 0, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // ADC/AIN[5] + { PORTA, 0, PIO_DIGITAL, 0, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_0 }, // ADC/AIN[4] + { PORTA, 1, PIO_DIGITAL, 0, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // ADC/AIN[5] // GPIO 5, 6, 7 (USB interface) // ---------------------------- diff --git a/variants/gemma_m0/variant.h b/variants/gemma_m0/variant.h index 43bdd68a6..ee1273b55 100644 --- a/variants/gemma_m0/variant.h +++ b/variants/gemma_m0/variant.h @@ -85,8 +85,12 @@ extern "C" #define PIN_LED3 PIN_LED_TXL #define LED_BUILTIN PIN_LED_13 // DotStar LED -#define INTERNAL_DS_DATA 3 -#define INTERNAL_DS_CLK 4 +#define INTERNAL_DS_DATA (3u) +#define INTERNAL_DS_CLK (4u) +#define PIN_DOTSTAR_DATA (3u) +#define PIN_DOTSTAR_CLK (4u) +#define PIN_DOTSTAR_CLOCK PIN_DOTSTAR_CLK +#define DOTSTAR_NUM (1u) /* * Analog pins diff --git a/variants/grand_central_m4/variant.cpp b/variants/grand_central_m4/variant.cpp index fd0d9e5c0..78aa1495d 100644 --- a/variants/grand_central_m4/variant.cpp +++ b/variants/grand_central_m4/variant.cpp @@ -181,6 +181,8 @@ const PinDescription g_APinDescription[]= // ---------------------- // 95 SD detect { PORTB, 31, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_15 }, + // 96 SWO (on debug header) + { PORTB, 30, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_14 }, } ; const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TCC3, TCC4, TC0, TC1, TC2, TC3, TC4, TC5, TC6, TC7 } ; diff --git a/variants/hallowing_m4/variant.cpp b/variants/hallowing_m4/variant.cpp index 4d8787495..8f9ab0838 100644 --- a/variants/hallowing_m4/variant.cpp +++ b/variants/hallowing_m4/variant.cpp @@ -54,14 +54,14 @@ const PinDescription g_APinDescription[]= // -------------------- { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A0 (DAC0) { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // A1 (DAC1) - { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, // A2 + { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // A2 { PORTB, 9, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel3, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, // A3 { PORTB, 8, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel2, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, // A4 - { PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // A5 + { PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // A5 { PORTB, 1, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel13, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // A6, D20 - vbatt { PORTB, 4, PIO_ANALOG, PIN_ATTR_ANALOG_ALT, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // A7, D21 - Light - { PORTB, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel15, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A8 / D2 + { PORTB, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel15, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // A8 / D2 { PORTB, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel14, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A9 / D3 // 24..25 I2C pins (SDA/SCL) diff --git a/variants/itsybitsy_m0/variant.h b/variants/itsybitsy_m0/variant.h index 4c0d1c15f..e9b945fed 100644 --- a/variants/itsybitsy_m0/variant.h +++ b/variants/itsybitsy_m0/variant.h @@ -80,6 +80,11 @@ extern "C" #define PIN_LED_13 (13u) #define PIN_LED PIN_LED_13 #define LED_BUILTIN PIN_LED_13 +// DotStar LED +#define PIN_DOTSTAR_DATA (41u) +#define PIN_DOTSTAR_CLK (40u) +#define PIN_DOTSTAR_CLOCK PIN_DOTSTAR_CLK +#define DOTSTAR_NUM (1u) /* * Analog pins diff --git a/variants/itsybitsy_m4/variant.h b/variants/itsybitsy_m4/variant.h index e031adc9f..dd6da9ba7 100644 --- a/variants/itsybitsy_m4/variant.h +++ b/variants/itsybitsy_m4/variant.h @@ -84,6 +84,11 @@ extern "C" #define PIN_LED_13 (13u) #define PIN_LED PIN_LED_13 #define LED_BUILTIN PIN_LED_13 +// DotStar LED +#define PIN_DOTSTAR_DATA (8u) +#define PIN_DOTSTAR_CLK (6u) +#define PIN_DOTSTAR_CLOCK PIN_DOTSTAR_CLK +#define DOTSTAR_NUM (1u) /* * Analog pins @@ -137,7 +142,7 @@ static const uint8_t ATN = PIN_ATN; #define PAD_SPI_TX SPI_PAD_0_SCK_1 #define PAD_SPI_RX SERCOM_RX_PAD_3 -static const uint8_t SS = PIN_A2 ; +static const uint8_t SS = PIN_A2 ; static const uint8_t MOSI = PIN_SPI_MOSI ; static const uint8_t MISO = PIN_SPI_MISO ; static const uint8_t SCK = PIN_SPI_SCK ; diff --git a/variants/matrixportal_m4/linker_scripts/gcc/flash_with_bootloader.ld b/variants/matrixportal_m4/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..1bdea69ae --- /dev/null +++ b/variants/matrixportal_m4/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x4000, LENGTH = 0x00080000-0x4000 /* First 16KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x4000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/matrixportal_m4/linker_scripts/gcc/flash_without_bootloader.ld b/variants/matrixportal_m4/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..9c0c4e06d --- /dev/null +++ b/variants/matrixportal_m4/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/matrixportal_m4/pins_arduino.h b/variants/matrixportal_m4/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/matrixportal_m4/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/matrixportal_m4/variant.cpp b/variants/matrixportal_m4/variant.cpp new file mode 100644 index 000000000..df23508fe --- /dev/null +++ b/variants/matrixportal_m4/variant.cpp @@ -0,0 +1,173 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +/* + * Pins descriptions + */ + +//TCC0 IOSET 6 +//TCC1 IOSET 1 +//TC0 IOSET 1 +//TC1 IOSET 1 +//TC2 IOSET 2 +//TC3 IOSET 1 +//TC4 IOSET 1 +const PinDescription g_APinDescription[]= +{ + // 0..13 - Digital pins + // ---------------------- + // 0/1 - SERCOM/UART (Serial1) + { PORTA, 1, PIO_SERCOM_ALT, PIN_ATTR_PWM_E, No_ADC_Channel, TC2_CH1, TC2_CH1, EXTERNAL_INT_1 }, // RX: SERCOM1/PAD[1] + { PORTA, 0, PIO_SERCOM_ALT, PIN_ATTR_PWM_E, No_ADC_Channel, TC2_CH0, TC2_CH0, EXTERNAL_INT_0 }, // TX: SERCOM1/PAD[0] + + // 2..3 buttons + { PORTB, 22, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // Up + { PORTB, 23, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // Down + + // 4 neopixel + { PORTA, 23, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // NeoPixel + + // 5..6 I2C + { PORTB, 31, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_15 }, // SERCOM5.1 SDA + { PORTB, 30, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_14 }, // SERCOM5.0 SCL + + // 7..12 RGBRGB pins + { PORTB, 0, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_0 }, // R1 + { PORTB, 1, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // G1 + { PORTB, 2, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // B1 + { PORTB, 3, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // R2 + { PORTB, 4, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // G2 + { PORTB, 5, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // B2 + + // 13 LED + { PORTA, 14, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC1_CH2, TCC1_CH2, EXTERNAL_INT_14 }, // Red LED + + // 14..21 Control pins + { PORTB, 6, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // CLK + { PORTB, 14, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_14 }, // LAT + { PORTB, 12, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_12 }, // OE + { PORTB, 7, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // ADDR A + { PORTB, 8, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, // ADDR B + { PORTB, 9, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, // ADDR C + { PORTB, 15, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_15 }, // ADDR D + { PORTB, 13, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_13 }, // ADDR E + + // 22..26 Analog pins + // -------------------- + { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A0 + { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // A1 + { PORTA, 4, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel4, TC0_CH0, TC0_CH0, EXTERNAL_INT_4 }, // A2 + { PORTA, 6, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel6, TC1_CH0, TC1_CH0, EXTERNAL_INT_6 }, // A3 + { PORTA, 7, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel7, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // A4 + + // 27..28 ESP UART + // ---------------------- + { PORTA, 12, PIO_SERCOM_ALT, PIN_ATTR_PWM_E, No_ADC_Channel, TC2_CH0, TC2_CH0, EXTERNAL_INT_12 }, // RX: SERCOM4/PAD[1] + { PORTA, 13, PIO_SERCOM_ALT, PIN_ATTR_PWM_E, No_ADC_Channel, TC2_CH1, TC2_CH1, EXTERNAL_INT_13 }, // TX: SERCOM4/PAD[0] + + // 29..33 ESP control + { PORTA, 20, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH0, NOT_ON_TIMER, EXTERNAL_INT_4 }, // ESP GPIO0 + { PORTA, 21, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH1, NOT_ON_TIMER, EXTERNAL_INT_5 }, // ESP Reset + { PORTA, 22, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH2, NOT_ON_TIMER, EXTERNAL_INT_6 }, // ESP Busy + { PORTA, 18, PIO_DIGITAL, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH2, NOT_ON_TIMER, EXTERNAL_INT_2 }, // ESP RTS + { PORTB, 17, PIO_DIGITAL, PIN_ATTR_PWM_G, No_ADC_Channel, TCC0_CH4, NOT_ON_TIMER, EXTERNAL_INT_1 }, // ESP CS + + // 34..36 ESP SPI + { PORTA, 16, PIO_SERCOM_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH0, TC2_CH0, EXTERNAL_INT_0 }, // SCK: SERCOM3/PAD[1] + { PORTA, 17, PIO_SERCOM_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH1, TC2_CH1, EXTERNAL_INT_1 }, // MISO: SERCOM3/PAD[0] + { PORTA, 19, PIO_SERCOM_ALT, PIN_ATTR_PWM_F, No_ADC_Channel, TCC1_CH3, TC3_CH1, EXTERNAL_INT_3 }, // MOSI: SERCOM1/PAD[3] + + // 37..39 - USB + // -------------------- + { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable DOES NOT EXIST ON THIS BOARD + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 27, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + + // 40 (AREF) + { PORTA, 3, PIO_ANALOG, PIN_ATTR_ANALOG, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // DAC/VREFP + + // ---------------------- + // 41..46 QSPI (SCK, CS, IO0, IO1, IO2, IO3) + { PORTB, 10, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTB, 11, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 8, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 9, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 10, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + { PORTA, 11, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + + // 47 LIS IRQ + { PORTA, 27, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, // IRQ + + // 48..50 external SPI #2 on sercom 0 + { PORTA, 5, PIO_SERCOM_ALT, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // SCK SERCOM 0.1 + { PORTA, 4, PIO_SERCOM_ALT, (PIN_ATTR_ANALOG|PIN_ATTR_PWM_E), ADC_Channel4, TC0_CH0, TC0_CH0, EXTERNAL_INT_4 }, // MOSI SERCOM 0.0 + { PORTA, 7, PIO_SERCOM_ALT, PIN_ATTR_ANALOG, ADC_Channel7, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // MISO SERCOM 0.3 +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TCC3, TCC4, TC0, TC1, TC2, TC3, TC4, TC5 } ; +const uint32_t GCLK_CLKCTRL_IDs[TCC_INST_NUM+TC_INST_NUM] = { TCC0_GCLK_ID, TCC1_GCLK_ID, TCC2_GCLK_ID, TCC3_GCLK_ID, TCC4_GCLK_ID, TC0_GCLK_ID, TC1_GCLK_ID, TC2_GCLK_ID, TC3_GCLK_ID, TC4_GCLK_ID, TC5_GCLK_ID } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; +SERCOM sercom4( SERCOM4 ) ; +SERCOM sercom5( SERCOM5 ) ; + +Uart Serial1( &sercom1, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ; + +void SERCOM1_0_Handler() +{ + Serial1.IrqHandler(); +} +void SERCOM1_1_Handler() +{ + Serial1.IrqHandler(); +} +void SERCOM1_2_Handler() +{ + Serial1.IrqHandler(); +} +void SERCOM1_3_Handler() +{ + Serial1.IrqHandler(); +} + + +// sercom for internal ESP32 UART connection +Uart Serial2( &sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX ) ; + +void SERCOM4_0_Handler() +{ + Serial2.IrqHandler(); +} +void SERCOM4_1_Handler() +{ + Serial2.IrqHandler(); +} +void SERCOM4_2_Handler() +{ + Serial2.IrqHandler(); +} +void SERCOM4_3_Handler() +{ + Serial2.IrqHandler(); +} diff --git a/variants/matrixportal_m4/variant.h b/variants/matrixportal_m4/variant.h new file mode 100644 index 000000000..deedf8502 --- /dev/null +++ b/variants/matrixportal_m4/variant.h @@ -0,0 +1,275 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_MATRIXPORTAL_M4_ +#define _VARIANT_MATRIXPORTAL_M4_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +#define VARIANT_GCLK0_FREQ (F_CPU) +#define VARIANT_GCLK1_FREQ (48000000UL) +#define VARIANT_GCLK2_FREQ (100000000UL) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (40u) +#define NUM_DIGITAL_PINS (20u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) ((p < 6u) ? (p) + 14u : -1) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_LED_13 (13u) +//#define PIN_LED_RXL (25u) +//#define PIN_LED_TXL (26u) +#define PIN_LED PIN_LED_13 +//#define PIN_LED2 PIN_LED_RXL +//#define PIN_LED3 PIN_LED_TXL +#define LED_BUILTIN PIN_LED_13 +#define PIN_NEOPIXEL (4) + +/* + * Analog pins + */ +#define PIN_A0 (22ul) +#define PIN_A1 (PIN_A0 + 1) +#define PIN_A2 (PIN_A0 + 2) +#define PIN_A3 (PIN_A0 + 3) +#define PIN_A4 (PIN_A0 + 4) + +#define PIN_DAC0 (22ul) +#define PIN_DAC1 PIN_A1 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; + +static const uint8_t DAC0 = PIN_DAC0; +static const uint8_t DAC1 = PIN_DAC1; + +#define ADC_RESOLUTION 12 + + + +/* WiFi interfaces */ +#define SerialESP32 Serial2 +#define SerialNina SerialESP32 +#define SPIWIFI SPI +#define ESP32_GPIO0 29 +#define ESP32_RESETN 30 +#define SPIWIFI_SS 33 +#define SPIWIFI_ACK 31 +#define SPIWIFI_RESET ESP32_RESETN +#define NINA_GPIO0 ESP32_GPIO0 +#define NINA_RESETN ESP32_RESETN +#define NINA_ACK SPIWIFI_ACK +#define NINA_CTS SPIWIFI_ACK +#define NINA_RTS NINA_GPIO0 + + +/* + * Serial interfaces + */ + +// Serial1 +#define PIN_SERIAL1_RX (0ul) +#define PIN_SERIAL1_TX (1ul) +#define PAD_SERIAL1_RX (SERCOM_RX_PAD_1) +#define PAD_SERIAL1_TX (UART_TX_PAD_0) + +// Serial2 +#define PIN_SERIAL2_RX (27ul) +#define PIN_SERIAL2_TX (28ul) +#define PAD_SERIAL2_RX (SERCOM_RX_PAD_1) +#define PAD_SERIAL2_TX (UART_TX_PAD_0) + + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 2 + +#define PIN_SPI_SCK (34u) +#define PIN_SPI_MISO (35u) +#define PIN_SPI_MOSI (36u) +#define PERIPH_SPI sercom3 +#define PAD_SPI_TX SPI_PAD_3_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_0 + +static const uint8_t SS = 33 ; +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + + +#define PIN_SPI1_SCK (48u) +#define PIN_SPI1_MOSI (49u) +#define PIN_SPI1_MISO (50u) +#define PERIPH_SPI1 sercom0 +#define PAD_SPI1_TX SPI_PAD_0_SCK_1 +#define PAD_SPI1_RX SERCOM_RX_PAD_3 + +static const uint8_t SS1 = PIN_A3 ; +static const uint8_t MOSI1 = PIN_SPI1_MOSI ; +static const uint8_t MISO1 = PIN_SPI1_MISO ; +static const uint8_t SCK1 = PIN_SPI1_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (5u) +#define PIN_WIRE_SCL (6u) +#define PERIPH_WIRE sercom5 +#define WIRE_IT_HANDLER SERCOM5_Handler +#define WIRE_IT_HANDLER_0 SERCOM5_0_Handler +#define WIRE_IT_HANDLER_1 SERCOM5_1_Handler +#define WIRE_IT_HANDLER_2 SERCOM5_2_Handler +#define WIRE_IT_HANDLER_3 SERCOM5_3_Handler + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (37ul) +#define PIN_USB_DM (38ul) +#define PIN_USB_DP (39ul) + +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_QSPI + +//QSPI Pins +#define PIN_QSPI_SCK (41u) +#define PIN_QSPI_CS (42u) +#define PIN_QSPI_IO0 (43u) +#define PIN_QSPI_IO1 (44u) +#define PIN_QSPI_IO2 (45u) +#define PIN_QSPI_IO3 (46u) + +#if !defined(VARIANT_QSPI_BAUD_DEFAULT) + // TODO: meaningful value for this + #define VARIANT_QSPI_BAUD_DEFAULT 5000000 +#endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + +extern Uart Serial1; +extern Uart Serial2; + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_MATRIX_PORTAL_M4_ */ + diff --git a/variants/metro_m4_airlift/variant.h b/variants/metro_m4_airlift/variant.h index 7b754792f..d078f2099 100644 --- a/variants/metro_m4_airlift/variant.h +++ b/variants/metro_m4_airlift/variant.h @@ -131,7 +131,8 @@ static const uint8_t ATN = PIN_ATN; #define NINA_GPIO0 ESP32_GPIO0 #define NINA_RESETN ESP32_RESETN #define NINA_ACK SPIWIFI_ACK - +#define NINA_CTS SPIWIFI_ACK +#define NINA_RTS NINA_GPIO0 /* * Serial interfaces diff --git a/variants/neokeytrinkey_m0/debug_scripts/variant.gdb b/variants/neokeytrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/neokeytrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/neokeytrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/neokeytrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/neokeytrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/neokeytrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/neokeytrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/neokeytrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/neokeytrinkey_m0/openocd_scripts/neokeytrinkey_m0.cfg b/variants/neokeytrinkey_m0/openocd_scripts/neokeytrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/neokeytrinkey_m0/openocd_scripts/neokeytrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/neokeytrinkey_m0/pins_arduino.h b/variants/neokeytrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/neokeytrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/neokeytrinkey_m0/variant.cpp b/variants/neokeytrinkey_m0/variant.cpp new file mode 100644 index 000000000..e64ad7b21 --- /dev/null +++ b/variants/neokeytrinkey_m0/variant.cpp @@ -0,0 +1,51 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // NeoPixel + { PORTA, 15, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_15 }, + + // Mechanical switch + { PORTA, 28, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, + + // Touch pad + { PORTA, 7, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, + + + // USB pins + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + + // Fake DAC pin just so we can compile stuff + { PORTA, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel0, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_2 }, // A0 / D0 / DAC +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; diff --git a/variants/neokeytrinkey_m0/variant.h b/variants/neokeytrinkey_m0/variant.h new file mode 100644 index 000000000..27e532bf4 --- /dev/null +++ b/variants/neokeytrinkey_m0/variant.h @@ -0,0 +1,185 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_NEOKEYTRINKEY_ZERO_ +#define _VARIANT_NEOKEYTRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (6u) +#define NUM_DIGITAL_PINS (6u) +#define NUM_ANALOG_INPUTS (1u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (0u) +#define NUM_NEOPIXEL (1u) + +#define PIN_SWITCH 1 +#define PIN_TOUCH 2 + +/* + * Analog pins + */ +#define PIN_A0 (6ul) +#define PIN_A1 (2) +#define PIN_DAC0 PIN_A0 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + * Fake SPI Interface just so we can compile + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO PIN_A0 +#define PIN_SPI_MOSI PIN_A0 +#define PIN_SPI_SCK PIN_A0 +#define PERIPH_SPI sercom0 +#define PAD_SPI_TX SPI_PAD_0_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_0 + +static const uint8_t SS = PIN_A0; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 0 + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (3ul) +#define PIN_USB_DM (4ul) +#define PIN_USB_DP (5ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +/* + * Serial interfaces + */ + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/neotrinkey_m0/debug_scripts/variant.gdb b/variants/neotrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/neotrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/neotrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/neotrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/neotrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/neotrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/neotrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/neotrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/neotrinkey_m0/openocd_scripts/neotrinkey_m0.cfg b/variants/neotrinkey_m0/openocd_scripts/neotrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/neotrinkey_m0/openocd_scripts/neotrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/neotrinkey_m0/pins_arduino.h b/variants/neotrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/neotrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/neotrinkey_m0/variant.cpp b/variants/neotrinkey_m0/variant.cpp new file mode 100644 index 000000000..150034974 --- /dev/null +++ b/variants/neotrinkey_m0/variant.cpp @@ -0,0 +1,50 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // NeoPixels + { PORTA, 5, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel5, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_5 }, + + // Touch Pin 1 + { PORTA, 3, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel1, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, + + // Touch Pin 2 + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, + + // USB pins + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + + // Fake DAC pin just so we can compile stuff + { PORTA, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel0, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_2 }, // A0 / D0 / DAC +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; diff --git a/variants/neotrinkey_m0/variant.h b/variants/neotrinkey_m0/variant.h new file mode 100644 index 000000000..3cf172c23 --- /dev/null +++ b/variants/neotrinkey_m0/variant.h @@ -0,0 +1,179 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_NEOTRINKEY_ZERO_ +#define _VARIANT_NEOTRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (7u) +#define NUM_DIGITAL_PINS (7u) +#define NUM_ANALOG_INPUTS (3u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (0u) +#define NUM_NEOPIXEL (4u) + +/* + * Analog pins + */ +#define PIN_A0 (6ul) +#define PIN_A1 (1) +#define PIN_A2 (2) +#define PIN_DAC0 PIN_A0 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + * Fake SPI Interface just so we can compile + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO PIN_A0 +#define PIN_SPI_MOSI PIN_A0 +#define PIN_SPI_SCK PIN_A0 +#define PERIPH_SPI sercom0 +#define PAD_SPI_TX SPI_PAD_0_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_0 + +static const uint8_t SS = PIN_A0; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 0 + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (3ul) +#define PIN_USB_DM (4ul) +#define PIN_USB_DP (5ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/pirkey/openocd_scripts/arduino_zero.cfg b/variants/pirkey/openocd_scripts/pirkey.cfg similarity index 100% rename from variants/pirkey/openocd_scripts/arduino_zero.cfg rename to variants/pirkey/openocd_scripts/pirkey.cfg diff --git a/variants/pirkey/variant.cpp b/variants/pirkey/variant.cpp index 33bb7fe7a..61734c020 100644 --- a/variants/pirkey/variant.cpp +++ b/variants/pirkey/variant.cpp @@ -25,11 +25,11 @@ const PinDescription g_APinDescription[]= { // GPIO 0 & 1 - DotStar internal data/clock // ---------------------------------------- - { PORTA, 0, PIO_DIGITAL, 0, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // ADC/AIN[4] - { PORTA, 1, PIO_DIGITAL, 0, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // ADC/AIN[5] + { PORTA, 0, PIO_DIGITAL, 0, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_0 }, // ADC/AIN[4] + { PORTA, 1, PIO_DIGITAL, 0, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // ADC/AIN[5] // GPIO 2 - Infrared In - { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable - GPIO #2 + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, // USB Host enable - GPIO #2 // GPIO 3 & 4 (SWCLK & SWDIO) // -------------------------- diff --git a/variants/pixeltrinkey_m0/debug_scripts/variant.gdb b/variants/pixeltrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/pixeltrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/pixeltrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/pixeltrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/pixeltrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/pixeltrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/pixeltrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/pixeltrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/pixeltrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg b/variants/pixeltrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/pixeltrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/pixeltrinkey_m0/pins_arduino.h b/variants/pixeltrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/pixeltrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/pixeltrinkey_m0/variant.cpp b/variants/pixeltrinkey_m0/variant.cpp new file mode 100644 index 000000000..15c9cce9c --- /dev/null +++ b/variants/pixeltrinkey_m0/variant.cpp @@ -0,0 +1,52 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // DAC / A0 for monitoring 5V + { PORTA, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel0, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_2 }, // A0 / D0 / DAC + + // Internal NeoPixel / D1 + { PORTA, 1, PIO_ANALOG, PIN_ATTR_ANALOG, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + + // SPI MOSI/SCK + { PORTA, 4, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // D2 / MOSI + { PORTA, 5, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // D3 / SCK + + // A6 / MISO + { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // A6 / MISO + + // USB pins D5, D6, D7 + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; diff --git a/variants/pixeltrinkey_m0/variant.h b/variants/pixeltrinkey_m0/variant.h new file mode 100644 index 000000000..9a2b8222f --- /dev/null +++ b/variants/pixeltrinkey_m0/variant.h @@ -0,0 +1,189 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_PIXELTRINKEY_ZERO_ +#define _VARIANT_PIXELTRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (7u) +#define NUM_DIGITAL_PINS (4u) +#define NUM_ANALOG_INPUTS (1u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (1u) +#define NUM_NEOPIXEL (1u) + +#define PIN_DATA (2u) +#define PIN_CLOCK (3u) + +/* + * Analog pins + */ +#define PIN_A0 (0ul) +#define PIN_DAC0 PIN_A0 + +#define PIN_A6 (4ul) + +static const uint8_t A0 = PIN_A0; + +static const uint8_t A6 = PIN_A6; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (4ul) // off 3-pin JST, broken out +#define PIN_SPI_MOSI (2ul) +#define PIN_SPI_SCK (3ul) +#define PERIPH_SPI sercom0 +#define PAD_SPI_TX SPI_PAD_0_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_2 + +static const uint8_t SS = (5ul); // not actually broken out +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces, fake just for compilation + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (2u) +#define PIN_WIRE_SCL (3u) +#define PERIPH_WIRE sercom0 +#define WIRE_IT_HANDLER SERCOM0_Handler + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (5ul) +#define PIN_USB_DM (6ul) +#define PIN_USB_DP (7ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/proxlighttrinkey_m0/debug_scripts/variant.gdb b/variants/proxlighttrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/proxlighttrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/proxlighttrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/proxlighttrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/proxlighttrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/proxlighttrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/proxlighttrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/proxlighttrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/proxlighttrinkey_m0/openocd_scripts/proxlighttrinkey_m0.cfg b/variants/proxlighttrinkey_m0/openocd_scripts/proxlighttrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/proxlighttrinkey_m0/openocd_scripts/proxlighttrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/proxlighttrinkey_m0/pins_arduino.h b/variants/proxlighttrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/proxlighttrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/proxlighttrinkey_m0/variant.cpp b/variants/proxlighttrinkey_m0/variant.cpp new file mode 100644 index 000000000..d9688d084 --- /dev/null +++ b/variants/proxlighttrinkey_m0/variant.cpp @@ -0,0 +1,57 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // Fake DAC A0 pin just so we can compile stuff + { PORTA, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel0, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_2 }, // A0 / D0 / DAC + + // touch 1 / A1 + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // TCC1/WO[1] + // touch 2 / A2 + { PORTA, 3, PIO_ANALOG, (PIN_ATTR_ANALOG), ADC_Channel3, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // ADC/AIN[3] + + // NeoPixel / D3 + { PORTA, 15, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM3_CH1, TC3_CH1, EXTERNAL_INT_15 }, // TC3/WO[1] + + // I2C SDA D4 & SCL D5 + { PORTA, 16, PIO_SERCOM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), No_ADC_Channel, PWM0_CH6, TCC0_CH6, EXTERNAL_INT_0 }, // D4 / SDA / PWM + { PORTA, 17, PIO_SERCOM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), No_ADC_Channel, PWM0_CH7, TCC0_CH7, EXTERNAL_INT_1 }, // D5 / SCL / PWM + + // Interrupt D6 + { PORTA, 0, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_0 }, + + // USB pins D7, D8, D9 + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; diff --git a/variants/proxlighttrinkey_m0/variant.h b/variants/proxlighttrinkey_m0/variant.h new file mode 100644 index 000000000..93554eafc --- /dev/null +++ b/variants/proxlighttrinkey_m0/variant.h @@ -0,0 +1,193 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_PROXLIGHTTRINKEY_ZERO_ +#define _VARIANT_PROXLIGHTTRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (10u) +#define NUM_DIGITAL_PINS (6u) +#define NUM_ANALOG_INPUTS (3u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (3u) +#define NUM_NEOPIXEL (2u) + +// TOUCH PINS +#define PIN_TOUCH1 1 +#define PIN_TOUCH2 2 + +#define PIN_INTERRUPT 6 + +/* + * Analog pins + */ +#define PIN_A0 (0ul) +#define PIN_A1 (1) +#define PIN_A2 (2) +#define PIN_DAC0 PIN_A0 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + * Fake SPI Interface just so we can compile + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO PIN_A0 +#define PIN_SPI_MOSI PIN_A0 +#define PIN_SPI_SCK PIN_A0 +#define PERIPH_SPI sercom0 +#define PAD_SPI_TX SPI_PAD_0_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_0 + +static const uint8_t SS = PIN_A0; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (4u) +#define PIN_WIRE_SCL (5u) +#define PERIPH_WIRE sercom1 +#define WIRE_IT_HANDLER SERCOM1_Handler + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (5ul) +#define PIN_USB_DM (6ul) +#define PIN_USB_DP (7ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/pybadge_m4/variant.cpp b/variants/pybadge_m4/variant.cpp index bd991fe04..ebc2c7f48 100644 --- a/variants/pybadge_m4/variant.cpp +++ b/variants/pybadge_m4/variant.cpp @@ -54,12 +54,12 @@ const PinDescription g_APinDescription[]= { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, { PORTB, 8, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel2, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, { PORTB, 9, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel3, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, - { PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, - { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, + { PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, + { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, { PORTB, 1, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel13, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // A6, D20 - vbatt { PORTB, 4, PIO_ANALOG, PIN_ATTR_ANALOG_ALT, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // A7, D21 - Light - { PORTB, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel15, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A8 / D2 + { PORTB, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel15, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // A8 / D2 { PORTB, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel14, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A9 / D3 diff --git a/variants/pygamer_advance_m4/variant.cpp b/variants/pygamer_advance_m4/variant.cpp index 1aa160945..34f7e9831 100644 --- a/variants/pygamer_advance_m4/variant.cpp +++ b/variants/pygamer_advance_m4/variant.cpp @@ -54,12 +54,12 @@ const PinDescription g_APinDescription[]= { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, { PORTB, 8, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel2, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, { PORTB, 9, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel3, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, - { PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, - { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, + { PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, + { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, { PORTB, 1, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel13, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // A6, D20 - vbatt { PORTB, 4, PIO_ANALOG, PIN_ATTR_ANALOG_ALT, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // A7, D21 - Light - { PORTB, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel15, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A8 / D2 + { PORTB, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel15, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // A8 / D2 { PORTB, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel14, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A9 / D3 { PORTB, 6, PIO_ANALOG, PIN_ATTR_ANALOG_ALT, ADC_Channel8, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // A10 / JOYY { PORTB, 7, PIO_ANALOG, PIN_ATTR_ANALOG_ALT, ADC_Channel9, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // A11 / JOYX diff --git a/variants/pygamer_m4/variant.cpp b/variants/pygamer_m4/variant.cpp index e1d852c60..ffbccefe8 100644 --- a/variants/pygamer_m4/variant.cpp +++ b/variants/pygamer_m4/variant.cpp @@ -54,12 +54,12 @@ const PinDescription g_APinDescription[]= { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, { PORTB, 8, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel2, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, { PORTB, 9, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel3, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, - { PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, - { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, + { PORTA, 4, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, + { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, { PORTB, 1, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel13, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // A6, D20 - vbatt { PORTB, 4, PIO_ANALOG, PIN_ATTR_ANALOG_ALT, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // A7, D21 - Light - { PORTB, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel15, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A8 / D2 + { PORTB, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel15, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // A8 / D2 { PORTB, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel14, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A9 / D3 { PORTB, 6, PIO_ANALOG, PIN_ATTR_ANALOG_ALT, ADC_Channel8, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // A10 / JOYY { PORTB, 7, PIO_ANALOG, PIN_ATTR_ANALOG_ALT, ADC_Channel9, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // A11 / JOYX diff --git a/variants/pyportal_m4/variant.h b/variants/pyportal_m4/variant.h index b159bd7e3..75fcb354c 100644 --- a/variants/pyportal_m4/variant.h +++ b/variants/pyportal_m4/variant.h @@ -160,7 +160,7 @@ static const uint8_t ATN = PIN_ATN; #define PAD_SPI_TX SPI_PAD_0_SCK_1 #define PAD_SPI_RX SERCOM_RX_PAD_2 -static const uint8_t SS = PIN_A2; // ??? +static const uint8_t SS = 32; static const uint8_t MOSI = PIN_SPI_MOSI; static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; diff --git a/variants/pyportal_m4_titano/variant.h b/variants/pyportal_m4_titano/variant.h index 3072826fa..0da7c158a 100644 --- a/variants/pyportal_m4_titano/variant.h +++ b/variants/pyportal_m4_titano/variant.h @@ -160,7 +160,7 @@ static const uint8_t ATN = PIN_ATN; #define PAD_SPI_TX SPI_PAD_0_SCK_1 #define PAD_SPI_RX SERCOM_RX_PAD_2 -static const uint8_t SS = PIN_A2; // ??? +static const uint8_t SS = 32; static const uint8_t MOSI = PIN_SPI_MOSI; static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; diff --git a/variants/qtpy_m0/debug_scripts/variant.gdb b/variants/qtpy_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/qtpy_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/qtpy_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/qtpy_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/qtpy_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/qtpy_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/qtpy_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/qtpy_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/qtpy_m0/openocd_scripts/qtpy_m0.cfg b/variants/qtpy_m0/openocd_scripts/qtpy_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/qtpy_m0/openocd_scripts/qtpy_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/qtpy_m0/pins_arduino.h b/variants/qtpy_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/qtpy_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/qtpy_m0/variant.cpp b/variants/qtpy_m0/variant.cpp new file mode 100644 index 000000000..4d5135036 --- /dev/null +++ b/variants/qtpy_m0/variant.cpp @@ -0,0 +1,86 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + { PORTA, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A0 / D0 / DAC + { PORTA, 3, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel1, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, // A1 / D1 / AREF + { PORTA, 4, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel4, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_4 }, // A2 / D2 / PWM + { PORTA, 5, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel5, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_5 }, // A3 / D3 / PWM + + // I2C SDA & SCL + { PORTA, 16, PIO_SERCOM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_0 }, // D4 / SDA / PWM + { PORTA, 17, PIO_SERCOM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM2_CH1, TCC2_CH1, EXTERNAL_INT_1 }, // D5 / SCL / PWM + + // UART TX & RX + { PORTA, 6, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, // A6 / D6 / TX / PWM + { PORTA, 7, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // A7 / D7 / RX / PWM + + // SPI SCK, MISO, MOSI + { PORTA, 11, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), ADC_Channel19, PWM0_CH3, TCC0_CH3, EXTERNAL_INT_11 }, // A8 / D8 / SCK / PWM + { PORTA, 9, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), ADC_Channel17, PWM1_CH3, TCC1_CH3, EXTERNAL_INT_9 }, // A9 / D9 / MISO / PWM + { PORTA, 10, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), ADC_Channel18, PWM0_CH2, TCC0_CH2, EXTERNAL_INT_10 }, // A10 / D10 / MOSI / PWM + + { PORTA, 18, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // D11 Neopix + { PORTA, 15, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_15 }, // D12 Neopix power + + // D13 fake pin + { PORTA, 27, PIO_OUTPUT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // used as fake output only + + // SPI1 SCK, MISO, MOSI + { PORTA, 23, PIO_SERCOM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), No_ADC_Channel, PWM0_CH5, TCC0_CH5, EXTERNAL_INT_7 }, // D14 / SCK1 + { PORTA, 19, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM3_CH1, TC3_CH1, EXTERNAL_INT_3 }, // D15 / MISO1 + { PORTA, 22, PIO_SERCOM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), No_ADC_Channel, PWM0_CH4, TCC0_CH4, EXTERNAL_INT_6 }, // D16 / MOSI1 + // SPI1 CS + { PORTA, 8, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER_ALT), ADC_Channel16, PWM1_CH2, TCC1_CH2, EXTERNAL_INT_NMI }, // D17 / CS + + // USB pins + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + + +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; + +Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ; + +void SERCOM0_Handler() +{ + Serial1.IrqHandler(); +} + +void initVariant(void) { + // special initialization code just for us + + // turn on neopixel + pinMode(12, OUTPUT); + digitalWrite(12, HIGH); +} diff --git a/variants/qtpy_m0/variant.h b/variants/qtpy_m0/variant.h new file mode 100644 index 000000000..1e4c4e0e1 --- /dev/null +++ b/variants/qtpy_m0/variant.h @@ -0,0 +1,234 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_QTPY_ZERO_ +#define _VARIANT_QTPY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (21u) +#define NUM_DIGITAL_PINS (21u) +#define NUM_ANALOG_INPUTS (9u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_LED_13 (13u) +#define PIN_LED PIN_LED_13 +#define LED_BUILTIN PIN_LED_13 +#define PIN_NEOPIXEL (11u) + +/* + * Analog pins + */ +#define PIN_A0 (0ul) +#define PIN_A1 (PIN_A0 + 1) +#define PIN_A2 (PIN_A0 + 2) +#define PIN_A3 (PIN_A0 + 3) +#define PIN_A6 (PIN_A0 + 6) +#define PIN_A7 (PIN_A0 + 7) +#define PIN_A8 (PIN_A0 + 8) +#define PIN_A9 (PIN_A0 + 9) +#define PIN_A10 (PIN_A0 + 10) +#define PIN_DAC0 (00ul) + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A6 = PIN_A6 ; +static const uint8_t A7 = PIN_A7 ; +static const uint8_t A8 = PIN_A8 ; +static const uint8_t A9 = PIN_A9 ; +static const uint8_t A10 = PIN_A10 ; +static const uint8_t DAC0 = PIN_DAC0; + +#define ADC_RESOLUTION 12 + +// On-board SPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C +#define EXTERNAL_FLASH_USE_SPI SPI1 +#define EXTERNAL_FLASH_USE_CS SS1 + +/* + * Serial interfaces + */ + +// Serial1 +#define PIN_SERIAL1_TX (6ul) +#define PIN_SERIAL1_RX (7ul) +#define PAD_SERIAL1_TX (UART_TX_PAD_2) +#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 2 + +#define PIN_SPI_SCK (8u) +#define PIN_SPI_MISO (9u) +#define PIN_SPI_MOSI (10u) +#define PERIPH_SPI sercom2 +#define PAD_SPI_TX SPI_PAD_2_SCK_3 +#define PAD_SPI_RX SERCOM_RX_PAD_1 + +static const uint8_t SS = PIN_A0 ; // unused, just for reference +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + + +#define PIN_SPI1_SCK (14u) +#define PIN_SPI1_MISO (15u) +#define PIN_SPI1_MOSI (16u) +#define PERIPH_SPI1 sercom3 +#define PAD_SPI1_TX SPI_PAD_0_SCK_1 +#define PAD_SPI1_RX SERCOM_RX_PAD_3 + +static const uint8_t SS1 = 17; +static const uint8_t MOSI1 = PIN_SPI1_MOSI ; +static const uint8_t MISO1 = PIN_SPI1_MISO ; +static const uint8_t SCK1 = PIN_SPI1_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (4u) +#define PIN_WIRE_SCL (5u) +#define PERIPH_WIRE sercom1 +#define WIRE_IT_HANDLER SERCOM1_Handler + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (18ul) +#define PIN_USB_DM (19ul) +#define PIN_USB_DP (20ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 1 + +#define I2S_DEVICE 0 +#define I2S_CLOCK_GENERATOR 3 +#define PIN_I2S_SD (A7) +#define PIN_I2S_SCK (MOSI) +#define PIN_I2S_FS (SCK) + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + +extern Uart Serial1; + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/rotarytrinkey_m0/debug_scripts/variant.gdb b/variants/rotarytrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/rotarytrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/rotarytrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/rotarytrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/rotarytrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/rotarytrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/rotarytrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/rotarytrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/rotarytrinkey_m0/openocd_scripts/rotarytrinkey_m0.cfg b/variants/rotarytrinkey_m0/openocd_scripts/rotarytrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/rotarytrinkey_m0/openocd_scripts/rotarytrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/rotarytrinkey_m0/pins_arduino.h b/variants/rotarytrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/rotarytrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/rotarytrinkey_m0/variant.cpp b/variants/rotarytrinkey_m0/variant.cpp new file mode 100644 index 000000000..e3c824ff5 --- /dev/null +++ b/variants/rotarytrinkey_m0/variant.cpp @@ -0,0 +1,68 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // NeoPixel + { PORTA, 1, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, + + // Encoder pin 1 + { PORTA, 0, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_0 }, + + // Encoder pin 2 + { PORTA, 4, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel4, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_4 }, + + // Encoder switch + { PORTA, 27, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_15 }, + + // Touch pad + { PORTA, 6, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, + + + // USB pins + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + + // Fake DAC pin just so we can compile stuff + { PORTA, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel0, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_2 }, // A0 / D0 / DAC +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; + +/* + * Serial interfaces + + +// Serial1 +#define PIN_SERIAL1_TX (6ul) +#define PIN_SERIAL1_RX (7ul) +#define PAD_SERIAL1_TX (UART_TX_PAD_2) +#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3) + */ diff --git a/variants/rotarytrinkey_m0/variant.h b/variants/rotarytrinkey_m0/variant.h new file mode 100644 index 000000000..a6442918e --- /dev/null +++ b/variants/rotarytrinkey_m0/variant.h @@ -0,0 +1,197 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ROTARYTRINKEY_ZERO_ +#define _VARIANT_ROTARYTRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (9u) +#define NUM_DIGITAL_PINS (5u) +#define NUM_ANALOG_INPUTS (2u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (0u) +#define NUM_NEOPIXEL (1u) + +// ENCODER +#define PIN_ENCODER_A 1 +#define PIN_ENCODER_B 2 +#define PIN_ENCODER_SWITCH 3 + +#define PIN_TOUCH 4 + +/* + * Analog pins + */ +#define PIN_A0 (8ul) +#define PIN_A1 (2) +#define PIN_A2 (4) +#define PIN_DAC0 PIN_A0 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + * Fake SPI Interface just so we can compile + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO PIN_A0 +#define PIN_SPI_MOSI PIN_A0 +#define PIN_SPI_SCK PIN_A0 +#define PERIPH_SPI sercom0 +#define PAD_SPI_TX SPI_PAD_0_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_0 + +static const uint8_t SS = PIN_A0; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 0 + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (5ul) +#define PIN_USB_DM (6ul) +#define PIN_USB_DP (7ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +/* + * Serial interfaces + */ + +// Serial1 +#define PIN_SERIAL1_TX (2ul) // D2 / PA04 / SERCOM 0.0 +#define PIN_SERIAL1_RX (4ul) // D2 / PA06 / SERCOM 0.2 +#define PAD_SERIAL1_TX (UART_TX_PAD_0) +#define PAD_SERIAL1_RX (SERCOM_RX_PAD_2) + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/sht4xtrinkey_m0/debug_scripts/variant.gdb b/variants/sht4xtrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/sht4xtrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/sht4xtrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/sht4xtrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/sht4xtrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/sht4xtrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/sht4xtrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/sht4xtrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/sht4xtrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg b/variants/sht4xtrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/sht4xtrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/sht4xtrinkey_m0/pins_arduino.h b/variants/sht4xtrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/sht4xtrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/sht4xtrinkey_m0/variant.cpp b/variants/sht4xtrinkey_m0/variant.cpp new file mode 100644 index 000000000..7d25cd281 --- /dev/null +++ b/variants/sht4xtrinkey_m0/variant.cpp @@ -0,0 +1,52 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // Fake DAC A0 pin just so we can compile stuff + { PORTA, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel0, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_2 }, // A0 / D0 / DAC + + // touch / A1 + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, // TCC1/WO[1] + + // NeoPixel / D2 + { PORTA, 3, PIO_ANALOG, PIN_ATTR_ANALOG, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + + // I2C SDA D3 & SCL D4 + { PORTA, 4, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // D4 / SDA / PWM + { PORTA, 5, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // D5 / SCL / PWM + + // USB pins D5, D6, D7 + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; diff --git a/variants/sht4xtrinkey_m0/variant.h b/variants/sht4xtrinkey_m0/variant.h new file mode 100644 index 000000000..2a3a0ee9b --- /dev/null +++ b/variants/sht4xtrinkey_m0/variant.h @@ -0,0 +1,188 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_SHT4XTRINKEY_ZERO_ +#define _VARIANT_SHT4XTRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (10u) +#define NUM_DIGITAL_PINS (6u) +#define NUM_ANALOG_INPUTS (2u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (2u) +#define NUM_NEOPIXEL (1u) + +// TOUCH PINS +#define PIN_TOUCH 1 + +/* + * Analog pins + */ +#define PIN_A0 (0ul) +#define PIN_A1 (1) +#define PIN_DAC0 PIN_A0 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + * Fake SPI Interface just so we can compile + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO PIN_A0 +#define PIN_SPI_MOSI PIN_A0 +#define PIN_SPI_SCK PIN_A0 +#define PERIPH_SPI sercom0 +#define PAD_SPI_TX SPI_PAD_0_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_0 + +static const uint8_t SS = PIN_A0; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (3u) +#define PIN_WIRE_SCL (4u) +#define PERIPH_WIRE sercom0 +#define WIRE_IT_HANDLER SERCOM0_Handler + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (5ul) +#define PIN_USB_DM (6ul) +#define PIN_USB_DP (7ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/slidetrinkey_m0/debug_scripts/variant.gdb b/variants/slidetrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/slidetrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/slidetrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/slidetrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/slidetrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/slidetrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/slidetrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/slidetrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/slidetrinkey_m0/openocd_scripts/slidetrinkey_m0.cfg b/variants/slidetrinkey_m0/openocd_scripts/slidetrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/slidetrinkey_m0/openocd_scripts/slidetrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/slidetrinkey_m0/pins_arduino.h b/variants/slidetrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/slidetrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/slidetrinkey_m0/variant.cpp b/variants/slidetrinkey_m0/variant.cpp new file mode 100644 index 000000000..88a348db7 --- /dev/null +++ b/variants/slidetrinkey_m0/variant.cpp @@ -0,0 +1,48 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // Potentiometer + { PORTA, 2, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel0, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_2 }, + + // Touch pad + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, + + // NeoPixel + { PORTA, 4, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel4, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_4 }, + + // USB pins + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; diff --git a/variants/slidetrinkey_m0/variant.h b/variants/slidetrinkey_m0/variant.h new file mode 100644 index 000000000..65d2e75e8 --- /dev/null +++ b/variants/slidetrinkey_m0/variant.h @@ -0,0 +1,188 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_SLIDETRINKEY_ZERO_ +#define _VARIANT_SLIDETRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (6u) +#define NUM_DIGITAL_PINS (3u) +#define NUM_ANALOG_INPUTS (3u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (2u) +#define NUM_NEOPIXEL (2u) + +// POT +#define PIN_POTENTIOMETER (0u) +#define PIN_TOUCH (1u) + +/* + * Analog pins + */ +#define PIN_A0 (0ul) +#define PIN_A1 (1ul) +#define PIN_A2 (2ul) +#define PIN_DAC0 PIN_A0 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + * Fake SPI Interface just so we can compile + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO PIN_A0 +#define PIN_SPI_MOSI PIN_A0 +#define PIN_SPI_SCK PIN_A0 +#define PERIPH_SPI sercom0 +#define PAD_SPI_TX SPI_PAD_0_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_0 + +static const uint8_t SS = PIN_A0; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 0 + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (3ul) +#define PIN_USB_DM (4ul) +#define PIN_USB_DP (5ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +/* + * Serial interfaces + */ + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/thumbsticktrinkey_m0/debug_scripts/variant.gdb b/variants/thumbsticktrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/thumbsticktrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/thumbsticktrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/thumbsticktrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/thumbsticktrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/thumbsticktrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/thumbsticktrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/thumbsticktrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/thumbsticktrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg b/variants/thumbsticktrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/thumbsticktrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/thumbsticktrinkey_m0/pins_arduino.h b/variants/thumbsticktrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/thumbsticktrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/thumbsticktrinkey_m0/variant.cpp b/variants/thumbsticktrinkey_m0/variant.cpp new file mode 100644 index 000000000..91bfef826 --- /dev/null +++ b/variants/thumbsticktrinkey_m0/variant.cpp @@ -0,0 +1,52 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // X (D0) + { PORTA, 9, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel17, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, + // Y (D1) + { PORTA, 11, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_ANALOG), ADC_Channel19, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, + + // Button 1 (D2) + { PORTA, 6, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, + // Button 2 (D3) + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, + + // NeoPixel (D4) + { PORTA, 0, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // TCC1/WO[0] + + // USB pins D5, D6, D7 + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; diff --git a/variants/thumbsticktrinkey_m0/variant.h b/variants/thumbsticktrinkey_m0/variant.h new file mode 100644 index 000000000..e996a8886 --- /dev/null +++ b/variants/thumbsticktrinkey_m0/variant.h @@ -0,0 +1,171 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_THUMBSTICKTRINKEY_ZERO_ +#define _VARIANT_THUMBSTICKTRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (10u) +#define NUM_DIGITAL_PINS (7u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (4u) +#define NUM_NEOPIXEL (1u) + +#define PIN_JOY_X (0ul) +#define PIN_JOY_Y (1ul) +#define PIN_BUTTON1 (2ul) +#define PIN_BUTTON2 (3ul) + +/* + * Analog pins + */ +#define PIN_A0 (0ul) +#define PIN_A1 (1ul) +#define PIN_DAC0 PIN_A0 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 0 + + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 0 + + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (5ul) +#define PIN_USB_DM (6ul) +#define PIN_USB_DP (7ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ + diff --git a/variants/trellis_m4/variant.cpp b/variants/trellis_m4/variant.cpp index 8f44f8ae5..cbe7be633 100644 --- a/variants/trellis_m4/variant.cpp +++ b/variants/trellis_m4/variant.cpp @@ -65,8 +65,8 @@ const PinDescription g_APinDescription[]= // 21..22 I2C pins (SDA/SCL) or Serial1 Pins // ---------------------- - { PORTB, 8, PIO_SERCOM_ALT, PIN_ATTR_ANALOG, ADC_Channel2, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_12 }, // SERCOM 4.0 - { PORTB, 9, PIO_SERCOM_ALT, PIN_ATTR_ANALOG_ALT, ADC_Channel1, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_13 }, // SERCOM 4.1 + { PORTB, 8, PIO_SERCOM_ALT, PIN_ATTR_ANALOG, ADC_Channel2, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, // SERCOM 4.0 + { PORTB, 9, PIO_SERCOM_ALT, PIN_ATTR_ANALOG_ALT, ADC_Channel1, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, // SERCOM 4.1 // ---------------------- // 23 - 28 QSPI (SCK, CS, IO0, IO1, IO2, IO3) @@ -81,8 +81,8 @@ const PinDescription g_APinDescription[]= // -------------------- { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // A0 { PORTA, 5, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // A1 - { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // Amp'd Mic - { PORTA, 7, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel7, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // Raw Mic + { PORTA, 6, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel6, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, // Amp'd Mic + { PORTA, 7, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel7, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, // Raw Mic { PORTB, 8, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel2, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_8 }, // SDA { PORTB, 9, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel3, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, // SCL diff --git a/variants/trinket_m0/variant.cpp b/variants/trinket_m0/variant.cpp index 27c0969b8..5363f8daf 100644 --- a/variants/trinket_m0/variant.cpp +++ b/variants/trinket_m0/variant.cpp @@ -46,8 +46,8 @@ const PinDescription g_APinDescription[]= // GPIO 7 & 8 - DotStar internal data/clock // ---------------------------------------- - { PORTA, 0, PIO_DIGITAL, 0, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, // ADC/AIN[4] - { PORTA, 1, PIO_DIGITAL, 0, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, // ADC/AIN[5] + { PORTA, 0, PIO_DIGITAL, 0, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_0 }, // ADC/AIN[4] + { PORTA, 1, PIO_DIGITAL, 0, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_1 }, // ADC/AIN[5] // GPIO 9, 10, 11 USB Host enable // ---------------------------- diff --git a/variants/trinket_m0/variant.h b/variants/trinket_m0/variant.h index f11b1ef09..12e99e9dc 100644 --- a/variants/trinket_m0/variant.h +++ b/variants/trinket_m0/variant.h @@ -85,8 +85,12 @@ extern "C" #define PIN_LED3 PIN_LED_TXL #define LED_BUILTIN PIN_LED_13 // DotStar LED -#define INTERNAL_DS_DATA 7 -#define INTERNAL_DS_CLK 8 +#define INTERNAL_DS_DATA (7u) +#define INTERNAL_DS_CLK (8u) +#define PIN_DOTSTAR_DATA (7u) +#define PIN_DOTSTAR_CLK (8u) +#define PIN_DOTSTAR_CLOCK PIN_DOTSTAR_CLK +#define DOTSTAR_NUM (1u) /* * Analog pins diff --git a/variants/trrstrinkey_m0/debug_scripts/variant.gdb b/variants/trrstrinkey_m0/debug_scripts/variant.gdb new file mode 100644 index 000000000..13ee2a173 --- /dev/null +++ b/variants/trrstrinkey_m0/debug_scripts/variant.gdb @@ -0,0 +1,31 @@ +# +# Arduino Zero OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define 'reset' command +define reset + +info reg + +break main + +# End of 'reset' command +end + +target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" diff --git a/variants/trrstrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld b/variants/trrstrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld new file mode 100644 index 000000000..357946455 --- /dev/null +++ b/variants/trrstrinkey_m0/linker_scripts/gcc/flash_with_bootloader.ld @@ -0,0 +1,216 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */ + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.sketch_boot)) + + . = ALIGN(0x2000); + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/trrstrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld b/variants/trrstrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld new file mode 100644 index 000000000..ebeeee37f --- /dev/null +++ b/variants/trrstrinkey_m0/linker_scripts/gcc/flash_without_bootloader.ld @@ -0,0 +1,214 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Linker script to configure memory regions. + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __ram_end__ + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + __text_start__ = .; + + KEEP(*(.isr_vector)) + *(.text*) + + 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*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * uncomment .copy.table section and, + * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */ + /* + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) + __copy_table_end__ = .; + } > FLASH + */ + + /* To clear multiple BSS sections, + * uncomment .zero.table section and, + * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */ + /* + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) + __zero_table_end__ = .; + } > FLASH + */ + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = 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 = .); + + KEEP(*(.jcr*)) + . = ALIGN(16); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): + { + __end__ = .; + PROVIDE(end = .); + *(.heap*) + __HeapLimit = .; + } > RAM + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM) ; + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + __ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ; + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/variants/trrstrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg b/variants/trrstrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg new file mode 100644 index 000000000..e4c3f81dc --- /dev/null +++ b/variants/trrstrinkey_m0/openocd_scripts/sht4xtrinkey_m0.cfg @@ -0,0 +1,28 @@ +# +# Adafruit ItsyBitsy M0 OpenOCD script. +# +# Copyright (c) 2014-2015 Arduino LLC. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# chip name +set CHIPNAME at91samd21e18 +set ENDIAN little + +# choose a port here +set telnet_port 0 + +source [find target/at91samdXX.cfg] diff --git a/variants/trrstrinkey_m0/pins_arduino.h b/variants/trrstrinkey_m0/pins_arduino.h new file mode 100644 index 000000000..db0e40c3d --- /dev/null +++ b/variants/trrstrinkey_m0/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/variants/trrstrinkey_m0/variant.cpp b/variants/trrstrinkey_m0/variant.cpp new file mode 100644 index 000000000..99184204b --- /dev/null +++ b/variants/trrstrinkey_m0/variant.cpp @@ -0,0 +1,64 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "Arduino.h" +/* + * Pins descriptions + */ +const PinDescription g_APinDescription[]= +{ + // TRRS Tip, D0 / DAC / A0 + { PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, + // TRRS Tip Switch, D1, A1 + { PORTA, 3, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel1, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_3 }, + + // TRRS Ring 1, D2, A2 + { PORTA, 6, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel6, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, + // TRRS Ring 1 Switch, D3, A3 + { PORTA, 7, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER|PIN_ATTR_ANALOG), ADC_Channel7, PWM1_CH1, TCC1_CH1, EXTERNAL_INT_7 }, + + // TRRS Ring2, D4, A4 + { PORTA, 4, PIO_ANALOG, PIN_ATTR_DIGITAL, ADC_Channel4, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, + + // TRRS Sleeve, D5, A5 + { PORTA, 5, PIO_ANALOG, PIN_ATTR_DIGITAL, ADC_Channel5, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, + + // Internal NeoPixel / D6 + { PORTA, 1, PIO_ANALOG, PIN_ATTR_ANALOG, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, + + // QT SDA D7 + { PORTA, 8, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel16, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_NMI }, // TCC0/WO[0] + + // QT SCL D8 + { PORTA, 9, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel17, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_9 }, // TCC0/WO[1] + + // USB pins D9, D10, D11 + { PORTA, 28, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB Host enable + { PORTA, 24, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DM + { PORTA, 25, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // USB/DP + +} ; + +const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ; + +// Multi-serial objects instantiation +SERCOM sercom0( SERCOM0 ) ; +SERCOM sercom1( SERCOM1 ) ; +SERCOM sercom2( SERCOM2 ) ; +SERCOM sercom3( SERCOM3 ) ; diff --git a/variants/trrstrinkey_m0/variant.h b/variants/trrstrinkey_m0/variant.h new file mode 100644 index 000000000..998d00ddb --- /dev/null +++ b/variants/trrstrinkey_m0/variant.h @@ -0,0 +1,207 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_TRRSTRINKEY_ZERO_ +#define _VARIANT_TRRSTRINKEY_ZERO_ + +// The definitions here needs a SAMD core >=1.6.10 +#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610 + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC (32768ul) + +/** Master clock frequency */ +#define VARIANT_MCK (F_CPU) + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +#include "SERCOM.h" +#include "Uart.h" +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (10u) +#define NUM_DIGITAL_PINS (7u) +#define NUM_ANALOG_INPUTS (6u) +#define NUM_ANALOG_OUTPUTS (1u) +#define analogInputToDigitalPin(p) (p) + +#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) ) +#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT.reg) ) +#define portInputRegister(port) ( &(port->IN.reg) ) +#define portModeRegister(port) ( &(port->DIR.reg) ) +#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER ) + +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// LEDs +#define PIN_NEOPIXEL (6u) +#define NUM_NEOPIXEL (1u) + +#define PIN_TIP (0ul) +#define PIN_TIP_SWITCH (1ul) +#define PIN_RING1 (2ul) +#define PIN_RING1_SWITCH (3ul) +#define PIN_RING2 (4ul) +#define PIN_SLEEVE (5ul) + +/* + * Analog pins + */ +#define PIN_A0 (0ul) +#define PIN_A1 (1ul) +#define PIN_A2 (2ul) +#define PIN_A3 (3ul) +#define PIN_A4 (4ul) +#define PIN_A5 (5ul) + +#define PIN_DAC0 PIN_A0 + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t A5 = PIN_A5; + +#define ADC_RESOLUTION 12 + + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO PIN_RING1 +#define PIN_SPI_MOSI PIN_RING2 +#define PIN_SPI_SCK PIN_SLEEVE +#define PERIPH_SPI sercom0 +#define PAD_SPI_TX SPI_PAD_0_SCK_1 +#define PAD_SPI_RX SERCOM_RX_PAD_2 + +static const uint8_t SS = PIN_TIP; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces, fake just for compilation + */ +#define WIRE_INTERFACES_COUNT 2 + +// QT Port +#define PIN_WIRE_SDA (7ul) +#define PIN_WIRE_SCL (8ul) +#define PERIPH_WIRE sercom2 +#define WIRE_IT_HANDLER SERCOM2_Handler + +// second, sekret I2C on the headphone jack +#define PIN_WIRE1_SDA PIN_RING2 +#define PIN_WIRE1_SCL PIN_SLEEVE +#define PERIPH_WIRE1 sercom0 +#define WIRE1_IT_HANDLER SERCOM0_Handler + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +/* + * USB + */ +#define PIN_USB_HOST_ENABLE (9ul) +#define PIN_USB_DM (10ul) +#define PIN_USB_DP (11ul) +/* + * I2S Interfaces + */ +#define I2S_INTERFACES_COUNT 0 + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +/* ========================= + * ===== SERCOM DEFINITION + * ========================= +*/ +extern SERCOM sercom0; +extern SERCOM sercom1; +extern SERCOM sercom2; +extern SERCOM sercom3; +extern SERCOM sercom4; +extern SERCOM sercom5; + + +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_MONITOR Serial +// Serial has no physical pins broken out, so it's not listed as HARDWARE port +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif /* _VARIANT_ARDUINO_ZERO_ */ +