Subversion Repositories DashDisplay

Rev

Rev 49 | Rev 61 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 49 Rev 50
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32l1xx_hal.c
3
  * @file    stm32l1xx_hal.c
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @version V1.2.0
-
 
6
  * @date    01-July-2016
-
 
7
  * @brief   HAL module driver.
5
  * @brief   HAL module driver.
8
  *          This is the common part of the HAL initialization
6
  *          This is the common part of the HAL initialization
9
  *
7
  *
10
  @verbatim
8
  @verbatim
11
  ==============================================================================
9
  ==============================================================================
12
                     ##### How to use this driver #####
10
                     ##### How to use this driver #####
13
  ==============================================================================
11
  ==============================================================================
14
    [..]
12
    [..]
15
    The common HAL driver contains a set of generic and common APIs that can be
13
    The common HAL driver contains a set of generic and common APIs that can be
16
    used by the PPP peripheral drivers and the user to start using the HAL.
14
    used by the PPP peripheral drivers and the user to start using the HAL.
17
    [..]
15
    [..]
18
    The HAL contains two APIs' categories:
16
    The HAL contains two APIs categories:
19
         (+) Common HAL APIs
17
         (+) Common HAL APIs
20
         (+) Services HAL APIs
18
         (+) Services HAL APIs
21
 
19
 
22
  @endverbatim
20
  @endverbatim
23
  ******************************************************************************
21
  ******************************************************************************
24
  * @attention
22
  * @attention
25
  *
23
  *
26
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
24
  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
-
 
25
  * All rights reserved.</center></h2>
27
  *
26
  *
28
  * Redistribution and use in source and binary forms, with or without modification,
27
  * This software component is licensed by ST under BSD 3-Clause license,
29
  * are permitted provided that the following conditions are met:
28
  * the "License"; You may not use this file except in compliance with the
30
  *   1. Redistributions of source code must retain the above copyright notice,
-
 
31
  *      this list of conditions and the following disclaimer.
-
 
32
  *   2. Redistributions in binary form must reproduce the above copyright notice,
-
 
33
  *      this list of conditions and the following disclaimer in the documentation
-
 
34
  *      and/or other materials provided with the distribution.
29
  * License. You may obtain a copy of the License at:
35
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-
 
36
  *      may be used to endorse or promote products derived from this software
30
  *                        opensource.org/licenses/BSD-3-Clause
37
  *      without specific prior written permission.
-
 
38
  *
-
 
39
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
 
40
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
41
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-
 
42
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-
 
43
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-
 
44
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-
 
45
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-
 
46
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-
 
47
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
 
48
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
49
  *
31
  *
50
  ******************************************************************************
32
  ******************************************************************************
51
  */
33
  */
52
 
34
 
53
/* Includes ------------------------------------------------------------------*/
35
/* Includes ------------------------------------------------------------------*/
Line 70... Line 52...
70
/** @defgroup HAL_Private_Defines HAL Private Defines
52
/** @defgroup HAL_Private_Defines HAL Private Defines
71
  * @{
53
  * @{
72
  */
54
  */
73
 
55
 
74
/**
56
/**
75
 * @brief STM32L1xx HAL Driver version number
57
 * @brief STM32L1xx HAL Driver version number V1.4.3
76
   */
58
   */
77
#define __STM32L1xx_HAL_VERSION_MAIN   (0x01) /*!< [31:24] main version */
59
#define __STM32L1xx_HAL_VERSION_MAIN   (0x01) /*!< [31:24] main version */
78
#define __STM32L1xx_HAL_VERSION_SUB1   (0x02) /*!< [23:16] sub1 version */
60
#define __STM32L1xx_HAL_VERSION_SUB1   (0x04) /*!< [23:16] sub1 version */
79
#define __STM32L1xx_HAL_VERSION_SUB2   (0x00) /*!< [15:8]  sub2 version */
61
#define __STM32L1xx_HAL_VERSION_SUB2   (0x03) /*!< [15:8]  sub2 version */
80
#define __STM32L1xx_HAL_VERSION_RC     (0x00) /*!< [7:0]  release candidate */
62
#define __STM32L1xx_HAL_VERSION_RC     (0x00) /*!< [7:0]  release candidate */
81
#define __STM32L1xx_HAL_VERSION         ((__STM32L1xx_HAL_VERSION_MAIN << 24)\
63
#define __STM32L1xx_HAL_VERSION         ((__STM32L1xx_HAL_VERSION_MAIN << 24)\
82
                                        |(__STM32L1xx_HAL_VERSION_SUB1 << 16)\
