diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..eccf785ca --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# top-most EditorConfig file +root = true + +# Common file settings. +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..ac8b40f23 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,72 @@ +Contributing +============ + +We appreciate your contributions! Because this is an open source project, we want to keep it as easy +as possible to contribute changes. However, we need contributors to follow a few guidelines. + + +## Requirements + +There are a few architectural requirements that must be followed by contributed changes. + +- Target-specific code is not allowed in common source files. Specifically, this means that you + may not introduce `#ifdefs` for the target or HIC into common code. +- If you need to implement a target-specific feature that would require changes to common code, you + must first add a hook mechanism to the common code that allows your target-specific feature to + be implemented outside the common code (in a family or board source file). +- DAPLink makes extensive use of weak function and variable definitions as hooks to allow + target-specific builds to change behaviour. This is the preferred hook mechanism. +- Another option is to use a macro defined in the board yaml to override a default. In such a + design, there must be a reasonable default if the macro is not set. + + +## Coding style + +Contributed source code must match the existing style of the DAPLink code base. + +The key requirements are: +- 4 space indents, no tabs are allowed. +- No trailing whitespace. +- All source files must end with a newline (an empty line at the end). +- Lines should generally not be longer than 120 characters, though this is not a hard rule. +- Braces generally follow the K&R style. +- Single-statement blocks for **if**, **else**, **do**, **while**, and **for** statements must be + enclosed in braces. +- Spaces are required between keywords and parentheses, and around operators. +- All functions require prototypes. +- Macros must be all uppercase. +- Functions should be all lowercase with underscores between words (sometimes called snake case). +- Types must be all lowercase, underscores between words, and have a `_t` suffix. +- Enumerations must start with `k` and use camel case, e.g. `kHardwareReset`. +- Code must be well commented and use Doxygen-style documentation comments for all declarations. + +For other style questions, please look to the existing code for answers. + + +## License + +By creating a pull request on GitHub, you are granting license your contributions under the same +Apache 2.0 license as the original code. However, you still own the copyright to your contributions. +You may add your copyright below the Arm copyright in the license header at the top of the source +file. If a file is newly added by you, it must contain the standard license header, but it does not +require an Arm copyright. Please note that we do not list changes in each source file by copyright +owner, as this becomes a burden to maintain. + + +## Process + +Please create a pull request in GitHub with your contribution. Before creating the pull request, +please ensure that your code meets the requirements listed above and all tests pass. We also run the +tests on a wide range of boards for every pull request using our CI setup. Changes must pass on all +tested boards before the the pull request can be merged. + +The [developers' guide](docs/DEVELOPERS-GUIDE.md) describes how to create your development +environment. The [automated tests guide](docs/AUTOMATED_TESTS.md) provides information about the +available types of tests and describes how to run the tests. + + +## More + +For more information about contributing, see the Mbed OS [contributor +documentation](http://os.mbed.com/contributing). Although this documentation is written primarily +with Mbed OS in mind, much of it applies directly to DAPLink, as well. diff --git a/LICENSE b/LICENSE index 97df0e645..d09782093 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,167 @@ -Unless specifically indicated otherwise in a file, files are licensed -under the Apache 2.0 license, as can be found in: apache-2.0.txt \ No newline at end of file +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: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +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 +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. + +END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md index 77eaa93fa..d45a54091 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,22 @@ There are many ARM microcontroller-based Hardware Interface Circuits (HICs) that There are many board builds (board = HIC + target combination) created from this repository. Quarterly releases will contain new features and bugfixes. Standalone bugfixes are released once reported, verified and fixed. Both quarterly and bugfix releases will result in the build number being incremented. Many development kits and products ship with DAPLink interface firmware or are capable of running DAPLink firmware. **[The current release builds and instructions for updating DAPLink interface firmware is hosted on the DAPLink release site.](https://armmbed.github.io/DAPLink/)** Release notes and previous release builds can be found under GitHub releases. ## Contribute -Look for an interesting feature or defect [under issues](https://github.com/ARMmbed/DAPLink/issues) or start a new thread to engage with the developers and maintainers. You must sign the [contributor agreement](https://os.mbed.com/contributor_agreement/) before any contributions can be accepted. + +We welcome contributions to DAPLink in any area. Look for an interesting feature or defect [under +issues](https://github.com/ARMmbed/DAPLink/issues), or start a new thread to engage with the +developers and maintainers. + +Please see the [contribution guidelines](CONTRIBUTING.md) for detailed requirements for +contributions. + +To report bugs, please [create an issue](https://github.com/ARMmbed/DAPLink/issues/new) in the +GitHub project. ## Develop Information for setting up a development environment, running the tests or creating a release build [can be found in the developers guide.](docs/DEVELOPERS-GUIDE.md) + +## License +DAPLink is licensed with the permissive Apache 2.0 license. See the [LICENSE](LICENSE) file for the +full text of the license. + +Copyright © 2006-2019 Arm Ltd diff --git a/apache-2.0.txt b/apache-2.0.txt deleted file mode 100644 index 2b6a74a12..000000000 --- a/apache-2.0.txt +++ /dev/null @@ -1,181 +0,0 @@ -In addition to any license you have otherwise agreed to, parts of this software are licensed under the terms of the Apache Software License, 2.0. Please refer to license headers in the individual files. - -Copyright (c) 2009-2016 ARM Limited - - 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. - - END OF TERMS AND CONDITIONS diff --git a/docs/DEVELOPERS-GUIDE.md b/docs/DEVELOPERS-GUIDE.md index 71f1afa4f..ae962454d 100644 --- a/docs/DEVELOPERS-GUIDE.md +++ b/docs/DEVELOPERS-GUIDE.md @@ -37,7 +37,7 @@ $ venv/Scripts/activate.bat (For Windows) $ pip install -r requirements.txt $ mbed deploy $ mbed config root . -$ mbed config ARM_PATH FULL_PATH_TO_ARMCC_FOLDER +$ mbed config ARM_PATH FULL_PATH_TO_ARMCC_FOLDER $ tools/mbedcli_compile.py project1 project2 project3 --clean $ venv/Scripts/deactivate ``` @@ -50,11 +50,12 @@ Valid project names are listed on help. ### Features - Support both Python 2.x and 3.x versions. -- Can compile a list of projects or the all of the projects. +- Can compile a list of projects or the all of the projects. - Can generate the release directory with one command. ### Prerequisite -mbedcli should be included in the python package or requirements.txt. Currently requirement3.txt contains the list of python packages needed to be able to compile in the mbedcli environment. +mbedcli is included in `requirements.txt`, so it will be installed automatically when configuring +your development environment. ### mbedcli_compile.py script Arguments diff --git a/projects.yaml b/projects.yaml index 5957d293e..411362396 100644 --- a/projects.yaml +++ b/projects.yaml @@ -20,6 +20,7 @@ module: - records/daplink/settings.yaml - records/daplink/settings_rom_stub.yaml - records/daplink/target_board.yaml + - records/rtos/rtos-none.yaml if: &module_if - *module_tools - records/usb/usb-core.yaml @@ -68,7 +69,7 @@ module: projects: kl26z_bl: - *module_bl - - *module_hic_kl26z + - records/hic_hal/kl26z.yaml - records/board/kl26z_bl.yaml kl26z_if: - *module_if @@ -76,35 +77,51 @@ projects: - records/family/all_family.yaml k20dx_bl: - *module_bl - - *module_hic_k20dx + - records/hic_hal/k20dx.yaml - records/board/k20dx_bl.yaml k20dx_if: - *module_if - *module_hic_k20dx - records/family/all_family.yaml + k26f_bl: + - *module_bl + - records/hic_hal/k26f.yaml + - records/board/k26f_bl.yaml + k26f_if: + - *module_if + - *module_hic_k26f + - records/family/all_family.yaml lpc11u35_if: - *module_if - *module_hic_lpc11u35 - records/family/all_family.yaml lpc4322_bl: - *module_bl - - *module_hic_lpc4322 + - records/hic_hal/lpc4322.yaml - records/board/lpc4322_bl.yaml lpc4322_if: - *module_if - *module_hic_lpc4322 - records/family/all_family.yaml - k26f_bl: + max32620_bl: - *module_bl - - *module_hic_k26f - - records/board/k26f_bl.yaml - k26f_if: + - records/hic_hal/max32620.yaml + - records/board/max32620_bl.yaml + max32620_if: - *module_if - - *module_hic_k26f + - *module_hic_max32620 + - records/family/all_family.yaml + max32625_bl: + - *module_bl + - records/hic_hal/max32625.yaml + - records/board/max32625_bl.yaml + max32625_if: + - *module_if + - *module_hic_max32625 - records/family/all_family.yaml sam3u2c_bl: - *module_bl - - *module_hic_sam3u2c + - records/hic_hal/sam3u2c.yaml - records/board/sam3u2c_bl.yaml sam3u2c_if: - *module_if @@ -112,12 +129,8 @@ projects: - records/family/all_family.yaml stm32f103xb_bl: - *module_bl - - *module_hic_stm32f103xb + - records/hic_hal/stm32f103xb.yaml - records/board/stm32f103xb_bl.yaml - max32625_bl: - - *module_bl - - *module_hic_max32625 - - records/board/max32625_bl.yaml stm32f103xb_if: - *module_if - *module_hic_stm32f103xb @@ -570,18 +583,10 @@ projects: - *module_if - *module_hic_lpc11u35 - records/board/mtb_stm32f439.yaml - max32620_bl: - - *module_bl - - *module_hic_max32620 - - records/board/max32620_bl.yaml max32620_max32625mbed_if: - *module_if - *module_hic_max32620 - records/board/max32625mbed.yaml - max32620_if: - - *module_if - - *module_hic_max32620 - - records/family/all_family.yaml max32625_max32620fthr_if: - *module_if - *module_hic_max32625 @@ -590,7 +595,3 @@ projects: - *module_if - *module_hic_max32625 - records/board/max32630fthr.yaml - max32625_if: - - *module_if - - *module_hic_max32625 - - records/family/all_family.yaml diff --git a/records/hic_hal/k20dx.yaml b/records/hic_hal/k20dx.yaml index b573f09f6..5b3aa41b0 100644 --- a/records/hic_hal/k20dx.yaml +++ b/records/hic_hal/k20dx.yaml @@ -10,6 +10,7 @@ common: - FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT=0 - FLASH_DRIVER_IS_FLASH_RESIDENT=1 - DAPLINK_NO_ASSERT_FILENAMES + - OS_CLOCK=48000000 includes: - source/hic_hal/freescale/k20dx - source/hic_hal/freescale/k20dx/MK20D5 diff --git a/records/hic_hal/k26f.yaml b/records/hic_hal/k26f.yaml index fb0f407c4..382a6142f 100644 --- a/records/hic_hal/k26f.yaml +++ b/records/hic_hal/k26f.yaml @@ -9,6 +9,7 @@ common: - DAPLINK_HIC_ID=0x97969909 # DAPLINK_HIC_ID_K26F - FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT=0 - FLASH_DRIVER_IS_FLASH_RESIDENT=1 + - OS_CLOCK=120000000 includes: - source/hic_hal/freescale/k26f - source/hic_hal/freescale/k26f/MK26F18 diff --git a/records/hic_hal/kl26z.yaml b/records/hic_hal/kl26z.yaml index b5639f4b9..eee977a79 100644 --- a/records/hic_hal/kl26z.yaml +++ b/records/hic_hal/kl26z.yaml @@ -10,6 +10,7 @@ common: - FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT=0 - FLASH_DRIVER_IS_FLASH_RESIDENT=1 - DAPLINK_NO_ASSERT_FILENAMES + - OS_CLOCK=48000000 includes: - source/hic_hal/freescale/kl26z - source/hic_hal/freescale/kl26z/MKL26Z4 diff --git a/records/hic_hal/lpc11u35.yaml b/records/hic_hal/lpc11u35.yaml index cdf54fe5f..c19dc0400 100644 --- a/records/hic_hal/lpc11u35.yaml +++ b/records/hic_hal/lpc11u35.yaml @@ -6,6 +6,7 @@ common: macros: - INTERFACE_LPC11U35 - DAPLINK_HIC_ID=0x97969902 # DAPLINK_HIC_ID_LPC11U35 + - OS_CLOCK=48000000 includes: - source/hic_hal/nxp/lpc11u35 - source/hic_hal/nxp/lpc11u35 diff --git a/records/hic_hal/lpc4322.yaml b/records/hic_hal/lpc4322.yaml index 497dda548..e094d19b9 100644 --- a/records/hic_hal/lpc4322.yaml +++ b/records/hic_hal/lpc4322.yaml @@ -8,6 +8,7 @@ common: - CORE_M4 - INTERNAL_FLASH - DAPLINK_HIC_ID=0x97969905 # DAPLINK_HIC_ID_LPC4322 + - OS_CLOCK=96000000 includes: - source/hic_hal/nxp/lpc4322 - source/hic_hal/nxp/lpc4322 diff --git a/records/hic_hal/max32620.yaml b/records/hic_hal/max32620.yaml index 72e4f742c..388a27656 100644 --- a/records/hic_hal/max32620.yaml +++ b/records/hic_hal/max32620.yaml @@ -6,6 +6,7 @@ common: macros: - INTERFACE_MAX32620 - DAPLINK_HIC_ID=0x97969904 # DAPLINK_HIC_ID_MAX32620 + - OS_CLOCK=96000000 includes: - source/hic_hal/maxim/max32620 sources: diff --git a/records/hic_hal/max32625.yaml b/records/hic_hal/max32625.yaml index 542a9f543..f6fcf178c 100644 --- a/records/hic_hal/max32625.yaml +++ b/records/hic_hal/max32625.yaml @@ -6,6 +6,7 @@ common: macros: - INTERFACE_MAX32625 - DAPLINK_HIC_ID=0x97969906 # DAPLINK_HIC_ID_MAX32625 + - OS_CLOCK=96000000 includes: - source/hic_hal/maxim/max32625 sources: diff --git a/records/hic_hal/sam3u2c.yaml b/records/hic_hal/sam3u2c.yaml index f825356c5..e80722a19 100644 --- a/records/hic_hal/sam3u2c.yaml +++ b/records/hic_hal/sam3u2c.yaml @@ -7,6 +7,7 @@ common: - INTERFACE_SAM3U2C - __SAM3U2C__ - DAPLINK_HIC_ID=0x97969903 # DAPLINK_HIC_ID_SAM3U2C + - OS_CLOCK=96000000 includes: - source/hic_hal/atmel/sam3u2c - source/hic_hal/atmel/sam3u2c diff --git a/records/hic_hal/stm32f103xb.yaml b/records/hic_hal/stm32f103xb.yaml index 6e7be9eeb..e828d5d5b 100644 --- a/records/hic_hal/stm32f103xb.yaml +++ b/records/hic_hal/stm32f103xb.yaml @@ -10,6 +10,7 @@ common: - DAPLINK_HIC_ID=0x97969908 # DAPLINK_HIC_ID_STM32F103XB - __packed=__packed # Prevent redefinition of __packed with ARMCC - DAPLINK_NO_ASSERT_FILENAMES + - OS_CLOCK=72000000 includes: - source/hic_hal/stm32/stm32f103xb - source/hic_hal/stm32/stm32f103xb/cmsis diff --git a/records/rtos/rtos-cm0.yaml b/records/rtos/rtos-cm0.yaml index caaee4e9c..79b3174f2 100644 --- a/records/rtos/rtos-cm0.yaml +++ b/records/rtos/rtos-cm0.yaml @@ -1,4 +1,6 @@ common: + macros: + - OS_TICK=10000 includes: - source/rtos sources: @@ -15,3 +17,5 @@ common: - source/rtos/rt_Task.c - source/rtos/rt_Time.c - source/rtos/rt_Timer.c + - source/rtos/RTX_Config.c + - source/rtos/cmsis_os2_port.c diff --git a/records/rtos/rtos-cm3.yaml b/records/rtos/rtos-cm3.yaml index 498b7544a..161f032db 100644 --- a/records/rtos/rtos-cm3.yaml +++ b/records/rtos/rtos-cm3.yaml @@ -1,4 +1,6 @@ common: + macros: + - OS_TICK=10000 includes: - source/rtos sources: @@ -15,3 +17,5 @@ common: - source/rtos/rt_Task.c - source/rtos/rt_Time.c - source/rtos/rt_Timer.c + - source/rtos/RTX_Config.c + - source/rtos/cmsis_os2_port.c diff --git a/records/rtos/rtos-cm4.yaml b/records/rtos/rtos-cm4.yaml index 5d5306887..7e231c5cc 100644 --- a/records/rtos/rtos-cm4.yaml +++ b/records/rtos/rtos-cm4.yaml @@ -1,4 +1,6 @@ common: + macros: + - OS_TICK=10000 includes: - source/rtos sources: @@ -15,3 +17,5 @@ common: - source/rtos/rt_Task.c - source/rtos/rt_Time.c - source/rtos/rt_Timer.c + - source/rtos/RTX_Config.c + - source/rtos/cmsis_os2_port.c diff --git a/records/rtos/rtos-none.yaml b/records/rtos/rtos-none.yaml new file mode 100644 index 000000000..2130ac23d --- /dev/null +++ b/records/rtos/rtos-none.yaml @@ -0,0 +1,8 @@ +common: + macros: + - OS_TICK=10000 + includes: + - source/rtos_none + sources: + rtos: + - source/rtos_none diff --git a/requirements.txt b/requirements.txt index 2e4478b87..242efea90 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ project_generator==0.9.13 -mbed_ls==1.6.2 +mbed-ls==1.6.2 pyserial pyOCD==0.16.0 requests @@ -7,7 +7,7 @@ intelhex six enum34 pyusb -mbed_cli==1.8.2 +mbed-cli==1.8.2 bs4 numpy pyelftools diff --git a/source/board/blueninja.c b/source/board/blueninja.c index c071ff580..8737ce0bc 100644 --- a/source/board/blueninja.c +++ b/source/board/blueninja.c @@ -18,7 +18,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include "cmsis_os2.h" #include "IO_Config.h" #include "swd_host.h" #include "target_family.h" @@ -29,7 +29,7 @@ static uint8_t target_set_state_by_board(TARGET_RESET_STATE state) if (RESET_PROGRAM == state) { LPC_GPIO->SET[PIN_PWH_PORT] = PIN_PWH; - os_dly_wait(10); + osDelay(10); } return 1; } diff --git a/source/board/microbit.c b/source/board/microbit.c index d1d4c590b..8d191c74d 100644 --- a/source/board/microbit.c +++ b/source/board/microbit.c @@ -21,7 +21,6 @@ #include "fsl_device_registers.h" #include "IO_Config.h" #include "DAP.h" -#include "RTL.h" #include "target_family.h" #include "target_board.h" @@ -71,7 +70,7 @@ static void prerun_board_config(void) { } // USB HID override function return 1 if the activity is trivial or response is null -uint8_t usbd_hid_no_activity(U8 *buf) +uint8_t usbd_hid_no_activity(uint8_t *buf) { if(buf[0] == ID_DAP_Vendor3 && buf[1] == 0) return 1; diff --git a/source/board/wizwiki_w7500.c b/source/board/wizwiki_w7500.c index dbefc85ab..299f9c6fe 100644 --- a/source/board/wizwiki_w7500.c +++ b/source/board/wizwiki_w7500.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "RTL.h" +#include "cmsis_os2.h" #include "target_family.h" #include "target_board.h" @@ -30,10 +30,10 @@ static uint8_t target_set_state_by_board(TARGET_RESET_STATE state) do { swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); } while(!swd_init_debug()); } return 1; diff --git a/source/board/wizwiki_w7500_eco.c b/source/board/wizwiki_w7500_eco.c index 923cbe9b4..efdc175cf 100644 --- a/source/board/wizwiki_w7500_eco.c +++ b/source/board/wizwiki_w7500_eco.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "RTL.h" +#include "cmsis_os2.h" #include "target_family.h" #include "target_board.h" @@ -30,10 +30,10 @@ static uint8_t target_set_state_by_board(TARGET_RESET_STATE state) do { swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); } while(!swd_init_debug()); } return 1; diff --git a/source/board/wizwiki_w7500p.c b/source/board/wizwiki_w7500p.c index a61a42705..446b3b513 100644 --- a/source/board/wizwiki_w7500p.c +++ b/source/board/wizwiki_w7500p.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "RTL.h" +#include "cmsis_os2.h" #include "target_family.h" #include "target_board.h" @@ -30,10 +30,10 @@ static uint8_t target_set_state_by_board(TARGET_RESET_STATE state) do { swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); } while(!swd_init_debug()); } return 1; diff --git a/source/daplink/bootloader/main.c b/source/daplink/bootloader/main.c index 963e95f8e..c153fc961 100644 --- a/source/daplink/bootloader/main.c +++ b/source/daplink/bootloader/main.c @@ -23,7 +23,7 @@ #include "gpio.h" #include "validation.h" #include "vfs_manager.h" -#include "RTL.h" +#include "cmsis_os2.h" #include "rl_usb.h" #include "settings.h" #include "info.h" @@ -66,7 +66,7 @@ __asm void modify_stack_pointer_and_start_app(uint32_t r0_sp, uint32_t r1_pc) main_usb_connect_t usb_state; // Reference to our main task -OS_TID main_task_id; +osThreadId_t main_task_id; static uint8_t msc_led_usb_activity = 0; static main_led_state_t msc_led_state = MAIN_LED_FLASH; @@ -74,27 +74,13 @@ static main_led_state_t msc_led_state = MAIN_LED_FLASH; static main_usb_busy_t usb_busy; static uint32_t usb_busy_count; -#define TIMER_TASK_30_PRIORITY (11) -#define TIMER_TASK_STACK (136) -static uint64_t stk_timer_task[TIMER_TASK_STACK / sizeof(uint64_t)]; - -#define MAIN_TASK_PRIORITY (10) -#define MAIN_TASK_STACK (800) -static uint64_t stk_main_task [MAIN_TASK_STACK / sizeof(uint64_t)]; - // Timer task, set flags every 30mS and 90mS -__task void timer_task_30mS(void) +void timer_task_30mS(void * arg) { - uint8_t i = 0; - os_itv_set(3); // 30mS - - while (1) { - os_itv_wait(); - os_evt_set(FLAGS_MAIN_30MS, main_task_id); - - if (!(i++ % 3)) { - os_evt_set(FLAGS_MAIN_90MS, main_task_id); - } + static uint32_t i = 0; + osThreadFlagsSet(main_task_id, FLAGS_MAIN_30MS); + if (!(i++ % 3)) { + osThreadFlagsSet(main_task_id, FLAGS_MAIN_90MS); } } @@ -108,10 +94,10 @@ void main_blink_msc_led(main_led_state_t state) void USBD_SignalHandler() { - isr_evt_set(FLAGS_MAIN_PROC_USB, main_task_id); + osThreadFlagsSet(main_task_id, FLAGS_MAIN_PROC_USB); } -__task void main_task(void) +void main_task(void * arg) { // State processing uint16_t flags; @@ -122,11 +108,11 @@ __task void main_task(void) if (config_ram_get_initial_hold_in_bl()) { // Delay for 1 second for VMs - os_dly_wait(100); + osDelay(100); } // Get a reference to this task - main_task_id = os_tsk_self(); + main_task_id = osThreadGetId(); // Set LED defaults gpio_set_hid_led(GPIO_LED_OFF); gpio_set_cdc_led(GPIO_LED_OFF); @@ -142,16 +128,16 @@ __task void main_task(void) usb_state = MAIN_USB_CONNECTING; usb_state_count = USB_CONNECT_DELAY; // Start timer tasks - os_tsk_create_user(timer_task_30mS, TIMER_TASK_30_PRIORITY, (void *)stk_timer_task, TIMER_TASK_STACK); + osTimerId_t tmr_id = osTimerNew(timer_task_30mS, osTimerPeriodic, NULL, NULL); + osTimerStart(tmr_id, 3); while (1) { // need to create a new event for programming failure - os_evt_wait_or(FLAGS_MAIN_90MS // 90mS tick - | FLAGS_MAIN_30MS // 30mS tick - | FLAGS_MAIN_PROC_USB // process usb events - , NO_TIMEOUT); - // Find out what event happened - flags = os_evt_get(); + flags = osThreadFlagsWait(FLAGS_MAIN_90MS // 90mS tick + | FLAGS_MAIN_30MS // 30mS tick + | FLAGS_MAIN_PROC_USB // process usb events + , osFlagsWaitAny, + osWaitForever); if (flags & FLAGS_MAIN_PROC_USB) { USBD_Handler(); @@ -217,7 +203,7 @@ __task void main_task(void) if (flags & FLAGS_MAIN_30MS) { if (msc_led_usb_activity) { - if((msc_led_state == MAIN_LED_FLASH) || (msc_led_state == MAIN_LED_FLASH_PERMANENT)){ + if ((msc_led_state == MAIN_LED_FLASH) || (msc_led_state == MAIN_LED_FLASH_PERMANENT)) { // Toggle LED value msc_led_value = (GPIO_LED_ON == msc_led_value) ? GPIO_LED_OFF : GPIO_LED_ON; // If in flash mode stop after one cycle but in bootloader LED stays on @@ -260,5 +246,8 @@ int main(void) // config the usb interface descriptor and web auth token before USB connects //unique_string_auth_config(); // either the rst pin was pressed or we have an empty app region - os_sys_init_user(main_task, MAIN_TASK_PRIORITY, stk_main_task, MAIN_TASK_STACK); + osKernelInitialize(); // Initialize CMSIS-RTOS + osThreadNew(main_task, NULL, NULL); // Create application main thread + osKernelStart(); // Start thread execution + for (;;) {} } diff --git a/source/daplink/cmsis-dap/DAP_vendor.c b/source/daplink/cmsis-dap/DAP_vendor.c index 8a68db74e..45bb8ae4d 100644 --- a/source/daplink/cmsis-dap/DAP_vendor.c +++ b/source/daplink/cmsis-dap/DAP_vendor.c @@ -25,7 +25,6 @@ * *---------------------------------------------------------------------------*/ -#include "RTL.h" #include "rl_usb.h" #include "DAP_config.h" #include "DAP.h" diff --git a/source/daplink/cmsis-dap/usbd_user_hid.c b/source/daplink/cmsis-dap/usbd_user_hid.c index a18095936..6058ff352 100644 --- a/source/daplink/cmsis-dap/usbd_user_hid.c +++ b/source/daplink/cmsis-dap/usbd_user_hid.c @@ -20,7 +20,6 @@ */ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb.h" #define __NO_USB_LIB_C diff --git a/source/daplink/daplink_debug.h b/source/daplink/daplink_debug.h index 7b73e8296..0101266ce 100644 --- a/source/daplink/daplink_debug.h +++ b/source/daplink/daplink_debug.h @@ -26,7 +26,7 @@ #include "stdio.h" #include "string.h" #include "stdint.h" -#include "RTL.h" +#include "cmsis_os2.h" #include "rl_usb.h" #include "macro.h" diff --git a/source/daplink/drag-n-drop/file_stream.c b/source/daplink/drag-n-drop/file_stream.c index ffa51fe5d..2ef69692d 100644 --- a/source/daplink/drag-n-drop/file_stream.c +++ b/source/daplink/drag-n-drop/file_stream.c @@ -27,7 +27,7 @@ #include "intelhex.h" #include "flash_decoder.h" #include "error.h" -#include "RTL.h" +#include "cmsis_os2.h" #include "compiler.h" #include "validation.h" @@ -89,14 +89,14 @@ static stream_state_t state = STREAM_STATE_CLOSED; static stream_t *current_stream = 0; // Thread variables (STUB these if RTX is not used) -static OS_TID stream_thread_tid = 0; +static osThreadId_t stream_thread_tid = 0; static void stream_thread_set(void) { - stream_thread_tid = os_tsk_self(); + stream_thread_tid = osThreadGetId(); } static void stream_thread_assert(void) { - util_assert(os_tsk_self() == stream_thread_tid); + util_assert(osThreadGetId() == stream_thread_tid); } stream_type_t stream_start_identify(const uint8_t *data, uint32_t size) diff --git a/source/daplink/drag-n-drop/flash_intf.h b/source/daplink/drag-n-drop/flash_intf.h index fbe8ae5b4..c1f55eeef 100644 --- a/source/daplink/drag-n-drop/flash_intf.h +++ b/source/daplink/drag-n-drop/flash_intf.h @@ -30,6 +30,13 @@ extern "C" { #endif +typedef enum { + FLASH_FUNC_NOP, + FLASH_FUNC_ERASE, + FLASH_FUNC_PROGRAM, + FLASH_FUNC_VERIFY +} flash_func_t; + typedef error_t (*flash_intf_init_cb_t)(void); typedef error_t (*flash_intf_uninit_cb_t)(void); typedef error_t (*flash_intf_program_page_cb_t)(uint32_t addr, const uint8_t *buf, uint32_t size); @@ -38,6 +45,7 @@ typedef error_t (*flash_intf_erase_chip_cb_t)(void); typedef uint32_t (*flash_program_page_min_size_cb_t)(uint32_t addr); typedef uint32_t (*flash_erase_sector_size_cb_t)(uint32_t addr); typedef uint8_t (*flash_busy_cb_t)(void); +typedef error_t (*flash_algo_set_cb_t)(uint32_t addr); typedef struct { flash_intf_init_cb_t init; @@ -48,6 +56,7 @@ typedef struct { flash_program_page_min_size_cb_t program_page_min_size; flash_erase_sector_size_cb_t erase_sector_size; flash_busy_cb_t flash_busy; + flash_algo_set_cb_t flash_algo_set; } flash_intf_t; // All flash interfaces. Unsupported interfaces are NULL. diff --git a/source/daplink/drag-n-drop/flash_manager.c b/source/daplink/drag-n-drop/flash_manager.c index 8ff256084..022e82695 100755 --- a/source/daplink/drag-n-drop/flash_manager.c +++ b/source/daplink/drag-n-drop/flash_manager.c @@ -321,6 +321,15 @@ static error_t setup_next_sector(uint32_t addr) current_write_block_addr = current_sector_addr; current_write_block_size = MIN(sector_size, sizeof(buf)); + //check flash algo every sector change, addresses with different flash algo should be sector aligned + if (intf->flash_algo_set) { + status = intf->flash_algo_set(current_sector_addr); + if (ERROR_SUCCESS != status) { + intf->uninit(); + return status; + } + } + if (page_erase_enabled) { // Erase the current sector status = intf->erase_sector(current_sector_addr); diff --git a/source/daplink/drag-n-drop/vfs_manager.c b/source/daplink/drag-n-drop/vfs_manager.c index 13ccb07a1..4b42e1131 100644 --- a/source/daplink/drag-n-drop/vfs_manager.c +++ b/source/daplink/drag-n-drop/vfs_manager.c @@ -23,7 +23,7 @@ #include "ctype.h" #include "main.h" -#include "RTL.h" +#include "cmsis_os2.h" #include "rl_usb.h" #include "virtual_fs.h" #include "vfs_manager.h" @@ -138,8 +138,8 @@ static vfs_mngr_state_t vfs_state; static vfs_mngr_state_t vfs_state_next; static uint32_t time_usb_idle; -static OS_MUT sync_mutex; -static OS_TID sync_thread = 0; +static osMutexId_t sync_mutex; +static osThreadId_t sync_thread = 0; // Synchronization functions static void sync_init(void); @@ -353,23 +353,23 @@ void usbd_msc_write_sect(uint32_t sector, uint8_t *buf, uint32_t num_of_sectors) static void sync_init(void) { - sync_thread = os_tsk_self(); - os_mut_init(&sync_mutex); + sync_thread = osThreadGetId(); + sync_mutex = osMutexNew(NULL); } static void sync_assert_usb_thread(void) { - util_assert(os_tsk_self() == sync_thread); + util_assert(osThreadGetId() == sync_thread); } static void sync_lock(void) { - os_mut_wait(&sync_mutex, 0xFFFF); + osMutexAcquire(sync_mutex, 0); } static void sync_unlock(void) { - os_mut_release(&sync_mutex); + osMutexRelease(sync_mutex); } static bool changing_state() diff --git a/source/daplink/error.c b/source/daplink/error.c index 7ac40c09f..9c2d89521 100644 --- a/source/daplink/error.c +++ b/source/daplink/error.c @@ -52,10 +52,14 @@ static const char *const error_message[] = { "The interface firmware FAILED to reset/halt the target MCU", // ERROR_ALGO_DL "The interface firmware FAILED to download the flash programming algorithms to the target MCU", + //ERROR_ALGO_MISSING + "The flash algo missing for a region", // ERROR_ALGO_DATA_SEQ "The interface firmware FAILED to download the flash data contents to be programmed", // ERROR_INIT "The interface firmware FAILED to initialize the target MCU", + // ERROR_UNINIT + "The interface firmware FAILED to uninitialize the target MCU", // ERROR_SECURITY_BITS "The interface firmware ABORTED programming. Image is trying to set security bits", // ERROR_UNLOCK @@ -66,6 +70,8 @@ static const char *const error_message[] = { "Flash algorithm erase all command FAILURE", // ERROR_WRITE "Flash algorithm write command FAILURE", + // ERROR_WRITE_VERIFY + "Flash algorithm write verify command FAILURE", /* File stream errors */ @@ -146,10 +152,14 @@ static error_type_t error_type[] = { ERROR_TYPE_TARGET, // ERROR_ALGO_DL ERROR_TYPE_TARGET, + //ERROR_ALGO_MISSING + ERROR_TYPE_TARGET, // ERROR_ALGO_DATA_SEQ ERROR_TYPE_TARGET, // ERROR_INIT ERROR_TYPE_TARGET, + // ERROR_UNINIT + ERROR_TYPE_TARGET, // ERROR_SECURITY_BITS ERROR_TYPE_USER, // ERROR_UNLOCK @@ -160,6 +170,8 @@ static error_type_t error_type[] = { ERROR_TYPE_TARGET, // ERROR_WRITE ERROR_TYPE_TARGET, + // ERROR_WRITE_VERIFY + ERROR_TYPE_TARGET, /* File stream errors */ diff --git a/source/daplink/error.h b/source/daplink/error.h index 874a64fff..c3a096086 100644 --- a/source/daplink/error.h +++ b/source/daplink/error.h @@ -42,13 +42,16 @@ typedef enum { /* Target flash errors */ ERROR_RESET, ERROR_ALGO_DL, + ERROR_ALGO_MISSING, ERROR_ALGO_DATA_SEQ, ERROR_INIT, + ERROR_UNINIT, ERROR_SECURITY_BITS, ERROR_UNLOCK, ERROR_ERASE_SECTOR, ERROR_ERASE_ALL, ERROR_WRITE, + ERROR_WRITE_VERIFY, /* File stream errors */ ERROR_SUCCESS_DONE, diff --git a/source/daplink/interface/main.c b/source/daplink/interface/main.c index 024f1f19e..8ec646d2e 100644 --- a/source/daplink/interface/main.c +++ b/source/daplink/interface/main.c @@ -23,7 +23,7 @@ #include "stdio.h" #include "stdint.h" -#include "RTL.h" +#include "cmsis_os2.h" #include "rl_usb.h" #include "main.h" #include "board.h" @@ -93,7 +93,7 @@ #endif // Reference to our main task -OS_TID main_task_id; +osThreadId_t main_task_id; // USB busy LED state; when TRUE the LED will flash once using 30mS clock tick static uint8_t hid_led_usb_activity = 0; @@ -107,22 +107,13 @@ static main_led_state_t msc_led_state = MAIN_LED_FLASH; main_usb_connect_t usb_state; static bool usb_test_mode = false; -static U64 stk_timer_30_task[TIMER_TASK_30_STACK / sizeof(U64)]; -static U64 stk_main_task[MAIN_TASK_STACK / sizeof(U64)]; - // Timer task, set flags every 30mS and 90mS -__task void timer_task_30mS(void) +void timer_task_30mS(void * arg) { - uint8_t i = 0; - os_itv_set(3); // 30mS - - while (1) { - os_itv_wait(); - os_evt_set(FLAGS_MAIN_30MS, main_task_id); - - if (!(i++ % 3)) { - os_evt_set(FLAGS_MAIN_90MS, main_task_id); - } + static uint32_t i = 0; + osThreadFlagsSet(main_task_id, FLAGS_MAIN_30MS); + if (!(i++ % 3)) { + osThreadFlagsSet(main_task_id, FLAGS_MAIN_90MS); } } @@ -130,7 +121,7 @@ __task void timer_task_30mS(void) // parameter should be reset type?? void main_reset_target(uint8_t send_unique_id) { - os_evt_set(FLAGS_MAIN_RESET, main_task_id); + osThreadFlagsSet(main_task_id, FLAGS_MAIN_RESET); return; } @@ -161,21 +152,21 @@ void main_blink_msc_led(main_led_state_t state) // Power down the interface void main_powerdown_event(void) { - os_evt_set(FLAGS_MAIN_POWERDOWN, main_task_id); + osThreadFlagsSet(main_task_id, FLAGS_MAIN_POWERDOWN); return; } // Disable debug on target void main_disable_debug_event(void) { - os_evt_set(FLAGS_MAIN_DISABLEDEBUG, main_task_id); + osThreadFlagsSet(main_task_id, FLAGS_MAIN_DISABLEDEBUG); return; } // Start CDC processing void main_cdc_send_event(void) { - os_evt_set(FLAGS_MAIN_CDC_EVENT, main_task_id); + osThreadFlagsSet(main_task_id, FLAGS_MAIN_CDC_EVENT); return; } @@ -186,12 +177,12 @@ void main_usb_set_test_mode(bool enabled) void USBD_SignalHandler() { - isr_evt_set(FLAGS_MAIN_PROC_USB, main_task_id); + osThreadFlagsSet(main_task_id, FLAGS_MAIN_PROC_USB); } extern void cdc_process_event(void); -__task void main_task(void) +void main_task(void * arg) { // State processing uint16_t flags = 0; @@ -210,7 +201,7 @@ __task void main_task(void) // Update bootloader if it is out of date bootloader_check_and_update(); // Get a reference to this task - main_task_id = os_tsk_self(); + main_task_id = osThreadGetId(); // leds gpio_init(); // Turn to LED default settings @@ -233,10 +224,10 @@ __task void main_task(void) } //setup some flags - if(g_board_info.flags & kEnableUnderResetConnect){ + if (g_board_info.flags & kEnableUnderResetConnect) { swd_set_reset_connect(CONNECT_UNDER_RESET); } - if(g_board_info.flags & kEnablePageErase){ + if (g_board_info.flags & kEnablePageErase) { #ifdef DRAG_N_DROP_SUPPORT flash_manager_set_page_erase(true); #endif @@ -252,26 +243,26 @@ __task void main_task(void) usbd_connect(0); usb_state = USB_CONNECTING; usb_state_count = USB_CONNECT_DELAY; - // Start timer tasks - os_tsk_create_user(timer_task_30mS, TIMER_TASK_30_PRIORITY, (void *)stk_timer_30_task, TIMER_TASK_30_STACK); + // Start timer tasks + osTimerId_t tmr_id = osTimerNew(timer_task_30mS, osTimerPeriodic, NULL, NULL); + osTimerStart(tmr_id, 3); while (1) { - os_evt_wait_or(FLAGS_MAIN_RESET // Put target in reset state + flags = osThreadFlagsWait(FLAGS_MAIN_RESET // Put target in reset state | FLAGS_MAIN_90MS // 90mS tick | FLAGS_MAIN_30MS // 30mS tick | FLAGS_MAIN_POWERDOWN // Power down interface | FLAGS_MAIN_DISABLEDEBUG // Disable target debug | FLAGS_MAIN_PROC_USB // process usb events | FLAGS_MAIN_CDC_EVENT // cdc event - , NO_TIMEOUT); - // Find out what event happened - flags = os_evt_get(); - + , osFlagsWaitAny + , osWaitForever); + if (flags & FLAGS_MAIN_PROC_USB) { if (usb_test_mode) { // When in USB test mode Insert a delay to // simulate worst-case behavior. - os_dly_wait(1); + osDelay(1); } USBD_Handler(); } @@ -375,7 +366,7 @@ __task void main_task(void) // DAP LED if (hid_led_usb_activity) { - if((hid_led_state == MAIN_LED_FLASH) || (hid_led_state == MAIN_LED_FLASH_PERMANENT)){ + if ((hid_led_state == MAIN_LED_FLASH) || (hid_led_state == MAIN_LED_FLASH_PERMANENT)) { // Toggle LED value hid_led_value = GPIO_LED_ON == hid_led_value ? GPIO_LED_OFF : GPIO_LED_ON; @@ -384,7 +375,7 @@ __task void main_task(void) hid_led_usb_activity = 0; hid_led_state = MAIN_LED_DEF; } - }else{ + } else { //LED next state is MAIN_LED_DEF hid_led_value = HID_LED_DEF; hid_led_usb_activity = 0; @@ -397,7 +388,7 @@ __task void main_task(void) // MSD LED if (msc_led_usb_activity) { - if((msc_led_state == MAIN_LED_FLASH) || (msc_led_state == MAIN_LED_FLASH_PERMANENT)){ + if ((msc_led_state == MAIN_LED_FLASH) || (msc_led_state == MAIN_LED_FLASH_PERMANENT)) { // Toggle LED value msc_led_value = GPIO_LED_ON == msc_led_value ? GPIO_LED_OFF : GPIO_LED_ON; @@ -406,7 +397,7 @@ __task void main_task(void) msc_led_usb_activity = 0; msc_led_state = MAIN_LED_DEF; } - }else{ + } else { //LED next state is MAIN_LED_DEF msc_led_value = MSC_LED_DEF; msc_led_usb_activity = 0; @@ -450,5 +441,9 @@ int main(void) #endif // initialize vendor sdk sdk_init(); - os_sys_init_user(main_task, MAIN_TASK_PRIORITY, stk_main_task, MAIN_TASK_STACK); + + osKernelInitialize(); // Initialize CMSIS-RTOS + osThreadNew(main_task, NULL, NULL); // Create application main thread + osKernelStart(); // Start thread execution + for (;;) {} } diff --git a/source/daplink/interface/swd_host.c b/source/daplink/interface/swd_host.c index cb6d0cf18..26228051c 100644 --- a/source/daplink/interface/swd_host.c +++ b/source/daplink/interface/swd_host.c @@ -20,7 +20,7 @@ */ #ifndef TARGET_MCU_CORTEX_A -#include "RTL.h" +#include "cmsis_os2.h" #include "target_reset.h" #include "target_config.h" #include "swd_host.h" @@ -794,9 +794,9 @@ uint8_t swd_init_debug(void) //do an abort on stale target, then reset the device swd_write_dp(DP_ABORT, DAPABORT); swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); do_abort = 0; } swd_init(); @@ -885,9 +885,9 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state) case RESET_RUN: swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); swd_off(); break; @@ -899,7 +899,7 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state) if (reset_connect == CONNECT_UNDER_RESET) { // Assert reset swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); } // Enable debug @@ -908,9 +908,9 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state) return 0; // Target is in invalid state? swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); } // Enable halt on reset @@ -921,12 +921,12 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state) if (reset_connect == CONNECT_NORMAL) { // Assert reset swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); } // Deassert reset swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); do { if (!swd_read_word(DBG_HCSR, &val)) { @@ -1026,9 +1026,9 @@ uint8_t swd_set_target_state_sw(TARGET_RESET_STATE state) case RESET_RUN: swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); swd_off(); break; @@ -1044,9 +1044,9 @@ uint8_t swd_set_target_state_sw(TARGET_RESET_STATE state) } // Target is in invalid state? swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); } // Wait until core is halted @@ -1070,7 +1070,7 @@ uint8_t swd_set_target_state_sw(TARGET_RESET_STATE state) return 0; } - os_dly_wait(2); + osDelay(2); do { if (!swd_read_word(DBG_HCSR, &val)) { diff --git a/source/daplink/interface/swd_host_ca.c b/source/daplink/interface/swd_host_ca.c index 9387e8a5a..a20bc0e1d 100644 --- a/source/daplink/interface/swd_host_ca.c +++ b/source/daplink/interface/swd_host_ca.c @@ -21,7 +21,7 @@ #ifdef TARGET_MCU_CORTEX_A -#include "RTL.h" +#include "cmsis_os2.h" #include "target_reset.h" #include "target_config.h" #include "swd_host.h" @@ -615,7 +615,7 @@ static uint8_t swd_wait_until_halted(void) if ((val & DBGDSCR_HALTED) == DBGDSCR_HALTED) { return 1; } - os_dly_wait(1); + osDelay(1); } return 0; @@ -802,17 +802,17 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state) case RESET_RUN: swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); swd_off(); break; case RESET_PROGRAM: swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); if (!swd_init_debug()) { return 0; @@ -826,7 +826,7 @@ uint8_t swd_set_target_state_hw(TARGET_RESET_STATE state) if (!swd_write_word(DBGDRCR, val )) { return 0; } - os_dly_wait(2); + osDelay(2); if (!swd_wait_until_halted()) { return 0; } @@ -884,9 +884,9 @@ uint8_t swd_set_target_state_sw(TARGET_RESET_STATE state) case RESET_RUN: swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); swd_off(); break; diff --git a/source/daplink/interface/target_flash.c b/source/daplink/interface/target_flash.c index e50654904..cc4bfb105 100644 --- a/source/daplink/interface/target_flash.c +++ b/source/daplink/interface/target_flash.c @@ -47,6 +47,7 @@ static error_t target_flash_erase_chip(void); static uint32_t target_flash_program_page_min_size(uint32_t addr); static uint32_t target_flash_erase_sector_size(uint32_t addr); static uint8_t target_flash_busy(void); +static error_t target_flash_set(uint32_t addr); static const flash_intf_t flash_intf = { target_flash_init, @@ -57,29 +58,99 @@ static const flash_intf_t flash_intf = { target_flash_program_page_min_size, target_flash_erase_sector_size, target_flash_busy, + target_flash_set, }; static state_t state = STATE_CLOSED; const flash_intf_t *const flash_intf_target = &flash_intf; +static flash_func_t last_flash_func = FLASH_FUNC_NOP; + +//saved flash algo +static program_target_t * current_flash_algo = NULL; + +//saved flash start from flash algo +static uint32_t flash_start = 0; + +static program_target_t * get_flash_algo(uint32_t addr) +{ + flash_region_info_t * flash_region = g_board_info.target_cfg->extra_flash; + + for (; flash_region->start != 0 && flash_region->end != 0; ++flash_region) { + if (addr >= flash_region->start && addr <= flash_region->end) { + flash_start = flash_region->start; //save the flash start + if (flash_region->flash_algo) { + return flash_region->flash_algo; + }else{ + return NULL; + } + } + } + + //could not find a flash algo for the region; use default + flash_start = g_board_info.target_cfg->flash_start; + return g_board_info.target_cfg->flash_algo; +} + +static error_t flash_func_start(flash_func_t func) +{ + program_target_t * flash = current_flash_algo; + + if (last_flash_func != func) + { + // Finish the currently active function. + if (FLASH_FUNC_NOP != last_flash_func && + 0 == swd_flash_syscall_exec(&flash->sys_call_s, flash->uninit, last_flash_func, 0, 0, 0)) { + return ERROR_UNINIT; + } + + // Start a new function. + if (FLASH_FUNC_NOP != func && + 0 == swd_flash_syscall_exec(&flash->sys_call_s, flash->init, flash_start, 0, func, 0)) { + return ERROR_INIT; + } + + last_flash_func = func; + } + + return ERROR_SUCCESS; +} + +static error_t target_flash_set(uint32_t addr) +{ + program_target_t * new_flash_algo = get_flash_algo(addr); + if (new_flash_algo == NULL) { + return ERROR_ALGO_MISSING; + } + if(current_flash_algo != new_flash_algo){ + //run uninit to last func + error_t status = flash_func_start(FLASH_FUNC_NOP); + if (status != ERROR_SUCCESS) { + return status; + } + // Download flash programming algorithm to target + if (0 == swd_write_memory(new_flash_algo->algo_start, (uint8_t *)new_flash_algo->algo_blob, new_flash_algo->algo_size)) { + return ERROR_ALGO_DL; + } + + current_flash_algo = new_flash_algo; + + } + return ERROR_SUCCESS; +} + static error_t target_flash_init() { if (g_board_info.target_cfg) { - const program_target_t *const flash = g_board_info.target_cfg->flash_algo; + last_flash_func = FLASH_FUNC_NOP; + + current_flash_algo = NULL; if (0 == target_set_state(RESET_PROGRAM)) { return ERROR_RESET; } - // Download flash programming algorithm to target and initialise. - if (0 == swd_write_memory(flash->algo_start, (uint8_t *)flash->algo_blob, flash->algo_size)) { - return ERROR_ALGO_DL; - } - - if (0 == swd_flash_syscall_exec(&flash->sys_call_s, flash->init, g_board_info.target_cfg->flash_start, 0, 0, 0)) { - return ERROR_INIT; - } state = STATE_OPEN; return ERROR_SUCCESS; } else { @@ -91,6 +162,10 @@ static error_t target_flash_init() static error_t target_flash_uninit(void) { if (g_board_info.target_cfg) { + error_t status = flash_func_start(FLASH_FUNC_NOP); + if (status != ERROR_SUCCESS) { + return status; + } if (config_get_auto_rst()) { // Resume the target if configured to do so target_set_state(RESET_RUN); @@ -113,9 +188,13 @@ static error_t target_flash_uninit(void) static error_t target_flash_program_page(uint32_t addr, const uint8_t *buf, uint32_t size) { if (g_board_info.target_cfg) { + error_t status = ERROR_SUCCESS; + program_target_t * flash = current_flash_algo; + + if (!flash) { + return ERROR_INTERNAL; + } - const program_target_t *const flash = g_board_info.target_cfg->flash_algo; - // check if security bits were set if (g_target_family && g_target_family->security_bits_set){ if (1 == g_target_family->security_bits_set(addr, (uint8_t *)buf, size)) { @@ -123,6 +202,12 @@ static error_t target_flash_program_page(uint32_t addr, const uint8_t *buf, uint } } + status = flash_func_start(FLASH_FUNC_PROGRAM); + + if (status != ERROR_SUCCESS) { + return status; + } + while (size > 0) { uint32_t write_size = MIN(size, flash->program_buffer_size); @@ -144,13 +229,17 @@ static error_t target_flash_program_page(uint32_t addr, const uint8_t *buf, uint if (config_get_automation_allowed()) { // Verify data flashed if in automation mode if (flash->verify != 0) { + status = flash_func_start(FLASH_FUNC_VERIFY); + if (status != ERROR_SUCCESS) { + return status; + } if (!swd_flash_syscall_exec(&flash->sys_call_s, flash->verify, addr, write_size, flash->program_buffer, 0)) { - return ERROR_WRITE; + return ERROR_WRITE_VERIFY; } } else { while (write_size > 0) { @@ -160,7 +249,7 @@ static error_t target_flash_program_page(uint32_t addr, const uint8_t *buf, uint return ERROR_ALGO_DATA_SEQ; } if (memcmp(buf, rb_buf, verify_size) != 0) { - return ERROR_WRITE; + return ERROR_WRITE_VERIFY; } addr += verify_size; buf += verify_size; @@ -186,13 +275,24 @@ static error_t target_flash_program_page(uint32_t addr, const uint8_t *buf, uint static error_t target_flash_erase_sector(uint32_t addr) { if (g_board_info.target_cfg) { - const program_target_t *const flash = g_board_info.target_cfg->flash_algo; + error_t status = ERROR_SUCCESS; + program_target_t * flash = current_flash_algo; + if (!flash) { + return ERROR_INTERNAL; + } + // Check to make sure the address is on a sector boundary if ((addr % target_flash_erase_sector_size(addr)) != 0) { return ERROR_ERASE_SECTOR; } + status = flash_func_start(FLASH_FUNC_ERASE); + + if (status != ERROR_SUCCESS) { + return status; + } + if (0 == swd_flash_syscall_exec(&flash->sys_call_s, flash->erase_sector, addr, 0, 0, 0)) { return ERROR_ERASE_SECTOR; } @@ -207,11 +307,39 @@ static error_t target_flash_erase_chip(void) { if (g_board_info.target_cfg){ error_t status = ERROR_SUCCESS; - const program_target_t *const flash = g_board_info.target_cfg->flash_algo; - - if (0 == swd_flash_syscall_exec(&flash->sys_call_s, flash->erase_chip, 0, 0, 0, 0)) { - return ERROR_ERASE_ALL; + program_target_t * flash; + flash_region_info_t * flash_region = g_board_info.target_cfg->extra_flash; + + if (current_flash_algo != g_board_info.target_cfg->flash_algo) { + //set the initial flash algo + error_t status = target_flash_set(g_board_info.target_cfg->flash_start); + if (status != ERROR_SUCCESS) { + return status; + } } + + do { + flash = current_flash_algo; + status = flash_func_start(FLASH_FUNC_ERASE); + if (status != ERROR_SUCCESS) { + return status; + } + if (0 == swd_flash_syscall_exec(&flash->sys_call_s, flash->erase_chip, 0, 0, 0, 0)) { + return ERROR_ERASE_ALL; + } + + while (flash_region->start != 0 && flash_region->end != 0) { + if (flash_region->flash_algo) { + status = target_flash_set(flash_region->start); + if (status != ERROR_SUCCESS) { + return status; + } + flash_region++; + break; + } + flash_region++; + } + } while (flash != current_flash_algo); //call erase on the next flash algo // Reset and re-initialize the target after the erase if required if (g_board_info.target_cfg->erase_reset) { diff --git a/source/daplink/usb2uart/usbd_user_cdc_acm.c b/source/daplink/usb2uart/usbd_user_cdc_acm.c index ae7854b3b..091fa81cd 100644 --- a/source/daplink/usb2uart/usbd_user_cdc_acm.c +++ b/source/daplink/usb2uart/usbd_user_cdc_acm.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "RTL.h" +#include "cmsis_os2.h" #include "rl_usb.h" #include "main.h" #include "target_reset.h" @@ -121,10 +121,10 @@ int32_t USBD_CDC_ACM_SendBreak(uint16_t dur) { //added checking if flashing on target is in progress // reset and send the unique id over CDC if (dur != 0) { - start_break_time = os_time_get(); + start_break_time = osKernelGetSysTimerCount(); target_set_state(RESET_HOLD); } else { - end_break_time = os_time_get(); + end_break_time = osKernelGetSysTimerCount(); // long reset -> send uID over serial (300 -> break > 3s) if ((end_break_time - start_break_time) >= (300)) { diff --git a/source/family/freescale/k22f/flash_blob.c b/source/family/freescale/k22f/flash_blob.c index 2eeb7409b..bfbeb0c39 100644 --- a/source/family/freescale/k22f/flash_blob.c +++ b/source/family/freescale/k22f/flash_blob.c @@ -1,88 +1,93 @@ -/** - * @file flash_blob.c - * @brief Flash algorithm for the k22f - * - * DAPLink Interface Firmware - * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 +/* Flash OS Routines (Automagically Generated) + * Copyright (c) 2009-2015 ARM Limited * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. + * 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 + * 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. + * 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. */ -#include "flash_blob.h" - -static const uint32_t K22F_FLM[] = { +static const uint32_t MK_P512_flash_prog_blob[] = { 0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2, - 0x4604b570, 0x4616460d, 0x5020f24c, 0x81c84932, 0x1028f64d, 0x460881c8, 0xf0208800, 0x80080001, - 0x4448482e, 0xf8dcf000, 0x2001b108, 0x2000bd70, 0x4601e7fc, 0x47702000, 0x4929b510, 0x44484827, - 0xf8b8f000, 0xb92c4604, 0x48242100, 0xf0004448, 0x4604f9b5, 0xf837f000, 0xbd104620, 0x4604b570, - 0x4448481e, 0x46214b1e, 0xf00068c2, 0x4605f85d, 0x481ab93d, 0x23004448, 0x68c24621, 0xf952f000, - 0xf0004605, 0x4628f820, 0xb5febd70, 0x460c4605, 0x46234616, 0x46294632, 0x44484810, 0xf90af000, - 0xb9674607, 0x22012000, 0x2000e9cd, 0x46224633, 0x90024629, 0x44484809, 0xf990f000, 0xf0004607, - 0x4638f802, 0x4807bdfe, 0xf4206840, 0xf5000070, 0x49040070, 0x47706048, 0x40052000, 0x00000004, - 0x6b65666b, 0x4001f000, 0x4a0e2070, 0x20807010, 0xbf007010, 0x7800480b, 0x280009c0, 0x4809d0fa, - 0xf0017801, 0xb1080020, 0x47702067, 0x0010f001, 0x2068b108, 0xf001e7f9, 0xb1080001, 0xe7f42069, - 0xe7f22000, 0x40020000, 0x4df0e92d, 0x460d4604, 0x469a4690, 0xf0004650, 0x4606f899, 0x4630b116, - 0x8df0e8bd, 0x46422308, 0x46204629, 0xf874f000, 0xb10e4606, 0xe7f34630, 0x0008eb05, 0x68e01e47, - 0xf1f0fbb7, 0x7011fb00, 0x68e0b140, 0xf0f0fbb7, 0x0b01f100, 0xfb0068e0, 0x1e47f00b, 0x480be011, - 0x68004478, 0x20096005, 0x71c84909, 0xffacf7ff, 0x69a04606, 0x69a0b108, 0xb1064780, 0x68e0e003, - 0x42bd4405, 0xbf00d9eb, 0xe7c94630, 0x00000304, 0x40020000, 0x4604b570, 0x4628460d, 0xf856f000, - 0xb10e4606, 0xbd704630, 0x2004b90c, 0x2044e7fb, 0x71c84902, 0xff88f7ff, 0x0000e7f5, 0x40020000, - 0xb9094601, 0x47702004, 0x6cc0482e, 0x6003f3c0, 0x447b4b2d, 0x0010f833, 0xb90a0302, 0xe7f22064, - 0x60082000, 0x2002604a, 0x02806088, 0x482760c8, 0x15807803, 0x61084098, 0x38284824, 0x002bf890, - 0x20006148, 0xbf006188, 0x4602e7dd, 0x2004b90a, 0x61914770, 0xe7fb2000, 0x4604b530, 0x2004b90c, - 0x1e58bd30, 0xb9104008, 0x40101e58, 0x2065b108, 0x6820e7f6, 0xd8054288, 0x0500e9d4, 0x188d4428, - 0xd20142a8, 0xe7eb2066, 0xe7e92000, 0x48104601, 0xd0014281, 0x4770206b, 0xe7fc2000, 0xb90b4603, - 0x47702004, 0xd803290f, 0xd0092a04, 0xe7f82004, 0xd8032913, 0xd0032a08, 0xe7f22004, 0xe7f02004, - 0xe7ee2000, 0x40048000, 0x00000272, 0x40020028, 0x6b65666b, 0x41f0e92d, 0x46884607, 0x461d4614, - 0x2004b914, 0x81f0e8bd, 0x462a2304, 0x46384641, 0xffb2f7ff, 0xb10e4606, 0xe7f34630, 0x480fe019, - 0x68004478, 0x8000f8c0, 0x490ccc01, 0x390c4479, 0x60486809, 0x490a2006, 0xf7ff71c8, 0x4606fef5, - 0xb10869b8, 0x478069b8, 0xe004b106, 0x0804f108, 0x2d001f2d, 0xbf00d1e3, 0xe7d34630, 0x000001a4, - 0x40020000, 0x4dffe92d, 0x4682b082, 0x2308460c, 0x46504621, 0xf7ff9a04, 0x4683ff7f, 0x0f00f1bb, - 0x4658d003, 0xe8bdb006, 0xe9da8df0, 0xfbb00101, 0x4260f7f1, 0x40084279, 0x42a54245, 0x443dd100, - 0xe0229e04, 0x0804eba5, 0xd90045b0, 0xea4f46b0, 0x900100d8, 0x4478480f, 0x60046800, 0x490e2001, - 0x980171c8, 0x72c80a00, 0x72889801, 0x72489805, 0xfeaaf7ff, 0xf1bb4683, 0xd0010f00, 0xe7d14658, - 0x0608eba6, 0x443d4444, 0x2e00bf00, 0x2000d1da, 0x0000e7c8, 0x0000010e, 0x40020000, 0x4604b570, - 0xb90c460d, 0xbd702004, 0x49032040, 0x460871c8, 0xf7ff7185, 0xe7f6fe89, 0x40020000, 0x4dffe92d, - 0x4617460c, 0xe9dd461d, 0xf8ddb80c, 0xb91da038, 0xb0042004, 0x8df0e8bd, 0x463a2304, 0x98004621, - 0xff1af7ff, 0xb10e4606, 0xe7f24630, 0x4814e022, 0x68004478, 0x20026004, 0x71c84912, 0xf8804608, - 0x490fb00b, 0x39144479, 0x68096828, 0xf7ff6088, 0x4606fe5b, 0xf1b8b15e, 0xd0010f00, 0x4000f8c8, - 0x0f00f1ba, 0x2000d002, 0x0000f8ca, 0x1f3fe004, 0x1d241d2d, 0xd1da2f00, 0x4630bf00, 0x0000e7c9, - 0x00000074, 0x40020000, 0x00000000, 0x00080000, 0x00100000, 0x00200000, 0x00400000, 0x00800000, - 0x01000000, 0x01000000, 0x40020004, 0x00000000, + 0xb5104938, 0x60084449, 0xf24c4837, 0x81c15120, 0x1128f64d, 0x880181c1, 0x0101f021, 0x48348001, + 0x44484932, 0x2200f44f, 0x21006001, 0x1201e9c0, 0x52a0f04f, 0xf44f6142, 0x61825280, 0x1020f880, + 0x62411e49, 0xf939f000, 0xd0002800, 0xbd102001, 0x47702000, 0x4a27b508, 0x9200447a, 0x02cff3c1, + 0x48234601, 0x44482300, 0xf979f000, 0xd0002800, 0xbd082001, 0x491fb508, 0x481d4479, 0x44483920, + 0xf89ff000, 0xd10f2800, 0x4478481a, 0x38324b1a, 0x9000447b, 0x22044816, 0x410cf240, 0xf0004448, + 0x2800f911, 0x2001d000, 0x4b12bd08, 0x4601447b, 0x3b54480f, 0x6200f44f, 0xf0004448, 0xb508b8b6, + 0x1dc94613, 0x0207f021, 0x4479490a, 0x91003972, 0x48074601, 0xf0004448, 0x2800f8f5, 0x2001d000, + 0x0000bd08, 0x00000004, 0x40052000, 0x40020000, 0x00000008, 0x000000a1, 0x0000035c, 0x4604b570, + 0x25006800, 0x061b7803, 0x2370d5fc, 0x20007003, 0x280ce03a, 0xe8dfd236, 0x0a06f000, 0x1a16120e, + 0x2a26221e, 0x6826322e, 0x71f37813, 0x6826e02a, 0x71b37853, 0x6826e026, 0x71737893, 0x6826e022, + 0x713378d3, 0x6826e01e, 0x72f37913, 0x6826e01a, 0x72b37953, 0x6826e016, 0x72737993, 0x6826e012, + 0x723379d3, 0x6826e00e, 0x73f37a13, 0x6826e00a, 0x73b37a53, 0x6826e006, 0x73737a93, 0x6826e002, + 0x73337ad3, 0xb2c01c40, 0xd9c24288, 0x20806821, 0xe0037008, 0x1c416a60, 0x4780d000, 0x78006820, + 0xd5f70600, 0x78006820, 0xd5010681, 0xe0062504, 0xd50106c1, 0xe0022508, 0xd00007c0, 0x46282510, + 0xb508bd70, 0x460b2244, 0x2000f88d, 0x2100466a, 0xbd084798, 0x4614b538, 0xd002078a, 0x7080f44f, + 0x6843bd38, 0xd803428b, 0x441a6882, 0xd80c428a, 0x428b68c3, 0x6902d803, 0x428a441a, 0x2002d801, + 0x1ac9bd38, 0x0100f501, 0x1ac9e000, 0xf88d2208, 0x0c0a2000, 0x2001f88d, 0xf88d0a0a, 0xf88d2002, + 0x466a1003, 0x47a02103, 0xe92dbd38, 0x460745f8, 0x46164698, 0x2000687b, 0x428b198a, 0x68bcd803, + 0x4294441c, 0x68fbd20e, 0xd803428b, 0x441c693c, 0xd2024294, 0xe8bd2002, 0x1acc85f8, 0xf5042500, + 0xe0020400, 0xf44f1acc, 0xfbb46500, 0xfb05f1f5, 0xb1114111, 0x7080f44f, 0xfbb6e7ed, 0xfb05f1f5, + 0xb1a96111, 0xe7e62001, 0xa000f88d, 0xf88d0c20, 0x0a200001, 0x0002f88d, 0x4003f88d, 0x2103466a, + 0x46434638, 0x28004798, 0x1b76d1d5, 0xe001442c, 0x0a09f04f, 0xd1e72e00, 0x4601e7cd, 0x61082000, + 0x477061c8, 0x47fce92d, 0x46074616, 0x2000461d, 0xf8dd198a, 0x078b8028, 0xf44fd003, 0xe8bd7080, + 0x07b387fc, 0x2001d001, 0x687be7f9, 0xd803428b, 0x441c68bc, 0xd20c4294, 0x428b68fb, 0x693cd803, + 0x4294441c, 0x2002d201, 0x1acce7e9, 0x0400f504, 0x1acce000, 0x0a06f04f, 0xd0e02e00, 0xa000f88d, + 0xf88d0c20, 0x0a200001, 0x0002f88d, 0x4003f88d, 0xf88d78e8, 0x78a80004, 0x0005f88d, 0xf88d7868, + 0x78280006, 0x0007f88d, 0x2107466a, 0x46434638, 0x28004798, 0x1d24d1c3, 0x1f361d2d, 0xe92de7dc, + 0x684641fc, 0xeb019d08, 0x428e04c2, 0x6887d803, 0x428f4437, 0x68c7d80a, 0xd804428f, 0xc010f8d0, + 0x428f4467, 0x2002d802, 0x81fce8bd, 0xd80642a6, 0x44376887, 0xd30242a7, 0x24081b89, 0x68c6e00a, + 0xd90342a6, 0x44376907, 0xd3ec42a7, 0x24081b89, 0x0100f501, 0xf6f4fbb1, 0x1416fb04, 0xf44fb114, + 0xe7e17080, 0xf88d2401, 0x0c0c4000, 0x4001f88d, 0xf88d0a0c, 0xf88d4002, 0x0a111003, 0x1004f88d, + 0x2005f88d, 0x3006f88d, 0x2106466a, 0xe7cb47a8, 0xfffffffe, 0x00000000, 0xffffffff, 0xfffffffe, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000 +}; + +// Start address of flash +static const uint32_t flash_start = 0x00000000; +// Size of flash +static const uint32_t flash_size = 0x00080000; + +/** +* List of start and size for each size of flash sector - even indexes are start, odd are size +* The size will apply to all sectors between the listed address and the next address +* in the list. +* The last pair in the list will have sectors starting at that address and ending +* at address flash_start + flash_size. +*/ +static const sector_info_t sectors_info[] = { + { 0x00000000, 0x00000800 }, }; static const program_target_t flash = { 0x20000021, // Init - 0x20000049, // UnInit - 0x20000059, // EraseChip - 0x2000007D, // EraseSector - 0x200000AB, // ProgramPage + 0x20000071, // UnInit + 0x20000095, // EraseChip + 0x200000cb, // EraseSector + 0x200000df, // ProgramPage 0x0, // Verify - - // breakpoint = RAM start + 1 - // RSB : base address is address of Execution Region PrgData in map file - // to access global/static data - // RSP : Initial stack pointer + + // BKPT : start of blob + 1 + // RSB : blob start + header + rw data offset + // RSP : stack pointer { - 0x20000001, // breakpoint instruction address - 0x20000000 + 0x20 + 0x48c, // static base register value (image start + header + static base offset) - 0x20000800 // initial stack pointer + 0x20000001, + 0x20000420, + 0x20000700 }, - 0x20001000, // program_buffer, any valid RAM location with +512 bytes of headroom - 0x20000000, // algo_start, start of RAM - sizeof(K22F_FLM), // algo_size, size of array above - K22F_FLM, // image, flash algo instruction array - 512 // ram_to_flash_bytes_to_be_written + 0x20000000 + 0x00000A00, // mem buffer location + 0x20000000, // location to write prog_blob in target RAM + sizeof(MK_P512_flash_prog_blob), // prog_blob size + MK_P512_flash_prog_blob, // address of prog_blob + 0x00000200 // ram_to_flash_bytes_to_be_written }; diff --git a/source/family/freescale/k64f/flash_blob.c b/source/family/freescale/k64f/flash_blob.c index 7db7d81cb..29f3ff9c5 100644 --- a/source/family/freescale/k64f/flash_blob.c +++ b/source/family/freescale/k64f/flash_blob.c @@ -1,91 +1,101 @@ -/** - * @file flash_blob.c - * @brief Flash algorithm for the k64f - * - * DAPLink Interface Firmware - * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 +/* Flash OS Routines (Automagically Generated) + * Copyright (c) 2009-2015 ARM Limited * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. + * 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 + * 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. + * 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. */ -#include "flash_blob.h" - -static const uint32_t K64F_FLM[] = { +static const uint32_t mk64f12_flash_prog_blob[] = { 0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2, - 0x4604b570, 0x4616460d, 0x5020f24c, 0x81c84932, 0x1028f64d, 0x460881c8, 0xf0208800, 0x80080001, - 0x4448482e, 0xf8dcf000, 0x2001b108, 0x2000bd70, 0x4601e7fc, 0x47702000, 0x4929b510, 0x44484827, - 0xf8b8f000, 0xb92c4604, 0x48242100, 0xf0004448, 0x4604f9a9, 0xf837f000, 0xbd104620, 0x4604b570, - 0x4448481e, 0x46214b1e, 0xf00068c2, 0x4605f85d, 0x481ab93d, 0x23004448, 0x68c24621, 0xf946f000, - 0xf0004605, 0x4628f820, 0xb5febd70, 0x460c4605, 0x46234616, 0x46294632, 0x44484810, 0xf8f8f000, - 0xb9674607, 0x22012000, 0x2000e9cd, 0x46224633, 0x90024629, 0x44484809, 0xf984f000, 0xf0004607, - 0x4638f802, 0x4807bdfe, 0xf4206840, 0xf5000070, 0x49040070, 0x47706048, 0x40052000, 0x00000004, - 0x6b65666b, 0x4001f000, 0x4a0e2070, 0x20807010, 0xbf007010, 0x7800480b, 0x280009c0, 0x4809d0fa, - 0xf0017801, 0xb1080020, 0x47702067, 0x0010f001, 0x2068b108, 0xf001e7f9, 0xb1080001, 0xe7f42069, - 0xe7f22000, 0x40020000, 0x4df0e92d, 0x460d4604, 0x469a4690, 0xf0004650, 0x4606f891, 0x4630b116, - 0x8df0e8bd, 0x46422310, 0x46204629, 0xf86cf000, 0xb10e4606, 0xe7f34630, 0x0008eb05, 0x68e01e47, - 0xf1f0fbb7, 0x7011fb00, 0x68e0b140, 0xf0f0fbb7, 0x0b01f100, 0xfb0068e0, 0x1e47f00b, 0x480be011, - 0x68004478, 0x20096005, 0x71c84909, 0xffacf7ff, 0x69a04606, 0x69a0b108, 0xb1064780, 0x68e0e003, - 0x42bd4405, 0xbf00d9eb, 0xe7c94630, 0x000002ec, 0x40020000, 0x4604b570, 0x4628460d, 0xf84ef000, - 0xb10e4606, 0xbd704630, 0x2004b90c, 0x2044e7fb, 0x71c84902, 0xff88f7ff, 0x0000e7f5, 0x40020000, - 0xb9094601, 0x47702004, 0x6cc04826, 0x6003f3c0, 0x447b4b25, 0x0010f833, 0xb90a0302, 0xe7f22064, - 0x60082000, 0x2002604a, 0x02c06088, 0x200060c8, 0x61486108, 0xbf006188, 0x4602e7e5, 0x2004b90a, - 0x61914770, 0xe7fb2000, 0x4604b530, 0x2004b90c, 0x1e58bd30, 0xb9104008, 0x40101e58, 0x2065b108, - 0x6820e7f6, 0xd8054288, 0x0500e9d4, 0x188d4428, 0xd20142a8, 0xe7eb2066, 0xe7e92000, 0x480b4601, - 0xd0014281, 0x4770206b, 0xe7fc2000, 0xb90b4603, 0x47702004, 0xd801290f, 0xd0012a04, 0xe7f82004, - 0xe7f62000, 0x40048000, 0x0000025a, 0x6b65666b, 0x41f0e92d, 0x46884607, 0x461d4614, 0x2004b914, - 0x81f0e8bd, 0x462a2308, 0x46384641, 0xffbcf7ff, 0xb10e4606, 0xe7f34630, 0x4812e01f, 0x68004478, - 0x8000f8c0, 0x490fcc01, 0x390c4479, 0x60486809, 0x490ccc01, 0x39184479, 0x60886809, 0x490a2007, - 0xf7ff71c8, 0x4606ff01, 0xb10869b8, 0x478069b8, 0xe004b106, 0x0808f108, 0x2d003d08, 0xbf00d1dd, - 0xe7cd4630, 0x000001b0, 0x40020000, 0x4dffe92d, 0x4682b082, 0x2310460c, 0x46504621, 0xf7ff9a04, - 0x4683ff83, 0x0f00f1bb, 0x4658d003, 0xe8bdb006, 0xe9da8df0, 0xfbb00101, 0x4260f7f1, 0x40084279, - 0x42a54245, 0x443dd100, 0xe0229e04, 0x0804eba5, 0xd90045b0, 0xea4f46b0, 0x90011018, 0x4478480f, - 0x60046800, 0x490e2001, 0x980171c8, 0x72c80a00, 0x72889801, 0x72489805, 0xfeb6f7ff, 0xf1bb4683, - 0xd0010f00, 0xe7d14658, 0x0608eba6, 0x443d4444, 0x2e00bf00, 0x2000d1da, 0x0000e7c8, 0x0000010e, - 0x40020000, 0x4604b570, 0xb90c460d, 0xbd702004, 0x49032040, 0x460871c8, 0xf7ff7185, 0xe7f6fe95, - 0x40020000, 0x4dffe92d, 0x4617460c, 0xe9dd461d, 0xf8ddb80c, 0xb91da038, 0xb0042004, 0x8df0e8bd, - 0x463a2304, 0x98004621, 0xff1ef7ff, 0xb10e4606, 0xe7f24630, 0x4814e022, 0x68004478, 0x20026004, - 0x71c84912, 0xf8804608, 0x490fb00b, 0x39144479, 0x68096828, 0xf7ff6088, 0x4606fe67, 0xf1b8b15e, - 0xd0010f00, 0x4000f8c8, 0x0f00f1ba, 0x2000d002, 0x0000f8ca, 0x1f3fe004, 0x1d241d2d, 0xd1da2f00, - 0x4630bf00, 0x0000e7c9, 0x00000074, 0x40020000, 0x00000000, 0x00080000, 0x00100000, 0x00200000, - 0x00400000, 0x00800000, 0x01000000, 0x01000000, 0x40020004, 0x00000000, + 0xb510483e, 0x5120f24c, 0xf64d81c1, 0x81c11128, 0xf0218801, 0x80010101, 0x78414839, 0x0160f001, + 0xbf0c2940, 0x21002101, 0x444a4a36, 0xb1397011, 0xf0217841, 0x70410160, 0xf0117841, 0xd1fb0f60, + 0x44484831, 0xf864f000, 0xbf182800, 0xbd102001, 0x4448482c, 0xb1587800, 0x78414829, 0x0160f021, + 0x0140f041, 0x78417041, 0x0160f001, 0xd1fa2940, 0x47702000, 0xb5104824, 0x44484924, 0xf891f000, + 0xbf182800, 0x2100bd10, 0xe8bd481f, 0x44484010, 0xb958f000, 0x4c1cb570, 0x444c4605, 0x4b1b4601, + 0x68e24620, 0xf8b6f000, 0xbf182800, 0x2300bd70, 0x68e24629, 0x4070e8bd, 0x44484813, 0xb94cf000, + 0x460cb570, 0x4606460b, 0x480f4601, 0x4615b084, 0xf0004448, 0x2800f8eb, 0xb004bf1c, 0x2000bd70, + 0xe9cd2101, 0x90021000, 0x462b4807, 0x46314622, 0xf0004448, 0xb004f97f, 0x0000bd70, 0x40052000, + 0x4007e000, 0x00000004, 0x00000008, 0x6b65666b, 0xbf042800, 0x47702004, 0x6cc949ea, 0x6103f3c1, + 0xbf08290f, 0x1180f44f, 0x4ae7bf1f, 0xf832447a, 0x02891011, 0xe9c02200, 0x21022100, 0x61426081, + 0x618202c9, 0x1203e9c0, 0x52a0f04f, 0x2108e9c0, 0x47702000, 0xbf0e2800, 0x61012004, 0x47702000, + 0x48da4602, 0x49d96840, 0x0070f440, 0x47706048, 0x217048d7, 0x21807001, 0x78017001, 0x0f80f011, + 0x7800d0fb, 0x0f20f010, 0x2067bf1c, 0xf0104770, 0xbf1c0f10, 0x47702068, 0x0001f010, 0x2069bf18, + 0x28004770, 0x2004bf04, 0xb5104770, 0x4ac84604, 0x403bf06f, 0x48c76050, 0xbf144281, 0x2000206b, + 0xbf182800, 0x4620bd10, 0xffd2f7ff, 0x46204603, 0xffc6f7ff, 0xbd104618, 0xbf042800, 0x47702004, + 0x60532300, 0x60d36093, 0x61536113, 0x61d36193, 0x68c16011, 0xe9d06051, 0xfbb11001, 0x6090f0f0, + 0x21102008, 0x0103e9c2, 0x1005e9c2, 0x61d02004, 0x47702000, 0x4df0e92d, 0x4615b088, 0x460c4698, + 0x466a4682, 0xffd8f7ff, 0x4621462a, 0x9b044650, 0xf931f000, 0xbf1c0007, 0xe8bdb008, 0xe9dd8df0, + 0x19604600, 0xfbb51e45, 0xfb06f0f6, 0xb1205010, 0xf0f6fbb5, 0x43701c40, 0x42ac1e45, 0xf8dfbf98, + 0xd81cb270, 0x407ff024, 0x6010f040, 0x0004f8cb, 0x45804898, 0x206bbf14, 0x28002000, 0xb008bf1c, + 0x8df0e8bd, 0xf7ff4650, 0x4607ff73, 0x0010f8da, 0xbf182800, 0xb9174780, 0x42ac4434, 0x4650d9e2, + 0xff5ef7ff, 0x4638b008, 0x8df0e8bd, 0xbf042a00, 0x47702004, 0x45f0e92d, 0x4614b089, 0x460d461e, + 0x466a4680, 0xff88f7ff, 0x46294632, 0x9b034640, 0xf8e1f000, 0xbf1c0007, 0xe8bdb009, 0x9d0085f0, + 0xbf182e00, 0xa1e8f8df, 0xf854d025, 0xf8ca0b04, 0x98030008, 0xbf042804, 0x407ff025, 0x60c0f040, + 0x2808d009, 0xf854d109, 0xf8ca0b04, 0xf025000c, 0xf040407f, 0xf8ca60e0, 0x46400004, 0xff28f7ff, + 0x1010f8d8, 0x29004607, 0x4788bf18, 0x9803b91f, 0x1a364405, 0x4640d1d9, 0xff12f7ff, 0x4638b009, + 0x85f0e8bd, 0xbf042800, 0x47702004, 0xea424a62, 0x4a5f4101, 0xe70b6051, 0x4dffe92d, 0x4614b088, + 0x460d469a, 0x9808466a, 0xff36f7ff, 0x46294622, 0x98089b05, 0xf88ff000, 0xbf1c2800, 0xe8bdb00c, + 0x466a8df0, 0x98084629, 0xff26f7ff, 0xf8dd9e00, 0x42708008, 0x0100f1c8, 0x42474008, 0xbf0842b7, + 0x2c004447, 0xf8dfbf18, 0xd01fb128, 0x42a51bbd, 0x4625bf88, 0xf0269805, 0xfbb5417f, 0xf041f0f0, + 0xf8cb7180, 0x04001004, 0x200aea40, 0x00fff040, 0x0008f8cb, 0xf7ff9808, 0x2800fecb, 0xb00cbf1c, + 0x8df0e8bd, 0x442e1b64, 0xd1df4447, 0x2000b00c, 0x8df0e8bd, 0xbf042b00, 0x47702004, 0x4dffe92d, + 0x4616b088, 0x7a14e9dd, 0x460c461d, 0xf8dd466a, 0x98088058, 0xfee0f7ff, 0x3007e9dd, 0x46214632, + 0xf839f000, 0xbf1c2800, 0xe8bdb00c, 0x9c008df0, 0xbf042e00, 0xe8bdb00c, 0xf8df8df0, 0xf06fb094, + 0xea40407f, 0xf0246707, 0xf040407f, 0xf8cb7000, 0xf8cb0004, 0x68287008, 0x000cf8cb, 0xf7ff9808, + 0xb168fe87, 0x0f00f1ba, 0xf8cabf18, 0xf1b84000, 0xbf1c0f00, 0xf8c82100, 0xb00c1000, 0x8df0e8bd, + 0x1a769907, 0x0103f021, 0x9907440d, 0xd1da440c, 0xe8bdb00c, 0x28008df0, 0x2004bf04, 0xf1a34770, + 0x42190301, 0x421abf0e, 0x47702065, 0x428b6803, 0x6840d806, 0x44184411, 0xbf244288, 0x47702000, + 0x47702066, 0x40048000, 0x000003b4, 0x4001f000, 0x40020000, 0x6b65666b, 0x4000ffff, 0x40020004, + 0x40020010, 0x00100008, 0x00200018, 0x00400030, 0x00800060, 0x010000c0, 0x02000180, 0x04000300, + 0x00000600, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; +// Start address of flash +static const uint32_t flash_start = 0x00000000; +// Size of flash +static const uint32_t flash_size = 0x00100000; + +/** +* List of start and size for each size of flash sector - even indexes are start, odd are size +* The size will apply to all sectors between the listed address and the next address +* in the list. +* The last pair in the list will have sectors starting at that address and ending +* at address flash_start + flash_size. +*/ static const sector_info_t sectors_info[] = { - {0x00000000, 0x00001000}, - }; + { 0x00000000, 0x00001000 }, +}; static const program_target_t flash = { 0x20000021, // Init - 0x20000049, // UnInit - 0x20000059, // EraseChip - 0x2000007D, // EraseSector - 0x200000AB, // ProgramPage + 0x20000071, // UnInit + 0x20000095, // EraseChip + 0x200000b5, // EraseSector + 0x200000e1, // ProgramPage 0x0, // Verify - - // breakpoint = RAM start + 1 - // RSB : base address is address of Execution Region PrgData in map file - // to access global/static data - // RSP : Initial stack pointer + + // BKPT : start of blob + 1 + // RSB : blob start + header + rw data offset + // RSP : stack pointer { - 0x20000001, // breakpoint instruction address - 0x20000000 + 0x20 + 0x474, // static base register value (image start + header + static base offset) - 0x20001000 // initial stack pointer + 0x20000001, + 0x20000524, + 0x20000800 }, - 0x20003000, // program_buffer, any valid RAM location with +512 bytes of headroom - 0x20000000, // algo_start, start of RAM - sizeof(K64F_FLM), // algo_size, size of array above - K64F_FLM, // image, flash algo instruction array - 512 // ram_to_flash_bytes_to_be_written + 0x20000000 + 0x00000A00, // mem buffer location + 0x20000000, // location to write prog_blob in target RAM + sizeof(mk64f12_flash_prog_blob), // prog_blob size + mk64f12_flash_prog_blob, // address of prog_blob + 0x00000400 // ram_to_flash_bytes_to_be_written }; diff --git a/source/family/nordic/target_reset_nrf51.c b/source/family/nordic/target_reset_nrf51.c index 9fa2da821..c83c8c4c6 100644 --- a/source/family/nordic/target_reset_nrf51.c +++ b/source/family/nordic/target_reset_nrf51.c @@ -45,7 +45,7 @@ static void swd_set_target_reset(uint8_t asserted) } PIN_SWCLK_TCK_CLR(); PIN_SWDIO_TMS_CLR(); - //os_dly_wait(1); + //osDelay(1); } else { PIN_SWCLK_TCK_SET(); PIN_SWDIO_TMS_SET(); diff --git a/source/family/nxp/lpc55S6X/target.c b/source/family/nxp/lpc55S6X/target.c index f280a5eb5..cb88a8c19 100644 --- a/source/family/nxp/lpc55S6X/target.c +++ b/source/family/nxp/lpc55S6X/target.c @@ -35,6 +35,7 @@ target_cfg_t target_device = { .flash_algo = (program_target_t *) &flash, .extra_flash[0].start = 0x10000000, .extra_flash[0].end = 0x10000000 + KB(608), + .extra_flash[0].flash_algo = (program_target_t *) &flash, //each extra flash region requires a flash algo .extra_ram[0].start = 0x30000000, .extra_ram[0].end = 0x30000000 + 0x00044000, }; diff --git a/source/family/nxp/lpc55S6X/target_reset.c b/source/family/nxp/lpc55S6X/target_reset.c index 50b88e3d3..a22b4d0d3 100644 --- a/source/family/nxp/lpc55S6X/target_reset.c +++ b/source/family/nxp/lpc55S6X/target_reset.c @@ -21,7 +21,7 @@ #include "target_family.h" #include "target_reset.h" #include "swd_host.h" -#include "RTL.h" +#include "cmsis_os2.h" #define DBG_Addr (0xE000EDF0) #define DWT_COMP0 (0xE0001020) @@ -52,9 +52,9 @@ static uint8_t target_set_state(TARGET_RESET_STATE state) return 0; // Target is in invalid state? swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); } // Set Trace Enable bit @@ -86,7 +86,7 @@ static uint8_t target_set_state(TARGET_RESET_STATE state) return 0; } - os_dly_wait(5); + osDelay(5); do { if (!swd_read_word(DBG_HCSR, &val)) { diff --git a/source/family/st/stm32f439zi/target_reset_f439.c b/source/family/st/stm32f439zi/target_reset_f439.c index 7091a8a67..d64d2f0db 100644 --- a/source/family/st/stm32f439zi/target_reset_f439.c +++ b/source/family/st/stm32f439zi/target_reset_f439.c @@ -21,12 +21,12 @@ #include "target_reset.h" #include "swd_host.h" -#include "RTL.h" +#include "cmsis_os2.h" void target_before_init_debug(void) { swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); } uint8_t target_unlock_sequence(void) diff --git a/source/family/toshiba/target_reset_tz.c b/source/family/toshiba/target_reset_tz.c index 356de6e8e..f72c0348d 100644 --- a/source/family/toshiba/target_reset_tz.c +++ b/source/family/toshiba/target_reset_tz.c @@ -19,16 +19,16 @@ * limitations under the License. */ -#include +#include "cmsis_os2.h" #include "target_reset.h" #include "swd_host.h" #include "target_family.h" void target_before_init_debug(void) { swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); return; } diff --git a/source/family/unsupported/atmel/atsam4e/flash_blob.h b/source/family/unsupported/atmel/atsam4e/flash_blob.h index 464f8867a..a58fd6ead 100644 --- a/source/family/unsupported/atmel/atsam4e/flash_blob.h +++ b/source/family/unsupported/atmel/atsam4e/flash_blob.h @@ -28,8 +28,8 @@ #include "stdint.h" #include "system_SAM3U.h" #include "debug_cm.h" -#include "RTL.h" +#include "cmsis_os2.h" const uint32_t flash_algorithm_blob[] = { diff --git a/source/family/unsupported/atmel/atsam4e/target_reset.c b/source/family/unsupported/atmel/atsam4e/target_reset.c index 72391bcc1..0b8c64a0b 100644 --- a/source/family/unsupported/atmel/atsam4e/target_reset.c +++ b/source/family/unsupported/atmel/atsam4e/target_reset.c @@ -20,7 +20,7 @@ */ #include "sam3u.h" -#include "RTL.h" +#include "cmsis_os2.h" #include "debug_cm.h" #include "target_reset.h" #include "swd_host.h" @@ -56,9 +56,9 @@ //Blink with 50ms interval //static void blinkLED(){ // gpio_set_dap_led(1); -// os_dly_wait(5); +// osDelay(5); // gpio_set_dap_led(0); -// os_dly_wait(5); +// osDelay(5); // gpio_set_dap_led(1); //} @@ -134,7 +134,7 @@ uint8_t target_set_state(TARGET_RESET_STATE state) //Check for 5 Second emergency erase routine while (!((PIOA->PIO_PDSR >> 25) & 1)) { - os_dly_wait(1); + osDelay(1); count++; gpio_set_dap_led((count >> 4) & 1); //Blink every 160ms diff --git a/source/family/unsupported/atmel/target_flash.c b/source/family/unsupported/atmel/target_flash.c index 6a43015cd..9efba58ba 100644 --- a/source/family/unsupported/atmel/target_flash.c +++ b/source/family/unsupported/atmel/target_flash.c @@ -20,7 +20,7 @@ */ #include "sam3u.h" -#include "RTL.h" +#include "cmsis_os2.h" #include "debug_cm.h" #include "target_reset.h" #include "swd_host.h" diff --git a/source/family/unsupported/renesas/swd_host_ca.c b/source/family/unsupported/renesas/swd_host_ca.c index d604f9b98..6c5ed1f9d 100644 --- a/source/family/unsupported/renesas/swd_host_ca.c +++ b/source/family/unsupported/renesas/swd_host_ca.c @@ -19,8 +19,8 @@ * limitations under the License. */ -#include "RTL.h" +#include "cmsis_os2.h" #include "target_flash.h" #include "target_reset.h" #include "target_config.h" diff --git a/source/family/wiznet/target_reset_wiznet.c b/source/family/wiznet/target_reset_wiznet.c index 526ae6d10..ddea28127 100644 --- a/source/family/wiznet/target_reset_wiznet.c +++ b/source/family/wiznet/target_reset_wiznet.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include +#include "cmsis_os2.h" #include "target_reset.h" #include "swd_host.h" #include "target_family.h" @@ -33,9 +33,9 @@ static uint8_t target_set_state(TARGET_RESET_STATE state) { do { swd_set_target_reset(1); - os_dly_wait(2); + osDelay(2); swd_set_target_reset(0); - os_dly_wait(2); + osDelay(2); } while(!swd_init_debug()); swd_off(); diff --git a/source/hic_hal/atmel/sam3u2c/DAP_config.h b/source/hic_hal/atmel/sam3u2c/DAP_config.h index ca1b3256c..d2ecc69b3 100644 --- a/source/hic_hal/atmel/sam3u2c/DAP_config.h +++ b/source/hic_hal/atmel/sam3u2c/DAP_config.h @@ -391,7 +391,7 @@ static __forceinline void PIN_nRESET_OUT(uint32_t bit) PIN_SWCLK_PORT->PIO_OER = PIN_SWCLK; PIN_SWDIO_PORT->PIO_CODR = PIN_SWDIO; PIN_SWCLK_PORT->PIO_CODR = PIN_SWCLK; - os_dly_wait(1); + osDelay(1); } } #else diff --git a/source/hic_hal/atmel/sam3u2c/gpio.c b/source/hic_hal/atmel/sam3u2c/gpio.c index 8426f5696..9479c7416 100644 --- a/source/hic_hal/atmel/sam3u2c/gpio.c +++ b/source/hic_hal/atmel/sam3u2c/gpio.c @@ -20,7 +20,6 @@ */ #include "sam3u.h" -#include "RTL.h" #include "gpio.h" #include "uart.h" #include "compiler.h" diff --git a/source/hic_hal/atmel/sam3u2c/usbd_ATSAM3U2C.c b/source/hic_hal/atmel/sam3u2c/usbd_ATSAM3U2C.c index aabf91fb3..f4a4c7bf2 100644 --- a/source/hic_hal/atmel/sam3u2c/usbd_ATSAM3U2C.c +++ b/source/hic_hal/atmel/sam3u2c/usbd_ATSAM3U2C.c @@ -19,7 +19,6 @@ * limitations under the License. */ -#include "RTL.h" #include "rl_usb.h" #include "sam3u.h" #include "util.h" diff --git a/source/hic_hal/freescale/k20dx/gpio.c b/source/hic_hal/freescale/k20dx/gpio.c index 483804699..a12026f05 100644 --- a/source/hic_hal/freescale/k20dx/gpio.c +++ b/source/hic_hal/freescale/k20dx/gpio.c @@ -20,7 +20,6 @@ */ #include "MK20D5.h" -#include "RTL.h" #include "DAP_config.h" #include "gpio.h" #include "target_reset.h" diff --git a/source/hic_hal/freescale/k26f/gpio.c b/source/hic_hal/freescale/k26f/gpio.c index 95557c56c..c9c74bb3c 100644 --- a/source/hic_hal/freescale/k26f/gpio.c +++ b/source/hic_hal/freescale/k26f/gpio.c @@ -21,7 +21,6 @@ */ #include "fsl_device_registers.h" -#include "RTL.h" #include "DAP_config.h" #include "gpio.h" #include "target_reset.h" diff --git a/source/hic_hal/freescale/k26f/usbd_MK26F.c b/source/hic_hal/freescale/k26f/usbd_MK26F.c index aa8ffd0e6..dc8f9be0b 100644 --- a/source/hic_hal/freescale/k26f/usbd_MK26F.c +++ b/source/hic_hal/freescale/k26f/usbd_MK26F.c @@ -19,7 +19,6 @@ * limitations under the License. */ -#include "RTL.h" #include "rl_usb.h" #include "usb.h" #include "fsl_device_registers.h" diff --git a/source/hic_hal/freescale/usbd_kinetis.c b/source/hic_hal/freescale/usbd_kinetis.c index ca732909a..1bfb93479 100644 --- a/source/hic_hal/freescale/usbd_kinetis.c +++ b/source/hic_hal/freescale/usbd_kinetis.c @@ -19,7 +19,6 @@ * limitations under the License. */ -#include "RTL.h" #include "rl_usb.h" #include "fsl_device_registers.h" #include "cortex_m.h" diff --git a/source/hic_hal/maxim/max32620/usbd_max32620.c b/source/hic_hal/maxim/max32620/usbd_max32620.c index 6fe100afc..f2e627b0e 100644 --- a/source/hic_hal/maxim/max32620/usbd_max32620.c +++ b/source/hic_hal/maxim/max32620/usbd_max32620.c @@ -15,7 +15,6 @@ */ #include -#include "RTL.h" #include "rl_usb.h" #include "util.h" diff --git a/source/hic_hal/maxim/max32625/usbd_max32625.c b/source/hic_hal/maxim/max32625/usbd_max32625.c index 3daccd945..c9fdf1885 100755 --- a/source/hic_hal/maxim/max32625/usbd_max32625.c +++ b/source/hic_hal/maxim/max32625/usbd_max32625.c @@ -15,7 +15,6 @@ */ #include -#include "RTL.h" #include "rl_usb.h" #include "util.h" diff --git a/source/hic_hal/nxp/lpc11u35/gpio.c b/source/hic_hal/nxp/lpc11u35/gpio.c index 700d50324..541fdd59f 100644 --- a/source/hic_hal/nxp/lpc11u35/gpio.c +++ b/source/hic_hal/nxp/lpc11u35/gpio.c @@ -20,7 +20,6 @@ */ #include "LPC11Uxx.h" -#include "RTL.h" #include "gpio.h" #include "compiler.h" #include "target_reset.h" diff --git a/source/hic_hal/nxp/lpc11u35/usbd_LPC11Uxx.c b/source/hic_hal/nxp/lpc11u35/usbd_LPC11Uxx.c index 8d56719d8..c609675f6 100644 --- a/source/hic_hal/nxp/lpc11u35/usbd_LPC11Uxx.c +++ b/source/hic_hal/nxp/lpc11u35/usbd_LPC11Uxx.c @@ -19,7 +19,6 @@ * limitations under the License. */ -#include "RTL.h" #include "rl_usb.h" #include "LPC11Uxx.h" #include "compiler.h" diff --git a/source/hic_hal/nxp/lpc4322/DAP_config.h b/source/hic_hal/nxp/lpc4322/DAP_config.h index 4469f3d50..ae596d553 100644 --- a/source/hic_hal/nxp/lpc4322/DAP_config.h +++ b/source/hic_hal/nxp/lpc4322/DAP_config.h @@ -37,7 +37,15 @@ Provides definitions about: #include "LPC43xx.h" // Debug Unit Cortex-M Processor Header File #include "lpc43xx_scu.h" -#include "RTL.h" + +typedef unsigned int BOOL; + +#ifndef __TRUE + #define __TRUE 1 +#endif +#ifndef __FALSE + #define __FALSE 0 +#endif /// Processor Clock of the Cortex-M MCU used in the Debug Unit. /// This value is used to calculate the SWD/JTAG clock speed. diff --git a/source/hic_hal/nxp/lpc4322/gpio.c b/source/hic_hal/nxp/lpc4322/gpio.c index e0bb6a247..489f6d579 100644 --- a/source/hic_hal/nxp/lpc4322/gpio.c +++ b/source/hic_hal/nxp/lpc4322/gpio.c @@ -20,7 +20,6 @@ */ #include "LPC43xx.h" -#include "RTL.h" #include "lpc43xx_scu.h" #include "gpio.h" #include "compiler.h" diff --git a/source/hic_hal/nxp/lpc4322/uart.c b/source/hic_hal/nxp/lpc4322/uart.c index b11dd6ded..6557e060f 100644 --- a/source/hic_hal/nxp/lpc4322/uart.c +++ b/source/hic_hal/nxp/lpc4322/uart.c @@ -35,7 +35,7 @@ extern uint32_t SystemCoreClock; #define RX_OVRF_MSG "\n" #define RX_OVRF_MSG_SIZE (sizeof(RX_OVRF_MSG) - 1) -#define BUFFER_SIZE (64) +#define BUFFER_SIZE (512) circ_buf_t write_buffer; uint8_t write_buffer_data[BUFFER_SIZE]; diff --git a/source/hic_hal/nxp/lpc4322/usbd_LPC43xx_USB0.c b/source/hic_hal/nxp/lpc4322/usbd_LPC43xx_USB0.c index 72e2d36be..5b19d6494 100644 --- a/source/hic_hal/nxp/lpc4322/usbd_LPC43xx_USB0.c +++ b/source/hic_hal/nxp/lpc4322/usbd_LPC43xx_USB0.c @@ -19,7 +19,6 @@ * limitations under the License. */ -#include "RTL.h" #include "rl_usb.h" #include "usb.h" #include "LPC43xx.h" diff --git a/source/hic_hal/stm32/stm32f103xb/DAP_config.h b/source/hic_hal/stm32/stm32f103xb/DAP_config.h index d8767ff6f..95b29f66f 100644 --- a/source/hic_hal/stm32/stm32f103xb/DAP_config.h +++ b/source/hic_hal/stm32/stm32f103xb/DAP_config.h @@ -24,7 +24,7 @@ #include "stm32f1xx.h" #include "stdint.h" -#include "RTL.h" +#include "cmsis_os2.h" #include "IO_Config.h" #include "uart.h" //#include "debug_cm.h" diff --git a/source/hic_hal/stm32/stm32f103xb/gpio.c b/source/hic_hal/stm32/stm32f103xb/gpio.c index 2fd7276c2..8eb745ccc 100644 --- a/source/hic_hal/stm32/stm32f103xb/gpio.c +++ b/source/hic_hal/stm32/stm32f103xb/gpio.c @@ -20,7 +20,6 @@ */ #include "stm32f1xx.h" -#include "RTL.h" #include "DAP_config.h" #include "gpio.h" #include "target_reset.h" diff --git a/source/hic_hal/stm32/stm32f103xb/sdk.c b/source/hic_hal/stm32/stm32f103xb/sdk.c index 9fa566e0b..8a2fec150 100644 --- a/source/hic_hal/stm32/stm32f103xb/sdk.c +++ b/source/hic_hal/stm32/stm32f103xb/sdk.c @@ -20,7 +20,6 @@ */ #include "stm32f1xx.h" -#include "RTL.h" #include "DAP_config.h" #include "gpio.h" #include "target_reset.h" diff --git a/source/hic_hal/stm32/stm32f103xb/usbd_STM32F103.c b/source/hic_hal/stm32/stm32f103xb/usbd_STM32F103.c index b792b7476..319d1166b 100644 --- a/source/hic_hal/stm32/stm32f103xb/usbd_STM32F103.c +++ b/source/hic_hal/stm32/stm32f103xb/usbd_STM32F103.c @@ -26,7 +26,6 @@ /* Double Buffering is not supported */ -#include #include #include "stm32f1xx.h" #include "usbreg.h" diff --git a/source/hic_hal/target_config.h b/source/hic_hal/target_config.h index a43befead..972ff9afa 100644 --- a/source/hic_hal/target_config.h +++ b/source/hic_hal/target_config.h @@ -44,10 +44,16 @@ extern "C" { #define MAX_EXTRA_FLASH_REGION 3 #define MAX_EXTRA_RAM_REGION 3 -typedef struct region_info { +typedef struct flash_region_info { uint32_t start; uint32_t end; -} region_info_t; + program_target_t *flash_algo; +} flash_region_info_t; + +typedef struct ram_region_info { + uint32_t start; + uint32_t end; +} ram_region_info_t; /** @struct target_cfg_t @@ -64,8 +70,8 @@ typedef struct target_cfg { uint8_t erase_reset; /*!< Reset after performing an erase */ const sector_info_t* sectors_info; int sector_info_length; - region_info_t extra_flash[MAX_EXTRA_FLASH_REGION + 1]; /*!< Extra flash regions */ - region_info_t extra_ram[MAX_EXTRA_RAM_REGION + 1]; /*!< Extra RAM regions */ + flash_region_info_t extra_flash[MAX_EXTRA_FLASH_REGION + 1]; /*!< Extra flash regions */ + ram_region_info_t extra_ram[MAX_EXTRA_RAM_REGION + 1]; /*!< Extra RAM regions */ const char *rt_board_id; /*!< If assigned, this is a flexible board ID */ uint16_t rt_family_id; /*!< If assigned, this is a flexible board ID */ } target_cfg_t; diff --git a/source/daplink/RTX_Config.c b/source/rtos/RTX_Config.c similarity index 91% rename from source/daplink/RTX_Config.c rename to source/rtos/RTX_Config.c index 51e3518d6..44c8e0bfa 100644 --- a/source/daplink/RTX_Config.c +++ b/source/rtos/RTX_Config.c @@ -83,28 +83,14 @@ // ============================= // Timer clock value [Hz] <1-1000000000> // Set the timer clock value for selected timer. -// Default: 6000000 (6MHz) #ifndef OS_CLOCK -#if defined(INTERFACE_LPC11U35) || defined(INTERFACE_K20D5) || defined (INTERFACE_KL26Z) -#define OS_CLOCK 48000000 -#elif defined(INTERFACE_K26F) -#define OS_CLOCK 120000000 -#elif defined(INTERFACE_SAM3U2C) -#define OS_CLOCK 96000000 -#elif defined(INTERFACE_LPC4322) -#define OS_CLOCK 96000000 -#elif defined(INTERFACE_STM32F103XB) -#define OS_CLOCK 72000000 -#elif defined(INTERFACE_MAX32620) || defined(INTERFACE_MAX32625) -#define OS_CLOCK 96000000 -#endif +#error "OS_CLOCK should be defined by HIC configuration" #endif // Timer tick value [us] <1-1000000> // Set the timer tick value for selected timer. -// Default: 10000 (10ms) #ifndef OS_TICK -#define OS_TICK 10000 +#error "OS_TICK should be defined by RTOS configuration" #endif // diff --git a/source/rtos/cmsis_os2.h b/source/rtos/cmsis_os2.h new file mode 100644 index 000000000..e0b602c79 --- /dev/null +++ b/source/rtos/cmsis_os2.h @@ -0,0 +1,756 @@ +/* + * Copyright (c) 2013-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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 + * + * 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. + * + * ---------------------------------------------------------------------- + * + * $Date: 18. June 2018 + * $Revision: V2.1.3 + * + * Project: CMSIS-RTOS2 API + * Title: cmsis_os2.h header file + * + * Version 2.1.3 + * Additional functions allowed to be called from Interrupt Service Routines: + * - osThreadGetId + * Version 2.1.2 + * Additional functions allowed to be called from Interrupt Service Routines: + * - osKernelGetInfo, osKernelGetState + * Version 2.1.1 + * Additional functions allowed to be called from Interrupt Service Routines: + * - osKernelGetTickCount, osKernelGetTickFreq + * Changed Kernel Tick type to uint32_t: + * - updated: osKernelGetTickCount, osDelayUntil + * Version 2.1.0 + * Support for critical and uncritical sections (nesting safe): + * - updated: osKernelLock, osKernelUnlock + * - added: osKernelRestoreLock + * Updated Thread and Event Flags: + * - changed flags parameter and return type from int32_t to uint32_t + * Version 2.0.0 + * Initial Release + *---------------------------------------------------------------------------*/ + +#ifndef CMSIS_OS2_H_ +#define CMSIS_OS2_H_ + +#ifndef __NO_RETURN +#if defined(__CC_ARM) +#define __NO_RETURN __declspec(noreturn) +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) +#define __NO_RETURN __attribute__((__noreturn__)) +#elif defined(__GNUC__) +#define __NO_RETURN __attribute__((__noreturn__)) +#elif defined(__ICCARM__) +#define __NO_RETURN __noreturn +#else +#define __NO_RETURN +#endif +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + +// ==== Enumerations, structures, defines ==== + +/// Version information. +typedef struct { + uint32_t api; ///< API version (major.minor.rev: mmnnnrrrr dec). + uint32_t kernel; ///< Kernel version (major.minor.rev: mmnnnrrrr dec). +} osVersion_t; + +/// Kernel state. +typedef enum { + osKernelInactive = 0, ///< Inactive. + osKernelReady = 1, ///< Ready. + osKernelRunning = 2, ///< Running. + osKernelLocked = 3, ///< Locked. + osKernelSuspended = 4, ///< Suspended. + osKernelError = -1, ///< Error. + osKernelReserved = 0x7FFFFFFFU ///< Prevents enum down-size compiler optimization. +} osKernelState_t; + +/// Thread state. +typedef enum { + osThreadInactive = 0, ///< Inactive. + osThreadReady = 1, ///< Ready. + osThreadRunning = 2, ///< Running. + osThreadBlocked = 3, ///< Blocked. + osThreadTerminated = 4, ///< Terminated. + osThreadError = -1, ///< Error. + osThreadReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. +} osThreadState_t; + +/// Priority values. +typedef enum { + osPriorityNone = 0, ///< No priority (not initialized). + osPriorityIdle = 1, ///< Reserved for Idle thread. + osPriorityLow = 8, ///< Priority: low + osPriorityLow1 = 8+1, ///< Priority: low + 1 + osPriorityLow2 = 8+2, ///< Priority: low + 2 + osPriorityLow3 = 8+3, ///< Priority: low + 3 + osPriorityLow4 = 8+4, ///< Priority: low + 4 + osPriorityLow5 = 8+5, ///< Priority: low + 5 + osPriorityLow6 = 8+6, ///< Priority: low + 6 + osPriorityLow7 = 8+7, ///< Priority: low + 7 + osPriorityBelowNormal = 16, ///< Priority: below normal + osPriorityBelowNormal1 = 16+1, ///< Priority: below normal + 1 + osPriorityBelowNormal2 = 16+2, ///< Priority: below normal + 2 + osPriorityBelowNormal3 = 16+3, ///< Priority: below normal + 3 + osPriorityBelowNormal4 = 16+4, ///< Priority: below normal + 4 + osPriorityBelowNormal5 = 16+5, ///< Priority: below normal + 5 + osPriorityBelowNormal6 = 16+6, ///< Priority: below normal + 6 + osPriorityBelowNormal7 = 16+7, ///< Priority: below normal + 7 + osPriorityNormal = 24, ///< Priority: normal + osPriorityNormal1 = 24+1, ///< Priority: normal + 1 + osPriorityNormal2 = 24+2, ///< Priority: normal + 2 + osPriorityNormal3 = 24+3, ///< Priority: normal + 3 + osPriorityNormal4 = 24+4, ///< Priority: normal + 4 + osPriorityNormal5 = 24+5, ///< Priority: normal + 5 + osPriorityNormal6 = 24+6, ///< Priority: normal + 6 + osPriorityNormal7 = 24+7, ///< Priority: normal + 7 + osPriorityAboveNormal = 32, ///< Priority: above normal + osPriorityAboveNormal1 = 32+1, ///< Priority: above normal + 1 + osPriorityAboveNormal2 = 32+2, ///< Priority: above normal + 2 + osPriorityAboveNormal3 = 32+3, ///< Priority: above normal + 3 + osPriorityAboveNormal4 = 32+4, ///< Priority: above normal + 4 + osPriorityAboveNormal5 = 32+5, ///< Priority: above normal + 5 + osPriorityAboveNormal6 = 32+6, ///< Priority: above normal + 6 + osPriorityAboveNormal7 = 32+7, ///< Priority: above normal + 7 + osPriorityHigh = 40, ///< Priority: high + osPriorityHigh1 = 40+1, ///< Priority: high + 1 + osPriorityHigh2 = 40+2, ///< Priority: high + 2 + osPriorityHigh3 = 40+3, ///< Priority: high + 3 + osPriorityHigh4 = 40+4, ///< Priority: high + 4 + osPriorityHigh5 = 40+5, ///< Priority: high + 5 + osPriorityHigh6 = 40+6, ///< Priority: high + 6 + osPriorityHigh7 = 40+7, ///< Priority: high + 7 + osPriorityRealtime = 48, ///< Priority: realtime + osPriorityRealtime1 = 48+1, ///< Priority: realtime + 1 + osPriorityRealtime2 = 48+2, ///< Priority: realtime + 2 + osPriorityRealtime3 = 48+3, ///< Priority: realtime + 3 + osPriorityRealtime4 = 48+4, ///< Priority: realtime + 4 + osPriorityRealtime5 = 48+5, ///< Priority: realtime + 5 + osPriorityRealtime6 = 48+6, ///< Priority: realtime + 6 + osPriorityRealtime7 = 48+7, ///< Priority: realtime + 7 + osPriorityISR = 56, ///< Reserved for ISR deferred thread. + osPriorityError = -1, ///< System cannot determine priority or illegal priority. + osPriorityReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. +} osPriority_t; + +/// Entry point of a thread. +typedef void (*osThreadFunc_t) (void *argument); + +/// Timer callback function. +typedef void (*osTimerFunc_t) (void *argument); + +/// Timer type. +typedef enum { + osTimerOnce = 0, ///< One-shot timer. + osTimerPeriodic = 1 ///< Repeating timer. +} osTimerType_t; + +// Timeout value. +#define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value. + +// Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait). +#define osFlagsWaitAny 0x00000000U ///< Wait for any flag (default). +#define osFlagsWaitAll 0x00000001U ///< Wait for all flags. +#define osFlagsNoClear 0x00000002U ///< Do not clear flags which have been specified to wait for. + +// Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx). +#define osFlagsError 0x80000000U ///< Error indicator. +#define osFlagsErrorUnknown 0xFFFFFFFFU ///< osError (-1). +#define osFlagsErrorTimeout 0xFFFFFFFEU ///< osErrorTimeout (-2). +#define osFlagsErrorResource 0xFFFFFFFDU ///< osErrorResource (-3). +#define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4). +#define osFlagsErrorISR 0xFFFFFFFAU ///< osErrorISR (-6). + +// Thread attributes (attr_bits in \ref osThreadAttr_t). +#define osThreadDetached 0x00000000U ///< Thread created in detached mode (default) +#define osThreadJoinable 0x00000001U ///< Thread created in joinable mode + +// Mutex attributes (attr_bits in \ref osMutexAttr_t). +#define osMutexRecursive 0x00000001U ///< Recursive mutex. +#define osMutexPrioInherit 0x00000002U ///< Priority inherit protocol. +#define osMutexRobust 0x00000008U ///< Robust mutex. + +/// Status code values returned by CMSIS-RTOS functions. +typedef enum { + osOK = 0, ///< Operation completed successfully. + osError = -1, ///< Unspecified RTOS error: run-time error but no other error message fits. + osErrorTimeout = -2, ///< Operation not completed within the timeout period. + osErrorResource = -3, ///< Resource not available. + osErrorParameter = -4, ///< Parameter error. + osErrorNoMemory = -5, ///< System is out of memory: it was impossible to allocate or reserve memory for the operation. + osErrorISR = -6, ///< Not allowed in ISR context: the function cannot be called from interrupt service routines. + osStatusReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. +} osStatus_t; + + +/// \details Thread ID identifies the thread. +typedef void *osThreadId_t; + +/// \details Timer ID identifies the timer. +typedef void *osTimerId_t; + +/// \details Event Flags ID identifies the event flags. +typedef void *osEventFlagsId_t; + +/// \details Mutex ID identifies the mutex. +typedef void *osMutexId_t; + +/// \details Semaphore ID identifies the semaphore. +typedef void *osSemaphoreId_t; + +/// \details Memory Pool ID identifies the memory pool. +typedef void *osMemoryPoolId_t; + +/// \details Message Queue ID identifies the message queue. +typedef void *osMessageQueueId_t; + + +#ifndef TZ_MODULEID_T +#define TZ_MODULEID_T +/// \details Data type that identifies secure software modules called by a process. +typedef uint32_t TZ_ModuleId_t; +#endif + + +/// Attributes structure for thread. +typedef struct { + const char *name; ///< name of the thread + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block + void *stack_mem; ///< memory for stack + uint32_t stack_size; ///< size of stack + osPriority_t priority; ///< initial thread priority (default: osPriorityNormal) + TZ_ModuleId_t tz_module; ///< TrustZone module identifier + uint32_t reserved; ///< reserved (must be 0) +} osThreadAttr_t; + +/// Attributes structure for timer. +typedef struct { + const char *name; ///< name of the timer + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osTimerAttr_t; + +/// Attributes structure for event flags. +typedef struct { + const char *name; ///< name of the event flags + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osEventFlagsAttr_t; + +/// Attributes structure for mutex. +typedef struct { + const char *name; ///< name of the mutex + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osMutexAttr_t; + +/// Attributes structure for semaphore. +typedef struct { + const char *name; ///< name of the semaphore + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osSemaphoreAttr_t; + +/// Attributes structure for memory pool. +typedef struct { + const char *name; ///< name of the memory pool + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block + void *mp_mem; ///< memory for data storage + uint32_t mp_size; ///< size of provided memory for data storage +} osMemoryPoolAttr_t; + +/// Attributes structure for message queue. +typedef struct { + const char *name; ///< name of the message queue + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block + void *mq_mem; ///< memory for data storage + uint32_t mq_size; ///< size of provided memory for data storage +} osMessageQueueAttr_t; + + +// ==== Kernel Management Functions ==== + +/// Initialize the RTOS Kernel. +/// \return status code that indicates the execution status of the function. +osStatus_t osKernelInitialize (void); + +/// Get RTOS Kernel Information. +/// \param[out] version pointer to buffer for retrieving version information. +/// \param[out] id_buf pointer to buffer for retrieving kernel identification string. +/// \param[in] id_size size of buffer for kernel identification string. +/// \return status code that indicates the execution status of the function. +osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size); + +/// Get the current RTOS Kernel state. +/// \return current RTOS Kernel state. +osKernelState_t osKernelGetState (void); + +/// Start the RTOS Kernel scheduler. +/// \return status code that indicates the execution status of the function. +osStatus_t osKernelStart (void); + +/// Lock the RTOS Kernel scheduler. +/// \return previous lock state (1 - locked, 0 - not locked, error code if negative). +int32_t osKernelLock (void); + +/// Unlock the RTOS Kernel scheduler. +/// \return previous lock state (1 - locked, 0 - not locked, error code if negative). +int32_t osKernelUnlock (void); + +/// Restore the RTOS Kernel scheduler lock state. +/// \param[in] lock lock state obtained by \ref osKernelLock or \ref osKernelUnlock. +/// \return new lock state (1 - locked, 0 - not locked, error code if negative). +int32_t osKernelRestoreLock (int32_t lock); + +/// Suspend the RTOS Kernel scheduler. +/// \return time in ticks, for how long the system can sleep or power-down. +uint32_t osKernelSuspend (void); + +/// Resume the RTOS Kernel scheduler. +/// \param[in] sleep_ticks time in ticks for how long the system was in sleep or power-down mode. +void osKernelResume (uint32_t sleep_ticks); + +/// Get the RTOS kernel tick count. +/// \return RTOS kernel current tick count. +uint32_t osKernelGetTickCount (void); + +/// Get the RTOS kernel tick frequency. +/// \return frequency of the kernel tick in hertz, i.e. kernel ticks per second. +uint32_t osKernelGetTickFreq (void); + +/// Get the RTOS kernel system timer count. +/// \return RTOS kernel current system timer count as 32-bit value. +uint32_t osKernelGetSysTimerCount (void); + +/// Get the RTOS kernel system timer frequency. +/// \return frequency of the system timer in hertz, i.e. timer ticks per second. +uint32_t osKernelGetSysTimerFreq (void); + + +// ==== Thread Management Functions ==== + +/// Create a thread and add it to Active Threads. +/// \param[in] func thread function. +/// \param[in] argument pointer that is passed to the thread function as start argument. +/// \param[in] attr thread attributes; NULL: default values. +/// \return thread ID for reference by other functions or NULL in case of error. +osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr); + +/// Get name of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return name as null-terminated string. +const char *osThreadGetName (osThreadId_t thread_id); + +/// Return the thread ID of the current running thread. +/// \return thread ID for reference by other functions or NULL in case of error. +osThreadId_t osThreadGetId (void); + +/// Get current thread state of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return current thread state of the specified thread. +osThreadState_t osThreadGetState (osThreadId_t thread_id); + +/// Get stack size of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return stack size in bytes. +uint32_t osThreadGetStackSize (osThreadId_t thread_id); + +/// Get available stack space of a thread based on stack watermark recording during execution. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return remaining stack space in bytes. +uint32_t osThreadGetStackSpace (osThreadId_t thread_id); + +/// Change priority of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \param[in] priority new priority value for the thread function. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority); + +/// Get current priority of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return current priority value of the specified thread. +osPriority_t osThreadGetPriority (osThreadId_t thread_id); + +/// Pass control to next thread that is in state \b READY. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadYield (void); + +/// Suspend execution of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadSuspend (osThreadId_t thread_id); + +/// Resume execution of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadResume (osThreadId_t thread_id); + +/// Detach a thread (thread storage can be reclaimed when thread terminates). +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadDetach (osThreadId_t thread_id); + +/// Wait for specified thread to terminate. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadJoin (osThreadId_t thread_id); + +/// Terminate execution of current running thread. +__NO_RETURN void osThreadExit (void); + +/// Terminate execution of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadTerminate (osThreadId_t thread_id); + +/// Get number of active threads. +/// \return number of active threads. +uint32_t osThreadGetCount (void); + +/// Enumerate active threads. +/// \param[out] thread_array pointer to array for retrieving thread IDs. +/// \param[in] array_items maximum number of items in array for retrieving thread IDs. +/// \return number of enumerated threads. +uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items); + + +// ==== Thread Flags Functions ==== + +/// Set the specified Thread Flags of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \param[in] flags specifies the flags of the thread that shall be set. +/// \return thread flags after setting or error code if highest bit set. +uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags); + +/// Clear the specified Thread Flags of current running thread. +/// \param[in] flags specifies the flags of the thread that shall be cleared. +/// \return thread flags before clearing or error code if highest bit set. +uint32_t osThreadFlagsClear (uint32_t flags); + +/// Get the current Thread Flags of current running thread. +/// \return current thread flags. +uint32_t osThreadFlagsGet (void); + +/// Wait for one or more Thread Flags of the current running thread to become signaled. +/// \param[in] flags specifies the flags to wait for. +/// \param[in] options specifies flags options (osFlagsXxxx). +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return thread flags before clearing or error code if highest bit set. +uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout); + + +// ==== Generic Wait Functions ==== + +/// Wait for Timeout (Time Delay). +/// \param[in] ticks \ref CMSIS_RTOS_TimeOutValue "time ticks" value +/// \return status code that indicates the execution status of the function. +osStatus_t osDelay (uint32_t ticks); + +/// Wait until specified time. +/// \param[in] ticks absolute time in ticks +/// \return status code that indicates the execution status of the function. +osStatus_t osDelayUntil (uint32_t ticks); + + +// ==== Timer Management Functions ==== + +/// Create and Initialize a timer. +/// \param[in] func function pointer to callback function. +/// \param[in] type \ref osTimerOnce for one-shot or \ref osTimerPeriodic for periodic behavior. +/// \param[in] argument argument to the timer callback function. +/// \param[in] attr timer attributes; NULL: default values. +/// \return timer ID for reference by other functions or NULL in case of error. +osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr); + +/// Get name of a timer. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \return name as null-terminated string. +const char *osTimerGetName (osTimerId_t timer_id); + +/// Start or restart a timer. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \param[in] ticks \ref CMSIS_RTOS_TimeOutValue "time ticks" value of the timer. +/// \return status code that indicates the execution status of the function. +osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks); + +/// Stop a timer. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osTimerStop (osTimerId_t timer_id); + +/// Check if a timer is running. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \return 0 not running, 1 running. +uint32_t osTimerIsRunning (osTimerId_t timer_id); + +/// Delete a timer. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osTimerDelete (osTimerId_t timer_id); + + +// ==== Event Flags Management Functions ==== + +/// Create and Initialize an Event Flags object. +/// \param[in] attr event flags attributes; NULL: default values. +/// \return event flags ID for reference by other functions or NULL in case of error. +osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr); + +/// Get name of an Event Flags object. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \return name as null-terminated string. +const char *osEventFlagsGetName (osEventFlagsId_t ef_id); + +/// Set the specified Event Flags. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \param[in] flags specifies the flags that shall be set. +/// \return event flags after setting or error code if highest bit set. +uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags); + +/// Clear the specified Event Flags. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \param[in] flags specifies the flags that shall be cleared. +/// \return event flags before clearing or error code if highest bit set. +uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags); + +/// Get the current Event Flags. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \return current event flags. +uint32_t osEventFlagsGet (osEventFlagsId_t ef_id); + +/// Wait for one or more Event Flags to become signaled. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \param[in] flags specifies the flags to wait for. +/// \param[in] options specifies flags options (osFlagsXxxx). +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return event flags before clearing or error code if highest bit set. +uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout); + +/// Delete an Event Flags object. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id); + + +// ==== Mutex Management Functions ==== + +/// Create and Initialize a Mutex object. +/// \param[in] attr mutex attributes; NULL: default values. +/// \return mutex ID for reference by other functions or NULL in case of error. +osMutexId_t osMutexNew (const osMutexAttr_t *attr); + +/// Get name of a Mutex object. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return name as null-terminated string. +const char *osMutexGetName (osMutexId_t mutex_id); + +/// Acquire a Mutex or timeout if it is locked. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout); + +/// Release a Mutex that was acquired by \ref osMutexAcquire. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMutexRelease (osMutexId_t mutex_id); + +/// Get Thread which owns a Mutex object. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return thread ID of owner thread or NULL when mutex was not acquired. +osThreadId_t osMutexGetOwner (osMutexId_t mutex_id); + +/// Delete a Mutex object. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMutexDelete (osMutexId_t mutex_id); + + +// ==== Semaphore Management Functions ==== + +/// Create and Initialize a Semaphore object. +/// \param[in] max_count maximum number of available tokens. +/// \param[in] initial_count initial number of available tokens. +/// \param[in] attr semaphore attributes; NULL: default values. +/// \return semaphore ID for reference by other functions or NULL in case of error. +osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr); + +/// Get name of a Semaphore object. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \return name as null-terminated string. +const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id); + +/// Acquire a Semaphore token or timeout if no tokens are available. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout); + +/// Release a Semaphore token up to the initial maximum count. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id); + +/// Get current Semaphore token count. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \return number of tokens available. +uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id); + +/// Delete a Semaphore object. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id); + + +// ==== Memory Pool Management Functions ==== + +/// Create and Initialize a Memory Pool object. +/// \param[in] block_count maximum number of memory blocks in memory pool. +/// \param[in] block_size memory block size in bytes. +/// \param[in] attr memory pool attributes; NULL: default values. +/// \return memory pool ID for reference by other functions or NULL in case of error. +osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr); + +/// Get name of a Memory Pool object. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return name as null-terminated string. +const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id); + +/// Allocate a memory block from a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return address of the allocated memory block or NULL in case of no memory is available. +void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout); + +/// Return an allocated memory block back to a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \param[in] block address of the allocated memory block to be returned to the memory pool. +/// \return status code that indicates the execution status of the function. +osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block); + +/// Get maximum number of memory blocks in a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return maximum number of memory blocks. +uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id); + +/// Get memory block size in a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return memory block size in bytes. +uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id); + +/// Get number of memory blocks used in a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return number of memory blocks used. +uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id); + +/// Get number of memory blocks available in a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return number of memory blocks available. +uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id); + +/// Delete a Memory Pool object. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id); + + +// ==== Message Queue Management Functions ==== + +/// Create and Initialize a Message Queue object. +/// \param[in] msg_count maximum number of messages in queue. +/// \param[in] msg_size maximum message size in bytes. +/// \param[in] attr message queue attributes; NULL: default values. +/// \return message queue ID for reference by other functions or NULL in case of error. +osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr); + +/// Get name of a Message Queue object. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return name as null-terminated string. +const char *osMessageQueueGetName (osMessageQueueId_t mq_id); + +/// Put a Message into a Queue or timeout if Queue is full. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \param[in] msg_ptr pointer to buffer with message to put into a queue. +/// \param[in] msg_prio message priority. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout); + +/// Get a Message from a Queue or timeout if Queue is empty. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \param[out] msg_ptr pointer to buffer for message to get from a queue. +/// \param[out] msg_prio pointer to buffer for message priority or NULL. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout); + +/// Get maximum number of messages in a Message Queue. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return maximum number of messages. +uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id); + +/// Get maximum message size in a Memory Pool. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return maximum message size in bytes. +uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id); + +/// Get number of queued messages in a Message Queue. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return number of queued messages. +uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id); + +/// Get number of available slots for messages in a Message Queue. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return number of available slots for messages. +uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id); + +/// Reset a Message Queue to initial empty state. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id); + +/// Delete a Message Queue object. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id); + + +#ifdef __cplusplus +} +#endif + +#endif // CMSIS_OS2_H_ diff --git a/source/rtos/cmsis_os2_port.c b/source/rtos/cmsis_os2_port.c new file mode 100644 index 000000000..bcb5c0bd4 --- /dev/null +++ b/source/rtos/cmsis_os2_port.c @@ -0,0 +1,141 @@ +/** + * @file cmsis_os2_port.c + * @brief + * + * DAPLink Interface Firmware + * Copyright (c) 2019, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +#include "cmsis_os2.h" +#include "RTL.h" +#include "cortex_m.h" + +#define MAIN_TASK_PRIORITY (10) +#define MAIN_TASK_STACK (800) +static uint64_t stk_main_task [MAIN_TASK_STACK / sizeof(uint64_t)]; + +#define TIMER_TASK_30_PRIORITY (11) +#define TIMER_TASK_STACK (136) +static uint64_t stk_timer_task[TIMER_TASK_STACK / sizeof(uint64_t)]; + +static uint32_t taskCount = 0; +static osTimerFunc_t onlyTimerFunction = NULL; +static uint32_t timerTick = 0; + +static OS_MUT onlyMutex; + +osStatus_t osKernelInitialize(void) +{ + taskCount = 0; + return osOK; +} + +osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) +{ + OS_TID tid = 0; + //first task will init the rtx + if (taskCount == 0) { + os_sys_init_user((void (*)(void))func, MAIN_TASK_PRIORITY, stk_main_task, MAIN_TASK_STACK); + } + else { + tid = os_tsk_create((void (*)(void))func, MAIN_TASK_PRIORITY+1); + } + taskCount++; + return (osThreadId_t) tid; +} + +uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) +{ + if (cortex_in_isr()){ + isr_evt_set(flags, (OS_TID)thread_id); + }else { + os_evt_set(flags, (OS_TID)thread_id); + } + return flags; +} + +osStatus_t osKernelStart(void) +{ + //first thread already started the kernel + return osOK; +} + +// Timer task +static void rt_timer_task(void) +{ + os_itv_set(timerTick); + while (1) { + os_itv_wait(); + if (onlyTimerFunction) { + onlyTimerFunction(NULL); + } + } +} + +osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) +{ + OS_TID tid = 0; + onlyTimerFunction = func; + return (osTimerId_t)tid; +} + +osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks) +{ + timerTick = ticks; + OS_TID tid = os_tsk_create_user(rt_timer_task, TIMER_TASK_30_PRIORITY, (void *)stk_timer_task, TIMER_TASK_STACK); + return osOK; +} + +uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout) +{ + os_evt_wait_or(flags, timeout); + return os_evt_get(); +} + +osMutexId_t osMutexNew(const osMutexAttr_t *attr) +{ + os_mut_init(onlyMutex); + return (osMutexId_t)onlyMutex; +} + +osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) +{ + os_mut_wait((OS_ID)mutex_id, timeout); + return osOK; +} + +osStatus_t osMutexRelease(osMutexId_t mutex_id) +{ + os_mut_release((OS_ID)mutex_id); + return osOK; +} + +osThreadId_t osThreadGetId(void) +{ + return (osThreadId_t)os_tsk_self(); +} + +osStatus_t osDelay(uint32_t ticks) +{ + os_dly_wait(ticks); + return osOK; +} + +uint32_t osKernelGetSysTimerCount(void) +{ + return os_time_get(); +} + diff --git a/source/rtos_none/SysTick_Handler.c b/source/rtos_none/SysTick_Handler.c new file mode 100644 index 000000000..65c0840cd --- /dev/null +++ b/source/rtos_none/SysTick_Handler.c @@ -0,0 +1,141 @@ +/** + * @file SysTick_Handler.c + * @brief No RTOS port only needs a systick handler + * + * DAPLink Interface Firmware + * Copyright (c) 2019, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +#include "Systick_Handler.h" + +#if defined (INTERFACE_K20D5) +#include "MK20D5.h" +#elif defined (INTERFACE_K26F) +#include "MK26F18.h" +#elif defined (INTERFACE_KL26Z) +#include "MKL26Z4.h" +#elif defined (INTERFACE_LPC11U35) +#include "LPC11Uxx.h" +#elif defined (INTERFACE_LPC4322) +#include "LPC43xx.h" +#elif defined (INTERFACE_MAX32620) +#include "max32620.h" +#elif defined (INTERFACE_MAX32625) +#include "max32625.h" +#elif defined (INTERFACE_SAM3U2C) +#include "sam3u2c.h" +#elif defined (INTERFACE_STM32F103XB) +#include "stm32f103xb.h" +#else +#error "CMSIS core headers needed" +#endif + + +//SysTick Timer Configuration +#ifndef OS_CLOCK +#error "OS_CLOCK should be defined by HIC configuration" +#endif + +//Set the timer tick value for selected timer. +#ifndef OS_TICK +#error "OS_TICK should be defined by RTOS configuration" +#endif + +#define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) + + +static volatile uint32_t tick_counter = 0; +static volatile uint32_t event_flags =0; +static volatile uint32_t wait_counter = 0; + +static osTimerFunc_t sysTickCb = NULL; +static uint32_t tickFreq = 0; +static osThreadFunc_t mainFuncCb = NULL; + +void sysTickInit(void) +{ + tick_counter = 0; + event_flags=0; + wait_counter = 0; + sysTickCb = NULL; + tickFreq = 0; + mainFuncCb = NULL; + SysTick_Config(OS_TRV); +} + + +void SysTick_Handler(void) +{ + if (sysTickCb && tickFreq && (tick_counter % tickFreq)==0) { + sysTickCb(NULL); + } + tick_counter++; + if(wait_counter){ + --wait_counter; + } +} + +void sysTickRegCallback(osTimerFunc_t callback) +{ + sysTickCb = callback; +} + +void sysTickFreqSet(uint32_t ticks) +{ + tickFreq = ticks; +} + +void sysTickWait(uint32_t wait) +{ + wait_counter = wait; + while(wait_counter); +} + +void sysTickEvtSet(uint32_t flag) +{ + __disable_irq(); + event_flags |= flag; + __enable_irq(); +} + +uint32_t sysTickEvtWaitOr(uint32_t flag) +{ + uint32_t return_flags=0; + while ((flag&event_flags)==0); + return_flags = event_flags; + __disable_irq(); + event_flags &= ~return_flags; + __enable_irq(); + return return_flags; +} + +uint32_t sysTickTime(void) +{ + return tick_counter; +} + +void sysTickRegMainFunc(osThreadFunc_t func) +{ + mainFuncCb = func; +} + +void sysTickStartMain(void) +{ + if(mainFuncCb){ + mainFuncCb(NULL); + } +} + diff --git a/source/rtos_none/SysTick_Handler.h b/source/rtos_none/SysTick_Handler.h new file mode 100644 index 000000000..4cf37eaee --- /dev/null +++ b/source/rtos_none/SysTick_Handler.h @@ -0,0 +1,48 @@ +/** + * @file Systick_Handler.h + * @brief + * + * DAPLink Interface Firmware + * Copyright (c) 2019, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +#ifndef SYSTICK_HANDLER_H_ +#define SYSTICK_HANDLER_H_ + +#include "cmsis_os2.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +//functions based on system tick +void sysTickInit(void); +void sysTickRegCallback(osTimerFunc_t callback); +void sysTickFreqSet(uint32_t ticks); +void sysTickWait(uint32_t wait); +void sysTickEvtSet(uint32_t flag); +uint32_t sysTickEvtWaitOr(uint32_t flag); +uint32_t sysTickTime(void); +void sysTickRegMainFunc(osThreadFunc_t func); +void sysTickStartMain(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/rtos_none/cmsis_os2.h b/source/rtos_none/cmsis_os2.h new file mode 100644 index 000000000..e0b602c79 --- /dev/null +++ b/source/rtos_none/cmsis_os2.h @@ -0,0 +1,756 @@ +/* + * Copyright (c) 2013-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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 + * + * 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. + * + * ---------------------------------------------------------------------- + * + * $Date: 18. June 2018 + * $Revision: V2.1.3 + * + * Project: CMSIS-RTOS2 API + * Title: cmsis_os2.h header file + * + * Version 2.1.3 + * Additional functions allowed to be called from Interrupt Service Routines: + * - osThreadGetId + * Version 2.1.2 + * Additional functions allowed to be called from Interrupt Service Routines: + * - osKernelGetInfo, osKernelGetState + * Version 2.1.1 + * Additional functions allowed to be called from Interrupt Service Routines: + * - osKernelGetTickCount, osKernelGetTickFreq + * Changed Kernel Tick type to uint32_t: + * - updated: osKernelGetTickCount, osDelayUntil + * Version 2.1.0 + * Support for critical and uncritical sections (nesting safe): + * - updated: osKernelLock, osKernelUnlock + * - added: osKernelRestoreLock + * Updated Thread and Event Flags: + * - changed flags parameter and return type from int32_t to uint32_t + * Version 2.0.0 + * Initial Release + *---------------------------------------------------------------------------*/ + +#ifndef CMSIS_OS2_H_ +#define CMSIS_OS2_H_ + +#ifndef __NO_RETURN +#if defined(__CC_ARM) +#define __NO_RETURN __declspec(noreturn) +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) +#define __NO_RETURN __attribute__((__noreturn__)) +#elif defined(__GNUC__) +#define __NO_RETURN __attribute__((__noreturn__)) +#elif defined(__ICCARM__) +#define __NO_RETURN __noreturn +#else +#define __NO_RETURN +#endif +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + +// ==== Enumerations, structures, defines ==== + +/// Version information. +typedef struct { + uint32_t api; ///< API version (major.minor.rev: mmnnnrrrr dec). + uint32_t kernel; ///< Kernel version (major.minor.rev: mmnnnrrrr dec). +} osVersion_t; + +/// Kernel state. +typedef enum { + osKernelInactive = 0, ///< Inactive. + osKernelReady = 1, ///< Ready. + osKernelRunning = 2, ///< Running. + osKernelLocked = 3, ///< Locked. + osKernelSuspended = 4, ///< Suspended. + osKernelError = -1, ///< Error. + osKernelReserved = 0x7FFFFFFFU ///< Prevents enum down-size compiler optimization. +} osKernelState_t; + +/// Thread state. +typedef enum { + osThreadInactive = 0, ///< Inactive. + osThreadReady = 1, ///< Ready. + osThreadRunning = 2, ///< Running. + osThreadBlocked = 3, ///< Blocked. + osThreadTerminated = 4, ///< Terminated. + osThreadError = -1, ///< Error. + osThreadReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. +} osThreadState_t; + +/// Priority values. +typedef enum { + osPriorityNone = 0, ///< No priority (not initialized). + osPriorityIdle = 1, ///< Reserved for Idle thread. + osPriorityLow = 8, ///< Priority: low + osPriorityLow1 = 8+1, ///< Priority: low + 1 + osPriorityLow2 = 8+2, ///< Priority: low + 2 + osPriorityLow3 = 8+3, ///< Priority: low + 3 + osPriorityLow4 = 8+4, ///< Priority: low + 4 + osPriorityLow5 = 8+5, ///< Priority: low + 5 + osPriorityLow6 = 8+6, ///< Priority: low + 6 + osPriorityLow7 = 8+7, ///< Priority: low + 7 + osPriorityBelowNormal = 16, ///< Priority: below normal + osPriorityBelowNormal1 = 16+1, ///< Priority: below normal + 1 + osPriorityBelowNormal2 = 16+2, ///< Priority: below normal + 2 + osPriorityBelowNormal3 = 16+3, ///< Priority: below normal + 3 + osPriorityBelowNormal4 = 16+4, ///< Priority: below normal + 4 + osPriorityBelowNormal5 = 16+5, ///< Priority: below normal + 5 + osPriorityBelowNormal6 = 16+6, ///< Priority: below normal + 6 + osPriorityBelowNormal7 = 16+7, ///< Priority: below normal + 7 + osPriorityNormal = 24, ///< Priority: normal + osPriorityNormal1 = 24+1, ///< Priority: normal + 1 + osPriorityNormal2 = 24+2, ///< Priority: normal + 2 + osPriorityNormal3 = 24+3, ///< Priority: normal + 3 + osPriorityNormal4 = 24+4, ///< Priority: normal + 4 + osPriorityNormal5 = 24+5, ///< Priority: normal + 5 + osPriorityNormal6 = 24+6, ///< Priority: normal + 6 + osPriorityNormal7 = 24+7, ///< Priority: normal + 7 + osPriorityAboveNormal = 32, ///< Priority: above normal + osPriorityAboveNormal1 = 32+1, ///< Priority: above normal + 1 + osPriorityAboveNormal2 = 32+2, ///< Priority: above normal + 2 + osPriorityAboveNormal3 = 32+3, ///< Priority: above normal + 3 + osPriorityAboveNormal4 = 32+4, ///< Priority: above normal + 4 + osPriorityAboveNormal5 = 32+5, ///< Priority: above normal + 5 + osPriorityAboveNormal6 = 32+6, ///< Priority: above normal + 6 + osPriorityAboveNormal7 = 32+7, ///< Priority: above normal + 7 + osPriorityHigh = 40, ///< Priority: high + osPriorityHigh1 = 40+1, ///< Priority: high + 1 + osPriorityHigh2 = 40+2, ///< Priority: high + 2 + osPriorityHigh3 = 40+3, ///< Priority: high + 3 + osPriorityHigh4 = 40+4, ///< Priority: high + 4 + osPriorityHigh5 = 40+5, ///< Priority: high + 5 + osPriorityHigh6 = 40+6, ///< Priority: high + 6 + osPriorityHigh7 = 40+7, ///< Priority: high + 7 + osPriorityRealtime = 48, ///< Priority: realtime + osPriorityRealtime1 = 48+1, ///< Priority: realtime + 1 + osPriorityRealtime2 = 48+2, ///< Priority: realtime + 2 + osPriorityRealtime3 = 48+3, ///< Priority: realtime + 3 + osPriorityRealtime4 = 48+4, ///< Priority: realtime + 4 + osPriorityRealtime5 = 48+5, ///< Priority: realtime + 5 + osPriorityRealtime6 = 48+6, ///< Priority: realtime + 6 + osPriorityRealtime7 = 48+7, ///< Priority: realtime + 7 + osPriorityISR = 56, ///< Reserved for ISR deferred thread. + osPriorityError = -1, ///< System cannot determine priority or illegal priority. + osPriorityReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. +} osPriority_t; + +/// Entry point of a thread. +typedef void (*osThreadFunc_t) (void *argument); + +/// Timer callback function. +typedef void (*osTimerFunc_t) (void *argument); + +/// Timer type. +typedef enum { + osTimerOnce = 0, ///< One-shot timer. + osTimerPeriodic = 1 ///< Repeating timer. +} osTimerType_t; + +// Timeout value. +#define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value. + +// Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait). +#define osFlagsWaitAny 0x00000000U ///< Wait for any flag (default). +#define osFlagsWaitAll 0x00000001U ///< Wait for all flags. +#define osFlagsNoClear 0x00000002U ///< Do not clear flags which have been specified to wait for. + +// Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx). +#define osFlagsError 0x80000000U ///< Error indicator. +#define osFlagsErrorUnknown 0xFFFFFFFFU ///< osError (-1). +#define osFlagsErrorTimeout 0xFFFFFFFEU ///< osErrorTimeout (-2). +#define osFlagsErrorResource 0xFFFFFFFDU ///< osErrorResource (-3). +#define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4). +#define osFlagsErrorISR 0xFFFFFFFAU ///< osErrorISR (-6). + +// Thread attributes (attr_bits in \ref osThreadAttr_t). +#define osThreadDetached 0x00000000U ///< Thread created in detached mode (default) +#define osThreadJoinable 0x00000001U ///< Thread created in joinable mode + +// Mutex attributes (attr_bits in \ref osMutexAttr_t). +#define osMutexRecursive 0x00000001U ///< Recursive mutex. +#define osMutexPrioInherit 0x00000002U ///< Priority inherit protocol. +#define osMutexRobust 0x00000008U ///< Robust mutex. + +/// Status code values returned by CMSIS-RTOS functions. +typedef enum { + osOK = 0, ///< Operation completed successfully. + osError = -1, ///< Unspecified RTOS error: run-time error but no other error message fits. + osErrorTimeout = -2, ///< Operation not completed within the timeout period. + osErrorResource = -3, ///< Resource not available. + osErrorParameter = -4, ///< Parameter error. + osErrorNoMemory = -5, ///< System is out of memory: it was impossible to allocate or reserve memory for the operation. + osErrorISR = -6, ///< Not allowed in ISR context: the function cannot be called from interrupt service routines. + osStatusReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. +} osStatus_t; + + +/// \details Thread ID identifies the thread. +typedef void *osThreadId_t; + +/// \details Timer ID identifies the timer. +typedef void *osTimerId_t; + +/// \details Event Flags ID identifies the event flags. +typedef void *osEventFlagsId_t; + +/// \details Mutex ID identifies the mutex. +typedef void *osMutexId_t; + +/// \details Semaphore ID identifies the semaphore. +typedef void *osSemaphoreId_t; + +/// \details Memory Pool ID identifies the memory pool. +typedef void *osMemoryPoolId_t; + +/// \details Message Queue ID identifies the message queue. +typedef void *osMessageQueueId_t; + + +#ifndef TZ_MODULEID_T +#define TZ_MODULEID_T +/// \details Data type that identifies secure software modules called by a process. +typedef uint32_t TZ_ModuleId_t; +#endif + + +/// Attributes structure for thread. +typedef struct { + const char *name; ///< name of the thread + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block + void *stack_mem; ///< memory for stack + uint32_t stack_size; ///< size of stack + osPriority_t priority; ///< initial thread priority (default: osPriorityNormal) + TZ_ModuleId_t tz_module; ///< TrustZone module identifier + uint32_t reserved; ///< reserved (must be 0) +} osThreadAttr_t; + +/// Attributes structure for timer. +typedef struct { + const char *name; ///< name of the timer + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osTimerAttr_t; + +/// Attributes structure for event flags. +typedef struct { + const char *name; ///< name of the event flags + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osEventFlagsAttr_t; + +/// Attributes structure for mutex. +typedef struct { + const char *name; ///< name of the mutex + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osMutexAttr_t; + +/// Attributes structure for semaphore. +typedef struct { + const char *name; ///< name of the semaphore + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block +} osSemaphoreAttr_t; + +/// Attributes structure for memory pool. +typedef struct { + const char *name; ///< name of the memory pool + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block + void *mp_mem; ///< memory for data storage + uint32_t mp_size; ///< size of provided memory for data storage +} osMemoryPoolAttr_t; + +/// Attributes structure for message queue. +typedef struct { + const char *name; ///< name of the message queue + uint32_t attr_bits; ///< attribute bits + void *cb_mem; ///< memory for control block + uint32_t cb_size; ///< size of provided memory for control block + void *mq_mem; ///< memory for data storage + uint32_t mq_size; ///< size of provided memory for data storage +} osMessageQueueAttr_t; + + +// ==== Kernel Management Functions ==== + +/// Initialize the RTOS Kernel. +/// \return status code that indicates the execution status of the function. +osStatus_t osKernelInitialize (void); + +/// Get RTOS Kernel Information. +/// \param[out] version pointer to buffer for retrieving version information. +/// \param[out] id_buf pointer to buffer for retrieving kernel identification string. +/// \param[in] id_size size of buffer for kernel identification string. +/// \return status code that indicates the execution status of the function. +osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size); + +/// Get the current RTOS Kernel state. +/// \return current RTOS Kernel state. +osKernelState_t osKernelGetState (void); + +/// Start the RTOS Kernel scheduler. +/// \return status code that indicates the execution status of the function. +osStatus_t osKernelStart (void); + +/// Lock the RTOS Kernel scheduler. +/// \return previous lock state (1 - locked, 0 - not locked, error code if negative). +int32_t osKernelLock (void); + +/// Unlock the RTOS Kernel scheduler. +/// \return previous lock state (1 - locked, 0 - not locked, error code if negative). +int32_t osKernelUnlock (void); + +/// Restore the RTOS Kernel scheduler lock state. +/// \param[in] lock lock state obtained by \ref osKernelLock or \ref osKernelUnlock. +/// \return new lock state (1 - locked, 0 - not locked, error code if negative). +int32_t osKernelRestoreLock (int32_t lock); + +/// Suspend the RTOS Kernel scheduler. +/// \return time in ticks, for how long the system can sleep or power-down. +uint32_t osKernelSuspend (void); + +/// Resume the RTOS Kernel scheduler. +/// \param[in] sleep_ticks time in ticks for how long the system was in sleep or power-down mode. +void osKernelResume (uint32_t sleep_ticks); + +/// Get the RTOS kernel tick count. +/// \return RTOS kernel current tick count. +uint32_t osKernelGetTickCount (void); + +/// Get the RTOS kernel tick frequency. +/// \return frequency of the kernel tick in hertz, i.e. kernel ticks per second. +uint32_t osKernelGetTickFreq (void); + +/// Get the RTOS kernel system timer count. +/// \return RTOS kernel current system timer count as 32-bit value. +uint32_t osKernelGetSysTimerCount (void); + +/// Get the RTOS kernel system timer frequency. +/// \return frequency of the system timer in hertz, i.e. timer ticks per second. +uint32_t osKernelGetSysTimerFreq (void); + + +// ==== Thread Management Functions ==== + +/// Create a thread and add it to Active Threads. +/// \param[in] func thread function. +/// \param[in] argument pointer that is passed to the thread function as start argument. +/// \param[in] attr thread attributes; NULL: default values. +/// \return thread ID for reference by other functions or NULL in case of error. +osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr); + +/// Get name of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return name as null-terminated string. +const char *osThreadGetName (osThreadId_t thread_id); + +/// Return the thread ID of the current running thread. +/// \return thread ID for reference by other functions or NULL in case of error. +osThreadId_t osThreadGetId (void); + +/// Get current thread state of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return current thread state of the specified thread. +osThreadState_t osThreadGetState (osThreadId_t thread_id); + +/// Get stack size of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return stack size in bytes. +uint32_t osThreadGetStackSize (osThreadId_t thread_id); + +/// Get available stack space of a thread based on stack watermark recording during execution. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return remaining stack space in bytes. +uint32_t osThreadGetStackSpace (osThreadId_t thread_id); + +/// Change priority of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \param[in] priority new priority value for the thread function. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority); + +/// Get current priority of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return current priority value of the specified thread. +osPriority_t osThreadGetPriority (osThreadId_t thread_id); + +/// Pass control to next thread that is in state \b READY. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadYield (void); + +/// Suspend execution of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadSuspend (osThreadId_t thread_id); + +/// Resume execution of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadResume (osThreadId_t thread_id); + +/// Detach a thread (thread storage can be reclaimed when thread terminates). +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadDetach (osThreadId_t thread_id); + +/// Wait for specified thread to terminate. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadJoin (osThreadId_t thread_id); + +/// Terminate execution of current running thread. +__NO_RETURN void osThreadExit (void); + +/// Terminate execution of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \return status code that indicates the execution status of the function. +osStatus_t osThreadTerminate (osThreadId_t thread_id); + +/// Get number of active threads. +/// \return number of active threads. +uint32_t osThreadGetCount (void); + +/// Enumerate active threads. +/// \param[out] thread_array pointer to array for retrieving thread IDs. +/// \param[in] array_items maximum number of items in array for retrieving thread IDs. +/// \return number of enumerated threads. +uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items); + + +// ==== Thread Flags Functions ==== + +/// Set the specified Thread Flags of a thread. +/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. +/// \param[in] flags specifies the flags of the thread that shall be set. +/// \return thread flags after setting or error code if highest bit set. +uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags); + +/// Clear the specified Thread Flags of current running thread. +/// \param[in] flags specifies the flags of the thread that shall be cleared. +/// \return thread flags before clearing or error code if highest bit set. +uint32_t osThreadFlagsClear (uint32_t flags); + +/// Get the current Thread Flags of current running thread. +/// \return current thread flags. +uint32_t osThreadFlagsGet (void); + +/// Wait for one or more Thread Flags of the current running thread to become signaled. +/// \param[in] flags specifies the flags to wait for. +/// \param[in] options specifies flags options (osFlagsXxxx). +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return thread flags before clearing or error code if highest bit set. +uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout); + + +// ==== Generic Wait Functions ==== + +/// Wait for Timeout (Time Delay). +/// \param[in] ticks \ref CMSIS_RTOS_TimeOutValue "time ticks" value +/// \return status code that indicates the execution status of the function. +osStatus_t osDelay (uint32_t ticks); + +/// Wait until specified time. +/// \param[in] ticks absolute time in ticks +/// \return status code that indicates the execution status of the function. +osStatus_t osDelayUntil (uint32_t ticks); + + +// ==== Timer Management Functions ==== + +/// Create and Initialize a timer. +/// \param[in] func function pointer to callback function. +/// \param[in] type \ref osTimerOnce for one-shot or \ref osTimerPeriodic for periodic behavior. +/// \param[in] argument argument to the timer callback function. +/// \param[in] attr timer attributes; NULL: default values. +/// \return timer ID for reference by other functions or NULL in case of error. +osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr); + +/// Get name of a timer. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \return name as null-terminated string. +const char *osTimerGetName (osTimerId_t timer_id); + +/// Start or restart a timer. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \param[in] ticks \ref CMSIS_RTOS_TimeOutValue "time ticks" value of the timer. +/// \return status code that indicates the execution status of the function. +osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks); + +/// Stop a timer. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osTimerStop (osTimerId_t timer_id); + +/// Check if a timer is running. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \return 0 not running, 1 running. +uint32_t osTimerIsRunning (osTimerId_t timer_id); + +/// Delete a timer. +/// \param[in] timer_id timer ID obtained by \ref osTimerNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osTimerDelete (osTimerId_t timer_id); + + +// ==== Event Flags Management Functions ==== + +/// Create and Initialize an Event Flags object. +/// \param[in] attr event flags attributes; NULL: default values. +/// \return event flags ID for reference by other functions or NULL in case of error. +osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr); + +/// Get name of an Event Flags object. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \return name as null-terminated string. +const char *osEventFlagsGetName (osEventFlagsId_t ef_id); + +/// Set the specified Event Flags. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \param[in] flags specifies the flags that shall be set. +/// \return event flags after setting or error code if highest bit set. +uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags); + +/// Clear the specified Event Flags. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \param[in] flags specifies the flags that shall be cleared. +/// \return event flags before clearing or error code if highest bit set. +uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags); + +/// Get the current Event Flags. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \return current event flags. +uint32_t osEventFlagsGet (osEventFlagsId_t ef_id); + +/// Wait for one or more Event Flags to become signaled. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \param[in] flags specifies the flags to wait for. +/// \param[in] options specifies flags options (osFlagsXxxx). +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return event flags before clearing or error code if highest bit set. +uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout); + +/// Delete an Event Flags object. +/// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id); + + +// ==== Mutex Management Functions ==== + +/// Create and Initialize a Mutex object. +/// \param[in] attr mutex attributes; NULL: default values. +/// \return mutex ID for reference by other functions or NULL in case of error. +osMutexId_t osMutexNew (const osMutexAttr_t *attr); + +/// Get name of a Mutex object. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return name as null-terminated string. +const char *osMutexGetName (osMutexId_t mutex_id); + +/// Acquire a Mutex or timeout if it is locked. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout); + +/// Release a Mutex that was acquired by \ref osMutexAcquire. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMutexRelease (osMutexId_t mutex_id); + +/// Get Thread which owns a Mutex object. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return thread ID of owner thread or NULL when mutex was not acquired. +osThreadId_t osMutexGetOwner (osMutexId_t mutex_id); + +/// Delete a Mutex object. +/// \param[in] mutex_id mutex ID obtained by \ref osMutexNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMutexDelete (osMutexId_t mutex_id); + + +// ==== Semaphore Management Functions ==== + +/// Create and Initialize a Semaphore object. +/// \param[in] max_count maximum number of available tokens. +/// \param[in] initial_count initial number of available tokens. +/// \param[in] attr semaphore attributes; NULL: default values. +/// \return semaphore ID for reference by other functions or NULL in case of error. +osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr); + +/// Get name of a Semaphore object. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \return name as null-terminated string. +const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id); + +/// Acquire a Semaphore token or timeout if no tokens are available. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout); + +/// Release a Semaphore token up to the initial maximum count. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id); + +/// Get current Semaphore token count. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \return number of tokens available. +uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id); + +/// Delete a Semaphore object. +/// \param[in] semaphore_id semaphore ID obtained by \ref osSemaphoreNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id); + + +// ==== Memory Pool Management Functions ==== + +/// Create and Initialize a Memory Pool object. +/// \param[in] block_count maximum number of memory blocks in memory pool. +/// \param[in] block_size memory block size in bytes. +/// \param[in] attr memory pool attributes; NULL: default values. +/// \return memory pool ID for reference by other functions or NULL in case of error. +osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr); + +/// Get name of a Memory Pool object. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return name as null-terminated string. +const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id); + +/// Allocate a memory block from a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return address of the allocated memory block or NULL in case of no memory is available. +void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout); + +/// Return an allocated memory block back to a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \param[in] block address of the allocated memory block to be returned to the memory pool. +/// \return status code that indicates the execution status of the function. +osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block); + +/// Get maximum number of memory blocks in a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return maximum number of memory blocks. +uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id); + +/// Get memory block size in a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return memory block size in bytes. +uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id); + +/// Get number of memory blocks used in a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return number of memory blocks used. +uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id); + +/// Get number of memory blocks available in a Memory Pool. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return number of memory blocks available. +uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id); + +/// Delete a Memory Pool object. +/// \param[in] mp_id memory pool ID obtained by \ref osMemoryPoolNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id); + + +// ==== Message Queue Management Functions ==== + +/// Create and Initialize a Message Queue object. +/// \param[in] msg_count maximum number of messages in queue. +/// \param[in] msg_size maximum message size in bytes. +/// \param[in] attr message queue attributes; NULL: default values. +/// \return message queue ID for reference by other functions or NULL in case of error. +osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr); + +/// Get name of a Message Queue object. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return name as null-terminated string. +const char *osMessageQueueGetName (osMessageQueueId_t mq_id); + +/// Put a Message into a Queue or timeout if Queue is full. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \param[in] msg_ptr pointer to buffer with message to put into a queue. +/// \param[in] msg_prio message priority. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout); + +/// Get a Message from a Queue or timeout if Queue is empty. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \param[out] msg_ptr pointer to buffer for message to get from a queue. +/// \param[out] msg_prio pointer to buffer for message priority or NULL. +/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. +/// \return status code that indicates the execution status of the function. +osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout); + +/// Get maximum number of messages in a Message Queue. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return maximum number of messages. +uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id); + +/// Get maximum message size in a Memory Pool. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return maximum message size in bytes. +uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id); + +/// Get number of queued messages in a Message Queue. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return number of queued messages. +uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id); + +/// Get number of available slots for messages in a Message Queue. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return number of available slots for messages. +uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id); + +/// Reset a Message Queue to initial empty state. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id); + +/// Delete a Message Queue object. +/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. +/// \return status code that indicates the execution status of the function. +osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id); + + +#ifdef __cplusplus +} +#endif + +#endif // CMSIS_OS2_H_ diff --git a/source/rtos_none/cmsis_os2_port.c b/source/rtos_none/cmsis_os2_port.c new file mode 100644 index 000000000..d049ae459 --- /dev/null +++ b/source/rtos_none/cmsis_os2_port.c @@ -0,0 +1,89 @@ +/** + * @file cmsis_os2_port.c + * @brief + * + * DAPLink Interface Firmware + * Copyright (c) 2019, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ +#include "cmsis_os2.h" +#include "Systick_Handler.h" + +osStatus_t osKernelInitialize(void) +{ + sysTickInit(); + return osOK; +} + +osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) +{ + sysTickRegMainFunc(func); + return (osThreadId_t)1; +} + +osStatus_t osKernelStart(void) +{ + sysTickStartMain(); + return osOK; +} + +uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) +{ + sysTickEvtSet(flags); + return flags; +} + +osStatus_t osDelay(uint32_t ticks) +{ + sysTickWait(ticks); + return osOK; +} + +osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) +{ + sysTickRegCallback(func); + return (osTimerId_t)1; +} + +osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks) +{ + sysTickFreqSet(ticks); + return osOK; +} + +uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout) +{ + return sysTickEvtWaitOr(flags); +} + +osMutexId_t osMutexNew(const osMutexAttr_t *attr) +{ + return NULL; +} + +osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) +{ + return osOK; +} + +osStatus_t osMutexRelease (osMutexId_t mutex_id) +{ + return osOK; +} + +osThreadId_t osThreadGetId (void) +{ + return (osThreadId_t)1; +} diff --git a/source/usb/cdc/usbd_cdc_acm.c b/source/usb/cdc/usbd_cdc_acm.c index 4923c1151..e26c66d0a 100644 --- a/source/usb/cdc/usbd_cdc_acm.c +++ b/source/usb/cdc/usbd_cdc_acm.c @@ -21,7 +21,6 @@ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb_for_lib.h" @@ -762,7 +761,7 @@ void USBD_CDC_ACM_EP_BULK_Event(uint32_t event) function (USBD_CDC_ACM_EP_INTIN_Event). */ -__task void USBD_RTX_CDC_ACM_EP_INTIN_Event(void) +void USBD_RTX_CDC_ACM_EP_INTIN_Event(void) { for (;;) { usbd_os_evt_wait_or(0xFFFF, 0xFFFF); @@ -777,7 +776,7 @@ __task void USBD_RTX_CDC_ACM_EP_INTIN_Event(void) function (USBD_CDC_ACM_EP_BULKIN_Event). */ -__task void USBD_RTX_CDC_ACM_EP_BULKIN_Event(void) +void USBD_RTX_CDC_ACM_EP_BULKIN_Event(void) { for (;;) { usbd_os_evt_wait_or(0xFFFF, 0xFFFF); @@ -795,7 +794,7 @@ __task void USBD_RTX_CDC_ACM_EP_BULKIN_Event(void) function (USBD_CDC_ACM_EP_BULKOUT_Event). */ -__task void USBD_RTX_CDC_ACM_EP_BULKOUT_Event(void) +void USBD_RTX_CDC_ACM_EP_BULKOUT_Event(void) { for (;;) { usbd_os_evt_wait_or(0xFFFF, 0xFFFF); @@ -813,7 +812,7 @@ __task void USBD_RTX_CDC_ACM_EP_BULKOUT_Event(void) function (USBD_CDC_ACM_EP_BULK_Event). */ -__task void USBD_RTX_CDC_ACM_EP_BULK_Event(void) +void USBD_RTX_CDC_ACM_EP_BULK_Event(void) { for (;;) { usbd_os_evt_wait_or(0xFFFF, 0xFFFF); diff --git a/source/usb/cdc/usbd_core_cdc.c b/source/usb/cdc/usbd_core_cdc.c index 7f51bc78d..a67c4809e 100644 --- a/source/usb/cdc/usbd_core_cdc.c +++ b/source/usb/cdc/usbd_core_cdc.c @@ -21,7 +21,6 @@ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb_for_lib.h" diff --git a/source/usb/hid/usbd_core_hid.c b/source/usb/hid/usbd_core_hid.c index 3b652fc24..f2d3982ab 100644 --- a/source/usb/hid/usbd_core_hid.c +++ b/source/usb/hid/usbd_core_hid.c @@ -21,7 +21,6 @@ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb_for_lib.h" diff --git a/source/usb/hid/usbd_hid.c b/source/usb/hid/usbd_hid.c index cdab6612f..fbfe55051 100644 --- a/source/usb/hid/usbd_hid.c +++ b/source/usb/hid/usbd_hid.c @@ -21,7 +21,6 @@ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb_for_lib.h" @@ -461,7 +460,7 @@ void USBD_HID_SOF_Event(void) * Return Value: None */ -__task void USBD_RTX_HID_EP_INTIN_Event(void) +void USBD_RTX_HID_EP_INTIN_Event(void) { for (;;) { usbd_os_evt_wait_or(0xFFFF, 0xFFFF); @@ -479,7 +478,7 @@ __task void USBD_RTX_HID_EP_INTIN_Event(void) * Return Value: None */ -__task void USBD_RTX_HID_EP_INTOUT_Event(void) +void USBD_RTX_HID_EP_INTOUT_Event(void) { for (;;) { usbd_os_evt_wait_or(0xFFFF, 0xFFFF); @@ -497,7 +496,7 @@ __task void USBD_RTX_HID_EP_INTOUT_Event(void) * Return Value: None */ -__task void USBD_RTX_HID_EP_INT_Event(void) +void USBD_RTX_HID_EP_INT_Event(void) { for (;;) { usbd_os_evt_wait_or(0xFFFF, 0xFFFF); diff --git a/source/usb/msc/usbd_core_msc.c b/source/usb/msc/usbd_core_msc.c index cbfe95c0c..70ad18fac 100644 --- a/source/usb/msc/usbd_core_msc.c +++ b/source/usb/msc/usbd_core_msc.c @@ -21,7 +21,6 @@ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb_for_lib.h" diff --git a/source/usb/msc/usbd_msc.c b/source/usb/msc/usbd_msc.c index b58174ec4..d7192ec47 100644 --- a/source/usb/msc/usbd_msc.c +++ b/source/usb/msc/usbd_msc.c @@ -21,7 +21,6 @@ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb_for_lib.h" #include "util.h" diff --git a/source/usb/usb_def.h b/source/usb/usb_def.h index 41ceed04e..8a02a922f 100644 --- a/source/usb/usb_def.h +++ b/source/usb/usb_def.h @@ -24,6 +24,44 @@ #pragma anon_unions +#include +#include + +#ifndef NULL + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *) 0) + #endif +#endif + +#ifndef EOF + #define EOF (-1) +#endif + +#ifndef __size_t + #define __size_t 1 + typedef unsigned int size_t; +#endif + +typedef signed char S8; +typedef unsigned char U8; +typedef short S16; +typedef unsigned short U16; +typedef int S32; +typedef unsigned int U32; +typedef long long S64; +typedef unsigned long long U64; +typedef unsigned char BIT; +typedef unsigned int BOOL; + +#ifndef __TRUE + #define __TRUE 1 +#endif +#ifndef __FALSE + #define __FALSE 0 +#endif + /* bmRequestType.Dir */ #define REQUEST_HOST_TO_DEVICE 0 diff --git a/source/usb/usb_lib.c b/source/usb/usb_lib.c index 68964fa2f..0956ff8fb 100644 --- a/source/usb/usb_lib.c +++ b/source/usb/usb_lib.c @@ -19,7 +19,6 @@ * limitations under the License. */ -#include "RTL.h" #include "rl_usb.h" #include "usb.h" #include "settings.h" @@ -1099,7 +1098,7 @@ void (* const USBD_P_Feature_Event)(void) = USBD_Feature_Event; const BOOL __rtx = __TRUE; #if ((USBD_HID_ENABLE) || (USBD_ADC_ENABLE) || (USBD_CDC_ACM_ENABLE) || (USBD_CLS_ENABLE)) -__weak __task void USBD_RTX_Device(void) +__weak void USBD_RTX_Device(void) { U16 evt; @@ -1133,62 +1132,62 @@ __weak __task void USBD_RTX_Device(void) } } #else -__weak __task void USBD_RTX_Device(void); +__weak void USBD_RTX_Device(void); #endif /* USB Device - Device Events Callback Pointer */ void (* const USBD_RTX_P_Device)(void) = USBD_RTX_Device; /* USB Device Endpoint Events Callback Functions */ -extern __task void USBD_RTX_EndPoint0(void); +extern void USBD_RTX_EndPoint0(void); #ifndef USBD_RTX_EndPoint1 -__weak __task void USBD_RTX_EndPoint1(void); +__weak void USBD_RTX_EndPoint1(void); #endif #ifndef USBD_RTX_EndPoint2 -__weak __task void USBD_RTX_EndPoint2(void); +__weak void USBD_RTX_EndPoint2(void); #endif #ifndef USBD_RTX_EndPoint3 -__weak __task void USBD_RTX_EndPoint3(void); +__weak void USBD_RTX_EndPoint3(void); #endif #ifndef USBD_RTX_EndPoint4 -__weak __task void USBD_RTX_EndPoint4(void); +__weak void USBD_RTX_EndPoint4(void); #endif #ifndef USBD_RTX_EndPoint5 -__weak __task void USBD_RTX_EndPoint5(void); +__weak void USBD_RTX_EndPoint5(void); #endif #ifndef USBD_RTX_EndPoint6 -__weak __task void USBD_RTX_EndPoint6(void); +__weak void USBD_RTX_EndPoint6(void); #endif #ifndef USBD_RTX_EndPoint7 -__weak __task void USBD_RTX_EndPoint7(void); +__weak void USBD_RTX_EndPoint7(void); #endif #ifndef USBD_RTX_EndPoint8 -__weak __task void USBD_RTX_EndPoint8(void); +__weak void USBD_RTX_EndPoint8(void); #endif #ifndef USBD_RTX_EndPoint9 -__weak __task void USBD_RTX_EndPoint9(void); +__weak void USBD_RTX_EndPoint9(void); #endif #ifndef USBD_RTX_EndPoint10 -__weak __task void USBD_RTX_EndPoint10(void); +__weak void USBD_RTX_EndPoint10(void); #endif #ifndef USBD_RTX_EndPoint11 -__weak __task void USBD_RTX_EndPoint11(void); +__weak void USBD_RTX_EndPoint11(void); #endif #ifndef USBD_RTX_EndPoint12 -__weak __task void USBD_RTX_EndPoint12(void); +__weak void USBD_RTX_EndPoint12(void); #endif #ifndef USBD_RTX_EndPoint13 -__weak __task void USBD_RTX_EndPoint13(void); +__weak void USBD_RTX_EndPoint13(void); #endif #ifndef USBD_RTX_EndPoint14 -__weak __task void USBD_RTX_EndPoint14(void); +__weak void USBD_RTX_EndPoint14(void); #endif #ifndef USBD_RTX_EndPoint15 -__weak __task void USBD_RTX_EndPoint15(void); +__weak void USBD_RTX_EndPoint15(void); #endif #if (USBD_HID_ENABLE) -__weak __task void USBD_RTX_Core(void) +__weak void USBD_RTX_Core(void) { U16 evt; @@ -1202,7 +1201,7 @@ __weak __task void USBD_RTX_Core(void) } } #else -__weak __task void USBD_RTX_Core(void); +__weak void USBD_RTX_Core(void); #endif /* USB Device - Core Events Callback Pointer */ diff --git a/source/usb/usbd_cdc_acm.h b/source/usb/usbd_cdc_acm.h index 6cd542eb8..2454ebdd3 100644 --- a/source/usb/usbd_cdc_acm.h +++ b/source/usb/usbd_cdc_acm.h @@ -34,10 +34,11 @@ extern void USBD_CDC_ACM_EP_BULKIN_Event(U32 event); extern void USBD_CDC_ACM_EP_BULKOUT_Event(U32 event); extern void USBD_CDC_ACM_EP_BULK_Event(U32 event); -extern __task void USBD_RTX_CDC_ACM_EP_INTIN_Event(void); -extern __task void USBD_RTX_CDC_ACM_EP_BULKIN_Event(void); -extern __task void USBD_RTX_CDC_ACM_EP_BULKOUT_Event(void); -extern __task void USBD_RTX_CDC_ACM_EP_BULK_Event(void); - +#ifdef __RTX +extern void USBD_RTX_CDC_ACM_EP_INTIN_Event(void); +extern void USBD_RTX_CDC_ACM_EP_BULKIN_Event(void); +extern void USBD_RTX_CDC_ACM_EP_BULKOUT_Event(void); +extern void USBD_RTX_CDC_ACM_EP_BULK_Event(void); +#endif #endif /* __USBD_CDC_ACM_H__ */ diff --git a/source/usb/usbd_core.c b/source/usb/usbd_core.c index 66bd33a96..f8d70b3a1 100644 --- a/source/usb/usbd_core.c +++ b/source/usb/usbd_core.c @@ -19,7 +19,6 @@ * limitations under the License. */ -#include "RTL.h" #include "rl_usb.h" #include "string.h" #include "usb_for_lib.h" @@ -1041,7 +1040,7 @@ void USBD_EndPoint0(U32 event) */ #ifdef __RTX -__task void USBD_RTX_EndPoint0(void) +void USBD_RTX_EndPoint0(void) { for (;;) { usbd_os_evt_wait_or(0xFFFF, 0xFFFF); diff --git a/source/usb/usbd_core.h b/source/usb/usbd_core.h index 951c0fc55..a24067be8 100644 --- a/source/usb/usbd_core.h +++ b/source/usb/usbd_core.h @@ -48,10 +48,11 @@ extern U8 USBD_ZLP; extern USBD_EP_DATA USBD_EP0Data; extern USB_SETUP_PACKET USBD_SetupPacket; +#ifdef __RTX extern OS_TID USBD_RTX_DevTask; extern OS_TID USBD_RTX_EPTask[]; extern OS_TID USBD_RTX_CoreTask; - +#endif /*--------------------------- Functions exported to class specific files -----*/ @@ -67,7 +68,8 @@ extern void USBD_StatusOutStage(void); extern void usbd_class_init(void); extern void USBD_EndPoint0(U32 event); -extern __task void USBD_RTX_EndPoint0(void); - +#ifdef __RTX +extern void USBD_RTX_EndPoint0(void); +#endif #endif /* __USBD_CORE_H__ */ diff --git a/source/usb/usbd_hid.h b/source/usb/usbd_hid.h index 07b6d25e4..80d341251 100644 --- a/source/usb/usbd_hid.h +++ b/source/usb/usbd_hid.h @@ -41,10 +41,10 @@ extern void USBD_HID_SOF_Event(void); extern void USBD_HID_EP_INTIN_Event(U32 event); extern void USBD_HID_EP_INTOUT_Event(U32 event); extern void USBD_HID_EP_INT_Event(U32 event); - -extern __task void USBD_RTX_HID_EP_INTIN_Event(void); -extern __task void USBD_RTX_HID_EP_INTOUT_Event(void); -extern __task void USBD_RTX_HID_EP_INT_Event(void); - +#ifdef __RTX +extern void USBD_RTX_HID_EP_INTIN_Event(void); +extern void USBD_RTX_HID_EP_INTOUT_Event(void); +extern void USBD_RTX_HID_EP_INT_Event(void); +#endif #endif /* __USBD_HID_H__ */ diff --git a/source/usb/usbd_msc.h b/source/usb/usbd_msc.h index 2c939e0f6..661ff8533 100644 --- a/source/usb/usbd_msc.h +++ b/source/usb/usbd_msc.h @@ -43,9 +43,10 @@ extern void USBD_MSC_EP_BULKIN_Event(U32 event); extern void USBD_MSC_EP_BULKOUT_Event(U32 event); extern void USBD_MSC_EP_BULK_Event(U32 event); -extern __task void USBD_RTX_MSC_EP_BULKIN_Event(void); -extern __task void USBD_RTX_MSC_EP_BULKOUT_Event(void); -extern __task void USBD_RTX_MSC_EP_BULK_Event(void); - +#ifdef __RTX +extern void USBD_RTX_MSC_EP_BULKIN_Event(void); +extern void USBD_RTX_MSC_EP_BULKOUT_Event(void); +extern void USBD_RTX_MSC_EP_BULK_Event(void); +#endif #endif /* __USBD_MSC_H__ */ diff --git a/source/usb/webusb/usbd_core_webusb.c b/source/usb/webusb/usbd_core_webusb.c index 8263a92bf..5613063fc 100644 --- a/source/usb/webusb/usbd_core_webusb.c +++ b/source/usb/webusb/usbd_core_webusb.c @@ -21,7 +21,6 @@ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb_for_lib.h" #include "info.h" diff --git a/source/usb/winusb/usbd_core_winusb.c b/source/usb/winusb/usbd_core_winusb.c index 60657bfc0..884cb4902 100644 --- a/source/usb/winusb/usbd_core_winusb.c +++ b/source/usb/winusb/usbd_core_winusb.c @@ -21,7 +21,6 @@ #include "string.h" -#include "RTL.h" #include "rl_usb.h" #include "usb_for_lib.h"