mbed library sources

Fork of mbed-src by mbed official

Committer:
moirans2
Date:
Wed Jan 14 20:53:08 2015 +0000
Revision:
445:9a3ffe6cfa19
Parent:
386:ea0442aaf784
internal clock stm32L051

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 381:5460fc57b6e4 1 /**
mbed_official 381:5460fc57b6e4 2 ******************************************************************************
mbed_official 381:5460fc57b6e4 3 * @file stm32f3xx.h
mbed_official 381:5460fc57b6e4 4 * @author MCD Application Team
mbed_official 381:5460fc57b6e4 5 * @version V2.1.0
mbed_official 381:5460fc57b6e4 6 * @date 12-Sept-2014
mbed_official 381:5460fc57b6e4 7 * @brief CMSIS STM32F3xx Device Peripheral Access Layer Header File.
mbed_official 381:5460fc57b6e4 8 *
mbed_official 381:5460fc57b6e4 9 * The file is the unique include file that the application programmer
mbed_official 381:5460fc57b6e4 10 * is using in the C source code, usually in main.c. This file contains:
mbed_official 381:5460fc57b6e4 11 * - Configuration section that allows to select:
mbed_official 381:5460fc57b6e4 12 * - The STM32F3xx device used in the target application
mbed_official 381:5460fc57b6e4 13 * - To use or not the peripheral’s drivers in application code(i.e.
mbed_official 381:5460fc57b6e4 14 * code will be based on direct access to peripheral’s registers
mbed_official 381:5460fc57b6e4 15 * rather than drivers API), this option is controlled by
mbed_official 381:5460fc57b6e4 16 * "#define USE_HAL_DRIVER"
mbed_official 381:5460fc57b6e4 17 *
mbed_official 381:5460fc57b6e4 18 ******************************************************************************
mbed_official 381:5460fc57b6e4 19 * @attention
mbed_official 381:5460fc57b6e4 20 *
mbed_official 381:5460fc57b6e4 21 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 381:5460fc57b6e4 22 *
mbed_official 381:5460fc57b6e4 23 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 381:5460fc57b6e4 24 * are permitted provided that the following conditions are met:
mbed_official 381:5460fc57b6e4 25 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 381:5460fc57b6e4 26 * this list of conditions and the following disclaimer.
mbed_official 381:5460fc57b6e4 27 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 381:5460fc57b6e4 28 * this list of conditions and the following disclaimer in the documentation
mbed_official 381:5460fc57b6e4 29 * and/or other materials provided with the distribution.
mbed_official 381:5460fc57b6e4 30 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 381:5460fc57b6e4 31 * may be used to endorse or promote products derived from this software
mbed_official 381:5460fc57b6e4 32 * without specific prior written permission.
mbed_official 381:5460fc57b6e4 33 *
mbed_official 381:5460fc57b6e4 34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 381:5460fc57b6e4 35 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 381:5460fc57b6e4 36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 381:5460fc57b6e4 37 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 381:5460fc57b6e4 38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 381:5460fc57b6e4 39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 381:5460fc57b6e4 40 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 381:5460fc57b6e4 41 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 381:5460fc57b6e4 42 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 381:5460fc57b6e4 43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 381:5460fc57b6e4 44 *
mbed_official 381:5460fc57b6e4 45 ******************************************************************************
mbed_official 381:5460fc57b6e4 46 */
mbed_official 381:5460fc57b6e4 47
mbed_official 381:5460fc57b6e4 48 /** @addtogroup CMSIS
mbed_official 381:5460fc57b6e4 49 * @{
mbed_official 381:5460fc57b6e4 50 */
mbed_official 381:5460fc57b6e4 51
mbed_official 381:5460fc57b6e4 52 /** @addtogroup stm32f3xx
mbed_official 381:5460fc57b6e4 53 * @{
mbed_official 381:5460fc57b6e4 54 */
mbed_official 381:5460fc57b6e4 55
mbed_official 381:5460fc57b6e4 56 #ifndef __STM32F3xx_H
mbed_official 381:5460fc57b6e4 57 #define __STM32F3xx_H
mbed_official 381:5460fc57b6e4 58
mbed_official 381:5460fc57b6e4 59 #ifdef __cplusplus
mbed_official 381:5460fc57b6e4 60 extern "C" {
mbed_official 381:5460fc57b6e4 61 #endif /* __cplusplus */
mbed_official 381:5460fc57b6e4 62
mbed_official 381:5460fc57b6e4 63 /** @addtogroup Library_configuration_section
mbed_official 381:5460fc57b6e4 64 * @{
mbed_official 381:5460fc57b6e4 65 */
mbed_official 381:5460fc57b6e4 66
mbed_official 381:5460fc57b6e4 67 /* Uncomment the line below according to the target STM32 device used in your
mbed_official 381:5460fc57b6e4 68 application
mbed_official 381:5460fc57b6e4 69 */
mbed_official 381:5460fc57b6e4 70
mbed_official 381:5460fc57b6e4 71 #if !defined (STM32F301x8) && !defined (STM32F302x8) && !defined (STM32F318xx) && \
mbed_official 381:5460fc57b6e4 72 !defined (STM32F302xC) && !defined (STM32F303xC) && !defined (STM32F358xx) && \
mbed_official 381:5460fc57b6e4 73 !defined (STM32F303x8) && !defined (STM32F334x8) && !defined (STM32F328xx) && \
mbed_official 381:5460fc57b6e4 74 !defined (STM32F302xE) && !defined (STM32F303xE) && !defined (STM32F398xx) && \
mbed_official 381:5460fc57b6e4 75 !defined (STM32F373xC) && !defined (STM32F378xx)
mbed_official 381:5460fc57b6e4 76
mbed_official 381:5460fc57b6e4 77 /* #define STM32F301x8 */ /*!< STM32F301K6, STM32F301K8, STM32F301C6, STM32F301C8,
mbed_official 381:5460fc57b6e4 78 STM32F301R6 and STM32F301R8 Devices */
mbed_official 381:5460fc57b6e4 79 /* #define STM32F302x8 */ /*!< STM32F302K6, STM32F302K8, STM32F302C6, STM32F302C8,
mbed_official 381:5460fc57b6e4 80 STM32F302R6 and STM32F302R8 Devices */
mbed_official 381:5460fc57b6e4 81 /* #define STM32F302xC */ /*!< STM32F302CB, STM32F302CC, STM32F302RB, STM32F302RC, STM32F302VB and STM32F302VC Devices */
mbed_official 381:5460fc57b6e4 82 /* #define STM32F302xE */ /*!< STM32F302CE, STM32F302RE, and STM32F302VE Devices */
mbed_official 381:5460fc57b6e4 83 /* #define STM32F303x8 */ /*!< STM32F303K6, STM32F303K8, STM32F303C6, STM32F303C8,
mbed_official 381:5460fc57b6e4 84 STM32F303R6 and STM32F303R8 Devices */
mbed_official 381:5460fc57b6e4 85 /* #define STM32F303xC */ /*!< STM32F303CB, STM32F303CC, STM32F303RB, STM32F303RC, STM32F303VB and STM32F303VC Devices */
mbed_official 381:5460fc57b6e4 86 /* #define STM32F303xE */ /*!< STM32F303RE, STM32F303VE and STM32F303ZE Devices */
mbed_official 381:5460fc57b6e4 87 /* #define STM32F373xC */ /*!< STM32F373C8, STM32F373CB, STM32F373CC, STM32F373R8, STM32F373RB, STM32F373RC,
mbed_official 381:5460fc57b6e4 88 STM32F373V8, STM32F373VB and STM32F373VC Devices */
mbed_official 381:5460fc57b6e4 89 #define STM32F334x8 /*!< STM32F334C4, STM32F334C6, STM32F334C8, STM32F334R4, STM32F334R6 and STM32F334R8 Devices */
mbed_official 381:5460fc57b6e4 90 /* #define STM32F318xx */ /*!< STM32F318K8, STM32F318C8: STM32F301x8 with regulator off: STM32F318xx Devices */
mbed_official 381:5460fc57b6e4 91 /* #define STM32F328xx */ /*!< STM32F328C8, STM32F328R8: STM32F334x8 with regulator off: STM32F328xx Devices */
mbed_official 381:5460fc57b6e4 92 /* #define STM32F358xx */ /*!< STM32F358CC, STM32F358RC, STM32F358VC: STM32F303xC with regulator off: STM32F358xx Devices */
mbed_official 381:5460fc57b6e4 93 /* #define STM32F378xx */ /*!< STM32F378CC, STM32F378RC, STM32F378VC: STM32F373xC with regulator off: STM32F378xx Devices */
mbed_official 381:5460fc57b6e4 94 /* #define STM32F398xx */ /*!< STM32F398CE, STM32F398RE, STM32F398VE: STM32F303xE with regulator off: STM32F398xx Devices */
mbed_official 381:5460fc57b6e4 95 #endif
mbed_official 381:5460fc57b6e4 96
mbed_official 381:5460fc57b6e4 97 /* Tip: To avoid modifying this file each time you need to switch between these
mbed_official 381:5460fc57b6e4 98 devices, you can define the device in your toolchain compiler preprocessor.
mbed_official 381:5460fc57b6e4 99 */
mbed_official 381:5460fc57b6e4 100 #if !defined (USE_HAL_DRIVER)
mbed_official 381:5460fc57b6e4 101 /**
mbed_official 381:5460fc57b6e4 102 * @brief Comment the line below if you will not use the peripherals drivers.
mbed_official 381:5460fc57b6e4 103 In this case, these drivers will not be included and the application code will
mbed_official 381:5460fc57b6e4 104 be based on direct access to peripherals registers
mbed_official 381:5460fc57b6e4 105 */
mbed_official 381:5460fc57b6e4 106 #define USE_HAL_DRIVER
mbed_official 381:5460fc57b6e4 107 #endif /* USE_HAL_DRIVER */
mbed_official 381:5460fc57b6e4 108
mbed_official 381:5460fc57b6e4 109 /**
mbed_official 381:5460fc57b6e4 110 * @brief CMSIS Device version number V2.1.0
mbed_official 381:5460fc57b6e4 111 */
mbed_official 381:5460fc57b6e4 112 #define __STM32F3xx_CMSIS_DEVICE_VERSION_MAIN (0x02) /*!< [31:24] main version */
mbed_official 381:5460fc57b6e4 113 #define __STM32F3xx_CMSIS_DEVICE_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */
mbed_official 381:5460fc57b6e4 114 #define __STM32F3xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
mbed_official 381:5460fc57b6e4 115 #define __STM32F3xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */
mbed_official 381:5460fc57b6e4 116 #define __STM32F3xx_CMSIS_DEVICE_VERSION ((__CMSIS_DEVICE_VERSION_MAIN << 24)\
mbed_official 381:5460fc57b6e4 117 |(__CMSIS_DEVICE_HAL_VERSION_SUB1 << 16)\
mbed_official 381:5460fc57b6e4 118 |(__CMSIS_DEVICE_HAL_VERSION_SUB2 << 8 )\
mbed_official 381:5460fc57b6e4 119 |(__CMSIS_DEVICE_HAL_VERSION_RC))
mbed_official 381:5460fc57b6e4 120
mbed_official 381:5460fc57b6e4 121 /**
mbed_official 381:5460fc57b6e4 122 * @}
mbed_official 381:5460fc57b6e4 123 */
mbed_official 381:5460fc57b6e4 124
mbed_official 381:5460fc57b6e4 125 /** @addtogroup Device_Included
mbed_official 381:5460fc57b6e4 126 * @{
mbed_official 381:5460fc57b6e4 127 */
mbed_official 381:5460fc57b6e4 128
mbed_official 381:5460fc57b6e4 129 #if defined(STM32F301x8)
mbed_official 381:5460fc57b6e4 130 #include "stm32f301x8.h"
mbed_official 381:5460fc57b6e4 131 #elif defined(STM32F302x8)
mbed_official 381:5460fc57b6e4 132 #include "stm32f302x8.h"
mbed_official 381:5460fc57b6e4 133 #elif defined(STM32F302xC)
mbed_official 381:5460fc57b6e4 134 #include "stm32f302xc.h"
mbed_official 381:5460fc57b6e4 135 #elif defined(STM32F302xE)
mbed_official 381:5460fc57b6e4 136 #include "stm32f302xe.h"
mbed_official 381:5460fc57b6e4 137 #elif defined(STM32F303x8)
mbed_official 381:5460fc57b6e4 138 #include "stm32f303x8.h"
mbed_official 381:5460fc57b6e4 139 #elif defined(STM32F303xC)
mbed_official 381:5460fc57b6e4 140 #include "stm32f303xc.h"
mbed_official 381:5460fc57b6e4 141 #elif defined(STM32F303xE)
mbed_official 381:5460fc57b6e4 142 #include "stm32f303xe.h"
mbed_official 381:5460fc57b6e4 143 #elif defined(STM32F373xC)
mbed_official 381:5460fc57b6e4 144 #include "stm32f373xc.h"
mbed_official 381:5460fc57b6e4 145 #elif defined(STM32F334x8)
mbed_official 381:5460fc57b6e4 146 #include "stm32f334x8.h"
mbed_official 381:5460fc57b6e4 147 #elif defined(STM32F318xx)
mbed_official 381:5460fc57b6e4 148 #include "stm32f318xx.h"
mbed_official 381:5460fc57b6e4 149 #elif defined(STM32F328xx)
mbed_official 381:5460fc57b6e4 150 #include "stm32f328xx.h"
mbed_official 381:5460fc57b6e4 151 #elif defined(STM32F358xx)
mbed_official 381:5460fc57b6e4 152 #include "stm32f358xx.h"
mbed_official 381:5460fc57b6e4 153 #elif defined(STM32F378xx)
mbed_official 381:5460fc57b6e4 154 #include "stm32f378xx.h"
mbed_official 381:5460fc57b6e4 155 #elif defined(STM32F398xx)
mbed_official 381:5460fc57b6e4 156 #include "stm32f398xx.h"
mbed_official 381:5460fc57b6e4 157 #else
mbed_official 381:5460fc57b6e4 158 #error "Please select first the target STM32F3xx device used in your application (in stm32f3xx.h file)"
mbed_official 381:5460fc57b6e4 159 #endif
mbed_official 381:5460fc57b6e4 160
mbed_official 381:5460fc57b6e4 161 /**
mbed_official 381:5460fc57b6e4 162 * @}
mbed_official 381:5460fc57b6e4 163 */
mbed_official 381:5460fc57b6e4 164
mbed_official 381:5460fc57b6e4 165 /** @addtogroup Exported_types
mbed_official 381:5460fc57b6e4 166 * @{
mbed_official 381:5460fc57b6e4 167 */
mbed_official 381:5460fc57b6e4 168 typedef enum
mbed_official 381:5460fc57b6e4 169 {
mbed_official 381:5460fc57b6e4 170 RESET = 0,
mbed_official 381:5460fc57b6e4 171 SET = !RESET
mbed_official 381:5460fc57b6e4 172 } FlagStatus, ITStatus;
mbed_official 381:5460fc57b6e4 173
mbed_official 381:5460fc57b6e4 174 typedef enum
mbed_official 381:5460fc57b6e4 175 {
mbed_official 381:5460fc57b6e4 176 DISABLE = 0,
mbed_official 381:5460fc57b6e4 177 ENABLE = !DISABLE
mbed_official 381:5460fc57b6e4 178 } FunctionalState;
mbed_official 381:5460fc57b6e4 179 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
mbed_official 381:5460fc57b6e4 180
mbed_official 381:5460fc57b6e4 181 typedef enum
mbed_official 381:5460fc57b6e4 182 {
mbed_official 381:5460fc57b6e4 183 ERROR = 0,
mbed_official 381:5460fc57b6e4 184 SUCCESS = !ERROR
mbed_official 381:5460fc57b6e4 185 } ErrorStatus;
mbed_official 381:5460fc57b6e4 186
mbed_official 381:5460fc57b6e4 187 /**
mbed_official 381:5460fc57b6e4 188 * @}
mbed_official 381:5460fc57b6e4 189 */
mbed_official 381:5460fc57b6e4 190
mbed_official 381:5460fc57b6e4 191
mbed_official 381:5460fc57b6e4 192 /** @addtogroup Exported_macros
mbed_official 381:5460fc57b6e4 193 * @{
mbed_official 381:5460fc57b6e4 194 */
mbed_official 381:5460fc57b6e4 195 #define SET_BIT(REG, BIT) ((REG) |= (BIT))
mbed_official 381:5460fc57b6e4 196
mbed_official 381:5460fc57b6e4 197 #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
mbed_official 381:5460fc57b6e4 198
mbed_official 381:5460fc57b6e4 199 #define READ_BIT(REG, BIT) ((REG) & (BIT))
mbed_official 381:5460fc57b6e4 200
mbed_official 381:5460fc57b6e4 201 #define CLEAR_REG(REG) ((REG) = (0x0))
mbed_official 381:5460fc57b6e4 202
mbed_official 381:5460fc57b6e4 203 #define WRITE_REG(REG, VAL) ((REG) = (VAL))
mbed_official 381:5460fc57b6e4 204
mbed_official 381:5460fc57b6e4 205 #define READ_REG(REG) ((REG))
mbed_official 381:5460fc57b6e4 206
mbed_official 381:5460fc57b6e4 207 #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
mbed_official 381:5460fc57b6e4 208
mbed_official 381:5460fc57b6e4 209 #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
mbed_official 381:5460fc57b6e4 210
mbed_official 381:5460fc57b6e4 211
mbed_official 381:5460fc57b6e4 212 #if defined (USE_HAL_DRIVER)
mbed_official 381:5460fc57b6e4 213 #include "stm32f3xx_hal.h"
mbed_official 381:5460fc57b6e4 214 #endif /* USE_HAL_DRIVER */
mbed_official 381:5460fc57b6e4 215
mbed_official 381:5460fc57b6e4 216
mbed_official 381:5460fc57b6e4 217 /**
mbed_official 381:5460fc57b6e4 218 * @}
mbed_official 381:5460fc57b6e4 219 */
mbed_official 381:5460fc57b6e4 220
mbed_official 381:5460fc57b6e4 221
mbed_official 381:5460fc57b6e4 222 #ifdef __cplusplus
mbed_official 381:5460fc57b6e4 223 }
mbed_official 381:5460fc57b6e4 224 #endif /* __cplusplus */
mbed_official 381:5460fc57b6e4 225
mbed_official 381:5460fc57b6e4 226 #endif /* __STM32F3xx_H */
mbed_official 381:5460fc57b6e4 227 /**
mbed_official 381:5460fc57b6e4 228 * @}
mbed_official 381:5460fc57b6e4 229 */
mbed_official 381:5460fc57b6e4 230
mbed_official 381:5460fc57b6e4 231 /**
mbed_official 381:5460fc57b6e4 232 * @}
mbed_official 381:5460fc57b6e4 233 */
mbed_official 381:5460fc57b6e4 234
mbed_official 381:5460fc57b6e4 235
mbed_official 381:5460fc57b6e4 236
mbed_official 381:5460fc57b6e4 237
mbed_official 381:5460fc57b6e4 238 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/