64
                                        |(__STM32L1xx_HAL_VERSION_SUB1 << 16)\
83
                                        |(__STM32L1xx_HAL_VERSION_SUB2 << 8 )\
65
                                        |(__STM32L1xx_HAL_VERSION_SUB2 << 8 )\
84
                                        |(__STM32L1xx_HAL_VERSION_RC))
66
                                        |(__STM32L1xx_HAL_VERSION_RC))
85
 
67
 
86
#define IDCODE_DEVID_MASK    ((uint32_t)0x00000FFF)
68
#define IDCODE_DEVID_MASK    (0x00000FFFU)
87
 
69
 
88
/**
70
/**
89
  * @}
71
  * @}
90
  */
72
  */
91
 
73
 
92
/* Private macro -------------------------------------------------------------*/
74
/* Private macro -------------------------------------------------------------*/
93
/* Private variables ---------------------------------------------------------*/
75
/* Private variables ---------------------------------------------------------*/
-
 
76
/* Private function prototypes -----------------------------------------------*/
-
 
77
/* Private functions ---------------------------------------------------------*/
94
 
78
 
-
 
79
/* Exported variables --------------------------------------------------------*/
95
/** @defgroup HAL_Private_Variables HAL Private Variables
80
/** @addtogroup HAL_Exported_Variables
96
  * @{
81
  * @{
97
  */
82
  */
98
 
-
 
99
__IO uint32_t uwTick;
83
__IO uint32_t uwTick;
100
 
-
 
-
 
84
uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid priority */
-
 
85
uint32_t uwTickFreq = HAL_TICK_FREQ_DEFAULT;  /* 1KHz */
101
/**
86
/**
102
  * @}
87
  * @}
103
  */
88
  */
104
 
89
 
105
/* Private function prototypes -----------------------------------------------*/
-
 
106
/* Private functions ---------------------------------------------------------*/
90
/* Exported functions --------------------------------------------------------*/
107
 
-
 
108
/** @defgroup HAL_Exported_Functions HAL Exported Functions
91
/** @defgroup HAL_Exported_Functions HAL Exported Functions
109
  * @{
92
  * @{
110
  */
93
  */
111
 
94
 
112
/** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
95
/** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
113
 *  @brief    Initialization and de-initialization functions
96
 *  @brief    Initialization and de-initialization functions
114
 *
97
 *
115
@verbatim
98
@verbatim
116
 ===============================================================================
99
 ===============================================================================
117
              ##### Initialization and de-initialization functions #####
100
              ##### Initialization and de-initialization functions #####
118
 ===============================================================================
101
 ===============================================================================
119
   [..]  This section provides functions allowing to:
102
   [..]  This section provides functions allowing to:
120
      (+) Initializes the Flash interface, the NVIC allocation and initial clock
103
      (+) Initialize the Flash interface, the NVIC allocation and initial clock
121
          configuration. It initializes the source of time base also when timeout
104
          configuration. It initializes the source of time base also when timeout
122
          is needed and the backup domain when enabled.
105
          is needed and the backup domain when enabled.
123
      (+) de-Initializes common part of the HAL.
106
      (+) De-initialize common part of the HAL.
124
      (+) Configure The time base source to have 1ms time base with a dedicated
107
      (+) Configure the time base source to have 1ms time base with a dedicated
125
          Tick interrupt priority.
108
          Tick interrupt priority.
126
        (++) Systick timer is used by default as source of time base, but user
109
        (++) SysTick timer is used by default as source of time base, but user
127
             can eventually implement his proper time base source (a general purpose
110
             can eventually implement his proper time base source (a general purpose
128
             timer for example or other time source), keeping in mind that Time base
111
             timer for example or other time source), keeping in mind that Time base
129
             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
112
             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
130
             handled in milliseconds basis.
113
             handled in milliseconds basis.
131
        (++) Time base configuration function (HAL_InitTick ()) is called automatically
114
        (++) Time base configuration function (HAL_InitTick ()) is called automatically
132
             at the beginning of the program after reset by HAL_Init() or at any time
115
             at the beginning of the program after reset by HAL_Init() or at any time
133
             when clock is configured, by HAL_RCC_ClockConfig().
116
             when clock is configured, by HAL_RCC_ClockConfig().
134
        (++) Source of time base is configured  to generate interrupts at regular
117
        (++) Source of time base is configured  to generate interrupts at regular
135
             time intervals. Care must be taken if HAL_Delay() is called from a
118
             time intervals. Care must be taken if HAL_Delay() is called from a
136
             peripheral ISR process, the Tick interrupt line must have higher priority
119
             peripheral ISR process, the Tick interrupt line must have higher priority
137
            (numerically lower) than the peripheral interrupt. Otherwise the caller
120
            (numerically lower) than the peripheral interrupt. Otherwise the caller
138
            ISR process will be blocked.
121
            ISR process will be blocked.
139
       (++) functions affecting time base configurations are declared as __Weak  
122
       (++) functions affecting time base configurations are declared as __weak
140
             to make  override possible  in case of other  implementations in user file.
123
             to make  override possible  in case of other  implementations in user file.
141
 
124
 
142
@endverbatim
125
@endverbatim
143
  * @{
126
  * @{
144
  */
