mirror of
https://github.com/martinloren/Artery-AT32-PlatformIO.git
synced 2026-05-21 09:22:14 +00:00
First Commit
This commit is contained in:
1
.platformio/platforms/at32/.github/FUNDING.yml
vendored
Normal file
1
.platformio/platforms/at32/.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
custom: https://platformio.org/donate
|
||||
76
.platformio/platforms/at32/.github/workflows/examples.yml
vendored
Normal file
76
.platformio/platforms/at32/.github/workflows/examples.yml
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
name: Examples
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-18.04, windows-latest, macos-latest]
|
||||
python-version: [3.7]
|
||||
example:
|
||||
- "examples/arduino-blink"
|
||||
- "examples/arduino-external-libs"
|
||||
- "examples/arduino-internal-libs"
|
||||
- "examples/arduino-mbed-doom"
|
||||
- "examples/arduino-mbed-rpc"
|
||||
- "examples/arduino-mxchip-azureiot"
|
||||
- "examples/arduino-mxchip-filesystem"
|
||||
- "examples/arduino-mxchip-sensors"
|
||||
- "examples/arduino-mxchip-wifiscan"
|
||||
- "examples/cmsis-blink"
|
||||
- "examples/libopencm3-1bitsy"
|
||||
- "examples/libopencm3-blink"
|
||||
- "examples/libopencm3-usb-cdcacm"
|
||||
- "examples/mbed-rtos-blink-baremetal"
|
||||
- "examples/mbed-rtos-custom-target"
|
||||
- "examples/mbed-rtos-ethernet-tls"
|
||||
- "examples/mbed-rtos-events"
|
||||
- "examples/mbed-rtos-filesystem"
|
||||
- "examples/mbed-rtos-mesh-minimal"
|
||||
- "examples/mbed-rtos-serial"
|
||||
- "examples/mbed-rtos-usb-keyboard"
|
||||
- "examples/mbed-rtos-wifi"
|
||||
- "examples/mbed-legacy-examples/mbed-blink"
|
||||
- "examples/mbed-legacy-examples/mbed-custom-target"
|
||||
- "examples/mbed-legacy-examples/mbed-dsp"
|
||||
- "examples/mbed-legacy-examples/mbed-events"
|
||||
- "examples/mbed-legacy-examples/mbed-filesystem"
|
||||
- "examples/mbed-legacy-examples/mbed-rtos"
|
||||
- "examples/mbed-legacy-examples/mbed-rtos-ethernet-tls"
|
||||
- "examples/mbed-legacy-examples/mbed-rtos-mesh-minimal"
|
||||
- "examples/mbed-legacy-examples/mbed-serial"
|
||||
- "examples/spl-blink"
|
||||
- "examples/stm32cube-hal-blink"
|
||||
- "examples/stm32cube-hal-eeprom-emulation"
|
||||
- "examples/stm32cube-hal-extmem-boot"
|
||||
- "examples/stm32cube-hal-iap"
|
||||
- "examples/stm32cube-hal-lcd"
|
||||
- "examples/stm32cube-hal-usb-device-dfu"
|
||||
- "examples/stm32cube-hal-wifi-client"
|
||||
- "examples/stm32cube-ll-blink"
|
||||
- "examples/zephyr-blink"
|
||||
- "examples/zephyr-cpp-synchronization"
|
||||
- "examples/zephyr-drivers-can"
|
||||
- "examples/zephyr-net-civetweb"
|
||||
- "examples/zephyr-net-https-client"
|
||||
- "examples/zephyr-subsys-usb-hid-mouse"
|
||||
- "tests/arduino-blink-different-cores"
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "recursive"
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -U https://github.com/platformio/platformio/archive/develop.zip
|
||||
platformio platform install file://.
|
||||
- name: Build examples
|
||||
run: |
|
||||
platformio run -d ${{ matrix.example }}
|
||||
3
.platformio/platforms/at32/.gitignore
vendored
Normal file
3
.platformio/platforms/at32/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*.pyc
|
||||
.piolibdeps
|
||||
.pio
|
||||
6
.platformio/platforms/at32/.gitmodules
vendored
Normal file
6
.platformio/platforms/at32/.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "builder/frameworks/libopencm3"]
|
||||
path = builder/frameworks/libopencm3
|
||||
url = https://github.com/platformio/builder-framework-libopencm3.git
|
||||
[submodule "builder/frameworks/arduino/mbed-core"]
|
||||
path = builder/frameworks/arduino/mbed-core
|
||||
url = https://github.com/platformio/builder-framework-arduino-core-mbed.git
|
||||
1
.platformio/platforms/at32/.piopm_
Normal file
1
.platformio/platforms/at32/.piopm_
Normal file
@@ -0,0 +1 @@
|
||||
{"type": "platform", "name": "at32", "version": "1.0.0", "spec": {"owner": "platformio", "id": 8020, "name": "at32", "requirements": null, "url": null}}
|
||||
174
.platformio/platforms/at32/LICENSE
Normal file
174
.platformio/platforms/at32/LICENSE
Normal file
@@ -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
.platformio/platforms/at32/README.md
Normal file
35
.platformio/platforms/at32/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# ST STM32: development platform for [PlatformIO](http://platformio.org)
|
||||
|
||||
[](https://github.com/platformio/platform-ststm32/actions)
|
||||
|
||||
The STM32 family of 32-bit Flash MCUs based on the ARM Cortex-M processor is designed to offer new degrees of freedom to MCU users. It offers a 32-bit product range that combines very high performance, real-time capabilities, digital signal processing, and low-power, low-voltage operation, while maintaining full integration and ease of development.
|
||||
|
||||
* [Home](http://platformio.org/platforms/ststm32) (home page in PlatformIO Platform Registry)
|
||||
* [Documentation](http://docs.platformio.org/page/platforms/ststm32.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 = ststm32
|
||||
board = ...
|
||||
...
|
||||
```
|
||||
|
||||
## Development version
|
||||
|
||||
```ini
|
||||
[env:development]
|
||||
platform = https://github.com/platformio/platform-ststm32.git
|
||||
board = ...
|
||||
...
|
||||
```
|
||||
|
||||
# Configuration
|
||||
|
||||
Please navigate to [documentation](http://docs.platformio.org/page/platforms/ststm32.html).
|
||||
51
.platformio/platforms/at32/boards/generic_f403a.json
Normal file
51
.platformio/platforms/at32/boards/generic_f403a.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "at32",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DAT32F403ACGT7",
|
||||
"f_cpu": "240000000L",
|
||||
"hwids": [
|
||||
[
|
||||
"0x1EAF",
|
||||
"0x0003"
|
||||
],
|
||||
[
|
||||
"0x1EAF",
|
||||
"0x0004"
|
||||
]
|
||||
],
|
||||
"mcu": "at32f403acgt7",
|
||||
"product_line": "AT32F403ACGT7",
|
||||
"variant": "AT32F4xx/F403A_F403A(T-U)"
|
||||
},
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"jlink_device": "STM32F103C8",
|
||||
"openocd_extra_args": [
|
||||
"-c",
|
||||
"reset_config none"
|
||||
],
|
||||
"openocd_target": "stm32f4x",
|
||||
"svd_path": "STM32F403xx.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"cmsis"
|
||||
],
|
||||
"name": "Generic F403A",
|
||||
"upload": {
|
||||
"maximum_ram_size": 98304,
|
||||
"maximum_size": 262144,
|
||||
"protocol": "serial",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"cmsis-dap",
|
||||
"stlink",
|
||||
"serial",
|
||||
"blackmagic"
|
||||
]
|
||||
},
|
||||
"url": "https://www.arterychip.com/en/product/AT32F403A.jsp",
|
||||
"vendor": "Artery"
|
||||
}
|
||||
38
.platformio/platforms/at32/builder/compat.py
Normal file
38
.platformio/platforms/at32/builder/compat.py
Normal file
@@ -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.
|
||||
|
||||
from SCons.Script import AlwaysBuild, Import
|
||||
|
||||
|
||||
Import("env")
|
||||
|
||||
|
||||
# Added in PIO Core 4.4.0
|
||||
if not hasattr(env, "AddPlatformTarget"):
|
||||
|
||||
def AddPlatformTarget(
|
||||
env,
|
||||
name,
|
||||
dependencies,
|
||||
actions,
|
||||
title=None,
|
||||
description=None,
|
||||
always_build=True,
|
||||
):
|
||||
target = env.Alias(name, dependencies, actions)
|
||||
if always_build:
|
||||
AlwaysBuild(target)
|
||||
return target
|
||||
|
||||
env.AddMethod(AddPlatformTarget)
|
||||
63
.platformio/platforms/at32/builder/frameworks/_bare.py
Normal file
63
.platformio/platforms/at32/builder/frameworks/_bare.py
Normal file
@@ -0,0 +1,63 @@
|
||||
# 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
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
"-Wall",
|
||||
"-mthumb"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
("F_CPU", "$BOARD_F_CPU")
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-Wl,--gc-sections,--relax",
|
||||
"-mthumb"
|
||||
],
|
||||
|
||||
LIBS=["c", "gcc", "m", "stdc++"]
|
||||
)
|
||||
|
||||
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", [])[:])
|
||||
153
.platformio/platforms/at32/builder/frameworks/cmsis.py
Normal file
153
.platformio/platforms/at32/builder/frameworks/cmsis.py
Normal file
@@ -0,0 +1,153 @@
|
||||
# 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.
|
||||
|
||||
"""
|
||||
CMSIS
|
||||
|
||||
The ARM Cortex Microcontroller Software Interface Standard (CMSIS) is a
|
||||
vendor-independent hardware abstraction layer for the Cortex-M processor
|
||||
series and specifies debugger interfaces. The CMSIS enables consistent and
|
||||
simple software interfaces to the processor for interface peripherals,
|
||||
real-time operating systems, and middleware. It simplifies software
|
||||
re-use, reducing the learning curve for new microcontroller developers
|
||||
and cutting the time-to-market for devices.
|
||||
|
||||
http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import string
|
||||
from SCons.Script import DefaultEnvironment, SConscript
|
||||
|
||||
import sys
|
||||
from os.path import join, isfile
|
||||
|
||||
|
||||
env = DefaultEnvironment()
|
||||
platform = env.PioPlatform()
|
||||
board = env.BoardConfig()
|
||||
mcu = board.get("build.mcu", "")
|
||||
product_line = board.get("build.product_line", "")
|
||||
assert product_line, "Missing MCU or Product Line field"
|
||||
|
||||
|
||||
|
||||
#env.SConscript("_bare.py")
|
||||
build_script = "_bare.py"
|
||||
build_script = join(env.PioPlatform().get_package_dir("framework-cmsis-" + mcu[0:7]),
|
||||
"tools", "platformio", "platformio-build.py")
|
||||
env.SConscript(build_script)
|
||||
|
||||
if not isfile(build_script):
|
||||
sys.stderr.write("Error: Missing PlatformIO build script %s!\n" % build_script)
|
||||
env.Exit(1)
|
||||
|
||||
SConscript(build_script)
|
||||
|
||||
|
||||
CMSIS_DIR = platform.get_package_dir("framework-cmsis")
|
||||
CMSIS_DEVICE_DIR = platform.get_package_dir("framework-cmsis-" + mcu[0:7])
|
||||
LDSCRIPTS_DIR = platform.get_package_dir("tool-ldscripts-at32")
|
||||
assert all(os.path.isdir(d) for d in (CMSIS_DIR, CMSIS_DEVICE_DIR, LDSCRIPTS_DIR))
|
||||
|
||||
|
||||
def generate_ldscript(default_ldscript_path):
|
||||
ram = board.get("upload.maximum_ram_size", 0)
|
||||
flash = board.get("upload.maximum_size", 0)
|
||||
template_file = os.path.join(LDSCRIPTS_DIR, "tpl", "linker.tpl")
|
||||
content = ""
|
||||
with open(template_file) as fp:
|
||||
data = string.Template(fp.read())
|
||||
content = data.substitute(
|
||||
stack=hex(0x20000000 + ram), # 0x20000000 - start address for RAM
|
||||
ram=str(int(ram / 1024)) + "K",
|
||||
flash=str(int(flash / 1024)) + "K")
|
||||
|
||||
with open(default_ldscript_path, "w") as fp:
|
||||
fp.write(content)
|
||||
|
||||
|
||||
def get_linker_script():
|
||||
ldscript_match = glob.glob(os.path.join(
|
||||
LDSCRIPTS_DIR, mcu[0:7], mcu[0:11].upper() + "*_FLASH.ld"))
|
||||
|
||||
if ldscript_match and os.path.isfile(ldscript_match[0]):
|
||||
return ldscript_match[0]
|
||||
|
||||
default_ldscript = os.path.join(
|
||||
LDSCRIPTS_DIR, mcu[0:7], mcu[0:11].upper() + "_DEFAULT.ld")
|
||||
|
||||
print("Warning! Cannot find a linker script for the required board! "
|
||||
"An auto-generated script will be used to link firmware!")
|
||||
|
||||
if not os.path.isfile(default_ldscript):
|
||||
generate_ldscript(default_ldscript)
|
||||
|
||||
return default_ldscript
|
||||
|
||||
|
||||
def prepare_startup_file(src_path):
|
||||
startup_file = os.path.join(src_path, "gcc", "startup_%s.S" % product_line.lower())
|
||||
# Change file extension to uppercase:
|
||||
if not os.path.isfile(startup_file) and os.path.isfile(startup_file[:-2] + ".s"):
|
||||
os.rename(startup_file[:-2] + ".s", startup_file)
|
||||
if not os.path.isfile(startup_file):
|
||||
print("Warning! Cannot find the default startup file for %s. "
|
||||
"Ignore this warning if the startup code is part of your project." % mcu)
|
||||
|
||||
|
||||
#
|
||||
# Allow using custom linker scripts
|
||||
#
|
||||
|
||||
if not board.get("build.ldscript", ""):
|
||||
env.Replace(LDSCRIPT_PATH=get_linker_script())
|
||||
|
||||
#
|
||||
# Prepare build environment
|
||||
#
|
||||
|
||||
# The final firmware is linked against standard library with two specifications:
|
||||
# nano.specs - link against a reduced-size variant of libc
|
||||
# nosys.specs - link against stubbed standard syscalls
|
||||
|
||||
env.Append(
|
||||
CPPPATH=[
|
||||
os.path.join(CMSIS_DIR, "CMSIS", "Include"),
|
||||
os.path.join(CMSIS_DEVICE_DIR, "Include")
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"--specs=nano.specs",
|
||||
"--specs=nosys.specs"
|
||||
]
|
||||
)
|
||||
|
||||
#
|
||||
# Compile CMSIS sources
|
||||
#
|
||||
|
||||
sources_path = os.path.join(CMSIS_DEVICE_DIR, "Source", "Templates")
|
||||
prepare_startup_file(sources_path)
|
||||
|
||||
|
||||
|
||||
env.BuildSources(
|
||||
os.path.join("$BUILD_DIR", "FrameworkCMSIS"), sources_path,
|
||||
src_filter=[
|
||||
"-<*>",
|
||||
"+<%s>" % board.get("build.cmsis.system_file", "system_%sxx.c" % mcu[0:7]),
|
||||
"+<gcc/startup_%s.S>" % product_line.lower()]
|
||||
)
|
||||
279
.platformio/platforms/at32/builder/main.py
Normal file
279
.platformio/platforms/at32/builder/main.py
Normal file
@@ -0,0 +1,279 @@
|
||||
# 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 basename, isdir, join
|
||||
|
||||
from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, AlwaysBuild,
|
||||
Builder, Default, DefaultEnvironment)
|
||||
|
||||
from platformio.util import get_serial_ports
|
||||
|
||||
|
||||
def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
|
||||
env.AutodetectUploadPort()
|
||||
|
||||
upload_options = {}
|
||||
if "BOARD" in env:
|
||||
upload_options = env.BoardConfig().get("upload", {})
|
||||
|
||||
if not bool(upload_options.get("disable_flushing", False)):
|
||||
env.FlushSerialBuffer("$UPLOAD_PORT")
|
||||
|
||||
before_ports = get_serial_ports()
|
||||
|
||||
if bool(upload_options.get("use_1200bps_touch", False)):
|
||||
env.TouchSerialPort("$UPLOAD_PORT", 1200)
|
||||
|
||||
if bool(upload_options.get("wait_for_upload_port", False)):
|
||||
env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports))
|
||||
|
||||
|
||||
env = DefaultEnvironment()
|
||||
env.SConscript("compat.py", exports="env")
|
||||
platform = env.PioPlatform()
|
||||
board = env.BoardConfig()
|
||||
|
||||
env.Replace(
|
||||
AR="arm-none-eabi-gcc-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",
|
||||
|
||||
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",
|
||||
SIZEPRINTCMD='$SIZETOOL -B -d $SOURCES',
|
||||
|
||||
PROGSUFFIX=".elf"
|
||||
)
|
||||
|
||||
# Allow user to override via pre:script
|
||||
if env.get("PROGNAME", "program") == "program":
|
||||
env.Replace(PROGNAME="firmware")
|
||||
|
||||
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.py")
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
frameworks = env.get("PIOFRAMEWORK", [])
|
||||
|
||||
target_elf = None
|
||||
if "nobuild" in COMMAND_LINE_TARGETS:
|
||||
target_elf = join("$BUILD_DIR", "${PROGNAME}.elf")
|
||||
target_firm = join("$BUILD_DIR", "${PROGNAME}.bin")
|
||||
else:
|
||||
target_elf = env.BuildProgram()
|
||||
target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf)
|
||||
env.Depends(target_firm, "checkprogsize")
|
||||
|
||||
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 .bin file
|
||||
#
|
||||
|
||||
upload_protocol = env.subst("$UPLOAD_PROTOCOL")
|
||||
debug_tools = board.get("debug.tools", {})
|
||||
upload_source = target_firm
|
||||
upload_actions = []
|
||||
|
||||
if upload_protocol.startswith("blackmagic"):
|
||||
env.Replace(
|
||||
UPLOADER="$GDB",
|
||||
UPLOADERFLAGS=[
|
||||
"-nx",
|
||||
"--batch",
|
||||
"-ex", "target extended-remote $UPLOAD_PORT",
|
||||
"-ex", "monitor %s_scan" %
|
||||
("jtag" if upload_protocol == "blackmagic-jtag" else "swdp"),
|
||||
"-ex", "attach 1",
|
||||
"-ex", "load",
|
||||
"-ex", "compare-sections",
|
||||
"-ex", "kill"
|
||||
],
|
||||
UPLOADCMD="$UPLOADER $UPLOADERFLAGS $SOURCE"
|
||||
)
|
||||
upload_source = target_elf
|
||||
upload_actions = [
|
||||
env.VerboseAction(env.AutodetectUploadPort, "Looking for BlackMagic port..."),
|
||||
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
|
||||
]
|
||||
|
||||
elif 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",
|
||||
"loadbin %s, %s" % (source, board.get(
|
||||
"upload.offset_address", "0x08000000")),
|
||||
"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.get("debug", {}).get("jlink_device"),
|
||||
"-speed", env.GetProjectOption("debug_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 == "serial":
|
||||
def __configure_upload_port(env):
|
||||
return env.subst("$UPLOAD_PORT")
|
||||
|
||||
env.Replace(
|
||||
__configure_upload_port=__configure_upload_port,
|
||||
UPLOADER=join(
|
||||
'"%s"' % platform.get_package_dir("tool-stm32duino") or "",
|
||||
"stm32flash", "stm32flash"),
|
||||
UPLOADERFLAGS=[
|
||||
"-g", board.get("upload.offset_address", "0x08000000"),
|
||||
"-b", env.subst("$UPLOAD_SPEED") or "115200", "-w"
|
||||
],
|
||||
UPLOADCMD='$UPLOADER $UPLOADERFLAGS "$SOURCE" "${__configure_upload_port(__env__)}"'
|
||||
)
|
||||
|
||||
upload_actions = [
|
||||
env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."),
|
||||
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
|
||||
]
|
||||
|
||||
elif upload_protocol == "hid":
|
||||
def __configure_upload_port(env):
|
||||
return basename(env.subst("$UPLOAD_PORT"))
|
||||
|
||||
env.Replace(
|
||||
__configure_upload_port=__configure_upload_port,
|
||||
UPLOADER="hid-flash",
|
||||
UPLOADCMD='$UPLOADER "$SOURCES" "${__configure_upload_port(__env__)}"'
|
||||
)
|
||||
upload_actions = [
|
||||
env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."),
|
||||
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
|
||||
]
|
||||
|
||||
elif upload_protocol in debug_tools:
|
||||
openocd_args = [
|
||||
"-d%d" % (2 if int(ARGUMENTS.get("PIOVERBOSE", 0)) else 1)
|
||||
]
|
||||
openocd_args.extend(
|
||||
debug_tools.get(upload_protocol).get("server").get("arguments", []))
|
||||
if env.GetProjectOption("debug_speed", ""):
|
||||
openocd_args.extend(
|
||||
["-c", "adapter speed %s" % env.GetProjectOption("debug_speed")]
|
||||
)
|
||||
openocd_args.extend([
|
||||
"-c", "program {$SOURCE} %s verify reset; shutdown;" %
|
||||
board.get("upload.offset_address", "")
|
||||
])
|
||||
openocd_args = [
|
||||
f.replace("$PACKAGE_DIR",
|
||||
platform.get_package_dir("tool-openocd") or "")
|
||||
for f in openocd_args
|
||||
]
|
||||
env.Replace(
|
||||
UPLOADER="openocd",
|
||||
UPLOADERFLAGS=openocd_args,
|
||||
UPLOADCMD="$UPLOADER $UPLOADERFLAGS")
|
||||
|
||||
if not board.get("upload").get("offset_address"):
|
||||
upload_source = target_elf
|
||||
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", upload_source, upload_actions))
|
||||
|
||||
#
|
||||
# Information about obsolete method of specifying linker scripts
|
||||
#
|
||||
|
||||
if any("-Wl,-T" in f for f in env.get("LINKFLAGS", [])):
|
||||
print("Warning! '-Wl,-T' option for specifying linker scripts is deprecated. "
|
||||
"Please use 'board_build.ldscript' option in your 'platformio.ini' file.")
|
||||
|
||||
#
|
||||
# Default targets
|
||||
#
|
||||
|
||||
Default([target_buildprog, target_size])
|
||||
1
.platformio/platforms/at32/examples/cmsis-acd1_dma/.gitignore
vendored
Normal file
1
.platformio/platforms/at32/examples/cmsis-acd1_dma/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.pio
|
||||
@@ -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
|
||||
46
.platformio/platforms/at32/examples/cmsis-acd1_dma/.vscode/c_cpp_properties.json
vendored
Normal file
46
.platformio/platforms/at32/examples/cmsis-acd1_dma/.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// !!! WARNING !!! AUTO-GENERATED FILE!
|
||||
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
|
||||
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
|
||||
//
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "PlatformIO",
|
||||
"includePath": [
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-acd1_dma/include",
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-acd1_dma/src",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis@2.50501.200527/CMSIS/Include",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis-at32f40/Include",
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-acd1_dma/lib/Delay",
|
||||
""
|
||||
],
|
||||
"browse": {
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"path": [
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-acd1_dma/include",
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-acd1_dma/src",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis@2.50501.200527/CMSIS/Include",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis-at32f40/Include",
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-acd1_dma/lib/Delay",
|
||||
""
|
||||
]
|
||||
},
|
||||
"defines": [
|
||||
"PLATFORMIO=50200",
|
||||
"AT32F403ACGT7",
|
||||
""
|
||||
],
|
||||
"cStandard": "c11",
|
||||
"compilerPath": "C:/Users/Xliloz/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe",
|
||||
"compilerArgs": [
|
||||
"-mcpu=cortex-m4",
|
||||
"-mthumb",
|
||||
"-mcpu=cortex-m4",
|
||||
"-mthumb",
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
7
.platformio/platforms/at32/examples/cmsis-acd1_dma/.vscode/extensions.json
vendored
Normal file
7
.platformio/platforms/at32/examples/cmsis-acd1_dma/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
34
.platformio/platforms/at32/examples/cmsis-acd1_dma/.vscode/launch.json
vendored
Normal file
34
.platformio/platforms/at32/examples/cmsis-acd1_dma/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
|
||||
//
|
||||
// PIO Unified Debugger
|
||||
//
|
||||
// Documentation: https://docs.platformio.org/page/plus/debugging.html
|
||||
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
|
||||
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug",
|
||||
"executable": "C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-acd1_dma/.pio/build/generic f403a/firmware.elf",
|
||||
"projectEnvName": "generic f403a",
|
||||
"toolchainBinDir": "C:/Users/Xliloz/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"preLaunchTask": {
|
||||
"type": "PlatformIO",
|
||||
"task": "Pre-Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug (skip Pre-Debug)",
|
||||
"executable": "C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-acd1_dma/.pio/build/generic f403a/firmware.elf",
|
||||
"projectEnvName": "generic f403a",
|
||||
"toolchainBinDir": "C:/Users/Xliloz/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
||||
5
.platformio/platforms/at32/examples/cmsis-acd1_dma/.vscode/settings.json
vendored
Normal file
5
.platformio/platforms/at32/examples/cmsis-acd1_dma/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"at32f4xx.h": "c"
|
||||
}
|
||||
}
|
||||
@@ -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-ststm32/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-at32/examples/cmsis-blink
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e disco_f407vg
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e disco_f407vg --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
||||
@@ -0,0 +1 @@
|
||||
.pio
|
||||
@@ -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
|
||||
@@ -0,0 +1,92 @@
|
||||
#include "delay.h"
|
||||
#include "stdio.h"
|
||||
|
||||
/*delay macros*/
|
||||
#define STEP_DELAY_MS 500
|
||||
|
||||
/*delay variable*/
|
||||
static __IO float fac_us;
|
||||
static __IO float fac_ms;
|
||||
|
||||
|
||||
/**
|
||||
* @brief initialize Delay function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void Delay_init()
|
||||
{
|
||||
/*Config Systick*/
|
||||
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
|
||||
fac_us=(float)SystemCoreClock/(8 * 1000000);
|
||||
fac_ms=fac_us*1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts a delay time.
|
||||
* @param nus: specifies the delay time length, in microsecond.
|
||||
* @retval None
|
||||
*/
|
||||
void Delay_us(u32 nus)
|
||||
{
|
||||
u32 temp;
|
||||
SysTick->LOAD = (u32)(nus*fac_us);
|
||||
SysTick->VAL = 0x00;
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk ;
|
||||
do
|
||||
{
|
||||
temp = SysTick->CTRL;
|
||||
}while((temp & 0x01) &&! (temp & (1<<16)));
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->VAL = 0X00;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts a delay time.
|
||||
* @param nms: specifies the delay time length, in milliseconds.
|
||||
* @retval None
|
||||
*/
|
||||
void Delay_ms(u16 nms)
|
||||
{
|
||||
u32 temp;
|
||||
while(nms)
|
||||
{
|
||||
if(nms > STEP_DELAY_MS)
|
||||
{
|
||||
SysTick->LOAD = (u32)(STEP_DELAY_MS * fac_ms);
|
||||
nms -= STEP_DELAY_MS;
|
||||
}
|
||||
else
|
||||
{
|
||||
SysTick->LOAD = (u32)(nms * fac_ms);
|
||||
nms = 0;
|
||||
}
|
||||
SysTick->VAL = 0x00;
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
do
|
||||
{
|
||||
temp = SysTick->CTRL;
|
||||
}while( (temp & 0x01) && !(temp & (1<<16)) );
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->VAL = 0X00;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts a delay time.
|
||||
* @param sec: specifies the delay time length, in seconds.
|
||||
* @retval None
|
||||
*/
|
||||
void Delay_sec(u16 sec)
|
||||
{
|
||||
u16 i;
|
||||
for(i=0; i<sec; i++)
|
||||
{
|
||||
Delay_ms(500);
|
||||
Delay_ms(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* File : delay.h
|
||||
*/
|
||||
|
||||
#ifndef __DELAY_H
|
||||
#define __DELAY_H
|
||||
#include <at32f4xx.h>
|
||||
|
||||
/*Delay function*/
|
||||
void Delay_init(void);
|
||||
void Delay_us(u32 nus);
|
||||
void Delay_ms(u16 nms);
|
||||
void Delay_sec(u16 sec);
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
@@ -0,0 +1,18 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:generic f403a]
|
||||
platform = at32
|
||||
framework = cmsis
|
||||
board = generic_f403a
|
||||
monitor_speed = 115200
|
||||
upload_protocol = custom
|
||||
upload_port = COM12
|
||||
upload_speed = 921600 ;115200 460800 921600
|
||||
upload_command = ${platformio.packages_dir}/framework-cmsis-at32f40/tools/stm32flash/stm32flash -g 0x8000000 -b $UPLOAD_SPEED -w $SOURCE $UPLOAD_PORT
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File : ADC/ADC1_DMA/at32f4xx_it.c
|
||||
* Version: V1.2.2
|
||||
* Date : 2020-07-01
|
||||
* Brief : Main Interrupt Service Routines.
|
||||
* This file provides template for all exceptions handler and peripherals
|
||||
* interrupt service routine.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "at32f4xx_it.h"
|
||||
|
||||
/** @addtogroup AT32F403A_StdPeriph_Examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ADC_ADC1_DMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief This function handles NMI exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Hard Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Hard Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Memory Manage exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Memory Manage exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Bus Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Bus Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Usage Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Usage Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SVCall exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SVC_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Debug Monitor exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles PendSV_Handler exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void PendSV_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SysTick Handler.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2018 ArteryTek *****END OF FILE****/
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File : ADC/ADC1_DMA/at32f4xx_it.h
|
||||
* Version: V1.2.2
|
||||
* Date : 2020-07-01
|
||||
* Brief : This file contains the headers of the interrupt handlers.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __AT32F4xx_IT_H
|
||||
#define __AT32F4xx_IT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "at32f4xx.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
void NMI_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void MemManage_Handler(void);
|
||||
void BusFault_Handler(void);
|
||||
void UsageFault_Handler(void);
|
||||
void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
#endif /* __AT32F4xx_IT_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2018 ArteryTek *****END OF FILE****/
|
||||
202
.platformio/platforms/at32/examples/cmsis-acd1_dma/src/main.c
Normal file
202
.platformio/platforms/at32/examples/cmsis-acd1_dma/src/main.c
Normal file
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File : ADC/ADC1_DMA/main.c
|
||||
* Version: V1.2.2
|
||||
* Date : 2020-07-01
|
||||
* Brief : Main program body
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "at32f4xx.h"
|
||||
#include "main.h"
|
||||
|
||||
/** @addtogroup AT32F403A_StdPeriph_Examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ADC_ADC1_DMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
ADC_InitType ADC_InitStructure;
|
||||
DMA_InitType DMA_InitStructure;
|
||||
__IO uint16_t ADCConvertedValue=0;
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
void RCC_Configuration(void);
|
||||
void GPIO_Configuration(void);
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
void UART_Print_sendData(uint8_t *buff, int len) {
|
||||
int i = 0;
|
||||
while (len > 0U)
|
||||
{
|
||||
len--;
|
||||
while ( USART_GetFlagStatus(AT32_PRINT_UART, USART_FLAG_TRAC) == RESET );
|
||||
AT32_PRINT_UART->DT = (buff[i++] & (uint16_t)0x01FF);
|
||||
}
|
||||
while ( USART_GetFlagStatus(AT32_PRINT_UART, USART_FLAG_TRAC) == RESET );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize UART1
|
||||
* @param bound: UART BaudRate
|
||||
* @retval None
|
||||
*/
|
||||
void UART_Print_Init(uint32_t bound)
|
||||
{
|
||||
GPIO_InitType GPIO_InitStructure;
|
||||
USART_InitType USART_InitStructure;
|
||||
|
||||
/*Enable the UART Clock*/
|
||||
RCC_APB2PeriphClockCmd(AT32_PRINT_UARTTX_GPIO_RCC | AT32_PRINT_UARTRX_GPIO_RCC, ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_USART1, ENABLE);
|
||||
|
||||
/* Configure the UART1 TX pin */
|
||||
GPIO_StructInit(&GPIO_InitStructure);
|
||||
GPIO_InitStructure.GPIO_Pins = AT32_PRINT_UARTTX_PIN;
|
||||
GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_Init(AT32_PRINT_UARTTX_GPIO, &GPIO_InitStructure);
|
||||
|
||||
/* Configure the UART1 RX pin */
|
||||
GPIO_InitStructure.GPIO_Pins = AT32_PRINT_UARTRX_PIN;//PA10
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
GPIO_Init(AT32_PRINT_UARTRX_GPIO, &GPIO_InitStructure);
|
||||
|
||||
/*Configure UART param*/
|
||||
USART_StructInit(&USART_InitStructure);
|
||||
USART_InitStructure.USART_BaudRate = bound;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
|
||||
|
||||
USART_Init(AT32_PRINT_UART, &USART_InitStructure);
|
||||
USART_INTConfig(AT32_PRINT_UART, USART_INT_RDNE, ENABLE);
|
||||
USART_Cmd(AT32_PRINT_UART, ENABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main program
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
/* System clocks configuration */
|
||||
RCC_Configuration();
|
||||
|
||||
/* GPIO configuration ------------------------------------------------------*/
|
||||
GPIO_Configuration();
|
||||
|
||||
/* UART configuration ------------------------------------------------------*/
|
||||
UART_Print_Init(115200);
|
||||
UART_Print_sendData("ADC Test", 8);
|
||||
|
||||
/* DMA1 channel1 configuration ----------------------------------------------*/
|
||||
DMA_Reset(DMA1_Channel1);
|
||||
DMA_DefaultInitParaConfig(&DMA_InitStructure);
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->RDOR;
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ADCConvertedValue;
|
||||
DMA_InitStructure.DMA_Direction = DMA_DIR_PERIPHERALSRC;
|
||||
DMA_InitStructure.DMA_BufferSize = 1;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PERIPHERALINC_DISABLE;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MEMORYINC_DISABLE;
|
||||
DMA_InitStructure.DMA_PeripheralDataWidth = DMA_PERIPHERALDATAWIDTH_HALFWORD;
|
||||
DMA_InitStructure.DMA_MemoryDataWidth = DMA_MEMORYDATAWIDTH_HALFWORD;
|
||||
DMA_InitStructure.DMA_Mode = DMA_MODE_CIRCULAR;
|
||||
DMA_InitStructure.DMA_Priority = DMA_PRIORITY_HIGH;
|
||||
DMA_InitStructure.DMA_MTOM = DMA_MEMTOMEM_DISABLE;
|
||||
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
|
||||
/* Enable DMA1 channel1 */
|
||||
DMA_ChannelEnable(DMA1_Channel1, ENABLE);
|
||||
|
||||
/* ADC1 configuration ------------------------------------------------------*/
|
||||
ADC_StructInit(&ADC_InitStructure);
|
||||
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
|
||||
ADC_InitStructure.ADC_ScanMode = DISABLE;
|
||||
ADC_InitStructure.ADC_ContinuousMode = ENABLE;
|
||||
ADC_InitStructure.ADC_ExternalTrig = ADC_ExternalTrig_None;
|
||||
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||
ADC_InitStructure.ADC_NumOfChannel = 1;
|
||||
ADC_Init(ADC1, &ADC_InitStructure);
|
||||
|
||||
/* ADC1 regular channels configuration */
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_28_5);
|
||||
|
||||
/* Enable ADC1 DMA */
|
||||
ADC_DMACtrl(ADC1, ENABLE);
|
||||
|
||||
/* Enable ADC1 */
|
||||
ADC_Ctrl(ADC1, ENABLE);
|
||||
|
||||
/* Enable ADC1 reset calibration register */
|
||||
ADC_RstCalibration(ADC1);
|
||||
/* Check the end of ADC1 reset calibration register */
|
||||
while(ADC_GetResetCalibrationStatus(ADC1));
|
||||
|
||||
/* Start ADC1 calibration */
|
||||
ADC_StartCalibration(ADC1);
|
||||
/* Check the end of ADC1 calibration */
|
||||
while(ADC_GetCalibrationStatus(ADC1));
|
||||
|
||||
/* Start ADC1 Software Conversion */
|
||||
ADC_SoftwareStartConvCtrl(ADC1, ENABLE);
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the different system clocks.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void RCC_Configuration(void)
|
||||
{
|
||||
/* ADCCLK = PCLK2/6 */
|
||||
RCC_ADCCLKConfig(RCC_APB2CLK_Div6);
|
||||
|
||||
/* Enable peripheral clocks ------------------------------------------------*/
|
||||
/* Enable DMA1 clocks */
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPERIPH_DMA1, ENABLE);
|
||||
|
||||
/* Enable ADC1 and GPIOC clocks */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_ADC1 | RCC_APB2PERIPH_GPIOC, ENABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the different GPIO ports.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_Configuration(void)
|
||||
{
|
||||
GPIO_InitType GPIO_InitStructure;
|
||||
|
||||
/* Configure PC.04 (ADC Channel14) as analog input -------------------------*/
|
||||
GPIO_StructInit(&GPIO_InitStructure);
|
||||
GPIO_InitStructure.GPIO_Pins = GPIO_Pins_4;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_ANALOG;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2018 ArteryTek *****END OF FILE****/
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MAIN_H
|
||||
#define __MAIN_H
|
||||
|
||||
|
||||
/**************** UART printf ****************/
|
||||
#define AT32_PRINT_UART USART1
|
||||
#define USARTx_IRQn USART1_IRQn
|
||||
#define USARTx_IRQ_Handler USART1_IRQHandler
|
||||
#define AT32_PRINT_UART_RCC RCC_APB2PERIPH_USART1
|
||||
|
||||
/*Tx*/
|
||||
#define AT32_PRINT_UARTTX_PIN GPIO_Pins_9
|
||||
#define AT32_PRINT_UARTTX_GPIO GPIOA
|
||||
#define AT32_PRINT_UARTTX_GPIO_RCC RCC_APB2PERIPH_GPIOA
|
||||
|
||||
/*Rx*/
|
||||
#define AT32_PRINT_UARTRX_PIN GPIO_Pins_10
|
||||
#define AT32_PRINT_UARTRX_GPIO GPIOA
|
||||
#define AT32_PRINT_UARTRX_GPIO_RCC RCC_APB2PERIPH_GPIOA
|
||||
/**************** End UART printf ****************/
|
||||
|
||||
void AT32_Board_Init(void);
|
||||
void AT32_USB_GPIO_init(void);
|
||||
|
||||
#endif /* __MAIN_H */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -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
|
||||
1
.platformio/platforms/at32/examples/cmsis-blink/.gitignore
vendored
Normal file
1
.platformio/platforms/at32/examples/cmsis-blink/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.pio
|
||||
67
.platformio/platforms/at32/examples/cmsis-blink/.travis.yml
Normal file
67
.platformio/platforms/at32/examples/cmsis-blink/.travis.yml
Normal file
@@ -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
|
||||
46
.platformio/platforms/at32/examples/cmsis-blink/.vscode/c_cpp_properties.json
vendored
Normal file
46
.platformio/platforms/at32/examples/cmsis-blink/.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// !!! WARNING !!! AUTO-GENERATED FILE!
|
||||
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
|
||||
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
|
||||
//
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "PlatformIO",
|
||||
"includePath": [
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-blink/include",
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-blink/src",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis-at32f40/Source",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis@2.50501.200527/CMSIS/Include",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis-at32f40/Include",
|
||||
""
|
||||
],
|
||||
"browse": {
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"path": [
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-blink/include",
|
||||
"C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-blink/src",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis-at32f40/Source",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis@2.50501.200527/CMSIS/Include",
|
||||
"C:/Users/Xliloz/.platformio/packages/framework-cmsis-at32f40/Include",
|
||||
""
|
||||
]
|
||||
},
|
||||
"defines": [
|
||||
"PLATFORMIO=50200",
|
||||
"AT32F403ACGT7",
|
||||
""
|
||||
],
|
||||
"cStandard": "c11",
|
||||
"compilerPath": "C:/Users/Xliloz/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe",
|
||||
"compilerArgs": [
|
||||
"-mcpu=cortex-m4",
|
||||
"-mthumb",
|
||||
"-mcpu=cortex-m4",
|
||||
"-mthumb",
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
7
.platformio/platforms/at32/examples/cmsis-blink/.vscode/extensions.json
vendored
Normal file
7
.platformio/platforms/at32/examples/cmsis-blink/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
34
.platformio/platforms/at32/examples/cmsis-blink/.vscode/launch.json
vendored
Normal file
34
.platformio/platforms/at32/examples/cmsis-blink/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
|
||||
//
|
||||
// PIO Unified Debugger
|
||||
//
|
||||
// Documentation: https://docs.platformio.org/page/plus/debugging.html
|
||||
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
|
||||
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug",
|
||||
"executable": "C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-blink/.pio/build/generic f403a/firmware.elf",
|
||||
"projectEnvName": "generic f403a",
|
||||
"toolchainBinDir": "C:/Users/Xliloz/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"preLaunchTask": {
|
||||
"type": "PlatformIO",
|
||||
"task": "Pre-Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug (skip Pre-Debug)",
|
||||
"executable": "C:/Users/Xliloz/.platformio/platforms/at32/examples/cmsis-blink/.pio/build/generic f403a/firmware.elf",
|
||||
"projectEnvName": "generic f403a",
|
||||
"toolchainBinDir": "C:/Users/Xliloz/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
||||
5
.platformio/platforms/at32/examples/cmsis-blink/.vscode/settings.json
vendored
Normal file
5
.platformio/platforms/at32/examples/cmsis-blink/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"at32f4xx.h": "c"
|
||||
}
|
||||
}
|
||||
38
.platformio/platforms/at32/examples/cmsis-blink/README.rst
Normal file
38
.platformio/platforms/at32/examples/cmsis-blink/README.rst
Normal file
@@ -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-ststm32/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platform-at32/examples/cmsis-blink
|
||||
|
||||
# Build project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
> platformio run -e disco_f407vg
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
> platformio run -e disco_f407vg --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
||||
@@ -0,0 +1 @@
|
||||
.pio
|
||||
@@ -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
|
||||
@@ -0,0 +1,94 @@
|
||||
/*DO NOT USE - DON'T WORK*/
|
||||
|
||||
#include "delay.h"
|
||||
#include "stdio.h"
|
||||
|
||||
/*delay macros*/
|
||||
#define STEP_DELAY_MS 500
|
||||
|
||||
/*delay variable*/
|
||||
static __IO float fac_us;
|
||||
static __IO float fac_ms;
|
||||
|
||||
|
||||
/**
|
||||
* @brief initialize Delay function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void Delay_init()
|
||||
{
|
||||
/*Config Systick*/
|
||||
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
|
||||
fac_us=(float)SystemCoreClock/(8 * 1000000);
|
||||
fac_ms=fac_us*1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts a delay time.
|
||||
* @param nus: specifies the delay time length, in microsecond.
|
||||
* @retval None
|
||||
*/
|
||||
void Delay_us(u32 nus)
|
||||
{
|
||||
u32 temp;
|
||||
SysTick->LOAD = (u32)(nus*fac_us);
|
||||
SysTick->VAL = 0x00;
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk ;
|
||||
do
|
||||
{
|
||||
temp = SysTick->CTRL;
|
||||
}while((temp & 0x01) &&! (temp & (1<<16)));
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->VAL = 0X00;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts a delay time.
|
||||
* @param nms: specifies the delay time length, in milliseconds.
|
||||
* @retval None
|
||||
*/
|
||||
void Delay_ms(u16 nms)
|
||||
{
|
||||
u32 temp;
|
||||
while(nms)
|
||||
{
|
||||
if(nms > STEP_DELAY_MS)
|
||||
{
|
||||
SysTick->LOAD = (u32)(STEP_DELAY_MS * fac_ms);
|
||||
nms -= STEP_DELAY_MS;
|
||||
}
|
||||
else
|
||||
{
|
||||
SysTick->LOAD = (u32)(nms * fac_ms);
|
||||
nms = 0;
|
||||
}
|
||||
SysTick->VAL = 0x00;
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
do
|
||||
{
|
||||
temp = SysTick->CTRL;
|
||||
}while( (temp & 0x01) && !(temp & (1<<16)) );
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->VAL = 0X00;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts a delay time.
|
||||
* @param sec: specifies the delay time length, in seconds.
|
||||
* @retval None
|
||||
*/
|
||||
void Delay_sec(u16 sec)
|
||||
{
|
||||
u16 i;
|
||||
for(i=0; i<sec; i++)
|
||||
{
|
||||
Delay_ms(500);
|
||||
Delay_ms(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* File : delay.h
|
||||
*/
|
||||
|
||||
#ifndef __DELAY_H
|
||||
#define __DELAY_H
|
||||
#include <at32f4xx.h>
|
||||
|
||||
/*Delay function*/
|
||||
void Delay_init(void);
|
||||
void Delay_us(u32 nus);
|
||||
void Delay_ms(u16 nms);
|
||||
void Delay_sec(u16 sec);
|
||||
|
||||
#endif
|
||||
46
.platformio/platforms/at32/examples/cmsis-blink/lib/README
Normal file
46
.platformio/platforms/at32/examples/cmsis-blink/lib/README
Normal file
@@ -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
|
||||
@@ -0,0 +1,17 @@
|
||||
; 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:generic f403a]
|
||||
platform = at32
|
||||
framework = cmsis
|
||||
board = generic_f403a
|
||||
upload_protocol = custom
|
||||
upload_port = COM16
|
||||
upload_speed = 460800 ;115200 460800 921600
|
||||
upload_command = ${platformio.packages_dir}/framework-cmsis-at32f40/tools/stm32flash/stm32flash -g 0x8000000 -b $UPLOAD_SPEED -w $SOURCE $UPLOAD_PORT
|
||||
34
.platformio/platforms/at32/examples/cmsis-blink/src/main.c
Normal file
34
.platformio/platforms/at32/examples/cmsis-blink/src/main.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/** Light on/off pin PC13, 100Hz frequency */
|
||||
|
||||
#include "at32f4xx.h"
|
||||
|
||||
#define LEDPORT (GPIOC)
|
||||
#define LED1 (13)
|
||||
#define ENABLE_GPIO_CLOCK (RCC->APB2EN |= RCC_APB2EN_GPIOCEN) //RCC_APB2ENR_IOPCEN)
|
||||
#define _MODER CTRLH
|
||||
#define GPIOMODER (GPIO_CTRLH_MDE13_0)
|
||||
|
||||
|
||||
void ms_delay(int ms)
|
||||
{
|
||||
while (ms-- > 0) {
|
||||
volatile int x=8000;
|
||||
while (x-- > 0)
|
||||
__asm("nop");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Alternates blue and green LEDs quickly
|
||||
int main(void)
|
||||
{
|
||||
ENABLE_GPIO_CLOCK; // enable the clock to GPIO
|
||||
LEDPORT->_MODER |= GPIOMODER; // set pins to be general purpose output
|
||||
|
||||
for (;;) {
|
||||
ms_delay(5);
|
||||
LEDPORT->OPTDT ^= (1<<LED1); // toggle diodes ODR
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MAIN_H
|
||||
#define __MAIN_H
|
||||
|
||||
|
||||
#endif /* __MAIN_H */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
11
.platformio/platforms/at32/examples/cmsis-blink/test/README
Normal file
11
.platformio/platforms/at32/examples/cmsis-blink/test/README
Normal file
@@ -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
|
||||
67
.platformio/platforms/at32/examples/cmsis-blink/travis.yml
Normal file
67
.platformio/platforms/at32/examples/cmsis-blink/travis.yml
Normal file
@@ -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
|
||||
6
.platformio/platforms/at32/gitmodules
Normal file
6
.platformio/platforms/at32/gitmodules
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "builder/frameworks/libopencm3"]
|
||||
path = builder/frameworks/libopencm3
|
||||
url = https://github.com/platformio/builder-framework-libopencm3.git
|
||||
[submodule "builder/frameworks/arduino/mbed-core"]
|
||||
path = builder/frameworks/arduino/mbed-core
|
||||
url = https://github.com/platformio/builder-framework-arduino-core-mbed.git
|
||||
154
.platformio/platforms/at32/ldscripts/AT32F403AxC_FLASH.ld
Normal file
154
.platformio/platforms/at32/ldscripts/AT32F403AxC_FLASH.ld
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : AT32F403AxC_FLASH.ld
|
||||
**
|
||||
** Abstract : Linker script for AT32F403xC Device with
|
||||
** 256KByte FLASH, 96KByte RAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : Artery Tek AT32
|
||||
**
|
||||
** Environment : Arm gcc toolchain
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20017FFF; /* end of RAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x400; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
/* Constant data goes into FLASH */
|
||||
.rodata :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM AT> FLASH
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
154
.platformio/platforms/at32/ldscripts/AT32F403AxE_FLASH.ld
Normal file
154
.platformio/platforms/at32/ldscripts/AT32F403AxE_FLASH.ld
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : AT32F403AxE_FLASH.ld
|
||||
**
|
||||
** Abstract : Linker script for AT32F403AxE Device with
|
||||
** 512KByte FLASH, 96KByte RAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : Artery Tek AT32
|
||||
**
|
||||
** Environment : Arm gcc toolchain
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20017FFF; /* end of RAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x400; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
/* Constant data goes into FLASH */
|
||||
.rodata :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM AT> FLASH
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
154
.platformio/platforms/at32/ldscripts/AT32F403AxG_FLASH.ld
Normal file
154
.platformio/platforms/at32/ldscripts/AT32F403AxG_FLASH.ld
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : AT32F403AxG_FLASH.ld
|
||||
**
|
||||
** Abstract : Linker script for AT32F403xG Device with
|
||||
** 1000KByte FLASH, 96KByte RAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : Artery Tek AT32
|
||||
**
|
||||
** Environment : Arm gcc toolchain
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20017FFF; /* end of RAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x400; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1000K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
/* Constant data goes into FLASH */
|
||||
.rodata :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM AT> FLASH
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
1
.platformio/platforms/at32/piopm_
Normal file
1
.platformio/platforms/at32/piopm_
Normal file
@@ -0,0 +1 @@
|
||||
{"type": "platform", "name": "at32", "version": "1.0.0", "spec": {"owner": "platformio", "id": 8020, "name": "at32", "requirements": null, "url": null}}
|
||||
95
.platformio/platforms/at32/platform.json
Normal file
95
.platformio/platforms/at32/platform.json
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"name": "at32",
|
||||
"title": "AT32",
|
||||
"description": "The AT32 family of 32-bit Flash MCUs based on the ARM Cortex-M processor is designed to offer new degrees of freedom to MCU users. It offers a 32-bit product range that combines very high performance, real-time capabilities, digital signal processing, and low-power, low-voltage operation, while maintaining full integration and ease of development.",
|
||||
"homepage": "https://www.arterychip.com/en/index.jsp",
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
"dev-platform",
|
||||
"arm",
|
||||
"cortex-m",
|
||||
"artery",
|
||||
"at32"
|
||||
],
|
||||
"engines": {
|
||||
"platformio": "^5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/platformio/platform-at32.git"
|
||||
},
|
||||
"version": "1.0.0",
|
||||
"frameworks": {
|
||||
"cmsis": {
|
||||
"package": "framework-cmsis",
|
||||
"script": "builder/frameworks/cmsis.py",
|
||||
"description": "The ARM Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for the Cortex-M processor series and specifies debugger interfaces. The CMSIS enables consistent and simple software interfaces to the processor for interface peripherals, real-time operating systems, and middleware. It simplifies software re-use, reducing the learning curve for new microcontroller developers and cutting the time-to-market for devices",
|
||||
"homepage": "https://developer.arm.com/tools-and-software/embedded/cmsis",
|
||||
"title": "CMSIS"
|
||||
}
|
||||
},
|
||||
"packages": {
|
||||
"toolchain-gccarmnoneeabi": {
|
||||
"type": "toolchain",
|
||||
"owner": "platformio",
|
||||
"version": ">=1.60301.0,<1.80000.0",
|
||||
"optionalVersions": [
|
||||
"~1.60301.0",
|
||||
"~1.80201.0",
|
||||
"~1.90201.0"
|
||||
]
|
||||
},
|
||||
"framework-cmsis": {
|
||||
"type": "framework",
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "~2.50501.0",
|
||||
"optionalVersions": [
|
||||
"~2.50700.0"
|
||||
]
|
||||
},
|
||||
"framework-cmsis-at32f40": {
|
||||
"type": "framework",
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "~1.0.0"
|
||||
},
|
||||
"tool-openocd": {
|
||||
"type": "uploader",
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "~2.1100.0"
|
||||
},
|
||||
"tool-jlink": {
|
||||
"type": "uploader",
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "^1.63208.0"
|
||||
},
|
||||
"tool-cmake": {
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "~3.21.0"
|
||||
},
|
||||
"tool-dtc": {
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "~1.4.7"
|
||||
},
|
||||
"tool-ninja": {
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "^1.7.0"
|
||||
},
|
||||
"tool-gperf": {
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "^3.0.0"
|
||||
},
|
||||
"tool-ldscripts-at32": {
|
||||
"optional": true,
|
||||
"owner": "platformio",
|
||||
"version": "~0.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
155
.platformio/platforms/at32/platform.py
Normal file
155
.platformio/platforms/at32/platform.py
Normal file
@@ -0,0 +1,155 @@
|
||||
# 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 copy
|
||||
import json
|
||||
import os
|
||||
|
||||
from platform import system
|
||||
|
||||
from platformio.managers.platform import PlatformBase
|
||||
from platformio.util import get_systype
|
||||
|
||||
class At32Platform(PlatformBase):
|
||||
|
||||
def configure_default_packages(self, variables, targets):
|
||||
board = variables.get("board")
|
||||
board_config = self.board_config(board)
|
||||
build_core = variables.get(
|
||||
"board_build.core", board_config.get("build.core", "arduino"))
|
||||
build_mcu = variables.get("board_build.mcu", board_config.get("build.mcu", ""))
|
||||
|
||||
frameworks = variables.get("pioframework", [])
|
||||
|
||||
if "cmsis" in frameworks:
|
||||
assert build_mcu, ("Missing MCU field for %s" % board)
|
||||
device_package = "framework-cmsis-" + build_mcu[0:7]
|
||||
if device_package in self.packages:
|
||||
self.packages[device_package]["optional"] = False
|
||||
|
||||
if any(f in frameworks for f in ("cmsis")):
|
||||
self.packages["tool-ldscripts-at32"]["optional"] = False
|
||||
|
||||
default_protocol = board_config.get("upload.protocol") or ""
|
||||
if variables.get("upload_protocol", default_protocol) == "dfu":
|
||||
self.packages["tool-dfuutil"]["optional"] = False
|
||||
|
||||
# configure J-LINK tool
|
||||
jlink_conds = [
|
||||
"jlink" in variables.get(option, "")
|
||||
for option in ("upload_protocol", "debug_tool")
|
||||
]
|
||||
if 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"] = {}
|
||||
|
||||
# BlackMagic, J-Link, ST-Link
|
||||
for link in ("blackmagic", "jlink", "stlink", "cmsis-dap"):
|
||||
if link not in upload_protocols or link in debug["tools"]:
|
||||
continue
|
||||
if link == "blackmagic":
|
||||
debug["tools"]["blackmagic"] = {
|
||||
"hwids": [["0x1d50", "0x6018"]],
|
||||
"require_debug_port": True
|
||||
}
|
||||
elif link == "jlink":
|
||||
assert debug.get("jlink_device"), (
|
||||
"Missed J-Link Device ID for %s" % board.id)
|
||||
debug["tools"][link] = {
|
||||
"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")
|
||||
}
|
||||
}
|
||||
else:
|
||||
server_args = ["-s", "$PACKAGE_DIR/scripts"]
|
||||
if debug.get("openocd_board"):
|
||||
server_args.extend([
|
||||
"-f", "board/%s.cfg" % debug.get("openocd_board")
|
||||
])
|
||||
else:
|
||||
assert debug.get("openocd_target"), (
|
||||
"Missed target configuration for %s" % board.id)
|
||||
server_args.extend([
|
||||
"-f", "interface/%s.cfg" % link,
|
||||
"-c", "transport select %s" % (
|
||||
"hla_swd" if link == "stlink" else "swd"),
|
||||
"-f", "target/%s.cfg" % debug.get("openocd_target")
|
||||
])
|
||||
server_args.extend(debug.get("openocd_extra_args", []))
|
||||
|
||||
debug["tools"][link] = {
|
||||
"server": {
|
||||
"package": "tool-openocd",
|
||||
"executable": "bin/openocd",
|
||||
"arguments": server_args
|
||||
}
|
||||
}
|
||||
debug["tools"][link]["onboard"] = link in debug.get("onboard_tools", [])
|
||||
debug["tools"][link]["default"] = link in debug.get("default_tools", [])
|
||||
|
||||
board.manifest["debug"] = debug
|
||||
return board
|
||||
|
||||
def configure_debug_options(self, initial_debug_options, ide_data):
|
||||
debug_options = copy.deepcopy(initial_debug_options)
|
||||
adapter_speed = initial_debug_options.get("speed")
|
||||
if adapter_speed:
|
||||
server_options = debug_options.get("server") or {}
|
||||
server_executable = server_options.get("executable", "").lower()
|
||||
if "openocd" in server_executable:
|
||||
debug_options["server"]["arguments"].extend(
|
||||
["-c", "adapter speed %s" % adapter_speed]
|
||||
)
|
||||
elif "jlink" in server_executable:
|
||||
debug_options["server"]["arguments"].extend(
|
||||
["-speed", adapter_speed]
|
||||
)
|
||||
|
||||
return debug_options
|
||||
Reference in New Issue
Block a user