瀏覽代碼

initial commit

main
John Robinson 3 年之前
當前提交
f02f78e6e6
沒有發現已知的金鑰在資料庫的簽署中
共有 81 個檔案被更改,包括 357295 行新增0 行删除
  1. +12
    -0
      .piopm
  2. +174
    -0
      LICENSE
  3. +35
    -0
      README.md
  4. 二進制
      __pycache__/platform.cpython-39.pyc
  5. +23
    -0
      boards/teensy2.json
  6. +23
    -0
      boards/teensy2pp.json
  7. +27
    -0
      boards/teensy30.json
  8. +33
    -0
      boards/teensy31.json
  9. +35
    -0
      boards/teensy35.json
  10. +35
    -0
      boards/teensy36.json
  11. +33
    -0
      boards/teensy40.json
  12. +33
    -0
      boards/teensy41.json
  13. +32
    -0
      boards/teensylc.json
  14. +85
    -0
      builder/frameworks/_bare_arm.py
  15. +55
    -0
      builder/frameworks/_bare_avr.py
  16. +329
    -0
      builder/frameworks/arduino.py
  17. +37
    -0
      builder/frameworks/mbed.py
  18. +243
    -0
      builder/main.py
  19. +2
    -0
      examples/arduino-blink/.gitignore
  20. +67
    -0
      examples/arduino-blink/.travis.yml
  21. +38
    -0
      examples/arduino-blink/README.rst
  22. +39
    -0
      examples/arduino-blink/include/README
  23. +46
    -0
      examples/arduino-blink/lib/README
  24. +53
    -0
      examples/arduino-blink/platformio.ini
  25. +25
    -0
      examples/arduino-blink/src/Blink.cpp
  26. +11
    -0
      examples/arduino-blink/test/README
  27. +2
    -0
      examples/arduino-hid-usb-mouse/.gitignore
  28. +67
    -0
      examples/arduino-hid-usb-mouse/.travis.yml
  29. +32
    -0
      examples/arduino-hid-usb-mouse/README.rst
  30. +39
    -0
      examples/arduino-hid-usb-mouse/include/README
  31. +46
    -0
      examples/arduino-hid-usb-mouse/lib/README
  32. +50
    -0
      examples/arduino-hid-usb-mouse/platformio.ini
  33. +26
    -0
      examples/arduino-hid-usb-mouse/src/TriangleMove.ino
  34. +11
    -0
      examples/arduino-hid-usb-mouse/test/README
  35. +2
    -0
      examples/arduino-internal-libs/.gitignore
  36. +67
    -0
      examples/arduino-internal-libs/.travis.yml
  37. +38
    -0
      examples/arduino-internal-libs/README.rst
  38. +39
    -0
      examples/arduino-internal-libs/include/README
  39. +46
    -0
      examples/arduino-internal-libs/lib/README
  40. +53
    -0
      examples/arduino-internal-libs/platformio.ini
  41. +80
    -0
      examples/arduino-internal-libs/src/ChatServer.ino
  42. +11
    -0
      examples/arduino-internal-libs/test/README
  43. +2
    -0
      examples/mbed-blink/.gitignore
  44. +67
    -0
      examples/mbed-blink/.travis.yml
  45. +32
    -0
      examples/mbed-blink/README.rst
  46. +39
    -0
      examples/mbed-blink/include/README
  47. +46
    -0
      examples/mbed-blink/lib/README
  48. +13
    -0
      examples/mbed-blink/platformio.ini
  49. +12
    -0
      examples/mbed-blink/src/main.cpp
  50. +11
    -0
      examples/mbed-blink/test/README
  51. +2
    -0
      examples/mbed-dsp/.gitignore
  52. +67
    -0
      examples/mbed-dsp/.travis.yml
  53. +32
    -0
      examples/mbed-dsp/README.rst
  54. +39
    -0
      examples/mbed-dsp/include/README
  55. +46
    -0
      examples/mbed-dsp/lib/README
  56. +13
    -0
      examples/mbed-dsp/platformio.ini
  57. +94
    -0
      examples/mbed-dsp/src/data.cpp
  58. +65
    -0
      examples/mbed-dsp/src/main.cpp
  59. +11
    -0
      examples/mbed-dsp/test/README
  60. +2
    -0
      examples/mbed-events/.gitignore
  61. +67
    -0
      examples/mbed-events/.travis.yml
  62. +32
    -0
      examples/mbed-events/README.rst
  63. +39
    -0
      examples/mbed-events/include/README
  64. +46
    -0
      examples/mbed-events/lib/README
  65. +13
    -0
      examples/mbed-events/platformio.ini
  66. +15
    -0
      examples/mbed-events/src/main.cpp
  67. +11
    -0
      examples/mbed-events/test/README
  68. +2
    -0
      examples/mbed-serial/.gitignore
  69. +67
    -0
      examples/mbed-serial/.travis.yml
  70. +32
    -0
      examples/mbed-serial/README.rst
  71. +39
    -0
      examples/mbed-serial/include/README
  72. +46
    -0
      examples/mbed-serial/lib/README
  73. +13
    -0
      examples/mbed-serial/platformio.ini
  74. +10
    -0
      examples/mbed-serial/src/main.cpp
  75. +11
    -0
      examples/mbed-serial/test/README
  76. +38445
    -0
      misc/svd/MK20D5.svd
  77. +136687
    -0
      misc/svd/MK64F12.svd
  78. +113910
    -0
      misc/svd/MK66F18.svd
  79. +64921
    -0
      misc/svd/MKL26Z4.svd
  80. +71
    -0
      platform.json
  81. +91
    -0
      platform.py

+ 12
- 0
.piopm 查看文件

@@ -0,0 +1,12 @@
{
"type": "platform",
"name": "teensy-gcc",
"version": "0.1.0",
"spec": {
"owner": "skepto",
"id": 8021,
"name": "teensy-gcc",
"requirements": null,
"url": null
}
}

+ 174
- 0
LICENSE 查看文件

@@ -0,0 +1,174 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

+ 35
- 0
README.md 查看文件