127
  */
145
 
128
 
146
/**
129
/**
147
  * @brief This function configures the Flash prefetch,
130
  * @brief This function configures the Flash prefetch,
148
  *        Configures time base source, NVIC and Low level hardware
131
  *        configures time base source, NVIC and Low level hardware
149
  * @note This function is called at the beginning of program after reset and before
132
  * @note This function is called at the beginning of program after reset and before
150
  *       the clock configuration
133
  *       the clock configuration
151
  * @note The time base configuration is based on MSI clock when exiting from Reset.
134
  * @note The time base configuration is based on MSI clock when exiting from Reset.
152
  *       Once done, time base tick start incrementing.
135
  *       Once done, time base tick start incrementing.
153
  *        In the default implementation,Systick is used as source of time base.
136
  *        In the default implementation,Systick is used as source of time base.
154
  *        the tick variable is incremented each 1ms in its ISR.
137
  *        the tick variable is incremented each 1ms in its ISR.
155
  * @retval HAL status
138
  * @retval HAL status
156
  */
139
  */
157
HAL_StatusTypeDef HAL_Init(void)
140
HAL_StatusTypeDef HAL_Init(void)
158
{
141
{
-
 
142
  HAL_StatusTypeDef  status = HAL_OK;
-
 
143
 
159
  /* Configure Flash prefetch */
144
  /* Configure Flash prefetch */
160
#if (PREFETCH_ENABLE != 0)
145
#if (PREFETCH_ENABLE != 0)
161
  __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
146
  __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
162
#endif /* PREFETCH_ENABLE */
147
#endif /* PREFETCH_ENABLE */
163
 
148
 
164
  /* Set Interrupt Group Priority */
149
  /* Set Interrupt Group Priority */
165
  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
150
  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
166
 
151
 
167
  /* Use systick as time base source and configure 1ms tick (default clock after Reset is MSI) */
152
  /* Use systick as time base source and configure 1ms tick (default clock after Reset is MSI) */
168
  HAL_InitTick(TICK_INT_PRIORITY);
153
  if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
-
 
154
  {
-
 
155
    status = HAL_ERROR;
-
 
156
  }
-
 
157
  else
169
 
158
  {
170
  /* Init the low level hardware */
159
    /* Init the low level hardware */
171
  HAL_MspInit();
160
    HAL_MspInit();
-
 
161
  }
172
 
162
 
173
  /* Return function status */
163
  /* Return function status */
174
  return HAL_OK;
164
  return status;
175
}
165
}
176
 
166
 
177
/**
167
/**
178
  * @brief This function de-Initializes common part of the HAL and stops the source
168
  * @brief This function de-initializes common part of the HAL and stops the source
179
  *        of time base.
169
  *        of time base.
180
  * @note This function is optional.
170
  * @note This function is optional.
181
  * @retval HAL status
171
  * @retval HAL status
182
  */
172
  */
183
HAL_StatusTypeDef HAL_DeInit(void)
173
HAL_StatusTypeDef HAL_DeInit(void)
Line 192... Line 182...
192
  __HAL_RCC_AHB_FORCE_RESET();
182
  __HAL_RCC_AHB_FORCE_RESET();
