Bare-metal configuration with EventQueue for a Bluepill board.
Warning
It does not work with the Mbed Online Compiler.
Follow these steps to import and compile it with Mbed CLI:
mbed import https://os.mbed.com/users/hudakz/code/Baremetal_EventQue_Bluepill mbed compile -t GCC_ARM -m bluepill
TARGET_BLUEPILL/device/stm32f1xx.h@0:2cf53c219693, 2020-05-14 (annotated)
- Committer:
- hudakz
- Date:
- Thu May 14 05:27:57 2020 +0000
- Revision:
- 0:2cf53c219693
Bare-metal configuration with EventQueue for a Bluepill board.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 0:2cf53c219693 | 1 | /** |
hudakz | 0:2cf53c219693 | 2 | ****************************************************************************** |
hudakz | 0:2cf53c219693 | 3 | * @file stm32f1xx.h |
hudakz | 0:2cf53c219693 | 4 | * @author MCD Application Team |
hudakz | 0:2cf53c219693 | 5 | * @version V4.2.0 |
hudakz | 0:2cf53c219693 | 6 | * @date 31-March-2017 |
hudakz | 0:2cf53c219693 | 7 | * @brief CMSIS STM32F1xx Device Peripheral Access Layer Header File. |
hudakz | 0:2cf53c219693 | 8 | * |
hudakz | 0:2cf53c219693 | 9 | * The file is the unique include file that the application programmer |
hudakz | 0:2cf53c219693 | 10 | * is using in the C source code, usually in main.c. This file contains: |
hudakz | 0:2cf53c219693 | 11 | * - Configuration section that allows to select: |
hudakz | 0:2cf53c219693 | 12 | * - The STM32F1xx device used in the target application |
hudakz | 0:2cf53c219693 | 13 | * - To use or not the peripherals drivers in application code(i.e. |
hudakz | 0:2cf53c219693 | 14 | * code will be based on direct access to peripherals registers |
hudakz | 0:2cf53c219693 | 15 | * rather than drivers API), this option is controlled by |
hudakz | 0:2cf53c219693 | 16 | * "#define USE_HAL_DRIVER" |
hudakz | 0:2cf53c219693 | 17 | * |
hudakz | 0:2cf53c219693 | 18 | ****************************************************************************** |
hudakz | 0:2cf53c219693 | 19 | * @attention |
hudakz | 0:2cf53c219693 | 20 | * |
hudakz | 0:2cf53c219693 | 21 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
hudakz | 0:2cf53c219693 | 22 | * |
hudakz | 0:2cf53c219693 | 23 | * Redistribution and use in source and binary forms, with or without modification, |
hudakz | 0:2cf53c219693 | 24 | * are permitted provided that the following conditions are met: |
hudakz | 0:2cf53c219693 | 25 | * 1. Redistributions of source code must retain the above copyright notice, |
hudakz | 0:2cf53c219693 | 26 | * this list of conditions and the following disclaimer. |
hudakz | 0:2cf53c219693 | 27 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
hudakz | 0:2cf53c219693 | 28 | * this list of conditions and the following disclaimer in the documentation |
hudakz | 0:2cf53c219693 | 29 | * and/or other materials provided with the distribution. |
hudakz | 0:2cf53c219693 | 30 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
hudakz | 0:2cf53c219693 | 31 | * may be used to endorse or promote products derived from this software |
hudakz | 0:2cf53c219693 | 32 | * without specific prior written permission. |
hudakz | 0:2cf53c219693 | 33 | * |
hudakz | 0:2cf53c219693 | 34 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
hudakz | 0:2cf53c219693 | 35 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
hudakz | 0:2cf53c219693 | 36 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
hudakz | 0:2cf53c219693 | 37 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
hudakz | 0:2cf53c219693 | 38 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
hudakz | 0:2cf53c219693 | 39 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
hudakz | 0:2cf53c219693 | 40 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
hudakz | 0:2cf53c219693 | 41 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
hudakz | 0:2cf53c219693 | 42 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
hudakz | 0:2cf53c219693 | 43 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
hudakz | 0:2cf53c219693 | 44 | * |
hudakz | 0:2cf53c219693 | 45 | ****************************************************************************** |
hudakz | 0:2cf53c219693 | 46 | */ |
hudakz | 0:2cf53c219693 | 47 | |
hudakz | 0:2cf53c219693 | 48 | /** @addtogroup CMSIS |
hudakz | 0:2cf53c219693 | 49 | * @{ |
hudakz | 0:2cf53c219693 | 50 | */ |
hudakz | 0:2cf53c219693 | 51 | |
hudakz | 0:2cf53c219693 | 52 | /** @addtogroup stm32f1xx |
hudakz | 0:2cf53c219693 | 53 | * @{ |
hudakz | 0:2cf53c219693 | 54 | */ |
hudakz | 0:2cf53c219693 | 55 | |
hudakz | 0:2cf53c219693 | 56 | #ifndef __STM32F1XX_H |
hudakz | 0:2cf53c219693 | 57 | #define __STM32F1XX_H |
hudakz | 0:2cf53c219693 | 58 | |
hudakz | 0:2cf53c219693 | 59 | #ifdef __cplusplus |
hudakz | 0:2cf53c219693 | 60 | extern "C" { |
hudakz | 0:2cf53c219693 | 61 | #endif /* __cplusplus */ |
hudakz | 0:2cf53c219693 | 62 | |
hudakz | 0:2cf53c219693 | 63 | /** @addtogroup Library_configuration_section |
hudakz | 0:2cf53c219693 | 64 | * @{ |
hudakz | 0:2cf53c219693 | 65 | */ |
hudakz | 0:2cf53c219693 | 66 | |
hudakz | 0:2cf53c219693 | 67 | /** |
hudakz | 0:2cf53c219693 | 68 | * @brief STM32 Family |
hudakz | 0:2cf53c219693 | 69 | */ |
hudakz | 0:2cf53c219693 | 70 | #if !defined (STM32F1) |
hudakz | 0:2cf53c219693 | 71 | #define STM32F1 |
hudakz | 0:2cf53c219693 | 72 | #endif /* STM32F1 */ |
hudakz | 0:2cf53c219693 | 73 | |
hudakz | 0:2cf53c219693 | 74 | /* Uncomment the line below according to the target STM32L device used in your |
hudakz | 0:2cf53c219693 | 75 | application |
hudakz | 0:2cf53c219693 | 76 | */ |
hudakz | 0:2cf53c219693 | 77 | |
hudakz | 0:2cf53c219693 | 78 | #if !defined (STM32F100xB) && !defined (STM32F100xE) && !defined (STM32F101x6) && \ |
hudakz | 0:2cf53c219693 | 79 | !defined (STM32F101xB) && !defined (STM32F101xE) && !defined (STM32F101xG) && !defined (STM32F102x6) && !defined (STM32F102xB) && !defined (STM32F103x6) && \ |
hudakz | 0:2cf53c219693 | 80 | !defined (STM32F103xB) && !defined (STM32F103xE) && !defined (STM32F103xG) && !defined (STM32F105xC) && !defined (STM32F107xC) |
hudakz | 0:2cf53c219693 | 81 | /* #define STM32F100xB */ /*!< STM32F100C4, STM32F100R4, STM32F100C6, STM32F100R6, STM32F100C8, STM32F100R8, STM32F100V8, STM32F100CB, STM32F100RB and STM32F100VB */ |
hudakz | 0:2cf53c219693 | 82 | /* #define STM32F100xE */ /*!< STM32F100RC, STM32F100VC, STM32F100ZC, STM32F100RD, STM32F100VD, STM32F100ZD, STM32F100RE, STM32F100VE and STM32F100ZE */ |
hudakz | 0:2cf53c219693 | 83 | /* #define STM32F101x6 */ /*!< STM32F101C4, STM32F101R4, STM32F101T4, STM32F101C6, STM32F101R6 and STM32F101T6 Devices */ |
hudakz | 0:2cf53c219693 | 84 | /* #define STM32F101xB */ /*!< STM32F101C8, STM32F101R8, STM32F101T8, STM32F101V8, STM32F101CB, STM32F101RB, STM32F101TB and STM32F101VB */ |
hudakz | 0:2cf53c219693 | 85 | /* #define STM32F101xE */ /*!< STM32F101RC, STM32F101VC, STM32F101ZC, STM32F101RD, STM32F101VD, STM32F101ZD, STM32F101RE, STM32F101VE and STM32F101ZE */ |
hudakz | 0:2cf53c219693 | 86 | /* #define STM32F101xG */ /*!< STM32F101RF, STM32F101VF, STM32F101ZF, STM32F101RG, STM32F101VG and STM32F101ZG */ |
hudakz | 0:2cf53c219693 | 87 | /* #define STM32F102x6 */ /*!< STM32F102C4, STM32F102R4, STM32F102C6 and STM32F102R6 */ |
hudakz | 0:2cf53c219693 | 88 | /* #define STM32F102xB */ /*!< STM32F102C8, STM32F102R8, STM32F102CB and STM32F102RB */ |
hudakz | 0:2cf53c219693 | 89 | /* #define STM32F103x6 */ /*!< STM32F103C4, STM32F103R4, STM32F103T4, STM32F103C6, STM32F103R6 and STM32F103T6 */ |
hudakz | 0:2cf53c219693 | 90 | #define STM32F103xB /*!< STM32F103C8, STM32F103R8, STM32F103T8, STM32F103V8, STM32F103CB, STM32F103RB, STM32F103TB and STM32F103VB */ |
hudakz | 0:2cf53c219693 | 91 | /* #define STM32F103xE */ /*!< STM32F103RC, STM32F103VC, STM32F103ZC, STM32F103RD, STM32F103VD, STM32F103ZD, STM32F103RE, STM32F103VE and STM32F103ZE */ |
hudakz | 0:2cf53c219693 | 92 | /* #define STM32F103xG */ /*!< STM32F103RF, STM32F103VF, STM32F103ZF, STM32F103RG, STM32F103VG and STM32F103ZG */ |
hudakz | 0:2cf53c219693 | 93 | /* #define STM32F105xC */ /*!< STM32F105R8, STM32F105V8, STM32F105RB, STM32F105VB, STM32F105RC and STM32F105VC */ |
hudakz | 0:2cf53c219693 | 94 | /* #define STM32F107xC */ /*!< STM32F107RB, STM32F107VB, STM32F107RC and STM32F107VC */ |
hudakz | 0:2cf53c219693 | 95 | #endif |
hudakz | 0:2cf53c219693 | 96 | |
hudakz | 0:2cf53c219693 | 97 | /* Tip: To avoid modifying this file each time you need to switch between these |
hudakz | 0:2cf53c219693 | 98 | devices, you can define the device in your toolchain compiler preprocessor. |
hudakz | 0:2cf53c219693 | 99 | */ |
hudakz | 0:2cf53c219693 | 100 | |
hudakz | 0:2cf53c219693 | 101 | #if !defined (USE_HAL_DRIVER) |
hudakz | 0:2cf53c219693 | 102 | /** |
hudakz | 0:2cf53c219693 | 103 | * @brief Comment the line below if you will not use the peripherals drivers. |
hudakz | 0:2cf53c219693 | 104 | In this case, these drivers will not be included and the application code will |
hudakz | 0:2cf53c219693 | 105 | be based on direct access to peripherals registers |
hudakz | 0:2cf53c219693 | 106 | */ |
hudakz | 0:2cf53c219693 | 107 | #define USE_HAL_DRIVER |
hudakz | 0:2cf53c219693 | 108 | #endif /* USE_HAL_DRIVER */ |
hudakz | 0:2cf53c219693 | 109 | |
hudakz | 0:2cf53c219693 | 110 | /** |
hudakz | 0:2cf53c219693 | 111 | * @brief CMSIS Device version number V4.2.0 |
hudakz | 0:2cf53c219693 | 112 | */ |
hudakz | 0:2cf53c219693 | 113 | #define __STM32F1_CMSIS_VERSION_MAIN (0x04) /*!< [31:24] main version */ |
hudakz | 0:2cf53c219693 | 114 | #define __STM32F1_CMSIS_VERSION_SUB1 (0x02) /*!< [23:16] sub1 version */ |
hudakz | 0:2cf53c219693 | 115 | #define __STM32F1_CMSIS_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ |
hudakz | 0:2cf53c219693 | 116 | #define __STM32F1_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */ |
hudakz | 0:2cf53c219693 | 117 | #define __STM32F1_CMSIS_VERSION ((__STM32F1_CMSIS_VERSION_MAIN << 24)\ |
hudakz | 0:2cf53c219693 | 118 | |(__STM32F1_CMSIS_VERSION_SUB1 << 16)\ |
hudakz | 0:2cf53c219693 | 119 | |(__STM32F1_CMSIS_VERSION_SUB2 << 8 )\ |
hudakz | 0:2cf53c219693 | 120 | |(__STM32F1_CMSIS_VERSION_RC)) |
hudakz | 0:2cf53c219693 | 121 | |
hudakz | 0:2cf53c219693 | 122 | /** |
hudakz | 0:2cf53c219693 | 123 | * @} |
hudakz | 0:2cf53c219693 | 124 | */ |
hudakz | 0:2cf53c219693 | 125 | |
hudakz | 0:2cf53c219693 | 126 | /** @addtogroup Device_Included |
hudakz | 0:2cf53c219693 | 127 | * @{ |
hudakz | 0:2cf53c219693 | 128 | */ |
hudakz | 0:2cf53c219693 | 129 | |
hudakz | 0:2cf53c219693 | 130 | #if defined(STM32F100xB) |
hudakz | 0:2cf53c219693 | 131 | #include "stm32f100xb.h" |
hudakz | 0:2cf53c219693 | 132 | #elif defined(STM32F100xE) |
hudakz | 0:2cf53c219693 | 133 | #include "stm32f100xe.h" |
hudakz | 0:2cf53c219693 | 134 | #elif defined(STM32F101x6) |
hudakz | 0:2cf53c219693 | 135 | #include "stm32f101x6.h" |
hudakz | 0:2cf53c219693 | 136 | #elif defined(STM32F101xB) |
hudakz | 0:2cf53c219693 | 137 | #include "stm32f101xb.h" |
hudakz | 0:2cf53c219693 | 138 | #elif defined(STM32F101xE) |
hudakz | 0:2cf53c219693 | 139 | #include "stm32f101xe.h" |
hudakz | 0:2cf53c219693 | 140 | #elif defined(STM32F101xG) |
hudakz | 0:2cf53c219693 | 141 | #include "stm32f101xg.h" |
hudakz | 0:2cf53c219693 | 142 | #elif defined(STM32F102x6) |
hudakz | 0:2cf53c219693 | 143 | #include "stm32f102x6.h" |
hudakz | 0:2cf53c219693 | 144 | #elif defined(STM32F102xB) |
hudakz | 0:2cf53c219693 | 145 | #include "stm32f102xb.h" |
hudakz | 0:2cf53c219693 | 146 | #elif defined(STM32F103x6) |
hudakz | 0:2cf53c219693 | 147 | #include "stm32f103x6.h" |
hudakz | 0:2cf53c219693 | 148 | #elif defined(STM32F103xB) |
hudakz | 0:2cf53c219693 | 149 | #include "stm32f103xb.h" |
hudakz | 0:2cf53c219693 | 150 | #elif defined(STM32F103xE) |
hudakz | 0:2cf53c219693 | 151 | #include "stm32f103xe.h" |
hudakz | 0:2cf53c219693 | 152 | #elif defined(STM32F103xG) |
hudakz | 0:2cf53c219693 | 153 | #include "stm32f103xg.h" |
hudakz | 0:2cf53c219693 | 154 | #elif defined(STM32F105xC) |
hudakz | 0:2cf53c219693 | 155 | #include "stm32f105xc.h" |
hudakz | 0:2cf53c219693 | 156 | #elif defined(STM32F107xC) |
hudakz | 0:2cf53c219693 | 157 | #include "stm32f107xc.h" |
hudakz | 0:2cf53c219693 | 158 | #else |
hudakz | 0:2cf53c219693 | 159 | #error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)" |
hudakz | 0:2cf53c219693 | 160 | #endif |
hudakz | 0:2cf53c219693 | 161 | |
hudakz | 0:2cf53c219693 | 162 | /** |
hudakz | 0:2cf53c219693 | 163 | * @} |
hudakz | 0:2cf53c219693 | 164 | */ |
hudakz | 0:2cf53c219693 | 165 | |
hudakz | 0:2cf53c219693 | 166 | /** @addtogroup Exported_types |
hudakz | 0:2cf53c219693 | 167 | * @{ |
hudakz | 0:2cf53c219693 | 168 | */ |
hudakz | 0:2cf53c219693 | 169 | typedef enum |
hudakz | 0:2cf53c219693 | 170 | { |
hudakz | 0:2cf53c219693 | 171 | RESET = 0, |
hudakz | 0:2cf53c219693 | 172 | SET = !RESET |
hudakz | 0:2cf53c219693 | 173 | } FlagStatus, ITStatus; |
hudakz | 0:2cf53c219693 | 174 | |
hudakz | 0:2cf53c219693 | 175 | typedef enum |
hudakz | 0:2cf53c219693 | 176 | { |
hudakz | 0:2cf53c219693 | 177 | DISABLE = 0, |
hudakz | 0:2cf53c219693 | 178 | ENABLE = !DISABLE |
hudakz | 0:2cf53c219693 | 179 | } FunctionalState; |
hudakz | 0:2cf53c219693 | 180 | #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) |
hudakz | 0:2cf53c219693 | 181 | |
hudakz | 0:2cf53c219693 | 182 | typedef enum |
hudakz | 0:2cf53c219693 | 183 | { |
hudakz | 0:2cf53c219693 | 184 | ERROR = 0, |
hudakz | 0:2cf53c219693 | 185 | SUCCESS = !ERROR |
hudakz | 0:2cf53c219693 | 186 | } ErrorStatus; |
hudakz | 0:2cf53c219693 | 187 | |
hudakz | 0:2cf53c219693 | 188 | /** |
hudakz | 0:2cf53c219693 | 189 | * @} |
hudakz | 0:2cf53c219693 | 190 | */ |
hudakz | 0:2cf53c219693 | 191 | |
hudakz | 0:2cf53c219693 | 192 | |
hudakz | 0:2cf53c219693 | 193 | /** @addtogroup Exported_macros |
hudakz | 0:2cf53c219693 | 194 | * @{ |
hudakz | 0:2cf53c219693 | 195 | */ |
hudakz | 0:2cf53c219693 | 196 | #define SET_BIT(REG, BIT) ((REG) |= (BIT)) |
hudakz | 0:2cf53c219693 | 197 | |
hudakz | 0:2cf53c219693 | 198 | #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) |
hudakz | 0:2cf53c219693 | 199 | |
hudakz | 0:2cf53c219693 | 200 | #define READ_BIT(REG, BIT) ((REG) & (BIT)) |
hudakz | 0:2cf53c219693 | 201 | |
hudakz | 0:2cf53c219693 | 202 | #define CLEAR_REG(REG) ((REG) = (0x0)) |
hudakz | 0:2cf53c219693 | 203 | |
hudakz | 0:2cf53c219693 | 204 | #define WRITE_REG(REG, VAL) ((REG) = (VAL)) |
hudakz | 0:2cf53c219693 | 205 | |
hudakz | 0:2cf53c219693 | 206 | #define READ_REG(REG) ((REG)) |
hudakz | 0:2cf53c219693 | 207 | |
hudakz | 0:2cf53c219693 | 208 | #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) |
hudakz | 0:2cf53c219693 | 209 | |
hudakz | 0:2cf53c219693 | 210 | #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) |
hudakz | 0:2cf53c219693 | 211 | |
hudakz | 0:2cf53c219693 | 212 | |
hudakz | 0:2cf53c219693 | 213 | /** |
hudakz | 0:2cf53c219693 | 214 | * @} |
hudakz | 0:2cf53c219693 | 215 | */ |
hudakz | 0:2cf53c219693 | 216 | |
hudakz | 0:2cf53c219693 | 217 | #if defined (USE_HAL_DRIVER) |
hudakz | 0:2cf53c219693 | 218 | #include "stm32f1xx_hal.h" |
hudakz | 0:2cf53c219693 | 219 | #endif /* USE_HAL_DRIVER */ |
hudakz | 0:2cf53c219693 | 220 | |
hudakz | 0:2cf53c219693 | 221 | |
hudakz | 0:2cf53c219693 | 222 | #ifdef __cplusplus |
hudakz | 0:2cf53c219693 | 223 | } |
hudakz | 0:2cf53c219693 | 224 | #endif /* __cplusplus */ |
hudakz | 0:2cf53c219693 | 225 | |
hudakz | 0:2cf53c219693 | 226 | #endif /* __STM32F1xx_H */ |
hudakz | 0:2cf53c219693 | 227 | /** |
hudakz | 0:2cf53c219693 | 228 | * @} |
hudakz | 0:2cf53c219693 | 229 | */ |
hudakz | 0:2cf53c219693 | 230 | |
hudakz | 0:2cf53c219693 | 231 | /** |
hudakz | 0:2cf53c219693 | 232 | * @} |
hudakz | 0:2cf53c219693 | 233 | */ |
hudakz | 0:2cf53c219693 | 234 | |
hudakz | 0:2cf53c219693 | 235 | |
hudakz | 0:2cf53c219693 | 236 | |
hudakz | 0:2cf53c219693 | 237 | |
hudakz | 0:2cf53c219693 | 238 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |