diff --git a/.travis.yml b/.travis.yml index a412ae4..e562728 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ python: - "2.7" env: + - PLATFORMIO_PROJECT_DIR=examples/arduino-blink + - PLATFORMIO_PROJECT_DIR=examples/arduino-external-libs + - PLATFORMIO_PROJECT_DIR=examples/arduino-internal-libs - PLATFORMIO_PROJECT_DIR=examples/cmsis-blink - PLATFORMIO_PROJECT_DIR=examples/libopencm3-blink - PLATFORMIO_PROJECT_DIR=examples/mbed-blink diff --git a/README.md b/README.md index 5902c24..c417e33 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The STM32 family of 32-bit Flash MCUs based on the ARM Cortex-M processor is des 1. [Install PlatformIO CLI](http://docs.platformio.org/en/latest/installation.html) 2. Install ST STM32 development platform: ```bash -# isntall the latest stable version +# install the latest stable version > platformio platform install ststm32 # install development version diff --git a/boards/bluepill_f103c8.json b/boards/bluepill_f103c8.json index 803bb1a..3dfc172 100644 --- a/boards/bluepill_f103c8.json +++ b/boards/bluepill_f103c8.json @@ -1,21 +1,22 @@ { "build": { - "core": "stm32", - "cpu": "cortex-m3", - "f_cpu": "72000000L", - "ldscript": "stm32f103xb.ld", - "mcu": "stm32f103c8t6", + "core": "stm32", + "cpu": "cortex-m3", + "f_cpu": "72000000L", + "ldscript": "stm32f103xb.ld", + "mcu": "stm32f103c8t6", "variant": "stm32f1" - }, + }, "frameworks": [ - "mbed" - ], - "name": "BluePill F103C8", + "mbed", + "arduino" + ], + "name": "BluePill F103C8", "upload": { - "maximum_ram_size": 20480, + "maximum_ram_size": 20480, "maximum_size": 65536, "protocol": "stlink" - }, - "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103c8.html", + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103c8.html", "vendor": "Generic" } diff --git a/boards/disco_f746ng.json b/boards/disco_f746ng.json new file mode 100644 index 0000000..293a715 --- /dev/null +++ b/boards/disco_f746ng.json @@ -0,0 +1,18 @@ +{ + "build": { + "cpu": "cortex-m7", + "f_cpu": "216000000L", + "mcu": "stm32f746ngh6" + }, + "frameworks": [ + "mbed" + ], + "name": "ST 32F746GDISCOVERY", + "upload": { + "maximum_ram_size": 327680, + "maximum_size": 1048576, + "protocol": "stlink" + }, + "url": "http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-discovery-kits/32f746gdiscovery.html", + "vendor": "ST" +} \ No newline at end of file diff --git a/boards/genericSTM32F103C8.json b/boards/genericSTM32F103C8.json new file mode 100644 index 0000000..f5843ff --- /dev/null +++ b/boards/genericSTM32F103C8.json @@ -0,0 +1,28 @@ +{ + "build": { + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DMCU_STM32F103C8", + "f_cpu": "72000000L", + "hwids": [ + ["0x1EAF", "0x0003"], + ["0x1EAF", "0x0004"] + ], + "ldscript": "jtag_c8.ld", + "mcu": "stm32f103c8", + "variant": "generic_stm32f103c" + }, + "frameworks": ["arduino"], + "name": "STM32F103C8 (20k RAM. 64k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 20480, + "maximum_size": 65536, + "protocol": "maple_serial", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103c8.html", + "vendor": "Generic" +} \ No newline at end of file diff --git a/boards/genericSTM32F103CB.json b/boards/genericSTM32F103CB.json new file mode 100644 index 0000000..47ef822 --- /dev/null +++ b/boards/genericSTM32F103CB.json @@ -0,0 +1,28 @@ +{ + "build": { + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DMCU_STM32F103CB", + "f_cpu": "72000000L", + "hwids": [ + ["0x1EAF", "0x0003"], + ["0x1EAF", "0x0004"] + ], + "ldscript": "jtag.ld", + "mcu": "stm32f103cb", + "variant": "generic_stm32f103c" + }, + "frameworks": ["arduino"], + "name": "STM32F103CB (20k RAM. 128k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 20480, + "maximum_size": 131072, + "protocol": "maple_serial", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103cb.html", + "vendor": "Generic" +} \ No newline at end of file diff --git a/boards/genericSTM32F103R8.json b/boards/genericSTM32F103R8.json new file mode 100644 index 0000000..5fd9c9a --- /dev/null +++ b/boards/genericSTM32F103R8.json @@ -0,0 +1,28 @@ +{ + "build": { + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DMCU_STM32F103R8", + "f_cpu": "72000000L", + "hwids": [ + ["0x1EAF", "0x0003"], + ["0x1EAF", "0x0004"] + ], + "ldscript": "stm32f103r8.ld", + "mcu": "stm32f103r8", + "variant": "generic_stm32f103r8" + }, + "frameworks": ["arduino"], + "name": "STM32F103R8 (20k RAM. 64 Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 20480, + "maximum_size": 65536, + "protocol": "maple_serial", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103r8.html", + "vendor": "Generic" +} \ No newline at end of file diff --git a/boards/genericSTM32F103RB.json b/boards/genericSTM32F103RB.json new file mode 100644 index 0000000..051898e --- /dev/null +++ b/boards/genericSTM32F103RB.json @@ -0,0 +1,28 @@ +{ + "build": { + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DMCU_STM32F103RB", + "f_cpu": "72000000L", + "hwids": [ + ["0x1EAF", "0x0003"], + ["0x1EAF", "0x0004"] + ], + "ldscript": "stm32f103rb.ld", + "mcu": "stm32f103rb", + "variant": "generic_stm32f103r8" + }, + "frameworks": ["arduino"], + "name": "STM32F103RB (20k RAM. 128k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 20480, + "maximum_size": 131072, + "protocol": "maple_serial", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103rb.html", + "vendor": "Generic" +} \ No newline at end of file diff --git a/boards/genericSTM32F103RC.json b/boards/genericSTM32F103RC.json new file mode 100644 index 0000000..ad90515 --- /dev/null +++ b/boards/genericSTM32F103RC.json @@ -0,0 +1,28 @@ +{ + "build": { + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DMCU_STM32F103RC", + "f_cpu": "72000000L", + "hwids": [ + ["0x1EAF", "0x0003"], + ["0x1EAF", "0x0004"] + ], + "ldscript": "stm32f103rc.ld", + "mcu": "stm32f103rc", + "variant": "generic_stm32f103r" + }, + "frameworks": ["arduino"], + "name": "STM32F103RC (48k RAM. 256k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 49152, + "maximum_size": 262144, + "protocol": "maple_serial", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103rc.html", + "vendor": "Generic" +} \ No newline at end of file diff --git a/boards/genericSTM32F103RE.json b/boards/genericSTM32F103RE.json new file mode 100644 index 0000000..3599f26 --- /dev/null +++ b/boards/genericSTM32F103RE.json @@ -0,0 +1,28 @@ +{ + "build": { + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DMCU_STM32F103RE", + "f_cpu": "72000000L", + "hwids": [ + ["0x1EAF", "0x0003"], + ["0x1EAF", "0x0004"] + ], + "ldscript": "stm32f103re.ld", + "mcu": "stm32f103re", + "variant": "generic_stm32f103r" + }, + "frameworks": ["arduino"], + "name": "STM32F103RE (64k RAM. 512k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 65536, + "maximum_size": 524288, + "protocol": "maple_serial", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103re.html", + "vendor": "Generic" +} \ No newline at end of file diff --git a/boards/maple.json b/boards/maple.json new file mode 100644 index 0000000..4f913bd --- /dev/null +++ b/boards/maple.json @@ -0,0 +1,28 @@ +{ + "build": { + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DMCU_STM32F103RB", + "f_cpu": "72000000L", + "hwids": [ + ["0x1EAF", "0x0003"], + ["0x1EAF", "0x0004"] + ], + "ldscript": "flash.ld", + "mcu": "stm32f103rb_maple", + "variant": "maple" + }, + "frameworks": ["arduino"], + "name": "Olimexino STM32", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 17000, + "maximum_size": 108000, + "protocol": "dfu", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/", + "vendor": "Olimex" +} diff --git a/boards/mts_mdot_f405rg.json b/boards/mts_mdot_f405rg.json new file mode 100644 index 0000000..ecf7d3d --- /dev/null +++ b/boards/mts_mdot_f405rg.json @@ -0,0 +1,17 @@ +{ + "build": { + "cpu": "cortex-m4", + "f_cpu": "100000000L", + "mcu": "stm32f411ret6" + }, + "frameworks": [ + "mbed" + ], + "name": "MultiTech mDot", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 524288 + }, + "url": "https://developer.mbed.org/platforms/MTS-mDot-F411/", + "vendor": "MultiTech" +} \ No newline at end of file diff --git a/boards/nucleo_f207zg.json b/boards/nucleo_f207zg.json new file mode 100644 index 0000000..d91fdb3 --- /dev/null +++ b/boards/nucleo_f207zg.json @@ -0,0 +1,18 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m3", + "f_cpu": "120000000L", + "mcu": "stm32f207zgt6" + }, + "frameworks": [ + "mbed" + ], + "name": "ST Nucleo F207ZG", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 1048576 + }, + "url": "https://developer.mbed.org/platforms/ST-Nucleo-F207ZG/", + "vendor": "ST" +} \ No newline at end of file diff --git a/boards/nucleo_f429zi.json b/boards/nucleo_f429zi.json new file mode 100644 index 0000000..f142247 --- /dev/null +++ b/boards/nucleo_f429zi.json @@ -0,0 +1,17 @@ +{ + "build": { + "cpu": "cortex-m4", + "f_cpu": "180000000L", + "mcu": "stm32f429zit6" + }, + "frameworks": [ + "mbed" + ], + "name": "ST Nucleo F429ZI", + "upload": { + "maximum_ram_size": 262144, + "maximum_size": 2097152 + }, + "url": "https://developer.mbed.org/platforms/ST-Nucleo-F429ZI/", + "vendor": "ST" +} \ No newline at end of file diff --git a/boards/nucleo_f446ze.json b/boards/nucleo_f446ze.json new file mode 100644 index 0000000..b10f6b5 --- /dev/null +++ b/boards/nucleo_f446ze.json @@ -0,0 +1,17 @@ +{ + "build": { + "cpu": "cortex-m4", + "f_cpu": "180000000L", + "mcu": "stm32f446zet6" + }, + "frameworks": [ + "mbed" + ], + "name": "ST Nucleo F446ZE", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 524288 + }, + "url": "https://developer.mbed.org/platforms/ST-Nucleo-F446ZE/", + "vendor": "ST" +} \ No newline at end of file diff --git a/boards/nucleo_f746zg.json b/boards/nucleo_f746zg.json new file mode 100644 index 0000000..046ac06 --- /dev/null +++ b/boards/nucleo_f746zg.json @@ -0,0 +1,17 @@ +{ + "build": { + "cpu": "cortex-m7", + "f_cpu": "216000000L", + "mcu": "stm32f746zgt6" + }, + "frameworks": [ + "mbed" + ], + "name": "ST Nucleo F746ZG", + "upload": { + "maximum_ram_size": 327680, + "maximum_size": 1048576 + }, + "url": "https://developer.mbed.org/platforms/ST-Nucleo-F446ZE/", + "vendor": "ST" +} \ No newline at end of file diff --git a/boards/nucleo_f767zi.json b/boards/nucleo_f767zi.json new file mode 100644 index 0000000..bf7f6b0 --- /dev/null +++ b/boards/nucleo_f767zi.json @@ -0,0 +1,17 @@ +{ + "build": { + "cpu": "cortex-m7", + "f_cpu": "216000000L", + "mcu": "stm32f746zgt6" + }, + "frameworks": [ + "mbed" + ], + "name": "ST Nucleo F767ZI", + "upload": { + "maximum_ram_size": 524288, + "maximum_size": 2097152 + }, + "url": "https://developer.mbed.org/platforms/ST-Nucleo-F767ZI/", + "vendor": "ST" +} \ No newline at end of file diff --git a/boards/nucleo_l011k4.json b/boards/nucleo_l011k4.json new file mode 100644 index 0000000..16e9fa0 --- /dev/null +++ b/boards/nucleo_l011k4.json @@ -0,0 +1,17 @@ +{ + "build": { + "cpu": "cortex-m0plus", + "f_cpu": "32000000L", + "mcu": "stm32l011k4t6" + }, + "frameworks": [ + "mbed" + ], + "name": "ST Nucleo L011K4", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 16384 + }, + "url": "https://developer.mbed.org/platforms/ST-Nucleo-L011K4/", + "vendor": "ST" +} \ No newline at end of file diff --git a/boards/nucleo_l432kc.json b/boards/nucleo_l432kc.json new file mode 100644 index 0000000..9cf7329 --- /dev/null +++ b/boards/nucleo_l432kc.json @@ -0,0 +1,17 @@ +{ + "build": { + "cpu": "cortex-m4", + "f_cpu": "80000000L", + "mcu": "stm32l432kcu6" + }, + "frameworks": [ + "mbed" + ], + "name": "ST Nucleo L432KC", + "upload": { + "maximum_ram_size": 65536, + "maximum_size": 262144 + }, + "url": "https://developer.mbed.org/platforms/ST-Nucleo-L432KC/", + "vendor": "ST" +} diff --git a/boards/seeedArchMax.json b/boards/seeedArchMax.json index ec91fd4..6bfff05 100644 --- a/boards/seeedArchMax.json +++ b/boards/seeedArchMax.json @@ -1,17 +1,17 @@ { "build": { - "cpu": "cortex-m4", - "f_cpu": "168000000L", + "cpu": "cortex-m4", + "f_cpu": "168000000L", "mcu": "stm32f407vet6" - }, + }, "frameworks": [ "mbed" - ], - "name": "SeeedStudio Arch Max", + ], + "name": "Seeed Arch Max", "upload": { - "maximum_ram_size": 196608, + "maximum_ram_size": 196608, "maximum_size": 524288 - }, - "url": "https://developer.mbed.org/platforms/Seeed-Arch-Max/", + }, + "url": "https://developer.mbed.org/platforms/Seeed-Arch-Max/", "vendor": "SeeedStudio" } \ No newline at end of file diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py new file mode 100644 index 0000000..baab9aa --- /dev/null +++ b/builder/frameworks/arduino.py @@ -0,0 +1,141 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Arduino + +Arduino Wiring-based Framework allows writing cross-platform software to +control devices attached to a wide range of Arduino boards to create all +kinds of creative coding, interactive objects, spaces or physical experiences. + +http://www.stm32duino.com +""" + +from os.path import isdir, join + +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() +platform = env.PioPlatform() +board = env.BoardConfig() + +if board.id == "bluepill_f103c8": + board = env.BoardConfig("genericSTM32F103C8") + env['LDSCRIPT_PATH'] = board.get("build.ldscript") + env.ProcessFlags(board.get("build.extra_flags")) + +if "stm32f103" in board.get("build.mcu", ""): + FRAMEWORK_DIR = join(platform.get_package_dir( + "framework-arduinoststm32"), "STM32F1") + env.Append( + CPPDEFINES=[ + "ERROR_LED_PORT=GPIOB", + "ERROR_LED_PIN=1", + "ARDUINO_ARCH_STM32F1" + ] + ) + if "stm32f103r8" or "stm32f103rb" in board.get( + "build.mcu", ""): + env.Append(CPPDEFINES=[ + "BOARD_generic_stm32f103r8", "ARDUINO_GENERIC_STM32F103R"]) + elif "stm32f103rc" or "stm32f103re" in board.get( + "build.mcu", ""): + env.Append(CPPDEFINES=[ + "BOARD_generic_stm32f103r", "ARDUINO_GENERIC_STM32F103R"]) + elif "stm32f103c" in board.get("build.mcu", ""): + env.Append(CPPDEFINES=[ + "BOARD_generic_stm32f103c", "ARDUINO_GENERIC_STM32F103C"]) + elif "stm32f103rb_maple" in board.get("build.mcu", ""): + env.Append(CPPDEFINES=["BOARD_maple", "ARDUINO_MAPLE_REV3"]) + +FRAMEWORK_VERSION = platform.get_package_version("framework-arduinoststm32") +assert isdir(FRAMEWORK_DIR) + +ARDUINO_VERSION = int(FRAMEWORK_VERSION.replace(".", "").strip()) + +env.Append( + CPPDEFINES=[ + "ARDUINO=%s" % FRAMEWORK_VERSION.split(".")[1] + ], + + CPPPATH=[ + join(FRAMEWORK_DIR, "cores", board.get("build.core")), + join(FRAMEWORK_DIR, "system", "libmaple"), + join(FRAMEWORK_DIR, "system", "libmaple", "include"), + join(FRAMEWORK_DIR, "system", "libmaple", "usb", "stm32f1"), + join(FRAMEWORK_DIR, "system", "libmaple", "usb", "usb_lib") + ], + + LIBPATH=[ + join(FRAMEWORK_DIR, "variants", + board.get("build.variant"), "ld") + ] +) + +for item in ("-nostartfiles", "-nostdlib"): + if item in env['LINKFLAGS']: + env['LINKFLAGS'].remove(item) + +ld = board.get("build.ldscript") + +if env.subst("$UPLOAD_PROTOCOL") == "dfu": + if "stm32f103c" in board.get("build.mcu", ""): + ld = "bootloader_20.ld" + elif "stm32f103r" in board.get("build.mcu", ""): + ld = "bootloader.ld" + if "stm32f103rb_maple" in board.get("build.mcu", ""): + env.Append(CPPDEFINES=["VECT_TAB_ADDR=0x8005000", "SERIAL_USB"]) + else: + env.Append(CPPDEFINES=[ + "VECT_TAB_ADDR=0x8002000", "SERIAL_USB", "GENERIC_BOOTLOADER"]) + env.Replace(LDSCRIPT_PATH=ld) +else: + env.Append(CPPDEFINES=["VECT_TAB_ADDR=0x8000000"]) + +# +# Lookup for specific core's libraries +# + +BOARD_CORELIBDIRNAME = board.get("build.core", "") +env.Append( + LIBSOURCE_DIRS=[ + join(FRAMEWORK_DIR, "libraries", "__cores__", BOARD_CORELIBDIRNAME), + join(FRAMEWORK_DIR, "libraries") + ] +) + +# +# Target: Build Core Library +# + +libs = [] + +if "build.variant" in board: + env.Append( + CPPPATH=[ + join(FRAMEWORK_DIR, "variants", + board.get("build.variant")) + ] + ) + libs.append(env.BuildLibrary( + join("$BUILD_DIR", "FrameworkArduinoVariant"), + join(FRAMEWORK_DIR, "variants", board.get("build.variant")) + )) + +libs.append(env.BuildLibrary( + join("$BUILD_DIR", "FrameworkArduino"), + join(FRAMEWORK_DIR, "cores", board.get("build.core")) +)) + +env.Prepend(LIBS=libs) diff --git a/builder/frameworks/mbed b/builder/frameworks/mbed index 714697c..6d1698a 160000 --- a/builder/frameworks/mbed +++ b/builder/frameworks/mbed @@ -1 +1 @@ -Subproject commit 714697c05922acd2912da5e7b5fdd76588b3a3e3 +Subproject commit 6d1698a1da1bd390034acf337752da7a82463852 diff --git a/builder/main.py b/builder/main.py index 66b570a..17ee510 100644 --- a/builder/main.py +++ b/builder/main.py @@ -21,6 +21,8 @@ from os.path import isfile, join from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, DefaultEnvironment) +from platformio import util + env = DefaultEnvironment() env.Replace( @@ -134,12 +136,40 @@ if env.subst("$UPLOAD_PROTOCOL") == "gdb": join("$BUILD_DIR", "firmware.elf"), "-batch", "-x", - '"%s"' % join("$PROJECT_DIR", "upload.gdb") + join("$PROJECT_DIR", "upload.gdb") ], UPLOADCMD='$UPLOADER $UPLOADERFLAGS' ) +if "arduino" in env.subst("$PIOFRAMEWORK"): + uploadProtocol = "" + uploadParams = "" + if "linux" in util.get_systype(): + uploadPlatform = "linux" + elif "darwin" in util.get_systype(): + uploadPlatform = "macosx" + else: + uploadPlatform = "win" + if env.subst("$UPLOAD_PROTOCOL") == "serial": + uploadProtocol = "serial_upload" + uploadParams = "{upload.altID} {upload.usbID} $PROJECT_DIR/$SOURCES" + elif env.subst("$UPLOAD_PROTOCOL") == "dfu": + uploadProtocol = "maple_upload" + usbids = env.BoardConfig().get("build.hwids") + usbid = '2 %s:%s' % (usbids[0][0], usbids[0][1]) + env.Replace(UPLOADERFLAGS=usbid) + uploadParams = usbid + env.Replace( + UPLOADER=join( + env.PioPlatform().get_package_dir( + "framework-arduinoststm32") or "", + "tools", uploadPlatform, uploadProtocol), + UPLOADERFLAGS=["$UPLOAD_PORT"], + UPLOADERPARAMS=uploadParams, + UPLOADCMD=( + '$UPLOADER $UPLOADERFLAGS $UPLOADERPARAMS $PROJECT_DIR/$SOURCES')) + # # Target: Build executable and linkable firmware # @@ -174,6 +204,12 @@ if "mbed" in env.subst("$PIOFRAMEWORK") and not env.subst("$UPLOAD_PROTOCOL"): [env.VerboseAction(env.AutodetectUploadPort, "Looking for upload disk..."), env.VerboseAction(env.UploadToDisk, "Uploading $SOURCE")]) +elif "arduino" in env.subst("$PIOFRAMEWORK"): + upload = env.Alias( + ["upload", "uploadlazy"], target_firm, + [env.VerboseAction(env.AutodetectUploadPort, + "Looking for upload disk..."), + env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]) else: upload = env.Alias(["upload", "uploadlazy"], target_firm, env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")) diff --git a/examples/arduino-blink/.gitignore b/examples/arduino-blink/.gitignore new file mode 100644 index 0000000..5402c18 --- /dev/null +++ b/examples/arduino-blink/.gitignore @@ -0,0 +1,3 @@ +.pioenvs +.clang_complete +.gcc-flags.json diff --git a/examples/arduino-blink/.travis.yml b/examples/arduino-blink/.travis.yml new file mode 100644 index 0000000..b636184 --- /dev/null +++ b/examples/arduino-blink/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/latest/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/latest/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/arduino-blink/README.rst b/examples/arduino-blink/README.rst new file mode 100644 index 0000000..b445869 --- /dev/null +++ b/examples/arduino-blink/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/arduino-blink + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e maple + + # Upload firmware for the specific environment + > platformio run -e maple --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/arduino-blink/lib/readme.txt b/examples/arduino-blink/lib/readme.txt new file mode 100644 index 0000000..607a92a --- /dev/null +++ b/examples/arduino-blink/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organized `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/latest/projectconf.html#lib-install + diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini new file mode 100644 index 0000000..d36e0c2 --- /dev/null +++ b/examples/arduino-blink/platformio.ini @@ -0,0 +1,18 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[env:maple] +platform = ststm32 +framework = arduino +board = maple + +[env:genericSTM32F103RB] +platform = ststm32 +framework = arduino +board = genericSTM32F103RB diff --git a/examples/arduino-blink/src/Blink.cpp b/examples/arduino-blink/src/Blink.cpp new file mode 100644 index 0000000..c9f0e6a --- /dev/null +++ b/examples/arduino-blink/src/Blink.cpp @@ -0,0 +1,25 @@ +/* + * Blink + * Turns on an LED on for one second, + * then off for one second, repeatedly. + */ + +#include + +void setup() +{ + // initialize LED digital pin as an output. + pinMode(PC13, OUTPUT); +} + +void loop() +{ + // turn the LED on (HIGH is the voltage level) + digitalWrite(PC13, HIGH); + // wait for a second + delay(1000); + // turn the LED off by making the voltage LOW + digitalWrite(PC13, LOW); + // wait for a second + delay(1000); +} diff --git a/examples/arduino-external-libs/.gitignore b/examples/arduino-external-libs/.gitignore new file mode 100644 index 0000000..5dac9f5 --- /dev/null +++ b/examples/arduino-external-libs/.gitignore @@ -0,0 +1,4 @@ +.pioenvs +.piolibdeps +.clang_complete +.gcc-flags.json diff --git a/examples/arduino-external-libs/.travis.yml b/examples/arduino-external-libs/.travis.yml new file mode 100644 index 0000000..b636184 --- /dev/null +++ b/examples/arduino-external-libs/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/latest/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/latest/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/arduino-external-libs/README.rst b/examples/arduino-external-libs/README.rst new file mode 100644 index 0000000..199cbd4 --- /dev/null +++ b/examples/arduino-external-libs/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/arduino-external-libs + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e maple + + # Upload firmware for the specific environment + > platformio run -e maple --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/arduino-external-libs/lib/readme.txt b/examples/arduino-external-libs/lib/readme.txt new file mode 100644 index 0000000..607a92a --- /dev/null +++ b/examples/arduino-external-libs/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organized `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/latest/projectconf.html#lib-install + diff --git a/examples/arduino-external-libs/platformio.ini b/examples/arduino-external-libs/platformio.ini new file mode 100644 index 0000000..3427c11 --- /dev/null +++ b/examples/arduino-external-libs/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[env:maple] +platform = ststm32 +framework = arduino +board = maple +lib_deps = BMP180 + +[env:genericSTM32F103RB] +platform = ststm32 +framework = arduino +board = genericSTM32F103RB +lib_deps = BMP180 diff --git a/examples/arduino-external-libs/src/BMP180_altitude_example.ino b/examples/arduino-external-libs/src/BMP180_altitude_example.ino new file mode 100644 index 0000000..c06ce1b --- /dev/null +++ b/examples/arduino-external-libs/src/BMP180_altitude_example.ino @@ -0,0 +1,169 @@ +/* SFE_BMP180 altitude example sketch + +This sketch shows how to use the Bosch BMP180 pressure sensor +as an altimiter. +https://www.sparkfun.com/products/11824 + +Like most pressure sensors, the BMP180 measures absolute pressure. +Since absolute pressure varies with altitude, you can use the pressure +to determine your altitude. + +Because pressure also varies with weather, you must first take a pressure +reading at a known baseline altitude. Then you can measure variations +from that pressure + +Hardware connections: + +- (GND) to GND ++ (VDD) to 3.3V + +(WARNING: do not connect + to 5V or the sensor will be damaged!) + +You will also need to connect the I2C pins (SCL and SDA) to your +Arduino. The pins are different on different Arduinos: + +Any Arduino pins labeled: SDA SCL +Uno, Redboard, Pro: A4 A5 +Mega2560, Due: 20 21 +Leonardo: 2 3 + +Leave the IO (VDDIO) pin unconnected. This pin is for connecting +the BMP180 to systems with lower logic levels such as 1.8V + +Have fun! -Your friends at SparkFun. + +The SFE_BMP180 library uses floating-point equations developed by the +Weather Station Data Logger project: http://wmrx00.sourceforge.net/ + +Our example code uses the "beerware" license. You can do anything +you like with this code. No really, anything. If you find it useful, +buy me a beer someday. + +V10 Mike Grusin, SparkFun Electronics 10/24/2013 +*/ + +// Your sketch must #include this library, and the Wire library. +// (Wire is a standard library included with Arduino.): + +#include +#include +#include + +// You will need to create an SFE_BMP180 object, here called "pressure": + +SFE_BMP180 pressure; + +double baseline; // baseline pressure + +void setup() +{ + Serial.begin(9600); + Serial.println("REBOOT"); + + // Initialize the sensor (it is important to get calibration values stored on the device). + + if (pressure.begin()) + Serial.println("BMP180 init success"); + else + { + // Oops, something went wrong, this is usually a connection problem, + // see the comments at the top of this sketch for the proper connections. + + Serial.println("BMP180 init fail (disconnected?)\n\n"); + while(1); // Pause forever. + } + + // Get the baseline pressure: + + baseline = getPressure(); + + Serial.print("baseline pressure: "); + Serial.print(baseline); + Serial.println(" mb"); +} + +void loop() +{ + double a,P; + + // Get a new pressure reading: + + P = getPressure(); + + // Show the relative altitude difference between + // the new reading and the baseline reading: + + a = pressure.altitude(P,baseline); + + Serial.print("relative altitude: "); + if (a >= 0.0) Serial.print(" "); // add a space for positive numbers + Serial.print(a,1); + Serial.print(" meters, "); + if (a >= 0.0) Serial.print(" "); // add a space for positive numbers + Serial.print(a*3.28084,0); + Serial.println(" feet"); + + delay(500); +} + + +double getPressure() +{ + char status; + double T,P,p0,a; + + // You must first get a temperature measurement to perform a pressure reading. + + // Start a temperature measurement: + // If request is successful, the number of ms to wait is returned. + // If request is unsuccessful, 0 is returned. + + status = pressure.startTemperature(); + if (status != 0) + { + // Wait for the measurement to complete: + + delay(status); + + // Retrieve the completed temperature measurement: + // Note that the measurement is stored in the variable T. + // Use '&T' to provide the address of T to the function. + // Function returns 1 if successful, 0 if failure. + + status = pressure.getTemperature(T); + if (status != 0) + { + // Start a pressure measurement: + // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait). + // If request is successful, the number of ms to wait is returned. + // If request is unsuccessful, 0 is returned. + + status = pressure.startPressure(3); + if (status != 0) + { + // Wait for the measurement to complete: + delay(status); + + // Retrieve the completed pressure measurement: + // Note that the measurement is stored in the variable P. + // Use '&P' to provide the address of P. + // Note also that the function requires the previous temperature measurement (T). + // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.) + // Function returns 1 if successful, 0 if failure. + + status = pressure.getPressure(P,T); + if (status != 0) + { + return(P); + } + else Serial.println("error retrieving pressure measurement\n"); + } + else Serial.println("error starting pressure measurement\n"); + } + else Serial.println("error retrieving temperature measurement\n"); + } + else Serial.println("error starting temperature measurement\n"); +} + + + diff --git a/examples/arduino-internal-libs/.gitignore b/examples/arduino-internal-libs/.gitignore new file mode 100644 index 0000000..5402c18 --- /dev/null +++ b/examples/arduino-internal-libs/.gitignore @@ -0,0 +1,3 @@ +.pioenvs +.clang_complete +.gcc-flags.json diff --git a/examples/arduino-internal-libs/.travis.yml b/examples/arduino-internal-libs/.travis.yml new file mode 100644 index 0000000..b636184 --- /dev/null +++ b/examples/arduino-internal-libs/.travis.yml @@ -0,0 +1,65 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < http://docs.platformio.org/en/latest/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < http://docs.platformio.org/en/latest/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to by used as a library with examples +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/arduino-internal-libs/README.rst b/examples/arduino-internal-libs/README.rst new file mode 100644 index 0000000..0fac78d --- /dev/null +++ b/examples/arduino-internal-libs/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/arduino-internal-libs + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e maple + + # Upload firmware for the specific environment + > platformio run -e maple --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/arduino-internal-libs/lib/readme.txt b/examples/arduino-internal-libs/lib/readme.txt new file mode 100644 index 0000000..607a92a --- /dev/null +++ b/examples/arduino-internal-libs/lib/readme.txt @@ -0,0 +1,38 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organized `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +See additional options for PlatformIO Library Dependency Finder `lib_*`: + +http://docs.platformio.org/en/latest/projectconf.html#lib-install + diff --git a/examples/arduino-internal-libs/platformio.ini b/examples/arduino-internal-libs/platformio.ini new file mode 100644 index 0000000..d36e0c2 --- /dev/null +++ b/examples/arduino-internal-libs/platformio.ini @@ -0,0 +1,18 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/en/stable/projectconf.html + +[env:maple] +platform = ststm32 +framework = arduino +board = maple + +[env:genericSTM32F103RB] +platform = ststm32 +framework = arduino +board = genericSTM32F103RB diff --git a/examples/arduino-internal-libs/src/Gilchrist_RTC.ino b/examples/arduino-internal-libs/src/Gilchrist_RTC.ino new file mode 100644 index 0000000..a131127 --- /dev/null +++ b/examples/arduino-internal-libs/src/Gilchrist_RTC.ino @@ -0,0 +1,93 @@ +/* + * test-rtc.c + * + * Example program that sets up the Real Time Clock and then blinks the + * LED in patterns for seconds and alarm interrupts. + * + * Created by Rod Gilchrist on 11-12-24. + Ray Burnette: 20150521: + Edited: \Documents\Arduino\hardware\STM32\STM32F1\system\libmaple\stm32f1\include\series\rcc.h to include: + #include + #define RCC_BDCR_RTCSEL_LSI (0x2 << 8) + static inline void rcc_start_lsi(void) + static inline void rcc_start_lse(void) + static inline void rcc_start_hse(void) + + Arduino GUI 1.7.3 from Arduino.org + Sketch uses 20,268 bytes (18%) of program storage space. Maximum is 110,592 bytes. + Global variables use 4,552 bytes of dynamic memory. + */ + +#include "RTClock.h" + +#define BOARD_LED_PIN PB1 + +int globAlmCnt = 0; +int globOvCnt = 0; +int globSecCnt = 0; +int specAlmCnt = 0; +int lastGlobAlmCnt = -1; +int lastSpecAlmCnt = -1; + +void rtc_sec_intr() { if (rtc_is_second()) globSecCnt++; } +void rtc_ovf_intr() { if (rtc_is_overflow()) globOvCnt++; } +void rtc_glob_alm_intr() { if (rtc_is_alarm()) globAlmCnt++; } +void rtc_spec_alm_intr() { if (rtc_is_alarm()) specAlmCnt++; } + +void setup() { + // http://forums.leaflabs.com/topic.php?id=1437 + // slow! div speed. NOTE! 512 is stop/hang when USB not connected! + // rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_256); + // Normal speed: + // rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1); + + pinMode(BOARD_LED_PIN, OUTPUT); + delay(5000); + Serial.println("begin RTC blink"); + delay(1000); + + rtc_init(RTCSEL_LSI); + rtc_set_prescaler_load(0x7fff); + rtc_set_count(0); + + rtc_attach_interrupt(RTC_SECONDS_INTERRUPT, rtc_sec_intr); + rtc_attach_interrupt(RTC_OVERFLOW_INTERRUPT, rtc_ovf_intr); // expected every 128000 seconds + rtc_attach_interrupt(RTC_ALARM_GLOBAL_INTERRUPT, rtc_glob_alm_intr); + rtc_attach_interrupt(RTC_ALARM_SPECIFIC_INTERRUPT, rtc_spec_alm_intr); +} + +void loop() { + int i,n; + + Serial.print("Time + interrupt counts: "); + Serial.print(rtc_get_count()); + Serial.print("."); + Serial.print(rtc_get_divider()); + Serial.print(" ("); + Serial.print(globSecCnt); + Serial.print(", "); + Serial.print(globOvCnt); + Serial.print(", "); + Serial.print(globAlmCnt); + Serial.print(", "); + Serial.print(specAlmCnt); + Serial.println(")"); + + delay(1000); + + digitalWrite(BOARD_LED_PIN, 1); + if ((lastSpecAlmCnt != specAlmCnt) || (lastGlobAlmCnt != globAlmCnt)){ + lastGlobAlmCnt = globAlmCnt; + lastSpecAlmCnt = specAlmCnt; + + Serial.println(" -- alarm -- "); + for (i=0;i<3;i++) { digitalWrite(BOARD_LED_PIN, 0); delay(100); digitalWrite(BOARD_LED_PIN, 1); delay(100);} + n = rtc_get_count() + 5; + rtc_set_alarm(n); + } + + delay(1000); + digitalWrite(BOARD_LED_PIN, 0); +} + + diff --git a/examples/mbed-blink/platformio.ini b/examples/mbed-blink/platformio.ini index 5dc9f05..910b17d 100644 --- a/examples/mbed-blink/platformio.ini +++ b/examples/mbed-blink/platformio.ini @@ -32,6 +32,11 @@ platform = ststm32 framework = mbed board = nucleo_f103rb +[env:nucleo_f207zg] +platform = ststm32 +framework = mbed +board = nucleo_f207zg + [env:nucleo_f302r8] platform = ststm32 framework = mbed @@ -42,6 +47,11 @@ platform = ststm32 framework = mbed board = nucleo_f401re +[env:nucleo_f767zi] +platform = ststm32 +framework = mbed +board = nucleo_f767zi + [env:nucleo_l053r8] platform = ststm32 framework = mbed diff --git a/examples/mbed-dsp/platformio.ini b/examples/mbed-dsp/platformio.ini index 5dc9f05..910b17d 100644 --- a/examples/mbed-dsp/platformio.ini +++ b/examples/mbed-dsp/platformio.ini @@ -32,6 +32,11 @@ platform = ststm32 framework = mbed board = nucleo_f103rb +[env:nucleo_f207zg] +platform = ststm32 +framework = mbed +board = nucleo_f207zg + [env:nucleo_f302r8] platform = ststm32 framework = mbed @@ -42,6 +47,11 @@ platform = ststm32 framework = mbed board = nucleo_f401re +[env:nucleo_f767zi] +platform = ststm32 +framework = mbed +board = nucleo_f767zi + [env:nucleo_l053r8] platform = ststm32 framework = mbed diff --git a/examples/mbed-rtos/platformio.ini b/examples/mbed-rtos/platformio.ini index 0ef4365..7907ed8 100644 --- a/examples/mbed-rtos/platformio.ini +++ b/examples/mbed-rtos/platformio.ini @@ -17,21 +17,26 @@ platform = ststm32 framework = mbed board = disco_f303vc -[env:disco_f100rb] -platform = ststm32 -framework = mbed -board = disco_f100rb +; [env:disco_f100rb] +; platform = ststm32 +; framework = mbed +; board = disco_f100rb -[env:nucleo_f030r8] -platform = ststm32 -framework = mbed -board = nucleo_f030r8 +; [env:nucleo_f030r8] +; platform = ststm32 +; framework = mbed +; board = nucleo_f030r8 [env:nucleo_f103rb] platform = ststm32 framework = mbed board = nucleo_f103rb +[env:nucleo_f207zg] +platform = ststm32 +framework = mbed +board = nucleo_f207zg + [env:nucleo_f302r8] platform = ststm32 framework = mbed @@ -42,20 +47,25 @@ platform = ststm32 framework = mbed board = nucleo_f401re -[env:nucleo_l053r8] +[env:nucleo_f767zi] platform = ststm32 framework = mbed -board = nucleo_l053r8 +board = nucleo_f767zi + +; [env:nucleo_l053r8] +; platform = ststm32 +; framework = mbed +; board = nucleo_l053r8 [env:nucleo_l152re] platform = ststm32 framework = mbed board = nucleo_l152re -[env:disco_l053c8] -platform = ststm32 -framework = mbed -board = disco_l053c8 +; [env:disco_l053c8] +; platform = ststm32 +; framework = mbed +; board = disco_l053c8 ; [env:seeedArchMax] ; platform = ststm32 diff --git a/examples/mbed-serial/platformio.ini b/examples/mbed-serial/platformio.ini index 5dc9f05..910b17d 100644 --- a/examples/mbed-serial/platformio.ini +++ b/examples/mbed-serial/platformio.ini @@ -32,6 +32,11 @@ platform = ststm32 framework = mbed board = nucleo_f103rb +[env:nucleo_f207zg] +platform = ststm32 +framework = mbed +board = nucleo_f207zg + [env:nucleo_f302r8] platform = ststm32 framework = mbed @@ -42,6 +47,11 @@ platform = ststm32 framework = mbed board = nucleo_f401re +[env:nucleo_f767zi] +platform = ststm32 +framework = mbed +board = nucleo_f767zi + [env:nucleo_l053r8] platform = ststm32 framework = mbed diff --git a/platform.json b/platform.json index 42287b6..29f3ea8 100644 --- a/platform.json +++ b/platform.json @@ -13,11 +13,21 @@ "type": "git", "url": "https://github.com/platformio/platform-ststm32.git" }, - "version": "1.0.1", + "version": "1.1.0", "packageRepositories": [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "https://sourceforge.net/projects/platformio-storage/files/packages/manifest.json/download", - "http://dl.platformio.org/packages/manifest.json" + "http://dl.platformio.org/packages/manifest.json", + { + "framework-arduinoststm32": [ + { + "url": "https://github.com/ubis/Arduino_STM32/archive/v1.0.0.tar.gz", + "sha1": "36f26069b70ef6b7ceae2a91e3c23be74cc79337", + "version": "1.0.0", + "system": "*" + } + ] + } ], "frameworks": { "mbed": { @@ -35,6 +45,10 @@ "libopencm3": { "package": "framework-libopencm3", "script": "builder/frameworks/libopencm3/libopencm3.py" + }, + "arduino": { + "package": "framework-arduinoststm32", + "script": "builder/frameworks/arduino.py" } }, "packages": { @@ -62,6 +76,11 @@ "optional": true, "version": "~1.1.0" }, + "framework-arduinoststm32": { + "type": "framework", + "optional": true, + "version": "~1.0.0" + }, "tool-stlink": { "type": "uploader", "optional": true,