├── .travis.yml ├── ChangeLog.md ├── LICENSE ├── README.md ├── bsp └── stm32f103vb │ ├── Libraries │ ├── core_cm3.h │ ├── misc.c │ ├── misc.h │ ├── stm32f10x.h │ ├── stm32f10x_conf.h │ ├── stm32f10x_gpio.c │ ├── stm32f10x_gpio.h │ ├── stm32f10x_it.c │ ├── stm32f10x_it.h │ ├── stm32f10x_rcc.c │ ├── stm32f10x_rcc.h │ ├── stm32f10x_tim.c │ ├── stm32f10x_tim.h │ ├── stm32f10x_usart.c │ ├── stm32f10x_usart.h │ ├── system_stm32f10x.c │ └── system_stm32f10x.h │ ├── gcc │ ├── Makefile │ ├── STM32F103RBTx_FLASH.ld │ └── startup_stm32f103xb.s │ ├── keil │ ├── project.uvopt │ ├── project.uvoptx │ ├── project.uvproj │ ├── project.uvprojx │ └── startup_stm32f10x_md.s │ ├── main.c │ └── periph_init.c ├── doc ├── microLite_timer_Code_Info.md ├── microLite_timer_api.chm └── picture │ ├── keil_Simulator.gif │ └── microLite_WeChat_log.gif ├── src ├── microLite_timer.c └── microLite_timer.h └── test ├── test1_period.c ├── test2_shot.c ├── test3_misc.c ├── test4_error.c └── test_5.c /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | os: linux 4 | dist: trusty 5 | 6 | 7 | compiler: arm-none-eabi-gcc 8 | 9 | 10 | before_install: 11 | - sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa -y 12 | - sudo apt-get update -q 13 | - sudo apt-get install gcc-arm-embedded -y 14 | 15 | 16 | script: 17 | - cd bsp/stm32f103vb/gcc 18 | - make 19 | 20 | 21 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### V0.01 (February 18, 2021) 4 | First version 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | #
microLite_timer
3 | 4 | 5 | 6 | [![GitHub](https://img.shields.io/badge/licence-Apache%202.0-blue.svg)](https://github.com/steven-lyan/microLite_timer/blob/main/LICENSE) 7 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/steven-lyan/microLite_timer/pulls) 8 | [![image](https://img.shields.io/badge/CSDN-microLite裸机系统-orange.svg)](https://blog.csdn.net/xlsbz1) 9 | [![Build status](https://travis-ci.com/steven-lyan/microLite_timer.svg?branch=main)](https://travis-ci.com/github/steven-lyan/microLite_timer) 10 | 11 | ## 简介 12 | 13 | microLite_timer是裸机软件定时器,源自[microLite裸机系统](https://blog.csdn.net/xlsbz1/article/details/111655405)的Kernel组件,提供两类定时器机制: 14 | 15 | - 第一类是周期触发定时器(MLPeriod),这类定时器会周期性的触发定时器,并且“一旦启动,永不停止”。 16 | ``` 17 | #include "microLite_timer.h" 18 | #include "stdio.h" 19 | void test_period(void) 20 | { 21 | MLPeriod.init(); 22 | while (1) { 23 | MLPeriod.run(); 24 | if (MLPeriod.check(1000)) { 25 | printf("timer1 timeout!\r\n"); 26 | } 27 | } 28 | } 29 | ``` 30 | 31 | - 第二类是单次触发定时器(MLShot),这类定时器在启动后只会触发一次定时器事件,然后定时器自动停止。 32 | 33 | ``` 34 | #include "microLite_timer.h" 35 | #include "stdio.h" 36 | static ml_shotTimer_TypeDef shot_timer1 = {0}; 37 | void test_shot(void) 38 | { 39 | MLShot.start(&shot_timer1, 1000); 40 | while (1) { 41 | if (MLShot.check(&shot_timer1)) { 42 | printf("timer1 stop(auto)!\r\n"); 43 | } 44 | } 45 | } 46 | ``` 47 | 48 | 49 | ## **源代码目录** 50 | 51 | microLite_timer源代码目录结构如下所示: 52 | 53 | | 名称 | 描述 | 54 | | ------------- | ------------------------------------------------------- | 55 | | bsp | Board Support Package(板级支持包)的移植 | 56 | | doc | 相关文档 | 57 | | test | 相关范例代码 | 58 | | src | microLite_timer 源文件 | 59 | 60 | 61 | ## 文档 62 | 63 | [microLite_timer doc](https://github.com/steven-lyan/microLite_timer/tree/main/doc/ )目录下包含了microLite_timer源代码的详细信息,包括源代码API、使用注意事项等。 64 | 65 | 66 | ## 范例 67 | 68 | [microLite_timer test](https://github.com/steven-lyan/microLite_timer/tree/main/test/)目录下包含了microLite_timer提供的范例代码,供开发者参考。 69 | 70 | ![studio](./doc/picture/keil_Simulator.gif) 71 | ## 许可协议 72 | 73 | microLite_timer完全开源,遵循Apache License 2.0开源许可协议。 74 | 75 | 76 | ## 社区支持 77 | 78 | 非常感谢各位小伙伴的支持,在使用microLite_timer的过程中若您有任何的想法,建议或疑问都可通过以下方式进行联系。 79 | 同时,任何问题都可以在 [issue](https://github.com/steven-lyan/microLite_timer/issues) 中通过创建一个issue来描述您的问题。 80 | 81 | - [microLite裸机系统的CSDN账号]( https://blog.csdn.net/xlsbz1) 82 | 83 | - 微信公众号:microLite裸机系统 84 | 85 | ![](./doc/picture/microLite_WeChat_log.gif) 86 | 87 | 88 | 89 | ## 贡献代码 90 | 91 | 如果您对microLite_timer感兴趣,并希望参与microLite_timer的开发并成为代码贡献者,请参照如下步骤: 92 | 93 | * 1. 在您自己的GitHub账户下Fork microLite_timer 开源项目; 94 | * 2. 根据您的需求在本地clone 一份microLite_timer 代码; 95 | * 3. 您修改或者新增功能后,push 到您fork的远程分支; 96 | * 4. 创建 pull request,向microLite_timer开发分支提交合入请求; 97 | * 5. microLite_timer作者会定期review代码,通过测试后合入。 98 | 99 | 100 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/misc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file misc.c 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 18-April-2011 7 | * @brief This file provides all the miscellaneous firmware functions (add-on 8 | * to CMSIS functions). 9 | * 10 | * @verbatim 11 | * 12 | * =================================================================== 13 | * How to configure Interrupts using driver 14 | * =================================================================== 15 | * 16 | * This section provide functions allowing to configure the NVIC interrupts (IRQ). 17 | * The Cortex-M3 exceptions are managed by CMSIS functions. 18 | * 19 | * 1. Configure the NVIC Priority Grouping using NVIC_PriorityGroupConfig() 20 | * function according to the following table. 21 | 22 | * The table below gives the allowed values of the pre-emption priority and subpriority according 23 | * to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function 24 | * ========================================================================================================================== 25 | * NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description 26 | * ========================================================================================================================== 27 | * NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority 28 | * | | | 4 bits for subpriority 29 | * -------------------------------------------------------------------------------------------------------------------------- 30 | * NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority 31 | * | | | 3 bits for subpriority 32 | * -------------------------------------------------------------------------------------------------------------------------- 33 | * NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority 34 | * | | | 2 bits for subpriority 35 | * -------------------------------------------------------------------------------------------------------------------------- 36 | * NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority 37 | * | | | 1 bits for subpriority 38 | * -------------------------------------------------------------------------------------------------------------------------- 39 | * NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority 40 | * | | | 0 bits for subpriority 41 | * ========================================================================================================================== 42 | * 43 | * 2. Enable and Configure the priority of the selected IRQ Channels using NVIC_Init() 44 | * 45 | * @note When the NVIC_PriorityGroup_0 is selected, IRQ pre-emption is no more possible. 46 | * The pending IRQ priority will be managed only by the subpriority. 47 | * 48 | * @note IRQ priority order (sorted by highest to lowest priority): 49 | * - Lowest pre-emption priority 50 | * - Lowest subpriority 51 | * - Lowest hardware priority (IRQ number) 52 | * 53 | * @endverbatim 54 | * 55 | ****************************************************************************** 56 | * @attention 57 | * 58 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 59 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 60 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 61 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 62 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 63 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 64 | * 65 | *

© COPYRIGHT 2011 STMicroelectronics

66 | ****************************************************************************** 67 | */ 68 | 69 | /* Includes ------------------------------------------------------------------*/ 70 | #include "misc.h" 71 | 72 | /** @addtogroup STM32F2xx_StdPeriph_Driver 73 | * @{ 74 | */ 75 | 76 | /** @defgroup MISC 77 | * @brief MISC driver modules 78 | * @{ 79 | */ 80 | 81 | /* Private typedef -----------------------------------------------------------*/ 82 | /* Private define ------------------------------------------------------------*/ 83 | #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000) 84 | 85 | /* Private macro -------------------------------------------------------------*/ 86 | /* Private variables ---------------------------------------------------------*/ 87 | /* Private function prototypes -----------------------------------------------*/ 88 | /* Private functions ---------------------------------------------------------*/ 89 | 90 | /** @defgroup MISC_Private_Functions 91 | * @{ 92 | */ 93 | 94 | /** 95 | * @brief Configures the priority grouping: pre-emption priority and subpriority. 96 | * @param NVIC_PriorityGroup: specifies the priority grouping bits length. 97 | * This parameter can be one of the following values: 98 | * @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority 99 | * 4 bits for subpriority 100 | * @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority 101 | * 3 bits for subpriority 102 | * @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority 103 | * 2 bits for subpriority 104 | * @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority 105 | * 1 bits for subpriority 106 | * @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority 107 | * 0 bits for subpriority 108 | * @note When the NVIC_PriorityGroup_0 is selected, IRQ pre-emption is no more possible. 109 | * The pending IRQ priority will be managed only by the subpriority. 110 | * @retval None 111 | */ 112 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup) 113 | { 114 | /* Check the parameters */ 115 | assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup)); 116 | 117 | /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */ 118 | SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup; 119 | } 120 | 121 | /** 122 | * @brief Initializes the NVIC peripheral according to the specified 123 | * parameters in the NVIC_InitStruct. 124 | * @note To configure interrupts priority correctly, the NVIC_PriorityGroupConfig() 125 | * function should be called before. 126 | * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains 127 | * the configuration information for the specified NVIC peripheral. 128 | * @retval None 129 | */ 130 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct) 131 | { 132 | uint8_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F; 133 | 134 | /* Check the parameters */ 135 | assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd)); 136 | assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority)); 137 | assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority)); 138 | 139 | if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE) 140 | { 141 | /* Compute the Corresponding IRQ Priority --------------------------------*/ 142 | tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08; 143 | tmppre = (0x4 - tmppriority); 144 | tmpsub = tmpsub >> tmppriority; 145 | 146 | tmppriority = NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre; 147 | tmppriority |= (uint8_t)(NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub); 148 | 149 | tmppriority = tmppriority << 0x04; 150 | 151 | NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority; 152 | 153 | /* Enable the Selected IRQ Channels --------------------------------------*/ 154 | NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = 155 | (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 156 | } 157 | else 158 | { 159 | /* Disable the Selected IRQ Channels -------------------------------------*/ 160 | NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = 161 | (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 162 | } 163 | } 164 | 165 | /** 166 | * @brief Sets the vector table location and Offset. 167 | * @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory. 168 | * This parameter can be one of the following values: 169 | * @arg NVIC_VectTab_RAM: Vector Table in internal SRAM. 170 | * @arg NVIC_VectTab_FLASH: Vector Table in internal FLASH. 171 | * @param Offset: Vector Table base offset field. This value must be a multiple of 0x200. 172 | * @retval None 173 | */ 174 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset) 175 | { 176 | /* Check the parameters */ 177 | assert_param(IS_NVIC_VECTTAB(NVIC_VectTab)); 178 | assert_param(IS_NVIC_OFFSET(Offset)); 179 | 180 | SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80); 181 | } 182 | 183 | /** 184 | * @brief Selects the condition for the system to enter low power mode. 185 | * @param LowPowerMode: Specifies the new mode for the system to enter low power mode. 186 | * This parameter can be one of the following values: 187 | * @arg NVIC_LP_SEVONPEND: Low Power SEV on Pend. 188 | * @arg NVIC_LP_SLEEPDEEP: Low Power DEEPSLEEP request. 189 | * @arg NVIC_LP_SLEEPONEXIT: Low Power Sleep on Exit. 190 | * @param NewState: new state of LP condition. This parameter can be: ENABLE or DISABLE. 191 | * @retval None 192 | */ 193 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState) 194 | { 195 | /* Check the parameters */ 196 | assert_param(IS_NVIC_LP(LowPowerMode)); 197 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 198 | 199 | if (NewState != DISABLE) 200 | { 201 | SCB->SCR |= LowPowerMode; 202 | } 203 | else 204 | { 205 | SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode); 206 | } 207 | } 208 | 209 | /** 210 | * @brief Configures the SysTick clock source. 211 | * @param SysTick_CLKSource: specifies the SysTick clock source. 212 | * This parameter can be one of the following values: 213 | * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source. 214 | * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source. 215 | * @retval None 216 | */ 217 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource) 218 | { 219 | /* Check the parameters */ 220 | assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource)); 221 | if (SysTick_CLKSource == SysTick_CLKSource_HCLK) 222 | { 223 | SysTick->CTRL |= SysTick_CLKSource_HCLK; 224 | } 225 | else 226 | { 227 | SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8; 228 | } 229 | } 230 | 231 | /** 232 | * @} 233 | */ 234 | 235 | /** 236 | * @} 237 | */ 238 | 239 | /** 240 | * @} 241 | */ 242 | 243 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 244 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file misc.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 18-April-2011 7 | * @brief This file contains all the functions prototypes for the miscellaneous 8 | * firmware library functions (add-on to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __MISC_H 25 | #define __MISC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F2xx_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup MISC 39 | * @{ 40 | */ 41 | 42 | /* Exported types ------------------------------------------------------------*/ 43 | 44 | /** 45 | * @brief NVIC Init Structure definition 46 | */ 47 | 48 | typedef struct 49 | { 50 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 51 | This parameter can be an enumerator of @ref IRQn_Type 52 | enumeration (For the complete STM32 Devices IRQ Channels 53 | list, please refer to stm32f2xx.h file) */ 54 | 55 | uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel 56 | specified in NVIC_IRQChannel. This parameter can be a value 57 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table 58 | A lower priority value indicates a higher priority */ 59 | 60 | uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified 61 | in NVIC_IRQChannel. This parameter can be a value 62 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table 63 | A lower priority value indicates a higher priority */ 64 | 65 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 66 | will be enabled or disabled. 67 | This parameter can be set either to ENABLE or DISABLE */ 68 | } NVIC_InitTypeDef; 69 | 70 | /* Exported constants --------------------------------------------------------*/ 71 | 72 | /** @defgroup MISC_Exported_Constants 73 | * @{ 74 | */ 75 | 76 | /** @defgroup MISC_Vector_Table_Base 77 | * @{ 78 | */ 79 | 80 | #define NVIC_VectTab_RAM ((uint32_t)0x20000000) 81 | #define NVIC_VectTab_FLASH ((uint32_t)0x08000000) 82 | #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ 83 | ((VECTTAB) == NVIC_VectTab_FLASH)) 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup MISC_System_Low_Power 89 | * @{ 90 | */ 91 | 92 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 93 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 94 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 95 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ 96 | ((LP) == NVIC_LP_SLEEPDEEP) || \ 97 | ((LP) == NVIC_LP_SLEEPONEXIT)) 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @defgroup MISC_Preemption_Priority_Group 103 | * @{ 104 | */ 105 | 106 | #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 107 | 4 bits for subpriority */ 108 | #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 109 | 3 bits for subpriority */ 110 | #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 111 | 2 bits for subpriority */ 112 | #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 113 | 1 bits for subpriority */ 114 | #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 115 | 0 bits for subpriority */ 116 | 117 | #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ 118 | ((GROUP) == NVIC_PriorityGroup_1) || \ 119 | ((GROUP) == NVIC_PriorityGroup_2) || \ 120 | ((GROUP) == NVIC_PriorityGroup_3) || \ 121 | ((GROUP) == NVIC_PriorityGroup_4)) 122 | 123 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 124 | 125 | #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 126 | 127 | #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /** @defgroup MISC_SysTick_clock_source 134 | * @{ 135 | */ 136 | 137 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 138 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 139 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ 140 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) 141 | /** 142 | * @} 143 | */ 144 | 145 | /** 146 | * @} 147 | */ 148 | 149 | /* Exported macro ------------------------------------------------------------*/ 150 | /* Exported functions --------------------------------------------------------*/ 151 | 152 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 153 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 154 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); 155 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 156 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 157 | 158 | #ifdef __cplusplus 159 | } 160 | #endif 161 | 162 | #endif /* __MISC_H */ 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | /** 169 | * @} 170 | */ 171 | 172 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 173 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/Printf/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.0.0 6 | * @date 04/06/2009 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2009 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_crc.h" */ 31 | /* #include "stm32f10x_dac.h" */ 32 | /* #include "stm32f10x_dbgmcu.h" */ 33 | /* #include "stm32f10x_dma.h" */ 34 | /* #include "stm32f10x_exti.h" */ 35 | /* #include "stm32f10x_flash.h" */ 36 | /* #include "stm32f10x_fsmc.h" */ 37 | #include "stm32f10x_gpio.h" 38 | /* #include "stm32f10x_i2c.h" */ 39 | /* #include "stm32f10x_iwdg.h" */ 40 | /* #include "stm32f10x_pwr.h" */ 41 | #include "stm32f10x_rcc.h" 42 | /* #include "stm32f10x_rtc.h" */ 43 | /* #include "stm32f10x_sdio.h" */ 44 | /* #include "stm32f10x_spi.h" */ 45 | /* #include "stm32f10x_tim.h" */ 46 | #include "stm32f10x_usart.h" 47 | /* #include "stm32f10x_wwdg.h" */ 48 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 49 | 50 | /* Exported types ------------------------------------------------------------*/ 51 | /* Exported constants --------------------------------------------------------*/ 52 | /* Uncomment the line below to expanse the "assert_param" macro in the 53 | Standard Peripheral Library drivers code */ 54 | /* #define USE_FULL_ASSERT 1 */ 55 | 56 | /* Exported macro ------------------------------------------------------------*/ 57 | #ifdef USE_FULL_ASSERT 58 | /** 59 | * @brief The assert_param macro is used for function's parameters check. 60 | * @param expr: If expr is false, it calls assert_failed function 61 | * which reports the name of the source file and the source 62 | * line number of the call that failed. 63 | * If expr is true, it returns no value. 64 | * @retval : None 65 | */ 66 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 67 | /* Exported functions ------------------------------------------------------- */ 68 | void assert_failed(uint8_t *file, uint32_t line); 69 | #else 70 | #define assert_param(expr) ((void)0) 71 | #endif /* USE_FULL_ASSERT */ 72 | 73 | #endif /* __STM32F10x_CONF_H */ 74 | 75 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_gpio.h 4 | * @author MCD Application Team 5 | * @version V3.0.0 6 | * @date 04/06/2009 7 | * @brief This file contains all the functions prototypes for the GPIO 8 | * firmware library. 9 | ****************************************************************************** 10 | * @copy 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2009 STMicroelectronics

20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_GPIO_H 24 | #define __STM32F10x_GPIO_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32f10x.h" 28 | 29 | /** @addtogroup StdPeriph_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup GPIO 34 | * @{ 35 | */ 36 | 37 | /** @defgroup GPIO_Exported_Types 38 | * @{ 39 | */ 40 | 41 | #define IS_GPIO_ALL_PERIPH(PERIPH) (((*(uint32_t*)&(PERIPH)) == GPIOA_BASE) || \ 42 | ((*(uint32_t*)&(PERIPH)) == GPIOB_BASE) || \ 43 | ((*(uint32_t*)&(PERIPH)) == GPIOC_BASE) || \ 44 | ((*(uint32_t*)&(PERIPH)) == GPIOD_BASE) || \ 45 | ((*(uint32_t*)&(PERIPH)) == GPIOE_BASE) || \ 46 | ((*(uint32_t*)&(PERIPH)) == GPIOF_BASE) || \ 47 | ((*(uint32_t*)&(PERIPH)) == GPIOG_BASE)) 48 | 49 | /** 50 | * @brief Output Maximum frequency selection 51 | */ 52 | 53 | typedef enum 54 | { 55 | GPIO_Speed_10MHz = 1, 56 | GPIO_Speed_2MHz, 57 | GPIO_Speed_50MHz 58 | }GPIOSpeed_TypeDef; 59 | #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_10MHz) || ((SPEED) == GPIO_Speed_2MHz) || \ 60 | ((SPEED) == GPIO_Speed_50MHz)) 61 | 62 | /** 63 | * @brief Configuration Mode enumeration 64 | */ 65 | 66 | typedef enum 67 | { GPIO_Mode_AIN = 0x0, 68 | GPIO_Mode_IN_FLOATING = 0x04, 69 | GPIO_Mode_IPD = 0x28, 70 | GPIO_Mode_IPU = 0x48, 71 | GPIO_Mode_Out_OD = 0x14, 72 | GPIO_Mode_Out_PP = 0x10, 73 | GPIO_Mode_AF_OD = 0x1C, 74 | GPIO_Mode_AF_PP = 0x18 75 | }GPIOMode_TypeDef; 76 | 77 | #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_AIN) || ((MODE) == GPIO_Mode_IN_FLOATING) || \ 78 | ((MODE) == GPIO_Mode_IPD) || ((MODE) == GPIO_Mode_IPU) || \ 79 | ((MODE) == GPIO_Mode_Out_OD) || ((MODE) == GPIO_Mode_Out_PP) || \ 80 | ((MODE) == GPIO_Mode_AF_OD) || ((MODE) == GPIO_Mode_AF_PP)) 81 | 82 | /** 83 | * @brief GPIO Init structure definition 84 | */ 85 | 86 | typedef struct 87 | { 88 | uint16_t GPIO_Pin; 89 | GPIOSpeed_TypeDef GPIO_Speed; 90 | GPIOMode_TypeDef GPIO_Mode; 91 | }GPIO_InitTypeDef; 92 | 93 | /** 94 | * @brief Bit_SET and Bit_RESET enumeration 95 | */ 96 | 97 | typedef enum 98 | { Bit_RESET = 0, 99 | Bit_SET 100 | }BitAction; 101 | 102 | #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET)) 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** @defgroup GPIO_Exported_Constants 109 | * @{ 110 | */ 111 | 112 | /** @defgroup GPIO_pins_define 113 | * @{ 114 | */ 115 | 116 | #define GPIO_Pin_0 ((uint16_t)0x0001) /* Pin 0 selected */ 117 | #define GPIO_Pin_1 ((uint16_t)0x0002) /* Pin 1 selected */ 118 | #define GPIO_Pin_2 ((uint16_t)0x0004) /* Pin 2 selected */ 119 | #define GPIO_Pin_3 ((uint16_t)0x0008) /* Pin 3 selected */ 120 | #define GPIO_Pin_4 ((uint16_t)0x0010) /* Pin 4 selected */ 121 | #define GPIO_Pin_5 ((uint16_t)0x0020) /* Pin 5 selected */ 122 | #define GPIO_Pin_6 ((uint16_t)0x0040) /* Pin 6 selected */ 123 | #define GPIO_Pin_7 ((uint16_t)0x0080) /* Pin 7 selected */ 124 | #define GPIO_Pin_8 ((uint16_t)0x0100) /* Pin 8 selected */ 125 | #define GPIO_Pin_9 ((uint16_t)0x0200) /* Pin 9 selected */ 126 | #define GPIO_Pin_10 ((uint16_t)0x0400) /* Pin 10 selected */ 127 | #define GPIO_Pin_11 ((uint16_t)0x0800) /* Pin 11 selected */ 128 | #define GPIO_Pin_12 ((uint16_t)0x1000) /* Pin 12 selected */ 129 | #define GPIO_Pin_13 ((uint16_t)0x2000) /* Pin 13 selected */ 130 | #define GPIO_Pin_14 ((uint16_t)0x4000) /* Pin 14 selected */ 131 | #define GPIO_Pin_15 ((uint16_t)0x8000) /* Pin 15 selected */ 132 | #define GPIO_Pin_All ((uint16_t)0xFFFF) /* All pins selected */ 133 | 134 | #define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00)) 135 | 136 | #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \ 137 | ((PIN) == GPIO_Pin_1) || \ 138 | ((PIN) == GPIO_Pin_2) || \ 139 | ((PIN) == GPIO_Pin_3) || \ 140 | ((PIN) == GPIO_Pin_4) || \ 141 | ((PIN) == GPIO_Pin_5) || \ 142 | ((PIN) == GPIO_Pin_6) || \ 143 | ((PIN) == GPIO_Pin_7) || \ 144 | ((PIN) == GPIO_Pin_8) || \ 145 | ((PIN) == GPIO_Pin_9) || \ 146 | ((PIN) == GPIO_Pin_10) || \ 147 | ((PIN) == GPIO_Pin_11) || \ 148 | ((PIN) == GPIO_Pin_12) || \ 149 | ((PIN) == GPIO_Pin_13) || \ 150 | ((PIN) == GPIO_Pin_14) || \ 151 | ((PIN) == GPIO_Pin_15)) 152 | 153 | /** 154 | * @} 155 | */ 156 | 157 | /** @defgroup GPIO_Remap_define 158 | * @{ 159 | */ 160 | 161 | #define GPIO_Remap_SPI1 ((uint32_t)0x00000001) /* SPI1 Alternate Function mapping */ 162 | #define GPIO_Remap_I2C1 ((uint32_t)0x00000002) /* I2C1 Alternate Function mapping */ 163 | #define GPIO_Remap_USART1 ((uint32_t)0x00000004) /* USART1 Alternate Function mapping */ 164 | #define GPIO_Remap_USART2 ((uint32_t)0x00000008) /* USART2 Alternate Function mapping */ 165 | #define GPIO_PartialRemap_USART3 ((uint32_t)0x00140010) /* USART3 Partial Alternate Function mapping */ 166 | #define GPIO_FullRemap_USART3 ((uint32_t)0x00140030) /* USART3 Full Alternate Function mapping */ 167 | #define GPIO_PartialRemap_TIM1 ((uint32_t)0x00160040) /* TIM1 Partial Alternate Function mapping */ 168 | #define GPIO_FullRemap_TIM1 ((uint32_t)0x001600C0) /* TIM1 Full Alternate Function mapping */ 169 | #define GPIO_PartialRemap1_TIM2 ((uint32_t)0x00180100) /* TIM2 Partial1 Alternate Function mapping */ 170 | #define GPIO_PartialRemap2_TIM2 ((uint32_t)0x00180200) /* TIM2 Partial2 Alternate Function mapping */ 171 | #define GPIO_FullRemap_TIM2 ((uint32_t)0x00180300) /* TIM2 Full Alternate Function mapping */ 172 | #define GPIO_PartialRemap_TIM3 ((uint32_t)0x001A0800) /* TIM3 Partial Alternate Function mapping */ 173 | #define GPIO_FullRemap_TIM3 ((uint32_t)0x001A0C00) /* TIM3 Full Alternate Function mapping */ 174 | #define GPIO_Remap_TIM4 ((uint32_t)0x00001000) /* TIM4 Alternate Function mapping */ 175 | #define GPIO_Remap1_CAN1 ((uint32_t)0x001D4000) /* CAN Alternate Function mapping */ 176 | #define GPIO_Remap2_CAN1 ((uint32_t)0x001D6000) /* CAN Alternate Function mapping */ 177 | #define GPIO_Remap_PD01 ((uint32_t)0x00008000) /* PD01 Alternate Function mapping */ 178 | #define GPIO_Remap_TIM5CH4_LSI ((uint32_t)0x00200001) /* LSI connected to TIM5 Channel4 input capture for calibration */ 179 | #define GPIO_Remap_ADC1_ETRGINJ ((uint32_t)0x00200002) /* ADC1 External Trigger Injected Conversion remapping */ 180 | #define GPIO_Remap_ADC1_ETRGREG ((uint32_t)0x00200004) /* ADC1 External Trigger Regular Conversion remapping */ 181 | #define GPIO_Remap_ADC2_ETRGINJ ((uint32_t)0x00200008) /* ADC2 External Trigger Injected Conversion remapping */ 182 | #define GPIO_Remap_ADC2_ETRGREG ((uint32_t)0x00200010) /* ADC2 External Trigger Regular Conversion remapping */ 183 | #define GPIO_Remap_SWJ_NoJTRST ((uint32_t)0x00300100) /* Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST */ 184 | #define GPIO_Remap_SWJ_JTAGDisable ((uint32_t)0x00300200) /* JTAG-DP Disabled and SW-DP Enabled */ 185 | #define GPIO_Remap_SWJ_Disable ((uint32_t)0x00300400) /* Full SWJ Disabled (JTAG-DP + SW-DP) */ 186 | 187 | #define IS_GPIO_REMAP(REMAP) (((REMAP) == GPIO_Remap_SPI1) || ((REMAP) == GPIO_Remap_I2C1) || \ 188 | ((REMAP) == GPIO_Remap_USART1) || ((REMAP) == GPIO_Remap_USART2) || \ 189 | ((REMAP) == GPIO_PartialRemap_USART3) || ((REMAP) == GPIO_FullRemap_USART3) || \ 190 | ((REMAP) == GPIO_PartialRemap_TIM1) || ((REMAP) == GPIO_FullRemap_TIM1) || \ 191 | ((REMAP) == GPIO_PartialRemap1_TIM2) || ((REMAP) == GPIO_PartialRemap2_TIM2) || \ 192 | ((REMAP) == GPIO_FullRemap_TIM2) || ((REMAP) == GPIO_PartialRemap_TIM3) || \ 193 | ((REMAP) == GPIO_FullRemap_TIM3) || ((REMAP) == GPIO_Remap_TIM4) || \ 194 | ((REMAP) == GPIO_Remap1_CAN1) || ((REMAP) == GPIO_Remap2_CAN1) || \ 195 | ((REMAP) == GPIO_Remap_PD01) || ((REMAP) == GPIO_Remap_TIM5CH4_LSI) || \ 196 | ((REMAP) == GPIO_Remap_ADC1_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC1_ETRGREG) || \ 197 | ((REMAP) == GPIO_Remap_ADC2_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC2_ETRGREG) || \ 198 | ((REMAP) == GPIO_Remap_SWJ_NoJTRST) || ((REMAP) == GPIO_Remap_SWJ_JTAGDisable)|| \ 199 | ((REMAP) == GPIO_Remap_SWJ_Disable)) 200 | 201 | /** 202 | * @} 203 | */ 204 | 205 | /** @defgroup GPIO_Port_Sources 206 | * @{ 207 | */ 208 | 209 | #define GPIO_PortSourceGPIOA ((uint8_t)0x00) 210 | #define GPIO_PortSourceGPIOB ((uint8_t)0x01) 211 | #define GPIO_PortSourceGPIOC ((uint8_t)0x02) 212 | #define GPIO_PortSourceGPIOD ((uint8_t)0x03) 213 | #define GPIO_PortSourceGPIOE ((uint8_t)0x04) 214 | #define GPIO_PortSourceGPIOF ((uint8_t)0x05) 215 | #define GPIO_PortSourceGPIOG ((uint8_t)0x06) 216 | #define IS_GPIO_EVENTOUT_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \ 217 | ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \ 218 | ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \ 219 | ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \ 220 | ((PORTSOURCE) == GPIO_PortSourceGPIOE)) 221 | 222 | #define IS_GPIO_EXTI_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \ 223 | ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \ 224 | ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \ 225 | ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \ 226 | ((PORTSOURCE) == GPIO_PortSourceGPIOE) || \ 227 | ((PORTSOURCE) == GPIO_PortSourceGPIOF) || \ 228 | ((PORTSOURCE) == GPIO_PortSourceGPIOG)) 229 | 230 | /** 231 | * @} 232 | */ 233 | 234 | /** @defgroup GPIO_Pin_sources 235 | * @{ 236 | */ 237 | 238 | #define GPIO_PinSource0 ((uint8_t)0x00) 239 | #define GPIO_PinSource1 ((uint8_t)0x01) 240 | #define GPIO_PinSource2 ((uint8_t)0x02) 241 | #define GPIO_PinSource3 ((uint8_t)0x03) 242 | #define GPIO_PinSource4 ((uint8_t)0x04) 243 | #define GPIO_PinSource5 ((uint8_t)0x05) 244 | #define GPIO_PinSource6 ((uint8_t)0x06) 245 | #define GPIO_PinSource7 ((uint8_t)0x07) 246 | #define GPIO_PinSource8 ((uint8_t)0x08) 247 | #define GPIO_PinSource9 ((uint8_t)0x09) 248 | #define GPIO_PinSource10 ((uint8_t)0x0A) 249 | #define GPIO_PinSource11 ((uint8_t)0x0B) 250 | #define GPIO_PinSource12 ((uint8_t)0x0C) 251 | #define GPIO_PinSource13 ((uint8_t)0x0D) 252 | #define GPIO_PinSource14 ((uint8_t)0x0E) 253 | #define GPIO_PinSource15 ((uint8_t)0x0F) 254 | 255 | #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \ 256 | ((PINSOURCE) == GPIO_PinSource1) || \ 257 | ((PINSOURCE) == GPIO_PinSource2) || \ 258 | ((PINSOURCE) == GPIO_PinSource3) || \ 259 | ((PINSOURCE) == GPIO_PinSource4) || \ 260 | ((PINSOURCE) == GPIO_PinSource5) || \ 261 | ((PINSOURCE) == GPIO_PinSource6) || \ 262 | ((PINSOURCE) == GPIO_PinSource7) || \ 263 | ((PINSOURCE) == GPIO_PinSource8) || \ 264 | ((PINSOURCE) == GPIO_PinSource9) || \ 265 | ((PINSOURCE) == GPIO_PinSource10) || \ 266 | ((PINSOURCE) == GPIO_PinSource11) || \ 267 | ((PINSOURCE) == GPIO_PinSource12) || \ 268 | ((PINSOURCE) == GPIO_PinSource13) || \ 269 | ((PINSOURCE) == GPIO_PinSource14) || \ 270 | ((PINSOURCE) == GPIO_PinSource15)) 271 | 272 | /** 273 | * @} 274 | */ 275 | 276 | /** 277 | * @} 278 | */ 279 | 280 | /** @defgroup GPIO_Exported_Macros 281 | * @{ 282 | */ 283 | 284 | /** 285 | * @} 286 | */ 287 | 288 | /** @defgroup GPIO_Exported_Functions 289 | * @{ 290 | */ 291 | 292 | void GPIO_DeInit(GPIO_TypeDef* GPIOx); 293 | void GPIO_AFIODeInit(void); 294 | void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); 295 | void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); 296 | uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 297 | uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); 298 | uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 299 | uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); 300 | void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 301 | void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 302 | void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); 303 | void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); 304 | void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 305 | void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource); 306 | void GPIO_EventOutputCmd(FunctionalState NewState); 307 | void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState); 308 | void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource); 309 | 310 | #endif /* __STM32F10x_GPIO_H */ 311 | /** 312 | * @} 313 | */ 314 | 315 | /** 316 | * @} 317 | */ 318 | 319 | /** 320 | * @} 321 | */ 322 | 323 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 324 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/Printf/stm32f10x_it.c 4 | * @author MCD Application Team 5 | * @version V3.0.0 6 | * @date 04/06/2009 7 | * @brief Main Interrupt Service Routines. 8 | * This file provides template for all exceptions handler and 9 | * peripherals interrupt service routine. 10 | ****************************************************************************** 11 | * @copy 12 | * 13 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 14 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 15 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 16 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 17 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 18 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 19 | * 20 | *

© COPYRIGHT 2009 STMicroelectronics

21 | */ 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include "stm32f10x_it.h" 25 | /** @addtogroup StdPeriph_Examples 26 | * @{ 27 | */ 28 | 29 | /** @addtogroup USART_Printf 30 | * @{ 31 | */ 32 | 33 | 34 | /* Private function prototypes -----------------------------------------------*/ 35 | /* Private functions ---------------------------------------------------------*/ 36 | 37 | /******************************************************************************/ 38 | /* Cortex-M3 Processor Exceptions Handlers */ 39 | /******************************************************************************/ 40 | 41 | /** 42 | * @brief This function handles NMI exception. 43 | * @param None 44 | * @retval : None 45 | */ 46 | void NMI_Handler(void) 47 | { 48 | } 49 | 50 | /** 51 | * @brief This function handles Hard Fault exception. 52 | * @param None 53 | * @retval : None 54 | */ 55 | void HardFault_Handler(void) 56 | { 57 | /* Go to infinite loop when Hard Fault exception occurs */ 58 | while (1) { 59 | } 60 | } 61 | 62 | /** 63 | * @brief This function handles Memory Manage exception. 64 | * @param None 65 | * @retval : None 66 | */ 67 | void MemManage_Handler(void) 68 | { 69 | /* Go to infinite loop when Memory Manage exception occurs */ 70 | while (1) { 71 | } 72 | } 73 | 74 | /** 75 | * @brief This function handles Bus Fault exception. 76 | * @param None 77 | * @retval : None 78 | */ 79 | void BusFault_Handler(void) 80 | { 81 | /* Go to infinite loop when Bus Fault exception occurs */ 82 | while (1) { 83 | } 84 | } 85 | 86 | /** 87 | * @brief This function handles Usage Fault exception. 88 | * @param None 89 | * @retval : None 90 | */ 91 | void UsageFault_Handler(void) 92 | { 93 | /* Go to infinite loop when Usage Fault exception occurs */ 94 | while (1) { 95 | } 96 | } 97 | 98 | /** 99 | * @brief This function handles SVCall exception. 100 | * @param None 101 | * @retval : None 102 | */ 103 | void SVC_Handler(void) 104 | { 105 | } 106 | 107 | /** 108 | * @brief This function handles Debug Monitor exception. 109 | * @param None 110 | * @retval : None 111 | */ 112 | void DebugMon_Handler(void) 113 | { 114 | } 115 | 116 | /** 117 | * @brief This function handles PendSV_Handler exception. 118 | * @param None 119 | * @retval : None 120 | */ 121 | void PendSV_Handler(void) 122 | { 123 | } 124 | 125 | 126 | /******************************************************************************/ 127 | /* STM32F10x Peripherals Interrupt Handlers */ 128 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 129 | /* available peripheral interrupt handler's name please refer to the startup */ 130 | /* file (startup_stm32f10x_xx.s). */ 131 | /******************************************************************************/ 132 | 133 | /** 134 | * @brief This function handles PPP interrupt request. 135 | * @param None 136 | * @retval : None 137 | */ 138 | /*void PPP_IRQHandler(void) 139 | { 140 | }*/ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 151 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/Printf/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.0.0 6 | * @date 04/06/2009 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2009 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_IT_H 23 | #define __STM32F10x_IT_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | #include "stm32f10x.h" 27 | 28 | /* Exported types ------------------------------------------------------------*/ 29 | /* Exported constants --------------------------------------------------------*/ 30 | /* Exported macro ------------------------------------------------------------*/ 31 | /* Exported functions ------------------------------------------------------- */ 32 | 33 | void NMI_Handler(void); 34 | void HardFault_Handler(void); 35 | void MemManage_Handler(void); 36 | void BusFault_Handler(void); 37 | void UsageFault_Handler(void); 38 | void SVC_Handler(void); 39 | void DebugMon_Handler(void); 40 | void PendSV_Handler(void); 41 | void SysTick_Handler(void); 42 | void USART1_IRQHandler(void); 43 | 44 | #endif /* __STM32F10x_IT_H */ 45 | 46 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 47 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_rcc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steven-lyan/microLite_timer/e12c267206030c1902159cae883746fbf190c82d/bsp/stm32f103vb/Libraries/stm32f10x_rcc.c -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_rcc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rcc.h 4 | * @author MCD Application Team 5 | * @version V3.0.0 6 | * @date 04/06/2009 7 | * @brief This file contains all the functions prototypes for the RCC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @copy 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2009 STMicroelectronics

20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_RCC_H 24 | #define __STM32F10x_RCC_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32f10x.h" 28 | 29 | /** @addtogroup StdPeriph_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup RCC 34 | * @{ 35 | */ 36 | 37 | /** @defgroup RCC_Exported_Types 38 | * @{ 39 | */ 40 | 41 | typedef struct 42 | { 43 | uint32_t SYSCLK_Frequency; 44 | uint32_t HCLK_Frequency; 45 | uint32_t PCLK1_Frequency; 46 | uint32_t PCLK2_Frequency; 47 | uint32_t ADCCLK_Frequency; 48 | }RCC_ClocksTypeDef; 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | /** @defgroup RCC_Exported_Constants 55 | * @{ 56 | */ 57 | 58 | /** @defgroup HSE_configuration 59 | * @{ 60 | */ 61 | 62 | #define RCC_HSE_OFF ((uint32_t)0x00000000) 63 | #define RCC_HSE_ON ((uint32_t)0x00010000) 64 | #define RCC_HSE_Bypass ((uint32_t)0x00040000) 65 | #define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \ 66 | ((HSE) == RCC_HSE_Bypass)) 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup PLL_entry_clock_source 73 | * @{ 74 | */ 75 | 76 | #define RCC_PLLSource_HSI_Div2 ((uint32_t)0x00000000) 77 | #define RCC_PLLSource_HSE_Div1 ((uint32_t)0x00010000) 78 | #define RCC_PLLSource_HSE_Div2 ((uint32_t)0x00030000) 79 | #define IS_RCC_PLL_SOURCE(SOURCE) (((SOURCE) == RCC_PLLSource_HSI_Div2) || \ 80 | ((SOURCE) == RCC_PLLSource_HSE_Div1) || \ 81 | ((SOURCE) == RCC_PLLSource_HSE_Div2)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup PLL_multiplication_factor 87 | * @{ 88 | */ 89 | 90 | #define RCC_PLLMul_2 ((uint32_t)0x00000000) 91 | #define RCC_PLLMul_3 ((uint32_t)0x00040000) 92 | #define RCC_PLLMul_4 ((uint32_t)0x00080000) 93 | #define RCC_PLLMul_5 ((uint32_t)0x000C0000) 94 | #define RCC_PLLMul_6 ((uint32_t)0x00100000) 95 | #define RCC_PLLMul_7 ((uint32_t)0x00140000) 96 | #define RCC_PLLMul_8 ((uint32_t)0x00180000) 97 | #define RCC_PLLMul_9 ((uint32_t)0x001C0000) 98 | #define RCC_PLLMul_10 ((uint32_t)0x00200000) 99 | #define RCC_PLLMul_11 ((uint32_t)0x00240000) 100 | #define RCC_PLLMul_12 ((uint32_t)0x00280000) 101 | #define RCC_PLLMul_13 ((uint32_t)0x002C0000) 102 | #define RCC_PLLMul_14 ((uint32_t)0x00300000) 103 | #define RCC_PLLMul_15 ((uint32_t)0x00340000) 104 | #define RCC_PLLMul_16 ((uint32_t)0x00380000) 105 | #define IS_RCC_PLL_MUL(MUL) (((MUL) == RCC_PLLMul_2) || ((MUL) == RCC_PLLMul_3) || \ 106 | ((MUL) == RCC_PLLMul_4) || ((MUL) == RCC_PLLMul_5) || \ 107 | ((MUL) == RCC_PLLMul_6) || ((MUL) == RCC_PLLMul_7) || \ 108 | ((MUL) == RCC_PLLMul_8) || ((MUL) == RCC_PLLMul_9) || \ 109 | ((MUL) == RCC_PLLMul_10) || ((MUL) == RCC_PLLMul_11) || \ 110 | ((MUL) == RCC_PLLMul_12) || ((MUL) == RCC_PLLMul_13) || \ 111 | ((MUL) == RCC_PLLMul_14) || ((MUL) == RCC_PLLMul_15) || \ 112 | ((MUL) == RCC_PLLMul_16)) 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup System_clock_source 118 | * @{ 119 | */ 120 | 121 | #define RCC_SYSCLKSource_HSI ((uint32_t)0x00000000) 122 | #define RCC_SYSCLKSource_HSE ((uint32_t)0x00000001) 123 | #define RCC_SYSCLKSource_PLLCLK ((uint32_t)0x00000002) 124 | #define IS_RCC_SYSCLK_SOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSource_HSI) || \ 125 | ((SOURCE) == RCC_SYSCLKSource_HSE) || \ 126 | ((SOURCE) == RCC_SYSCLKSource_PLLCLK)) 127 | /** 128 | * @} 129 | */ 130 | 131 | /** @defgroup AHB_clock_source 132 | * @{ 133 | */ 134 | 135 | #define RCC_SYSCLK_Div1 ((uint32_t)0x00000000) 136 | #define RCC_SYSCLK_Div2 ((uint32_t)0x00000080) 137 | #define RCC_SYSCLK_Div4 ((uint32_t)0x00000090) 138 | #define RCC_SYSCLK_Div8 ((uint32_t)0x000000A0) 139 | #define RCC_SYSCLK_Div16 ((uint32_t)0x000000B0) 140 | #define RCC_SYSCLK_Div64 ((uint32_t)0x000000C0) 141 | #define RCC_SYSCLK_Div128 ((uint32_t)0x000000D0) 142 | #define RCC_SYSCLK_Div256 ((uint32_t)0x000000E0) 143 | #define RCC_SYSCLK_Div512 ((uint32_t)0x000000F0) 144 | #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_Div1) || ((HCLK) == RCC_SYSCLK_Div2) || \ 145 | ((HCLK) == RCC_SYSCLK_Div4) || ((HCLK) == RCC_SYSCLK_Div8) || \ 146 | ((HCLK) == RCC_SYSCLK_Div16) || ((HCLK) == RCC_SYSCLK_Div64) || \ 147 | ((HCLK) == RCC_SYSCLK_Div128) || ((HCLK) == RCC_SYSCLK_Div256) || \ 148 | ((HCLK) == RCC_SYSCLK_Div512)) 149 | /** 150 | * @} 151 | */ 152 | 153 | /** @defgroup APB1_APB2_clock_source 154 | * @{ 155 | */ 156 | 157 | #define RCC_HCLK_Div1 ((uint32_t)0x00000000) 158 | #define RCC_HCLK_Div2 ((uint32_t)0x00000400) 159 | #define RCC_HCLK_Div4 ((uint32_t)0x00000500) 160 | #define RCC_HCLK_Div8 ((uint32_t)0x00000600) 161 | #define RCC_HCLK_Div16 ((uint32_t)0x00000700) 162 | #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_Div1) || ((PCLK) == RCC_HCLK_Div2) || \ 163 | ((PCLK) == RCC_HCLK_Div4) || ((PCLK) == RCC_HCLK_Div8) || \ 164 | ((PCLK) == RCC_HCLK_Div16)) 165 | /** 166 | * @} 167 | */ 168 | 169 | /** @defgroup RCC_Interrupt_source 170 | * @{ 171 | */ 172 | 173 | #define RCC_IT_LSIRDY ((uint8_t)0x01) 174 | #define RCC_IT_LSERDY ((uint8_t)0x02) 175 | #define RCC_IT_HSIRDY ((uint8_t)0x04) 176 | #define RCC_IT_HSERDY ((uint8_t)0x08) 177 | #define RCC_IT_PLLRDY ((uint8_t)0x10) 178 | #define RCC_IT_CSS ((uint8_t)0x80) 179 | #define IS_RCC_IT(IT) ((((IT) & (uint8_t)0xE0) == 0x00) && ((IT) != 0x00)) 180 | #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \ 181 | ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \ 182 | ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_CSS)) 183 | 184 | #define IS_RCC_CLEAR_IT(IT) ((((IT) & (uint8_t)0x60) == 0x00) && ((IT) != 0x00)) 185 | /** 186 | * @} 187 | */ 188 | 189 | /** @defgroup USB_clock_source 190 | * @{ 191 | */ 192 | 193 | #define RCC_USBCLKSource_PLLCLK_1Div5 ((uint8_t)0x00) 194 | #define RCC_USBCLKSource_PLLCLK_Div1 ((uint8_t)0x01) 195 | #define IS_RCC_USBCLK_SOURCE(SOURCE) (((SOURCE) == RCC_USBCLKSource_PLLCLK_1Div5) || \ 196 | ((SOURCE) == RCC_USBCLKSource_PLLCLK_Div1)) 197 | /** 198 | * @} 199 | */ 200 | 201 | /** @defgroup ADC_clock_source 202 | * @{ 203 | */ 204 | 205 | #define RCC_PCLK2_Div2 ((uint32_t)0x00000000) 206 | #define RCC_PCLK2_Div4 ((uint32_t)0x00004000) 207 | #define RCC_PCLK2_Div6 ((uint32_t)0x00008000) 208 | #define RCC_PCLK2_Div8 ((uint32_t)0x0000C000) 209 | #define IS_RCC_ADCCLK(ADCCLK) (((ADCCLK) == RCC_PCLK2_Div2) || ((ADCCLK) == RCC_PCLK2_Div4) || \ 210 | ((ADCCLK) == RCC_PCLK2_Div6) || ((ADCCLK) == RCC_PCLK2_Div8)) 211 | /** 212 | * @} 213 | */ 214 | 215 | /** @defgroup LSE_configuration 216 | * @{ 217 | */ 218 | 219 | #define RCC_LSE_OFF ((uint8_t)0x00) 220 | #define RCC_LSE_ON ((uint8_t)0x01) 221 | #define RCC_LSE_Bypass ((uint8_t)0x04) 222 | #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \ 223 | ((LSE) == RCC_LSE_Bypass)) 224 | /** 225 | * @} 226 | */ 227 | 228 | /** @defgroup RTC_clock_source 229 | * @{ 230 | */ 231 | 232 | #define RCC_RTCCLKSource_LSE ((uint32_t)0x00000100) 233 | #define RCC_RTCCLKSource_LSI ((uint32_t)0x00000200) 234 | #define RCC_RTCCLKSource_HSE_Div128 ((uint32_t)0x00000300) 235 | #define IS_RCC_RTCCLK_SOURCE(SOURCE) (((SOURCE) == RCC_RTCCLKSource_LSE) || \ 236 | ((SOURCE) == RCC_RTCCLKSource_LSI) || \ 237 | ((SOURCE) == RCC_RTCCLKSource_HSE_Div128)) 238 | /** 239 | * @} 240 | */ 241 | 242 | /** @defgroup AHB_peripheral 243 | * @{ 244 | */ 245 | 246 | #define RCC_AHBPeriph_DMA1 ((uint32_t)0x00000001) 247 | #define RCC_AHBPeriph_DMA2 ((uint32_t)0x00000002) 248 | #define RCC_AHBPeriph_SRAM ((uint32_t)0x00000004) 249 | #define RCC_AHBPeriph_FLITF ((uint32_t)0x00000010) 250 | #define RCC_AHBPeriph_CRC ((uint32_t)0x00000040) 251 | #define RCC_AHBPeriph_FSMC ((uint32_t)0x00000100) 252 | #define RCC_AHBPeriph_SDIO ((uint32_t)0x00000400) 253 | #define IS_RCC_AHB_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFAA8) == 0x00) && ((PERIPH) != 0x00)) 254 | /** 255 | * @} 256 | */ 257 | 258 | /** @defgroup APB2_peripheral 259 | * @{ 260 | */ 261 | 262 | #define RCC_APB2Periph_AFIO ((uint32_t)0x00000001) 263 | #define RCC_APB2Periph_GPIOA ((uint32_t)0x00000004) 264 | #define RCC_APB2Periph_GPIOB ((uint32_t)0x00000008) 265 | #define RCC_APB2Periph_GPIOC ((uint32_t)0x00000010) 266 | #define RCC_APB2Periph_GPIOD ((uint32_t)0x00000020) 267 | #define RCC_APB2Periph_GPIOE ((uint32_t)0x00000040) 268 | #define RCC_APB2Periph_GPIOF ((uint32_t)0x00000080) 269 | #define RCC_APB2Periph_GPIOG ((uint32_t)0x00000100) 270 | #define RCC_APB2Periph_ADC1 ((uint32_t)0x00000200) 271 | #define RCC_APB2Periph_ADC2 ((uint32_t)0x00000400) 272 | #define RCC_APB2Periph_TIM1 ((uint32_t)0x00000800) 273 | #define RCC_APB2Periph_SPI1 ((uint32_t)0x00001000) 274 | #define RCC_APB2Periph_TIM8 ((uint32_t)0x00002000) 275 | #define RCC_APB2Periph_USART1 ((uint32_t)0x00004000) 276 | #define RCC_APB2Periph_ADC3 ((uint32_t)0x00008000) 277 | #define RCC_APB2Periph_ALL ((uint32_t)0x0000FFFD) 278 | 279 | #define IS_RCC_APB2_PERIPH(PERIPH) ((((PERIPH) & 0xFFFF0002) == 0x00) && ((PERIPH) != 0x00)) 280 | /** 281 | * @} 282 | */ 283 | 284 | /** @defgroup APB1_peripheral 285 | * @{ 286 | */ 287 | 288 | #define RCC_APB1Periph_TIM2 ((uint32_t)0x00000001) 289 | #define RCC_APB1Periph_TIM3 ((uint32_t)0x00000002) 290 | #define RCC_APB1Periph_TIM4 ((uint32_t)0x00000004) 291 | #define RCC_APB1Periph_TIM5 ((uint32_t)0x00000008) 292 | #define RCC_APB1Periph_TIM6 ((uint32_t)0x00000010) 293 | #define RCC_APB1Periph_TIM7 ((uint32_t)0x00000020) 294 | #define RCC_APB1Periph_WWDG ((uint32_t)0x00000800) 295 | #define RCC_APB1Periph_SPI2 ((uint32_t)0x00004000) 296 | #define RCC_APB1Periph_SPI3 ((uint32_t)0x00008000) 297 | #define RCC_APB1Periph_USART2 ((uint32_t)0x00020000) 298 | #define RCC_APB1Periph_USART3 ((uint32_t)0x00040000) 299 | #define RCC_APB1Periph_UART4 ((uint32_t)0x00080000) 300 | #define RCC_APB1Periph_UART5 ((uint32_t)0x00100000) 301 | #define RCC_APB1Periph_I2C1 ((uint32_t)0x00200000) 302 | #define RCC_APB1Periph_I2C2 ((uint32_t)0x00400000) 303 | #define RCC_APB1Periph_USB ((uint32_t)0x00800000) 304 | #define RCC_APB1Periph_CAN1 ((uint32_t)0x02000000) 305 | #define RCC_APB1Periph_BKP ((uint32_t)0x08000000) 306 | #define RCC_APB1Periph_PWR ((uint32_t)0x10000000) 307 | #define RCC_APB1Periph_DAC ((uint32_t)0x20000000) 308 | #define RCC_APB1Periph_ALL ((uint32_t)0x3AFEC83F) 309 | 310 | #define IS_RCC_APB1_PERIPH(PERIPH) ((((PERIPH) & 0xC50137C0) == 0x00) && ((PERIPH) != 0x00)) 311 | /** 312 | * @} 313 | */ 314 | 315 | /** @defgroup Clock_source_to_output_on_MCO_pin 316 | * @{ 317 | */ 318 | 319 | #define RCC_MCO_NoClock ((uint8_t)0x00) 320 | #define RCC_MCO_SYSCLK ((uint8_t)0x04) 321 | #define RCC_MCO_HSI ((uint8_t)0x05) 322 | #define RCC_MCO_HSE ((uint8_t)0x06) 323 | #define RCC_MCO_PLLCLK_Div2 ((uint8_t)0x07) 324 | #define IS_RCC_MCO(MCO) (((MCO) == RCC_MCO_NoClock) || ((MCO) == RCC_MCO_HSI) || \ 325 | ((MCO) == RCC_MCO_SYSCLK) || ((MCO) == RCC_MCO_HSE) || \ 326 | ((MCO) == RCC_MCO_PLLCLK_Div2)) 327 | /** 328 | * @} 329 | */ 330 | 331 | /** @defgroup RCC_Flag 332 | * @{ 333 | */ 334 | 335 | #define RCC_FLAG_HSIRDY ((uint8_t)0x21) 336 | #define RCC_FLAG_HSERDY ((uint8_t)0x31) 337 | #define RCC_FLAG_PLLRDY ((uint8_t)0x39) 338 | #define RCC_FLAG_LSERDY ((uint8_t)0x41) 339 | #define RCC_FLAG_LSIRDY ((uint8_t)0x61) 340 | #define RCC_FLAG_PINRST ((uint8_t)0x7A) 341 | #define RCC_FLAG_PORRST ((uint8_t)0x7B) 342 | #define RCC_FLAG_SFTRST ((uint8_t)0x7C) 343 | #define RCC_FLAG_IWDGRST ((uint8_t)0x7D) 344 | #define RCC_FLAG_WWDGRST ((uint8_t)0x7E) 345 | #define RCC_FLAG_LPWRRST ((uint8_t)0x7F) 346 | #define IS_RCC_FLAG(FLAG) (((FLAG) == RCC_FLAG_HSIRDY) || ((FLAG) == RCC_FLAG_HSERDY) || \ 347 | ((FLAG) == RCC_FLAG_PLLRDY) || ((FLAG) == RCC_FLAG_LSERDY) || \ 348 | ((FLAG) == RCC_FLAG_LSIRDY) || ((FLAG) == RCC_FLAG_PINRST) || \ 349 | ((FLAG) == RCC_FLAG_PORRST) || ((FLAG) == RCC_FLAG_SFTRST) || \ 350 | ((FLAG) == RCC_FLAG_IWDGRST)|| ((FLAG) == RCC_FLAG_WWDGRST)|| \ 351 | ((FLAG) == RCC_FLAG_LPWRRST)) 352 | 353 | #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F) 354 | /** 355 | * @} 356 | */ 357 | 358 | /** 359 | * @} 360 | */ 361 | 362 | /** @defgroup RCC_Exported_Macros 363 | * @{ 364 | */ 365 | 366 | /** 367 | * @} 368 | */ 369 | 370 | /** @defgroup RCC_Exported_Functions 371 | * @{ 372 | */ 373 | 374 | void RCC_DeInit(void); 375 | void RCC_HSEConfig(uint32_t RCC_HSE); 376 | ErrorStatus RCC_WaitForHSEStartUp(void); 377 | void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue); 378 | void RCC_HSICmd(FunctionalState NewState); 379 | void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul); 380 | void RCC_PLLCmd(FunctionalState NewState); 381 | void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource); 382 | uint8_t RCC_GetSYSCLKSource(void); 383 | void RCC_HCLKConfig(uint32_t RCC_SYSCLK); 384 | void RCC_PCLK1Config(uint32_t RCC_HCLK); 385 | void RCC_PCLK2Config(uint32_t RCC_HCLK); 386 | void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState); 387 | void RCC_USBCLKConfig(uint32_t RCC_USBCLKSource); 388 | void RCC_ADCCLKConfig(uint32_t RCC_PCLK2); 389 | void RCC_LSEConfig(uint8_t RCC_LSE); 390 | void RCC_LSICmd(FunctionalState NewState); 391 | void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource); 392 | void RCC_RTCCLKCmd(FunctionalState NewState); 393 | void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks); 394 | void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState); 395 | void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState); 396 | void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState); 397 | void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState); 398 | void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState); 399 | void RCC_BackupResetCmd(FunctionalState NewState); 400 | void RCC_ClockSecuritySystemCmd(FunctionalState NewState); 401 | void RCC_MCOConfig(uint8_t RCC_MCO); 402 | FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG); 403 | void RCC_ClearFlag(void); 404 | ITStatus RCC_GetITStatus(uint8_t RCC_IT); 405 | void RCC_ClearITPendingBit(uint8_t RCC_IT); 406 | 407 | #endif /* __STM32F10x_RCC_H */ 408 | /** 409 | * @} 410 | */ 411 | 412 | /** 413 | * @} 414 | */ 415 | 416 | /** 417 | * @} 418 | */ 419 | 420 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 421 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_tim.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steven-lyan/microLite_timer/e12c267206030c1902159cae883746fbf190c82d/bsp/stm32f103vb/Libraries/stm32f10x_tim.c -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steven-lyan/microLite_timer/e12c267206030c1902159cae883746fbf190c82d/bsp/stm32f103vb/Libraries/stm32f10x_usart.c -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/stm32f10x_usart.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_usart.h 4 | * @author MCD Application Team 5 | * @version V3.0.0 6 | * @date 04/06/2009 7 | * @brief This file contains all the functions prototypes for the USART 8 | * firmware library. 9 | ****************************************************************************** 10 | * @copy 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2009 STMicroelectronics

20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_USART_H 24 | #define __STM32F10x_USART_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32f10x.h" 28 | 29 | /** @addtogroup StdPeriph_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup USART 34 | * @{ 35 | */ 36 | 37 | /** @defgroup USART_Exported_Types 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief USART Init Structure definition 43 | */ 44 | 45 | typedef struct 46 | { 47 | uint32_t USART_BaudRate; 48 | uint16_t USART_WordLength; 49 | uint16_t USART_StopBits; 50 | uint16_t USART_Parity; 51 | uint16_t USART_Mode; 52 | uint16_t USART_HardwareFlowControl; 53 | } USART_InitTypeDef; 54 | 55 | /** 56 | * @brief USART Clock Init Structure definition 57 | */ 58 | 59 | typedef struct 60 | { 61 | uint16_t USART_Clock; 62 | uint16_t USART_CPOL; 63 | uint16_t USART_CPHA; 64 | uint16_t USART_LastBit; 65 | } USART_ClockInitTypeDef; 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USART_Exported_Constants 72 | * @{ 73 | */ 74 | 75 | #define IS_USART_ALL_PERIPH(PERIPH) (((*(uint32_t*)&(PERIPH)) == USART1_BASE) || \ 76 | ((*(uint32_t*)&(PERIPH)) == USART2_BASE) || \ 77 | ((*(uint32_t*)&(PERIPH)) == USART3_BASE) || \ 78 | ((*(uint32_t*)&(PERIPH)) == UART4_BASE) || \ 79 | ((*(uint32_t*)&(PERIPH)) == UART5_BASE)) 80 | #define IS_USART_123_PERIPH(PERIPH) (((*(uint32_t*)&(PERIPH)) == USART1_BASE) || \ 81 | ((*(uint32_t*)&(PERIPH)) == USART2_BASE) || \ 82 | ((*(uint32_t*)&(PERIPH)) == USART3_BASE)) 83 | #define IS_USART_1234_PERIPH(PERIPH) (((*(uint32_t*)&(PERIPH)) == USART1_BASE) || \ 84 | ((*(uint32_t*)&(PERIPH)) == USART2_BASE) || \ 85 | ((*(uint32_t*)&(PERIPH)) == USART3_BASE) || \ 86 | ((*(uint32_t*)&(PERIPH)) == UART4_BASE)) 87 | /** @defgroup USART_Word_Length 88 | * @{ 89 | */ 90 | 91 | #define USART_WordLength_8b ((uint16_t)0x0000) 92 | #define USART_WordLength_9b ((uint16_t)0x1000) 93 | 94 | #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \ 95 | ((LENGTH) == USART_WordLength_9b)) 96 | /** 97 | * @} 98 | */ 99 | 100 | /** @defgroup USART_Stop_Bits 101 | * @{ 102 | */ 103 | 104 | #define USART_StopBits_1 ((uint16_t)0x0000) 105 | #define USART_StopBits_0_5 ((uint16_t)0x1000) 106 | #define USART_StopBits_2 ((uint16_t)0x2000) 107 | #define USART_StopBits_1_5 ((uint16_t)0x3000) 108 | #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \ 109 | ((STOPBITS) == USART_StopBits_0_5) || \ 110 | ((STOPBITS) == USART_StopBits_2) || \ 111 | ((STOPBITS) == USART_StopBits_1_5)) 112 | /** 113 | * @} 114 | */ 115 | 116 | /** @defgroup USART_Parity 117 | * @{ 118 | */ 119 | 120 | #define USART_Parity_No ((uint16_t)0x0000) 121 | #define USART_Parity_Even ((uint16_t)0x0400) 122 | #define USART_Parity_Odd ((uint16_t)0x0600) 123 | #define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \ 124 | ((PARITY) == USART_Parity_Even) || \ 125 | ((PARITY) == USART_Parity_Odd)) 126 | /** 127 | * @} 128 | */ 129 | 130 | /** @defgroup USART_Mode 131 | * @{ 132 | */ 133 | 134 | #define USART_Mode_Rx ((uint16_t)0x0004) 135 | #define USART_Mode_Tx ((uint16_t)0x0008) 136 | #define IS_USART_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00)) 137 | /** 138 | * @} 139 | */ 140 | 141 | /** @defgroup USART_Hardware_Flow_Control 142 | * @{ 143 | */ 144 | #define USART_HardwareFlowControl_None ((uint16_t)0x0000) 145 | #define USART_HardwareFlowControl_RTS ((uint16_t)0x0100) 146 | #define USART_HardwareFlowControl_CTS ((uint16_t)0x0200) 147 | #define USART_HardwareFlowControl_RTS_CTS ((uint16_t)0x0300) 148 | #define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\ 149 | (((CONTROL) == USART_HardwareFlowControl_None) || \ 150 | ((CONTROL) == USART_HardwareFlowControl_RTS) || \ 151 | ((CONTROL) == USART_HardwareFlowControl_CTS) || \ 152 | ((CONTROL) == USART_HardwareFlowControl_RTS_CTS)) 153 | #define IS_USART_PERIPH_HFC(PERIPH, HFC) ((((*(uint32_t*)&(PERIPH)) != UART4_BASE) && \ 154 | ((*(uint32_t*)&(PERIPH)) != UART5_BASE)) \ 155 | || ((HFC) == USART_HardwareFlowControl_None)) 156 | /** 157 | * @} 158 | */ 159 | 160 | /** @defgroup USART_Clock 161 | * @{ 162 | */ 163 | #define USART_Clock_Disable ((uint16_t)0x0000) 164 | #define USART_Clock_Enable ((uint16_t)0x0800) 165 | #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \ 166 | ((CLOCK) == USART_Clock_Enable)) 167 | /** 168 | * @} 169 | */ 170 | 171 | /** @defgroup USART_Clock_Polarity 172 | * @{ 173 | */ 174 | 175 | #define USART_CPOL_Low ((uint16_t)0x0000) 176 | #define USART_CPOL_High ((uint16_t)0x0400) 177 | #define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High)) 178 | 179 | /** 180 | * @} 181 | */ 182 | 183 | /** @defgroup USART_Clock_Phase 184 | * @{ 185 | */ 186 | 187 | #define USART_CPHA_1Edge ((uint16_t)0x0000) 188 | #define USART_CPHA_2Edge ((uint16_t)0x0200) 189 | #define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge)) 190 | 191 | /** 192 | * @} 193 | */ 194 | 195 | /** @defgroup USART_Last_Bit 196 | * @{ 197 | */ 198 | 199 | #define USART_LastBit_Disable ((uint16_t)0x0000) 200 | #define USART_LastBit_Enable ((uint16_t)0x0100) 201 | #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \ 202 | ((LASTBIT) == USART_LastBit_Enable)) 203 | /** 204 | * @} 205 | */ 206 | 207 | /** @defgroup USART_Interrupt_definition 208 | * @{ 209 | */ 210 | 211 | #define USART_IT_PE ((uint16_t)0x0028) 212 | #define USART_IT_TXE ((uint16_t)0x0727) 213 | #define USART_IT_TC ((uint16_t)0x0626) 214 | #define USART_IT_RXNE ((uint16_t)0x0525) 215 | #define USART_IT_IDLE ((uint16_t)0x0424) 216 | #define USART_IT_LBD ((uint16_t)0x0846) 217 | #define USART_IT_CTS ((uint16_t)0x096A) 218 | #define USART_IT_ERR ((uint16_t)0x0060) 219 | #define USART_IT_ORE ((uint16_t)0x0360) 220 | #define USART_IT_NE ((uint16_t)0x0260) 221 | #define USART_IT_FE ((uint16_t)0x0160) 222 | #define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \ 223 | ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ 224 | ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \ 225 | ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR)) 226 | #define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \ 227 | ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ 228 | ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \ 229 | ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE) || \ 230 | ((IT) == USART_IT_NE) || ((IT) == USART_IT_FE)) 231 | #define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ 232 | ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS)) 233 | #define IS_USART_PERIPH_IT(PERIPH, USART_IT) ((((*(uint32_t*)&(PERIPH)) != UART4_BASE) && \ 234 | ((*(uint32_t*)&(PERIPH)) != UART5_BASE)) \ 235 | || ((USART_IT) != USART_IT_CTS)) 236 | /** 237 | * @} 238 | */ 239 | 240 | /** @defgroup USART_DMA_Requests 241 | * @{ 242 | */ 243 | 244 | #define USART_DMAReq_Tx ((uint16_t)0x0080) 245 | #define USART_DMAReq_Rx ((uint16_t)0x0040) 246 | #define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFF3F) == 0x00) && ((DMAREQ) != (uint16_t)0x00)) 247 | 248 | /** 249 | * @} 250 | */ 251 | 252 | /** @defgroup USART_WakeUp_methods 253 | * @{ 254 | */ 255 | 256 | #define USART_WakeUp_IdleLine ((uint16_t)0x0000) 257 | #define USART_WakeUp_AddressMark ((uint16_t)0x0800) 258 | #define IS_USART_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \ 259 | ((WAKEUP) == USART_WakeUp_AddressMark)) 260 | /** 261 | * @} 262 | */ 263 | 264 | /** @defgroup USART_LIN_Break_Detection_Length 265 | * @{ 266 | */ 267 | 268 | #define USART_LINBreakDetectLength_10b ((uint16_t)0x0000) 269 | #define USART_LINBreakDetectLength_11b ((uint16_t)0x0020) 270 | #define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \ 271 | (((LENGTH) == USART_LINBreakDetectLength_10b) || \ 272 | ((LENGTH) == USART_LINBreakDetectLength_11b)) 273 | /** 274 | * @} 275 | */ 276 | 277 | /** @defgroup USART_IrDA_Low_Power 278 | * @{ 279 | */ 280 | 281 | #define USART_IrDAMode_LowPower ((uint16_t)0x0004) 282 | #define USART_IrDAMode_Normal ((uint16_t)0x0000) 283 | #define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \ 284 | ((MODE) == USART_IrDAMode_Normal)) 285 | /** 286 | * @} 287 | */ 288 | 289 | /** @defgroup USART_Flags 290 | * @{ 291 | */ 292 | 293 | #define USART_FLAG_CTS ((uint16_t)0x0200) 294 | #define USART_FLAG_LBD ((uint16_t)0x0100) 295 | #define USART_FLAG_TXE ((uint16_t)0x0080) 296 | #define USART_FLAG_TC ((uint16_t)0x0040) 297 | #define USART_FLAG_RXNE ((uint16_t)0x0020) 298 | #define USART_FLAG_IDLE ((uint16_t)0x0010) 299 | #define USART_FLAG_ORE ((uint16_t)0x0008) 300 | #define USART_FLAG_NE ((uint16_t)0x0004) 301 | #define USART_FLAG_FE ((uint16_t)0x0002) 302 | #define USART_FLAG_PE ((uint16_t)0x0001) 303 | #define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \ 304 | ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \ 305 | ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \ 306 | ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \ 307 | ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE)) 308 | 309 | #define IS_USART_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFC9F) == 0x00) && ((FLAG) != (uint16_t)0x00)) 310 | #define IS_USART_PERIPH_FLAG(PERIPH, USART_FLAG) ((((*(uint32_t*)&(PERIPH)) != UART4_BASE) &&\ 311 | ((*(uint32_t*)&(PERIPH)) != UART5_BASE)) \ 312 | || ((USART_FLAG) != USART_FLAG_CTS)) 313 | #define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x0044AA21)) 314 | #define IS_USART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF) 315 | #define IS_USART_DATA(DATA) ((DATA) <= 0x1FF) 316 | 317 | /** 318 | * @} 319 | */ 320 | 321 | /** 322 | * @} 323 | */ 324 | 325 | /** @defgroup USART_Exported_Macros 326 | * @{ 327 | */ 328 | 329 | /** 330 | * @} 331 | */ 332 | 333 | /** @defgroup USART_Exported_Functions 334 | * @{ 335 | */ 336 | 337 | void USART_DeInit(USART_TypeDef* USARTx); 338 | void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct); 339 | void USART_StructInit(USART_InitTypeDef* USART_InitStruct); 340 | void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct); 341 | void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct); 342 | void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState); 343 | void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState); 344 | void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState); 345 | void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address); 346 | void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp); 347 | void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState); 348 | void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength); 349 | void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState); 350 | void USART_SendData(USART_TypeDef* USARTx, uint16_t Data); 351 | uint16_t USART_ReceiveData(USART_TypeDef* USARTx); 352 | void USART_SendBreak(USART_TypeDef* USARTx); 353 | void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime); 354 | void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler); 355 | void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState); 356 | void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState); 357 | void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState); 358 | void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode); 359 | void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState); 360 | FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG); 361 | void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG); 362 | ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT); 363 | void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT); 364 | 365 | #endif /* __STM32F10x_USART_H */ 366 | /** 367 | * @} 368 | */ 369 | 370 | /** 371 | * @} 372 | */ 373 | 374 | /** 375 | * @} 376 | */ 377 | 378 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 379 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/Libraries/system_stm32f10x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 5 | * @author STMicroelectronics - MCD Application Team 6 | * @version V3.0.0 7 | * @date 04/06/2009 8 | ****************************************************************************** 9 | * 10 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 11 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 12 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 13 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 14 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 15 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 16 | * 17 | *

© COPYRIGHT 2009 STMicroelectronics

18 | ****************************************************************************** 19 | */ 20 | 21 | /** 22 | * @brief Define to prevent recursive inclusion 23 | */ 24 | #ifndef __SYSTEM_STM32F10X_H 25 | #define __SYSTEM_STM32F10X_H 26 | 27 | /** @addtogroup Includes 28 | * @{ 29 | */ 30 | 31 | /** 32 | * @} 33 | */ 34 | 35 | 36 | /** @addtogroup Exported_types 37 | * @{ 38 | */ 39 | 40 | extern const uint32_t SystemFrequency; /*!< System Clock Frequency (Core Clock) */ 41 | extern const uint32_t SystemFrequency_SysClk; /*!< System clock */ 42 | extern const uint32_t SystemFrequency_AHBClk; /*!< AHB System bus speed */ 43 | extern const uint32_t SystemFrequency_APB1Clk; /*!< APB Peripheral Bus 1 (low) speed */ 44 | extern const uint32_t SystemFrequency_APB2Clk; /*!< APB Peripheral Bus 2 (high) speed */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @addtogroup Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @addtogroup Exported_Macros 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup Exported_Functions 67 | * @{ 68 | */ 69 | 70 | extern void SystemInit(void); 71 | /** 72 | * @} 73 | */ 74 | 75 | #endif /*__SYSTEM_STM32F10X_H */ 76 | 77 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/gcc/Makefile: -------------------------------------------------------------------------------- 1 | ###################################### 2 | # target 3 | ###################################### 4 | TARGET = microLite_timer 5 | 6 | ###################################### 7 | # building variables 8 | ###################################### 9 | # debug build? 10 | DEBUG = 1 11 | # optimization 12 | OPT = -Og 13 | 14 | TOP_DIR = ../../../../microLite_timer 15 | 16 | ####################################### 17 | # paths 18 | ####################################### 19 | # Build path 20 | BUILD_DIR = build 21 | 22 | ###################################### 23 | # source 24 | ###################################### 25 | # C sources 26 | C_SOURCES = \ 27 | $(TOP_DIR)/src/microLite_timer.c \ 28 | ${wildcard $(TOP_DIR)/test/*.c} \ 29 | ${wildcard $(TOP_DIR)/bsp/stm32f103vb/main.c} 30 | 31 | # ASM sources 32 | ASM_SOURCES = \ 33 | startup_stm32f103xb.s 34 | 35 | 36 | ####################################### 37 | # binaries 38 | ####################################### 39 | PREFIX = arm-none-eabi- 40 | # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) 41 | # either it can be added to the PATH environment variable. 42 | ifdef GCC_PATH 43 | CC = $(GCC_PATH)/$(PREFIX)gcc 44 | AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp 45 | CP = $(GCC_PATH)/$(PREFIX)objcopy 46 | SZ = $(GCC_PATH)/$(PREFIX)size 47 | else 48 | CC = $(PREFIX)gcc 49 | AS = $(PREFIX)gcc -x assembler-with-cpp 50 | CP = $(PREFIX)objcopy 51 | SZ = $(PREFIX)size 52 | endif 53 | HEX = $(CP) -O ihex 54 | BIN = $(CP) -O binary -S 55 | 56 | ####################################### 57 | # CFLAGS 58 | ####################################### 59 | # cpu 60 | CPU = -mcpu=cortex-m3 61 | 62 | # fpu 63 | # NONE for Cortex-M0/M0+/M3 64 | 65 | # float-abi 66 | 67 | # mcu 68 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) 69 | 70 | # macros for gcc 71 | # AS defines 72 | AS_DEFS = 73 | 74 | # C defines 75 | C_DEFS = \ 76 | -DUSE_STDPERIPH_DRIVER \ 77 | -DSTM32F10X_MD 78 | 79 | # AS includes 80 | AS_INCLUDES = 81 | 82 | # C includes 83 | C_INCLUDES = \ 84 | -I $(TOP_DIR)/src \ 85 | -I $(TOP_DIR)/bsp/stm32f103vb/Libraries 86 | 87 | # compile gcc flags 88 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 89 | 90 | CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 91 | 92 | ifeq ($(DEBUG), 1) 93 | CFLAGS += -g -gdwarf-2 94 | endif 95 | 96 | 97 | # Generate dependency information 98 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" 99 | 100 | 101 | ####################################### 102 | # LDFLAGS 103 | ####################################### 104 | # link script 105 | LDSCRIPT = STM32F103RBTx_FLASH.ld 106 | 107 | # libraries 108 | LIBS = -lc -lm -lnosys 109 | LIBDIR = 110 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections 111 | 112 | # default action: build all 113 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin 114 | 115 | 116 | ####################################### 117 | # build the application 118 | ####################################### 119 | # list of objects 120 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) 121 | vpath %.c $(sort $(dir $(C_SOURCES))) 122 | # list of ASM program objects 123 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) 124 | vpath %.s $(sort $(dir $(ASM_SOURCES))) 125 | 126 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 127 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ 128 | 129 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) 130 | $(AS) -c $(CFLAGS) $< -o $@ 131 | 132 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile 133 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ 134 | $(SZ) $@ 135 | 136 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 137 | $(HEX) $< $@ 138 | 139 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 140 | $(BIN) $< $@ 141 | 142 | $(BUILD_DIR): 143 | mkdir $@ 144 | 145 | ####################################### 146 | # clean up 147 | ####################################### 148 | clean: 149 | -rm -fR $(BUILD_DIR) 150 | 151 | ####################################### 152 | # dependencies 153 | ####################################### 154 | -include $(wildcard $(BUILD_DIR)/*.d) 155 | 156 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/gcc/STM32F103RBTx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Author : Auto-generated by Ac6 System Workbench 8 | ** 9 | ** Abstract : Linker script for STM32F103RBTx series 10 | ** 128Kbytes FLASH and 20Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed “as is,” without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2014 Ac6

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of Ac6 nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Highest address of the user mode stack */ 56 | _estack = 0x20005000; /* end of RAM */ 57 | /* Generate a link error if heap and stack don't fit into RAM */ 58 | _Min_Heap_Size = 0x200; /* required amount of heap */ 59 | _Min_Stack_Size = 0x400; /* required amount of stack */ 60 | 61 | /* Specify the memory areas */ 62 | MEMORY 63 | { 64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 65 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K 66 | } 67 | 68 | /* Define output sections */ 69 | SECTIONS 70 | { 71 | /* The startup code goes first into FLASH */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data goes into FLASH */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data goes into FLASH */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 106 | .ARM : { 107 | __exidx_start = .; 108 | *(.ARM.exidx*) 109 | __exidx_end = .; 110 | } >FLASH 111 | 112 | .preinit_array : 113 | { 114 | PROVIDE_HIDDEN (__preinit_array_start = .); 115 | KEEP (*(.preinit_array*)) 116 | PROVIDE_HIDDEN (__preinit_array_end = .); 117 | } >FLASH 118 | .init_array : 119 | { 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | } >FLASH 125 | .fini_array : 126 | { 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | } >FLASH 132 | 133 | /* used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections goes into RAM, load LMA copy after code */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | } >RAM AT> FLASH 147 | 148 | 149 | /* Uninitialized data section */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss secion */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough RAM left */ 166 | ._user_heap_stack : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | 177 | 178 | /* Remove information from the standard libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | 189 | 190 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/gcc/startup_stm32f103xb.s: -------------------------------------------------------------------------------- 1 | /** 2 | *************** (C) COPYRIGHT 2017 STMicroelectronics ************************ 3 | * @file startup_stm32f103xb.s 4 | * @author MCD Application Team 5 | * @brief STM32F103xB Devices vector table for Atollic toolchain. 6 | * This module performs: 7 | * - Set the initial SP 8 | * - Set the initial PC == Reset_Handler, 9 | * - Set the vector table entries with the exceptions ISR address 10 | * - Configure the clock system 11 | * - Branches to main in the C library (which eventually 12 | * calls main()). 13 | * After Reset the Cortex-M3 processor is in Thread mode, 14 | * priority is Privileged, and the Stack is set to Main. 15 | ****************************************************************************** 16 | * @attention 17 | * 18 | *

© Copyright (c) 2017 STMicroelectronics. 19 | * All rights reserved.

20 | * 21 | * This software component is licensed by ST under BSD 3-Clause license, 22 | * the "License"; You may not use this file except in compliance with the 23 | * License. You may obtain a copy of the License at: 24 | * opensource.org/licenses/BSD-3-Clause 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | .syntax unified 30 | .cpu cortex-m3 31 | .fpu softvfp 32 | .thumb 33 | 34 | .global g_pfnVectors 35 | .global Default_Handler 36 | 37 | /* start address for the initialization values of the .data section. 38 | defined in linker script */ 39 | .word _sidata 40 | /* start address for the .data section. defined in linker script */ 41 | .word _sdata 42 | /* end address for the .data section. defined in linker script */ 43 | .word _edata 44 | /* start address for the .bss section. defined in linker script */ 45 | .word _sbss 46 | /* end address for the .bss section. defined in linker script */ 47 | .word _ebss 48 | 49 | .equ BootRAM, 0xF108F85F 50 | /** 51 | * @brief This is the code that gets called when the processor first 52 | * starts execution following a reset event. Only the absolutely 53 | * necessary set is performed, after which the application 54 | * supplied main() routine is called. 55 | * @param None 56 | * @retval : None 57 | */ 58 | 59 | .section .text.Reset_Handler 60 | .weak Reset_Handler 61 | .type Reset_Handler, %function 62 | Reset_Handler: 63 | 64 | /* Copy the data segment initializers from flash to SRAM */ 65 | movs r1, #0 66 | b LoopCopyDataInit 67 | 68 | CopyDataInit: 69 | ldr r3, =_sidata 70 | ldr r3, [r3, r1] 71 | str r3, [r0, r1] 72 | adds r1, r1, #4 73 | 74 | LoopCopyDataInit: 75 | ldr r0, =_sdata 76 | ldr r3, =_edata 77 | adds r2, r0, r1 78 | cmp r2, r3 79 | bcc CopyDataInit 80 | ldr r2, =_sbss 81 | b LoopFillZerobss 82 | /* Zero fill the bss segment. */ 83 | FillZerobss: 84 | movs r3, #0 85 | str r3, [r2], #4 86 | 87 | LoopFillZerobss: 88 | ldr r3, = _ebss 89 | cmp r2, r3 90 | bcc FillZerobss 91 | 92 | /* Call the clock system intitialization function.*/ 93 | bl SystemInit 94 | /* Call static constructors */ 95 | bl __libc_init_array 96 | /* Call the application's entry point.*/ 97 | bl main 98 | bx lr 99 | .size Reset_Handler, .-Reset_Handler 100 | 101 | /** 102 | * @brief This is the code that gets called when the processor receives an 103 | * unexpected interrupt. This simply enters an infinite loop, preserving 104 | * the system state for examination by a debugger. 105 | * 106 | * @param None 107 | * @retval : None 108 | */ 109 | .section .text.Default_Handler,"ax",%progbits 110 | Default_Handler: 111 | Infinite_Loop: 112 | b Infinite_Loop 113 | .size Default_Handler, .-Default_Handler 114 | /****************************************************************************** 115 | * 116 | * The minimal vector table for a Cortex M3. Note that the proper constructs 117 | * must be placed on this to ensure that it ends up at physical address 118 | * 0x0000.0000. 119 | * 120 | ******************************************************************************/ 121 | .section .isr_vector,"a",%progbits 122 | .type g_pfnVectors, %object 123 | .size g_pfnVectors, .-g_pfnVectors 124 | 125 | 126 | g_pfnVectors: 127 | 128 | .word _estack 129 | .word Reset_Handler 130 | .word NMI_Handler 131 | .word HardFault_Handler 132 | .word MemManage_Handler 133 | .word BusFault_Handler 134 | .word UsageFault_Handler 135 | .word 0 136 | .word 0 137 | .word 0 138 | .word 0 139 | .word SVC_Handler 140 | .word DebugMon_Handler 141 | .word 0 142 | .word PendSV_Handler 143 | .word SysTick_Handler 144 | .word WWDG_IRQHandler 145 | .word PVD_IRQHandler 146 | .word TAMPER_IRQHandler 147 | .word RTC_IRQHandler 148 | .word FLASH_IRQHandler 149 | .word RCC_IRQHandler 150 | .word EXTI0_IRQHandler 151 | .word EXTI1_IRQHandler 152 | .word EXTI2_IRQHandler 153 | .word EXTI3_IRQHandler 154 | .word EXTI4_IRQHandler 155 | .word DMA1_Channel1_IRQHandler 156 | .word DMA1_Channel2_IRQHandler 157 | .word DMA1_Channel3_IRQHandler 158 | .word DMA1_Channel4_IRQHandler 159 | .word DMA1_Channel5_IRQHandler 160 | .word DMA1_Channel6_IRQHandler 161 | .word DMA1_Channel7_IRQHandler 162 | .word ADC1_2_IRQHandler 163 | .word USB_HP_CAN1_TX_IRQHandler 164 | .word USB_LP_CAN1_RX0_IRQHandler 165 | .word CAN1_RX1_IRQHandler 166 | .word CAN1_SCE_IRQHandler 167 | .word EXTI9_5_IRQHandler 168 | .word TIM1_BRK_IRQHandler 169 | .word TIM1_UP_IRQHandler 170 | .word TIM1_TRG_COM_IRQHandler 171 | .word TIM1_CC_IRQHandler 172 | .word TIM2_IRQHandler 173 | .word TIM3_IRQHandler 174 | .word TIM4_IRQHandler 175 | .word I2C1_EV_IRQHandler 176 | .word I2C1_ER_IRQHandler 177 | .word I2C2_EV_IRQHandler 178 | .word I2C2_ER_IRQHandler 179 | .word SPI1_IRQHandler 180 | .word SPI2_IRQHandler 181 | .word USART1_IRQHandler 182 | .word USART2_IRQHandler 183 | .word USART3_IRQHandler 184 | .word EXTI15_10_IRQHandler 185 | .word RTC_Alarm_IRQHandler 186 | .word USBWakeUp_IRQHandler 187 | .word 0 188 | .word 0 189 | .word 0 190 | .word 0 191 | .word 0 192 | .word 0 193 | .word 0 194 | .word BootRAM /* @0x108. This is for boot in RAM mode for 195 | STM32F10x Medium Density devices. */ 196 | 197 | /******************************************************************************* 198 | * 199 | * Provide weak aliases for each Exception handler to the Default_Handler. 200 | * As they are weak aliases, any function with the same name will override 201 | * this definition. 202 | * 203 | *******************************************************************************/ 204 | 205 | .weak NMI_Handler 206 | .thumb_set NMI_Handler,Default_Handler 207 | 208 | .weak HardFault_Handler 209 | .thumb_set HardFault_Handler,Default_Handler 210 | 211 | .weak MemManage_Handler 212 | .thumb_set MemManage_Handler,Default_Handler 213 | 214 | .weak BusFault_Handler 215 | .thumb_set BusFault_Handler,Default_Handler 216 | 217 | .weak UsageFault_Handler 218 | .thumb_set UsageFault_Handler,Default_Handler 219 | 220 | .weak SVC_Handler 221 | .thumb_set SVC_Handler,Default_Handler 222 | 223 | .weak DebugMon_Handler 224 | .thumb_set DebugMon_Handler,Default_Handler 225 | 226 | .weak PendSV_Handler 227 | .thumb_set PendSV_Handler,Default_Handler 228 | 229 | .weak SysTick_Handler 230 | .thumb_set SysTick_Handler,Default_Handler 231 | 232 | .weak WWDG_IRQHandler 233 | .thumb_set WWDG_IRQHandler,Default_Handler 234 | 235 | .weak PVD_IRQHandler 236 | .thumb_set PVD_IRQHandler,Default_Handler 237 | 238 | .weak TAMPER_IRQHandler 239 | .thumb_set TAMPER_IRQHandler,Default_Handler 240 | 241 | .weak RTC_IRQHandler 242 | .thumb_set RTC_IRQHandler,Default_Handler 243 | 244 | .weak FLASH_IRQHandler 245 | .thumb_set FLASH_IRQHandler,Default_Handler 246 | 247 | .weak RCC_IRQHandler 248 | .thumb_set RCC_IRQHandler,Default_Handler 249 | 250 | .weak EXTI0_IRQHandler 251 | .thumb_set EXTI0_IRQHandler,Default_Handler 252 | 253 | .weak EXTI1_IRQHandler 254 | .thumb_set EXTI1_IRQHandler,Default_Handler 255 | 256 | .weak EXTI2_IRQHandler 257 | .thumb_set EXTI2_IRQHandler,Default_Handler 258 | 259 | .weak EXTI3_IRQHandler 260 | .thumb_set EXTI3_IRQHandler,Default_Handler 261 | 262 | .weak EXTI4_IRQHandler 263 | .thumb_set EXTI4_IRQHandler,Default_Handler 264 | 265 | .weak DMA1_Channel1_IRQHandler 266 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler 267 | 268 | .weak DMA1_Channel2_IRQHandler 269 | .thumb_set DMA1_Channel2_IRQHandler,Default_Handler 270 | 271 | .weak DMA1_Channel3_IRQHandler 272 | .thumb_set DMA1_Channel3_IRQHandler,Default_Handler 273 | 274 | .weak DMA1_Channel4_IRQHandler 275 | .thumb_set DMA1_Channel4_IRQHandler,Default_Handler 276 | 277 | .weak DMA1_Channel5_IRQHandler 278 | .thumb_set DMA1_Channel5_IRQHandler,Default_Handler 279 | 280 | .weak DMA1_Channel6_IRQHandler 281 | .thumb_set DMA1_Channel6_IRQHandler,Default_Handler 282 | 283 | .weak DMA1_Channel7_IRQHandler 284 | .thumb_set DMA1_Channel7_IRQHandler,Default_Handler 285 | 286 | .weak ADC1_2_IRQHandler 287 | .thumb_set ADC1_2_IRQHandler,Default_Handler 288 | 289 | .weak USB_HP_CAN1_TX_IRQHandler 290 | .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler 291 | 292 | .weak USB_LP_CAN1_RX0_IRQHandler 293 | .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler 294 | 295 | .weak CAN1_RX1_IRQHandler 296 | .thumb_set CAN1_RX1_IRQHandler,Default_Handler 297 | 298 | .weak CAN1_SCE_IRQHandler 299 | .thumb_set CAN1_SCE_IRQHandler,Default_Handler 300 | 301 | .weak EXTI9_5_IRQHandler 302 | .thumb_set EXTI9_5_IRQHandler,Default_Handler 303 | 304 | .weak TIM1_BRK_IRQHandler 305 | .thumb_set TIM1_BRK_IRQHandler,Default_Handler 306 | 307 | .weak TIM1_UP_IRQHandler 308 | .thumb_set TIM1_UP_IRQHandler,Default_Handler 309 | 310 | .weak TIM1_TRG_COM_IRQHandler 311 | .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler 312 | 313 | .weak TIM1_CC_IRQHandler 314 | .thumb_set TIM1_CC_IRQHandler,Default_Handler 315 | 316 | .weak TIM2_IRQHandler 317 | .thumb_set TIM2_IRQHandler,Default_Handler 318 | 319 | .weak TIM3_IRQHandler 320 | .thumb_set TIM3_IRQHandler,Default_Handler 321 | 322 | .weak TIM4_IRQHandler 323 | .thumb_set TIM4_IRQHandler,Default_Handler 324 | 325 | .weak I2C1_EV_IRQHandler 326 | .thumb_set I2C1_EV_IRQHandler,Default_Handler 327 | 328 | .weak I2C1_ER_IRQHandler 329 | .thumb_set I2C1_ER_IRQHandler,Default_Handler 330 | 331 | .weak I2C2_EV_IRQHandler 332 | .thumb_set I2C2_EV_IRQHandler,Default_Handler 333 | 334 | .weak I2C2_ER_IRQHandler 335 | .thumb_set I2C2_ER_IRQHandler,Default_Handler 336 | 337 | .weak SPI1_IRQHandler 338 | .thumb_set SPI1_IRQHandler,Default_Handler 339 | 340 | .weak SPI2_IRQHandler 341 | .thumb_set SPI2_IRQHandler,Default_Handler 342 | 343 | .weak USART1_IRQHandler 344 | .thumb_set USART1_IRQHandler,Default_Handler 345 | 346 | .weak USART2_IRQHandler 347 | .thumb_set USART2_IRQHandler,Default_Handler 348 | 349 | .weak USART3_IRQHandler 350 | .thumb_set USART3_IRQHandler,Default_Handler 351 | 352 | .weak EXTI15_10_IRQHandler 353 | .thumb_set EXTI15_10_IRQHandler,Default_Handler 354 | 355 | .weak RTC_Alarm_IRQHandler 356 | .thumb_set RTC_Alarm_IRQHandler,Default_Handler 357 | 358 | .weak USBWakeUp_IRQHandler 359 | .thumb_set USBWakeUp_IRQHandler,Default_Handler 360 | 361 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 362 | 363 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/keil/project.uvopt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0 5 | 6 |
### uVision Project, (C) Keil Software
7 | 8 | 9 | *.c 10 | *.s*; *.src; *.a* 11 | *.obj 12 | *.lib 13 | *.txt; *.h; *.inc 14 | *.plm 15 | *.cpp 16 | 17 | 18 | 19 | 0 20 | 0 21 | 22 | 23 | 24 | microLite_timer_prj 25 | 0x4 26 | ARM-ADS 27 | 28 | 12000000 29 | 30 | 1 31 | 1 32 | 1 33 | 0 34 | 35 | 36 | 1 37 | 65535 38 | 0 39 | 0 40 | 0 41 | 42 | 43 | 79 44 | 66 45 | 8 46 | .\build\ 47 | 48 | 49 | 1 50 | 1 51 | 1 52 | 0 53 | 1 54 | 1 55 | 0 56 | 1 57 | 0 58 | 0 59 | 0 60 | 0 61 | 62 | 63 | 1 64 | 1 65 | 1 66 | 1 67 | 1 68 | 1 69 | 1 70 | 0 71 | 0 72 | 73 | 74 | 1 75 | 0 76 | 1 77 | 78 | 0 79 | 80 | 1 81 | 0 82 | 1 83 | 1 84 | 1 85 | 1 86 | 1 87 | 1 88 | 1 89 | 1 90 | 1 91 | 1 92 | 1 93 | 1 94 | 0 95 | 1 96 | 1 97 | 1 98 | 1 99 | 0 100 | 0 101 | 0 102 | 0 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | BIN\UL2CM3.DLL 114 | 115 | 116 | 117 | 0 118 | DLGDARM 119 | (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(124=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) 120 | 121 | 122 | 0 123 | ARMDBGFLAGS 124 | -T0 125 | 126 | 127 | 0 128 | UL2CM3 129 | UL2CM3(-O14 -S0 -C0 -N00("ARM Cortex-M3") -D00(1BA00477) -L00(4) -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000) 130 | 131 | 132 | 133 | 134 | 0 135 | 136 | 137 | 0 138 | 0 139 | 1 140 | 0 141 | 1 142 | 0 143 | 0 144 | 1 145 | 0 146 | 0 147 | 0 148 | 0 149 | 0 150 | 0 151 | 0 152 | 0 153 | 0 154 | 0 155 | 0 156 | 0 157 | 0 158 | 0 159 | 0 160 | 0 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | microLite_timer/src 169 | 1 170 | 0 171 | 0 172 | 0 173 | 174 | 1 175 | 1 176 | 1 177 | 0 178 | 0 179 | 0 180 | 0 181 | 180 182 | 186 183 | 0 184 | ..\..\..\src\microLite_timer.c 185 | microLite_timer.c 186 | 0 187 | 0 188 | 189 | 190 | 1 191 | 2 192 | 5 193 | 0 194 | 0 195 | 0 196 | 0 197 | 0 198 | 0 199 | 0 200 | ..\..\..\src\microLite_timer.h 201 | microLite_timer.h 202 | 0 203 | 0 204 | 205 | 206 | 207 | 208 | microLite_timer/test 209 | 1 210 | 0 211 | 0 212 | 0 213 | 214 | 2 215 | 3 216 | 1 217 | 0 218 | 0 219 | 0 220 | 0 221 | 0 222 | 0 223 | 0 224 | ..\..\..\test\test1_period.c 225 | test1_period.c 226 | 0 227 | 0 228 | 229 | 230 | 2 231 | 4 232 | 1 233 | 0 234 | 0 235 | 0 236 | 0 237 | 0 238 | 0 239 | 0 240 | ..\..\..\test\test2_shot.c 241 | test2_shot.c 242 | 0 243 | 0 244 | 245 | 246 | 2 247 | 5 248 | 1 249 | 0 250 | 0 251 | 0 252 | 0 253 | 0 254 | 0 255 | 0 256 | ..\..\..\test\test3_misc.c 257 | test3_misc.c 258 | 0 259 | 0 260 | 261 | 262 | 2 263 | 6 264 | 1 265 | 0 266 | 0 267 | 0 268 | 0 269 | 0 270 | 0 271 | 0 272 | ..\..\..\test\test4_error.c 273 | test4_error.c 274 | 0 275 | 0 276 | 277 | 278 | 2 279 | 7 280 | 1 281 | 0 282 | 0 283 | 0 284 | 0 285 | 0 286 | 0 287 | 0 288 | ..\..\..\test\test_5.c 289 | test_5.c 290 | 0 291 | 0 292 | 293 | 294 | 295 | 296 | main 297 | 1 298 | 0 299 | 0 300 | 0 301 | 302 | 3 303 | 8 304 | 1 305 | 0 306 | 0 307 | 0 308 | 0 309 | 44 310 | 50 311 | 0 312 | ..\main.c 313 | main.c 314 | 0 315 | 0 316 | 317 | 318 | 3 319 | 9 320 | 2 321 | 0 322 | 0 323 | 0 324 | 0 325 | 123 326 | 131 327 | 0 328 | .\startup_stm32f10x_md.s 329 | startup_stm32f10x_md.s 330 | 0 331 | 0 332 | 333 | 334 | 335 | 336 | ::CMSIS 337 | 0 338 | 0 339 | 0 340 | 0 341 | 342 | 343 |
344 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/keil/project.uvoptx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0 5 | 6 |
### uVision Project, (C) Keil Software
7 | 8 | 9 | *.c 10 | *.s*; *.src; *.a* 11 | *.obj; *.o 12 | *.lib 13 | *.txt; *.h; *.inc; *.md 14 | *.plm 15 | *.cpp 16 | 0 17 | 18 | 19 | 20 | 0 21 | 0 22 | 23 | 24 | 25 | microLite_timer_prj 26 | 0x4 27 | ARM-ADS 28 | 29 | 12000000 30 | 31 | 1 32 | 1 33 | 0 34 | 1 35 | 0 36 | 37 | 38 | 1 39 | 65535 40 | 0 41 | 0 42 | 0 43 | 44 | 45 | 79 46 | 66 47 | 8 48 | .\build\ 49 | 50 | 51 | 1 52 | 1 53 | 1 54 | 0 55 | 1 56 | 1 57 | 0 58 | 1 59 | 0 60 | 0 61 | 0 62 | 0 63 | 64 | 65 | 1 66 | 1 67 | 1 68 | 1 69 | 1 70 | 1 71 | 1 72 | 0 73 | 0 74 | 75 | 76 | 1 77 | 0 78 | 1 79 | 80 | 0 81 | 82 | 1 83 | 0 84 | 1 85 | 1 86 | 1 87 | 1 88 | 1 89 | 1 90 | 1 91 | 1 92 | 1 93 | 1 94 | 1 95 | 1 96 | 0 97 | 1 98 | 1 99 | 1 100 | 1 101 | 0 102 | 1 103 | 1 104 | 0 105 | 0 106 | 0 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | BIN\UL2CM3.DLL 118 | 119 | 120 | 121 | 0 122 | ARMRTXEVENTFLAGS 123 | -L70 -Z18 -C0 -M0 -T1 124 | 125 | 126 | 0 127 | DLGDARM 128 | (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(124=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) 129 | 130 | 131 | 0 132 | ARMDBGFLAGS 133 | -T0 134 | 135 | 136 | 0 137 | UL2CM3 138 | UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103VB$Flash\STM32F10x_128.FLM)) 139 | 140 | 141 | 142 | 143 | 0 144 | 145 | 146 | 0 147 | 0 148 | 1 149 | 0 150 | 1 151 | 0 152 | 0 153 | 1 154 | 0 155 | 0 156 | 0 157 | 0 158 | 0 159 | 0 160 | 0 161 | 0 162 | 0 163 | 0 164 | 0 165 | 0 166 | 0 167 | 0 168 | 0 169 | 0 170 | 171 | 172 | 173 | 0 174 | 0 175 | 0 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 1 186 | 1 187 | 0 188 | 2 189 | 10000000 190 | 191 | 192 | 193 | 194 | 195 | microLite_timer/src 196 | 1 197 | 0 198 | 0 199 | 0 200 | 201 | 1 202 | 1 203 | 1 204 | 0 205 | 0 206 | 0 207 | ..\..\..\src\microLite_timer.c 208 | microLite_timer.c 209 | 0 210 | 0 211 | 212 | 213 | 1 214 | 2 215 | 5 216 | 0 217 | 0 218 | 0 219 | ..\..\..\src\microLite_timer.h 220 | microLite_timer.h 221 | 0 222 | 0 223 | 224 | 225 | 226 | 227 | microLite_timer/test 228 | 1 229 | 0 230 | 0 231 | 0 232 | 233 | 2 234 | 3 235 | 1 236 | 0 237 | 0 238 | 0 239 | ..\..\..\test\test1_period.c 240 | test1_period.c 241 | 0 242 | 0 243 | 244 | 245 | 2 246 | 4 247 | 1 248 | 0 249 | 0 250 | 0 251 | ..\..\..\test\test2_shot.c 252 | test2_shot.c 253 | 0 254 | 0 255 | 256 | 257 | 2 258 | 5 259 | 1 260 | 0 261 | 0 262 | 0 263 | ..\..\..\test\test3_misc.c 264 | test3_misc.c 265 | 0 266 | 0 267 | 268 | 269 | 2 270 | 6 271 | 1 272 | 0 273 | 0 274 | 0 275 | ..\..\..\test\test4_error.c 276 | test4_error.c 277 | 0 278 | 0 279 | 280 | 281 | 2 282 | 7 283 | 1 284 | 0 285 | 0 286 | 0 287 | ..\..\..\test\test_5.c 288 | test_5.c 289 | 0 290 | 0 291 | 292 | 293 | 294 | 295 | main 296 | 1 297 | 0 298 | 0 299 | 0 300 | 301 | 3 302 | 8 303 | 1 304 | 0 305 | 0 306 | 0 307 | ..\main.c 308 | main.c 309 | 0 310 | 0 311 | 312 | 313 | 3 314 | 9 315 | 2 316 | 0 317 | 0 318 | 0 319 | .\startup_stm32f10x_md.s 320 | startup_stm32f10x_md.s 321 | 0 322 | 0 323 | 324 | 325 | 326 | 327 | ::CMSIS 328 | 0 329 | 0 330 | 0 331 | 1 332 | 333 | 334 |
335 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/keil/project.uvprojx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2.1 5 | 6 |
### uVision Project, (C) Keil Software
7 | 8 | 9 | 10 | microLite_timer_prj 11 | 0x4 12 | ARM-ADS 13 | 5060960::V5.06 update 7 (build 960)::ARMCC 14 | 5060960::V5.06 update 7 (build 960)::ARMCC 15 | 0 16 | 17 | 18 | STM32F103VB 19 | STMicroelectronics 20 | Keil.STM32F1xx_DFP.2.3.0 21 | http://www.keil.com/pack/ 22 | IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE 23 | 24 | 25 | UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103VB$Flash\STM32F10x_128.FLM)) 26 | 4223 27 | $$Device:STM32F103VB$Device\Include\stm32f10x.h 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | $$Device:STM32F103VB$SVD\STM32F103xx.svd 38 | 0 39 | 0 40 | 41 | 42 | 43 | 44 | 45 | 46 | 0 47 | 0 48 | 0 49 | 0 50 | 1 51 | 52 | .\build\ 53 | microLite_timer 54 | 1 55 | 0 56 | 1 57 | 1 58 | 1 59 | .\build\ 60 | 1 61 | 0 62 | 0 63 | 64 | 0 65 | 0 66 | 67 | 68 | 0 69 | 0 70 | 0 71 | 0 72 | 73 | 74 | 0 75 | 0 76 | 77 | 78 | 0 79 | 0 80 | 0 81 | 0 82 | 83 | 84 | 0 85 | 0 86 | 87 | 88 | 0 89 | 0 90 | 0 91 | 0 92 | 93 | 0 94 | 95 | 96 | 97 | 0 98 | 0 99 | 0 100 | 0 101 | 0 102 | 1 103 | 0 104 | 0 105 | 0 106 | 0 107 | 3 108 | 109 | 110 | 0 111 | 112 | 113 | SARMCM3.DLL 114 | 115 | DARMSTM.DLL 116 | -pSTM32F103VB 117 | SARMCM3.DLL 118 | 119 | TARMSTM.DLL 120 | -pSTM32F103VB 121 | 122 | 123 | 124 | 1 125 | 0 126 | 0 127 | 0 128 | 16 129 | 130 | 131 | 132 | 133 | 1 134 | 0 135 | 0 136 | 1 137 | 1 138 | 4096 139 | 140 | 1 141 | BIN\UL2CM3.DLL 142 | "" () 143 | 144 | 145 | 146 | 147 | 0 148 | 149 | 150 | 151 | 0 152 | 1 153 | 1 154 | 1 155 | 1 156 | 1 157 | 1 158 | 1 159 | 0 160 | 1 161 | 1 162 | 0 163 | 0 164 | 0 165 | 0 166 | 0 167 | 1 168 | 1 169 | 0 170 | 1 171 | 1 172 | 0 173 | 0 174 | 0 175 | 0 176 | 0 177 | 0 178 | "Cortex-M3" 179 | 180 | 0 181 | 0 182 | 0 183 | 1 184 | 1 185 | 0 186 | 0 187 | 0 188 | 0 189 | 0 190 | 0 191 | 0 192 | 8 193 | 1 194 | 0 195 | 0 196 | 0 197 | 3 198 | 3 199 | 0 200 | 0 201 | 0 202 | 0 203 | 0 204 | 0 205 | 0 206 | 0 207 | 0 208 | 0 209 | 1 210 | 0 211 | 0 212 | 0 213 | 0 214 | 1 215 | 0 216 | 217 | 218 | 0 219 | 0x0 220 | 0x0 221 | 222 | 223 | 0 224 | 0x0 225 | 0x0 226 | 227 | 228 | 0 229 | 0x0 230 | 0x0 231 | 232 | 233 | 0 234 | 0x0 235 | 0x0 236 | 237 | 238 | 0 239 | 0x0 240 | 0x0 241 | 242 | 243 | 0 244 | 0x0 245 | 0x0 246 | 247 | 248 | 0 249 | 0x20000000 250 | 0x5000 251 | 252 | 253 | 1 254 | 0x8000000 255 | 0x20000 256 | 257 | 258 | 0 259 | 0x0 260 | 0x0 261 | 262 | 263 | 1 264 | 0x0 265 | 0x0 266 | 267 | 268 | 1 269 | 0x0 270 | 0x0 271 | 272 | 273 | 1 274 | 0x0 275 | 0x0 276 | 277 | 278 | 1 279 | 0x8000000 280 | 0x20000 281 | 282 | 283 | 1 284 | 0x0 285 | 0x0 286 | 287 | 288 | 0 289 | 0x0 290 | 0x0 291 | 292 | 293 | 0 294 | 0x0 295 | 0x0 296 | 297 | 298 | 0 299 | 0x0 300 | 0x0 301 | 302 | 303 | 0 304 | 0x20000000 305 | 0x5000 306 | 307 | 308 | 0 309 | 0x0 310 | 0x0 311 | 312 | 313 | 314 | 315 | 316 | 1 317 | 0 318 | 0 319 | 0 320 | 0 321 | 0 322 | 0 323 | 0 324 | 0 325 | 0 326 | 0 327 | 0 328 | 0 329 | 0 330 | 0 331 | 0 332 | 3 333 | 3 334 | 1 335 | 1 336 | 0 337 | 0 338 | 0 339 | 340 | 341 | USE_STDPERIPH_DRIVER, STM32F10X_MD 342 | 343 | ..\..\..\src;..\..\..\test;..\Libraries 344 | 345 | 346 | 347 | 1 348 | 0 349 | 0 350 | 0 351 | 0 352 | 0 353 | 0 354 | 0 355 | 0 356 | 1 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 1 366 | 0 367 | 0 368 | 0 369 | 1 370 | 0 371 | 0x08000000 372 | 0x20000000 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | microLite_timer/src 386 | 387 | 388 | microLite_timer.c 389 | 1 390 | ..\..\..\src\microLite_timer.c 391 | 392 | 393 | microLite_timer.h 394 | 5 395 | ..\..\..\src\microLite_timer.h 396 | 397 | 398 | 399 | 400 | microLite_timer/test 401 | 402 | 403 | test1_period.c 404 | 1 405 | ..\..\..\test\test1_period.c 406 | 407 | 408 | test2_shot.c 409 | 1 410 | ..\..\..\test\test2_shot.c 411 | 412 | 413 | test3_misc.c 414 | 1 415 | ..\..\..\test\test3_misc.c 416 | 417 | 418 | test4_error.c 419 | 1 420 | ..\..\..\test\test4_error.c 421 | 422 | 423 | test_5.c 424 | 1 425 | ..\..\..\test\test_5.c 426 | 427 | 428 | 429 | 430 | main 431 | 432 | 433 | main.c 434 | 1 435 | ..\main.c 436 | 437 | 438 | startup_stm32f10x_md.s 439 | 2 440 | .\startup_stm32f10x_md.s 441 | 442 | 443 | 444 | 445 | ::CMSIS 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | project 468 | 1 469 | 470 | 471 | 472 | 473 |
474 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/keil/startup_stm32f10x_md.s: -------------------------------------------------------------------------------- 1 | ;******************** (C) COPYRIGHT 2009 STMicroelectronics ******************** 2 | ;* File Name : startup_stm32f10x_md.s 3 | ;* Author : MCD Application Team 4 | ;* Version : V3.0.0 5 | ;* Date : 04/06/2009 6 | ;* Description : STM32F10x Medium Density Devices vector table for RVMDK 7 | ;* toolchain. 8 | ;* This module performs: 9 | ;* - Set the initial SP 10 | ;* - Set the initial PC == Reset_Handler 11 | ;* - Set the vector table entries with the exceptions ISR address 12 | ;* - Branches to __main in the C library (which eventually 13 | ;* calls main()). 14 | ;* After Reset the CortexM3 processor is in Thread mode, 15 | ;* priority is Privileged, and the Stack is set to Main. 16 | ;* <<< Use Configuration Wizard in Context Menu >>> 17 | ;******************************************************************************* 18 | ; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 19 | ; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 20 | ; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 21 | ; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 22 | ; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 23 | ; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 24 | ;******************************************************************************* 25 | 26 | ; Amount of memory (in bytes) allocated for Stack 27 | ; Tailor this value to your application needs 28 | ; Stack Configuration 29 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> 30 | ; 31 | 32 | Stack_Size EQU 0x00000200 33 | 34 | AREA STACK, NOINIT, READWRITE, ALIGN=3 35 | Stack_Mem SPACE Stack_Size 36 | __initial_sp 37 | 38 | 39 | ; Heap Configuration 40 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> 41 | ; 42 | 43 | Heap_Size EQU 0x00000000 44 | 45 | AREA HEAP, NOINIT, READWRITE, ALIGN=3 46 | __heap_base 47 | Heap_Mem SPACE Heap_Size 48 | __heap_limit 49 | 50 | PRESERVE8 51 | THUMB 52 | 53 | 54 | ; Vector Table Mapped to Address 0 at Reset 55 | AREA RESET, DATA, READONLY 56 | EXPORT __Vectors 57 | EXPORT __Vectors_End 58 | EXPORT __Vectors_Size 59 | 60 | __Vectors DCD __initial_sp ; Top of Stack 61 | DCD Reset_Handler ; Reset Handler 62 | DCD NMI_Handler ; NMI Handler 63 | DCD HardFault_Handler ; Hard Fault Handler 64 | DCD MemManage_Handler ; MPU Fault Handler 65 | DCD BusFault_Handler ; Bus Fault Handler 66 | DCD UsageFault_Handler ; Usage Fault Handler 67 | DCD 0 ; Reserved 68 | DCD 0 ; Reserved 69 | DCD 0 ; Reserved 70 | DCD 0 ; Reserved 71 | DCD SVC_Handler ; SVCall Handler 72 | DCD DebugMon_Handler ; Debug Monitor Handler 73 | DCD 0 ; Reserved 74 | DCD PendSV_Handler ; PendSV Handler 75 | DCD SysTick_Handler ; SysTick Handler 76 | 77 | ; External Interrupts 78 | DCD WWDG_IRQHandler ; Window Watchdog 79 | DCD PVD_IRQHandler ; PVD through EXTI Line detect 80 | DCD TAMPER_IRQHandler ; Tamper 81 | DCD RTC_IRQHandler ; RTC 82 | DCD FLASH_IRQHandler ; Flash 83 | DCD RCC_IRQHandler ; RCC 84 | DCD EXTI0_IRQHandler ; EXTI Line 0 85 | DCD EXTI1_IRQHandler ; EXTI Line 1 86 | DCD EXTI2_IRQHandler ; EXTI Line 2 87 | DCD EXTI3_IRQHandler ; EXTI Line 3 88 | DCD EXTI4_IRQHandler ; EXTI Line 4 89 | DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 90 | DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 91 | DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 92 | DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 93 | DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 94 | DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 95 | DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 96 | DCD ADC1_2_IRQHandler ; ADC1_2 97 | DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX 98 | DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0 99 | DCD CAN1_RX1_IRQHandler ; CAN1 RX1 100 | DCD CAN1_SCE_IRQHandler ; CAN1 SCE 101 | DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 102 | DCD TIM1_BRK_IRQHandler ; TIM1 Break 103 | DCD TIM1_UP_IRQHandler ; TIM1 Update 104 | DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation 105 | DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare 106 | DCD TIM2_IRQHandler ; TIM2 107 | DCD TIM3_IRQHandler ; TIM3 108 | DCD TIM4_IRQHandler ; TIM4 109 | DCD I2C1_EV_IRQHandler ; I2C1 Event 110 | DCD I2C1_ER_IRQHandler ; I2C1 Error 111 | DCD I2C2_EV_IRQHandler ; I2C2 Event 112 | DCD I2C2_ER_IRQHandler ; I2C2 Error 113 | DCD SPI1_IRQHandler ; SPI1 114 | DCD SPI2_IRQHandler ; SPI2 115 | DCD USART1_IRQHandler ; USART1 116 | DCD USART2_IRQHandler ; USART2 117 | DCD USART3_IRQHandler ; USART3 118 | DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 119 | DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line 120 | DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend 121 | __Vectors_End 122 | 123 | __Vectors_Size EQU __Vectors_End - __Vectors 124 | 125 | AREA |.text|, CODE, READONLY 126 | 127 | ; Reset handler routine 128 | Reset_Handler PROC 129 | EXPORT Reset_Handler [WEAK] 130 | IMPORT __main 131 | LDR R0, =__main 132 | BX R0 133 | ENDP 134 | 135 | ; Dummy Exception Handlers (infinite loops which can be modified) 136 | 137 | NMI_Handler PROC 138 | EXPORT NMI_Handler [WEAK] 139 | B . 140 | ENDP 141 | HardFault_Handler\ 142 | PROC 143 | EXPORT HardFault_Handler [WEAK] 144 | B . 145 | ENDP 146 | MemManage_Handler\ 147 | PROC 148 | EXPORT MemManage_Handler [WEAK] 149 | B . 150 | ENDP 151 | BusFault_Handler\ 152 | PROC 153 | EXPORT BusFault_Handler [WEAK] 154 | B . 155 | ENDP 156 | UsageFault_Handler\ 157 | PROC 158 | EXPORT UsageFault_Handler [WEAK] 159 | B . 160 | ENDP 161 | SVC_Handler PROC 162 | EXPORT SVC_Handler [WEAK] 163 | B . 164 | ENDP 165 | DebugMon_Handler\ 166 | PROC 167 | EXPORT DebugMon_Handler [WEAK] 168 | B . 169 | ENDP 170 | PendSV_Handler PROC 171 | EXPORT PendSV_Handler [WEAK] 172 | B . 173 | ENDP 174 | SysTick_Handler PROC 175 | EXPORT SysTick_Handler [WEAK] 176 | B . 177 | ENDP 178 | 179 | Default_Handler PROC 180 | 181 | EXPORT WWDG_IRQHandler [WEAK] 182 | EXPORT PVD_IRQHandler [WEAK] 183 | EXPORT TAMPER_IRQHandler [WEAK] 184 | EXPORT RTC_IRQHandler [WEAK] 185 | EXPORT FLASH_IRQHandler [WEAK] 186 | EXPORT RCC_IRQHandler [WEAK] 187 | EXPORT EXTI0_IRQHandler [WEAK] 188 | EXPORT EXTI1_IRQHandler [WEAK] 189 | EXPORT EXTI2_IRQHandler [WEAK] 190 | EXPORT EXTI3_IRQHandler [WEAK] 191 | EXPORT EXTI4_IRQHandler [WEAK] 192 | EXPORT DMA1_Channel1_IRQHandler [WEAK] 193 | EXPORT DMA1_Channel2_IRQHandler [WEAK] 194 | EXPORT DMA1_Channel3_IRQHandler [WEAK] 195 | EXPORT DMA1_Channel4_IRQHandler [WEAK] 196 | EXPORT DMA1_Channel5_IRQHandler [WEAK] 197 | EXPORT DMA1_Channel6_IRQHandler [WEAK] 198 | EXPORT DMA1_Channel7_IRQHandler [WEAK] 199 | EXPORT ADC1_2_IRQHandler [WEAK] 200 | EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] 201 | EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] 202 | EXPORT CAN1_RX1_IRQHandler [WEAK] 203 | EXPORT CAN1_SCE_IRQHandler [WEAK] 204 | EXPORT EXTI9_5_IRQHandler [WEAK] 205 | EXPORT TIM1_BRK_IRQHandler [WEAK] 206 | EXPORT TIM1_UP_IRQHandler [WEAK] 207 | EXPORT TIM1_TRG_COM_IRQHandler [WEAK] 208 | EXPORT TIM1_CC_IRQHandler [WEAK] 209 | EXPORT TIM2_IRQHandler [WEAK] 210 | EXPORT TIM3_IRQHandler [WEAK] 211 | EXPORT TIM4_IRQHandler [WEAK] 212 | EXPORT I2C1_EV_IRQHandler [WEAK] 213 | EXPORT I2C1_ER_IRQHandler [WEAK] 214 | EXPORT I2C2_EV_IRQHandler [WEAK] 215 | EXPORT I2C2_ER_IRQHandler [WEAK] 216 | EXPORT SPI1_IRQHandler [WEAK] 217 | EXPORT SPI2_IRQHandler [WEAK] 218 | EXPORT USART1_IRQHandler [WEAK] 219 | EXPORT USART2_IRQHandler [WEAK] 220 | EXPORT USART3_IRQHandler [WEAK] 221 | EXPORT EXTI15_10_IRQHandler [WEAK] 222 | EXPORT RTCAlarm_IRQHandler [WEAK] 223 | EXPORT USBWakeUp_IRQHandler [WEAK] 224 | 225 | WWDG_IRQHandler 226 | PVD_IRQHandler 227 | TAMPER_IRQHandler 228 | RTC_IRQHandler 229 | FLASH_IRQHandler 230 | RCC_IRQHandler 231 | EXTI0_IRQHandler 232 | EXTI1_IRQHandler 233 | EXTI2_IRQHandler 234 | EXTI3_IRQHandler 235 | EXTI4_IRQHandler 236 | DMA1_Channel1_IRQHandler 237 | DMA1_Channel2_IRQHandler 238 | DMA1_Channel3_IRQHandler 239 | DMA1_Channel4_IRQHandler 240 | DMA1_Channel5_IRQHandler 241 | DMA1_Channel6_IRQHandler 242 | DMA1_Channel7_IRQHandler 243 | ADC1_2_IRQHandler 244 | USB_HP_CAN1_TX_IRQHandler 245 | USB_LP_CAN1_RX0_IRQHandler 246 | CAN1_RX1_IRQHandler 247 | CAN1_SCE_IRQHandler 248 | EXTI9_5_IRQHandler 249 | TIM1_BRK_IRQHandler 250 | TIM1_UP_IRQHandler 251 | TIM1_TRG_COM_IRQHandler 252 | TIM1_CC_IRQHandler 253 | TIM2_IRQHandler 254 | TIM3_IRQHandler 255 | TIM4_IRQHandler 256 | I2C1_EV_IRQHandler 257 | I2C1_ER_IRQHandler 258 | I2C2_EV_IRQHandler 259 | I2C2_ER_IRQHandler 260 | SPI1_IRQHandler 261 | SPI2_IRQHandler 262 | USART1_IRQHandler 263 | USART2_IRQHandler 264 | USART3_IRQHandler 265 | EXTI15_10_IRQHandler 266 | RTCAlarm_IRQHandler 267 | USBWakeUp_IRQHandler 268 | 269 | B . 270 | 271 | ENDP 272 | 273 | ALIGN 274 | 275 | ;******************************************************************************* 276 | ; User Stack and Heap initialization 277 | ;******************************************************************************* 278 | IF :DEF:__MICROLIB 279 | 280 | EXPORT __initial_sp 281 | EXPORT __heap_base 282 | EXPORT __heap_limit 283 | 284 | ELSE 285 | 286 | IMPORT __use_two_region_memory 287 | EXPORT __user_initial_stackheap 288 | 289 | __user_initial_stackheap 290 | 291 | LDR R0, = Heap_Mem 292 | LDR R1, =(Stack_Mem + Stack_Size) 293 | LDR R2, = (Heap_Mem + Heap_Size) 294 | LDR R3, = Stack_Mem 295 | BX LR 296 | 297 | ALIGN 298 | 299 | ENDIF 300 | 301 | END 302 | 303 | ;******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE***** 304 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * stevenLyan is pleased to support the open source community. 3 | * 4 | * Copyright 2021 stevenLyan (Email:stevenlyan@qq.com) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * 19 | * Change Logs: 20 | * Date Author Notes 21 | * 2021-02-18 stevenLyan first version 22 | * 23 | */ 24 | #include "misc.c" 25 | #include "stm32f10x_gpio.c" 26 | #include "stm32f10x_it.c" 27 | #include "stm32f10x_rcc.c" 28 | #include "stm32f10x_tim.c" 29 | #include "stm32f10x_usart.c" 30 | #include "system_stm32f10x.c" 31 | #include "periph_init.c" 32 | 33 | static uint32_t hal_systick_config(uint32_t tick_rate) 34 | { 35 | if ((tick_rate == 1000) || (tick_rate == 100)) { 36 | if (SysTick_Config(72000000 / (tick_rate))) { 37 | /* assert: Failed!!! Initialize systime failure!!! */ 38 | return 1; 39 | } 40 | } else { 41 | /* assert: Failed!!! only 1000 or 100 is supported!!! */ 42 | return 1; 43 | } 44 | return 0; 45 | } 46 | 47 | 48 | extern void test1(void); 49 | int main(void) 50 | { 51 | int xxx = 0xffff; 52 | periph_init(); 53 | hal_systick_config(1000); 54 | while (xxx--) { 55 | ; 56 | } 57 | test1(); 58 | } 59 | 60 | /* irq */ 61 | #include "microLite_timer.h" 62 | void SysTick_Handler(void) 63 | { 64 | ml_tick_increase(); 65 | } 66 | 67 | 68 | #include "stdio.h" 69 | /* printf, use MicroLib */ 70 | int fputc(int ch, FILE *f) 71 | { 72 | USART_SendData(USART1, (unsigned char) ch); 73 | while (!(USART1->SR & USART_FLAG_TXE)); 74 | return (ch); 75 | } 76 | 77 | /* keep an empty line */ 78 | 79 | 80 | -------------------------------------------------------------------------------- /bsp/stm32f103vb/periph_init.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | ****************************************************************************** 4 | * @file 5 | * @author MCD Application Team 6 | * @version V3.0.0 7 | * @date 04/06/2009 8 | * @brief Main program body 9 | ****************************************************************************** 10 | * @copy 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2009 STMicroelectronics