193
  __HAL_RCC_AHB_RELEASE_RESET();
183
  __HAL_RCC_AHB_RELEASE_RESET();
194
 
184
 
195
  /* De-Init the low level hardware */
185
  /* De-Init the low level hardware */
196
  HAL_MspDeInit();
186
  HAL_MspDeInit();
197
   
187
 
198
  /* Return function status */
188
  /* Return function status */
199
  return HAL_OK;
189
  return HAL_OK;
200
}
190
}
201
 
191
 
202
/**
192
/**
203
  * @brief  Initializes the MSP.
193
  * @brief  Initialize the MSP.
204
  * @retval None
194
  * @retval None
205
  */
195
  */
206
__weak void HAL_MspInit(void)
196
__weak void HAL_MspInit(void)
207
{
197
{
208
  /* NOTE : This function Should not be modified, when the callback is needed,
198
  /* NOTE : This function should not be modified, when the callback is needed,
209
            the HAL_MspInit could be implemented in the user file
199
            the HAL_MspInit could be implemented in the user file
210
   */
200
   */
211
}
201
}
212
 
202
 
213
/**
203
/**
214
  * @brief  DeInitializes the MSP.
204
  * @brief  DeInitialize the MSP.
215
  * @retval None
205
  * @retval None
216
  */
206
  */
217
__weak void HAL_MspDeInit(void)
207
__weak void HAL_MspDeInit(void)
218
{
208
{
219
  /* NOTE : This function Should not be modified, when the callback is needed,
209
  /* NOTE : This function should not be modified, when the callback is needed,
220
            the HAL_MspDeInit could be implemented in the user file
210
            the HAL_MspDeInit could be implemented in the user file
221
   */
211
   */
222
}
212
}
223
 
213
 
224
/**
214
/**
225
  * @brief This function configures the source of the time base.
215
  * @brief This function configures the source of the time base:
226
  *        The time source is configured  to have 1ms time base with a dedicated
216
  *        The time source is configured to have 1ms time base with a dedicated
227
  *        Tick interrupt priority.
217
  *        Tick interrupt priority.
228
  * @note This function is called  automatically at the beginning of program after
218
  * @note This function is called  automatically at the beginning of program after
229
  *       reset by HAL_Init() or at any time when clock is reconfigured  by HAL_RCC_ClockConfig().
219
  *       reset by HAL_Init() or at any time when clock is reconfigured  by HAL_RCC_ClockConfig().
230
  * @note In the default implementation, SysTick timer is the source of time base.
220
  * @note In the default implementation, SysTick timer is the source of time base.
231
  *       It is used to generate interrupts at regular time intervals.
221
  *       It is used to generate interrupts at regular time intervals.
232
  *       Care must be taken if HAL_Delay() is called from a peripheral ISR process,
222
  *       Care must be taken if HAL_Delay() is called from a peripheral ISR process,
233
  *       The the SysTick interrupt must have higher priority (numerically lower)
223
  *       The SysTick interrupt must have higher priority (numerically lower)
234
  *       than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
224
  *       than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
235
  *       The function is declared as __Weak  to be overwritten  in case of other
225
  *       The function is declared as __weak  to be overwritten  in case of other
236
  *       implementation  in user file.
226
  *       implementation  in user file.
237
  * @param TickPriority: Tick interrupt priority.
227
  * @param TickPriority Tick interrupt priority.
238
  * @retval HAL status
228
  * @retval HAL status
239
  */
229
  */
240
__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
230
__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
241
{
231
{
242
  /*Configure the SysTick to have interrupt in 1ms time basis*/
-
 
243
  HAL_SYSTICK_Config(SystemCoreClock /1000);
232
  HAL_StatusTypeDef  status = HAL_OK;
244
 
233
 
-
 
234
  if (uwTickFreq != 0U)
-
 
235
  {
-
 
236
    /*Configure the SysTick to have interrupt in 1ms time basis*/
-
 
237
    if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) == 0U)
-
 
238
    {
245
  /*Configure the SysTick IRQ priority */
239
      /* Configure the SysTick IRQ priority */
-
 
240
      if (TickPriority < (1UL << __NVIC_PRIO_BITS))
-
 
241
      {
246
  HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);
242
        HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
-
 
243
        uwTickPrio = TickPriority;
-
 
244
      }
-
 
245
      else
-
 
246
      {
-
 
247
        status = HAL_ERROR;
-
 
248
      }
-
 
249
    }