@@ -0,0 +1,35 @@
# Teensy: development platform for [PlatformIO](http://platformio.org)
[![Build Status](https://github.com/platformio/platform-teensy/workflows/Examples/badge.svg)](https://github.com/platformio/platform-teensy/actions)
Teensy is a complete USB-based microcontroller development system, in a very small footprint, capable of implementing many types of projects. All programming is done via the USB port. No special programmer is needed, only a standard USB cable and a PC or Macintosh with a USB port.
* [Home](http://platformio.org/platforms/teensy) (home page in PlatformIO Platform Registry)
* [Documentation](http://docs.platformio.org/page/platforms/teensy.html) (advanced usage, packages, boards, frameworks, etc.)
# Usage
1. [Install PlatformIO](http://platformio.org)
2. Create PlatformIO project and configure a platform option in [platformio.ini](http://docs.platformio.org/page/projectconf.html) file:
## Stable version
```ini
[env:stable]
platform = teensy
board = ...
...
```
## Development version
```ini
[env:development]
platform = https://github.com/platformio/platform-teensy.git
board = ...
...
```
# Configuration
Please navigate to [documentation](http://docs.platformio.org/page/platforms/teensy.html).

二進制
__pycache__/platform.cpython-39.pyc 查看文件


+ 23
- 0
boards/teensy2.json 查看文件

@@ -0,0 +1,23 @@
{
"build": {
"core": "teensy",
"extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_TEENSY2",
"f_cpu": "16000000L",
"mcu": "atmega32u4"
},
"frameworks": [
"arduino"
],
"name": "Teensy 2.0",
"upload": {
"maximum_ram_size": 2560,
"maximum_size": 32256,
"protocol": "teensy-gui",
"protocols": [
"teensy-cli",
"teensy-gui"
]
},
"url": "https://www.pjrc.com/store/teensy.html",
"vendor": "Teensy"
}

+ 23
- 0
boards/teensy2pp.json 查看文件

@@ -0,0 +1,23 @@
{
"build": {
"core": "teensy",
"extra_flags": "-DARDUINO_TEENSY2PP",
"f_cpu": "16000000L",
"mcu": "at90usb1286"
},
"frameworks": [
"arduino"
],
"name": "Teensy++ 2.0",
"upload": {
"maximum_ram_size": 8192,
"maximum_size": 130048,
"protocol": "teensy-gui",
"protocols": [
"teensy-cli",
"teensy-gui"
]
},
"url": "https://www.pjrc.com/store/teensypp.html",
"vendor": "Teensy"
}

+ 27
- 0
boards/teensy30.json 查看文件

@@ -0,0 +1,27 @@
{
"build": {
"arduino": {
"ldscript": "mk20dx128.ld"
},
"core": "teensy3",
"cpu": "cortex-m4",
"extra_flags": "-D__MK20DX128__ -DARDUINO_TEENSY30",
"f_cpu": "48000000L",
"mcu": "mk20dx128"
},
"frameworks": [
"arduino"
],
"name": "Teensy 3.0",
"upload": {
"maximum_ram_size": 16384,
"maximum_size": 131072,
"protocol": "teensy-gui",
"protocols": [
"teensy-cli",
"teensy-gui"
]
},
"url": "https://www.pjrc.com/store/teensy3.html",
"vendor": "Teensy"
}

+ 33
- 0
boards/teensy31.json 查看文件

@@ -0,0 +1,33 @@
{
"build": {
"arduino": {
"ldscript": "mk20dx256.ld"
},
"core": "teensy3",
"cpu": "cortex-m4",
"extra_flags": "-D__MK20DX256__ -DARDUINO_TEENSY31",
"f_cpu": "72000000L",
"mcu": "mk20dx256"
},
"debug": {
"jlink_device": "MK20DX256xxx10",
"svd_path": "MK20D5.svd"
},
"frameworks": [
"arduino",
"mbed"
],
"name": "Teensy 3.1 / 3.2",
"upload": {
"maximum_ram_size": 65536,
"maximum_size": 262144,
"protocol": "teensy-gui",
"protocols": [
"teensy-cli",
"teensy-gui",
"jlink"
]
},
"url": "https://www.pjrc.com/store/teensy31.html",
"vendor": "Teensy"
}

+ 35
- 0
boards/teensy35.json 查看文件

@@ -0,0 +1,35 @@
{
"build": {
"arduino": {
"ldscript": "mk64fx512.ld"
},
"core": "teensy3",
"cpu": "cortex-m4",
"extra_flags": "-D__MK64FX512__ -DARDUINO_TEENSY35",
"f_cpu": "120000000L",
"mcu": "mk64fx512"
},
"connectivity": [
"can"
],
"debug": {
"jlink_device": "MK64FX512xxx12",
"svd_path": "MK64F12.svd"
},
"frameworks": [
"arduino"
],
"name": "Teensy 3.5",
"upload": {
"maximum_ram_size": 262136,
"maximum_size": 524288,
"protocol": "teensy-gui",
"protocols": [
"teensy-cli",
"teensy-gui",
"jlink"
]
},
"url": "https://www.pjrc.com/store/teensy35.html",
"vendor": "Teensy"
}

+ 35
- 0
boards/teensy36.json 查看文件

@@ -0,0 +1,35 @@
{
"build": {
"arduino": {
"ldscript": "mk66fx1m0.ld"
},
"core": "teensy3",
"cpu": "cortex-m4",
"extra_flags": "-D__MK66FX1M0__ -DARDUINO_TEENSY36",
"f_cpu": "180000000L",
"mcu": "mk66fx1m0"
},
"connectivity": [
"can"
],
"debug": {
"jlink_device": "MK66FX1M0xxx18",
"svd_path": "MK66F18.svd"
},
"frameworks": [
"arduino"
],
"name": "Teensy 3.6",
"upload": {
"maximum_ram_size": 262144,
"maximum_size": 1048576,
"protocol": "teensy-gui",
"protocols": [
"teensy-cli",
"teensy-gui",
"jlink"
]
},
"url": "https://www.pjrc.com/store/teensy36.html",
"vendor": "Teensy"
}

+ 33
- 0
boards/teensy40.json 查看文件

@@ -0,0 +1,33 @@
{
"build": {
"arduino": {
"ldscript": "imxrt1062.ld"
},
"core": "teensy4",
"cpu": "cortex-m7",
"extra_flags": "-D__IMXRT1062__ -DARDUINO_TEENSY40",
"f_cpu": "600000000",
"mcu": "imxrt1062"
},
"connectivity": [
"can"
],
"debug": {
"jlink_device": "MIMXRT1062xxxxA"
},
"frameworks": [
"arduino"
],
"name": "Teensy 4.0",
"upload": {
"maximum_ram_size": 524288,
"maximum_size": 2031616,
"protocol": "teensy-gui",
"protocols": [
"teensy-gui",
"jlink"
]
},
"url": "https://www.pjrc.com/store/teensy40.html",
"vendor": "Teensy"
}

+ 33
- 0
boards/teensy41.json 查看文件

@@ -0,0 +1,33 @@
{
"build": {
"arduino": {
"ldscript": "imxrt1062_t41.ld"
},
"core": "teensy4",
"cpu": "cortex-m7",
"extra_flags": "-D__IMXRT1062__ -DARDUINO_TEENSY41",
"f_cpu": "600000000",
"mcu": "imxrt1062"
},
"connectivity": [
"can"
],
"debug": {
"jlink_device": "MIMXRT1062xxxxA"
},
"frameworks": [
"arduino"
],
"name": "Teensy 4.1",
"upload": {
"maximum_ram_size": 524288,
"maximum_size": 8126464,
"protocol": "teensy-gui",
"protocols": [
"teensy-gui",
"jlink"
]
},
"url": "https://www.pjrc.com/store/teensy41.html",
"vendor": "Teensy"
}

+ 32
- 0
boards/teensylc.json 查看文件

@@ -0,0 +1,32 @@
{
"build": {
"arduino": {
"ldscript": "mkl26z64.ld"
},
"core": "teensy3",
"cpu": "cortex-m0plus",
"extra_flags": "-D__MKL26Z64__ -DARDUINO_TEENSYLC",
"f_cpu": "48000000L",
"mcu": "mkl26z64"
},
"debug": {
"jlink_device": "MKL26Z64xxx4",
"svd_path": "MKL26Z4.svd"
},
"frameworks": [
"arduino"
],
"name": "Teensy LC",
"upload": {
"maximum_ram_size": 8192,
"maximum_size": 63488,
"protocol": "teensy-gui",
"protocols": [
"teensy-cli",
"teensy-gui",
"jlink"
]
},
"url": "http://www.pjrc.com/teensy/teensyLC.html",
"vendor": "Teensy"
}

+ 85
- 0
builder/frameworks/_bare_arm.py 查看文件

@@ -0,0 +1,85 @@
# Copyright 2014-present PlatformIO <contact@platformio.org>
#
# 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.
#
# Default flags for bare-metal programming (without any framework layers)
#
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
env.Append(
ASFLAGS=["-x", "assembler-with-cpp"],
CCFLAGS=[
"-Os", # optimize for size
"-Wall", # show warnings
"-ffunction-sections", # place each function in its own section
"-fdata-sections",
"-mthumb",
"-nostdlib",
"-fsingle-precision-constant"
],
CXXFLAGS=[
"-fno-exceptions",
"-felide-constructors",
"-fno-rtti",
"-std=gnu++14"
],
CPPDEFINES=[
("F_CPU", "$BOARD_F_CPU"),
"LAYOUT_US_ENGLISH"
],
RANLIBFLAGS=["-s"],
LINKFLAGS=[
"-Os",
"-Wl,--gc-sections,--relax",
"-mthumb",
"-Wl,--defsym=__rtc_localtime=$UNIX_TIME",
"-fsingle-precision-constant"
],
LIBS=["m", "stdc++"]
)
if env.BoardConfig().id_ in ("teensy35", "teensy36"):
env.Append(
CCFLAGS=[
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16"
],
LINKFLAGS=[
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16"
]
)
if "BOARD" in env:
env.Append(
CCFLAGS=[
"-mcpu=%s" % env.BoardConfig().get("build.cpu")
],
LINKFLAGS=[
"-mcpu=%s" % env.BoardConfig().get("build.cpu")
]
)
# copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode)
env.Append(ASFLAGS=env.get("CCFLAGS", [])[:])

+ 55
- 0
builder/frameworks/_bare_avr.py 查看文件

@@ -0,0 +1,55 @@
# Copyright 2014-present PlatformIO <contact@platformio.org>
#
# 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.
#
# Default flags for bare-metal programming (without any framework layers)
#
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
env.Append(
ASFLAGS=["-x", "assembler-with-cpp"],
CCFLAGS=[
"-Os", # optimize for size
"-Wall", # show warnings
"-ffunction-sections", # place each function in its own section
"-fdata-sections",
"-mmcu=$BOARD_MCU"
],
CXXFLAGS=[
"-fno-exceptions",
"-felide-constructors",
"-std=gnu++11"
],
CPPDEFINES=[
("F_CPU", "$BOARD_F_CPU"),
"LAYOUT_US_ENGLISH"
],
LINKFLAGS=[
"-Os",
"-Wl,--gc-sections,--relax",
"-mmcu=$BOARD_MCU"
],
LIBS=["m"]
)
# copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode)
env.Append(ASFLAGS=env.get("CCFLAGS", [])[:])

+ 329
- 0
builder/frameworks/arduino.py 查看文件

@@ -0,0 +1,329 @@
# Copyright 2014-present PlatformIO <contact@platformio.org>
#
# 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://arduino.cc/en/Reference/HomePage
"""
from io import open
from os import listdir
from os.path import isdir, isfile, join
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
platform = env.PioPlatform()
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoteensy-cxx17")
FRAMEWORK_VERSION = platform.get_package_version("framework-arduinoteensy-cxx17")
BUILD_CORE = env.BoardConfig().get("build.core")
assert isdir(FRAMEWORK_DIR)
BUILTIN_USB_FLAGS = (
"USB_SERIAL",
"USB_DUAL_SERIAL",
"USB_TRIPLE_SERIAL",
"USB_KEYBOARDONLY",
"USB_TOUCHSCREEN",
"USB_HID_TOUCHSCREEN",
"USB_HID",
"USB_SERIAL_HID",
"USB_MIDI",
"USB_MIDI4",
"USB_MIDI16",
"USB_MIDI_SERIAL",
"USB_MIDI4_SERIAL",
"USB_MIDI16_SERIAL",
"USB_AUDIO",
"USB_MIDI_AUDIO_SERIAL",
"USB_MIDI16_AUDIO_SERIAL",
"USB_MTPDISK",
"USB_RAWHID",
"USB_FLIGHTSIM",
"USB_FLIGHTSIM_JOYSTICK",
"USB_EVERYTHING",
"USB_DISABLED",
)
if not set(env.get("CPPDEFINES", [])) & set(BUILTIN_USB_FLAGS):
env.Append(CPPDEFINES=["USB_SERIAL"])
env.Replace(
SIZEPROGREGEXP=r"^(?:\.text|\.text\.progmem|\.text\.itcm|\.data)\s+([0-9]+).*",
SIZEDATAREGEXP=r"^(?:\.usbdescriptortable|\.dmabuffers|\.usbbuffers|\.data|\.bss|\.noinit|\.text\.itcm|\.text\.itcm\.padding)\s+([0-9]+).*"
)
env.Append(
CPPDEFINES=[
("ARDUINO", 10805),
("TEENSYDUINO", 149),
"CORE_TEENSY"
],
CPPPATH=[
join(FRAMEWORK_DIR, "cores", BUILD_CORE)
],
LIBSOURCE_DIRS=[
join(FRAMEWORK_DIR, "libraries")
]
)
if "BOARD" in env and BUILD_CORE == "teensy":
env.Append(
ASFLAGS=["-x", "assembler-with-cpp"],
CCFLAGS=[
"-Os", # optimize for size
"-Wall", # show warnings
"-ffunction-sections", # place each function in its own section
"-fdata-sections",
"-mmcu=$BOARD_MCU"
],
CXXFLAGS=[
"-fno-exceptions",
"-felide-constructors",
"-std=gnu++11",
"-fpermissive"
],
CPPDEFINES=[
("F_CPU", "$BOARD_F_CPU"),
"LAYOUT_US_ENGLISH"
],
LINKFLAGS=[
"-Os",
"-Wl,--gc-sections,--relax",
"-mmcu=$BOARD_MCU"
],
LIBS=["m"]
)
elif "BOARD" in env and BUILD_CORE in ("teensy3", "teensy4", "teensy41"):
env.Replace(
AR="arm-none-eabi-gcc-ar",
RANLIB="$AR"
)
env.Append(
ASFLAGS=["-x", "assembler-with-cpp"],
CCFLAGS=[
"-Wall", # show warnings
"-ffunction-sections", # place each function in its own section
"-fdata-sections",
"-mthumb",
"-mcpu=%s" % env.BoardConfig().get("build.cpu"),
"-fsingle-precision-constant"
],
CXXFLAGS=[
"-fno-exceptions",
"-felide-constructors",
"-fno-rtti",
"-std=gnu++17",
"-Wno-error=narrowing",
"-fpermissive"
],
CPPDEFINES=[
("F_CPU", "$BOARD_F_CPU"),
"LAYOUT_US_ENGLISH"
],
RANLIBFLAGS=["-s"],
LINKFLAGS=[
"-Wl,--gc-sections,--relax",
"-mthumb",
"-mcpu=%s" % env.BoardConfig().get("build.cpu"),
"-Wl,--defsym=__rtc_localtime=$UNIX_TIME",
"-fsingle-precision-constant"
],
LIBS=["m", "stdc++"]
)
if not env.BoardConfig().get("build.ldscript", ""):
env.Replace(LDSCRIPT_PATH=env.BoardConfig().get("build.arduino.ldscript", ""))
if env.BoardConfig().id_ in ("teensy35", "teensy36", "teensy40", "teensy41"):
fpv_version = "4-sp"
if env.BoardConfig().id_.startswith("teensy4"):
fpv_version = "5"
env.Append(
CCFLAGS=[
"-mfloat-abi=hard",
"-mfpu=fpv%s-d16" % fpv_version
],
LINKFLAGS=[
"-mfloat-abi=hard",
"-mfpu=fpv%s-d16" % fpv_version
]
)
# Optimization
if "TEENSY_OPT_FASTER_LTO" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-O2", "-flto", "-fno-fat-lto-objects"],
LINKFLAGS=["-O2", "-flto", "-fno-fat-lto-objects", "-fuse-linker-plugin"]
)
elif "TEENSY_OPT_FAST" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-O1"],
LINKFLAGS=["-O1"]
)
elif "TEENSY_OPT_FAST_LTO" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-O1", "-flto", "-fno-fat-lto-objects"],
LINKFLAGS=["-O1", "-flto", "-fno-fat-lto-objects", "-fuse-linker-plugin"]
)
elif "TEENSY_OPT_FASTEST" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-O3"],
LINKFLAGS=["-O3"]
)
elif "TEENSY_OPT_FASTEST_LTO" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-O3", "-flto", "-fno-fat-lto-objects"],
LINKFLAGS=["-O3", "-flto", "-fno-fat-lto-objects", "-fuse-linker-plugin"]
)
elif "TEENSY_OPT_FASTEST_PURE_CODE" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-O3", "-mpure-code"],
CPPDEFINES=["__PURE_CODE__"],
LINKFLAGS=["-O3", "-mpure-code"]
)
elif "TEENSY_OPT_FASTEST_PURE_CODE_LTO" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-O3", "-mpure-code", "-flto", "-fno-fat-lto-objects"],
CPPDEFINES=["__PURE_CODE__"],
LINKFLAGS=["-O3", "-mpure-code", "-flto", "-fno-fat-lto-objects", "-fuse-linker-plugin"]
)
elif "TEENSY_OPT_DEBUG" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-g", "-Og"],
LINKFLAGS=["-g", "-Og"]
)
elif "TEENSY_OPT_DEBUG_LTO" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-g", "-Og", "-flto", "-fno-fat-lto-objects"],
LINKFLAGS=["-g", "-Og", "-flto", "-fno-fat-lto-objects", "-fuse-linker-plugin"]
)
elif "TEENSY_OPT_SMALLEST_CODE_LTO" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-Os", "--specs=nano.specs", "-flto", "-fno-fat-lto-objects"],
LINKFLAGS=["-Os", "--specs=nano.specs", "-flto", "-fno-fat-lto-objects", "-fuse-linker-plugin"]
)
elif "TEENSY_OPT_FASTER" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-O2"],
LINKFLAGS=["-O2"]
)
elif "TEENSY_OPT_SMALLEST_CODE" in env['CPPDEFINES']:
env.Append(
CCFLAGS=["-Os", "--specs=nano.specs"],
LINKFLAGS=["-Os", "--specs=nano.specs"]
)
# default profiles
else:
# for Teensy LC => TEENSY_OPT_SMALLEST_CODE
if env.BoardConfig().id_ == "teensylc":
env.Append(
CCFLAGS=["-Os", "--specs=nano.specs"],
LINKFLAGS=["-Os", "--specs=nano.specs"]
)
# for others => TEENSY_OPT_FASTER
else:
env.Append(
CCFLAGS=["-O2"],
LINKFLAGS=["-O2"]
)
env.Append(
ASFLAGS=env.get("CCFLAGS", [])[:]
)
if "cortex-m" in env.BoardConfig().get("build.cpu", ""):
board = env.subst("$BOARD")
math_lib = "arm_cortex%s_math"
if board in ("teensy35", "teensy36"):
math_lib = math_lib % "M4lf"
elif board in ("teensy30", "teensy31"):
math_lib = math_lib % "M4l"
elif board.startswith("teensy4"):
math_lib = math_lib % "M7lfsp"
else:
math_lib = math_lib % "M0l"
env.Prepend(LIBS=[math_lib])
# Teensy 2.x Core
if BUILD_CORE == "teensy":
env.Append(CPPPATH=[join(FRAMEWORK_DIR, "cores")])
# search relative includes in teensy directories
core_dir = join(FRAMEWORK_DIR, "cores", "teensy")
for item in sorted(listdir(core_dir)):
file_path = join(core_dir, item)
if not isfile(file_path):
continue
content = None
content_changed = False
with open(file_path, encoding="latin-1") as fp:
content = fp.read()
if '#include "../' in content:
content_changed = True
content = content.replace('#include "../', '#include "')
if not content_changed:
continue
with open(file_path, "w", encoding="latin-1") as fp:
fp.write(content)
else:
env.Prepend(LIBPATH=[join(FRAMEWORK_DIR, "cores", BUILD_CORE)])
#
# Target: Build Core Library
#
libs = []
if "build.variant" in env.BoardConfig():
env.Append(
CPPPATH=[
join(FRAMEWORK_DIR, "variants",
env.BoardConfig().get("build.variant"))
]
)
libs.append(env.BuildLibrary(
join("$BUILD_DIR", "FrameworkArduinoVariant"),
join(FRAMEWORK_DIR, "variants", env.BoardConfig().get("build.variant"))
))
libs.append(env.BuildLibrary(
join("$BUILD_DIR", "FrameworkArduino"),
join(FRAMEWORK_DIR, "cores", BUILD_CORE)
))
env.Prepend(LIBS=libs)

+ 37
- 0
builder/frameworks/mbed.py 查看文件

@@ -0,0 +1,37 @@
# Copyright 2014-present PlatformIO <contact@platformio.org>
#
# 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.
"""
mbed
The mbed framework The mbed SDK has been designed to provide enough
hardware abstraction to be intuitive and concise, yet powerful enough to
build complex projects. It is built on the low-level ARM CMSIS APIs,
allowing you to code down to the metal if needed. In addition to RTOS,
USB and Networking libraries, a cookbook of hundreds of reusable
peripheral and module libraries have been built on top of the SDK by
the mbed Developer Community.
http://mbed.org/
"""
from os.path import join
from SCons.Script import Import, SConscript
Import("env")
# https://github.com/platformio/builder-framework-mbed.git
SConscript(
join(env.PioPlatform().get_package_dir("framework-mbed"), "platformio",
"platformio-build.py"))

+ 243
- 0
builder/main.py 查看文件

@@ -0,0 +1,243 @@
# Copyright 2014-present PlatformIO <contact@platformio.org>
#
# 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.
import sys
from platform import system
from os import makedirs
from os.path import isdir, isfile, join
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
DefaultEnvironment)
env = DefaultEnvironment()
platform = env.PioPlatform()
board_config = env.BoardConfig()
env.Replace(
ARFLAGS=["rc"],
SIZEPROGREGEXP=r"^(?:\.text|\.data|\.rodata|\.text.align|\.ARM.exidx)\s+(\d+).*",
SIZEDATAREGEXP=r"^(?:\.data|\.bss|\.noinit)\s+(\d+).*",
SIZECHECKCMD="$SIZETOOL -A -d $SOURCES",
PROGSUFFIX=".elf"
)
# Allow user to override via pre:script
if env.get("PROGNAME", "program") == "program":
env.Replace(PROGNAME="firmware")
if "BOARD" in env and board_config.get("build.core") == "teensy":
env.Replace(
AR="avr-ar",
AS="avr-as",
CC="avr-gcc",
CXX="avr-g++",
GDB="avr-gdb",
OBJCOPY="avr-objcopy",
RANLIB="avr-ranlib",
SIZETOOL="avr-size",
SIZEPRINTCMD='$SIZETOOL --mcu=$BOARD_MCU -C -d $SOURCES'
)
env.Append(
BUILDERS=dict(
ElfToEep=Builder(
action=env.VerboseAction(" ".join([
"$OBJCOPY",
"-O",
"ihex",
"-j",
".eeprom",
'--set-section-flags=.eeprom="alloc,load"',
"--no-change-warnings",
"--change-section-lma",
".eeprom=0",
"$SOURCES",
"$TARGET"
]), "Building $TARGET"),
suffix=".eep"
),
ElfToHex=Builder(
action=env.VerboseAction(" ".join([
"$OBJCOPY",
"-O",
"ihex",
"-R",
".eeprom",
"$SOURCES",
"$TARGET"
]), "Building $TARGET"),
suffix=".hex"
)
)
)
if not env.get("PIOFRAMEWORK"):
env.SConscript("frameworks/_bare_avr.py")
elif "BOARD" in env and board_config.get("build.core") in ("teensy3", "teensy4", "teensy41"):
env.Replace(
AR="arm-none-eabi-ar",
AS="arm-none-eabi-as",
CC="arm-none-eabi-gcc",
CXX="arm-none-eabi-g++",
GDB="arm-none-eabi-gdb",
OBJCOPY="arm-none-eabi-objcopy",
RANLIB="arm-none-eabi-gcc-ranlib",
SIZETOOL="arm-none-eabi-size",
SIZEPRINTCMD='$SIZETOOL -B -d $SOURCES'
)
env.Append(
BUILDERS=dict(
ElfToBin=Builder(
action=env.VerboseAction(" ".join([
"$OBJCOPY",
"-O",
"binary",
"$SOURCES",
"$TARGET"
]), "Building $TARGET"),
suffix=".bin"
),
ElfToHex=Builder(
action=env.VerboseAction(" ".join([
"$OBJCOPY",
"-O",
"ihex",
"-R",
".eeprom",
"$SOURCES",
"$TARGET"
]), "Building $TARGET"),
suffix=".hex"
)
)
)
if not env.get("PIOFRAMEWORK"):
env.SConscript("frameworks/_bare_arm.py")
#
# Target: Build executable and linkable firmware
#
target_elf = None
if "nobuild" in COMMAND_LINE_TARGETS:
target_elf = join("$BUILD_DIR", "${PROGNAME}.elf")
target_firm = join("$BUILD_DIR", "${PROGNAME}.hex")
else:
target_elf = env.BuildProgram()
target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf)
AlwaysBuild(env.Alias("nobuild", target_firm))
target_buildprog = env.Alias("buildprog", target_firm, target_firm)
#
# Target: Print binary size
#
target_size = env.Alias(
"size", target_elf,
env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE"))
AlwaysBuild(target_size)
#
# Target: Upload by default firmware file
#
# Force Teensy CLI when Teensy App is not available (Linux ARM)
if env.subst("$UPLOAD_PROTOCOL") == "teensy-gui" and not isfile(
join(
platform.get_package_dir("tool-teensy") or "",
"teensy_post_compile.exe"
if system() == "Windows" else "teensy_post_compile")):
env.Replace(UPLOAD_PROTOCOL="teensy-cli")
upload_protocol = env.subst("$UPLOAD_PROTOCOL")
upload_actions = []
if upload_protocol.startswith("jlink"):
def _jlink_cmd_script(env, source):
build_dir = env.subst("$BUILD_DIR")
if not isdir(build_dir):
makedirs(build_dir)
script_path = join(build_dir, "upload.jlink")
commands = ["h", "loadfile %s" % source, "r", "q"]
with open(script_path, "w") as fp:
fp.write("\n".join(commands))
return script_path
env.Replace(
__jlink_cmd_script=_jlink_cmd_script,
UPLOADER="JLink.exe" if system() == "Windows" else "JLinkExe",
UPLOADERFLAGS=[
"-device", board_config.get("debug", {}).get("jlink_device"),
"-speed", "4000",
"-if", ("jtag" if upload_protocol == "jlink-jtag" else "swd"),
"-autoconnect", "1",
"-NoGui", "1"
],
UPLOADCMD='$UPLOADER $UPLOADERFLAGS -CommanderScript "${__jlink_cmd_script(__env__, SOURCE)}"'
)
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]
elif upload_protocol == "teensy-cli":
env.Replace(
REBOOTER="teensy_reboot",
UPLOADER="teensy_loader_cli",
UPLOADERFLAGS=[
"-mmcu=$BOARD_MCU",
"-w", # wait for device to appear
"-s", # soft reboot if device not online
"-v" # verbose output
],
UPLOADCMD="$UPLOADER $UPLOADERFLAGS $SOURCES"
)
upload_actions = [
env.VerboseAction("$REBOOTER -s", "Rebooting..."),
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
]
elif upload_protocol == "teensy-gui":
env.Replace(
UPLOADER="teensy_post_compile",
UPLOADERFLAGS=[
"-file=${PROGNAME}", '-path="$BUILD_DIR"',
"-tools=%s" % (platform.get_package_dir("tool-teensy") or ""),
"-board=%s" % board_config.id.upper(),
"-reboot"
],
UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
)
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]
# custom upload tool
elif upload_protocol == "custom":
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]
else:
sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol)
AlwaysBuild(env.Alias("upload", target_firm, upload_actions))
#
# Default targets
#
Default([target_buildprog, target_size])

+ 2
- 0
examples/arduino-blink/.gitignore 查看文件

@@ -0,0 +1,2 @@
.pioenvs
.piolibdeps

+ 67
- 0
examples/arduino-blink/.travis.yml 查看文件

@@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/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
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be 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
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

+ 38
- 0
examples/arduino-blink/README.rst 查看文件

@@ -0,0 +1,38 @@
.. Copyright 2014-present PlatformIO <contact@platformio.org>
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 Core <http://docs.platformio.org/page/core.html>`_
2. Download `development platform with examples <https://github.com/platformio/platform-teensy/archive/develop.zip>`_
3. Extract ZIP archive
4. Run these commands:
.. code-block:: bash
# Change directory to example
> cd platform-teensy/examples/arduino-blink
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Build specific environment
> platformio run -e teensy31
# Upload firmware for the specific environment
> platformio run -e teensy31 --target upload
# Clean build files
> platformio run --target clean

+ 39
- 0
examples/arduino-blink/include/README 查看文件

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

+ 46
- 0
examples/arduino-blink/lib/README 查看文件

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

+ 53
- 0
examples/arduino-blink/platformio.ini 查看文件

@@ -0,0 +1,53 @@
; 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/page/projectconf.html
[env:teensy2]
platform = teensy
framework = arduino
board = teensy2
[env:teensy 2pp]
platform = teensy
framework = arduino
board = teensy2pp
[env:teensy30]
platform = teensy
framework = arduino
board = teensy30
[env:teensy31]
platform = teensy
framework = arduino
board = teensy31
[env:teensylc]
platform = teensy
framework = arduino
board = teensylc
[env:teensy35]
platform = teensy
framework = arduino
board = teensy35
[env:teensy36]
platform = teensy
framework = arduino
board = teensy36
[env:teensy40]
platform = teensy
framework = arduino
board = teensy40
[env:teensy41]
platform = teensy
framework = arduino
board = teensy41

+ 25
- 0
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 <Arduino.h>
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(1000);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(1000);
}

+ 11
- 0
examples/arduino-blink/test/README 查看文件

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

+ 2
- 0
examples/arduino-hid-usb-mouse/.gitignore 查看文件

@@ -0,0 +1,2 @@
.pioenvs
.piolibdeps

+ 67
- 0
examples/arduino-hid-usb-mouse/.travis.yml 查看文件

@@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/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
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be 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
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

+ 32
- 0
examples/arduino-hid-usb-mouse/README.rst 查看文件

@@ -0,0 +1,32 @@
.. Copyright 2014-present PlatformIO <contact@platformio.org>
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 Core <http://docs.platformio.org/page/core.html>`_
2. Download `development platform with examples <https://github.com/platformio/platform-teensy/archive/develop.zip>`_
3. Extract ZIP archive
4. Run these commands:
.. code-block:: bash
# Change directory to example
> cd platform-teensy/examples/arduino-hid-usb-mouse
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Clean build files
> platformio run --target clean

+ 39
- 0
examples/arduino-hid-usb-mouse/include/README 查看文件

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

+ 46
- 0
examples/arduino-hid-usb-mouse/lib/README 查看文件

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

+ 50
- 0
examples/arduino-hid-usb-mouse/platformio.ini 查看文件

@@ -0,0 +1,50 @@
; 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/page/projectconf.html
[env:teensy2]
platform = teensy
framework = arduino
board = teensy2
build_flags = -DUSB_SERIAL_HID
[env:teensy2pp]
platform = teensy
framework = arduino
board = teensy2pp
build_flags = -DUSB_SERIAL_HID
[env:teensy30]
platform = teensy
framework = arduino
board = teensy30
build_flags = -DUSB_SERIAL_HID
[env:teensy31]
platform = teensy
framework = arduino
board = teensy31
build_flags = -DUSB_SERIAL_HID
[env:teensylc]
platform = teensy
framework = arduino
board = teensylc
build_flags = -DUSB_SERIAL_HID
[env:teensy35]
platform = teensy
framework = arduino
board = teensy35
build_flags = -DUSB_SERIAL_HID
[env:teensy36]
platform = teensy
framework = arduino
board = teensy36
build_flags = -DUSB_SERIAL_HID

+ 26
- 0
examples/arduino-hid-usb-mouse/src/TriangleMove.ino 查看文件

@@ -0,0 +1,26 @@
/* Simple USB Mouse Example
Teensy becomes a USB mouse and moves the cursor in a triangle
You must select Mouse from the "Tools > USB Type" menu
This example code is in the public domain.
*/
#include <Arduino.h>
void setup() { } // no setup needed
void loop() {
int i;
for (i=0; i<40; i++) {
Mouse.move(2, -1);
delay(25);
}
for (i=0; i<40; i++) {
Mouse.move(2, 2);
delay(25);
}
for (i=0; i<40; i++) {
Mouse.move(-4, -1);
delay(25);
}
}

+ 11
- 0
examples/arduino-hid-usb-mouse/test/README 查看文件

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

+ 2
- 0
examples/arduino-internal-libs/.gitignore 查看文件

@@ -0,0 +1,2 @@
.pioenvs
.piolibdeps

+ 67
- 0
examples/arduino-internal-libs/.travis.yml 查看文件

@@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/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
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be 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
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

+ 38
- 0
examples/arduino-internal-libs/README.rst 查看文件

@@ -0,0 +1,38 @@
.. Copyright 2014-present PlatformIO <contact@platformio.org>
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 Core <http://docs.platformio.org/page/core.html>`_
2. Download `development platform with examples <https://github.com/platformio/platform-teensy/archive/develop.zip>`_
3. Extract ZIP archive
4. Run these commands:
.. code-block:: bash
# Change directory to example
> cd platform-teensy/examples/arduino-internal-libs
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Build specific environment
> platformio run -e teensy31
# Upload firmware for the specific environment
> platformio run -e teensy31 --target upload
# Clean build files
> platformio run --target clean

+ 39
- 0
examples/arduino-internal-libs/include/README 查看文件

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

+ 46
- 0
examples/arduino-internal-libs/lib/README 查看文件

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

+ 53
- 0
examples/arduino-internal-libs/platformio.ini 查看文件

@@ -0,0 +1,53 @@
; 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/page/projectconf.html
[env:teensy2]
platform = teensy
framework = arduino
board = teensy2
[env:teensy2pp]
platform = teensy
framework = arduino
board = teensy2pp
[env:teensy30]
platform = teensy
framework = arduino
board = teensy30
[env:teensy31]
platform = teensy
framework = arduino
board = teensy31
[env:teensylc]
platform = teensy
framework = arduino
board = teensylc
[env:teensy35]
platform = teensy
framework = arduino
board = teensy35
[env:teensy36]
platform = teensy
framework = arduino
board = teensy36
[env:teensy40]
platform = teensy
framework = arduino
board = teensy40
[env:teensy41]
platform = teensy
framework = arduino
board = teensy41

+ 80
- 0
examples/arduino-internal-libs/src/ChatServer.ino 查看文件

@@ -0,0 +1,80 @@
/*
Chat Server
A simple server that distributes any incoming messages to all
connected clients. To use telnet to your device's IP address and type.
You can see the client's input in the serial monitor as well.
Using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
*/
#include <Arduino.h>
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255, 0, 0);
// telnet defaults to port 23
EthernetServer server(23);
boolean alreadyConnected = false; // whether or not the client was connected previously
void setup() {
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Chat server address:");
Serial.println(Ethernet.localIP());
}
void loop() {
// wait for a new client:
EthernetClient client = server.available();
// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clead out the input buffer:
client.flush();
Serial.println("We have a new client");
client.println("Hello, client!");
alreadyConnected = true;
}
if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.write(thisChar);
}
}
}

+ 11
- 0
examples/arduino-internal-libs/test/README 查看文件

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

+ 2
- 0
examples/mbed-blink/.gitignore 查看文件

@@ -0,0 +1,2 @@
.pioenvs
.piolibdeps

+ 67
- 0
examples/mbed-blink/.travis.yml 查看文件

@@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/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
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be 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
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

+ 32
- 0
examples/mbed-blink/README.rst 查看文件

@@ -0,0 +1,32 @@
.. Copyright 2014-present PlatformIO <contact@platformio.org>
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 Core <http://docs.platformio.org/page/core.html>`_
2. Download `development platform with examples <https://github.com/platformio/platform-teensy/archive/develop.zip>`_
3. Extract ZIP archive
4. Run these commands:
.. code-block:: bash
# Change directory to example
> cd platform-teensy/examples/mbed-blink
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Clean build files
> platformio run --target clean

+ 39
- 0
examples/mbed-blink/include/README 查看文件

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

+ 46
- 0
examples/mbed-blink/lib/README 查看文件

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

+ 13
- 0
examples/mbed-blink/platformio.ini 查看文件

@@ -0,0 +1,13 @@
; 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/page/projectconf.html
[env:teensy31]
platform = teensy
framework = mbed
board = teensy31

+ 12
- 0
examples/mbed-blink/src/main.cpp 查看文件

@@ -0,0 +1,12 @@
#include "mbed.h"
DigitalOut myled(LED1);
int main() {
while(1) {
myled = 1;
wait(1);
myled = 0;
wait(1);
}
}

+ 11
- 0
examples/mbed-blink/test/README 查看文件

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

+ 2
- 0
examples/mbed-dsp/.gitignore 查看文件

@@ -0,0 +1,2 @@
.pioenvs
.piolibdeps

+ 67
- 0
examples/mbed-dsp/.travis.yml 查看文件

@@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/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
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be 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
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

+ 32
- 0
examples/mbed-dsp/README.rst 查看文件

@@ -0,0 +1,32 @@
.. Copyright 2014-present PlatformIO <contact@platformio.org>
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 Core <http://docs.platformio.org/page/core.html>`_
2. Download `development platform with examples <https://github.com/platformio/platform-teensy/archive/develop.zip>`_
3. Extract ZIP archive
4. Run these commands:
.. code-block:: bash
# Change directory to example
> cd platform-teensy/examples/mbed-dsp
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Clean build files
> platformio run --target clean

+ 39
- 0
examples/mbed-dsp/include/README 查看文件

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

+ 46
- 0
examples/mbed-dsp/lib/README 查看文件

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

+ 13
- 0
examples/mbed-dsp/platformio.ini 查看文件

@@ -0,0 +1,13 @@
; 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/page/projectconf.html
[env:teensy31]
platform = teensy
framework = mbed
board = teensy31

+ 94
- 0
examples/mbed-dsp/src/data.cpp 查看文件

@@ -0,0 +1,94 @@
#include "arm_math.h"
/* ----------------------------------------------------------------------
** Test input signal contains 1000Hz + 15000 Hz
** ------------------------------------------------------------------- */
float32_t testInput_f32_1kHz_15kHz[320] =
{
+0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f,
+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f,
+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f,
-0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f,
-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f,
-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f,
+0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f,
+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f,
+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f,
+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f,
-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f,
-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f,
+0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f,
+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f,
+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f,
+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f,
-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f,
-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f,
-0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f,
+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f,
+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f,
-0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f,
-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f,
-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f,
+0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f,
+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f,
+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f,
+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f,
-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f,
-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f,
-0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f,
+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f,
+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f,
+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f,
-0.8660254038f, -0.4619397663f, -1.3194792169f, -1.1827865776f, -0.5000000000f, -1.1827865776f, -1.3194792169f, -0.4619397663f,
-0.8660254038f, -1.2552931065f, -0.3535533906f, -0.4174197128f, -1.0000000000f, -0.1913417162f, +0.0947343455f, -0.5924659585f,
-0.0000000000f, +0.5924659585f, -0.0947343455f, +0.1913417162f, +1.0000000000f, +0.4174197128f, +0.3535533906f, +1.2552931065f,
+0.8660254038f, +0.4619397663f, +1.3194792169f, +1.1827865776f, +0.5000000000f, +1.1827865776f, +1.3194792169f, +0.4619397663f,
+0.8660254038f, +1.2552931065f, +0.3535533906f, +0.4174197128f, +1.0000000000f, +0.1913417162f, -0.0947343455f, +0.5924659585f,
+0.0000000000f, -0.5924659585f, +0.0947343455f, -0.1913417162f, -1.0000000000f, -0.4174197128f, -0.3535533906f, -1.2552931065f,
};
float32_t refOutput[320] =
{
+0.0000000000f, -0.0010797829f, -0.0007681386f, -0.0001982932f, +0.0000644313f, +0.0020854271f, +0.0036891871f, +0.0015855941f,
-0.0026280805f, -0.0075907658f, -0.0119390538f, -0.0086665968f, +0.0088981202f, +0.0430539279f, +0.0974468742f, +0.1740405600f,
+0.2681416601f, +0.3747720089f, +0.4893362230f, +0.6024154672f, +0.7058740791f, +0.7968348987f, +0.8715901940f, +0.9277881093f,
+0.9682182661f, +0.9934674267f, +1.0012052245f, +0.9925859371f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f,
+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f,
-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f,
-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f,
-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f,
+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f,
+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f,
+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f,
-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f,
-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f,
-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f,
+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f,
+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f,
+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, -0.0000000000f, -0.1309866321f,
-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f,
-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f,
-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f,
+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f,
+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f,
+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f,
-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f,
-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f,
-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f,
+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f,
+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f,
+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f,
-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f,
-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f,
-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, -0.0000000000f, +0.1309866321f,
+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f,
+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f,
+0.7085021596f, +0.6100062330f, +0.5012752767f, +0.3834386057f, +0.2592435399f, +0.1309866321f, +0.0000000000f, -0.1309866321f,
-0.2592435399f, -0.3834386057f, -0.5012752767f, -0.6100062330f, -0.7085021596f, -0.7952493046f, -0.8679010068f, -0.9257026822f,
-0.9681538347f, -0.9936657199f, -1.0019733630f, -0.9936657199f, -0.9681538347f, -0.9257026822f, -0.8679010068f, -0.7952493046f,
-0.7085021596f, -0.6100062330f, -0.5012752767f, -0.3834386057f, -0.2592435399f, -0.1309866321f, +0.0000000000f, +0.1309866321f,
+0.2592435399f, +0.3834386057f, +0.5012752767f, +0.6100062330f, +0.7085021596f, +0.7952493046f, +0.8679010068f, +0.9257026822f,
+0.9681538347f, +0.9936657199f, +1.0019733630f, +0.9936657199f, +0.9681538347f, +0.9257026822f, +0.8679010068f, +0.7952493046f
};

+ 65
- 0
examples/mbed-dsp/src/main.cpp 查看文件

@@ -0,0 +1,65 @@
#include "arm_math.h"
#include "math_helper.h"
#include <stdio.h>
#define BLOCK_SIZE 32
#define NUM_BLOCKS 10
#define TEST_LENGTH_SAMPLES (BLOCK_SIZE * NUM_BLOCKS)
#define SNR_THRESHOLD_F32 140.0f
#define NUM_TAPS 29
/* -------------------------------------------------------------------
* The input signal and reference output (computed with MATLAB)
* are defined externally in arm_fir_lpf_data.c.
* ------------------------------------------------------------------- */
extern float32_t testInput_f32_1kHz_15kHz[TEST_LENGTH_SAMPLES];
extern float32_t refOutput[TEST_LENGTH_SAMPLES];
/* -------------------------------------------------------------------
* Declare State buffer of size (numTaps + blockSize - 1)
* ------------------------------------------------------------------- */
static float32_t firStateF32[BLOCK_SIZE + NUM_TAPS - 1];
/* ----------------------------------------------------------------------
* FIR Coefficients buffer generated using fir1() MATLAB function.
* fir1(28, 6/24)
* ------------------------------------------------------------------- */
const float32_t firCoeffs32[NUM_TAPS] = {
-0.0018225230f, -0.0015879294f, +0.0000000000f, +0.0036977508f, +0.0080754303f,
+0.0085302217f, -0.0000000000f, -0.0173976984f, -0.0341458607f, -0.0333591565f,
+0.0000000000f, +0.0676308395f, +0.1522061835f, +0.2229246956f, +0.2504960933f,
+0.2229246956f, +0.1522061835f, +0.0676308395f, +0.0000000000f, -0.0333591565f,
-0.0341458607f, -0.0173976984f, -0.0000000000f, +0.0085302217f, +0.0080754303f,
+0.0036977508f, +0.0000000000f, -0.0015879294f, -0.0018225230f
};
/* ----------------------------------------------------------------------
* FIR LPF Example
* ------------------------------------------------------------------- */
int main(void) {
/* Call FIR init function to initialize the instance structure. */
arm_fir_instance_f32 S;
arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], BLOCK_SIZE);
/* ----------------------------------------------------------------------
* Call the FIR process function for every blockSize samples
* ------------------------------------------------------------------- */
for (uint32_t i=0; i < NUM_BLOCKS; i++) {
float32_t* signal = testInput_f32_1kHz_15kHz + (i * BLOCK_SIZE);
arm_fir_f32(&S, signal, signal, BLOCK_SIZE);
}
/* ----------------------------------------------------------------------
* Compare the generated output against the reference output computed
* in MATLAB.
* ------------------------------------------------------------------- */
float32_t snr = arm_snr_f32(refOutput, testInput_f32_1kHz_15kHz, TEST_LENGTH_SAMPLES);
printf("snr: %f\n\r", snr);
if (snr < SNR_THRESHOLD_F32) {
printf("Failed\n\r");
} else {
printf("Success\n\r");
}
}

+ 11
- 0
examples/mbed-dsp/test/README 查看文件

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

+ 2
- 0
examples/mbed-events/.gitignore 查看文件

@@ -0,0 +1,2 @@
.pioenvs
.piolibdeps

+ 67
- 0
examples/mbed-events/.travis.yml 查看文件

@@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/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
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be 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
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

+ 32
- 0
examples/mbed-events/README.rst 查看文件

@@ -0,0 +1,32 @@
.. Copyright 2014-present PlatformIO <contact@platformio.org>
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 Core <http://docs.platformio.org/page/core.html>`_
2. Download `development platform with examples <https://github.com/platformio/platform-teensy/archive/develop.zip>`_
3. Extract ZIP archive
4. Run these commands:
.. code-block:: bash
# Change directory to example
> cd platform-teensy/examples/mbed-events
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Clean build files
> platformio run --target clean

+ 39
- 0
examples/mbed-events/include/README 查看文件

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

+ 46
- 0
examples/mbed-events/lib/README 查看文件

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

+ 13
- 0
examples/mbed-events/platformio.ini 查看文件

@@ -0,0 +1,13 @@
; 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/page/projectconf.html
[env:teensy31 events]
platform = teensy
framework = mbed
board = teensy31

+ 15
- 0
examples/mbed-events/src/main.cpp 查看文件

@@ -0,0 +1,15 @@
#include "mbed_events.h"
#include <stdio.h>
int main() {
// creates a queue with the default size
EventQueue queue;
// events are simple callbacks
queue.call(printf, "called immediately\n");
queue.call_in(2000, printf, "called in 2 seconds\n");
queue.call_every(1000, printf, "called every 1 seconds\n");
// events are executed by the dispatch method
queue.dispatch();
}

+ 11
- 0
examples/mbed-events/test/README 查看文件

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

+ 2
- 0
examples/mbed-serial/.gitignore 查看文件

@@ -0,0 +1,2 @@
.pioenvs
.piolibdeps

+ 67
- 0
examples/mbed-serial/.travis.yml 查看文件

@@ -0,0 +1,67 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/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
# - platformio update
#
# script:
# - platformio run
#
# Template #2: The project is intended to be 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
# - platformio update
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

+ 32
- 0
examples/mbed-serial/README.rst 查看文件

@@ -0,0 +1,32 @@
.. Copyright 2014-present PlatformIO <contact@platformio.org>
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 Core <http://docs.platformio.org/page/core.html>`_
2. Download `development platform with examples <https://github.com/platformio/platform-teensy/archive/develop.zip>`_
3. Extract ZIP archive
4. Run these commands:
.. code-block:: bash
# Change directory to example
> cd platform-teensy/examples/mbed-serial
# Build project
> platformio run
# Upload firmware
> platformio run --target upload
# Clean build files
> platformio run --target clean

+ 39
- 0
examples/mbed-serial/include/README 查看文件

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

+ 46
- 0
examples/mbed-serial/lib/README 查看文件

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

+ 13
- 0
examples/mbed-serial/platformio.ini 查看文件

@@ -0,0 +1,13 @@
; 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/page/projectconf.html
[env:teensy31]
platform = teensy
framework = mbed
board = teensy31

+ 10
- 0
examples/mbed-serial/src/main.cpp 查看文件

@@ -0,0 +1,10 @@
#include "mbed.h"
Serial pc(USBTX, USBRX); // tx, rx
int main() {
pc.printf("Hello World!\n\r");
while(1) {
pc.putc(pc.getc() + 1); // echo input back to terminal
}
}

+ 11
- 0
examples/mbed-serial/test/README 查看文件

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

+ 38445
- 0
misc/svd/MK20D5.svd
文件差異過大導致無法顯示
查看文件


+ 136687
- 0
misc/svd/MK64F12.svd
文件差異過大導致無法顯示
查看文件


+ 113910
- 0
misc/svd/MK66F18.svd
文件差異過大導致無法顯示
查看文件


+ 64921
- 0
misc/svd/MKL26Z4.svd
文件差異過大導致無法顯示
查看文件


+ 71
- 0
platform.json 查看文件

@@ -0,0 +1,71 @@
{
"name": "teensy-gcc",
"title": "Teensy",
"description": "Teensy is a complete USB-based microcontroller development system, in a very small footprint, capable of implementing many types of projects. All programming is done via the USB port. No special programmer is needed, only a standard USB cable and a PC or Macintosh with a USB port.",
"homepage": "https://www.pjrc.com/teensy",
"license": "Apache-2.0",
"keywords": [
"dev-platform",
"ARM",
"AVR",
"Cortex-M",
"NXP Semiconductors",
"Microchip"
],
"engines": {
"platformio": "^5"
},
"repository": {
"type": "git",
"url": "https://github.com/platformio/platform-teensy.git"
},
"version": "4.17.0",
"frameworks": {
"arduino": {
"package": "framework-arduinoteensy-cxx17",
"script": "builder/frameworks/arduino.py"
},
"mbed": {
"package": "framework-mbed",
"script": "builder/frameworks/mbed.py"
}
},
"packages": {
"toolchain-atmelavr": {
"type": "toolchain",
"optional": false,
"owner": "platformio",
"version": "~1.50400.0"
},
"toolchain-gcc-arm-embedded": {
"type": "toolchain",
"optional": false,
"owner": "skepto",
"version": "~0.1.0"
},
"framework-arduinoteensy-cxx17": {
"type": "framework",
"optional": true,
"owner": "skepto",
"version": "~0.1.0"
},
"framework-mbed": {
"type": "framework",
"optional": true,
"owner": "platformio",
"version": "~6.51506.0"
},
"tool-teensy": {
"type": "uploader",
"optional": true,
"owner": "platformio",
"version": "<2"
},
"tool-jlink": {
"type": "uploader",
"optional": true,
"owner": "platformio",
"version": "^1.63208.0"
}
}
}

+ 91
- 0
platform.py 查看文件

@@ -0,0 +1,91 @@
# Copyright 2014-present PlatformIO <contact@platformio.org>
#
# 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.
from platform import system
from platformio.managers.platform import PlatformBase
class TeensygccPlatform(PlatformBase):
def configure_default_packages(self, variables, targets):
if variables.get("board"):
board_config = self.board_config(variables.get("board"))
del_toolchain = "toolchain-gcc-arm-embedded"
if board_config.get("build.core") != "teensy":
del_toolchain = "toolchain-atmelavr"
if del_toolchain in self.packages:
del self.packages[del_toolchain]
if "mbed" in variables.get("pioframework", []):
self.packages["toolchain-gccarmnoneeabi"][
'version'] = ">=1.60301.0,<1.80000.0"
# configure J-LINK tool
jlink_conds = [
"jlink" in variables.get(option, "")
for option in ("upload_protocol", "debug_tool")
]
if variables.get("board"):
board_config = self.board_config(variables.get("board"))
jlink_conds.extend([
"jlink" in board_config.get(key, "")
for key in ("debug.default_tools", "upload.protocol")
])
jlink_pkgname = "tool-jlink"
if not any(jlink_conds) and jlink_pkgname in self.packages:
del self.packages[jlink_pkgname]
return PlatformBase.configure_default_packages(
self, variables, targets)
def get_boards(self, id_=None):
result = PlatformBase.get_boards(self, id_)
if not result:
return result
if id_:
return self._add_default_debug_tools(result)
else:
for key, value in result.items():
result[key] = self._add_default_debug_tools(result[key])
return result
def _add_default_debug_tools(self, board):
debug = board.manifest.get("debug", {})
upload_protocols = board.manifest.get("upload", {}).get(
"protocols", [])
if "tools" not in debug:
debug['tools'] = {}
if "jlink" in upload_protocols and "jlink" not in debug['tools']:
assert debug.get("jlink_device"), (
"Missed J-Link Device ID for %s" % board.id)
debug['tools']['jlink'] = {
"server": {
"package": "tool-jlink",
"arguments": [
"-singlerun",
"-if", "SWD",
"-select", "USB",
"-device", debug.get("jlink_device"),
"-port", "2331"
],
"executable": ("JLinkGDBServerCL.exe"
if system() == "Windows" else
"JLinkGDBServer")
}
}
board.manifest['debug'] = debug
return board

Loading…
取消
儲存