annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal.c @ 163:9c77cfe8c2b2 linux-build

Add Linux pack script and a README to explain a little. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Thu, 21 Feb 2019 16:56:08 +0100
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file stm32f4xx_hal.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author MCD Application Team
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 26-December-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * This is the common part of the HAL initialization
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ##### How to use this driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 The common HAL driver contains a set of generic and common APIs that can be
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 used by the PPP peripheral drivers and the user to start using the HAL.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 The HAL contains two APIs' categories:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 (+) Common HAL APIs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 (+) Services HAL APIs
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 /** @defgroup HAL HAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 * @brief HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 /** @addtogroup HAL_Private_Constants
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 * @brief STM32F4xx HAL Driver version number V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 #define __STM32F4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 #define __STM32F4xx_HAL_VERSION_SUB1 (0x02) /*!< [23:16] sub1 version */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 #define __STM32F4xx_HAL_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 #define __STM32F4xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 #define __STM32F4xx_HAL_VERSION ((__STM32F4xx_HAL_VERSION_MAIN << 24)\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 |(__STM32F4xx_HAL_VERSION_SUB1 << 16)\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 |(__STM32F4xx_HAL_VERSION_SUB2 << 8 )\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 |(__STM32F4xx_HAL_VERSION_RC))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 /* ------------ RCC registers bit address in the alias region ----------- */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 /* --- MEMRMP Register ---*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 /* Alias word address of UFB_MODE bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 #define MEMRMP_OFFSET SYSCFG_OFFSET
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 #define UFB_MODE_BIT_NUMBER POSITION_VAL(SYSCFG_MEMRMP_UFB_MODE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 #define UFB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (UFB_MODE_BIT_NUMBER * 4))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 /* --- CMPCR Register ---*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 /* Alias word address of CMP_PD bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 #define CMP_PD_BIT_NUMBER POSITION_VAL(SYSCFG_CMPCR_CMP_PD)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 #define CMPCR_CMP_PD_BB (PERIPH_BB_BASE + (CMPCR_OFFSET * 32) + (CMP_PD_BIT_NUMBER * 4))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 /** @addtogroup HAL_Private_Variables
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 static __IO uint32_t uwTick;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 /** @defgroup HAL_Exported_Functions HAL Exported Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 * @brief Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 ##### Initialization and de-initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 (+) Initializes the Flash interface the NVIC allocation and initial clock
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 configuration. It initializes the systick also when timeout is needed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 and the backup domain when enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 (+) de-Initializes common part of the HAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 (+) Configure The time base source to have 1ms time base with a dedicated
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 Tick interrupt priority.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 (++) Systick timer is used by default as source of time base, but user
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 can eventually implement his proper time base source (a general purpose
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 timer for example or other time source), keeping in mind that Time base
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 handled in milliseconds basis.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 (++) Time base configuration function (HAL_InitTick ()) is called automatically
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 at the beginning of the program after reset by HAL_Init() or at any time
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 when clock is configured, by HAL_RCC_ClockConfig().
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 (++) Source of time base is configured to generate interrupts at regular
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 time intervals. Care must be taken if HAL_Delay() is called from a
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 peripheral ISR process, the Tick interrupt line must have higher priority
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 (numerically lower) than the peripheral interrupt. Otherwise the caller
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 ISR process will be blocked.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 (++) functions affecting time base configurations are declared as __weak
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 to make override possible in case of other implementations in user file.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 * @brief This function is used to initialize the HAL Library; it must be the first
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 * instruction to be executed in the main program (before to call any other
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 * HAL function), it performs the following:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 * Configure the Flash prefetch, instruction and Data caches.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 * Configures the SysTick to generate an interrupt each 1 millisecond,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 * which is clocked by the HSI (at this stage, the clock is not yet
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 * configured and thus the system is running from the internal HSI at 16 MHz).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 * Set NVIC Group Priority to 4.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 * Calls the HAL_MspInit() callback function defined in user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 * "stm32f4xx_hal_msp.c" to do the global low level hardware initialization
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 * @note SysTick is used as time base for the HAL_Delay() function, the application
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 * need to ensure that the SysTick time base is always set to 1 millisecond
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 * to have correct HAL operation.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 HAL_StatusTypeDef HAL_Init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 /* Configure Flash prefetch, Instruction cache, Data cache */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 #if (INSTRUCTION_CACHE_ENABLE != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 __HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 #endif /* INSTRUCTION_CACHE_ENABLE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 #if (DATA_CACHE_ENABLE != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 __HAL_FLASH_DATA_CACHE_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 #endif /* DATA_CACHE_ENABLE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 #if (PREFETCH_ENABLE != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 #endif /* PREFETCH_ENABLE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 /* Set Interrupt Group Priority */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 HAL_InitTick(TICK_INT_PRIORITY);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 /* Init the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 HAL_MspInit();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 * @brief This function de-Initializes common part of the HAL and stops the systick.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 * This function is optional.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 HAL_StatusTypeDef HAL_DeInit(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 /* Reset of all peripherals */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 __HAL_RCC_APB1_FORCE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 __HAL_RCC_APB1_RELEASE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 __HAL_RCC_APB2_FORCE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 __HAL_RCC_APB2_RELEASE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 __HAL_RCC_AHB1_FORCE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 __HAL_RCC_AHB1_RELEASE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 __HAL_RCC_AHB2_FORCE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 __HAL_RCC_AHB2_RELEASE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 __HAL_RCC_AHB3_FORCE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 __HAL_RCC_AHB3_RELEASE_RESET();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 /* De-Init the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 HAL_MspDeInit();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 * @brief Initializes the MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 __weak void HAL_MspInit(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 the HAL_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 * @brief DeInitializes the MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 __weak void HAL_MspDeInit(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 the HAL_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 * @brief This function configures the source of the time base.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 * The time source is configured to have 1ms time base with a dedicated
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 * Tick interrupt priority.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 * @note This function is called automatically at the beginning of program after
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 * @note In the default implementation, SysTick timer is the source of time base.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 * It is used to generate interrupts at regular time intervals.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 * The the SysTick interrupt must have higher priority (numerically lower)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 * The function is declared as __weak to be overwritten in case of other
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 * implementation in user file.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 * @param TickPriority: Tick interrupt priority.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 /*Configure the SysTick to have interrupt in 1ms time basis*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 /*Configure the SysTick IRQ priority */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 * @brief HAL Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 ##### HAL Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 (+) Provide a tick value in millisecond
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 (+) Provide a blocking delay in millisecond
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 (+) Suspend the time base source interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 (+) Resume the time base source interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 (+) Get the HAL API driver version
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 (+) Get the device identifier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 (+) Get the device revision identifier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 (+) Enable/Disable Debug module during SLEEP mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 (+) Enable/Disable Debug module during STOP mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 (+) Enable/Disable Debug module during STANDBY mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 * @brief This function is called to increment a global variable "uwTick"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 * used as application time base.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 * @note In the default implementation, this variable is incremented each 1ms
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 * in Systick ISR.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 * @note This function is declared as __weak to be overwritten in case of other
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 * implementations in user file.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 __weak void HAL_IncTick(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 uwTick++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 * @brief Provides a tick value in millisecond.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 * @note This function is declared as __weak to be overwritten in case of other
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 * implementations in user file.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 * @retval tick value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 __weak uint32_t HAL_GetTick(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 return uwTick;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 * @brief This function provides accurate delay (in milliseconds) based
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 * on variable incremented.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 * @note In the default implementation , SysTick timer is the source of time base.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 * It is used to generate interrupts at regular time intervals where uwTick
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 * is incremented.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 * @note This function is declared as __weak to be overwritten in case of other
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 * implementations in user file.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 * @param Delay: specifies the delay time length, in milliseconds.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 __weak void HAL_Delay(__IO uint32_t Delay)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 while((HAL_GetTick() - tickstart) < Delay)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 * @brief Suspend Tick increment.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 * @note In the default implementation , SysTick timer is the source of time base. It is
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 * is called, the SysTick interrupt will be disabled and so Tick increment
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 * is suspended.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 * @note This function is declared as __weak to be overwritten in case of other
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 * implementations in user file.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 __weak void HAL_SuspendTick(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 /* Disable SysTick Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 * @brief Resume Tick increment.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 * @note In the default implementation , SysTick timer is the source of time base. It is
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 * is called, the SysTick interrupt will be enabled and so Tick increment
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 * is resumed.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 * @note This function is declared as __weak to be overwritten in case of other
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 * implementations in user file.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 __weak void HAL_ResumeTick(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 /* Enable SysTick Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 * @brief Returns the HAL revision
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 * @retval version : 0xXYZR (8bits for each decimal, R for RC)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 uint32_t HAL_GetHalVersion(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 return __STM32F4xx_HAL_VERSION;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 * @brief Returns the device revision identifier.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 * @retval Device revision identifier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 uint32_t HAL_GetREVID(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 return((DBGMCU->IDCODE) >> 16);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 * @brief Returns the device identifier.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 * @retval Device identifier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 uint32_t HAL_GetDEVID(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 * @brief Enable the Debug Module during SLEEP mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 void HAL_DBGMCU_EnableDBGSleepMode(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 * @brief Disable the Debug Module during SLEEP mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 void HAL_DBGMCU_DisableDBGSleepMode(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 * @brief Enable the Debug Module during STOP mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 void HAL_DBGMCU_EnableDBGStopMode(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 * @brief Disable the Debug Module during STOP mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 void HAL_DBGMCU_DisableDBGStopMode(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 * @brief Enable the Debug Module during STANDBY mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 void HAL_DBGMCU_EnableDBGStandbyMode(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 * @brief Disable the Debug Module during STANDBY mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 void HAL_DBGMCU_DisableDBGStandbyMode(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 * @brief Enables the I/O Compensation Cell.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 * @note The I/O compensation cell can be used only when the device supply
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 * voltage ranges from 2.4 to 3.6 V.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 void HAL_EnableCompensationCell(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 * @brief Power-down the I/O Compensation Cell.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 * @note The I/O compensation cell can be used only when the device supply
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 * voltage ranges from 2.4 to 3.6 V.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 void HAL_DisableCompensationCell(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)DISABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 * @brief Enables the Internal FLASH Bank Swapping.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 * @note This function can be used only for STM32F42xxx/43xxx devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 void HAL_EnableMemorySwappingBank(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)ENABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 * @brief Disables the Internal FLASH Bank Swapping.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 * @note This function can be used only for STM32F42xxx/43xxx devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 void HAL_DisableMemorySwappingBank(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)DISABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/