From 66b5ff51f68ade840f1dc4b119bc43ab588fa480 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 15 Dec 2018 01:52:10 +0200 Subject: [PATCH 1/8] Update CI and manifest --- .travis.yml | 22 +++++++ LICENSE | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 37 ++++++++++- appveyor.yml | 22 +++++++ platform.json | 33 ++++++++++ 5 files changed, 286 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 appveyor.yml create mode 100644 platform.json diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ae0354d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: python +python: + - "2.7" + +env: + - PLATFORMIO_PROJECT_DIR=examples/@TODO + +install: + - pip install -U https://github.com/platformio/platformio/archive/develop.zip + - platformio platform install file://. + +script: + - platformio run -d $PLATFORMIO_PROJECT_DIR + +notifications: + email: false + + slack: + rooms: + secure: "JirBq/um4E+UNrkheapLD7IxveySs6AYycJsCnhBdwW3jeXP7ZhHLQr5oOjZWHW/bjQ3ncGs6CrTClbBuea0zUAUtlg7mzrO3y0uomwycgy4VSiPi7ps7X7YBKuuX4Xo/NTEa2SML759hLE0rESIX37UnRAnw63OditUE7qDfJy8Lx3nK6sZUBrQ12J+PzRwlDblaz78ZbGuHMWemVChcm5koCwxNIMDvvwcZH+lyOfOm+OOHKyeS4wk6B5lEjJ/kUIkKp6YgtBtjhOkQDeidjfUCU1BcTTkI3JB+LwjQgeaacpjvIV2M8iwQJOaMiB+YlyPdnrWw18ubyLCnuzfgRu8vDulhpfuZkWz/v++1ReBAN0ju8lLnu1MPaA6LNZ+bJuC6l+nBbu1CQW/lsIjLwfh2kgNk0LkjGCRfhwsOpU/c0rA61+4OjrQbe4jscPmqU9Yku3whnJwdwEskTlD25Q1IUYq1UjE1z6LpytZ18wFcPPySTBUbWW3lmlbCbzj4gQfpTGx/rvk2zbsI52jP8vBR4VEpsJqGO2n3mlnFLrQCxslpo9F+EH0VoIVrwFsfZrH41Dx2X36i5/cI2JXSrEqeBfILvtIHuAfwxq6+g/ULZCakSqzu+eP88KU67S0ifGVW5k0lNOSsuskvbVBcsuG+q5O1BPG/qDAyWSAwwg=" + on_failure: always + on_success: change diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2f79a3b --- /dev/null +++ b/LICENSE @@ -0,0 +1,174 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. diff --git a/README.md b/README.md index 079ee53..c39f625 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ -# platform-ststm8 -ST STM8: development platform for PlatformIO +# ST STM8: development platform for [PlatformIO](http://platformio.org) +[![Build Status](https://travis-ci.org/platformio/platform-ststm8.svg?branch=develop)](https://travis-ci.org/platformio/platform-ststm8) +[![Build status](https://ci.appveyor.com/api/projects/status/ej9yhi2d9tbd2y0t/branch/develop?svg=true)](https://ci.appveyor.com/project/ivankravets/platform-ststm8/branch/develop) + +The STM8 is an 8-bit microcontroller family by STMicroelectronics an extended variant of the ST7 microcontroller architecture. STM8 microcontrollers are particularly low cost for a full-featured 8-bit microcontroller. + +* [Home](http://platformio.org/platforms/ststm8) (home page in PlatformIO Platform Registry) +* [Documentation](http://docs.platformio.org/page/platforms/ststm8.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 = ststm8 +board = ... +... +``` + +## Development version + +```ini +[env:development] +platform = https://github.com/platformio/platform-ststm8.git +board = ... +... +``` + +# Configuration + +Please navigate to [documentation](http://docs.platformio.org/page/platforms/ststm8.html). diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..dfffcab --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,22 @@ +build: off +environment: + + matrix: + - PLATFORMIO_PROJECT_DIR: "@TODO" + +install: + - cmd: git submodule update --init --recursive + - cmd: SET PATH=%PATH%;C:\Python27\Scripts + - cmd: pip install -U https://github.com/platformio/platformio/archive/develop.zip + - cmd: platformio platform install file://. + +test_script: + - cmd: platformio run -d %PLATFORMIO_PROJECT_DIR% + +notifications: + - provider: Slack + incoming_webhook: + secure: E9H0SU0Ju7WLDvgxsV8cs3J62T3nTTX7QkEjsczN0Sto/c9hWkVfhc5gGWUkxhlD975cokHByKGJIdwYwCewqOI+7BrcT8U+nlga4Uau7J8= + on_build_success: false + on_build_failure: true + on_build_status_changed: true diff --git a/platform.json b/platform.json new file mode 100644 index 0000000..5fb99d6 --- /dev/null +++ b/platform.json @@ -0,0 +1,33 @@ +{ + "name": "ststm8", + "title": "ST STM8", + "description": "The STM8 is an 8-bit microcontroller family by STMicroelectronics an extended variant of the ST7 microcontroller architecture. STM8 microcontrollers are particularly low cost for a full-featured 8-bit microcontroller.", + "url": "https://www.st.com/en/microcontrollers/stm8-8-bit-mcus.html", + "homepage": "http://platformio.org/platforms/ststm8", + "license": "Apache-2.0", + "engines": { + "platformio": "^3.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/platformio/platform-ststm8.git" + }, + "version": "0.0.0", + "packageRepositories": [ + "https://dl.bintray.com/platformio/dl-packages/manifest.json", + "http://dl.platformio.org/packages/manifest.json" + ], + "frameworks": { + "arduino": { + "package": "framework-arduinoststm8", + "script": "builder/frameworks/arduino.py" + } + }, + "packages": { + "framework-arduinoststm8": { + "type": "framework", + "optional": true, + "version": "*" + } + } +} From 2bd9c1aa90a967e8df7ff0ef4a9313f5542f6c93 Mon Sep 17 00:00:00 2001 From: valeros Date: Thu, 20 Dec 2018 00:00:32 +0200 Subject: [PATCH 2/8] Add initial support for ST STM8 platform --- .travis.yml | 7 +- appveyor.yml | 7 +- boards/mb208.json | 26 + boards/s8uno.json | 26 + boards/stm8sblack.json | 26 + boards/stm8sblue.json | 25 + boards/stm8sdisco.json | 46 ++ builder/frameworks/arduino.py | 84 +++ builder/frameworks/spl.py | 90 +++ builder/main.py | 174 ++++++ examples/arduino-fade-all-pins/.gitignore | 2 + examples/arduino-fade-all-pins/.travis.yml | 67 +++ examples/arduino-fade-all-pins/README.rst | 38 ++ examples/arduino-fade-all-pins/include/README | 39 ++ examples/arduino-fade-all-pins/lib/README | 46 ++ examples/arduino-fade-all-pins/platformio.ini | 33 ++ .../arduino-fade-all-pins/src/fade-all-pins.c | 37 ++ examples/arduino-fade-all-pins/test/README | 11 + examples/arduino-internal-lib/.gitignore | 2 + examples/arduino-internal-lib/.travis.yml | 67 +++ examples/arduino-internal-lib/README.rst | 38 ++ examples/arduino-internal-lib/include/README | 39 ++ examples/arduino-internal-lib/lib/README | 46 ++ examples/arduino-internal-lib/platformio.ini | 33 ++ examples/arduino-internal-lib/src/oled-mini.c | 89 +++ examples/arduino-internal-lib/test/README | 11 + examples/arduino-ping-hc04/.gitignore | 2 + examples/arduino-ping-hc04/.travis.yml | 67 +++ examples/arduino-ping-hc04/README.rst | 38 ++ examples/arduino-ping-hc04/include/README | 39 ++ examples/arduino-ping-hc04/lib/README | 46 ++ examples/arduino-ping-hc04/platformio.ini | 23 + examples/arduino-ping-hc04/src/ping-hc04.c | 97 ++++ examples/arduino-ping-hc04/test/README | 11 + examples/spl-blink/.gitignore | 2 + examples/spl-blink/.travis.yml | 67 +++ examples/spl-blink/README.rst | 38 ++ examples/spl-blink/include/README | 39 ++ examples/spl-blink/lib/README | 46 ++ examples/spl-blink/platformio.ini | 33 ++ examples/spl-blink/src/main.c | 112 ++++ examples/spl-blink/src/readme.txt | 79 +++ examples/spl-blink/src/stm8s_conf.h | 118 ++++ examples/spl-blink/src/stm8s_it.c | 482 ++++++++++++++++ examples/spl-blink/src/stm8s_it.h | 201 +++++++ examples/spl-blink/test/README | 11 + examples/spl-flash/.gitignore | 2 + examples/spl-flash/.travis.yml | 67 +++ examples/spl-flash/README.rst | 38 ++ examples/spl-flash/include/README | 39 ++ examples/spl-flash/lib/README | 46 ++ examples/spl-flash/platformio.ini | 24 + examples/spl-flash/src/main.c | 143 +++++ examples/spl-flash/src/readme.txt | 81 +++ examples/spl-flash/src/stm8s_conf.h | 118 ++++ examples/spl-flash/src/stm8s_it.c | 520 +++++++++++++++++ examples/spl-flash/src/stm8s_it.h | 201 +++++++ examples/spl-flash/test/README | 11 + examples/spl-uart/.gitignore | 2 + examples/spl-uart/.travis.yml | 67 +++ examples/spl-uart/README.rst | 38 ++ examples/spl-uart/include/README | 39 ++ examples/spl-uart/lib/README | 46 ++ examples/spl-uart/platformio.ini | 13 + examples/spl-uart/src/main.c | 347 +++++++++++ examples/spl-uart/src/main.h | 63 ++ examples/spl-uart/src/readme.txt | 94 +++ examples/spl-uart/src/stm8s_conf.h | 118 ++++ examples/spl-uart/src/stm8s_it.c | 546 ++++++++++++++++++ examples/spl-uart/src/stm8s_it.h | 201 +++++++ examples/spl-uart/test/README | 11 + platform.json | 29 +- 72 files changed, 5561 insertions(+), 3 deletions(-) create mode 100644 boards/mb208.json create mode 100644 boards/s8uno.json create mode 100644 boards/stm8sblack.json create mode 100644 boards/stm8sblue.json create mode 100644 boards/stm8sdisco.json create mode 100644 builder/frameworks/arduino.py create mode 100644 builder/frameworks/spl.py create mode 100644 builder/main.py create mode 100644 examples/arduino-fade-all-pins/.gitignore create mode 100644 examples/arduino-fade-all-pins/.travis.yml create mode 100644 examples/arduino-fade-all-pins/README.rst create mode 100644 examples/arduino-fade-all-pins/include/README create mode 100644 examples/arduino-fade-all-pins/lib/README create mode 100644 examples/arduino-fade-all-pins/platformio.ini create mode 100644 examples/arduino-fade-all-pins/src/fade-all-pins.c create mode 100644 examples/arduino-fade-all-pins/test/README create mode 100644 examples/arduino-internal-lib/.gitignore create mode 100644 examples/arduino-internal-lib/.travis.yml create mode 100644 examples/arduino-internal-lib/README.rst create mode 100644 examples/arduino-internal-lib/include/README create mode 100644 examples/arduino-internal-lib/lib/README create mode 100644 examples/arduino-internal-lib/platformio.ini create mode 100644 examples/arduino-internal-lib/src/oled-mini.c create mode 100644 examples/arduino-internal-lib/test/README create mode 100644 examples/arduino-ping-hc04/.gitignore create mode 100644 examples/arduino-ping-hc04/.travis.yml create mode 100644 examples/arduino-ping-hc04/README.rst create mode 100644 examples/arduino-ping-hc04/include/README create mode 100644 examples/arduino-ping-hc04/lib/README create mode 100644 examples/arduino-ping-hc04/platformio.ini create mode 100644 examples/arduino-ping-hc04/src/ping-hc04.c create mode 100644 examples/arduino-ping-hc04/test/README create mode 100644 examples/spl-blink/.gitignore create mode 100644 examples/spl-blink/.travis.yml create mode 100644 examples/spl-blink/README.rst create mode 100644 examples/spl-blink/include/README create mode 100644 examples/spl-blink/lib/README create mode 100644 examples/spl-blink/platformio.ini create mode 100644 examples/spl-blink/src/main.c create mode 100644 examples/spl-blink/src/readme.txt create mode 100644 examples/spl-blink/src/stm8s_conf.h create mode 100644 examples/spl-blink/src/stm8s_it.c create mode 100644 examples/spl-blink/src/stm8s_it.h create mode 100644 examples/spl-blink/test/README create mode 100644 examples/spl-flash/.gitignore create mode 100644 examples/spl-flash/.travis.yml create mode 100644 examples/spl-flash/README.rst create mode 100644 examples/spl-flash/include/README create mode 100644 examples/spl-flash/lib/README create mode 100644 examples/spl-flash/platformio.ini create mode 100644 examples/spl-flash/src/main.c create mode 100644 examples/spl-flash/src/readme.txt create mode 100644 examples/spl-flash/src/stm8s_conf.h create mode 100644 examples/spl-flash/src/stm8s_it.c create mode 100644 examples/spl-flash/src/stm8s_it.h create mode 100644 examples/spl-flash/test/README create mode 100644 examples/spl-uart/.gitignore create mode 100644 examples/spl-uart/.travis.yml create mode 100644 examples/spl-uart/README.rst create mode 100644 examples/spl-uart/include/README create mode 100644 examples/spl-uart/lib/README create mode 100644 examples/spl-uart/platformio.ini create mode 100644 examples/spl-uart/src/main.c create mode 100644 examples/spl-uart/src/main.h create mode 100644 examples/spl-uart/src/readme.txt create mode 100644 examples/spl-uart/src/stm8s_conf.h create mode 100644 examples/spl-uart/src/stm8s_it.c create mode 100644 examples/spl-uart/src/stm8s_it.h create mode 100644 examples/spl-uart/test/README diff --git a/.travis.yml b/.travis.yml index ae0354d..8e88666 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,12 @@ python: - "2.7" env: - - PLATFORMIO_PROJECT_DIR=examples/@TODO + - PLATFORMIO_PROJECT_DIR=examples/arduino-fade-all-pins + - PLATFORMIO_PROJECT_DIR=examples/arduino-internal-lib + - PLATFORMIO_PROJECT_DIR=examples/arduino-ping-hc04 + - PLATFORMIO_PROJECT_DIR=examples/spl-blink + - PLATFORMIO_PROJECT_DIR=examples/spl-flash + - PLATFORMIO_PROJECT_DIR=examples/spl-uart install: - pip install -U https://github.com/platformio/platformio/archive/develop.zip diff --git a/appveyor.yml b/appveyor.yml index dfffcab..efaebc3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,12 @@ build: off environment: matrix: - - PLATFORMIO_PROJECT_DIR: "@TODO" + - PLATFORMIO_PROJECT_DIR: "examples/arduino-fade-all-pins" + - PLATFORMIO_PROJECT_DIR: "examples/arduino-internal-lib" + - PLATFORMIO_PROJECT_DIR: "examples/arduino-ping-hc04" + - PLATFORMIO_PROJECT_DIR: "examples/spl-blink4" + - PLATFORMIO_PROJECT_DIR: "examples/spl-flash" + - PLATFORMIO_PROJECT_DIR: "examples/spl-uart" install: - cmd: git submodule update --init --recursive diff --git a/boards/mb208.json b/boards/mb208.json new file mode 100644 index 0000000..e4ed85f --- /dev/null +++ b/boards/mb208.json @@ -0,0 +1,26 @@ +{ + "build": { + "core": "sduino", + "extra_flags": "-DSTM8S_MB -DSTM8S208", + "f_cpu": "16000000L", + "cpu": "stm8", + "mcu": "stm8s208mbt6", + "variant": "mb208" + }, + "frameworks": [ + "arduino", + "spl" + ], + "upload": { + "maximum_ram_size": 6144, + "maximum_size": 131072, + "protocol": "serial", + "protocols": [ + "stlinkv2", + "serial" + ] + }, + "name": "sduino MB (STM8S208MBT6B)", + "url": "https://github.com/roybaer/sduino_mb", + "vendor": "sduino" +} diff --git a/boards/s8uno.json b/boards/s8uno.json new file mode 100644 index 0000000..6047fde --- /dev/null +++ b/boards/s8uno.json @@ -0,0 +1,26 @@ +{ + "build": { + "core": "sduino", + "extra_flags": "-DSTM8S_UNO -DSTM8S105", + "f_cpu": "16000000L", + "cpu": "stm8", + "mcu": "stm8s105k6t6", + "variant": "s8uno" + }, + "frameworks": [ + "arduino", + "spl" + ], + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32768, + "protocol": "serial", + "protocols": [ + "stlinkv2", + "serial" + ] + }, + "name": "sduino UNO (STM8S105K6)", + "url": "https://github.com/roybaer/sduino_uno", + "vendor": "sduino" +} diff --git a/boards/stm8sblack.json b/boards/stm8sblack.json new file mode 100644 index 0000000..7b11e1c --- /dev/null +++ b/boards/stm8sblack.json @@ -0,0 +1,26 @@ +{ + "build": { + "core": "sduino", + "extra_flags": "-DSTM8S_BLACK -DSTM8S105", + "f_cpu": "16000000L", + "cpu": "stm8", + "mcu": "stm8s105k4t6", + "variant": "stm8sblack" + }, + "frameworks": [ + "arduino", + "spl" + ], + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 16384, + "protocol": "serial", + "protocols": [ + "stlinkv2", + "serial" + ] + }, + "name": "ST STM8S105K4T6 Breakout Board", + "url": "https://github.com/TG9541/stm8ef/wiki/Breakout-Boards#stm8s105k4t6-breakout-board", + "vendor": "ST" +} diff --git a/boards/stm8sblue.json b/boards/stm8sblue.json new file mode 100644 index 0000000..6413031 --- /dev/null +++ b/boards/stm8sblue.json @@ -0,0 +1,25 @@ +{ + "build": { + "core": "sduino", + "extra_flags": "-DSTM8S_BLUE -DSTM8S103", + "f_cpu": "16000000L", + "cpu": "stm8", + "mcu": "stm8s103f3p6", + "variant": "standard" + }, + "frameworks": [ + "arduino", + "spl" + ], + "upload": { + "maximum_ram_size": 1024, + "maximum_size": 8192, + "protocol": "serial", + "protocols": [ + "serial" + ] + }, + "name": "ST STM8S103F3 Breakout Board", + "url": "https://tenbaht.github.io/sduino/hardware/stm8blue/", + "vendor": "ST" +} diff --git a/boards/stm8sdisco.json b/boards/stm8sdisco.json new file mode 100644 index 0000000..f195ad7 --- /dev/null +++ b/boards/stm8sdisco.json @@ -0,0 +1,46 @@ +{ + "build": { + "core": "sduino", + "extra_flags": "-DSTM8S_DISCOVERY -DSTM8S105", + "f_cpu": "16000000L", + "cpu": "stm8", + "mcu": "stm8s105c6t6", + "variant": "stm8sdisco" + }, + "debug": { + "openocd_target": "stm8s", + "tools": { + "stlink": { + "default": true, + "server": { + "arguments": [ + "-f", + "scripts/interface/stlink.cfg", + "-f", + "scripts/target/stm8s.cfg" + ], + "executable": "bin/openocd", + "package": "tool-openocd" + }, + "onboard": true + } + } + }, + "frameworks": [ + "arduino", + "spl" + ], + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 32768, + "protocol": "stlink", + "protocols": [ + "serial", + "stlink", + "stlinkv2" + ] + }, + "name": "ST STM8S-DISCOVERY", + "url": "https://www.st.com/en/evaluation-tools/stm8s-discovery.html", + "vendor": "ST" +} diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py new file mode 100644 index 0000000..1c503ae --- /dev/null +++ b/builder/frameworks/arduino.py @@ -0,0 +1,84 @@ +# Copyright 2018-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Arduino + +Arduino Wiring-based Framework allows writing cross-platform software to +control devices attached to a wide range of Arduino boards to create all +kinds of creative coding, interactive objects, spaces or physical experiences. + +http://arduino.cc/en/Reference/HomePage +""" + +from os.path import isdir, join + +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() +platform = env.PioPlatform() +board_config = env.BoardConfig() + +FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm8") +assert isdir(FRAMEWORK_DIR) + +env.Append( + CPPDEFINES=[ + "ARDUINO_ARCH_STM8", + ("ARDUINO", 10802), + ("double", "float"), + "USE_STDINT", + "__PROG_TYPES_COMPAT__" + ], + + CPPPATH=[ + join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core")), + join(FRAMEWORK_DIR, "STM8S_StdPeriph_Driver", "inc") + ], + + LIBPATH=[ + join(FRAMEWORK_DIR, "STM8S_StdPeriph_Driver", "lib") + ], + + LIBS=[board_config.get("build.mcu")[0:8].upper()], + + LIBSOURCE_DIRS=[ + join(FRAMEWORK_DIR, "libraries") + ] +) + +# +# Target: Build Core Library +# + +libs = [] + +if "build.variant" in env.BoardConfig(): + env.Append( + CPPPATH=[ + join(FRAMEWORK_DIR, "variants", + env.BoardConfig().get("build.variant")) + ] + ) + libs.append(env.BuildLibrary( + join("$BUILD_DIR", "FrameworkArduinoVariant"), + join(FRAMEWORK_DIR, "variants", env.BoardConfig().get("build.variant")) + )) + +libs.append(env.BuildLibrary( + join("$BUILD_DIR", "FrameworkArduino"), + join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core")) +)) + +env.Prepend(LIBS=libs) diff --git a/builder/frameworks/spl.py b/builder/frameworks/spl.py new file mode 100644 index 0000000..6195c2d --- /dev/null +++ b/builder/frameworks/spl.py @@ -0,0 +1,90 @@ +# Copyright 2018-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +SPL + +Library that enables developers to easily exploit all the functions of the STM8 +microcontrollers to address a wide range of applications. + +https://www.st.com/en/embedded-software/stsw-stm8069.html +""" + +import sys +from os.path import basename, isdir, join + +from SCons.Script import DefaultEnvironment + +from platformio.util import exec_command + +env = DefaultEnvironment() +platform = env.PioPlatform() +board_config = env.BoardConfig() + +FRAMEWORK_DIR = platform.get_package_dir("framework-ststm8spl") +assert isdir(FRAMEWORK_DIR) + + +def get_core_files(): + command = [ + env.subst("$CC"), "-m%s" % board_config.get("build.cpu"), + "-D%s" % board_config.get("build.mcu")[0:8].upper(), + "-I.", "-I", "%s" % env.subst("$PROJECTSRC_DIR"), + "-Wp-MM", "-E", "stm8s.h" + ] + + result = exec_command( + command, + cwd=join(FRAMEWORK_DIR, "Libraries", "STM8S_StdPeriph_Driver", "inc") + ) + + if result['returncode'] != 0: + sys.stderr.write( + "Error: Could not parse library files for the target.\n") + sys.stderr.write(result['err']) + env.Exit(1) + + src_files = [] + includes = result['out'] + for inc in includes.split(" "): + if "_" not in inc or ".h" not in inc or "conf" in inc: + continue + src_files.append(basename(inc).replace(".h", ".c").strip()) + + return src_files + +env.Append( + CFLAGS=["--opt-code-size"], + + CPPDEFINES=[ + "USE_STDPERIPH_DRIVER", + "USE_STDINT" + ], + + CPPPATH=[ + join(FRAMEWORK_DIR, "Libraries", "STM8S_StdPeriph_Driver", "inc"), + "$PROJECTSRC_DIR", + ] +) + + +# +# Target: Build Core Library +# + +env.BuildSources( + join("$BUILD_DIR", "SPL"), + join(FRAMEWORK_DIR, "Libraries", "STM8S_StdPeriph_Driver", "src"), + src_filter=["-<*>"] + [" +<%s>" % f for f in get_core_files()] +) diff --git a/builder/main.py b/builder/main.py new file mode 100644 index 0000000..926ed54 --- /dev/null +++ b/builder/main.py @@ -0,0 +1,174 @@ +# Copyright 2018-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +from os.path import join +from platform import system + +from SCons.Script import (AlwaysBuild, COMMAND_LINE_TARGETS, Default, + DefaultEnvironment) + + +env = DefaultEnvironment() +board_config = env.BoardConfig() + +env.Replace( + AR="sdar", + AS="sdasstm8", + CC="sdcc", + GDB="stm8-gdb", + LD="sdldstm8", + RANLIB="sdranlib", + OBJCOPY="sdobjcopy", + SIZETOOL="stm8-size", + OBJSUFFIX=".rel", + LIBSUFFIX=".lib", + + ARFLAGS=["rcs"], + + ASFLAGS=["-x", "assembler-with-cpp", "-flto"], + + CFLAGS=[ + "-m%s" % board_config.get("build.cpu") + ], + + CPPDEFINES=[ + "F_CPU=$BOARD_F_CPU" + ], + + LINKFLAGS=[ + "-m%s" % board_config.get("build.cpu"), + "--nostdlib", + "--code-size", board_config.get("upload.maximum_size"), + "--iram-size", board_config.get("upload.maximum_ram_size"), + "--out-fmt-elf" + ], + + LIBPATH=[ + join(env.PioPlatform().get_package_dir("toolchain-sdcc"), + "%s" % "lib" if system() == "Windows" else join("share", "sdcc", "lib"), + board_config.get("build.cpu")) + ], + + LIBS=["stm8"], + + SIZEPROGREGEXP=r"^(?:HOME|GSINIT|GSFINAL|CODE|INITIALIZER)\s+([0-9]+).*", + SIZEDATAREGEXP=r"^(?:DATA|INITIALIZED)\s+([0-9]+).*", + SIZEEEPROMREGEXP=r"^(?:EEPROM)\s+([0-9]+).*", + SIZECHECKCMD="$SIZETOOL -A $SOURCES", + SIZEPRINTCMD='$SIZETOOL -d $SOURCES', + + PROGNAME="firmware", + PROGSUFFIX=".elf" +) + + +def _ldflags_for_hex(env, ldflags): + ldflags = ["--out-fmt-ihx" if f == "--out-fmt-elf" else f for f in ldflags] + return ldflags + +env.Append( + ASFLAGS=env.get("CFLAGS", [])[:], + __ldflags_for_hex=_ldflags_for_hex +) + +# Allow user to override via pre:script +if env.get("PROGNAME", "program") == "program": + env.Replace(PROGNAME="firmware") + +# +# Target: Build executable and linkable firmware +# + +target_elf = None +if "nobuild" in COMMAND_LINE_TARGETS: + target_firm = join("$BUILD_DIR", "${PROGNAME}.ihx") +else: + target_elf = env.BuildProgram() + target_firm = env.Command( + join("$BUILD_DIR", "${PROGNAME}.ihx"), + env['PIOBUILDFILES'], + env['LINKCOM'].replace("$LINKFLAGS", + "${__ldflags_for_hex(__env__, LINKFLAGS)}") + ) + env.Depends(target_firm, target_elf) + +AlwaysBuild(env.Alias("nobuild", target_firm)) +target_buildprog = env.Alias("buildprog", target_firm, target_firm) + +# +# Target: Print binary size +# + +target_size = env.Alias( + "size", target_elf, + env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE")) +AlwaysBuild(target_size) + +# +# Target: Upload firmware +# + +upload_protocol = env.subst("$UPLOAD_PROTOCOL") +upload_actions = [] + + +if upload_protocol == "serial": + env.Replace( + UPLOADER="stm8gal", + UPLOADERFLAGS=[ + "-p", "$UPLOAD_PORT", + "-R", 1, "-u", 2, + "-V", 2, "-v", "-B", "-w" + ], + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCE' + ) + + if env.subst("$UPLOAD_SPEED"): + env.Prepend(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"]) + + upload_actions = [ + env.VerboseAction(env.AutodetectUploadPort, + "Looking for upload port..."), + env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") + ] + +elif "stlink" in upload_protocol: + mcu = board_config.get("build.mcu") + env.Replace( + UPLOADER="stm8flash", + UPLOADERFLAGS=[ + "-c", board_config.get("upload.protocol"), + "-p", "%s" % mcu[:8] + "?" + mcu[9], + "-s", "flash", "-w" + ], + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCE' + ) + + upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] + +# custom upload tool +elif "UPLOADCMD" in env: + upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] + +else: + sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol) + +AlwaysBuild(env.Alias("upload", target_firm, upload_actions)) + +# +# Setup default targets +# + +Default([target_buildprog, target_size]) \ No newline at end of file diff --git a/examples/arduino-fade-all-pins/.gitignore b/examples/arduino-fade-all-pins/.gitignore new file mode 100644 index 0000000..6c69f4c --- /dev/null +++ b/examples/arduino-fade-all-pins/.gitignore @@ -0,0 +1,2 @@ +.pioenvs +.piolibdeps diff --git a/examples/arduino-fade-all-pins/.travis.yml b/examples/arduino-fade-all-pins/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/examples/arduino-fade-all-pins/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/arduino-fade-all-pins/README.rst b/examples/arduino-fade-all-pins/README.rst new file mode 100644 index 0000000..e9a604b --- /dev/null +++ b/examples/arduino-fade-all-pins/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2018-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm8/examples/arduino-fade-all-pins + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e stm8sdisco + + # Upload firmware for the specific environment + > platformio run -e stm8sdisco --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/arduino-fade-all-pins/include/README b/examples/arduino-fade-all-pins/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/arduino-fade-all-pins/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/arduino-fade-all-pins/lib/README b/examples/arduino-fade-all-pins/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/arduino-fade-all-pins/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +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 diff --git a/examples/arduino-fade-all-pins/platformio.ini b/examples/arduino-fade-all-pins/platformio.ini new file mode 100644 index 0000000..bee1a17 --- /dev/null +++ b/examples/arduino-fade-all-pins/platformio.ini @@ -0,0 +1,33 @@ +; 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:stm8sdisco] +platform = ststm8 +framework = arduino +board = stm8sdisco + +[env:stm8sblue] +platform = ststm8 +framework = arduino +board = stm8sblue + +[env:s8uno] +platform = ststm8 +framework = arduino +board = s8uno + +[env:mb208] +platform = ststm8 +framework = arduino +board = mb208 + +[env:stm8sblack] +platform = ststm8 +framework = arduino +board = stm8sblack diff --git a/examples/arduino-fade-all-pins/src/fade-all-pins.c b/examples/arduino-fade-all-pins/src/fade-all-pins.c new file mode 100644 index 0000000..66ca44a --- /dev/null +++ b/examples/arduino-fade-all-pins/src/fade-all-pins.c @@ -0,0 +1,37 @@ +/* + * fade-all-pins + * + * This example shows how to fade an LED on all PWM-capable pins + * using the analogWrite() function. (Derived from 01.Basics/Fade) + * + * This example code is in the public domain. + */ + +#include + +int brightness = 0; // how bright the LED is +int fadeAmount = 5; // how many points to fade the LED by +char i; + +// the setup routine runs once when you press reset: +void setup() { + // declare all pin to be an output: + for (i=0; i +# +# 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 diff --git a/examples/arduino-internal-lib/README.rst b/examples/arduino-internal-lib/README.rst new file mode 100644 index 0000000..81f701f --- /dev/null +++ b/examples/arduino-internal-lib/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2018-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm8/examples/arduino-internal-lib + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e stm8sdisco + + # Upload firmware for the specific environment + > platformio run -e stm8sdisco --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/arduino-internal-lib/include/README b/examples/arduino-internal-lib/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/arduino-internal-lib/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/arduino-internal-lib/lib/README b/examples/arduino-internal-lib/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/arduino-internal-lib/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +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 diff --git a/examples/arduino-internal-lib/platformio.ini b/examples/arduino-internal-lib/platformio.ini new file mode 100644 index 0000000..bee1a17 --- /dev/null +++ b/examples/arduino-internal-lib/platformio.ini @@ -0,0 +1,33 @@ +; 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:stm8sdisco] +platform = ststm8 +framework = arduino +board = stm8sdisco + +[env:stm8sblue] +platform = ststm8 +framework = arduino +board = stm8sblue + +[env:s8uno] +platform = ststm8 +framework = arduino +board = s8uno + +[env:mb208] +platform = ststm8 +framework = arduino +board = mb208 + +[env:stm8sblack] +platform = ststm8 +framework = arduino +board = stm8sblack diff --git a/examples/arduino-internal-lib/src/oled-mini.c b/examples/arduino-internal-lib/src/oled-mini.c new file mode 100644 index 0000000..9aea833 --- /dev/null +++ b/examples/arduino-internal-lib/src/oled-mini.c @@ -0,0 +1,89 @@ +/* + * This is an example for using the i2c library with a monochrome OLED + * display based on SSD1306 drivers. + * + * It shows the Adafruit splash screen and blinks a pixel pattern once per + * second. On CPUs with only 1kB RAM the display buffer overlaps with the + * stack and you will see it as a wild pattern in the lower left corner of + * the display. For this reason the blinking loop does not touch the lower + * 8 rows of the display memory buffer. + * + * The display has 128x64 pixel and uses only SCL and SDA for communication, + * there is no reset pin. + * + * The framebuffer needs to be kept in RAM as reading the display is not + * supported by the driver chips. Since the STM8S103F3 has only 1kB RAM + * total, we will see the stack contents in the lower part of the display + * as a wild bit pattern. Using drawPixel() on this memory would mess up + * the stack contents and would result in an immediate crash. So don't + * use the lower lines on low memory devices! + * + * This code is adopted from the Adafruit example code contained in the + * Adafruit_SSD1306 library. + * + * modified 2017 by Michael Mayer + */ + +/********************************************************************* +This is an example for our Monochrome OLEDs based on SSD1306 drivers + + Pick one up today in the adafruit shop! + ------> http://www.adafruit.com/category/63_98 + +This example is for a 128x64 size display using I2C to communicate +3 pins are required to interface (2 I2C and one reset) + +Adafruit invests time and resources providing this open source code, +please support Adafruit and open-source hardware by purchasing +products from Adafruit! + +Written by Limor Fried/Ladyada for Adafruit Industries. +BSD license, check license.txt for more information +All text above, and the splash screen must be included in any redistribution +*********************************************************************/ + + +// I2C is included here to let the build system automatically be aware of this +// second-level dependency. Otherwise you would need to list it in the Makefile: +// ARDUINO_LIBS = I2C +#include "I2C.h" +#include "Mini_SSD1306.h" + +#define OLED_RESET -1 + +Mini_SSD1306(display,OLED_RESET); + +#if (SSD1306_LCDHEIGHT != 64) +#error("Height incorrect, please fix Mini_SSD1306.h!"); +#endif + + +void setup() +{ + // The Nokia 5110 display generates the high voltage from the 3.3v + // line internally! (neat!) + // Initialize with the I2C addr 0x3C. Some displays use 0x3D instead. + display_begin(SSD1306_SWITCHCAPVCC, 0x3C,0); +} + + +void loop() +{ + uint8_t x,y; + + // Show image buffer on the display hardware. + // Since the buffer is intialized with an Adafruit splashscreen + // internally, this will display the splashscreen. + display_display(); + + delay (1000); + + // draw some dots in an 8x8 pattern + for (x=0; x +# +# 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 diff --git a/examples/arduino-ping-hc04/README.rst b/examples/arduino-ping-hc04/README.rst new file mode 100644 index 0000000..e9a604b --- /dev/null +++ b/examples/arduino-ping-hc04/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2018-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm8/examples/arduino-fade-all-pins + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e stm8sdisco + + # Upload firmware for the specific environment + > platformio run -e stm8sdisco --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/arduino-ping-hc04/include/README b/examples/arduino-ping-hc04/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/arduino-ping-hc04/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/arduino-ping-hc04/lib/README b/examples/arduino-ping-hc04/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/arduino-ping-hc04/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +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 diff --git a/examples/arduino-ping-hc04/platformio.ini b/examples/arduino-ping-hc04/platformio.ini new file mode 100644 index 0000000..d13dcb3 --- /dev/null +++ b/examples/arduino-ping-hc04/platformio.ini @@ -0,0 +1,23 @@ +; 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:stm8sdisco] +platform = ststm8 +framework = arduino +board = stm8sdisco + +[env:stm8sblue] +platform = ststm8 +framework = arduino +board = stm8sblue + +[env:stm8sblack] +platform = ststm8 +framework = arduino +board = stm8sblack diff --git a/examples/arduino-ping-hc04/src/ping-hc04.c b/examples/arduino-ping-hc04/src/ping-hc04.c new file mode 100644 index 0000000..74a1ba9 --- /dev/null +++ b/examples/arduino-ping-hc04/src/ping-hc04.c @@ -0,0 +1,97 @@ +/* SR-HC04 ultrasonic distance Sensor + + This sketch reads a SR-HC04 ultrasonic rangefinder and returns the + distance to the closest object in range. To do this, it sends a pulse + to the sensor to initiate a reading, then listens for a pulse + to return. The length of the returning pulse is proportional to + the distance of the object from the sensor. + + The circuit: + * +V connection of the HC-04 attached to +5V + * GND connection of the HC-04 attached to ground + * Echo connection of the HC-04 attached to digital pin 0/PA1 + * Trig connection of the HC-04 attached to digital pin 1/PA2 + + This sketch is derived from the example sketch for the Ping)) sensor. + The Ping)) sensor uses the same pin connection for the trigger and the echo + signal, the HC-04 uses two separate connections. + http://www.arduino.cc/en/Tutorial/Ping + + created 3 Nov 2008 + by David A. Mellis + modified 30 Aug 2011 + by Tom Igoe + modified 1 Mar 2017 for use with HC-04 and sduino + by Michael Mayer + + This example code is in the public domain. + + */ + +#include + +// this constant won't change. It's the pin number +// of the sensor's output: +const int trigPin = PA2; +const int echoPin = PA1; + +long microsecondsToInches(long microseconds); +long microsecondsToCentimeters(long microseconds); + +void setup() { + // make sure we start with a high level when the pin is set to output + digitalWrite(trigPin, HIGH); + pinMode(trigPin, OUTPUT); + pinMode(echoPin, INPUT); + // initialize serial communication: + Serial_begin(9600); +} + +void loop() { + // establish variables for duration of the ping, + // and the distance result in inches and centimeters: + long duration, inches, cm; + + // The HC-04 is triggered by a falling edge on the trigger input. The + // following low period has to be at least 10us long. + digitalWrite(trigPin, LOW); + + // approx. 450us later the Echo pins gets high. It stays high until the echo + // is received. Maximum timeout is 200ms (no echo received) + duration = pulseInLong(echoPin, HIGH, 200000L); + digitalWrite(trigPin, HIGH); + + // convert the time into a distance + inches = microsecondsToInches(duration); + cm = microsecondsToCentimeters(duration); + + Serial_print_u(duration); + Serial_print_s("us\t"); + Serial_print_u(inches); + Serial_print_s("in\t"); + Serial_print_u(cm); + Serial_println_s("cm"); + + // maximum is one measurement every 20ms + delay(100); +} + +long microsecondsToInches(long microseconds) { + // According to Parallax's datasheet for the PING))), there are + // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per + // second). This gives the distance travelled by the ping, outbound + // and return, so we divide by 2 to get the distance of the obstacle. + // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf + return microseconds / 74 / 2; +} + +long microsecondsToCentimeters(long microseconds) { + // The speed of sound is 340 m/s or 29 microseconds per centimeter. + // The ping travels out and back, so to find the distance of the + // object we take half of the distance travelled. + // + // The exact value for speed sound depends on the air temperature: + // v = (331.5 + 0.6*temp/°C) m/s + // v(temp=20°C) = (331.5 + 0.6*20)m/s = 343.5m/s + return microseconds / 29 / 2; +} diff --git a/examples/arduino-ping-hc04/test/README b/examples/arduino-ping-hc04/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/examples/arduino-ping-hc04/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/spl-blink/.gitignore b/examples/spl-blink/.gitignore new file mode 100644 index 0000000..6c69f4c --- /dev/null +++ b/examples/spl-blink/.gitignore @@ -0,0 +1,2 @@ +.pioenvs +.piolibdeps diff --git a/examples/spl-blink/.travis.yml b/examples/spl-blink/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/examples/spl-blink/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/spl-blink/README.rst b/examples/spl-blink/README.rst new file mode 100644 index 0000000..8430947 --- /dev/null +++ b/examples/spl-blink/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2018-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm8/examples/spl-blink + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e stm8sdisco + + # Upload firmware for the specific environment + > platformio run -e stm8sdisco --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/spl-blink/include/README b/examples/spl-blink/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/spl-blink/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/spl-blink/lib/README b/examples/spl-blink/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/spl-blink/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +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 diff --git a/examples/spl-blink/platformio.ini b/examples/spl-blink/platformio.ini new file mode 100644 index 0000000..3255b15 --- /dev/null +++ b/examples/spl-blink/platformio.ini @@ -0,0 +1,33 @@ +; 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:stm8sdisco] +platform = ststm8 +framework = spl +board = stm8sdisco + +[env:stm8sblue] +platform = ststm8 +framework = spl +board = stm8sblue + +[env:s8uno] +platform = ststm8 +framework = spl +board = s8uno + +[env:mb208] +platform = ststm8 +framework = spl +board = mb208 + +[env:stm8sblack] +platform = ststm8 +framework = spl +board = stm8sblack diff --git a/examples/spl-blink/src/main.c b/examples/spl-blink/src/main.c new file mode 100644 index 0000000..7327eac --- /dev/null +++ b/examples/spl-blink/src/main.c @@ -0,0 +1,112 @@ +/** + ****************************************************************************** + * @file GPIO_Toggle\main.c + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file contains the main function for GPIO Toggle example. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" +#include "stm8s_it.h" /* SDCC patch: required by SDCC for interrupts */ + +/** + * @addtogroup GPIO_Toggle + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Evalboard I/Os configuration */ + +#define LED_GPIO_PORT (GPIOG) +#define LED_GPIO_PINS (GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0) + +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +void Delay (uint16_t nCount); + +/* Private functions ---------------------------------------------------------*/ +/* Public functions ----------------------------------------------------------*/ + +/** + * @brief Main program. + * @param None + * @retval None + */ +void main(void) +{ + + /* Initialize I/Os in Output Mode */ + GPIO_Init(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST); + + while (1) + { + /* Toggles LEDs */ + GPIO_WriteReverse(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS); + Delay(0xFFFF); + } + +} + +/** + * @brief Delay + * @param nCount + * @retval None + */ +void Delay(uint16_t nCount) +{ + /* Decrement nCount value */ + while (nCount != 0) + { + nCount--; + } +} + +#ifdef USE_FULL_ASSERT + +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t* file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + { + } +} +#endif + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-blink/src/readme.txt b/examples/spl-blink/src/readme.txt new file mode 100644 index 0000000..5c795ec --- /dev/null +++ b/examples/spl-blink/src/readme.txt @@ -0,0 +1,79 @@ +/** @page GPIO_Toggle Use GPIO to toggle Port Pins + + @verbatim + ******************** (C)COPYRIGHT 2014 STMicroelectronics ******************* + * @file GPIO/GPIO_Toggle/readme.txt + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief Description of the GPIO Toggle Example. + ****************************************************************************** + * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + @endverbatim + + @par Example description + + This example provides a short description of how to use the GPIO peripheral to + toggle Ports Pins infinitely. + + + @par Directory contents + + - GPIO\GPIO_Toggle\main.c Main file containing the "main" function + - GPIO\GPIO_Toggle\stm8s_conf.h Library Configuration file + - GPIO\GPIO_Toggle\stm8s_it.c Interrupt routines source + - GPIO\GPIO_Toggle\stm8s_it.h Interrupt routines declaration + + + @par Hardware and Software environment + + - This example runs on STM8S and STM8A High density, Medium density and Low + density devices. + + - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation + board and can be easily tailored to any other development board. + + - STM8/128-EVAL Set-up + - LD1, LD2, LD3 and LD4 are already connected to PH3, PH2, PH1 and PH0 + + + @par How to use it ? + + In order to make the program work, you must do the following : + + - Copy all source files from this example folder to the template folder under + Project\Template + - Open your preferred toolchain + - Rebuild all files and load your image into target memory + - Run the example + - The LD1 and LD4 blink continuously + + @note + - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax, + STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory + density ranges between 32 to 128 Kbytes + - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68, + STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory + density ranges between 8 to 32 Kbytes + - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers + where the Flash memory density ranges between 32 to 128 Kbytes. + - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers + where the Flash memory density ranges between 16 to 32-Kbytes. + - Low-Density STM8S devices are the STM8S103xx, STM8S003, STM8S001 and STM8S903xx microcontrollers + where the Flash density is 8 Kbytes. + + *