-
 
250
    else
-
 
251
    {
-
 
252
      status = HAL_ERROR;
-
 
253
    }
-
 
254
  }
-
 
255
  else
-
 
256
  {
-
 
257
    status = HAL_ERROR;
-
 
258
  }
247
 
259
 
248
   /* Return function status */
260
  /* Return function status */
249
  return HAL_OK;
261
  return status;
250
}
262
}
251
 
263
 
252
/**
264
/**
253
  * @}
265
  * @}
254
  */
266
  */
255
 
267
 
256
/** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
268
/** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
257
 *  @brief    HAL Control functions
269
 *  @brief    HAL Control functions
258
 *
270
 *
259
@verbatim
271
@verbatim
260
 ===============================================================================
272
 ===============================================================================
261
                      ##### HAL Control functions #####
273
                      ##### HAL Control functions #####
Line 266... Line 278...
266
      (+) Suspend the time base source interrupt
278
      (+) Suspend the time base source interrupt
267
      (+) Resume the time base source interrupt
279
      (+) Resume the time base source interrupt
268
      (+) Get the HAL API driver version
280
      (+) Get the HAL API driver version
269
      (+) Get the device identifier
281
      (+) Get the device identifier
270
      (+) Get the device revision identifier
282
      (+) Get the device revision identifier
271
      (+) Enable/Disable Debug module during Sleep mode
283
      (+) Get the unique device identifier
272
      (+) Enable/Disable Debug module during STOP mode
-
 
273
      (+) Enable/Disable Debug module during STANDBY mode
-
 
274
     
284
 
275
@endverbatim
285
@endverbatim
276
  * @{
286
  * @{
277
  */
287
  */
278
 
288
 
279
/**
289
/**
280
  * @brief This function is called to increment  a global variable "uwTick"
290
  * @brief This function is called to increment a global variable "uwTick"
281
  *        used as application time base.
291
  *        used as application time base.
282
  * @note In the default implementation, this variable is incremented each 1ms
292
  * @note In the default implementation, this variable is incremented each 1ms
283
  *       in Systick ISR.
293
  *       in SysTick ISR.
284
 * @note This function is declared as __weak to be overwritten in case of other
294
 * @note This function is declared as __weak to be overwritten in case of other
285
  *      implementations in user file.
295
  *      implementations in user file.
286
  * @retval None
296
  * @retval None
287
  */
297
  */
288
__weak void HAL_IncTick(void)
298
__weak void HAL_IncTick(void)
289
{
299
{
290
  uwTick++;
300
  uwTick += uwTickFreq;
291
}
301
}
292
 
302
 
293
/**
303
/**
294
  * @brief Provides a tick value in millisecond.
304
  * @brief Provide a tick value in millisecond.
295
  * @note This function is declared as __weak to be overwritten in case of other
305
  * @note This function is declared as __weak to be overwritten in case of other
296
  *       implementations in user file.
306
  *       implementations in user file.
297
  * @retval tick value
307
  * @retval tick value
298
  */
308
  */
299
__weak uint32_t HAL_GetTick(void)
309
__weak uint32_t HAL_GetTick(void)
300
{
310
{
301
  return uwTick;
311
  return uwTick;
302
}
312
}
303
 
313
 
304
/**
314
/**
-
 
315
  * @brief This function returns a tick priority.
-
 
316
  * @retval tick priority
-
 
317
  */
-
 
318
uint32_t HAL_GetTickPrio(void)
-
 
319
{
-
 
320
  return uwTickPrio;
-
 
321
}
-
 
322
 
-
 
323
/**
-
 
324
  * @brief Set new tick Freq.
-
 
325
  * @param Freq tick frequency
-
 
326
  * @retval HAL status
-
 
327
  */
-
 
328
HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq)
-
 
