2018-03-31 16:34:59 +03:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @file stm32f1xx_hal.c
|
|
|
|
* @author MCD Application Team
|
|
|
|
* @brief HAL module driver.
|
|
|
|
* This is the common part of the HAL initialization
|
|
|
|
*
|
|
|
|
@verbatim
|
|
|
|
==============================================================================
|
|
|
|
##### How to use this driver #####
|
|
|
|
==============================================================================
|
|
|
|
[..]
|
|
|
|
The common HAL driver contains a set of generic and common APIs that can be
|
2019-07-22 03:29:14 +03:00
|
|
|
used by the PPP peripheral drivers and the user to start using the HAL.
|
2018-03-31 16:34:59 +03:00
|
|
|
[..]
|
2019-07-22 03:29:14 +03:00
|
|
|
The HAL contains two APIs' categories:
|
2018-03-31 16:34:59 +03:00
|
|
|
(+) Common HAL APIs
|
|
|
|
(+) Services HAL APIs
|
|
|
|
|
|
|
|
@endverbatim
|
|
|
|
******************************************************************************
|
|
|
|
* @attention
|
|
|
|
*
|
2019-07-22 03:29:14 +03:00
|
|
|
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
|
|
* All rights reserved.</center></h2>
|
2018-03-31 16:34:59 +03:00
|
|
|
*
|
2019-07-22 03:29:14 +03:00
|
|
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
|
|
* the "License"; You may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at:
|
|
|
|
* opensource.org/licenses/BSD-3-Clause
|
2018-03-31 16:34:59 +03:00
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
#include "stm32f1xx_hal.h"
|
|
|
|
|
|
|
|
/** @addtogroup STM32F1xx_HAL_Driver
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @defgroup HAL HAL
|
|
|
|
* @brief HAL module driver.
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAL_MODULE_ENABLED
|
|
|
|
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/** @defgroup HAL_Private_Constants HAL Private Constants
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/**
|
2019-07-22 03:29:14 +03:00
|
|
|
* @brief STM32F1xx HAL Driver version number V1.1.4
|
2018-03-31 16:34:59 +03:00
|
|
|
*/
|
|
|
|
#define __STM32F1xx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
|
|
|
#define __STM32F1xx_HAL_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */
|
2019-07-22 03:29:14 +03:00
|
|
|
#define __STM32F1xx_HAL_VERSION_SUB2 (0x04U) /*!< [15:8] sub2 version */
|
2018-03-31 16:34:59 +03:00
|
|
|
#define __STM32F1xx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */
|
|
|
|
#define __STM32F1xx_HAL_VERSION ((__STM32F1xx_HAL_VERSION_MAIN << 24)\
|
|
|
|
|(__STM32F1xx_HAL_VERSION_SUB1 << 16)\
|
|
|
|
|(__STM32F1xx_HAL_VERSION_SUB2 << 8 )\
|
|
|
|
|(__STM32F1xx_HAL_VERSION_RC))
|
|
|
|
|
|
|
|
#define IDCODE_DEVID_MASK 0x00000FFFU
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
|
|
|
|
/** @defgroup HAL_Private_Variables HAL Private Variables
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
__IO uint32_t uwTick;
|
2019-07-22 03:29:14 +03:00
|
|
|
uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
|
|
|
|
HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
|
2018-03-31 16:34:59 +03:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* Exported functions ---------------------------------------------------------*/
|
|
|
|
|
|
|
|
/** @defgroup HAL_Exported_Functions HAL Exported Functions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
|
2018-03-31 16:34:59 +03:00
|
|
|
* @brief Initialization and de-initialization functions
|
|
|
|
*
|
|
|
|
@verbatim
|
|
|
|
===============================================================================
|
|
|
|
##### Initialization and de-initialization functions #####
|
|
|
|
===============================================================================
|
|
|
|
[..] This section provides functions allowing to:
|
2019-07-22 03:29:14 +03:00
|
|
|
(+) Initializes the Flash interface, the NVIC allocation and initial clock
|
|
|
|
configuration. It initializes the systick also when timeout is needed
|
|
|
|
and the backup domain when enabled.
|
2018-03-31 16:34:59 +03:00
|
|
|
(+) de-Initializes common part of the HAL.
|
2019-07-22 03:29:14 +03:00
|
|
|
(+) Configure The time base source to have 1ms time base with a dedicated
|
|
|
|
Tick interrupt priority.
|
|
|
|
(++) SysTick timer is used by default as source of time base, but user
|
|
|
|
can eventually implement his proper time base source (a general purpose
|
|
|
|
timer for example or other time source), keeping in mind that Time base
|
|
|
|
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
|
2018-03-31 16:34:59 +03:00
|
|
|
handled in milliseconds basis.
|
2019-07-22 03:29:14 +03:00
|
|
|
(++) Time base configuration function (HAL_InitTick ()) is called automatically
|
|
|
|
at the beginning of the program after reset by HAL_Init() or at any time
|
|
|
|
when clock is configured, by HAL_RCC_ClockConfig().
|
|
|
|
(++) Source of time base is configured to generate interrupts at regular
|
|
|
|
time intervals. Care must be taken if HAL_Delay() is called from a
|
|
|
|
peripheral ISR process, the Tick interrupt line must have higher priority
|
|
|
|
(numerically lower) than the peripheral interrupt. Otherwise the caller
|
|
|
|
ISR process will be blocked.
|
|
|
|
(++) functions affecting time base configurations are declared as __weak
|
2018-03-31 16:34:59 +03:00
|
|
|
to make override possible in case of other implementations in user file.
|
|
|
|
@endverbatim
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2019-07-22 03:29:14 +03:00
|
|
|
* @brief This function is used to initialize the HAL Library; it must be the first
|
2018-03-31 16:34:59 +03:00
|
|
|
* instruction to be executed in the main program (before to call any other
|
|
|
|
* HAL function), it performs the following:
|
|
|
|
* Configure the Flash prefetch.
|
|
|
|
* Configures the SysTick to generate an interrupt each 1 millisecond,
|
|
|
|
* which is clocked by the HSI (at this stage, the clock is not yet
|
|
|
|
* configured and thus the system is running from the internal HSI at 16 MHz).
|
|
|
|
* Set NVIC Group Priority to 4.
|
2019-07-22 03:29:14 +03:00
|
|
|
* Calls the HAL_MspInit() callback function defined in user file
|
|
|
|
* "stm32f1xx_hal_msp.c" to do the global low level hardware initialization
|
|
|
|
*
|
2018-03-31 16:34:59 +03:00
|
|
|
* @note SysTick is used as time base for the HAL_Delay() function, the application
|
|
|
|
* need to ensure that the SysTick time base is always set to 1 millisecond
|
|
|
|
* to have correct HAL operation.
|
|
|
|
* @retval HAL status
|
|
|
|
*/
|
|
|
|
HAL_StatusTypeDef HAL_Init(void)
|
|
|
|
{
|
|
|
|
/* Configure Flash prefetch */
|
|
|
|
#if (PREFETCH_ENABLE != 0)
|
|
|
|
#if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || \
|
|
|
|
defined(STM32F102x6) || defined(STM32F102xB) || \
|
|
|
|
defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || \
|
|
|
|
defined(STM32F105xC) || defined(STM32F107xC)
|
|
|
|
|
|
|
|
/* Prefetch buffer is not available on value line devices */
|
|
|
|
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
|
|
|
|
#endif
|
|
|
|
#endif /* PREFETCH_ENABLE */
|
|
|
|
|
|
|
|
/* Set Interrupt Group Priority */
|
|
|
|
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
|
2018-03-31 16:34:59 +03:00
|
|
|
HAL_InitTick(TICK_INT_PRIORITY);
|
|
|
|
|
|
|
|
/* Init the low level hardware */
|
|
|
|
HAL_MspInit();
|
|
|
|
|
|
|
|
/* Return function status */
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-22 03:29:14 +03:00
|
|
|
* @brief This function de-Initializes common part of the HAL and stops the systick.
|
2018-03-31 16:34:59 +03:00
|
|
|
* of time base.
|
|
|
|
* @note This function is optional.
|
|
|
|
* @retval HAL status
|
|
|
|
*/
|
|
|
|
HAL_StatusTypeDef HAL_DeInit(void)
|
|
|
|
{
|
|
|
|
/* Reset of all peripherals */
|
|
|
|
__HAL_RCC_APB1_FORCE_RESET();
|
|
|
|
__HAL_RCC_APB1_RELEASE_RESET();
|
|
|
|
|
|
|
|
__HAL_RCC_APB2_FORCE_RESET();
|
|
|
|
__HAL_RCC_APB2_RELEASE_RESET();
|
|
|
|
|
|
|
|
#if defined(STM32F105xC) || defined(STM32F107xC)
|
|
|
|
__HAL_RCC_AHB_FORCE_RESET();
|
|
|
|
__HAL_RCC_AHB_RELEASE_RESET();
|
|
|
|
#endif
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
/* De-Init the low level hardware */
|
|
|
|
HAL_MspDeInit();
|
2019-07-22 03:29:14 +03:00
|
|
|
|
2018-03-31 16:34:59 +03:00
|
|
|
/* Return function status */
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-22 03:29:14 +03:00
|
|
|
* @brief Initialize the MSP.
|
2018-03-31 16:34:59 +03:00
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
__weak void HAL_MspInit(void)
|
|
|
|
{
|
2019-07-22 03:29:14 +03:00
|
|
|
/* NOTE : This function should not be modified, when the callback is needed,
|
2018-03-31 16:34:59 +03:00
|
|
|
the HAL_MspInit could be implemented in the user file
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief DeInitializes the MSP.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
__weak void HAL_MspDeInit(void)
|
|
|
|
{
|
2019-07-22 03:29:14 +03:00
|
|
|
/* NOTE : This function should not be modified, when the callback is needed,
|
2018-03-31 16:34:59 +03:00
|
|
|
the HAL_MspDeInit could be implemented in the user file
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-22 03:29:14 +03:00
|
|
|
* @brief This function configures the source of the time base.
|
|
|
|
* The time source is configured to have 1ms time base with a dedicated
|
2018-03-31 16:34:59 +03:00
|
|
|
* Tick interrupt priority.
|
|
|
|
* @note This function is called automatically at the beginning of program after
|
2019-07-22 03:29:14 +03:00
|
|
|
* reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
|
|
|
|
* @note In the default implementation, SysTick timer is the source of time base.
|
|
|
|
* It is used to generate interrupts at regular time intervals.
|
|
|
|
* Care must be taken if HAL_Delay() is called from a peripheral ISR process,
|
|
|
|
* The SysTick interrupt must have higher priority (numerically lower)
|
2018-03-31 16:34:59 +03:00
|
|
|
* than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
|
|
|
|
* The function is declared as __weak to be overwritten in case of other
|
|
|
|
* implementation in user file.
|
2019-07-22 03:29:14 +03:00
|
|
|
* @param TickPriority Tick interrupt priority.
|
2018-03-31 16:34:59 +03:00
|
|
|
* @retval HAL status
|
|
|
|
*/
|
|
|
|
__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
|
|
|
{
|
2019-07-22 03:29:14 +03:00
|
|
|
/* Configure the SysTick to have interrupt in 1ms time basis*/
|
|
|
|
if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)
|
|
|
|
{
|
|
|
|
return HAL_ERROR;
|
|
|
|
}
|
2018-03-31 16:34:59 +03:00
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/* Configure the SysTick IRQ priority */
|
|
|
|
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
|
|
|
|
{
|
|
|
|
HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
|
|
|
|
uwTickPrio = TickPriority;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return HAL_ERROR;
|
|
|
|
}
|
2018-03-31 16:34:59 +03:00
|
|
|
|
|
|
|
/* Return function status */
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2019-07-22 03:29:14 +03:00
|
|
|
/** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
|
2018-03-31 16:34:59 +03:00
|
|
|
* @brief HAL Control functions
|
|
|
|
*
|
|
|
|
@verbatim
|
|
|
|
===============================================================================
|
|
|
|
##### HAL Control functions #####
|
|
|
|
===============================================================================
|
|
|
|
[..] This section provides functions allowing to:
|
|
|
|
(+) Provide a tick value in millisecond
|
|
|
|
(+) Provide a blocking delay in millisecond
|
|
|
|
(+) Suspend the time base source interrupt
|
|
|
|
(+) Resume the time base source interrupt
|
|
|
|
(+) Get the HAL API driver version
|
|
|
|
(+) Get the device identifier
|
|
|
|
(+) Get the device revision identifier
|
|
|
|
(+) Enable/Disable Debug module during SLEEP mode
|
|
|
|
(+) Enable/Disable Debug module during STOP mode
|
|
|
|
(+) Enable/Disable Debug module during STANDBY mode
|
|
|
|
|
|
|
|
@endverbatim
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function is called to increment a global variable "uwTick"
|
|
|
|
* used as application time base.
|
|
|
|
* @note In the default implementation, this variable is incremented each 1ms
|
2019-07-22 03:29:14 +03:00
|
|
|
* in SysTick ISR.
|
|
|
|
* @note This function is declared as __weak to be overwritten in case of other
|
2018-03-31 16:34:59 +03:00
|
|
|
* implementations in user file.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
__weak void HAL_IncTick(void)
|
|
|
|
{
|
2019-07-22 03:29:14 +03:00
|
|
|
uwTick += uwTickFreq;
|
2018-03-31 16:34:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Provides a tick value in millisecond.
|
2019-07-22 03:29:14 +03:00
|
|
|
* @note This function is declared as __weak to be overwritten in case of other
|
2018-03-31 16:34:59 +03:00
|
|
|
* implementations in user file.
|
|
|
|
* @retval tick value
|
|
|
|
*/
|
|
|
|
__weak uint32_t HAL_GetTick(void)
|
|
|
|
{
|
|
|
|
return uwTick;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-22 03:29:14 +03:00
|
|
|
* @brief This function returns a tick priority.
|
|
|
|
* @retval tick priority
|
|
|
|
*/
|
|
|
|
uint32_t HAL_GetTickPrio(void)
|
|
|
|
{
|
|
|
|
return uwTickPrio;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set new tick Freq.
|
|
|
|
* @retval status
|
|
|
|
*/
|
|
|
|
HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq)
|
|
|
|
{
|
|
|
|
HAL_StatusTypeDef status = HAL_OK;
|
|
|
|
assert_param(IS_TICKFREQ(Freq));
|
|
|
|
|
|
|
|
if (uwTickFreq != Freq)
|
|
|
|
{
|
|
|
|
/* Apply the new tick Freq */
|
|
|
|
status = HAL_InitTick(uwTickPrio);
|
|
|
|
if (status == HAL_OK)
|
|
|
|
{
|
|
|
|
uwTickFreq = Freq;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Return tick frequency.
|
|
|
|
* @retval tick period in Hz
|
|
|
|
*/
|
|
|
|
HAL_TickFreqTypeDef HAL_GetTickFreq(void)
|
|
|
|
{
|
|
|
|
return uwTickFreq;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function provides minimum delay (in milliseconds) based
|
2018-03-31 16:34:59 +03:00
|
|
|
* on variable incremented.
|
|
|
|
* @note In the default implementation , SysTick timer is the source of time base.
|
|
|
|
* It is used to generate interrupts at regular time intervals where uwTick
|
|
|
|
* is incremented.
|
|
|
|
* @note This function is declared as __weak to be overwritten in case of other
|
|
|
|
* implementations in user file.
|
2019-07-22 03:29:14 +03:00
|
|
|
* @param Delay specifies the delay time length, in milliseconds.
|
2018-03-31 16:34:59 +03:00
|
|
|
* @retval None
|
|
|
|
*/
|
2019-07-22 03:29:14 +03:00
|
|
|
__weak void HAL_Delay(uint32_t Delay)
|
2018-03-31 16:34:59 +03:00
|
|
|
{
|
|
|
|
uint32_t tickstart = HAL_GetTick();
|
|
|
|
uint32_t wait = Delay;
|
2019-07-22 03:29:14 +03:00
|
|
|
|
|
|
|
/* Add a freq to guarantee minimum wait */
|
2018-03-31 16:34:59 +03:00
|
|
|
if (wait < HAL_MAX_DELAY)
|
|
|
|
{
|
2019-07-22 03:29:14 +03:00
|
|
|
wait += (uint32_t)(uwTickFreq);
|
2018-03-31 16:34:59 +03:00
|
|
|
}
|
2019-07-22 03:29:14 +03:00
|
|
|
|
|
|
|
while ((HAL_GetTick() - tickstart) < wait)
|
2018-03-31 16:34:59 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Suspend Tick increment.
|
|
|
|
* @note In the default implementation , SysTick timer is the source of time base. It is
|
|
|
|
* used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
|
2019-07-22 03:29:14 +03:00
|
|
|
* is called, the SysTick interrupt will be disabled and so Tick increment
|
2018-03-31 16:34:59 +03:00
|
|
|
* is suspended.
|
|
|
|
* @note This function is declared as __weak to be overwritten in case of other
|
|
|
|
* implementations in user file.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
__weak void HAL_SuspendTick(void)
|
|
|
|
{
|
|
|
|
/* Disable SysTick Interrupt */
|
2019-07-22 03:29:14 +03:00
|
|
|
CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
|
2018-03-31 16:34:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Resume Tick increment.
|
|
|
|
* @note In the default implementation , SysTick timer is the source of time base. It is
|
|
|
|
* used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
|
2019-07-22 03:29:14 +03:00
|
|
|
* is called, the SysTick interrupt will be enabled and so Tick increment
|
2018-03-31 16:34:59 +03:00
|
|
|
* is resumed.
|
|
|
|
* @note This function is declared as __weak to be overwritten in case of other
|
|
|
|
* implementations in user file.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
__weak void HAL_ResumeTick(void)
|
|
|
|
{
|
|
|
|
/* Enable SysTick Interrupt */
|
2019-07-22 03:29:14 +03:00
|
|
|
SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
|
2018-03-31 16:34:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns the HAL revision
|
2019-07-22 03:29:14 +03:00
|
|
|
* @retval version 0xXYZR (8bits for each decimal, R for RC)
|
2018-03-31 16:34:59 +03:00
|
|
|
*/
|
|
|
|
uint32_t HAL_GetHalVersion(void)
|
|
|
|
{
|
2019-07-22 03:29:14 +03:00
|
|
|
return __STM32F1xx_HAL_VERSION;
|
2018-03-31 16:34:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns the device revision identifier.
|
|
|
|
* Note: On devices STM32F10xx8 and STM32F10xxB,
|
|
|
|
* STM32F101xC/D/E and STM32F103xC/D/E,
|
|
|
|
* STM32F101xF/G and STM32F103xF/G
|
|
|
|
* STM32F10xx4 and STM32F10xx6
|
2019-07-22 03:29:14 +03:00
|
|
|
* Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug mode (not accessible by the user software in normal mode).
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* @retval Device revision identifier
|
|
|
|
*/
|
|
|
|
uint32_t HAL_GetREVID(void)
|
|
|
|
{
|
2019-07-22 03:29:14 +03:00
|
|
|
return ((DBGMCU->IDCODE) >> DBGMCU_IDCODE_REV_ID_Pos);
|
2018-03-31 16:34:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns the device identifier.
|
|
|
|
* Note: On devices STM32F10xx8 and STM32F10xxB,
|
|
|
|
* STM32F101xC/D/E and STM32F103xC/D/E,
|
|
|
|
* STM32F101xF/G and STM32F103xF/G
|
|
|
|
* STM32F10xx4 and STM32F10xx6
|
2019-07-22 03:29:14 +03:00
|
|
|
* Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug mode (not accessible by the user software in normal mode).
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* @retval Device identifier
|
|
|
|
*/
|
|
|
|
uint32_t HAL_GetDEVID(void)
|
|
|
|
{
|
2019-07-22 03:29:14 +03:00
|
|
|
return ((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns first word of the unique device identifier (UID based on 96 bits)
|
|
|
|
* @retval Device identifier
|
|
|
|
*/
|
|
|
|
uint32_t HAL_GetUIDw0(void)
|
|
|
|
{
|
|
|
|
return(READ_REG(*((uint32_t *)UID_BASE)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns second word of the unique device identifier (UID based on 96 bits)
|
|
|
|
* @retval Device identifier
|
|
|
|
*/
|
|
|
|
uint32_t HAL_GetUIDw1(void)
|
|
|
|
{
|
|
|
|
return(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns third word of the unique device identifier (UID based on 96 bits)
|
|
|
|
* @retval Device identifier
|
|
|
|
*/
|
|
|
|
uint32_t HAL_GetUIDw2(void)
|
|
|
|
{
|
|
|
|
return(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
|
2018-03-31 16:34:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable the Debug Module during SLEEP mode
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_DBGMCU_EnableDBGSleepMode(void)
|
|
|
|
{
|
|
|
|
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable the Debug Module during SLEEP mode
|
|
|
|
* Note: On devices STM32F10xx8 and STM32F10xxB,
|
|
|
|
* STM32F101xC/D/E and STM32F103xC/D/E,
|
|
|
|
* STM32F101xF/G and STM32F103xF/G
|
|
|
|
* STM32F10xx4 and STM32F10xx6
|
2019-07-22 03:29:14 +03:00
|
|
|
* Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug mode (not accessible by the user software in normal mode).
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_DBGMCU_DisableDBGSleepMode(void)
|
|
|
|
{
|
|
|
|
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable the Debug Module during STOP mode
|
|
|
|
* Note: On devices STM32F10xx8 and STM32F10xxB,
|
|
|
|
* STM32F101xC/D/E and STM32F103xC/D/E,
|
|
|
|
* STM32F101xF/G and STM32F103xF/G
|
|
|
|
* STM32F10xx4 and STM32F10xx6
|
2019-07-22 03:29:14 +03:00
|
|
|
* Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug mode (not accessible by the user software in normal mode).
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* Note: On all STM32F1 devices:
|
2019-07-22 03:29:14 +03:00
|
|
|
* If the system tick timer interrupt is enabled during the Stop mode
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
|
|
|
|
* the system from Stop mode.
|
2019-07-22 03:29:14 +03:00
|
|
|
* Workaround: To debug the Stop mode, disable the system tick timer
|
2018-03-31 16:34:59 +03:00
|
|
|
* interrupt.
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* Note: On all STM32F1 devices:
|
2019-07-22 03:29:14 +03:00
|
|
|
* If the system tick timer interrupt is enabled during the Stop mode
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
|
|
|
|
* the system from Stop mode.
|
|
|
|
* Workaround: To debug the Stop mode, disable the system tick timer
|
|
|
|
* interrupt.
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_DBGMCU_EnableDBGStopMode(void)
|
|
|
|
{
|
|
|
|
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable the Debug Module during STOP mode
|
|
|
|
* Note: On devices STM32F10xx8 and STM32F10xxB,
|
|
|
|
* STM32F101xC/D/E and STM32F103xC/D/E,
|
|
|
|
* STM32F101xF/G and STM32F103xF/G
|
|
|
|
* STM32F10xx4 and STM32F10xx6
|
2019-07-22 03:29:14 +03:00
|
|
|
* Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug mode (not accessible by the user software in normal mode).
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_DBGMCU_DisableDBGStopMode(void)
|
|
|
|
{
|
|
|
|
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable the Debug Module during STANDBY mode
|
|
|
|
* Note: On devices STM32F10xx8 and STM32F10xxB,
|
|
|
|
* STM32F101xC/D/E and STM32F103xC/D/E,
|
|
|
|
* STM32F101xF/G and STM32F103xF/G
|
|
|
|
* STM32F10xx4 and STM32F10xx6
|
2019-07-22 03:29:14 +03:00
|
|
|
* Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug mode (not accessible by the user software in normal mode).
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_DBGMCU_EnableDBGStandbyMode(void)
|
|
|
|
{
|
|
|
|
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable the Debug Module during STANDBY mode
|
|
|
|
* Note: On devices STM32F10xx8 and STM32F10xxB,
|
|
|
|
* STM32F101xC/D/E and STM32F103xC/D/E,
|
|
|
|
* STM32F101xF/G and STM32F103xF/G
|
|
|
|
* STM32F10xx4 and STM32F10xx6
|
2019-07-22 03:29:14 +03:00
|
|
|
* Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
|
2018-03-31 16:34:59 +03:00
|
|
|
* debug mode (not accessible by the user software in normal mode).
|
|
|
|
* Refer to errata sheet of these devices for more details.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
void HAL_DBGMCU_DisableDBGStandbyMode(void)
|
|
|
|
{
|
|
|
|
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endif /* HAL_MODULE_ENABLED */
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|