Browse Source

Version initiale : Activité 2 étape 2.3

Paul Faure 3 years ago
parent
commit
fc35ad8b62
42 changed files with 37720 additions and 253 deletions
  1. 46
    0
      Inc/stm32f1xx_it.h
  2. 3932
    0
      LLDrivers/inc/stm32f1xx_ll_adc.h
  3. 1015
    0
      LLDrivers/inc/stm32f1xx_ll_bus.h
  4. 640
    0
      LLDrivers/inc/stm32f1xx_ll_cortex.h
  5. 204
    0
      LLDrivers/inc/stm32f1xx_ll_crc.h
  6. 1326
    0
      LLDrivers/inc/stm32f1xx_ll_dac.h
  7. 1960
    0
      LLDrivers/inc/stm32f1xx_ll_dma.h
  8. 888
    0
      LLDrivers/inc/stm32f1xx_ll_exti.h
  9. 951
    0
      LLDrivers/inc/stm32f1xx_ll_fsmc.h
  10. 2345
    0
      LLDrivers/inc/stm32f1xx_ll_gpio.h
  11. 1784
    0
      LLDrivers/inc/stm32f1xx_ll_i2c.h
  12. 311
    0
      LLDrivers/inc/stm32f1xx_ll_iwdg.h
  13. 440
    0
      LLDrivers/inc/stm32f1xx_ll_pwr.h
  14. 1003
    0
      LLDrivers/inc/stm32f1xx_ll_rtc.h
  15. 1112
    0
      LLDrivers/inc/stm32f1xx_ll_sdmmc.h
  16. 1938
    0
      LLDrivers/inc/stm32f1xx_ll_spi.h
  17. 3831
    0
      LLDrivers/inc/stm32f1xx_ll_tim.h
  18. 2569
    0
      LLDrivers/inc/stm32f1xx_ll_usart.h
  19. 651
    0
      LLDrivers/inc/stm32f1xx_ll_usb.h
  20. 318
    0
      LLDrivers/inc/stm32f1xx_ll_wwdg.h
  21. 886
    0
      LLDrivers/src/stm32f1xx_ll_adc.c
  22. 108
    0
      LLDrivers/src/stm32f1xx_ll_crc.c
  23. 274
    0
      LLDrivers/src/stm32f1xx_ll_dac.c
  24. 314
    0
      LLDrivers/src/stm32f1xx_ll_dma.c
  25. 215
    0
      LLDrivers/src/stm32f1xx_ll_exti.c
  26. 985
    0
      LLDrivers/src/stm32f1xx_ll_fsmc.c
  27. 253
    0
      LLDrivers/src/stm32f1xx_ll_gpio.c
  28. 221
    0
      LLDrivers/src/stm32f1xx_ll_i2c.c
  29. 86
    0
      LLDrivers/src/stm32f1xx_ll_pwr.c
  30. 544
    0
      LLDrivers/src/stm32f1xx_ll_rtc.c
  31. 1521
    0
      LLDrivers/src/stm32f1xx_ll_sdmmc.c
  32. 530
    0
      LLDrivers/src/stm32f1xx_ll_spi.c
  33. 1198
    0
      LLDrivers/src/stm32f1xx_ll_tim.c
  34. 446
    0
      LLDrivers/src/stm32f1xx_ll_usart.c
  35. 2591
    0
      LLDrivers/src/stm32f1xx_ll_usb.c
  36. 65
    114
      MDK-ARM/Project.uvoptx
  37. 17
    13
      MDK-ARM/Project.uvprojx
  38. 153
    83
      MyDrivers/MyTimer.c
  39. 3
    4
      Services/Chrono.c
  40. 38
    0
      Services/Chrono.h
  41. 8
    36
      Src/main.c
  42. 0
    3
      readme.txt

+ 46
- 0
Inc/stm32f1xx_it.h View File

@@ -0,0 +1,46 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    Examples_LL/GPIO/GPIO_InfiniteLedToggling/Inc/stm32f1xx_it.h
4
+  * @author  MCD Application Team
5
+  * @brief   This file contains the headers of the interrupt handlers.
6
+	* !! modif : include main.h enlevé
7
+  ******************************************************************************
8
+  * @attention
9
+  *
10
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
11
+  * All rights reserved.</center></h2>
12
+  *
13
+  * This software component is licensed by ST under BSD 3-Clause license,
14
+  * the "License"; You may not use this file except in compliance with the
15
+  * License. You may obtain a copy of the License at:
16
+  *                        opensource.org/licenses/BSD-3-Clause
17
+  *
18
+  ******************************************************************************
19
+  */
20
+
21
+/* Define to prevent recursive inclusion -------------------------------------*/
22
+#ifndef __STM32F1xx_IT_H
23
+#define __STM32F1xx_IT_H
24
+
25
+#ifdef __cplusplus
26
+extern "C" {
27
+#endif
28
+
29
+
30
+void NMI_Handler(void);
31
+void HardFault_Handler(void);
32
+void MemManage_Handler(void);
33
+void BusFault_Handler(void);
34
+void UsageFault_Handler(void);
35
+void SVC_Handler(void);
36
+void DebugMon_Handler(void);
37
+void PendSV_Handler(void);
38
+void SysTick_Handler(void);
39
+
40
+#ifdef __cplusplus
41
+}
42
+#endif
43
+
44
+#endif /* __STM32F1xx_IT_H */
45
+
46
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 3932
- 0
LLDrivers/inc/stm32f1xx_ll_adc.h
File diff suppressed because it is too large
View File


+ 1015
- 0
LLDrivers/inc/stm32f1xx_ll_bus.h
File diff suppressed because it is too large
View File


+ 640
- 0
LLDrivers/inc/stm32f1xx_ll_cortex.h View File

@@ -0,0 +1,640 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_cortex.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of CORTEX LL module.
6
+  @verbatim
7
+  ==============================================================================
8
+                     ##### How to use this driver #####
9
+  ==============================================================================
10
+    [..]
11
+    The LL CORTEX driver contains a set of generic APIs that can be
12
+    used by user:
13
+      (+) SYSTICK configuration used by @ref LL_mDelay and @ref LL_Init1msTick
14
+          functions
15
+      (+) Low power mode configuration (SCB register of Cortex-MCU)
16
+      (+) MPU API to configure and enable regions
17
+          (MPU services provided only on some devices)
18
+      (+) API to access to MCU info (CPUID register)
19
+      (+) API to enable fault handler (SHCSR accesses)
20
+
21
+  @endverbatim
22
+  ******************************************************************************
23
+  * @attention
24
+  *
25
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
26
+  * All rights reserved.</center></h2>
27
+  *
28
+  * This software component is licensed by ST under BSD 3-Clause license,
29
+  * the "License"; You may not use this file except in compliance with the
30
+  * License. You may obtain a copy of the License at:
31
+  *                        opensource.org/licenses/BSD-3-Clause
32
+  *
33
+  ******************************************************************************
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_LL_CORTEX_H
38
+#define __STM32F1xx_LL_CORTEX_H
39
+
40
+#ifdef __cplusplus
41
+extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx.h"
46
+
47
+/** @addtogroup STM32F1xx_LL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @defgroup CORTEX_LL CORTEX
52
+  * @{
53
+  */
54
+
55
+/* Private types -------------------------------------------------------------*/
56
+/* Private variables ---------------------------------------------------------*/
57
+
58
+/* Private constants ---------------------------------------------------------*/
59
+
60
+/* Private macros ------------------------------------------------------------*/
61
+
62
+/* Exported types ------------------------------------------------------------*/
63
+/* Exported constants --------------------------------------------------------*/
64
+/** @defgroup CORTEX_LL_Exported_Constants CORTEX Exported Constants
65
+  * @{
66
+  */
67
+
68
+/** @defgroup CORTEX_LL_EC_CLKSOURCE_HCLK SYSTICK Clock Source
69
+  * @{
70
+  */
71
+#define LL_SYSTICK_CLKSOURCE_HCLK_DIV8     0x00000000U                 /*!< AHB clock divided by 8 selected as SysTick clock source.*/
72
+#define LL_SYSTICK_CLKSOURCE_HCLK          SysTick_CTRL_CLKSOURCE_Msk  /*!< AHB clock selected as SysTick clock source. */
73
+/**
74
+  * @}
75
+  */
76
+
77
+/** @defgroup CORTEX_LL_EC_FAULT Handler Fault type
78
+  * @{
79
+  */
80
+#define LL_HANDLER_FAULT_USG               SCB_SHCSR_USGFAULTENA_Msk              /*!< Usage fault */
81
+#define LL_HANDLER_FAULT_BUS               SCB_SHCSR_BUSFAULTENA_Msk              /*!< Bus fault */
82
+#define LL_HANDLER_FAULT_MEM               SCB_SHCSR_MEMFAULTENA_Msk              /*!< Memory management fault */
83
+/**
84
+  * @}
85
+  */
86
+
87
+#if __MPU_PRESENT
88
+
89
+/** @defgroup CORTEX_LL_EC_CTRL_HFNMI_PRIVDEF MPU Control
90
+  * @{
91
+  */
92
+#define LL_MPU_CTRL_HFNMI_PRIVDEF_NONE     0x00000000U                                       /*!< Disable NMI and privileged SW access */
93
+#define LL_MPU_CTRL_HARDFAULT_NMI          MPU_CTRL_HFNMIENA_Msk                             /*!< Enables the operation of MPU during hard fault, NMI, and FAULTMASK handlers */
94
+#define LL_MPU_CTRL_PRIVILEGED_DEFAULT     MPU_CTRL_PRIVDEFENA_Msk                           /*!< Enable privileged software access to default memory map */
95
+#define LL_MPU_CTRL_HFNMI_PRIVDEF          (MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_PRIVDEFENA_Msk) /*!< Enable NMI and privileged SW access */
96
+/**
97
+  * @}
98
+  */
99
+
100
+/** @defgroup CORTEX_LL_EC_REGION MPU Region Number
101
+  * @{
102
+  */
103
+#define LL_MPU_REGION_NUMBER0              0x00U /*!< REGION Number 0 */
104
+#define LL_MPU_REGION_NUMBER1              0x01U /*!< REGION Number 1 */
105
+#define LL_MPU_REGION_NUMBER2              0x02U /*!< REGION Number 2 */
106
+#define LL_MPU_REGION_NUMBER3              0x03U /*!< REGION Number 3 */
107
+#define LL_MPU_REGION_NUMBER4              0x04U /*!< REGION Number 4 */
108
+#define LL_MPU_REGION_NUMBER5              0x05U /*!< REGION Number 5 */
109
+#define LL_MPU_REGION_NUMBER6              0x06U /*!< REGION Number 6 */
110
+#define LL_MPU_REGION_NUMBER7              0x07U /*!< REGION Number 7 */
111
+/**
112
+  * @}
113
+  */
114
+
115
+/** @defgroup CORTEX_LL_EC_REGION_SIZE MPU Region Size
116
+  * @{
117
+  */
118
+#define LL_MPU_REGION_SIZE_32B             (0x04U << MPU_RASR_SIZE_Pos) /*!< 32B Size of the MPU protection region */
119
+#define LL_MPU_REGION_SIZE_64B             (0x05U << MPU_RASR_SIZE_Pos) /*!< 64B Size of the MPU protection region */
120
+#define LL_MPU_REGION_SIZE_128B            (0x06U << MPU_RASR_SIZE_Pos) /*!< 128B Size of the MPU protection region */
121
+#define LL_MPU_REGION_SIZE_256B            (0x07U << MPU_RASR_SIZE_Pos) /*!< 256B Size of the MPU protection region */
122
+#define LL_MPU_REGION_SIZE_512B            (0x08U << MPU_RASR_SIZE_Pos) /*!< 512B Size of the MPU protection region */
123
+#define LL_MPU_REGION_SIZE_1KB             (0x09U << MPU_RASR_SIZE_Pos) /*!< 1KB Size of the MPU protection region */
124
+#define LL_MPU_REGION_SIZE_2KB             (0x0AU << MPU_RASR_SIZE_Pos) /*!< 2KB Size of the MPU protection region */
125
+#define LL_MPU_REGION_SIZE_4KB             (0x0BU << MPU_RASR_SIZE_Pos) /*!< 4KB Size of the MPU protection region */
126
+#define LL_MPU_REGION_SIZE_8KB             (0x0CU << MPU_RASR_SIZE_Pos) /*!< 8KB Size of the MPU protection region */
127
+#define LL_MPU_REGION_SIZE_16KB            (0x0DU << MPU_RASR_SIZE_Pos) /*!< 16KB Size of the MPU protection region */
128
+#define LL_MPU_REGION_SIZE_32KB            (0x0EU << MPU_RASR_SIZE_Pos) /*!< 32KB Size of the MPU protection region */
129
+#define LL_MPU_REGION_SIZE_64KB            (0x0FU << MPU_RASR_SIZE_Pos) /*!< 64KB Size of the MPU protection region */
130
+#define LL_MPU_REGION_SIZE_128KB           (0x10U << MPU_RASR_SIZE_Pos) /*!< 128KB Size of the MPU protection region */
131
+#define LL_MPU_REGION_SIZE_256KB           (0x11U << MPU_RASR_SIZE_Pos) /*!< 256KB Size of the MPU protection region */
132
+#define LL_MPU_REGION_SIZE_512KB           (0x12U << MPU_RASR_SIZE_Pos) /*!< 512KB Size of the MPU protection region */
133
+#define LL_MPU_REGION_SIZE_1MB             (0x13U << MPU_RASR_SIZE_Pos) /*!< 1MB Size of the MPU protection region */
134
+#define LL_MPU_REGION_SIZE_2MB             (0x14U << MPU_RASR_SIZE_Pos) /*!< 2MB Size of the MPU protection region */
135
+#define LL_MPU_REGION_SIZE_4MB             (0x15U << MPU_RASR_SIZE_Pos) /*!< 4MB Size of the MPU protection region */
136
+#define LL_MPU_REGION_SIZE_8MB             (0x16U << MPU_RASR_SIZE_Pos) /*!< 8MB Size of the MPU protection region */
137
+#define LL_MPU_REGION_SIZE_16MB            (0x17U << MPU_RASR_SIZE_Pos) /*!< 16MB Size of the MPU protection region */
138
+#define LL_MPU_REGION_SIZE_32MB            (0x18U << MPU_RASR_SIZE_Pos) /*!< 32MB Size of the MPU protection region */
139
+#define LL_MPU_REGION_SIZE_64MB            (0x19U << MPU_RASR_SIZE_Pos) /*!< 64MB Size of the MPU protection region */
140
+#define LL_MPU_REGION_SIZE_128MB           (0x1AU << MPU_RASR_SIZE_Pos) /*!< 128MB Size of the MPU protection region */
141
+#define LL_MPU_REGION_SIZE_256MB           (0x1BU << MPU_RASR_SIZE_Pos) /*!< 256MB Size of the MPU protection region */
142
+#define LL_MPU_REGION_SIZE_512MB           (0x1CU << MPU_RASR_SIZE_Pos) /*!< 512MB Size of the MPU protection region */
143
+#define LL_MPU_REGION_SIZE_1GB             (0x1DU << MPU_RASR_SIZE_Pos) /*!< 1GB Size of the MPU protection region */
144
+#define LL_MPU_REGION_SIZE_2GB             (0x1EU << MPU_RASR_SIZE_Pos) /*!< 2GB Size of the MPU protection region */
145
+#define LL_MPU_REGION_SIZE_4GB             (0x1FU << MPU_RASR_SIZE_Pos) /*!< 4GB Size of the MPU protection region */
146
+/**
147
+  * @}
148
+  */
149
+
150
+/** @defgroup CORTEX_LL_EC_REGION_PRIVILEDGES MPU Region Privileges
151
+  * @{
152
+  */
153
+#define LL_MPU_REGION_NO_ACCESS            (0x00U << MPU_RASR_AP_Pos) /*!< No access*/
154
+#define LL_MPU_REGION_PRIV_RW              (0x01U << MPU_RASR_AP_Pos) /*!< RW privileged (privileged access only)*/
155
+#define LL_MPU_REGION_PRIV_RW_URO          (0x02U << MPU_RASR_AP_Pos) /*!< RW privileged - RO user (Write in a user program generates a fault) */
156
+#define LL_MPU_REGION_FULL_ACCESS          (0x03U << MPU_RASR_AP_Pos) /*!< RW privileged & user (Full access) */
157
+#define LL_MPU_REGION_PRIV_RO              (0x05U << MPU_RASR_AP_Pos) /*!< RO privileged (privileged read only)*/
158
+#define LL_MPU_REGION_PRIV_RO_URO          (0x06U << MPU_RASR_AP_Pos) /*!< RO privileged & user (read only) */
159
+/**
160
+  * @}
161
+  */
162
+
163
+/** @defgroup CORTEX_LL_EC_TEX MPU TEX Level
164
+  * @{
165
+  */
166
+#define LL_MPU_TEX_LEVEL0                  (0x00U << MPU_RASR_TEX_Pos) /*!< b000 for TEX bits */
167
+#define LL_MPU_TEX_LEVEL1                  (0x01U << MPU_RASR_TEX_Pos) /*!< b001 for TEX bits */
168
+#define LL_MPU_TEX_LEVEL2                  (0x02U << MPU_RASR_TEX_Pos) /*!< b010 for TEX bits */
169
+#define LL_MPU_TEX_LEVEL4                  (0x04U << MPU_RASR_TEX_Pos) /*!< b100 for TEX bits */
170
+/**
171
+  * @}
172
+  */
173
+
174
+/** @defgroup CORTEX_LL_EC_INSTRUCTION_ACCESS MPU Instruction Access
175
+  * @{
176
+  */
177
+#define LL_MPU_INSTRUCTION_ACCESS_ENABLE   0x00U            /*!< Instruction fetches enabled */
178
+#define LL_MPU_INSTRUCTION_ACCESS_DISABLE  MPU_RASR_XN_Msk  /*!< Instruction fetches disabled*/
179
+/**
180
+  * @}
181
+  */
182
+
183
+/** @defgroup CORTEX_LL_EC_SHAREABLE_ACCESS MPU Shareable Access
184
+  * @{
185
+  */
186
+#define LL_MPU_ACCESS_SHAREABLE            MPU_RASR_S_Msk   /*!< Shareable memory attribute */
187
+#define LL_MPU_ACCESS_NOT_SHAREABLE        0x00U            /*!< Not Shareable memory attribute */
188
+/**
189
+  * @}
190
+  */
191
+
192
+/** @defgroup CORTEX_LL_EC_CACHEABLE_ACCESS MPU Cacheable Access
193
+  * @{
194
+  */
195
+#define LL_MPU_ACCESS_CACHEABLE            MPU_RASR_C_Msk   /*!< Cacheable memory attribute */
196
+#define LL_MPU_ACCESS_NOT_CACHEABLE        0x00U            /*!< Not Cacheable memory attribute */
197
+/**
198
+  * @}
199
+  */
200
+
201
+/** @defgroup CORTEX_LL_EC_BUFFERABLE_ACCESS MPU Bufferable Access
202
+  * @{
203
+  */
204
+#define LL_MPU_ACCESS_BUFFERABLE           MPU_RASR_B_Msk   /*!< Bufferable memory attribute */
205
+#define LL_MPU_ACCESS_NOT_BUFFERABLE       0x00U            /*!< Not Bufferable memory attribute */
206
+/**
207
+  * @}
208
+  */
209
+#endif /* __MPU_PRESENT */
210
+/**
211
+  * @}
212
+  */
213
+
214
+/* Exported macro ------------------------------------------------------------*/
215
+
216
+/* Exported functions --------------------------------------------------------*/
217
+/** @defgroup CORTEX_LL_Exported_Functions CORTEX Exported Functions
218
+  * @{
219
+  */
220
+
221
+/** @defgroup CORTEX_LL_EF_SYSTICK SYSTICK
222
+  * @{
223
+  */
224
+
225
+/**
226
+  * @brief  This function checks if the Systick counter flag is active or not.
227
+  * @note   It can be used in timeout function on application side.
228
+  * @rmtoll STK_CTRL     COUNTFLAG     LL_SYSTICK_IsActiveCounterFlag
229
+  * @retval State of bit (1 or 0).
230
+  */
231
+__STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void)
232
+{
233
+  return ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk));
234
+}
235
+
236
+/**
237
+  * @brief  Configures the SysTick clock source
238
+  * @rmtoll STK_CTRL     CLKSOURCE     LL_SYSTICK_SetClkSource
239
+  * @param  Source This parameter can be one of the following values:
240
+  *         @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
241
+  *         @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
242
+  * @retval None
243
+  */
244
+__STATIC_INLINE void LL_SYSTICK_SetClkSource(uint32_t Source)
245
+{
246
+  if (Source == LL_SYSTICK_CLKSOURCE_HCLK)
247
+  {
248
+    SET_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
249
+  }
250
+  else
251
+  {
252
+    CLEAR_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
253
+  }
254
+}
255
+
256
+/**
257
+  * @brief  Get the SysTick clock source
258
+  * @rmtoll STK_CTRL     CLKSOURCE     LL_SYSTICK_GetClkSource
259
+  * @retval Returned value can be one of the following values:
260
+  *         @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
261
+  *         @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
262
+  */
263
+__STATIC_INLINE uint32_t LL_SYSTICK_GetClkSource(void)
264
+{
265
+  return READ_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
266
+}
267
+
268
+/**
269
+  * @brief  Enable SysTick exception request
270
+  * @rmtoll STK_CTRL     TICKINT       LL_SYSTICK_EnableIT
271
+  * @retval None
272
+  */
273
+__STATIC_INLINE void LL_SYSTICK_EnableIT(void)
274
+{
275
+  SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
276
+}
277
+
278
+/**
279
+  * @brief  Disable SysTick exception request
280
+  * @rmtoll STK_CTRL     TICKINT       LL_SYSTICK_DisableIT
281
+  * @retval None
282
+  */
283
+__STATIC_INLINE void LL_SYSTICK_DisableIT(void)
284
+{
285
+  CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
286
+}
287
+
288
+/**
289
+  * @brief  Checks if the SYSTICK interrupt is enabled or disabled.
290
+  * @rmtoll STK_CTRL     TICKINT       LL_SYSTICK_IsEnabledIT
291
+  * @retval State of bit (1 or 0).
292
+  */
293
+__STATIC_INLINE uint32_t LL_SYSTICK_IsEnabledIT(void)
294
+{
295
+  return (READ_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk) == (SysTick_CTRL_TICKINT_Msk));
296
+}
297
+
298
+/**
299
+  * @}
300
+  */
301
+
302
+/** @defgroup CORTEX_LL_EF_LOW_POWER_MODE LOW POWER MODE
303
+  * @{
304
+  */
305
+
306
+/**
307
+  * @brief  Processor uses sleep as its low power mode
308
+  * @rmtoll SCB_SCR      SLEEPDEEP     LL_LPM_EnableSleep
309
+  * @retval None
310
+  */
311
+__STATIC_INLINE void LL_LPM_EnableSleep(void)
312
+{
313
+  /* Clear SLEEPDEEP bit of Cortex System Control Register */
314
+  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
315
+}
316
+
317
+/**
318
+  * @brief  Processor uses deep sleep as its low power mode
319
+  * @rmtoll SCB_SCR      SLEEPDEEP     LL_LPM_EnableDeepSleep
320
+  * @retval None
321
+  */
322
+__STATIC_INLINE void LL_LPM_EnableDeepSleep(void)
323
+{
324
+  /* Set SLEEPDEEP bit of Cortex System Control Register */
325
+  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
326
+}
327
+
328
+/**
329
+  * @brief  Configures sleep-on-exit when returning from Handler mode to Thread mode.
330
+  * @note   Setting this bit to 1 enables an interrupt-driven application to avoid returning to an
331
+  *         empty main application.
332
+  * @rmtoll SCB_SCR      SLEEPONEXIT   LL_LPM_EnableSleepOnExit
333
+  * @retval None
334
+  */
335
+__STATIC_INLINE void LL_LPM_EnableSleepOnExit(void)
336
+{
337
+  /* Set SLEEPONEXIT bit of Cortex System Control Register */
338
+  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
339
+}
340
+
341
+/**
342
+  * @brief  Do not sleep when returning to Thread mode.
343
+  * @rmtoll SCB_SCR      SLEEPONEXIT   LL_LPM_DisableSleepOnExit
344
+  * @retval None
345
+  */
346
+__STATIC_INLINE void LL_LPM_DisableSleepOnExit(void)
347
+{
348
+  /* Clear SLEEPONEXIT bit of Cortex System Control Register */
349
+  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
350
+}
351
+
352
+/**
353
+  * @brief  Enabled events and all interrupts, including disabled interrupts, can wakeup the
354
+  *         processor.
355
+  * @rmtoll SCB_SCR      SEVEONPEND    LL_LPM_EnableEventOnPend
356
+  * @retval None
357
+  */
358
+__STATIC_INLINE void LL_LPM_EnableEventOnPend(void)
359
+{
360
+  /* Set SEVEONPEND bit of Cortex System Control Register */
361
+  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
362
+}
363
+
364
+/**
365
+  * @brief  Only enabled interrupts or events can wakeup the processor, disabled interrupts are
366
+  *         excluded
367
+  * @rmtoll SCB_SCR      SEVEONPEND    LL_LPM_DisableEventOnPend
368
+  * @retval None
369
+  */
370
+__STATIC_INLINE void LL_LPM_DisableEventOnPend(void)
371
+{
372
+  /* Clear SEVEONPEND bit of Cortex System Control Register */
373
+  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
374
+}
375
+
376
+/**
377
+  * @}
378
+  */
379
+
380
+/** @defgroup CORTEX_LL_EF_HANDLER HANDLER
381
+  * @{
382
+  */
383
+
384
+/**
385
+  * @brief  Enable a fault in System handler control register (SHCSR)
386
+  * @rmtoll SCB_SHCSR    MEMFAULTENA   LL_HANDLER_EnableFault
387
+  * @param  Fault This parameter can be a combination of the following values:
388
+  *         @arg @ref LL_HANDLER_FAULT_USG
389
+  *         @arg @ref LL_HANDLER_FAULT_BUS
390
+  *         @arg @ref LL_HANDLER_FAULT_MEM
391
+  * @retval None
392
+  */
393
+__STATIC_INLINE void LL_HANDLER_EnableFault(uint32_t Fault)
394
+{
395
+  /* Enable the system handler fault */
396
+  SET_BIT(SCB->SHCSR, Fault);
397
+}
398
+
399
+/**
400
+  * @brief  Disable a fault in System handler control register (SHCSR)
401
+  * @rmtoll SCB_SHCSR    MEMFAULTENA   LL_HANDLER_DisableFault
402
+  * @param  Fault This parameter can be a combination of the following values:
403
+  *         @arg @ref LL_HANDLER_FAULT_USG
404
+  *         @arg @ref LL_HANDLER_FAULT_BUS
405
+  *         @arg @ref LL_HANDLER_FAULT_MEM
406
+  * @retval None
407
+  */
408
+__STATIC_INLINE void LL_HANDLER_DisableFault(uint32_t Fault)
409
+{
410
+  /* Disable the system handler fault */
411
+  CLEAR_BIT(SCB->SHCSR, Fault);
412
+}
413
+
414
+/**
415
+  * @}
416
+  */
417
+
418
+/** @defgroup CORTEX_LL_EF_MCU_INFO MCU INFO
419
+  * @{
420
+  */
421
+
422
+/**
423
+  * @brief  Get Implementer code
424
+  * @rmtoll SCB_CPUID    IMPLEMENTER   LL_CPUID_GetImplementer
425
+  * @retval Value should be equal to 0x41 for ARM
426
+  */
427
+__STATIC_INLINE uint32_t LL_CPUID_GetImplementer(void)
428
+{
429
+  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_IMPLEMENTER_Msk) >> SCB_CPUID_IMPLEMENTER_Pos);
430
+}
431
+
432
+/**
433
+  * @brief  Get Variant number (The r value in the rnpn product revision identifier)
434
+  * @rmtoll SCB_CPUID    VARIANT       LL_CPUID_GetVariant
435
+  * @retval Value between 0 and 255 (0x1: revision 1, 0x2: revision 2)
436
+  */
437
+__STATIC_INLINE uint32_t LL_CPUID_GetVariant(void)
438
+{
439
+  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos);
440
+}
441
+
442
+/**
443
+  * @brief  Get Constant number
444
+  * @rmtoll SCB_CPUID    ARCHITECTURE  LL_CPUID_GetConstant
445
+  * @retval Value should be equal to 0xF for Cortex-M3 devices
446
+  */
447
+__STATIC_INLINE uint32_t LL_CPUID_GetConstant(void)
448
+{
449
+  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos);
450
+}
451
+
452
+/**
453
+  * @brief  Get Part number
454
+  * @rmtoll SCB_CPUID    PARTNO        LL_CPUID_GetParNo
455
+  * @retval Value should be equal to 0xC23 for Cortex-M3
456
+  */
457
+__STATIC_INLINE uint32_t LL_CPUID_GetParNo(void)
458
+{
459
+  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_PARTNO_Msk) >> SCB_CPUID_PARTNO_Pos);
460
+}
461
+
462
+/**
463
+  * @brief  Get Revision number (The p value in the rnpn product revision identifier, indicates patch release)
464
+  * @rmtoll SCB_CPUID    REVISION      LL_CPUID_GetRevision
465
+  * @retval Value between 0 and 255 (0x0: patch 0, 0x1: patch 1)
466
+  */
467
+__STATIC_INLINE uint32_t LL_CPUID_GetRevision(void)
468
+{
469
+  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos);
470
+}
471
+
472
+/**
473
+  * @}
474
+  */
475
+
476
+#if __MPU_PRESENT
477
+/** @defgroup CORTEX_LL_EF_MPU MPU
478
+  * @{
479
+  */
480
+
481
+/**
482
+  * @brief  Enable MPU with input options
483
+  * @rmtoll MPU_CTRL     ENABLE        LL_MPU_Enable
484
+  * @param  Options This parameter can be one of the following values:
485
+  *         @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF_NONE
486
+  *         @arg @ref LL_MPU_CTRL_HARDFAULT_NMI
487
+  *         @arg @ref LL_MPU_CTRL_PRIVILEGED_DEFAULT
488
+  *         @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF
489
+  * @retval None
490
+  */
491
+__STATIC_INLINE void LL_MPU_Enable(uint32_t Options)
492
+{
493
+  /* Enable the MPU*/
494
+  WRITE_REG(MPU->CTRL, (MPU_CTRL_ENABLE_Msk | Options));
495
+  /* Ensure MPU settings take effects */
496
+  __DSB();
497
+  /* Sequence instruction fetches using update settings */
498
+  __ISB();
499
+}
500
+
501
+/**
502
+  * @brief  Disable MPU
503
+  * @rmtoll MPU_CTRL     ENABLE        LL_MPU_Disable
504
+  * @retval None
505
+  */
506
+__STATIC_INLINE void LL_MPU_Disable(void)
507
+{
508
+  /* Make sure outstanding transfers are done */
509
+  __DMB();
510
+  /* Disable MPU*/
511
+  WRITE_REG(MPU->CTRL, 0U);
512
+}
513
+
514
+/**
515
+  * @brief  Check if MPU is enabled or not
516
+  * @rmtoll MPU_CTRL     ENABLE        LL_MPU_IsEnabled
517
+  * @retval State of bit (1 or 0).
518
+  */
519
+__STATIC_INLINE uint32_t LL_MPU_IsEnabled(void)
520
+{
521
+  return (READ_BIT(MPU->CTRL, MPU_CTRL_ENABLE_Msk) == (MPU_CTRL_ENABLE_Msk));
522
+}
523
+
524
+/**
525
+  * @brief  Enable a MPU region
526
+  * @rmtoll MPU_RASR     ENABLE        LL_MPU_EnableRegion
527
+  * @param  Region This parameter can be one of the following values:
528
+  *         @arg @ref LL_MPU_REGION_NUMBER0
529
+  *         @arg @ref LL_MPU_REGION_NUMBER1
530
+  *         @arg @ref LL_MPU_REGION_NUMBER2
531
+  *         @arg @ref LL_MPU_REGION_NUMBER3
532
+  *         @arg @ref LL_MPU_REGION_NUMBER4
533
+  *         @arg @ref LL_MPU_REGION_NUMBER5
534
+  *         @arg @ref LL_MPU_REGION_NUMBER6
535
+  *         @arg @ref LL_MPU_REGION_NUMBER7
536
+  * @retval None
537
+  */
538
+__STATIC_INLINE void LL_MPU_EnableRegion(uint32_t Region)
539
+{
540
+  /* Set Region number */
541
+  WRITE_REG(MPU->RNR, Region);
542
+  /* Enable the MPU region */
543
+  SET_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk);
544
+}
545
+
546
+/**
547
+  * @brief  Configure and enable a region
548
+  * @rmtoll MPU_RNR      REGION        LL_MPU_ConfigRegion\n
549
+  *         MPU_RBAR     REGION        LL_MPU_ConfigRegion\n
550
+  *         MPU_RBAR     ADDR          LL_MPU_ConfigRegion\n
551
+  *         MPU_RASR     XN            LL_MPU_ConfigRegion\n
552
+  *         MPU_RASR     AP            LL_MPU_ConfigRegion\n
553
+  *         MPU_RASR     S             LL_MPU_ConfigRegion\n
554
+  *         MPU_RASR     C             LL_MPU_ConfigRegion\n
555
+  *         MPU_RASR     B             LL_MPU_ConfigRegion\n
556
+  *         MPU_RASR     SIZE          LL_MPU_ConfigRegion
557
+  * @param  Region This parameter can be one of the following values:
558
+  *         @arg @ref LL_MPU_REGION_NUMBER0
559
+  *         @arg @ref LL_MPU_REGION_NUMBER1
560
+  *         @arg @ref LL_MPU_REGION_NUMBER2
561
+  *         @arg @ref LL_MPU_REGION_NUMBER3
562
+  *         @arg @ref LL_MPU_REGION_NUMBER4
563
+  *         @arg @ref LL_MPU_REGION_NUMBER5
564
+  *         @arg @ref LL_MPU_REGION_NUMBER6
565
+  *         @arg @ref LL_MPU_REGION_NUMBER7
566
+  * @param  Address Value of region base address
567
+  * @param  SubRegionDisable Sub-region disable value between Min_Data = 0x00 and Max_Data = 0xFF
568
+  * @param  Attributes This parameter can be a combination of the following values:
569
+  *         @arg @ref LL_MPU_REGION_SIZE_32B or @ref LL_MPU_REGION_SIZE_64B or @ref LL_MPU_REGION_SIZE_128B or @ref LL_MPU_REGION_SIZE_256B or @ref LL_MPU_REGION_SIZE_512B
570
+  *           or @ref LL_MPU_REGION_SIZE_1KB or @ref LL_MPU_REGION_SIZE_2KB or @ref LL_MPU_REGION_SIZE_4KB or @ref LL_MPU_REGION_SIZE_8KB or @ref LL_MPU_REGION_SIZE_16KB
571
+  *           or @ref LL_MPU_REGION_SIZE_32KB or @ref LL_MPU_REGION_SIZE_64KB or @ref LL_MPU_REGION_SIZE_128KB or @ref LL_MPU_REGION_SIZE_256KB or @ref LL_MPU_REGION_SIZE_512KB
572
+  *           or @ref LL_MPU_REGION_SIZE_1MB or @ref LL_MPU_REGION_SIZE_2MB or @ref LL_MPU_REGION_SIZE_4MB or @ref LL_MPU_REGION_SIZE_8MB or @ref LL_MPU_REGION_SIZE_16MB
573
+  *           or @ref LL_MPU_REGION_SIZE_32MB or @ref LL_MPU_REGION_SIZE_64MB or @ref LL_MPU_REGION_SIZE_128MB or @ref LL_MPU_REGION_SIZE_256MB or @ref LL_MPU_REGION_SIZE_512MB
574
+  *           or @ref LL_MPU_REGION_SIZE_1GB or @ref LL_MPU_REGION_SIZE_2GB or @ref LL_MPU_REGION_SIZE_4GB
575
+  *         @arg @ref LL_MPU_REGION_NO_ACCESS or @ref LL_MPU_REGION_PRIV_RW or @ref LL_MPU_REGION_PRIV_RW_URO or @ref LL_MPU_REGION_FULL_ACCESS
576
+  *           or @ref LL_MPU_REGION_PRIV_RO or @ref LL_MPU_REGION_PRIV_RO_URO
577
+  *         @arg @ref LL_MPU_TEX_LEVEL0 or @ref LL_MPU_TEX_LEVEL1 or @ref LL_MPU_TEX_LEVEL2 or @ref LL_MPU_TEX_LEVEL4
578
+  *         @arg @ref LL_MPU_INSTRUCTION_ACCESS_ENABLE or  @ref LL_MPU_INSTRUCTION_ACCESS_DISABLE
579
+  *         @arg @ref LL_MPU_ACCESS_SHAREABLE or @ref LL_MPU_ACCESS_NOT_SHAREABLE
580
+  *         @arg @ref LL_MPU_ACCESS_CACHEABLE or @ref LL_MPU_ACCESS_NOT_CACHEABLE
581
+  *         @arg @ref LL_MPU_ACCESS_BUFFERABLE or @ref LL_MPU_ACCESS_NOT_BUFFERABLE
582
+  * @retval None
583
+  */
584
+__STATIC_INLINE void LL_MPU_ConfigRegion(uint32_t Region, uint32_t SubRegionDisable, uint32_t Address, uint32_t Attributes)
585
+{
586
+  /* Set Region number */
587
+  WRITE_REG(MPU->RNR, Region);
588
+  /* Set base address */
589
+  WRITE_REG(MPU->RBAR, (Address & 0xFFFFFFE0U));
590
+  /* Configure MPU */
591
+  WRITE_REG(MPU->RASR, (MPU_RASR_ENABLE_Msk | Attributes | SubRegionDisable << MPU_RASR_SRD_Pos));
592
+}
593
+
594
+/**
595
+  * @brief  Disable a region
596
+  * @rmtoll MPU_RNR      REGION        LL_MPU_DisableRegion\n
597
+  *         MPU_RASR     ENABLE        LL_MPU_DisableRegion
598
+  * @param  Region This parameter can be one of the following values:
599
+  *         @arg @ref LL_MPU_REGION_NUMBER0
600
+  *         @arg @ref LL_MPU_REGION_NUMBER1
601
+  *         @arg @ref LL_MPU_REGION_NUMBER2
602
+  *         @arg @ref LL_MPU_REGION_NUMBER3
603
+  *         @arg @ref LL_MPU_REGION_NUMBER4
604
+  *         @arg @ref LL_MPU_REGION_NUMBER5
605
+  *         @arg @ref LL_MPU_REGION_NUMBER6
606
+  *         @arg @ref LL_MPU_REGION_NUMBER7
607
+  * @retval None
608
+  */
609
+__STATIC_INLINE void LL_MPU_DisableRegion(uint32_t Region)
610
+{
611
+  /* Set Region number */
612
+  WRITE_REG(MPU->RNR, Region);
613
+  /* Disable the MPU region */
614
+  CLEAR_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk);
615
+}
616
+
617
+/**
618
+  * @}
619
+  */
620
+
621
+#endif /* __MPU_PRESENT */
622
+/**
623
+  * @}
624
+  */
625
+
626
+/**
627
+  * @}
628
+  */
629
+
630
+/**
631
+  * @}
632
+  */
633
+
634
+#ifdef __cplusplus
635
+}
636
+#endif
637
+
638
+#endif /* __STM32F1xx_LL_CORTEX_H */
639
+
640
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 204
- 0
LLDrivers/inc/stm32f1xx_ll_crc.h View File

@@ -0,0 +1,204 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_crc.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of CRC LL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+/* Define to prevent recursive inclusion -------------------------------------*/
21
+#ifndef STM32F1xx_LL_CRC_H
22
+#define STM32F1xx_LL_CRC_H
23
+
24
+#ifdef __cplusplus
25
+extern "C" {
26
+#endif
27
+
28
+/* Includes ------------------------------------------------------------------*/
29
+#include "stm32f1xx.h"
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined(CRC)
36
+
37
+/** @defgroup CRC_LL CRC
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/* Private macros ------------------------------------------------------------*/
45
+
46
+/* Exported types ------------------------------------------------------------*/
47
+/* Exported constants --------------------------------------------------------*/
48
+/** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
49
+  * @{
50
+  */
51
+
52
+/**
53
+  * @}
54
+  */
55
+
56
+/* Exported macro ------------------------------------------------------------*/
57
+/** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
58
+  * @{
59
+  */
60
+
61
+/** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
62
+  * @{
63
+  */
64
+
65
+/**
66
+  * @brief  Write a value in CRC register
67
+  * @param  __INSTANCE__ CRC Instance
68
+  * @param  __REG__ Register to be written
69
+  * @param  __VALUE__ Value to be written in the register
70
+  * @retval None
71
+  */
72
+#define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
73
+
74
+/**
75
+  * @brief  Read a value in CRC register
76
+  * @param  __INSTANCE__ CRC Instance
77
+  * @param  __REG__ Register to be read
78
+  * @retval Register value
79
+  */
80
+#define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
81
+/**
82
+  * @}
83
+  */
84
+
85
+/**
86
+  * @}
87
+  */
88
+
89
+
90
+/* Exported functions --------------------------------------------------------*/
91
+/** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
92
+  * @{
93
+  */
94
+
95
+/** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
96
+  * @{
97
+  */
98
+
99
+/**
100
+  * @brief  Reset the CRC calculation unit.
101
+  * @note   If Programmable Initial CRC value feature
102
+  *         is available, also set the Data Register to the value stored in the
103
+  *         CRC_INIT register, otherwise, reset Data Register to its default value.
104
+  * @rmtoll CR           RESET         LL_CRC_ResetCRCCalculationUnit
105
+  * @param  CRCx CRC Instance
106
+  * @retval None
107
+  */
108
+__STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
109
+{
110
+  SET_BIT(CRCx->CR, CRC_CR_RESET);
111
+}
112
+
113
+/**
114
+  * @}
115
+  */
116
+
117
+/** @defgroup CRC_LL_EF_Data_Management Data_Management
118
+  * @{
119
+  */
120
+
121
+/**
122
+  * @brief  Write given 32-bit data to the CRC calculator
123
+  * @rmtoll DR           DR            LL_CRC_FeedData32
124
+  * @param  CRCx CRC Instance
125
+  * @param  InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
126
+  * @retval None
127
+  */
128
+__STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
129
+{
130
+  WRITE_REG(CRCx->DR, InData);
131
+}
132
+
133
+/**
134
+  * @brief  Return current CRC calculation result. 32 bits value is returned.
135
+  * @rmtoll DR           DR            LL_CRC_ReadData32
136
+  * @param  CRCx CRC Instance
137
+  * @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
138
+  */
139
+__STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
140
+{
141
+  return (uint32_t)(READ_REG(CRCx->DR));
142
+}
143
+
144
+/**
145
+  * @brief  Return data stored in the Independent Data(IDR) register.
146
+  * @note   This register can be used as a temporary storage location for one byte.
147
+  * @rmtoll IDR          IDR           LL_CRC_Read_IDR
148
+  * @param  CRCx CRC Instance
149
+  * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register).
150
+  */
151
+__STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
152
+{
153
+  return (uint32_t)(READ_REG(CRCx->IDR));
154
+}
155
+
156
+/**
157
+  * @brief  Store data in the Independent Data(IDR) register.
158
+  * @note   This register can be used as a temporary storage location for one byte.
159
+  * @rmtoll IDR          IDR           LL_CRC_Write_IDR
160
+  * @param  CRCx CRC Instance
161
+  * @param  InData value to be stored in CRC_IDR register (8-bit) between Min_Data=0 and Max_Data=0xFF
162
+  * @retval None
163
+  */
164
+__STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
165
+{
166
+  *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
167
+}
168
+/**
169
+  * @}
170
+  */
171
+
172
+#if defined(USE_FULL_LL_DRIVER)
173
+/** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
174
+  * @{
175
+  */
176
+
177
+ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
178
+
179
+/**
180
+  * @}
181
+  */
182
+#endif /* USE_FULL_LL_DRIVER */
183
+
184
+/**
185
+  * @}
186
+  */
187
+
188
+/**
189
+  * @}
190
+  */
191
+
192
+#endif /* defined(CRC) */
193
+
194
+/**
195
+  * @}
196
+  */
197
+
198
+#ifdef __cplusplus
199
+}
200
+#endif
201
+
202
+#endif /* STM32F1xx_LL_CRC_H */
203
+
204
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 1326
- 0
LLDrivers/inc/stm32f1xx_ll_dac.h
File diff suppressed because it is too large
View File


+ 1960
- 0
LLDrivers/inc/stm32f1xx_ll_dma.h
File diff suppressed because it is too large
View File


+ 888
- 0
LLDrivers/inc/stm32f1xx_ll_exti.h View File

@@ -0,0 +1,888 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_exti.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of EXTI LL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+/* Define to prevent recursive inclusion -------------------------------------*/
21
+#ifndef STM32F1xx_LL_EXTI_H
22
+#define STM32F1xx_LL_EXTI_H
23
+
24
+#ifdef __cplusplus
25
+extern "C" {
26
+#endif
27
+
28
+/* Includes ------------------------------------------------------------------*/
29
+#include "stm32f1xx.h"
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined (EXTI)
36
+
37
+/** @defgroup EXTI_LL EXTI
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/* Private Macros ------------------------------------------------------------*/
45
+#if defined(USE_FULL_LL_DRIVER)
46
+/** @defgroup EXTI_LL_Private_Macros EXTI Private Macros
47
+  * @{
48
+  */
49
+/**
50
+  * @}
51
+  */
52
+#endif /*USE_FULL_LL_DRIVER*/
53
+/* Exported types ------------------------------------------------------------*/
54
+#if defined(USE_FULL_LL_DRIVER)
55
+/** @defgroup EXTI_LL_ES_INIT EXTI Exported Init structure
56
+  * @{
57
+  */
58
+typedef struct
59
+{
60
+
61
+  uint32_t Line_0_31;           /*!< Specifies the EXTI lines to be enabled or disabled for Lines in range 0 to 31
62
+                                     This parameter can be any combination of @ref EXTI_LL_EC_LINE */
63
+
64
+  FunctionalState LineCommand;  /*!< Specifies the new state of the selected EXTI lines.
65
+                                     This parameter can be set either to ENABLE or DISABLE */
66
+
67
+  uint8_t Mode;                 /*!< Specifies the mode for the EXTI lines.
68
+                                     This parameter can be a value of @ref EXTI_LL_EC_MODE. */
69
+
70
+  uint8_t Trigger;              /*!< Specifies the trigger signal active edge for the EXTI lines.
71
+                                     This parameter can be a value of @ref EXTI_LL_EC_TRIGGER. */
72
+} LL_EXTI_InitTypeDef;
73
+
74
+/**
75
+  * @}
76
+  */
77
+#endif /*USE_FULL_LL_DRIVER*/
78
+
79
+/* Exported constants --------------------------------------------------------*/
80
+/** @defgroup EXTI_LL_Exported_Constants EXTI Exported Constants
81
+  * @{
82
+  */
83
+
84
+/** @defgroup EXTI_LL_EC_LINE LINE
85
+  * @{
86
+  */
87
+#define LL_EXTI_LINE_0                 EXTI_IMR_IM0           /*!< Extended line 0 */
88
+#define LL_EXTI_LINE_1                 EXTI_IMR_IM1           /*!< Extended line 1 */
89
+#define LL_EXTI_LINE_2                 EXTI_IMR_IM2           /*!< Extended line 2 */
90
+#define LL_EXTI_LINE_3                 EXTI_IMR_IM3           /*!< Extended line 3 */
91
+#define LL_EXTI_LINE_4                 EXTI_IMR_IM4           /*!< Extended line 4 */
92
+#define LL_EXTI_LINE_5                 EXTI_IMR_IM5           /*!< Extended line 5 */
93
+#define LL_EXTI_LINE_6                 EXTI_IMR_IM6           /*!< Extended line 6 */
94
+#define LL_EXTI_LINE_7                 EXTI_IMR_IM7           /*!< Extended line 7 */
95
+#define LL_EXTI_LINE_8                 EXTI_IMR_IM8           /*!< Extended line 8 */
96
+#define LL_EXTI_LINE_9                 EXTI_IMR_IM9           /*!< Extended line 9 */
97
+#define LL_EXTI_LINE_10                EXTI_IMR_IM10          /*!< Extended line 10 */
98
+#define LL_EXTI_LINE_11                EXTI_IMR_IM11          /*!< Extended line 11 */
99
+#define LL_EXTI_LINE_12                EXTI_IMR_IM12          /*!< Extended line 12 */
100
+#define LL_EXTI_LINE_13                EXTI_IMR_IM13          /*!< Extended line 13 */
101
+#define LL_EXTI_LINE_14                EXTI_IMR_IM14          /*!< Extended line 14 */
102
+#define LL_EXTI_LINE_15                EXTI_IMR_IM15          /*!< Extended line 15 */
103
+#if defined(EXTI_IMR_IM16)
104
+#define LL_EXTI_LINE_16                EXTI_IMR_IM16          /*!< Extended line 16 */
105
+#endif
106
+#define LL_EXTI_LINE_17                EXTI_IMR_IM17          /*!< Extended line 17 */
107
+#if defined(EXTI_IMR_IM18)
108
+#define LL_EXTI_LINE_18                EXTI_IMR_IM18          /*!< Extended line 18 */
109
+#endif
110
+#if defined(EXTI_IMR_IM19)
111
+#define LL_EXTI_LINE_19                EXTI_IMR_IM19          /*!< Extended line 19 */
112
+#endif
113
+#if defined(EXTI_IMR_IM20)
114
+#define LL_EXTI_LINE_20                EXTI_IMR_IM20          /*!< Extended line 20 */
115
+#endif
116
+#if defined(EXTI_IMR_IM21)
117
+#define LL_EXTI_LINE_21                EXTI_IMR_IM21          /*!< Extended line 21 */
118
+#endif
119
+#if defined(EXTI_IMR_IM22)
120
+#define LL_EXTI_LINE_22                EXTI_IMR_IM22          /*!< Extended line 22 */
121
+#endif
122
+#if defined(EXTI_IMR_IM23)
123
+#define LL_EXTI_LINE_23                EXTI_IMR_IM23          /*!< Extended line 23 */
124
+#endif
125
+#if defined(EXTI_IMR_IM24)
126
+#define LL_EXTI_LINE_24                EXTI_IMR_IM24          /*!< Extended line 24 */
127
+#endif
128
+#if defined(EXTI_IMR_IM25)
129
+#define LL_EXTI_LINE_25                EXTI_IMR_IM25          /*!< Extended line 25 */
130
+#endif
131
+#if defined(EXTI_IMR_IM26)
132
+#define LL_EXTI_LINE_26                EXTI_IMR_IM26          /*!< Extended line 26 */
133
+#endif
134
+#if defined(EXTI_IMR_IM27)
135
+#define LL_EXTI_LINE_27                EXTI_IMR_IM27          /*!< Extended line 27 */
136
+#endif
137
+#if defined(EXTI_IMR_IM28)
138
+#define LL_EXTI_LINE_28                EXTI_IMR_IM28          /*!< Extended line 28 */
139
+#endif
140
+#if defined(EXTI_IMR_IM29)
141
+#define LL_EXTI_LINE_29                EXTI_IMR_IM29          /*!< Extended line 29 */
142
+#endif
143
+#if defined(EXTI_IMR_IM30)
144
+#define LL_EXTI_LINE_30                EXTI_IMR_IM30          /*!< Extended line 30 */
145
+#endif
146
+#if defined(EXTI_IMR_IM31)
147
+#define LL_EXTI_LINE_31                EXTI_IMR_IM31          /*!< Extended line 31 */
148
+#endif
149
+#define LL_EXTI_LINE_ALL_0_31          EXTI_IMR_IM            /*!< All Extended line not reserved*/
150
+
151
+
152
+#define LL_EXTI_LINE_ALL               (0xFFFFFFFFU)  /*!< All Extended line */
153
+
154
+#if defined(USE_FULL_LL_DRIVER)
155
+#define LL_EXTI_LINE_NONE              (0x00000000U)  /*!< None Extended line */
156
+#endif /*USE_FULL_LL_DRIVER*/
157
+
158
+/**
159
+  * @}
160
+  */
161
+#if defined(USE_FULL_LL_DRIVER)
162
+
163
+/** @defgroup EXTI_LL_EC_MODE Mode
164
+  * @{
165
+  */
166
+#define LL_EXTI_MODE_IT                 ((uint8_t)0x00) /*!< Interrupt Mode */
167
+#define LL_EXTI_MODE_EVENT              ((uint8_t)0x01) /*!< Event Mode */
168
+#define LL_EXTI_MODE_IT_EVENT           ((uint8_t)0x02) /*!< Interrupt & Event Mode */
169
+/**
170
+  * @}
171
+  */
172
+
173
+/** @defgroup EXTI_LL_EC_TRIGGER Edge Trigger
174
+  * @{
175
+  */
176
+#define LL_EXTI_TRIGGER_NONE            ((uint8_t)0x00) /*!< No Trigger Mode */
177
+#define LL_EXTI_TRIGGER_RISING          ((uint8_t)0x01) /*!< Trigger Rising Mode */
178
+#define LL_EXTI_TRIGGER_FALLING         ((uint8_t)0x02) /*!< Trigger Falling Mode */
179
+#define LL_EXTI_TRIGGER_RISING_FALLING  ((uint8_t)0x03) /*!< Trigger Rising & Falling Mode */
180
+
181
+/**
182
+  * @}
183
+  */
184
+
185
+
186
+#endif /*USE_FULL_LL_DRIVER*/
187
+
188
+
189
+/**
190
+  * @}
191
+  */
192
+
193
+/* Exported macro ------------------------------------------------------------*/
194
+/** @defgroup EXTI_LL_Exported_Macros EXTI Exported Macros
195
+  * @{
196
+  */
197
+
198
+/** @defgroup EXTI_LL_EM_WRITE_READ Common Write and read registers Macros
199
+  * @{
200
+  */
201
+
202
+/**
203
+  * @brief  Write a value in EXTI register
204
+  * @param  __REG__ Register to be written
205
+  * @param  __VALUE__ Value to be written in the register
206
+  * @retval None
207
+  */
208
+#define LL_EXTI_WriteReg(__REG__, __VALUE__) WRITE_REG(EXTI->__REG__, (__VALUE__))
209
+
210
+/**
211
+  * @brief  Read a value in EXTI register
212
+  * @param  __REG__ Register to be read
213
+  * @retval Register value
214
+  */
215
+#define LL_EXTI_ReadReg(__REG__) READ_REG(EXTI->__REG__)
216
+/**
217
+  * @}
218
+  */
219
+
220
+
221
+/**
222
+  * @}
223
+  */
224
+
225
+
226
+
227
+/* Exported functions --------------------------------------------------------*/
228
+/** @defgroup EXTI_LL_Exported_Functions EXTI Exported Functions
229
+ * @{
230
+ */
231
+/** @defgroup EXTI_LL_EF_IT_Management IT_Management
232
+  * @{
233
+  */
234
+
235
+/**
236
+  * @brief  Enable ExtiLine Interrupt request for Lines in range 0 to 31
237
+  * @note The reset value for the direct or internal lines (see RM)
238
+  *       is set to 1 in order to enable the interrupt by default.
239
+  *       Bits are set automatically at Power on.
240
+  * @rmtoll IMR         IMx           LL_EXTI_EnableIT_0_31
241
+  * @param  ExtiLine This parameter can be one of the following values:
242
+  *         @arg @ref LL_EXTI_LINE_0
243
+  *         @arg @ref LL_EXTI_LINE_1
244
+  *         @arg @ref LL_EXTI_LINE_2
245
+  *         @arg @ref LL_EXTI_LINE_3
246
+  *         @arg @ref LL_EXTI_LINE_4
247
+  *         @arg @ref LL_EXTI_LINE_5
248
+  *         @arg @ref LL_EXTI_LINE_6
249
+  *         @arg @ref LL_EXTI_LINE_7
250
+  *         @arg @ref LL_EXTI_LINE_8
251
+  *         @arg @ref LL_EXTI_LINE_9
252
+  *         @arg @ref LL_EXTI_LINE_10
253
+  *         @arg @ref LL_EXTI_LINE_11
254
+  *         @arg @ref LL_EXTI_LINE_12
255
+  *         @arg @ref LL_EXTI_LINE_13
256
+  *         @arg @ref LL_EXTI_LINE_14
257
+  *         @arg @ref LL_EXTI_LINE_15
258
+  *         @arg @ref LL_EXTI_LINE_16
259
+  *         @arg @ref LL_EXTI_LINE_17
260
+  *         @arg @ref LL_EXTI_LINE_18
261
+  *         @arg @ref LL_EXTI_LINE_19
262
+  *         @arg @ref LL_EXTI_LINE_ALL_0_31
263
+  * @note   Please check each device line mapping for EXTI Line availability
264
+  * @retval None
265
+  */
266
+__STATIC_INLINE void LL_EXTI_EnableIT_0_31(uint32_t ExtiLine)
267
+{
268
+  SET_BIT(EXTI->IMR, ExtiLine);
269
+}
270
+
271
+/**
272
+  * @brief  Disable ExtiLine Interrupt request for Lines in range 0 to 31
273
+  * @note The reset value for the direct or internal lines (see RM)
274
+  *       is set to 1 in order to enable the interrupt by default.
275
+  *       Bits are set automatically at Power on.
276
+  * @rmtoll IMR         IMx           LL_EXTI_DisableIT_0_31
277
+  * @param  ExtiLine This parameter can be one of the following values:
278
+  *         @arg @ref LL_EXTI_LINE_0
279
+  *         @arg @ref LL_EXTI_LINE_1
280
+  *         @arg @ref LL_EXTI_LINE_2
281
+  *         @arg @ref LL_EXTI_LINE_3
282
+  *         @arg @ref LL_EXTI_LINE_4
283
+  *         @arg @ref LL_EXTI_LINE_5
284
+  *         @arg @ref LL_EXTI_LINE_6
285
+  *         @arg @ref LL_EXTI_LINE_7
286
+  *         @arg @ref LL_EXTI_LINE_8
287
+  *         @arg @ref LL_EXTI_LINE_9
288
+  *         @arg @ref LL_EXTI_LINE_10
289
+  *         @arg @ref LL_EXTI_LINE_11
290
+  *         @arg @ref LL_EXTI_LINE_12
291
+  *         @arg @ref LL_EXTI_LINE_13
292
+  *         @arg @ref LL_EXTI_LINE_14
293
+  *         @arg @ref LL_EXTI_LINE_15
294
+  *         @arg @ref LL_EXTI_LINE_16
295
+  *         @arg @ref LL_EXTI_LINE_17
296
+  *         @arg @ref LL_EXTI_LINE_18
297
+  *         @arg @ref LL_EXTI_LINE_19
298
+  *         @arg @ref LL_EXTI_LINE_ALL_0_31
299
+  * @note   Please check each device line mapping for EXTI Line availability
300
+  * @retval None
301
+  */
302
+__STATIC_INLINE void LL_EXTI_DisableIT_0_31(uint32_t ExtiLine)
303
+{
304
+  CLEAR_BIT(EXTI->IMR, ExtiLine);
305
+}
306
+
307
+
308
+/**
309
+  * @brief  Indicate if ExtiLine Interrupt request is enabled for Lines in range 0 to 31
310
+  * @note The reset value for the direct or internal lines (see RM)
311
+  *       is set to 1 in order to enable the interrupt by default.
312
+  *       Bits are set automatically at Power on.
313
+  * @rmtoll IMR         IMx           LL_EXTI_IsEnabledIT_0_31
314
+  * @param  ExtiLine This parameter can be one of the following values:
315
+  *         @arg @ref LL_EXTI_LINE_0
316
+  *         @arg @ref LL_EXTI_LINE_1
317
+  *         @arg @ref LL_EXTI_LINE_2
318
+  *         @arg @ref LL_EXTI_LINE_3
319
+  *         @arg @ref LL_EXTI_LINE_4
320
+  *         @arg @ref LL_EXTI_LINE_5
321
+  *         @arg @ref LL_EXTI_LINE_6
322
+  *         @arg @ref LL_EXTI_LINE_7
323
+  *         @arg @ref LL_EXTI_LINE_8
324
+  *         @arg @ref LL_EXTI_LINE_9
325
+  *         @arg @ref LL_EXTI_LINE_10
326
+  *         @arg @ref LL_EXTI_LINE_11
327
+  *         @arg @ref LL_EXTI_LINE_12
328
+  *         @arg @ref LL_EXTI_LINE_13
329
+  *         @arg @ref LL_EXTI_LINE_14
330
+  *         @arg @ref LL_EXTI_LINE_15
331
+  *         @arg @ref LL_EXTI_LINE_16
332
+  *         @arg @ref LL_EXTI_LINE_17
333
+  *         @arg @ref LL_EXTI_LINE_18
334
+  *         @arg @ref LL_EXTI_LINE_19
335
+  *         @arg @ref LL_EXTI_LINE_ALL_0_31
336
+  * @note   Please check each device line mapping for EXTI Line availability
337
+  * @retval State of bit (1 or 0).
338
+  */
339
+__STATIC_INLINE uint32_t LL_EXTI_IsEnabledIT_0_31(uint32_t ExtiLine)
340
+{
341
+  return (READ_BIT(EXTI->IMR, ExtiLine) == (ExtiLine));
342
+}
343
+
344
+
345
+/**
346
+  * @}
347
+  */
348
+
349
+/** @defgroup EXTI_LL_EF_Event_Management Event_Management
350
+  * @{
351
+  */
352
+
353
+/**
354
+  * @brief  Enable ExtiLine Event request for Lines in range 0 to 31
355
+  * @rmtoll EMR         EMx           LL_EXTI_EnableEvent_0_31
356
+  * @param  ExtiLine This parameter can be one of the following values:
357
+  *         @arg @ref LL_EXTI_LINE_0
358
+  *         @arg @ref LL_EXTI_LINE_1
359
+  *         @arg @ref LL_EXTI_LINE_2
360
+  *         @arg @ref LL_EXTI_LINE_3
361
+  *         @arg @ref LL_EXTI_LINE_4
362
+  *         @arg @ref LL_EXTI_LINE_5
363
+  *         @arg @ref LL_EXTI_LINE_6
364
+  *         @arg @ref LL_EXTI_LINE_7
365
+  *         @arg @ref LL_EXTI_LINE_8
366
+  *         @arg @ref LL_EXTI_LINE_9
367
+  *         @arg @ref LL_EXTI_LINE_10
368
+  *         @arg @ref LL_EXTI_LINE_11
369
+  *         @arg @ref LL_EXTI_LINE_12
370
+  *         @arg @ref LL_EXTI_LINE_13
371
+  *         @arg @ref LL_EXTI_LINE_14
372
+  *         @arg @ref LL_EXTI_LINE_15
373
+  *         @arg @ref LL_EXTI_LINE_16
374
+  *         @arg @ref LL_EXTI_LINE_17
375
+  *         @arg @ref LL_EXTI_LINE_18
376
+  *         @arg @ref LL_EXTI_LINE_19
377
+  *         @arg @ref LL_EXTI_LINE_ALL_0_31
378
+  * @note   Please check each device line mapping for EXTI Line availability
379
+  * @retval None
380
+  */
381
+__STATIC_INLINE void LL_EXTI_EnableEvent_0_31(uint32_t ExtiLine)
382
+{
383
+  SET_BIT(EXTI->EMR, ExtiLine);
384
+
385
+}
386
+
387
+
388
+/**
389
+  * @brief  Disable ExtiLine Event request for Lines in range 0 to 31
390
+  * @rmtoll EMR         EMx           LL_EXTI_DisableEvent_0_31
391
+  * @param  ExtiLine This parameter can be one of the following values:
392
+  *         @arg @ref LL_EXTI_LINE_0
393
+  *         @arg @ref LL_EXTI_LINE_1
394
+  *         @arg @ref LL_EXTI_LINE_2
395
+  *         @arg @ref LL_EXTI_LINE_3
396
+  *         @arg @ref LL_EXTI_LINE_4
397
+  *         @arg @ref LL_EXTI_LINE_5
398
+  *         @arg @ref LL_EXTI_LINE_6
399
+  *         @arg @ref LL_EXTI_LINE_7
400
+  *         @arg @ref LL_EXTI_LINE_8
401
+  *         @arg @ref LL_EXTI_LINE_9
402
+  *         @arg @ref LL_EXTI_LINE_10
403
+  *         @arg @ref LL_EXTI_LINE_11
404
+  *         @arg @ref LL_EXTI_LINE_12
405
+  *         @arg @ref LL_EXTI_LINE_13
406
+  *         @arg @ref LL_EXTI_LINE_14
407
+  *         @arg @ref LL_EXTI_LINE_15
408
+  *         @arg @ref LL_EXTI_LINE_16
409
+  *         @arg @ref LL_EXTI_LINE_17
410
+  *         @arg @ref LL_EXTI_LINE_18
411
+  *         @arg @ref LL_EXTI_LINE_19
412
+  *         @arg @ref LL_EXTI_LINE_ALL_0_31
413
+  * @note   Please check each device line mapping for EXTI Line availability
414
+  * @retval None
415
+  */
416
+__STATIC_INLINE void LL_EXTI_DisableEvent_0_31(uint32_t ExtiLine)
417
+{
418
+  CLEAR_BIT(EXTI->EMR, ExtiLine);
419
+}
420
+
421
+
422
+/**
423
+  * @brief  Indicate if ExtiLine Event request is enabled for Lines in range 0 to 31
424
+  * @rmtoll EMR         EMx           LL_EXTI_IsEnabledEvent_0_31
425
+  * @param  ExtiLine This parameter can be one of the following values:
426
+  *         @arg @ref LL_EXTI_LINE_0
427
+  *         @arg @ref LL_EXTI_LINE_1
428
+  *         @arg @ref LL_EXTI_LINE_2
429
+  *         @arg @ref LL_EXTI_LINE_3
430
+  *         @arg @ref LL_EXTI_LINE_4
431
+  *         @arg @ref LL_EXTI_LINE_5
432
+  *         @arg @ref LL_EXTI_LINE_6
433
+  *         @arg @ref LL_EXTI_LINE_7
434
+  *         @arg @ref LL_EXTI_LINE_8
435
+  *         @arg @ref LL_EXTI_LINE_9
436
+  *         @arg @ref LL_EXTI_LINE_10
437
+  *         @arg @ref LL_EXTI_LINE_11
438
+  *         @arg @ref LL_EXTI_LINE_12
439
+  *         @arg @ref LL_EXTI_LINE_13
440
+  *         @arg @ref LL_EXTI_LINE_14
441
+  *         @arg @ref LL_EXTI_LINE_15
442
+  *         @arg @ref LL_EXTI_LINE_16
443
+  *         @arg @ref LL_EXTI_LINE_17
444
+  *         @arg @ref LL_EXTI_LINE_18
445
+  *         @arg @ref LL_EXTI_LINE_19
446
+  *         @arg @ref LL_EXTI_LINE_ALL_0_31
447
+  * @note   Please check each device line mapping for EXTI Line availability
448
+  * @retval State of bit (1 or 0).
449
+  */
450
+__STATIC_INLINE uint32_t LL_EXTI_IsEnabledEvent_0_31(uint32_t ExtiLine)
451
+{
452
+  return (READ_BIT(EXTI->EMR, ExtiLine) == (ExtiLine));
453
+
454
+}
455
+
456
+
457
+/**
458
+  * @}
459
+  */
460
+
461
+/** @defgroup EXTI_LL_EF_Rising_Trigger_Management Rising_Trigger_Management
462
+  * @{
463
+  */
464
+
465
+/**
466
+  * @brief  Enable ExtiLine Rising Edge Trigger for Lines in range 0 to 31
467
+  * @note The configurable wakeup lines are edge-triggered. No glitch must be
468
+  *       generated on these lines. If a rising edge on a configurable interrupt
469
+  *       line occurs during a write operation in the EXTI_RTSR register, the
470
+  *       pending bit is not set.
471
+  *       Rising and falling edge triggers can be set for
472
+  *       the same interrupt line. In this case, both generate a trigger
473
+  *       condition.
474
+  * @rmtoll RTSR        RTx           LL_EXTI_EnableRisingTrig_0_31
475
+  * @param  ExtiLine This parameter can be a combination of the following values:
476
+  *         @arg @ref LL_EXTI_LINE_0
477
+  *         @arg @ref LL_EXTI_LINE_1
478
+  *         @arg @ref LL_EXTI_LINE_2
479
+  *         @arg @ref LL_EXTI_LINE_3
480
+  *         @arg @ref LL_EXTI_LINE_4
481
+  *         @arg @ref LL_EXTI_LINE_5
482
+  *         @arg @ref LL_EXTI_LINE_6
483
+  *         @arg @ref LL_EXTI_LINE_7
484
+  *         @arg @ref LL_EXTI_LINE_8
485
+  *         @arg @ref LL_EXTI_LINE_9
486
+  *         @arg @ref LL_EXTI_LINE_10
487
+  *         @arg @ref LL_EXTI_LINE_11
488
+  *         @arg @ref LL_EXTI_LINE_12
489
+  *         @arg @ref LL_EXTI_LINE_13
490
+  *         @arg @ref LL_EXTI_LINE_14
491
+  *         @arg @ref LL_EXTI_LINE_15
492
+  *         @arg @ref LL_EXTI_LINE_16
493
+  *         @arg @ref LL_EXTI_LINE_18
494
+  *         @arg @ref LL_EXTI_LINE_19
495
+  * @note   Please check each device line mapping for EXTI Line availability
496
+  * @retval None
497
+  */
498
+__STATIC_INLINE void LL_EXTI_EnableRisingTrig_0_31(uint32_t ExtiLine)
499
+{
500
+  SET_BIT(EXTI->RTSR, ExtiLine);
501
+
502
+}
503
+
504
+
505
+/**
506
+  * @brief  Disable ExtiLine Rising Edge Trigger for Lines in range 0 to 31
507
+  * @note The configurable wakeup lines are edge-triggered. No glitch must be
508
+  *       generated on these lines. If a rising edge on a configurable interrupt
509
+  *       line occurs during a write operation in the EXTI_RTSR register, the
510
+  *       pending bit is not set.
511
+  *       Rising and falling edge triggers can be set for
512
+  *       the same interrupt line. In this case, both generate a trigger
513
+  *       condition.
514
+  * @rmtoll RTSR        RTx           LL_EXTI_DisableRisingTrig_0_31
515
+  * @param  ExtiLine This parameter can be a combination of the following values:
516
+  *         @arg @ref LL_EXTI_LINE_0
517
+  *         @arg @ref LL_EXTI_LINE_1
518
+  *         @arg @ref LL_EXTI_LINE_2
519
+  *         @arg @ref LL_EXTI_LINE_3
520
+  *         @arg @ref LL_EXTI_LINE_4
521
+  *         @arg @ref LL_EXTI_LINE_5
522
+  *         @arg @ref LL_EXTI_LINE_6
523
+  *         @arg @ref LL_EXTI_LINE_7
524
+  *         @arg @ref LL_EXTI_LINE_8
525
+  *         @arg @ref LL_EXTI_LINE_9
526
+  *         @arg @ref LL_EXTI_LINE_10
527
+  *         @arg @ref LL_EXTI_LINE_11
528
+  *         @arg @ref LL_EXTI_LINE_12
529
+  *         @arg @ref LL_EXTI_LINE_13
530
+  *         @arg @ref LL_EXTI_LINE_14
531
+  *         @arg @ref LL_EXTI_LINE_15
532
+  *         @arg @ref LL_EXTI_LINE_16
533
+  *         @arg @ref LL_EXTI_LINE_18
534
+  *         @arg @ref LL_EXTI_LINE_19
535
+  * @note   Please check each device line mapping for EXTI Line availability
536
+  * @retval None
537
+  */
538
+__STATIC_INLINE void LL_EXTI_DisableRisingTrig_0_31(uint32_t ExtiLine)
539
+{
540
+  CLEAR_BIT(EXTI->RTSR, ExtiLine);
541
+
542
+}
543
+
544
+
545
+/**
546
+  * @brief  Check if rising edge trigger is enabled for Lines in range 0 to 31
547
+  * @rmtoll RTSR        RTx           LL_EXTI_IsEnabledRisingTrig_0_31
548
+  * @param  ExtiLine This parameter can be a combination of the following values:
549
+  *         @arg @ref LL_EXTI_LINE_0
550
+  *         @arg @ref LL_EXTI_LINE_1
551
+  *         @arg @ref LL_EXTI_LINE_2
552
+  *         @arg @ref LL_EXTI_LINE_3
553
+  *         @arg @ref LL_EXTI_LINE_4
554
+  *         @arg @ref LL_EXTI_LINE_5
555
+  *         @arg @ref LL_EXTI_LINE_6
556
+  *         @arg @ref LL_EXTI_LINE_7
557
+  *         @arg @ref LL_EXTI_LINE_8
558
+  *         @arg @ref LL_EXTI_LINE_9
559
+  *         @arg @ref LL_EXTI_LINE_10
560
+  *         @arg @ref LL_EXTI_LINE_11
561
+  *         @arg @ref LL_EXTI_LINE_12
562
+  *         @arg @ref LL_EXTI_LINE_13
563
+  *         @arg @ref LL_EXTI_LINE_14
564
+  *         @arg @ref LL_EXTI_LINE_15
565
+  *         @arg @ref LL_EXTI_LINE_16
566
+  *         @arg @ref LL_EXTI_LINE_18
567
+  *         @arg @ref LL_EXTI_LINE_19
568
+  * @note   Please check each device line mapping for EXTI Line availability
569
+  * @retval State of bit (1 or 0).
570
+  */
571
+__STATIC_INLINE uint32_t LL_EXTI_IsEnabledRisingTrig_0_31(uint32_t ExtiLine)
572
+{
573
+  return (READ_BIT(EXTI->RTSR, ExtiLine) == (ExtiLine));
574
+}
575
+
576
+
577
+/**
578
+  * @}
579
+  */
580
+
581
+/** @defgroup EXTI_LL_EF_Falling_Trigger_Management Falling_Trigger_Management
582
+  * @{
583
+  */
584
+
585
+/**
586
+  * @brief  Enable ExtiLine Falling Edge Trigger for Lines in range 0 to 31
587
+  * @note The configurable wakeup lines are edge-triggered. No glitch must be
588
+  *       generated on these lines. If a falling edge on a configurable interrupt
589
+  *       line occurs during a write operation in the EXTI_FTSR register, the
590
+  *       pending bit is not set.
591
+  *       Rising and falling edge triggers can be set for
592
+  *       the same interrupt line. In this case, both generate a trigger
593
+  *       condition.
594
+  * @rmtoll FTSR        FTx           LL_EXTI_EnableFallingTrig_0_31
595
+  * @param  ExtiLine This parameter can be a combination of the following values:
596
+  *         @arg @ref LL_EXTI_LINE_0
597
+  *         @arg @ref LL_EXTI_LINE_1
598
+  *         @arg @ref LL_EXTI_LINE_2
599
+  *         @arg @ref LL_EXTI_LINE_3
600
+  *         @arg @ref LL_EXTI_LINE_4
601
+  *         @arg @ref LL_EXTI_LINE_5
602
+  *         @arg @ref LL_EXTI_LINE_6
603
+  *         @arg @ref LL_EXTI_LINE_7
604
+  *         @arg @ref LL_EXTI_LINE_8
605
+  *         @arg @ref LL_EXTI_LINE_9
606
+  *         @arg @ref LL_EXTI_LINE_10
607
+  *         @arg @ref LL_EXTI_LINE_11
608
+  *         @arg @ref LL_EXTI_LINE_12
609
+  *         @arg @ref LL_EXTI_LINE_13
610
+  *         @arg @ref LL_EXTI_LINE_14
611
+  *         @arg @ref LL_EXTI_LINE_15
612
+  *         @arg @ref LL_EXTI_LINE_16
613
+  *         @arg @ref LL_EXTI_LINE_18
614
+  *         @arg @ref LL_EXTI_LINE_19
615
+  * @note   Please check each device line mapping for EXTI Line availability
616
+  * @retval None
617
+  */
618
+__STATIC_INLINE void LL_EXTI_EnableFallingTrig_0_31(uint32_t ExtiLine)
619
+{
620
+  SET_BIT(EXTI->FTSR, ExtiLine);
621
+}
622
+
623
+
624
+/**
625
+  * @brief  Disable ExtiLine Falling Edge Trigger for Lines in range 0 to 31
626
+  * @note The configurable wakeup lines are edge-triggered. No glitch must be
627
+  *       generated on these lines. If a Falling edge on a configurable interrupt
628
+  *       line occurs during a write operation in the EXTI_FTSR register, the
629
+  *       pending bit is not set.
630
+  *       Rising and falling edge triggers can be set for the same interrupt line.
631
+  *       In this case, both generate a trigger condition.
632
+  * @rmtoll FTSR        FTx           LL_EXTI_DisableFallingTrig_0_31
633
+  * @param  ExtiLine This parameter can be a combination of the following values:
634
+  *         @arg @ref LL_EXTI_LINE_0
635
+  *         @arg @ref LL_EXTI_LINE_1
636
+  *         @arg @ref LL_EXTI_LINE_2
637
+  *         @arg @ref LL_EXTI_LINE_3
638
+  *         @arg @ref LL_EXTI_LINE_4
639
+  *         @arg @ref LL_EXTI_LINE_5
640
+  *         @arg @ref LL_EXTI_LINE_6
641
+  *         @arg @ref LL_EXTI_LINE_7
642
+  *         @arg @ref LL_EXTI_LINE_8
643
+  *         @arg @ref LL_EXTI_LINE_9
644
+  *         @arg @ref LL_EXTI_LINE_10
645
+  *         @arg @ref LL_EXTI_LINE_11
646
+  *         @arg @ref LL_EXTI_LINE_12
647
+  *         @arg @ref LL_EXTI_LINE_13
648
+  *         @arg @ref LL_EXTI_LINE_14
649
+  *         @arg @ref LL_EXTI_LINE_15
650
+  *         @arg @ref LL_EXTI_LINE_16
651
+  *         @arg @ref LL_EXTI_LINE_18
652
+  *         @arg @ref LL_EXTI_LINE_19
653
+  * @note   Please check each device line mapping for EXTI Line availability
654
+  * @retval None
655
+  */
656
+__STATIC_INLINE void LL_EXTI_DisableFallingTrig_0_31(uint32_t ExtiLine)
657
+{
658
+  CLEAR_BIT(EXTI->FTSR, ExtiLine);
659
+}
660
+
661
+
662
+/**
663
+  * @brief  Check if falling edge trigger is enabled for Lines in range 0 to 31
664
+  * @rmtoll FTSR        FTx           LL_EXTI_IsEnabledFallingTrig_0_31
665
+  * @param  ExtiLine This parameter can be a combination of the following values:
666
+  *         @arg @ref LL_EXTI_LINE_0
667
+  *         @arg @ref LL_EXTI_LINE_1
668
+  *         @arg @ref LL_EXTI_LINE_2
669
+  *         @arg @ref LL_EXTI_LINE_3
670
+  *         @arg @ref LL_EXTI_LINE_4
671
+  *         @arg @ref LL_EXTI_LINE_5
672
+  *         @arg @ref LL_EXTI_LINE_6
673
+  *         @arg @ref LL_EXTI_LINE_7
674
+  *         @arg @ref LL_EXTI_LINE_8
675
+  *         @arg @ref LL_EXTI_LINE_9
676
+  *         @arg @ref LL_EXTI_LINE_10
677
+  *         @arg @ref LL_EXTI_LINE_11
678
+  *         @arg @ref LL_EXTI_LINE_12
679
+  *         @arg @ref LL_EXTI_LINE_13
680
+  *         @arg @ref LL_EXTI_LINE_14
681
+  *         @arg @ref LL_EXTI_LINE_15
682
+  *         @arg @ref LL_EXTI_LINE_16
683
+  *         @arg @ref LL_EXTI_LINE_18
684
+  *         @arg @ref LL_EXTI_LINE_19
685
+  * @note   Please check each device line mapping for EXTI Line availability
686
+  * @retval State of bit (1 or 0).
687
+  */
688
+__STATIC_INLINE uint32_t LL_EXTI_IsEnabledFallingTrig_0_31(uint32_t ExtiLine)
689
+{
690
+  return (READ_BIT(EXTI->FTSR, ExtiLine) == (ExtiLine));
691
+}
692
+
693
+
694
+/**
695
+  * @}
696
+  */
697
+
698
+/** @defgroup EXTI_LL_EF_Software_Interrupt_Management Software_Interrupt_Management
699
+  * @{
700
+  */
701
+
702
+/**
703
+  * @brief  Generate a software Interrupt Event for Lines in range 0 to 31
704
+  * @note If the interrupt is enabled on this line in the EXTI_IMR, writing a 1 to
705
+  *       this bit when it is at '0' sets the corresponding pending bit in EXTI_PR
706
+  *       resulting in an interrupt request generation.
707
+  *       This bit is cleared by clearing the corresponding bit in the EXTI_PR
708
+  *       register (by writing a 1 into the bit)
709
+  * @rmtoll SWIER       SWIx          LL_EXTI_GenerateSWI_0_31
710
+  * @param  ExtiLine This parameter can be a combination of the following values:
711
+  *         @arg @ref LL_EXTI_LINE_0
712
+  *         @arg @ref LL_EXTI_LINE_1
713
+  *         @arg @ref LL_EXTI_LINE_2
714
+  *         @arg @ref LL_EXTI_LINE_3
715
+  *         @arg @ref LL_EXTI_LINE_4
716
+  *         @arg @ref LL_EXTI_LINE_5
717
+  *         @arg @ref LL_EXTI_LINE_6
718
+  *         @arg @ref LL_EXTI_LINE_7
719
+  *         @arg @ref LL_EXTI_LINE_8
720
+  *         @arg @ref LL_EXTI_LINE_9
721
+  *         @arg @ref LL_EXTI_LINE_10
722
+  *         @arg @ref LL_EXTI_LINE_11
723
+  *         @arg @ref LL_EXTI_LINE_12
724
+  *         @arg @ref LL_EXTI_LINE_13
725
+  *         @arg @ref LL_EXTI_LINE_14
726
+  *         @arg @ref LL_EXTI_LINE_15
727
+  *         @arg @ref LL_EXTI_LINE_16
728
+  *         @arg @ref LL_EXTI_LINE_18
729
+  *         @arg @ref LL_EXTI_LINE_19
730
+  * @note   Please check each device line mapping for EXTI Line availability
731
+  * @retval None
732
+  */
733
+__STATIC_INLINE void LL_EXTI_GenerateSWI_0_31(uint32_t ExtiLine)
734
+{
735
+  SET_BIT(EXTI->SWIER, ExtiLine);
736
+}
737
+
738
+
739
+/**
740
+  * @}
741
+  */
742
+
743
+/** @defgroup EXTI_LL_EF_Flag_Management Flag_Management
744
+  * @{
745
+  */
746
+
747
+/**
748
+  * @brief  Check if the ExtLine Flag is set or not for Lines in range 0 to 31
749
+  * @note This bit is set when the selected edge event arrives on the interrupt
750
+  *       line. This bit is cleared by writing a 1 to the bit.
751
+  * @rmtoll PR          PIFx           LL_EXTI_IsActiveFlag_0_31
752
+  * @param  ExtiLine This parameter can be a combination of the following values:
753
+  *         @arg @ref LL_EXTI_LINE_0
754
+  *         @arg @ref LL_EXTI_LINE_1
755
+  *         @arg @ref LL_EXTI_LINE_2
756
+  *         @arg @ref LL_EXTI_LINE_3
757
+  *         @arg @ref LL_EXTI_LINE_4
758
+  *         @arg @ref LL_EXTI_LINE_5
759
+  *         @arg @ref LL_EXTI_LINE_6
760
+  *         @arg @ref LL_EXTI_LINE_7
761
+  *         @arg @ref LL_EXTI_LINE_8
762
+  *         @arg @ref LL_EXTI_LINE_9
763
+  *         @arg @ref LL_EXTI_LINE_10
764
+  *         @arg @ref LL_EXTI_LINE_11
765
+  *         @arg @ref LL_EXTI_LINE_12
766
+  *         @arg @ref LL_EXTI_LINE_13
767
+  *         @arg @ref LL_EXTI_LINE_14
768
+  *         @arg @ref LL_EXTI_LINE_15
769
+  *         @arg @ref LL_EXTI_LINE_16
770
+  *         @arg @ref LL_EXTI_LINE_18
771
+  *         @arg @ref LL_EXTI_LINE_19
772
+  * @note   Please check each device line mapping for EXTI Line availability
773
+  * @retval State of bit (1 or 0).
774
+  */
775
+__STATIC_INLINE uint32_t LL_EXTI_IsActiveFlag_0_31(uint32_t ExtiLine)
776
+{
777
+  return (READ_BIT(EXTI->PR, ExtiLine) == (ExtiLine));
778
+}
779
+
780
+
781
+/**
782
+  * @brief  Read ExtLine Combination Flag for Lines in range 0 to 31
783
+  * @note This bit is set when the selected edge event arrives on the interrupt
784
+  *       line. This bit is cleared by writing a 1 to the bit.
785
+  * @rmtoll PR          PIFx           LL_EXTI_ReadFlag_0_31
786
+  * @param  ExtiLine This parameter can be a combination of the following values:
787
+  *         @arg @ref LL_EXTI_LINE_0
788
+  *         @arg @ref LL_EXTI_LINE_1
789
+  *         @arg @ref LL_EXTI_LINE_2
790
+  *         @arg @ref LL_EXTI_LINE_3
791
+  *         @arg @ref LL_EXTI_LINE_4
792
+  *         @arg @ref LL_EXTI_LINE_5
793
+  *         @arg @ref LL_EXTI_LINE_6
794
+  *         @arg @ref LL_EXTI_LINE_7
795
+  *         @arg @ref LL_EXTI_LINE_8
796
+  *         @arg @ref LL_EXTI_LINE_9
797
+  *         @arg @ref LL_EXTI_LINE_10
798
+  *         @arg @ref LL_EXTI_LINE_11
799
+  *         @arg @ref LL_EXTI_LINE_12
800
+  *         @arg @ref LL_EXTI_LINE_13
801
+  *         @arg @ref LL_EXTI_LINE_14
802
+  *         @arg @ref LL_EXTI_LINE_15
803
+  *         @arg @ref LL_EXTI_LINE_16
804
+  *         @arg @ref LL_EXTI_LINE_18
805
+  *         @arg @ref LL_EXTI_LINE_19
806
+  * @note   Please check each device line mapping for EXTI Line availability
807
+  * @retval @note This bit is set when the selected edge event arrives on the interrupt
808
+  */
809
+__STATIC_INLINE uint32_t LL_EXTI_ReadFlag_0_31(uint32_t ExtiLine)
810
+{
811
+  return (uint32_t)(READ_BIT(EXTI->PR, ExtiLine));
812
+}
813
+
814
+
815
+/**
816
+  * @brief  Clear ExtLine Flags  for Lines in range 0 to 31
817
+  * @note This bit is set when the selected edge event arrives on the interrupt
818
+  *       line. This bit is cleared by writing a 1 to the bit.
819
+  * @rmtoll PR          PIFx           LL_EXTI_ClearFlag_0_31
820
+  * @param  ExtiLine This parameter can be a combination of the following values:
821
+  *         @arg @ref LL_EXTI_LINE_0
822
+  *         @arg @ref LL_EXTI_LINE_1
823
+  *         @arg @ref LL_EXTI_LINE_2
824
+  *         @arg @ref LL_EXTI_LINE_3
825
+  *         @arg @ref LL_EXTI_LINE_4
826
+  *         @arg @ref LL_EXTI_LINE_5
827
+  *         @arg @ref LL_EXTI_LINE_6
828
+  *         @arg @ref LL_EXTI_LINE_7
829
+  *         @arg @ref LL_EXTI_LINE_8
830
+  *         @arg @ref LL_EXTI_LINE_9
831
+  *         @arg @ref LL_EXTI_LINE_10
832
+  *         @arg @ref LL_EXTI_LINE_11
833
+  *         @arg @ref LL_EXTI_LINE_12
834
+  *         @arg @ref LL_EXTI_LINE_13
835
+  *         @arg @ref LL_EXTI_LINE_14
836
+  *         @arg @ref LL_EXTI_LINE_15
837
+  *         @arg @ref LL_EXTI_LINE_16
838
+  *         @arg @ref LL_EXTI_LINE_18
839
+  *         @arg @ref LL_EXTI_LINE_19
840
+  * @note   Please check each device line mapping for EXTI Line availability
841
+  * @retval None
842
+  */
843
+__STATIC_INLINE void LL_EXTI_ClearFlag_0_31(uint32_t ExtiLine)
844
+{
845
+  WRITE_REG(EXTI->PR, ExtiLine);
846
+}
847
+
848
+
849
+/**
850
+  * @}
851
+  */
852
+
853
+#if defined(USE_FULL_LL_DRIVER)
854
+/** @defgroup EXTI_LL_EF_Init Initialization and de-initialization functions
855
+  * @{
856
+  */
857
+
858
+uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct);
859
+uint32_t LL_EXTI_DeInit(void);
860
+void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct);
861
+
862
+
863
+/**
864
+  * @}
865
+  */
866
+#endif /* USE_FULL_LL_DRIVER */
867
+
868
+/**
869
+  * @}
870
+  */
871
+
872
+/**
873
+  * @}
874
+  */
875
+
876
+#endif /* EXTI */
877
+
878
+/**
879
+  * @}
880
+  */
881
+
882
+#ifdef __cplusplus
883
+}
884
+#endif
885
+
886
+#endif /* STM32F1xx_LL_EXTI_H */
887
+
888
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 951
- 0
LLDrivers/inc/stm32f1xx_ll_fsmc.h View File

@@ -0,0 +1,951 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_fsmc.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of FSMC HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                       opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+/* Define to prevent recursive inclusion -------------------------------------*/
21
+#ifndef STM32F1xx_LL_FSMC_H
22
+#define STM32F1xx_LL_FSMC_H
23
+
24
+#ifdef __cplusplus
25
+extern "C" {
26
+#endif
27
+
28
+/* Includes ------------------------------------------------------------------*/
29
+#include "stm32f1xx_hal_def.h"
30
+
31
+/** @addtogroup STM32F1xx_HAL_Driver
32
+  * @{
33
+  */
34
+
35
+/** @addtogroup FSMC_LL
36
+  * @{
37
+  */
38
+
39
+/** @addtogroup FSMC_LL_Private_Macros
40
+  * @{
41
+  */
42
+#if defined FSMC_BANK1
43
+
44
+#define IS_FSMC_NORSRAM_BANK(__BANK__) (((__BANK__) == FSMC_NORSRAM_BANK1) || \
45
+                                       ((__BANK__) == FSMC_NORSRAM_BANK2) || \
46
+                                       ((__BANK__) == FSMC_NORSRAM_BANK3) || \
47
+                                       ((__BANK__) == FSMC_NORSRAM_BANK4))
48
+#define IS_FSMC_MUX(__MUX__) (((__MUX__) == FSMC_DATA_ADDRESS_MUX_DISABLE) || \
49
+                             ((__MUX__) == FSMC_DATA_ADDRESS_MUX_ENABLE))
50
+#define IS_FSMC_MEMORY(__MEMORY__) (((__MEMORY__) == FSMC_MEMORY_TYPE_SRAM) || \
51
+                                   ((__MEMORY__) == FSMC_MEMORY_TYPE_PSRAM)|| \
52
+                                   ((__MEMORY__) == FSMC_MEMORY_TYPE_NOR))
53
+#define IS_FSMC_NORSRAM_MEMORY_WIDTH(__WIDTH__) (((__WIDTH__) == FSMC_NORSRAM_MEM_BUS_WIDTH_8)  || \
54
+                                                ((__WIDTH__) == FSMC_NORSRAM_MEM_BUS_WIDTH_16) || \
55
+                                                ((__WIDTH__) == FSMC_NORSRAM_MEM_BUS_WIDTH_32))
56
+#define IS_FSMC_PAGESIZE(__SIZE__) (((__SIZE__) == FSMC_PAGE_SIZE_NONE) || \
57
+                                   ((__SIZE__) == FSMC_PAGE_SIZE_128) || \
58
+                                   ((__SIZE__) == FSMC_PAGE_SIZE_256) || \
59
+                                   ((__SIZE__) == FSMC_PAGE_SIZE_512) || \
60
+                                   ((__SIZE__) == FSMC_PAGE_SIZE_1024))
61
+#define IS_FSMC_ACCESS_MODE(__MODE__) (((__MODE__) == FSMC_ACCESS_MODE_A) || \
62
+                                      ((__MODE__) == FSMC_ACCESS_MODE_B) || \
63
+                                      ((__MODE__) == FSMC_ACCESS_MODE_C) || \
64
+                                      ((__MODE__) == FSMC_ACCESS_MODE_D))
65
+#define IS_FSMC_BURSTMODE(__STATE__) (((__STATE__) == FSMC_BURST_ACCESS_MODE_DISABLE) || \
66
+                                     ((__STATE__) == FSMC_BURST_ACCESS_MODE_ENABLE))
67
+#define IS_FSMC_WAIT_POLARITY(__POLARITY__) (((__POLARITY__) == FSMC_WAIT_SIGNAL_POLARITY_LOW) || \
68
+                                            ((__POLARITY__) == FSMC_WAIT_SIGNAL_POLARITY_HIGH))
69
+#define IS_FSMC_WRAP_MODE(__MODE__) (((__MODE__) == FSMC_WRAP_MODE_DISABLE) || \
70
+                                     ((__MODE__) == FSMC_WRAP_MODE_ENABLE))     
71
+#define IS_FSMC_WAIT_SIGNAL_ACTIVE(__ACTIVE__) (((__ACTIVE__) == FSMC_WAIT_TIMING_BEFORE_WS) || \
72
+                                               ((__ACTIVE__) == FSMC_WAIT_TIMING_DURING_WS))
73
+#define IS_FSMC_WRITE_OPERATION(__OPERATION__) (((__OPERATION__) == FSMC_WRITE_OPERATION_DISABLE) || \
74
+                                               ((__OPERATION__) == FSMC_WRITE_OPERATION_ENABLE))
75
+#define IS_FSMC_WAITE_SIGNAL(__SIGNAL__) (((__SIGNAL__) == FSMC_WAIT_SIGNAL_DISABLE) || \
76
+                                         ((__SIGNAL__) == FSMC_WAIT_SIGNAL_ENABLE))
77
+#define IS_FSMC_EXTENDED_MODE(__MODE__) (((__MODE__) == FSMC_EXTENDED_MODE_DISABLE) || \
78
+                                        ((__MODE__) == FSMC_EXTENDED_MODE_ENABLE))
79
+#define IS_FSMC_ASYNWAIT(__STATE__) (((__STATE__) == FSMC_ASYNCHRONOUS_WAIT_DISABLE) || \
80
+                                    ((__STATE__) == FSMC_ASYNCHRONOUS_WAIT_ENABLE))
81
+#define IS_FSMC_DATA_LATENCY(__LATENCY__) (((__LATENCY__) > 1U) && ((__LATENCY__) <= 17U))
82
+#define IS_FSMC_WRITE_BURST(__BURST__) (((__BURST__) == FSMC_WRITE_BURST_DISABLE) || \
83
+                                       ((__BURST__) == FSMC_WRITE_BURST_ENABLE))
84
+#define IS_FSMC_CONTINOUS_CLOCK(__CCLOCK__) (((__CCLOCK__) == FSMC_CONTINUOUS_CLOCK_SYNC_ONLY) || \
85
+                                            ((__CCLOCK__) == FSMC_CONTINUOUS_CLOCK_SYNC_ASYNC))
86
+#define IS_FSMC_ADDRESS_SETUP_TIME(__TIME__) ((__TIME__) <= 15U)
87
+#define IS_FSMC_ADDRESS_HOLD_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 15U))
88
+#define IS_FSMC_DATASETUP_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 255U))
89
+#define IS_FSMC_DATAHOLD_DURATION(__DATAHOLD__) ((__DATAHOLD__) <= 3U)
90
+#define IS_FSMC_TURNAROUND_TIME(__TIME__) ((__TIME__) <= 15U)
91
+#define IS_FSMC_CLK_DIV(__DIV__) (((__DIV__) > 1U) && ((__DIV__) <= 16U))
92
+#define IS_FSMC_NORSRAM_DEVICE(__INSTANCE__) ((__INSTANCE__) == FSMC_NORSRAM_DEVICE)
93
+#define IS_FSMC_NORSRAM_EXTENDED_DEVICE(__INSTANCE__) ((__INSTANCE__) == FSMC_NORSRAM_EXTENDED_DEVICE)
94
+
95
+#endif /* FSMC_BANK1 */
96
+#if defined(FSMC_BANK3)
97
+
98
+#define IS_FSMC_NAND_BANK(__BANK__) ((__BANK__) == FSMC_NAND_BANK3)
99
+#define IS_FSMC_WAIT_FEATURE(__FEATURE__) (((__FEATURE__) == FSMC_NAND_PCC_WAIT_FEATURE_DISABLE) || \
100
+                                          ((__FEATURE__) == FSMC_NAND_PCC_WAIT_FEATURE_ENABLE))
101
+#define IS_FSMC_NAND_MEMORY_WIDTH(__WIDTH__) (((__WIDTH__) == FSMC_NAND_PCC_MEM_BUS_WIDTH_8) || \
102
+                                             ((__WIDTH__) == FSMC_NAND_PCC_MEM_BUS_WIDTH_16))
103
+#define IS_FSMC_ECC_STATE(__STATE__) (((__STATE__) == FSMC_NAND_ECC_DISABLE) || \
104
+                                     ((__STATE__) == FSMC_NAND_ECC_ENABLE))
105
+
106
+#define IS_FSMC_ECCPAGE_SIZE(__SIZE__) (((__SIZE__) == FSMC_NAND_ECC_PAGE_SIZE_256BYTE)  || \
107
+                                       ((__SIZE__) == FSMC_NAND_ECC_PAGE_SIZE_512BYTE)  || \
108
+                                       ((__SIZE__) == FSMC_NAND_ECC_PAGE_SIZE_1024BYTE) || \
109
+                                       ((__SIZE__) == FSMC_NAND_ECC_PAGE_SIZE_2048BYTE) || \
110
+                                       ((__SIZE__) == FSMC_NAND_ECC_PAGE_SIZE_4096BYTE) || \
111
+                                       ((__SIZE__) == FSMC_NAND_ECC_PAGE_SIZE_8192BYTE))
112
+#define IS_FSMC_TCLR_TIME(__TIME__) ((__TIME__) <= 255U)
113
+#define IS_FSMC_TAR_TIME(__TIME__) ((__TIME__) <= 255U)
114
+#define IS_FSMC_SETUP_TIME(__TIME__) ((__TIME__) <= 254U)
115
+#define IS_FSMC_WAIT_TIME(__TIME__) ((__TIME__) <= 254U)
116
+#define IS_FSMC_HOLD_TIME(__TIME__) ((__TIME__) <= 254U)
117
+#define IS_FSMC_HIZ_TIME(__TIME__) ((__TIME__) <= 254U)
118
+#define IS_FSMC_NAND_DEVICE(__INSTANCE__) ((__INSTANCE__) == FSMC_NAND_DEVICE)
119
+
120
+#endif /* FSMC_BANK3 */
121
+#if defined(FSMC_BANK4)
122
+#define IS_FSMC_PCCARD_DEVICE(__INSTANCE__) ((__INSTANCE__) == FSMC_PCCARD_DEVICE)
123
+
124
+#endif /* FSMC_BANK4 */
125
+
126
+/**
127
+  * @}
128
+  */
129
+
130
+/* Exported typedef ----------------------------------------------------------*/
131
+
132
+/** @defgroup FSMC_LL_Exported_typedef FSMC Low Layer Exported Types
133
+  * @{
134
+  */
135
+
136
+#if defined FSMC_BANK1
137
+#define FSMC_NORSRAM_TypeDef            FSMC_Bank1_TypeDef
138
+#define FSMC_NORSRAM_EXTENDED_TypeDef   FSMC_Bank1E_TypeDef
139
+#endif /* FSMC_BANK1 */
140
+#if defined(FSMC_BANK3)
141
+#define FSMC_NAND_TypeDef               FSMC_Bank2_3_TypeDef
142
+#endif /* FSMC_BANK3 */
143
+#if defined(FSMC_BANK4)
144
+#define FSMC_PCCARD_TypeDef             FSMC_Bank4_TypeDef
145
+#endif /* FSMC_BANK4 */
146
+
147
+#if defined FSMC_BANK1
148
+#define FSMC_NORSRAM_DEVICE             FSMC_Bank1
149
+#define FSMC_NORSRAM_EXTENDED_DEVICE    FSMC_Bank1E
150
+#endif /* FSMC_BANK1 */
151
+#if defined(FSMC_BANK3)
152
+#define FSMC_NAND_DEVICE                FSMC_Bank2_3
153
+#endif /* FSMC_BANK3 */
154
+#if defined(FSMC_BANK4)
155
+#define FSMC_PCCARD_DEVICE              FSMC_Bank4
156
+#endif /* FSMC_BANK4 */
157
+
158
+#if defined FSMC_BANK1
159
+/**
160
+  * @brief  FSMC NORSRAM Configuration Structure definition
161
+  */
162
+typedef struct
163
+{
164
+  uint32_t NSBank;                       /*!< Specifies the NORSRAM memory device that will be used.
165
+                                              This parameter can be a value of @ref FSMC_NORSRAM_Bank                     */
166
+
167
+  uint32_t DataAddressMux;               /*!< Specifies whether the address and data values are
168
+                                              multiplexed on the data bus or not.
169
+                                              This parameter can be a value of @ref FSMC_Data_Address_Bus_Multiplexing    */
170
+
171
+  uint32_t MemoryType;                   /*!< Specifies the type of external memory attached to
172
+                                              the corresponding memory device.
173
+                                              This parameter can be a value of @ref FSMC_Memory_Type                      */
174
+
175
+  uint32_t MemoryDataWidth;              /*!< Specifies the external memory device width.
176
+                                              This parameter can be a value of @ref FSMC_NORSRAM_Data_Width               */
177
+
178
+  uint32_t BurstAccessMode;              /*!< Enables or disables the burst access mode for Flash memory,
179
+                                              valid only with synchronous burst Flash memories.
180
+                                              This parameter can be a value of @ref FSMC_Burst_Access_Mode                */
181
+
182
+  uint32_t WaitSignalPolarity;           /*!< Specifies the wait signal polarity, valid only when accessing
183
+                                              the Flash memory in burst mode.
184
+                                              This parameter can be a value of @ref FSMC_Wait_Signal_Polarity             */
185
+
186
+  uint32_t WrapMode;                     /*!< Enables or disables the Wrapped burst access mode for Flash
187
+                                              memory, valid only when accessing Flash memories in burst mode.
188
+                                              This parameter can be a value of @ref FSMC_Wrap_Mode                        */
189
+
190
+  uint32_t WaitSignalActive;             /*!< Specifies if the wait signal is asserted by the memory one
191
+                                              clock cycle before the wait state or during the wait state,
192
+                                              valid only when accessing memories in burst mode.
193
+                                              This parameter can be a value of @ref FSMC_Wait_Timing                      */
194
+
195
+  uint32_t WriteOperation;               /*!< Enables or disables the write operation in the selected device by the FSMC.
196
+                                              This parameter can be a value of @ref FSMC_Write_Operation                  */
197
+
198
+  uint32_t WaitSignal;                   /*!< Enables or disables the wait state insertion via wait
199
+                                              signal, valid for Flash memory access in burst mode.
200
+                                              This parameter can be a value of @ref FSMC_Wait_Signal                      */
201
+
202
+  uint32_t ExtendedMode;                 /*!< Enables or disables the extended mode.
203
+                                              This parameter can be a value of @ref FSMC_Extended_Mode                    */
204
+
205
+  uint32_t AsynchronousWait;             /*!< Enables or disables wait signal during asynchronous transfers,
206
+                                              valid only with asynchronous Flash memories.
207
+                                              This parameter can be a value of @ref FSMC_AsynchronousWait                 */
208
+
209
+  uint32_t WriteBurst;                   /*!< Enables or disables the write burst operation.
210
+                                              This parameter can be a value of @ref FSMC_Write_Burst                      */
211
+
212
+
213
+  uint32_t PageSize;                     /*!< Specifies the memory page size.
214
+                                              This parameter can be a value of @ref FSMC_Page_Size                        */
215
+}FSMC_NORSRAM_InitTypeDef;
216
+
217
+/**
218
+  * @brief  FSMC NORSRAM Timing parameters structure definition
219
+  */
220
+typedef struct
221
+{
222
+  uint32_t AddressSetupTime;             /*!< Defines the number of HCLK cycles to configure
223
+                                              the duration of the address setup time.
224
+                                              This parameter can be a value between Min_Data = 0 and Max_Data = 15.
225
+                                              @note This parameter is not used with synchronous NOR Flash memories.      */
226
+
227
+  uint32_t AddressHoldTime;              /*!< Defines the number of HCLK cycles to configure
228
+                                              the duration of the address hold time.
229
+                                              This parameter can be a value between Min_Data = 1 and Max_Data = 15.
230
+                                              @note This parameter is not used with synchronous NOR Flash memories.      */
231
+
232
+  uint32_t DataSetupTime;                /*!< Defines the number of HCLK cycles to configure
233
+                                              the duration of the data setup time.
234
+                                              This parameter can be a value between Min_Data = 1 and Max_Data = 255.
235
+                                              @note This parameter is used for SRAMs, ROMs and asynchronous multiplexed
236
+                                              NOR Flash memories.                                                        */
237
+
238
+  uint32_t BusTurnAroundDuration;        /*!< Defines the number of HCLK cycles to configure
239
+                                              the duration of the bus turnaround.
240
+                                              This parameter can be a value between Min_Data = 0 and Max_Data = 15.
241
+                                              @note This parameter is only used for multiplexed NOR Flash memories.      */
242
+
243
+  uint32_t CLKDivision;                  /*!< Defines the period of CLK clock output signal, expressed in number of
244
+                                              HCLK cycles. This parameter can be a value between Min_Data = 2 and Max_Data = 16.
245
+                                              @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM
246
+                                              accesses.                                                                  */
247
+
248
+  uint32_t DataLatency;                  /*!< Defines the number of memory clock cycles to issue
249
+                                              to the memory before getting the first data.
250
+                                              The parameter value depends on the memory type as shown below:
251
+                                              - It must be set to 0 in case of a CRAM
252
+                                              - It is don't care in asynchronous NOR, SRAM or ROM accesses
253
+                                              - It may assume a value between Min_Data = 2 and Max_Data = 17 in NOR Flash memories
254
+                                                with synchronous burst mode enable                                       */
255
+
256
+  uint32_t AccessMode;                   /*!< Specifies the asynchronous access mode.
257
+                                              This parameter can be a value of @ref FSMC_Access_Mode                      */
258
+}FSMC_NORSRAM_TimingTypeDef;
259
+#endif /* FSMC_BANK1 */
260
+
261
+#if defined(FSMC_BANK3)
262
+/**
263
+  * @brief  FSMC NAND Configuration Structure definition
264
+  */
265
+typedef struct
266
+{
267
+  uint32_t NandBank;               /*!< Specifies the NAND memory device that will be used.
268
+                                        This parameter can be a value of @ref FSMC_NAND_Bank                    */
269
+
270
+  uint32_t Waitfeature;            /*!< Enables or disables the Wait feature for the NAND Memory device.
271
+                                        This parameter can be any value of @ref FSMC_Wait_feature               */
272
+
273
+  uint32_t MemoryDataWidth;        /*!< Specifies the external memory device width.
274
+                                        This parameter can be any value of @ref FSMC_NAND_Data_Width            */
275
+
276
+  uint32_t EccComputation;         /*!< Enables or disables the ECC computation.
277
+                                        This parameter can be any value of @ref FSMC_ECC                        */
278
+
279
+  uint32_t ECCPageSize;            /*!< Defines the page size for the extended ECC.
280
+                                        This parameter can be any value of @ref FSMC_ECC_Page_Size              */
281
+
282
+  uint32_t TCLRSetupTime;          /*!< Defines the number of HCLK cycles to configure the
283
+                                        delay between CLE low and RE low.
284
+                                        This parameter can be a value between Min_Data = 0 and Max_Data = 255  */
285
+
286
+  uint32_t TARSetupTime;           /*!< Defines the number of HCLK cycles to configure the
287
+                                        delay between ALE low and RE low.
288
+                                        This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
289
+}FSMC_NAND_InitTypeDef;
290
+#endif
291
+
292
+#if defined(FSMC_BANK3)||defined(FSMC_BANK4)
293
+/**
294
+  * @brief  FSMC NAND Timing parameters structure definition
295
+  */
296
+typedef struct
297
+{
298
+  uint32_t SetupTime;            /*!< Defines the number of HCLK cycles to setup address before
299
+                                      the command assertion for NAND-Flash read or write access
300
+                                      to common/Attribute or I/O memory space (depending on
301
+                                      the memory space timing to be configured).
302
+                                      This parameter can be a value between Min_Data = 0 and Max_Data = 254    */
303
+
304
+  uint32_t WaitSetupTime;        /*!< Defines the minimum number of HCLK cycles to assert the
305
+                                      command for NAND-Flash read or write access to
306
+                                      common/Attribute or I/O memory space (depending on the
307
+                                      memory space timing to be configured).
308
+                                      This parameter can be a number between Min_Data = 0 and Max_Data = 254   */
309
+
310
+  uint32_t HoldSetupTime;        /*!< Defines the number of HCLK clock cycles to hold address
311
+                                      (and data for write access) after the command de-assertion
312
+                                      for NAND-Flash read or write access to common/Attribute
313
+                                      or I/O memory space (depending on the memory space timing
314
+                                      to be configured).
315
+                                      This parameter can be a number between Min_Data = 0 and Max_Data = 254   */
316
+
317
+  uint32_t HiZSetupTime;         /*!< Defines the number of HCLK clock cycles during which the
318
+                                      data bus is kept in HiZ after the start of a NAND-Flash
319
+                                      write access to common/Attribute or I/O memory space (depending
320
+                                      on the memory space timing to be configured).
321
+                                      This parameter can be a number between Min_Data = 0 and Max_Data = 254   */
322
+}FSMC_NAND_PCC_TimingTypeDef;
323
+#endif /* FSMC_BANK3 */
324
+
325
+#if defined(FSMC_BANK4)
326
+/** 
327
+  * @brief FSMC PCCARD Configuration Structure definition
328
+  */ 
329
+typedef struct
330
+{
331
+  uint32_t Waitfeature;            /*!< Enables or disables the Wait feature for the PCCARD Memory device.
332
+                                        This parameter can be any value of @ref FSMC_Wait_feature      */
333
+
334
+  uint32_t TCLRSetupTime;          /*!< Defines the number of HCLK cycles to configure the
335
+                                        delay between CLE low and RE low.
336
+                                        This parameter can be a value between Min_Data = 0 and Max_Data = 255  */
337
+
338
+  uint32_t TARSetupTime;           /*!< Defines the number of HCLK cycles to configure the
339
+                                        delay between ALE low and RE low.
340
+                                        This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
341
+}FSMC_PCCARD_InitTypeDef;
342
+#endif
343
+
344
+/**
345
+  * @}
346
+  */
347
+
348
+/* Exported constants --------------------------------------------------------*/
349
+/** @addtogroup FSMC_LL_Exported_Constants FSMC Low Layer Exported Constants
350
+  * @{
351
+  */
352
+#if defined FSMC_BANK1
353
+
354
+/** @defgroup FSMC_LL_NOR_SRAM_Controller FSMC NOR/SRAM Controller
355
+  * @{
356
+  */
357
+
358
+/** @defgroup FSMC_NORSRAM_Bank FSMC NOR/SRAM Bank
359
+  * @{
360
+  */
361
+#define FSMC_NORSRAM_BANK1                       ((uint32_t)0x00000000U)
362
+#define FSMC_NORSRAM_BANK2                       ((uint32_t)0x00000002U)
363
+#define FSMC_NORSRAM_BANK3                       ((uint32_t)0x00000004U)
364
+#define FSMC_NORSRAM_BANK4                       ((uint32_t)0x00000006U)
365
+/**
366
+  * @}
367
+  */
368
+
369
+/** @defgroup FSMC_Data_Address_Bus_Multiplexing FSMC Data Address Bus Multiplexing
370
+  * @{
371
+  */
372
+#define FSMC_DATA_ADDRESS_MUX_DISABLE            ((uint32_t)0x00000000U)
373
+#define FSMC_DATA_ADDRESS_MUX_ENABLE             ((uint32_t)0x00000002U)
374
+/**
375
+  * @}
376
+  */
377
+
378
+/** @defgroup FSMC_Memory_Type FSMC Memory Type
379
+  * @{
380
+  */
381
+#define FSMC_MEMORY_TYPE_SRAM                    ((uint32_t)0x00000000U)
382
+#define FSMC_MEMORY_TYPE_PSRAM                   ((uint32_t)0x00000004U)
383
+#define FSMC_MEMORY_TYPE_NOR                     ((uint32_t)0x00000008U)
384
+/**
385
+  * @}
386
+  */
387
+
388
+/** @defgroup FSMC_NORSRAM_Data_Width FSMC NORSRAM Data Width
389
+  * @{
390
+  */
391
+#define FSMC_NORSRAM_MEM_BUS_WIDTH_8             ((uint32_t)0x00000000U)
392
+#define FSMC_NORSRAM_MEM_BUS_WIDTH_16            ((uint32_t)0x00000010U)
393
+#define FSMC_NORSRAM_MEM_BUS_WIDTH_32            ((uint32_t)0x00000020U)
394
+/**
395
+  * @}
396
+  */
397
+
398
+/** @defgroup FSMC_NORSRAM_Flash_Access FSMC NOR/SRAM Flash Access
399
+  * @{
400
+  */
401
+#define FSMC_NORSRAM_FLASH_ACCESS_ENABLE         ((uint32_t)0x00000040U)
402
+#define FSMC_NORSRAM_FLASH_ACCESS_DISABLE        ((uint32_t)0x00000000U)
403
+/**
404
+  * @}
405
+  */
406
+
407
+/** @defgroup FSMC_Burst_Access_Mode FSMC Burst Access Mode
408
+  * @{
409
+  */
410
+#define FSMC_BURST_ACCESS_MODE_DISABLE           ((uint32_t)0x00000000U)
411
+#define FSMC_BURST_ACCESS_MODE_ENABLE            ((uint32_t)0x00000100U)
412
+/**
413
+  * @}
414
+  */
415
+
416
+/** @defgroup FSMC_Wait_Signal_Polarity FSMC Wait Signal Polarity
417
+  * @{
418
+  */
419
+#define FSMC_WAIT_SIGNAL_POLARITY_LOW            ((uint32_t)0x00000000U)
420
+#define FSMC_WAIT_SIGNAL_POLARITY_HIGH           ((uint32_t)0x00000200U)
421
+/**
422
+  * @}
423
+  */
424
+
425
+/** @defgroup FSMC_Wrap_Mode FSMC Wrap Mode 
426
+  * @{
427
+  */
428
+#define FSMC_WRAP_MODE_DISABLE                   ((uint32_t)0x00000000U)
429
+#define FSMC_WRAP_MODE_ENABLE                    ((uint32_t)0x00000400U)
430
+/**
431
+  * @}
432
+  */
433
+
434
+/** @defgroup FSMC_Wait_Timing FSMC Wait Timing
435
+  * @{
436
+  */
437
+#define FSMC_WAIT_TIMING_BEFORE_WS               ((uint32_t)0x00000000U)
438
+#define FSMC_WAIT_TIMING_DURING_WS               ((uint32_t)0x00000800U)
439
+/**
440
+  * @}
441
+  */
442
+
443
+/** @defgroup FSMC_Write_Operation FSMC Write Operation
444
+  * @{
445
+  */
446
+#define FSMC_WRITE_OPERATION_DISABLE             ((uint32_t)0x00000000U)
447
+#define FSMC_WRITE_OPERATION_ENABLE              ((uint32_t)0x00001000U)
448
+/**
449
+  * @}
450
+  */
451
+
452
+/** @defgroup FSMC_Wait_Signal FSMC Wait Signal
453
+  * @{
454
+  */
455
+#define FSMC_WAIT_SIGNAL_DISABLE                 ((uint32_t)0x00000000U)
456
+#define FSMC_WAIT_SIGNAL_ENABLE                  ((uint32_t)0x00002000U)
457
+/**
458
+  * @}
459
+  */
460
+
461
+/** @defgroup FSMC_Extended_Mode FSMC Extended Mode
462
+  * @{
463
+  */
464
+#define FSMC_EXTENDED_MODE_DISABLE               ((uint32_t)0x00000000U)
465
+#define FSMC_EXTENDED_MODE_ENABLE                ((uint32_t)0x00004000U)
466
+/**
467
+  * @}
468
+  */
469
+
470
+/** @defgroup FSMC_AsynchronousWait FSMC Asynchronous Wait
471
+  * @{
472
+  */
473
+#define FSMC_ASYNCHRONOUS_WAIT_DISABLE           ((uint32_t)0x00000000U)
474
+#define FSMC_ASYNCHRONOUS_WAIT_ENABLE            ((uint32_t)0x00008000U)
475
+/**
476
+  * @}
477
+  */
478
+
479
+/** @defgroup FSMC_Page_Size FSMC Page Size
480
+  * @{
481
+  */
482
+#define FSMC_PAGE_SIZE_NONE                      ((uint32_t)0x00000000U)
483
+#define FSMC_PAGE_SIZE_128                       ((uint32_t)0x00010000U)
484
+#define FSMC_PAGE_SIZE_256                       ((uint32_t)0x00020000U)
485
+#define FSMC_PAGE_SIZE_512                       ((uint32_t)0x00030000U)
486
+#define FSMC_PAGE_SIZE_1024                      ((uint32_t)0x00040000U)
487
+/**
488
+  * @}
489
+  */
490
+
491
+/** @defgroup FSMC_Write_Burst FSMC Write Burst
492
+  * @{
493
+  */
494
+#define FSMC_WRITE_BURST_DISABLE                 ((uint32_t)0x00000000U)
495
+#define FSMC_WRITE_BURST_ENABLE                  ((uint32_t)0x00080000U)
496
+/**
497
+  * @}
498
+  */
499
+
500
+/** @defgroup FSMC_Continous_Clock FSMC Continuous Clock
501
+  * @{
502
+  */
503
+#define FSMC_CONTINUOUS_CLOCK_SYNC_ONLY          ((uint32_t)0x00000000U)
504
+#define FSMC_CONTINUOUS_CLOCK_SYNC_ASYNC         ((uint32_t)0x00100000U)
505
+/**
506
+  * @}
507
+  */
508
+
509
+  /** @defgroup FSMC_Access_Mode FSMC Access Mode
510
+  * @{
511
+  */
512
+#define FSMC_ACCESS_MODE_A                       ((uint32_t)0x00000000U)
513
+#define FSMC_ACCESS_MODE_B                       ((uint32_t)0x10000000U)
514
+#define FSMC_ACCESS_MODE_C                       ((uint32_t)0x20000000U)
515
+#define FSMC_ACCESS_MODE_D                       ((uint32_t)0x30000000U)
516
+/**
517
+  * @}
518
+  */
519
+
520
+/**
521
+  * @}
522
+  */
523
+#endif /* FSMC_BANK1 */
524
+
525
+#if defined(FSMC_BANK3)||defined(FSMC_BANK4)
526
+
527
+/** @defgroup FSMC_LL_NAND_Controller FSMC NAND Controller
528
+  * @{
529
+  */
530
+/** @defgroup FSMC_NAND_Bank FSMC NAND Bank
531
+  * @{
532
+  */
533
+#define FSMC_NAND_BANK2                          ((uint32_t)0x00000010U)
534
+#define FSMC_NAND_BANK3                          ((uint32_t)0x00000100U)
535
+/**
536
+  * @}
537
+  */
538
+
539
+/** @defgroup FSMC_Wait_feature FSMC Wait feature
540
+  * @{
541
+  */
542
+#define FSMC_NAND_PCC_WAIT_FEATURE_DISABLE       ((uint32_t)0x00000000U)
543
+#define FSMC_NAND_PCC_WAIT_FEATURE_ENABLE        ((uint32_t)0x00000002U)
544
+/**
545
+  * @}
546
+  */
547
+
548
+/** @defgroup FSMC_PCR_Memory_Type FSMC PCR Memory Type
549
+  * @{
550
+  */
551
+#if defined(FSMC_BANK4)
552
+#define FSMC_PCR_MEMORY_TYPE_PCCARD              ((uint32_t)0x00000000U)
553
+#endif
554
+#define FSMC_PCR_MEMORY_TYPE_NAND                ((uint32_t)0x00000008U)
555
+/**
556
+  * @}
557
+  */
558
+
559
+/** @defgroup FSMC_NAND_Data_Width FSMC NAND Data Width
560
+  * @{
561
+  */
562
+#define FSMC_NAND_PCC_MEM_BUS_WIDTH_8                ((uint32_t)0x00000000U)
563
+#define FSMC_NAND_PCC_MEM_BUS_WIDTH_16               ((uint32_t)0x00000010U)
564
+/**
565
+  * @}
566
+  */
567
+
568
+/** @defgroup FSMC_ECC FSMC ECC
569
+  * @{
570
+  */
571
+#define FSMC_NAND_ECC_DISABLE                    ((uint32_t)0x00000000U)
572
+#define FSMC_NAND_ECC_ENABLE                     ((uint32_t)0x00000040U)
573
+/**
574
+  * @}
575
+  */
576
+
577
+/** @defgroup FSMC_ECC_Page_Size FSMC ECC Page Size
578
+  * @{
579
+  */
580
+#define FSMC_NAND_ECC_PAGE_SIZE_256BYTE          ((uint32_t)0x00000000U)
581
+#define FSMC_NAND_ECC_PAGE_SIZE_512BYTE          ((uint32_t)0x00020000U)
582
+#define FSMC_NAND_ECC_PAGE_SIZE_1024BYTE         ((uint32_t)0x00040000U)
583
+#define FSMC_NAND_ECC_PAGE_SIZE_2048BYTE         ((uint32_t)0x00060000U)
584
+#define FSMC_NAND_ECC_PAGE_SIZE_4096BYTE         ((uint32_t)0x00080000U)
585
+#define FSMC_NAND_ECC_PAGE_SIZE_8192BYTE         ((uint32_t)0x000A0000U)
586
+/**
587
+  * @}
588
+  */
589
+
590
+/**
591
+  * @}
592
+  */
593
+#endif /* FSMC_BANK3 */
594
+
595
+
596
+/** @defgroup FSMC_LL_Interrupt_definition FSMC Low Layer Interrupt definition
597
+  * @{
598
+  */
599
+#if defined(FSMC_BANK3)||defined(FSMC_BANK4)
600
+#define FSMC_IT_RISING_EDGE                      ((uint32_t)0x00000008U)
601
+#define FSMC_IT_LEVEL                            ((uint32_t)0x00000010U)
602
+#define FSMC_IT_FALLING_EDGE                     ((uint32_t)0x00000020U)
603
+#endif /* FSMC_BANK3 */
604
+/**
605
+  * @}
606
+  */
607
+
608
+/** @defgroup FSMC_LL_Flag_definition FSMC Low Layer Flag definition
609
+  * @{
610
+  */
611
+#if defined(FSMC_BANK3)||defined(FSMC_BANK4)
612
+#define FSMC_FLAG_RISING_EDGE                    ((uint32_t)0x00000001U)
613
+#define FSMC_FLAG_LEVEL                          ((uint32_t)0x00000002U)
614
+#define FSMC_FLAG_FALLING_EDGE                   ((uint32_t)0x00000004U)
615
+#define FSMC_FLAG_FEMPT                          ((uint32_t)0x00000040U)
616
+#endif /* FSMC_BANK3 */
617
+/**
618
+  * @}
619
+  */
620
+
621
+/**
622
+  * @}
623
+  */
624
+
625
+/**
626
+  * @}
627
+  */
628
+  
629
+/* Private macro -------------------------------------------------------------*/
630
+/** @defgroup FSMC_LL_Private_Macros FSMC_LL  Private Macros
631
+  * @{
632
+  */
633
+#if defined FSMC_BANK1
634
+/** @defgroup FSMC_LL_NOR_Macros FSMC NOR/SRAM Macros
635
+  * @brief macros to handle NOR device enable/disable and read/write operations
636
+  * @{
637
+  */
638
+
639
+/**
640
+  * @brief  Enable the NORSRAM device access.
641
+  * @param  __INSTANCE__ FSMC_NORSRAM Instance
642
+  * @param  __BANK__ FSMC_NORSRAM Bank
643
+  * @retval None
644
+  */
645
+#define __FSMC_NORSRAM_ENABLE(__INSTANCE__, __BANK__)  ((__INSTANCE__)->BTCR[(__BANK__)] |= FSMC_BCRx_MBKEN)
646
+
647
+/**
648
+  * @brief  Disable the NORSRAM device access.
649
+  * @param  __INSTANCE__ FSMC_NORSRAM Instance
650
+  * @param  __BANK__ FSMC_NORSRAM Bank
651
+  * @retval None
652
+  */
653
+#define __FSMC_NORSRAM_DISABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)] &= ~FSMC_BCRx_MBKEN)
654
+
655
+/**
656
+  * @}
657
+  */
658
+#endif /* FSMC_BANK1 */
659
+
660
+#if defined(FSMC_BANK3)
661
+/** @defgroup FSMC_LL_NAND_Macros FSMC NAND Macros
662
+ *  @brief macros to handle NAND device enable/disable
663
+ *  @{
664
+ */
665
+
666
+/**
667
+  * @brief  Enable the NAND device access.
668
+  * @param  __INSTANCE__ FSMC_NAND Instance
669
+  * @param  __BANK__     FSMC_NAND Bank
670
+  * @retval None
671
+  */
672
+#define __FSMC_NAND_ENABLE(__INSTANCE__, __BANK__)  (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->PCR2 |= FSMC_PCRx_PBKEN): \
673
+                                                             ((__INSTANCE__)->PCR3 |= FSMC_PCRx_PBKEN))
674
+
675
+/**
676
+  * @brief  Disable the NAND device access.
677
+  * @param  __INSTANCE__ FSMC_NAND Instance
678
+  * @param  __BANK__     FSMC_NAND Bank
679
+  * @retval None
680
+  */
681
+#define __FSMC_NAND_DISABLE(__INSTANCE__, __BANK__) (((__BANK__) == FSMC_NAND_BANK2)? CLEAR_BIT((__INSTANCE__)->PCR2, FSMC_PCRx_PBKEN): \
682
+                                                             CLEAR_BIT((__INSTANCE__)->PCR3, FSMC_PCRx_PBKEN))
683
+
684
+/**
685
+  * @}
686
+  */
687
+#endif
688
+
689
+#if defined(FSMC_BANK4)
690
+/** @defgroup FSMC_LL_PCCARD_Macros FMC PCCARD Macros
691
+ *  @brief macros to handle PCCARD read/write operations 
692
+ *  @{
693
+ */
694
+/**
695
+  * @brief  Enable the PCCARD device access.
696
+  * @param  __INSTANCE__ FSMC_PCCARD Instance  
697
+  * @retval None
698
+  */ 
699
+#define __FSMC_PCCARD_ENABLE(__INSTANCE__)  ((__INSTANCE__)->PCR4 |= FSMC_PCRx_PBKEN)
700
+
701
+/**
702
+  * @brief  Disable the PCCARD device access.
703
+  * @param  __INSTANCE__ FSMC_PCCARD Instance     
704
+  * @retval None
705
+  */ 
706
+#define __FSMC_PCCARD_DISABLE(__INSTANCE__) ((__INSTANCE__)->PCR4 &= ~FSMC_PCRx_PBKEN)
707
+/**
708
+  * @}
709
+  */
710
+
711
+#endif
712
+#if defined(FSMC_BANK3)
713
+/** @defgroup FSMC_LL_NAND_Interrupt FSMC NAND Interrupt
714
+  * @brief macros to handle NAND interrupts
715
+  * @{
716
+  */
717
+
718
+/**
719
+  * @brief  Enable the NAND device interrupt.
720
+  * @param  __INSTANCE__  FSMC_NAND instance
721
+  * @param  __BANK__     FSMC_NAND Bank
722
+  * @param  __INTERRUPT__ FSMC_NAND interrupt
723
+  *         This parameter can be any combination of the following values:
724
+  *            @arg FSMC_IT_RISING_EDGE: Interrupt rising edge.
725
+  *            @arg FSMC_IT_LEVEL: Interrupt level.
726
+  *            @arg FSMC_IT_FALLING_EDGE: Interrupt falling edge.
727
+  * @retval None
728
+  */
729
+#define __FSMC_NAND_ENABLE_IT(__INSTANCE__, __BANK__, __INTERRUPT__)  (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->SR2 |= (__INTERRUPT__)): \
730
+                                                                               ((__INSTANCE__)->SR3 |= (__INTERRUPT__)))
731
+
732
+/**
733
+  * @brief  Disable the NAND device interrupt.
734
+  * @param  __INSTANCE__  FSMC_NAND Instance
735
+  * @param  __BANK__     FSMC_NAND Bank
736
+  * @param  __INTERRUPT__ FSMC_NAND interrupt
737
+  *         This parameter can be any combination of the following values:
738
+  *            @arg FSMC_IT_RISING_EDGE: Interrupt rising edge.
739
+  *            @arg FSMC_IT_LEVEL: Interrupt level.
740
+  *            @arg FSMC_IT_FALLING_EDGE: Interrupt falling edge.
741
+  * @retval None
742
+  */
743
+#define __FSMC_NAND_DISABLE_IT(__INSTANCE__, __BANK__, __INTERRUPT__)  (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->SR2 &= ~(__INTERRUPT__)): \
744
+                                                                                ((__INSTANCE__)->SR3 &= ~(__INTERRUPT__))) 
745
+
746
+/**
747
+  * @brief  Get flag status of the NAND device.
748
+  * @param  __INSTANCE__ FSMC_NAND Instance
749
+  * @param  __BANK__     FSMC_NAND Bank
750
+  * @param  __FLAG__     FSMC_NAND flag
751
+  *         This parameter can be any combination of the following values:
752
+  *            @arg FSMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
753
+  *            @arg FSMC_FLAG_LEVEL: Interrupt level edge flag.
754
+  *            @arg FSMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
755
+  *            @arg FSMC_FLAG_FEMPT: FIFO empty flag.
756
+  * @retval The state of FLAG (SET or RESET).
757
+  */
758
+#define __FSMC_NAND_GET_FLAG(__INSTANCE__, __BANK__, __FLAG__)  (((__BANK__) == FSMC_NAND_BANK2)? (((__INSTANCE__)->SR2 &(__FLAG__)) == (__FLAG__)): \
759
+                                                                         (((__INSTANCE__)->SR3 &(__FLAG__)) == (__FLAG__)))
760
+
761
+/**
762
+  * @brief  Clear flag status of the NAND device.
763
+  * @param  __INSTANCE__ FSMC_NAND Instance
764
+  * @param  __BANK__     FSMC_NAND Bank
765
+  * @param  __FLAG__     FSMC_NAND flag
766
+  *         This parameter can be any combination of the following values:
767
+  *            @arg FSMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
768
+  *            @arg FSMC_FLAG_LEVEL: Interrupt level edge flag.
769
+  *            @arg FSMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
770
+  *            @arg FSMC_FLAG_FEMPT: FIFO empty flag.
771
+  * @retval None
772
+  */
773
+#define __FSMC_NAND_CLEAR_FLAG(__INSTANCE__, __BANK__, __FLAG__)  (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->SR2 &= ~(__FLAG__)): \
774
+                                                                           ((__INSTANCE__)->SR3 &= ~(__FLAG__)))
775
+
776
+/**
777
+  * @}
778
+  */
779
+#endif /* FSMC_BANK3 */
780
+
781
+#if defined(FSMC_BANK4)
782
+/** @defgroup FSMC_LL_PCCARD_Interrupt FSMC PCCARD Interrupt
783
+  * @brief macros to handle PCCARD interrupts
784
+  * @{
785
+  */
786
+
787
+/**
788
+  * @brief  Enable the PCCARD device interrupt.
789
+  * @param  __INSTANCE__ FSMC_PCCARD instance  
790
+  * @param  __INTERRUPT__ FSMC_PCCARD interrupt 
791
+  *         This parameter can be any combination of the following values:
792
+  *            @arg FSMC_IT_RISING_EDGE: Interrupt rising edge.
793
+  *            @arg FSMC_IT_LEVEL: Interrupt level.
794
+  *            @arg FSMC_IT_FALLING_EDGE: Interrupt falling edge.       
795
+  * @retval None
796
+  */ 
797
+#define __FSMC_PCCARD_ENABLE_IT(__INSTANCE__, __INTERRUPT__)  ((__INSTANCE__)->SR4 |= (__INTERRUPT__))
798
+
799
+/**
800
+  * @brief  Disable the PCCARD device interrupt.
801
+  * @param  __INSTANCE__ FSMC_PCCARD instance  
802
+  * @param  __INTERRUPT__ FSMC_PCCARD interrupt 
803
+  *         This parameter can be any combination of the following values:
804
+  *            @arg FSMC_IT_RISING_EDGE: Interrupt rising edge.
805
+  *            @arg FSMC_IT_LEVEL: Interrupt level.
806
+  *            @arg FSMC_IT_FALLING_EDGE: Interrupt falling edge.       
807
+  * @retval None
808
+  */ 
809
+#define __FSMC_PCCARD_DISABLE_IT(__INSTANCE__, __INTERRUPT__)  ((__INSTANCE__)->SR4 &= ~(__INTERRUPT__)) 
810
+
811
+/**
812
+  * @brief  Get flag status of the PCCARD device.
813
+  * @param  __INSTANCE__ FSMC_PCCARD instance  
814
+  * @param  __FLAG__ FSMC_PCCARD flag
815
+  *         This parameter can be any combination of the following values:
816
+  *            @arg  FSMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
817
+  *            @arg  FSMC_FLAG_LEVEL: Interrupt level edge flag.
818
+  *            @arg  FSMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
819
+  *            @arg  FSMC_FLAG_FEMPT: FIFO empty flag.   
820
+  * @retval The state of FLAG (SET or RESET).
821
+  */
822
+#define __FSMC_PCCARD_GET_FLAG(__INSTANCE__, __FLAG__)  (((__INSTANCE__)->SR4 &(__FLAG__)) == (__FLAG__))
823
+
824
+/**
825
+  * @brief  Clear flag status of the PCCARD device.
826
+  * @param  __INSTANCE__ FSMC_PCCARD instance  
827
+  * @param  __FLAG__ FSMC_PCCARD flag
828
+  *         This parameter can be any combination of the following values:
829
+  *            @arg  FSMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
830
+  *            @arg  FSMC_FLAG_LEVEL: Interrupt level edge flag.
831
+  *            @arg  FSMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
832
+  *            @arg  FSMC_FLAG_FEMPT: FIFO empty flag.   
833
+  * @retval None
834
+  */
835
+#define __FSMC_PCCARD_CLEAR_FLAG(__INSTANCE__, __FLAG__)  ((__INSTANCE__)->SR4 &= ~(__FLAG__))
836
+
837
+/**
838
+  * @}
839
+  */
840
+#endif
841
+
842
+/**
843
+  * @}
844
+  */
845
+
846
+/**
847
+  * @}
848
+  */
849
+
850
+/* Private functions ---------------------------------------------------------*/
851
+/** @defgroup FSMC_LL_Private_Functions FSMC LL Private Functions
852
+  *  @{
853
+  */
854
+
855
+#if defined FSMC_BANK1
856
+/** @defgroup FSMC_LL_NORSRAM  NOR SRAM
857
+  *  @{
858
+  */
859
+/** @defgroup FSMC_LL_NORSRAM_Private_Functions_Group1 NOR SRAM Initialization/de-initialization functions
860
+  *  @{
861
+  */
862
+HAL_StatusTypeDef  FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_InitTypeDef *Init);
863
+HAL_StatusTypeDef  FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank);
864
+HAL_StatusTypeDef  FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode);
865
+HAL_StatusTypeDef  FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank);
866
+/**
867
+  * @}
868
+  */
869
+
870
+/** @defgroup FSMC_LL_NORSRAM_Private_Functions_Group2 NOR SRAM Control functions
871
+  *  @{
872
+  */
873
+HAL_StatusTypeDef  FSMC_NORSRAM_WriteOperation_Enable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank);
874
+HAL_StatusTypeDef  FSMC_NORSRAM_WriteOperation_Disable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank);
875
+/**
876
+  * @}
877
+  */
878
+/**
879
+  * @}
880
+  */
881
+#endif /* FSMC_BANK1 */
882
+
883
+#if defined(FSMC_BANK3)
884
+/** @defgroup FSMC_LL_NAND NAND
885
+  *  @{
886
+  */
887
+/** @defgroup FSMC_LL_NAND_Private_Functions_Group1 NAND Initialization/de-initialization functions
888
+  *  @{
889
+  */
890
+HAL_StatusTypeDef  FSMC_NAND_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_InitTypeDef *Init);
891
+HAL_StatusTypeDef  FSMC_NAND_CommonSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
892
+HAL_StatusTypeDef  FSMC_NAND_AttributeSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
893
+HAL_StatusTypeDef  FSMC_NAND_DeInit(FSMC_NAND_TypeDef *Device, uint32_t Bank);
894
+/**
895
+  * @}
896
+  */
897
+
898
+/** @defgroup FSMC_LL_NAND_Private_Functions_Group2 NAND Control functions
899
+  *  @{
900
+  */
901
+HAL_StatusTypeDef  FSMC_NAND_ECC_Enable(FSMC_NAND_TypeDef *Device, uint32_t Bank);
902
+HAL_StatusTypeDef  FSMC_NAND_ECC_Disable(FSMC_NAND_TypeDef *Device, uint32_t Bank);
903
+HAL_StatusTypeDef  FSMC_NAND_GetECC(FSMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout);
904
+/**
905
+  * @}
906
+  */
907
+/**
908
+  * @}
909
+  */
910
+#endif /* FSMC_BANK3 */
911
+
912
+#if defined(FSMC_BANK4)
913
+/** @defgroup FSMC_LL_PCCARD PCCARD
914
+  *  @{
915
+  */
916
+/** @defgroup FSMC_LL_PCCARD_Private_Functions_Group1 PCCARD Initialization/de-initialization functions
917
+  *  @{
918
+  */
919
+HAL_StatusTypeDef  FSMC_PCCARD_Init(FSMC_PCCARD_TypeDef *Device, FSMC_PCCARD_InitTypeDef *Init);
920
+HAL_StatusTypeDef  FSMC_PCCARD_CommonSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing);
921
+HAL_StatusTypeDef  FSMC_PCCARD_AttributeSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing);
922
+HAL_StatusTypeDef  FSMC_PCCARD_IOSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing);
923
+HAL_StatusTypeDef  FSMC_PCCARD_DeInit(FSMC_PCCARD_TypeDef *Device);
924
+/**
925
+  * @}
926
+  */
927
+/**
928
+  * @}
929
+  */
930
+#endif /* FSMC_BANK4 */
931
+
932
+
933
+/**
934
+  * @}
935
+  */
936
+
937
+/**
938
+  * @}
939
+  */
940
+
941
+/**
942
+  * @}
943
+  */
944
+
945
+#ifdef __cplusplus
946
+}
947
+#endif
948
+
949
+#endif /* STM32F1xx_LL_FSMC_H */
950
+
951
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 2345
- 0
LLDrivers/inc/stm32f1xx_ll_gpio.h
File diff suppressed because it is too large
View File


+ 1784
- 0
LLDrivers/inc/stm32f1xx_ll_i2c.h
File diff suppressed because it is too large
View File


+ 311
- 0
LLDrivers/inc/stm32f1xx_ll_iwdg.h View File

@@ -0,0 +1,311 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_iwdg.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of IWDG LL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+/* Define to prevent recursive inclusion -------------------------------------*/
21
+#ifndef STM32F1xx_LL_IWDG_H
22
+#define STM32F1xx_LL_IWDG_H
23
+
24
+#ifdef __cplusplus
25
+extern "C" {
26
+#endif
27
+
28
+/* Includes ------------------------------------------------------------------*/
29
+#include "stm32f1xx.h"
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined(IWDG)
36
+
37
+/** @defgroup IWDG_LL IWDG
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+
44
+/* Private constants ---------------------------------------------------------*/
45
+/** @defgroup IWDG_LL_Private_Constants IWDG Private Constants
46
+  * @{
47
+  */
48
+
49
+#define LL_IWDG_KEY_RELOAD                 0x0000AAAAU               /*!< IWDG Reload Counter Enable   */
50
+#define LL_IWDG_KEY_ENABLE                 0x0000CCCCU               /*!< IWDG Peripheral Enable       */
51
+#define LL_IWDG_KEY_WR_ACCESS_ENABLE       0x00005555U               /*!< IWDG KR Write Access Enable  */
52
+#define LL_IWDG_KEY_WR_ACCESS_DISABLE      0x00000000U               /*!< IWDG KR Write Access Disable */
53
+
54
+/**
55
+  * @}
56
+  */
57
+
58
+/* Private macros ------------------------------------------------------------*/
59
+
60
+/* Exported types ------------------------------------------------------------*/
61
+/* Exported constants --------------------------------------------------------*/
62
+/** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants
63
+  * @{
64
+  */
65
+
66
+/** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines
67
+  * @brief    Flags defines which can be used with LL_IWDG_ReadReg function
68
+  * @{
69
+  */
70
+#define LL_IWDG_SR_PVU                     IWDG_SR_PVU                           /*!< Watchdog prescaler value update */
71
+#define LL_IWDG_SR_RVU                     IWDG_SR_RVU                           /*!< Watchdog counter reload value update */
72
+
73
+/**
74
+  * @}
75
+  */
76
+
77
+/** @defgroup IWDG_LL_EC_PRESCALER  Prescaler Divider
78
+  * @{
79
+  */
80
+#define LL_IWDG_PRESCALER_4                0x00000000U                           /*!< Divider by 4   */
81
+#define LL_IWDG_PRESCALER_8                (IWDG_PR_PR_0)                        /*!< Divider by 8   */
82
+#define LL_IWDG_PRESCALER_16               (IWDG_PR_PR_1)                        /*!< Divider by 16  */
83
+#define LL_IWDG_PRESCALER_32               (IWDG_PR_PR_1 | IWDG_PR_PR_0)         /*!< Divider by 32  */
84
+#define LL_IWDG_PRESCALER_64               (IWDG_PR_PR_2)                        /*!< Divider by 64  */
85
+#define LL_IWDG_PRESCALER_128              (IWDG_PR_PR_2 | IWDG_PR_PR_0)         /*!< Divider by 128 */
86
+#define LL_IWDG_PRESCALER_256              (IWDG_PR_PR_2 | IWDG_PR_PR_1)         /*!< Divider by 256 */
87
+/**
88
+  * @}
89
+  */
90
+
91
+/**
92
+  * @}
93
+  */
94
+
95
+/* Exported macro ------------------------------------------------------------*/
96
+/** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros
97
+  * @{
98
+  */
99
+
100
+/** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros
101
+  * @{
102
+  */
103
+
104
+/**
105
+  * @brief  Write a value in IWDG register
106
+  * @param  __INSTANCE__ IWDG Instance
107
+  * @param  __REG__ Register to be written
108
+  * @param  __VALUE__ Value to be written in the register
109
+  * @retval None
110
+  */
111
+#define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
112
+
113
+/**
114
+  * @brief  Read a value in IWDG register
115
+  * @param  __INSTANCE__ IWDG Instance
116
+  * @param  __REG__ Register to be read
117
+  * @retval Register value
118
+  */
119
+#define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
120
+/**
121
+  * @}
122
+  */
123
+
124
+/**
125
+  * @}
126
+  */
127
+
128
+
129
+/* Exported functions --------------------------------------------------------*/
130
+/** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions
131
+  * @{
132
+  */
133
+/** @defgroup IWDG_LL_EF_Configuration Configuration
134
+  * @{
135
+  */
136
+
137
+/**
138
+  * @brief  Start the Independent Watchdog
139
+  * @note   Except if the hardware watchdog option is selected
140
+  * @rmtoll KR           KEY           LL_IWDG_Enable
141
+  * @param  IWDGx IWDG Instance
142
+  * @retval None
143
+  */
144
+__STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx)
145
+{
146
+  WRITE_REG(IWDG->KR, LL_IWDG_KEY_ENABLE);
147
+}
148
+
149
+/**
150
+  * @brief  Reloads IWDG counter with value defined in the reload register
151
+  * @rmtoll KR           KEY           LL_IWDG_ReloadCounter
152
+  * @param  IWDGx IWDG Instance
153
+  * @retval None
154
+  */
155
+__STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx)
156
+{
157
+  WRITE_REG(IWDG->KR, LL_IWDG_KEY_RELOAD);
158
+}
159
+
160
+/**
161
+  * @brief  Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
162
+  * @rmtoll KR           KEY           LL_IWDG_EnableWriteAccess
163
+  * @param  IWDGx IWDG Instance
164
+  * @retval None
165
+  */
166
+__STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx)
167
+{
168
+  WRITE_REG(IWDG->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE);
169
+}
170
+
171
+/**
172
+  * @brief  Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
173
+  * @rmtoll KR           KEY           LL_IWDG_DisableWriteAccess
174
+  * @param  IWDGx IWDG Instance
175
+  * @retval None
176
+  */
177
+__STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx)
178
+{
179
+  WRITE_REG(IWDG->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE);
180
+}
181
+
182
+/**
183
+  * @brief  Select the prescaler of the IWDG
184
+  * @rmtoll PR           PR            LL_IWDG_SetPrescaler
185
+  * @param  IWDGx IWDG Instance
186
+  * @param  Prescaler This parameter can be one of the following values:
187
+  *         @arg @ref LL_IWDG_PRESCALER_4
188
+  *         @arg @ref LL_IWDG_PRESCALER_8
189
+  *         @arg @ref LL_IWDG_PRESCALER_16
190
+  *         @arg @ref LL_IWDG_PRESCALER_32
191
+  *         @arg @ref LL_IWDG_PRESCALER_64
192
+  *         @arg @ref LL_IWDG_PRESCALER_128
193
+  *         @arg @ref LL_IWDG_PRESCALER_256
194
+  * @retval None
195
+  */
196
+__STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler)
197
+{
198
+  WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler);
199
+}
200
+
201
+/**
202
+  * @brief  Get the selected prescaler of the IWDG
203
+  * @rmtoll PR           PR            LL_IWDG_GetPrescaler
204
+  * @param  IWDGx IWDG Instance
205
+  * @retval Returned value can be one of the following values:
206
+  *         @arg @ref LL_IWDG_PRESCALER_4
207
+  *         @arg @ref LL_IWDG_PRESCALER_8
208
+  *         @arg @ref LL_IWDG_PRESCALER_16
209
+  *         @arg @ref LL_IWDG_PRESCALER_32
210
+  *         @arg @ref LL_IWDG_PRESCALER_64
211
+  *         @arg @ref LL_IWDG_PRESCALER_128
212
+  *         @arg @ref LL_IWDG_PRESCALER_256
213
+  */
214
+__STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx)
215
+{
216
+  return (uint32_t)(READ_REG(IWDGx->PR));
217
+}
218
+
219
+/**
220
+  * @brief  Specify the IWDG down-counter reload value
221
+  * @rmtoll RLR          RL            LL_IWDG_SetReloadCounter
222
+  * @param  IWDGx IWDG Instance
223
+  * @param  Counter Value between Min_Data=0 and Max_Data=0x0FFF
224
+  * @retval None
225
+  */
226
+__STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter)
227
+{
228
+  WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter);
229
+}
230
+
231
+/**
232
+  * @brief  Get the specified IWDG down-counter reload value
233
+  * @rmtoll RLR          RL            LL_IWDG_GetReloadCounter
234
+  * @param  IWDGx IWDG Instance
235
+  * @retval Value between Min_Data=0 and Max_Data=0x0FFF
236
+  */
237
+__STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx)
238
+{
239
+  return (uint32_t)(READ_REG(IWDGx->RLR));
240
+}
241
+
242
+
243
+/**
244
+  * @}
245
+  */
246
+
247
+/** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management
248
+  * @{
249
+  */
250
+
251
+/**
252
+  * @brief  Check if flag Prescaler Value Update is set or not
253
+  * @rmtoll SR           PVU           LL_IWDG_IsActiveFlag_PVU
254
+  * @param  IWDGx IWDG Instance
255
+  * @retval State of bit (1 or 0).
256
+  */
257
+__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx)
258
+{
259
+  return (READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU));
260
+}
261
+
262
+/**
263
+  * @brief  Check if flag Reload Value Update is set or not
264
+  * @rmtoll SR           RVU           LL_IWDG_IsActiveFlag_RVU
265
+  * @param  IWDGx IWDG Instance
266
+  * @retval State of bit (1 or 0).
267
+  */
268
+__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx)
269
+{
270
+  return (READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU));
271
+}
272
+
273
+
274
+/**
275
+  * @brief  Check if all flags Prescaler, Reload & Window Value Update are reset or not
276
+  * @rmtoll SR           PVU           LL_IWDG_IsReady\n
277
+  *         SR           RVU           LL_IWDG_IsReady
278
+  * @param  IWDGx IWDG Instance
279
+  * @retval State of bits (1 or 0).
280
+  */
281
+__STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx)
282
+{
283
+  return (READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU) == 0U);
284
+}
285
+
286
+/**
287
+  * @}
288
+  */
289
+
290
+
291
+/**
292
+  * @}
293
+  */
294
+
295
+/**
296
+  * @}
297
+  */
298
+
299
+#endif /* IWDG) */
300
+
301
+/**
302
+  * @}
303
+  */
304
+
305
+#ifdef __cplusplus
306
+}
307
+#endif
308
+
309
+#endif /* STM32F1xx_LL_IWDG_H */
310
+
311
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 440
- 0
LLDrivers/inc/stm32f1xx_ll_pwr.h View File

@@ -0,0 +1,440 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_pwr.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of PWR LL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+/* Define to prevent recursive inclusion -------------------------------------*/
21
+#ifndef __STM32F1xx_LL_PWR_H
22
+#define __STM32F1xx_LL_PWR_H
23
+
24
+#ifdef __cplusplus
25
+extern "C" {
26
+#endif
27
+
28
+/* Includes ------------------------------------------------------------------*/
29
+#include "stm32f1xx.h"
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined(PWR)
36
+
37
+/** @defgroup PWR_LL PWR
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/* Private macros ------------------------------------------------------------*/
45
+/* Exported types ------------------------------------------------------------*/
46
+/* Exported constants --------------------------------------------------------*/
47
+/** @defgroup PWR_LL_Exported_Constants PWR Exported Constants
48
+  * @{
49
+  */
50
+
51
+/** @defgroup PWR_LL_EC_CLEAR_FLAG Clear Flags Defines
52
+  * @brief    Flags defines which can be used with LL_PWR_WriteReg function
53
+  * @{
54
+  */
55
+#define LL_PWR_CR_CSBF                     PWR_CR_CSBF            /*!< Clear standby flag */
56
+#define LL_PWR_CR_CWUF                     PWR_CR_CWUF            /*!< Clear wakeup flag */
57
+/**
58
+  * @}
59
+  */
60
+
61
+/** @defgroup PWR_LL_EC_GET_FLAG Get Flags Defines
62
+  * @brief    Flags defines which can be used with LL_PWR_ReadReg function
63
+  * @{
64
+  */
65
+#define LL_PWR_CSR_WUF                     PWR_CSR_WUF            /*!< Wakeup flag */
66
+#define LL_PWR_CSR_SBF                     PWR_CSR_SBF            /*!< Standby flag */
67
+#define LL_PWR_CSR_PVDO                    PWR_CSR_PVDO           /*!< Power voltage detector output flag */
68
+#define LL_PWR_CSR_EWUP1                   PWR_CSR_EWUP           /*!< Enable WKUP pin 1 */
69
+/**
70
+  * @}
71
+  */
72
+
73
+
74
+/** @defgroup PWR_LL_EC_MODE_PWR Mode Power
75
+  * @{
76
+  */
77
+#define LL_PWR_MODE_STOP_MAINREGU             0x00000000U                    /*!< Enter Stop mode when the CPU enters deepsleep */
78
+#define LL_PWR_MODE_STOP_LPREGU               (PWR_CR_LPDS)                  /*!< Enter Stop mode (with low power Regulator ON) when the CPU enters deepsleep */
79
+#define LL_PWR_MODE_STANDBY                   (PWR_CR_PDDS)                  /*!< Enter Standby mode when the CPU enters deepsleep */
80
+/**
81
+  * @}
82
+  */
83
+
84
+/** @defgroup PWR_LL_EC_REGU_MODE_DS_MODE  Regulator Mode In Deep Sleep Mode
85
+ * @{
86
+ */
87
+#define LL_PWR_REGU_DSMODE_MAIN        0x00000000U           /*!< Voltage Regulator in main mode during deepsleep mode */
88
+#define LL_PWR_REGU_DSMODE_LOW_POWER   (PWR_CR_LPDS)         /*!< Voltage Regulator in low-power mode during deepsleep mode */
89
+/**
90
+  * @}
91
+  */
92
+
93
+/** @defgroup PWR_LL_EC_PVDLEVEL Power Voltage Detector Level
94
+  * @{
95
+  */
96
+#define LL_PWR_PVDLEVEL_0                  (PWR_CR_PLS_LEV0)      /*!< Voltage threshold detected by PVD 2.2 V */
97
+#define LL_PWR_PVDLEVEL_1                  (PWR_CR_PLS_LEV1)      /*!< Voltage threshold detected by PVD 2.3 V */
98
+#define LL_PWR_PVDLEVEL_2                  (PWR_CR_PLS_LEV2)      /*!< Voltage threshold detected by PVD 2.4 V */
99
+#define LL_PWR_PVDLEVEL_3                  (PWR_CR_PLS_LEV3)      /*!< Voltage threshold detected by PVD 2.5 V */
100
+#define LL_PWR_PVDLEVEL_4                  (PWR_CR_PLS_LEV4)      /*!< Voltage threshold detected by PVD 2.6 V */
101
+#define LL_PWR_PVDLEVEL_5                  (PWR_CR_PLS_LEV5)      /*!< Voltage threshold detected by PVD 2.7 V */
102
+#define LL_PWR_PVDLEVEL_6                  (PWR_CR_PLS_LEV6)      /*!< Voltage threshold detected by PVD 2.8 V */
103
+#define LL_PWR_PVDLEVEL_7                  (PWR_CR_PLS_LEV7)      /*!< Voltage threshold detected by PVD 2.9 V */
104
+/**
105
+  * @}
106
+  */
107
+/** @defgroup PWR_LL_EC_WAKEUP_PIN  Wakeup Pins
108
+  * @{
109
+  */
110
+#define LL_PWR_WAKEUP_PIN1                 (PWR_CSR_EWUP)         /*!< WKUP pin 1 : PA0 */
111
+/**
112
+  * @}
113
+  */
114
+
115
+/**
116
+  * @}
117
+  */
118
+
119
+
120
+/* Exported macro ------------------------------------------------------------*/
121
+/** @defgroup PWR_LL_Exported_Macros PWR Exported Macros
122
+  * @{
123
+  */
124
+
125
+/** @defgroup PWR_LL_EM_WRITE_READ Common write and read registers Macros
126
+  * @{
127
+  */
128
+
129
+/**
130
+  * @brief  Write a value in PWR register
131
+  * @param  __REG__ Register to be written
132
+  * @param  __VALUE__ Value to be written in the register
133
+  * @retval None
134
+  */
135
+#define LL_PWR_WriteReg(__REG__, __VALUE__) WRITE_REG(PWR->__REG__, (__VALUE__))
136
+
137
+/**
138
+  * @brief  Read a value in PWR register
139
+  * @param  __REG__ Register to be read
140
+  * @retval Register value
141
+  */
142
+#define LL_PWR_ReadReg(__REG__) READ_REG(PWR->__REG__)
143
+/**
144
+  * @}
145
+  */
146
+
147
+/**
148
+  * @}
149
+  */
150
+
151
+/* Exported functions --------------------------------------------------------*/
152
+/** @defgroup PWR_LL_Exported_Functions PWR Exported Functions
153
+  * @{
154
+  */
155
+
156
+/** @defgroup PWR_LL_EF_Configuration Configuration
157
+  * @{
158
+  */
159
+
160
+/**
161
+  * @brief  Enable access to the backup domain
162
+  * @rmtoll CR    DBP       LL_PWR_EnableBkUpAccess
163
+  * @retval None
164
+  */
165
+__STATIC_INLINE void LL_PWR_EnableBkUpAccess(void)
166
+{
167
+  SET_BIT(PWR->CR, PWR_CR_DBP);
168
+}
169
+
170
+/**
171
+  * @brief  Disable access to the backup domain
172
+  * @rmtoll CR    DBP       LL_PWR_DisableBkUpAccess
173
+  * @retval None
174
+  */
175
+__STATIC_INLINE void LL_PWR_DisableBkUpAccess(void)
176
+{
177
+  CLEAR_BIT(PWR->CR, PWR_CR_DBP);
178
+}
179
+
180
+/**
181
+  * @brief  Check if the backup domain is enabled
182
+  * @rmtoll CR    DBP       LL_PWR_IsEnabledBkUpAccess
183
+  * @retval State of bit (1 or 0).
184
+  */
185
+__STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpAccess(void)
186
+{
187
+  return (READ_BIT(PWR->CR, PWR_CR_DBP) == (PWR_CR_DBP));
188
+}
189
+
190
+/**
191
+  * @brief  Set voltage Regulator mode during deep sleep mode
192
+  * @rmtoll CR    LPDS         LL_PWR_SetRegulModeDS
193
+  * @param  RegulMode This parameter can be one of the following values:
194
+  *         @arg @ref LL_PWR_REGU_DSMODE_MAIN
195
+  *         @arg @ref LL_PWR_REGU_DSMODE_LOW_POWER
196
+  * @retval None
197
+  */
198
+__STATIC_INLINE void LL_PWR_SetRegulModeDS(uint32_t RegulMode)
199
+{
200
+  MODIFY_REG(PWR->CR, PWR_CR_LPDS, RegulMode);
201
+}
202
+
203
+/**
204
+  * @brief  Get voltage Regulator mode during deep sleep mode
205
+  * @rmtoll CR    LPDS         LL_PWR_GetRegulModeDS
206
+  * @retval Returned value can be one of the following values:
207
+  *         @arg @ref LL_PWR_REGU_DSMODE_MAIN
208
+  *         @arg @ref LL_PWR_REGU_DSMODE_LOW_POWER
209
+  */
210
+__STATIC_INLINE uint32_t LL_PWR_GetRegulModeDS(void)
211
+{
212
+  return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_LPDS));
213
+}
214
+
215
+/**
216
+  * @brief  Set Power Down mode when CPU enters deepsleep
217
+  * @rmtoll CR    PDDS         LL_PWR_SetPowerMode\n
218
+  * @rmtoll CR    LPDS         LL_PWR_SetPowerMode
219
+  * @param  PDMode This parameter can be one of the following values:
220
+  *         @arg @ref LL_PWR_MODE_STOP_MAINREGU
221
+  *         @arg @ref LL_PWR_MODE_STOP_LPREGU
222
+  *         @arg @ref LL_PWR_MODE_STANDBY
223
+  * @retval None
224
+  */
225
+__STATIC_INLINE void LL_PWR_SetPowerMode(uint32_t PDMode)
226
+{
227
+  MODIFY_REG(PWR->CR, (PWR_CR_PDDS| PWR_CR_LPDS), PDMode);
228
+}
229
+
230
+/**
231
+  * @brief  Get Power Down mode when CPU enters deepsleep
232
+  * @rmtoll CR    PDDS         LL_PWR_GetPowerMode\n
233
+  * @rmtoll CR    LPDS         LL_PWR_GetPowerMode
234
+  * @retval Returned value can be one of the following values:
235
+  *         @arg @ref LL_PWR_MODE_STOP_MAINREGU
236
+  *         @arg @ref LL_PWR_MODE_STOP_LPREGU
237
+  *         @arg @ref LL_PWR_MODE_STANDBY
238
+  */
239
+__STATIC_INLINE uint32_t LL_PWR_GetPowerMode(void)
240
+{
241
+  return (uint32_t)(READ_BIT(PWR->CR, (PWR_CR_PDDS| PWR_CR_LPDS)));
242
+}
243
+
244
+/**
245
+  * @brief  Configure the voltage threshold detected by the Power Voltage Detector
246
+  * @rmtoll CR    PLS       LL_PWR_SetPVDLevel
247
+  * @param  PVDLevel This parameter can be one of the following values:
248
+  *         @arg @ref LL_PWR_PVDLEVEL_0
249
+  *         @arg @ref LL_PWR_PVDLEVEL_1
250
+  *         @arg @ref LL_PWR_PVDLEVEL_2
251
+  *         @arg @ref LL_PWR_PVDLEVEL_3
252
+  *         @arg @ref LL_PWR_PVDLEVEL_4
253
+  *         @arg @ref LL_PWR_PVDLEVEL_5
254
+  *         @arg @ref LL_PWR_PVDLEVEL_6
255
+  *         @arg @ref LL_PWR_PVDLEVEL_7
256
+  * @retval None
257
+  */
258
+__STATIC_INLINE void LL_PWR_SetPVDLevel(uint32_t PVDLevel)
259
+{
260
+  MODIFY_REG(PWR->CR, PWR_CR_PLS, PVDLevel);
261
+}
262
+
263
+/**
264
+  * @brief  Get the voltage threshold detection
265
+  * @rmtoll CR    PLS       LL_PWR_GetPVDLevel
266
+  * @retval Returned value can be one of the following values:
267
+  *         @arg @ref LL_PWR_PVDLEVEL_0
268
+  *         @arg @ref LL_PWR_PVDLEVEL_1
269
+  *         @arg @ref LL_PWR_PVDLEVEL_2
270
+  *         @arg @ref LL_PWR_PVDLEVEL_3
271
+  *         @arg @ref LL_PWR_PVDLEVEL_4
272
+  *         @arg @ref LL_PWR_PVDLEVEL_5
273
+  *         @arg @ref LL_PWR_PVDLEVEL_6
274
+  *         @arg @ref LL_PWR_PVDLEVEL_7
275
+  */
276
+__STATIC_INLINE uint32_t LL_PWR_GetPVDLevel(void)
277
+{
278
+  return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_PLS));
279
+}
280
+
281
+/**
282
+  * @brief  Enable Power Voltage Detector
283
+  * @rmtoll CR    PVDE       LL_PWR_EnablePVD
284
+  * @retval None
285
+  */
286
+__STATIC_INLINE void LL_PWR_EnablePVD(void)
287
+{
288
+  SET_BIT(PWR->CR, PWR_CR_PVDE);
289
+}
290
+
291
+/**
292
+  * @brief  Disable Power Voltage Detector
293
+  * @rmtoll CR    PVDE       LL_PWR_DisablePVD
294
+  * @retval None
295
+  */
296
+__STATIC_INLINE void LL_PWR_DisablePVD(void)
297
+{
298
+  CLEAR_BIT(PWR->CR, PWR_CR_PVDE);
299
+}
300
+
301
+/**
302
+  * @brief  Check if Power Voltage Detector is enabled
303
+  * @rmtoll CR    PVDE       LL_PWR_IsEnabledPVD
304
+  * @retval State of bit (1 or 0).
305
+  */
306
+__STATIC_INLINE uint32_t LL_PWR_IsEnabledPVD(void)
307
+{
308
+  return (READ_BIT(PWR->CR, PWR_CR_PVDE) == (PWR_CR_PVDE));
309
+}
310
+
311
+/**
312
+  * @brief  Enable the WakeUp PINx functionality
313
+  * @rmtoll CSR   EWUP       LL_PWR_EnableWakeUpPin
314
+  * @param  WakeUpPin This parameter can be one of the following values:
315
+  *         @arg @ref LL_PWR_WAKEUP_PIN1
316
+  * @retval None
317
+  */
318
+__STATIC_INLINE void LL_PWR_EnableWakeUpPin(uint32_t WakeUpPin)
319
+{
320
+  SET_BIT(PWR->CSR, WakeUpPin);
321
+}
322
+
323
+/**
324
+  * @brief  Disable the WakeUp PINx functionality
325
+  * @rmtoll CSR   EWUP       LL_PWR_DisableWakeUpPin
326
+  * @param  WakeUpPin This parameter can be one of the following values:
327
+  *         @arg @ref LL_PWR_WAKEUP_PIN1
328
+  * @retval None
329
+  */
330
+__STATIC_INLINE void LL_PWR_DisableWakeUpPin(uint32_t WakeUpPin)
331
+{
332
+  CLEAR_BIT(PWR->CSR, WakeUpPin);
333
+}
334
+
335
+/**
336
+  * @brief  Check if the WakeUp PINx functionality is enabled
337
+  * @rmtoll CSR   EWUP       LL_PWR_IsEnabledWakeUpPin
338
+  * @param  WakeUpPin This parameter can be one of the following values:
339
+  *         @arg @ref LL_PWR_WAKEUP_PIN1
340
+  * @retval State of bit (1 or 0).
341
+  */
342
+__STATIC_INLINE uint32_t LL_PWR_IsEnabledWakeUpPin(uint32_t WakeUpPin)
343
+{
344
+  return (READ_BIT(PWR->CSR, WakeUpPin) == (WakeUpPin));
345
+}
346
+
347
+
348
+/**
349
+  * @}
350
+  */
351
+
352
+/** @defgroup PWR_LL_EF_FLAG_Management FLAG_Management
353
+  * @{
354
+  */
355
+
356
+/**
357
+  * @brief  Get Wake-up Flag
358
+  * @rmtoll CSR   WUF       LL_PWR_IsActiveFlag_WU
359
+  * @retval State of bit (1 or 0).
360
+  */
361
+__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU(void)
362
+{
363
+  return (READ_BIT(PWR->CSR, PWR_CSR_WUF) == (PWR_CSR_WUF));
364
+}
365
+
366
+/**
367
+  * @brief  Get Standby Flag
368
+  * @rmtoll CSR   SBF       LL_PWR_IsActiveFlag_SB
369
+  * @retval State of bit (1 or 0).
370
+  */
371
+__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SB(void)
372
+{
373
+  return (READ_BIT(PWR->CSR, PWR_CSR_SBF) == (PWR_CSR_SBF));
374
+}
375
+
376
+/**
377
+  * @brief  Indicate whether VDD voltage is below the selected PVD threshold
378
+  * @rmtoll CSR   PVDO       LL_PWR_IsActiveFlag_PVDO
379
+  * @retval State of bit (1 or 0).
380
+  */
381
+__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVDO(void)
382
+{
383
+  return (READ_BIT(PWR->CSR, PWR_CSR_PVDO) == (PWR_CSR_PVDO));
384
+}
385
+
386
+/**
387
+  * @brief  Clear Standby Flag
388
+  * @rmtoll CR   CSBF       LL_PWR_ClearFlag_SB
389
+  * @retval None
390
+  */
391
+__STATIC_INLINE void LL_PWR_ClearFlag_SB(void)
392
+{
393
+  SET_BIT(PWR->CR, PWR_CR_CSBF);
394
+}
395
+
396
+/**
397
+  * @brief  Clear Wake-up Flags
398
+  * @rmtoll CR   CWUF       LL_PWR_ClearFlag_WU
399
+  * @retval None
400
+  */
401
+__STATIC_INLINE void LL_PWR_ClearFlag_WU(void)
402
+{
403
+  SET_BIT(PWR->CR, PWR_CR_CWUF);
404
+}
405
+
406
+/**
407
+  * @}
408
+  */
409
+
410
+#if defined(USE_FULL_LL_DRIVER)
411
+/** @defgroup PWR_LL_EF_Init De-initialization function
412
+  * @{
413
+  */
414
+ErrorStatus LL_PWR_DeInit(void);
415
+/**
416
+  * @}
417
+  */
418
+#endif /* USE_FULL_LL_DRIVER */
419
+
420
+/**
421
+  * @}
422
+  */
423
+
424
+/**
425
+  * @}
426
+  */
427
+
428
+#endif /* defined(PWR) */
429
+
430
+/**
431
+  * @}
432
+  */
433
+
434
+#ifdef __cplusplus
435
+}
436
+#endif
437
+
438
+#endif /* __STM32F1xx_LL_PWR_H */
439
+
440
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 1003
- 0
LLDrivers/inc/stm32f1xx_ll_rtc.h
File diff suppressed because it is too large
View File


+ 1112
- 0
LLDrivers/inc/stm32f1xx_ll_sdmmc.h
File diff suppressed because it is too large
View File


+ 1938
- 0
LLDrivers/inc/stm32f1xx_ll_spi.h
File diff suppressed because it is too large
View File


+ 3831
- 0
LLDrivers/inc/stm32f1xx_ll_tim.h
File diff suppressed because it is too large
View File


+ 2569
- 0
LLDrivers/inc/stm32f1xx_ll_usart.h
File diff suppressed because it is too large
View File


+ 651
- 0
LLDrivers/inc/stm32f1xx_ll_usb.h View File

@@ -0,0 +1,651 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_usb.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of USB Low Layer HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+/* Define to prevent recursive inclusion -------------------------------------*/
21
+#ifndef STM32F1xx_LL_USB_H
22
+#define STM32F1xx_LL_USB_H
23
+
24
+#ifdef __cplusplus
25
+extern "C" {
26
+#endif
27
+
28
+/* Includes ------------------------------------------------------------------*/
29
+#include "stm32f1xx_hal_def.h"
30
+
31
+#if defined (USB) || defined (USB_OTG_FS)
32
+/** @addtogroup STM32F1xx_HAL_Driver
33
+  * @{
34
+  */
35
+
36
+/** @addtogroup USB_LL
37
+  * @{
38
+  */
39
+
40
+/* Exported types ------------------------------------------------------------*/
41
+
42
+/**
43
+  * @brief  USB Mode definition
44
+  */
45
+#if defined (USB_OTG_FS)
46
+
47
+typedef enum
48
+{
49
+  USB_DEVICE_MODE  = 0,
50
+  USB_HOST_MODE    = 1,
51
+  USB_DRD_MODE     = 2
52
+} USB_ModeTypeDef;
53
+
54
+/**
55
+  * @brief  URB States definition
56
+  */
57
+typedef enum
58
+{
59
+  URB_IDLE = 0,
60
+  URB_DONE,
61
+  URB_NOTREADY,
62
+  URB_NYET,
63
+  URB_ERROR,
64
+  URB_STALL
65
+} USB_OTG_URBStateTypeDef;
66
+
67
+/**
68
+  * @brief  Host channel States  definition
69
+  */
70
+typedef enum
71
+{
72
+  HC_IDLE = 0,
73
+  HC_XFRC,
74
+  HC_HALTED,
75
+  HC_NAK,
76
+  HC_NYET,
77
+  HC_STALL,
78
+  HC_XACTERR,
79
+  HC_BBLERR,
80
+  HC_DATATGLERR
81
+} USB_OTG_HCStateTypeDef;
82
+
83
+/**
84
+  * @brief  USB OTG Initialization Structure definition
85
+  */
86
+typedef struct
87
+{
88
+  uint32_t dev_endpoints;           /*!< Device Endpoints number.
89
+                                         This parameter depends on the used USB core.
90
+                                         This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
91
+
92
+  uint32_t Host_channels;           /*!< Host Channels number.
93
+                                         This parameter Depends on the used USB core.
94
+                                         This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
95
+
96
+  uint32_t speed;                   /*!< USB Core speed.
97
+                                         This parameter can be any value of @ref USB_Core_Speed_                */
98
+
99
+  uint32_t dma_enable;              /*!< Enable or disable of the USB embedded DMA used only for OTG HS.        */
100
+
101
+  uint32_t ep0_mps;                 /*!< Set the Endpoint 0 Max Packet size.                                    */
102
+
103
+  uint32_t phy_itface;              /*!< Select the used PHY interface.
104
+                                         This parameter can be any value of @ref USB_Core_PHY_                  */
105
+
106
+  uint32_t Sof_enable;              /*!< Enable or disable the output of the SOF signal.                        */
107
+
108
+  uint32_t low_power_enable;        /*!< Enable or disable the low power mode.                                  */
109
+
110
+  uint32_t lpm_enable;              /*!< Enable or disable Link Power Management.                               */
111
+
112
+  uint32_t battery_charging_enable; /*!< Enable or disable Battery charging.                                    */
113
+
114
+  uint32_t vbus_sensing_enable;     /*!< Enable or disable the VBUS Sensing feature.                            */
115
+
116
+  uint32_t use_dedicated_ep1;       /*!< Enable or disable the use of the dedicated EP1 interrupt.              */
117
+
118
+  uint32_t use_external_vbus;       /*!< Enable or disable the use of the external VBUS.                        */
119
+} USB_OTG_CfgTypeDef;
120
+
121
+typedef struct
122
+{
123
+  uint8_t   num;                  /*!< Endpoint number
124
+                                       This parameter must be a number between Min_Data = 1 and Max_Data = 15   */
125
+
126
+  uint8_t   is_in;                /*!< Endpoint direction
127
+                                       This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
128
+
129
+  uint8_t   is_stall;             /*!< Endpoint stall condition
130
+                                       This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
131
+
132
+  uint8_t   type;                 /*!< Endpoint type
133
+                                       This parameter can be any value of @ref USB_EP_Type_                     */
134
+
135
+  uint8_t   data_pid_start;       /*!< Initial data PID
136
+                                       This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
137
+
138
+  uint8_t   even_odd_frame;       /*!< IFrame parity
139
+                                       This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
140
+
141
+  uint16_t  tx_fifo_num;          /*!< Transmission FIFO number
142
+                                       This parameter must be a number between Min_Data = 1 and Max_Data = 15   */
143
+
144
+  uint32_t  maxpacket;            /*!< Endpoint Max packet size
145
+                                       This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
146
+
147
+  uint8_t   *xfer_buff;           /*!< Pointer to transfer buffer                                               */
148
+
149
+  uint32_t  dma_addr;             /*!< 32 bits aligned transfer buffer address                                  */
150
+
151
+  uint32_t  xfer_len;             /*!< Current transfer length                                                  */
152
+
153
+  uint32_t  xfer_count;           /*!< Partial transfer length in case of multi packet transfer                 */
154
+} USB_OTG_EPTypeDef;
155
+
156
+typedef struct
157
+{
158
+  uint8_t   dev_addr ;          /*!< USB device address.
159
+                                     This parameter must be a number between Min_Data = 1 and Max_Data = 255    */
160
+
161
+  uint8_t   ch_num;             /*!< Host channel number.
162
+                                     This parameter must be a number between Min_Data = 1 and Max_Data = 15     */
163
+
164
+  uint8_t   ep_num;             /*!< Endpoint number.
165
+                                     This parameter must be a number between Min_Data = 1 and Max_Data = 15     */
166
+
167
+  uint8_t   ep_is_in;           /*!< Endpoint direction
168
+                                     This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
169
+
170
+  uint8_t   speed;              /*!< USB Host speed.
171
+                                     This parameter can be any value of @ref USB_Core_Speed_                    */
172
+
173
+  uint8_t   do_ping;            /*!< Enable or disable the use of the PING protocol for HS mode.                */
174
+
175
+  uint8_t   process_ping;       /*!< Execute the PING protocol for HS mode.                                     */
176
+
177
+  uint8_t   ep_type;            /*!< Endpoint Type.
178
+                                     This parameter can be any value of @ref USB_EP_Type_                       */
179
+
180
+  uint16_t  max_packet;         /*!< Endpoint Max packet size.
181
+                                     This parameter must be a number between Min_Data = 0 and Max_Data = 64KB   */
182
+
183
+  uint8_t   data_pid;           /*!< Initial data PID.
184
+                                     This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
185
+
186
+  uint8_t   *xfer_buff;         /*!< Pointer to transfer buffer.                                                */
187
+
188
+  uint32_t  xfer_len;           /*!< Current transfer length.                                                   */
189
+
190
+  uint32_t  xfer_count;         /*!< Partial transfer length in case of multi packet transfer.                  */
191
+
192
+  uint8_t   toggle_in;          /*!< IN transfer current toggle flag.
193
+                                     This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
194
+
195
+  uint8_t   toggle_out;         /*!< OUT transfer current toggle flag
196
+                                     This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
197
+
198
+  uint32_t  dma_addr;           /*!< 32 bits aligned transfer buffer address.                                   */
199
+
200
+  uint32_t  ErrCnt;             /*!< Host channel error count.*/
201
+
202
+  USB_OTG_URBStateTypeDef  urb_state;  /*!< URB state.
203
+                                            This parameter can be any value of @ref USB_OTG_URBStateTypeDef */
204
+
205
+  USB_OTG_HCStateTypeDef   state;     /*!< Host Channel state.
206
+                                           This parameter can be any value of @ref USB_OTG_HCStateTypeDef   */
207
+} USB_OTG_HCTypeDef;
208
+#endif /* defined (USB_OTG_FS) */
209
+
210
+#if defined (USB)
211
+
212
+typedef enum
213
+{
214
+  USB_DEVICE_MODE  = 0
215
+} USB_ModeTypeDef;
216
+
217
+/**
218
+  * @brief  USB Initialization Structure definition
219
+  */
220
+typedef struct
221
+{
222
+  uint32_t dev_endpoints;           /*!< Device Endpoints number.
223
+                                         This parameter depends on the used USB core.
224
+                                         This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
225
+
226
+  uint32_t speed;                   /*!< USB Core speed.
227
+                                         This parameter can be any value of @ref USB_Core_Speed                 */
228
+
229
+  uint32_t ep0_mps;                 /*!< Set the Endpoint 0 Max Packet size.                                    */
230
+
231
+  uint32_t phy_itface;              /*!< Select the used PHY interface.
232
+                                         This parameter can be any value of @ref USB_Core_PHY                   */
233
+
234
+  uint32_t Sof_enable;              /*!< Enable or disable the output of the SOF signal.                        */
235
+
236
+  uint32_t low_power_enable;        /*!< Enable or disable Low Power mode                                       */
237
+
238
+  uint32_t lpm_enable;              /*!< Enable or disable Battery charging.                                    */
239
+
240
+  uint32_t battery_charging_enable; /*!< Enable or disable Battery charging.                                    */
241
+} USB_CfgTypeDef;
242
+
243
+typedef struct
244
+{
245
+  uint8_t   num;             /*!< Endpoint number
246
+                                  This parameter must be a number between Min_Data = 1 and Max_Data = 15    */
247
+
248
+  uint8_t   is_in;           /*!< Endpoint direction
249
+                                  This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
250
+
251
+  uint8_t   is_stall;        /*!< Endpoint stall condition
252
+                                  This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
253
+
254
+  uint8_t   type;            /*!< Endpoint type
255
+                                  This parameter can be any value of @ref USB_EP_Type                       */
256
+
257
+  uint8_t   data_pid_start;  /*!< Initial data PID
258
+                                  This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
259
+
260
+  uint16_t  pmaadress;       /*!< PMA Address
261
+                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K    */
262
+
263
+  uint16_t  pmaaddr0;        /*!< PMA Address0
264
+                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K    */
265
+
266
+  uint16_t  pmaaddr1;        /*!< PMA Address1
267
+                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K    */
268
+
269
+  uint8_t   doublebuffer;    /*!< Double buffer enable
270
+                                  This parameter can be 0 or 1                                              */
271
+
272
+  uint16_t  tx_fifo_num;     /*!< This parameter is not required by USB Device FS peripheral, it is used
273
+                                  only by USB OTG FS peripheral
274
+                                  This parameter is added to ensure compatibility across USB peripherals    */
275
+
276
+  uint32_t  maxpacket;       /*!< Endpoint Max packet size
277
+                                  This parameter must be a number between Min_Data = 0 and Max_Data = 64KB  */
278
+
279
+  uint8_t   *xfer_buff;      /*!< Pointer to transfer buffer                                                */
280
+
281
+  uint32_t  xfer_len;        /*!< Current transfer length                                                   */
282
+
283
+  uint32_t  xfer_count;      /*!< Partial transfer length in case of multi packet transfer                  */
284
+
285
+} USB_EPTypeDef;
286
+#endif /* defined (USB) */
287
+
288
+/* Exported constants --------------------------------------------------------*/
289
+
290
+/** @defgroup PCD_Exported_Constants PCD Exported Constants
291
+  * @{
292
+  */
293
+
294
+#if defined (USB_OTG_FS)
295
+/** @defgroup USB_OTG_CORE VERSION ID
296
+  * @{
297
+  */
298
+#define USB_OTG_CORE_ID_300A          0x4F54300AU
299
+#define USB_OTG_CORE_ID_310A          0x4F54310AU
300
+/**
301
+  * @}
302
+  */
303
+
304
+/** @defgroup USB_Core_Mode_ USB Core Mode
305
+  * @{
306
+  */
307
+#define USB_OTG_MODE_DEVICE                    0U
308
+#define USB_OTG_MODE_HOST                      1U
309
+#define USB_OTG_MODE_DRD                       2U
310
+/**
311
+  * @}
312
+  */
313
+
314
+/** @defgroup USB_LL Device Speed
315
+  * @{
316
+  */
317
+#define USBD_FS_SPEED               2U
318
+#define USBH_FS_SPEED               1U
319
+/**
320
+  * @}
321
+  */
322
+
323
+/** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed
324
+  * @{
325
+  */
326
+#define USB_OTG_SPEED_FULL                     3U
327
+/**
328
+  * @}
329
+  */
330
+
331
+/** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY
332
+  * @{
333
+  */
334
+#define USB_OTG_ULPI_PHY                       1U
335
+#define USB_OTG_EMBEDDED_PHY                   2U
336
+/**
337
+  * @}
338
+  */
339
+
340
+/** @defgroup USB_LL_Turnaround_Timeout Turnaround Timeout Value
341
+  * @{
342
+  */
343
+#ifndef USBD_FS_TRDT_VALUE
344
+#define USBD_FS_TRDT_VALUE           5U
345
+#define USBD_DEFAULT_TRDT_VALUE      9U
346
+#endif /* USBD_HS_TRDT_VALUE */
347
+/**
348
+  * @}
349
+  */
350
+
351
+/** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS
352
+  * @{
353
+  */
354
+#define USB_OTG_FS_MAX_PACKET_SIZE             64U
355
+#define USB_OTG_MAX_EP0_SIZE                   64U
356
+/**
357
+  * @}
358
+  */
359
+
360
+/** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency
361
+  * @{
362
+  */
363
+#define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ     (0U << 1)
364
+#define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ     (1U << 1)
365
+#define DSTS_ENUMSPD_FS_PHY_48MHZ              (3U << 1)
366
+/**
367
+  * @}
368
+  */
369
+
370
+/** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval
371
+  * @{
372
+  */
373
+#define DCFG_FRAME_INTERVAL_80                 0U
374
+#define DCFG_FRAME_INTERVAL_85                 1U
375
+#define DCFG_FRAME_INTERVAL_90                 2U
376
+#define DCFG_FRAME_INTERVAL_95                 3U
377
+/**
378
+  * @}
379
+  */
380
+
381
+/** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
382
+  * @{
383
+  */
384
+#define DEP0CTL_MPS_64                         0U
385
+#define DEP0CTL_MPS_32                         1U
386
+#define DEP0CTL_MPS_16                         2U
387
+#define DEP0CTL_MPS_8                          3U
388
+/**
389
+  * @}
390
+  */
391
+
392
+/** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed
393
+  * @{
394
+  */
395
+#define EP_SPEED_LOW                           0U
396
+#define EP_SPEED_FULL                          1U
397
+#define EP_SPEED_HIGH                          2U
398
+/**
399
+  * @}
400
+  */
401
+
402
+/** @defgroup USB_LL_EP_Type USB Low Layer EP Type
403
+  * @{
404
+  */
405
+#define EP_TYPE_CTRL                           0U
406
+#define EP_TYPE_ISOC                           1U
407
+#define EP_TYPE_BULK                           2U
408
+#define EP_TYPE_INTR                           3U
409
+#define EP_TYPE_MSK                            3U
410
+/**
411
+  * @}
412
+  */
413
+
414
+/** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines
415
+  * @{
416
+  */
417
+#define STS_GOUT_NAK                           1U
418
+#define STS_DATA_UPDT                          2U
419
+#define STS_XFER_COMP                          3U
420
+#define STS_SETUP_COMP                         4U
421
+#define STS_SETUP_UPDT                         6U
422
+/**
423
+  * @}
424
+  */
425
+
426
+/** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines
427
+  * @{
428
+  */
429
+#define HCFG_30_60_MHZ                         0U
430
+#define HCFG_48_MHZ                            1U
431
+#define HCFG_6_MHZ                             2U
432
+/**
433
+  * @}
434
+  */
435
+
436
+/** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines
437
+  * @{
438
+  */
439
+#define HPRT0_PRTSPD_HIGH_SPEED                0U
440
+#define HPRT0_PRTSPD_FULL_SPEED                1U
441
+#define HPRT0_PRTSPD_LOW_SPEED                 2U
442
+/**
443
+  * @}
444
+  */
445
+
446
+#define HCCHAR_CTRL                            0U
447
+#define HCCHAR_ISOC                            1U
448
+#define HCCHAR_BULK                            2U
449
+#define HCCHAR_INTR                            3U
450
+
451
+#define HC_PID_DATA0                           0U
452
+#define HC_PID_DATA2                           1U
453
+#define HC_PID_DATA1                           2U
454
+#define HC_PID_SETUP                           3U
455
+
456
+#define GRXSTS_PKTSTS_IN                       2U
457
+#define GRXSTS_PKTSTS_IN_XFER_COMP             3U
458
+#define GRXSTS_PKTSTS_DATA_TOGGLE_ERR          5U
459
+#define GRXSTS_PKTSTS_CH_HALTED                7U
460
+
461
+#define USBx_PCGCCTL    *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_PCGCCTL_BASE)
462
+#define USBx_HPRT0      *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_HOST_PORT_BASE)
463
+
464
+#define USBx_DEVICE     ((USB_OTG_DeviceTypeDef *)(USBx_BASE + USB_OTG_DEVICE_BASE))
465
+#define USBx_INEP(i)    ((USB_OTG_INEndpointTypeDef *)(USBx_BASE + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
466
+#define USBx_OUTEP(i)   ((USB_OTG_OUTEndpointTypeDef *)(USBx_BASE + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
467
+#define USBx_DFIFO(i)   *(__IO uint32_t *)(USBx_BASE + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE))
468
+
469
+#define USBx_HOST       ((USB_OTG_HostTypeDef *)(USBx_BASE + USB_OTG_HOST_BASE))
470
+#define USBx_HC(i)      ((USB_OTG_HostChannelTypeDef *)(USBx_BASE + USB_OTG_HOST_CHANNEL_BASE + ((i) * USB_OTG_HOST_CHANNEL_SIZE)))
471
+#endif /* defined (USB_OTG_FS) */
472
+
473
+#if defined (USB)
474
+/** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
475
+  * @{
476
+  */
477
+#define DEP0CTL_MPS_64                         0U
478
+#define DEP0CTL_MPS_32                         1U
479
+#define DEP0CTL_MPS_16                         2U
480
+#define DEP0CTL_MPS_8                          3U
481
+/**
482
+  * @}
483
+  */
484
+
485
+/** @defgroup USB_LL_EP_Type USB Low Layer EP Type
486
+  * @{
487
+  */
488
+#define EP_TYPE_CTRL                           0U
489
+#define EP_TYPE_ISOC                           1U
490
+#define EP_TYPE_BULK                           2U
491
+#define EP_TYPE_INTR                           3U
492
+#define EP_TYPE_MSK                            3U
493
+/**
494
+  * @}
495
+  */
496
+
497
+/** @defgroup USB_LL Device Speed
498
+  * @{
499
+  */
500
+#define USBD_FS_SPEED                          2U
501
+/**
502
+  * @}
503
+  */
504
+
505
+#define BTABLE_ADDRESS                         0x000U
506
+#define PMA_ACCESS                             2U
507
+#endif /* defined (USB) */
508
+#if defined (USB_OTG_FS)
509
+#define EP_ADDR_MSK                            0xFU
510
+#endif /* defined (USB_OTG_FS) */
511
+#if defined (USB)
512
+#define EP_ADDR_MSK                            0x7U
513
+#endif /* defined (USB) */
514
+/**
515
+  * @}
516
+  */
517
+
518
+/* Exported macro ------------------------------------------------------------*/
519
+/** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros
520
+  * @{
521
+  */
522
+#if defined (USB_OTG_FS)
523
+#define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__)     ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__))
524
+#define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__)   ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__))
525
+
526
+#define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__)          (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__))
527
+#define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__)         (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__))
528
+#endif /* defined (USB_OTG_FS) */
529
+/**
530
+  * @}
531
+  */
532
+
533
+/* Exported functions --------------------------------------------------------*/
534
+/** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions
535
+  * @{
536
+  */
537
+#if defined (USB_OTG_FS)
538
+HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
539
+HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
540
+HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
541
+HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
542
+HAL_StatusTypeDef USB_SetTurnaroundTime(USB_OTG_GlobalTypeDef *USBx, uint32_t hclk, uint8_t speed);
543
+HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx, USB_ModeTypeDef mode);
544
+HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx, uint8_t speed);
545
+HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx);
546
+HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num);
547
+HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
548
+HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
549
+HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
550
+HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
551
+HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
552
+HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
553
+HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len);
554
+void             *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len);
555
+HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
556
+HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
557
+HAL_StatusTypeDef USB_SetDevAddress(USB_OTG_GlobalTypeDef *USBx, uint8_t address);
558
+HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx);
559
+HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx);
560
+HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx);
561
+HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx);
562
+HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t *psetup);
563
+uint8_t           USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx);
564
+uint32_t          USB_GetMode(USB_OTG_GlobalTypeDef *USBx);
565
+uint32_t          USB_ReadInterrupts(USB_OTG_GlobalTypeDef *USBx);
566
+uint32_t          USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx);
567
+uint32_t          USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum);
568
+uint32_t          USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx);
569
+uint32_t          USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum);
570
+void              USB_ClearInterrupts(USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt);
571
+
572
+HAL_StatusTypeDef USB_HostInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
573
+HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx, uint8_t freq);
574
+HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx);
575
+HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state);
576
+uint32_t          USB_GetHostSpeed(USB_OTG_GlobalTypeDef *USBx);
577
+uint32_t          USB_GetCurrentFrame(USB_OTG_GlobalTypeDef *USBx);
578
+HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,
579
+                              uint8_t ch_num,
580
+                              uint8_t epnum,
581
+                              uint8_t dev_address,
582
+                              uint8_t speed,
583
+                              uint8_t ep_type,
584
+                              uint16_t mps);
585
+HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDef *hc);
586
+uint32_t          USB_HC_ReadInterrupt(USB_OTG_GlobalTypeDef *USBx);
587
+HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx, uint8_t hc_num);
588
+HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num);
589
+HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx);
590
+HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
591
+HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
592
+#endif /* defined (USB_OTG_FS) */
593
+
594
+#if defined (USB)
595
+HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
596
+HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
597
+HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx);
598
+HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx);
599
+HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode);
600
+HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed);
601
+HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef *USBx);
602
+HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef *USBx, uint32_t num);
603
+HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
604
+HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
605
+HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep);
606
+HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len);
607
+void             *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len);
608
+HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
609
+HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
610
+HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address);
611
+HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx);
612
+HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx);
613
+HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx);
614
+HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup);
615
+uint32_t          USB_ReadInterrupts(USB_TypeDef *USBx);
616
+uint32_t          USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx);
617
+uint32_t          USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum);
618
+uint32_t          USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx);
619
+uint32_t          USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum);
620
+void              USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt);
621
+
622
+HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx);
623
+HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx);
624
+void USB_WritePMA(USB_TypeDef  *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
625
+void USB_ReadPMA(USB_TypeDef  *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
626
+#endif /* defined (USB) */
627
+/**
628
+  * @}
629
+  */
630
+
631
+/**
632
+  * @}
633
+  */
634
+
635
+/**
636
+  * @}
637
+  */
638
+
639
+/**
640
+  * @}
641
+  */
642
+#endif /* defined (USB) || defined (USB_OTG_FS) */
643
+
644
+#ifdef __cplusplus
645
+}
646
+#endif
647
+
648
+
649
+#endif /* STM32F1xx_LL_USB_H */
650
+
651
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 318
- 0
LLDrivers/inc/stm32f1xx_ll_wwdg.h View File

@@ -0,0 +1,318 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_wwdg.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of WWDG LL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+/* Define to prevent recursive inclusion -------------------------------------*/
21
+#ifndef STM32F1xx_LL_WWDG_H
22
+#define STM32F1xx_LL_WWDG_H
23
+
24
+#ifdef __cplusplus
25
+extern "C" {
26
+#endif
27
+
28
+/* Includes ------------------------------------------------------------------*/
29
+#include "stm32f1xx.h"
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined (WWDG)
36
+/** @defgroup WWDG_LL WWDG
37
+  * @{
38
+  */
39
+
40
+/* Private types -------------------------------------------------------------*/
41
+/* Private variables ---------------------------------------------------------*/
42
+/* Private constants ---------------------------------------------------------*/
43
+/* Private macros ------------------------------------------------------------*/
44
+/* Exported types ------------------------------------------------------------*/
45
+/* Exported constants --------------------------------------------------------*/
46
+/** @defgroup WWDG_LL_Exported_Constants WWDG Exported Constants
47
+  * @{
48
+  */
49
+
50
+/** @defgroup WWDG_LL_EC_IT IT Defines
51
+  * @brief    IT defines which can be used with LL_WWDG_ReadReg and  LL_WWDG_WriteReg functions
52
+  * @{
53
+  */
54
+#define LL_WWDG_CFR_EWI                    WWDG_CFR_EWI
55
+/**
56
+  * @}
57
+  */
58
+
59
+/** @defgroup WWDG_LL_EC_PRESCALER  PRESCALER
60
+* @{
61
+*/
62
+#define LL_WWDG_PRESCALER_1                0x00000000U                                             /*!< WWDG counter clock = (PCLK1/4096)/1 */
63
+#define LL_WWDG_PRESCALER_2                WWDG_CFR_WDGTB_0                                        /*!< WWDG counter clock = (PCLK1/4096)/2 */
64
+#define LL_WWDG_PRESCALER_4                WWDG_CFR_WDGTB_1                                        /*!< WWDG counter clock = (PCLK1/4096)/4 */
65
+#define LL_WWDG_PRESCALER_8                (WWDG_CFR_WDGTB_0 | WWDG_CFR_WDGTB_1)                   /*!< WWDG counter clock = (PCLK1/4096)/8 */
66
+/**
67
+  * @}
68
+  */
69
+
70
+/**
71
+  * @}
72
+  */
73
+
74
+/* Exported macro ------------------------------------------------------------*/
75
+/** @defgroup WWDG_LL_Exported_Macros WWDG Exported Macros
76
+  * @{
77
+  */
78
+/** @defgroup WWDG_LL_EM_WRITE_READ Common Write and read registers macros
79
+  * @{
80
+  */
81
+/**
82
+  * @brief  Write a value in WWDG register
83
+  * @param  __INSTANCE__ WWDG Instance
84
+  * @param  __REG__ Register to be written
85
+  * @param  __VALUE__ Value to be written in the register
86
+  * @retval None
87
+  */
88
+#define LL_WWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
89
+
90
+/**
91
+  * @brief  Read a value in WWDG register
92
+  * @param  __INSTANCE__ WWDG Instance
93
+  * @param  __REG__ Register to be read
94
+  * @retval Register value
95
+  */
96
+#define LL_WWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
97
+/**
98
+  * @}
99
+  */
100
+
101
+/**
102
+  * @}
103
+  */
104
+
105
+/* Exported functions --------------------------------------------------------*/
106
+/** @defgroup WWDG_LL_Exported_Functions WWDG Exported Functions
107
+  * @{
108
+  */
109
+
110
+/** @defgroup WWDG_LL_EF_Configuration Configuration
111
+  * @{
112
+  */
113
+/**
114
+  * @brief  Enable Window Watchdog. The watchdog is always disabled after a reset.
115
+  * @note   It is enabled by setting the WDGA bit in the WWDG_CR register,
116
+  *         then it cannot be disabled again except by a reset.
117
+  *         This bit is set by software and only cleared by hardware after a reset.
118
+  *         When WDGA = 1, the watchdog can generate a reset.
119
+  * @rmtoll CR           WDGA          LL_WWDG_Enable
120
+  * @param  WWDGx WWDG Instance
121
+  * @retval None
122
+  */
123
+__STATIC_INLINE void LL_WWDG_Enable(WWDG_TypeDef *WWDGx)
124
+{
125
+  SET_BIT(WWDGx->CR, WWDG_CR_WDGA);
126
+}
127
+
128
+/**
129
+  * @brief  Checks if Window Watchdog is enabled
130
+  * @rmtoll CR           WDGA          LL_WWDG_IsEnabled
131
+  * @param  WWDGx WWDG Instance
132
+  * @retval State of bit (1 or 0).
133
+  */
134
+__STATIC_INLINE uint32_t LL_WWDG_IsEnabled(WWDG_TypeDef *WWDGx)
135
+{
136
+  return ((READ_BIT(WWDGx->CR, WWDG_CR_WDGA) == (WWDG_CR_WDGA)) ? 1UL : 0UL);
137
+}
138
+
139
+/**
140
+  * @brief  Set the Watchdog counter value to provided value (7-bits T[6:0])
141
+  * @note   When writing to the WWDG_CR register, always write 1 in the MSB b6 to avoid generating an immediate reset
142
+  *         This counter is decremented every (4096 x 2expWDGTB) PCLK cycles
143
+  *         A reset is produced when it rolls over from 0x40 to 0x3F (bit T6 becomes cleared)
144
+  *         Setting the counter lower then 0x40 causes an immediate reset (if WWDG enabled)
145
+  * @rmtoll CR           T             LL_WWDG_SetCounter
146
+  * @param  WWDGx WWDG Instance
147
+  * @param  Counter 0..0x7F (7 bit counter value)
148
+  * @retval None
149
+  */
150
+__STATIC_INLINE void LL_WWDG_SetCounter(WWDG_TypeDef *WWDGx, uint32_t Counter)
151
+{
152
+  MODIFY_REG(WWDGx->CR, WWDG_CR_T, Counter);
153
+}
154
+
155
+/**
156
+  * @brief  Return current Watchdog Counter Value (7 bits counter value)
157
+  * @rmtoll CR           T             LL_WWDG_GetCounter
158
+  * @param  WWDGx WWDG Instance
159
+  * @retval 7 bit Watchdog Counter value
160
+  */
161
+__STATIC_INLINE uint32_t LL_WWDG_GetCounter(WWDG_TypeDef *WWDGx)
162
+{
163
+  return (READ_BIT(WWDGx->CR, WWDG_CR_T));
164
+}
165
+
166
+/**
167
+  * @brief  Set the time base of the prescaler (WDGTB).
168
+  * @note   Prescaler is used to apply ratio on PCLK clock, so that Watchdog counter
169
+  *         is decremented every (4096 x 2expWDGTB) PCLK cycles
170
+  * @rmtoll CFR          WDGTB         LL_WWDG_SetPrescaler
171
+  * @param  WWDGx WWDG Instance
172
+  * @param  Prescaler This parameter can be one of the following values:
173
+  *         @arg @ref LL_WWDG_PRESCALER_1
174
+  *         @arg @ref LL_WWDG_PRESCALER_2
175
+  *         @arg @ref LL_WWDG_PRESCALER_4
176
+  *         @arg @ref LL_WWDG_PRESCALER_8
177
+  * @retval None
178
+  */
179
+__STATIC_INLINE void LL_WWDG_SetPrescaler(WWDG_TypeDef *WWDGx, uint32_t Prescaler)
180
+{
181
+  MODIFY_REG(WWDGx->CFR, WWDG_CFR_WDGTB, Prescaler);
182
+}
183
+
184
+/**
185
+  * @brief  Return current Watchdog Prescaler Value
186
+  * @rmtoll CFR          WDGTB         LL_WWDG_GetPrescaler
187
+  * @param  WWDGx WWDG Instance
188
+  * @retval Returned value can be one of the following values:
189
+  *         @arg @ref LL_WWDG_PRESCALER_1
190
+  *         @arg @ref LL_WWDG_PRESCALER_2
191
+  *         @arg @ref LL_WWDG_PRESCALER_4
192
+  *         @arg @ref LL_WWDG_PRESCALER_8
193
+  */
194
+__STATIC_INLINE uint32_t LL_WWDG_GetPrescaler(WWDG_TypeDef *WWDGx)
195
+{
196
+  return (READ_BIT(WWDGx->CFR, WWDG_CFR_WDGTB));
197
+}
198
+
199
+/**
200
+  * @brief  Set the Watchdog Window value to be compared to the downcounter (7-bits W[6:0]).
201
+  * @note   This window value defines when write in the WWDG_CR register
202
+  *         to program Watchdog counter is allowed.
203
+  *         Watchdog counter value update must occur only when the counter value
204
+  *         is lower than the Watchdog window register value.
205
+  *         Otherwise, a MCU reset is generated if the 7-bit Watchdog counter value
206
+  *         (in the control register) is refreshed before the downcounter has reached
207
+  *         the watchdog window register value.
208
+  *         Physically is possible to set the Window lower then 0x40 but it is not recommended.
209
+  *         To generate an immediate reset, it is possible to set the Counter lower than 0x40.
210
+  * @rmtoll CFR          W             LL_WWDG_SetWindow
211
+  * @param  WWDGx WWDG Instance
212
+  * @param  Window 0x00..0x7F (7 bit Window value)
213
+  * @retval None
214
+  */
215
+__STATIC_INLINE void LL_WWDG_SetWindow(WWDG_TypeDef *WWDGx, uint32_t Window)
216
+{
217
+  MODIFY_REG(WWDGx->CFR, WWDG_CFR_W, Window);
218
+}
219
+
220
+/**
221
+  * @brief  Return current Watchdog Window Value (7 bits value)
222
+  * @rmtoll CFR          W             LL_WWDG_GetWindow
223
+  * @param  WWDGx WWDG Instance
224
+  * @retval 7 bit Watchdog Window value
225
+  */
226
+__STATIC_INLINE uint32_t LL_WWDG_GetWindow(WWDG_TypeDef *WWDGx)
227
+{
228
+  return (READ_BIT(WWDGx->CFR, WWDG_CFR_W));
229
+}
230
+
231
+/**
232
+  * @}
233
+  */
234
+
235
+/** @defgroup WWDG_LL_EF_FLAG_Management FLAG_Management
236
+  * @{
237
+  */
238
+/**
239
+  * @brief  Indicates if the WWDG Early Wakeup Interrupt Flag is set or not.
240
+  * @note   This bit is set by hardware when the counter has reached the value 0x40.
241
+  *         It must be cleared by software by writing 0.
242
+  *         A write of 1 has no effect. This bit is also set if the interrupt is not enabled.
243
+  * @rmtoll SR           EWIF          LL_WWDG_IsActiveFlag_EWKUP
244
+  * @param  WWDGx WWDG Instance
245
+  * @retval State of bit (1 or 0).
246
+  */
247
+__STATIC_INLINE uint32_t LL_WWDG_IsActiveFlag_EWKUP(WWDG_TypeDef *WWDGx)
248
+{
249
+  return ((READ_BIT(WWDGx->SR, WWDG_SR_EWIF) == (WWDG_SR_EWIF)) ? 1UL : 0UL);  
250
+}
251
+
252
+/**
253
+  * @brief  Clear WWDG Early Wakeup Interrupt Flag (EWIF)
254
+  * @rmtoll SR           EWIF          LL_WWDG_ClearFlag_EWKUP
255
+  * @param  WWDGx WWDG Instance
256
+  * @retval None
257
+  */
258
+__STATIC_INLINE void LL_WWDG_ClearFlag_EWKUP(WWDG_TypeDef *WWDGx)
259
+{
260
+  WRITE_REG(WWDGx->SR, ~WWDG_SR_EWIF);
261
+}
262
+
263
+/**
264
+  * @}
265
+  */
266
+
267
+/** @defgroup WWDG_LL_EF_IT_Management IT_Management
268
+  * @{
269
+  */
270
+/**
271
+  * @brief  Enable the Early Wakeup Interrupt.
272
+  * @note   When set, an interrupt occurs whenever the counter reaches value 0x40.
273
+  *         This interrupt is only cleared by hardware after a reset
274
+  * @rmtoll CFR          EWI           LL_WWDG_EnableIT_EWKUP
275
+  * @param  WWDGx WWDG Instance
276
+  * @retval None
277
+  */
278
+__STATIC_INLINE void LL_WWDG_EnableIT_EWKUP(WWDG_TypeDef *WWDGx)
279
+{
280
+  SET_BIT(WWDGx->CFR, WWDG_CFR_EWI);
281
+}
282
+
283
+/**
284
+  * @brief  Check if Early Wakeup Interrupt is enabled
285
+  * @rmtoll CFR          EWI           LL_WWDG_IsEnabledIT_EWKUP
286
+  * @param  WWDGx WWDG Instance
287
+  * @retval State of bit (1 or 0).
288
+  */
289
+__STATIC_INLINE uint32_t LL_WWDG_IsEnabledIT_EWKUP(WWDG_TypeDef *WWDGx)
290
+{
291
+  return ((READ_BIT(WWDGx->CFR, WWDG_CFR_EWI) == (WWDG_CFR_EWI)) ? 1UL : 0UL);
292
+}
293
+
294
+/**
295
+  * @}
296
+  */
297
+
298
+/**
299
+  * @}
300
+  */
301
+
302
+/**
303
+  * @}
304
+  */
305
+
306
+#endif /* WWDG */
307
+
308
+/**
309
+  * @}
310
+  */
311
+
312
+#ifdef __cplusplus
313
+}
314
+#endif
315
+
316
+#endif /* STM32F1xx_LL_WWDG_H */
317
+
318
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 886
- 0
LLDrivers/src/stm32f1xx_ll_adc.c View File

@@ -0,0 +1,886 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_adc.c
4
+  * @author  MCD Application Team
5
+  * @brief   ADC LL module driver
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+#if defined(USE_FULL_LL_DRIVER)
21
+
22
+/* Includes ------------------------------------------------------------------*/
23
+#include "stm32f1xx_ll_adc.h"
24
+#include "stm32f1xx_ll_bus.h"
25
+
26
+#ifdef  USE_FULL_ASSERT
27
+  #include "stm32_assert.h"
28
+#else
29
+  #define assert_param(expr) ((void)0U)
30
+#endif
31
+
32
+/** @addtogroup STM32F1xx_LL_Driver
33
+  * @{
34
+  */
35
+
36
+#if defined (ADC1) || defined (ADC2) || defined (ADC3)
37
+
38
+/** @addtogroup ADC_LL ADC
39
+  * @{
40
+  */
41
+
42
+/* Private types -------------------------------------------------------------*/
43
+/* Private variables ---------------------------------------------------------*/
44
+/* Private constants ---------------------------------------------------------*/
45
+/* Private macros ------------------------------------------------------------*/
46
+
47
+/** @addtogroup ADC_LL_Private_Macros
48
+  * @{
49
+  */
50
+
51
+/* Check of parameters for configuration of ADC hierarchical scope:           */
52
+/* common to several ADC instances.                                           */
53
+/* Check of parameters for configuration of ADC hierarchical scope:           */
54
+/* ADC instance.                                                              */
55
+#define IS_LL_ADC_DATA_ALIGN(__DATA_ALIGN__)                                   \
56
+  (   ((__DATA_ALIGN__) == LL_ADC_DATA_ALIGN_RIGHT)                            \
57
+   || ((__DATA_ALIGN__) == LL_ADC_DATA_ALIGN_LEFT)                             \
58
+  )
59
+
60
+#define IS_LL_ADC_SCAN_SELECTION(__SCAN_SELECTION__)                           \
61
+  (   ((__SCAN_SELECTION__) == LL_ADC_SEQ_SCAN_DISABLE)                        \
62
+   || ((__SCAN_SELECTION__) == LL_ADC_SEQ_SCAN_ENABLE)                         \
63
+  )
64
+
65
+#define IS_LL_ADC_SEQ_SCAN_MODE(__SEQ_SCAN_MODE__)                             \
66
+  (   ((__SCAN_MODE__) == LL_ADC_SEQ_SCAN_DISABLE)                             \
67
+   || ((__SCAN_MODE__) == LL_ADC_SEQ_SCAN_ENABLE)                              \
68
+  )
69
+
70
+/* Check of parameters for configuration of ADC hierarchical scope:           */
71
+/* ADC group regular                                                          */
72
+#if defined(ADC3)
73
+#define IS_LL_ADC_REG_TRIG_SOURCE(__ADC_INSTANCE__, __REG_TRIG_SOURCE__)       \
74
+  ((((__ADC_INSTANCE__) == ADC1) || ((__ADC_INSTANCE__) == ADC2))              \
75
+    ? (   ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_SOFTWARE)                  \
76
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH3)              \
77
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH1)              \
78
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH2)              \
79
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH2)              \
80
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_TRGO)             \
81
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM4_CH4)              \
82
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_EXTI_LINE11)           \
83
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM8_TRGO)             \
84
+      )                                                                        \
85
+      :                                                                        \
86
+      (   ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_SOFTWARE)                  \
87
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH3)              \
88
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_CH1)              \
89
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH3)              \
90
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM8_CH1)              \
91
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM8_TRGO_ADC3)        \
92
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM5_CH1)              \
93
+       || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM5_CH3)              \
94
+      )                                                                        \
95
+  )
96
+#else
97
+#if defined (STM32F101xE) || defined (STM32F105xC) || defined (STM32F107xC)
98
+#define IS_LL_ADC_REG_TRIG_SOURCE(__REG_TRIG_SOURCE__)                         \
99
+  (   ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_SOFTWARE)                      \
100
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH3)                  \
101
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH1)                  \
102
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH2)                  \
103
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH2)                  \
104
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_TRGO)                 \
105
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM4_CH4)                  \
106
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_EXTI_LINE11)               \
107
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM8_TRGO)                 \
108
+  )
109
+#else
110
+#define IS_LL_ADC_REG_TRIG_SOURCE(__REG_TRIG_SOURCE__)                         \
111
+  (   ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_SOFTWARE)                      \
112
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH3)                  \
113
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH1)                  \
114
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH2)                  \
115
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH2)                  \
116
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_TRGO)                 \
117
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM4_CH4)                  \
118
+   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_EXTI_LINE11)               \
119
+  )
120
+#endif
121
+#endif
122
+#define IS_LL_ADC_REG_CONTINUOUS_MODE(__REG_CONTINUOUS_MODE__)                 \
123
+  (   ((__REG_CONTINUOUS_MODE__) == LL_ADC_REG_CONV_SINGLE)                    \
124
+   || ((__REG_CONTINUOUS_MODE__) == LL_ADC_REG_CONV_CONTINUOUS)                \
125
+  )
126
+
127
+#define IS_LL_ADC_REG_DMA_TRANSFER(__REG_DMA_TRANSFER__)                       \
128
+  (   ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_NONE)                 \
129
+   || ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_UNLIMITED)            \
130
+  )
131
+
132
+#define IS_LL_ADC_REG_SEQ_SCAN_LENGTH(__REG_SEQ_SCAN_LENGTH__)                 \
133
+  (   ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_DISABLE)               \
134
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS)         \
135
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS)         \
136
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS)         \
137
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS)         \
138
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS)         \
139
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS)         \
140
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS)         \
141
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS)         \
142
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS)        \
143
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS)        \
144
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS)        \
145
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS)        \
146
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS)        \
147
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS)        \
148
+   || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS)        \
149
+  )
150
+
151
+#define IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(__REG_SEQ_DISCONT_MODE__)          \
152
+  (   ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_DISABLE)           \
153
+   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_1RANK)             \
154
+   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_2RANKS)            \
155
+   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_3RANKS)            \
156
+   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_4RANKS)            \
157
+   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_5RANKS)            \
158
+   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_6RANKS)            \
159
+   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_7RANKS)            \
160
+   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_8RANKS)            \
161
+  )
162
+
163
+/* Check of parameters for configuration of ADC hierarchical scope:           */
164
+/* ADC group injected                                                         */
165
+#if defined(ADC3)
166
+#define IS_LL_ADC_INJ_TRIG_SOURCE(__ADC_INSTANCE__, __INJ_TRIG_SOURCE__)       \
167
+  ((((__ADC_INSTANCE__) == ADC1) || ((__ADC_INSTANCE__) == ADC2))              \
168
+    ? (   ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_SOFTWARE)                  \
169
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_TRGO)             \
170
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_CH4)              \
171
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_TRGO)             \
172
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_CH1)              \
173
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_CH4)              \
174
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_TRGO)             \
175
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_EXTI_LINE15)           \
176
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_CH4)              \
177
+      )                                                                        \
178
+      :                                                                        \
179
+      (   ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_SOFTWARE)                  \
180
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_TRGO)             \
181
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_CH4)              \
182
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_CH3)              \
183
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_CH2)              \
184
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_CH4_ADC3)         \
185
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM5_TRGO)             \
186
+       || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM5_CH4)              \
187
+      )                                                                        \
188
+  )
189
+#else
190
+#if defined (STM32F101xE) || defined (STM32F105xC) || defined (STM32F107xC)
191
+#define IS_LL_ADC_INJ_TRIG_SOURCE(__INJ_TRIG_SOURCE__)                         \
192
+  (   ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_SOFTWARE)                      \
193
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_TRGO)                 \
194
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_CH4)                  \
195
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_TRGO)                 \
196
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_CH1)                  \
197
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_CH4)                  \
198
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_TRGO)                 \
199
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_EXTI_LINE15)               \
200
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_CH4)                  \
201
+  )
202
+#else
203
+#define IS_LL_ADC_INJ_TRIG_SOURCE(__INJ_TRIG_SOURCE__)                         \
204
+  (   ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_SOFTWARE)                      \
205
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_TRGO)                 \
206
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_CH4)                  \
207
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_TRGO)                 \
208
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_CH1)                  \
209
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_CH4)                  \
210
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_TRGO)                 \
211
+   || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_EXTI_LINE15)               \
212
+  )
213
+#endif
214
+#endif
215
+#define IS_LL_ADC_INJ_TRIG_AUTO(__INJ_TRIG_AUTO__)                             \
216
+  (   ((__INJ_TRIG_AUTO__) == LL_ADC_INJ_TRIG_INDEPENDENT)                     \
217
+   || ((__INJ_TRIG_AUTO__) == LL_ADC_INJ_TRIG_FROM_GRP_REGULAR)                \
218
+  )
219
+
220
+#define IS_LL_ADC_INJ_SEQ_SCAN_LENGTH(__INJ_SEQ_SCAN_LENGTH__)                 \
221
+  (   ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_DISABLE)               \
222
+   || ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS)         \
223
+   || ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS)         \
224
+   || ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS)         \
225
+  )
226
+
227
+#define IS_LL_ADC_INJ_SEQ_SCAN_DISCONT_MODE(__INJ_SEQ_DISCONT_MODE__)          \
228
+  (   ((__INJ_SEQ_DISCONT_MODE__) == LL_ADC_INJ_SEQ_DISCONT_DISABLE)           \
229
+   || ((__INJ_SEQ_DISCONT_MODE__) == LL_ADC_INJ_SEQ_DISCONT_1RANK)             \
230
+  )
231
+
232
+#if defined(ADC_MULTIMODE_SUPPORT)
233
+/* Check of parameters for configuration of ADC hierarchical scope:           */
234
+/* multimode.                                                                 */
235
+#define IS_LL_ADC_MULTI_MODE(__MULTI_MODE__)                                   \
236
+  (   ((__MULTI_MODE__) == LL_ADC_MULTI_INDEPENDENT)                           \
237
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIMULT)                       \
238
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INTERL_FAST)                  \
239
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INTERL_SLOW)                  \
240
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_INJ_SIMULT)                       \
241
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_INJ_ALTERN)                       \
242
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM)                  \
243
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT)                  \
244
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INTFAST_INJ_SIM)              \
245
+   || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INTSLOW_INJ_SIM)              \
246
+  )
247
+
248
+#define IS_LL_ADC_MULTI_MASTER_SLAVE(__MULTI_MASTER_SLAVE__)                   \
249
+  (   ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_MASTER)                        \
250
+   || ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_SLAVE)                         \
251
+   || ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_MASTER_SLAVE)                  \
252
+  )
253
+
254
+#endif /* ADC_MULTIMODE_SUPPORT */
255
+/**
256
+  * @}
257
+  */
258
+
259
+
260
+/* Private function prototypes -----------------------------------------------*/
261
+
262
+/* Exported functions --------------------------------------------------------*/
263
+/** @addtogroup ADC_LL_Exported_Functions
264
+  * @{
265
+  */
266
+
267
+/** @addtogroup ADC_LL_EF_Init
268
+  * @{
269
+  */
270
+
271
+/**
272
+  * @brief  De-initialize registers of all ADC instances belonging to
273
+  *         the same ADC common instance to their default reset values.
274
+  * @param  ADCxy_COMMON ADC common instance
275
+  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
276
+  * @retval An ErrorStatus enumeration value:
277
+  *          - SUCCESS: ADC common registers are de-initialized
278
+  *          - ERROR: not applicable
279
+  */
280
+ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON)
281
+{
282
+  /* Check the parameters */
283
+  assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON));
284
+  
285
+  /* Force reset of ADC clock (core clock) */
286
+  LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_ADC1);
287
+  
288
+  /* Release reset of ADC clock (core clock) */
289
+  LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_ADC1);
290
+  
291
+  return SUCCESS;
292
+}
293
+
294
+/**
295
+  * @brief  Initialize some features of ADC common parameters
296
+  *         (all ADC instances belonging to the same ADC common instance)
297
+  *         and multimode (for devices with several ADC instances available).
298
+  * @note   The setting of ADC common parameters is conditioned to
299
+  *         ADC instances state:
300
+  *         All ADC instances belonging to the same ADC common instance
301
+  *         must be disabled.
302
+  * @param  ADCxy_COMMON ADC common instance
303
+  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
304
+  * @param  ADC_CommonInitStruct Pointer to a @ref LL_ADC_CommonInitTypeDef structure
305
+  * @retval An ErrorStatus enumeration value:
306
+  *          - SUCCESS: ADC common registers are initialized
307
+  *          - ERROR: ADC common registers are not initialized
308
+  */
309
+ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct)
310
+{
311
+  ErrorStatus status = SUCCESS;
312
+  
313
+  /* Check the parameters */
314
+  assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON));
315
+#if defined(ADC_MULTIMODE_SUPPORT)
316
+  assert_param(IS_LL_ADC_MULTI_MODE(ADC_CommonInitStruct->Multimode));
317
+#endif /* ADC_MULTIMODE_SUPPORT */
318
+
319
+  /* Note: Hardware constraint (refer to description of functions             */
320
+  /*       "LL_ADC_SetCommonXXX()" and "LL_ADC_SetMultiXXX()"):               */
321
+  /*       On this STM32 serie, setting of these features is conditioned to   */
322
+  /*       ADC state:                                                         */
323
+  /*       All ADC instances of the ADC common group must be disabled.        */
324
+  if(__LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(ADCxy_COMMON) == 0U)
325
+  {
326
+    /* Configuration of ADC hierarchical scope:                               */
327
+    /*  - common to several ADC                                               */
328
+    /*    (all ADC instances belonging to the same ADC common instance)       */
329
+    /*  - multimode (if several ADC instances available on the                */
330
+    /*    selected device)                                                    */
331
+    /*    - Set ADC multimode configuration                                   */
332
+    /*    - Set ADC multimode DMA transfer                                    */
333
+    /*    - Set ADC multimode: delay between 2 sampling phases                */
334
+#if defined(ADC_MULTIMODE_SUPPORT)
335
+    if(ADC_CommonInitStruct->Multimode != LL_ADC_MULTI_INDEPENDENT)
336
+    {
337
+      MODIFY_REG(ADCxy_COMMON->CR1,
338
+                 ADC_CR1_DUALMOD,
339
+                 ADC_CommonInitStruct->Multimode
340
+                );
341
+    }
342
+    else
343
+    {
344
+      MODIFY_REG(ADCxy_COMMON->CR1,
345
+                 ADC_CR1_DUALMOD,
346
+                 LL_ADC_MULTI_INDEPENDENT
347
+                );
348
+    }
349
+#endif
350
+  }
351
+  else
352
+  {
353
+    /* Initialization error: One or several ADC instances belonging to        */
354
+    /* the same ADC common instance are not disabled.                         */
355
+    status = ERROR;
356
+  }
357
+  
358
+  return status;
359
+}
360
+
361
+/**
362
+  * @brief  Set each @ref LL_ADC_CommonInitTypeDef field to default value.
363
+  * @param  ADC_CommonInitStruct Pointer to a @ref LL_ADC_CommonInitTypeDef structure
364
+  *                              whose fields will be set to default values.
365
+  * @retval None
366
+  */
367
+void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct)
368
+{
369
+  /* Set ADC_CommonInitStruct fields to default values */
370
+  /* Set fields of ADC common */
371
+  /* (all ADC instances belonging to the same ADC common instance) */
372
+  
373
+#if defined(ADC_MULTIMODE_SUPPORT)
374
+  /* Set fields of ADC multimode */
375
+  ADC_CommonInitStruct->Multimode             = LL_ADC_MULTI_INDEPENDENT;
376
+#endif /* ADC_MULTIMODE_SUPPORT */
377
+}
378
+
379
+/**
380
+  * @brief  De-initialize registers of the selected ADC instance
381
+  *         to their default reset values.
382
+  * @note   To reset all ADC instances quickly (perform a hard reset),
383
+  *         use function @ref LL_ADC_CommonDeInit().
384
+  * @param  ADCx ADC instance
385
+  * @retval An ErrorStatus enumeration value:
386
+  *          - SUCCESS: ADC registers are de-initialized
387
+  *          - ERROR: ADC registers are not de-initialized
388
+  */
389
+ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx)
390
+{
391
+  ErrorStatus status = SUCCESS;
392
+  
393
+  /* Check the parameters */
394
+  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
395
+  
396
+  /* Disable ADC instance if not already disabled.                            */
397
+  if(LL_ADC_IsEnabled(ADCx) == 1U)
398
+  {
399
+    /* Set ADC group regular trigger source to SW start to ensure to not      */
400
+    /* have an external trigger event occurring during the conversion stop    */
401
+    /* ADC disable process.                                                   */
402
+    LL_ADC_REG_SetTriggerSource(ADCx, LL_ADC_REG_TRIG_SOFTWARE);
403
+    
404
+    /* Set ADC group injected trigger source to SW start to ensure to not     */
405
+    /* have an external trigger event occurring during the conversion stop    */
406
+    /* ADC disable process.                                                   */
407
+    LL_ADC_INJ_SetTriggerSource(ADCx, LL_ADC_INJ_TRIG_SOFTWARE);
408
+    
409
+    /* Disable the ADC instance */
410
+    LL_ADC_Disable(ADCx);
411
+  }
412
+  
413
+  /* Check whether ADC state is compliant with expected state */
414
+  /* (hardware requirements of bits state to reset registers below) */
415
+  if(READ_BIT(ADCx->CR2, ADC_CR2_ADON) == 0U)
416
+  {
417
+    /* ========== Reset ADC registers ========== */
418
+    /* Reset register SR */
419
+    CLEAR_BIT(ADCx->SR,
420
+              (  LL_ADC_FLAG_STRT
421
+               | LL_ADC_FLAG_JSTRT
422
+               | LL_ADC_FLAG_EOS
423
+               | LL_ADC_FLAG_JEOS
424
+               | LL_ADC_FLAG_AWD1 )
425
+             );
426
+    
427
+    /* Reset register CR1 */
428
+  #if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
429
+
430
+    CLEAR_BIT(ADCx->CR1,
431
+              (  ADC_CR1_AWDEN   | ADC_CR1_JAWDEN  | ADC_CR1_DUALMOD
432
+               | ADC_CR1_DISCNUM | ADC_CR1_JDISCEN | ADC_CR1_DISCEN
433
+               | ADC_CR1_JAUTO   | ADC_CR1_AWDSGL  | ADC_CR1_SCAN
434
+               | ADC_CR1_JEOCIE  | ADC_CR1_AWDIE   | ADC_CR1_EOCIE
435
+               | ADC_CR1_AWDCH                                     )
436
+             );
437
+  #else 
438
+
439
+    CLEAR_BIT(ADCx->CR1,
440
+              (  ADC_CR1_AWDEN   | ADC_CR1_JAWDEN  | ADC_CR1_DISCNUM 
441
+               | ADC_CR1_JDISCEN | ADC_CR1_DISCEN  | ADC_CR1_JAUTO
442
+               | ADC_CR1_AWDSGL  | ADC_CR1_SCAN    | ADC_CR1_JEOCIE  
443
+               | ADC_CR1_AWDIE   | ADC_CR1_EOCIE   | ADC_CR1_AWDCH )
444
+             );
445
+  #endif
446
+    
447
+    /* Reset register CR2 */
448
+    CLEAR_BIT(ADCx->CR2,
449
+              (  ADC_CR2_TSVREFE
450
+               | ADC_CR2_SWSTART  | ADC_CR2_EXTTRIG  | ADC_CR2_EXTSEL
451
+               | ADC_CR2_JSWSTART | ADC_CR2_JEXTTRIG | ADC_CR2_JEXTSEL
452
+               | ADC_CR2_ALIGN    | ADC_CR2_DMA
453
+               | ADC_CR2_RSTCAL   | ADC_CR2_CAL
454
+               | ADC_CR2_CONT     | ADC_CR2_ADON                      )
455
+             );
456
+    
457
+    /* Reset register SMPR1 */
458
+    CLEAR_BIT(ADCx->SMPR1,
459
+              (  ADC_SMPR1_SMP17 | ADC_SMPR1_SMP16
460
+               | ADC_SMPR1_SMP15 | ADC_SMPR1_SMP14 | ADC_SMPR1_SMP13
461
+               | ADC_SMPR1_SMP12 | ADC_SMPR1_SMP11 | ADC_SMPR1_SMP10)
462
+             );
463
+    
464
+    /* Reset register SMPR2 */
465
+    CLEAR_BIT(ADCx->SMPR2,
466
+              (  ADC_SMPR2_SMP9
467
+               | ADC_SMPR2_SMP8 | ADC_SMPR2_SMP7 | ADC_SMPR2_SMP6
468
+               | ADC_SMPR2_SMP5 | ADC_SMPR2_SMP4 | ADC_SMPR2_SMP3
469
+               | ADC_SMPR2_SMP2 | ADC_SMPR2_SMP1 | ADC_SMPR2_SMP0)
470
+             );
471
+    
472
+    /* Reset register JOFR1 */
473
+    CLEAR_BIT(ADCx->JOFR1, ADC_JOFR1_JOFFSET1);
474
+    /* Reset register JOFR2 */
475
+    CLEAR_BIT(ADCx->JOFR2, ADC_JOFR2_JOFFSET2);
476
+    /* Reset register JOFR3 */
477
+    CLEAR_BIT(ADCx->JOFR3, ADC_JOFR3_JOFFSET3);
478
+    /* Reset register JOFR4 */
479
+    CLEAR_BIT(ADCx->JOFR4, ADC_JOFR4_JOFFSET4);
480
+    
481
+    /* Reset register HTR */
482
+    SET_BIT(ADCx->HTR, ADC_HTR_HT);
483
+    /* Reset register LTR */
484
+    CLEAR_BIT(ADCx->LTR, ADC_LTR_LT);
485
+    
486
+    /* Reset register SQR1 */
487
+    CLEAR_BIT(ADCx->SQR1,
488
+              (  ADC_SQR1_L
489
+               | ADC_SQR1_SQ16
490
+               | ADC_SQR1_SQ15 | ADC_SQR1_SQ14 | ADC_SQR1_SQ13)
491
+             );
492
+             
493
+    /* Reset register SQR2 */
494
+    CLEAR_BIT(ADCx->SQR2,
495
+              (  ADC_SQR2_SQ12 | ADC_SQR2_SQ11 | ADC_SQR2_SQ10
496
+               | ADC_SQR2_SQ9 | ADC_SQR2_SQ8 | ADC_SQR2_SQ7)
497
+             );
498
+    
499
+    
500
+    /* Reset register JSQR */
501
+    CLEAR_BIT(ADCx->JSQR,
502
+              (  ADC_JSQR_JL
503
+               | ADC_JSQR_JSQ4 | ADC_JSQR_JSQ3
504
+               | ADC_JSQR_JSQ2 | ADC_JSQR_JSQ1  )
505
+             );
506
+    
507
+    /* Reset register DR */
508
+    /* bits in access mode read only, no direct reset applicable */
509
+    
510
+    /* Reset registers JDR1, JDR2, JDR3, JDR4 */
511
+    /* bits in access mode read only, no direct reset applicable */
512
+    
513
+  }
514
+  
515
+  return status;
516
+}
517
+
518
+/**
519
+  * @brief  Initialize some features of ADC instance.
520
+  * @note   These parameters have an impact on ADC scope: ADC instance.
521
+  *         Affects both group regular and group injected (availability
522
+  *         of ADC group injected depends on STM32 families).
523
+  *         Refer to corresponding unitary functions into
524
+  *         @ref ADC_LL_EF_Configuration_ADC_Instance .
525
+  * @note   The setting of these parameters by function @ref LL_ADC_Init()
526
+  *         is conditioned to ADC state:
527
+  *         ADC instance must be disabled.
528
+  *         This condition is applied to all ADC features, for efficiency
529
+  *         and compatibility over all STM32 families. However, the different
530
+  *         features can be set under different ADC state conditions
531
+  *         (setting possible with ADC enabled without conversion on going,
532
+  *         ADC enabled with conversion on going, ...)
533
+  *         Each feature can be updated afterwards with a unitary function
534
+  *         and potentially with ADC in a different state than disabled,
535
+  *         refer to description of each function for setting
536
+  *         conditioned to ADC state.
537
+  * @note   After using this function, some other features must be configured
538
+  *         using LL unitary functions.
539
+  *         The minimum configuration remaining to be done is:
540
+  *          - Set ADC group regular or group injected sequencer:
541
+  *            map channel on the selected sequencer rank.
542
+  *            Refer to function @ref LL_ADC_REG_SetSequencerRanks().
543
+  *          - Set ADC channel sampling time
544
+  *            Refer to function LL_ADC_SetChannelSamplingTime();
545
+  * @param  ADCx ADC instance
546
+  * @param  ADC_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
547
+  * @retval An ErrorStatus enumeration value:
548
+  *          - SUCCESS: ADC registers are initialized
549
+  *          - ERROR: ADC registers are not initialized
550
+  */
551
+ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct)
552
+{
553
+  ErrorStatus status = SUCCESS;
554
+  
555
+  /* Check the parameters */
556
+  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
557
+  
558
+  assert_param(IS_LL_ADC_DATA_ALIGN(ADC_InitStruct->DataAlignment));
559
+  assert_param(IS_LL_ADC_SCAN_SELECTION(ADC_InitStruct->SequencersScanMode));
560
+  
561
+  /* Note: Hardware constraint (refer to description of this function):       */
562
+  /*       ADC instance must be disabled.                                     */
563
+  if(LL_ADC_IsEnabled(ADCx) == 0U)
564
+  {
565
+    /* Configuration of ADC hierarchical scope:                               */
566
+    /*  - ADC instance                                                        */
567
+    /*    - Set ADC conversion data alignment                                 */
568
+    MODIFY_REG(ADCx->CR1,
569
+                 ADC_CR1_SCAN
570
+              ,
571
+                 ADC_InitStruct->SequencersScanMode
572
+              );
573
+    
574
+    MODIFY_REG(ADCx->CR2,
575
+                 ADC_CR2_ALIGN
576
+              ,
577
+                 ADC_InitStruct->DataAlignment
578
+              );
579
+
580
+  }
581
+  else
582
+  {
583
+    /* Initialization error: ADC instance is not disabled. */
584
+    status = ERROR;
585
+  }
586
+  return status;
587
+}
588
+
589
+/**
590
+  * @brief  Set each @ref LL_ADC_InitTypeDef field to default value.
591
+  * @param  ADC_InitStruct Pointer to a @ref LL_ADC_InitTypeDef structure
592
+  *                        whose fields will be set to default values.
593
+  * @retval None
594
+  */
595
+void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct)
596
+{
597
+  /* Set ADC_InitStruct fields to default values */
598
+  /* Set fields of ADC instance */
599
+  ADC_InitStruct->DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
600
+  
601
+  /* Enable scan mode to have a generic behavior with ADC of other            */
602
+  /* STM32 families, without this setting available:                          */
603
+  /* ADC group regular sequencer and ADC group injected sequencer depend      */
604
+  /* only of their own configuration.                                         */
605
+  ADC_InitStruct->SequencersScanMode      = LL_ADC_SEQ_SCAN_ENABLE;
606
+  
607
+}
608
+
609
+/**
610
+  * @brief  Initialize some features of ADC group regular.
611
+  * @note   These parameters have an impact on ADC scope: ADC group regular.
612
+  *         Refer to corresponding unitary functions into
613
+  *         @ref ADC_LL_EF_Configuration_ADC_Group_Regular
614
+  *         (functions with prefix "REG").
615
+  * @note   The setting of these parameters by function @ref LL_ADC_Init()
616
+  *         is conditioned to ADC state:
617
+  *         ADC instance must be disabled.
618
+  *         This condition is applied to all ADC features, for efficiency
619
+  *         and compatibility over all STM32 families. However, the different
620
+  *         features can be set under different ADC state conditions
621
+  *         (setting possible with ADC enabled without conversion on going,
622
+  *         ADC enabled with conversion on going, ...)
623
+  *         Each feature can be updated afterwards with a unitary function
624
+  *         and potentially with ADC in a different state than disabled,
625
+  *         refer to description of each function for setting
626
+  *         conditioned to ADC state.
627
+  * @note   After using this function, other features must be configured
628
+  *         using LL unitary functions.
629
+  *         The minimum configuration remaining to be done is:
630
+  *          - Set ADC group regular or group injected sequencer:
631
+  *            map channel on the selected sequencer rank.
632
+  *            Refer to function @ref LL_ADC_REG_SetSequencerRanks().
633
+  *          - Set ADC channel sampling time
634
+  *            Refer to function LL_ADC_SetChannelSamplingTime();
635
+  * @param  ADCx ADC instance
636
+  * @param  ADC_REG_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
637
+  * @retval An ErrorStatus enumeration value:
638
+  *          - SUCCESS: ADC registers are initialized
639
+  *          - ERROR: ADC registers are not initialized
640
+  */
641
+ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct)
642
+{
643
+  ErrorStatus status = SUCCESS;
644
+  
645
+  /* Check the parameters */
646
+  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
647
+#if defined(ADC3)
648
+  assert_param(IS_LL_ADC_REG_TRIG_SOURCE(ADCx, ADC_REG_InitStruct->TriggerSource));
649
+#else
650
+  assert_param(IS_LL_ADC_REG_TRIG_SOURCE(ADC_REG_InitStruct->TriggerSource));
651
+#endif
652
+  assert_param(IS_LL_ADC_REG_SEQ_SCAN_LENGTH(ADC_REG_InitStruct->SequencerLength));
653
+  if(ADC_REG_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
654
+  {
655
+    assert_param(IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(ADC_REG_InitStruct->SequencerDiscont));
656
+  }
657
+  assert_param(IS_LL_ADC_REG_CONTINUOUS_MODE(ADC_REG_InitStruct->ContinuousMode));
658
+  assert_param(IS_LL_ADC_REG_DMA_TRANSFER(ADC_REG_InitStruct->DMATransfer));
659
+  
660
+  /* Note: Hardware constraint (refer to description of this function):       */
661
+  /*       ADC instance must be disabled.                                     */
662
+  if(LL_ADC_IsEnabled(ADCx) == 0U)
663
+  {
664
+    /* Configuration of ADC hierarchical scope:                               */
665
+    /*  - ADC group regular                                                   */
666
+    /*    - Set ADC group regular trigger source                              */
667
+    /*    - Set ADC group regular sequencer length                            */
668
+    /*    - Set ADC group regular sequencer discontinuous mode                */
669
+    /*    - Set ADC group regular continuous mode                             */
670
+    /*    - Set ADC group regular conversion data transfer: no transfer or    */
671
+    /*      transfer by DMA, and DMA requests mode                            */
672
+    /* Note: On this STM32 serie, ADC trigger edge is set when starting       */
673
+    /*       ADC conversion.                                                  */
674
+    /*       Refer to function @ref LL_ADC_REG_StartConversionExtTrig().      */
675
+    if(ADC_REG_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
676
+    {
677
+      MODIFY_REG(ADCx->CR1,
678
+                   ADC_CR1_DISCEN
679
+                 | ADC_CR1_DISCNUM
680
+                ,
681
+                   ADC_REG_InitStruct->SequencerLength
682
+                 | ADC_REG_InitStruct->SequencerDiscont
683
+                );
684
+    }
685
+    else
686
+    {
687
+      MODIFY_REG(ADCx->CR1,
688
+                   ADC_CR1_DISCEN
689
+                 | ADC_CR1_DISCNUM
690
+                ,
691
+                   ADC_REG_InitStruct->SequencerLength
692
+                 | LL_ADC_REG_SEQ_DISCONT_DISABLE
693
+                );
694
+    }
695
+    
696
+    MODIFY_REG(ADCx->CR2,
697
+                 ADC_CR2_EXTSEL
698
+               | ADC_CR2_CONT
699
+               | ADC_CR2_DMA
700
+              ,
701
+                 ADC_REG_InitStruct->TriggerSource
702
+               | ADC_REG_InitStruct->ContinuousMode
703
+               | ADC_REG_InitStruct->DMATransfer
704
+              );
705
+
706
+    /* Set ADC group regular sequencer length and scan direction */
707
+    /* Note: Hardware constraint (refer to description of this function):     */
708
+    /* Note: If ADC instance feature scan mode is disabled                    */
709
+    /*       (refer to  ADC instance initialization structure                 */
710
+    /*       parameter @ref SequencersScanMode                                */
711
+    /*       or function @ref LL_ADC_SetSequencersScanMode() ),               */
712
+    /*       this parameter is discarded.                                     */
713
+    LL_ADC_REG_SetSequencerLength(ADCx, ADC_REG_InitStruct->SequencerLength);
714
+  }
715
+  else
716
+  {
717
+    /* Initialization error: ADC instance is not disabled. */
718
+    status = ERROR;
719
+  }
720
+  return status;
721
+}
722
+
723
+/**
724
+  * @brief  Set each @ref LL_ADC_REG_InitTypeDef field to default value.
725
+  * @param  ADC_REG_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
726
+  *                            whose fields will be set to default values.
727
+  * @retval None
728
+  */
729
+void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct)
730
+{
731
+  /* Set ADC_REG_InitStruct fields to default values */
732
+  /* Set fields of ADC group regular */
733
+  /* Note: On this STM32 serie, ADC trigger edge is set when starting         */
734
+  /*       ADC conversion.                                                    */
735
+  /*       Refer to function @ref LL_ADC_REG_StartConversionExtTrig().        */
736
+  ADC_REG_InitStruct->TriggerSource    = LL_ADC_REG_TRIG_SOFTWARE;
737
+  ADC_REG_InitStruct->SequencerLength  = LL_ADC_REG_SEQ_SCAN_DISABLE;
738
+  ADC_REG_InitStruct->SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
739
+  ADC_REG_InitStruct->ContinuousMode   = LL_ADC_REG_CONV_SINGLE;
740
+  ADC_REG_InitStruct->DMATransfer      = LL_ADC_REG_DMA_TRANSFER_NONE;
741
+}
742
+
743
+/**
744
+  * @brief  Initialize some features of ADC group injected.
745
+  * @note   These parameters have an impact on ADC scope: ADC group injected.
746
+  *         Refer to corresponding unitary functions into
747
+  *         @ref ADC_LL_EF_Configuration_ADC_Group_Regular
748
+  *         (functions with prefix "INJ").
749
+  * @note   The setting of these parameters by function @ref LL_ADC_Init()
750
+  *         is conditioned to ADC state:
751
+  *         ADC instance must be disabled.
752
+  *         This condition is applied to all ADC features, for efficiency
753
+  *         and compatibility over all STM32 families. However, the different
754
+  *         features can be set under different ADC state conditions
755
+  *         (setting possible with ADC enabled without conversion on going,
756
+  *         ADC enabled with conversion on going, ...)
757
+  *         Each feature can be updated afterwards with a unitary function
758
+  *         and potentially with ADC in a different state than disabled,
759
+  *         refer to description of each function for setting
760
+  *         conditioned to ADC state.
761
+  * @note   After using this function, other features must be configured
762
+  *         using LL unitary functions.
763
+  *         The minimum configuration remaining to be done is:
764
+  *          - Set ADC group injected sequencer:
765
+  *            map channel on the selected sequencer rank.
766
+  *            Refer to function @ref LL_ADC_INJ_SetSequencerRanks().
767
+  *          - Set ADC channel sampling time
768
+  *            Refer to function LL_ADC_SetChannelSamplingTime();
769
+  * @param  ADCx ADC instance
770
+  * @param  ADC_INJ_InitStruct Pointer to a @ref LL_ADC_INJ_InitTypeDef structure
771
+  * @retval An ErrorStatus enumeration value:
772
+  *          - SUCCESS: ADC registers are initialized
773
+  *          - ERROR: ADC registers are not initialized
774
+  */
775
+ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct)
776
+{
777
+  ErrorStatus status = SUCCESS;
778
+  
779
+  /* Check the parameters */
780
+  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
781
+#if defined(ADC3)
782
+  assert_param(IS_LL_ADC_INJ_TRIG_SOURCE(ADCx, ADC_INJ_InitStruct->TriggerSource));
783
+#else
784
+  assert_param(IS_LL_ADC_INJ_TRIG_SOURCE(ADC_INJ_InitStruct->TriggerSource));
785
+#endif
786
+  assert_param(IS_LL_ADC_INJ_SEQ_SCAN_LENGTH(ADC_INJ_InitStruct->SequencerLength));
787
+  if(ADC_INJ_InitStruct->SequencerLength != LL_ADC_INJ_SEQ_SCAN_DISABLE)
788
+  {
789
+    assert_param(IS_LL_ADC_INJ_SEQ_SCAN_DISCONT_MODE(ADC_INJ_InitStruct->SequencerDiscont));
790
+  }
791
+  assert_param(IS_LL_ADC_INJ_TRIG_AUTO(ADC_INJ_InitStruct->TrigAuto));
792
+  
793
+  /* Note: Hardware constraint (refer to description of this function):       */
794
+  /*       ADC instance must be disabled.                                     */
795
+  if(LL_ADC_IsEnabled(ADCx) == 0U)
796
+  {
797
+    /* Configuration of ADC hierarchical scope:                               */
798
+    /*  - ADC group injected                                                  */
799
+    /*    - Set ADC group injected trigger source                             */
800
+    /*    - Set ADC group injected sequencer length                           */
801
+    /*    - Set ADC group injected sequencer discontinuous mode               */
802
+    /*    - Set ADC group injected conversion trigger: independent or         */
803
+    /*      from ADC group regular                                            */
804
+    /* Note: On this STM32 serie, ADC trigger edge is set when starting       */
805
+    /*       ADC conversion.                                                  */
806
+    /*       Refer to function @ref LL_ADC_INJ_StartConversionExtTrig().      */
807
+    if(ADC_INJ_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
808
+    {
809
+      MODIFY_REG(ADCx->CR1,
810
+                   ADC_CR1_JDISCEN
811
+                 | ADC_CR1_JAUTO
812
+                ,
813
+                   ADC_INJ_InitStruct->SequencerDiscont
814
+                 | ADC_INJ_InitStruct->TrigAuto
815
+                );
816
+    }
817
+    else
818
+    {
819
+      MODIFY_REG(ADCx->CR1,
820
+                   ADC_CR1_JDISCEN
821
+                 | ADC_CR1_JAUTO
822
+                ,
823
+                   LL_ADC_REG_SEQ_DISCONT_DISABLE
824
+                 | ADC_INJ_InitStruct->TrigAuto
825
+                );
826
+    }
827
+    
828
+    MODIFY_REG(ADCx->CR2,
829
+               ADC_CR2_JEXTSEL
830
+              ,
831
+               ADC_INJ_InitStruct->TriggerSource
832
+              );
833
+    
834
+    /* Note: Hardware constraint (refer to description of this function):     */
835
+    /* Note: If ADC instance feature scan mode is disabled                    */
836
+    /*       (refer to  ADC instance initialization structure                 */
837
+    /*       parameter @ref SequencersScanMode                                */
838
+    /*       or function @ref LL_ADC_SetSequencersScanMode() ),               */
839
+    /*       this parameter is discarded.                                     */
840
+    LL_ADC_INJ_SetSequencerLength(ADCx, ADC_INJ_InitStruct->SequencerLength);
841
+  }
842
+  else
843
+  {
844
+    /* Initialization error: ADC instance is not disabled. */
845
+    status = ERROR;
846
+  }
847
+  return status;
848
+}
849
+
850
+/**
851
+  * @brief  Set each @ref LL_ADC_INJ_InitTypeDef field to default value.
852
+  * @param  ADC_INJ_InitStruct Pointer to a @ref LL_ADC_INJ_InitTypeDef structure
853
+  *                            whose fields will be set to default values.
854
+  * @retval None
855
+  */
856
+void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct)
857
+{
858
+  /* Set ADC_INJ_InitStruct fields to default values */
859
+  /* Set fields of ADC group injected */
860
+  ADC_INJ_InitStruct->TriggerSource    = LL_ADC_INJ_TRIG_SOFTWARE;
861
+  ADC_INJ_InitStruct->SequencerLength  = LL_ADC_INJ_SEQ_SCAN_DISABLE;
862
+  ADC_INJ_InitStruct->SequencerDiscont = LL_ADC_INJ_SEQ_DISCONT_DISABLE;
863
+  ADC_INJ_InitStruct->TrigAuto         = LL_ADC_INJ_TRIG_INDEPENDENT;
864
+}
865
+
866
+/**
867
+  * @}
868
+  */
869
+
870
+/**
871
+  * @}
872
+  */
873
+
874
+/**
875
+  * @}
876
+  */
877
+
878
+#endif /* ADC1 || ADC2 || ADC3 */
879
+
880
+/**
881
+  * @}
882
+  */
883
+
884
+#endif /* USE_FULL_LL_DRIVER */
885
+
886
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 108
- 0
LLDrivers/src/stm32f1xx_ll_crc.c View File

@@ -0,0 +1,108 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_crc.c
4
+  * @author  MCD Application Team
5
+  * @brief   CRC LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+#if defined(USE_FULL_LL_DRIVER)
20
+
21
+/* Includes ------------------------------------------------------------------*/
22
+#include "stm32f1xx_ll_crc.h"
23
+#include "stm32f1xx_ll_bus.h"
24
+
25
+#ifdef  USE_FULL_ASSERT
26
+#include "stm32_assert.h"
27
+#else
28
+#define assert_param(expr) ((void)0U)
29
+#endif
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined (CRC)
36
+
37
+/** @addtogroup CRC_LL
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/* Private macros ------------------------------------------------------------*/
45
+/* Private function prototypes -----------------------------------------------*/
46
+
47
+/* Exported functions --------------------------------------------------------*/
48
+/** @addtogroup CRC_LL_Exported_Functions
49
+  * @{
50
+  */
51
+
52
+/** @addtogroup CRC_LL_EF_Init
53
+  * @{
54
+  */
55
+
56
+/**
57
+  * @brief  De-initialize CRC registers (Registers restored to their default values).
58
+  * @param  CRCx CRC Instance
59
+  * @retval An ErrorStatus enumeration value:
60
+  *          - SUCCESS: CRC registers are de-initialized
61
+  *          - ERROR: CRC registers are not de-initialized
62
+  */
63
+ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx)
64
+{
65
+  ErrorStatus status = SUCCESS;
66
+
67
+  /* Check the parameters */
68
+  assert_param(IS_CRC_ALL_INSTANCE(CRCx));
69
+
70
+  if (CRCx == CRC)
71
+  {
72
+
73
+    /* Reset the CRC calculation unit */
74
+    LL_CRC_ResetCRCCalculationUnit(CRCx);
75
+
76
+    /* Reset IDR register */
77
+    LL_CRC_Write_IDR(CRCx, 0x00U);
78
+  }
79
+  else
80
+  {
81
+    status = ERROR;
82
+  }
83
+
84
+  return (status);
85
+}
86
+
87
+/**
88
+  * @}
89
+  */
90
+
91
+/**
92
+  * @}
93
+  */
94
+
95
+/**
96
+  * @}
97
+  */
98
+
99
+#endif /* defined (CRC) */
100
+
101
+/**
102
+  * @}
103
+  */
104
+
105
+#endif /* USE_FULL_LL_DRIVER */
106
+
107
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
108
+

+ 274
- 0
LLDrivers/src/stm32f1xx_ll_dac.c View File

@@ -0,0 +1,274 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_dac.c
4
+  * @author  MCD Application Team
5
+  * @brief   DAC LL module driver
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+#if defined(USE_FULL_LL_DRIVER)
20
+
21
+/* Includes ------------------------------------------------------------------*/
22
+#include "stm32f1xx_ll_dac.h"
23
+#include "stm32f1xx_ll_bus.h"
24
+
25
+#ifdef USE_FULL_ASSERT
26
+#include "stm32_assert.h"
27
+#else
28
+#define assert_param(expr) ((void)0U)
29
+#endif
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined(DAC)
36
+
37
+/** @addtogroup DAC_LL DAC
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/* Private macros ------------------------------------------------------------*/
45
+
46
+/** @addtogroup DAC_LL_Private_Macros
47
+  * @{
48
+  */
49
+#define IS_LL_DAC_CHANNEL(__DAC_CHANNEL__)                                     \
50
+  (                                                                            \
51
+      ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_1)                                  \
52
+   || ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_2)                                  \
53
+  )
54
+
55
+#define IS_LL_DAC_TRIGGER_SOURCE(__TRIGGER_SOURCE__)                           \
56
+  (   ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_SOFTWARE)                           \
57
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM3_TRGO)                      \
58
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM15_TRGO)                     \
59
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM2_TRGO)                      \
60
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM4_TRGO)                      \
61
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM5_TRGO)                      \
62
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM6_TRGO)                      \
63
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM7_TRGO)                      \
64
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM8_TRGO)                      \
65
+   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_EXTI_LINE9)                     \
66
+  )
67
+
68
+#define IS_LL_DAC_WAVE_AUTO_GENER_MODE(__WAVE_AUTO_GENERATION_MODE__)           \
69
+  (   ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NONE)     \
70
+   || ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NOISE)    \
71
+   || ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE) \
72
+  )
73
+
74
+#define IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(__WAVE_AUTO_GENERATION_MODE__, __WAVE_AUTO_GENERATION_CONFIG__)  \
75
+  ( (((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NOISE)                               \
76
+    && (  ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BIT0)                            \
77
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS1_0)                         \
78
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS2_0)                         \
79
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS3_0)                         \
80
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS4_0)                         \
81
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS5_0)                         \
82
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS6_0)                         \
83
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS7_0)                         \
84
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS8_0)                         \
85
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS9_0)                         \
86
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS10_0)                        \
87
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS11_0))                       \
88
+    )                                                                                                     \
89
+  ||(((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE)                            \
90
+    && (  ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_1)                              \
91
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_3)                              \
92
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_7)                              \
93
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_15)                             \
94
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_31)                             \
95
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_63)                             \
96
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_127)                            \
97
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_255)                            \
98
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_511)                            \
99
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_1023)                           \
100
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_2047)                           \
101
+       || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_4095))                          \
102
+    )                                                                                                     \
103
+  )
104
+
105
+#define IS_LL_DAC_OUTPUT_BUFFER(__OUTPUT_BUFFER__)                             \
106
+  (   ((__OUTPUT_BUFFER__) == LL_DAC_OUTPUT_BUFFER_ENABLE)                     \
107
+   || ((__OUTPUT_BUFFER__) == LL_DAC_OUTPUT_BUFFER_DISABLE)                    \
108
+  )
109
+
110
+/**
111
+  * @}
112
+  */
113
+
114
+
115
+/* Private function prototypes -----------------------------------------------*/
116
+
117
+/* Exported functions --------------------------------------------------------*/
118
+/** @addtogroup DAC_LL_Exported_Functions
119
+  * @{
120
+  */
121
+
122
+/** @addtogroup DAC_LL_EF_Init
123
+  * @{
124
+  */
125
+
126
+/**
127
+  * @brief  De-initialize registers of the selected DAC instance
128
+  *         to their default reset values.
129
+  * @param  DACx DAC instance
130
+  * @retval An ErrorStatus enumeration value:
131
+  *          - SUCCESS: DAC registers are de-initialized
132
+  *          - ERROR: not applicable
133
+  */
134
+ErrorStatus LL_DAC_DeInit(DAC_TypeDef *DACx)
135
+{
136
+  /* Check the parameters */
137
+  assert_param(IS_DAC_ALL_INSTANCE(DACx));
138
+
139
+  /* Force reset of DAC clock */
140
+  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_DAC1);
141
+
142
+  /* Release reset of DAC clock */
143
+  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_DAC1);
144
+
145
+  return SUCCESS;
146
+}
147
+
148
+/**
149
+  * @brief  Initialize some features of DAC channel.
150
+  * @note   @ref LL_DAC_Init() aims to ease basic configuration of a DAC channel.
151
+  *         Leaving it ready to be enabled and output:
152
+  *         a level by calling one of
153
+  *           @ref LL_DAC_ConvertData12RightAligned
154
+  *           @ref LL_DAC_ConvertData12LeftAligned
155
+  *           @ref LL_DAC_ConvertData8RightAligned
156
+  *         or one of the supported autogenerated wave.
157
+  * @note   This function allows configuration of:
158
+  *          - Output mode
159
+  *          - Trigger
160
+  *          - Wave generation
161
+  * @note   The setting of these parameters by function @ref LL_DAC_Init()
162
+  *         is conditioned to DAC state:
163
+  *         DAC channel must be disabled.
164
+  * @param  DACx DAC instance
165
+  * @param  DAC_Channel This parameter can be one of the following values:
166
+  *         @arg @ref LL_DAC_CHANNEL_1
167
+  *         @arg @ref LL_DAC_CHANNEL_2
168
+  * @param  DAC_InitStruct Pointer to a @ref LL_DAC_InitTypeDef structure
169
+  * @retval An ErrorStatus enumeration value:
170
+  *          - SUCCESS: DAC registers are initialized
171
+  *          - ERROR: DAC registers are not initialized
172
+  */
173
+ErrorStatus LL_DAC_Init(DAC_TypeDef *DACx, uint32_t DAC_Channel, LL_DAC_InitTypeDef *DAC_InitStruct)
174
+{
175
+  ErrorStatus status = SUCCESS;
176
+
177
+  /* Check the parameters */
178
+  assert_param(IS_DAC_ALL_INSTANCE(DACx));
179
+  assert_param(IS_LL_DAC_CHANNEL(DAC_Channel));
180
+  assert_param(IS_LL_DAC_TRIGGER_SOURCE(DAC_InitStruct->TriggerSource));
181
+  assert_param(IS_LL_DAC_OUTPUT_BUFFER(DAC_InitStruct->OutputBuffer));
182
+  assert_param(IS_LL_DAC_WAVE_AUTO_GENER_MODE(DAC_InitStruct->WaveAutoGeneration));
183
+  if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE)
184
+  {
185
+    assert_param(IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(DAC_InitStruct->WaveAutoGeneration,
186
+                                                  DAC_InitStruct->WaveAutoGenerationConfig));
187
+  }
188
+
189
+  /* Note: Hardware constraint (refer to description of this function)        */
190
+  /*       DAC instance must be disabled.                                     */
191
+  if (LL_DAC_IsEnabled(DACx, DAC_Channel) == 0U)
192
+  {
193
+    /* Configuration of DAC channel:                                          */
194
+    /*  - TriggerSource                                                       */
195
+    /*  - WaveAutoGeneration                                                  */
196
+    /*  - OutputBuffer                                                        */
197
+    /*  - OutputMode                                                          */
198
+    if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE)
199
+    {
200
+      MODIFY_REG(DACx->CR,
201
+                 (DAC_CR_TSEL1
202
+                  | DAC_CR_WAVE1
203
+                  | DAC_CR_MAMP1
204
+                  | DAC_CR_BOFF1
205
+                 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
206
+                 ,
207
+                 (DAC_InitStruct->TriggerSource
208
+                  | DAC_InitStruct->WaveAutoGeneration
209
+                  | DAC_InitStruct->WaveAutoGenerationConfig
210
+                  | DAC_InitStruct->OutputBuffer
211
+                 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
212
+                );
213
+    }
214
+    else
215
+    {
216
+      MODIFY_REG(DACx->CR,
217
+                 (DAC_CR_TSEL1
218
+                  | DAC_CR_WAVE1
219
+                  | DAC_CR_BOFF1
220
+                 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
221
+                 ,
222
+                 (DAC_InitStruct->TriggerSource
223
+                  | LL_DAC_WAVE_AUTO_GENERATION_NONE
224
+                  | DAC_InitStruct->OutputBuffer
225
+                 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
226
+                );
227
+    }
228
+  }
229
+  else
230
+  {
231
+    /* Initialization error: DAC instance is not disabled.                    */
232
+    status = ERROR;
233
+  }
234
+  return status;
235
+}
236
+
237
+/**
238
+  * @brief Set each @ref LL_DAC_InitTypeDef field to default value.
239
+  * @param DAC_InitStruct pointer to a @ref LL_DAC_InitTypeDef structure
240
+  *                       whose fields will be set to default values.
241
+  * @retval None
242
+  */
243
+void LL_DAC_StructInit(LL_DAC_InitTypeDef *DAC_InitStruct)
244
+{
245
+  /* Set DAC_InitStruct fields to default values */
246
+  DAC_InitStruct->TriggerSource            = LL_DAC_TRIG_SOFTWARE;
247
+  DAC_InitStruct->WaveAutoGeneration       = LL_DAC_WAVE_AUTO_GENERATION_NONE;
248
+  /* Note: Parameter discarded if wave auto generation is disabled,           */
249
+  /*       set anyway to its default value.                                   */
250
+  DAC_InitStruct->WaveAutoGenerationConfig = LL_DAC_NOISE_LFSR_UNMASK_BIT0;
251
+  DAC_InitStruct->OutputBuffer             = LL_DAC_OUTPUT_BUFFER_ENABLE;
252
+}
253
+
254
+/**
255
+  * @}
256
+  */
257
+
258
+/**
259
+  * @}
260
+  */
261
+
262
+/**
263
+  * @}
264
+  */
265
+
266
+#endif /* DAC */
267
+
268
+/**
269
+  * @}
270
+  */
271
+
272
+#endif /* USE_FULL_LL_DRIVER */
273
+
274
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 314
- 0
LLDrivers/src/stm32f1xx_ll_dma.c View File

@@ -0,0 +1,314 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_dma.c
4
+  * @author  MCD Application Team
5
+  * @brief   DMA LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+#if defined(USE_FULL_LL_DRIVER)
21
+
22
+/* Includes ------------------------------------------------------------------*/
23
+#include "stm32f1xx_ll_dma.h"
24
+#include "stm32f1xx_ll_bus.h"
25
+#ifdef  USE_FULL_ASSERT
26
+#include "stm32_assert.h"
27
+#else
28
+#define assert_param(expr) ((void)0U)
29
+#endif
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined (DMA1) || defined (DMA2)
36
+
37
+/** @defgroup DMA_LL DMA
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/* Private macros ------------------------------------------------------------*/
45
+/** @addtogroup DMA_LL_Private_Macros
46
+  * @{
47
+  */
48
+#define IS_LL_DMA_DIRECTION(__VALUE__)          (((__VALUE__) == LL_DMA_DIRECTION_PERIPH_TO_MEMORY) || \
49
+                                                 ((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_PERIPH) || \
50
+                                                 ((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_MEMORY))
51
+
52
+#define IS_LL_DMA_MODE(__VALUE__)               (((__VALUE__) == LL_DMA_MODE_NORMAL) || \
53
+                                                 ((__VALUE__) == LL_DMA_MODE_CIRCULAR))
54
+
55
+#define IS_LL_DMA_PERIPHINCMODE(__VALUE__)      (((__VALUE__) == LL_DMA_PERIPH_INCREMENT) || \
56
+                                                 ((__VALUE__) == LL_DMA_PERIPH_NOINCREMENT))
57
+
58
+#define IS_LL_DMA_MEMORYINCMODE(__VALUE__)      (((__VALUE__) == LL_DMA_MEMORY_INCREMENT) || \
59
+                                                 ((__VALUE__) == LL_DMA_MEMORY_NOINCREMENT))
60
+
61
+#define IS_LL_DMA_PERIPHDATASIZE(__VALUE__)     (((__VALUE__) == LL_DMA_PDATAALIGN_BYTE)      || \
62
+                                                 ((__VALUE__) == LL_DMA_PDATAALIGN_HALFWORD)  || \
63
+                                                 ((__VALUE__) == LL_DMA_PDATAALIGN_WORD))
64
+
65
+#define IS_LL_DMA_MEMORYDATASIZE(__VALUE__)     (((__VALUE__) == LL_DMA_MDATAALIGN_BYTE)      || \
66
+                                                 ((__VALUE__) == LL_DMA_MDATAALIGN_HALFWORD)  || \
67
+                                                 ((__VALUE__) == LL_DMA_MDATAALIGN_WORD))
68
+
69
+#define IS_LL_DMA_NBDATA(__VALUE__)             ((__VALUE__)  <= 0x0000FFFFU)
70
+
71
+#define IS_LL_DMA_PRIORITY(__VALUE__)           (((__VALUE__) == LL_DMA_PRIORITY_LOW)    || \
72
+                                                 ((__VALUE__) == LL_DMA_PRIORITY_MEDIUM) || \
73
+                                                 ((__VALUE__) == LL_DMA_PRIORITY_HIGH)   || \
74
+                                                 ((__VALUE__) == LL_DMA_PRIORITY_VERYHIGH))
75
+
76
+#if defined (DMA2)
77
+#define IS_LL_DMA_ALL_CHANNEL_INSTANCE(INSTANCE, CHANNEL)  ((((INSTANCE) == DMA1) && \
78
+                                                            (((CHANNEL) == LL_DMA_CHANNEL_1) || \
79
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_2) || \
80
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_3) || \
81
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_4) || \
82
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_5) || \
83
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_6) || \
84
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_7))) || \
85
+                                                            (((INSTANCE) == DMA2) && \
86
+                                                            (((CHANNEL) == LL_DMA_CHANNEL_1) || \
87
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_2) || \
88
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_3) || \
89
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_4) || \
90
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_5))))
91
+#else
92
+#define IS_LL_DMA_ALL_CHANNEL_INSTANCE(INSTANCE, CHANNEL)  ((((INSTANCE) == DMA1) && \
93
+                                                            (((CHANNEL) == LL_DMA_CHANNEL_1) || \
94
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_2) || \
95
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_3) || \
96
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_4) || \
97
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_5) || \
98
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_6) || \
99
+                                                             ((CHANNEL) == LL_DMA_CHANNEL_7))))
100
+#endif
101
+/**
102
+  * @}
103
+  */
104
+
105
+/* Private function prototypes -----------------------------------------------*/
106
+/* Exported functions --------------------------------------------------------*/
107
+/** @addtogroup DMA_LL_Exported_Functions
108
+  * @{
109
+  */
110
+
111
+/** @addtogroup DMA_LL_EF_Init
112
+  * @{
113
+  */
114
+
115
+/**
116
+  * @brief  De-initialize the DMA registers to their default reset values.
117
+  * @param  DMAx DMAx Instance
118
+  * @param  Channel This parameter can be one of the following values:
119
+  *         @arg @ref LL_DMA_CHANNEL_1
120
+  *         @arg @ref LL_DMA_CHANNEL_2
121
+  *         @arg @ref LL_DMA_CHANNEL_3
122
+  *         @arg @ref LL_DMA_CHANNEL_4
123
+  *         @arg @ref LL_DMA_CHANNEL_5
124
+  *         @arg @ref LL_DMA_CHANNEL_6
125
+  *         @arg @ref LL_DMA_CHANNEL_7
126
+  * @retval An ErrorStatus enumeration value:
127
+  *          - SUCCESS: DMA registers are de-initialized
128
+  *          - ERROR: DMA registers are not de-initialized
129
+  */
130
+uint32_t LL_DMA_DeInit(DMA_TypeDef *DMAx, uint32_t Channel)
131
+{
132
+  DMA_Channel_TypeDef *tmp = (DMA_Channel_TypeDef *)DMA1_Channel1;
133
+  ErrorStatus status = SUCCESS;
134
+
135
+  /* Check the DMA Instance DMAx and Channel parameters*/
136
+  assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel));
137
+
138
+  tmp = (DMA_Channel_TypeDef *)(__LL_DMA_GET_CHANNEL_INSTANCE(DMAx, Channel));
139
+
140
+  /* Disable the selected DMAx_Channely */
141
+  CLEAR_BIT(tmp->CCR, DMA_CCR_EN);
142
+
143
+  /* Reset DMAx_Channely control register */
144
+  LL_DMA_WriteReg(tmp, CCR, 0U);
145
+
146
+  /* Reset DMAx_Channely remaining bytes register */
147
+  LL_DMA_WriteReg(tmp, CNDTR, 0U);
148
+
149
+  /* Reset DMAx_Channely peripheral address register */
150
+  LL_DMA_WriteReg(tmp, CPAR, 0U);
151
+
152
+  /* Reset DMAx_Channely memory address register */
153
+  LL_DMA_WriteReg(tmp, CMAR, 0U);
154
+
155
+  if (Channel == LL_DMA_CHANNEL_1)
156
+  {
157
+    /* Reset interrupt pending bits for DMAx Channel1 */
158
+    LL_DMA_ClearFlag_GI1(DMAx);
159
+  }
160
+  else if (Channel == LL_DMA_CHANNEL_2)
161
+  {
162
+    /* Reset interrupt pending bits for DMAx Channel2 */
163
+    LL_DMA_ClearFlag_GI2(DMAx);
164
+  }
165
+  else if (Channel == LL_DMA_CHANNEL_3)
166
+  {
167
+    /* Reset interrupt pending bits for DMAx Channel3 */
168
+    LL_DMA_ClearFlag_GI3(DMAx);
169
+  }
170
+  else if (Channel == LL_DMA_CHANNEL_4)
171
+  {
172
+    /* Reset interrupt pending bits for DMAx Channel4 */
173
+    LL_DMA_ClearFlag_GI4(DMAx);
174
+  }
175
+  else if (Channel == LL_DMA_CHANNEL_5)
176
+  {
177
+    /* Reset interrupt pending bits for DMAx Channel5 */
178
+    LL_DMA_ClearFlag_GI5(DMAx);
179
+  }
180
+
181
+  else if (Channel == LL_DMA_CHANNEL_6)
182
+  {
183
+    /* Reset interrupt pending bits for DMAx Channel6 */
184
+    LL_DMA_ClearFlag_GI6(DMAx);
185
+  }
186
+  else if (Channel == LL_DMA_CHANNEL_7)
187
+  {
188
+    /* Reset interrupt pending bits for DMAx Channel7 */
189
+    LL_DMA_ClearFlag_GI7(DMAx);
190
+  }
191
+  else
192
+  {
193
+    status = ERROR;
194
+  }
195
+
196
+  return status;
197
+}
198
+
199
+/**
200
+  * @brief  Initialize the DMA registers according to the specified parameters in DMA_InitStruct.
201
+  * @note   To convert DMAx_Channely Instance to DMAx Instance and Channely, use helper macros :
202
+  *         @arg @ref __LL_DMA_GET_INSTANCE
203
+  *         @arg @ref __LL_DMA_GET_CHANNEL
204
+  * @param  DMAx DMAx Instance
205
+  * @param  Channel This parameter can be one of the following values:
206
+  *         @arg @ref LL_DMA_CHANNEL_1
207
+  *         @arg @ref LL_DMA_CHANNEL_2
208
+  *         @arg @ref LL_DMA_CHANNEL_3
209
+  *         @arg @ref LL_DMA_CHANNEL_4
210
+  *         @arg @ref LL_DMA_CHANNEL_5
211
+  *         @arg @ref LL_DMA_CHANNEL_6
212
+  *         @arg @ref LL_DMA_CHANNEL_7
213
+  * @param  DMA_InitStruct pointer to a @ref LL_DMA_InitTypeDef structure.
214
+  * @retval An ErrorStatus enumeration value:
215
+  *          - SUCCESS: DMA registers are initialized
216
+  *          - ERROR: Not applicable
217
+  */
218
+uint32_t LL_DMA_Init(DMA_TypeDef *DMAx, uint32_t Channel, LL_DMA_InitTypeDef *DMA_InitStruct)
219
+{
220
+  /* Check the DMA Instance DMAx and Channel parameters*/
221
+  assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel));
222
+
223
+  /* Check the DMA parameters from DMA_InitStruct */
224
+  assert_param(IS_LL_DMA_DIRECTION(DMA_InitStruct->Direction));
225
+  assert_param(IS_LL_DMA_MODE(DMA_InitStruct->Mode));
226
+  assert_param(IS_LL_DMA_PERIPHINCMODE(DMA_InitStruct->PeriphOrM2MSrcIncMode));
227
+  assert_param(IS_LL_DMA_MEMORYINCMODE(DMA_InitStruct->MemoryOrM2MDstIncMode));
228
+  assert_param(IS_LL_DMA_PERIPHDATASIZE(DMA_InitStruct->PeriphOrM2MSrcDataSize));
229
+  assert_param(IS_LL_DMA_MEMORYDATASIZE(DMA_InitStruct->MemoryOrM2MDstDataSize));
230
+  assert_param(IS_LL_DMA_NBDATA(DMA_InitStruct->NbData));
231
+  assert_param(IS_LL_DMA_PRIORITY(DMA_InitStruct->Priority));
232
+
233
+  /*---------------------------- DMAx CCR Configuration ------------------------
234
+   * Configure DMAx_Channely: data transfer direction, data transfer mode,
235
+   *                          peripheral and memory increment mode,
236
+   *                          data size alignment and  priority level with parameters :
237
+   * - Direction:      DMA_CCR_DIR and DMA_CCR_MEM2MEM bits
238
+   * - Mode:           DMA_CCR_CIRC bit
239
+   * - PeriphOrM2MSrcIncMode:  DMA_CCR_PINC bit
240
+   * - MemoryOrM2MDstIncMode:  DMA_CCR_MINC bit
241
+   * - PeriphOrM2MSrcDataSize: DMA_CCR_PSIZE[1:0] bits
242
+   * - MemoryOrM2MDstDataSize: DMA_CCR_MSIZE[1:0] bits
243
+   * - Priority:               DMA_CCR_PL[1:0] bits
244
+   */
245
+  LL_DMA_ConfigTransfer(DMAx, Channel, DMA_InitStruct->Direction | \
246
+                        DMA_InitStruct->Mode                   | \
247
+                        DMA_InitStruct->PeriphOrM2MSrcIncMode  | \
248
+                        DMA_InitStruct->MemoryOrM2MDstIncMode  | \
249
+                        DMA_InitStruct->PeriphOrM2MSrcDataSize | \
250
+                        DMA_InitStruct->MemoryOrM2MDstDataSize | \
251
+                        DMA_InitStruct->Priority);
252
+
253
+  /*-------------------------- DMAx CMAR Configuration -------------------------
254
+   * Configure the memory or destination base address with parameter :
255
+   * - MemoryOrM2MDstAddress: DMA_CMAR_MA[31:0] bits
256
+   */
257
+  LL_DMA_SetMemoryAddress(DMAx, Channel, DMA_InitStruct->MemoryOrM2MDstAddress);
258
+
259
+  /*-------------------------- DMAx CPAR Configuration -------------------------
260
+   * Configure the peripheral or source base address with parameter :
261
+   * - PeriphOrM2MSrcAddress: DMA_CPAR_PA[31:0] bits
262
+   */
263
+  LL_DMA_SetPeriphAddress(DMAx, Channel, DMA_InitStruct->PeriphOrM2MSrcAddress);
264
+
265
+  /*--------------------------- DMAx CNDTR Configuration -----------------------
266
+   * Configure the peripheral base address with parameter :
267
+   * - NbData: DMA_CNDTR_NDT[15:0] bits
268
+   */
269
+  LL_DMA_SetDataLength(DMAx, Channel, DMA_InitStruct->NbData);
270
+
271
+  return SUCCESS;
272
+}
273
+
274
+/**
275
+  * @brief  Set each @ref LL_DMA_InitTypeDef field to default value.
276
+  * @param  DMA_InitStruct Pointer to a @ref LL_DMA_InitTypeDef structure.
277
+  * @retval None
278
+  */
279
+void LL_DMA_StructInit(LL_DMA_InitTypeDef *DMA_InitStruct)
280
+{
281
+  /* Set DMA_InitStruct fields to default values */
282
+  DMA_InitStruct->PeriphOrM2MSrcAddress  = 0x00000000U;
283
+  DMA_InitStruct->MemoryOrM2MDstAddress  = 0x00000000U;
284
+  DMA_InitStruct->Direction              = LL_DMA_DIRECTION_PERIPH_TO_MEMORY;
285
+  DMA_InitStruct->Mode                   = LL_DMA_MODE_NORMAL;
286
+  DMA_InitStruct->PeriphOrM2MSrcIncMode  = LL_DMA_PERIPH_NOINCREMENT;
287
+  DMA_InitStruct->MemoryOrM2MDstIncMode  = LL_DMA_MEMORY_NOINCREMENT;
288
+  DMA_InitStruct->PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_BYTE;
289
+  DMA_InitStruct->MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_BYTE;
290
+  DMA_InitStruct->NbData                 = 0x00000000U;
291
+  DMA_InitStruct->Priority               = LL_DMA_PRIORITY_LOW;
292
+}
293
+
294
+/**
295
+  * @}
296
+  */
297
+
298
+/**
299
+  * @}
300
+  */
301
+
302
+/**
303
+  * @}
304
+  */
305
+
306
+#endif /* DMA1 || DMA2 */
307
+
308
+/**
309
+  * @}
310
+  */
311
+
312
+#endif /* USE_FULL_LL_DRIVER */
313
+
314
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 215
- 0
LLDrivers/src/stm32f1xx_ll_exti.c View File

@@ -0,0 +1,215 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_exti.c
4
+  * @author  MCD Application Team
5
+  * @brief   EXTI LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+#if defined(USE_FULL_LL_DRIVER)
21
+
22
+/* Includes ------------------------------------------------------------------*/
23
+#include "stm32f1xx_ll_exti.h"
24
+#ifdef  USE_FULL_ASSERT
25
+#include "stm32_assert.h"
26
+#else
27
+#define assert_param(expr) ((void)0U)
28
+#endif
29
+
30
+/** @addtogroup STM32F1xx_LL_Driver
31
+  * @{
32
+  */
33
+
34
+#if defined (EXTI)
35
+
36
+/** @defgroup EXTI_LL EXTI
37
+  * @{
38
+  */
39
+
40
+/* Private types -------------------------------------------------------------*/
41
+/* Private variables ---------------------------------------------------------*/
42
+/* Private constants ---------------------------------------------------------*/
43
+/* Private macros ------------------------------------------------------------*/
44
+/** @addtogroup EXTI_LL_Private_Macros
45
+  * @{
46
+  */
47
+
48
+#define IS_LL_EXTI_LINE_0_31(__VALUE__)              (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
49
+
50
+#define IS_LL_EXTI_MODE(__VALUE__)                   (((__VALUE__) == LL_EXTI_MODE_IT)            \
51
+                                                   || ((__VALUE__) == LL_EXTI_MODE_EVENT)         \
52
+                                                   || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
53
+
54
+
55
+#define IS_LL_EXTI_TRIGGER(__VALUE__)                (((__VALUE__) == LL_EXTI_TRIGGER_NONE)       \
56
+                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_RISING)     \
57
+                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING)    \
58
+                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
59
+
60
+/**
61
+  * @}
62
+  */
63
+
64
+/* Private function prototypes -----------------------------------------------*/
65
+
66
+/* Exported functions --------------------------------------------------------*/
67
+/** @addtogroup EXTI_LL_Exported_Functions
68
+  * @{
69
+  */
70
+
71
+/** @addtogroup EXTI_LL_EF_Init
72
+  * @{
73
+  */
74
+
75
+/**
76
+  * @brief  De-initialize the EXTI registers to their default reset values.
77
+  * @retval An ErrorStatus enumeration value:
78
+  *          - SUCCESS: EXTI registers are de-initialized
79
+  *          - ERROR: not applicable
80
+  */
81
+uint32_t LL_EXTI_DeInit(void)
82
+{
83
+  /* Interrupt mask register set to default reset values */
84
+  LL_EXTI_WriteReg(IMR,   0x00000000U);
85
+  /* Event mask register set to default reset values */
86
+  LL_EXTI_WriteReg(EMR,   0x00000000U);
87
+  /* Rising Trigger selection register set to default reset values */
88
+  LL_EXTI_WriteReg(RTSR,  0x00000000U);
89
+  /* Falling Trigger selection register set to default reset values */
90
+  LL_EXTI_WriteReg(FTSR,  0x00000000U);
91
+  /* Software interrupt event register set to default reset values */
92
+  LL_EXTI_WriteReg(SWIER, 0x00000000U);
93
+  /* Pending register clear */
94
+  LL_EXTI_WriteReg(PR,    0x000FFFFFU);
95
+
96
+  return SUCCESS;
97
+}
98
+
99
+/**
100
+  * @brief  Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
101
+  * @param  EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
102
+  * @retval An ErrorStatus enumeration value:
103
+  *          - SUCCESS: EXTI registers are initialized
104
+  *          - ERROR: not applicable
105
+  */
106
+uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
107
+{
108
+  ErrorStatus status = SUCCESS;
109
+  /* Check the parameters */
110
+  assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31));
111
+  assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
112
+  assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
113
+
114
+  /* ENABLE LineCommand */
115
+  if (EXTI_InitStruct->LineCommand != DISABLE)
116
+  {
117
+    assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
118
+
119
+    /* Configure EXTI Lines in range from 0 to 31 */
120
+    if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE)
121
+    {
122
+      switch (EXTI_InitStruct->Mode)
123
+      {
124
+        case LL_EXTI_MODE_IT:
125
+          /* First Disable Event on provided Lines */
126
+          LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
127
+          /* Then Enable IT on provided Lines */
128
+          LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
129
+          break;
130
+        case LL_EXTI_MODE_EVENT:
131
+          /* First Disable IT on provided Lines */
132
+          LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
133
+          /* Then Enable Event on provided Lines */
134
+          LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
135
+          break;
136
+        case LL_EXTI_MODE_IT_EVENT:
137
+          /* Directly Enable IT & Event on provided Lines */
138
+          LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
139
+          LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
140
+          break;
141
+        default:
142
+          status = ERROR;
143
+          break;
144
+      }
145
+      if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
146
+      {
147
+        switch (EXTI_InitStruct->Trigger)
148
+        {
149
+          case LL_EXTI_TRIGGER_RISING:
150
+            /* First Disable Falling Trigger on provided Lines */
151
+            LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
152
+            /* Then Enable Rising Trigger on provided Lines */
153
+            LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
154
+            break;
155
+          case LL_EXTI_TRIGGER_FALLING:
156
+            /* First Disable Rising Trigger on provided Lines */
157
+            LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
158
+            /* Then Enable Falling Trigger on provided Lines */
159
+            LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
160
+            break;
161
+          case LL_EXTI_TRIGGER_RISING_FALLING:
162
+            LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
163
+            LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
164
+            break;
165
+          default:
166
+            status = ERROR;
167
+            break;
168
+        }
169
+      }
170
+    }
171
+  }
172
+  /* DISABLE LineCommand */
173
+  else
174
+  {
175
+    /* De-configure EXTI Lines in range from 0 to 31 */
176
+    LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
177
+    LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
178
+  }
179
+  return status;
180
+}
181
+
182
+/**
183
+  * @brief  Set each @ref LL_EXTI_InitTypeDef field to default value.
184
+  * @param  EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
185
+  * @retval None
186
+  */
187
+void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
188
+{
189
+  EXTI_InitStruct->Line_0_31      = LL_EXTI_LINE_NONE;
190
+  EXTI_InitStruct->LineCommand    = DISABLE;
191
+  EXTI_InitStruct->Mode           = LL_EXTI_MODE_IT;
192
+  EXTI_InitStruct->Trigger        = LL_EXTI_TRIGGER_FALLING;
193
+}
194
+
195
+/**
196
+  * @}
197
+  */
198
+
199
+/**
200
+  * @}
201
+  */
202
+
203
+/**
204
+  * @}
205
+  */
206
+
207
+#endif /* defined (EXTI) */
208
+
209
+/**
210
+  * @}
211
+  */
212
+
213
+#endif /* USE_FULL_LL_DRIVER */
214
+
215
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 985
- 0
LLDrivers/src/stm32f1xx_ll_fsmc.c View File

@@ -0,0 +1,985 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_fsmc.c
4
+  * @author  MCD Application Team
5
+  * @brief   FSMC Low Layer HAL module driver.
6
+  *
7
+  *          This file provides firmware functions to manage the following
8
+  *          functionalities of the Flexible Memory Controller (FSMC) peripheral memories:
9
+  *           + Initialization/de-initialization functions
10
+  *           + Peripheral Control functions
11
+  *           + Peripheral State functions
12
+  *
13
+  @verbatim
14
+  ==============================================================================
15
+                        ##### FSMC peripheral features #####
16
+  ==============================================================================
17
+  [..] The Flexible memory controller (FSMC) includes following memory controllers:
18
+       (+) The NOR/PSRAM memory controller
19
+       (+) The NAND/PC Card memory controller
20
+
21
+  [..] The FSMC functional block makes the interface with synchronous and asynchronous static
22
+       memories and 16-bit PC memory cards. Its main purposes are:
23
+       (+) to translate AHB transactions into the appropriate external device protocol
24
+       (+) to meet the access time requirements of the external memory devices
25
+
26
+  [..] All external memories share the addresses, data and control signals with the controller.
27
+       Each external device is accessed by means of a unique Chip Select. The FSMC performs
28
+       only one access at a time to an external device.
29
+       The main features of the FSMC controller are the following:
30
+        (+) Interface with static-memory mapped devices including:
31
+           (++) Static random access memory (SRAM)
32
+           (++) Read-only memory (ROM)
33
+           (++) NOR Flash memory/OneNAND Flash memory
34
+           (++) PSRAM (4 memory banks)
35
+           (++) 16-bit PC Card compatible devices
36
+           (++) Two banks of NAND Flash memory with ECC hardware to check up to 8 Kbytes of
37
+                data
38
+        (+) Independent Chip Select control for each memory bank
39
+        (+) Independent configuration for each memory bank
40
+
41
+  @endverbatim
42
+  ******************************************************************************
43
+  * @attention
44
+  *
45
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
46
+  * All rights reserved.</center></h2>
47
+  *
48
+  * This software component is licensed by ST under BSD 3-Clause license,
49
+  * the "License"; You may not use this file except in compliance with the
50
+  * License. You may obtain a copy of the License at:
51
+  *                       opensource.org/licenses/BSD-3-Clause
52
+  *
53
+  ******************************************************************************
54
+  */
55
+
56
+/* Includes ------------------------------------------------------------------*/
57
+#include "stm32f1xx_hal.h"
58
+
59
+/** @addtogroup STM32F1xx_HAL_Driver
60
+  * @{
61
+  */
62
+#if (((defined HAL_NOR_MODULE_ENABLED || defined HAL_SRAM_MODULE_ENABLED)) || defined HAL_NAND_MODULE_ENABLED || defined HAL_PCCARD_MODULE_ENABLED )
63
+
64
+/** @defgroup FSMC_LL  FSMC Low Layer
65
+  * @brief FSMC driver modules
66
+  * @{
67
+  */
68
+	
69
+/* Private typedef -----------------------------------------------------------*/
70
+/* Private define ------------------------------------------------------------*/
71
+
72
+/** @defgroup FSMC_LL_Private_Constants FSMC Low Layer Private Constants
73
+  * @{
74
+  */
75
+
76
+/* ----------------------- FSMC registers bit mask --------------------------- */
77
+
78
+#if defined FSMC_BANK1
79
+/* --- BCR Register ---*/
80
+/* BCR register clear mask */
81
+
82
+/* --- BTR Register ---*/
83
+/* BTR register clear mask */
84
+#define BTR_CLEAR_MASK    ((uint32_t)(FSMC_BTRx_ADDSET | FSMC_BTRx_ADDHLD  |\
85
+                                      FSMC_BTRx_DATAST | FSMC_BTRx_BUSTURN |\
86
+                                      FSMC_BTRx_CLKDIV | FSMC_BTRx_DATLAT  |\
87
+                                      FSMC_BTRx_ACCMOD))
88
+
89
+/* --- BWTR Register ---*/
90
+/* BWTR register clear mask */
91
+#if defined(FSMC_BWTRx_BUSTURN)
92
+#define BWTR_CLEAR_MASK   ((uint32_t)(FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD  |\
93
+                                      FSMC_BWTRx_DATAST | FSMC_BWTRx_BUSTURN |\
94
+                                      FSMC_BWTRx_ACCMOD))
95
+#else
96
+#define BWTR_CLEAR_MASK   ((uint32_t)(FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD  |\
97
+                                      FSMC_BWTRx_DATAST | FSMC_BWTRx_ACCMOD))
98
+#endif /* FSMC_BWTRx_BUSTURN */
99
+#endif /* FSMC_BANK1 */
100
+#if defined(FSMC_BANK3)
101
+
102
+/* --- PCR Register ---*/
103
+/* PCR register clear mask */
104
+#define PCR_CLEAR_MASK    ((uint32_t)(FSMC_PCRx_PWAITEN | FSMC_PCRx_PBKEN  | \
105
+                                      FSMC_PCRx_PTYP    | FSMC_PCRx_PWID   | \
106
+                                      FSMC_PCRx_ECCEN   | FSMC_PCRx_TCLR   | \
107
+                                      FSMC_PCRx_TAR     | FSMC_PCRx_ECCPS))
108
+/* --- PMEM Register ---*/
109
+/* PMEM register clear mask */
110
+#define PMEM_CLEAR_MASK   ((uint32_t)(FSMC_PMEMx_MEMSETx  | FSMC_PMEMx_MEMWAITx |\
111
+                                      FSMC_PMEMx_MEMHOLDx | FSMC_PMEMx_MEMHIZx))
112
+
113
+/* --- PATT Register ---*/
114
+/* PATT register clear mask */
115
+#define PATT_CLEAR_MASK   ((uint32_t)(FSMC_PATTx_ATTSETx  | FSMC_PATTx_ATTWAITx |\
116
+                                      FSMC_PATTx_ATTHOLDx | FSMC_PATTx_ATTHIZx))
117
+
118
+#endif /* FSMC_BANK3 */
119
+#if defined(FSMC_BANK4)
120
+/* --- PCR Register ---*/
121
+/* PCR register clear mask */
122
+#define PCR4_CLEAR_MASK   ((uint32_t)(FSMC_PCR4_PWAITEN | FSMC_PCR4_PBKEN  | \
123
+                                      FSMC_PCR4_PTYP    | FSMC_PCR4_PWID   | \
124
+                                      FSMC_PCR4_ECCEN   | FSMC_PCR4_TCLR   | \
125
+                                      FSMC_PCR4_TAR     | FSMC_PCR4_ECCPS))
126
+/* --- PMEM Register ---*/
127
+/* PMEM register clear mask */
128
+#define PMEM4_CLEAR_MASK  ((uint32_t)(FSMC_PMEM4_MEMSET4  | FSMC_PMEM4_MEMWAIT4 |\
129
+                                      FSMC_PMEM4_MEMHOLD4 | FSMC_PMEM4_MEMHIZ4))
130
+
131
+/* --- PATT Register ---*/
132
+/* PATT register clear mask */
133
+#define PATT4_CLEAR_MASK  ((uint32_t)(FSMC_PATT4_ATTSET4  | FSMC_PATT4_ATTWAIT4 |\
134
+                                      FSMC_PATT4_ATTHOLD4 | FSMC_PATT4_ATTHIZ4))
135
+
136
+/* --- PIO4 Register ---*/
137
+/* PIO4 register clear mask */
138
+#define PIO4_CLEAR_MASK   ((uint32_t)(FSMC_PIO4_IOSET4  | FSMC_PIO4_IOWAIT4 | \
139
+                                      FSMC_PIO4_IOHOLD4 | FSMC_PIO4_IOHIZ4))
140
+
141
+#endif /* FSMC_BANK4 */
142
+
143
+/**
144
+  * @}
145
+  */
146
+
147
+/* Private macro -------------------------------------------------------------*/
148
+/* Private variables ---------------------------------------------------------*/
149
+/* Private function prototypes -----------------------------------------------*/
150
+/* Exported functions --------------------------------------------------------*/
151
+
152
+/** @defgroup FSMC_LL_Exported_Functions FSMC Low Layer Exported Functions
153
+  * @{
154
+  */
155
+
156
+#if defined FSMC_BANK1
157
+
158
+/** @defgroup FSMC_LL_Exported_Functions_NORSRAM FSMC Low Layer NOR SRAM Exported Functions
159
+  * @brief  NORSRAM Controller functions
160
+  *
161
+  @verbatim
162
+  ==============================================================================
163
+                   ##### How to use NORSRAM device driver #####
164
+  ==============================================================================
165
+
166
+  [..]
167
+    This driver contains a set of APIs to interface with the FSMC NORSRAM banks in order
168
+    to run the NORSRAM external devices.
169
+
170
+    (+) FSMC NORSRAM bank reset using the function FSMC_NORSRAM_DeInit()
171
+    (+) FSMC NORSRAM bank control configuration using the function FSMC_NORSRAM_Init()
172
+    (+) FSMC NORSRAM bank timing configuration using the function FSMC_NORSRAM_Timing_Init()
173
+    (+) FSMC NORSRAM bank extended timing configuration using the function
174
+        FSMC_NORSRAM_Extended_Timing_Init()
175
+    (+) FSMC NORSRAM bank enable/disable write operation using the functions
176
+        FSMC_NORSRAM_WriteOperation_Enable()/FSMC_NORSRAM_WriteOperation_Disable()
177
+
178
+@endverbatim
179
+  * @{
180
+  */
181
+
182
+/** @defgroup FSMC_LL_NORSRAM_Exported_Functions_Group1 Initialization and de-initialization functions
183
+  * @brief    Initialization and Configuration functions
184
+  *
185
+  @verbatim
186
+  ==============================================================================
187
+              ##### Initialization and de_initialization functions #####
188
+  ==============================================================================
189
+  [..]
190
+    This section provides functions allowing to:
191
+    (+) Initialize and configure the FSMC NORSRAM interface
192
+    (+) De-initialize the FSMC NORSRAM interface
193
+    (+) Configure the FSMC clock and associated GPIOs
194
+
195
+@endverbatim
196
+  * @{
197
+  */
198
+
199
+/**
200
+  * @brief  Initialize the FSMC_NORSRAM device according to the specified
201
+  *         control parameters in the FSMC_NORSRAM_InitTypeDef
202
+  * @param  Device Pointer to NORSRAM device instance
203
+  * @param  Init Pointer to NORSRAM Initialization structure
204
+  * @retval HAL status
205
+  */
206
+HAL_StatusTypeDef  FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_InitTypeDef *Init)
207
+{
208
+  uint32_t flashaccess;
209
+
210
+  /* Check the parameters */
211
+  assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
212
+  assert_param(IS_FSMC_NORSRAM_BANK(Init->NSBank));
213
+  assert_param(IS_FSMC_MUX(Init->DataAddressMux));
214
+  assert_param(IS_FSMC_MEMORY(Init->MemoryType));
215
+  assert_param(IS_FSMC_NORSRAM_MEMORY_WIDTH(Init->MemoryDataWidth));
216
+  assert_param(IS_FSMC_BURSTMODE(Init->BurstAccessMode));
217
+  assert_param(IS_FSMC_WAIT_POLARITY(Init->WaitSignalPolarity));
218
+  assert_param(IS_FSMC_WRAP_MODE(Init->WrapMode));
219
+  assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(Init->WaitSignalActive));
220
+  assert_param(IS_FSMC_WRITE_OPERATION(Init->WriteOperation));
221
+  assert_param(IS_FSMC_WAITE_SIGNAL(Init->WaitSignal));
222
+  assert_param(IS_FSMC_EXTENDED_MODE(Init->ExtendedMode));
223
+  assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait));
224
+  assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst));
225
+  assert_param(IS_FSMC_PAGESIZE(Init->PageSize));
226
+
227
+  /* Disable NORSRAM Device */
228
+  __FSMC_NORSRAM_DISABLE(Device, Init->NSBank);
229
+
230
+  /* Set NORSRAM device control parameters */
231
+  if (Init->MemoryType == FSMC_MEMORY_TYPE_NOR)
232
+  {
233
+    flashaccess = FSMC_NORSRAM_FLASH_ACCESS_ENABLE;
234
+  }
235
+  else
236
+  {
237
+    flashaccess = FSMC_NORSRAM_FLASH_ACCESS_DISABLE;
238
+  }
239
+
240
+  MODIFY_REG(Device->BTCR[Init->NSBank],
241
+             (FSMC_BCRx_MBKEN                |
242
+              FSMC_BCRx_MUXEN                |
243
+              FSMC_BCRx_MTYP                 |
244
+              FSMC_BCRx_MWID                 |
245
+              FSMC_BCRx_FACCEN               |
246
+              FSMC_BCRx_BURSTEN              |
247
+              FSMC_BCRx_WAITPOL              |
248
+              FSMC_BCRx_WRAPMOD              |
249
+              FSMC_BCRx_WAITCFG              |
250
+              FSMC_BCRx_WREN                 |
251
+              FSMC_BCRx_WAITEN               |
252
+              FSMC_BCRx_EXTMOD               |
253
+              FSMC_BCRx_ASYNCWAIT            |
254
+              FSMC_BCRx_CBURSTRW             |
255
+              0x00070000U), /* CPSIZE to be defined in CMSIS file */
256
+             (flashaccess                   |
257
+              Init->DataAddressMux          |
258
+              Init->MemoryType              |
259
+              Init->MemoryDataWidth         |
260
+              Init->BurstAccessMode         |
261
+              Init->WaitSignalPolarity      |
262
+              Init->WrapMode                |
263
+              Init->WaitSignalActive        |
264
+              Init->WriteOperation          |
265
+              Init->WaitSignal              |
266
+              Init->ExtendedMode            |
267
+              Init->AsynchronousWait        |
268
+              Init->WriteBurst              |
269
+              Init->PageSize));
270
+
271
+
272
+  return HAL_OK;
273
+}
274
+
275
+/**
276
+  * @brief  DeInitialize the FSMC_NORSRAM peripheral
277
+  * @param  Device Pointer to NORSRAM device instance
278
+  * @param  ExDevice Pointer to NORSRAM extended mode device instance
279
+  * @param  Bank NORSRAM bank number
280
+  * @retval HAL status
281
+  */
282
+HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank)
283
+{
284
+  /* Check the parameters */
285
+  assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
286
+  assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(ExDevice));
287
+  assert_param(IS_FSMC_NORSRAM_BANK(Bank));
288
+
289
+  /* Disable the FSMC_NORSRAM device */
290
+  __FSMC_NORSRAM_DISABLE(Device, Bank);
291
+
292
+  /* De-initialize the FSMC_NORSRAM device */
293
+  /* FSMC_NORSRAM_BANK1 */
294
+  if (Bank == FSMC_NORSRAM_BANK1)
295
+  {
296
+    Device->BTCR[Bank] = 0x000030DBU;
297
+  }
298
+  /* FSMC_NORSRAM_BANK2, FSMC_NORSRAM_BANK3 or FSMC_NORSRAM_BANK4 */
299
+  else
300
+  {
301
+    Device->BTCR[Bank] = 0x000030D2U;
302
+  }
303
+
304
+  Device->BTCR[Bank + 1U] = 0x0FFFFFFFU;
305
+  ExDevice->BWTR[Bank]   = 0x0FFFFFFFU;
306
+
307
+  return HAL_OK;
308
+}
309
+
310
+/**
311
+  * @brief  Initialize the FSMC_NORSRAM Timing according to the specified
312
+  *         parameters in the FSMC_NORSRAM_TimingTypeDef
313
+  * @param  Device Pointer to NORSRAM device instance
314
+  * @param  Timing Pointer to NORSRAM Timing structure
315
+  * @param  Bank NORSRAM bank number
316
+  * @retval HAL status
317
+  */
318
+HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank)
319
+{
320
+
321
+  /* Check the parameters */
322
+  assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
323
+  assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
324
+  assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
325
+  assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime));
326
+  assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
327
+  assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision));
328
+  assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency));
329
+  assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode));
330
+  assert_param(IS_FSMC_NORSRAM_BANK(Bank));
331
+
332
+  /* Set FSMC_NORSRAM device timing parameters */
333
+  MODIFY_REG(Device->BTCR[Bank + 1U], BTR_CLEAR_MASK, (Timing->AddressSetupTime                                  |
334
+                                                      ((Timing->AddressHoldTime)        << FSMC_BTRx_ADDHLD_Pos)  |
335
+                                                      ((Timing->DataSetupTime)          << FSMC_BTRx_DATAST_Pos)  |
336
+                                                      ((Timing->BusTurnAroundDuration)  << FSMC_BTRx_BUSTURN_Pos) |
337
+                                                      (((Timing->CLKDivision) - 1U)     << FSMC_BTRx_CLKDIV_Pos)  |
338
+                                                      (((Timing->DataLatency) - 2U)     << FSMC_BTRx_DATLAT_Pos)  |
339
+                                                      (Timing->AccessMode)));
340
+
341
+  return HAL_OK;
342
+}
343
+
344
+/**
345
+  * @brief  Initialize the FSMC_NORSRAM Extended mode Timing according to the specified
346
+  *         parameters in the FSMC_NORSRAM_TimingTypeDef
347
+  * @param  Device Pointer to NORSRAM device instance
348
+  * @param  Timing Pointer to NORSRAM Timing structure
349
+  * @param  Bank NORSRAM bank number
350
+  * @param  ExtendedMode FSMC Extended Mode
351
+  *          This parameter can be one of the following values:
352
+  *            @arg FSMC_EXTENDED_MODE_DISABLE
353
+  *            @arg FSMC_EXTENDED_MODE_ENABLE
354
+  * @retval HAL status
355
+  */
356
+HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode)
357
+{
358
+  /* Check the parameters */
359
+  assert_param(IS_FSMC_EXTENDED_MODE(ExtendedMode));
360
+
361
+  /* Set NORSRAM device timing register for write configuration, if extended mode is used */
362
+  if (ExtendedMode == FSMC_EXTENDED_MODE_ENABLE)
363
+  {
364
+    /* Check the parameters */
365
+    assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(Device));
366
+    assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
367
+    assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
368
+    assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime));
369
+#if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)
370
+    assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
371
+#else
372
+    assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision));
373
+    assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency));
374
+#endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */
375
+    assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode));
376
+    assert_param(IS_FSMC_NORSRAM_BANK(Bank));
377
+
378
+    /* Set NORSRAM device timing register for write configuration, if extended mode is used */
379
+#if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)
380
+    MODIFY_REG(Device->BWTR[Bank], BWTR_CLEAR_MASK, (Timing->AddressSetupTime                                    |
381
+                                                     ((Timing->AddressHoldTime)        << FSMC_BWTRx_ADDHLD_Pos)  |
382
+                                                     ((Timing->DataSetupTime)          << FSMC_BWTRx_DATAST_Pos)  |
383
+                                                     Timing->AccessMode                                          |
384
+                                                     ((Timing->BusTurnAroundDuration)  << FSMC_BWTRx_BUSTURN_Pos)));
385
+#else
386
+    MODIFY_REG(Device->BWTR[Bank], BWTR_CLEAR_MASK, (Timing->AddressSetupTime                                    |
387
+                                                     ((Timing->AddressHoldTime)        << FSMC_BWTRx_ADDHLD_Pos)  |
388
+                                                     ((Timing->DataSetupTime)          << FSMC_BWTRx_DATAST_Pos)  |
389
+                                                     Timing->AccessMode                                          |
390
+                                                     (((Timing->CLKDivision) - 1U)     << FSMC_BTRx_CLKDIV_Pos)   |
391
+                                                     (((Timing->DataLatency) - 2U)     << FSMC_BWTRx_DATLAT_Pos)));
392
+#endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */
393
+  }
394
+  else
395
+  {
396
+    Device->BWTR[Bank] = 0x0FFFFFFFU;
397
+  }
398
+
399
+  return HAL_OK;
400
+}
401
+/**
402
+  * @}
403
+  */
404
+
405
+/** @addtogroup FSMC_LL_NORSRAM_Private_Functions_Group2
406
+ *  @brief   management functions
407
+ *
408
+@verbatim
409
+  ==============================================================================
410
+                      ##### FSMC_NORSRAM Control functions #####
411
+  ==============================================================================
412
+  [..]
413
+    This subsection provides a set of functions allowing to control dynamically
414
+    the FSMC NORSRAM interface.
415
+
416
+@endverbatim
417
+  * @{
418
+  */
419
+
420
+/**
421
+  * @brief  Enables dynamically FSMC_NORSRAM write operation.
422
+  * @param  Device Pointer to NORSRAM device instance
423
+  * @param  Bank NORSRAM bank number
424
+  * @retval HAL status
425
+  */
426
+HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Enable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank)
427
+{
428
+  /* Check the parameters */
429
+  assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
430
+  assert_param(IS_FSMC_NORSRAM_BANK(Bank));
431
+
432
+  /* Enable write operation */
433
+  SET_BIT(Device->BTCR[Bank], FSMC_WRITE_OPERATION_ENABLE);
434
+
435
+  return HAL_OK;
436
+}
437
+
438
+/**
439
+  * @brief  Disables dynamically FSMC_NORSRAM write operation.
440
+  * @param  Device Pointer to NORSRAM device instance
441
+  * @param  Bank NORSRAM bank number
442
+  * @retval HAL status
443
+  */
444
+HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Disable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank)
445
+{
446
+  /* Check the parameters */
447
+  assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
448
+  assert_param(IS_FSMC_NORSRAM_BANK(Bank));
449
+
450
+  /* Disable write operation */
451
+  CLEAR_BIT(Device->BTCR[Bank], FSMC_WRITE_OPERATION_ENABLE);
452
+
453
+  return HAL_OK;
454
+}
455
+
456
+/**
457
+  * @}
458
+  */
459
+
460
+/**
461
+  * @}
462
+  */
463
+#endif /* FSMC_BANK1 */
464
+
465
+#if defined(FSMC_BANK3)
466
+
467
+/** @defgroup FSMC_LL_Exported_Functions_NAND FSMC Low Layer NAND Exported Functions
468
+  * @brief    NAND Controller functions
469
+  *
470
+  @verbatim
471
+  ==============================================================================
472
+                    ##### How to use NAND device driver #####
473
+  ==============================================================================
474
+  [..]
475
+    This driver contains a set of APIs to interface with the FSMC NAND banks in order
476
+    to run the NAND external devices.
477
+
478
+    (+) FSMC NAND bank reset using the function FSMC_NAND_DeInit()
479
+    (+) FSMC NAND bank control configuration using the function FSMC_NAND_Init()
480
+    (+) FSMC NAND bank common space timing configuration using the function
481
+        FSMC_NAND_CommonSpace_Timing_Init()
482
+    (+) FSMC NAND bank attribute space timing configuration using the function
483
+        FSMC_NAND_AttributeSpace_Timing_Init()
484
+    (+) FSMC NAND bank enable/disable ECC correction feature using the functions
485
+        FSMC_NAND_ECC_Enable()/FSMC_NAND_ECC_Disable()
486
+    (+) FSMC NAND bank get ECC correction code using the function FSMC_NAND_GetECC()
487
+
488
+@endverbatim
489
+  * @{
490
+  */
491
+
492
+/** @defgroup FSMC_LL_NAND_Exported_Functions_Group1 Initialization and de-initialization functions
493
+ *  @brief    Initialization and Configuration functions
494
+ *
495
+@verbatim
496
+  ==============================================================================
497
+              ##### Initialization and de_initialization functions #####
498
+  ==============================================================================
499
+  [..]
500
+    This section provides functions allowing to:
501
+    (+) Initialize and configure the FSMC NAND interface
502
+    (+) De-initialize the FSMC NAND interface
503
+    (+) Configure the FSMC clock and associated GPIOs
504
+
505
+@endverbatim
506
+  * @{
507
+  */
508
+
509
+/**
510
+  * @brief  Initializes the FSMC_NAND device according to the specified
511
+  *         control parameters in the FSMC_NAND_HandleTypeDef
512
+  * @param  Device Pointer to NAND device instance
513
+  * @param  Init Pointer to NAND Initialization structure
514
+  * @retval HAL status
515
+  */
516
+HAL_StatusTypeDef FSMC_NAND_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_InitTypeDef *Init)
517
+{
518
+  /* Check the parameters */
519
+  assert_param(IS_FSMC_NAND_DEVICE(Device));
520
+  assert_param(IS_FSMC_NAND_BANK(Init->NandBank));
521
+  assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature));
522
+  assert_param(IS_FSMC_NAND_MEMORY_WIDTH(Init->MemoryDataWidth));
523
+  assert_param(IS_FSMC_ECC_STATE(Init->EccComputation));
524
+  assert_param(IS_FSMC_ECCPAGE_SIZE(Init->ECCPageSize));
525
+  assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime));
526
+  assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime));
527
+
528
+  /* Set NAND device control parameters */
529
+  if (Init->NandBank == FSMC_NAND_BANK2)
530
+  {
531
+    /* NAND bank 2 registers configuration */
532
+    MODIFY_REG(Device->PCR2, PCR_CLEAR_MASK, (Init->Waitfeature                                      |
533
+                                              FSMC_PCR_MEMORY_TYPE_NAND                               |
534
+                                              Init->MemoryDataWidth                                  |
535
+                                              Init->EccComputation                                   |
536
+                                              Init->ECCPageSize                                      |
537
+                                              ((Init->TCLRSetupTime) << FSMC_PCRx_TCLR_Pos)  |
538
+                                              ((Init->TARSetupTime)  << FSMC_PCRx_TAR_Pos)));
539
+  }
540
+  else
541
+  {
542
+    /* NAND bank 3 registers configuration */
543
+    MODIFY_REG(Device->PCR3, PCR_CLEAR_MASK, (Init->Waitfeature                                      |
544
+                                              FSMC_PCR_MEMORY_TYPE_NAND                               |
545
+                                              Init->MemoryDataWidth                                  |
546
+                                              Init->EccComputation                                   |
547
+                                              Init->ECCPageSize                                      |
548
+                                              ((Init->TCLRSetupTime) << FSMC_PCRx_TCLR_Pos)  |
549
+                                              ((Init->TARSetupTime)  << FSMC_PCRx_TAR_Pos)));
550
+  }
551
+
552
+  return HAL_OK;
553
+}
554
+
555
+/**
556
+  * @brief  Initializes the FSMC_NAND Common space Timing according to the specified
557
+  *         parameters in the FSMC_NAND_PCC_TimingTypeDef
558
+  * @param  Device Pointer to NAND device instance
559
+  * @param  Timing Pointer to NAND timing structure
560
+  * @param  Bank NAND bank number
561
+  * @retval HAL status
562
+  */
563
+HAL_StatusTypeDef FSMC_NAND_CommonSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
564
+{
565
+  /* Check the parameters */
566
+  assert_param(IS_FSMC_NAND_DEVICE(Device));
567
+  assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
568
+  assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
569
+  assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
570
+  assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
571
+  assert_param(IS_FSMC_NAND_BANK(Bank));
572
+
573
+  /* Set FSMC_NAND device timing parameters */
574
+  if (Bank == FSMC_NAND_BANK2)
575
+  {
576
+    /* NAND bank 2 registers configuration */
577
+    MODIFY_REG(Device->PMEM2, PMEM_CLEAR_MASK, (Timing->SetupTime                                             |
578
+                                                ((Timing->WaitSetupTime) << FSMC_PMEMx_MEMWAITx_Pos) |
579
+                                                ((Timing->HoldSetupTime) << FSMC_PMEMx_MEMHOLDx_Pos) |
580
+                                                ((Timing->HiZSetupTime)  << FSMC_PMEMx_MEMHIZx_Pos)));
581
+  }
582
+  else
583
+  {
584
+    /* NAND bank 3 registers configuration */
585
+    MODIFY_REG(Device->PMEM3, PMEM_CLEAR_MASK, (Timing->SetupTime                                             |
586
+                                                ((Timing->WaitSetupTime) << FSMC_PMEMx_MEMWAITx_Pos) |
587
+                                                ((Timing->HoldSetupTime) << FSMC_PMEMx_MEMHOLDx_Pos) |
588
+                                                ((Timing->HiZSetupTime)  << FSMC_PMEMx_MEMHIZx_Pos)));
589
+  }
590
+
591
+  return HAL_OK;
592
+}
593
+
594
+/**
595
+  * @brief  Initializes the FSMC_NAND Attribute space Timing according to the specified
596
+  *         parameters in the FSMC_NAND_PCC_TimingTypeDef
597
+  * @param  Device Pointer to NAND device instance
598
+  * @param  Timing Pointer to NAND timing structure
599
+  * @param  Bank NAND bank number
600
+  * @retval HAL status
601
+  */
602
+HAL_StatusTypeDef FSMC_NAND_AttributeSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
603
+{
604
+  /* Check the parameters */
605
+  assert_param(IS_FSMC_NAND_DEVICE(Device));
606
+  assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
607
+  assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
608
+  assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
609
+  assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
610
+  assert_param(IS_FSMC_NAND_BANK(Bank));
611
+
612
+  /* Set FSMC_NAND device timing parameters */
613
+  if (Bank == FSMC_NAND_BANK2)
614
+  {
615
+    /* NAND bank 2 registers configuration */
616
+    MODIFY_REG(Device->PATT2, PATT_CLEAR_MASK, (Timing->SetupTime                                             |
617
+                                                ((Timing->WaitSetupTime) << FSMC_PATTx_ATTWAITx_Pos) |
618
+                                                ((Timing->HoldSetupTime) << FSMC_PATTx_ATTHOLDx_Pos) |
619
+                                                ((Timing->HiZSetupTime)  << FSMC_PATTx_ATTHIZx_Pos)));
620
+  }
621
+  else
622
+  {
623
+    /* NAND bank 3 registers configuration */
624
+    MODIFY_REG(Device->PATT3, PATT_CLEAR_MASK, (Timing->SetupTime                                             |
625
+                                                ((Timing->WaitSetupTime) << FSMC_PATTx_ATTWAITx_Pos) |
626
+                                                ((Timing->HoldSetupTime) << FSMC_PATTx_ATTHOLDx_Pos) |
627
+                                                ((Timing->HiZSetupTime)  << FSMC_PATTx_ATTHIZx_Pos)));
628
+  }
629
+
630
+  return HAL_OK;
631
+}
632
+
633
+/**
634
+  * @brief  DeInitializes the FSMC_NAND device
635
+  * @param  Device Pointer to NAND device instance
636
+  * @param  Bank NAND bank number
637
+  * @retval HAL status
638
+  */
639
+HAL_StatusTypeDef FSMC_NAND_DeInit(FSMC_NAND_TypeDef *Device, uint32_t Bank)
640
+{
641
+  /* Check the parameters */
642
+  assert_param(IS_FSMC_NAND_DEVICE(Device));
643
+  assert_param(IS_FSMC_NAND_BANK(Bank));
644
+
645
+  /* Disable the NAND Bank */
646
+  __FSMC_NAND_DISABLE(Device, Bank);
647
+
648
+  /* De-initialize the NAND Bank */
649
+  if (Bank == FSMC_NAND_BANK2)
650
+  {
651
+    /* Set the FSMC_NAND_BANK2 registers to their reset values */
652
+    WRITE_REG(Device->PCR2,  0x00000018U);
653
+    WRITE_REG(Device->SR2,   0x00000040U);
654
+    WRITE_REG(Device->PMEM2, 0xFCFCFCFCU);
655
+    WRITE_REG(Device->PATT2, 0xFCFCFCFCU);
656
+  }
657
+  /* FSMC_Bank3_NAND */
658
+  else
659
+  {
660
+    /* Set the FSMC_NAND_BANK3 registers to their reset values */
661
+    WRITE_REG(Device->PCR3,  0x00000018U);
662
+    WRITE_REG(Device->SR3,   0x00000040U);
663
+    WRITE_REG(Device->PMEM3, 0xFCFCFCFCU);
664
+    WRITE_REG(Device->PATT3, 0xFCFCFCFCU);
665
+  }
666
+
667
+  return HAL_OK;
668
+}
669
+
670
+/**
671
+  * @}
672
+  */
673
+
674
+/** @defgroup HAL_FSMC_NAND_Group2 Peripheral Control functions
675
+  *  @brief   management functions
676
+  *
677
+@verbatim
678
+  ==============================================================================
679
+                       ##### FSMC_NAND Control functions #####
680
+  ==============================================================================
681
+  [..]
682
+    This subsection provides a set of functions allowing to control dynamically
683
+    the FSMC NAND interface.
684
+
685
+@endverbatim
686
+  * @{
687
+  */
688
+
689
+
690
+/**
691
+  * @brief  Enables dynamically FSMC_NAND ECC feature.
692
+  * @param  Device Pointer to NAND device instance
693
+  * @param  Bank NAND bank number
694
+  * @retval HAL status
695
+  */
696
+HAL_StatusTypeDef FSMC_NAND_ECC_Enable(FSMC_NAND_TypeDef *Device, uint32_t Bank)
697
+{
698
+  /* Check the parameters */
699
+  assert_param(IS_FSMC_NAND_DEVICE(Device));
700
+  assert_param(IS_FSMC_NAND_BANK(Bank));
701
+
702
+  /* Enable ECC feature */
703
+  if (Bank == FSMC_NAND_BANK2)
704
+  {
705
+    SET_BIT(Device->PCR2, FSMC_PCRx_ECCEN);
706
+  }
707
+  else
708
+  {
709
+    SET_BIT(Device->PCR3, FSMC_PCRx_ECCEN);
710
+  }
711
+
712
+  return HAL_OK;
713
+}
714
+
715
+
716
+/**
717
+  * @brief  Disables dynamically FSMC_NAND ECC feature.
718
+  * @param  Device Pointer to NAND device instance
719
+  * @param  Bank NAND bank number
720
+  * @retval HAL status
721
+  */
722
+HAL_StatusTypeDef FSMC_NAND_ECC_Disable(FSMC_NAND_TypeDef *Device, uint32_t Bank)
723
+{
724
+  /* Check the parameters */
725
+  assert_param(IS_FSMC_NAND_DEVICE(Device));
726
+  assert_param(IS_FSMC_NAND_BANK(Bank));
727
+
728
+  /* Disable ECC feature */
729
+  if (Bank == FSMC_NAND_BANK2)
730
+  {
731
+    CLEAR_BIT(Device->PCR2, FSMC_PCRx_ECCEN);
732
+  }
733
+  else
734
+  {
735
+    CLEAR_BIT(Device->PCR3, FSMC_PCRx_ECCEN);
736
+  }
737
+
738
+  return HAL_OK;
739
+}
740
+
741
+/**
742
+  * @brief  Disables dynamically FSMC_NAND ECC feature.
743
+  * @param  Device Pointer to NAND device instance
744
+  * @param  ECCval Pointer to ECC value
745
+  * @param  Bank NAND bank number
746
+  * @param  Timeout Timeout wait value
747
+  * @retval HAL status
748
+  */
749
+HAL_StatusTypeDef FSMC_NAND_GetECC(FSMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout)
750
+{
751
+  uint32_t tickstart;
752
+
753
+  /* Check the parameters */
754
+  assert_param(IS_FSMC_NAND_DEVICE(Device));
755
+  assert_param(IS_FSMC_NAND_BANK(Bank));
756
+
757
+  /* Get tick */
758
+  tickstart = HAL_GetTick();
759
+
760
+  /* Wait until FIFO is empty */
761
+  while (__FSMC_NAND_GET_FLAG(Device, Bank, FSMC_FLAG_FEMPT) == RESET)
762
+  {
763
+    /* Check for the Timeout */
764
+    if (Timeout != HAL_MAX_DELAY)
765
+    {
766
+      if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
767
+      {
768
+        return HAL_TIMEOUT;
769
+      }
770
+    }
771
+  }
772
+
773
+  if (Bank == FSMC_NAND_BANK2)
774
+  {
775
+    /* Get the ECCR2 register value */
776
+    *ECCval = (uint32_t)Device->ECCR2;
777
+  }
778
+  else
779
+  {
780
+    /* Get the ECCR3 register value */
781
+    *ECCval = (uint32_t)Device->ECCR3;
782
+  }
783
+
784
+  return HAL_OK;
785
+}
786
+
787
+/**
788
+  * @}
789
+  */
790
+#endif /* FSMC_BANK3 */
791
+
792
+#if defined(FSMC_BANK4)
793
+
794
+/** @addtogroup FSMC_LL_PCCARD
795
+  * @brief    PCCARD Controller functions
796
+  *
797
+  @verbatim
798
+  ==============================================================================
799
+                    ##### How to use PCCARD device driver #####
800
+  ==============================================================================
801
+  [..]
802
+    This driver contains a set of APIs to interface with the FSMC PCCARD bank in order
803
+    to run the PCCARD/compact flash external devices.
804
+
805
+    (+) FSMC PCCARD bank reset using the function FSMC_PCCARD_DeInit()
806
+    (+) FSMC PCCARD bank control configuration using the function FSMC_PCCARD_Init()
807
+    (+) FSMC PCCARD bank common space timing configuration using the function
808
+        FSMC_PCCARD_CommonSpace_Timing_Init()
809
+    (+) FSMC PCCARD bank attribute space timing configuration using the function
810
+        FSMC_PCCARD_AttributeSpace_Timing_Init()
811
+    (+) FSMC PCCARD bank IO space timing configuration using the function
812
+        FSMC_PCCARD_IOSpace_Timing_Init()
813
+@endverbatim
814
+  * @{
815
+  */
816
+
817
+/** @addtogroup FSMC_LL_PCCARD_Private_Functions_Group1
818
+  *  @brief    Initialization and Configuration functions
819
+  *
820
+@verbatim
821
+  ==============================================================================
822
+              ##### Initialization and de_initialization functions #####
823
+  ==============================================================================
824
+  [..]
825
+    This section provides functions allowing to:
826
+    (+) Initialize and configure the FSMC PCCARD interface
827
+    (+) De-initialize the FSMC PCCARD interface
828
+    (+) Configure the FSMC clock and associated GPIOs
829
+
830
+@endverbatim
831
+  * @{
832
+  */
833
+
834
+/**
835
+  * @brief  Initializes the FSMC_PCCARD device according to the specified
836
+  *         control parameters in the FSMC_PCCARD_HandleTypeDef
837
+  * @param  Device Pointer to PCCARD device instance
838
+  * @param  Init Pointer to PCCARD Initialization structure
839
+  * @retval HAL status
840
+  */
841
+HAL_StatusTypeDef FSMC_PCCARD_Init(FSMC_PCCARD_TypeDef *Device, FSMC_PCCARD_InitTypeDef *Init)
842
+{
843
+  /* Check the parameters */
844
+  assert_param(IS_FSMC_PCCARD_DEVICE(Device));
845
+  assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature));
846
+  assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime));
847
+  assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime));
848
+
849
+  /* Set FSMC_PCCARD device control parameters */
850
+  MODIFY_REG(Device->PCR4,
851
+             (FSMC_PCRx_PTYP                                          |
852
+              FSMC_PCRx_PWAITEN                                       |
853
+              FSMC_PCRx_PWID                                          |
854
+              FSMC_PCRx_TCLR                                          |
855
+              FSMC_PCRx_TAR),
856
+             (FSMC_PCR_MEMORY_TYPE_PCCARD                             |
857
+              Init->Waitfeature                                      |
858
+              FSMC_NAND_PCC_MEM_BUS_WIDTH_16                          |
859
+              (Init->TCLRSetupTime << FSMC_PCRx_TCLR_Pos)   |
860
+              (Init->TARSetupTime  << FSMC_PCRx_TAR_Pos)));
861
+
862
+  return HAL_OK;
863
+}
864
+
865
+/**
866
+  * @brief  Initializes the FSMC_PCCARD Common space Timing according to the specified
867
+  *         parameters in the FSMC_NAND_PCC_TimingTypeDef
868
+  * @param  Device Pointer to PCCARD device instance
869
+  * @param  Timing Pointer to PCCARD timing structure
870
+  * @retval HAL status
871
+  */
872
+HAL_StatusTypeDef FSMC_PCCARD_CommonSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
873
+{
874
+  /* Check the parameters */
875
+  assert_param(IS_FSMC_PCCARD_DEVICE(Device));
876
+  assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
877
+  assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
878
+  assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
879
+  assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
880
+
881
+  /* Set PCCARD timing parameters */
882
+  MODIFY_REG(Device->PMEM4, PMEM_CLEAR_MASK,
883
+             (Timing->SetupTime                                              |
884
+              ((Timing->WaitSetupTime) << FSMC_PMEMx_MEMWAITx_Pos)  |
885
+              ((Timing->HoldSetupTime) << FSMC_PMEMx_MEMHOLDx_Pos)  |
886
+              ((Timing->HiZSetupTime)  << FSMC_PMEMx_MEMHIZx_Pos)));
887
+
888
+  return HAL_OK;
889
+}
890
+
891
+/**
892
+  * @brief  Initializes the FSMC_PCCARD Attribute space Timing according to the specified
893
+  *         parameters in the FSMC_NAND_PCC_TimingTypeDef
894
+  * @param  Device Pointer to PCCARD device instance
895
+  * @param  Timing Pointer to PCCARD timing structure
896
+  * @retval HAL status
897
+  */
898
+HAL_StatusTypeDef FSMC_PCCARD_AttributeSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
899
+{
900
+  /* Check the parameters */
901
+  assert_param(IS_FSMC_PCCARD_DEVICE(Device));
902
+  assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
903
+  assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
904
+  assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
905
+  assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
906
+
907
+  /* Set PCCARD timing parameters */
908
+  MODIFY_REG(Device->PATT4, PATT_CLEAR_MASK,
909
+             (Timing->SetupTime                                              |
910
+              ((Timing->WaitSetupTime) << FSMC_PATTx_ATTWAITx_Pos)  |
911
+              ((Timing->HoldSetupTime) << FSMC_PATTx_ATTHOLDx_Pos)  |
912
+              ((Timing->HiZSetupTime)  << FSMC_PATTx_ATTHIZx_Pos)));
913
+
914
+  return HAL_OK;
915
+}
916
+
917
+/**
918
+  * @brief  Initializes the FSMC_PCCARD IO space Timing according to the specified
919
+  *         parameters in the FSMC_NAND_PCC_TimingTypeDef
920
+  * @param  Device Pointer to PCCARD device instance
921
+  * @param  Timing Pointer to PCCARD timing structure
922
+  * @retval HAL status
923
+  */
924
+HAL_StatusTypeDef FSMC_PCCARD_IOSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
925
+{
926
+  /* Check the parameters */
927
+  assert_param(IS_FSMC_PCCARD_DEVICE(Device));
928
+  assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
929
+  assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
930
+  assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
931
+  assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
932
+
933
+  /* Set FSMC_PCCARD device timing parameters */
934
+  MODIFY_REG(Device->PIO4, PIO4_CLEAR_MASK,
935
+             (Timing->SetupTime                                           |
936
+              (Timing->WaitSetupTime   << FSMC_PIO4_IOWAIT4_Pos) |
937
+              (Timing->HoldSetupTime   << FSMC_PIO4_IOHOLD4_Pos) |
938
+              (Timing->HiZSetupTime    << FSMC_PIO4_IOHIZ4_Pos)));
939
+
940
+  return HAL_OK;
941
+}
942
+
943
+/**
944
+  * @brief  DeInitializes the FSMC_PCCARD device
945
+  * @param  Device Pointer to PCCARD device instance
946
+  * @retval HAL status
947
+  */
948
+HAL_StatusTypeDef FSMC_PCCARD_DeInit(FSMC_PCCARD_TypeDef *Device)
949
+{
950
+  /* Check the parameters */
951
+  assert_param(IS_FSMC_PCCARD_DEVICE(Device));
952
+
953
+  /* Disable the FSMC_PCCARD device */
954
+  __FSMC_PCCARD_DISABLE(Device);
955
+
956
+  /* De-initialize the FSMC_PCCARD device */
957
+  Device->PCR4    = 0x00000018U;
958
+  Device->SR4     = 0x00000040U;
959
+  Device->PMEM4   = 0xFCFCFCFCU;
960
+  Device->PATT4   = 0xFCFCFCFCU;
961
+  Device->PIO4    = 0xFCFCFCFCU;
962
+
963
+  return HAL_OK;
964
+}
965
+
966
+/**
967
+  * @}
968
+  */
969
+#endif /* FSMC_BANK4 */
970
+
971
+
972
+/**
973
+  * @}
974
+  */
975
+
976
+/**
977
+  * @}
978
+  */
979
+
980
+#endif /* HAL_NOR_MODULE_ENABLED */
981
+/**
982
+  * @}
983
+  */
984
+
985
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 253
- 0
LLDrivers/src/stm32f1xx_ll_gpio.c View File

@@ -0,0 +1,253 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_gpio.c
4
+  * @author  MCD Application Team
5
+  * @brief   GPIO LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+#if defined(USE_FULL_LL_DRIVER)
21
+
22
+/* Includes ------------------------------------------------------------------*/
23
+#include "stm32f1xx_ll_gpio.h"
24
+#include "stm32f1xx_ll_bus.h"
25
+#ifdef  USE_FULL_ASSERT
26
+#include "stm32_assert.h"
27
+#else
28
+#define assert_param(expr) ((void)0U)
29
+#endif
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG)
36
+
37
+/** @addtogroup GPIO_LL
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/* Private macros ------------------------------------------------------------*/
45
+/** @addtogroup GPIO_LL_Private_Macros
46
+  * @{
47
+  */
48
+
49
+#define IS_LL_GPIO_PIN(__VALUE__)          ((((__VALUE__) & LL_GPIO_PIN_ALL)!= 0u) &&\
50
+                                            (((__VALUE__) & (~LL_GPIO_PIN_ALL))== 0u))
51
+
52
+#define IS_LL_GPIO_MODE(__VALUE__)         (((__VALUE__) == LL_GPIO_MODE_ANALOG)       ||\
53
+                                            ((__VALUE__) == LL_GPIO_MODE_FLOATING)     ||\
54
+                                            ((__VALUE__) == LL_GPIO_MODE_INPUT)        ||\
55
+                                            ((__VALUE__) == LL_GPIO_MODE_OUTPUT)       ||\
56
+                                            ((__VALUE__) == LL_GPIO_MODE_ALTERNATE))
57
+
58
+#define IS_LL_GPIO_SPEED(__VALUE__)        (((__VALUE__) == LL_GPIO_SPEED_FREQ_LOW)       ||\
59
+                                            ((__VALUE__) == LL_GPIO_SPEED_FREQ_MEDIUM)    ||\
60
+                                            ((__VALUE__) == LL_GPIO_SPEED_FREQ_HIGH))
61
+
62
+#define IS_LL_GPIO_OUTPUT_TYPE(__VALUE__)  (((__VALUE__) == LL_GPIO_OUTPUT_PUSHPULL)  ||\
63
+                                            ((__VALUE__) == LL_GPIO_OUTPUT_OPENDRAIN))
64
+
65
+#define IS_LL_GPIO_PULL(__VALUE__)         (((__VALUE__) == LL_GPIO_PULL_DOWN)   ||\
66
+                                            ((__VALUE__) == LL_GPIO_PULL_UP))
67
+
68
+/**
69
+  * @}
70
+  */
71
+
72
+/* Private function prototypes -----------------------------------------------*/
73
+
74
+/* Exported functions --------------------------------------------------------*/
75
+/** @addtogroup GPIO_LL_Exported_Functions
76
+  * @{
77
+  */
78
+
79
+/** @addtogroup GPIO_LL_EF_Init
80
+  * @{
81
+  */
82
+
83
+/**
84
+  * @brief  De-initialize GPIO registers (Registers restored to their default values).
85
+  * @param  GPIOx GPIO Port
86
+  * @retval An ErrorStatus enumeration value:
87
+  *          - SUCCESS: GPIO registers are de-initialized
88
+  *          - ERROR:   Wrong GPIO Port
89
+  */
90
+ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx)
91
+{
92
+  ErrorStatus status = SUCCESS;
93
+
94
+  /* Check the parameters */
95
+  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
96
+
97
+  /* Force and Release reset on clock of GPIOx Port */
98
+  if (GPIOx == GPIOA)
99
+  {
100
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_GPIOA);
101
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_GPIOA);
102
+  }
103
+  else if (GPIOx == GPIOB)
104
+  {
105
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_GPIOB);
106
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_GPIOB);
107
+  }
108
+  else if (GPIOx == GPIOC)
109
+  {
110
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_GPIOC);
111
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_GPIOC);
112
+  }
113
+  else if (GPIOx == GPIOD)
114
+  {
115
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_GPIOD);
116
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_GPIOD);
117
+  }
118
+#if defined(GPIOE)
119
+  else if (GPIOx == GPIOE)
120
+  {
121
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_GPIOE);
122
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_GPIOE);
123
+  }
124
+#endif
125
+#if defined(GPIOF)
126
+  else if (GPIOx == GPIOF)
127
+  {
128
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_GPIOF);
129
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_GPIOF);
130
+  }
131
+#endif
132
+#if defined(GPIOG)
133
+  else if (GPIOx == GPIOG)
134
+  {
135
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_GPIOG);
136
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_GPIOG);
137
+  }
138
+#endif
139
+  else
140
+  {
141
+    status = ERROR;
142
+  }
143
+
144
+  return (status);
145
+}
146
+
147
+/**
148
+  * @brief  Initialize GPIO registers according to the specified parameters in GPIO_InitStruct.
149
+  * @param  GPIOx GPIO Port
150
+  * @param  GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure
151
+  *         that contains the configuration information for the specified GPIO peripheral.
152
+  * @retval An ErrorStatus enumeration value:
153
+  *          - SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content
154
+  *          - ERROR:   Not applicable
155
+  */
156
+ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct)
157
+{
158
+  uint32_t pinmask;
159
+  uint32_t pinpos;
160
+  uint32_t currentpin;
161
+
162
+  /* Check the parameters */
163
+  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
164
+  assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin));
165
+
166
+  /* ------------------------- Configure the port pins ---------------- */
167
+  /* Initialize  pinpos on first pin set */
168
+
169
+  pinmask = ((GPIO_InitStruct->Pin) << GPIO_PIN_MASK_POS) >> GPIO_PIN_NB;
170
+  pinpos = POSITION_VAL(pinmask);
171
+
172
+  /* Configure the port pins */
173
+  while ((pinmask  >> pinpos) != 0u)
174
+  {
175
+    /* skip if bit is not set */
176
+    if ((pinmask & (1u << pinpos)) != 0u)
177
+    {
178
+      /* Get current io position */
179
+      if (pinpos < GPIO_PIN_MASK_POS)
180
+      {
181
+        currentpin = (0x00000101uL << pinpos);
182
+      }
183
+      else
184
+      {
185
+        currentpin = ((0x00010001u << (pinpos - GPIO_PIN_MASK_POS)) | 0x04000000u);
186
+      }
187
+
188
+      /* Check Pin Mode and Pin Pull parameters */
189
+      assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode));
190
+      assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull));
191
+
192
+      /* Pin Mode configuration */
193
+      LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode);
194
+
195
+      /* Pull-up Pull-down resistor configuration*/
196
+      LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull);
197
+
198
+      if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
199
+      {
200
+        /* Check speed and Output mode parameters */
201
+        assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed));
202
+        assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType));
203
+
204
+        /* Speed mode configuration */
205
+        LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed);
206
+
207
+        /* Output mode configuration*/
208
+        LL_GPIO_SetPinOutputType(GPIOx, currentpin, GPIO_InitStruct->OutputType);
209
+      }
210
+    }
211
+    pinpos++;
212
+  }
213
+  return (SUCCESS);
214
+}
215
+
216
+/**
217
+  * @brief Set each @ref LL_GPIO_InitTypeDef field to default value.
218
+  * @param GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure
219
+  *                          whose fields will be set to default values.
220
+  * @retval None
221
+  */
222
+
223
+void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct)
224
+{
225
+  /* Reset GPIO init structure parameters values */
226
+  GPIO_InitStruct->Pin        = LL_GPIO_PIN_ALL;
227
+  GPIO_InitStruct->Mode       = LL_GPIO_MODE_FLOATING;
228
+  GPIO_InitStruct->Speed      = LL_GPIO_SPEED_FREQ_LOW;
229
+  GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
230
+  GPIO_InitStruct->Pull       = LL_GPIO_PULL_DOWN;
231
+}
232
+
233
+/**
234
+  * @}
235
+  */
236
+
237
+/**
238
+  * @}
239
+  */
240
+
241
+/**
242
+  * @}
243
+  */
244
+
245
+#endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) */
246
+
247
+/**
248
+  * @}
249
+  */
250
+
251
+#endif /* USE_FULL_LL_DRIVER */
252
+
253
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 221
- 0
LLDrivers/src/stm32f1xx_ll_i2c.c View File

@@ -0,0 +1,221 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_i2c.c
4
+  * @author  MCD Application Team
5
+  * @brief   I2C LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+#if defined(USE_FULL_LL_DRIVER)
20
+
21
+/* Includes ------------------------------------------------------------------*/
22
+#include "stm32f1xx_ll_i2c.h"
23
+#include "stm32f1xx_ll_bus.h"
24
+#include "stm32f1xx_ll_rcc.h"
25
+#ifdef  USE_FULL_ASSERT
26
+#include "stm32_assert.h"
27
+#else
28
+#define assert_param(expr) ((void)0U)
29
+#endif
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined (I2C1) || defined (I2C2)
36
+
37
+/** @defgroup I2C_LL I2C
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/* Private macros ------------------------------------------------------------*/
45
+/** @addtogroup I2C_LL_Private_Macros
46
+  * @{
47
+  */
48
+
49
+#define IS_LL_I2C_PERIPHERAL_MODE(__VALUE__)    (((__VALUE__) == LL_I2C_MODE_I2C)          || \
50
+                                                 ((__VALUE__) == LL_I2C_MODE_SMBUS_HOST)   || \
51
+                                                 ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE) || \
52
+                                                 ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE_ARP))
53
+
54
+#define IS_LL_I2C_CLOCK_SPEED(__VALUE__)           (((__VALUE__) > 0U) && ((__VALUE__) <= LL_I2C_MAX_SPEED_FAST))
55
+
56
+#define IS_LL_I2C_DUTY_CYCLE(__VALUE__)            (((__VALUE__) == LL_I2C_DUTYCYCLE_2) || \
57
+                                                 ((__VALUE__) == LL_I2C_DUTYCYCLE_16_9))
58
+
59
+#define IS_LL_I2C_OWN_ADDRESS1(__VALUE__)       ((__VALUE__) <= 0x000003FFU)
60
+
61
+#define IS_LL_I2C_TYPE_ACKNOWLEDGE(__VALUE__)   (((__VALUE__) == LL_I2C_ACK) || \
62
+                                                 ((__VALUE__) == LL_I2C_NACK))
63
+
64
+#define IS_LL_I2C_OWN_ADDRSIZE(__VALUE__)       (((__VALUE__) == LL_I2C_OWNADDRESS1_7BIT) || \
65
+                                                 ((__VALUE__) == LL_I2C_OWNADDRESS1_10BIT))
66
+/**
67
+  * @}
68
+  */
69
+
70
+/* Private function prototypes -----------------------------------------------*/
71
+
72
+/* Exported functions --------------------------------------------------------*/
73
+/** @addtogroup I2C_LL_Exported_Functions
74
+  * @{
75
+  */
76
+
77
+/** @addtogroup I2C_LL_EF_Init
78
+  * @{
79
+  */
80
+
81
+/**
82
+  * @brief  De-initialize the I2C registers to their default reset values.
83
+  * @param  I2Cx I2C Instance.
84
+  * @retval An ErrorStatus enumeration value:
85
+  *          - SUCCESS  I2C registers are de-initialized
86
+  *          - ERROR  I2C registers are not de-initialized
87
+  */
88
+uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx)
89
+{
90
+  ErrorStatus status = SUCCESS;
91
+
92
+  /* Check the I2C Instance I2Cx */
93
+  assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
94
+
95
+  if (I2Cx == I2C1)
96
+  {
97
+    /* Force reset of I2C clock */
98
+    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1);
99
+
100
+    /* Release reset of I2C clock */
101
+    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1);
102
+  }
103
+#if defined(I2C2)
104
+  else if (I2Cx == I2C2)
105
+  {
106
+    /* Force reset of I2C clock */
107
+    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C2);
108
+
109
+    /* Release reset of I2C clock */
110
+    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C2);
111
+
112
+  }
113
+#endif /* I2C2 */
114
+  else
115
+  {
116
+    status = ERROR;
117
+  }
118
+
119
+  return status;
120
+}
121
+
122
+/**
123
+  * @brief  Initialize the I2C registers according to the specified parameters in I2C_InitStruct.
124
+  * @param  I2Cx I2C Instance.
125
+  * @param  I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure.
126
+  * @retval An ErrorStatus enumeration value:
127
+  *          - SUCCESS  I2C registers are initialized
128
+  *          - ERROR  Not applicable
129
+  */
130
+uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct)
131
+{
132
+  LL_RCC_ClocksTypeDef rcc_clocks;
133
+
134
+  /* Check the I2C Instance I2Cx */
135
+  assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
136
+
137
+  /* Check the I2C parameters from I2C_InitStruct */
138
+  assert_param(IS_LL_I2C_PERIPHERAL_MODE(I2C_InitStruct->PeripheralMode));
139
+  assert_param(IS_LL_I2C_CLOCK_SPEED(I2C_InitStruct->ClockSpeed));
140
+  assert_param(IS_LL_I2C_DUTY_CYCLE(I2C_InitStruct->DutyCycle));
141
+  assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1));
142
+  assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge));
143
+  assert_param(IS_LL_I2C_OWN_ADDRSIZE(I2C_InitStruct->OwnAddrSize));
144
+
145
+  /* Disable the selected I2Cx Peripheral */
146
+  LL_I2C_Disable(I2Cx);
147
+
148
+  /* Retrieve Clock frequencies */
149
+  LL_RCC_GetSystemClocksFreq(&rcc_clocks);
150
+
151
+  /*---------------------------- I2Cx SCL Clock Speed Configuration ------------
152
+   * Configure the SCL speed :
153
+   * - ClockSpeed: I2C_CR2_FREQ[5:0], I2C_TRISE_TRISE[5:0], I2C_CCR_FS,
154
+   *           and I2C_CCR_CCR[11:0] bits
155
+   * - DutyCycle: I2C_CCR_DUTY[7:0] bits
156
+   */
157
+  LL_I2C_ConfigSpeed(I2Cx, rcc_clocks.PCLK1_Frequency, I2C_InitStruct->ClockSpeed, I2C_InitStruct->DutyCycle);
158
+
159
+  /*---------------------------- I2Cx OAR1 Configuration -----------------------
160
+   * Disable, Configure and Enable I2Cx device own address 1 with parameters :
161
+   * - OwnAddress1:  I2C_OAR1_ADD[9:8], I2C_OAR1_ADD[7:1] and I2C_OAR1_ADD0 bits
162
+   * - OwnAddrSize:  I2C_OAR1_ADDMODE bit
163
+   */
164
+  LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, I2C_InitStruct->OwnAddrSize);
165
+
166
+  /*---------------------------- I2Cx MODE Configuration -----------------------
167
+  * Configure I2Cx peripheral mode with parameter :
168
+   * - PeripheralMode: I2C_CR1_SMBUS, I2C_CR1_SMBTYPE and I2C_CR1_ENARP bits
169
+   */
170
+  LL_I2C_SetMode(I2Cx, I2C_InitStruct->PeripheralMode);
171
+
172
+  /* Enable the selected I2Cx Peripheral */
173
+  LL_I2C_Enable(I2Cx);
174
+
175
+  /*---------------------------- I2Cx CR2 Configuration ------------------------
176
+   * Configure the ACKnowledge or Non ACKnowledge condition
177
+   * after the address receive match code or next received byte with parameter :
178
+   * - TypeAcknowledge: I2C_CR2_NACK bit
179
+   */
180
+  LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge);
181
+
182
+  return SUCCESS;
183
+}
184
+
185
+/**
186
+  * @brief  Set each @ref LL_I2C_InitTypeDef field to default value.
187
+  * @param  I2C_InitStruct Pointer to a @ref LL_I2C_InitTypeDef structure.
188
+  * @retval None
189
+  */
190
+void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct)
191
+{
192
+  /* Set I2C_InitStruct fields to default values */
193
+  I2C_InitStruct->PeripheralMode  = LL_I2C_MODE_I2C;
194
+  I2C_InitStruct->ClockSpeed      = 5000U;
195
+  I2C_InitStruct->DutyCycle       = LL_I2C_DUTYCYCLE_2;
196
+  I2C_InitStruct->OwnAddress1     = 0U;
197
+  I2C_InitStruct->TypeAcknowledge = LL_I2C_NACK;
198
+  I2C_InitStruct->OwnAddrSize     = LL_I2C_OWNADDRESS1_7BIT;
199
+}
200
+
201
+/**
202
+  * @}
203
+  */
204
+
205
+/**
206
+  * @}
207
+  */
208
+
209
+/**
210
+  * @}
211
+  */
212
+
213
+#endif /* I2C1 || I2C2 */
214
+
215
+/**
216
+  * @}
217
+  */
218
+
219
+#endif /* USE_FULL_LL_DRIVER */
220
+
221
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 86
- 0
LLDrivers/src/stm32f1xx_ll_pwr.c View File

@@ -0,0 +1,86 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_pwr.c
4
+  * @author  MCD Application Team
5
+  * @brief   PWR LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+#if defined(USE_FULL_LL_DRIVER)
21
+
22
+/* Includes ------------------------------------------------------------------*/
23
+#include "stm32f1xx_ll_pwr.h"
24
+#include "stm32f1xx_ll_bus.h"
25
+
26
+/** @addtogroup STM32F1xx_LL_Driver
27
+  * @{
28
+  */
29
+
30
+#if defined(PWR)
31
+
32
+/** @defgroup PWR_LL PWR
33
+  * @{
34
+  */
35
+
36
+/* Private types -------------------------------------------------------------*/
37
+/* Private variables ---------------------------------------------------------*/
38
+/* Private constants ---------------------------------------------------------*/
39
+/* Private macros ------------------------------------------------------------*/
40
+/* Private function prototypes -----------------------------------------------*/
41
+
42
+/* Exported functions --------------------------------------------------------*/
43
+/** @addtogroup PWR_LL_Exported_Functions
44
+  * @{
45
+  */
46
+
47
+/** @addtogroup PWR_LL_EF_Init
48
+  * @{
49
+  */
50
+
51
+/**
52
+  * @brief  De-initialize the PWR registers to their default reset values.
53
+  * @retval An ErrorStatus enumeration value:
54
+  *          - SUCCESS: PWR registers are de-initialized
55
+  *          - ERROR: not applicable
56
+  */
57
+ErrorStatus LL_PWR_DeInit(void)
58
+{
59
+  /* Force reset of PWR clock */
60
+  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_PWR);
61
+
62
+  /* Release reset of PWR clock */
63
+  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_PWR);
64
+
65
+  return SUCCESS;
66
+}
67
+
68
+/**
69
+  * @}
70
+  */
71
+
72
+/**
73
+  * @}
74
+  */
75
+
76
+/**
77
+  * @}
78
+  */
79
+#endif /* defined(PWR) */
80
+/**
81
+  * @}
82
+  */
83
+
84
+#endif /* USE_FULL_LL_DRIVER */
85
+
86
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 544
- 0
LLDrivers/src/stm32f1xx_ll_rtc.c View File

@@ -0,0 +1,544 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_rtc.c
4
+  * @author  MCD Application Team
5
+  * @brief   RTC LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+#if defined(USE_FULL_LL_DRIVER)
21
+
22
+/* Includes ------------------------------------------------------------------*/
23
+#include "stm32f1xx_ll_rtc.h"
24
+#include "stm32f1xx_ll_cortex.h"
25
+#ifdef  USE_FULL_ASSERT
26
+#include "stm32_assert.h"
27
+#else
28
+#define assert_param(expr) ((void)0U)
29
+#endif
30
+
31
+/** @addtogroup STM32F1xx_LL_Driver
32
+  * @{
33
+  */
34
+
35
+#if defined(RTC)
36
+
37
+/** @addtogroup RTC_LL
38
+  * @{
39
+  */
40
+
41
+/* Private types -------------------------------------------------------------*/
42
+/* Private variables ---------------------------------------------------------*/
43
+/* Private constants ---------------------------------------------------------*/
44
+/** @addtogroup RTC_LL_Private_Constants
45
+  * @{
46
+  */
47
+/* Default values used for prescaler */
48
+#define RTC_ASYNCH_PRESC_DEFAULT     0x00007FFFU
49
+
50
+/* Values used for timeout */
51
+#define RTC_INITMODE_TIMEOUT         1000U /* 1s when tick set to 1ms */
52
+#define RTC_SYNCHRO_TIMEOUT          1000U /* 1s when tick set to 1ms */
53
+/**
54
+  * @}
55
+  */
56
+
57
+/* Private macros ------------------------------------------------------------*/
58
+/** @addtogroup RTC_LL_Private_Macros
59
+  * @{
60
+  */
61
+
62
+#define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__)   ((__VALUE__) <= 0xFFFFFU)
63
+
64
+#define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \
65
+                                  || ((__VALUE__) == LL_RTC_FORMAT_BCD))
66
+
67
+#define IS_LL_RTC_HOUR24(__HOUR__)            ((__HOUR__) <= 23U)
68
+#define IS_LL_RTC_MINUTES(__MINUTES__)        ((__MINUTES__) <= 59U)
69
+#define IS_LL_RTC_SECONDS(__SECONDS__)        ((__SECONDS__) <= 59U)
70
+#define IS_LL_RTC_CALIB_OUTPUT(__OUTPUT__) (((__OUTPUT__) == LL_RTC_CALIB_OUTPUT_NONE) || \
71
+                                            ((__OUTPUT__) == LL_RTC_CALIB_OUTPUT_RTCCLOCK) || \
72
+                                            ((__OUTPUT__) == LL_RTC_CALIB_OUTPUT_ALARM) || \
73
+                                            ((__OUTPUT__) == LL_RTC_CALIB_OUTPUT_SECOND))
74
+/**
75
+  * @}
76
+  */
77
+/* Private function prototypes -----------------------------------------------*/
78
+/* Exported functions --------------------------------------------------------*/
79
+/** @addtogroup RTC_LL_Exported_Functions
80
+  * @{
81
+  */
82
+
83
+/** @addtogroup RTC_LL_EF_Init
84
+  * @{
85
+  */
86
+
87
+/**
88
+  * @brief  De-Initializes the RTC registers to their default reset values.
89
+  * @note   This function doesn't reset the RTC Clock source and RTC Backup Data
90
+  *         registers.
91
+  * @param  RTCx RTC Instance
92
+  * @retval An ErrorStatus enumeration value:
93
+  *          - SUCCESS: RTC registers are de-initialized
94
+  *          - ERROR: RTC registers are not de-initialized
95
+  */
96
+ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx)
97
+{
98
+  ErrorStatus status = ERROR;
99
+
100
+  /* Check the parameter */
101
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
102
+
103
+  /* Disable the write protection for RTC registers */
104
+  LL_RTC_DisableWriteProtection(RTCx);
105
+
106
+  /* Set Initialization mode */
107
+  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
108
+  {
109
+    LL_RTC_WriteReg(RTCx, CNTL, 0x0000);
110
+    LL_RTC_WriteReg(RTCx, CNTH, 0x0000);
111
+    LL_RTC_WriteReg(RTCx, PRLH, 0x0000);
112
+    LL_RTC_WriteReg(RTCx, PRLL, 0x8000);
113
+    LL_RTC_WriteReg(RTCx, CRH,  0x0000);
114
+    LL_RTC_WriteReg(RTCx, CRL,  0x0020);
115
+
116
+    /* Reset Tamper and alternate functions configuration register */
117
+    LL_RTC_WriteReg(BKP, RTCCR, 0x00000000U);
118
+    LL_RTC_WriteReg(BKP, CR,    0x00000000U);
119
+    LL_RTC_WriteReg(BKP, CSR,   0x00000000U);
120
+
121
+    /* Exit Initialization Mode */
122
+    if (LL_RTC_ExitInitMode(RTCx) != ERROR)
123
+    {
124
+      /* Wait till the RTC RSF flag is set */
125
+      status = LL_RTC_WaitForSynchro(RTCx);
126
+  
127
+      /* Clear RSF Flag */
128
+      LL_RTC_ClearFlag_RS(RTCx);
129
+      
130
+      /* Enable the write protection for RTC registers */
131
+      LL_RTC_EnableWriteProtection(RTCx);
132
+    }
133
+  }
134
+  else
135
+  {
136
+    /* Enable the write protection for RTC registers */
137
+    LL_RTC_EnableWriteProtection(RTCx);
138
+  }
139
+
140
+  return status;
141
+}
142
+
143
+/**
144
+  * @brief  Initializes the RTC registers according to the specified parameters
145
+  *         in RTC_InitStruct.
146
+  * @param  RTCx RTC Instance
147
+  * @param  RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure that contains
148
+  *         the configuration information for the RTC peripheral.
149
+  * @note   The RTC Prescaler register is write protected and can be written in
150
+  *         initialization mode only.
151
+  * @note   the user should call LL_RTC_StructInit()  or the structure of Prescaler
152
+  *         need to be initialized  before RTC init()
153
+  * @retval An ErrorStatus enumeration value:
154
+  *          - SUCCESS: RTC registers are initialized
155
+  *          - ERROR: RTC registers are not initialized
156
+  */
157
+ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct)
158
+{
159
+  ErrorStatus status = ERROR;
160
+
161
+  /* Check the parameters */
162
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
163
+  assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->AsynchPrescaler));
164
+  assert_param(IS_LL_RTC_CALIB_OUTPUT(RTC_InitStruct->OutPutSource));
165
+  /* Waiting for synchro */
166
+  if (LL_RTC_WaitForSynchro(RTCx) != ERROR)
167
+  {
168
+    /* Set Initialization mode */
169
+    if (LL_RTC_EnterInitMode(RTCx) != ERROR)
170
+    {
171
+      /* Clear Flag Bits */
172
+      LL_RTC_ClearFlag_ALR(RTCx);
173
+      LL_RTC_ClearFlag_OW(RTCx);
174
+      LL_RTC_ClearFlag_SEC(RTCx);
175
+
176
+      if (RTC_InitStruct->OutPutSource != LL_RTC_CALIB_OUTPUT_NONE)
177
+      {
178
+        /* Disable the selected Tamper Pin */
179
+        LL_RTC_TAMPER_Disable(BKP);
180
+      }
181
+      /* Set the signal which will be routed to RTC Tamper Pin */
182
+      LL_RTC_SetOutputSource(BKP, RTC_InitStruct->OutPutSource);
183
+
184
+      /* Configure Synchronous and Asynchronous prescaler factor */
185
+      LL_RTC_SetAsynchPrescaler(RTCx, RTC_InitStruct->AsynchPrescaler);
186
+
187
+      /* Exit Initialization Mode */
188
+      LL_RTC_ExitInitMode(RTCx);
189
+
190
+      status = SUCCESS;
191
+    }
192
+  }
193
+  return status;
194
+}
195
+
196
+/**
197
+  * @brief  Set each @ref LL_RTC_InitTypeDef field to default value.
198
+  * @param  RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure which will be initialized.
199
+  * @retval None
200
+  */
201
+void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct)
202
+{
203
+  /* Set RTC_InitStruct fields to default values */
204
+  RTC_InitStruct->AsynchPrescaler = RTC_ASYNCH_PRESC_DEFAULT;
205
+  RTC_InitStruct->OutPutSource    = LL_RTC_CALIB_OUTPUT_NONE;
206
+}
207
+
208
+/**
209
+  * @brief  Set the RTC current time.
210
+  * @param  RTCx RTC Instance
211
+  * @param  RTC_Format This parameter can be one of the following values:
212
+  *         @arg @ref LL_RTC_FORMAT_BIN
213
+  *         @arg @ref LL_RTC_FORMAT_BCD
214
+  * @param  RTC_TimeStruct pointer to a RTC_TimeTypeDef structure that contains
215
+  *                        the time configuration information for the RTC.
216
+  * @note  The user should call LL_RTC_TIME_StructInit() or the structure
217
+  *        of time need to be initialized  before time init()
218
+  * @retval An ErrorStatus enumeration value:
219
+  *          - SUCCESS: RTC Time register is configured
220
+  *          - ERROR: RTC Time register is not configured
221
+  */
222
+ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct)
223
+{
224
+  ErrorStatus status = ERROR;
225
+  uint32_t counter_time = 0U;
226
+
227
+  /* Check the parameters */
228
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
229
+  assert_param(IS_LL_RTC_FORMAT(RTC_Format));
230
+
231
+  if (RTC_Format == LL_RTC_FORMAT_BIN)
232
+  {
233
+    assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->Hours));
234
+    assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->Minutes));
235
+    assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->Seconds));
236
+  }
237
+  else
238
+  {
239
+    assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours)));
240
+    assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes)));
241
+    assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds)));
242
+  }
243
+
244
+  /* Enter Initialization mode */
245
+  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
246
+  {
247
+    /* Check the input parameters format */
248
+    if (RTC_Format != LL_RTC_FORMAT_BIN)
249
+    {
250
+      counter_time = (uint32_t)(((uint32_t)RTC_TimeStruct->Hours * 3600U) + \
251
+                                ((uint32_t)RTC_TimeStruct->Minutes * 60U) + \
252
+                                ((uint32_t)RTC_TimeStruct->Seconds));
253
+      LL_RTC_TIME_Set(RTCx, counter_time);
254
+    }
255
+    else
256
+    {
257
+      counter_time = (((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours)) * 3600U) + \
258
+                      ((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes)) * 60U) + \
259
+                      ((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds))));
260
+      LL_RTC_TIME_Set(RTCx, counter_time);
261
+    }
262
+    status = SUCCESS;
263
+  }
264
+  /* Exit Initialization mode */
265
+  LL_RTC_ExitInitMode(RTCx);
266
+
267
+  return status;
268
+}
269
+
270
+/**
271
+  * @brief  Set each @ref LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec).
272
+  * @param  RTC_TimeStruct pointer to a @ref LL_RTC_TimeTypeDef structure which will be initialized.
273
+  * @retval None
274
+  */
275
+void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct)
276
+{
277
+  /* Time = 00h:00min:00sec */
278
+  RTC_TimeStruct->Hours      = 0U;
279
+  RTC_TimeStruct->Minutes    = 0U;
280
+  RTC_TimeStruct->Seconds    = 0U;
281
+}
282
+
283
+/**
284
+  * @brief  Set the RTC Alarm.
285
+  * @param  RTCx RTC Instance
286
+  * @param  RTC_Format This parameter can be one of the following values:
287
+  *         @arg @ref LL_RTC_FORMAT_BIN
288
+  *         @arg @ref LL_RTC_FORMAT_BCD
289
+  * @param  RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that
290
+  *                         contains the alarm configuration parameters.
291
+  * @note   the user should call LL_RTC_ALARM_StructInit()  or the structure
292
+  *         of Alarm need to be initialized  before Alarm init()
293
+  * @retval An ErrorStatus enumeration value:
294
+  *          - SUCCESS: ALARM registers are configured
295
+  *          - ERROR: ALARM registers are not configured
296
+  */
297
+ErrorStatus LL_RTC_ALARM_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
298
+{
299
+  ErrorStatus status = ERROR;
300
+  uint32_t counter_alarm = 0U;
301
+  /* Check the parameters */
302
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
303
+  assert_param(IS_LL_RTC_FORMAT(RTC_Format));
304
+
305
+  if (RTC_Format == LL_RTC_FORMAT_BIN)
306
+  {
307
+    assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours));
308
+    assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes));
309
+    assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds));
310
+  }
311
+  else
312
+  {
313
+    assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
314
+    assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes)));
315
+    assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds)));
316
+  }
317
+
318
+  /* Enter Initialization mode */
319
+  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
320
+  {
321
+    /* Check the input parameters format */
322
+    if (RTC_Format != LL_RTC_FORMAT_BIN)
323
+    {
324
+      counter_alarm = (uint32_t)(((uint32_t)RTC_AlarmStruct->AlarmTime.Hours * 3600U) + \
325
+                                 ((uint32_t)RTC_AlarmStruct->AlarmTime.Minutes * 60U) + \
326
+                                 ((uint32_t)RTC_AlarmStruct->AlarmTime.Seconds));
327
+      LL_RTC_ALARM_Set(RTCx, counter_alarm);
328
+    }
329
+    else
330
+    {
331
+      counter_alarm = (((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)) * 3600U) + \
332
+                       ((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes)) * 60U) + \
333
+                       ((uint32_t)(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))));
334
+      LL_RTC_ALARM_Set(RTCx, counter_alarm);
335
+    }
336
+    status = SUCCESS;
337
+  }
338
+  /* Exit Initialization mode */
339
+  LL_RTC_ExitInitMode(RTCx);
340
+
341
+  return status;
342
+}
343
+
344
+/**
345
+  * @brief  Set each @ref LL_RTC_AlarmTypeDef of ALARM field to default value (Time = 00h:00mn:00sec /
346
+  *         Day = 1st day of the month/Mask = all fields are masked).
347
+  * @param  RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized.
348
+  * @retval None
349
+  */
350
+void LL_RTC_ALARM_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
351
+{
352
+  /* Alarm Time Settings : Time = 00h:00mn:00sec */
353
+  RTC_AlarmStruct->AlarmTime.Hours      = 0U;
354
+  RTC_AlarmStruct->AlarmTime.Minutes    = 0U;
355
+  RTC_AlarmStruct->AlarmTime.Seconds    = 0U;
356
+}
357
+
358
+/**
359
+  * @brief  Enters the RTC Initialization mode.
360
+  * @param  RTCx RTC Instance
361
+  * @retval An ErrorStatus enumeration value:
362
+  *          - SUCCESS: RTC is in Init mode
363
+  *          - ERROR: RTC is not in Init mode
364
+  */
365
+ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx)
366
+{
367
+  __IO uint32_t timeout = RTC_INITMODE_TIMEOUT;
368
+  ErrorStatus status = SUCCESS;
369
+  uint32_t tmp = 0U;
370
+
371
+  /* Check the parameter */
372
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
373
+
374
+  /* Wait till RTC is in INIT state and if Time out is reached exit */
375
+  tmp = LL_RTC_IsActiveFlag_RTOF(RTCx);
376
+  while ((timeout != 0U) && (tmp != 1U))
377
+  {
378
+    if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
379
+    {
380
+      timeout --;
381
+    }
382
+    tmp = LL_RTC_IsActiveFlag_RTOF(RTCx);
383
+    if (timeout == 0U)
384
+    {
385
+      status = ERROR;
386
+    }
387
+  }
388
+
389
+  /* Disable the write protection for RTC registers */
390
+  LL_RTC_DisableWriteProtection(RTCx);
391
+
392
+  return status;
393
+}
394
+
395
+/**
396
+  * @brief  Exit the RTC Initialization mode.
397
+  * @note   When the initialization sequence is complete, the calendar restarts
398
+  *         counting after 4 RTCCLK cycles.
399
+  * @param  RTCx RTC Instance
400
+  * @retval An ErrorStatus enumeration value:
401
+  *          - SUCCESS: RTC exited from in Init mode
402
+  *          - ERROR: Not applicable
403
+  */
404
+ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx)
405
+{
406
+  __IO uint32_t timeout = RTC_INITMODE_TIMEOUT;
407
+  ErrorStatus status = SUCCESS;
408
+  uint32_t tmp = 0U;
409
+
410
+  /* Check the parameter */
411
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
412
+
413
+  /* Disable initialization mode */
414
+  LL_RTC_EnableWriteProtection(RTCx);
415
+
416
+  /* Wait till RTC is in INIT state and if Time out is reached exit */
417
+  tmp = LL_RTC_IsActiveFlag_RTOF(RTCx);
418
+  while ((timeout != 0U) && (tmp != 1U))
419
+  {
420
+    if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
421
+    {
422
+      timeout --;
423
+    }
424
+    tmp = LL_RTC_IsActiveFlag_RTOF(RTCx);
425
+    if (timeout == 0U)
426
+    {
427
+      status = ERROR;
428
+    }
429
+  }
430
+  return status;
431
+}
432
+
433
+/**
434
+  * @brief  Set the Time Counter
435
+  * @param  RTCx RTC Instance
436
+  * @param  TimeCounter this value can be from 0 to 0xFFFFFFFF
437
+  * @retval An ErrorStatus enumeration value:
438
+  *          - SUCCESS: RTC Counter register configured
439
+  *          - ERROR: Not applicable
440
+  */
441
+ErrorStatus LL_RTC_TIME_SetCounter(RTC_TypeDef *RTCx, uint32_t TimeCounter)
442
+{
443
+  ErrorStatus status = ERROR;
444
+  /* Check the parameter */
445
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
446
+
447
+  /* Enter Initialization mode */
448
+  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
449
+  {
450
+    LL_RTC_TIME_Set(RTCx, TimeCounter);
451
+    status = SUCCESS;
452
+  }
453
+  /* Exit Initialization mode */
454
+  LL_RTC_ExitInitMode(RTCx);
455
+
456
+  return status;
457
+}
458
+
459
+/**
460
+  * @brief  Set Alarm Counter.
461
+  * @param  RTCx RTC Instance
462
+  * @param  AlarmCounter this value can be from 0 to 0xFFFFFFFF
463
+  * @retval An ErrorStatus enumeration value:
464
+  *          - SUCCESS: RTC exited from in Init mode
465
+  *          - ERROR: Not applicable
466
+  */
467
+ErrorStatus LL_RTC_ALARM_SetCounter(RTC_TypeDef *RTCx, uint32_t AlarmCounter)
468
+{
469
+  ErrorStatus status = ERROR;
470
+  /* Check the parameter */
471
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
472
+
473
+  /* Enter Initialization mode */
474
+  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
475
+  {
476
+    LL_RTC_ALARM_Set(RTCx, AlarmCounter);
477
+    status = SUCCESS;
478
+  }
479
+  /* Exit Initialization mode */
480
+  LL_RTC_ExitInitMode(RTCx);
481
+
482
+  return status;
483
+}
484
+
485
+/**
486
+  * @brief  Waits until the RTC registers are synchronized with RTC APB clock.
487
+  * @note   The RTC Resynchronization mode is write protected, use the
488
+  *         @ref LL_RTC_DisableWriteProtection before calling this function.
489
+  * @param  RTCx RTC Instance
490
+  * @retval An ErrorStatus enumeration value:
491
+  *          - SUCCESS: RTC registers are synchronised
492
+  *          - ERROR: RTC registers are not synchronised
493
+  */
494
+ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx)
495
+{
496
+  __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT;
497
+  ErrorStatus status = SUCCESS;
498
+  uint32_t tmp = 0U;
499
+
500
+  /* Check the parameter */
501
+  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
502
+
503
+  /* Clear RSF flag */
504
+  LL_RTC_ClearFlag_RS(RTCx);
505
+
506
+  /* Wait the registers to be synchronised */
507
+  tmp = LL_RTC_IsActiveFlag_RS(RTCx);
508
+  while ((timeout != 0U) && (tmp != 0U))
509
+  {
510
+    if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
511
+    {
512
+      timeout--;
513
+    }
514
+    tmp = LL_RTC_IsActiveFlag_RS(RTCx);
515
+    if (timeout == 0U)
516
+    {
517
+      status = ERROR;
518
+    }
519
+  }
520
+
521
+  return (status);
522
+}
523
+
524
+/**
525
+  * @}
526
+  */
527
+
528
+/**
529
+  * @}
530
+  */
531
+
532
+/**
533
+  * @}
534
+  */
535
+
536
+#endif /* defined(RTC) */
537
+
538
+/**
539
+  * @}
540
+  */
541
+
542
+#endif /* USE_FULL_LL_DRIVER */
543
+
544
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 1521
- 0
LLDrivers/src/stm32f1xx_ll_sdmmc.c
File diff suppressed because it is too large
View File


+ 530
- 0
LLDrivers/src/stm32f1xx_ll_spi.c View File

@@ -0,0 +1,530 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_spi.c
4
+  * @author  MCD Application Team
5
+  * @brief   SPI LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+#if defined(USE_FULL_LL_DRIVER)
20
+
21
+/* Includes ------------------------------------------------------------------*/
22
+#include "stm32f1xx_ll_spi.h"
23
+#include "stm32f1xx_ll_bus.h"
24
+#include "stm32f1xx_ll_rcc.h"
25
+
26
+#ifdef  USE_FULL_ASSERT
27
+#include "stm32_assert.h"
28
+#else
29
+#define assert_param(expr) ((void)0U)
30
+#endif
31
+
32
+/** @addtogroup STM32F1xx_LL_Driver
33
+  * @{
34
+  */
35
+
36
+#if defined (SPI1) || defined (SPI2) || defined (SPI3)
37
+
38
+/** @addtogroup SPI_LL
39
+  * @{
40
+  */
41
+
42
+/* Private types -------------------------------------------------------------*/
43
+/* Private variables ---------------------------------------------------------*/
44
+
45
+/* Private constants ---------------------------------------------------------*/
46
+/** @defgroup SPI_LL_Private_Constants SPI Private Constants
47
+  * @{
48
+  */
49
+/* SPI registers Masks */
50
+#define SPI_CR1_CLEAR_MASK                 (SPI_CR1_CPHA    | SPI_CR1_CPOL     | SPI_CR1_MSTR   | \
51
+                                            SPI_CR1_BR      | SPI_CR1_LSBFIRST | SPI_CR1_SSI    | \
52
+                                            SPI_CR1_SSM     | SPI_CR1_RXONLY   | SPI_CR1_DFF    | \
53
+                                            SPI_CR1_CRCNEXT | SPI_CR1_CRCEN    | SPI_CR1_BIDIOE | \
54
+                                            SPI_CR1_BIDIMODE)
55
+/**
56
+  * @}
57
+  */
58
+
59
+/* Private macros ------------------------------------------------------------*/
60
+/** @defgroup SPI_LL_Private_Macros SPI Private Macros
61
+  * @{
62
+  */
63
+#define IS_LL_SPI_TRANSFER_DIRECTION(__VALUE__) (((__VALUE__) == LL_SPI_FULL_DUPLEX)       \
64
+                                                 || ((__VALUE__) == LL_SPI_SIMPLEX_RX)     \
65
+                                                 || ((__VALUE__) == LL_SPI_HALF_DUPLEX_RX) \
66
+                                                 || ((__VALUE__) == LL_SPI_HALF_DUPLEX_TX))
67
+
68
+#define IS_LL_SPI_MODE(__VALUE__) (((__VALUE__) == LL_SPI_MODE_MASTER) \
69
+                                   || ((__VALUE__) == LL_SPI_MODE_SLAVE))
70
+
71
+#define IS_LL_SPI_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_SPI_DATAWIDTH_8BIT)  \
72
+                                        || ((__VALUE__) == LL_SPI_DATAWIDTH_16BIT))
73
+
74
+#define IS_LL_SPI_POLARITY(__VALUE__) (((__VALUE__) == LL_SPI_POLARITY_LOW) \
75
+                                       || ((__VALUE__) == LL_SPI_POLARITY_HIGH))
76
+
77
+#define IS_LL_SPI_PHASE(__VALUE__) (((__VALUE__) == LL_SPI_PHASE_1EDGE) \
78
+                                    || ((__VALUE__) == LL_SPI_PHASE_2EDGE))
79
+
80
+#define IS_LL_SPI_NSS(__VALUE__) (((__VALUE__) == LL_SPI_NSS_SOFT)          \
81
+                                  || ((__VALUE__) == LL_SPI_NSS_HARD_INPUT) \
82
+                                  || ((__VALUE__) == LL_SPI_NSS_HARD_OUTPUT))
83
+
84
+#define IS_LL_SPI_BAUDRATE(__VALUE__) (((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV2)      \
85
+                                       || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV4)   \
86
+                                       || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV8)   \
87
+                                       || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV16)  \
88
+                                       || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV32)  \
89
+                                       || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV64)  \
90
+                                       || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV128) \
91
+                                       || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV256))
92
+
93
+#define IS_LL_SPI_BITORDER(__VALUE__) (((__VALUE__) == LL_SPI_LSB_FIRST) \
94
+                                       || ((__VALUE__) == LL_SPI_MSB_FIRST))
95
+
96
+#define IS_LL_SPI_CRCCALCULATION(__VALUE__) (((__VALUE__) == LL_SPI_CRCCALCULATION_ENABLE) \
97
+                                             || ((__VALUE__) == LL_SPI_CRCCALCULATION_DISABLE))
98
+
99
+#define IS_LL_SPI_CRC_POLYNOMIAL(__VALUE__) ((__VALUE__) >= 0x1U)
100
+
101
+/**
102
+  * @}
103
+  */
104
+
105
+/* Private function prototypes -----------------------------------------------*/
106
+
107
+/* Exported functions --------------------------------------------------------*/
108
+/** @addtogroup SPI_LL_Exported_Functions
109
+  * @{
110
+  */
111
+
112
+/** @addtogroup SPI_LL_EF_Init
113
+  * @{
114
+  */
115
+
116
+/**
117
+  * @brief  De-initialize the SPI registers to their default reset values.
118
+  * @param  SPIx SPI Instance
119
+  * @retval An ErrorStatus enumeration value:
120
+  *          - SUCCESS: SPI registers are de-initialized
121
+  *          - ERROR: SPI registers are not de-initialized
122
+  */
123
+ErrorStatus LL_SPI_DeInit(SPI_TypeDef *SPIx)
124
+{
125
+  ErrorStatus status = ERROR;
126
+
127
+  /* Check the parameters */
128
+  assert_param(IS_SPI_ALL_INSTANCE(SPIx));
129
+
130
+#if defined(SPI1)
131
+  if (SPIx == SPI1)
132
+  {
133
+    /* Force reset of SPI clock */
134
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_SPI1);
135
+
136
+    /* Release reset of SPI clock */
137
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_SPI1);
138
+
139
+    status = SUCCESS;
140
+  }
141
+#endif /* SPI1 */
142
+#if defined(SPI2)
143
+  if (SPIx == SPI2)
144
+  {
145
+    /* Force reset of SPI clock */
146
+    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_SPI2);
147
+
148
+    /* Release reset of SPI clock */
149
+    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_SPI2);
150
+
151
+    status = SUCCESS;
152
+  }
153
+#endif /* SPI2 */
154
+#if defined(SPI3)
155
+  if (SPIx == SPI3)
156
+  {
157
+    /* Force reset of SPI clock */
158
+    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_SPI3);
159
+
160
+    /* Release reset of SPI clock */
161
+    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_SPI3);
162
+
163
+    status = SUCCESS;
164
+  }
165
+#endif /* SPI3 */
166
+
167
+  return status;
168
+}
169
+
170
+/**
171
+  * @brief  Initialize the SPI registers according to the specified parameters in SPI_InitStruct.
172
+  * @note   As some bits in SPI configuration registers can only be written when the SPI is disabled (SPI_CR1_SPE bit =0),
173
+  *         SPI peripheral should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
174
+  * @param  SPIx SPI Instance
175
+  * @param  SPI_InitStruct pointer to a @ref LL_SPI_InitTypeDef structure
176
+  * @retval An ErrorStatus enumeration value. (Return always SUCCESS)
177
+  */
178
+ErrorStatus LL_SPI_Init(SPI_TypeDef *SPIx, LL_SPI_InitTypeDef *SPI_InitStruct)
179
+{
180
+  ErrorStatus status = ERROR;
181
+
182
+  /* Check the SPI Instance SPIx*/
183
+  assert_param(IS_SPI_ALL_INSTANCE(SPIx));
184
+
185
+  /* Check the SPI parameters from SPI_InitStruct*/
186
+  assert_param(IS_LL_SPI_TRANSFER_DIRECTION(SPI_InitStruct->TransferDirection));
187
+  assert_param(IS_LL_SPI_MODE(SPI_InitStruct->Mode));
188
+  assert_param(IS_LL_SPI_DATAWIDTH(SPI_InitStruct->DataWidth));
189
+  assert_param(IS_LL_SPI_POLARITY(SPI_InitStruct->ClockPolarity));
190
+  assert_param(IS_LL_SPI_PHASE(SPI_InitStruct->ClockPhase));
191
+  assert_param(IS_LL_SPI_NSS(SPI_InitStruct->NSS));
192
+  assert_param(IS_LL_SPI_BAUDRATE(SPI_InitStruct->BaudRate));
193
+  assert_param(IS_LL_SPI_BITORDER(SPI_InitStruct->BitOrder));
194
+  assert_param(IS_LL_SPI_CRCCALCULATION(SPI_InitStruct->CRCCalculation));
195
+
196
+  if (LL_SPI_IsEnabled(SPIx) == 0x00000000U)
197
+  {
198
+    /*---------------------------- SPIx CR1 Configuration ------------------------
199
+     * Configure SPIx CR1 with parameters:
200
+     * - TransferDirection:  SPI_CR1_BIDIMODE, SPI_CR1_BIDIOE and SPI_CR1_RXONLY bits
201
+     * - Master/Slave Mode:  SPI_CR1_MSTR bit
202
+     * - DataWidth:          SPI_CR1_DFF bit
203
+     * - ClockPolarity:      SPI_CR1_CPOL bit
204
+     * - ClockPhase:         SPI_CR1_CPHA bit
205
+     * - NSS management:     SPI_CR1_SSM bit
206
+     * - BaudRate prescaler: SPI_CR1_BR[2:0] bits
207
+     * - BitOrder:           SPI_CR1_LSBFIRST bit
208
+     * - CRCCalculation:     SPI_CR1_CRCEN bit
209
+     */
210
+    MODIFY_REG(SPIx->CR1,
211
+               SPI_CR1_CLEAR_MASK,
212
+               SPI_InitStruct->TransferDirection | SPI_InitStruct->Mode | SPI_InitStruct->DataWidth |
213
+               SPI_InitStruct->ClockPolarity | SPI_InitStruct->ClockPhase |
214
+               SPI_InitStruct->NSS | SPI_InitStruct->BaudRate |
215
+               SPI_InitStruct->BitOrder | SPI_InitStruct->CRCCalculation);
216
+
217
+    /*---------------------------- SPIx CR2 Configuration ------------------------
218
+     * Configure SPIx CR2 with parameters:
219
+     * - NSS management:     SSOE bit
220
+     */
221
+    MODIFY_REG(SPIx->CR2, SPI_CR2_SSOE, (SPI_InitStruct->NSS >> 16U));
222
+
223
+    /*---------------------------- SPIx CRCPR Configuration ----------------------
224
+     * Configure SPIx CRCPR with parameters:
225
+     * - CRCPoly:            CRCPOLY[15:0] bits
226
+     */
227
+    if (SPI_InitStruct->CRCCalculation == LL_SPI_CRCCALCULATION_ENABLE)
228
+    {
229
+      assert_param(IS_LL_SPI_CRC_POLYNOMIAL(SPI_InitStruct->CRCPoly));
230
+      LL_SPI_SetCRCPolynomial(SPIx, SPI_InitStruct->CRCPoly);
231
+    }
232
+    status = SUCCESS;
233
+  }
234
+
235
+#if defined (SPI_I2S_SUPPORT)
236
+  /* Activate the SPI mode (Reset I2SMOD bit in I2SCFGR register) */
237
+  CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SMOD);
238
+#endif /* SPI_I2S_SUPPORT */
239
+  return status;
240
+}
241
+
242
+/**
243
+  * @brief  Set each @ref LL_SPI_InitTypeDef field to default value.
244
+  * @param  SPI_InitStruct pointer to a @ref LL_SPI_InitTypeDef structure
245
+  * whose fields will be set to default values.
246
+  * @retval None
247
+  */
248
+void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct)
249
+{
250
+  /* Set SPI_InitStruct fields to default values */
251
+  SPI_InitStruct->TransferDirection = LL_SPI_FULL_DUPLEX;
252
+  SPI_InitStruct->Mode              = LL_SPI_MODE_SLAVE;
253
+  SPI_InitStruct->DataWidth         = LL_SPI_DATAWIDTH_8BIT;
254
+  SPI_InitStruct->ClockPolarity     = LL_SPI_POLARITY_LOW;
255
+  SPI_InitStruct->ClockPhase        = LL_SPI_PHASE_1EDGE;
256
+  SPI_InitStruct->NSS               = LL_SPI_NSS_HARD_INPUT;
257
+  SPI_InitStruct->BaudRate          = LL_SPI_BAUDRATEPRESCALER_DIV2;
258
+  SPI_InitStruct->BitOrder          = LL_SPI_MSB_FIRST;
259
+  SPI_InitStruct->CRCCalculation    = LL_SPI_CRCCALCULATION_DISABLE;
260
+  SPI_InitStruct->CRCPoly           = 7U;
261
+}
262
+
263
+/**
264
+  * @}
265
+  */
266
+
267
+/**
268
+  * @}
269
+  */
270
+
271
+/**
272
+  * @}
273
+  */
274
+
275
+#if defined(SPI_I2S_SUPPORT)
276
+/** @addtogroup I2S_LL
277
+  * @{
278
+  */
279
+
280
+/* Private types -------------------------------------------------------------*/
281
+/* Private variables ---------------------------------------------------------*/
282
+/* Private constants ---------------------------------------------------------*/
283
+/** @defgroup I2S_LL_Private_Constants I2S Private Constants
284
+  * @{
285
+  */
286
+/* I2S registers Masks */
287
+#define I2S_I2SCFGR_CLEAR_MASK             (SPI_I2SCFGR_CHLEN   | SPI_I2SCFGR_DATLEN | \
288
+                                            SPI_I2SCFGR_CKPOL   | SPI_I2SCFGR_I2SSTD | \
289
+                                            SPI_I2SCFGR_I2SCFG  | SPI_I2SCFGR_I2SMOD )
290
+
291
+#define I2S_I2SPR_CLEAR_MASK               0x0002U
292
+/**
293
+  * @}
294
+  */
295
+/* Private macros ------------------------------------------------------------*/
296
+/** @defgroup I2S_LL_Private_Macros I2S Private Macros
297
+  * @{
298
+  */
299
+
300
+#define IS_LL_I2S_DATAFORMAT(__VALUE__)  (((__VALUE__) == LL_I2S_DATAFORMAT_16B)             \
301
+                                          || ((__VALUE__) == LL_I2S_DATAFORMAT_16B_EXTENDED) \
302
+                                          || ((__VALUE__) == LL_I2S_DATAFORMAT_24B)          \
303
+                                          || ((__VALUE__) == LL_I2S_DATAFORMAT_32B))
304
+
305
+#define IS_LL_I2S_CPOL(__VALUE__)        (((__VALUE__) == LL_I2S_POLARITY_LOW)  \
306
+                                          || ((__VALUE__) == LL_I2S_POLARITY_HIGH))
307
+
308
+#define IS_LL_I2S_STANDARD(__VALUE__)    (((__VALUE__) == LL_I2S_STANDARD_PHILIPS)      \
309
+                                          || ((__VALUE__) == LL_I2S_STANDARD_MSB)       \
310
+                                          || ((__VALUE__) == LL_I2S_STANDARD_LSB)       \
311
+                                          || ((__VALUE__) == LL_I2S_STANDARD_PCM_SHORT) \
312
+                                          || ((__VALUE__) == LL_I2S_STANDARD_PCM_LONG))
313
+
314
+#define IS_LL_I2S_MODE(__VALUE__)        (((__VALUE__) == LL_I2S_MODE_SLAVE_TX)     \
315
+                                          || ((__VALUE__) == LL_I2S_MODE_SLAVE_RX)  \
316
+                                          || ((__VALUE__) == LL_I2S_MODE_MASTER_TX) \
317
+                                          || ((__VALUE__) == LL_I2S_MODE_MASTER_RX))
318
+
319
+#define IS_LL_I2S_MCLK_OUTPUT(__VALUE__) (((__VALUE__) == LL_I2S_MCLK_OUTPUT_ENABLE) \
320
+                                          || ((__VALUE__) == LL_I2S_MCLK_OUTPUT_DISABLE))
321
+
322
+#define IS_LL_I2S_AUDIO_FREQ(__VALUE__) ((((__VALUE__) >= LL_I2S_AUDIOFREQ_8K)       \
323
+                                          && ((__VALUE__) <= LL_I2S_AUDIOFREQ_192K)) \
324
+                                         || ((__VALUE__) == LL_I2S_AUDIOFREQ_DEFAULT))
325
+
326
+#define IS_LL_I2S_PRESCALER_LINEAR(__VALUE__)  ((__VALUE__) >= 0x2U)
327
+
328
+#define IS_LL_I2S_PRESCALER_PARITY(__VALUE__) (((__VALUE__) == LL_I2S_PRESCALER_PARITY_EVEN) \
329
+                                               || ((__VALUE__) == LL_I2S_PRESCALER_PARITY_ODD))
330
+/**
331
+  * @}
332
+  */
333
+
334
+/* Private function prototypes -----------------------------------------------*/
335
+
336
+/* Exported functions --------------------------------------------------------*/
337
+/** @addtogroup I2S_LL_Exported_Functions
338
+  * @{
339
+  */
340
+
341
+/** @addtogroup I2S_LL_EF_Init
342
+  * @{
343
+  */
344
+
345
+/**
346
+  * @brief  De-initialize the SPI/I2S registers to their default reset values.
347
+  * @param  SPIx SPI Instance
348
+  * @retval An ErrorStatus enumeration value:
349
+  *          - SUCCESS: SPI registers are de-initialized
350
+  *          - ERROR: SPI registers are not de-initialized
351
+  */
352
+ErrorStatus LL_I2S_DeInit(SPI_TypeDef *SPIx)
353
+{
354
+  return LL_SPI_DeInit(SPIx);
355
+}
356
+
357
+/**
358
+  * @brief  Initializes the SPI/I2S registers according to the specified parameters in I2S_InitStruct.
359
+  * @note   As some bits in SPI configuration registers can only be written when the SPI is disabled (SPI_CR1_SPE bit =0),
360
+  *         SPI peripheral should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
361
+  * @param  SPIx SPI Instance
362
+  * @param  I2S_InitStruct pointer to a @ref LL_I2S_InitTypeDef structure
363
+  * @retval An ErrorStatus enumeration value:
364
+  *          - SUCCESS: SPI registers are Initialized
365
+  *          - ERROR: SPI registers are not Initialized
366
+  */
367
+ErrorStatus LL_I2S_Init(SPI_TypeDef *SPIx, LL_I2S_InitTypeDef *I2S_InitStruct)
368
+{
369
+  uint32_t i2sdiv = 2U;
370
+  uint32_t i2sodd = 0U;
371
+  uint32_t packetlength = 1U;
372
+  uint32_t tmp;
373
+  LL_RCC_ClocksTypeDef rcc_clocks;
374
+  uint32_t sourceclock;
375
+  ErrorStatus status = ERROR;
376
+
377
+  /* Check the I2S parameters */
378
+  assert_param(IS_I2S_ALL_INSTANCE(SPIx));
379
+  assert_param(IS_LL_I2S_MODE(I2S_InitStruct->Mode));
380
+  assert_param(IS_LL_I2S_STANDARD(I2S_InitStruct->Standard));
381
+  assert_param(IS_LL_I2S_DATAFORMAT(I2S_InitStruct->DataFormat));
382
+  assert_param(IS_LL_I2S_MCLK_OUTPUT(I2S_InitStruct->MCLKOutput));
383
+  assert_param(IS_LL_I2S_AUDIO_FREQ(I2S_InitStruct->AudioFreq));
384
+  assert_param(IS_LL_I2S_CPOL(I2S_InitStruct->ClockPolarity));
385
+
386
+  if (LL_I2S_IsEnabled(SPIx) == 0x00000000U)
387
+  {
388
+    /*---------------------------- SPIx I2SCFGR Configuration --------------------
389
+     * Configure SPIx I2SCFGR with parameters:
390
+     * - Mode:          SPI_I2SCFGR_I2SCFG[1:0] bit
391
+     * - Standard:      SPI_I2SCFGR_I2SSTD[1:0] and SPI_I2SCFGR_PCMSYNC bits
392
+     * - DataFormat:    SPI_I2SCFGR_CHLEN and SPI_I2SCFGR_DATLEN bits
393
+     * - ClockPolarity: SPI_I2SCFGR_CKPOL bit
394
+     */
395
+
396
+    /* Write to SPIx I2SCFGR */
397
+    MODIFY_REG(SPIx->I2SCFGR,
398
+               I2S_I2SCFGR_CLEAR_MASK,
399
+               I2S_InitStruct->Mode | I2S_InitStruct->Standard |
400
+               I2S_InitStruct->DataFormat | I2S_InitStruct->ClockPolarity |
401
+               SPI_I2SCFGR_I2SMOD);
402
+
403
+    /*---------------------------- SPIx I2SPR Configuration ----------------------
404
+     * Configure SPIx I2SPR with parameters:
405
+     * - MCLKOutput:    SPI_I2SPR_MCKOE bit
406
+     * - AudioFreq:     SPI_I2SPR_I2SDIV[7:0] and SPI_I2SPR_ODD bits
407
+     */
408
+
409
+    /* If the requested audio frequency is not the default, compute the prescaler (i2sodd, i2sdiv)
410
+     * else, default values are used:  i2sodd = 0U, i2sdiv = 2U.
411
+     */
412
+    if (I2S_InitStruct->AudioFreq != LL_I2S_AUDIOFREQ_DEFAULT)
413
+    {
414
+      /* Check the frame length (For the Prescaler computing)
415
+       * Default value: LL_I2S_DATAFORMAT_16B (packetlength = 1U).
416
+       */
417
+      if (I2S_InitStruct->DataFormat != LL_I2S_DATAFORMAT_16B)
418
+      {
419
+        /* Packet length is 32 bits */
420
+        packetlength = 2U;
421
+      }
422
+
423
+      /* I2S Clock source is System clock: Get System Clock frequency */
424
+      LL_RCC_GetSystemClocksFreq(&rcc_clocks);
425
+
426
+      /* Get the source clock value: based on System Clock value */
427
+      sourceclock = rcc_clocks.SYSCLK_Frequency;
428
+
429
+      /* Compute the Real divider depending on the MCLK output state with a floating point */
430
+      if (I2S_InitStruct->MCLKOutput == LL_I2S_MCLK_OUTPUT_ENABLE)
431
+      {
432
+        /* MCLK output is enabled */
433
+        tmp = (((((sourceclock / 256U) * 10U) / I2S_InitStruct->AudioFreq)) + 5U);
434
+      }
435
+      else
436
+      {
437
+        /* MCLK output is disabled */
438
+        tmp = (((((sourceclock / (32U * packetlength)) * 10U) / I2S_InitStruct->AudioFreq)) + 5U);
439
+      }
440
+
441
+      /* Remove the floating point */
442
+      tmp = tmp / 10U;
443
+
444
+      /* Check the parity of the divider */
445
+      i2sodd = (tmp & (uint16_t)0x0001U);
446
+
447
+      /* Compute the i2sdiv prescaler */
448
+      i2sdiv = ((tmp - i2sodd) / 2U);
449
+
450
+      /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */
451
+      i2sodd = (i2sodd << 8U);
452
+    }
453
+
454
+    /* Test if the divider is 1 or 0 or greater than 0xFF */
455
+    if ((i2sdiv < 2U) || (i2sdiv > 0xFFU))
456
+    {
457
+      /* Set the default values */
458
+      i2sdiv = 2U;
459
+      i2sodd = 0U;
460
+    }
461
+
462
+    /* Write to SPIx I2SPR register the computed value */
463
+    WRITE_REG(SPIx->I2SPR, i2sdiv | i2sodd | I2S_InitStruct->MCLKOutput);
464
+
465
+    status = SUCCESS;
466
+  }
467
+  return status;
468
+}
469
+
470
+/**
471
+  * @brief  Set each @ref LL_I2S_InitTypeDef field to default value.
472
+  * @param  I2S_InitStruct pointer to a @ref LL_I2S_InitTypeDef structure
473
+  *         whose fields will be set to default values.
474
+  * @retval None
475
+  */
476
+void LL_I2S_StructInit(LL_I2S_InitTypeDef *I2S_InitStruct)
477
+{
478
+  /*--------------- Reset I2S init structure parameters values -----------------*/
479
+  I2S_InitStruct->Mode              = LL_I2S_MODE_SLAVE_TX;
480
+  I2S_InitStruct->Standard          = LL_I2S_STANDARD_PHILIPS;
481
+  I2S_InitStruct->DataFormat        = LL_I2S_DATAFORMAT_16B;
482
+  I2S_InitStruct->MCLKOutput        = LL_I2S_MCLK_OUTPUT_DISABLE;
483
+  I2S_InitStruct->AudioFreq         = LL_I2S_AUDIOFREQ_DEFAULT;
484
+  I2S_InitStruct->ClockPolarity     = LL_I2S_POLARITY_LOW;
485
+}
486
+
487
+/**
488
+  * @brief  Set linear and parity prescaler.
489
+  * @note   To calculate value of PrescalerLinear(I2SDIV[7:0] bits) and PrescalerParity(ODD bit)\n
490
+  *         Check Audio frequency table and formulas inside Reference Manual (SPI/I2S).
491
+  * @param  SPIx SPI Instance
492
+  * @param  PrescalerLinear value Min_Data=0x02 and Max_Data=0xFF.
493
+  * @param  PrescalerParity This parameter can be one of the following values:
494
+  *         @arg @ref LL_I2S_PRESCALER_PARITY_EVEN
495
+  *         @arg @ref LL_I2S_PRESCALER_PARITY_ODD
496
+  * @retval None
497
+  */
498
+void LL_I2S_ConfigPrescaler(SPI_TypeDef *SPIx, uint32_t PrescalerLinear, uint32_t PrescalerParity)
499
+{
500
+  /* Check the I2S parameters */
501
+  assert_param(IS_I2S_ALL_INSTANCE(SPIx));
502
+  assert_param(IS_LL_I2S_PRESCALER_LINEAR(PrescalerLinear));
503
+  assert_param(IS_LL_I2S_PRESCALER_PARITY(PrescalerParity));
504
+
505
+  /* Write to SPIx I2SPR */
506
+  MODIFY_REG(SPIx->I2SPR, SPI_I2SPR_I2SDIV | SPI_I2SPR_ODD, PrescalerLinear | (PrescalerParity << 8U));
507
+}
508
+
509
+/**
510
+  * @}
511
+  */
512
+
513
+/**
514
+  * @}
515
+  */
516
+
517
+/**
518
+  * @}
519
+  */
520
+#endif /* SPI_I2S_SUPPORT */
521
+
522
+#endif /* defined (SPI1) || defined (SPI2) || defined (SPI3) */
523
+
524
+/**
525
+  * @}
526
+  */
527
+
528
+#endif /* USE_FULL_LL_DRIVER */
529
+
530
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 1198
- 0
LLDrivers/src/stm32f1xx_ll_tim.c
File diff suppressed because it is too large
View File


+ 446
- 0
LLDrivers/src/stm32f1xx_ll_usart.c View File

@@ -0,0 +1,446 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_ll_usart.c
4
+  * @author  MCD Application Team
5
+  * @brief   USART LL module driver.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+#if defined(USE_FULL_LL_DRIVER)
21
+
22
+/* Includes ------------------------------------------------------------------*/
23
+#include "stm32f1xx_ll_usart.h"
24
+#include "stm32f1xx_ll_rcc.h"
25
+#include "stm32f1xx_ll_bus.h"
26
+#ifdef  USE_FULL_ASSERT
27
+#include "stm32_assert.h"
28
+#else
29
+#define assert_param(expr) ((void)0U)
30
+#endif
31
+
32
+/** @addtogroup STM32F1xx_LL_Driver
33
+  * @{
34
+  */
35
+
36
+#if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5)
37
+
38
+/** @addtogroup USART_LL
39
+  * @{
40
+  */
41
+
42
+/* Private types -------------------------------------------------------------*/
43
+/* Private variables ---------------------------------------------------------*/
44
+/* Private constants ---------------------------------------------------------*/
45
+/** @addtogroup USART_LL_Private_Constants
46
+  * @{
47
+  */
48
+
49
+/**
50
+  * @}
51
+  */
52
+
53
+
54
+/* Private macros ------------------------------------------------------------*/
55
+/** @addtogroup USART_LL_Private_Macros
56
+  * @{
57
+  */
58
+
59
+/* __BAUDRATE__ The maximum Baud Rate is derived from the maximum clock available
60
+ *              divided by the smallest oversampling used on the USART (i.e. 8)    */
61
+#define IS_LL_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 4500000U)
62
+
63
+/* __VALUE__ In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. */
64
+#define IS_LL_USART_BRR_MIN(__VALUE__) ((__VALUE__) >= 16U)
65
+
66
+/* __VALUE__ BRR content must be lower than or equal to 0xFFFF. */
67
+#define IS_LL_USART_BRR_MAX(__VALUE__) ((__VALUE__) <= 0x0000FFFFU)
68
+
69
+#define IS_LL_USART_DIRECTION(__VALUE__) (((__VALUE__) == LL_USART_DIRECTION_NONE) \
70
+                                       || ((__VALUE__) == LL_USART_DIRECTION_RX) \
71
+                                       || ((__VALUE__) == LL_USART_DIRECTION_TX) \
72
+                                       || ((__VALUE__) == LL_USART_DIRECTION_TX_RX))
73
+
74
+#define IS_LL_USART_PARITY(__VALUE__) (((__VALUE__) == LL_USART_PARITY_NONE) \
75
+                                    || ((__VALUE__) == LL_USART_PARITY_EVEN) \
76
+                                    || ((__VALUE__) == LL_USART_PARITY_ODD))
77
+
78
+#define IS_LL_USART_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_USART_DATAWIDTH_8B) \
79
+                                       || ((__VALUE__) == LL_USART_DATAWIDTH_9B))
80
+
81
+#define IS_LL_USART_OVERSAMPLING(__VALUE__) (((__VALUE__) == LL_USART_OVERSAMPLING_16) \
82
+                                          || ((__VALUE__) == LL_USART_OVERSAMPLING_8))
83
+
84
+#define IS_LL_USART_LASTBITCLKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_LASTCLKPULSE_NO_OUTPUT) \
85
+                                              || ((__VALUE__) == LL_USART_LASTCLKPULSE_OUTPUT))
86
+
87
+#define IS_LL_USART_CLOCKPHASE(__VALUE__) (((__VALUE__) == LL_USART_PHASE_1EDGE) \
88
+                                        || ((__VALUE__) == LL_USART_PHASE_2EDGE))
89
+
90
+#define IS_LL_USART_CLOCKPOLARITY(__VALUE__) (((__VALUE__) == LL_USART_POLARITY_LOW) \
91
+                                           || ((__VALUE__) == LL_USART_POLARITY_HIGH))
92
+
93
+#define IS_LL_USART_CLOCKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_CLOCK_DISABLE) \
94
+                                         || ((__VALUE__) == LL_USART_CLOCK_ENABLE))
95
+
96
+#define IS_LL_USART_STOPBITS(__VALUE__) (((__VALUE__) == LL_USART_STOPBITS_0_5) \
97
+                                      || ((__VALUE__) == LL_USART_STOPBITS_1) \
98
+                                      || ((__VALUE__) == LL_USART_STOPBITS_1_5) \
99
+                                      || ((__VALUE__) == LL_USART_STOPBITS_2))
100
+
101
+#define IS_LL_USART_HWCONTROL(__VALUE__) (((__VALUE__) == LL_USART_HWCONTROL_NONE) \
102
+                                       || ((__VALUE__) == LL_USART_HWCONTROL_RTS) \
103
+                                       || ((__VALUE__) == LL_USART_HWCONTROL_CTS) \
104
+                                       || ((__VALUE__) == LL_USART_HWCONTROL_RTS_CTS))
105
+
106
+/**
107
+  * @}
108
+  */
109
+
110
+/* Private function prototypes -----------------------------------------------*/
111
+
112
+/* Exported functions --------------------------------------------------------*/
113
+/** @addtogroup USART_LL_Exported_Functions
114
+  * @{
115
+  */
116
+
117
+/** @addtogroup USART_LL_EF_Init
118
+  * @{
119
+  */
120
+
121
+/**
122
+  * @brief  De-initialize USART registers (Registers restored to their default values).
123
+  * @param  USARTx USART Instance
124
+  * @retval An ErrorStatus enumeration value:
125
+  *          - SUCCESS: USART registers are de-initialized
126
+  *          - ERROR: USART registers are not de-initialized
127
+  */
128
+ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx)
129
+{
130
+  ErrorStatus status = SUCCESS;
131
+
132
+  /* Check the parameters */
133
+  assert_param(IS_UART_INSTANCE(USARTx));
134
+
135
+  if (USARTx == USART1)
136
+  {
137
+    /* Force reset of USART clock */
138
+    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_USART1);
139
+
140
+    /* Release reset of USART clock */
141
+    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_USART1);
142
+  }
143
+  else if (USARTx == USART2)
144
+  {
145
+    /* Force reset of USART clock */
146
+    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART2);
147
+
148
+    /* Release reset of USART clock */
149
+    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART2);
150
+  }
151
+#if defined(USART3)
152
+  else if (USARTx == USART3)
153
+  {
154
+    /* Force reset of USART clock */
155
+    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART3);
156
+
157
+    /* Release reset of USART clock */
158
+    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART3);
159
+  }
160
+#endif /* USART3 */
161
+#if defined(UART4)
162
+  else if (USARTx == UART4)
163
+  {
164
+    /* Force reset of UART clock */
165
+    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART4);
166
+
167
+    /* Release reset of UART clock */
168
+    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART4);
169
+  }
170
+#endif /* UART4 */
171
+#if defined(UART5)
172
+  else if (USARTx == UART5)
173
+  {
174
+    /* Force reset of UART clock */
175
+    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART5);
176
+
177
+    /* Release reset of UART clock */
178
+    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART5);
179
+  }
180
+#endif /* UART5 */
181
+  else
182
+  {
183
+    status = ERROR;
184
+  }
185
+
186
+  return (status);
187
+}
188
+
189
+/**
190
+  * @brief  Initialize USART registers according to the specified
191
+  *         parameters in USART_InitStruct.
192
+  * @note   As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0),
193
+  *         USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
194
+  * @note   Baud rate value stored in USART_InitStruct BaudRate field, should be valid (different from 0).
195
+  * @param  USARTx USART Instance
196
+  * @param  USART_InitStruct pointer to a LL_USART_InitTypeDef structure
197
+  *         that contains the configuration information for the specified USART peripheral.
198
+  * @retval An ErrorStatus enumeration value:
199
+  *          - SUCCESS: USART registers are initialized according to USART_InitStruct content
200
+  *          - ERROR: Problem occurred during USART Registers initialization
201
+  */
202
+ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct)
203
+{
204
+  ErrorStatus status = ERROR;
205
+  uint32_t periphclk = LL_RCC_PERIPH_FREQUENCY_NO;
206
+  LL_RCC_ClocksTypeDef rcc_clocks;
207
+
208
+  /* Check the parameters */
209
+  assert_param(IS_UART_INSTANCE(USARTx));
210
+  assert_param(IS_LL_USART_BAUDRATE(USART_InitStruct->BaudRate));
211
+  assert_param(IS_LL_USART_DATAWIDTH(USART_InitStruct->DataWidth));
212
+  assert_param(IS_LL_USART_STOPBITS(USART_InitStruct->StopBits));
213
+  assert_param(IS_LL_USART_PARITY(USART_InitStruct->Parity));
214
+  assert_param(IS_LL_USART_DIRECTION(USART_InitStruct->TransferDirection));
215
+  assert_param(IS_LL_USART_HWCONTROL(USART_InitStruct->HardwareFlowControl));
216
+#if defined(USART_CR1_OVER8)
217
+  assert_param(IS_LL_USART_OVERSAMPLING(USART_InitStruct->OverSampling));
218
+#endif /* USART_OverSampling_Feature */
219
+
220
+  /* USART needs to be in disabled state, in order to be able to configure some bits in
221
+     CRx registers */
222
+  if (LL_USART_IsEnabled(USARTx) == 0U)
223
+  {
224
+    /*---------------------------- USART CR1 Configuration -----------------------
225
+     * Configure USARTx CR1 (USART Word Length, Parity, Mode and Oversampling bits) with parameters:
226
+     * - DataWidth:          USART_CR1_M bits according to USART_InitStruct->DataWidth value
227
+     * - Parity:             USART_CR1_PCE, USART_CR1_PS bits according to USART_InitStruct->Parity value
228
+     * - TransferDirection:  USART_CR1_TE, USART_CR1_RE bits according to USART_InitStruct->TransferDirection value
229
+     * - Oversampling:       USART_CR1_OVER8 bit according to USART_InitStruct->OverSampling value.
230
+     */
231
+#if defined(USART_CR1_OVER8)
232
+    MODIFY_REG(USARTx->CR1,
233
+               (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS |
234
+                USART_CR1_TE | USART_CR1_RE | USART_CR1_OVER8),
235
+               (USART_InitStruct->DataWidth | USART_InitStruct->Parity |
236
+                USART_InitStruct->TransferDirection | USART_InitStruct->OverSampling));
237
+#else
238
+    MODIFY_REG(USARTx->CR1,
239
+               (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS |
240
+                USART_CR1_TE | USART_CR1_RE),
241
+               (USART_InitStruct->DataWidth | USART_InitStruct->Parity |
242
+                USART_InitStruct->TransferDirection));
243
+#endif /* USART_OverSampling_Feature */
244
+
245
+    /*---------------------------- USART CR2 Configuration -----------------------
246
+     * Configure USARTx CR2 (Stop bits) with parameters:
247
+     * - Stop Bits:          USART_CR2_STOP bits according to USART_InitStruct->StopBits value.
248
+     * - CLKEN, CPOL, CPHA and LBCL bits are to be configured using LL_USART_ClockInit().
249
+     */
250
+    LL_USART_SetStopBitsLength(USARTx, USART_InitStruct->StopBits);
251
+
252
+    /*---------------------------- USART CR3 Configuration -----------------------
253
+     * Configure USARTx CR3 (Hardware Flow Control) with parameters:
254
+     * - HardwareFlowControl: USART_CR3_RTSE, USART_CR3_CTSE bits according to USART_InitStruct->HardwareFlowControl value.
255
+     */
256
+    LL_USART_SetHWFlowCtrl(USARTx, USART_InitStruct->HardwareFlowControl);
257
+
258
+    /*---------------------------- USART BRR Configuration -----------------------
259
+     * Retrieve Clock frequency used for USART Peripheral
260
+     */
261
+    LL_RCC_GetSystemClocksFreq(&rcc_clocks);
262
+    if (USARTx == USART1)
263
+    {
264
+      periphclk = rcc_clocks.PCLK2_Frequency;
265
+    }
266
+    else if (USARTx == USART2)
267
+    {
268
+      periphclk = rcc_clocks.PCLK1_Frequency;
269
+    }
270
+#if defined(USART3)
271
+    else if (USARTx == USART3)
272
+    {
273
+      periphclk = rcc_clocks.PCLK1_Frequency;
274
+    }
275
+#endif /* USART3 */
276
+#if defined(UART4)
277
+    else if (USARTx == UART4)
278
+    {
279
+      periphclk = rcc_clocks.PCLK1_Frequency;
280
+    }
281
+#endif /* UART4 */
282
+#if defined(UART5)
283
+    else if (USARTx == UART5)
284
+    {
285
+      periphclk = rcc_clocks.PCLK1_Frequency;
286
+    }
287
+#endif /* UART5 */
288
+    else
289
+    {
290
+      /* Nothing to do, as error code is already assigned to ERROR value */
291
+    }
292
+
293
+    /* Configure the USART Baud Rate :
294
+       - valid baud rate value (different from 0) is required
295
+       - Peripheral clock as returned by RCC service, should be valid (different from 0).
296
+    */
297
+    if ((periphclk != LL_RCC_PERIPH_FREQUENCY_NO)
298
+        && (USART_InitStruct->BaudRate != 0U))
299
+    {
300
+      status = SUCCESS;
301
+#if defined(USART_CR1_OVER8)
302
+      LL_USART_SetBaudRate(USARTx,
303
+                           periphclk,
304
+                           USART_InitStruct->OverSampling,
305
+                           USART_InitStruct->BaudRate);
306
+#else
307
+      LL_USART_SetBaudRate(USARTx,
308
+                           periphclk,
309
+                           USART_InitStruct->BaudRate);
310
+#endif /* USART_OverSampling_Feature */
311
+
312
+      /* Check BRR is greater than or equal to 16d */
313
+      assert_param(IS_LL_USART_BRR_MIN(USARTx->BRR));
314
+
315
+      /* Check BRR is greater than or equal to 16d */
316
+      assert_param(IS_LL_USART_BRR_MAX(USARTx->BRR));
317
+    }
318
+  }
319
+  /* Endif (=> USART not in Disabled state => return ERROR) */
320
+
321
+  return (status);
322
+}
323
+
324
+/**
325
+  * @brief Set each @ref LL_USART_InitTypeDef field to default value.
326
+  * @param USART_InitStruct Pointer to a @ref LL_USART_InitTypeDef structure
327
+  *                         whose fields will be set to default values.
328
+  * @retval None
329
+  */
330
+
331
+void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct)
332
+{
333
+  /* Set USART_InitStruct fields to default values */
334
+  USART_InitStruct->BaudRate            = 9600U;
335
+  USART_InitStruct->DataWidth           = LL_USART_DATAWIDTH_8B;
336
+  USART_InitStruct->StopBits            = LL_USART_STOPBITS_1;
337
+  USART_InitStruct->Parity              = LL_USART_PARITY_NONE ;
338
+  USART_InitStruct->TransferDirection   = LL_USART_DIRECTION_TX_RX;
339
+  USART_InitStruct->HardwareFlowControl = LL_USART_HWCONTROL_NONE;
340
+#if defined(USART_CR1_OVER8)
341
+  USART_InitStruct->OverSampling        = LL_USART_OVERSAMPLING_16;
342
+#endif /* USART_OverSampling_Feature */
343
+}
344
+
345
+/**
346
+  * @brief  Initialize USART Clock related settings according to the
347
+  *         specified parameters in the USART_ClockInitStruct.
348
+  * @note   As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0),
349
+  *         USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
350
+  * @param  USARTx USART Instance
351
+  * @param  USART_ClockInitStruct Pointer to a @ref LL_USART_ClockInitTypeDef structure
352
+  *         that contains the Clock configuration information for the specified USART peripheral.
353
+  * @retval An ErrorStatus enumeration value:
354
+  *          - SUCCESS: USART registers related to Clock settings are initialized according to USART_ClockInitStruct content
355
+  *          - ERROR: Problem occurred during USART Registers initialization
356
+  */
357
+ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct)
358
+{
359
+  ErrorStatus status = SUCCESS;
360
+
361
+  /* Check USART Instance and Clock signal output parameters */
362
+  assert_param(IS_UART_INSTANCE(USARTx));
363
+  assert_param(IS_LL_USART_CLOCKOUTPUT(USART_ClockInitStruct->ClockOutput));
364
+
365
+  /* USART needs to be in disabled state, in order to be able to configure some bits in
366
+     CRx registers */
367
+  if (LL_USART_IsEnabled(USARTx) == 0U)
368
+  {
369
+    /*---------------------------- USART CR2 Configuration -----------------------*/
370
+    /* If Clock signal has to be output */
371
+    if (USART_ClockInitStruct->ClockOutput == LL_USART_CLOCK_DISABLE)
372
+    {
373
+      /* Deactivate Clock signal delivery :
374
+       * - Disable Clock Output:        USART_CR2_CLKEN cleared
375
+       */
376
+      LL_USART_DisableSCLKOutput(USARTx);
377
+    }
378
+    else
379
+    {
380
+      /* Ensure USART instance is USART capable */
381
+      assert_param(IS_USART_INSTANCE(USARTx));
382
+
383
+      /* Check clock related parameters */
384
+      assert_param(IS_LL_USART_CLOCKPOLARITY(USART_ClockInitStruct->ClockPolarity));
385
+      assert_param(IS_LL_USART_CLOCKPHASE(USART_ClockInitStruct->ClockPhase));
386
+      assert_param(IS_LL_USART_LASTBITCLKOUTPUT(USART_ClockInitStruct->LastBitClockPulse));
387
+
388
+      /*---------------------------- USART CR2 Configuration -----------------------
389
+       * Configure USARTx CR2 (Clock signal related bits) with parameters:
390
+       * - Enable Clock Output:         USART_CR2_CLKEN set
391
+       * - Clock Polarity:              USART_CR2_CPOL bit according to USART_ClockInitStruct->ClockPolarity value
392
+       * - Clock Phase:                 USART_CR2_CPHA bit according to USART_ClockInitStruct->ClockPhase value
393
+       * - Last Bit Clock Pulse Output: USART_CR2_LBCL bit according to USART_ClockInitStruct->LastBitClockPulse value.
394
+       */
395
+      MODIFY_REG(USARTx->CR2,
396
+                 USART_CR2_CLKEN | USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL,
397
+                 USART_CR2_CLKEN | USART_ClockInitStruct->ClockPolarity |
398
+                 USART_ClockInitStruct->ClockPhase | USART_ClockInitStruct->LastBitClockPulse);
399
+    }
400
+  }
401
+  /* Else (USART not in Disabled state => return ERROR */
402
+  else
403
+  {
404
+    status = ERROR;
405
+  }
406
+
407
+  return (status);
408
+}
409
+
410
+/**
411
+  * @brief Set each field of a @ref LL_USART_ClockInitTypeDef type structure to default value.
412
+  * @param USART_ClockInitStruct Pointer to a @ref LL_USART_ClockInitTypeDef structure
413
+  *                              whose fields will be set to default values.
414
+  * @retval None
415
+  */
416
+void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct)
417
+{
418
+  /* Set LL_USART_ClockInitStruct fields with default values */
419
+  USART_ClockInitStruct->ClockOutput       = LL_USART_CLOCK_DISABLE;
420
+  USART_ClockInitStruct->ClockPolarity     = LL_USART_POLARITY_LOW;            /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
421
+  USART_ClockInitStruct->ClockPhase        = LL_USART_PHASE_1EDGE;             /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
422
+  USART_ClockInitStruct->LastBitClockPulse = LL_USART_LASTCLKPULSE_NO_OUTPUT;  /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
423
+}
424
+
425
+/**
426
+  * @}
427
+  */
428
+
429
+/**
430
+  * @}
431
+  */
432
+
433
+/**
434
+  * @}
435
+  */
436
+
437
+#endif /* USART1 || USART2 || USART3 || UART4 || UART5 */
438
+
439
+/**
440
+  * @}
441
+  */
442
+
443
+#endif /* USE_FULL_LL_DRIVER */
444
+
445
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
446
+

+ 2591
- 0
LLDrivers/src/stm32f1xx_ll_usb.c
File diff suppressed because it is too large
View File


+ 65
- 114
MDK-ARM/Project.uvoptx View File

@@ -101,9 +101,7 @@
101 101
         <sRunDeb>0</sRunDeb>
102 102
         <sLrtime>0</sLrtime>
103 103
         <bEvRecOn>1</bEvRecOn>
104
-        <bSchkAxf>0</bSchkAxf>
105
-        <bTchkAxf>0</bTchkAxf>
106
-        <nTsel>6</nTsel>
104
+        <nTsel>5</nTsel>
107 105
         <sDll></sDll>
108 106
         <sDllPa></sDllPa>
109 107
         <sDlgDll></sDlgDll>
@@ -130,7 +128,7 @@
130 128
         <SetRegEntry>
131 129
           <Number>0</Number>
132 130
           <Key>DLGTARM</Key>
133
-          <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=100,127,658,622,0)(121=-1,-1,-1,-1,0)(122=834,179,1255,584,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
131
+          <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=100,127,658,622,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
134 132
         </SetRegEntry>
135 133
         <SetRegEntry>
136 134
           <Number>0</Number>
@@ -150,10 +148,50 @@
150 148
         <SetRegEntry>
151 149
           <Number>0</Number>
152 150
           <Key>ST-LINKIII-KEIL_SWO</Key>
153
-          <Name>-U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
151
+          <Name>-U-O142 -O2254 -S0 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
154 152
         </SetRegEntry>
155 153
       </TargetDriverDllRegistry>
156
-      <Breakpoint/>
154
+      <Breakpoint>
155
+        <Bp>
156
+          <Number>0</Number>
157
+          <Type>0</Type>
158
+          <LineNumber>47</LineNumber>
159
+          <EnabledFlag>1</EnabledFlag>
160
+          <Address>134219058</Address>
161
+          <ByteObject>0</ByteObject>
162
+          <HtxType>0</HtxType>
163
+          <ManyObjects>0</ManyObjects>
164
+          <SizeOfObject>0</SizeOfObject>
165
+          <BreakByAccess>0</BreakByAccess>
166
+          <BreakIfRCount>1</BreakIfRCount>
167
+          <Filename>../Src/main.c</Filename>
168
+          <ExecCommand></ExecCommand>
169
+          <Expression>\\NUCLEO_F103RB\../Src/main.c\47</Expression>
170
+        </Bp>
171
+        <Bp>
172
+          <Number>1</Number>
173
+          <Type>0</Type>
174
+          <LineNumber>44</LineNumber>
175
+          <EnabledFlag>1</EnabledFlag>
176
+          <Address>134219052</Address>
177
+          <ByteObject>0</ByteObject>
178
+          <HtxType>0</HtxType>
179
+          <ManyObjects>0</ManyObjects>
180
+          <SizeOfObject>0</SizeOfObject>
181
+          <BreakByAccess>0</BreakByAccess>
182
+          <BreakIfRCount>1</BreakIfRCount>
183
+          <Filename>../Src/main.c</Filename>
184
+          <ExecCommand></ExecCommand>
185
+          <Expression>\\NUCLEO_F103RB\../Src/main.c\44</Expression>
186
+        </Bp>
187
+      </Breakpoint>
188
+      <WatchWindow1>
189
+        <Ww>
190
+          <count>0</count>
191
+          <WinNumber>1</WinNumber>
192
+          <ItemText>Main_Time</ItemText>
193
+        </Ww>
194
+      </WatchWindow1>
157 195
       <Tracepoint>
158 196
         <THDelay>0</THDelay>
159 197
       </Tracepoint>
@@ -192,13 +230,8 @@
192 230
       <pszMrule></pszMrule>
193 231
       <pSingCmds></pSingCmds>
194 232
       <pMultCmds></pMultCmds>
195
-      <pMisraNamep></pMisraNamep>
196
-      <pszMrulep></pszMrulep>
197
-      <pSingCmdsp></pSingCmdsp>
198
-      <pMultCmdsp></pMultCmdsp>
199 233
       <DebugDescription>
200 234
         <Enable>1</Enable>
201
-        <EnableFlashSeq>0</EnableFlashSeq>
202 235
         <EnableLog>0</EnableLog>
203 236
         <Protocol>2</Protocol>
204 237
         <DbgClock>10000000</DbgClock>
@@ -286,8 +319,6 @@
286 319
         <sRunDeb>0</sRunDeb>
287 320
         <sLrtime>0</sLrtime>
288 321
         <bEvRecOn>1</bEvRecOn>
289
-        <bSchkAxf>0</bSchkAxf>
290
-        <bTchkAxf>0</bTchkAxf>
291 322
         <nTsel>5</nTsel>
292 323
         <sDll></sDll>
293 324
         <sDllPa></sDllPa>
@@ -305,7 +336,7 @@
305 336
         <SetRegEntry>
306 337
           <Number>0</Number>
307 338
           <Key>DLGDARM</Key>
308
-          <Name>(1010=75,104,451,661,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=738,132,1159,559,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=859,49,1453,800,0)(131=828,47,1422,798,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
339
+          <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
309 340
         </SetRegEntry>
310 341
         <SetRegEntry>
311 342
           <Number>0</Number>
@@ -342,57 +373,9 @@
342 373
         <Bp>
343 374
           <Number>0</Number>
344 375
           <Type>0</Type>
345
-          <LineNumber>32</LineNumber>
346
-          <EnabledFlag>1</EnabledFlag>
347
-          <Address>134218060</Address>
348
-          <ByteObject>0</ByteObject>
349
-          <HtxType>0</HtxType>
350
-          <ManyObjects>0</ManyObjects>
351
-          <SizeOfObject>0</SizeOfObject>
352
-          <BreakByAccess>0</BreakByAccess>
353
-          <BreakIfRCount>1</BreakIfRCount>
354
-          <Filename>..\Services\Chrono.c</Filename>
355
-          <ExecCommand></ExecCommand>
356
-          <Expression>\\NUCLEO_F103RB\../Services/Chrono.c\32</Expression>
357
-        </Bp>
358
-        <Bp>
359
-          <Number>1</Number>
360
-          <Type>0</Type>
361
-          <LineNumber>117</LineNumber>
362
-          <EnabledFlag>1</EnabledFlag>
363
-          <Address>134218120</Address>
364
-          <ByteObject>0</ByteObject>
365
-          <HtxType>0</HtxType>
366
-          <ManyObjects>0</ManyObjects>
367
-          <SizeOfObject>0</SizeOfObject>
368
-          <BreakByAccess>0</BreakByAccess>
369
-          <BreakIfRCount>1</BreakIfRCount>
370
-          <Filename>..\Services\Chrono.c</Filename>
371
-          <ExecCommand></ExecCommand>
372
-          <Expression>\\NUCLEO_F103RB\../Services/Chrono.c\117</Expression>
373
-        </Bp>
374
-        <Bp>
375
-          <Number>2</Number>
376
-          <Type>0</Type>
377
-          <LineNumber>20</LineNumber>
378
-          <EnabledFlag>1</EnabledFlag>
379
-          <Address>134218204</Address>
380
-          <ByteObject>0</ByteObject>
381
-          <HtxType>0</HtxType>
382
-          <ManyObjects>0</ManyObjects>
383
-          <SizeOfObject>0</SizeOfObject>
384
-          <BreakByAccess>0</BreakByAccess>
385
-          <BreakIfRCount>1</BreakIfRCount>
386
-          <Filename>..\MyDrivers\MyTimer.c</Filename>
387
-          <ExecCommand></ExecCommand>
388
-          <Expression>\\NUCLEO_F103RB\../MyDrivers/MyTimer.c\20</Expression>
389
-        </Bp>
390
-        <Bp>
391
-          <Number>3</Number>
392
-          <Type>0</Type>
393
-          <LineNumber>67</LineNumber>
376
+          <LineNumber>46</LineNumber>
394 377
           <EnabledFlag>1</EnabledFlag>
395
-          <Address>134219134</Address>
378
+          <Address>134219406</Address>
396 379
           <ByteObject>0</ByteObject>
397 380
           <HtxType>0</HtxType>
398 381
           <ManyObjects>0</ManyObjects>
@@ -401,41 +384,9 @@
401 384
           <BreakIfRCount>1</BreakIfRCount>
402 385
           <Filename>../Src/main.c</Filename>
403 386
           <ExecCommand></ExecCommand>
404
-          <Expression>\\NUCLEO_F103RB\../Src/main.c\67</Expression>
387
+          <Expression>\\NUCLEO_F103RB\../Src/main.c\46</Expression>
405 388
         </Bp>
406 389
       </Breakpoint>
407
-      <WatchWindow1>
408
-        <Ww>
409
-          <count>0</count>
410
-          <WinNumber>1</WinNumber>
411
-          <ItemText>TIM1</ItemText>
412
-        </Ww>
413
-        <Ww>
414
-          <count>1</count>
415
-          <WinNumber>1</WinNumber>
416
-          <ItemText>GPIOB</ItemText>
417
-        </Ww>
418
-        <Ww>
419
-          <count>2</count>
420
-          <WinNumber>1</WinNumber>
421
-          <ItemText>SPI1</ItemText>
422
-        </Ww>
423
-        <Ww>
424
-          <count>3</count>
425
-          <WinNumber>1</WinNumber>
426
-          <ItemText>USART1</ItemText>
427
-        </Ww>
428
-        <Ww>
429
-          <count>4</count>
430
-          <WinNumber>1</WinNumber>
431
-          <ItemText>TIM2</ItemText>
432
-        </Ww>
433
-        <Ww>
434
-          <count>5</count>
435
-          <WinNumber>1</WinNumber>
436
-          <ItemText>Chrono_Time</ItemText>
437
-        </Ww>
438
-      </WatchWindow1>
439 390
       <Tracepoint>
440 391
         <THDelay>0</THDelay>
441 392
       </Tracepoint>
@@ -474,20 +425,8 @@
474 425
       <pszMrule></pszMrule>
475 426
       <pSingCmds></pSingCmds>
476 427
       <pMultCmds></pMultCmds>
477
-      <pMisraNamep></pMisraNamep>
478
-      <pszMrulep></pszMrulep>
479
-      <pSingCmdsp></pSingCmdsp>
480
-      <pMultCmdsp></pMultCmdsp>
481
-      <LogicAnalyzers>
482
-        <Wi>
483
-          <IntNumber>0</IntNumber>
484
-          <FirstString>`TIM2_CNT</FirstString>
485
-          <SecondString>FF00000000000000000000000000E0FFFFFFEF410000000000000000000000000000000054494D325F434E540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1800000000000000000000000000000000000000CE020008</SecondString>
486
-        </Wi>
487
-      </LogicAnalyzers>
488 428
       <DebugDescription>
489 429
         <Enable>1</Enable>
490
-        <EnableFlashSeq>0</EnableFlashSeq>
491 430
         <EnableLog>0</EnableLog>
492 431
         <Protocol>2</Protocol>
493 432
         <DbgClock>10000000</DbgClock>
@@ -525,7 +464,7 @@
525 464
       <GroupNumber>2</GroupNumber>
526 465
       <FileNumber>2</FileNumber>
527 466
       <FileType>1</FileType>
528
-      <tvExp>1</tvExp>
467
+      <tvExp>0</tvExp>
529 468
       <tvExpOptDlg>0</tvExpOptDlg>
530 469
       <bDave2>0</bDave2>
531 470
       <PathWithFileName>..\Services\Chrono.c</PathWithFileName>
@@ -545,7 +484,7 @@
545 484
       <GroupNumber>3</GroupNumber>
546 485
       <FileNumber>3</FileNumber>
547 486
       <FileType>1</FileType>
548
-      <tvExp>1</tvExp>
487
+      <tvExp>0</tvExp>
549 488
       <tvExpOptDlg>0</tvExpOptDlg>
550 489
       <bDave2>0</bDave2>
551 490
       <PathWithFileName>..\MyDrivers\MyTimer.c</PathWithFileName>
@@ -585,6 +524,18 @@
585 524
       <RteFlg>0</RteFlg>
586 525
       <bShared>0</bShared>
587 526
     </File>
527
+    <File>
528
+      <GroupNumber>4</GroupNumber>
529
+      <FileNumber>6</FileNumber>
530
+      <FileType>1</FileType>
531
+      <tvExp>0</tvExp>
532
+      <tvExpOptDlg>0</tvExpOptDlg>
533
+      <bDave2>0</bDave2>
534
+      <PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_tim.c</PathWithFileName>
535
+      <FilenameWithoutPath>stm32f1xx_ll_tim.c</FilenameWithoutPath>
536
+      <RteFlg>0</RteFlg>
537
+      <bShared>0</bShared>
538
+    </File>
588 539
   </Group>
589 540
 
590 541
   <Group>
@@ -595,7 +546,7 @@
595 546
     <RteFlg>0</RteFlg>
596 547
     <File>
597 548
       <GroupNumber>5</GroupNumber>
598
-      <FileNumber>6</FileNumber>
549
+      <FileNumber>7</FileNumber>
599 550
       <FileType>5</FileType>
600 551
       <tvExp>0</tvExp>
601 552
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -615,7 +566,7 @@
615 566
     <RteFlg>0</RteFlg>
616 567
     <File>
617 568
       <GroupNumber>6</GroupNumber>
618
-      <FileNumber>7</FileNumber>
569
+      <FileNumber>8</FileNumber>
619 570
       <FileType>1</FileType>
620 571
       <tvExp>0</tvExp>
621 572
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -635,7 +586,7 @@
635 586
     <RteFlg>0</RteFlg>
636 587
     <File>
637 588
       <GroupNumber>7</GroupNumber>
638
-      <FileNumber>8</FileNumber>
589
+      <FileNumber>9</FileNumber>
639 590
       <FileType>2</FileType>
640 591
       <tvExp>0</tvExp>
641 592
       <tvExpOptDlg>0</tvExpOptDlg>

+ 17
- 13
MDK-ARM/Project.uvprojx View File

@@ -10,13 +10,12 @@
10 10
       <TargetName>NUCLEO-F103RB</TargetName>
11 11
       <ToolsetNumber>0x4</ToolsetNumber>
12 12
       <ToolsetName>ARM-ADS</ToolsetName>
13
-      <pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
14
-      <uAC6>0</uAC6>
13
+      <pCCUsed>5060422::V5.06 update 4 (build 422)::ARMCC</pCCUsed>
15 14
       <TargetOption>
16 15
         <TargetCommonOption>
17 16
           <Device>STM32F103RB</Device>
18 17
           <Vendor>STMicroelectronics</Vendor>
19
-          <PackID>Keil.STM32F1xx_DFP.2.3.0</PackID>
18
+          <PackID>Keil.STM32F1xx_DFP.2.2.0</PackID>
20 19
           <PackURL>http://www.keil.com/pack/</PackURL>
21 20
           <Cpu>IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
22 21
           <FlashUtilSpec></FlashUtilSpec>
@@ -184,7 +183,6 @@
184 183
             <hadXRAM>0</hadXRAM>
185 184
             <uocXRam>0</uocXRam>
186 185
             <RvdsVP>0</RvdsVP>
187
-            <RvdsMve>0</RvdsMve>
188 186
             <hadIRAM2>0</hadIRAM2>
189 187
             <hadIROM2>0</hadIROM2>
190 188
             <StupSel>8</StupSel>
@@ -312,7 +310,7 @@
312 310
           </ArmAdsMisc>
313 311
           <Cads>
314 312
             <interw>1</interw>
315
-            <Optim>4</Optim>
313
+            <Optim>1</Optim>
316 314
             <oTime>0</oTime>
317 315
             <SplitLS>0</SplitLS>
318 316
             <OneElfS>1</OneElfS>
@@ -325,7 +323,6 @@
325 323
             <uThumb>0</uThumb>
326 324
             <uSurpInc>0</uSurpInc>
327 325
             <uC99>0</uC99>
328
-            <uGnu>0</uGnu>
329 326
             <useXO>0</useXO>
330 327
             <v6Lang>1</v6Lang>
331 328
             <v6LangP>1</v6LangP>
@@ -336,7 +333,7 @@
336 333
             <v6Rtti>0</v6Rtti>
337 334
             <VariousControls>
338 335
               <MiscControls>--C99</MiscControls>
339
-              <Define>STM32F103xB,USE_FULL_LL_DRIVER,HSE_VALUE=8000000U</Define>
336
+              <Define>STM32F103xB,USE_FULL_LL_DRIVER,HSE_VALUE=8000000U,USE_FULL_ASSERT</Define>
340 337
               <Undefine></Undefine>
341 338
               <IncludePath>..\Inc;..\LLDrivers\inc;..\Services;..\MyDrivers</IncludePath>
342 339
             </VariousControls>
@@ -422,6 +419,11 @@
422 419
               <FileType>1</FileType>
423 420
               <FilePath>..\LLDrivers\src\stm32f1xx_ll_utils.c</FilePath>
424 421
             </File>
422
+            <File>
423
+              <FileName>stm32f1xx_ll_tim.c</FileName>
424
+              <FileType>1</FileType>
425
+              <FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
426
+            </File>
425 427
           </Files>
426 428
         </Group>
427 429
         <Group>
@@ -463,13 +465,12 @@
463 465
       <TargetName>Simulateur</TargetName>
464 466
       <ToolsetNumber>0x4</ToolsetNumber>
465 467
       <ToolsetName>ARM-ADS</ToolsetName>
466
-      <pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
467
-      <uAC6>0</uAC6>
468
+      <pCCUsed>5060422::V5.06 update 4 (build 422)::ARMCC</pCCUsed>
468 469
       <TargetOption>
469 470
         <TargetCommonOption>
470 471
           <Device>STM32F103RB</Device>
471 472
           <Vendor>STMicroelectronics</Vendor>
472
-          <PackID>Keil.STM32F1xx_DFP.2.3.0</PackID>
473
+          <PackID>Keil.STM32F1xx_DFP.2.2.0</PackID>
473 474
           <PackURL>http://www.keil.com/pack/</PackURL>
474 475
           <Cpu>IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
475 476
           <FlashUtilSpec></FlashUtilSpec>
@@ -637,7 +638,6 @@
637 638
             <hadXRAM>0</hadXRAM>
638 639
             <uocXRam>0</uocXRam>
639 640
             <RvdsVP>0</RvdsVP>
640
-            <RvdsMve>0</RvdsMve>
641 641
             <hadIRAM2>0</hadIRAM2>
642 642
             <hadIROM2>0</hadIROM2>
643 643
             <StupSel>8</StupSel>
@@ -778,7 +778,6 @@
778 778
             <uThumb>0</uThumb>
779 779
             <uSurpInc>0</uSurpInc>
780 780
             <uC99>0</uC99>
781
-            <uGnu>0</uGnu>
782 781
             <useXO>0</useXO>
783 782
             <v6Lang>1</v6Lang>
784 783
             <v6LangP>1</v6LangP>
@@ -789,7 +788,7 @@
789 788
             <v6Rtti>0</v6Rtti>
790 789
             <VariousControls>
791 790
               <MiscControls>--C99</MiscControls>
792
-              <Define>STM32F103xB,USE_FULL_LL_DRIVER,HSE_VALUE=8000000U</Define>
791
+              <Define>STM32F103xB,USE_FULL_LL_DRIVER,HSE_VALUE=8000000U,USE_FULL_ASSERT</Define>
793 792
               <Undefine></Undefine>
794 793
               <IncludePath>..\Inc;..\LLDrivers\inc;..\Services;..\MyDrivers</IncludePath>
795 794
             </VariousControls>
@@ -875,6 +874,11 @@
875 874
               <FileType>1</FileType>
876 875
               <FilePath>..\LLDrivers\src\stm32f1xx_ll_utils.c</FilePath>
877 876
             </File>
877
+            <File>
878
+              <FileName>stm32f1xx_ll_tim.c</FileName>
879
+              <FileType>1</FileType>
880
+              <FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
881
+            </File>
878 882
           </Files>
879 883
         </Group>
880 884
         <Group>

+ 153
- 83
MyDrivers/MyTimer.c View File

@@ -10,103 +10,173 @@
10 10
 				  pour mettre à 0  , reg = reg&~ Mask (ou Mask est le représente le ou les bits à positionner à 0)
11 11
  
12 12
 */ 
13
-#include "stm32f103xb.h" 
14
-
15
-void (* ptrfonc1)(void);
16
-void (* ptrfonc2)(void);
17
-void (* ptrfonc3)(void);
18
-void (* ptrfonc4)(void);
19
-
20
-void MyTimer_Conf(TIM_TypeDef * Timer,int Arr, int Psc) {
21
-	int valid = 1;
22
-	if (Timer == TIM1) {
23
-		RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
24
-	} else if (Timer == TIM2) {
25
-		RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
26
-	} else if (Timer == TIM3) {
27
-		RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
28
-	} else if (Timer == TIM4) {
29
-		RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
30
-	} else {
31
-		valid = 0;
32
-	}
13
+
14
+#include "MyTimer.h"
15
+#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
16
+#include "stm32f1xx_ll_tim.h" 
17
+
18
+
19
+// variable pointeur de fonction permettant de mémoriser le callback à appeler depuis
20
+// le handler d'IT
21
+void (*Ptr_ItFct_TIM1)(void); 
22
+void (*Ptr_ItFct_TIM2)(void); 
23
+void (*Ptr_ItFct_TIM3)(void); 
24
+void (*Ptr_ItFct_TIM4)(void); 
25
+
26
+
27
+
28
+
29
+/**
30
+	* @brief  Active l'horloge et règle l'ARR et le PSC du timer visé
31
+  * @note   Fonction à lancer avant toute autre. Le timer n'est pas encore lancé (voir MyTimerStart)
32
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
33
+	* 				int Arr   : valeur à placer dans ARR
34
+	*					int Psc   : valeur à placer dans PSC
35
+  * @retval None
36
+  */
37
+void MyTimer_Conf(TIM_TypeDef * Timer,int Arr, int Psc)
38
+{
39
+	LL_TIM_InitTypeDef My_LL_Tim_Init_Struct;
40
+	
41
+	// Validation horloge locale
42
+	if (Timer==TIM1) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_TIM1);
43
+	else if (Timer==TIM2) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
44
+	else if (Timer==TIM3) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
45
+	else  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
46
+	
47
+	// chargement structure Arr, Psc, Up Count
48
+	My_LL_Tim_Init_Struct.Autoreload=Arr;
49
+	My_LL_Tim_Init_Struct.Prescaler=Psc;
50
+	My_LL_Tim_Init_Struct.ClockDivision=LL_TIM_CLOCKDIVISION_DIV1;
51
+	My_LL_Tim_Init_Struct.CounterMode=LL_TIM_COUNTERMODE_UP;
52
+	My_LL_Tim_Init_Struct.RepetitionCounter=0;
53
+	
54
+	LL_TIM_Init(Timer,&My_LL_Tim_Init_Struct);
55
+	
56
+
57
+	// Blocage IT
58
+	LL_TIM_DisableIT_UPDATE(Timer);
59
+	
60
+	
61
+	// Blocage Timer
62
+	LL_TIM_DisableCounter(Timer);
33 63
 	
34
-	if (valid) {
35
-		Timer->ARR = Arr;
36
-		Timer->PSC = Psc;
37
-	}
38
-}
39 64
 
40
-void MyTimer_Start(TIM_TypeDef * Timer) {
41
-	Timer->CR1 |= TIM_CR1_CEN;
65
+		
42 66
 }
43 67
 
44
-void MyTimer_Stop(TIM_TypeDef * Timer) {
45
-	Timer->CR1 &= ~TIM_CR1_CEN;
68
+
69
+/**
70
+	* @brief  Démarre le timer considéré
71
+  * @note   
72
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
73
+  * @retval None
74
+  */
75
+void MyTimer_Start(TIM_TypeDef * Timer)
76
+{
77
+		LL_TIM_EnableCounter(Timer);
46 78
 }
47 79
 
48
-void MyTimer_IT_Conf(TIM_TypeDef * Timer, void (*IT_function) (void),int Prio) {
49
-	if (Timer == TIM1) {
50
-		NVIC->ISER[0] = NVIC->ISER[0] | (1 << 25);
51
-		NVIC->IP[25] = NVIC->IP[25] | (Prio << 4);
52
-		ptrfonc1 = IT_function;
53
-	} else if (Timer == TIM2) {
54
-		NVIC->ISER[0] = NVIC->ISER[0] | (1 << 28);
55
-		NVIC->IP[28] = NVIC->IP[28] | (Prio << 4);
56
-		ptrfonc2 = IT_function;
57
-	} else if (Timer == TIM3) {
58
-		NVIC->ISER[0] = NVIC->ISER[0] | (1 << 29);
59
-		NVIC->IP[29] = NVIC->IP[29] | (Prio << 4);
60
-		ptrfonc3 = IT_function;
61
-	} else if (Timer == TIM4) {
62
-		NVIC->ISER[0] = NVIC->ISER[0] | (1 << 30);
63
-		NVIC->IP[30] = NVIC->IP[30] | (Prio << 4);
64
-		ptrfonc4 = IT_function;
65
-	}
80
+/**
81
+	* @brief  Arrêt le timer considéré
82
+  * @note   
83
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
84
+  * @retval None
85
+  */
86
+void MyTimer_Stop(TIM_TypeDef * Timer)
87
+{
88
+	LL_TIM_DisableCounter(Timer);
66 89
 }
67 90
 
68 91
 
69
-void MyTimer_IT_Enable(TIM_TypeDef * Timer) {
70
-	if (Timer == TIM1) {
71
-		TIM1->DIER |= TIM_DIER_UIE;
72
-	} else if (Timer == TIM2) {
73
-		TIM2->DIER |= TIM_DIER_UIE;	
74
-	} else if (Timer == TIM3) {
75
-		TIM3->DIER |= TIM_DIER_UIE;
76
-	} else if (Timer == TIM4) {
77
-		TIM4->DIER |= TIM_DIER_UIE;
78
-	}
79
-}
92
+/**
93
+	* @brief  Configure le Timer considéré en interruption sur débordement.
94
+  * @note   A ce stade, les interruptions ne sont pas validés (voir  MyTimer_IT_Enable )
95
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
96
+	* 				void (*IT_function) (void) : nom (adresse) de la fonction à lancer sur interruption
97
+	*         int Prio : priorité associée à l'interruption
98
+  * @retval None
99
+  */
100
+void MyTimer_IT_Conf(TIM_TypeDef * Timer, void (*IT_function) (void),int Prio)
101
+{
102
+	// affectation de la fonction
103
+	if (Timer==TIM1) Ptr_ItFct_TIM1=IT_function;
104
+	else if (Timer==TIM2)	Ptr_ItFct_TIM2=IT_function;
105
+	else if (Timer==TIM3)	Ptr_ItFct_TIM3=IT_function;
106
+	else  Ptr_ItFct_TIM4=IT_function;
80 107
 
108
+	
109
+	// Blocage IT (il faudra la débloquer voir fct suivante)
110
+	LL_TIM_DisableIT_UPDATE(Timer);
111
+	
112
+	// validation du canal NVIC
113
+	IRQn_Type TIM_irq;
114
+	
115
+	if (Timer==TIM1) TIM_irq=TIM1_UP_IRQn;
116
+	else if (Timer==TIM2)	TIM_irq=TIM2_IRQn;
117
+	else if (Timer==TIM3)	TIM_irq=TIM3_IRQn;
118
+	else 	TIM_irq=TIM4_IRQn;
119
+	
120
+	NVIC_SetPriority(TIM_irq, Prio);
121
+	NVIC_EnableIRQ(TIM_irq);
81 122
 
82
-void MyTimer_IT_Disable(TIM_TypeDef * Timer) {
83
-	if (Timer == TIM1) {
84
-		TIM1->DIER &= ~TIM_DIER_UIE;
85
-	} else if (Timer == TIM2) {
86
-		TIM2->DIER &= ~TIM_DIER_UIE;	
87
-	} else if (Timer == TIM3) {
88
-		TIM3->DIER &= ~TIM_DIER_UIE;
89
-	} else if (Timer == TIM4) {
90
-		TIM4->DIER &= ~TIM_DIER_UIE;
91
-	}
123
+	
92 124
 }
93 125
 
94 126
 
95
-void TIM1_UP_IRQHandler(void) {
96
-	TIM1->SR &= ~TIM_SR_UIF;
97
-	(*ptrfonc1)();
127
+/**
128
+	* @brief  Autorise les interruptions
129
+  * @note   
130
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
131
+  * @retval None
132
+  */
133
+void MyTimer_IT_Enable(TIM_TypeDef * Timer)
134
+{
135
+		LL_TIM_EnableIT_UPDATE(Timer);
98 136
 }
99 137
 
100
-void TIM2_IRQHandler(void) {
101
-	TIM2->SR &= ~TIM_SR_UIF;
102
-	(*ptrfonc2)();
103
-}
104 138
 
105
-void TIM3_IRQHandler(void) {
106
-	TIM3->SR &= ~TIM_SR_UIF;
107
-	(*ptrfonc3)();
108
-}
109
-void TIM4_IRQHandler(void) {
110
-	TIM4->SR &= ~TIM_SR_UIF;
111
-	(*ptrfonc4)();
112
-}
139
+/**
140
+	* @brief  Interdit les interruptions
141
+  * @note   
142
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
143
+  * @retval None
144
+  */
145
+void MyTimer_IT_Disable(TIM_TypeDef * Timer)
146
+{
147
+			LL_TIM_DisableIT_UPDATE(Timer); 
148
+}	
149
+
150
+
151
+/*
152
+============ LES INTERRUPTIONS =================================
153
+
154
+*/
155
+
156
+void TIM1_UP_IRQHandler(void)
157
+{
158
+	// rabaisser le flag d'IT
159
+	LL_TIM_ClearFlag_UPDATE(TIM1);
160
+	(*Ptr_ItFct_TIM1)();
161
+}	
162
+
163
+void TIM2_IRQHandler(void)
164
+{
165
+	// rabaisser le flag d'IT
166
+	LL_TIM_ClearFlag_UPDATE(TIM2);
167
+	(*Ptr_ItFct_TIM2)();
168
+}	
169
+
170
+void TIM3_IRQHandler(void)
171
+{
172
+	// rabaisser le flag d'IT
173
+	LL_TIM_ClearFlag_UPDATE(TIM3);
174
+	(*Ptr_ItFct_TIM3)();
175
+}	
176
+
177
+void TIM4_IRQHandler(void)
178
+{
179
+	// rabaisser le flag d'IT
180
+	LL_TIM_ClearFlag_UPDATE(TIM4);
181
+	(*Ptr_ItFct_TIM4)();
182
+}	

+ 3
- 4
Services/Chrono.c View File

@@ -37,10 +37,10 @@ void Chrono_Conf(TIM_TypeDef * Timer)
37 37
 	Chrono_Timer=Timer;
38 38
 
39 39
 	// Réglage Timer pour un débordement à 10ms
40
-	MyTimer_Conf(Chrono_Timer, 99, 7199);
40
+	MyTimer_Conf(Chrono_Timer,999, 719);
41 41
 	
42 42
 	// Réglage interruption du Timer avec callback : Chrono_Task_10ms()
43
-	MyTimer_IT_Conf(Chrono_Timer, Chrono_Task_10ms, 7);
43
+	MyTimer_IT_Conf(Chrono_Timer, Chrono_Task_10ms,3);
44 44
 	
45 45
 	// Validation IT
46 46
 	MyTimer_IT_Enable(Chrono_Timer);
@@ -57,7 +57,6 @@ void Chrono_Conf(TIM_TypeDef * Timer)
57 57
   */
58 58
 void Chrono_Start(void)
59 59
 {
60
-	// Lancement du Timer
61 60
 	MyTimer_Start(Chrono_Timer);
62 61
 }
63 62
 
@@ -113,7 +112,7 @@ Time * Chrono_Read(void)
113 112
   * @retval Aucun
114 113
   */
115 114
 void Chrono_Task_10ms(void)
116
-{
115
+{ 
117 116
 	Chrono_Time.Hund++;
118 117
 	if (Chrono_Time.Hund==100)
119 118
 	{

+ 38
- 0
Services/Chrono.h View File

@@ -11,6 +11,37 @@ Utilise la lib MyTimers.h /.c
11 11
 
12 12
 #include "stm32f103xb.h" 
13 13
 
14
+/* =====================================================================================
15
+Les fonctions qui gèrent les IO (ajout par rapport à l'activité 1)
16
+=======================================================================================*/
17
+
18
+
19
+#define PinStart LL_GPIO_PIN_8
20
+#define PinStop LL_GPIO_PIN_6
21
+// à compléter pour la pin reset du chronometre
22
+#define PinLED LL_GPIO_PIN_10
23
+#define GPIO_Pin GPIOC
24
+#define GPIO_LED GPIOC
25
+
26
+
27
+
28
+
29
+
30
+
31
+/**
32
+	* @brief  polle les 3 entrées et gènère les actions à faire
33
+  * @note   Fct à lancer en tâche de fond (non bloquante)
34
+	* @param  None 
35
+  * @retval None
36
+  */
37
+		
38
+void Chrono_Background(void);
39
+
40
+//=======================================================================================//
41
+
42
+
43
+
44
+
14 45
 // Type de donnée utilisé dans le module
15 46
 
16 47
 typedef struct {
@@ -31,6 +62,10 @@ typedef struct {
31 62
 void Chrono_Conf(TIM_TypeDef * Timer);
32 63
 
33 64
 
65
+
66
+
67
+
68
+
34 69
 /**
35 70
 	* @brief  Démarre le chronomètre. 
36 71
   * @note   si la durée dépasse 59mn 59sec 99 cent, elle est remise à zéro et repart
@@ -66,4 +101,7 @@ void Chrono_Reset(void);
66 101
   */
67 102
 Time * Chrono_Read(void);
68 103
 
104
+
105
+
106
+
69 107
 #endif

+ 8
- 36
Src/main.c View File

@@ -31,53 +31,25 @@ void  SystemClock_Config(void);
31 31
   * @param  None
32 32
   * @retval None
33 33
   */
34
+	
35
+
34 36
 int main(void)
35
-{	
37
+{
36 38
   /* Configure the system clock to 72 MHz */
37 39
   SystemClock_Config();
38 40
 
39
-	
40
-	/* DU BLABLA POUR JOUER AU DéBUT 
41
-	TIM1->CR2|=0x1 ;
42
-	TIM1->CR2=0xFFFF ;
43
-	TIM1->CR2 &= ~0x0040 ;
44
-	TIM1->CR2=0xFFFF ;
45
-	TIM1->CR2&=~(1<<6) ; 
46
-	GPIOB->CRL=(0xFFFF ) ;
47
-	GPIOB->CRL&=~(0xF<<8) ;
48
-	GPIOB->CRL|= (0x5<<8) ;
49
-	GPIOB->ODR|=GPIO_ODR_ODR1 ;
50
-	SPI1->CR1 |= 0x2;
51
-	
52
-	SPI1->CR1 = 0xFFFF;
53
-	SPI1->CR1 &= ~SPI_CR1_DFF;
54
-	USART1->CR2 = 0xFFFFFFFF;
55
-	USART1->CR2 &= ~USART_CR2_STOP;
56
-	USART1->CR2 |= (0x2 << USART_CR2_STOP_Pos);*/
57
-	
58
-	
59 41
   /* Add your application code here */
60 42
   // Configuration chronomètre
61
-	Chrono_Conf(TIM1);
43
+	Chrono_Conf(TIM3);
62 44
 	
63 45
 	// Lancement chronomètre
64
-	//Chrono_Start(); 
46
+	Chrono_Start(); 
47
+	
48
+
65 49
   
66 50
   /* Infinite loop */
67
-	RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
68
-	GPIOC->CRH &= ~(0xF << 0);
69
-	GPIOC->CRH |= (0x4 << 0);
70
-	GPIOC->CRH &= ~(0xF << 8);
71
-	GPIOC->CRH |= (0x6 << 8);
72
-	
73 51
   while (1)
74 52
   {
75
-		int valeur_bouton = (GPIOC->IDR & (1 << 8)) >> 8;
76
-		if (valeur_bouton) {
77
-			GPIOC->ODR &= ~(1 << 10);
78
-		} else {
79
-			GPIOC->ODR |= (1 << 10);
80
-		}
81 53
   }
82 54
 }
83 55
 
@@ -136,7 +108,7 @@ void SystemClock_Config(void)
136 108
   LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
137 109
 
138 110
   /* Set systick to 1ms in using frequency set to 72MHz */
139
-  //LL_Init1msTick(72000000); !! décommenter que si l'IT est récupérée
111
+  LL_Init1msTick(72000000); // utile lorsqu'on utilise la fonction LL_mDelay
140 112
 
141 113
   /* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */
142 114
   LL_SetSystemCoreClock(72000000);

+ 0
- 3
readme.txt View File

@@ -49,11 +49,8 @@ main.h enlevé
49 49
 Remarque ligne 72   LL_RCC_HSE_EnableBypass();, si on devait travailler sur MCBSTM32, il faudrait commenter la ligne
50 50
 Ligne 108 commentée, il s'agit de l'activation systick inutile mais qui active les IT non récupérée ... donc otée
51 51
 
52
-*********************** FIN DES MODIFICATIONS    ************************************************
53 52
 
54 53
 
55
-Readme d'origine ...
56
-
57 54
 
58 55
 
59 56
 /**

Loading…
Cancel
Save