329
{
-
 
330
  HAL_StatusTypeDef status  = HAL_OK;
-
 
331
  uint32_t prevTickFreq;
-
 
332
 
-
 
333
  assert_param(IS_TICKFREQ(Freq));
-
 
334
 
-
 
335
  if (uwTickFreq != Freq)
-
 
336
  {
-
 
337
    /* Back up uwTickFreq frequency */
-
 
338
    prevTickFreq = uwTickFreq;
-
 
339
 
-
 
340
    /* Update uwTickFreq global variable used by HAL_InitTick() */
-
 
341
    uwTickFreq = Freq;
-
 
342
 
-
 
343
   /* Apply the new tick Freq  */
-
 
344
    status = HAL_InitTick(uwTickPrio);
-
 
345
 
-
 
346
    if (status != HAL_OK)
-
 
347
    {
-
 
348
      /* Restore previous tick frequency */
-
 
349
      uwTickFreq = prevTickFreq;
-
 
350
    }
-
 
351
  }
-
 
352
 
-
 
353
  return status;
-
 
354
}
-
 
355
 
-
 
356
/**
-
 
357
  * @brief Return tick frequency.
-
 
358
  * @retval tick period in Hz
-
 
359
  */
-
 
360
uint32_t HAL_GetTickFreq(void)
-
 
361
{
-
 
362
  return uwTickFreq;
-
 
363
}
-
 
364
 
-
 
365
/**
305
  * @brief This function provides accurate delay (in milliseconds) based
366
  * @brief This function provides minimum delay (in milliseconds) based
306
  *        on variable incremented.
367
  *        on variable incremented.
307
  * @note In the default implementation , SysTick timer is the source of time base.
368
  * @note In the default implementation , SysTick timer is the source of time base.
308
  *       It is used to generate interrupts at regular time intervals where uwTick
369
  *       It is used to generate interrupts at regular time intervals where uwTick
309
  *       is incremented.
370
  *       is incremented.
310
  * @note ThiS function is declared as __weak to be overwritten in case of other
371
  * @note This function is declared as __weak to be overwritten in case of other
311
  *       implementations in user file.
372
  *       implementations in user file.
312
  * @param Delay: specifies the delay time length, in milliseconds.
373
  * @param Delay specifies the delay time length, in milliseconds.
313
  * @retval None
374
  * @retval None
314
  */
375
  */
315
__weak void HAL_Delay(__IO uint32_t Delay)
376
__weak void HAL_Delay(uint32_t Delay)
316
{
377
{
317
  uint32_t tickstart = 0;
378
  uint32_t tickstart = HAL_GetTick();
-
 
379
  uint32_t wait = Delay;
-
 
380
 
-
 
381
  /* Add a period to guaranty minimum wait */
318
  tickstart = HAL_GetTick();
382
  if (wait < HAL_MAX_DELAY)
-
 
383
  {
-
 
384
    wait += (uint32_t)(uwTickFreq);
-
 
385
  }
-
 
386
 
319
  while((HAL_GetTick() - tickstart) < Delay)
387
  while((HAL_GetTick() - tickstart) < wait)
320
  {
388
  {
321
  }
389
  }
322
}
390
}
323
 
391
 
324
/**
392
/**
325
  * @brief Suspend Tick increment.
393
  * @brief Suspend the Tick increment.
326
  * @note In the default implementation , SysTick timer is the source of time base. It is
394
  * @note In the default implementation , SysTick timer is the source of time base. It is
327
  *       used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
395
  *       used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
328
  *       is called, the the SysTick interrupt will be disabled and so Tick increment
396
  *       is called, the SysTick interrupt will be disabled and so Tick increment
329
  *       is suspended.
397
  *       is suspended.
330
  * @note This function is declared as __weak to be overwritten in case of other
398
  * @note This function is declared as __weak to be overwritten in case of other
331
  *       implementations in user file.
399
  *       implementations in user file.
332
  * @retval None
400
  * @retval None
333
  */
401
  */
Line 336... Line 404...
336
  /* Disable SysTick Interrupt */
404
  /* Disable SysTick Interrupt */
337
  CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
405
  CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
338
}
406
}
339
 
407
 
340
/**
408
/**
341
  * @brief Resume Tick increment.
409
  * @brief Resume the Tick increment.
342
  * @note In the default implementation , SysTick timer is the source of time base. It is
410
  * @note In the default implementation , SysTick timer is the source of time base. It is
343
  *       used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
411
  *       used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
344
  *       is called, the the SysTick interrupt will be enabled and so Tick increment
412
  *       is called, the SysTick interrupt will be enabled and so Tick increment
345
  *       is resumed.
413
  *       is resumed.
346
  * @note This function is declared as __weak to be overwritten in case of other
414
  * @note This function is declared as __weak to be overwritten in case of other
347
  *       implementations in user file.
415
  *       implementations in user file.
348
  * @retval None
416
  * @retval None
349
  */