20 | */ 21 | 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include "stm32f10x.h" 25 | #include "misc.h" 26 | 27 | /* Private function prototypes -----------------------------------------------*/ 28 | static void RCC_Configuration(void); 29 | static void NVIC_Configuration(void); 30 | static void USART_Configuration(void); 31 | static void GPIO_Configuration(void); 32 | 33 | void periph_init(void) 34 | { 35 | RCC_Configuration(); 36 | NVIC_Configuration(); 37 | GPIO_Configuration(); 38 | USART_Configuration(); 39 | } 40 | 41 | /** 42 | * @brief Configures the different system clocks. 43 | * @param None 44 | * @retval : None 45 | */ 46 | void RCC_Configuration(void) 47 | { 48 | /* Setup the microcontroller system. Initialize the Embedded Flash Interface, 49 | initialize the PLL and update the SystemFrequency variable. */ 50 | SystemInit(); 51 | 52 | /* Enable GPIOA clock */ 53 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 54 | 55 | /* Enable USART1 clocks */ 56 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); 57 | } 58 | 59 | /** 60 | * @brief Configures the different GPIO ports. 61 | * @param None 62 | * @retval : None 63 | */ 64 | void GPIO_Configuration(void) 65 | { 66 | GPIO_InitTypeDef GPIO_InitStructure; 67 | 68 | /* Configure USART1_Tx as alternate function push-pull */ 69 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;//GPIO_TxPin; 70 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 71 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 72 | GPIO_Init(GPIOA, &GPIO_InitStructure); 73 | 74 | /* Configure USART1_Rx as input floating */ 75 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;//GPIO_RxPin; 76 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 77 | GPIO_Init(GPIOA, &GPIO_InitStructure); 78 | 79 | } 80 | void USART_Configuration(void) 81 | { 82 | USART_InitTypeDef USART_InitStructure; 83 | 84 | USART_InitStructure.USART_BaudRate = 115200; 85 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 86 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 87 | USART_InitStructure.USART_Parity = USART_Parity_No ; 88 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 89 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; // 90 | /* Configure the USART1 */ 91 | USART_Init(USART1, &USART_InitStructure); 92 | 93 | USART_ITConfig(USART1, USART_IT_RXNE, DISABLE); 94 | /* Enable the USART1 */ 95 | USART_Cmd(USART1, ENABLE); 96 | } 97 | 98 | 99 | /** 100 | * @brief Configures the nested vectored interrupt controller. 101 | * @param None 102 | * @retval : None 103 | */ 104 | void NVIC_Configuration(void) 105 | { 106 | NVIC_InitTypeDef NVIC_InitStructure; 107 | 108 | /* Configure the NVIC Preemption Priority Bits */ 109 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); 110 | 111 | /* Enable the USART1 Interrupt */ 112 | NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; 113 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 114 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 115 | NVIC_Init(&NVIC_InitStructure); 116 | } 117 | 118 | -------------------------------------------------------------------------------- /doc/microLite_timer_Code_Info.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1、扫描周期与时钟节拍 3 | 一般小型系统由Background和Foreground构成。Background称为任务区,Foreground称为中断区。对实时性要求很高的操作要由中断区的中断服务程序来完成。位于Background区域的任务响应时间取决于超级循环(Super-Loops)执行一次的时间,也称之为扫描周期ScanCycleTime。扫描周期并不固定,任务执行过程中扫描周期的最大值意味着任务最坏的响应时间。 4 | 5 | microLite裸机系统最小的时间单位是时钟节拍(Tick),时钟节拍是特定的周期性中断,这个中断可以看做是系统心跳,时钟节拍由硬件定时器产生,当中断到来时,将调用一次ml_tick_increase()。不同硬件定时器的中断实现不同,下面的中断函数以 STM32 定时器作为示例: 6 | ``` 7 | void SysTick_Handler(void) 8 | { 9 | ml_tick_increase(); 10 | } 11 | ``` 12 | 在中断函数中调用 ml_tick_increase()对全局变量 ml_tick 进行自加,代码如下: 13 | ``` 14 | void ml_tick_increase(void) 15 | { 16 | ml_tick++; 17 | } 18 | ``` 19 | 通过调用 ml_tick_get会返回当前 ml_tick 的值,即可以获取到当前的时钟节拍值。此接口可用于获取系统的最大扫描周期,或者测量某任务运行的时间。接口函数如下: 20 | 21 | ``` 22 | ml_tick_t ml_tick_get(void) 23 | { 24 | ml_tick_t t = 0; 25 | t = ml_tick; 26 | while (t != ml_tick) { 27 | t = ml_tick; 28 | } 29 | return t; 30 | } 31 | ``` 32 | 33 | 34 | ## 2、软件定时器microLite_timer介绍 35 | 36 | 软件定时器microLite_timer提供两类定时器机制: 37 | - 第一类是周期触发定时器(MLPeriod),这类定时器会周期性的触发定时器,并且“一旦启动,永不停止”。 38 | 39 | - 第二类是单次触发定时器(MLShot),这类定时器在启动后只会触发一次定时器事件,然后定时器自动停止。 40 | 41 | ## 3、应用场景 42 | 周期触发定时器(MLPeriod),适用于对首次触发时间要求不严格的场合。比如,让LED以280ms周期性亮灭。这种情况下我们并不关心LED首次由灭到亮用了多长时间,我们只要求LED在以后的时间以准确的280ms周期性亮灭。 43 | 44 | 单次触发定时器(MLShot),适用于对首次触发时间要求严格的场合。另外MLshot定时器自动停止后,调用启动函数MLShot.start,亦可实现周期触发。 45 | 46 | ## 4、API接口 47 | microLite_timer支持的MLPeriod接口主要包括: 48 | - MLPeriod.Init,初始化定时器; 49 | - MLPeriod.run; 50 | - MLPeriod.check,检查定时器是否超时。 51 | 52 | microLite_timer支持的MLShot接口主要包括: 53 | - MLShot.start,启动定时器; 54 | - MLShot.stop,停止定时器; 55 | - MLShot.check,检查定时器是否超时。 56 | 57 | ## 5、注意事项 58 | 59 | - MLPeriod.run在一个扫描周期内,应被调用一次且仅一次; 60 | - 不建议将MLPeriod.check的参数设置为不固定值; 61 | - 不建议嵌套使用MLPeriod.check; 62 | - MLPeriod支持定时周期不同的定时器的个数为ML_PERIODTIMER_MAX; 63 | - MLShot触发后,定时器自动停止; 64 | - microLite_timer的定时精度由系统Tick时钟的周期以及扫描周期决定。 65 | 66 | -------------------------------------------------------------------------------- /doc/microLite_timer_api.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steven-lyan/microLite_timer/e12c267206030c1902159cae883746fbf190c82d/doc/microLite_timer_api.chm -------------------------------------------------------------------------------- /doc/picture/keil_Simulator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steven-lyan/microLite_timer/e12c267206030c1902159cae883746fbf190c82d/doc/picture/keil_Simulator.gif -------------------------------------------------------------------------------- /doc/picture/microLite_WeChat_log.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steven-lyan/microLite_timer/e12c267206030c1902159cae883746fbf190c82d/doc/picture/microLite_WeChat_log.gif -------------------------------------------------------------------------------- /src/microLite_timer.c: -------------------------------------------------------------------------------- 1 | /** 2 | * stevenLyan is pleased to support the open source community. 3 | * 4 | * Copyright 2021 stevenLyan (Email:stevenlyan@qq.com) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * 19 | * Change Logs: 20 | * Date Author Notes 21 | * 2021-02-18 stevenLyan first version(v0.0.1) 22 | * 23 | */ 24 | 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "microLite_timer.h" 28 | 29 | 30 | /** @defgroup periodTimer 31 | * @brief period timer modules 32 | * @{ 33 | */ 34 | 35 | /** @defgroup periodTimer_Private_TypesDefinitions 36 | * @{ 37 | */ 38 | 39 | typedef struct { 40 | ml_tick_t initTick; 41 | ml_tick_t timeoutTick; 42 | ml_tickStatus timeoutFlag; 43 | } ml_periodTimer_TypeDef; 44 | 45 | /** 46 | * @} 47 | */ 48 | 49 | /** @defgroup periodTimer_Private_Defines 50 | * @{ 51 | */ 52 | 53 | /** Limits and boundaries */ 54 | #if (!((0 < ML_PERIODTIMER_MAX) && (ML_PERIODTIMER_MAX < 500))) 55 | #error Wrong defined micro "ML_PERIODTIMER_MAX" (microLite_timer.h). 56 | #endif 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** periodTimer error code */ 63 | #define ML_TIMER_ERRCODE_PARM_INVALID ((ml_u32_t)1) 64 | #define ML_TIMER_ERRCODE_TC_OVERFLOW1 ((ml_u32_t)2) 65 | 66 | /** @defgroup periodTimer_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | 70 | static ml_u16_t ml_periodTimer_usedNum_get(void); 71 | static ml_u32_t ml_periodTimer_errCode_get(void); 72 | static void ml_periodTimer_init(void); 73 | static void ml_periodTimer_run(void); 74 | static ml_tickStatus ml_periodTimer_check(ml_tick_t init_tick); 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | 81 | /** @defgroup periodTimer_Private_Variables 82 | * @{ 83 | */ 84 | static ml_periodTimer_TypeDef ml_pedTimer[ML_PERIODTIMER_MAX + 1] = {0}; /* " + 1" for debug */ 85 | static ml_u16_t ml_pedTimer_num = 0; 86 | static ml_u32_t ml_pedTimer_errorCode = 0; 87 | 88 | static const ml_periodTimer_Object_Struct MLpedTimer_Object = { 89 | ml_periodTimer_init, 90 | ml_periodTimer_run, 91 | ml_periodTimer_check, 92 | ml_periodTimer_usedNum_get, 93 | ml_periodTimer_errCode_get 94 | }; 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** @defgroup periodTimer_Private_Functions 101 | * @{ 102 | */ 103 | 104 | /** 105 | * this function init periodTimer. 106 | */ 107 | static void ml_periodTimer_init(void) 108 | { 109 | ml_u16_t i = 0; 110 | 111 | for (i = 0; i < ML_PERIODTIMER_MAX; i++) { 112 | ml_pedTimer[i].initTick = 0; 113 | ml_pedTimer[i].timeoutTick = 0; 114 | ml_pedTimer[i].timeoutFlag = ML_TICK_RESET; 115 | } 116 | } 117 | 118 | /** 119 | * Attention!!! this function can only be invoked in one place. 120 | */ 121 | static void ml_periodTimer_run(void) 122 | { 123 | ml_tick_t current_tick; 124 | ml_u16_t j = 0; 125 | 126 | for (j = 0; j < ML_PERIODTIMER_MAX; j++) { 127 | if (ml_pedTimer[j].initTick) { 128 | /* re-get current tick */ 129 | current_tick = ml_tick_get(); 130 | if (((ml_tick_t)(current_tick - ml_pedTimer[j].timeoutTick)) >= (ml_tick_t)ml_pedTimer[j].initTick) { 131 | ml_pedTimer[j].timeoutTick = current_tick; 132 | ml_pedTimer[j].timeoutFlag = ML_TICK_SET; 133 | } else { 134 | ml_pedTimer[j].timeoutFlag = ML_TICK_RESET; 135 | } 136 | } else { 137 | break; 138 | } 139 | } 140 | 141 | } 142 | 143 | /** 144 | * This function will check periodTimer structure 145 | * @param[in] init_tick 146 | * @return the operation status, ML_TICK_SUCCESS on OK, ML_TICK_ERROR on error 147 | */ 148 | static ml_tickStatus ml_periodTimer_check(ml_tick_t init_tick) 149 | { 150 | ml_tickStatus status = ML_TICK_RESET; 151 | 152 | if ((0 < init_tick) && ((ml_tick_t)init_tick < (ml_tick_t)0xFFFFFFFFUL)) { 153 | 154 | do { 155 | ml_u16_t k = 0; 156 | ml_u16_t unfound_cnt = 0; 157 | 158 | for (k = 0; k < ML_PERIODTIMER_MAX; k++) { 159 | if ((ml_pedTimer[k].initTick == init_tick) || (ml_pedTimer[k].initTick == 0)) { 160 | /* check the initTick is new */ 161 | if (ml_pedTimer[k].initTick == 0) { 162 | ml_pedTimer[k].initTick = init_tick; 163 | ml_pedTimer[k].timeoutTick = ml_tick_get(); 164 | ml_pedTimer[k].timeoutFlag = ML_TICK_RESET; 165 | ml_pedTimer_num++; 166 | } 167 | break; 168 | } else { 169 | unfound_cnt++; 170 | } 171 | } 172 | 173 | if (unfound_cnt >= ML_PERIODTIMER_MAX) { 174 | /* assert: error!!! */ 175 | ml_pedTimer_errorCode |= ML_TIMER_ERRCODE_TC_OVERFLOW1; 176 | } else { 177 | /* do nothing */ 178 | } 179 | 180 | } while (0); 181 | 182 | do { 183 | ml_u16_t n = 0; 184 | 185 | for (n = 0; n < ml_pedTimer_num; n++) { 186 | if ((ml_pedTimer[n].initTick == init_tick) && (ml_pedTimer[n].timeoutFlag == ML_TICK_SET)) { 187 | status = ML_TICK_SET; 188 | break; 189 | } else { 190 | /* do nothing */ 191 | } 192 | } 193 | } while (0); 194 | } else { 195 | /* invalid param, assert: error. */ 196 | ml_pedTimer_errorCode |= ML_TIMER_ERRCODE_PARM_INVALID; 197 | } 198 | 199 | return status; 200 | } 201 | 202 | /** 203 | * this function get periodTimer used number. 204 | */ 205 | static ml_u16_t ml_periodTimer_usedNum_get(void) 206 | { 207 | return ml_pedTimer_num; 208 | } 209 | /** 210 | * this function get periodTimer error code. 211 | */ 212 | static ml_u32_t ml_periodTimer_errCode_get(void) 213 | { 214 | return ml_pedTimer_errorCode; 215 | } 216 | /** 217 | * @brief Get the periodTimer object 218 | * @retval MLpedTimer_Object 219 | */ 220 | ml_periodTimer_Object_Struct ML_periodTimer_Object_Get(void) 221 | { 222 | return MLpedTimer_Object; 223 | } 224 | 225 | /** 226 | * @} 227 | */ 228 | 229 | /** 230 | * @} 231 | */ 232 | 233 | 234 | 235 | /** @defgroup shotTimer 236 | * @brief shot timer modules 237 | * @{ 238 | */ 239 | 240 | /** @defgroup shotTimer_Private_FunctionPrototypes 241 | * @{ 242 | */ 243 | 244 | 245 | static ml_errorStatus ml_shotTimer_start(ml_shotTimer_TypeDef *shot_ptr, ml_tick_t initTick); 246 | static ml_errorStatus ml_shotTimer_stop(ml_shotTimer_TypeDef *shot_ptr); 247 | static ml_tickStatus ml_shotTimer_check(ml_shotTimer_TypeDef *shot_ptr); 248 | static ml_tick_t ml_shotTimer_offsetTick_get(const ml_shotTimer_TypeDef *shot_ptr); 249 | static ml_tickStatus ml_shotTimer_state_get(const ml_shotTimer_TypeDef *shot_ptr); 250 | 251 | 252 | /** 253 | * @} 254 | */ 255 | 256 | /** @defgroup shotTimer_Private_Variables 257 | * @{ 258 | */ 259 | static const ml_shotTimer_Object_Struct MLshotTimer_Object = { 260 | ml_shotTimer_start, 261 | ml_shotTimer_stop, 262 | ml_shotTimer_check, 263 | ml_shotTimer_offsetTick_get, 264 | ml_shotTimer_state_get 265 | }; 266 | 267 | /** 268 | * @} 269 | */ 270 | /** @defgroup shotTimer_Private_Functions 271 | * @{ 272 | */ 273 | 274 | /** 275 | * This function will start the shotTimer 276 | * @param[in] shot_ptr 277 | * @param[in] initTick Initial time value 278 | * @return the operation status, ML_TICK_SUCCESS on OK, ML_TICK_ERROR on error 279 | */ 280 | static ml_errorStatus ml_shotTimer_start(ml_shotTimer_TypeDef *shot_ptr, ml_tick_t initTick) 281 | { 282 | if ((0 < initTick) && ((ml_tick_t)initTick < (ml_tick_t)0xFFFFFFFFUL)) { 283 | /* deactive state */ 284 | if (shot_ptr->activeStatus == ML_TICK_RESET) { 285 | shot_ptr->activeStatus = ML_TICK_SET; 286 | 287 | shot_ptr->initTick = initTick; 288 | shot_ptr->timeoutTick = ml_tick_get(); 289 | shot_ptr->offsetTick = 0; 290 | 291 | return ML_TICK_SUCCESS; 292 | } 293 | } 294 | return ML_TICK_ERROR; 295 | } 296 | 297 | /** 298 | * This function will stop the shotTimer 299 | * @return the operation status, ML_TICK_SUCCESS on OK, ML_TICK_ERROR on error 300 | */ 301 | static ml_errorStatus ml_shotTimer_stop(ml_shotTimer_TypeDef *shot_ptr) 302 | { 303 | /* deactived state */ 304 | if (shot_ptr->activeStatus == ML_TICK_SET) { 305 | shot_ptr->activeStatus = ML_TICK_RESET; 306 | 307 | return ML_TICK_SUCCESS; 308 | } 309 | return ML_TICK_ERROR; 310 | } 311 | 312 | /** 313 | * This function will check shotTimer structure, if a timeout event happens, 314 | * the shotTimer stop automaticly. 315 | */ 316 | static ml_tickStatus ml_shotTimer_check(ml_shotTimer_TypeDef *shot_ptr) 317 | { 318 | ml_tickStatus timeoutFlag = ML_TICK_RESET; 319 | /* actived state */ 320 | if (shot_ptr->activeStatus) { 321 | 322 | shot_ptr->offsetTick = (ml_tick_t)((ml_tick_get() - shot_ptr->timeoutTick)); 323 | 324 | if ((ml_tick_t)(shot_ptr->offsetTick) >= (ml_tick_t)shot_ptr->initTick) { 325 | shot_ptr->activeStatus = ML_TICK_RESET; 326 | timeoutFlag = ML_TICK_SET; 327 | } else { 328 | /* do nothing */ 329 | } 330 | } else { 331 | /* do nothing */ 332 | } 333 | 334 | return timeoutFlag; 335 | } 336 | 337 | /** 338 | * this function get shotTimer offset tick. 339 | */ 340 | static ml_tick_t ml_shotTimer_offsetTick_get(const ml_shotTimer_TypeDef *shot_ptr) 341 | { 342 | return (ml_tick_t)(shot_ptr->offsetTick); 343 | } 344 | /** 345 | * this function get shotTimer operation state. 346 | */ 347 | static ml_tickStatus ml_shotTimer_state_get(const ml_shotTimer_TypeDef *shot_ptr) 348 | { 349 | return (ml_tickStatus)(shot_ptr->activeStatus); 350 | } 351 | 352 | 353 | /** 354 | * @brief Get the shotTimer object 355 | * @retval MLshotTimer_Object 356 | */ 357 | ml_shotTimer_Object_Struct ML_shotTimer_Object_Get(void) 358 | { 359 | return MLshotTimer_Object; 360 | } 361 | 362 | 363 | /** 364 | * @} 365 | */ 366 | 367 | /** 368 | * @} 369 | */ 370 | 371 | 372 | /** @defgroup tick 373 | * @brief tick modules 374 | * @{ 375 | */ 376 | 377 | /** @defgroup tick_Private_Variables 378 | * @{ 379 | */ 380 | static volatile ml_tick_t ml_tick = 0; 381 | /** 382 | * @} 383 | */ 384 | 385 | 386 | /** @defgroup tick_Private_Functions 387 | * @{ 388 | */ 389 | 390 | /** 391 | * @brief Normally, this function is invoked by clock ISR. 392 | * @retval : None 393 | */ 394 | void ml_tick_increase(void) 395 | { 396 | ml_tick++; 397 | } 398 | 399 | /** 400 | * @brief This function will return current tick 401 | * @retval : current tick 402 | */ 403 | ml_tick_t ml_tick_get(void) 404 | { 405 | ml_tick_t t = 0; 406 | 407 | t = ml_tick; 408 | while (t != ml_tick) { 409 | t = ml_tick; 410 | } 411 | 412 | return t; 413 | } 414 | 415 | 416 | /** 417 | * @} 418 | */ 419 | 420 | /** 421 | * @} 422 | */ 423 | 424 | 425 | /* keep an empty line */ 426 | -------------------------------------------------------------------------------- /src/microLite_timer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * stevenLyan is pleased to support the open source community. 3 | * 4 | * Copyright 2021 stevenLyan (Email:stevenlyan@qq.com) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * 19 | * Change Logs: 20 | * Date Author Notes 21 | * 2021-02-18 stevenLyan first version(v0.0.1) 22 | * 23 | */ 24 | 25 | 26 | /* Define to prevent recursive inclusion -------------------------------------*/ 27 | #ifndef __MICROLITE_TIMER_H 28 | #define __MICROLITE_TIMER_H 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * typedef 36 | */ 37 | 38 | typedef unsigned short int ml_u16_t; 39 | typedef unsigned int ml_u32_t; 40 | 41 | typedef enum { 42 | ML_TICK_RESET = 0, 43 | ML_TICK_SET = !ML_TICK_RESET 44 | } ml_tickStatus; 45 | 46 | typedef enum { 47 | ML_TICK_ERROR = 0, 48 | ML_TICK_SUCCESS = !ML_TICK_ERROR 49 | } ml_errorStatus; 50 | 51 | typedef ml_u32_t ml_tick_t; 52 | 53 | /** 54 | * periodTimer 55 | */ 56 | 57 | 58 | #ifndef ML_PERIODTIMER_MAX 59 | #define ML_PERIODTIMER_MAX (50) /* Maxium number of periodTimer */ 60 | #endif 61 | 62 | typedef struct { 63 | void (*init)(void); 64 | void (*run)(void); 65 | ml_tickStatus (*check)(ml_tick_t period); 66 | ml_u16_t (*getUsedNum)(void); 67 | ml_u32_t (*getErrCode)(void); 68 | } ml_periodTimer_Object_Struct; 69 | 70 | ml_periodTimer_Object_Struct ML_periodTimer_Object_Get(void); 71 | 72 | #define MLPeriod (ML_periodTimer_Object_Get()) 73 | 74 | /** 75 | * shotTimer 76 | */ 77 | 78 | typedef struct { 79 | ml_tick_t initTick; 80 | ml_tick_t timeoutTick; 81 | ml_tick_t offsetTick; 82 | ml_tickStatus activeStatus; 83 | } ml_shotTimer_TypeDef; 84 | 85 | typedef struct { 86 | ml_errorStatus (*start)(ml_shotTimer_TypeDef *shot_ptr, ml_tick_t initTick); 87 | ml_errorStatus (*stop)(ml_shotTimer_TypeDef *shot_ptr); 88 | ml_tickStatus (*check)(ml_shotTimer_TypeDef *shot_ptr); 89 | ml_tick_t (*getOffsetTick)(const ml_shotTimer_TypeDef *shot_ptr); 90 | ml_tickStatus (*getState)(const ml_shotTimer_TypeDef *shot_ptr); 91 | } ml_shotTimer_Object_Struct; 92 | 93 | ml_shotTimer_Object_Struct ML_shotTimer_Object_Get(void); 94 | 95 | #define MLShot (ML_shotTimer_Object_Get()) 96 | 97 | /** 98 | * tick 99 | */ 100 | ml_tick_t ml_tick_get(void); 101 | void ml_tick_increase(void); 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | 108 | #endif 109 | 110 | /* keep an empty line */ 111 | 112 | -------------------------------------------------------------------------------- /test/test1_period.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * stevenLyan is pleased to support the open source community. 4 | * 5 | * Copyright 2021 stevenLyan (Email:stevenlyan@qq.com) 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | * 2021-02-18 stevenLyan first version 23 | * 24 | */ 25 | 26 | #include "microLite_timer.h" 27 | #include "stdio.h" 28 | 29 | void test1(void) 30 | { 31 | MLPeriod.init(); 32 | 33 | printf("microLite - Bare metal system, 2021 Copyright by stevenLyan\r\n\r\n"); 34 | 35 | printf("microLite timer sample, current tick is %d \r\n", ml_tick_get()); 36 | while (1) { 37 | MLPeriod.run(); 38 | 39 | if (MLPeriod.check(1000)) { 40 | printf("task1, current tick is %d\r\n", ml_tick_get()); 41 | } 42 | if (MLPeriod.check(500)) { 43 | printf("task2, current tick is %d\r\n", ml_tick_get()); 44 | } 45 | if (MLPeriod.check(500)) { 46 | printf("task3, current tick is %d\r\n", ml_tick_get()); 47 | } 48 | if (MLPeriod.check(800)) { 49 | printf("task4, current tick is %d\r\n", ml_tick_get()); 50 | } 51 | } 52 | } 53 | 54 | /* keep an empty line */ 55 | -------------------------------------------------------------------------------- /test/test2_shot.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * stevenLyan is pleased to support the open source community. 4 | * 5 | * Copyright 2021 stevenLyan (Email:stevenlyan@qq.com) 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | * 2021-02-18 stevenLyan first version 23 | * 24 | */ 25 | 26 | #include "microLite_timer.h" 27 | #include "stdio.h" 28 | 29 | static ml_shotTimer_TypeDef test2_timer1 = {0}; 30 | static ml_shotTimer_TypeDef test2_timer2 = {0}; 31 | static ml_shotTimer_TypeDef test2_timer3 = {0}; 32 | 33 | void test2(void) 34 | { 35 | printf("microLite - Bare metal system, 2021 Copyright by stevenLyan\r\n\r\n"); 36 | 37 | printf("microLite timer sample, current tick is %d \r\n", ml_tick_get()); 38 | MLShot.start(&test2_timer1, 800); 39 | MLShot.start(&test2_timer2, 500); 40 | 41 | while (1) { 42 | /*----------------------------------------------------------------------------*/ 43 | /* Schedules the specified task for execution after the specified delay. 44 | [the specified delay]: [timer1]800 ticks */ 45 | if (MLShot.check(&test2_timer1)) { 46 | printf("timer1 stop(auto), current tick is %d!!!\r\n", ml_tick_get()); 47 | } 48 | /*----------------------------------------------------------------------------*/ 49 | /* Schedules the specified task for repeated fixed-delay execution, beginning 50 | after the specified delay. 51 | [the specified delay]: [timer2]500 ticks 52 | [repeated fixed-delay]: [timer3]1000 ticks 53 | */ 54 | if (MLShot.check(&test2_timer2)) { 55 | MLShot.start(&test2_timer3, 1000); 56 | printf("timer2 stop(auto) and timer3 start, current tick is %d!!!\r\n", ml_tick_get()); 57 | } 58 | if (MLShot.check(&test2_timer3)) { 59 | MLShot.start(&test2_timer3, 1000); 60 | printf("timer3 timeout, current tick is %d\r\n", ml_tick_get()); 61 | } 62 | 63 | } 64 | } 65 | 66 | /* keep an empty line */ 67 | -------------------------------------------------------------------------------- /test/test3_misc.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * stevenLyan is pleased to support the open source community. 4 | * 5 | * Copyright 2021 stevenLyan (Email:stevenlyan@qq.com) 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | * 2021-02-18 stevenLyan first version 23 | * 24 | */ 25 | 26 | #include "microLite_timer.h" 27 | #include "stdio.h" 28 | 29 | static ml_shotTimer_TypeDef test3_timer1 = {0}; 30 | 31 | 32 | void test3(void) 33 | { 34 | MLPeriod.init(); 35 | 36 | printf("microLite - Bare metal system, 2021 Copyright by stevenLyan\r\n\r\n"); 37 | 38 | printf("microLite timer sample, current tick is %d \r\n", ml_tick_get()); 39 | MLShot.start(&test3_timer1, 800); 40 | 41 | while (1) { 42 | MLPeriod.run(); 43 | /*----------------------------------------------------------------------------*/ 44 | if (MLPeriod.check(1000)) { 45 | printf("periodTimer is timeout, current tick is %d\r\n", ml_tick_get()); 46 | } 47 | /*----------------------------------------------------------------------------*/ 48 | if (MLShot.check(&test3_timer1)) { 49 | printf("timer1 stop(auto), current tick is %d!!!\r\n", ml_tick_get()); 50 | } else { 51 | /* stop timer1 ahead of time manually */ 52 | if (MLShot.getState(&test3_timer1) == ML_TICK_SET) { 53 | if (MLShot.getOffsetTick(&test3_timer1) > 500) { 54 | MLShot.stop(&test3_timer1); 55 | printf("timer1 stop(manual), current tick is %d!!!\r\n", ml_tick_get()); 56 | } 57 | } 58 | } 59 | } 60 | } 61 | 62 | /* keep an empty line */ 63 | -------------------------------------------------------------------------------- /test/test4_error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * stevenLyan is pleased to support the open source community. 3 | * 4 | * Copyright 2021 stevenLyan (Email:stevenlyan@qq.com) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * 19 | * Change Logs: 20 | * Date Author Notes 21 | * 2021-02-18 stevenLyan first version 22 | * 23 | */ 24 | 25 | #include "microLite_timer.h" 26 | #include "stdio.h" 27 | 28 | void test4(void) 29 | { 30 | MLPeriod.init(); 31 | printf("microLite - Bare metal system, 2021 Copyright by stevenLyan\r\n\r\n"); 32 | 33 | printf("supported the max periodTimer num is %d \r\n", ML_PERIODTIMER_MAX); 34 | while (1) { 35 | ml_u32_t index; 36 | 37 | MLPeriod.run(); 38 | 39 | for (index = 0; index < ML_PERIODTIMER_MAX; index++) { 40 | if (MLPeriod.check(index + 1)) { 41 | ; 42 | } 43 | printf("MLPeriod.check(%d) invoked \r\n", index + 1); 44 | printf("allocated periodTimer num is %d, error code is %d \r\n", MLPeriod.getUsedNum(), MLPeriod.getErrCode()); 45 | } 46 | printf("\r\n"); 47 | 48 | if (MLPeriod.check(1)) { 49 | ; 50 | } 51 | printf("MLPeriod.check(%d) invoked \r\n", 1); 52 | printf("allocated periodTimer num is %d, error code is %d \r\n", MLPeriod.getUsedNum(), MLPeriod.getErrCode()); 53 | printf("\r\n"); 54 | 55 | if (MLPeriod.check(1 + (ML_PERIODTIMER_MAX / 2))) { 56 | ; 57 | } 58 | printf("MLPeriod.check(%d) invoked \r\n", 1 + (ML_PERIODTIMER_MAX / 2)); 59 | printf("allocated periodTimer num is %d, error code is %d \r\n", MLPeriod.getUsedNum(), MLPeriod.getErrCode()); 60 | printf("\r\n"); 61 | 62 | if (MLPeriod.check(ML_PERIODTIMER_MAX)) { 63 | ; 64 | } 65 | printf("MLPeriod.check(%d) invoked \r\n", ML_PERIODTIMER_MAX); 66 | printf("allocated periodTimer num is %d, error code is %d \r\n", MLPeriod.getUsedNum(), MLPeriod.getErrCode()); 67 | printf("\r\n"); 68 | 69 | 70 | if (MLPeriod.check(ML_PERIODTIMER_MAX + 1)) { 71 | ; 72 | } 73 | printf("MLPeriod.check(%d) invoked \r\n", ML_PERIODTIMER_MAX + 1); 74 | printf("allocated periodTimer num is %d, error code is %d \r\n", MLPeriod.getUsedNum(), MLPeriod.getErrCode()); 75 | printf("\r\n"); 76 | 77 | 78 | if (MLPeriod.check((ml_tick_t)0xFFFFFFFF)) { 79 | ; 80 | } 81 | printf("MLPeriod.check(%d) invoked \r\n", (ml_tick_t)0xFFFFFFFF); 82 | printf("no periodTimer is allocated, error code is %d \r\n", MLPeriod.getErrCode()); 83 | printf("\r\n"); 84 | 85 | /* end test */ 86 | printf("end test \r\n"); 87 | while (1); 88 | } 89 | } 90 | 91 | 92 | /* keep an empty line */ 93 | 94 | -------------------------------------------------------------------------------- /test/test_5.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * stevenLyan is pleased to support the open source community. 4 | * 5 | * Copyright 2021 stevenLyan (Email:stevenlyan@qq.com) 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * 20 | * Change Logs: 21 | * Date Author Notes 22 | * 2021-02-18 stevenLyan first version 23 | * 24 | */ 25 | 26 | #include "microLite_timer.h" 27 | #include "stdio.h" 28 | 29 | ml_u32_t cnt1[50] = {0}; 30 | ml_u32_t cnt2[50] = {0}; 31 | 32 | ml_u32_t scanTime = 0; 33 | ml_u32_t maxScan = 0; 34 | void test5(void) 35 | { 36 | MLPeriod.init(); 37 | 38 | while (1) { 39 | static ml_u32_t store = 0; 40 | ml_u32_t i; 41 | 42 | scanTime = ml_tick_get() - store; 43 | store = ml_tick_get(); 44 | 45 | if (scanTime > maxScan) { 46 | maxScan = scanTime; 47 | } 48 | 49 | MLPeriod.run(); 50 | 51 | 52 | for (i = 0; i < 50; i++) { 53 | if (MLPeriod.check(50 + i)) { 54 | cnt1[i]++; 55 | } 56 | } 57 | for (i = 0; i < 50; i++) { 58 | if (MLPeriod.check(60 + i)) { 59 | cnt2[i]++; 60 | } 61 | } 62 | 63 | } 64 | } 65 | 66 | 67 | 68 | 69 | /* keep an empty line */ 70 | --------------------------------------------------------------------------------