© COPYRIGHT STMicroelectronics

+ */ diff --git a/examples/spl-blink/src/stm8s_conf.h b/examples/spl-blink/src/stm8s_conf.h new file mode 100644 index 0000000..d5a9c6a --- /dev/null +++ b/examples/spl-blink/src/stm8s_conf.h @@ -0,0 +1,118 @@ +/** + ****************************************************************************** + * @file stm8s_conf.h + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file is used to configure the Library. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* SDCC patch: include "STM8AF622x" defined in "STM8S_StdPeriph_Tempate" */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM8S_CONF_H +#define __STM8S_CONF_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" + +/* Uncomment the line below to enable peripheral header file inclusion */ +#if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) ||\ + defined(STM8S001) || defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x) +#include "stm8s_adc1.h" +#endif /* (STM8S105) ||(STM8S103) || (STM8S001) || (STM8S903) || (STM8AF626x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\ + defined (STM8AF62Ax) + #include "stm8s_adc2.h" +#endif /* (STM8S208) || (STM8S207) || (STM8AF62Ax) || (STM8AF52Ax) */ +#include "stm8s_awu.h" +#include "stm8s_beep.h" +#if defined (STM8S208) || defined (STM8AF52Ax) + #include "stm8s_can.h" +#endif /* (STM8S208) || (STM8AF52Ax) */ +#include "stm8s_clk.h" +#include "stm8s_exti.h" +#include "stm8s_flash.h" +#include "stm8s_gpio.h" +#include "stm8s_i2c.h" +#include "stm8s_itc.h" +#include "stm8s_iwdg.h" +#include "stm8s_rst.h" +#include "stm8s_spi.h" +#include "stm8s_tim1.h" +#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim2.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) ||\ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + #include "stm8s_tim3.h" +#endif /* (STM8S208) || (STM8S207) || (STM8S007) || (STM8S105) */ +#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim4.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S903) || defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim5.h" + #include "stm8s_tim6.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) ||\ + defined(STM8S003) || defined(STM8S001) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + #include "stm8s_uart1.h" +#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S001) || (STM8S903) || (STM8AF52Ax) || (STM8AF62Ax) */ +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + #include "stm8s_uart2.h" +#endif /* (STM8S105) || (STM8AF626x) */ +#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\ + defined (STM8AF62Ax) + #include "stm8s_uart3.h" +#endif /* (STM8S208) || (STM8S207) || (STM8AF52Ax) || (STM8AF62Ax) */ +#if defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_uart4.h" +#endif /* (STM8AF622x) */ +#include "stm8s_wwdg.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Uncomment the line below to expanse the "assert_param" macro in the + Standard Peripheral Library drivers code */ +#define USE_FULL_ASSERT (1) + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT + +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval : None + */ +#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t* file, uint32_t line); +#else +#define assert_param(expr) ((void)0) +#endif /* USE_FULL_ASSERT */ + +#endif /* __STM8S_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-blink/src/stm8s_it.c b/examples/spl-blink/src/stm8s_it.c new file mode 100644 index 0000000..6cf68a1 --- /dev/null +++ b/examples/spl-blink/src/stm8s_it.c @@ -0,0 +1,482 @@ +/** + ****************************************************************************** + * @file stm8s_it.c + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief Main Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s_it.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/* Public functions ----------------------------------------------------------*/ + +/** @addtogroup GPIO_Toggle + * @{ + */ +#ifdef _COSMIC_ +/** + * @brief Dummy interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(NonHandledInterrupt, 25) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*_COSMIC_*/ + +/** + * @brief TRAP interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +/** + * @brief Top Level Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(TLI_IRQHandler, 0) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Auto Wake Up Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(AWU_IRQHandler, 1) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Clock Controller Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(CLK_IRQHandler, 2) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTA Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTB Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTC Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTD Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTE Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#ifdef STM8S903 +/** + * @brief External Interrupt PORTF Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +#if defined (STM8S208) || defined (STM8AF52Ax) +/** + * @brief CAN RX Interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief CAN TX Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208 || STM8AF52Ax */ + +/** + * @brief SPI Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(SPI_IRQHandler, 10) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer1 Capture/Compare Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#ifdef STM8S903 +/** + * @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +/** + * @brief Timer5 Capture/Compare Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ +/** + * @brief Timer2 Update/Overflow/Break Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer2 Capture/Compare Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8AF626x) +/** + * @brief Timer3 Update/Overflow/Break Interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer3 Capture/Compare Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8S903) +/** + * @brief UART1 TX Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief UART1 RX Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S105 || STM8S001 */ + +/** + * @brief I2C Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(I2C_IRQHandler, 19) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +/** + * @brief UART2 TX interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ + } + +/** + * @brief UART2 RX interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ + } +#endif /* STM8S105*/ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +/** + * @brief UART3 TX interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ + } + +/** + * @brief UART3 RX interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ + } +#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +/** + * @brief ADC2 interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(ADC2_IRQHandler, 22) +{ + + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ + return; + +} +#else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */ +/** + * @brief ADC1 interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(ADC1_IRQHandler, 22) +{ + + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ + return; + +} +#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ + +#ifdef STM8S903 +/** + * @brief Timer6 Update/Overflow/Trigger Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ +/** + * @brief Timer4 Update/Overflow Interrupt routine + * @param None + * @retval None + */ + INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +/** + * @brief Eeprom EEC Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-blink/src/stm8s_it.h b/examples/spl-blink/src/stm8s_it.h new file mode 100644 index 0000000..46aac46 --- /dev/null +++ b/examples/spl-blink/src/stm8s_it.h @@ -0,0 +1,201 @@ +/** + ****************************************************************************** + * @file stm8s_it.h + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file contains the headers of the interrupt handlers + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM8S_IT_H +#define __STM8S_IT_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +#ifdef _COSMIC_ + void _stext(void); /* RESET startup routine */ + INTERRUPT void NonHandledInterrupt(void); +#endif /* _COSMIC_ */ + +// SDCC patch: requires separate handling for SDCC (see below) +#if !defined(_RAISONANCE_) && !defined(_SDCC_) + INTERRUPT void TRAP_IRQHandler(void); /* TRAP */ + INTERRUPT void TLI_IRQHandler(void); /* TLI */ + INTERRUPT void AWU_IRQHandler(void); /* AWU */ + INTERRUPT void CLK_IRQHandler(void); /* CLOCK */ + INTERRUPT void EXTI_PORTA_IRQHandler(void); /* EXTI PORTA */ + INTERRUPT void EXTI_PORTB_IRQHandler(void); /* EXTI PORTB */ + INTERRUPT void EXTI_PORTC_IRQHandler(void); /* EXTI PORTC */ + INTERRUPT void EXTI_PORTD_IRQHandler(void); /* EXTI PORTD */ + INTERRUPT void EXTI_PORTE_IRQHandler(void); /* EXTI PORTE */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void EXTI_PORTF_IRQHandler(void); /* EXTI PORTF */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined (STM8AF52Ax) + INTERRUPT void CAN_RX_IRQHandler(void); /* CAN RX */ + INTERRUPT void CAN_TX_IRQHandler(void); /* CAN TX/ER/SC */ +#endif /* (STM8S208) || (STM8AF52Ax) */ + + INTERRUPT void SPI_IRQHandler(void); /* SPI */ + INTERRUPT void TIM1_CAP_COM_IRQHandler(void); /* TIM1 CAP/COM */ + INTERRUPT void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void); /* TIM1 UPD/OVF/TRG/BRK */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void); /* TIM5 UPD/OVF/BRK/TRG */ + INTERRUPT void TIM5_CAP_COM_IRQHandler(void); /* TIM5 CAP/COM */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + INTERRUPT void TIM2_UPD_OVF_BRK_IRQHandler(void); /* TIM2 UPD/OVF/BRK */ + INTERRUPT void TIM2_CAP_COM_IRQHandler(void); /* TIM2 CAP/COM */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + INTERRUPT void TIM3_UPD_OVF_BRK_IRQHandler(void); /* TIM3 UPD/OVF/BRK */ + INTERRUPT void TIM3_CAP_COM_IRQHandler(void); /* TIM3 CAP/COM */ +#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined(STM8AF52Ax) || defined(STM8AF62Ax) || defined(STM8S903) + INTERRUPT void UART1_TX_IRQHandler(void); /* UART1 TX */ + INTERRUPT void UART1_RX_IRQHandler(void); /* UART1 RX */ +#endif /* (STM8S208) || (STM8S207) || (STM8S007) || (STM8S103) || (STM8S003) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8S903) */ + +#if defined (STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void UART4_TX_IRQHandler(void); /* UART4 TX */ + INTERRUPT void UART4_RX_IRQHandler(void); /* UART4 RX */ +#endif /* (STM8AF622x) */ + + INTERRUPT void I2C_IRQHandler(void); /* I2C */ + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + INTERRUPT void UART2_RX_IRQHandler(void); /* UART2 RX */ + INTERRUPT void UART2_TX_IRQHandler(void); /* UART2 TX */ +#endif /* (STM8S105) || (STM8S005) || (STM8AF626x) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT void UART3_RX_IRQHandler(void); /* UART3 RX */ + INTERRUPT void UART3_TX_IRQHandler(void); /* UART3 TX */ +#endif /* (STM8S207) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT void ADC2_IRQHandler(void); /* ADC2 */ +#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */ + INTERRUPT void ADC1_IRQHandler(void); /* ADC1 */ +#endif /* (STM8S207) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */ +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ + INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */ +#endif /* (STM8S903) || (STM8AF622x) */ + INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */ + + +// SDCC patch: __interrupt keyword required after function name --> requires new block +#elif defined (_SDCC_) + + INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler); /* TRAP */ + INTERRUPT_HANDLER(TLI_IRQHandler, 0); /* TLI */ + INTERRUPT_HANDLER(AWU_IRQHandler, 1); /* AWU */ + INTERRUPT_HANDLER(CLK_IRQHandler, 2); /* CLOCK */ + INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3); /* EXTI PORTA */ + INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4); /* EXTI PORTB */ + INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5); /* EXTI PORTC */ + INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6); /* EXTI PORTD */ + INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7); /* EXTI PORTE */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8); /* EXTI PORTF */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined (STM8AF52Ax) + INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8); /* CAN RX */ + INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9); /* CAN TX/ER/SC */ +#endif /* (STM8S208) || (STM8AF52Ax) */ + + INTERRUPT_HANDLER(SPI_IRQHandler, 10); /* SPI */ + INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); /* TIM1 UPD/OVF/TRG/BRK */ + INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12); /* TIM1 CAP/COM */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); /* TIM5 UPD/OVF/BRK/TRG */ + INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14); /* TIM5 CAP/COM */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13); /* TIM2 UPD/OVF/BRK */ + INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14); /* TIM2 CAP/COM */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15); /* TIM3 UPD/OVF/BRK */ + INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16); /* TIM3 CAP/COM */ +#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903) + INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17); /* UART1 TX */ + INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18); /* UART1 RX */ +#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined (STM8AF622x) + INTERRUPT_HANDLER(UART4_TX_IRQHandler, 17); /* UART4 TX */ + INTERRUPT_HANDLER(UART4_RX_IRQHandler, 18); /* UART4 RX */ +#endif /* (STM8AF622x) */ + + INTERRUPT_HANDLER(I2C_IRQHandler, 19); /* I2C */ + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20); /* UART2 TX */ + INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21); /* UART2 RX */ +#endif /* (STM8S105) || (STM8AF626x) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT_HANDLER(UART3_RX_IRQHandler, 20); /* UART3 RX */ + INTERRUPT_HANDLER(UART3_TX_IRQHandler, 21); /* UART3 TX */ +#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT_HANDLER(ADC2_IRQHandler, 22); /* ADC2 */ +#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */ + INTERRUPT_HANDLER(ADC1_IRQHandler, 22); /* ADC1 */ +#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23); /* TIM6 UPD/OVF/TRG */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */ + INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23); /* TIM4 UPD/OVF */ +#endif /* (STM8S903) || (STM8AF622x) */ + INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24); /* EEPROM ECC CORRECTION */ + +#endif /* !(_RAISONANCE_) && !(_SDCC_) */ + +#endif /* __STM8S_IT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-blink/test/README b/examples/spl-blink/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/examples/spl-blink/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/spl-flash/.gitignore b/examples/spl-flash/.gitignore new file mode 100644 index 0000000..6c69f4c --- /dev/null +++ b/examples/spl-flash/.gitignore @@ -0,0 +1,2 @@ +.pioenvs +.piolibdeps diff --git a/examples/spl-flash/.travis.yml b/examples/spl-flash/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/examples/spl-flash/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/spl-flash/README.rst b/examples/spl-flash/README.rst new file mode 100644 index 0000000..c1e2836 --- /dev/null +++ b/examples/spl-flash/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2018-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm8/examples/spl-flash + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e stm8sdisco + + # Upload firmware for the specific environment + > platformio run -e stm8sdisco --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/spl-flash/include/README b/examples/spl-flash/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/spl-flash/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/spl-flash/lib/README b/examples/spl-flash/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/spl-flash/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +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 diff --git a/examples/spl-flash/platformio.ini b/examples/spl-flash/platformio.ini new file mode 100644 index 0000000..c798182 --- /dev/null +++ b/examples/spl-flash/platformio.ini @@ -0,0 +1,24 @@ +; 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:stm8sdisco] +platform = ststm8 +framework = spl +board = stm8sdisco + +[env:s8uno] +platform = ststm8 +framework = spl +board = s8uno + +[env:mb208] +platform = ststm8 +framework = spl +board = mb208 + diff --git a/examples/spl-flash/src/main.c b/examples/spl-flash/src/main.c new file mode 100644 index 0000000..c4181d2 --- /dev/null +++ b/examples/spl-flash/src/main.c @@ -0,0 +1,143 @@ +/** + ****************************************************************************** + * @file FLASH_ByteReadWriteOperation\main.c + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file contains the main function for FLASH byte read write operation example. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" +#include "stm8s_it.h" /* SDCC patch: required by SDCC for interrupts */ + +/** + * @addtogroup FLASH_ByteReadWriteOperation + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +typedef enum { FAILED = 0, PASSED = !FAILED} TestStatus; +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +__IO TestStatus OperationStatus; +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ +/* Public functions ----------------------------------------------------------*/ + +/** + * @brief How to Read / Write / Erase one Byte on FLASH memory. + * @par Examples description + * - Read one byte at address 0x40A5 + * - Write its complement value at address + 1 + * - Check programed value + * - Erase 2 byte (address 40A5 & 40A6) + * - Check the 2 bytes value is 0x00. + * @param None + * @retval None + */ +void main(void) +{ + + uint8_t val = 0x00, val_comp = 0x00; + uint32_t add = 0x00; + + /* Define FLASH programming time */ + FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD); + + /* Unlock Data memory */ + FLASH_Unlock(FLASH_MEMTYPE_DATA); + + /* Read a byte at a specified address */ + add = 0x40A5; + val = FLASH_ReadByte(add); + + /* Program complement value (of previous read byte) at previous address + 1 */ + val_comp = (uint8_t)(~val); + FLASH_ProgramByte((add + 1), val_comp); + + /* Check program action */ + val = FLASH_ReadByte((add + 1)); + if (val != val_comp) + { + /* Error */ + OperationStatus = FAILED; + /* OperationStatus = PASSED, if the data written/read to/from DATA EEPROM memory is correct */ + /* OperationStatus = FAILED, if the data written/read to/from DATA EEPROM memory is corrupted */ + while (1) + { + } + } + + /* Erase byte at a specified address & address + 1 */ + FLASH_EraseByte(add); + FLASH_EraseByte((add + 1)); + /* Erase action */ + val = FLASH_ReadByte(add); + val_comp = FLASH_ReadByte((add + 1)); + if ((val != 0x00) & (val_comp != 0x00)) + { + /* Error */ + OperationStatus = FAILED; + /* OperationStatus = PASSED, if the data written/read to/from DATA EEPROM memory is correct */ + /* OperationStatus = FAILED, if the data written/read to/from DATA EEPROM memory is corrupted */ + while (1) + { + } + } + + /* Pass */ + OperationStatus = PASSED; + /* OperationStatus = PASSED, if the data written/read to/from DATA EEPROM memory is correct */ + /* OperationStatus = FAILED, if the data written/read to/from DATA EEPROM memory is corrupted */ + while (1) + { + } +} + +#ifdef USE_FULL_ASSERT + +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t* file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + { + } +} +#endif + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-flash/src/readme.txt b/examples/spl-flash/src/readme.txt new file mode 100644 index 0000000..73b76e6 --- /dev/null +++ b/examples/spl-flash/src/readme.txt @@ -0,0 +1,81 @@ +/** @page FLASH_ByteReadWriteOperation Read, Write, Erase byte + @verbatim + ******************** (C)COPYRIGHT 2014 STMicroelectronics ******************* + * @file FLASH/FLASH_ByteReadWriteOperation/readme.txt + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file contains the description of the FLASH byte read write + * operation example. + ****************************************************************************** + * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + @endverbatim + + @par Example description + + This example provides a short description on how to use FLASH Read/Write/Erase + operations on byte: + - Read a byte at a specified address (0x40A5). + - Write its complement value at address +1 (0x40A6). + - Check programmed byte (using read function) + - Erase 2 bytes at address & address+1 + - Check 2 bytes are erased (value must be equal to 0x00). + + + @par Directory contents + + - FLASH\FLASH_ByteReadWriteOperation\main.c Main file containing the "main" function + - FLASH\FLASH_ByteReadWriteOperation\stm8s_conf.h Library Configuration file + - FLASH\FLASH_ByteReadWriteOperation\stm8s_it.c Interrupt routines source (not used in this example) + - FLASH\FLASH_ByteReadWriteOperation\stm8s_it.h Interrupt routines declaration + + + @par Hardware and Software environment + + - This example runs on STM8S and STM8A High density devices. + + - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation + board and can be easily tailored to any other development board. + + + @par How to use it ? + + In order to make the program work, you must do the following : + + - Copy all source files from this example folder to the template folder under + Project\Template + - Open your preferred toolchain + - Rebuild all files and load your image into target memory + - Run the example + - The data read from the data memory is compared with the expected values. + The result of this comparison is stored in the "OperationStatus" variable. + + @note + - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax, + STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory + density ranges between 32 to 128 Kbytes + - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68, + STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory + density ranges between 8 to 32 Kbytes + - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers + where the Flash memory density ranges between 32 to 128 Kbytes. + - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers + where the Flash memory density ranges between 16 to 32-Kbytes. + - Low-Density STM8S devices are the STM8S103xx, STM8S003, STM8S001 and STM8S903xx microcontrollers + where the Flash density is 8 Kbytes. + + *