417
  */
Line 352... Line 420...
352
  /* Enable SysTick Interrupt */
420
  /* Enable SysTick Interrupt */
353
  SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
421
  SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
354
}
422
}
355
 
423
 
356
/**
424
/**
357
  * @brief Returns the HAL revision
425
  * @brief Return the HAL revision
358
  * @retval version: 0xXYZR (8bits for each decimal, R for RC)
426
  * @retval version: 0xXYZR (8bits for each decimal, R for RC)
359
  */
427
  */
360
uint32_t HAL_GetHalVersion(void)
428
uint32_t HAL_GetHalVersion(void)
361
{
429
{
362
 return __STM32L1xx_HAL_VERSION;
430
  return __STM32L1xx_HAL_VERSION;
363
}
431
}
364
 
432
 
365
/**
433
/**
366
  * @brief Returns the device revision identifier.
434
  * @brief Return the device revision identifier.
367
  * @retval Device revision identifier
435
  * @retval Device revision identifier
368
  */
436
  */
369
uint32_t HAL_GetREVID(void)
437
uint32_t HAL_GetREVID(void)
370
{
438
{
371
  return((DBGMCU->IDCODE) >> 16);
439
  return((DBGMCU->IDCODE) >> 16U);
372
}
440
}
373
 
441
 
374
/**
442
/**
375
  * @brief  Returns the device identifier.
443
  * @brief  Return the device identifier.
376
  * @retval Device identifier
444
  * @retval Device identifier
377
  */
445
  */
378
uint32_t HAL_GetDEVID(void)
446
uint32_t HAL_GetDEVID(void)
379
{
447
{
380
   return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
448
   return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
381
}
449
}
382
 
450
 
383
/**
451
/**
-
 
452
  * @brief  Return the first word of the unique device identifier (UID based on 96 bits)
-
 
453
  * @retval Device identifier 31:0 bits
-
 
454
  */
-
 
455
uint32_t HAL_GetUIDw0(void)
-
 
456
{
-
 
457
  return(READ_REG(*((uint32_t *)UID_BASE)));
-
 
458
}
-
 
459
 
-
 
460
/**
-
 
461
  * @brief  Return the second word of the unique device identifier (UID based on 96 bits)
-
 
462
  * @retval Device identifier 63:32 bits
-
 
463
  */
-
 
464
uint32_t HAL_GetUIDw1(void)
-
 
465
{
-
 
466
  return(READ_REG(*((uint32_t *)(UID_BASE + 0x4U))));
-
 
467
}
-
 
468
 
-
 
469
/**
-
 
470
  * @brief  Return the third word of the unique device identifier (UID based on 96 bits)
-
 
471
  * @retval Device identifier 95:64 bits
-
 
472
  */
-
 
473
uint32_t HAL_GetUIDw2(void)
-
 
474
{
-
 
475
  return(READ_REG(*((uint32_t *)(UID_BASE + 0x14U))));
-
 
476
}
-
 
477
 
-
 
478
/**
-
 
479
  * @}
-
 
480
  */
-
 
481
 
-
 
482
/** @defgroup HAL_Exported_Functions_Group3 DBGMCU Peripheral Control functions
-
 
483
 *  @brief    DBGMCU Peripheral Control functions
-
 
484
 *
-
 
485
@verbatim
-
 
486
 ===============================================================================
-
 
487
                      ##### DBGMCU Peripheral Control functions #####
-
 
488
 ===============================================================================
-
 
489
    [..]  This section provides functions allowing to:
-
 
490
      (+) Enable/Disable Debug module during SLEEP mode
-
 
491
      (+) Enable/Disable Debug module during STOP mode
-
 
492
      (+) Enable/Disable Debug module during STANDBY mode
-
 
493
 
-
 
494
@endverbatim
-
 
495
  * @{
-
 
496
  */
-
 
497
 
-
 
498
/**
384
  * @brief  Enable the Debug Module during SLEEP mode
499
  * @brief  Enable the Debug Module during SLEEP mode
385
  * @retval None
500
  * @retval None
386
  */
501
  */
387
void HAL_DBGMCU_EnableDBGSleepMode(void)
502
void HAL_DBGMCU_EnableDBGSleepMode(void)
388
{
503
{