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