© COPYRIGHT STMicroelectronics

+ */ diff --git a/examples/spl-flash/src/stm8s_conf.h b/examples/spl-flash/src/stm8s_conf.h new file mode 100644 index 0000000..d5a9c6a --- /dev/null +++ b/examples/spl-flash/src/stm8s_conf.h @@ -0,0 +1,118 @@ +/** + ****************************************************************************** + * @file stm8s_conf.h + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file is used to configure the Library. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* SDCC patch: include "STM8AF622x" defined in "STM8S_StdPeriph_Tempate" */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM8S_CONF_H +#define __STM8S_CONF_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" + +/* Uncomment the line below to enable peripheral header file inclusion */ +#if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) ||\ + defined(STM8S001) || defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x) +#include "stm8s_adc1.h" +#endif /* (STM8S105) ||(STM8S103) || (STM8S001) || (STM8S903) || (STM8AF626x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\ + defined (STM8AF62Ax) + #include "stm8s_adc2.h" +#endif /* (STM8S208) || (STM8S207) || (STM8AF62Ax) || (STM8AF52Ax) */ +#include "stm8s_awu.h" +#include "stm8s_beep.h" +#if defined (STM8S208) || defined (STM8AF52Ax) + #include "stm8s_can.h" +#endif /* (STM8S208) || (STM8AF52Ax) */ +#include "stm8s_clk.h" +#include "stm8s_exti.h" +#include "stm8s_flash.h" +#include "stm8s_gpio.h" +#include "stm8s_i2c.h" +#include "stm8s_itc.h" +#include "stm8s_iwdg.h" +#include "stm8s_rst.h" +#include "stm8s_spi.h" +#include "stm8s_tim1.h" +#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim2.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) ||\ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + #include "stm8s_tim3.h" +#endif /* (STM8S208) || (STM8S207) || (STM8S007) || (STM8S105) */ +#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim4.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S903) || defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim5.h" + #include "stm8s_tim6.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) ||\ + defined(STM8S003) || defined(STM8S001) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + #include "stm8s_uart1.h" +#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S001) || (STM8S903) || (STM8AF52Ax) || (STM8AF62Ax) */ +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + #include "stm8s_uart2.h" +#endif /* (STM8S105) || (STM8AF626x) */ +#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\ + defined (STM8AF62Ax) + #include "stm8s_uart3.h" +#endif /* (STM8S208) || (STM8S207) || (STM8AF52Ax) || (STM8AF62Ax) */ +#if defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_uart4.h" +#endif /* (STM8AF622x) */ +#include "stm8s_wwdg.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Uncomment the line below to expanse the "assert_param" macro in the + Standard Peripheral Library drivers code */ +#define USE_FULL_ASSERT (1) + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT + +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval : None + */ +#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t* file, uint32_t line); +#else +#define assert_param(expr) ((void)0) +#endif /* USE_FULL_ASSERT */ + +#endif /* __STM8S_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-flash/src/stm8s_it.c b/examples/spl-flash/src/stm8s_it.c new file mode 100644 index 0000000..4a678c8 --- /dev/null +++ b/examples/spl-flash/src/stm8s_it.c @@ -0,0 +1,520 @@ +/** + ****************************************************************************** + * @file stm8s_it.c + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief Main Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s_it.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/* Public functions ----------------------------------------------------------*/ + +/** @addtogroup FLASH_ByteReadWriteOperation + * @{ + */ +#ifdef _COSMIC_ +/** + * @brief Dummy interrupt routine + * @param None + * @retval None + */ +@far @interrupt void NonHandledInterrupt(void) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief TRAP interrupt routine + * @param None + * @retval None + */ +@far @interrupt void TRAP_IRQHandler(void) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#else /*_RAISONANCE_*/ + +/** + * @brief TRAP interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*_COSMIC_*/ + +/** + * @brief Top Level Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(TLI_IRQHandler, 0) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Auto Wake Up Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(AWU_IRQHandler, 1) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Clock Controller Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(CLK_IRQHandler, 2) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTA Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTB Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTC Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTD Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTE Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#ifdef STM8S903 +/** + * @brief External Interrupt PORTF Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +#ifdef STM8S208 +/** + * @brief CAN RX Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief CAN TX Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208 || STM8AF52Ax */ + +/** + * @brief SPI Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(SPI_IRQHandler, 10) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer1 Capture/Compare Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#ifdef STM8S903 +/** + * @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +/** + * @brief Timer5 Capture/Compare Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ +/** + * @brief Timer2 Update/Overflow/Break Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer2 Capture/Compare Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8AF626x) +/** + * @brief Timer3 Update/Overflow/Break Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer3 Capture/Compare Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8S903) +/** + * @brief UART1 TX Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief UART1 RX Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S105 || STM8S001 */ + +/** + * @brief I2C Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(I2C_IRQHandler, 19) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +/** + * @brief UART2 TX interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief UART2 RX interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /* STM8S105*/ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +/** + * @brief UART3 TX interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief UART3 RX interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +/** + * @brief ADC2 interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(ADC2_IRQHandler, 22) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */ +/** + * @brief ADC1 interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(ADC1_IRQHandler, 22) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ + +#ifdef STM8S903 +/** + * @brief Timer6 Update/Overflow/Trigger Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ +/** + * @brief Timer4 Update/Overflow Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +/** + * @brief Eeprom EEC Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file diff --git a/examples/spl-flash/src/stm8s_it.h b/examples/spl-flash/src/stm8s_it.h new file mode 100644 index 0000000..46aac46 --- /dev/null +++ b/examples/spl-flash/src/stm8s_it.h @@ -0,0 +1,201 @@ +/** + ****************************************************************************** + * @file stm8s_it.h + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file contains the headers of the interrupt handlers + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM8S_IT_H +#define __STM8S_IT_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +#ifdef _COSMIC_ + void _stext(void); /* RESET startup routine */ + INTERRUPT void NonHandledInterrupt(void); +#endif /* _COSMIC_ */ + +// SDCC patch: requires separate handling for SDCC (see below) +#if !defined(_RAISONANCE_) && !defined(_SDCC_) + INTERRUPT void TRAP_IRQHandler(void); /* TRAP */ + INTERRUPT void TLI_IRQHandler(void); /* TLI */ + INTERRUPT void AWU_IRQHandler(void); /* AWU */ + INTERRUPT void CLK_IRQHandler(void); /* CLOCK */ + INTERRUPT void EXTI_PORTA_IRQHandler(void); /* EXTI PORTA */ + INTERRUPT void EXTI_PORTB_IRQHandler(void); /* EXTI PORTB */ + INTERRUPT void EXTI_PORTC_IRQHandler(void); /* EXTI PORTC */ + INTERRUPT void EXTI_PORTD_IRQHandler(void); /* EXTI PORTD */ + INTERRUPT void EXTI_PORTE_IRQHandler(void); /* EXTI PORTE */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void EXTI_PORTF_IRQHandler(void); /* EXTI PORTF */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined (STM8AF52Ax) + INTERRUPT void CAN_RX_IRQHandler(void); /* CAN RX */ + INTERRUPT void CAN_TX_IRQHandler(void); /* CAN TX/ER/SC */ +#endif /* (STM8S208) || (STM8AF52Ax) */ + + INTERRUPT void SPI_IRQHandler(void); /* SPI */ + INTERRUPT void TIM1_CAP_COM_IRQHandler(void); /* TIM1 CAP/COM */ + INTERRUPT void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void); /* TIM1 UPD/OVF/TRG/BRK */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void); /* TIM5 UPD/OVF/BRK/TRG */ + INTERRUPT void TIM5_CAP_COM_IRQHandler(void); /* TIM5 CAP/COM */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + INTERRUPT void TIM2_UPD_OVF_BRK_IRQHandler(void); /* TIM2 UPD/OVF/BRK */ + INTERRUPT void TIM2_CAP_COM_IRQHandler(void); /* TIM2 CAP/COM */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + INTERRUPT void TIM3_UPD_OVF_BRK_IRQHandler(void); /* TIM3 UPD/OVF/BRK */ + INTERRUPT void TIM3_CAP_COM_IRQHandler(void); /* TIM3 CAP/COM */ +#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined(STM8AF52Ax) || defined(STM8AF62Ax) || defined(STM8S903) + INTERRUPT void UART1_TX_IRQHandler(void); /* UART1 TX */ + INTERRUPT void UART1_RX_IRQHandler(void); /* UART1 RX */ +#endif /* (STM8S208) || (STM8S207) || (STM8S007) || (STM8S103) || (STM8S003) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8S903) */ + +#if defined (STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void UART4_TX_IRQHandler(void); /* UART4 TX */ + INTERRUPT void UART4_RX_IRQHandler(void); /* UART4 RX */ +#endif /* (STM8AF622x) */ + + INTERRUPT void I2C_IRQHandler(void); /* I2C */ + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + INTERRUPT void UART2_RX_IRQHandler(void); /* UART2 RX */ + INTERRUPT void UART2_TX_IRQHandler(void); /* UART2 TX */ +#endif /* (STM8S105) || (STM8S005) || (STM8AF626x) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT void UART3_RX_IRQHandler(void); /* UART3 RX */ + INTERRUPT void UART3_TX_IRQHandler(void); /* UART3 TX */ +#endif /* (STM8S207) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT void ADC2_IRQHandler(void); /* ADC2 */ +#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */ + INTERRUPT void ADC1_IRQHandler(void); /* ADC1 */ +#endif /* (STM8S207) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */ +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ + INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */ +#endif /* (STM8S903) || (STM8AF622x) */ + INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */ + + +// SDCC patch: __interrupt keyword required after function name --> requires new block +#elif defined (_SDCC_) + + INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler); /* TRAP */ + INTERRUPT_HANDLER(TLI_IRQHandler, 0); /* TLI */ + INTERRUPT_HANDLER(AWU_IRQHandler, 1); /* AWU */ + INTERRUPT_HANDLER(CLK_IRQHandler, 2); /* CLOCK */ + INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3); /* EXTI PORTA */ + INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4); /* EXTI PORTB */ + INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5); /* EXTI PORTC */ + INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6); /* EXTI PORTD */ + INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7); /* EXTI PORTE */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8); /* EXTI PORTF */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined (STM8AF52Ax) + INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8); /* CAN RX */ + INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9); /* CAN TX/ER/SC */ +#endif /* (STM8S208) || (STM8AF52Ax) */ + + INTERRUPT_HANDLER(SPI_IRQHandler, 10); /* SPI */ + INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); /* TIM1 UPD/OVF/TRG/BRK */ + INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12); /* TIM1 CAP/COM */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); /* TIM5 UPD/OVF/BRK/TRG */ + INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14); /* TIM5 CAP/COM */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13); /* TIM2 UPD/OVF/BRK */ + INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14); /* TIM2 CAP/COM */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15); /* TIM3 UPD/OVF/BRK */ + INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16); /* TIM3 CAP/COM */ +#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903) + INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17); /* UART1 TX */ + INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18); /* UART1 RX */ +#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined (STM8AF622x) + INTERRUPT_HANDLER(UART4_TX_IRQHandler, 17); /* UART4 TX */ + INTERRUPT_HANDLER(UART4_RX_IRQHandler, 18); /* UART4 RX */ +#endif /* (STM8AF622x) */ + + INTERRUPT_HANDLER(I2C_IRQHandler, 19); /* I2C */ + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20); /* UART2 TX */ + INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21); /* UART2 RX */ +#endif /* (STM8S105) || (STM8AF626x) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT_HANDLER(UART3_RX_IRQHandler, 20); /* UART3 RX */ + INTERRUPT_HANDLER(UART3_TX_IRQHandler, 21); /* UART3 TX */ +#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT_HANDLER(ADC2_IRQHandler, 22); /* ADC2 */ +#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */ + INTERRUPT_HANDLER(ADC1_IRQHandler, 22); /* ADC1 */ +#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23); /* TIM6 UPD/OVF/TRG */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */ + INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23); /* TIM4 UPD/OVF */ +#endif /* (STM8S903) || (STM8AF622x) */ + INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24); /* EEPROM ECC CORRECTION */ + +#endif /* !(_RAISONANCE_) && !(_SDCC_) */ + +#endif /* __STM8S_IT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-flash/test/README b/examples/spl-flash/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/examples/spl-flash/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/spl-uart/.gitignore b/examples/spl-uart/.gitignore new file mode 100644 index 0000000..6c69f4c --- /dev/null +++ b/examples/spl-uart/.gitignore @@ -0,0 +1,2 @@ +.pioenvs +.piolibdeps diff --git a/examples/spl-uart/.travis.yml b/examples/spl-uart/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/examples/spl-uart/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/spl-uart/README.rst b/examples/spl-uart/README.rst new file mode 100644 index 0000000..8710e74 --- /dev/null +++ b/examples/spl-uart/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2018-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm8/examples/spl-uart + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e stm8sdisco + + # Upload firmware for the specific environment + > platformio run -e stm8sdisco --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/spl-uart/include/README b/examples/spl-uart/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/spl-uart/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/spl-uart/lib/README b/examples/spl-uart/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/spl-uart/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +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 diff --git a/examples/spl-uart/platformio.ini b/examples/spl-uart/platformio.ini new file mode 100644 index 0000000..d2295a0 --- /dev/null +++ b/examples/spl-uart/platformio.ini @@ -0,0 +1,13 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:mb208] +platform = ststm8 +framework = spl +board = mb208 diff --git a/examples/spl-uart/src/main.c b/examples/spl-uart/src/main.c new file mode 100644 index 0000000..887ca33 --- /dev/null +++ b/examples/spl-uart/src/main.c @@ -0,0 +1,347 @@ +/** + ****************************************************************************** + * @file UART1_Interrupt\main.c + * @brief This file contains the main function for a basic communication between UART1 and UART3 using interrupts. + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" +#include "stm8s_it.h" /* SDCC patch: required by SDCC for interrupts */ +#include "main.h" + +/** + * @addtogroup UART1_Interrupt + * @{ + */ +/* Private typedef -----------------------------------------------------------*/ +typedef enum { FAILED = 0, PASSED = !FAILED} TestStatus; +/* Private variables ---------------------------------------------------------*/ +uint8_t TxBuffer1[] = "UART1 Interrupt Example: UART1 -> UART3 using Interrupt"; +uint8_t TxBuffer2[] = "UART1 Interrupt Example: UART3 -> UART1 using Interrupt"; +uint8_t RxBuffer1[RxBufferSize1]; +uint8_t RxBuffer2[RxBufferSize2]; +__IO uint8_t TxCounter1 = 0x00; +__IO uint8_t TxCounter2 = 0x00; +__IO uint8_t RxCounter1 = 0x00; +__IO uint8_t RxCounter2 = 0x00; +uint8_t NbrOfDataToTransfer1 = TxBufferSize1; +uint8_t NbrOfDataToTransfer2 = TxBufferSize2; +uint8_t NbrOfDataToRead1 = RxBufferSize1; +uint8_t NbrOfDataToRead2 = RxBufferSize2; +__IO TestStatus TransferStatus1 = FAILED; +__IO TestStatus TransferStatus2 = FAILED; + +/* Private function prototypes -----------------------------------------------*/ +TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength); +static void CLK_Config(void); +static void UART_Config(void); + +/* Private functions ---------------------------------------------------------*/ +/** + * @brief Main program. + * @param None + * @retval None + */ +void main(void) +{ + /* CLK configuration -----------------------------------------*/ + CLK_Config(); + + /* UART configuration -----------------------------------------*/ + UART_Config(); + + /* Wait until end of transmission from UART1 to UART3 */ + while (GetVar_RxCounter2() < GetVar_NbrOfDataToTransfer1()) + { + } + /* Enable UART1 Receive and UART3 Transmit interrupt */ + UART1_ITConfig(UART1_IT_RXNE_OR, ENABLE); + UART3_ITConfig(UART3_IT_TXE, ENABLE); + /* Wait until end of transmission from UART3 to UART1 */ + while (GetVar_RxCounter1() < GetVar_NbrOfDataToTransfer2()) + { + } + + /* Check the received data with the send ones */ + TransferStatus1 = Buffercmp(TxBuffer2, RxBuffer1, RxBufferSize1); + /* TransferStatus1 = PASSED, if the data transmitted from UART3 and + received by UART1 are the same */ + /* TransferStatus1 = FAILED, if the data transmitted from UART3 and + received by UART1 are different */ + TransferStatus2 = Buffercmp(TxBuffer1, RxBuffer2, RxBufferSize2); + /* TransferStatus2 = PASSED, if the data transmitted from UART1 and + received by UART3 are the same */ + /* TransferStatus2 = FAILED, if the data transmitted from UART1 and + received by UART3 are different */ + + while (1) + {} +} + +/** + * @brief Configure system clock to run at 16Mhz + * @param None + * @retval None + */ +static void CLK_Config(void) +{ + /* Initialization of the clock */ + /* Clock divider to HSI/1 */ + CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); +} + +/** + * @brief UART1 and UART3 Configuration for interrupt communication + * @param None + * @retval None + */ +static void UART_Config(void) +{ + /* Deinitializes the UART1 and UART3 peripheral */ + UART1_DeInit(); + UART3_DeInit(); + /* UART1 and UART3 configuration -------------------------------------------------*/ + /* UART1 and UART3 configured as follow: + - BaudRate = 9600 baud + - Word Length = 8 Bits + - One Stop Bit + - No parity + - Receive and transmit enabled + - UART1 Clock disabled + */ + /* Configure the UART1 */ + UART1_Init((uint32_t)9600, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, UART1_PARITY_NO, + UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE); + + /* Enable UART1 Transmit interrupt*/ + UART1_ITConfig(UART1_IT_TXE, ENABLE); + + /* Configure the UART3 */ + UART3_Init((uint32_t)9600, UART3_WORDLENGTH_8D, UART3_STOPBITS_1, UART3_PARITY_NO, + UART3_MODE_TXRX_ENABLE); + + /* Enable UART3 Receive interrupt */ + UART3_ITConfig(UART3_IT_RXNE_OR, ENABLE); + + /* Enable general interrupts */ + enableInterrupts(); +} + +/** + * @brief Compares two buffers. + * @param[in] pBuffer1 First buffer to be compared. + * @param[in] pBuffer2 Second buffer to be compared. + * @param[in] BufferLength Buffer's length + * @retval TestStatus Status of buffer comparison + * - PASSED: pBuffer1 identical to pBuffer2 + * - FAILED: pBuffer1 differs from pBuffer2 + * @par Required preconditions: + * None + */ +TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength) +{ + while (BufferLength--) + { + if (*pBuffer1 != *pBuffer2) + { + return FAILED; + } + + pBuffer1++; + pBuffer2++; + } + + return PASSED; +} +/** + * @brief Returns TxCounter1 value. + * @param None + * @retval Transmit counter index1 + * - uint8_t: TxCounter1 + * @par Required preconditions: + * None + */ +uint8_t GetVar_TxCounter1(void) +{ +return TxCounter1; +} +/** + * @brief Returns TxCounter2 value. + * @param None + * @retval Transmit counter index2 + * - uint8_t: TxCounter2 + * @par Required preconditions: + * None + */ +uint8_t GetVar_TxCounter2(void) +{ +return TxCounter2; +} +/** + * @brief Returns RxCounter1 value. + * @param None + * @retval Receive counter index1 + * - uint8_t: RxCounter1 + * @par Required preconditions: + * None + */ +uint8_t GetVar_RxCounter1(void) +{ +return RxCounter1; +} +/** + * @brief Returns RxCounter2 value. + * @param None + * @retval Receive counter index2 + * - uint8_t: RxCounter2 + * @par Required preconditions: + * None + */ +uint8_t GetVar_RxCounter2(void) +{ +return RxCounter2; +} +/** + * @brief Increments TxCounter1 variable and return its value + * @param None + * @retval Transmit counter index1++ + * - uint8_t: TxCounter1++ + * @par Required preconditions: + * None + */ +uint8_t IncrementVar_TxCounter1(void) +{ + return TxCounter1++; +} +/** + * @brief Increments TxCounter2 variable and return its value + * @param None + * @retval Transmit counter index2++ + * - uint8_t: TxCounter2++ + * @par Required preconditions: + * None + */ +uint8_t IncrementVar_TxCounter2(void) +{ + return TxCounter2++; +} +/** + * @brief Increments RxCounter1 variable and return its value + * @param None + * @retval Receive counter index1++ + * - uint8_t: RxCounter1++ + * @par Required preconditions: + * None + */ +uint8_t IncrementVar_RxCounter1(void) +{ + return RxCounter1++; +} +/** + * @brief Increments RxCounter2 variable and return its value + * @param None + * @retval Receive counter index2++ + * - uint8_t: RxCounter2++ + * @par Required preconditions: + * None + */ +uint8_t IncrementVar_RxCounter2(void) +{ + return RxCounter2++; +} +/** + * @brief Returns NbrOfDataToTransfer1 value. + * @param None + * @retval Tx Buffer Size1 + * - uint8_t: NbrOfDataToTransfer1 + * @par Required preconditions: + * None + */ +uint8_t GetVar_NbrOfDataToTransfer1(void) +{ +return NbrOfDataToTransfer1; +} +/** + * @brief Returns NbrOfDataToTransfer2 value. + * @param None + * @retval Tx Buffer Size2 + * - uint8_t: NbrOfDataToTransfer2 + * @par Required preconditions: + * None + */ +uint8_t GetVar_NbrOfDataToTransfer2(void) +{ +return NbrOfDataToTransfer2; +} +/** + * @brief Returns NbrOfDataToRead1 value. + * @param None + * @retval Rx Buffer Size1 + * - uint8_t: NbrOfDataToRead1 + * @par Required preconditions: + * None + */ +uint8_t GetVar_NbrOfDataToRead1(void) +{ +return NbrOfDataToRead1; +} +/** + * @brief Returns NbrOfDataToRead2 value. + * @param None + * @retval Rx Buffer Size2 + * - uint8_t: NbrOfDataToRead2 + * @par Required preconditions: + * None + */ +uint8_t GetVar_NbrOfDataToRead2(void) +{ +return NbrOfDataToRead2; +} +#ifdef USE_FULL_ASSERT + +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t* file, uint32_t line) +{ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + + /* Infinite loop */ + while (1) + { + } +} +#endif + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-uart/src/main.h b/examples/spl-uart/src/main.h new file mode 100644 index 0000000..b362470 --- /dev/null +++ b/examples/spl-uart/src/main.h @@ -0,0 +1,63 @@ +/** + ****************************************************************************** + * @file UART1_Interrupt\main.h + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file contains the external declaration of main.c file. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +/* Includes ------------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +#define TxBufferSize1 (countof(TxBuffer1) - 1) +#define TxBufferSize2 (countof(TxBuffer2) - 1) +#define RxBufferSize1 TxBufferSize2 +#define RxBufferSize2 TxBufferSize1 + +/* Private macro -------------------------------------------------------------*/ +#define countof(a) (sizeof(a) / sizeof(*(a))) + +/* Exported functions ------------------------------------------------------- */ +uint8_t GetVar_TxCounter1(void); +uint8_t IncrementVar_TxCounter1(void); +uint8_t GetVar_TxCounter2(void); +uint8_t IncrementVar_TxCounter2(void); +uint8_t GetVar_RxCounter1(void); +uint8_t IncrementVar_RxCounter1(void); +uint8_t GetVar_RxCounter2(void); +uint8_t IncrementVar_RxCounter2(void); +uint8_t GetVar_NbrOfDataToTransfer1(void); +uint8_t GetVar_NbrOfDataToTransfer2(void); +uint8_t GetVar_NbrOfDataToRead1(void); +uint8_t GetVar_NbrOfDataToRead2(void); + + +#endif /* __MAIN_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-uart/src/readme.txt b/examples/spl-uart/src/readme.txt new file mode 100644 index 0000000..734f8ea --- /dev/null +++ b/examples/spl-uart/src/readme.txt @@ -0,0 +1,94 @@ +/** @page UART1_Interrupt Communication between UART1 and UART3 using interrupts + + @verbatim + ******************** (C)COPYRIGHT 2014 STMicroelectronics ******************* + * @file UART1/UART1_Interrupt/readme.txt + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief Description of the communication between UART1 and UART3 using + * interrupts Example. + ****************************************************************************** + * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + @endverbatim + + @par Example description + + This example provides a basic communication between UART1 and UART3 using interrupts. + UART3 sends TxBuffer2 to UART1 which sends TxBuffer1 to UART3. The data received + by UART1 and UART3 are stored respectively in RxBuffer1 and RxBuffer2. The data + transfer is managed in UART1_TX_IRQHandler,UART1_RX_IRQHandler,UART3_TX_IRQHandler + and UART3_RX_IRQHandler in stm8s_it.c file. + + + The UART1 and UART3 are configured as follows: + - BaudRate = 9600 baud + - Word Length = 8 Bits + - One Stop Bit + - No parity + - Receive and transmit enabled + - UART1 Clock disabled + + + @par Directory contents + + - UART1\UART1_Interrupt\main.c Main file containing the "main" function + - UART1\UART1_Interrupt\main.h Main functions prototype + - UART1\UART1_Interrupt\stm8s_conf.h Library Configuration file + - UART1\UART1_Interrupt\stm8s_it.c Interrupt routines source + - UART1\UART1_Interrupt\stm8s_it.h Interrupt routines declaration + + + @par Hardware and Software environment + + - This example runs on STM8S and STM8A High density devices only. + + - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation + board and can be easily tailored to any other development board. + + - STM8/128-EVAL Set-up + - Connect UART1_Tx(PA.05) to UART3_Rx(PD.06) and UART1_Rx(PA.04) to UART3_Tx(PD.05) + or connect a null-modem female/female RS232 cable between CN15 and CN13. + + + @par How to use it ? + + In order to make the program work, you must do the following : + + - Copy all source files from this example folder to the template folder under + Project\Template + - Open your preferred toolchain + - Rebuild all files and load your image into target memory + - Run the example + - Communication result in Receiver/ Transmitter modes can be checked respectively + via TransferStatus2 and TransferStatus1 variables. + + @note + - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax, + STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory + density ranges between 32 to 128 Kbytes + - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68, + STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory + density ranges between 8 to 32 Kbytes + - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers + where the Flash memory density ranges between 32 to 128 Kbytes. + - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers + where the Flash memory density ranges between 16 to 32-Kbytes. + - Low-Density STM8S devices are the STM8S103xx, STM8S003, STM8S001 and STM8S903xx microcontrollers + where the Flash density is 8 Kbytes. + + *

© COPYRIGHT STMicroelectronics

+ */ diff --git a/examples/spl-uart/src/stm8s_conf.h b/examples/spl-uart/src/stm8s_conf.h new file mode 100644 index 0000000..d5a9c6a --- /dev/null +++ b/examples/spl-uart/src/stm8s_conf.h @@ -0,0 +1,118 @@ +/** + ****************************************************************************** + * @file stm8s_conf.h + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file is used to configure the Library. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* SDCC patch: include "STM8AF622x" defined in "STM8S_StdPeriph_Tempate" */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM8S_CONF_H +#define __STM8S_CONF_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" + +/* Uncomment the line below to enable peripheral header file inclusion */ +#if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) ||\ + defined(STM8S001) || defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x) +#include "stm8s_adc1.h" +#endif /* (STM8S105) ||(STM8S103) || (STM8S001) || (STM8S903) || (STM8AF626x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\ + defined (STM8AF62Ax) + #include "stm8s_adc2.h" +#endif /* (STM8S208) || (STM8S207) || (STM8AF62Ax) || (STM8AF52Ax) */ +#include "stm8s_awu.h" +#include "stm8s_beep.h" +#if defined (STM8S208) || defined (STM8AF52Ax) + #include "stm8s_can.h" +#endif /* (STM8S208) || (STM8AF52Ax) */ +#include "stm8s_clk.h" +#include "stm8s_exti.h" +#include "stm8s_flash.h" +#include "stm8s_gpio.h" +#include "stm8s_i2c.h" +#include "stm8s_itc.h" +#include "stm8s_iwdg.h" +#include "stm8s_rst.h" +#include "stm8s_spi.h" +#include "stm8s_tim1.h" +#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim2.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) ||\ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + #include "stm8s_tim3.h" +#endif /* (STM8S208) || (STM8S207) || (STM8S007) || (STM8S105) */ +#if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim4.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S903) || defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_tim5.h" + #include "stm8s_tim6.h" +#endif /* (STM8S903) || (STM8AF622x) */ +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) ||\ + defined(STM8S003) || defined(STM8S001) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + #include "stm8s_uart1.h" +#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S001) || (STM8S903) || (STM8AF52Ax) || (STM8AF62Ax) */ +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + #include "stm8s_uart2.h" +#endif /* (STM8S105) || (STM8AF626x) */ +#if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\ + defined (STM8AF62Ax) + #include "stm8s_uart3.h" +#endif /* (STM8S208) || (STM8S207) || (STM8AF52Ax) || (STM8AF62Ax) */ +#if defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ + #include "stm8s_uart4.h" +#endif /* (STM8AF622x) */ +#include "stm8s_wwdg.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Uncomment the line below to expanse the "assert_param" macro in the + Standard Peripheral Library drivers code */ +#define USE_FULL_ASSERT (1) + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT + +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval : None + */ +#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t* file, uint32_t line); +#else +#define assert_param(expr) ((void)0) +#endif /* USE_FULL_ASSERT */ + +#endif /* __STM8S_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-uart/src/stm8s_it.c b/examples/spl-uart/src/stm8s_it.c new file mode 100644 index 0000000..26bd487 --- /dev/null +++ b/examples/spl-uart/src/stm8s_it.c @@ -0,0 +1,546 @@ +/** + ****************************************************************************** + * @file stm8s_it.c + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief Main Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s_it.h" +#include "main.h" + +/** @addtogroup UART1_Interrupt + * @{ + */ +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +extern uint8_t TxBuffer1[]; +extern uint8_t TxBuffer2[]; +extern uint8_t RxBuffer1[]; +extern uint8_t RxBuffer2[]; +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ +/* Public functions ----------------------------------------------------------*/ +extern void Delay (uint16_t nCount); + + +#ifdef _COSMIC_ +/** + * @brief Dummy interrupt routine + * @param None + * @retval None + */ +@far @interrupt void NonHandledInterrupt(void) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief TRAP interrupt routine + * @param None + * @retval None + */ +@far @interrupt void TRAP_IRQHandler(void) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#else /*_RAISONANCE_*/ + +/** + * @brief TRAP interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*_COSMIC_*/ + +/** + * @brief Top Level Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(TLI_IRQHandler, 0) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Auto Wake Up Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(AWU_IRQHandler, 1) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Clock Controller Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(CLK_IRQHandler, 2) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTA Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTB Interrupt routine + * @param None + * @retval None + */ +INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTC Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTD Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief External Interrupt PORTE Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#ifdef STM8S903 +/** + * @brief External Interrupt PORTF Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +#ifdef STM8S208 +/** + * @brief CAN RX Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief CAN TX Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208 || STM8AF52Ax */ + +/** + * @brief SPI Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(SPI_IRQHandler, 10) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer1 Capture/Compare Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#ifdef STM8S903 +/** + * @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +/** + * @brief Timer5 Capture/Compare Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ +/** + * @brief Timer2 Update/Overflow/Break Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer2 Capture/Compare Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8AF626x) +/** + * @brief Timer3 Update/Overflow/Break Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief Timer3 Capture/Compare Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined(STM8AF62Ax) || defined(STM8AF52Ax) || defined(STM8S903) +/** + * @brief UART1 TX Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17) +{ + /* Write one byte to the transmit data register */ + UART1_SendData8(TxBuffer1[IncrementVar_TxCounter1()]); + + if (GetVar_TxCounter1() == GetVar_NbrOfDataToTransfer1()) + { + /* Disable the UART1 Transmit interrupt */ + UART1_ITConfig(UART1_IT_TXE, DISABLE); + } +} + +/** + * @brief UART1 RX Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18) +{ + /* Read one byte from the receive data register */ + RxBuffer1[IncrementVar_RxCounter1()] = UART1_ReceiveData8(); + + if (GetVar_RxCounter1() == GetVar_NbrOfDataToRead1()) + { + /* Disable the UART1 Receive interrupt */ + UART1_ITConfig(UART1_IT_RXNE_OR, DISABLE); + } +} +#endif /*STM8S105*/ + +/** + * @brief I2C Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(I2C_IRQHandler, 19) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) +/** + * @brief UART2 TX interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @brief UART2 RX interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /* STM8S105*/ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +/** + * @brief UART3 TX interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20) +{ + /* Write one byte to the transmit data register */ + UART3_SendData8(TxBuffer2[IncrementVar_TxCounter2()]); + + if (GetVar_TxCounter2() == GetVar_NbrOfDataToTransfer2()) + { + /* Disable the UART3 Transmit interrupt */ + UART3_ITConfig(UART3_IT_TXE, DISABLE); + } +} + +/** + * @brief UART3 RX interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21) +{ + /* Read one byte from the receive data register */ + RxBuffer2[IncrementVar_RxCounter2()] = UART3_ReceiveData8(); + + if (GetVar_RxCounter2() == GetVar_NbrOfDataToRead2()) + { + /* Disable the UART1 Receive interrupt */ + UART3_ITConfig(UART3_IT_RXNE_OR, DISABLE); + } +} +#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) +/** + * @brief ADC2 interrupt routine. + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(ADC2_IRQHandler, 22) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */ +/** + * @brief ADC1 interrupt routine. + * @param None + * @retval None + */ + INTERRUPT_HANDLER(ADC1_IRQHandler, 22) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ + +#ifdef STM8S903 +/** + * @brief Timer6 Update/Overflow/Trigger Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8S001 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ +/** + * @brief Timer4 Update/Overflow Interrupt routine + * @param None + * @retval + * None + */ + INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} +#endif /*STM8S903*/ + +/** + * @brief Eeprom EEC Interrupt routine + * @param None + * @retval + * None + */ +INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24) +{ + /* In order to detect unexpected events during development, + it is recommended to set a breakpoint on the following instruction. + */ +} + +/** + * @} + */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file diff --git a/examples/spl-uart/src/stm8s_it.h b/examples/spl-uart/src/stm8s_it.h new file mode 100644 index 0000000..46aac46 --- /dev/null +++ b/examples/spl-uart/src/stm8s_it.h @@ -0,0 +1,201 @@ +/** + ****************************************************************************** + * @file stm8s_it.h + * @author MCD Application Team + * @version V2.0.4 + * @date 26-April-2018 + * @brief This file contains the headers of the interrupt handlers + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2014 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 + * + * 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM8S_IT_H +#define __STM8S_IT_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm8s.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ +#ifdef _COSMIC_ + void _stext(void); /* RESET startup routine */ + INTERRUPT void NonHandledInterrupt(void); +#endif /* _COSMIC_ */ + +// SDCC patch: requires separate handling for SDCC (see below) +#if !defined(_RAISONANCE_) && !defined(_SDCC_) + INTERRUPT void TRAP_IRQHandler(void); /* TRAP */ + INTERRUPT void TLI_IRQHandler(void); /* TLI */ + INTERRUPT void AWU_IRQHandler(void); /* AWU */ + INTERRUPT void CLK_IRQHandler(void); /* CLOCK */ + INTERRUPT void EXTI_PORTA_IRQHandler(void); /* EXTI PORTA */ + INTERRUPT void EXTI_PORTB_IRQHandler(void); /* EXTI PORTB */ + INTERRUPT void EXTI_PORTC_IRQHandler(void); /* EXTI PORTC */ + INTERRUPT void EXTI_PORTD_IRQHandler(void); /* EXTI PORTD */ + INTERRUPT void EXTI_PORTE_IRQHandler(void); /* EXTI PORTE */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void EXTI_PORTF_IRQHandler(void); /* EXTI PORTF */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined (STM8AF52Ax) + INTERRUPT void CAN_RX_IRQHandler(void); /* CAN RX */ + INTERRUPT void CAN_TX_IRQHandler(void); /* CAN TX/ER/SC */ +#endif /* (STM8S208) || (STM8AF52Ax) */ + + INTERRUPT void SPI_IRQHandler(void); /* SPI */ + INTERRUPT void TIM1_CAP_COM_IRQHandler(void); /* TIM1 CAP/COM */ + INTERRUPT void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void); /* TIM1 UPD/OVF/TRG/BRK */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void); /* TIM5 UPD/OVF/BRK/TRG */ + INTERRUPT void TIM5_CAP_COM_IRQHandler(void); /* TIM5 CAP/COM */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + INTERRUPT void TIM2_UPD_OVF_BRK_IRQHandler(void); /* TIM2 UPD/OVF/BRK */ + INTERRUPT void TIM2_CAP_COM_IRQHandler(void); /* TIM2 CAP/COM */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + INTERRUPT void TIM3_UPD_OVF_BRK_IRQHandler(void); /* TIM3 UPD/OVF/BRK */ + INTERRUPT void TIM3_CAP_COM_IRQHandler(void); /* TIM3 CAP/COM */ +#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + +#if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined(STM8AF52Ax) || defined(STM8AF62Ax) || defined(STM8S903) + INTERRUPT void UART1_TX_IRQHandler(void); /* UART1 TX */ + INTERRUPT void UART1_RX_IRQHandler(void); /* UART1 RX */ +#endif /* (STM8S208) || (STM8S207) || (STM8S007) || (STM8S103) || (STM8S003) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8S903) */ + +#if defined (STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void UART4_TX_IRQHandler(void); /* UART4 TX */ + INTERRUPT void UART4_RX_IRQHandler(void); /* UART4 RX */ +#endif /* (STM8AF622x) */ + + INTERRUPT void I2C_IRQHandler(void); /* I2C */ + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + INTERRUPT void UART2_RX_IRQHandler(void); /* UART2 RX */ + INTERRUPT void UART2_TX_IRQHandler(void); /* UART2 TX */ +#endif /* (STM8S105) || (STM8S005) || (STM8AF626x) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT void UART3_RX_IRQHandler(void); /* UART3 RX */ + INTERRUPT void UART3_TX_IRQHandler(void); /* UART3 TX */ +#endif /* (STM8S207) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT void ADC2_IRQHandler(void); /* ADC2 */ +#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */ + INTERRUPT void ADC1_IRQHandler(void); /* ADC1 */ +#endif /* (STM8S207) || (STM8S007) || (STM8S208) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined(STM8S903) || defined(STM8AF622x) // SDCC patch: add STM8AF622x + INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */ +#else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ + INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */ +#endif /* (STM8S903) || (STM8AF622x) */ + INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */ + + +// SDCC patch: __interrupt keyword required after function name --> requires new block +#elif defined (_SDCC_) + + INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler); /* TRAP */ + INTERRUPT_HANDLER(TLI_IRQHandler, 0); /* TLI */ + INTERRUPT_HANDLER(AWU_IRQHandler, 1); /* AWU */ + INTERRUPT_HANDLER(CLK_IRQHandler, 2); /* CLOCK */ + INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3); /* EXTI PORTA */ + INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4); /* EXTI PORTB */ + INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5); /* EXTI PORTC */ + INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6); /* EXTI PORTD */ + INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7); /* EXTI PORTE */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8); /* EXTI PORTF */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined (STM8AF52Ax) + INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8); /* CAN RX */ + INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9); /* CAN TX/ER/SC */ +#endif /* (STM8S208) || (STM8AF52Ax) */ + + INTERRUPT_HANDLER(SPI_IRQHandler, 10); /* SPI */ + INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11); /* TIM1 UPD/OVF/TRG/BRK */ + INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12); /* TIM1 CAP/COM */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13); /* TIM5 UPD/OVF/BRK/TRG */ + INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14); /* TIM5 CAP/COM */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13); /* TIM2 UPD/OVF/BRK */ + INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14); /* TIM2 CAP/COM */ +#endif /* (STM8S903) || (STM8AF622x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ + defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) + INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15); /* TIM3 UPD/OVF/BRK */ + INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16); /* TIM3 CAP/COM */ +#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ + +#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ + defined(STM8S003) || defined(STM8S001) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903) + INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17); /* UART1 TX */ + INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18); /* UART1 RX */ +#endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8S001) || (STM8AF52Ax) || (STM8AF62Ax) */ + +#if defined (STM8AF622x) + INTERRUPT_HANDLER(UART4_TX_IRQHandler, 17); /* UART4 TX */ + INTERRUPT_HANDLER(UART4_RX_IRQHandler, 18); /* UART4 RX */ +#endif /* (STM8AF622x) */ + + INTERRUPT_HANDLER(I2C_IRQHandler, 19); /* I2C */ + +#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) + INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20); /* UART2 TX */ + INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21); /* UART2 RX */ +#endif /* (STM8S105) || (STM8AF626x) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT_HANDLER(UART3_RX_IRQHandler, 20); /* UART3 RX */ + INTERRUPT_HANDLER(UART3_TX_IRQHandler, 21); /* UART3 TX */ +#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ + +#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) + INTERRUPT_HANDLER(ADC2_IRQHandler, 22); /* ADC2 */ +#else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */ + INTERRUPT_HANDLER(ADC1_IRQHandler, 22); /* ADC1 */ +#endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ + +#if defined(STM8S903) || defined(STM8AF622x) + INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23); /* TIM6 UPD/OVF/TRG */ +#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */ + INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23); /* TIM4 UPD/OVF */ +#endif /* (STM8S903) || (STM8AF622x) */ + INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24); /* EEPROM ECC CORRECTION */ + +#endif /* !(_RAISONANCE_) && !(_SDCC_) */ + +#endif /* __STM8S_IT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/examples/spl-uart/test/README b/examples/spl-uart/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/examples/spl-uart/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/platform.json b/platform.json index 5fb99d6..04c2201 100644 --- a/platform.json +++ b/platform.json @@ -21,13 +21,40 @@ "arduino": { "package": "framework-arduinoststm8", "script": "builder/frameworks/arduino.py" + }, + "spl": { + "package": "framework-ststm8spl", + "script": "builder/frameworks/spl.py" } }, "packages": { + "toolchain-sdcc": { + "type": "toolchain", + "version": "~1.30804.10766" + }, "framework-arduinoststm8": { "type": "framework", "optional": true, - "version": "*" + "version": "0.40.181216" + }, + "framework-ststm8spl": { + "type": "framework", + "optional": true, + "version": "0.20301.181217" + }, + "tool-stm8binutils": { + "type": "uploader", + "version": "0.230.0" + }, + "tool-stm8tools": { + "type": "uploader", + "optional": true, + "version": "~0.40.181218" + }, + "tool-openocd": { + "type": "uploader", + "optional": true, + "version": "~1.1000.0" } } } From a6b5b331cbfaf43161a205758603ce636d739fd7 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 20 Dec 2018 01:01:23 +0200 Subject: [PATCH 3/8] Fix typo with "spl-blink" example --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index efaebc3..7167233 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ environment: - PLATFORMIO_PROJECT_DIR: "examples/arduino-fade-all-pins" - PLATFORMIO_PROJECT_DIR: "examples/arduino-internal-lib" - PLATFORMIO_PROJECT_DIR: "examples/arduino-ping-hc04" - - PLATFORMIO_PROJECT_DIR: "examples/spl-blink4" + - PLATFORMIO_PROJECT_DIR: "examples/spl-blink" - PLATFORMIO_PROJECT_DIR: "examples/spl-flash" - PLATFORMIO_PROJECT_DIR: "examples/spl-uart" From 33922672e4a76daf708e5e74f9e7cfc869e6945a Mon Sep 17 00:00:00 2001 From: valeros Date: Thu, 20 Dec 2018 22:03:50 +0200 Subject: [PATCH 4/8] Remove unsupported boards from spl-blink example --- examples/spl-blink/platformio.ini | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/examples/spl-blink/platformio.ini b/examples/spl-blink/platformio.ini index 3255b15..10ae4d6 100644 --- a/examples/spl-blink/platformio.ini +++ b/examples/spl-blink/platformio.ini @@ -12,11 +12,6 @@ platform = ststm8 framework = spl board = stm8sdisco -[env:stm8sblue] -platform = ststm8 -framework = spl -board = stm8sblue - [env:s8uno] platform = ststm8 framework = spl @@ -26,8 +21,3 @@ board = s8uno platform = ststm8 framework = spl board = mb208 - -[env:stm8sblack] -platform = ststm8 -framework = spl -board = stm8sblack From 1b8996ce9f54f257016bcb808154355b168e6cc8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 21 Dec 2018 17:11:12 +0200 Subject: [PATCH 5/8] Fix warning about "Unknown upload protocol custom" --- builder/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/main.py b/builder/main.py index 926ed54..ae8ce05 100644 --- a/builder/main.py +++ b/builder/main.py @@ -159,7 +159,7 @@ def _ldflags_for_hex(env, ldflags): upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] # custom upload tool -elif "UPLOADCMD" in env: +elif upload_protocol == "custom": upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] else: @@ -171,4 +171,4 @@ def _ldflags_for_hex(env, ldflags): # Setup default targets # -Default([target_buildprog, target_size]) \ No newline at end of file +Default([target_buildprog, target_size]) From 5ecb227de4b155fff9dadcb52da3ea3ebe5a5437 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 27 Dec 2018 02:48:47 +0200 Subject: [PATCH 6/8] Text examples with Python 3 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8e88666..21b107b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: - "2.7" + - "3.5" env: - PLATFORMIO_PROJECT_DIR=examples/arduino-fade-all-pins From b3644cae3f49d222c221891964068e879b8fe62b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 11 Jan 2019 14:02:20 +0200 Subject: [PATCH 7/8] Update compatible PlatformIO Core engine to <5 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 04c2201..26e7496 100644 --- a/platform.json +++ b/platform.json @@ -6,7 +6,7 @@ "homepage": "http://platformio.org/platforms/ststm8", "license": "Apache-2.0", "engines": { - "platformio": "^3.0.0" + "platformio": "<5" }, "repository": { "type": "git", From 102081cefa86ec5c2ef454120d3c6e223d1d76ff Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 11 Jan 2019 16:43:09 +0200 Subject: [PATCH 8/8] Bump version to 1.0.0 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 26e7496..31ad74f 100644 --- a/platform.json +++ b/platform.json @@ -12,7 +12,7 @@ "type": "git", "url": "https://github.com/platformio/platform-ststm8.git" }, - "version": "0.0.0", + "version": "1.0.0", "packageRepositories": [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "http://dl.platformio.org/packages/manifest.json"