Merge led and master (deleted Debug)
This commit is contained in:
commit
9672fd5377
52
fw/.cproject
52
fw/.cproject
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1992458385" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1992458385" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||||
|
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1211256952" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.4 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || STM32L011F4Ux || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32L0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32L0xx/Include | ../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy || || || USE_HAL_DRIVER | STM32L011xx | USE_FULL_LL_DRIVER || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32L011F4UX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1211256952" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.4 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || STM32L011F4Ux || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32L0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32L0xx/Include || || || STM32L011xx | USE_FULL_LL_DRIVER | HSE_VALUE=8000000 | HSE_STARTUP_TIMEOUT=100 | LSE_STARTUP_TIMEOUT=5000 | LSE_VALUE=32768 | MSI_VALUE=2097000 | HSI_VALUE=16000000 | LSI_VALUE=37000 | VDD_VALUE=3300 | PREFETCH_ENABLE=0 | INSTRUCTION_CACHE_ENABLE=1 | DATA_CACHE_ENABLE=1 || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32L011F4UX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None" valueType="string"/>
|
||||||
|
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.445833440" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.445833440" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||||
|
|
||||||
@ -75,7 +75,27 @@
|
|||||||
|
|
||||||
<listOptionValue builtIn="false" value="USE_FULL_LL_DRIVER"/>
|
<listOptionValue builtIn="false" value="USE_FULL_LL_DRIVER"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="HSE_STARTUP_TIMEOUT=100"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="LSE_STARTUP_TIMEOUT=5000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="LSE_VALUE=32768"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="MSI_VALUE=2097000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="HSI_VALUE=16000000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="LSI_VALUE=37000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="VDD_VALUE=3300"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="PREFETCH_ENABLE=0"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="INSTRUCTION_CACHE_ENABLE=1"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="DATA_CACHE_ENABLE=1"/>
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
@ -88,8 +108,6 @@
|
|||||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
|
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy"/>
|
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
@ -201,7 +219,7 @@
|
|||||||
|
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1944321553" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1944321553" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||||
|
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1781594695" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.4 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || STM32L011F4Ux || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32L0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32L0xx/Include | ../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy || || || USE_HAL_DRIVER | STM32L011xx | USE_FULL_LL_DRIVER || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32L011F4UX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1781594695" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.4 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || STM32L011F4Ux || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32L0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32L0xx/Include || || || STM32L011xx | USE_FULL_LL_DRIVER | HSE_VALUE=8000000 | HSE_STARTUP_TIMEOUT=100 | LSE_STARTUP_TIMEOUT=5000 | LSE_VALUE=32768 | MSI_VALUE=2097000 | HSI_VALUE=16000000 | LSI_VALUE=37000 | VDD_VALUE=3300 | PREFETCH_ENABLE=0 | INSTRUCTION_CACHE_ENABLE=1 | DATA_CACHE_ENABLE=1 || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32L011F4UX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None" valueType="string"/>
|
||||||
|
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1728902878" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1728902878" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||||
|
|
||||||
@ -227,7 +245,27 @@
|
|||||||
|
|
||||||
<listOptionValue builtIn="false" value="USE_FULL_LL_DRIVER"/>
|
<listOptionValue builtIn="false" value="USE_FULL_LL_DRIVER"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="HSE_STARTUP_TIMEOUT=100"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="LSE_STARTUP_TIMEOUT=5000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="LSE_VALUE=32768"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="MSI_VALUE=2097000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="HSI_VALUE=16000000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="LSI_VALUE=37000"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="VDD_VALUE=3300"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="PREFETCH_ENABLE=0"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="INSTRUCTION_CACHE_ENABLE=1"/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value="DATA_CACHE_ENABLE=1"/>
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
@ -240,8 +278,6 @@
|
|||||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
|
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L0xx/Include"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy"/>
|
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -28,19 +28,23 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
#include "stm32l0xx_ll_dma.h"
|
#include "stm32l0xx_ll_dma.h"
|
||||||
#include "stm32l0xx.h"
|
#include "stm32l0xx.h"
|
||||||
#include "stm32l0xx_ll_i2c.h"
|
#include "stm32l0xx_ll_i2c.h"
|
||||||
#include "stm32l0xx_ll_lpuart.h"
|
#include "stm32l0xx_ll_lpuart.h"
|
||||||
#include "stm32l0xx_ll_rcc.h"
|
#include "stm32l0xx_ll_rcc.h"
|
||||||
#include "stm32l0xx_ll_system.h"
|
#include "stm32l0xx_ll_crs.h"
|
||||||
#include "stm32l0xx_ll_gpio.h"
|
|
||||||
#include "stm32l0xx_ll_exti.h"
|
|
||||||
#include "stm32l0xx_ll_bus.h"
|
#include "stm32l0xx_ll_bus.h"
|
||||||
|
#include "stm32l0xx_ll_system.h"
|
||||||
|
#include "stm32l0xx_ll_exti.h"
|
||||||
#include "stm32l0xx_ll_cortex.h"
|
#include "stm32l0xx_ll_cortex.h"
|
||||||
#include "stm32l0xx_ll_utils.h"
|
#include "stm32l0xx_ll_utils.h"
|
||||||
#include "stm32l0xx_ll_pwr.h"
|
#include "stm32l0xx_ll_pwr.h"
|
||||||
|
#include "stm32l0xx_ll_gpio.h"
|
||||||
|
|
||||||
|
#if defined(USE_FULL_ASSERT)
|
||||||
|
#include "stm32_assert.h"
|
||||||
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
@ -76,6 +80,18 @@ void Error_Handler(void);
|
|||||||
#define LED_G_GPIO_Port GPIOA
|
#define LED_G_GPIO_Port GPIOA
|
||||||
#define LED_R_Pin LL_GPIO_PIN_7
|
#define LED_R_Pin LL_GPIO_PIN_7
|
||||||
#define LED_R_GPIO_Port GPIOA
|
#define LED_R_GPIO_Port GPIOA
|
||||||
|
#ifndef NVIC_PRIORITYGROUP_0
|
||||||
|
#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority,
|
||||||
|
4 bits for subpriority */
|
||||||
|
#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority,
|
||||||
|
3 bits for subpriority */
|
||||||
|
#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority,
|
||||||
|
2 bits for subpriority */
|
||||||
|
#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority,
|
||||||
|
1 bit for subpriority */
|
||||||
|
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority,
|
||||||
|
0 bit for subpriority */
|
||||||
|
#endif
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
/* USER CODE END Private defines */
|
/* USER CODE END Private defines */
|
||||||
|
@ -1,330 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_conf.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief HAL configuration template file.
|
|
||||||
* This file should be copied to the application folder and renamed
|
|
||||||
* to stm32l0xx_hal_conf.h.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_CONF_H
|
|
||||||
#define __STM32L0xx_HAL_CONF_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* ########################## Module Selection ############################## */
|
|
||||||
/**
|
|
||||||
* @brief This is the list of modules to be used in the HAL driver
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define HAL_MODULE_ENABLED
|
|
||||||
/*#define HAL_ADC_MODULE_ENABLED */
|
|
||||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
|
||||||
/*#define HAL_COMP_MODULE_ENABLED */
|
|
||||||
/*#define HAL_CRC_MODULE_ENABLED */
|
|
||||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
|
||||||
/*#define HAL_DAC_MODULE_ENABLED */
|
|
||||||
/*#define HAL_FIREWALL_MODULE_ENABLED */
|
|
||||||
/*#define HAL_I2S_MODULE_ENABLED */
|
|
||||||
/*#define HAL_IWDG_MODULE_ENABLED */
|
|
||||||
/*#define HAL_LCD_MODULE_ENABLED */
|
|
||||||
/*#define HAL_LPTIM_MODULE_ENABLED */
|
|
||||||
/*#define HAL_RNG_MODULE_ENABLED */
|
|
||||||
/*#define HAL_RTC_MODULE_ENABLED */
|
|
||||||
/*#define HAL_SPI_MODULE_ENABLED */
|
|
||||||
/*#define HAL_TIM_MODULE_ENABLED */
|
|
||||||
/*#define HAL_TSC_MODULE_ENABLED */
|
|
||||||
/*#define HAL_UART_MODULE_ENABLED */
|
|
||||||
/*#define HAL_USART_MODULE_ENABLED */
|
|
||||||
/*#define HAL_IRDA_MODULE_ENABLED */
|
|
||||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
|
||||||
/*#define HAL_SMBUS_MODULE_ENABLED */
|
|
||||||
/*#define HAL_WWDG_MODULE_ENABLED */
|
|
||||||
/*#define HAL_PCD_MODULE_ENABLED */
|
|
||||||
#define HAL_GPIO_MODULE_ENABLED
|
|
||||||
#define HAL_EXTI_MODULE_ENABLED
|
|
||||||
#define HAL_DMA_MODULE_ENABLED
|
|
||||||
#define HAL_I2C_MODULE_ENABLED
|
|
||||||
#define HAL_RCC_MODULE_ENABLED
|
|
||||||
#define HAL_FLASH_MODULE_ENABLED
|
|
||||||
#define HAL_PWR_MODULE_ENABLED
|
|
||||||
#define HAL_CORTEX_MODULE_ENABLED
|
|
||||||
|
|
||||||
/* ########################## Oscillator Values adaptation ####################*/
|
|
||||||
/**
|
|
||||||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
|
||||||
* This value is used by the RCC HAL module to compute the system frequency
|
|
||||||
* (when HSE is used as system clock source, directly or through the PLL).
|
|
||||||
*/
|
|
||||||
#if !defined (HSE_VALUE)
|
|
||||||
#define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
|
|
||||||
#endif /* HSE_VALUE */
|
|
||||||
|
|
||||||
#if !defined (HSE_STARTUP_TIMEOUT)
|
|
||||||
#define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
|
|
||||||
#endif /* HSE_STARTUP_TIMEOUT */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Internal Multiple Speed oscillator (MSI) default value.
|
|
||||||
* This value is the default MSI range value after Reset.
|
|
||||||
*/
|
|
||||||
#if !defined (MSI_VALUE)
|
|
||||||
#define MSI_VALUE ((uint32_t)2097000U) /*!< Value of the Internal oscillator in Hz*/
|
|
||||||
#endif /* MSI_VALUE */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Internal High Speed oscillator (HSI) value.
|
|
||||||
* This value is used by the RCC HAL module to compute the system frequency
|
|
||||||
* (when HSI is used as system clock source, directly or through the PLL).
|
|
||||||
*/
|
|
||||||
#if !defined (HSI_VALUE)
|
|
||||||
#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
|
|
||||||
#endif /* HSI_VALUE */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Internal High Speed oscillator for USB (HSI48) value.
|
|
||||||
*/
|
|
||||||
#if !defined (HSI48_VALUE)
|
|
||||||
#define HSI48_VALUE ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB in Hz.
|
|
||||||
The real value may vary depending on the variations
|
|
||||||
in voltage and temperature. */
|
|
||||||
#endif /* HSI48_VALUE */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Internal Low Speed oscillator (LSI) value.
|
|
||||||
*/
|
|
||||||
#if !defined (LSI_VALUE)
|
|
||||||
#define LSI_VALUE ((uint32_t)37000U) /*!< LSI Typical Value in Hz*/
|
|
||||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
|
||||||
The real value may vary depending on the variations
|
|
||||||
in voltage and temperature.*/
|
|
||||||
/**
|
|
||||||
* @brief External Low Speed oscillator (LSE) value.
|
|
||||||
* This value is used by the UART, RTC HAL module to compute the system frequency
|
|
||||||
*/
|
|
||||||
#if !defined (LSE_VALUE)
|
|
||||||
#define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/
|
|
||||||
#endif /* LSE_VALUE */
|
|
||||||
|
|
||||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
|
||||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
|
|
||||||
#endif /* LSE_STARTUP_TIMEOUT */
|
|
||||||
|
|
||||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
|
||||||
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
|
||||||
|
|
||||||
/* ########################### System Configuration ######################### */
|
|
||||||
/**
|
|
||||||
* @brief This is the HAL system configuration section
|
|
||||||
*/
|
|
||||||
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
|
|
||||||
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
|
|
||||||
#define USE_RTOS 0U
|
|
||||||
#define PREFETCH_ENABLE 0U
|
|
||||||
#define PREREAD_ENABLE 1U
|
|
||||||
#define BUFFER_CACHE_DISABLE 0U
|
|
||||||
|
|
||||||
/* ########################## Assert Selection ############################## */
|
|
||||||
/**
|
|
||||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
|
||||||
* HAL drivers code
|
|
||||||
*/
|
|
||||||
/* #define USE_FULL_ASSERT 1U */
|
|
||||||
|
|
||||||
/* ################## Register callback feature configuration ############### */
|
|
||||||
/**
|
|
||||||
* @brief Set below the peripheral configuration to "1U" to add the support
|
|
||||||
* of HAL callback registration/deregistration feature for the HAL
|
|
||||||
* driver(s). This allows user application to provide specific callback
|
|
||||||
* functions thanks to HAL_PPP_RegisterCallback() rather than overwriting
|
|
||||||
* the default weak callback functions (see each stm32l0xx_hal_ppp.h file
|
|
||||||
* for possible callback identifiers defined in HAL_PPP_CallbackIDTypeDef
|
|
||||||
* for each PPP peripheral).
|
|
||||||
*/
|
|
||||||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_COMP_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_TSC_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_UART_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_USART_REGISTER_CALLBACKS 0U
|
|
||||||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* @brief Include module's header file
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_RCC_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_rcc.h"
|
|
||||||
#endif /* HAL_RCC_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_exti.h"
|
|
||||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_gpio.h"
|
|
||||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_DMA_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_dma.h"
|
|
||||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_cortex.h"
|
|
||||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_ADC_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_adc.h"
|
|
||||||
#endif /* HAL_ADC_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_COMP_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_comp.h"
|
|
||||||
#endif /* HAL_COMP_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_CRC_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_crc.h"
|
|
||||||
#endif /* HAL_CRC_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_CRYP_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_cryp.h"
|
|
||||||
#endif /* HAL_CRYP_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_DAC_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_dac.h"
|
|
||||||
#endif /* HAL_DAC_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_FIREWALL_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_firewall.h"
|
|
||||||
#endif /* HAL_FIREWALL_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_flash.h"
|
|
||||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_I2C_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_i2c.h"
|
|
||||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_I2S_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_i2s.h"
|
|
||||||
#endif /* HAL_I2S_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_IWDG_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_iwdg.h"
|
|
||||||
#endif /* HAL_IWDG_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_LCD_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_lcd.h"
|
|
||||||
#endif /* HAL_LCD_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_LPTIM_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_lptim.h"
|
|
||||||
#endif /* HAL_LPTIM_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_PWR_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_pwr.h"
|
|
||||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_RNG_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_rng.h"
|
|
||||||
#endif /* HAL_RNG_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_RTC_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_rtc.h"
|
|
||||||
|
|
||||||
#endif /* HAL_RTC_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_SPI_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_spi.h"
|
|
||||||
#endif /* HAL_SPI_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_TIM_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_tim.h"
|
|
||||||
#endif /* HAL_TIM_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_TSC_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_tsc.h"
|
|
||||||
#endif /* HAL_TSC_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_UART_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_uart.h"
|
|
||||||
#endif /* HAL_UART_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_USART_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_usart.h"
|
|
||||||
#endif /* HAL_USART_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_IRDA_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_irda.h"
|
|
||||||
#endif /* HAL_IRDA_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_SMARTCARD_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_smartcard.h"
|
|
||||||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_SMBUS_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_smbus.h"
|
|
||||||
#endif /* HAL_SMBUS_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_WWDG_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_wwdg.h"
|
|
||||||
#endif /* HAL_WWDG_MODULE_ENABLED */
|
|
||||||
|
|
||||||
#ifdef HAL_PCD_MODULE_ENABLED
|
|
||||||
#include "stm32l0xx_hal_pcd.h"
|
|
||||||
#endif /* HAL_PCD_MODULE_ENABLED */
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
#ifdef USE_FULL_ASSERT
|
|
||||||
/**
|
|
||||||
* @brief The assert_param macro is used for function's parameters check.
|
|
||||||
* @param expr: If expr is false, it calls assert_failed function
|
|
||||||
* which reports the name of the source file and the source
|
|
||||||
* line number of the call that failed.
|
|
||||||
* If expr is true, it returns no value.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void assert_failed(uint8_t* file, uint32_t line);
|
|
||||||
#else
|
|
||||||
#define assert_param(expr) ((void)0U)
|
|
||||||
#endif /* USE_FULL_ASSERT */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_HAL_CONF_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -73,7 +73,11 @@ int main(void)
|
|||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
|
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
||||||
HAL_Init();
|
|
||||||
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
|
||||||
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
|
||||||
|
|
||||||
|
/* System interrupt init*/
|
||||||
|
|
||||||
/* USER CODE BEGIN Init */
|
/* USER CODE BEGIN Init */
|
||||||
|
|
||||||
@ -111,7 +115,6 @@ int main(void)
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
@ -123,45 +126,36 @@ int main(void)
|
|||||||
*/
|
*/
|
||||||
void SystemClock_Config(void)
|
void SystemClock_Config(void)
|
||||||
{
|
{
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_0)
|
||||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
{
|
||||||
|
}
|
||||||
|
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
|
||||||
|
LL_RCC_MSI_Enable();
|
||||||
|
|
||||||
/** Configure the main internal regulator output voltage
|
/* Wait till MSI is ready */
|
||||||
*/
|
while(LL_RCC_MSI_IsReady() != 1)
|
||||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
|
||||||
/** Initializes the RCC Oscillators according to the specified parameters
|
|
||||||
* in the RCC_OscInitTypeDef structure.
|
|
||||||
*/
|
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
|
|
||||||
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
|
|
||||||
RCC_OscInitStruct.MSICalibrationValue = 0;
|
|
||||||
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
|
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
|
||||||
{
|
{
|
||||||
Error_Handler();
|
|
||||||
}
|
|
||||||
/** Initializes the CPU, AHB and APB buses clocks
|
|
||||||
*/
|
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
|
||||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
|
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
|
||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
|
||||||
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
|
|
||||||
{
|
|
||||||
Error_Handler();
|
|
||||||
}
|
}
|
||||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1|RCC_PERIPHCLK_I2C1;
|
LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_5);
|
||||||
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
|
LL_RCC_MSI_SetCalibTrimming(0);
|
||||||
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
|
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
|
||||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
|
||||||
|
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
|
||||||
|
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_MSI);
|
||||||
|
|
||||||
|
/* Wait till System clock is ready */
|
||||||
|
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_MSI)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LL_Init1msTick(2097000);
|
||||||
|
|
||||||
|
LL_SetSystemCoreClock(2097000);
|
||||||
|
LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1);
|
||||||
|
LL_RCC_SetI2CClockSource(LL_RCC_I2C1_CLKSOURCE_PCLK1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
/* USER CODE BEGIN Header */
|
|
||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_msp.c
|
|
||||||
* @brief This file provides code for the MSP Initialization
|
|
||||||
* and de-Initialization codes.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/* USER CODE END Header */
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "main.h"
|
|
||||||
/* USER CODE BEGIN Includes */
|
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN TD */
|
|
||||||
|
|
||||||
/* USER CODE END TD */
|
|
||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN Define */
|
|
||||||
|
|
||||||
/* USER CODE END Define */
|
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN Macro */
|
|
||||||
|
|
||||||
/* USER CODE END Macro */
|
|
||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PV */
|
|
||||||
|
|
||||||
/* USER CODE END PV */
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PFP */
|
|
||||||
|
|
||||||
/* USER CODE END PFP */
|
|
||||||
|
|
||||||
/* External functions --------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN ExternalFunctions */
|
|
||||||
|
|
||||||
/* USER CODE END ExternalFunctions */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN 0 */
|
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
|
||||||
/**
|
|
||||||
* Initializes the Global MSP.
|
|
||||||
*/
|
|
||||||
void HAL_MspInit(void)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN MspInit 0 */
|
|
||||||
|
|
||||||
/* USER CODE END MspInit 0 */
|
|
||||||
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
||||||
__HAL_RCC_PWR_CLK_ENABLE();
|
|
||||||
|
|
||||||
/* System interrupt init*/
|
|
||||||
|
|
||||||
/* USER CODE BEGIN MspInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END MspInit 1 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -129,7 +129,7 @@ void SysTick_Handler(void)
|
|||||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END SysTick_IRQn 0 */
|
/* USER CODE END SysTick_IRQn 0 */
|
||||||
HAL_IncTick();
|
|
||||||
/* USER CODE BEGIN SysTick_IRQn 1 */
|
/* USER CODE BEGIN SysTick_IRQn 1 */
|
||||||
led_pwm_handler();
|
led_pwm_handler();
|
||||||
/* USER CODE END SysTick_IRQn 1 */
|
/* USER CODE END SysTick_IRQn 1 */
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,487 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief This file contains all the functions prototypes for the HAL
|
|
||||||
* module driver.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_H
|
|
||||||
#define __STM32L0xx_HAL_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_conf.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL HAL
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_Exported_Constants HAL Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_TICK_FREQ Tick Frequency
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_TICK_FREQ_10HZ = 100U,
|
|
||||||
HAL_TICK_FREQ_100HZ = 10U,
|
|
||||||
HAL_TICK_FREQ_1KHZ = 1U,
|
|
||||||
HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ
|
|
||||||
} HAL_TickFreqTypeDef;
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SYSCFG_BootMode Boot Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SYSCFG_BOOT_MAINFLASH (0x00000000U)
|
|
||||||
#define SYSCFG_BOOT_SYSTEMFLASH SYSCFG_CFGR1_BOOT_MODE_0
|
|
||||||
#define SYSCFG_BOOT_SRAM SYSCFG_CFGR1_BOOT_MODE
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DBGMCU_Low_Power_Config DBGMCU Low Power Configuration
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DBGMCU_SLEEP DBGMCU_CR_DBG_SLEEP
|
|
||||||
#define DBGMCU_STOP DBGMCU_CR_DBG_STOP
|
|
||||||
#define DBGMCU_STANDBY DBGMCU_CR_DBG_STANDBY
|
|
||||||
#define IS_DBGMCU_PERIPH(__PERIPH__) ((((__PERIPH__) & (~(DBGMCU_CR_DBG))) == 0x00U) && ((__PERIPH__) != 0x00U))
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (LCD_BASE) /* STM32L0x3xx only */
|
|
||||||
/** @defgroup SYSCFG_LCD_EXT_CAPA SYSCFG LCD External Capacitors
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SYSCFG_LCD_EXT_CAPA SYSCFG_CFGR2_CAPA /*!< Connection of internal Vlcd rail to external capacitors */
|
|
||||||
#define SYSCFG_VLCD_PB2_EXT_CAPA_ON SYSCFG_CFGR2_CAPA_0 /*!< Connection on PB2 */
|
|
||||||
#define SYSCFG_VLCD_PB12_EXT_CAPA_ON SYSCFG_CFGR2_CAPA_1 /*!< Connection on PB12 */
|
|
||||||
#define SYSCFG_VLCD_PB0_EXT_CAPA_ON SYSCFG_CFGR2_CAPA_2 /*!< Connection on PB0 */
|
|
||||||
#if defined (SYSCFG_CFGR2_CAPA_3)
|
|
||||||
#define SYSCFG_VLCD_PE11_EXT_CAPA_ON SYSCFG_CFGR2_CAPA_3 /*!< Connection on PE11 */
|
|
||||||
#endif
|
|
||||||
#if defined (SYSCFG_CFGR2_CAPA_4)
|
|
||||||
#define SYSCFG_VLCD_PE12_EXT_CAPA_ON SYSCFG_CFGR2_CAPA_4 /*!< Connection on PE12 */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @defgroup SYSCFG_VREFINT_OUT_SELECT SYSCFG VREFINT Out Selection
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SYSCFG_VREFINT_OUT_NONE (0x00000000U) /* no pad connected */
|
|
||||||
#define SYSCFG_VREFINT_OUT_PB0 SYSCFG_CFGR3_VREF_OUT_0 /* Selects PBO as output for the Vrefint */
|
|
||||||
#define SYSCFG_VREFINT_OUT_PB1 SYSCFG_CFGR3_VREF_OUT_1 /* Selects PB1 as output for the Vrefint */
|
|
||||||
#define SYSCFG_VREFINT_OUT_PB0_PB1 SYSCFG_CFGR3_VREF_OUT /* Selects PBO and PB1 as output for the Vrefint */
|
|
||||||
|
|
||||||
#define IS_SYSCFG_VREFINT_OUT_SELECT(OUTPUT) (((OUTPUT) == SYSCFG_VREFINT_OUT_NONE) || \
|
|
||||||
((OUTPUT) == SYSCFG_VREFINT_OUT_PB0) || \
|
|
||||||
((OUTPUT) == SYSCFG_VREFINT_OUT_PB1) || \
|
|
||||||
((OUTPUT) == SYSCFG_VREFINT_OUT_PB0_PB1))
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SYSCFG_flags_definition SYSCFG Flags Definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SYSCFG_FLAG_VREFINT_READY SYSCFG_CFGR3_VREFINT_RDYF
|
|
||||||
|
|
||||||
#define IS_SYSCFG_FLAG(FLAG) ((FLAG) == SYSCFG_FLAG_VREFINT_READY))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup SYSCFG_FastModePlus_GPIO Fast Mode Plus on GPIO
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/** @brief Fast mode Plus driving capability on a specific GPIO
|
|
||||||
*/
|
|
||||||
#if defined (SYSCFG_CFGR2_I2C_PB6_FMP)
|
|
||||||
#define SYSCFG_FASTMODEPLUS_PB6 SYSCFG_CFGR2_I2C_PB6_FMP /* Enable Fast Mode Plus on PB6 */
|
|
||||||
#endif
|
|
||||||
#if defined (SYSCFG_CFGR2_I2C_PB7_FMP)
|
|
||||||
#define SYSCFG_FASTMODEPLUS_PB7 SYSCFG_CFGR2_I2C_PB7_FMP /* Enable Fast Mode Plus on PB7 */
|
|
||||||
#endif
|
|
||||||
#if defined (SYSCFG_CFGR2_I2C_PB8_FMP)
|
|
||||||
#define SYSCFG_FASTMODEPLUS_PB8 SYSCFG_CFGR2_I2C_PB8_FMP /* Enable Fast Mode Plus on PB8 */
|
|
||||||
#endif
|
|
||||||
#if defined (SYSCFG_CFGR2_I2C_PB9_FMP)
|
|
||||||
#define SYSCFG_FASTMODEPLUS_PB9 SYSCFG_CFGR2_I2C_PB9_FMP /* Enable Fast Mode Plus on PB9 */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IS_SYSCFG_FASTMODEPLUS(PIN) ((((PIN) & (SYSCFG_FASTMODEPLUS_PB6)) == SYSCFG_FASTMODEPLUS_PB6) || \
|
|
||||||
(((PIN) & (SYSCFG_FASTMODEPLUS_PB7)) == SYSCFG_FASTMODEPLUS_PB7) || \
|
|
||||||
(((PIN) & (SYSCFG_FASTMODEPLUS_PB8)) == SYSCFG_FASTMODEPLUS_PB8) || \
|
|
||||||
(((PIN) & (SYSCFG_FASTMODEPLUS_PB9)) == SYSCFG_FASTMODEPLUS_PB9) )
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macros -----------------------------------------------------------*/
|
|
||||||
/** @defgroup HAL_Exported_Macros HAL Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief Freeze/Unfreeze Peripherals in Debug mode
|
|
||||||
*/
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_TIM2_STOP)
|
|
||||||
/**
|
|
||||||
* @brief TIM2 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_TIM2() SET_BIT(DBGMCU->APB1FZ,DBGMCU_APB1_FZ_DBG_TIM2_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_TIM2() CLEAR_BIT(DBGMCU->APB1FZ,DBGMCU_APB1_FZ_DBG_TIM2_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_TIM3_STOP)
|
|
||||||
/**
|
|
||||||
* @brief TIM3 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_TIM3() SET_BIT(DBGMCU->APB1FZ,DBGMCU_APB1_FZ_DBG_TIM3_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_TIM3() CLEAR_BIT(DBGMCU->APB1FZ,DBGMCU_APB1_FZ_DBG_TIM3_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_TIM6_STOP)
|
|
||||||
/**
|
|
||||||
* @brief TIM6 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_TIM6() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM6_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_TIM6() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM6_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_TIM7_STOP)
|
|
||||||
/**
|
|
||||||
* @brief TIM7 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_TIM7() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM7_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_TIM7() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM7_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_RTC_STOP)
|
|
||||||
/**
|
|
||||||
* @brief RTC Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_RTC() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_RTC_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_RTC() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_RTC_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_WWDG_STOP)
|
|
||||||
/**
|
|
||||||
* @brief WWDG Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_WWDG() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_WWDG_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_WWDG() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_WWDG_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_IWDG_STOP)
|
|
||||||
/**
|
|
||||||
* @brief IWDG Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_IWDG() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_IWDG_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_IWDG() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_IWDG_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_I2C1_STOP)
|
|
||||||
/**
|
|
||||||
* @brief I2C1 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C1_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT_DBGMCU() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C1_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_I2C2_STOP)
|
|
||||||
/**
|
|
||||||
* @brief I2C2 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT_DBGMCU() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C2_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT_DBGMCU() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C2_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_I2C3_STOP)
|
|
||||||
/**
|
|
||||||
* @brief I2C3 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_I2C3_TIMEOUT() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C3_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_I2C3_TIMEOUT() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C3_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB1_FZ_DBG_LPTIMER_STOP)
|
|
||||||
/**
|
|
||||||
* @brief LPTIMER Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_LPTIMER() SET_BIT(DBGMCU->APB1FZ ,DBGMCU_APB1_FZ_DBG_LPTIMER_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_LPTIMER() CLEAR_BIT(DBGMCU->APB1FZ ,DBGMCU_APB1_FZ_DBG_LPTIMER_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB2_FZ_DBG_TIM22_STOP)
|
|
||||||
/**
|
|
||||||
* @brief TIM22 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_TIM22() SET_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM22_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_TIM22() CLEAR_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM22_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (DBGMCU_APB2_FZ_DBG_TIM21_STOP)
|
|
||||||
/**
|
|
||||||
* @brief TIM21 Peripherals Debug mode
|
|
||||||
*/
|
|
||||||
#define __HAL_DBGMCU_FREEZE_TIM21() SET_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM21_STOP)
|
|
||||||
#define __HAL_DBGMCU_UNFREEZE_TIM21() CLEAR_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM21_STOP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @brief Main Flash memory mapped at 0x00000000
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_REMAPMEMORY_FLASH() CLEAR_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_MEM_MODE)
|
|
||||||
|
|
||||||
/** @brief System Flash memory mapped at 0x00000000
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH() MODIFY_REG(SYSCFG->CFGR1, SYSCFG_CFGR1_MEM_MODE, SYSCFG_CFGR1_MEM_MODE_0)
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Embedded SRAM mapped at 0x00000000
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_REMAPMEMORY_SRAM() MODIFY_REG(SYSCFG->CFGR1, SYSCFG_CFGR1_MEM_MODE, SYSCFG_CFGR1_MEM_MODE_0 | SYSCFG_CFGR1_MEM_MODE_1)
|
|
||||||
|
|
||||||
/** @brief Configuration of the DBG Low Power mode.
|
|
||||||
* @param __DBGLPMODE__ bit field to indicate in wich Low Power mode DBG is still active.
|
|
||||||
* This parameter can be a value of
|
|
||||||
* - DBGMCU_SLEEP
|
|
||||||
* - DBGMCU_STOP
|
|
||||||
* - DBGMCU_STANDBY
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_DBG_LP_CONFIG(__DBGLPMODE__) do {assert_param(IS_DBGMCU_PERIPH(__DBGLPMODE__)); \
|
|
||||||
MODIFY_REG(DBGMCU->CR, DBGMCU_CR_DBG, (__DBGLPMODE__)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#if defined (LCD_BASE) /* STM32L0x3xx only */
|
|
||||||
|
|
||||||
/** @brief Macro to configure the VLCD Decoupling capacitance connection.
|
|
||||||
*
|
|
||||||
* @param __SYSCFG_VLCD_CAPA__ specifies the decoupling of LCD capacitance for rails connection on GPIO.
|
|
||||||
* This parameter can be a combination of following values (when available):
|
|
||||||
* @arg SYSCFG_VLCD_PB2_EXT_CAPA_ON: Connection on PB2
|
|
||||||
* @arg SYSCFG_VLCD_PB12_EXT_CAPA_ON: Connection on PB12
|
|
||||||
* @arg SYSCFG_VLCD_PB0_EXT_CAPA_ON: Connection on PB0
|
|
||||||
* @arg SYSCFG_VLCD_PE11_EXT_CAPA_ON: Connection on PE11
|
|
||||||
* @arg SYSCFG_VLCD_PE12_EXT_CAPA_ON: Connection on PE12
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_VLCD_CAPA_CONFIG(__SYSCFG_VLCD_CAPA__) \
|
|
||||||
MODIFY_REG(SYSCFG->CFGR2, SYSCFG_LCD_EXT_CAPA, (uint32_t)(__SYSCFG_VLCD_CAPA__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the decoupling of LCD capacitance configured by user.
|
|
||||||
* @retval The LCD capacitance connection as configured by user. The returned can be a combination of :
|
|
||||||
* SYSCFG_VLCD_PB2_EXT_CAPA_ON: Connection on PB2
|
|
||||||
* SYSCFG_VLCD_PB12_EXT_CAPA_ON: Connection on PB12
|
|
||||||
* SYSCFG_VLCD_PB0_EXT_CAPA_ON: Connection on PB0
|
|
||||||
* SYSCFG_VLCD_PE11_EXT_CAPA_ON: Connection on PE11
|
|
||||||
* SYSCFG_VLCD_PE12_EXT_CAPA_ON: Connection on PE12
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_GET_VLCD_CAPA_CONFIG() READ_BIT(SYSCFG->CFGR2, SYSCFG_LCD_EXT_CAPA)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the boot mode as configured by user.
|
|
||||||
* @retval The boot mode as configured by user. The returned can be a value of :
|
|
||||||
* - SYSCFG_BOOT_MAINFLASH
|
|
||||||
* - SYSCFG_BOOT_SYSTEMFLASH
|
|
||||||
* - SYSCFG_BOOT_SRAM
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_GET_BOOT_MODE() READ_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_BOOT_MODE)
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Check whether the specified SYSCFG flag is set or not.
|
|
||||||
* @param __FLAG__ specifies the flag to check.
|
|
||||||
* The only parameter supported is SYSCFG_FLAG_VREFINT_READY
|
|
||||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_GET_FLAG(__FLAG__) (((SYSCFG->CFGR3) & (__FLAG__)) == (__FLAG__))
|
|
||||||
|
|
||||||
/** @brief Fast mode Plus driving capability enable macro
|
|
||||||
* @param __FASTMODEPLUS__ This parameter can be a value of :
|
|
||||||
* @arg SYSCFG_FASTMODEPLUS_PB6
|
|
||||||
* @arg SYSCFG_FASTMODEPLUS_PB7
|
|
||||||
* @arg SYSCFG_FASTMODEPLUS_PB8
|
|
||||||
* @arg SYSCFG_FASTMODEPLUS_PB9
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_FASTMODEPLUS_ENABLE(__FASTMODEPLUS__) do {assert_param(IS_SYSCFG_FASTMODEPLUS((__FASTMODEPLUS__))); \
|
|
||||||
SET_BIT(SYSCFG->CFGR2, (__FASTMODEPLUS__)); \
|
|
||||||
}while(0)
|
|
||||||
/** @brief Fast mode Plus driving capability disable macro
|
|
||||||
* @param __FASTMODEPLUS__ This parameter can be a value of :
|
|
||||||
* @arg SYSCFG_FASTMODEPLUS_PB6
|
|
||||||
* @arg SYSCFG_FASTMODEPLUS_PB7
|
|
||||||
* @arg SYSCFG_FASTMODEPLUS_PB8
|
|
||||||
* @arg SYSCFG_FASTMODEPLUS_PB9
|
|
||||||
*/
|
|
||||||
#define __HAL_SYSCFG_FASTMODEPLUS_DISABLE(__FASTMODEPLUS__) do {assert_param(IS_SYSCFG_FASTMODEPLUS((__FASTMODEPLUS__))); \
|
|
||||||
CLEAR_BIT(SYSCFG->CFGR2, (__FASTMODEPLUS__)); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_Private_Macros HAL Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ) || \
|
|
||||||
((FREQ) == HAL_TICK_FREQ_100HZ) || \
|
|
||||||
((FREQ) == HAL_TICK_FREQ_1KHZ))
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported variables --------------------------------------------------------*/
|
|
||||||
/** @defgroup HAL_Exported_Variables HAL Exported Variables
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
extern __IO uint32_t uwTick;
|
|
||||||
extern uint32_t uwTickPrio;
|
|
||||||
extern HAL_TickFreqTypeDef uwTickFreq;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @defgroup HAL_Exported_Functions HAL Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
||||||
* @brief Initialization and de-initialization functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_Init(void);
|
|
||||||
HAL_StatusTypeDef HAL_DeInit(void);
|
|
||||||
void HAL_MspInit(void);
|
|
||||||
void HAL_MspDeInit(void);
|
|
||||||
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_Exported_Functions_Group2 Peripheral Control functions
|
|
||||||
* @brief Peripheral Control functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
void HAL_IncTick(void);
|
|
||||||
void HAL_Delay(uint32_t Delay);
|
|
||||||
uint32_t HAL_GetTick(void);
|
|
||||||
uint32_t HAL_GetTickPrio(void);
|
|
||||||
HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq);
|
|
||||||
HAL_TickFreqTypeDef HAL_GetTickFreq(void);
|
|
||||||
void HAL_SuspendTick(void);
|
|
||||||
void HAL_ResumeTick(void);
|
|
||||||
uint32_t HAL_GetHalVersion(void);
|
|
||||||
uint32_t HAL_GetREVID(void);
|
|
||||||
uint32_t HAL_GetDEVID(void);
|
|
||||||
uint32_t HAL_GetUIDw0(void);
|
|
||||||
uint32_t HAL_GetUIDw1(void);
|
|
||||||
uint32_t HAL_GetUIDw2(void);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_Exported_Functions_Group3 DBGMCU Peripheral Control functions
|
|
||||||
* @brief DBGMCU Peripheral Control functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_EnableDBGSleepMode(void);
|
|
||||||
void HAL_DBGMCU_DisableDBGSleepMode(void);
|
|
||||||
void HAL_DBGMCU_EnableDBGStopMode(void);
|
|
||||||
void HAL_DBGMCU_DisableDBGStopMode(void);
|
|
||||||
void HAL_DBGMCU_EnableDBGStandbyMode(void);
|
|
||||||
void HAL_DBGMCU_DisableDBGStandbyMode(void);
|
|
||||||
void HAL_DBGMCU_DBG_EnableLowPowerConfig(uint32_t Periph);
|
|
||||||
void HAL_DBGMCU_DBG_DisableLowPowerConfig(uint32_t Periph);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_Exported_Functions_Group4 SYSCFG Peripheral Control functions
|
|
||||||
* @brief SYSCFG Peripheral Control functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
uint32_t HAL_SYSCFG_GetBootMode(void);
|
|
||||||
void HAL_SYSCFG_Enable_Lock_VREFINT(void);
|
|
||||||
void HAL_SYSCFG_Disable_Lock_VREFINT(void);
|
|
||||||
void HAL_SYSCFG_VREFINT_OutputSelect(uint32_t SYSCFG_Vrefint_OUTPUT);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define the private group ***********************************/
|
|
||||||
/**************************************************************/
|
|
||||||
/** @defgroup HAL_Private HAL Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_HAL_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
@ -1,365 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_cortex.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of CORTEX HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_CORTEX_H
|
|
||||||
#define __STM32L0xx_HAL_CORTEX_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX CORTEX
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_Exported_Types CORTEX Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if (__MPU_PRESENT == 1)
|
|
||||||
/** @defgroup CORTEX_MPU_Region_Initialization_Structure_definition MPU Region Initialization Structure Definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t BaseAddress; /*!< Specifies the base address of the region to protect. */
|
|
||||||
|
|
||||||
uint8_t Enable; /*!< Specifies the status of the region.
|
|
||||||
This parameter can be a value of @ref CORTEX_MPU_Region_Enable */
|
|
||||||
uint8_t Number; /*!< Specifies the number of the region to protect.
|
|
||||||
This parameter can be a value of @ref CORTEX_MPU_Region_Number */
|
|
||||||
|
|
||||||
uint8_t Size; /*!< Specifies the size of the region to protect.
|
|
||||||
This parameter can be a value of @ref CORTEX_MPU_Region_Size */
|
|
||||||
uint8_t SubRegionDisable; /*!< Specifies the number of the subregion protection to disable.
|
|
||||||
This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */
|
|
||||||
uint8_t TypeExtField; /*!< This parameter is NOT used but is kept to keep API unified through all families*/
|
|
||||||
|
|
||||||
uint8_t AccessPermission; /*!< Specifies the region access permission type.
|
|
||||||
This parameter can be a value of @ref CORTEX_MPU_Region_Permission_Attributes */
|
|
||||||
uint8_t DisableExec; /*!< Specifies the instruction access status.
|
|
||||||
This parameter can be a value of @ref CORTEX_MPU_Instruction_Access */
|
|
||||||
uint8_t IsShareable; /*!< Specifies the shareability status of the protected region.
|
|
||||||
This parameter can be a value of @ref CORTEX_MPU_Access_Shareable */
|
|
||||||
uint8_t IsCacheable; /*!< Specifies the cacheable status of the region protected.
|
|
||||||
This parameter can be a value of @ref CORTEX_MPU_Access_Cacheable */
|
|
||||||
uint8_t IsBufferable; /*!< Specifies the bufferable status of the protected region.
|
|
||||||
This parameter can be a value of @ref CORTEX_MPU_Access_Bufferable */
|
|
||||||
}MPU_Region_InitTypeDef;
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* __MPU_PRESENT */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_Exported_Constants CORTEx Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define IS_NVIC_PREEMPTION_PRIORITY(__PRIORITY__) ((__PRIORITY__) < 0x10U)
|
|
||||||
|
|
||||||
#define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= 0x0)
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick Clock Source
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SYSTICK_CLKSOURCE_HCLK_DIV8 (0x00000000U)
|
|
||||||
#define SYSTICK_CLKSOURCE_HCLK (0x00000004U)
|
|
||||||
#define IS_SYSTICK_CLK_SOURCE(__SOURCE__) (((__SOURCE__) == SYSTICK_CLKSOURCE_HCLK) || \
|
|
||||||
((__SOURCE__) == SYSTICK_CLKSOURCE_HCLK_DIV8))
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if (__MPU_PRESENT == 1)
|
|
||||||
/** @defgroup CORTEX_MPU_HFNMI_PRIVDEF_Control CORTEX MPU HFNMI and PRIVILEGED Access control
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_HFNMI_PRIVDEF_NONE (0x00000000U)
|
|
||||||
#define MPU_HARDFAULT_NMI (0x00000002U)
|
|
||||||
#define MPU_PRIVILEGED_DEFAULT (0x00000004U)
|
|
||||||
#define MPU_HFNMI_PRIVDEF (0x00000006U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_MPU_Region_Enable CORTEX MPU Region Enable
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_REGION_ENABLE ((uint8_t)0x01)
|
|
||||||
#define MPU_REGION_DISABLE ((uint8_t)0x00)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_MPU_Instruction_Access CORTEX MPU Instruction Access
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_INSTRUCTION_ACCESS_ENABLE ((uint8_t)0x00)
|
|
||||||
#define MPU_INSTRUCTION_ACCESS_DISABLE ((uint8_t)0x01)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_MPU_Access_Shareable CORTEX MPU Instruction Access Shareable
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_ACCESS_SHAREABLE ((uint8_t)0x01)
|
|
||||||
#define MPU_ACCESS_NOT_SHAREABLE ((uint8_t)0x00)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_MPU_Access_Cacheable CORTEX MPU Instruction Access Cacheable
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_ACCESS_CACHEABLE ((uint8_t)0x01)
|
|
||||||
#define MPU_ACCESS_NOT_CACHEABLE ((uint8_t)0x00)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_MPU_Access_Bufferable CORTEX MPU Instruction Access Bufferable
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_ACCESS_BUFFERABLE ((uint8_t)0x01)
|
|
||||||
#define MPU_ACCESS_NOT_BUFFERABLE ((uint8_t)0x00)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_MPU_Region_Size CORTEX MPU Region Size
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_REGION_SIZE_32B ((uint8_t)0x04)
|
|
||||||
#define MPU_REGION_SIZE_64B ((uint8_t)0x05)
|
|
||||||
#define MPU_REGION_SIZE_128B ((uint8_t)0x06)
|
|
||||||
#define MPU_REGION_SIZE_256B ((uint8_t)0x07)
|
|
||||||
#define MPU_REGION_SIZE_512B ((uint8_t)0x08)
|
|
||||||
#define MPU_REGION_SIZE_1KB ((uint8_t)0x09)
|
|
||||||
#define MPU_REGION_SIZE_2KB ((uint8_t)0x0A)
|
|
||||||
#define MPU_REGION_SIZE_4KB ((uint8_t)0x0B)
|
|
||||||
#define MPU_REGION_SIZE_8KB ((uint8_t)0x0C)
|
|
||||||
#define MPU_REGION_SIZE_16KB ((uint8_t)0x0D)
|
|
||||||
#define MPU_REGION_SIZE_32KB ((uint8_t)0x0E)
|
|
||||||
#define MPU_REGION_SIZE_64KB ((uint8_t)0x0F)
|
|
||||||
#define MPU_REGION_SIZE_128KB ((uint8_t)0x10)
|
|
||||||
#define MPU_REGION_SIZE_256KB ((uint8_t)0x11)
|
|
||||||
#define MPU_REGION_SIZE_512KB ((uint8_t)0x12)
|
|
||||||
#define MPU_REGION_SIZE_1MB ((uint8_t)0x13)
|
|
||||||
#define MPU_REGION_SIZE_2MB ((uint8_t)0x14)
|
|
||||||
#define MPU_REGION_SIZE_4MB ((uint8_t)0x15)
|
|
||||||
#define MPU_REGION_SIZE_8MB ((uint8_t)0x16)
|
|
||||||
#define MPU_REGION_SIZE_16MB ((uint8_t)0x17)
|
|
||||||
#define MPU_REGION_SIZE_32MB ((uint8_t)0x18)
|
|
||||||
#define MPU_REGION_SIZE_64MB ((uint8_t)0x19)
|
|
||||||
#define MPU_REGION_SIZE_128MB ((uint8_t)0x1A)
|
|
||||||
#define MPU_REGION_SIZE_256MB ((uint8_t)0x1B)
|
|
||||||
#define MPU_REGION_SIZE_512MB ((uint8_t)0x1C)
|
|
||||||
#define MPU_REGION_SIZE_1GB ((uint8_t)0x1D)
|
|
||||||
#define MPU_REGION_SIZE_2GB ((uint8_t)0x1E)
|
|
||||||
#define MPU_REGION_SIZE_4GB ((uint8_t)0x1F)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_MPU_Region_Permission_Attributes CORTEX MPU Region Permission Attributes
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_REGION_NO_ACCESS ((uint8_t)0x00)
|
|
||||||
#define MPU_REGION_PRIV_RW ((uint8_t)0x01)
|
|
||||||
#define MPU_REGION_PRIV_RW_URO ((uint8_t)0x02)
|
|
||||||
#define MPU_REGION_FULL_ACCESS ((uint8_t)0x03)
|
|
||||||
#define MPU_REGION_PRIV_RO ((uint8_t)0x05)
|
|
||||||
#define MPU_REGION_PRIV_RO_URO ((uint8_t)0x06)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_MPU_Region_Number CORTEX MPU Region Number
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define MPU_REGION_NUMBER0 ((uint8_t)0x00)
|
|
||||||
#define MPU_REGION_NUMBER1 ((uint8_t)0x01)
|
|
||||||
#define MPU_REGION_NUMBER2 ((uint8_t)0x02)
|
|
||||||
#define MPU_REGION_NUMBER3 ((uint8_t)0x03)
|
|
||||||
#define MPU_REGION_NUMBER4 ((uint8_t)0x04)
|
|
||||||
#define MPU_REGION_NUMBER5 ((uint8_t)0x05)
|
|
||||||
#define MPU_REGION_NUMBER6 ((uint8_t)0x06)
|
|
||||||
#define MPU_REGION_NUMBER7 ((uint8_t)0x07)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* __MPU_PRESENT */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @defgroup CORTEX_Exported_Functions CORTEX Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_Exported_Functions_Group1 Initialization and Configuration functions
|
|
||||||
* @brief Initialization and Configuration functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority);
|
|
||||||
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn);
|
|
||||||
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn);
|
|
||||||
void HAL_NVIC_SystemReset(void);
|
|
||||||
uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup CORTEX_Exported_Functions_Group2 Peripheral Control functions
|
|
||||||
* @brief Cortex control functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint32_t HAL_NVIC_GetPriority(IRQn_Type IRQn);
|
|
||||||
uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn);
|
|
||||||
void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn);
|
|
||||||
void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn);
|
|
||||||
void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource);
|
|
||||||
void HAL_SYSTICK_IRQHandler(void);
|
|
||||||
void HAL_SYSTICK_Callback(void);
|
|
||||||
#if (__MPU_PRESENT == 1U)
|
|
||||||
void HAL_MPU_Enable(uint32_t MPU_Control);
|
|
||||||
void HAL_MPU_Disable(void);
|
|
||||||
void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init);
|
|
||||||
#endif /* __MPU_PRESENT */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private types -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup CORTEX_Private_Macros CORTEX Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if (__MPU_PRESENT == 1)
|
|
||||||
#define IS_MPU_REGION_ENABLE(STATE) (((STATE) == MPU_REGION_ENABLE) || \
|
|
||||||
((STATE) == MPU_REGION_DISABLE))
|
|
||||||
|
|
||||||
#define IS_MPU_INSTRUCTION_ACCESS(STATE) (((STATE) == MPU_INSTRUCTION_ACCESS_ENABLE) || \
|
|
||||||
((STATE) == MPU_INSTRUCTION_ACCESS_DISABLE))
|
|
||||||
|
|
||||||
#define IS_MPU_ACCESS_SHAREABLE(STATE) (((STATE) == MPU_ACCESS_SHAREABLE) || \
|
|
||||||
((STATE) == MPU_ACCESS_NOT_SHAREABLE))
|
|
||||||
|
|
||||||
#define IS_MPU_ACCESS_CACHEABLE(STATE) (((STATE) == MPU_ACCESS_CACHEABLE) || \
|
|
||||||
((STATE) == MPU_ACCESS_NOT_CACHEABLE))
|
|
||||||
|
|
||||||
#define IS_MPU_ACCESS_BUFFERABLE(STATE) (((STATE) == MPU_ACCESS_BUFFERABLE) || \
|
|
||||||
((STATE) == MPU_ACCESS_NOT_BUFFERABLE))
|
|
||||||
|
|
||||||
#define IS_MPU_REGION_PERMISSION_ATTRIBUTE(TYPE) (((TYPE) == MPU_REGION_NO_ACCESS) || \
|
|
||||||
((TYPE) == MPU_REGION_PRIV_RW) || \
|
|
||||||
((TYPE) == MPU_REGION_PRIV_RW_URO) || \
|
|
||||||
((TYPE) == MPU_REGION_FULL_ACCESS) || \
|
|
||||||
((TYPE) == MPU_REGION_PRIV_RO) || \
|
|
||||||
((TYPE) == MPU_REGION_PRIV_RO_URO))
|
|
||||||
|
|
||||||
#define IS_MPU_REGION_NUMBER(NUMBER) (((NUMBER) == MPU_REGION_NUMBER0) || \
|
|
||||||
((NUMBER) == MPU_REGION_NUMBER1) || \
|
|
||||||
((NUMBER) == MPU_REGION_NUMBER2) || \
|
|
||||||
((NUMBER) == MPU_REGION_NUMBER3) || \
|
|
||||||
((NUMBER) == MPU_REGION_NUMBER4) || \
|
|
||||||
((NUMBER) == MPU_REGION_NUMBER5) || \
|
|
||||||
((NUMBER) == MPU_REGION_NUMBER6) || \
|
|
||||||
((NUMBER) == MPU_REGION_NUMBER7))
|
|
||||||
|
|
||||||
#define IS_MPU_REGION_SIZE(SIZE) (((SIZE) == MPU_REGION_SIZE_256B) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_512B) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_1KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_2KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_4KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_8KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_16KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_32KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_64KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_128KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_256KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_512KB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_1MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_2MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_4MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_8MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_16MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_32MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_64MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_128MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_256MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_512MB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_1GB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_2GB) || \
|
|
||||||
((SIZE) == MPU_REGION_SIZE_4GB))
|
|
||||||
|
|
||||||
#define IS_MPU_SUB_REGION_DISABLE(SUBREGION) ((SUBREGION) < (uint16_t)0x00FFU)
|
|
||||||
#endif /* __MPU_PRESENT */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_HAL_CORTEX_H */
|
|
||||||
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
@ -1,204 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_def.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief This file contains HAL common defines, enumeration, macros and
|
|
||||||
* structures definitions.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_DEF
|
|
||||||
#define __STM32L0xx_HAL_DEF
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx.h"
|
|
||||||
#include "Legacy/stm32_hal_legacy.h"
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL Status structures definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_OK = 0x00U,
|
|
||||||
HAL_ERROR = 0x01U,
|
|
||||||
HAL_BUSY = 0x02U,
|
|
||||||
HAL_TIMEOUT = 0x03U
|
|
||||||
} HAL_StatusTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL Lock structures definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_UNLOCKED = 0x00U,
|
|
||||||
HAL_LOCKED = 0x01U
|
|
||||||
} HAL_LockTypeDef;
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
|
|
||||||
|
|
||||||
#define HAL_MAX_DELAY 0xFFFFFFFFU
|
|
||||||
|
|
||||||
#define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
|
|
||||||
#define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
|
|
||||||
|
|
||||||
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
|
|
||||||
do{ \
|
|
||||||
(__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
|
|
||||||
(__DMA_HANDLE__).Parent = (__HANDLE__); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
/** @brief Reset the Handle's State field.
|
|
||||||
* @param __HANDLE__: specifies the Peripheral Handle.
|
|
||||||
* @note This macro can be used for the following purpose:
|
|
||||||
* - When the Handle is declared as local variable; before passing it as parameter
|
|
||||||
* to HAL_PPP_Init() for the first time, it is mandatory to use this macro
|
|
||||||
* to set to 0 the Handle's "State" field.
|
|
||||||
* Otherwise, "State" field may have any random value and the first time the function
|
|
||||||
* HAL_PPP_Init() is called, the low level hardware initialization will be missed
|
|
||||||
* (i.e. HAL_PPP_MspInit() will not be executed).
|
|
||||||
* - When there is a need to reconfigure the low level hardware: instead of calling
|
|
||||||
* HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
|
|
||||||
* In this later function, when the Handle's "State" field is set to 0, it will execute the function
|
|
||||||
* HAL_PPP_MspInit() which will reconfigure the low level hardware.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
|
|
||||||
|
|
||||||
#if (USE_RTOS == 1)
|
|
||||||
|
|
||||||
/* Reserved for future use */
|
|
||||||
#error "USE_RTOS should be 0 in the current HAL release"
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define __HAL_LOCK(__HANDLE__) \
|
|
||||||
do{ \
|
|
||||||
if((__HANDLE__)->Lock == HAL_LOCKED) \
|
|
||||||
{ \
|
|
||||||
return HAL_BUSY; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
(__HANDLE__)->Lock = HAL_LOCKED; \
|
|
||||||
} \
|
|
||||||
}while (0)
|
|
||||||
|
|
||||||
#define __HAL_UNLOCK(__HANDLE__) \
|
|
||||||
do{ \
|
|
||||||
(__HANDLE__)->Lock = HAL_UNLOCKED; \
|
|
||||||
}while (0)
|
|
||||||
#endif /* USE_RTOS */
|
|
||||||
|
|
||||||
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
|
|
||||||
#ifndef __weak
|
|
||||||
#define __weak __attribute__((weak))
|
|
||||||
#endif
|
|
||||||
#ifndef __packed
|
|
||||||
#define __packed __attribute__((packed))
|
|
||||||
#endif
|
|
||||||
#elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
|
|
||||||
#ifndef __weak
|
|
||||||
#define __weak __attribute__((weak))
|
|
||||||
#endif /* __weak */
|
|
||||||
#ifndef __packed
|
|
||||||
#define __packed __attribute__((__packed__))
|
|
||||||
#endif /* __packed */
|
|
||||||
|
|
||||||
#define __NOINLINE __attribute__ ( (noinline) )
|
|
||||||
|
|
||||||
#endif /* __GNUC__ */
|
|
||||||
|
|
||||||
|
|
||||||
/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
|
|
||||||
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
|
|
||||||
#ifndef __ALIGN_BEGIN
|
|
||||||
#define __ALIGN_BEGIN
|
|
||||||
#endif
|
|
||||||
#ifndef __ALIGN_END
|
|
||||||
#define __ALIGN_END __attribute__ ((aligned (4)))
|
|
||||||
#endif
|
|
||||||
#elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
|
|
||||||
#ifndef __ALIGN_END
|
|
||||||
#define __ALIGN_END __attribute__ ((aligned (4)))
|
|
||||||
#endif /* __ALIGN_END */
|
|
||||||
#ifndef __ALIGN_BEGIN
|
|
||||||
#define __ALIGN_BEGIN
|
|
||||||
#endif /* __ALIGN_BEGIN */
|
|
||||||
#else
|
|
||||||
#ifndef __ALIGN_END
|
|
||||||
#define __ALIGN_END
|
|
||||||
#endif /* __ALIGN_END */
|
|
||||||
#ifndef __ALIGN_BEGIN
|
|
||||||
#if defined (__CC_ARM) /* ARM Compiler V5*/
|
|
||||||
#define __ALIGN_BEGIN __align(4)
|
|
||||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
|
||||||
#define __ALIGN_BEGIN
|
|
||||||
#endif /* __CC_ARM */
|
|
||||||
#endif /* __ALIGN_BEGIN */
|
|
||||||
#endif /* __GNUC__ */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief __RAM_FUNC definition
|
|
||||||
*/
|
|
||||||
#if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
|
||||||
/* ARM Compiler V4/V5 and V6
|
|
||||||
--------------------------
|
|
||||||
RAM functions are defined using the toolchain options.
|
|
||||||
Functions that are executed in RAM should reside in a separate source module.
|
|
||||||
Using the 'Options for File' dialog you can simply change the 'Code / Const'
|
|
||||||
area of a module to a memory space in physical RAM.
|
|
||||||
Available memory areas are declared in the 'Target' tab of the 'Options for Target'
|
|
||||||
dialog.
|
|
||||||
*/
|
|
||||||
#define __RAM_FUNC
|
|
||||||
|
|
||||||
#define __NOINLINE __attribute__ ( (noinline) )
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined ( __ICCARM__ )
|
|
||||||
/* ICCARM Compiler
|
|
||||||
---------------
|
|
||||||
RAM functions are defined using a specific toolchain keyword "__ramfunc".
|
|
||||||
*/
|
|
||||||
#define __RAM_FUNC __ramfunc
|
|
||||||
|
|
||||||
#define __NOINLINE _Pragma("optimize = no_inline")
|
|
||||||
|
|
||||||
#elif defined ( __GNUC__ )
|
|
||||||
/* GNU Compiler
|
|
||||||
------------
|
|
||||||
RAM functions are defined using a specific toolchain attribute
|
|
||||||
"__attribute__((section(".RamFunc")))".
|
|
||||||
*/
|
|
||||||
#define __RAM_FUNC __attribute__((section(".RamFunc")))
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ___STM32L0xx_HAL_DEF */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
@ -1,675 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_dma.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of DMA HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef STM32L0xx_HAL_DMA_H
|
|
||||||
#define STM32L0xx_HAL_DMA_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup DMA
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/** @defgroup DMA_Exported_Types DMA Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief DMA Configuration Structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t Request; /*!< Specifies the request selected for the specified channel.
|
|
||||||
This parameter can be a value of @ref DMA_request */
|
|
||||||
|
|
||||||
uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral,
|
|
||||||
from memory to memory or from peripheral to memory.
|
|
||||||
This parameter can be a value of @ref DMA_Data_transfer_direction */
|
|
||||||
|
|
||||||
uint32_t PeriphInc; /*!< Specifies whether the Peripheral address register should be incremented or not.
|
|
||||||
This parameter can be a value of @ref DMA_Peripheral_incremented_mode */
|
|
||||||
|
|
||||||
uint32_t MemInc; /*!< Specifies whether the memory address register should be incremented or not.
|
|
||||||
This parameter can be a value of @ref DMA_Memory_incremented_mode */
|
|
||||||
|
|
||||||
uint32_t PeriphDataAlignment; /*!< Specifies the Peripheral data width.
|
|
||||||
This parameter can be a value of @ref DMA_Peripheral_data_size */
|
|
||||||
|
|
||||||
uint32_t MemDataAlignment; /*!< Specifies the Memory data width.
|
|
||||||
This parameter can be a value of @ref DMA_Memory_data_size */
|
|
||||||
|
|
||||||
uint32_t Mode; /*!< Specifies the operation mode of the DMAy Channelx.
|
|
||||||
This parameter can be a value of @ref DMA_mode
|
|
||||||
@note The circular buffer mode cannot be used if the memory-to-memory
|
|
||||||
data transfer is configured on the selected Channel */
|
|
||||||
|
|
||||||
uint32_t Priority; /*!< Specifies the software priority for the DMAy Channelx.
|
|
||||||
This parameter can be a value of @ref DMA_Priority_level */
|
|
||||||
} DMA_InitTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL DMA State structures definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_DMA_STATE_RESET = 0x00U, /*!< DMA not yet initialized or disabled */
|
|
||||||
HAL_DMA_STATE_READY = 0x01U, /*!< DMA initialized and ready for use */
|
|
||||||
HAL_DMA_STATE_BUSY = 0x02U, /*!< DMA process is ongoing */
|
|
||||||
HAL_DMA_STATE_TIMEOUT = 0x03U, /*!< DMA timeout state */
|
|
||||||
}HAL_DMA_StateTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL DMA Error Code structure definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_DMA_FULL_TRANSFER = 0x00U, /*!< Full transfer */
|
|
||||||
HAL_DMA_HALF_TRANSFER = 0x01U /*!< Half Transfer */
|
|
||||||
}HAL_DMA_LevelCompleteTypeDef;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL DMA Callback ID structure definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_DMA_XFER_CPLT_CB_ID = 0x00U, /*!< Full transfer */
|
|
||||||
HAL_DMA_XFER_HALFCPLT_CB_ID = 0x01U, /*!< Half transfer */
|
|
||||||
HAL_DMA_XFER_ERROR_CB_ID = 0x02U, /*!< Error */
|
|
||||||
HAL_DMA_XFER_ABORT_CB_ID = 0x03U, /*!< Abort */
|
|
||||||
HAL_DMA_XFER_ALL_CB_ID = 0x04U /*!< All */
|
|
||||||
}HAL_DMA_CallbackIDTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief DMA handle Structure definition
|
|
||||||
*/
|
|
||||||
typedef struct __DMA_HandleTypeDef
|
|
||||||
{
|
|
||||||
DMA_Channel_TypeDef *Instance; /*!< Register base address */
|
|
||||||
|
|
||||||
DMA_InitTypeDef Init; /*!< DMA communication parameters */
|
|
||||||
|
|
||||||
HAL_LockTypeDef Lock; /*!< DMA locking object */
|
|
||||||
|
|
||||||
__IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
|
|
||||||
|
|
||||||
void *Parent; /*!< Parent object state */
|
|
||||||
|
|
||||||
void (* XferCpltCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete callback */
|
|
||||||
|
|
||||||
void (* XferHalfCpltCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback */
|
|
||||||
|
|
||||||
void (* XferErrorCallback)(struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */
|
|
||||||
|
|
||||||
void (* XferAbortCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer abort callback */
|
|
||||||
|
|
||||||
__IO uint32_t ErrorCode; /*!< DMA Error code */
|
|
||||||
|
|
||||||
DMA_TypeDef *DmaBaseAddress; /*!< DMA Channel Base Address */
|
|
||||||
|
|
||||||
uint32_t ChannelIndex; /*!< DMA Channel Index */
|
|
||||||
|
|
||||||
}DMA_HandleTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Exported_Constants DMA Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Error_Code DMA Error Code
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define HAL_DMA_ERROR_NONE 0x00000000U /*!< No error */
|
|
||||||
#define HAL_DMA_ERROR_TE 0x00000001U /*!< Transfer error */
|
|
||||||
#define HAL_DMA_ERROR_NO_XFER 0x00000004U /*!< Abort requested with no Xfer ongoing */
|
|
||||||
#define HAL_DMA_ERROR_TIMEOUT 0x00000020U /*!< Timeout error */
|
|
||||||
#define HAL_DMA_ERROR_NOT_SUPPORTED 0x00000100U /*!< Not supported mode */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_request DMA request
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (STM32L010x4) || defined (STM32L010x6) || defined (STM32L010x8) || defined (STM32L010xC)
|
|
||||||
|
|
||||||
#define DMA_REQUEST_0 0U
|
|
||||||
#define DMA_REQUEST_1 1U
|
|
||||||
#define DMA_REQUEST_4 4U
|
|
||||||
#define DMA_REQUEST_5 5U
|
|
||||||
#define DMA_REQUEST_6 6U
|
|
||||||
#define DMA_REQUEST_8 8U
|
|
||||||
|
|
||||||
#define IS_DMA_ALL_REQUEST(REQUEST) (((REQUEST) == DMA_REQUEST_0) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_1) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_4) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_5) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_6) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_8))
|
|
||||||
|
|
||||||
/* STM32L010x4 || STM32L010x6 || STM32L010x8 || STM32L010xC */
|
|
||||||
|
|
||||||
#elif defined (STM32L021xx) || defined (STM32L041xx) || defined (STM32L062xx) || defined (STM32L063xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
|
|
||||||
|
|
||||||
#define DMA_REQUEST_0 0U
|
|
||||||
#define DMA_REQUEST_1 1U
|
|
||||||
#define DMA_REQUEST_2 2U
|
|
||||||
#define DMA_REQUEST_3 3U
|
|
||||||
#define DMA_REQUEST_4 4U
|
|
||||||
#define DMA_REQUEST_5 5U
|
|
||||||
#define DMA_REQUEST_6 6U
|
|
||||||
#define DMA_REQUEST_7 7U
|
|
||||||
#define DMA_REQUEST_8 8U
|
|
||||||
#define DMA_REQUEST_9 9U
|
|
||||||
#define DMA_REQUEST_10 10U
|
|
||||||
#define DMA_REQUEST_11 11U /* AES product only */
|
|
||||||
#define DMA_REQUEST_12 12U
|
|
||||||
#define DMA_REQUEST_13 13U
|
|
||||||
#define DMA_REQUEST_14 14U
|
|
||||||
#define DMA_REQUEST_15 15U
|
|
||||||
|
|
||||||
#define IS_DMA_ALL_REQUEST(REQUEST) (((REQUEST) == DMA_REQUEST_0) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_1) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_2) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_3) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_4) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_5) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_6) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_7) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_8) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_9) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_10) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_11) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_12) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_13) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_14) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_15))
|
|
||||||
|
|
||||||
/* (STM32L021xx) || (STM32L041xx) || (STM32L062xx) || (STM32L063xx) || (STM32L081xx) || (STM32L082xx) || (STM32L083xx) */
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define DMA_REQUEST_0 0U
|
|
||||||
#define DMA_REQUEST_1 1U
|
|
||||||
#define DMA_REQUEST_2 2U
|
|
||||||
#define DMA_REQUEST_3 3U
|
|
||||||
#define DMA_REQUEST_4 4U
|
|
||||||
#define DMA_REQUEST_5 5U
|
|
||||||
#define DMA_REQUEST_6 6U
|
|
||||||
#define DMA_REQUEST_7 7U
|
|
||||||
#define DMA_REQUEST_8 8U
|
|
||||||
#define DMA_REQUEST_9 9U
|
|
||||||
#define DMA_REQUEST_10 10U
|
|
||||||
#define DMA_REQUEST_12 12U
|
|
||||||
#define DMA_REQUEST_13 13U
|
|
||||||
#define DMA_REQUEST_14 14U
|
|
||||||
#define DMA_REQUEST_15 15U
|
|
||||||
|
|
||||||
#define IS_DMA_ALL_REQUEST(REQUEST) (((REQUEST) == DMA_REQUEST_0) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_1) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_2) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_3) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_4) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_5) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_6) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_7) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_8) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_9) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_10) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_12) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_13) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_14) || \
|
|
||||||
((REQUEST) == DMA_REQUEST_15))
|
|
||||||
|
|
||||||
#endif /* (STM32L031xx) || (STM32L051xx) || (STM32L052xx) || (STM32L053xx) || (STM32L071xx) || (STM32L072xx) || (STM32L073xx) */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Data_transfer_direction DMA Data transfer direction
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_PERIPH_TO_MEMORY 0x00000000U /*!< Peripheral to memory direction */
|
|
||||||
#define DMA_MEMORY_TO_PERIPH DMA_CCR_DIR /*!< Memory to peripheral direction */
|
|
||||||
#define DMA_MEMORY_TO_MEMORY DMA_CCR_MEM2MEM /*!< Memory to memory direction */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Peripheral_incremented_mode DMA Peripheral incremented mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_PINC_ENABLE DMA_CCR_PINC /*!< Peripheral increment mode Enable */
|
|
||||||
#define DMA_PINC_DISABLE 0x00000000U /*!< Peripheral increment mode Disable */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Memory_incremented_mode DMA Memory incremented mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_MINC_ENABLE DMA_CCR_MINC /*!< Memory increment mode Enable */
|
|
||||||
#define DMA_MINC_DISABLE 0x00000000U /*!< Memory increment mode Disable */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Peripheral_data_size DMA Peripheral data size
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_PDATAALIGN_BYTE 0x00000000U /*!< Peripheral data alignment : Byte */
|
|
||||||
#define DMA_PDATAALIGN_HALFWORD DMA_CCR_PSIZE_0 /*!< Peripheral data alignment : HalfWord */
|
|
||||||
#define DMA_PDATAALIGN_WORD DMA_CCR_PSIZE_1 /*!< Peripheral data alignment : Word */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Memory_data_size DMA Memory data size
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_MDATAALIGN_BYTE 0x00000000U /*!< Memory data alignment : Byte */
|
|
||||||
#define DMA_MDATAALIGN_HALFWORD DMA_CCR_MSIZE_0 /*!< Memory data alignment : HalfWord */
|
|
||||||
#define DMA_MDATAALIGN_WORD DMA_CCR_MSIZE_1 /*!< Memory data alignment : Word */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_mode DMA mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_NORMAL 0x00000000U /*!< Normal mode */
|
|
||||||
#define DMA_CIRCULAR DMA_CCR_CIRC /*!< Circular mode */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Priority_level DMA Priority level
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_PRIORITY_LOW 0x00000000U /*!< Priority level : Low */
|
|
||||||
#define DMA_PRIORITY_MEDIUM DMA_CCR_PL_0 /*!< Priority level : Medium */
|
|
||||||
#define DMA_PRIORITY_HIGH DMA_CCR_PL_1 /*!< Priority level : High */
|
|
||||||
#define DMA_PRIORITY_VERY_HIGH DMA_CCR_PL /*!< Priority level : Very_High */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup DMA_interrupt_enable_definitions DMA interrupt enable definitions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_IT_TC DMA_CCR_TCIE
|
|
||||||
#define DMA_IT_HT DMA_CCR_HTIE
|
|
||||||
#define DMA_IT_TE DMA_CCR_TEIE
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_flag_definitions DMA flag definitions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define DMA_FLAG_GL1 DMA_ISR_GIF1
|
|
||||||
#define DMA_FLAG_TC1 DMA_ISR_TCIF1
|
|
||||||
#define DMA_FLAG_HT1 DMA_ISR_HTIF1
|
|
||||||
#define DMA_FLAG_TE1 DMA_ISR_TEIF1
|
|
||||||
#define DMA_FLAG_GL2 DMA_ISR_GIF2
|
|
||||||
#define DMA_FLAG_TC2 DMA_ISR_TCIF2
|
|
||||||
#define DMA_FLAG_HT2 DMA_ISR_HTIF2
|
|
||||||
#define DMA_FLAG_TE2 DMA_ISR_TEIF2
|
|
||||||
#define DMA_FLAG_GL3 DMA_ISR_GIF3
|
|
||||||
#define DMA_FLAG_TC3 DMA_ISR_TCIF3
|
|
||||||
#define DMA_FLAG_HT3 DMA_ISR_HTIF3
|
|
||||||
#define DMA_FLAG_TE3 DMA_ISR_TEIF3
|
|
||||||
#define DMA_FLAG_GL4 DMA_ISR_GIF4
|
|
||||||
#define DMA_FLAG_TC4 DMA_ISR_TCIF4
|
|
||||||
#define DMA_FLAG_HT4 DMA_ISR_HTIF4
|
|
||||||
#define DMA_FLAG_TE4 DMA_ISR_TEIF4
|
|
||||||
#define DMA_FLAG_GL5 DMA_ISR_GIF5
|
|
||||||
#define DMA_FLAG_TC5 DMA_ISR_TCIF5
|
|
||||||
#define DMA_FLAG_HT5 DMA_ISR_HTIF5
|
|
||||||
#define DMA_FLAG_TE5 DMA_ISR_TEIF5
|
|
||||||
#define DMA_FLAG_GL6 DMA_ISR_GIF6
|
|
||||||
#define DMA_FLAG_TC6 DMA_ISR_TCIF6
|
|
||||||
#define DMA_FLAG_HT6 DMA_ISR_HTIF6
|
|
||||||
#define DMA_FLAG_TE6 DMA_ISR_TEIF6
|
|
||||||
#define DMA_FLAG_GL7 DMA_ISR_GIF7
|
|
||||||
#define DMA_FLAG_TC7 DMA_ISR_TCIF7
|
|
||||||
#define DMA_FLAG_HT7 DMA_ISR_HTIF7
|
|
||||||
#define DMA_FLAG_TE7 DMA_ISR_TEIF7
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macros -----------------------------------------------------------*/
|
|
||||||
/** @defgroup DMA_Exported_Macros DMA Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief Reset DMA handle state
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the specified DMA Channel.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR |= DMA_CCR_EN)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the specified DMA Channel.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR &= ~DMA_CCR_EN)
|
|
||||||
|
|
||||||
|
|
||||||
/* Interrupt & Flag management */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the current DMA Channel transfer complete flag.
|
|
||||||
* @param __HANDLE__: DMA handle
|
|
||||||
* @retval The specified transfer complete flag index.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (STM32L010x4) || defined (STM32L011xx) || defined (STM32L021xx)
|
|
||||||
#define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
|
|
||||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
|
|
||||||
DMA_FLAG_TC5)
|
|
||||||
#else
|
|
||||||
#define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
|
|
||||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TC5 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TC6 :\
|
|
||||||
DMA_FLAG_TC7)
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @brief Return the current DMA Channel half transfer complete flag.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @retval The specified half transfer complete flag index.
|
|
||||||
*/
|
|
||||||
#if defined (STM32L010x4) || defined (STM32L011xx) || defined (STM32L021xx)
|
|
||||||
#define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
|
|
||||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\
|
|
||||||
DMA_FLAG_HT5)
|
|
||||||
#else
|
|
||||||
#define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
|
|
||||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_HT5 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_HT6 :\
|
|
||||||
DMA_FLAG_HT7)
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @brief Returns the current DMA Channel transfer error flag.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @retval The specified transfer error flag index.
|
|
||||||
*/
|
|
||||||
#if defined (STM32L010x4) || defined (STM32L011xx) || defined (STM32L021xx)
|
|
||||||
#define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
|
|
||||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\
|
|
||||||
DMA_FLAG_TE5)
|
|
||||||
#else
|
|
||||||
#define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
|
|
||||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TE5 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TE6 :\
|
|
||||||
DMA_FLAG_TE7)
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @brief Returns the current DMA Channel Global interrupt flag.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @retval The specified transfer error flag index.
|
|
||||||
*/
|
|
||||||
#if defined (STM32L010x4) || defined (STM32L011xx) || defined (STM32L021xx)
|
|
||||||
#define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
|
|
||||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_ISR_GIF1 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_ISR_GIF2 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_ISR_GIF3 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_ISR_GIF4 :\
|
|
||||||
DMA_ISR_GIF5)
|
|
||||||
#else
|
|
||||||
#define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
|
|
||||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_ISR_GIF1 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_ISR_GIF2 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_ISR_GIF3 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_ISR_GIF4 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_ISR_GIF5 :\
|
|
||||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_ISR_GIF6 :\
|
|
||||||
DMA_ISR_GIF7)
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @brief Get the DMA Channel pending flags.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @param __FLAG__ Get the specified flag.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg DMA_FLAG_TCIFx: Transfer complete flag
|
|
||||||
* @arg DMA_FLAG_HTIFx: Half transfer complete flag
|
|
||||||
* @arg DMA_FLAG_TEIFx: Transfer error flag
|
|
||||||
* @arg DMA_ISR_GIFx: Global interrupt flag
|
|
||||||
* Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Channel flag.
|
|
||||||
* @retval The state of FLAG (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__) (DMA1->ISR & (__FLAG__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clears the DMA Channel pending flags.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @param __FLAG__ specifies the flag to clear.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg DMA_FLAG_TCx: Transfer complete flag
|
|
||||||
* @arg DMA_FLAG_HTx: Half transfer complete flag
|
|
||||||
* @arg DMA_FLAG_TEx: Transfer error flag
|
|
||||||
* @arg DMA_FLAG_GLx: Global interrupt flag
|
|
||||||
* Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Channel flag.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) (DMA1->IFCR = (__FLAG__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the specified DMA Channel interrupts.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @param __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg DMA_IT_TC: Transfer complete interrupt mask
|
|
||||||
* @arg DMA_IT_HT: Half transfer complete interrupt mask
|
|
||||||
* @arg DMA_IT_TE: Transfer error interrupt mask
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR |= (__INTERRUPT__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the specified DMA Channel interrupts.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @param __INTERRUPT__ specifies the DMA interrupt sources to be enabled or disabled.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg DMA_IT_TC: Transfer complete interrupt mask
|
|
||||||
* @arg DMA_IT_HT: Half transfer complete interrupt mask
|
|
||||||
* @arg DMA_IT_TE: Transfer error interrupt mask
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR &= ~(__INTERRUPT__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check whether the specified DMA Channel interrupt is enabled or not.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @param __INTERRUPT__ specifies the DMA interrupt source to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg DMA_IT_TC: Transfer complete interrupt mask
|
|
||||||
* @arg DMA_IT_HT: Half transfer complete interrupt mask
|
|
||||||
* @arg DMA_IT_TE: Transfer error interrupt mask
|
|
||||||
* @retval The state of DMA_IT (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CCR & (__INTERRUPT__)))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the number of remaining data units in the current DMA Channel transfer.
|
|
||||||
* @param __HANDLE__ DMA handle
|
|
||||||
* @retval The number of remaining data units in the current DMA Channel transfer.
|
|
||||||
*/
|
|
||||||
#define __HAL_DMA_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNDTR)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @addtogroup DMA_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup DMA_Exported_Functions_Group1
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Initialization and de-initialization functions *****************************/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma);
|
|
||||||
HAL_StatusTypeDef HAL_DMA_DeInit (DMA_HandleTypeDef *hdma);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup DMA_Exported_Functions_Group2
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* IO operation functions *****************************************************/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma);
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma);
|
|
||||||
HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout);
|
|
||||||
void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma);
|
|
||||||
HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)( DMA_HandleTypeDef * _hdma));
|
|
||||||
HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup DMA_Exported_Functions_Group3
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral State and Error functions ***************************************/
|
|
||||||
HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma);
|
|
||||||
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* Define the private group ***********************************/
|
|
||||||
/**************************************************************/
|
|
||||||
/** @defgroup DMA_Private DMA Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \
|
|
||||||
((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \
|
|
||||||
((DIRECTION) == DMA_MEMORY_TO_MEMORY))
|
|
||||||
|
|
||||||
#define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1U) && ((SIZE) < 0x10000U))
|
|
||||||
|
|
||||||
#define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \
|
|
||||||
((STATE) == DMA_PINC_DISABLE))
|
|
||||||
|
|
||||||
#define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \
|
|
||||||
((STATE) == DMA_MINC_DISABLE))
|
|
||||||
|
|
||||||
#define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \
|
|
||||||
((SIZE) == DMA_PDATAALIGN_HALFWORD) || \
|
|
||||||
((SIZE) == DMA_PDATAALIGN_WORD))
|
|
||||||
|
|
||||||
#define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \
|
|
||||||
((SIZE) == DMA_MDATAALIGN_HALFWORD) || \
|
|
||||||
((SIZE) == DMA_MDATAALIGN_WORD ))
|
|
||||||
|
|
||||||
#define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \
|
|
||||||
((MODE) == DMA_CIRCULAR))
|
|
||||||
|
|
||||||
#define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \
|
|
||||||
((PRIORITY) == DMA_PRIORITY_MEDIUM) || \
|
|
||||||
((PRIORITY) == DMA_PRIORITY_HIGH) || \
|
|
||||||
((PRIORITY) == DMA_PRIORITY_VERY_HIGH))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* STM32L0xx_HAL_DMA_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,342 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_ll_exti.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of EXTI LL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2020 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_EXTI_H
|
|
||||||
#define __STM32L0xx_HAL_EXTI_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup EXTI EXTI
|
|
||||||
* @brief EXTI HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup EXTI_Exported_Types EXTI Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_EXTI_COMMON_CB_ID = 0x00U,
|
|
||||||
HAL_EXTI_RISING_CB_ID = 0x01U,
|
|
||||||
HAL_EXTI_FALLING_CB_ID = 0x02U,
|
|
||||||
} EXTI_CallbackIDTypeDef;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXTI Handle structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t Line; /*!< Exti line number */
|
|
||||||
void (* PendingCallback)(void); /*!< Exti pending callback */
|
|
||||||
} EXTI_HandleTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXTI Configuration structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t Line; /*!< The Exti line to be configured. This parameter
|
|
||||||
can be a value of @ref EXTI_Line */
|
|
||||||
uint32_t Mode; /*!< The Exit Mode to be configured for a core.
|
|
||||||
This parameter can be a combination of @ref EXTI_Mode */
|
|
||||||
uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter
|
|
||||||
can be a value of @ref EXTI_Trigger */
|
|
||||||
uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured.
|
|
||||||
This parameter is only possible for line 0 to 15. It
|
|
||||||
can be a value of @ref EXTI_GPIOSel */
|
|
||||||
} EXTI_ConfigTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/** @defgroup EXTI_Exported_Constants EXTI Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup EXTI_Line EXTI Line
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define EXTI_LINE_0 (EXTI_GPIO | 0x00u) /*!< External interrupt line 0 */
|
|
||||||
#define EXTI_LINE_1 (EXTI_GPIO | 0x01u) /*!< External interrupt line 1 */
|
|
||||||
#define EXTI_LINE_2 (EXTI_GPIO | 0x02u) /*!< External interrupt line 2 */
|
|
||||||
#define EXTI_LINE_3 (EXTI_GPIO | 0x03u) /*!< External interrupt line 3 */
|
|
||||||
#define EXTI_LINE_4 (EXTI_GPIO | 0x04u) /*!< External interrupt line 4 */
|
|
||||||
#define EXTI_LINE_5 (EXTI_GPIO | 0x05u) /*!< External interrupt line 5 */
|
|
||||||
#define EXTI_LINE_6 (EXTI_GPIO | 0x06u) /*!< External interrupt line 6 */
|
|
||||||
#define EXTI_LINE_7 (EXTI_GPIO | 0x07u) /*!< External interrupt line 7 */
|
|
||||||
#define EXTI_LINE_8 (EXTI_GPIO | 0x08u) /*!< External interrupt line 8 */
|
|
||||||
#define EXTI_LINE_9 (EXTI_GPIO | 0x09u) /*!< External interrupt line 9 */
|
|
||||||
#define EXTI_LINE_10 (EXTI_GPIO | 0x0Au) /*!< External interrupt line 10 */
|
|
||||||
#define EXTI_LINE_11 (EXTI_GPIO | 0x0Bu) /*!< External interrupt line 11 */
|
|
||||||
#define EXTI_LINE_12 (EXTI_GPIO | 0x0Cu) /*!< External interrupt line 12 */
|
|
||||||
#define EXTI_LINE_13 (EXTI_GPIO | 0x0Du) /*!< External interrupt line 13 */
|
|
||||||
#define EXTI_LINE_14 (EXTI_GPIO | 0x0Eu) /*!< External interrupt line 14 */
|
|
||||||
#define EXTI_LINE_15 (EXTI_GPIO | 0x0Fu) /*!< External interrupt line 15 */
|
|
||||||
#if defined(EXTI_IMR_IM16)
|
|
||||||
#define EXTI_LINE_16 (EXTI_CONFIG | 0x10u) /*!< External interrupt line 16 Connected to the PVD Output */
|
|
||||||
#else
|
|
||||||
#define EXTI_LINE_16 (EXTI_RESERVED | 0x10u) /*!< No interrupt supported in this line */
|
|
||||||
#endif /* EXTI_IMR_IM16 */
|
|
||||||
#define EXTI_LINE_17 (EXTI_CONFIG | 0x11u) /*!< External interrupt line 17 Connected to the RTC Alarm event */
|
|
||||||
#if defined(EXTI_IMR_IM18)
|
|
||||||
#define EXTI_LINE_18 (EXTI_DIRECT | 0x12u) /*!< External interrupt line 18 Connected to the USB Wakeup from suspend event */
|
|
||||||
#else
|
|
||||||
#define EXTI_LINE_18 (EXTI_RESERVED | 0x12u) /*!< No interrupt supported in this line */
|
|
||||||
#endif /* EXTI_IMR_IM18 */
|
|
||||||
#define EXTI_LINE_19 (EXTI_CONFIG | 0x13u) /*!< External interrupt line 19 Connected to the RTC Tamper and Time Stamp events or CSS_LSE */
|
|
||||||
#define EXTI_LINE_20 (EXTI_CONFIG | 0x14u) /*!< External interrupt line 20 Connected to the RTC wakeup timer */
|
|
||||||
#if defined(EXTI_IMR_IM21)
|
|
||||||
#define EXTI_LINE_21 (EXTI_CONFIG | 0x15u) /*!< External interrupt line 21 Connected to the Comparator 1 output */
|
|
||||||
#else
|
|
||||||
#define EXTI_LINE_21 (EXTI_RESERVED | 0x15u) /*!< No interrupt supported in this line */
|
|
||||||
#endif /* EXTI_IMR_IM21 */
|
|
||||||
#if defined(EXTI_IMR_IM22)
|
|
||||||
#define EXTI_LINE_22 (EXTI_CONFIG | 0x16u) /*!< External interrupt line 22 Connected to the Comparator 2 output */
|
|
||||||
#else
|
|
||||||
#define EXTI_LINE_22 (EXTI_RESERVED | 0x16u) /*!< No interrupt supported in this line */
|
|
||||||
#endif /* EXTI_IMR_IM22 */
|
|
||||||
#define EXTI_LINE_23 (EXTI_DIRECT | 0x17u) /*!< External interrupt line 23 Connected to the internal I2C1 wakeup event */
|
|
||||||
#if defined(EXTI_IMR_IM24)
|
|
||||||
#define EXTI_LINE_24 (EXTI_DIRECT | 0x18u) /*!< External interrupt line 24 Connected to the internal I2C3 wakeup event */
|
|
||||||
#else
|
|
||||||
#define EXTI_LINE_24 (EXTI_RESERVED | 0x18u) /*!< No interrupt supported in this line */
|
|
||||||
#endif /* EXTI_IMR_IM24 */
|
|
||||||
#if defined(EXTI_IMR_IM25)
|
|
||||||
#define EXTI_LINE_25 (EXTI_DIRECT | 0x19u) /*!< External interrupt line 25 Connected to the internal USART1 wakeup event */
|
|
||||||
#else
|
|
||||||
#define EXTI_LINE_25 (EXTI_RESERVED | 0x19u) /*!< No interrupt supported in this line */
|
|
||||||
#endif /* EXTI_IMR_IM25 */
|
|
||||||
#define EXTI_LINE_26 (EXTI_DIRECT | 0x1Au) /*!< External interrupt line 26 Connected to the internal USART2 wakeup event */
|
|
||||||
#define EXTI_LINE_27 (EXTI_RESERVED | 0x1Bu) /*!< No interrupt supported in this line */
|
|
||||||
#define EXTI_LINE_28 (EXTI_DIRECT | 0x1Cu) /*!< External interrupt line 28 Connected to the LPUART1 Wakeup event */
|
|
||||||
#define EXTI_LINE_29 (EXTI_DIRECT | 0x1Du) /*!< External interrupt line 29 Connected to the LPTIM1 Wakeup event */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup EXTI_Mode EXTI Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define EXTI_MODE_NONE 0x00000000u
|
|
||||||
#define EXTI_MODE_INTERRUPT 0x00000001u
|
|
||||||
#define EXTI_MODE_EVENT 0x00000002u
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup EXTI_Trigger EXTI Trigger
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define EXTI_TRIGGER_NONE 0x00000000u
|
|
||||||
#define EXTI_TRIGGER_RISING 0x00000001u
|
|
||||||
#define EXTI_TRIGGER_FALLING 0x00000002u
|
|
||||||
#define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup EXTI_GPIOSel EXTI GPIOSel
|
|
||||||
* @brief
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define EXTI_GPIOA 0x00000000u
|
|
||||||
#define EXTI_GPIOB 0x00000001u
|
|
||||||
#define EXTI_GPIOC 0x00000002u
|
|
||||||
#if defined (GPIOD)
|
|
||||||
#define EXTI_GPIOD 0x00000003u
|
|
||||||
#endif /* GPIOD*/
|
|
||||||
#if defined (GPIOE)
|
|
||||||
#define EXTI_GPIOE 0x00000004u
|
|
||||||
#endif /* GPIOE*/
|
|
||||||
#if defined (GPIOH)
|
|
||||||
#define EXTI_GPIOH 0x00000007u
|
|
||||||
#endif /* GPIOH*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/** @defgroup EXTI_Exported_Macros EXTI Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private constants --------------------------------------------------------*/
|
|
||||||
/** @defgroup EXTI_Private_Constants EXTI Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief EXTI Line property definition
|
|
||||||
*/
|
|
||||||
#define EXTI_PROPERTY_SHIFT 24u
|
|
||||||
#define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT)
|
|
||||||
#define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT)
|
|
||||||
#define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG)
|
|
||||||
#define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT)
|
|
||||||
#define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXTI bit usage
|
|
||||||
*/
|
|
||||||
#define EXTI_PIN_MASK 0x0000001Fu
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXTI Mask for interrupt & event mode
|
|
||||||
*/
|
|
||||||
#define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXTI Mask for trigger possibilities
|
|
||||||
*/
|
|
||||||
#define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXTI Line number
|
|
||||||
*/
|
|
||||||
#define EXTI_LINE_NB 30u
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup EXTI_Private_Macros EXTI Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \
|
|
||||||
((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \
|
|
||||||
(((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \
|
|
||||||
(((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB))
|
|
||||||
|
|
||||||
#define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \
|
|
||||||
(((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u))
|
|
||||||
|
|
||||||
#define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u)
|
|
||||||
|
|
||||||
#define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING)
|
|
||||||
|
|
||||||
#define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u)
|
|
||||||
|
|
||||||
#if !defined (GPIOH)
|
|
||||||
#define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
|
|
||||||
((__PORT__) == EXTI_GPIOB) || \
|
|
||||||
((__PORT__) == EXTI_GPIOC))
|
|
||||||
#elif !defined (GPIOD)
|
|
||||||
#define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
|
|
||||||
((__PORT__) == EXTI_GPIOB) || \
|
|
||||||
((__PORT__) == EXTI_GPIOC) || \
|
|
||||||
((__PORT__) == EXTI_GPIOH))
|
|
||||||
#elif !defined (GPIOE)
|
|
||||||
#define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
|
|
||||||
((__PORT__) == EXTI_GPIOB) || \
|
|
||||||
((__PORT__) == EXTI_GPIOC) || \
|
|
||||||
((__PORT__) == EXTI_GPIOD) || \
|
|
||||||
((__PORT__) == EXTI_GPIOH))
|
|
||||||
#else
|
|
||||||
#define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
|
|
||||||
((__PORT__) == EXTI_GPIOB) || \
|
|
||||||
((__PORT__) == EXTI_GPIOC) || \
|
|
||||||
((__PORT__) == EXTI_GPIOD) || \
|
|
||||||
((__PORT__) == EXTI_GPIOE) || \
|
|
||||||
((__PORT__) == EXTI_GPIOH))
|
|
||||||
#endif /* GPIOH */
|
|
||||||
|
|
||||||
#define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @defgroup EXTI_Exported_Functions EXTI Exported Functions
|
|
||||||
* @brief EXTI Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup EXTI_Exported_Functions_Group1 Configuration functions
|
|
||||||
* @brief Configuration functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Configuration functions ****************************************************/
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti);
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void));
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup EXTI_Exported_Functions_Group2 IO operation functions
|
|
||||||
* @brief IO operation functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* IO operation functions *****************************************************/
|
|
||||||
void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti);
|
|
||||||
uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
|
|
||||||
void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
|
|
||||||
void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* STM32L0xx_HAL_EXTI_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,378 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_flash.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of Flash HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_FLASH_H
|
|
||||||
#define __STM32L0xx_HAL_FLASH_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_Private_Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define FLASH_TIMEOUT_VALUE (50000U) /* 50 s */
|
|
||||||
#define FLASH_SIZE_DATA_REGISTER FLASHSIZE_BASE
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_Private_Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IS_FLASH_TYPEPROGRAM(_VALUE_) ((_VALUE_) == FLASH_TYPEPROGRAM_WORD)
|
|
||||||
|
|
||||||
#define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \
|
|
||||||
((__LATENCY__) == FLASH_LATENCY_1))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/** @defgroup FLASH_Exported_Types FLASH Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief FLASH Procedure structure definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
FLASH_PROC_NONE = 0,
|
|
||||||
FLASH_PROC_PAGEERASE = 1,
|
|
||||||
FLASH_PROC_PROGRAM = 2,
|
|
||||||
} FLASH_ProcedureTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief FLASH handle Structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
__IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */
|
|
||||||
|
|
||||||
__IO uint32_t NbPagesToErase; /*!< Internal variable to save the remaining sectors to erase in IT context*/
|
|
||||||
|
|
||||||
__IO uint32_t Address; /*!< Internal variable to save address selected for program or erase */
|
|
||||||
|
|
||||||
__IO uint32_t Page; /*!< Internal variable to define the current page which is erasing */
|
|
||||||
|
|
||||||
HAL_LockTypeDef Lock; /*!< FLASH locking object */
|
|
||||||
|
|
||||||
__IO uint32_t ErrorCode; /*!< FLASH error code
|
|
||||||
This parameter can be a value of @ref FLASH_Error_Codes */
|
|
||||||
} FLASH_ProcessTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/** @defgroup FLASH_Exported_Constants FLASH Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Error_Codes FLASH Error Codes
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define HAL_FLASH_ERROR_NONE 0x00U /*!< No error */
|
|
||||||
#define HAL_FLASH_ERROR_PGA 0x01U /*!< Programming alignment error */
|
|
||||||
#define HAL_FLASH_ERROR_WRP 0x02U /*!< Write protection error */
|
|
||||||
#define HAL_FLASH_ERROR_OPTV 0x04U /*!< Option validity error */
|
|
||||||
#define HAL_FLASH_ERROR_SIZE 0x08U /*!< */
|
|
||||||
#define HAL_FLASH_ERROR_RD 0x10U /*!< Read protected error */
|
|
||||||
#define HAL_FLASH_ERROR_FWWERR 0x20U /*!< FLASH Write or Erase operation aborted */
|
|
||||||
#define HAL_FLASH_ERROR_NOTZERO 0x40U /*!< FLASH Write operation is done in a not-erased region */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Page_Size FLASH size information
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define FLASH_SIZE (uint32_t)((*((uint32_t *)FLASHSIZE_BASE)&0xFFFF) * 1024U)
|
|
||||||
#define FLASH_PAGE_SIZE (128U) /*!< FLASH Page Size in bytes */
|
|
||||||
|
|
||||||
#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1) /*!< FLASH end address in the alias region */
|
|
||||||
|
|
||||||
#if defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
|
|
||||||
#define FLASH_BANK2_BASE (FLASH_BASE + (FLASH_SIZE >> 1)) /*!< FLASH BANK2 base address in the alias region */
|
|
||||||
#define FLASH_BANK1_END (FLASH_BANK2_BASE - 1) /*!< Program end FLASH BANK1 address */
|
|
||||||
#define FLASH_BANK2_END (FLASH_END) /*!< Program end FLASH BANK2 address */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Type_Program FLASH Type Program
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define FLASH_TYPEPROGRAM_WORD (0x02U) /*!<Program a word (32-bit) at a specified address.*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Latency FLASH Latency
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define FLASH_LATENCY_0 (0x00000000U) /*!< FLASH Zero Latency cycle */
|
|
||||||
#define FLASH_LATENCY_1 FLASH_ACR_LATENCY /*!< FLASH One Latency cycle */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Interrupts FLASH Interrupts
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define FLASH_IT_EOP FLASH_PECR_EOPIE /*!< End of programming interrupt source */
|
|
||||||
#define FLASH_IT_ERR FLASH_PECR_ERRIE /*!< Error interrupt source */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Flags FLASH Flags
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */
|
|
||||||
#define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Programming flag */
|
|
||||||
#define FLASH_FLAG_ENDHV FLASH_SR_HVOFF /*!< FLASH End of High Voltage flag */
|
|
||||||
#define FLASH_FLAG_READY FLASH_SR_READY /*!< FLASH Ready flag after low power mode */
|
|
||||||
#define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */
|
|
||||||
#define FLASH_FLAG_PGAERR FLASH_SR_PGAERR /*!< FLASH Programming Alignment error flag */
|
|
||||||
#define FLASH_FLAG_SIZERR FLASH_SR_SIZERR /*!< FLASH Size error flag */
|
|
||||||
#define FLASH_FLAG_OPTVERR FLASH_SR_OPTVERR /*!< FLASH Option Validity error flag */
|
|
||||||
#define FLASH_FLAG_RDERR FLASH_SR_RDERR /*!< FLASH Read protected error flag */
|
|
||||||
#define FLASH_FLAG_FWWERR FLASH_SR_FWWERR /*!< FLASH Write or Errase operation aborted */
|
|
||||||
#define FLASH_FLAG_NOTZEROERR FLASH_SR_NOTZEROERR /*!< FLASH Read protected error flag */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Keys FLASH Keys
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define FLASH_PDKEY1 (0x04152637U) /*!< Flash power down key1 */
|
|
||||||
#define FLASH_PDKEY2 (0xFAFBFCFDU) /*!< Flash power down key2: used with FLASH_PDKEY1
|
|
||||||
to unlock the RUN_PD bit in FLASH_ACR */
|
|
||||||
|
|
||||||
#define FLASH_PEKEY1 (0x89ABCDEFU) /*!< Flash program erase key1 */
|
|
||||||
#define FLASH_PEKEY2 (0x02030405U) /*!< Flash program erase key: used with FLASH_PEKEY2
|
|
||||||
to unlock the write access to the FLASH_PECR register and
|
|
||||||
data EEPROM */
|
|
||||||
|
|
||||||
#define FLASH_PRGKEY1 (0x8C9DAEBFU) /*!< Flash program memory key1 */
|
|
||||||
#define FLASH_PRGKEY2 (0x13141516U) /*!< Flash program memory key2: used with FLASH_PRGKEY2
|
|
||||||
to unlock the program memory */
|
|
||||||
|
|
||||||
#define FLASH_OPTKEY1 (0xFBEAD9C8U) /*!< Flash option key1 */
|
|
||||||
#define FLASH_OPTKEY2 (0x24252627U) /*!< Flash option key2: used with FLASH_OPTKEY1 to
|
|
||||||
unlock the write access to the option byte block */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* CMSIS_Legacy */
|
|
||||||
|
|
||||||
#if defined ( __ICCARM__ )
|
|
||||||
#define InterruptType_ACTLR_DISMCYCINT_Msk IntType_ACTLR_DISMCYCINT_Msk
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Exported_Macros FLASH Exported Macros
|
|
||||||
* @brief macros to control FLASH features
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Interrupt FLASH Interrupts
|
|
||||||
* @brief macros to handle FLASH interrupts
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the specified FLASH interrupt.
|
|
||||||
* @param __INTERRUPT__ FLASH interrupt
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt
|
|
||||||
* @arg @ref FLASH_IT_ERR Error Interrupt
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) SET_BIT((FLASH->PECR), (__INTERRUPT__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the specified FLASH interrupt.
|
|
||||||
* @param __INTERRUPT__ FLASH interrupt
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt
|
|
||||||
* @arg @ref FLASH_IT_ERR Error Interrupt
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) CLEAR_BIT((FLASH->PECR), (uint32_t)(__INTERRUPT__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the specified FLASH flag status.
|
|
||||||
* @param __FLAG__ specifies the FLASH flag to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref FLASH_FLAG_BSY FLASH Busy flag
|
|
||||||
* @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag
|
|
||||||
* @arg @ref FLASH_FLAG_ENDHV FLASH End of High Voltage flag
|
|
||||||
* @arg @ref FLASH_FLAG_READY FLASH Ready flag after low power mode
|
|
||||||
* @arg @ref FLASH_FLAG_PGAERR FLASH Programming Alignment error flag
|
|
||||||
* @arg @ref FLASH_FLAG_SIZERR FLASH Size error flag
|
|
||||||
* @arg @ref FLASH_FLAG_OPTVERR FLASH Option validity error flag (not valid with STM32L031xx/STM32L041xx)
|
|
||||||
* @arg @ref FLASH_FLAG_RDERR FLASH Read protected error flag
|
|
||||||
* @arg @ref FLASH_FLAG_WRPERR FLASH Write protected error flag
|
|
||||||
* @arg @ref FLASH_FLAG_FWWERR FLASH Fetch While Write Error flag
|
|
||||||
* @arg @ref FLASH_FLAG_NOTZEROERR Not Zero area error flag
|
|
||||||
* @retval The new state of __FLAG__ (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_GET_FLAG(__FLAG__) (((FLASH->SR) & (__FLAG__)) == (__FLAG__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the specified FLASH flag.
|
|
||||||
* @param __FLAG__ specifies the FLASH flags to clear.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag
|
|
||||||
* @arg @ref FLASH_FLAG_PGAERR FLASH Programming Alignment error flag
|
|
||||||
* @arg @ref FLASH_FLAG_SIZERR FLASH Size error flag
|
|
||||||
* @arg @ref FLASH_FLAG_OPTVERR FLASH Option validity error flag (not valid with STM32L031xx/STM32L041xx)
|
|
||||||
* @arg @ref FLASH_FLAG_RDERR FLASH Read protected error flag
|
|
||||||
* @arg @ref FLASH_FLAG_WRPERR FLASH Write protected error flag
|
|
||||||
* @arg @ref FLASH_FLAG_FWWERR FLASH Fetch While Write Error flag
|
|
||||||
* @arg @ref FLASH_FLAG_NOTZEROERR Not Zero area error flag
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_CLEAR_FLAG(__FLAG__) ((FLASH->SR) = (__FLAG__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Include FLASH HAL Extended module */
|
|
||||||
#include "stm32l0xx_hal_flash_ex.h"
|
|
||||||
#include "stm32l0xx_hal_flash_ramfunc.h"
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup FLASH_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_Exported_Functions_Group1
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* IO operation functions *****************************************************/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint32_t Data);
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint32_t Data);
|
|
||||||
|
|
||||||
/* FLASH IRQ handler function */
|
|
||||||
void HAL_FLASH_IRQHandler(void);
|
|
||||||
/* Callbacks in non blocking modes */
|
|
||||||
void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
|
|
||||||
void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_Exported_Functions_Group2
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral Control functions ***********************************************/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_Unlock(void);
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_Lock(void);
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_Exported_Functions_Group3
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral State and Error functions ***************************************/
|
|
||||||
uint32_t HAL_FLASH_GetError(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private function -------------------------------------------------*/
|
|
||||||
/** @addtogroup FLASH_Private_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_HAL_FLASH_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
@ -1,811 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_flash_ex.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of Flash HAL Extended module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_FLASH_EX_H
|
|
||||||
#define __STM32L0xx_HAL_FLASH_EX_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASHEx
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASHEx_Private_Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define FLASH_SIZE_DATA_REGISTER FLASHSIZE_BASE
|
|
||||||
|
|
||||||
#define FLASH_NBPAGES_MAX (FLASH_SIZE / FLASH_PAGE_SIZE)
|
|
||||||
|
|
||||||
#define WRP_MASK_LOW (0x0000FFFFU)
|
|
||||||
#define WRP_MASK_HIGH (0xFFFF0000U)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASHEx_Private_Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IS_FLASH_TYPEERASE(__VALUE__) (((__VALUE__) == FLASH_TYPEERASE_PAGES))
|
|
||||||
|
|
||||||
#define IS_OPTIONBYTE(__VALUE__) (((__VALUE__) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | \
|
|
||||||
OPTIONBYTE_USER | OPTIONBYTE_BOR | OPTIONBYTE_BOOT_BIT1)))
|
|
||||||
|
|
||||||
#define IS_WRPSTATE(__VALUE__) (((__VALUE__) == OB_WRPSTATE_DISABLE) || \
|
|
||||||
((__VALUE__) == OB_WRPSTATE_ENABLE))
|
|
||||||
|
|
||||||
#define IS_OB_WRP(__PAGE__) (((__PAGE__) != 0x0000000U))
|
|
||||||
|
|
||||||
#define IS_OB_RDP(__LEVEL__) (((__LEVEL__) == OB_RDP_LEVEL_0) ||\
|
|
||||||
((__LEVEL__) == OB_RDP_LEVEL_1) ||\
|
|
||||||
((__LEVEL__) == OB_RDP_LEVEL_2))
|
|
||||||
|
|
||||||
#define IS_OB_BOR_LEVEL(__LEVEL__) (((__LEVEL__) == OB_BOR_OFF) || \
|
|
||||||
((__LEVEL__) == OB_BOR_LEVEL1) || \
|
|
||||||
((__LEVEL__) == OB_BOR_LEVEL2) || \
|
|
||||||
((__LEVEL__) == OB_BOR_LEVEL3) || \
|
|
||||||
((__LEVEL__) == OB_BOR_LEVEL4) || \
|
|
||||||
((__LEVEL__) == OB_BOR_LEVEL5))
|
|
||||||
|
|
||||||
#define IS_OB_IWDG_SOURCE(__SOURCE__) (((__SOURCE__) == OB_IWDG_SW) || ((__SOURCE__) == OB_IWDG_HW))
|
|
||||||
|
|
||||||
#define IS_OB_STOP_SOURCE(__SOURCE__) (((__SOURCE__) == OB_STOP_NORST) || ((__SOURCE__) == OB_STOP_RST))
|
|
||||||
|
|
||||||
#define IS_OB_STDBY_SOURCE(__SOURCE__) (((__SOURCE__) == OB_STDBY_NORST) || ((__SOURCE__) == OB_STDBY_RST))
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_WPRMOD) && defined(FLASH_OPTR_BFB2)
|
|
||||||
|
|
||||||
#define IS_OBEX(__VALUE__) (((__VALUE__) <= (OPTIONBYTE_PCROP | OPTIONBYTE_BOOTCONFIG)) && ((__VALUE__) != 0U))
|
|
||||||
|
|
||||||
#elif defined(FLASH_OPTR_WPRMOD) && !defined(FLASH_OPTR_BFB2)
|
|
||||||
|
|
||||||
#define IS_OBEX(__VALUE__) ((__VALUE__) == OPTIONBYTE_PCROP)
|
|
||||||
|
|
||||||
#elif !defined(FLASH_OPTR_WPRMOD) && defined(FLASH_OPTR_BFB2)
|
|
||||||
|
|
||||||
#define IS_OBEX(__VALUE__) ((__VALUE__) == OPTIONBYTE_BOOTCONFIG)
|
|
||||||
|
|
||||||
#endif /* FLASH_OPTR_WPRMOD && FLASH_OPTR_BFB2 */
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_WPRMOD)
|
|
||||||
|
|
||||||
#define IS_PCROPSTATE(__VALUE__) (((__VALUE__) == OB_PCROP_STATE_DISABLE) || \
|
|
||||||
((__VALUE__) == OB_PCROP_STATE_ENABLE))
|
|
||||||
|
|
||||||
#define IS_OB_PCROP(__PAGE__) (((__PAGE__) != 0x0000000U))
|
|
||||||
#endif /* FLASH_OPTR_WPRMOD */
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_BFB2)
|
|
||||||
|
|
||||||
#define IS_OB_BOOT_BANK(__BANK__) (((__BANK__) == OB_BOOT_BANK2) || ((__BANK__) == OB_BOOT_BANK1))
|
|
||||||
|
|
||||||
#endif /* FLASH_OPTR_BFB2 */
|
|
||||||
|
|
||||||
#define IS_OB_BOOT1(__BOOT_BIT1__) (((__BOOT_BIT1__) == OB_BOOT_BIT1_RESET) || ((__BOOT_BIT1__) == OB_BOOT_BIT1_SET))
|
|
||||||
#define IS_TYPEPROGRAMDATA(__VALUE__) (((__VALUE__) == FLASH_TYPEPROGRAMDATA_BYTE) || \
|
|
||||||
((__VALUE__) == FLASH_TYPEPROGRAMDATA_HALFWORD) || \
|
|
||||||
((__VALUE__) == FLASH_TYPEPROGRAMDATA_WORD))
|
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Address FLASHEx Address
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
|
|
||||||
|
|
||||||
#define IS_FLASH_DATA_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= DATA_EEPROM_BASE) && ((__ADDRESS__) <= DATA_EEPROM_BANK2_END))
|
|
||||||
#define IS_FLASH_DATA_BANK1_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= DATA_EEPROM_BASE) && ((__ADDRESS__) <= DATA_EEPROM_BANK1_END))
|
|
||||||
#define IS_FLASH_DATA_BANK2_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= DATA_EEPROM_BANK2_BASE) && ((__ADDRESS__) <= DATA_EEPROM_BANK2_END))
|
|
||||||
#define IS_FLASH_PROGRAM_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= FLASH_BASE) && ((__ADDRESS__) < (FLASH_BASE + FLASH_SIZE)))
|
|
||||||
#define IS_FLASH_PROGRAM_BANK1_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= FLASH_BASE) && ((__ADDRESS__) < (FLASH_BASE + (FLASH_SIZE >> 1))))
|
|
||||||
#define IS_FLASH_PROGRAM_BANK2_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= FLASH_BANK2_BASE) && ((__ADDRESS__) < (FLASH_BASE + FLASH_SIZE)))
|
|
||||||
#else
|
|
||||||
#define IS_FLASH_DATA_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= DATA_EEPROM_BASE) && ((__ADDRESS__) <= DATA_EEPROM_END))
|
|
||||||
#define IS_FLASH_PROGRAM_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= FLASH_BASE) && ((__ADDRESS__) < (FLASH_BASE + FLASH_SIZE)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IS_NBPAGES(__PAGES__) (((__PAGES__) >= 1) && ((__PAGES__) <= FLASH_NBPAGES_MAX))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Exported_Types FLASHEx Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief FLASH Erase structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t TypeErase; /*!< TypeErase: Page Erase only.
|
|
||||||
This parameter can be a value of @ref FLASHEx_Type_Erase */
|
|
||||||
|
|
||||||
uint32_t PageAddress; /*!< PageAddress: Initial FLASH address to be erased
|
|
||||||
This parameter must be a value belonging to FLASH Programm address (depending on the devices) */
|
|
||||||
|
|
||||||
uint32_t NbPages; /*!< NbPages: Number of pages to be erased.
|
|
||||||
This parameter must be a value between 1 and (max number of pages - value of Initial page)*/
|
|
||||||
|
|
||||||
} FLASH_EraseInitTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief FLASH Option Bytes PROGRAM structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t OptionType; /*!< OptionType: Option byte to be configured.
|
|
||||||
This parameter can be a value of @ref FLASHEx_Option_Type */
|
|
||||||
|
|
||||||
uint32_t WRPState; /*!< WRPState: Write protection activation or deactivation.
|
|
||||||
This parameter can be a value of @ref FLASHEx_WRP_State */
|
|
||||||
|
|
||||||
uint32_t WRPSector; /*!< WRPSector: This bitfield specifies the sector (s) which are write protected.
|
|
||||||
This parameter can be a combination of @ref FLASHEx_Option_Bytes_Write_Protection */
|
|
||||||
|
|
||||||
#if defined(STM32L071xx) || defined(STM32L072xx) || defined(STM32L073xx) || defined(STM32L081xx) || defined(STM32L082xx) || defined(STM32L083xx)
|
|
||||||
uint32_t WRPSector2; /*!< WRPSector2 : This bitfield specifies the sector(s) upper Sector31 which are write protected.
|
|
||||||
This parameter can be a combination of @ref FLASHEx_Option_Bytes_Write_Protection2 */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t RDPLevel; /*!< RDPLevel: Set the read protection level.
|
|
||||||
This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */
|
|
||||||
|
|
||||||
uint8_t BORLevel; /*!< BORLevel: Set the BOR Level.
|
|
||||||
This parameter can be a value of @ref FLASHEx_Option_Bytes_BOR_Level */
|
|
||||||
|
|
||||||
uint8_t USERConfig; /*!< USERConfig: Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.
|
|
||||||
This parameter can be a combination of @ref FLASHEx_Option_Bytes_IWatchdog,
|
|
||||||
@ref FLASHEx_Option_Bytes_nRST_STOP and @ref FLASHEx_Option_Bytes_nRST_STDBY*/
|
|
||||||
|
|
||||||
uint8_t BOOTBit1Config; /*!< BOOT1Config: Together with input pad Boot0, this bit selects the boot source, flash, ram or system memory
|
|
||||||
This parameter can be a value of @ref FLASHEx_Option_Bytes_BOOTBit1 */
|
|
||||||
} FLASH_OBProgramInitTypeDef;
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_WPRMOD) || defined(FLASH_OPTR_BFB2)
|
|
||||||
/**
|
|
||||||
* @brief FLASH Advanced Option Bytes Program structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t OptionType; /*!< OptionType: Option byte to be configured for extension .
|
|
||||||
This parameter can be a value of @ref FLASHEx_OptionAdv_Type */
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_WPRMOD)
|
|
||||||
uint32_t PCROPState; /*!< PCROPState: PCROP activation or deactivation.
|
|
||||||
This parameter can be a value of @ref FLASHEx_PCROP_State */
|
|
||||||
|
|
||||||
uint32_t PCROPSector; /*!< PCROPSector : This bitfield specifies the sector(s) which are read/write protected.
|
|
||||||
This parameter can be a combination of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */
|
|
||||||
|
|
||||||
#if defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
|
|
||||||
uint32_t PCROPSector2; /*!< PCROPSector : This bitfield specifies the sector(s) upper Sector31 which are read/write protected.
|
|
||||||
This parameter can be a combination of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection2 */
|
|
||||||
#endif /* STM32L071xx || STM32L072xx || STM32L073xx || STM32L081xx || STM32L082xx || STM32L083xx */
|
|
||||||
#endif /* FLASH_OPTR_WPRMOD */
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_BFB2)
|
|
||||||
uint16_t BootConfig; /*!< BootConfig: specifies Option bytes for boot config
|
|
||||||
This parameter can be a value of @ref FLASHEx_Option_Bytes_BOOT */
|
|
||||||
#endif /* FLASH_OPTR_BFB2*/
|
|
||||||
} FLASH_AdvOBProgramInitTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* FLASH_OPTR_WPRMOD || FLASH_OPTR_BFB2 */
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Exported_Constants FLASHEx Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Type_Erase FLASHEx_Type_Erase
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define FLASH_TYPEERASE_PAGES (0x00U) /*!<Page erase only*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Type FLASHEx Option Type
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OPTIONBYTE_WRP (0x01U) /*!<WRP option byte configuration*/
|
|
||||||
#define OPTIONBYTE_RDP (0x02U) /*!<RDP option byte configuration*/
|
|
||||||
#define OPTIONBYTE_USER (0x04U) /*!<USER option byte configuration*/
|
|
||||||
#define OPTIONBYTE_BOR (0x08U) /*!<BOR option byte configuration*/
|
|
||||||
#define OPTIONBYTE_BOOT_BIT1 (0x10U) /*!< BOOT PIN1 option byte configuration*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_WRP_State FLASHEx WRP State
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_WRPSTATE_DISABLE (0x00U) /*!<Disable the write protection of the desired sectors*/
|
|
||||||
#define OB_WRPSTATE_ENABLE (0x01U) /*!<Enable the write protection of the desired sectors*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (STM32L011xx) || defined (STM32L021xx) || defined (STM32L031xx) || defined (STM32L041xx)
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_WRP_Pages0to31 (0x00000001U) /* Write protection of Sector0 */
|
|
||||||
#define OB_WRP_Pages32to63 (0x00000002U) /* Write protection of Sector1 */
|
|
||||||
#define OB_WRP_Pages64to95 (0x00000004U) /* Write protection of Sector2 */
|
|
||||||
#define OB_WRP_Pages96to127 (0x00000008U) /* Write protection of Sector3 */
|
|
||||||
#define OB_WRP_Pages128to159 (0x00000010U) /* Write protection of Sector4 */
|
|
||||||
#define OB_WRP_Pages160to191 (0x00000020U) /* Write protection of Sector5 */
|
|
||||||
#define OB_WRP_Pages192to223 (0x00000040U) /* Write protection of Sector6 */
|
|
||||||
#define OB_WRP_Pages224to255 (0x00000080U) /* Write protection of Sector7 */
|
|
||||||
#define OB_WRP_AllPages (0x000000FFU) /*!< Write protection of all Sectors */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#elif defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || defined (STM32L062xx) || defined (STM32L063xx)
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_WRP_Pages0to31 (0x00000001U) /* Write protection of Sector0 */
|
|
||||||
#define OB_WRP_Pages32to63 (0x00000002U) /* Write protection of Sector1 */
|
|
||||||
#define OB_WRP_Pages64to95 (0x00000004U) /* Write protection of Sector2 */
|
|
||||||
#define OB_WRP_Pages96to127 (0x00000008U) /* Write protection of Sector3 */
|
|
||||||
#define OB_WRP_Pages128to159 (0x00000010U) /* Write protection of Sector4 */
|
|
||||||
#define OB_WRP_Pages160to191 (0x00000020U) /* Write protection of Sector5 */
|
|
||||||
#define OB_WRP_Pages192to223 (0x00000040U) /* Write protection of Sector6 */
|
|
||||||
#define OB_WRP_Pages224to255 (0x00000080U) /* Write protection of Sector7 */
|
|
||||||
#define OB_WRP_Pages256to287 (0x00000100U) /* Write protection of Sector8 */
|
|
||||||
#define OB_WRP_Pages288to319 (0x00000200U) /* Write protection of Sector9 */
|
|
||||||
#define OB_WRP_Pages320to351 (0x00000400U) /* Write protection of Sector10 */
|
|
||||||
#define OB_WRP_Pages352to383 (0x00000800U) /* Write protection of Sector11 */
|
|
||||||
#define OB_WRP_Pages384to415 (0x00001000U) /* Write protection of Sector12 */
|
|
||||||
#define OB_WRP_Pages416to447 (0x00002000U) /* Write protection of Sector13 */
|
|
||||||
#define OB_WRP_Pages448to479 (0x00004000U) /* Write protection of Sector14 */
|
|
||||||
#define OB_WRP_Pages480to511 (0x00008000U) /* Write protection of Sector15 */
|
|
||||||
#define OB_WRP_AllPages (0x0000FFFFU) /*!< Write protection of all Sectors */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#elif defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write ProtectionP
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_WRP_Pages0to31 (0x00000001U) /* Write protection of Sector0 */
|
|
||||||
#define OB_WRP_Pages32to63 (0x00000002U) /* Write protection of Sector1 */
|
|
||||||
#define OB_WRP_Pages64to95 (0x00000004U) /* Write protection of Sector2 */
|
|
||||||
#define OB_WRP_Pages96to127 (0x00000008U) /* Write protection of Sector3 */
|
|
||||||
#define OB_WRP_Pages128to159 (0x00000010U) /* Write protection of Sector4 */
|
|
||||||
#define OB_WRP_Pages160to191 (0x00000020U) /* Write protection of Sector5 */
|
|
||||||
#define OB_WRP_Pages192to223 (0x00000040U) /* Write protection of Sector6 */
|
|
||||||
#define OB_WRP_Pages224to255 (0x00000080U) /* Write protection of Sector7 */
|
|
||||||
#define OB_WRP_Pages256to287 (0x00000100U) /* Write protection of Sector8 */
|
|
||||||
#define OB_WRP_Pages288to319 (0x00000200U) /* Write protection of Sector9 */
|
|
||||||
#define OB_WRP_Pages320to351 (0x00000400U) /* Write protection of Sector10 */
|
|
||||||
#define OB_WRP_Pages352to383 (0x00000800U) /* Write protection of Sector11 */
|
|
||||||
#define OB_WRP_Pages384to415 (0x00001000U) /* Write protection of Sector12 */
|
|
||||||
#define OB_WRP_Pages416to447 (0x00002000U) /* Write protection of Sector13 */
|
|
||||||
#define OB_WRP_Pages448to479 (0x00004000U) /* Write protection of Sector14 */
|
|
||||||
#define OB_WRP_Pages480to511 (0x00008000U) /* Write protection of Sector15 */
|
|
||||||
#define OB_WRP_Pages512to543 (0x00010000U) /* Write protection of Sector16 */
|
|
||||||
#define OB_WRP_Pages544to575 (0x00020000U) /* Write protection of Sector17 */
|
|
||||||
#define OB_WRP_Pages576to607 (0x00040000U) /* Write protection of Sector18 */
|
|
||||||
#define OB_WRP_Pages608to639 (0x00080000U) /* Write protection of Sector19 */
|
|
||||||
#define OB_WRP_Pages640to671 (0x00100000U) /* Write protection of Sector20 */
|
|
||||||
#define OB_WRP_Pages672to703 (0x00200000U) /* Write protection of Sector21 */
|
|
||||||
#define OB_WRP_Pages704to735 (0x00400000U) /* Write protection of Sector22 */
|
|
||||||
#define OB_WRP_Pages736to767 (0x00800000U) /* Write protection of Sector23 */
|
|
||||||
#define OB_WRP_Pages768to799 (0x01000000U) /* Write protection of Sector24 */
|
|
||||||
#define OB_WRP_Pages800to831 (0x02000000U) /* Write protection of Sector25 */
|
|
||||||
#define OB_WRP_Pages832to863 (0x04000000U) /* Write protection of Sector26 */
|
|
||||||
#define OB_WRP_Pages864to895 (0x08000000U) /* Write protection of Sector27 */
|
|
||||||
#define OB_WRP_Pages896to927 (0x10000000U) /* Write protection of Sector28 */
|
|
||||||
#define OB_WRP_Pages928to959 (0x20000000U) /* Write protection of Sector29 */
|
|
||||||
#define OB_WRP_Pages960to991 (0x40000000U) /* Write protection of Sector30 */
|
|
||||||
#define OB_WRP_Pages992to1023 (0x80000000U) /* Write protection of Sector31 */
|
|
||||||
#define OB_WRP_AllPages (0xFFFFFFFFU) /*!<Write protection of all Sectors */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_Write_Protection2 FLASH Option Bytes Write Protection
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_WRP2_Pages1024to1055 (0x00000001U) /* Write protection of Sector32 */
|
|
||||||
#define OB_WRP2_Pages1056to1087 (0x00000002U) /* Write protection of Sector33 */
|
|
||||||
#define OB_WRP2_Pages1088to1119 (0x00000004U) /* Write protection of Sector34 */
|
|
||||||
#define OB_WRP2_Pages1120to1151 (0x00000008U) /* Write protection of Sector35 */
|
|
||||||
#define OB_WRP2_Pages1152to1183 (0x00000010U) /* Write protection of Sector36 */
|
|
||||||
#define OB_WRP2_Pages1184to1215 (0x00000020U) /* Write protection of Sector37 */
|
|
||||||
#define OB_WRP2_Pages1216to1247 (0x00000040U) /* Write protection of Sector38 */
|
|
||||||
#define OB_WRP2_Pages1248to1279 (0x00000080U) /* Write protection of Sector39 */
|
|
||||||
#define OB_WRP2_Pages1280to1311 (0x00000100U) /* Write protection of Sector40 */
|
|
||||||
#define OB_WRP2_Pages1312to1343 (0x00000200U) /* Write protection of Sector41 */
|
|
||||||
#define OB_WRP2_Pages1344to1375 (0x00000400U) /* Write protection of Sector42 */
|
|
||||||
#define OB_WRP2_Pages1376to1407 (0x00000800U) /* Write protection of Sector43 */
|
|
||||||
#define OB_WRP2_Pages1408to1439 (0x00001000U) /* Write protection of Sector44 */
|
|
||||||
#define OB_WRP2_Pages1440to1471 (0x00002000U) /* Write protection of Sector45 */
|
|
||||||
#define OB_WRP2_Pages1472to1503 (0x00004000U) /* Write protection of Sector46 */
|
|
||||||
#define OB_WRP2_Pages1504to1535 (0x00008000U) /* Write protection of Sector47 */
|
|
||||||
#define OB_WRP2_AllPages (0x0000FFFFU) /*!< Write protection of all Sectors WRP2 */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* STM32L071xx || STM32L072xx || (STM32L073xx) || (STM32L081xx) || (STM32L082xx) || (STM32L083xx) */
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASHEx Option Bytes Read Protection
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_RDP_LEVEL_0 ((uint8_t)0xAA)
|
|
||||||
#define OB_RDP_LEVEL_1 ((uint8_t)0xBB)
|
|
||||||
#define OB_RDP_LEVEL_2 ((uint8_t)0xCC) /* Warning: When enabling read protection level 2
|
|
||||||
it is no more possible to go back to level 1 or 0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_BOR_Level FLASHEx Option Bytes BOR Level
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define OB_BOR_OFF ((uint8_t)0x00) /*!< BOR is disabled at power down, the reset is asserted when the VDD
|
|
||||||
power supply reaches the PDR(Power Down Reset) threshold (1.5V) */
|
|
||||||
#define OB_BOR_LEVEL1 ((uint8_t)0x08) /*!< BOR Reset threshold levels for 1.7V - 1.8V VDD power supply */
|
|
||||||
#define OB_BOR_LEVEL2 ((uint8_t)0x09) /*!< BOR Reset threshold levels for 1.9V - 2.0V VDD power supply */
|
|
||||||
#define OB_BOR_LEVEL3 ((uint8_t)0x0A) /*!< BOR Reset threshold levels for 2.3V - 2.4V VDD power supply */
|
|
||||||
#define OB_BOR_LEVEL4 ((uint8_t)0x0B) /*!< BOR Reset threshold levels for 2.55V - 2.65V VDD power supply */
|
|
||||||
#define OB_BOR_LEVEL5 ((uint8_t)0x0C) /*!< BOR Reset threshold levels for 2.8V - 2.9V VDD power supply */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASHEx Option Bytes IWatchdog
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define OB_IWDG_SW ((uint8_t)0x10) /*!< Software WDG selected */
|
|
||||||
#define OB_IWDG_HW ((uint8_t)0x00) /*!< Hardware WDG selected */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASHEx Option Bytes nRST_STOP
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define OB_STOP_NORST ((uint8_t)0x20) /*!< No reset generated when entering in STOP */
|
|
||||||
#define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASHEx Option Bytes nRST_STDBY
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define OB_STDBY_NORST ((uint8_t)0x40) /*!< No reset generated when entering in STANDBY */
|
|
||||||
#define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_WPRMOD)
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_OptionAdv_Type FLASHEx Option Advanced Type
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define OPTIONBYTE_PCROP (0x01U) /*!<PCROP option byte configuration*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* FLASH_OPTR_WPRMOD */
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_BFB2)
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_OptionAdv_Type FLASHEx Option Advanced Type
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define OPTIONBYTE_BOOTCONFIG (0x02U) /*!<BOOTConfig option byte configuration*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* FLASH_OPTR_BFB2 */
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_WPRMOD)
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_PCROP_State FLASHEx PCROP State
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_PCROP_STATE_DISABLE (0x00U) /*!<Disable PCROP for selected sectors */
|
|
||||||
#define OB_PCROP_STATE_ENABLE (0x01U) /*!<Enable PCROP for selected sectors */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Selection_Protection_Mode FLASHEx Selection Protection Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_PCROP_DESELECTED ((uint16_t)0x0000) /*!< Disabled PCROP, nWPRi bits used for Write Protection on sector i */
|
|
||||||
#define OB_PCROP_SELECTED ((uint16_t)FLASH_OPTR_WPRMOD) /*!< Enable PCROP, nWPRi bits used for PCRoP Protection on sector i */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* FLASH_OPTR_WPRMOD */
|
|
||||||
|
|
||||||
#if defined (STM32L011xx) || defined (STM32L021xx) || defined (STM32L031xx) || defined (STM32L041xx)
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASHEx Option Bytes PC Read/Write Protection
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_PCROP_Pages0to31 (0x00000001U) /* PC Read/Write protection of Sector0 */
|
|
||||||
#define OB_PCROP_Pages32to63 (0x00000002U) /* PC Read/Write protection of Sector1 */
|
|
||||||
#define OB_PCROP_Pages64to95 (0x00000004U) /* PC Read/Write protection of Sector2 */
|
|
||||||
#define OB_PCROP_Pages96to127 (0x00000008U) /* PC Read/Write protection of Sector3 */
|
|
||||||
#define OB_PCROP_Pages128to159 (0x00000010U) /* PC Read/Write protection of Sector4 */
|
|
||||||
#define OB_PCROP_Pages160to191 (0x00000020U) /* PC Read/Write protection of Sector5 */
|
|
||||||
#define OB_PCROP_Pages192to223 (0x00000040U) /* PC Read/Write protection of Sector6 */
|
|
||||||
#define OB_PCROP_Pages224to255 (0x00000080U) /* PC Read/Write protection of Sector7 */
|
|
||||||
#define OB_PCROP_AllPages (0x000000FFU) /*!< PC Read/Write protection of all Sectors */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#elif defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || defined (STM32L062xx) || defined (STM32L063xx)
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASHEx Option Bytes PC Read/Write Protection
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_PCROP_Pages0to31 (0x00000001U) /* PC Read/Write protection of Sector0 */
|
|
||||||
#define OB_PCROP_Pages32to63 (0x00000002U) /* PC Read/Write protection of Sector1 */
|
|
||||||
#define OB_PCROP_Pages64to95 (0x00000004U) /* PC Read/Write protection of Sector2 */
|
|
||||||
#define OB_PCROP_Pages96to127 (0x00000008U) /* PC Read/Write protection of Sector3 */
|
|
||||||
#define OB_PCROP_Pages128to159 (0x00000010U) /* PC Read/Write protection of Sector4 */
|
|
||||||
#define OB_PCROP_Pages160to191 (0x00000020U) /* PC Read/Write protection of Sector5 */
|
|
||||||
#define OB_PCROP_Pages192to223 (0x00000040U) /* PC Read/Write protection of Sector6 */
|
|
||||||
#define OB_PCROP_Pages224to255 (0x00000080U) /* PC Read/Write protection of Sector7 */
|
|
||||||
#define OB_PCROP_Pages256to287 (0x00000100U) /* PC Read/Write protection of Sector8 */
|
|
||||||
#define OB_PCROP_Pages288to319 (0x00000200U) /* PC Read/Write protection of Sector9 */
|
|
||||||
#define OB_PCROP_Pages320to351 (0x00000400U) /* PC Read/Write protection of Sector10 */
|
|
||||||
#define OB_PCROP_Pages352to383 (0x00000800U) /* PC Read/Write protection of Sector11 */
|
|
||||||
#define OB_PCROP_Pages384to415 (0x00001000U) /* PC Read/Write protection of Sector12 */
|
|
||||||
#define OB_PCROP_Pages416to447 (0x00002000U) /* PC Read/Write protection of Sector13 */
|
|
||||||
#define OB_PCROP_Pages448to479 (0x00004000U) /* PC Read/Write protection of Sector14 */
|
|
||||||
#define OB_PCROP_Pages480to511 (0x00008000U) /* PC Read/Write protection of Sector15 */
|
|
||||||
#define OB_PCROP_AllPages (0x0000FFFFU) /*!< PC Read/Write protection of all Sectors */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASH Option Bytes PC Read/Write Protection
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_PCROP_Pages0to31 (0x00000001U) /* PC Read/Write protection of Sector0 */
|
|
||||||
#define OB_PCROP_Pages32to63 (0x00000002U) /* PC Read/Write protection of Sector1 */
|
|
||||||
#define OB_PCROP_Pages64to95 (0x00000004U) /* PC Read/Write protection of Sector2 */
|
|
||||||
#define OB_PCROP_Pages96to127 (0x00000008U) /* PC Read/Write protection of Sector3 */
|
|
||||||
#define OB_PCROP_Pages128to159 (0x00000010U) /* PC Read/Write protection of Sector4 */
|
|
||||||
#define OB_PCROP_Pages160to191 (0x00000020U) /* PC Read/Write protection of Sector5 */
|
|
||||||
#define OB_PCROP_Pages192to223 (0x00000040U) /* PC Read/Write protection of Sector6 */
|
|
||||||
#define OB_PCROP_Pages224to255 (0x00000080U) /* PC Read/Write protection of Sector7 */
|
|
||||||
#define OB_PCROP_Pages256to287 (0x00000100U) /* PC Read/Write protection of Sector8 */
|
|
||||||
#define OB_PCROP_Pages288to319 (0x00000200U) /* PC Read/Write protection of Sector9 */
|
|
||||||
#define OB_PCROP_Pages320to351 (0x00000400U) /* PC Read/Write protection of Sector10 */
|
|
||||||
#define OB_PCROP_Pages352to383 (0x00000800U) /* PC Read/Write protection of Sector11 */
|
|
||||||
#define OB_PCROP_Pages384to415 (0x00001000U) /* PC Read/Write protection of Sector12 */
|
|
||||||
#define OB_PCROP_Pages416to447 (0x00002000U) /* PC Read/Write protection of Sector13 */
|
|
||||||
#define OB_PCROP_Pages448to479 (0x00004000U) /* PC Read/Write protection of Sector14 */
|
|
||||||
#define OB_PCROP_Pages480to511 (0x00008000U) /* PC Read/Write protection of Sector15 */
|
|
||||||
#define OB_PCROP_Pages512to543 (0x00010000U) /* PC Read/Write protection of Sector16 */
|
|
||||||
#define OB_PCROP_Pages544to575 (0x00020000U) /* PC Read/Write protection of Sector17 */
|
|
||||||
#define OB_PCROP_Pages576to607 (0x00040000U) /* PC Read/Write protection of Sector18 */
|
|
||||||
#define OB_PCROP_Pages608to639 (0x00080000U) /* PC Read/Write protection of Sector19 */
|
|
||||||
#define OB_PCROP_Pages640to671 (0x00100000U) /* PC Read/Write protection of Sector20 */
|
|
||||||
#define OB_PCROP_Pages672to703 (0x00200000U) /* PC Read/Write protection of Sector21 */
|
|
||||||
#define OB_PCROP_Pages704to735 (0x00400000U) /* PC Read/Write protection of Sector22 */
|
|
||||||
#define OB_PCROP_Pages736to767 (0x00800000U) /* PC Read/Write protection of Sector23 */
|
|
||||||
#define OB_PCROP_Pages768to799 (0x01000000U) /* PC Read/Write protection of Sector24 */
|
|
||||||
#define OB_PCROP_Pages800to831 (0x02000000U) /* PC Read/Write protection of Sector25 */
|
|
||||||
#define OB_PCROP_Pages832to863 (0x04000000U) /* PC Read/Write protection of Sector26 */
|
|
||||||
#define OB_PCROP_Pages864to895 (0x08000000U) /* PC Read/Write protection of Sector27 */
|
|
||||||
#define OB_PCROP_Pages896to927 (0x10000000U) /* PC Read/Write protection of Sector28 */
|
|
||||||
#define OB_PCROP_Pages928to959 (0x20000000U) /* PC Read/Write protection of Sector29 */
|
|
||||||
#define OB_PCROP_Pages960to991 (0x40000000U) /* PC Read/Write protection of Sector30 */
|
|
||||||
#define OB_PCROP_Pages992to1023 (0x80000000U) /* PC Read/Write protection of Sector31 */
|
|
||||||
#define OB_PCROP_AllPages (0xFFFFFFFFU) /*!<PC Read/Write protection of all Sectors */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection2 FLASH Option Bytes PC Read/Write Protection (Sector 2)
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_PCROP2_Pages1024to1055 (0x00000001U) /* PC Read/Write protection of Sector32 */
|
|
||||||
#define OB_PCROP2_Pages1056to1087 (0x00000002U) /* PC Read/Write protection of Sector33 */
|
|
||||||
#define OB_PCROP2_Pages1088to1119 (0x00000004U) /* PC Read/Write protection of Sector34 */
|
|
||||||
#define OB_PCROP2_Pages1120to1151 (0x00000008U) /* PC Read/Write protection of Sector35 */
|
|
||||||
#define OB_PCROP2_Pages1152to1183 (0x00000010U) /* PC Read/Write protection of Sector36 */
|
|
||||||
#define OB_PCROP2_Pages1184to1215 (0x00000020U) /* PC Read/Write protection of Sector37 */
|
|
||||||
#define OB_PCROP2_Pages1216to1247 (0x00000040U) /* PC Read/Write protection of Sector38 */
|
|
||||||
#define OB_PCROP2_Pages1248to1279 (0x00000080U) /* PC Read/Write protection of Sector39 */
|
|
||||||
#define OB_PCROP2_Pages1280to1311 (0x00000100U) /* PC Read/Write protection of Sector40 */
|
|
||||||
#define OB_PCROP2_Pages1312to1343 (0x00000200U) /* PC Read/Write protection of Sector41 */
|
|
||||||
#define OB_PCROP2_Pages1344to1375 (0x00000400U) /* PC Read/Write protection of Sector42 */
|
|
||||||
#define OB_PCROP2_Pages1376to1407 (0x00000800U) /* PC Read/Write protection of Sector43 */
|
|
||||||
#define OB_PCROP2_Pages1408to1439 (0x00001000U) /* PC Read/Write protection of Sector44 */
|
|
||||||
#define OB_PCROP2_Pages1440to1471 (0x00002000U) /* PC Read/Write protection of Sector45 */
|
|
||||||
#define OB_PCROP2_Pages1472to1503 (0x00004000U) /* PC Read/Write protection of Sector46 */
|
|
||||||
#define OB_PCROP2_Pages1504to1535 (0x00008000U) /* PC Read/Write protection of Sector47 */
|
|
||||||
#define OB_PCROP2_AllPages (0x0000FFFFU) /*!< PC Read/Write protection of all Sectors PCROP2 */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* STM32L071xx || STM32L072xx || STM32L073xx || STM32L081xx || STM32L082xx || STM32L083xx */
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_BOOTBit1 FLASH Option Bytes BOOT Bit1 Setup
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define OB_BOOT_BIT1_RESET (uint8_t)(0x00) /*!< BOOT Bit 1 Reset */
|
|
||||||
#define OB_BOOT_BIT1_SET (uint8_t)(0x01) /*!< BOOT Bit 1 Set */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Type_Program_Data FLASHEx Type Program Data
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define FLASH_TYPEPROGRAMDATA_BYTE (0x00U) /*!<Program byte (8-bit) at a specified address.*/
|
|
||||||
#define FLASH_TYPEPROGRAMDATA_HALFWORD (0x01U) /*!<Program a half-word (16-bit) at a specified address.*/
|
|
||||||
#define FLASH_TYPEPROGRAMDATA_WORD (0x02U) /*!<Program a word (32-bit) at a specified address.*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_BFB2)
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Option_Bytes_BOOT FLASHEx Option Bytes BOOT
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define OB_BOOT_BANK1 ((uint8_t)0x00) /*!< At startup, if boot pin 0 and BOOT1 bit are set in boot from user Flash position
|
|
||||||
and this parameter is selected the device will boot from Bank 1 (Default)*/
|
|
||||||
#define OB_BOOT_BANK2 ((uint8_t)(FLASH_OPTR_BFB2 >> 16)) /*!< At startup, if boot pin 0 and BOOT1 bit are set in boot from user Flash position
|
|
||||||
and this parameter is selected the device will boot from Bank 2 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* FLASH_OPTR_BFB2 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup FLASHEx_Exported_Macros FLASHEx Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the FLASH Latency.
|
|
||||||
* @param __LATENCY__ FLASH Latency
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref FLASH_LATENCY_0 FLASH Zero Latency cycle
|
|
||||||
* @arg @ref FLASH_LATENCY_1 FLASH One Latency cycle
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_SET_LATENCY(__LATENCY__) \
|
|
||||||
MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(__LATENCY__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the FLASH Latency.
|
|
||||||
* @retval FLASH Latency
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref FLASH_LATENCY_0 FLASH Zero Latency cycle
|
|
||||||
* @arg @ref FLASH_LATENCY_1 FLASH One Latency cycle
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the FLASH prefetch buffer.
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() SET_BIT((FLASH->ACR), FLASH_ACR_PRFTEN)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the FLASH prefetch buffer.
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() CLEAR_BIT((FLASH->ACR), FLASH_ACR_PRFTEN)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the FLASH Buffer cache.
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_BUFFER_CACHE_ENABLE() CLEAR_BIT((FLASH->ACR), FLASH_ACR_DISAB_BUF)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the FLASH Buffer cache.
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_BUFFER_CACHE_DISABLE() SET_BIT((FLASH->ACR), FLASH_ACR_DISAB_BUF)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the FLASH preread buffer.
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_PREREAD_BUFFER_ENABLE() SET_BIT((FLASH->ACR), FLASH_ACR_PRE_READ)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the FLASH preread buffer.
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_PREREAD_BUFFER_DISABLE() CLEAR_BIT((FLASH->ACR), FLASH_ACR_PRE_READ)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the FLASH power down during Sleep mode
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_SLEEP_POWERDOWN_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the FLASH power down during Sleep mode
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_SLEEP_POWERDOWN_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the Flash Run power down mode.
|
|
||||||
* @note Writing this bit to 0 this bit, automatically the keys are
|
|
||||||
* loss and a new unlock sequence is necessary to re-write it to 1.
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_POWER_DOWN_ENABLE() do { FLASH->PDKEYR = FLASH_PDKEY1; \
|
|
||||||
FLASH->PDKEYR = FLASH_PDKEY2; \
|
|
||||||
SET_BIT((FLASH->ACR), FLASH_ACR_RUN_PD); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the Flash Run power down mode.
|
|
||||||
* @note Writing this bit to 0 this bit, automatically the keys are
|
|
||||||
* loss and a new unlock sequence is necessary to re-write it to 1.
|
|
||||||
*/
|
|
||||||
#define __HAL_FLASH_POWER_DOWN_DISABLE() do { FLASH->PDKEYR = FLASH_PDKEY1; \
|
|
||||||
FLASH->PDKEYR = FLASH_PDKEY2; \
|
|
||||||
CLEAR_BIT((FLASH->ACR), FLASH_ACR_RUN_PD); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASHEx_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASHEx_Exported_Functions_Group1
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError);
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASHEx_Exported_Functions_Group2
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
|
|
||||||
void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_WPRMOD) || defined(FLASH_OPTR_BFB2)
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram (FLASH_AdvOBProgramInitTypeDef *pAdvOBInit);
|
|
||||||
void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit);
|
|
||||||
|
|
||||||
#endif /* FLASH_OPTR_WPRMOD || FLASH_OPTR_BFB2 */
|
|
||||||
|
|
||||||
#if defined(FLASH_OPTR_WPRMOD)
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void);
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void);
|
|
||||||
|
|
||||||
#endif /* FLASH_OPTR_WPRMOD */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASHEx_Exported_Functions_Group3
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_Unlock(void);
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_Lock(void);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_Erase(uint32_t Address);
|
|
||||||
HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_Program(uint32_t TypeProgram, uint32_t Address, uint32_t Data);
|
|
||||||
void HAL_FLASHEx_DATAEEPROM_EnableFixedTimeProgram(void);
|
|
||||||
void HAL_FLASHEx_DATAEEPROM_DisableFixedTimeProgram(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_HAL_FLASH_EX_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,108 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_flash_ramfunc.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of FLASH RAMFUNC driver.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_FLASH_RAMFUNC_H
|
|
||||||
#define __STM32L0xx_FLASH_RAMFUNC_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_RAMFUNC
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_RAMFUNC_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief FLASH memory functions that should be executed from internal SRAM.
|
|
||||||
* These functions are defined inside the "stm32l0xx_hal_flash_ramfunc.c"
|
|
||||||
* file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableRunPowerDown(void);
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableRunPowerDown(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group2
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(FLASH_PECR_PARALLBANK)
|
|
||||||
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EraseParallelPage(uint32_t Page_Address1, uint32_t Page_Address2);
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_ProgramParallelHalfPage(uint32_t Address1, uint32_t* pBuffer1, uint32_t Address2, uint32_t* pBuffer2);
|
|
||||||
|
|
||||||
#endif /* FLASH_PECR_PARALLBANK */
|
|
||||||
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_HalfPageProgram(uint32_t Address, uint32_t* pBuffer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group3
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_GetError(uint32_t *Error);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_FLASH_RAMFUNC_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,326 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_gpio.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of GPIO HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_GPIO_H
|
|
||||||
#define __STM32L0xx_HAL_GPIO_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup GPIO GPIO
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/** @defgroup GPIO_Exported_Types GPIO Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup GPIO_Init_Configuration GPIO init configuration structure
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief GPIO Init structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
|
|
||||||
This parameter can be a combination of @ref GPIO_pins_define */
|
|
||||||
|
|
||||||
uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
|
|
||||||
This parameter can be a value of @ref GPIO_mode_define */
|
|
||||||
|
|
||||||
uint32_t Pull; /*!< Specifies the Pull-up or Pull-Down activation for the selected pins.
|
|
||||||
This parameter can be a value of @ref GPIO_pull_define */
|
|
||||||
|
|
||||||
uint32_t Speed; /*!< Specifies the speed for the selected pins.
|
|
||||||
This parameter can be a value of @ref GPIO_speed_define */
|
|
||||||
|
|
||||||
uint32_t Alternate; /*!< Peripheral to be connected to the selected pins
|
|
||||||
This parameter can be a value of @ref GPIOEx_Alternate_function_selection */
|
|
||||||
} GPIO_InitTypeDef;
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup GPIO_SetReset_Definition GPIO set reset definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief GPIO Bit SET and Bit RESET enumeration
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GPIO_PIN_RESET = 0U,
|
|
||||||
GPIO_PIN_SET
|
|
||||||
} GPIO_PinState;
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define IS_GPIO_PIN_ACTION(__ACTION__) (((__ACTION__) == GPIO_PIN_RESET) || ((__ACTION__) == GPIO_PIN_SET))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/** @defgroup GPIO_Exported_Constants GPIO Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup GPIO_pins_define Pin definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define GPIO_PIN_0 (0x0001U) /* Pin 0 selected */
|
|
||||||
#define GPIO_PIN_1 (0x0002U) /* Pin 1 selected */
|
|
||||||
#define GPIO_PIN_2 (0x0004U) /* Pin 2 selected */
|
|
||||||
#define GPIO_PIN_3 (0x0008U) /* Pin 3 selected */
|
|
||||||
#define GPIO_PIN_4 (0x0010U) /* Pin 4 selected */
|
|
||||||
#define GPIO_PIN_5 (0x0020U) /* Pin 5 selected */
|
|
||||||
#define GPIO_PIN_6 (0x0040U) /* Pin 6 selected */
|
|
||||||
#define GPIO_PIN_7 (0x0080U) /* Pin 7 selected */
|
|
||||||
#define GPIO_PIN_8 (0x0100U) /* Pin 8 selected */
|
|
||||||
#define GPIO_PIN_9 (0x0200U) /* Pin 9 selected */
|
|
||||||
#define GPIO_PIN_10 (0x0400U) /* Pin 10 selected */
|
|
||||||
#define GPIO_PIN_11 (0x0800U) /* Pin 11 selected */
|
|
||||||
#define GPIO_PIN_12 (0x1000U) /* Pin 12 selected */
|
|
||||||
#define GPIO_PIN_13 (0x2000U) /* Pin 13 selected */
|
|
||||||
#define GPIO_PIN_14 (0x4000U) /* Pin 14 selected */
|
|
||||||
#define GPIO_PIN_15 (0x8000U) /* Pin 15 selected */
|
|
||||||
#define GPIO_PIN_All (0xFFFFU) /* All pins selected */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GPIO_PIN_MASK (0x0000FFFFU) /* PIN mask for assert test */
|
|
||||||
#define IS_GPIO_PIN(__PIN__) ((((uint32_t)(__PIN__) & GPIO_PIN_MASK) != 0x00U) &&\
|
|
||||||
(((uint32_t)(__PIN__) & ~GPIO_PIN_MASK) == 0x00U))
|
|
||||||
|
|
||||||
/** @defgroup GPIO_mode_define Mode definition
|
|
||||||
* @brief GPIO Configuration Mode
|
|
||||||
* Elements values convention: 0xX0yz00YZ
|
|
||||||
* - X : GPIO mode or EXTI Mode
|
|
||||||
* - y : External IT or Event trigger detection
|
|
||||||
* - z : IO configuration on External IT or Event
|
|
||||||
* - Y : Output type (Push Pull or Open Drain)
|
|
||||||
* - Z : IO Direction mode (Input, Output, Alternate or Analog)
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define GPIO_MODE_INPUT (0x00000000U) /*!< Input Floating Mode */
|
|
||||||
#define GPIO_MODE_OUTPUT_PP (0x00000001U) /*!< Output Push Pull Mode */
|
|
||||||
#define GPIO_MODE_OUTPUT_OD (0x00000011U) /*!< Output Open Drain Mode */
|
|
||||||
#define GPIO_MODE_AF_PP (0x00000002U) /*!< Alternate Function Push Pull Mode */
|
|
||||||
#define GPIO_MODE_AF_OD (0x00000012U) /*!< Alternate Function Open Drain Mode */
|
|
||||||
|
|
||||||
#define GPIO_MODE_ANALOG (0x00000003U) /*!< Analog Mode */
|
|
||||||
|
|
||||||
#define GPIO_MODE_IT_RISING (0x10110000U) /*!< External Interrupt Mode with Rising edge trigger detection */
|
|
||||||
#define GPIO_MODE_IT_FALLING (0x10210000U) /*!< External Interrupt Mode with Falling edge trigger detection */
|
|
||||||
#define GPIO_MODE_IT_RISING_FALLING (0x10310000U) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
|
|
||||||
|
|
||||||
#define GPIO_MODE_EVT_RISING (0x10120000U) /*!< External Event Mode with Rising edge trigger detection */
|
|
||||||
#define GPIO_MODE_EVT_FALLING (0x10220000U) /*!< External Event Mode with Falling edge trigger detection */
|
|
||||||
#define GPIO_MODE_EVT_RISING_FALLING (0x10320000U) /*!< External Event Mode with Rising/Falling edge trigger detection */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IS_GPIO_MODE(__MODE__) (((__MODE__) == GPIO_MODE_INPUT) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_OUTPUT_PP) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_OUTPUT_OD) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_AF_PP) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_AF_OD) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_IT_RISING) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_IT_FALLING) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_IT_RISING_FALLING) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_EVT_RISING) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_EVT_FALLING) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_EVT_RISING_FALLING) ||\
|
|
||||||
((__MODE__) == GPIO_MODE_ANALOG))
|
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup GPIO_speed_define Speed definition
|
|
||||||
* @brief GPIO Output Maximum frequency
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define GPIO_SPEED_FREQ_LOW (0x00000000U) /*!< range up to 0.4 MHz, please refer to the product datasheet */
|
|
||||||
#define GPIO_SPEED_FREQ_MEDIUM (0x00000001U) /*!< range 0.4 MHz to 2 MHz, please refer to the product datasheet */
|
|
||||||
#define GPIO_SPEED_FREQ_HIGH (0x00000002U) /*!< range 2 MHz to 10 MHz, please refer to the product datasheet */
|
|
||||||
#define GPIO_SPEED_FREQ_VERY_HIGH (0x00000003U) /*!< range 10 MHz to 35 MHz, please refer to the product datasheet */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IS_GPIO_SPEED(__SPEED__) (((__SPEED__) == GPIO_SPEED_FREQ_LOW ) || ((__SPEED__) == GPIO_SPEED_FREQ_MEDIUM ) || \
|
|
||||||
((__SPEED__) == GPIO_SPEED_FREQ_HIGH ) || ((__SPEED__) == GPIO_SPEED_FREQ_VERY_HIGH))
|
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup GPIO_pull_define Pull definition
|
|
||||||
* @brief GPIO Pull-Up or Pull-Down Activation
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define GPIO_NOPULL (0x00000000U) /*!< No Pull-up or Pull-down activation */
|
|
||||||
#define GPIO_PULLUP (0x00000001U) /*!< Pull-up activation */
|
|
||||||
#define GPIO_PULLDOWN (0x00000002U) /*!< Pull-down activation */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IS_GPIO_PULL(__PULL__) (((__PULL__) == GPIO_NOPULL) || ((__PULL__) == GPIO_PULLUP) || \
|
|
||||||
((__PULL__) == GPIO_PULLDOWN))
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/** @defgroup GPIO_Exported_Macro GPIO Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief Checks whether the specified EXTI line flag is set or not.
|
|
||||||
* @param __EXTI_LINE__ specifies the EXTI line flag to check.
|
|
||||||
* This parameter can be GPIO_PIN_x where x can be(0..15)
|
|
||||||
* @retval The new state of __EXTI_LINE__ (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define __HAL_GPIO_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clears the EXTI's line pending flags.
|
|
||||||
* @param __EXTI_LINE__ specifies the EXTI lines flags to clear.
|
|
||||||
* This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_GPIO_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Checks whether the specified EXTI line is asserted or not.
|
|
||||||
* @param __EXTI_LINE__ specifies the EXTI line to check.
|
|
||||||
* This parameter can be GPIO_PIN_x where x can be(0..15)
|
|
||||||
* @retval The new state of __EXTI_LINE__ (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define __HAL_GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clears the EXTI's line pending bits.
|
|
||||||
* @param __EXTI_LINE__ specifies the EXTI lines to clear.
|
|
||||||
* This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Generates a Software interrupt on selected EXTI line.
|
|
||||||
* @param __EXTI_LINE__ specifies the EXTI line to check.
|
|
||||||
* This parameter can be GPIO_PIN_x where x can be(0..15)
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_GPIO_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER |= (__EXTI_LINE__))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* Include GPIO HAL Extension module */
|
|
||||||
#include "stm32l0xx_hal_gpio_ex.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @defgroup GPIO_Exported_Functions GPIO Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Initialization and de-initialization functions *******************************/
|
|
||||||
/** @defgroup GPIO_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init);
|
|
||||||
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* IO operation functions *******************************************************/
|
|
||||||
/** @defgroup GPIO_Exported_Functions_Group2 IO operation functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
|
|
||||||
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
|
|
||||||
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
|
|
||||||
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
|
|
||||||
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin);
|
|
||||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define the private group ***********************************/
|
|
||||||
/**************************************************************/
|
|
||||||
/** @defgroup GPIO_Private GPIO Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_HAL_GPIO_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,809 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_i2c.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of I2C HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef STM32L0xx_HAL_I2C_H
|
|
||||||
#define STM32L0xx_HAL_I2C_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Exported_Types I2C Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
|
|
||||||
* @brief I2C Configuration Structure definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t Timing; /*!< Specifies the I2C_TIMINGR_register value.
|
|
||||||
This parameter calculated by referring to I2C initialization
|
|
||||||
section in Reference manual */
|
|
||||||
|
|
||||||
uint32_t OwnAddress1; /*!< Specifies the first device own address.
|
|
||||||
This parameter can be a 7-bit or 10-bit address. */
|
|
||||||
|
|
||||||
uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_ADDRESSING_MODE */
|
|
||||||
|
|
||||||
uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_DUAL_ADDRESSING_MODE */
|
|
||||||
|
|
||||||
uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
|
|
||||||
This parameter can be a 7-bit address. */
|
|
||||||
|
|
||||||
uint32_t OwnAddress2Masks; /*!< Specifies the acknowledge mask address second device own address if dual addressing mode is selected
|
|
||||||
This parameter can be a value of @ref I2C_OWN_ADDRESS2_MASKS */
|
|
||||||
|
|
||||||
uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_GENERAL_CALL_ADDRESSING_MODE */
|
|
||||||
|
|
||||||
uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_NOSTRETCH_MODE */
|
|
||||||
|
|
||||||
} I2C_InitTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_state_structure_definition HAL state structure definition
|
|
||||||
* @brief HAL State structure definition
|
|
||||||
* @note HAL I2C State value coding follow below described bitmap :\n
|
|
||||||
* b7-b6 Error information\n
|
|
||||||
* 00 : No Error\n
|
|
||||||
* 01 : Abort (Abort user request on going)\n
|
|
||||||
* 10 : Timeout\n
|
|
||||||
* 11 : Error\n
|
|
||||||
* b5 Peripheral initialization status\n
|
|
||||||
* 0 : Reset (peripheral not initialized)\n
|
|
||||||
* 1 : Init done (peripheral initialized and ready to use. HAL I2C Init function called)\n
|
|
||||||
* b4 (not used)\n
|
|
||||||
* x : Should be set to 0\n
|
|
||||||
* b3\n
|
|
||||||
* 0 : Ready or Busy (No Listen mode ongoing)\n
|
|
||||||
* 1 : Listen (peripheral in Address Listen Mode)\n
|
|
||||||
* b2 Intrinsic process state\n
|
|
||||||
* 0 : Ready\n
|
|
||||||
* 1 : Busy (peripheral busy with some configuration or internal operations)\n
|
|
||||||
* b1 Rx state\n
|
|
||||||
* 0 : Ready (no Rx operation ongoing)\n
|
|
||||||
* 1 : Busy (Rx operation ongoing)\n
|
|
||||||
* b0 Tx state\n
|
|
||||||
* 0 : Ready (no Tx operation ongoing)\n
|
|
||||||
* 1 : Busy (Tx operation ongoing)
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
|
|
||||||
HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
|
|
||||||
HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
|
|
||||||
HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
|
|
||||||
process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
|
|
||||||
process is ongoing */
|
|
||||||
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
|
|
||||||
HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
|
|
||||||
HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
|
|
||||||
|
|
||||||
} HAL_I2C_StateTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_mode_structure_definition HAL mode structure definition
|
|
||||||
* @brief HAL Mode structure definition
|
|
||||||
* @note HAL I2C Mode value coding follow below described bitmap :\n
|
|
||||||
* b7 (not used)\n
|
|
||||||
* x : Should be set to 0\n
|
|
||||||
* b6\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Memory (HAL I2C communication is in Memory Mode)\n
|
|
||||||
* b5\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Slave (HAL I2C communication is in Slave Mode)\n
|
|
||||||
* b4\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Master (HAL I2C communication is in Master Mode)\n
|
|
||||||
* b3-b2-b1-b0 (not used)\n
|
|
||||||
* xxxx : Should be set to 0000
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_MODE_NONE = 0x00U, /*!< No I2C communication on going */
|
|
||||||
HAL_I2C_MODE_MASTER = 0x10U, /*!< I2C communication is in Master Mode */
|
|
||||||
HAL_I2C_MODE_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */
|
|
||||||
HAL_I2C_MODE_MEM = 0x40U /*!< I2C communication is in Memory Mode */
|
|
||||||
|
|
||||||
} HAL_I2C_ModeTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Error_Code_definition I2C Error Code definition
|
|
||||||
* @brief I2C Error Code definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define HAL_I2C_ERROR_NONE (0x00000000U) /*!< No error */
|
|
||||||
#define HAL_I2C_ERROR_BERR (0x00000001U) /*!< BERR error */
|
|
||||||
#define HAL_I2C_ERROR_ARLO (0x00000002U) /*!< ARLO error */
|
|
||||||
#define HAL_I2C_ERROR_AF (0x00000004U) /*!< ACKF error */
|
|
||||||
#define HAL_I2C_ERROR_OVR (0x00000008U) /*!< OVR error */
|
|
||||||
#define HAL_I2C_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
|
|
||||||
#define HAL_I2C_ERROR_TIMEOUT (0x00000020U) /*!< Timeout error */
|
|
||||||
#define HAL_I2C_ERROR_SIZE (0x00000040U) /*!< Size Management error */
|
|
||||||
#define HAL_I2C_ERROR_DMA_PARAM (0x00000080U) /*!< DMA Parameter Error */
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
#define HAL_I2C_ERROR_INVALID_CALLBACK (0x00000100U) /*!< Invalid Callback error */
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
#define HAL_I2C_ERROR_INVALID_PARAM (0x00000200U) /*!< Invalid Parameters error */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_handle_Structure_definition I2C handle Structure definition
|
|
||||||
* @brief I2C handle Structure definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef struct __I2C_HandleTypeDef
|
|
||||||
{
|
|
||||||
I2C_TypeDef *Instance; /*!< I2C registers base address */
|
|
||||||
|
|
||||||
I2C_InitTypeDef Init; /*!< I2C communication parameters */
|
|
||||||
|
|
||||||
uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */
|
|
||||||
|
|
||||||
uint16_t XferSize; /*!< I2C transfer size */
|
|
||||||
|
|
||||||
__IO uint16_t XferCount; /*!< I2C transfer counter */
|
|
||||||
|
|
||||||
__IO uint32_t XferOptions; /*!< I2C sequantial transfer options, this parameter can
|
|
||||||
be a value of @ref I2C_XFEROPTIONS */
|
|
||||||
|
|
||||||
__IO uint32_t PreviousState; /*!< I2C communication Previous state */
|
|
||||||
|
|
||||||
HAL_StatusTypeDef(*XferISR)(struct __I2C_HandleTypeDef *hi2c, uint32_t ITFlags, uint32_t ITSources); /*!< I2C transfer IRQ handler function pointer */
|
|
||||||
|
|
||||||
DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
|
|
||||||
|
|
||||||
DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
|
|
||||||
|
|
||||||
HAL_LockTypeDef Lock; /*!< I2C locking object */
|
|
||||||
|
|
||||||
__IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */
|
|
||||||
|
|
||||||
__IO HAL_I2C_ModeTypeDef Mode; /*!< I2C communication mode */
|
|
||||||
|
|
||||||
__IO uint32_t ErrorCode; /*!< I2C Error code */
|
|
||||||
|
|
||||||
__IO uint32_t AddrEventCount; /*!< I2C Address Event counter */
|
|
||||||
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
void (* MasterTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Tx Transfer completed callback */
|
|
||||||
void (* MasterRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Rx Transfer completed callback */
|
|
||||||
void (* SlaveTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Tx Transfer completed callback */
|
|
||||||
void (* SlaveRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Rx Transfer completed callback */
|
|
||||||
void (* ListenCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Listen Complete callback */
|
|
||||||
void (* MemTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Tx Transfer completed callback */
|
|
||||||
void (* MemRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Rx Transfer completed callback */
|
|
||||||
void (* ErrorCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Error callback */
|
|
||||||
void (* AbortCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Abort callback */
|
|
||||||
|
|
||||||
void (* AddrCallback)(struct __I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< I2C Slave Address Match callback */
|
|
||||||
|
|
||||||
void (* MspInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp Init callback */
|
|
||||||
void (* MspDeInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp DeInit callback */
|
|
||||||
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
} I2C_HandleTypeDef;
|
|
||||||
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
/**
|
|
||||||
* @brief HAL I2C Callback ID enumeration definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_MASTER_TX_COMPLETE_CB_ID = 0x00U, /*!< I2C Master Tx Transfer completed callback ID */
|
|
||||||
HAL_I2C_MASTER_RX_COMPLETE_CB_ID = 0x01U, /*!< I2C Master Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_SLAVE_TX_COMPLETE_CB_ID = 0x02U, /*!< I2C Slave Tx Transfer completed callback ID */
|
|
||||||
HAL_I2C_SLAVE_RX_COMPLETE_CB_ID = 0x03U, /*!< I2C Slave Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_LISTEN_COMPLETE_CB_ID = 0x04U, /*!< I2C Listen Complete callback ID */
|
|
||||||
HAL_I2C_MEM_TX_COMPLETE_CB_ID = 0x05U, /*!< I2C Memory Tx Transfer callback ID */
|
|
||||||
HAL_I2C_MEM_RX_COMPLETE_CB_ID = 0x06U, /*!< I2C Memory Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_ERROR_CB_ID = 0x07U, /*!< I2C Error callback ID */
|
|
||||||
HAL_I2C_ABORT_CB_ID = 0x08U, /*!< I2C Abort callback ID */
|
|
||||||
|
|
||||||
HAL_I2C_MSPINIT_CB_ID = 0x09U, /*!< I2C Msp Init callback ID */
|
|
||||||
HAL_I2C_MSPDEINIT_CB_ID = 0x0AU /*!< I2C Msp DeInit callback ID */
|
|
||||||
|
|
||||||
} HAL_I2C_CallbackIDTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL I2C Callback pointer definition
|
|
||||||
*/
|
|
||||||
typedef void (*pI2C_CallbackTypeDef)(I2C_HandleTypeDef *hi2c); /*!< pointer to an I2C callback function */
|
|
||||||
typedef void (*pI2C_AddrCallbackTypeDef)(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< pointer to an I2C Address Match callback function */
|
|
||||||
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Exported_Constants I2C Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_XFEROPTIONS I2C Sequential Transfer Options
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_FIRST_FRAME ((uint32_t)I2C_SOFTEND_MODE)
|
|
||||||
#define I2C_FIRST_AND_NEXT_FRAME ((uint32_t)(I2C_RELOAD_MODE | I2C_SOFTEND_MODE))
|
|
||||||
#define I2C_NEXT_FRAME ((uint32_t)(I2C_RELOAD_MODE | I2C_SOFTEND_MODE))
|
|
||||||
#define I2C_FIRST_AND_LAST_FRAME ((uint32_t)I2C_AUTOEND_MODE)
|
|
||||||
#define I2C_LAST_FRAME ((uint32_t)I2C_AUTOEND_MODE)
|
|
||||||
#define I2C_LAST_FRAME_NO_STOP ((uint32_t)I2C_SOFTEND_MODE)
|
|
||||||
|
|
||||||
/* List of XferOptions in usage of :
|
|
||||||
* 1- Restart condition in all use cases (direction change or not)
|
|
||||||
*/
|
|
||||||
#define I2C_OTHER_FRAME (0x000000AAU)
|
|
||||||
#define I2C_OTHER_AND_LAST_FRAME (0x0000AA00U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_ADDRESSING_MODE I2C Addressing Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_ADDRESSINGMODE_7BIT (0x00000001U)
|
|
||||||
#define I2C_ADDRESSINGMODE_10BIT (0x00000002U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_DUAL_ADDRESSING_MODE I2C Dual Addressing Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_DUALADDRESS_DISABLE (0x00000000U)
|
|
||||||
#define I2C_DUALADDRESS_ENABLE I2C_OAR2_OA2EN
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_OWN_ADDRESS2_MASKS I2C Own Address2 Masks
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_OA2_NOMASK ((uint8_t)0x00U)
|
|
||||||
#define I2C_OA2_MASK01 ((uint8_t)0x01U)
|
|
||||||
#define I2C_OA2_MASK02 ((uint8_t)0x02U)
|
|
||||||
#define I2C_OA2_MASK03 ((uint8_t)0x03U)
|
|
||||||
#define I2C_OA2_MASK04 ((uint8_t)0x04U)
|
|
||||||
#define I2C_OA2_MASK05 ((uint8_t)0x05U)
|
|
||||||
#define I2C_OA2_MASK06 ((uint8_t)0x06U)
|
|
||||||
#define I2C_OA2_MASK07 ((uint8_t)0x07U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_GENERAL_CALL_ADDRESSING_MODE I2C General Call Addressing Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_GENERALCALL_DISABLE (0x00000000U)
|
|
||||||
#define I2C_GENERALCALL_ENABLE I2C_CR1_GCEN
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_NOSTRETCH_MODE I2C No-Stretch Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_NOSTRETCH_DISABLE (0x00000000U)
|
|
||||||
#define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_MEMORY_ADDRESS_SIZE I2C Memory Address Size
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_MEMADD_SIZE_8BIT (0x00000001U)
|
|
||||||
#define I2C_MEMADD_SIZE_16BIT (0x00000002U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_XFERDIRECTION I2C Transfer Direction Master Point of View
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_DIRECTION_TRANSMIT (0x00000000U)
|
|
||||||
#define I2C_DIRECTION_RECEIVE (0x00000001U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_RELOAD_END_MODE I2C Reload End Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_RELOAD_MODE I2C_CR2_RELOAD
|
|
||||||
#define I2C_AUTOEND_MODE I2C_CR2_AUTOEND
|
|
||||||
#define I2C_SOFTEND_MODE (0x00000000U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_START_STOP_MODE I2C Start or Stop Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_NO_STARTSTOP (0x00000000U)
|
|
||||||
#define I2C_GENERATE_STOP (uint32_t)(0x80000000U | I2C_CR2_STOP)
|
|
||||||
#define I2C_GENERATE_START_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN)
|
|
||||||
#define I2C_GENERATE_START_WRITE (uint32_t)(0x80000000U | I2C_CR2_START)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
|
|
||||||
* @brief I2C Interrupt definition
|
|
||||||
* Elements values convention: 0xXXXXXXXX
|
|
||||||
* - XXXXXXXX : Interrupt control mask
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_IT_ERRI I2C_CR1_ERRIE
|
|
||||||
#define I2C_IT_TCI I2C_CR1_TCIE
|
|
||||||
#define I2C_IT_STOPI I2C_CR1_STOPIE
|
|
||||||
#define I2C_IT_NACKI I2C_CR1_NACKIE
|
|
||||||
#define I2C_IT_ADDRI I2C_CR1_ADDRIE
|
|
||||||
#define I2C_IT_RXI I2C_CR1_RXIE
|
|
||||||
#define I2C_IT_TXI I2C_CR1_TXIE
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Flag_definition I2C Flag definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_FLAG_TXE I2C_ISR_TXE
|
|
||||||
#define I2C_FLAG_TXIS I2C_ISR_TXIS
|
|
||||||
#define I2C_FLAG_RXNE I2C_ISR_RXNE
|
|
||||||
#define I2C_FLAG_ADDR I2C_ISR_ADDR
|
|
||||||
#define I2C_FLAG_AF I2C_ISR_NACKF
|
|
||||||
#define I2C_FLAG_STOPF I2C_ISR_STOPF
|
|
||||||
#define I2C_FLAG_TC I2C_ISR_TC
|
|
||||||
#define I2C_FLAG_TCR I2C_ISR_TCR
|
|
||||||
#define I2C_FLAG_BERR I2C_ISR_BERR
|
|
||||||
#define I2C_FLAG_ARLO I2C_ISR_ARLO
|
|
||||||
#define I2C_FLAG_OVR I2C_ISR_OVR
|
|
||||||
#define I2C_FLAG_PECERR I2C_ISR_PECERR
|
|
||||||
#define I2C_FLAG_TIMEOUT I2C_ISR_TIMEOUT
|
|
||||||
#define I2C_FLAG_ALERT I2C_ISR_ALERT
|
|
||||||
#define I2C_FLAG_BUSY I2C_ISR_BUSY
|
|
||||||
#define I2C_FLAG_DIR I2C_ISR_DIR
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macros -----------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Exported_Macros I2C Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief Reset I2C handle state.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
|
||||||
(__HANDLE__)->State = HAL_I2C_STATE_RESET; \
|
|
||||||
(__HANDLE__)->MspInitCallback = NULL; \
|
|
||||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
|
||||||
} while(0)
|
|
||||||
#else
|
|
||||||
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @brief Enable the specified I2C interrupt.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __INTERRUPT__ specifies the interrupt source to enable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref I2C_IT_ERRI Errors interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable
|
|
||||||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable
|
|
||||||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable
|
|
||||||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable
|
|
||||||
* @arg @ref I2C_IT_RXI RX interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TXI TX interrupt enable
|
|
||||||
*
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__))
|
|
||||||
|
|
||||||
/** @brief Disable the specified I2C interrupt.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __INTERRUPT__ specifies the interrupt source to disable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref I2C_IT_ERRI Errors interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable
|
|
||||||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable
|
|
||||||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable
|
|
||||||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable
|
|
||||||
* @arg @ref I2C_IT_RXI RX interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TXI TX interrupt enable
|
|
||||||
*
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__)))
|
|
||||||
|
|
||||||
/** @brief Check whether the specified I2C interrupt source is enabled or not.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __INTERRUPT__ specifies the I2C interrupt source to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref I2C_IT_ERRI Errors interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable
|
|
||||||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable
|
|
||||||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable
|
|
||||||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable
|
|
||||||
* @arg @ref I2C_IT_RXI RX interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TXI TX interrupt enable
|
|
||||||
*
|
|
||||||
* @retval The new state of __INTERRUPT__ (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & \
|
|
||||||
(__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
|
||||||
|
|
||||||
/** @brief Check whether the specified I2C flag is set or not.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __FLAG__ specifies the flag to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref I2C_FLAG_TXE Transmit data register empty
|
|
||||||
* @arg @ref I2C_FLAG_TXIS Transmit interrupt status
|
|
||||||
* @arg @ref I2C_FLAG_RXNE Receive data register not empty
|
|
||||||
* @arg @ref I2C_FLAG_ADDR Address matched (slave mode)
|
|
||||||
* @arg @ref I2C_FLAG_AF Acknowledge failure received flag
|
|
||||||
* @arg @ref I2C_FLAG_STOPF STOP detection flag
|
|
||||||
* @arg @ref I2C_FLAG_TC Transfer complete (master mode)
|
|
||||||
* @arg @ref I2C_FLAG_TCR Transfer complete reload
|
|
||||||
* @arg @ref I2C_FLAG_BERR Bus error
|
|
||||||
* @arg @ref I2C_FLAG_ARLO Arbitration lost
|
|
||||||
* @arg @ref I2C_FLAG_OVR Overrun/Underrun
|
|
||||||
* @arg @ref I2C_FLAG_PECERR PEC error in reception
|
|
||||||
* @arg @ref I2C_FLAG_TIMEOUT Timeout or Tlow detection flag
|
|
||||||
* @arg @ref I2C_FLAG_ALERT SMBus alert
|
|
||||||
* @arg @ref I2C_FLAG_BUSY Bus busy
|
|
||||||
* @arg @ref I2C_FLAG_DIR Transfer direction (slave mode)
|
|
||||||
*
|
|
||||||
* @retval The new state of __FLAG__ (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define I2C_FLAG_MASK (0x0001FFFFU)
|
|
||||||
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & \
|
|
||||||
(__FLAG__)) == (__FLAG__)) ? SET : RESET)
|
|
||||||
|
|
||||||
/** @brief Clear the I2C pending flags which are cleared by writing 1 in a specific bit.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __FLAG__ specifies the flag to clear.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg @ref I2C_FLAG_TXE Transmit data register empty
|
|
||||||
* @arg @ref I2C_FLAG_ADDR Address matched (slave mode)
|
|
||||||
* @arg @ref I2C_FLAG_AF Acknowledge failure received flag
|
|
||||||
* @arg @ref I2C_FLAG_STOPF STOP detection flag
|
|
||||||
* @arg @ref I2C_FLAG_BERR Bus error
|
|
||||||
* @arg @ref I2C_FLAG_ARLO Arbitration lost
|
|
||||||
* @arg @ref I2C_FLAG_OVR Overrun/Underrun
|
|
||||||
* @arg @ref I2C_FLAG_PECERR PEC error in reception
|
|
||||||
* @arg @ref I2C_FLAG_TIMEOUT Timeout or Tlow detection flag
|
|
||||||
* @arg @ref I2C_FLAG_ALERT SMBus alert
|
|
||||||
*
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__FLAG__) == I2C_FLAG_TXE) ? ((__HANDLE__)->Instance->ISR |= (__FLAG__)) \
|
|
||||||
: ((__HANDLE__)->Instance->ICR = (__FLAG__)))
|
|
||||||
|
|
||||||
/** @brief Enable the specified I2C peripheral.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE))
|
|
||||||
|
|
||||||
/** @brief Disable the specified I2C peripheral.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE))
|
|
||||||
|
|
||||||
/** @brief Generate a Non-Acknowledge I2C peripheral in Slave mode.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_GENERATE_NACK(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR2, I2C_CR2_NACK))
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Include I2C HAL Extended module */
|
|
||||||
#include "stm32l0xx_hal_i2c_ex.h"
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup I2C_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Initialization and de-initialization functions******************************/
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
|
|
||||||
/* Callbacks Register/UnRegister functions ***********************************/
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
HAL_StatusTypeDef HAL_I2C_RegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID,
|
|
||||||
pI2C_CallbackTypeDef pCallback);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_UnRegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_RegisterAddrCallback(I2C_HandleTypeDef *hi2c, pI2C_AddrCallbackTypeDef pCallback);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_UnRegisterAddrCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* IO operation functions ****************************************************/
|
|
||||||
/******* Blocking mode: Polling */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials,
|
|
||||||
uint32_t Timeout);
|
|
||||||
|
|
||||||
/******* Non-Blocking mode: Interrupt */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_EnableListen_IT(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress);
|
|
||||||
|
|
||||||
/******* Non-Blocking mode: DMA */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t XferOptions);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
|
|
||||||
void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
|
|
||||||
void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group3 Peripheral State, Mode and Error functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral State, Mode and Error functions *********************************/
|
|
||||||
HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_I2C_ModeTypeDef HAL_I2C_GetMode(I2C_HandleTypeDef *hi2c);
|
|
||||||
uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Constants I2C Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Macro I2C Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IS_I2C_ADDRESSING_MODE(MODE) (((MODE) == I2C_ADDRESSINGMODE_7BIT) || \
|
|
||||||
((MODE) == I2C_ADDRESSINGMODE_10BIT))
|
|
||||||
|
|
||||||
#define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \
|
|
||||||
((ADDRESS) == I2C_DUALADDRESS_ENABLE))
|
|
||||||
|
|
||||||
#define IS_I2C_OWN_ADDRESS2_MASK(MASK) (((MASK) == I2C_OA2_NOMASK) || \
|
|
||||||
((MASK) == I2C_OA2_MASK01) || \
|
|
||||||
((MASK) == I2C_OA2_MASK02) || \
|
|
||||||
((MASK) == I2C_OA2_MASK03) || \
|
|
||||||
((MASK) == I2C_OA2_MASK04) || \
|
|
||||||
((MASK) == I2C_OA2_MASK05) || \
|
|
||||||
((MASK) == I2C_OA2_MASK06) || \
|
|
||||||
((MASK) == I2C_OA2_MASK07))
|
|
||||||
|
|
||||||
#define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || \
|
|
||||||
((CALL) == I2C_GENERALCALL_ENABLE))
|
|
||||||
|
|
||||||
#define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || \
|
|
||||||
((STRETCH) == I2C_NOSTRETCH_ENABLE))
|
|
||||||
|
|
||||||
#define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \
|
|
||||||
((SIZE) == I2C_MEMADD_SIZE_16BIT))
|
|
||||||
|
|
||||||
#define IS_TRANSFER_MODE(MODE) (((MODE) == I2C_RELOAD_MODE) || \
|
|
||||||
((MODE) == I2C_AUTOEND_MODE) || \
|
|
||||||
((MODE) == I2C_SOFTEND_MODE))
|
|
||||||
|
|
||||||
#define IS_TRANSFER_REQUEST(REQUEST) (((REQUEST) == I2C_GENERATE_STOP) || \
|
|
||||||
((REQUEST) == I2C_GENERATE_START_READ) || \
|
|
||||||
((REQUEST) == I2C_GENERATE_START_WRITE) || \
|
|
||||||
((REQUEST) == I2C_NO_STARTSTOP))
|
|
||||||
|
|
||||||
#define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_FIRST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_FIRST_AND_NEXT_FRAME) || \
|
|
||||||
((REQUEST) == I2C_NEXT_FRAME) || \
|
|
||||||
((REQUEST) == I2C_FIRST_AND_LAST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_LAST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_LAST_FRAME_NO_STOP) || \
|
|
||||||
IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST))
|
|
||||||
|
|
||||||
#define IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_OTHER_FRAME) || \
|
|
||||||
((REQUEST) == I2C_OTHER_AND_LAST_FRAME))
|
|
||||||
|
|
||||||
#define I2C_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= \
|
|
||||||
(uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN)))
|
|
||||||
|
|
||||||
#define I2C_GET_ADDR_MATCH(__HANDLE__) ((uint16_t)(((__HANDLE__)->Instance->ISR & I2C_ISR_ADDCODE) >> 16U))
|
|
||||||
#define I2C_GET_DIR(__HANDLE__) ((uint8_t)(((__HANDLE__)->Instance->ISR & I2C_ISR_DIR) >> 16U))
|
|
||||||
#define I2C_GET_STOP_MODE(__HANDLE__) ((__HANDLE__)->Instance->CR2 & I2C_CR2_AUTOEND)
|
|
||||||
#define I2C_GET_OWN_ADDRESS1(__HANDLE__) ((uint16_t)((__HANDLE__)->Instance->OAR1 & I2C_OAR1_OA1))
|
|
||||||
#define I2C_GET_OWN_ADDRESS2(__HANDLE__) ((uint16_t)((__HANDLE__)->Instance->OAR2 & I2C_OAR2_OA2))
|
|
||||||
|
|
||||||
#define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= 0x000003FFU)
|
|
||||||
#define IS_I2C_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FFU)
|
|
||||||
|
|
||||||
#define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & \
|
|
||||||
(uint16_t)(0xFF00U))) >> 8U)))
|
|
||||||
#define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FFU))))
|
|
||||||
|
|
||||||
#define I2C_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == I2C_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_START) | (I2C_CR2_AUTOEND)) & (~I2C_CR2_RD_WRN)) : \
|
|
||||||
(uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_ADD10) | (I2C_CR2_START)) & (~I2C_CR2_RD_WRN)))
|
|
||||||
|
|
||||||
#define I2C_CHECK_FLAG(__ISR__, __FLAG__) ((((__ISR__) & ((__FLAG__) & I2C_FLAG_MASK)) == \
|
|
||||||
((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET)
|
|
||||||
#define I2C_CHECK_IT_SOURCE(__CR1__, __IT__) ((((__CR1__) & (__IT__)) == (__IT__)) ? SET : RESET)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private Functions ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Functions I2C Private Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Private functions are defined in stm32l0xx_hal_i2c.c file */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* STM32L0xx_HAL_I2C_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,197 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_i2c_ex.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of I2C HAL Extended module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef STM32L0xx_HAL_I2C_EX_H
|
|
||||||
#define STM32L0xx_HAL_I2C_EX_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Exported_Constants I2C Extended Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Analog_Filter I2C Extended Analog Filter
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_ANALOGFILTER_ENABLE 0x00000000U
|
|
||||||
#define I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_FastModePlus I2C Extended Fast Mode Plus
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_FMP_NOT_SUPPORTED 0xAAAA0000U /*!< Fast Mode Plus not supported */
|
|
||||||
#if defined(SYSCFG_CFGR2_I2C_PB6_FMP)
|
|
||||||
#define I2C_FASTMODEPLUS_PB6 SYSCFG_CFGR2_I2C_PB6_FMP /*!< Enable Fast Mode Plus on PB6 */
|
|
||||||
#define I2C_FASTMODEPLUS_PB7 SYSCFG_CFGR2_I2C_PB7_FMP /*!< Enable Fast Mode Plus on PB7 */
|
|
||||||
#else
|
|
||||||
#define I2C_FASTMODEPLUS_PB6 (uint32_t)(0x00000004U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus PB6 not supported */
|
|
||||||
#define I2C_FASTMODEPLUS_PB7 (uint32_t)(0x00000008U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus PB7 not supported */
|
|
||||||
#endif
|
|
||||||
#if defined(SYSCFG_CFGR2_I2C_PB8_FMP)
|
|
||||||
#define I2C_FASTMODEPLUS_PB8 SYSCFG_CFGR2_I2C_PB8_FMP /*!< Enable Fast Mode Plus on PB8 */
|
|
||||||
#define I2C_FASTMODEPLUS_PB9 SYSCFG_CFGR2_I2C_PB9_FMP /*!< Enable Fast Mode Plus on PB9 */
|
|
||||||
#else
|
|
||||||
#define I2C_FASTMODEPLUS_PB8 (uint32_t)(0x00000010U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus PB8 not supported */
|
|
||||||
#define I2C_FASTMODEPLUS_PB9 (uint32_t)(0x00000012U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus PB9 not supported */
|
|
||||||
#endif
|
|
||||||
#if defined(SYSCFG_CFGR2_I2C1_FMP)
|
|
||||||
#define I2C_FASTMODEPLUS_I2C1 SYSCFG_CFGR2_I2C1_FMP /*!< Enable Fast Mode Plus on I2C1 pins */
|
|
||||||
#else
|
|
||||||
#define I2C_FASTMODEPLUS_I2C1 (uint32_t)(0x00000100U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus I2C1 not supported */
|
|
||||||
#endif
|
|
||||||
#if defined(SYSCFG_CFGR2_I2C2_FMP)
|
|
||||||
#define I2C_FASTMODEPLUS_I2C2 SYSCFG_CFGR2_I2C2_FMP /*!< Enable Fast Mode Plus on I2C2 pins */
|
|
||||||
#else
|
|
||||||
#define I2C_FASTMODEPLUS_I2C2 (uint32_t)(0x00000200U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus I2C2 not supported */
|
|
||||||
#endif
|
|
||||||
#if defined(SYSCFG_CFGR2_I2C3_FMP)
|
|
||||||
#define I2C_FASTMODEPLUS_I2C3 SYSCFG_CFGR2_I2C3_FMP /*!< Enable Fast Mode Plus on I2C3 pins */
|
|
||||||
#else
|
|
||||||
#define I2C_FASTMODEPLUS_I2C3 (uint32_t)(0x00000400U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus I2C3 not supported */
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Exported_Macros I2C Extended Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions I2C Extended Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions_Group1 I2C Extended Filter Mode Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral Control functions ************************************************/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter);
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions_Group2 I2C Extended WakeUp Mode Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions_Group3 I2C Extended FastModePlus Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#if (defined(SYSCFG_CFGR2_I2C_PB6_FMP) || defined(SYSCFG_CFGR2_I2C_PB7_FMP)) || (defined(SYSCFG_CFGR2_I2C_PB8_FMP) || defined(SYSCFG_CFGR2_I2C_PB9_FMP)) || (defined(SYSCFG_CFGR2_I2C1_FMP)) || defined(SYSCFG_CFGR2_I2C2_FMP) || defined(SYSCFG_CFGR2_I2C3_FMP)
|
|
||||||
void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus);
|
|
||||||
void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus);
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Private_Constants I2C Extended Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Private_Macro I2C Extended Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \
|
|
||||||
((FILTER) == I2C_ANALOGFILTER_DISABLE))
|
|
||||||
|
|
||||||
#define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU)
|
|
||||||
|
|
||||||
#define IS_I2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & I2C_FMP_NOT_SUPPORTED) != I2C_FMP_NOT_SUPPORTED) && \
|
|
||||||
((((__CONFIG__) & (I2C_FASTMODEPLUS_PB6)) == I2C_FASTMODEPLUS_PB6) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB7)) == I2C_FASTMODEPLUS_PB7) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB8)) == I2C_FASTMODEPLUS_PB8) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB9)) == I2C_FASTMODEPLUS_PB9) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_I2C1)) == I2C_FASTMODEPLUS_I2C1) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_I2C2)) == I2C_FASTMODEPLUS_I2C2) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_I2C3)) == I2C_FASTMODEPLUS_I2C3)))
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private Functions ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Private_Functions I2C Extended Private Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Private functions are defined in stm32l0xx_hal_i2c_ex.c file */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* STM32L0xx_HAL_I2C_EX_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,460 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_pwr.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of PWR HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_PWR_H
|
|
||||||
#define __STM32L0xx_HAL_PWR_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR PWR
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_Exported_Types PWR Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
/**
|
|
||||||
* @brief PWR PVD configuration structure definition
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level.
|
|
||||||
This parameter can be a value of @ref PWR_PVD_detection_level */
|
|
||||||
|
|
||||||
uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins.
|
|
||||||
This parameter can be a value of @ref PWR_PVD_Mode */
|
|
||||||
}PWR_PVDTypeDef;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWR_Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
#define PWR_EXTI_LINE_PVD EXTI_FTSR_TR16 /*!< External interrupt line 16 Connected to the PVD EXTI Line */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_Exported_Constants PWR Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_register_alias_address PWR Register alias address
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PWR_WAKEUP_PIN1 PWR_CSR_EWUP1
|
|
||||||
#if defined (STM32L010x4) || defined (STM32L011xx) || defined (STM32L021xx)
|
|
||||||
#else
|
|
||||||
#define PWR_WAKEUP_PIN2 PWR_CSR_EWUP2
|
|
||||||
#endif
|
|
||||||
#if defined (STM32L010x4) || defined (STM32L010x6) || defined (STM32L011xx) || defined (STM32L021xx) || \
|
|
||||||
defined (STM32L031xx) || defined (STM32L041xx) || defined (STM32L071xx) || defined (STM32L072xx) || \
|
|
||||||
defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
|
|
||||||
#define PWR_WAKEUP_PIN3 PWR_CSR_EWUP3
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
/** @defgroup PWR_PVD_detection_level PVD detection level
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PWR_PVDLEVEL_0 PWR_CR_PLS_LEV0
|
|
||||||
#define PWR_PVDLEVEL_1 PWR_CR_PLS_LEV1
|
|
||||||
#define PWR_PVDLEVEL_2 PWR_CR_PLS_LEV2
|
|
||||||
#define PWR_PVDLEVEL_3 PWR_CR_PLS_LEV3
|
|
||||||
#define PWR_PVDLEVEL_4 PWR_CR_PLS_LEV4
|
|
||||||
#define PWR_PVDLEVEL_5 PWR_CR_PLS_LEV5
|
|
||||||
#define PWR_PVDLEVEL_6 PWR_CR_PLS_LEV6
|
|
||||||
#define PWR_PVDLEVEL_7 PWR_CR_PLS_LEV7 /* External input analog voltage
|
|
||||||
(Compare internally to VREFINT) */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_PVD_Mode PWR PVD Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PWR_PVD_MODE_NORMAL (0x00000000U) /*!< basic mode is used */
|
|
||||||
#define PWR_PVD_MODE_IT_RISING (0x00010001U) /*!< External Interrupt Mode with Rising edge trigger detection */
|
|
||||||
#define PWR_PVD_MODE_IT_FALLING (0x00010002U) /*!< External Interrupt Mode with Falling edge trigger detection */
|
|
||||||
#define PWR_PVD_MODE_IT_RISING_FALLING (0x00010003U) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
|
|
||||||
#define PWR_PVD_MODE_EVENT_RISING (0x00020001U) /*!< Event Mode with Rising edge trigger detection */
|
|
||||||
#define PWR_PVD_MODE_EVENT_FALLING (0x00020002U) /*!< Event Mode with Falling edge trigger detection */
|
|
||||||
#define PWR_PVD_MODE_EVENT_RISING_FALLING (0x00020003U) /*!< Event Mode with Rising/Falling edge trigger detection */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* PWR_PVD_SUPPORT */
|
|
||||||
|
|
||||||
/** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR Regulator state in SLEEP/STOP mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PWR_MAINREGULATOR_ON (0x00000000U)
|
|
||||||
#define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPSDSR
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PWR_SLEEPENTRY_WFI (0x01U)
|
|
||||||
#define PWR_SLEEPENTRY_WFE (0x02U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PWR_STOPENTRY_WFI (0x01U)
|
|
||||||
#define PWR_STOPENTRY_WFE (0x02U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_Regulator_Voltage_Scale PWR Regulator Voltage Scale
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define PWR_REGULATOR_VOLTAGE_SCALE1 PWR_CR_VOS_0
|
|
||||||
#define PWR_REGULATOR_VOLTAGE_SCALE2 PWR_CR_VOS_1
|
|
||||||
#define PWR_REGULATOR_VOLTAGE_SCALE3 PWR_CR_VOS
|
|
||||||
|
|
||||||
#define IS_PWR_VOLTAGE_SCALING_RANGE(RANGE) (((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
|
|
||||||
((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE2) || \
|
|
||||||
((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE3))
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_Flag PWR Flag
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PWR_FLAG_WU PWR_CSR_WUF
|
|
||||||
#define PWR_FLAG_SB PWR_CSR_SBF
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
#define PWR_FLAG_PVDO PWR_CSR_PVDO
|
|
||||||
#endif
|
|
||||||
#define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF
|
|
||||||
#define PWR_FLAG_VOS PWR_CSR_VOSF
|
|
||||||
#define PWR_FLAG_REGLP PWR_CSR_REGLPF
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_Exported_Macro PWR Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/** @brief macros configure the main internal regulator output voltage.
|
|
||||||
* When exiting Low Power Run Mode or during dynamic voltage scaling configuration,
|
|
||||||
* the reference manual recommends to poll PWR_FLAG_REGLP bit to wait for the regulator
|
|
||||||
* to reach main mode (resp. to get stabilized) for a transition from 0 to 1.
|
|
||||||
* Only then the clock can be increased.
|
|
||||||
*
|
|
||||||
* @param __REGULATOR__ specifies the regulator output voltage to achieve
|
|
||||||
* a tradeoff between performance and power consumption when the device does
|
|
||||||
* not operate at the maximum frequency (refer to the datasheets for more details).
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_REGULATOR_VOLTAGE_SCALE1: Regulator voltage output Scale 1 mode,
|
|
||||||
* System frequency up to 32 MHz.
|
|
||||||
* @arg PWR_REGULATOR_VOLTAGE_SCALE2: Regulator voltage output Scale 2 mode,
|
|
||||||
* System frequency up to 16 MHz.
|
|
||||||
* @arg PWR_REGULATOR_VOLTAGE_SCALE3: Regulator voltage output Scale 3 mode,
|
|
||||||
* System frequency up to 4.2 MHz
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) (MODIFY_REG(PWR->CR, PWR_CR_VOS, (__REGULATOR__)))
|
|
||||||
|
|
||||||
/** @brief Check PWR flag is set or not.
|
|
||||||
* @param __FLAG__ specifies the flag to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
|
|
||||||
* was received from the WKUP pin or from the RTC alarm (Alarm B),
|
|
||||||
* RTC Tamper event, RTC TimeStamp event or RTC Wakeup.
|
|
||||||
* An additional wakeup event is detected if the WKUP pin is enabled
|
|
||||||
* (by setting the EWUP bit) when the WKUP pin level is already high.
|
|
||||||
* @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
|
|
||||||
* resumed from StandBy mode.
|
|
||||||
* @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
|
|
||||||
* by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode.
|
|
||||||
* For this reason, this bit is equal to 0 after Standby or reset
|
|
||||||
* until the PVDE bit is set. Not available on L0 Value line.
|
|
||||||
* @arg PWR_FLAG_VREFINTRDY: Internal voltage reference (VREFINT) ready flag.
|
|
||||||
* This bit indicates the state of the internal voltage reference, VREFINT.
|
|
||||||
* @arg PWR_FLAG_VOS: Voltage Scaling select flag. A delay is required for
|
|
||||||
* the internal regulator to be ready after the voltage range is changed.
|
|
||||||
* The VOSF bit indicates that the regulator has reached the voltage level
|
|
||||||
* defined with bits VOS of PWR_CR register.
|
|
||||||
* @arg PWR_FLAG_REGLP: Regulator LP flag. When the MCU exits from Low power run
|
|
||||||
* mode, this bit stays at 1 until the regulator is ready in main mode.
|
|
||||||
* A polling on this bit is recommended to wait for the regulator main mode.
|
|
||||||
* This bit is reset by hardware when the regulator is ready.
|
|
||||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
|
|
||||||
|
|
||||||
/** @brief Clear the PWR pending flags.
|
|
||||||
* @param __FLAG__ specifies the flag to clear.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_FLAG_WU: Wake Up flag
|
|
||||||
* @arg PWR_FLAG_SB: StandBy flag
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_CLEAR_FLAG(__FLAG__) SET_BIT(PWR->CR, (__FLAG__) << 2U)
|
|
||||||
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
/**
|
|
||||||
* @brief Enable interrupt on PVD Exti Line 16.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable interrupt on PVD Exti Line 16.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable event on PVD Exti Line 16.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable event on PVD Exti Line 16.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PVD EXTI line configuration: set falling edge trigger.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the PVD Extended Interrupt Falling Trigger.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PVD EXTI line configuration: set rising edge trigger.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the PVD Extended Interrupt Rising Trigger.
|
|
||||||
* This parameter can be:
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PVD EXTI line configuration: set rising & falling edge trigger.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); } while(0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
|
|
||||||
* This parameter can be:
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); } while(0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check whether the specified PVD EXTI interrupt flag is set or not.
|
|
||||||
* @retval EXTI PVD Line Status.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the PVD EXTI flag.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Generate a Software interrupt on selected EXTI line.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Generate a Software interrupt on selected EXTI line.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD)
|
|
||||||
|
|
||||||
#endif /* PWR_PVD_SUPPORT */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWR_Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
|
|
||||||
((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
|
|
||||||
((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
|
|
||||||
((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
|
|
||||||
|
|
||||||
#define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
|
|
||||||
((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
|
|
||||||
((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
|
|
||||||
((MODE) == PWR_PVD_MODE_NORMAL))
|
|
||||||
#endif /* PWR_PVD_SUPPORT */
|
|
||||||
|
|
||||||
#if defined (STM32L010x6) || defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
|
|
||||||
#define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
|
|
||||||
((PIN) == PWR_WAKEUP_PIN2) || \
|
|
||||||
((PIN) == PWR_WAKEUP_PIN3))
|
|
||||||
#elif defined (STM32L010xB) || defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || defined (STM32L062xx) || defined (STM32L063xx)
|
|
||||||
#define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
|
|
||||||
((PIN) == PWR_WAKEUP_PIN2))
|
|
||||||
#elif defined (STM32L010x8) || defined (STM32L031xx) || defined (STM32L041xx)
|
|
||||||
#define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
|
|
||||||
((PIN) == PWR_WAKEUP_PIN2))
|
|
||||||
#elif defined (STM32L010x4) || defined (STM32L011xx) || defined (STM32L021xx)
|
|
||||||
#define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
|
|
||||||
((PIN) == PWR_WAKEUP_PIN3))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
|
|
||||||
((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
|
|
||||||
#define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
|
|
||||||
|
|
||||||
#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Include PWR HAL Extension module */
|
|
||||||
#include "stm32l0xx_hal_pwr_ex.h"
|
|
||||||
|
|
||||||
/** @defgroup PWR_Exported_Functions PWR Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
void HAL_PWR_DeInit(void);
|
|
||||||
void HAL_PWR_EnableBkUpAccess(void);
|
|
||||||
void HAL_PWR_DisableBkUpAccess(void);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_Exported_Functions_Group2 Low Power modes configuration functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
/* PVD control functions ************************************************/
|
|
||||||
void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
|
|
||||||
void HAL_PWR_EnablePVD(void);
|
|
||||||
void HAL_PWR_DisablePVD(void);
|
|
||||||
void HAL_PWR_PVD_IRQHandler(void);
|
|
||||||
void HAL_PWR_PVDCallback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* WakeUp pins configuration functions ****************************************/
|
|
||||||
void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
|
|
||||||
void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
|
|
||||||
|
|
||||||
/* Low Power modes configuration functions ************************************/
|
|
||||||
void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
|
|
||||||
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
|
|
||||||
void HAL_PWR_EnterSTANDBYMode(void);
|
|
||||||
|
|
||||||
void HAL_PWR_EnableSleepOnExit(void);
|
|
||||||
void HAL_PWR_DisableSleepOnExit(void);
|
|
||||||
void HAL_PWR_EnableSEVOnPend(void);
|
|
||||||
void HAL_PWR_DisableSEVOnPend(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define the private group ***********************************/
|
|
||||||
/**************************************************************/
|
|
||||||
/** @defgroup PWR_Private PWR Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_HAL_PWR_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_pwr_ex.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of PWR HAL Extension module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32L0xx_HAL_PWR_EX_H
|
|
||||||
#define __STM32L0xx_HAL_PWR_EX_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWREx PWREx
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWREx_Exported_Macros PWREx Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief Macros to enable the Deep-sleep mode with Flash memory kept off.
|
|
||||||
* @note When entering low power mode (stop or standby only), if DS_EE_KOFF and RUN_PD of
|
|
||||||
* FLASH_ACR register are both set , the Flash memory will not be woken up
|
|
||||||
* when exiting from deep-sleep mode.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_FLASHWAKEUP_ENABLE() CLEAR_BIT(PWR->CR, PWR_CR_DSEEKOFF)
|
|
||||||
|
|
||||||
/** @brief Macros to disable the Deep-sleep mode with Flash memory kept off.
|
|
||||||
* @note When entering low power mode (stop or standby only), if DS_EE_KOFF and RUN_PD of
|
|
||||||
* FLASH_ACR register are both set , the Flash memory will not be woken up
|
|
||||||
* when exiting from deep-sleep mode.
|
|
||||||
*/
|
|
||||||
#define __HAL_PWR_FLASHWAKEUP_DISABLE() SET_BIT(PWR->CR, PWR_CR_DSEEKOFF)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWREx_Exported_Functions PWREx Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
uint32_t HAL_PWREx_GetVoltageRange(void);
|
|
||||||
void HAL_PWREx_EnableFastWakeUp(void);
|
|
||||||
void HAL_PWREx_DisableFastWakeUp(void);
|
|
||||||
void HAL_PWREx_EnableUltraLowPower(void);
|
|
||||||
void HAL_PWREx_DisableUltraLowPower(void);
|
|
||||||
void HAL_PWREx_EnableLowPowerRunMode(void);
|
|
||||||
HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define the private group ***********************************/
|
|
||||||
/**************************************************************/
|
|
||||||
/** @defgroup PWREx_Private PWREx Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __STM32L0xx_HAL_PWR_EX_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,247 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_tim_ex.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of TIM HAL Extended module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef STM32L0xx_HAL_TIM_EX_H
|
|
||||||
#define STM32L0xx_HAL_TIM_EX_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup TIMEx
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* End of exported types -----------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup TIMEx_Remap TIM Extended Remapping
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define TIM2_ETR_GPIO 0x00000000U /*!< TIM2 ETR input is connected to ORed GPIOs */
|
|
||||||
#if defined(RCC_HSI48_SUPPORT)
|
|
||||||
#define TIM2_ETR_HSI48 TIM2_OR_ETR_RMP_2 /*!< TIM2 ETR input is connected to HSI48 clock */
|
|
||||||
#endif /* RCC_HSI48_SUPPORT */
|
|
||||||
#define TIM2_ETR_HSI16 (TIM2_OR_ETR_RMP_1 | TIM2_OR_ETR_RMP_0) /*!< TIM2 ETR input is connected to HSI16 clock */
|
|
||||||
#define TIM2_ETR_LSE (TIM2_OR_ETR_RMP_2 | TIM2_OR_ETR_RMP_0) /*!< TIM2 ETR input is connected to LSE clock */
|
|
||||||
#if defined(COMP1) && defined(COMP2)
|
|
||||||
#define TIM2_ETR_COMP2_OUT (TIM2_OR_ETR_RMP_2 | TIM2_OR_ETR_RMP_1) /*!< TIM2 ETR input is connected to COMP2_OUT */
|
|
||||||
#define TIM2_ETR_COMP1_OUT TIM2_OR_ETR_RMP /*!< TIM2 ETR input is connected to COMP1_OUT */
|
|
||||||
#endif /* COMP1 && COMP2 */
|
|
||||||
|
|
||||||
#define TIM2_TI4_GPIO 0x00000000U /*!< TIM2 TI4 input connected to ORed GPIOs */
|
|
||||||
#if defined(COMP1) && defined(COMP2)
|
|
||||||
#define TIM2_TI4_COMP2 TIM2_OR_TI4_RMP_0 /*!< TIM2 TI4 input connected to COMP2_OUT */
|
|
||||||
#define TIM2_TI4_COMP1 TIM2_OR_TI4_RMP_1 /*!< TIM2 TI4 input connected to COMP1_OUT */
|
|
||||||
#endif /* COMP1 && COMP2 */
|
|
||||||
|
|
||||||
#if defined(TIM3)
|
|
||||||
#if defined(USB)
|
|
||||||
#define TIM3_TI4_USB_NOE 0x00000000U /*!< USB_NOE selected selected for PC9 (AF2) remapping */
|
|
||||||
#endif /* USB */
|
|
||||||
|
|
||||||
#define TIM3_TI4_GPIOC9_AF2 TIM3_OR_TI4_RMP /*!< TIM3_CH4 selected for PC9 (AF2) remapping */
|
|
||||||
#define TIM3_TI2_GPIO_DEF 0x00000000U /*!< TIM3_CH2 selected for PB5 (AF4) remapping */
|
|
||||||
#define TIM3_TI2_GPIOB5_AF4 TIM3_OR_TI2_RMP /*!< TIM22_CH2 selected for PB5 (AF4) remapping */
|
|
||||||
|
|
||||||
#if defined(USB)
|
|
||||||
#define TIM3_TI1_USB_SOF 0x00000000U /*!< TIM3 TI1 input connected to USB_SOF */
|
|
||||||
#endif /* USB */
|
|
||||||
|
|
||||||
#define TIM3_TI1_GPIO TIM3_OR_TI1_RMP /*!< TIM3 TI1 input connected to ORed GPIOs */
|
|
||||||
#define TIM3_ETR_GPIO 0x00000000U /*!< TIM3 ETR input connected to ORed GPIOs */
|
|
||||||
#define TIM3_ETR_HSI TIM3_OR_ETR_RMP_1 /*!< TIM3_ETR input is connected to HSI48 clock */
|
|
||||||
#endif /* TIM3 */
|
|
||||||
|
|
||||||
#define TIM21_ETR_GPIO 0x00000000U /*!< TIM21 ETR input connected to ORed GPIOs */
|
|
||||||
#if defined(COMP1) && defined(COMP2)
|
|
||||||
#define TIM21_ETR_COMP2_OUT TIM21_OR_ETR_RMP_0 /*!< TIM21 ETR input connected to COMP2_OUT */
|
|
||||||
#define TIM21_ETR_COMP1_OUT TIM21_OR_ETR_RMP_1 /*!< TIM21 ETR input connected to COMP1_OUT */
|
|
||||||
#endif /* COMP1 && COMP2 */
|
|
||||||
#define TIM21_ETR_LSE TIM21_OR_ETR_RMP /*!< TIM21 ETR input connected to LSE clock */
|
|
||||||
|
|
||||||
#define TIM21_TI1_GPIO 0x00000000U /*!< TIM21 TI1 input connected to ORed GPIOs */
|
|
||||||
#define TIM21_TI1_MCO TIM21_OR_TI1_RMP /*!< TIM21 TI1 input connected to MCO clock */
|
|
||||||
#define TIM21_TI1_RTC_WKUT_IT TIM21_OR_TI1_RMP_0 /*!< TIM21 TI1 input connected to RTC WAKEUP interrupt */
|
|
||||||
#define TIM21_TI1_HSE_RTC TIM21_OR_TI1_RMP_1 /*!< TIM21 TI1 input connected to HSE_RTC clock */
|
|
||||||
#define TIM21_TI1_MSI (TIM21_OR_TI1_RMP_0 | TIM21_OR_TI1_RMP_1) /*!< TIM21 TI1 input connected to MSI clock */
|
|
||||||
#define TIM21_TI1_LSE TIM21_OR_TI1_RMP_2 /*!< TIM21 TI1 input connected to LSE clock */
|
|
||||||
#define TIM21_TI1_LSI (TIM21_OR_TI1_RMP_2 | TIM21_OR_TI1_RMP_0) /*!< TIM21 TI1 input connected to LSI clock */
|
|
||||||
#if defined(COMP1)
|
|
||||||
#define TIM21_TI1_COMP1_OUT (TIM21_OR_TI1_RMP_2 | TIM21_OR_TI1_RMP_1) /*!< TIM21 TI1 input connected to COMP1_OUT */
|
|
||||||
#endif /* COMP1 */
|
|
||||||
|
|
||||||
#define TIM21_TI2_GPIO 0x00000000U /*!< TIM21 TI2 input connected to ORed GPIOs */
|
|
||||||
#if defined(COMP2)
|
|
||||||
#define TIM21_TI2_COMP2_OUT TIM21_OR_TI2_RMP /*!< TIM21 TI2 input connected to COMP2_OUT */
|
|
||||||
#endif /* COMP2 */
|
|
||||||
|
|
||||||
#if defined(TIM22)
|
|
||||||
#define TIM22_ETR_GPIO 0x00000000U /*!< TIM22 ETR input is connected to ORed GPIOs */
|
|
||||||
#if defined(COMP1) && defined(COMP2)
|
|
||||||
#define TIM22_ETR_COMP2_OUT TIM22_OR_ETR_RMP_0 /*!< TIM22 ETR input is connected to COMP2_OUT */
|
|
||||||
#define TIM22_ETR_COMP1_OUT TIM22_OR_ETR_RMP_1 /*!< TIM22 ETR input is connected to COMP1_OUT */
|
|
||||||
#endif /* COMP1 && COMP2 */
|
|
||||||
#define TIM22_ETR_LSE TIM22_OR_ETR_RMP /*!< TIM22 ETR input is connected to LSE clock */
|
|
||||||
|
|
||||||
#define TIM22_TI1_GPIO 0x00000000U /*!< TIM22 TI1 input is connected to ORed GPIOs */
|
|
||||||
#if defined(COMP1) && defined(COMP2)
|
|
||||||
#define TIM22_TI1_COMP2_OUT TIM22_OR_TI1_RMP_0 /*!< TIM22 TI1 input is connected to COMP2_OUT */
|
|
||||||
#define TIM22_TI1_COMP1_OUT TIM22_OR_TI1_RMP_1 /*!< TIM22 TI1 input is connected to COMP1_OUT */
|
|
||||||
#endif /* COMP1 && COMP2 */
|
|
||||||
#endif /* TIM22 */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* End of exported constants -------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* End of exported macro -----------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#if defined(TIM3) && defined(TIM22)
|
|
||||||
|
|
||||||
#define IS_TIM_REMAP(__INSTANCE__, __TIM_REMAP__) \
|
|
||||||
((((__INSTANCE__) == TIM2) && ((__TIM_REMAP__) <= (TIM2_OR_TI4_RMP | TIM2_OR_ETR_RMP))) || \
|
|
||||||
(((__INSTANCE__) == TIM22) && ((__TIM_REMAP__) <= (TIM22_OR_TI1_RMP | TIM22_OR_ETR_RMP))) || \
|
|
||||||
(((__INSTANCE__) == TIM21) && ((__TIM_REMAP__) <= (TIM21_OR_ETR_RMP | TIM21_OR_TI1_RMP | TIM21_OR_TI2_RMP))) || \
|
|
||||||
(((__INSTANCE__) == TIM3) && ((__TIM_REMAP__) <= (TIM3_OR_ETR_RMP | TIM3_OR_TI1_RMP | TIM3_OR_TI2_RMP | TIM3_OR_TI4_RMP))))
|
|
||||||
|
|
||||||
#define IS_CHANNEL_AVAILABLE(__INSTANCE__, __CHANNEL__) \
|
|
||||||
((((__INSTANCE__) == TIM2) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_3) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_4))) || \
|
|
||||||
(((__INSTANCE__) == TIM3) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_3) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_4))) || \
|
|
||||||
(((__INSTANCE__) == TIM21) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2))) || \
|
|
||||||
(((__INSTANCE__) == TIM22) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2))))
|
|
||||||
|
|
||||||
#elif defined(TIM22)
|
|
||||||
|
|
||||||
#define IS_TIM_REMAP(__INSTANCE__, __TIM_REMAP__) \
|
|
||||||
((((__INSTANCE__) == TIM2) && ((__TIM_REMAP__) <= (TIM2_OR_TI4_RMP | TIM2_OR_ETR_RMP))) || \
|
|
||||||
(((__INSTANCE__) == TIM22) && ((__TIM_REMAP__) <= (TIM22_OR_TI1_RMP | TIM22_OR_ETR_RMP))) || \
|
|
||||||
(((__INSTANCE__) == TIM21) && ((__TIM_REMAP__) <= (TIM21_OR_ETR_RMP | TIM21_OR_TI1_RMP | TIM21_OR_TI2_RMP))))
|
|
||||||
|
|
||||||
#define IS_CHANNEL_AVAILABLE(__INSTANCE__, __CHANNEL__) \
|
|
||||||
((((__INSTANCE__) == TIM2) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_3) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_4))) || \
|
|
||||||
(((__INSTANCE__) == TIM21) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2))) || \
|
|
||||||
(((__INSTANCE__) == TIM22) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2))))
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define IS_TIM_REMAP(__INSTANCE__, __TIM_REMAP__) \
|
|
||||||
((((__INSTANCE__) == TIM2) && ((__TIM_REMAP__) <= (TIM2_OR_TI4_RMP | TIM2_OR_ETR_RMP))) || \
|
|
||||||
(((__INSTANCE__) == TIM21) && ((__TIM_REMAP__) <= (TIM21_OR_ETR_RMP | TIM21_OR_TI1_RMP | TIM21_OR_TI2_RMP))))
|
|
||||||
|
|
||||||
#define IS_CHANNEL_AVAILABLE(__INSTANCE__, __CHANNEL__) \
|
|
||||||
((((__INSTANCE__) == TIM2) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_3) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_4))) || \
|
|
||||||
(((__INSTANCE__) == TIM21) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
|
||||||
((__CHANNEL__) == TIM_CHANNEL_2))))
|
|
||||||
#endif /* TIM3 && TIM22 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* End of private macro ------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
|
|
||||||
* @brief Peripheral Control functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Extended Control functions ************************************************/
|
|
||||||
HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
|
|
||||||
TIM_MasterConfigTypeDef *sMasterConfig);
|
|
||||||
HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* End of exported functions -------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* STM32L0xx_HAL_TIM_EX_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,674 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_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
|
|
||||||
used by the PPP peripheral drivers and the user to start using the HAL.
|
|
||||||
[..]
|
|
||||||
The HAL contains two APIs categories:
|
|
||||||
(+) Common HAL APIs
|
|
||||||
(+) Services HAL APIs
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_MODULE_ENABLED
|
|
||||||
|
|
||||||
/** @addtogroup HAL
|
|
||||||
* @brief HAL module driver.
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup HAL_Exported_Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_Version HAL Version
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief STM32L0xx HAL Driver version number
|
|
||||||
*/
|
|
||||||
#define __STM32L0xx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
|
||||||
#define __STM32L0xx_HAL_VERSION_SUB1 (0x0AU) /*!< [23:16] sub1 version */
|
|
||||||
#define __STM32L0xx_HAL_VERSION_SUB2 (0x04U) /*!< [15:8] sub2 version */
|
|
||||||
#define __STM32L0xx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */
|
|
||||||
#define __STM32L0xx_HAL_VERSION ((__STM32L0xx_HAL_VERSION_MAIN << 24U)\
|
|
||||||
|(__STM32L0xx_HAL_VERSION_SUB1 << 16U)\
|
|
||||||
|(__STM32L0xx_HAL_VERSION_SUB2 << 8U )\
|
|
||||||
|(__STM32L0xx_HAL_VERSION_RC))
|
|
||||||
|
|
||||||
#define IDCODE_DEVID_MASK (0x00000FFFU)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported variables --------------------------------------------------------*/
|
|
||||||
/** @addtogroup HAL_Exported_Variables
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
__IO uint32_t uwTick;
|
|
||||||
uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
|
|
||||||
HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup HAL_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup HAL_Exported_Functions_Group1
|
|
||||||
* @brief Initialization and de-initialization functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Initialization and de-initialization functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Initialize the Flash interface, the NVIC allocation and initial clock
|
|
||||||
configuration. It initializes the source of time base also when timeout
|
|
||||||
is needed and the backup domain when enabled.
|
|
||||||
(+) De-initialize common part of the HAL.
|
|
||||||
(+) 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
|
|
||||||
handled in milliseconds basis.
|
|
||||||
(++) 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
|
|
||||||
to make override possible in case of other implementations in user file.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function configures the Flash prefetch, Flash preread and Buffer cache,
|
|
||||||
* Configures time base source, NVIC and Low level hardware
|
|
||||||
* @note This function is called at the beginning of program after reset and before
|
|
||||||
* the clock configuration
|
|
||||||
* @note The time base configuration is based on MSI clock when exiting from Reset.
|
|
||||||
* Once done, time base tick start incrementing.
|
|
||||||
* In the default implementation,Systick is used as source of time base.
|
|
||||||
* the tick variable is incremented each 1ms in its ISR.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_Init(void)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Configure Buffer cache, Flash prefetch, Flash preread */
|
|
||||||
#if (BUFFER_CACHE_DISABLE != 0)
|
|
||||||
__HAL_FLASH_BUFFER_CACHE_DISABLE();
|
|
||||||
#endif /* BUFFER_CACHE_DISABLE */
|
|
||||||
|
|
||||||
#if (PREREAD_ENABLE != 0)
|
|
||||||
__HAL_FLASH_PREREAD_BUFFER_ENABLE();
|
|
||||||
#endif /* PREREAD_ENABLE */
|
|
||||||
|
|
||||||
#if (PREFETCH_ENABLE != 0)
|
|
||||||
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
|
|
||||||
#endif /* PREFETCH_ENABLE */
|
|
||||||
|
|
||||||
/* Use SysTick as time base source and configure 1ms tick (default clock after Reset is MSI) */
|
|
||||||
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
|
|
||||||
{
|
|
||||||
status = HAL_ERROR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Init the low level hardware */
|
|
||||||
HAL_MspInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return function status */
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function de-initializes common part of the HAL and stops the source
|
|
||||||
* 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();
|
|
||||||
|
|
||||||
__HAL_RCC_AHB_FORCE_RESET();
|
|
||||||
__HAL_RCC_AHB_RELEASE_RESET();
|
|
||||||
|
|
||||||
__HAL_RCC_IOP_FORCE_RESET();
|
|
||||||
__HAL_RCC_IOP_RELEASE_RESET();
|
|
||||||
|
|
||||||
/* De-Init the low level hardware */
|
|
||||||
HAL_MspDeInit();
|
|
||||||
|
|
||||||
/* Return function status */
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initializes the MSP.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
__weak void HAL_MspInit(void)
|
|
||||||
{
|
|
||||||
/* NOTE : This function should not be modified, when the callback is needed,
|
|
||||||
the HAL_MspInit could be implemented in the user file
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief DeInitializes the MSP.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
__weak void HAL_MspDeInit(void)
|
|
||||||
{
|
|
||||||
/* NOTE : This function should not be modified, when the callback is needed,
|
|
||||||
the HAL_MspDeInit could be implemented in the user file
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function configures the source of the time base:
|
|
||||||
* The time source is configured to have 1ms time base with a dedicated
|
|
||||||
* Tick interrupt priority.
|
|
||||||
* @note This function is called automatically at the beginning of program after
|
|
||||||
* 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)
|
|
||||||
* 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.
|
|
||||||
* @param TickPriority Tick interrupt priority.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
|
||||||
{
|
|
||||||
/* Configure the SysTick to have interrupt in 1ms time basis*/
|
|
||||||
if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure the SysTick IRQ priority */
|
|
||||||
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
|
|
||||||
{
|
|
||||||
HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
|
|
||||||
uwTickPrio = TickPriority;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return function status */
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup HAL_Exported_Functions_Group2
|
|
||||||
* @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
|
|
||||||
|
|
||||||
@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
|
|
||||||
* in SysTick ISR.
|
|
||||||
* @note This function is declared as __weak to be overwritten in case of other
|
|
||||||
* implementations in user file.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
__weak void HAL_IncTick(void)
|
|
||||||
{
|
|
||||||
uwTick += uwTickFreq;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Provides a tick value in millisecond.
|
|
||||||
* @note This function is declared as __weak to be overwritten in case of other
|
|
||||||
* implementations in user file.
|
|
||||||
* @retval tick value
|
|
||||||
*/
|
|
||||||
__weak uint32_t HAL_GetTick(void)
|
|
||||||
{
|
|
||||||
return uwTick;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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;
|
|
||||||
HAL_TickFreqTypeDef prevTickFreq;
|
|
||||||
|
|
||||||
assert_param(IS_TICKFREQ(Freq));
|
|
||||||
|
|
||||||
if (uwTickFreq != Freq)
|
|
||||||
{
|
|
||||||
/* Back up uwTickFreq frequency */
|
|
||||||
prevTickFreq = uwTickFreq;
|
|
||||||
|
|
||||||
/* Update uwTickFreq global variable used by HAL_InitTick() */
|
|
||||||
uwTickFreq = Freq;
|
|
||||||
|
|
||||||
/* Apply the new tick Freq */
|
|
||||||
status = HAL_InitTick(uwTickPrio);
|
|
||||||
|
|
||||||
if (status != HAL_OK)
|
|
||||||
{
|
|
||||||
/* Restore previous tick frequency */
|
|
||||||
uwTickFreq = prevTickFreq;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
* 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.
|
|
||||||
* @param Delay specifies the delay time length, in milliseconds.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
__weak void HAL_Delay(uint32_t Delay)
|
|
||||||
{
|
|
||||||
uint32_t tickstart = HAL_GetTick();
|
|
||||||
uint32_t wait = Delay;
|
|
||||||
|
|
||||||
/* Add a freq to guarantee minimum wait */
|
|
||||||
if (wait < HAL_MAX_DELAY)
|
|
||||||
{
|
|
||||||
wait += (uint32_t)(uwTickFreq);
|
|
||||||
}
|
|
||||||
|
|
||||||
while((HAL_GetTick() - tickstart) < wait)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Suspends the 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()
|
|
||||||
* is called, the SysTick interrupt will be disabled and so Tick increment
|
|
||||||
* 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 */
|
|
||||||
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Resumes the 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()
|
|
||||||
* is called, the SysTick interrupt will be enabled and so Tick increment
|
|
||||||
* 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 */
|
|
||||||
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the HAL revision
|
|
||||||
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
|
|
||||||
*/
|
|
||||||
uint32_t HAL_GetHalVersion(void)
|
|
||||||
{
|
|
||||||
return __STM32L0xx_HAL_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the device revision identifier.
|
|
||||||
* @retval Device revision identifier
|
|
||||||
*/
|
|
||||||
uint32_t HAL_GetREVID(void)
|
|
||||||
{
|
|
||||||
return((DBGMCU->IDCODE) >> 16U);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the device identifier.
|
|
||||||
* @retval Device identifier
|
|
||||||
*/
|
|
||||||
uint32_t HAL_GetDEVID(void)
|
|
||||||
{
|
|
||||||
return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the 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 the 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 + 0x04U))));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the 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 + 0x14U))));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup HAL_Exported_Functions_Group2
|
|
||||||
* @brief HAL Debug functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### HAL Debug functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Enable/Disable Debug module during SLEEP mode
|
|
||||||
(+) Enable/Disable Debug module during STOP mode
|
|
||||||
(+) Enable/Disable Debug module during STANDBY mode
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables the Debug Module during SLEEP mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_EnableDBGSleepMode(void)
|
|
||||||
{
|
|
||||||
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables the Debug Module during SLEEP mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_DisableDBGSleepMode(void)
|
|
||||||
{
|
|
||||||
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables the Debug Module during STOP mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_EnableDBGStopMode(void)
|
|
||||||
{
|
|
||||||
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables the Debug Module during STOP mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_DisableDBGStopMode(void)
|
|
||||||
{
|
|
||||||
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables the Debug Module during STANDBY mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_EnableDBGStandbyMode(void)
|
|
||||||
{
|
|
||||||
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables the Debug Module during STANDBY mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_DisableDBGStandbyMode(void)
|
|
||||||
{
|
|
||||||
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable low power mode behavior when the MCU is in Debug mode.
|
|
||||||
* @param Periph: specifies the low power mode.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode
|
|
||||||
* @arg DBGMCU_STOP: Keep debugger connection during STOP mode
|
|
||||||
* @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_DBG_EnableLowPowerConfig(uint32_t Periph)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_DBGMCU_PERIPH(Periph));
|
|
||||||
|
|
||||||
DBGMCU->CR |= Periph;
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Disable low power mode behavior when the MCU is in Debug mode.
|
|
||||||
* @param Periph: specifies the low power mode.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode
|
|
||||||
* @arg DBGMCU_STOP: Keep debugger connection during STOP mode
|
|
||||||
* @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DBGMCU_DBG_DisableLowPowerConfig(uint32_t Periph)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_DBGMCU_PERIPH(Periph));
|
|
||||||
{
|
|
||||||
DBGMCU->CR &= ~Periph;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup HAL_Exported_Functions_Group3
|
|
||||||
* @brief HAL SYSCFG configuration functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### HAL SYSCFG configuration functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Return the boot mode
|
|
||||||
(+) Select the output of internal reference voltage (VREFINT)
|
|
||||||
(+) Lock/Unlock the SYSCFG VREF register values
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the boot mode as configured by user.
|
|
||||||
* @retval The boot mode as configured by user. The returned value can be one
|
|
||||||
* of the following values:
|
|
||||||
* - 0x00000000 : Boot is configured in Main Flash memory
|
|
||||||
* - 0x00000100 : Boot is configured in System Flash memory
|
|
||||||
* - 0x00000300 : Boot is configured in Embedded SRAM memory
|
|
||||||
*/
|
|
||||||
uint32_t HAL_SYSCFG_GetBootMode(void)
|
|
||||||
{
|
|
||||||
return (SYSCFG->CFGR1 & SYSCFG_CFGR1_BOOT_MODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Selects the output of internal reference voltage (VREFINT).
|
|
||||||
* The VREFINT output can be routed to(PB0) or
|
|
||||||
* (PB1) or both.
|
|
||||||
* @param SYSCFG_Vrefint_OUTPUT: new state of the Vrefint output.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg SYSCFG_VREFINT_OUT_NONE
|
|
||||||
* @arg SYSCFG_VREFINT_OUT_PB0
|
|
||||||
* @arg SYSCFG_VREFINT_OUT_PB1
|
|
||||||
* @arg SYSCFG_VREFINT_OUT_PB0_PB1
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_SYSCFG_VREFINT_OutputSelect(uint32_t SYSCFG_Vrefint_OUTPUT)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_SYSCFG_VREFINT_OUT_SELECT(SYSCFG_Vrefint_OUTPUT));
|
|
||||||
|
|
||||||
/* Set the output Vrefint pin */
|
|
||||||
SYSCFG->CFGR3 &= ~(SYSCFG_CFGR3_VREF_OUT);
|
|
||||||
SYSCFG->CFGR3 |= (uint32_t)(SYSCFG_Vrefint_OUTPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Lock the SYSCFG VREF register values
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_SYSCFG_Enable_Lock_VREFINT(void)
|
|
||||||
{
|
|
||||||
/* Enable the LOCK by setting REF_LOCK bit in the CFGR3 register */
|
|
||||||
SET_BIT(SYSCFG->CFGR3, SYSCFG_CFGR3_REF_LOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Unlock the overall SYSCFG VREF register values
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_SYSCFG_Disable_Lock_VREFINT(void)
|
|
||||||
{
|
|
||||||
/* Disable the LOCK by setting REF_LOCK bit in the CFGR3 register */
|
|
||||||
CLEAR_BIT(SYSCFG->CFGR3, SYSCFG_CFGR3_REF_LOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* HAL_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
@ -1,415 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_cortex.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief CORTEX HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of the CORTEX:
|
|
||||||
* + Initialization and Configuration functions
|
|
||||||
* + Peripheral Control functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### How to use this driver #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
*** How to configure Interrupts using CORTEX HAL driver ***
|
|
||||||
===========================================================
|
|
||||||
[..]
|
|
||||||
This section provides functions allowing to configure the NVIC interrupts (IRQ).
|
|
||||||
The Cortex M0+ exceptions are managed by CMSIS functions.
|
|
||||||
(#) Enable and Configure the priority of the selected IRQ Channels.
|
|
||||||
The priority can be 0..3.
|
|
||||||
|
|
||||||
-@- Lower priority values gives higher priority.
|
|
||||||
-@- Priority Order:
|
|
||||||
(#@) Lowest priority.
|
|
||||||
(#@) Lowest hardware priority (IRQn position).
|
|
||||||
|
|
||||||
(#) Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority()
|
|
||||||
|
|
||||||
(#) Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ()
|
|
||||||
|
|
||||||
[..]
|
|
||||||
*** How to configure Systick using CORTEX HAL driver ***
|
|
||||||
========================================================
|
|
||||||
[..]
|
|
||||||
Setup SysTick Timer for time base.
|
|
||||||
|
|
||||||
(+) The HAL_SYSTICK_Config()function calls the SysTick_Config() function which
|
|
||||||
is a CMSIS function that:
|
|
||||||
(++) Configures the SysTick Reload register with value passed as function parameter.
|
|
||||||
(++) Configures the SysTick IRQ priority to the lowest value (0x03).
|
|
||||||
(++) Resets the SysTick Counter register.
|
|
||||||
(++) Configures the SysTick Counter clock source to be Core Clock Source (HCLK).
|
|
||||||
(++) Enables the SysTick Interrupt.
|
|
||||||
(++) Starts the SysTick Counter.
|
|
||||||
|
|
||||||
(+) You can change the SysTick Clock source to be HCLK_Div8 by calling the function
|
|
||||||
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK_DIV8) just after the
|
|
||||||
HAL_SYSTICK_Config() function call. The HAL_SYSTICK_CLKSourceConfig() function is defined
|
|
||||||
inside the stm32l0xx_hal_cortex.c file.
|
|
||||||
|
|
||||||
(+) You can change the SysTick IRQ priority by calling the
|
|
||||||
HAL_NVIC_SetPriority(SysTick_IRQn,...) function just after the HAL_SYSTICK_Config() function
|
|
||||||
call. The HAL_NVIC_SetPriority() call the NVIC_SetPriority() function which is a CMSIS function.
|
|
||||||
|
|
||||||
(+) To adjust the SysTick time base, use the following formula:
|
|
||||||
|
|
||||||
Reload Value = SysTick Counter Clock (Hz) x Desired Time base (s)
|
|
||||||
(++) Reload Value is the parameter to be passed for HAL_SYSTICK_Config() function
|
|
||||||
(++) Reload Value should not exceed 0xFFFFFF
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
|
||||||
|
|
||||||
/** @addtogroup CORTEX
|
|
||||||
* @brief CORTEX HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private types -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @addtogroup CORTEX_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @addtogroup CORTEX_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
||||||
* @brief Initialization and Configuration functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### Initialization and Configuration functions #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
This section provides the CORTEX HAL driver functions allowing to configure Interrupts
|
|
||||||
Systick functionalities
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets the priority of an interrupt.
|
|
||||||
* @param IRQn External interrupt number .
|
|
||||||
* This parameter can be an enumerator of IRQn_Type enumeration
|
|
||||||
* (For the complete STM32 Devices IRQ Channels list, please refer to stm32l0xx.h file)
|
|
||||||
* @param PreemptPriority The pre-emption priority for the IRQn channel.
|
|
||||||
* This parameter can be a value between 0 and 3.
|
|
||||||
* A lower priority value indicates a higher priority
|
|
||||||
* @param SubPriority the subpriority level for the IRQ channel.
|
|
||||||
* with stm32l0xx devices, this parameter is a dummy value and it is ignored, because
|
|
||||||
* no subpriority supported in Cortex M0+ based products.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority));
|
|
||||||
NVIC_SetPriority(IRQn,PreemptPriority);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable a device specific interrupt in the NVIC interrupt controller.
|
|
||||||
* @note To configure interrupts priority correctly, the NVIC_PriorityGroupConfig()
|
|
||||||
* function should be called before.
|
|
||||||
* @param IRQn External interrupt number .
|
|
||||||
* This parameter can be an enumerator of IRQn_Type enumeration
|
|
||||||
* (For the complete STM32 Devices IRQ Channels list, please refer to stm32l0xx.h file)
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_NVIC_DEVICE_IRQ(IRQn));
|
|
||||||
|
|
||||||
/* Enable interrupt */
|
|
||||||
NVIC_EnableIRQ(IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable a device specific interrupt in the NVIC interrupt controller.
|
|
||||||
* @param IRQn External interrupt number .
|
|
||||||
* This parameter can be an enumerator of IRQn_Type enumeration
|
|
||||||
* (For the complete STM32 Devices IRQ Channels list, please refer to stm32l0xx.h file)
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_NVIC_DEVICE_IRQ(IRQn));
|
|
||||||
|
|
||||||
/* Disable interrupt */
|
|
||||||
NVIC_DisableIRQ(IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initiate a system reset request to reset the MCU.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_NVIC_SystemReset(void)
|
|
||||||
{
|
|
||||||
/* System Reset */
|
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the System Timer with interrupt enabled and start the System Tick Timer (SysTick)
|
|
||||||
* Counter is in free running mode to generate periodic interrupts.
|
|
||||||
* @param TicksNumb Specifies the ticks Number of ticks between two interrupts.
|
|
||||||
* @retval status: - 0 Function succeeded.
|
|
||||||
* - 1 Function failed.
|
|
||||||
*/
|
|
||||||
uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb)
|
|
||||||
{
|
|
||||||
return SysTick_Config(TicksNumb);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup CORTEX_Exported_Functions_Group2 Peripheral Control functions
|
|
||||||
* @brief Cortex control functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### Peripheral Control functions #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
This subsection provides a set of functions allowing to control the CORTEX
|
|
||||||
(NVIC, SYSTICK) functionalities.
|
|
||||||
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets the priority of an interrupt.
|
|
||||||
* @param IRQn External interrupt number.
|
|
||||||
* This parameter can be an enumerator of IRQn_Type enumeration
|
|
||||||
* (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l0xxxx.h))
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
uint32_t HAL_NVIC_GetPriority(IRQn_Type IRQn)
|
|
||||||
{
|
|
||||||
/* Get priority for Cortex-M system or device specific interrupts */
|
|
||||||
return NVIC_GetPriority(IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets Pending bit of an external interrupt.
|
|
||||||
* @param IRQn External interrupt number
|
|
||||||
* This parameter can be an enumerator of IRQn_Type enumeration
|
|
||||||
* (For the complete STM32 Devices IRQ Channels list, please refer to stm32l0xx.h file)
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
|
||||||
{
|
|
||||||
/* Set interrupt pending */
|
|
||||||
NVIC_SetPendingIRQ(IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get Pending Interrupt (read the pending register in the NVIC
|
|
||||||
* and return the pending bit for the specified interrupt).
|
|
||||||
* @param IRQn External interrupt number .
|
|
||||||
* This parameter can be an enumerator of IRQn_Type enumeration
|
|
||||||
* (For the complete STM32 Devices IRQ Channels list, please refer to stm32l0xx.h file)
|
|
||||||
* @retval status: - 0 Interrupt status is not pending.
|
|
||||||
* - 1 Interrupt status is pending.
|
|
||||||
*/
|
|
||||||
uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
|
||||||
{
|
|
||||||
/* Return 1 if pending else 0 */
|
|
||||||
return NVIC_GetPendingIRQ(IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the pending bit of an external interrupt.
|
|
||||||
* @param IRQn External interrupt number .
|
|
||||||
* This parameter can be an enumerator of IRQn_Type enumeration
|
|
||||||
* (For the complete STM32 Devices IRQ Channels list, please refer to stm32l0xx.h file)
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
|
||||||
{
|
|
||||||
/* Clear pending interrupt */
|
|
||||||
NVIC_ClearPendingIRQ(IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure the SysTick clock source.
|
|
||||||
* @param CLKSource specifies the SysTick clock source.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg SYSTICK_CLKSOURCE_HCLK_DIV8: AHB clock divided by 8 selected as SysTick clock source.
|
|
||||||
* @arg SYSTICK_CLKSOURCE_HCLK: AHB clock selected as SysTick clock source.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_SYSTICK_CLK_SOURCE(CLKSource));
|
|
||||||
if (CLKSource == SYSTICK_CLKSOURCE_HCLK)
|
|
||||||
{
|
|
||||||
SysTick->CTRL |= SYSTICK_CLKSOURCE_HCLK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SysTick->CTRL &= ~SYSTICK_CLKSOURCE_HCLK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Handle SYSTICK interrupt request.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_SYSTICK_IRQHandler(void)
|
|
||||||
{
|
|
||||||
HAL_SYSTICK_Callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SYSTICK callback.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
__weak void HAL_SYSTICK_Callback(void)
|
|
||||||
{
|
|
||||||
/* NOTE : This function should not be modified, when the callback is needed,
|
|
||||||
the HAL_SYSTICK_Callback could be implemented in the user file
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (__MPU_PRESENT == 1U)
|
|
||||||
/**
|
|
||||||
* @brief Disable the MPU.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_MPU_Disable(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*Data Memory Barrier setup */
|
|
||||||
__DMB();
|
|
||||||
/* Disable the MPU */
|
|
||||||
MPU->CTRL = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the MPU.
|
|
||||||
* @param MPU_Control Specifies the control mode of the MPU during hard fault,
|
|
||||||
* NMI, FAULTMASK and privileged access to the default memory
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg MPU_HFNMI_PRIVDEF_NONE
|
|
||||||
* @arg MPU_HARDFAULT_NMI
|
|
||||||
* @arg MPU_PRIVILEGED_DEFAULT
|
|
||||||
* @arg MPU_HFNMI_PRIVDEF
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
|
|
||||||
void HAL_MPU_Enable(uint32_t MPU_Control)
|
|
||||||
{
|
|
||||||
/* Enable the MPU */
|
|
||||||
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
|
|
||||||
/* Data Synchronization Barrier setup */
|
|
||||||
__DSB();
|
|
||||||
/* Instruction Synchronization Barrier setup */
|
|
||||||
__ISB();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize and configure the Region and the memory to be protected.
|
|
||||||
* @param MPU_Init Pointer to a MPU_Region_InitTypeDef structure that contains
|
|
||||||
* the initialization and configuration information.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_MPU_REGION_NUMBER(MPU_Init->Number));
|
|
||||||
assert_param(IS_MPU_REGION_ENABLE(MPU_Init->Enable));
|
|
||||||
|
|
||||||
/* Set the Region number */
|
|
||||||
MPU->RNR = MPU_Init->Number;
|
|
||||||
|
|
||||||
if ((MPU_Init->Enable) == MPU_REGION_ENABLE)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_MPU_INSTRUCTION_ACCESS(MPU_Init->DisableExec));
|
|
||||||
assert_param(IS_MPU_REGION_PERMISSION_ATTRIBUTE(MPU_Init->AccessPermission));
|
|
||||||
assert_param(IS_MPU_ACCESS_SHAREABLE(MPU_Init->IsShareable));
|
|
||||||
assert_param(IS_MPU_ACCESS_CACHEABLE(MPU_Init->IsCacheable));
|
|
||||||
assert_param(IS_MPU_ACCESS_BUFFERABLE(MPU_Init->IsBufferable));
|
|
||||||
assert_param(IS_MPU_SUB_REGION_DISABLE(MPU_Init->SubRegionDisable));
|
|
||||||
assert_param(IS_MPU_REGION_SIZE(MPU_Init->Size));
|
|
||||||
|
|
||||||
/* Set the base adsress and set the 4 LSB to 0 */
|
|
||||||
MPU->RBAR = (MPU_Init->BaseAddress) & 0xfffffff0U;
|
|
||||||
|
|
||||||
/* Fill the field RASR */
|
|
||||||
MPU->RASR = ((uint32_t)MPU_Init->DisableExec << MPU_RASR_XN_Pos) |
|
|
||||||
((uint32_t)MPU_Init->AccessPermission << MPU_RASR_AP_Pos) |
|
|
||||||
((uint32_t)MPU_Init->IsShareable << MPU_RASR_S_Pos) |
|
|
||||||
((uint32_t)MPU_Init->IsCacheable << MPU_RASR_C_Pos) |
|
|
||||||
((uint32_t)MPU_Init->IsBufferable << MPU_RASR_B_Pos) |
|
|
||||||
((uint32_t)MPU_Init->SubRegionDisable << MPU_RASR_SRD_Pos) |
|
|
||||||
((uint32_t)MPU_Init->Size << MPU_RASR_SIZE_Pos) |
|
|
||||||
((uint32_t)MPU_Init->Enable << MPU_RASR_ENABLE_Pos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MPU->RBAR = 0x00U;
|
|
||||||
MPU->RASR = 0x00U;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* __MPU_PRESENT */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
@ -1,885 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_dma.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief DMA HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of the Direct Memory Access (DMA) peripheral:
|
|
||||||
* + Initialization and de-initialization functions
|
|
||||||
* + IO operation functions
|
|
||||||
* + Peripheral State and errors functions
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### How to use this driver #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
(#) Enable and configure the peripheral to be connected to the DMA Channel
|
|
||||||
(except for internal SRAM / FLASH memories: no initialization is
|
|
||||||
necessary).
|
|
||||||
|
|
||||||
(#) For a given Channel, program the required configuration through the following parameters:
|
|
||||||
Channel request, Transfer Direction, Source and Destination data formats,
|
|
||||||
Circular or Normal mode, Channel Priority level, Source and Destination Increment mode
|
|
||||||
using HAL_DMA_Init() function.
|
|
||||||
|
|
||||||
(#) Use HAL_DMA_GetState() function to return the DMA state and HAL_DMA_GetError() in case of error
|
|
||||||
detection.
|
|
||||||
|
|
||||||
(#) Use HAL_DMA_Abort() function to abort the current transfer
|
|
||||||
|
|
||||||
-@- In Memory-to-Memory transfer mode, Circular mode is not allowed.
|
|
||||||
|
|
||||||
*** Polling mode IO operation ***
|
|
||||||
=================================
|
|
||||||
[..]
|
|
||||||
(+) Use HAL_DMA_Start() to start DMA transfer after the configuration of Source
|
|
||||||
address and destination address and the Length of data to be transferred
|
|
||||||
(+) Use HAL_DMA_PollForTransfer() to poll for the end of current transfer, in this
|
|
||||||
case a fixed Timeout can be configured by User depending from his application.
|
|
||||||
|
|
||||||
*** Interrupt mode IO operation ***
|
|
||||||
===================================
|
|
||||||
[..]
|
|
||||||
(+) Configure the DMA interrupt priority using HAL_NVIC_SetPriority()
|
|
||||||
(+) Enable the DMA IRQ handler using HAL_NVIC_EnableIRQ()
|
|
||||||
(+) Use HAL_DMA_Start_IT() to start DMA transfer after the configuration of
|
|
||||||
Source address and destination address and the Length of data to be transferred.
|
|
||||||
In this case the DMA interrupt is configured
|
|
||||||
(+) Use HAL_DMA_IRQHandler() called under DMA_IRQHandler() Interrupt subroutine
|
|
||||||
(+) At the end of data transfer HAL_DMA_IRQHandler() function is executed and user can
|
|
||||||
add his own function to register callbacks with HAL_DMA_RegisterCallback().
|
|
||||||
|
|
||||||
*** DMA HAL driver macros list ***
|
|
||||||
=============================================
|
|
||||||
[..]
|
|
||||||
Below the list of macros in DMA HAL driver.
|
|
||||||
|
|
||||||
(+) __HAL_DMA_ENABLE: Enable the specified DMA Channel.
|
|
||||||
(+) __HAL_DMA_DISABLE: Disable the specified DMA Channel.
|
|
||||||
(+) __HAL_DMA_GET_FLAG: Get the DMA Channel pending flags.
|
|
||||||
(+) __HAL_DMA_CLEAR_FLAG: Clear the DMA Channel pending flags.
|
|
||||||
(+) __HAL_DMA_ENABLE_IT: Enable the specified DMA Channel interrupts.
|
|
||||||
(+) __HAL_DMA_DISABLE_IT: Disable the specified DMA Channel interrupts.
|
|
||||||
(+) __HAL_DMA_GET_IT_SOURCE: Check whether the specified DMA Channel interrupt has occurred or not.
|
|
||||||
|
|
||||||
[..]
|
|
||||||
(@) You can refer to the DMA HAL driver header file for more useful macros
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA DMA
|
|
||||||
* @brief DMA HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_DMA_MODULE_ENABLED
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/** @defgroup DMA_Private_Functions DMA Private Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Exported_Functions DMA Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
||||||
* @brief Initialization and de-initialization functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Initialization and de-initialization functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..]
|
|
||||||
This section provides functions allowing to initialize the DMA Channel source
|
|
||||||
and destination addresses, incrementation and data sizes, transfer direction,
|
|
||||||
circular/normal mode selection, memory-to-memory mode selection and Channel priority value.
|
|
||||||
[..]
|
|
||||||
The HAL_DMA_Init() function follows the DMA configuration procedures as described in
|
|
||||||
reference manual.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the DMA according to the specified
|
|
||||||
* parameters in the DMA_InitTypeDef and initialize the associated handle.
|
|
||||||
* @param hdma Pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
|
|
||||||
{
|
|
||||||
uint32_t tmp;
|
|
||||||
|
|
||||||
/* Check the DMA handle allocation */
|
|
||||||
if(hdma == NULL)
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
|
|
||||||
assert_param(IS_DMA_ALL_REQUEST(hdma->Init.Request));
|
|
||||||
assert_param(IS_DMA_DIRECTION(hdma->Init.Direction));
|
|
||||||
assert_param(IS_DMA_PERIPHERAL_INC_STATE(hdma->Init.PeriphInc));
|
|
||||||
assert_param(IS_DMA_MEMORY_INC_STATE(hdma->Init.MemInc));
|
|
||||||
assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(hdma->Init.PeriphDataAlignment));
|
|
||||||
assert_param(IS_DMA_MEMORY_DATA_SIZE(hdma->Init.MemDataAlignment));
|
|
||||||
assert_param(IS_DMA_MODE(hdma->Init.Mode));
|
|
||||||
assert_param(IS_DMA_PRIORITY(hdma->Init.Priority));
|
|
||||||
|
|
||||||
/* Compute the channel index */
|
|
||||||
/* Only one DMA: DMA1 */
|
|
||||||
hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA1_Channel1) / ((uint32_t)DMA1_Channel2 - (uint32_t)DMA1_Channel1)) << 2;
|
|
||||||
hdma->DmaBaseAddress = DMA1;
|
|
||||||
|
|
||||||
/* Change DMA peripheral state */
|
|
||||||
hdma->State = HAL_DMA_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Get the CR register value */
|
|
||||||
tmp = hdma->Instance->CCR;
|
|
||||||
|
|
||||||
/* Clear PL, MSIZE, PSIZE, MINC, PINC, CIRC, DIR and MEM2MEM bits */
|
|
||||||
tmp &= ((uint32_t)~(DMA_CCR_PL | DMA_CCR_MSIZE | DMA_CCR_PSIZE |
|
|
||||||
DMA_CCR_MINC | DMA_CCR_PINC | DMA_CCR_CIRC |
|
|
||||||
DMA_CCR_DIR | DMA_CCR_MEM2MEM));
|
|
||||||
|
|
||||||
/* Prepare the DMA Channel configuration */
|
|
||||||
tmp |= hdma->Init.Direction |
|
|
||||||
hdma->Init.PeriphInc | hdma->Init.MemInc |
|
|
||||||
hdma->Init.PeriphDataAlignment | hdma->Init.MemDataAlignment |
|
|
||||||
hdma->Init.Mode | hdma->Init.Priority;
|
|
||||||
|
|
||||||
/* Write to DMA Channel CR register */
|
|
||||||
hdma->Instance->CCR = tmp;
|
|
||||||
|
|
||||||
/* Set request selection */
|
|
||||||
if(hdma->Init.Direction != DMA_MEMORY_TO_MEMORY)
|
|
||||||
{
|
|
||||||
/* Write to DMA channel selection register */
|
|
||||||
/* Reset request selection for DMA1 Channelx */
|
|
||||||
DMA1_CSELR->CSELR &= ~(DMA_CSELR_C1S << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Configure request selection for DMA1 Channelx */
|
|
||||||
DMA1_CSELR->CSELR |= (uint32_t) (hdma->Init.Request << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialise the error code */
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_NONE;
|
|
||||||
|
|
||||||
/* Initialize the DMA state*/
|
|
||||||
hdma->State = HAL_DMA_STATE_READY;
|
|
||||||
|
|
||||||
/* Allocate lock resource and initialize it */
|
|
||||||
hdma->Lock = HAL_UNLOCKED;
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief DeInitialize the DMA peripheral.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Check the DMA handle allocation */
|
|
||||||
if (NULL == hdma )
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
|
|
||||||
|
|
||||||
/* Disable the selected DMA Channelx */
|
|
||||||
__HAL_DMA_DISABLE(hdma);
|
|
||||||
|
|
||||||
/* Compute the channel index */
|
|
||||||
/* DMA1 */
|
|
||||||
hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA1_Channel1) / ((uint32_t)DMA1_Channel2 - (uint32_t)DMA1_Channel1)) << 2;
|
|
||||||
hdma->DmaBaseAddress = DMA1;
|
|
||||||
|
|
||||||
/* Reset DMA Channel control register */
|
|
||||||
hdma->Instance->CCR = 0U;
|
|
||||||
|
|
||||||
/* Clear all flags */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Reset DMA channel selection register */
|
|
||||||
/* DMA1 */
|
|
||||||
DMA1_CSELR->CSELR &= ~(DMA_CSELR_C1S << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Clean callbacks */
|
|
||||||
hdma->XferCpltCallback = NULL;
|
|
||||||
hdma->XferHalfCpltCallback = NULL;
|
|
||||||
hdma->XferErrorCallback = NULL;
|
|
||||||
hdma->XferAbortCallback = NULL;
|
|
||||||
|
|
||||||
/* Initialise the error code */
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_NONE;
|
|
||||||
|
|
||||||
/* Initialize the DMA state */
|
|
||||||
hdma->State = HAL_DMA_STATE_RESET;
|
|
||||||
|
|
||||||
/* Release Lock */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup DMA_Exported_Functions_Group2 Input and Output operation functions
|
|
||||||
* @brief Input and Output operation functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### IO operation functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Configure the source, destination address and data length and Start DMA transfer
|
|
||||||
(+) Configure the source, destination address and data length and
|
|
||||||
Start DMA transfer with interrupt
|
|
||||||
(+) Abort DMA transfer
|
|
||||||
(+) Poll for transfer complete
|
|
||||||
(+) Handle DMA interrupt request
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Start the DMA Transfer.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @param SrcAddress The source memory Buffer address
|
|
||||||
* @param DstAddress The destination memory Buffer address
|
|
||||||
* @param DataLength The length of data to be transferred from source to destination
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_DMA_BUFFER_SIZE(DataLength));
|
|
||||||
|
|
||||||
/* Process locked */
|
|
||||||
__HAL_LOCK(hdma);
|
|
||||||
|
|
||||||
if(HAL_DMA_STATE_READY == hdma->State)
|
|
||||||
{
|
|
||||||
/* Change DMA peripheral state */
|
|
||||||
hdma->State = HAL_DMA_STATE_BUSY;
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_NONE;
|
|
||||||
|
|
||||||
/* Disable the peripheral */
|
|
||||||
__HAL_DMA_DISABLE(hdma);
|
|
||||||
|
|
||||||
/* Configure the source, destination address and the data length & clear flags*/
|
|
||||||
DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength);
|
|
||||||
|
|
||||||
/* Enable the Peripheral */
|
|
||||||
__HAL_DMA_ENABLE(hdma);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
status = HAL_BUSY;
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Start the DMA Transfer with interrupt enabled.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @param SrcAddress The source memory Buffer address
|
|
||||||
* @param DstAddress The destination memory Buffer address
|
|
||||||
* @param DataLength The length of data to be transferred from source to destination
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_DMA_BUFFER_SIZE(DataLength));
|
|
||||||
|
|
||||||
/* Process locked */
|
|
||||||
__HAL_LOCK(hdma);
|
|
||||||
|
|
||||||
if(HAL_DMA_STATE_READY == hdma->State)
|
|
||||||
{
|
|
||||||
/* Change DMA peripheral state */
|
|
||||||
hdma->State = HAL_DMA_STATE_BUSY;
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_NONE;
|
|
||||||
|
|
||||||
/* Disable the peripheral */
|
|
||||||
__HAL_DMA_DISABLE(hdma);
|
|
||||||
|
|
||||||
/* Configure the source, destination address and the data length & clear flags*/
|
|
||||||
DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength);
|
|
||||||
|
|
||||||
/* Enable the transfer complete interrupt */
|
|
||||||
/* Enable the transfer Error interrupt */
|
|
||||||
if(NULL != hdma->XferHalfCpltCallback )
|
|
||||||
{
|
|
||||||
/* Enable the Half transfer complete interrupt as well */
|
|
||||||
__HAL_DMA_ENABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
__HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT);
|
|
||||||
__HAL_DMA_ENABLE_IT(hdma, (DMA_IT_TC | DMA_IT_TE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable the Peripheral */
|
|
||||||
__HAL_DMA_ENABLE(hdma);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
/* Remain BUSY */
|
|
||||||
status = HAL_BUSY;
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Abort the DMA Transfer.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Check the DMA peripheral state */
|
|
||||||
if(hdma->State != HAL_DMA_STATE_BUSY)
|
|
||||||
{
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Disable DMA IT */
|
|
||||||
__HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
|
|
||||||
|
|
||||||
/* Disable the channel */
|
|
||||||
__HAL_DMA_DISABLE(hdma);
|
|
||||||
|
|
||||||
/* Clear all flags */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Change the DMA state */
|
|
||||||
hdma->State = HAL_DMA_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Aborts the DMA Transfer in Interrupt mode.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
if(HAL_DMA_STATE_BUSY != hdma->State)
|
|
||||||
{
|
|
||||||
/* no transfer ongoing */
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
|
|
||||||
|
|
||||||
status = HAL_ERROR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Disable DMA IT */
|
|
||||||
__HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
|
|
||||||
|
|
||||||
/* Disable the channel */
|
|
||||||
__HAL_DMA_DISABLE(hdma);
|
|
||||||
|
|
||||||
/* Clear all flags */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Change the DMA state */
|
|
||||||
hdma->State = HAL_DMA_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
/* Call User Abort callback */
|
|
||||||
if(hdma->XferAbortCallback != NULL)
|
|
||||||
{
|
|
||||||
hdma->XferAbortCallback(hdma);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Polling for transfer complete.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @param CompleteLevel Specifies the DMA level complete.
|
|
||||||
* @param Timeout Timeout duration.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout)
|
|
||||||
{
|
|
||||||
uint32_t temp;
|
|
||||||
uint32_t tickstart;
|
|
||||||
|
|
||||||
if(HAL_DMA_STATE_BUSY != hdma->State)
|
|
||||||
{
|
|
||||||
/* no transfer ongoing */
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Polling mode not supported in circular mode */
|
|
||||||
if (0U != (hdma->Instance->CCR & DMA_CCR_CIRC))
|
|
||||||
{
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED;
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the level transfer complete flag */
|
|
||||||
if (HAL_DMA_FULL_TRANSFER == CompleteLevel)
|
|
||||||
{
|
|
||||||
/* Transfer Complete flag */
|
|
||||||
temp = DMA_FLAG_TC1 << (hdma->ChannelIndex & 0x1cU);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Half Transfer Complete flag */
|
|
||||||
temp = DMA_FLAG_HT1 << (hdma->ChannelIndex & 0x1cU);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get tick */
|
|
||||||
tickstart = HAL_GetTick();
|
|
||||||
|
|
||||||
while(0U == (hdma->DmaBaseAddress->ISR & temp))
|
|
||||||
{
|
|
||||||
if((0U != (hdma->DmaBaseAddress->ISR & (DMA_FLAG_TE1 << (hdma->ChannelIndex& 0x1cU)))))
|
|
||||||
{
|
|
||||||
/* When a DMA transfer error occurs */
|
|
||||||
/* A hardware clear of its EN bits is performed */
|
|
||||||
/* Clear all flags */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Update error code */
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_TE;
|
|
||||||
|
|
||||||
/* Change the DMA state */
|
|
||||||
hdma->State= HAL_DMA_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
/* Check for the Timeout */
|
|
||||||
if(Timeout != HAL_MAX_DELAY)
|
|
||||||
{
|
|
||||||
if(((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
|
|
||||||
{
|
|
||||||
/* Update error code */
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_TIMEOUT;
|
|
||||||
|
|
||||||
/* Change the DMA state */
|
|
||||||
hdma->State = HAL_DMA_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(HAL_DMA_FULL_TRANSFER == CompleteLevel)
|
|
||||||
{
|
|
||||||
/* Clear the transfer complete flag */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_FLAG_TC1 << (hdma->ChannelIndex& 0x1cU));
|
|
||||||
|
|
||||||
/* The selected Channelx EN bit is cleared (DMA is disabled and
|
|
||||||
all transfers are complete) */
|
|
||||||
hdma->State = HAL_DMA_STATE_READY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Clear the half transfer complete flag */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_FLAG_HT1 << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Handle DMA interrupt request.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma)
|
|
||||||
{
|
|
||||||
uint32_t flag_it = hdma->DmaBaseAddress->ISR;
|
|
||||||
uint32_t source_it = hdma->Instance->CCR;
|
|
||||||
|
|
||||||
/* Half Transfer Complete Interrupt management ******************************/
|
|
||||||
if ((0U != (flag_it & (DMA_FLAG_HT1 << (hdma->ChannelIndex & 0x1cU)))) && (0U != (source_it & DMA_IT_HT)))
|
|
||||||
{
|
|
||||||
/* Disable the half transfer interrupt if the DMA mode is not CIRCULAR */
|
|
||||||
if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0U)
|
|
||||||
{
|
|
||||||
/* Disable the half transfer interrupt */
|
|
||||||
__HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT);
|
|
||||||
}
|
|
||||||
/* Clear the half transfer complete flag */
|
|
||||||
hdma->DmaBaseAddress->IFCR = DMA_ISR_HTIF1 << (hdma->ChannelIndex & 0x1cU);
|
|
||||||
|
|
||||||
/* DMA peripheral state is not updated in Half Transfer */
|
|
||||||
/* but in Transfer Complete case */
|
|
||||||
|
|
||||||
if(hdma->XferHalfCpltCallback != NULL)
|
|
||||||
{
|
|
||||||
/* Half transfer callback */
|
|
||||||
hdma->XferHalfCpltCallback(hdma);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Transfer Complete Interrupt management ***********************************/
|
|
||||||
else if ((0U != (flag_it & (DMA_FLAG_TC1 << (hdma->ChannelIndex & 0x1cU)))) && (0U != (source_it & DMA_IT_TC)))
|
|
||||||
{
|
|
||||||
if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0U)
|
|
||||||
{
|
|
||||||
/* Disable the transfer complete and error interrupt */
|
|
||||||
__HAL_DMA_DISABLE_IT(hdma, DMA_IT_TE | DMA_IT_TC);
|
|
||||||
|
|
||||||
/* Change the DMA state */
|
|
||||||
hdma->State = HAL_DMA_STATE_READY;
|
|
||||||
}
|
|
||||||
/* Clear the transfer complete flag */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_ISR_TCIF1 << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
if(hdma->XferCpltCallback != NULL)
|
|
||||||
{
|
|
||||||
/* Transfer complete callback */
|
|
||||||
hdma->XferCpltCallback(hdma);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Transfer Error Interrupt management **************************************/
|
|
||||||
else if ((0U != (flag_it & (DMA_FLAG_TE1 << (hdma->ChannelIndex & 0x1cU)))) && (0U != (source_it & DMA_IT_TE)))
|
|
||||||
{
|
|
||||||
/* When a DMA transfer error occurs */
|
|
||||||
/* A hardware clear of its EN bits is performed */
|
|
||||||
/* Disable ALL DMA IT */
|
|
||||||
__HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
|
|
||||||
|
|
||||||
/* Clear all flags */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Update error code */
|
|
||||||
hdma->ErrorCode = HAL_DMA_ERROR_TE;
|
|
||||||
|
|
||||||
/* Change the DMA state */
|
|
||||||
hdma->State = HAL_DMA_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
if (hdma->XferErrorCallback != NULL)
|
|
||||||
{
|
|
||||||
/* Transfer error callback */
|
|
||||||
hdma->XferErrorCallback(hdma);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Nothing To Do */
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register callbacks
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @param CallbackID User Callback identifer
|
|
||||||
* a HAL_DMA_CallbackIDTypeDef ENUM as parameter.
|
|
||||||
* @param pCallback pointer to private callbacsk function which has pointer to
|
|
||||||
* a DMA_HandleTypeDef structure as parameter.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)( DMA_HandleTypeDef * _hdma))
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Process locked */
|
|
||||||
__HAL_LOCK(hdma);
|
|
||||||
|
|
||||||
if(HAL_DMA_STATE_READY == hdma->State)
|
|
||||||
{
|
|
||||||
switch (CallbackID)
|
|
||||||
{
|
|
||||||
case HAL_DMA_XFER_CPLT_CB_ID:
|
|
||||||
hdma->XferCpltCallback = pCallback;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HAL_DMA_XFER_HALFCPLT_CB_ID:
|
|
||||||
hdma->XferHalfCpltCallback = pCallback;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HAL_DMA_XFER_ERROR_CB_ID:
|
|
||||||
hdma->XferErrorCallback = pCallback;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HAL_DMA_XFER_ABORT_CB_ID:
|
|
||||||
hdma->XferAbortCallback = pCallback;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
status = HAL_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release Lock */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief UnRegister callbacks
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @param CallbackID User Callback identifer
|
|
||||||
* a HAL_DMA_CallbackIDTypeDef ENUM as parameter.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Process locked */
|
|
||||||
__HAL_LOCK(hdma);
|
|
||||||
|
|
||||||
if(HAL_DMA_STATE_READY == hdma->State)
|
|
||||||
{
|
|
||||||
switch (CallbackID)
|
|
||||||
{
|
|
||||||
case HAL_DMA_XFER_CPLT_CB_ID:
|
|
||||||
hdma->XferCpltCallback = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HAL_DMA_XFER_HALFCPLT_CB_ID:
|
|
||||||
hdma->XferHalfCpltCallback = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HAL_DMA_XFER_ERROR_CB_ID:
|
|
||||||
hdma->XferErrorCallback = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HAL_DMA_XFER_ABORT_CB_ID:
|
|
||||||
hdma->XferAbortCallback = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HAL_DMA_XFER_ALL_CB_ID:
|
|
||||||
hdma->XferCpltCallback = NULL;
|
|
||||||
hdma->XferHalfCpltCallback = NULL;
|
|
||||||
hdma->XferErrorCallback = NULL;
|
|
||||||
hdma->XferAbortCallback = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
status = HAL_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release Lock */
|
|
||||||
__HAL_UNLOCK(hdma);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup DMA_Exported_Functions_Group3 Peripheral State and Errors functions
|
|
||||||
* @brief Peripheral State and Errors functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Peripheral State and Errors functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..]
|
|
||||||
This subsection provides functions allowing to
|
|
||||||
(+) Check the DMA state
|
|
||||||
(+) Get error code
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the DMA handle state.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @retval HAL state
|
|
||||||
*/
|
|
||||||
HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma)
|
|
||||||
{
|
|
||||||
/* Return DMA handle state */
|
|
||||||
return hdma->State;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the DMA error code.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @retval DMA Error Code
|
|
||||||
*/
|
|
||||||
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
|
|
||||||
{
|
|
||||||
return hdma->ErrorCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup DMA_Private_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets the DMA Transfer parameter.
|
|
||||||
* @param hdma pointer to a DMA_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified DMA Channel.
|
|
||||||
* @param SrcAddress The source memory Buffer address
|
|
||||||
* @param DstAddress The destination memory Buffer address
|
|
||||||
* @param DataLength The length of data to be transferred from source to destination
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
|
|
||||||
{
|
|
||||||
/* Clear all flags */
|
|
||||||
hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex & 0x1cU));
|
|
||||||
|
|
||||||
/* Configure DMA Channel data length */
|
|
||||||
hdma->Instance->CNDTR = DataLength;
|
|
||||||
|
|
||||||
/* Memory to Peripheral */
|
|
||||||
if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH)
|
|
||||||
{
|
|
||||||
/* Configure DMA Channel destination address */
|
|
||||||
hdma->Instance->CPAR = DstAddress;
|
|
||||||
|
|
||||||
/* Configure DMA Channel source address */
|
|
||||||
hdma->Instance->CMAR = SrcAddress;
|
|
||||||
}
|
|
||||||
/* Peripheral to Memory */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Configure DMA Channel source address */
|
|
||||||
hdma->Instance->CPAR = SrcAddress;
|
|
||||||
|
|
||||||
/* Configure DMA Channel destination address */
|
|
||||||
hdma->Instance->CMAR = DstAddress;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,559 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_exti.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief EXTI HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of the Extended Interrupts and events controller (EXTI) peripheral:
|
|
||||||
* + Initialization and de-initialization functions
|
|
||||||
* + IO operation functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### EXTI Peripheral features #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
(+) Each Exti line can be configured within this driver.
|
|
||||||
|
|
||||||
(+) Exti line can be configured in 3 different modes
|
|
||||||
(++) Interrupt
|
|
||||||
(++) Event
|
|
||||||
(++) Both of them
|
|
||||||
|
|
||||||
(+) Configurable Exti lines can be configured with 3 different triggers
|
|
||||||
(++) Rising
|
|
||||||
(++) Falling
|
|
||||||
(++) Both of them
|
|
||||||
|
|
||||||
(+) When set in interrupt mode, configurable Exti lines have two different
|
|
||||||
interrupts pending registers which allow to distinguish which transition
|
|
||||||
occurs:
|
|
||||||
(++) Rising edge pending interrupt
|
|
||||||
(++) Falling
|
|
||||||
|
|
||||||
(+) Exti lines 0 to 15 are linked to gpio pin number 0 to 15. Gpio port can
|
|
||||||
be selected through multiplexer.
|
|
||||||
|
|
||||||
##### How to use this driver #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
|
|
||||||
(#) Configure the EXTI line using HAL_EXTI_SetConfigLine().
|
|
||||||
(++) Choose the interrupt line number by setting "Line" member from
|
|
||||||
EXTI_ConfigTypeDef structure.
|
|
||||||
(++) Configure the interrupt and/or event mode using "Mode" member from
|
|
||||||
EXTI_ConfigTypeDef structure.
|
|
||||||
(++) For configurable lines, configure rising and/or falling trigger
|
|
||||||
"Trigger" member from EXTI_ConfigTypeDef structure.
|
|
||||||
(++) For Exti lines linked to gpio, choose gpio port using "GPIOSel"
|
|
||||||
member from GPIO_InitTypeDef structure.
|
|
||||||
|
|
||||||
(#) Get current Exti configuration of a dedicated line using
|
|
||||||
HAL_EXTI_GetConfigLine().
|
|
||||||
(++) Provide exiting handle as parameter.
|
|
||||||
(++) Provide pointer on EXTI_ConfigTypeDef structure as second parameter.
|
|
||||||
|
|
||||||
(#) Clear Exti configuration of a dedicated line using HAL_EXTI_GetConfigLine().
|
|
||||||
(++) Provide exiting handle as parameter.
|
|
||||||
|
|
||||||
(#) Register callback to treat Exti interrupts using HAL_EXTI_RegisterCallback().
|
|
||||||
(++) Provide exiting handle as first parameter.
|
|
||||||
(++) Provide which callback will be registered using one value from
|
|
||||||
EXTI_CallbackIDTypeDef.
|
|
||||||
(++) Provide callback function pointer.
|
|
||||||
|
|
||||||
(#) Get interrupt pending bit using HAL_EXTI_GetPending().
|
|
||||||
|
|
||||||
(#) Clear interrupt pending bit using HAL_EXTI_GetPending().
|
|
||||||
|
|
||||||
(#) Generate software interrupt using HAL_EXTI_GenerateSWI().
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup EXTI
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/** MISRA C:2012 deviation rule has been granted for following rule:
|
|
||||||
* Rule-18.1_b - Medium: Array `EXTICR' 1st subscript interval [0,7] may be out
|
|
||||||
* of bounds [0,3] in following API :
|
|
||||||
* HAL_EXTI_SetConfigLine
|
|
||||||
* HAL_EXTI_GetConfigLine
|
|
||||||
* HAL_EXTI_ClearConfigLine
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private defines -----------------------------------------------------------*/
|
|
||||||
/** @defgroup EXTI_Private_Constants EXTI Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @addtogroup EXTI_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup EXTI_Exported_Functions_Group1
|
|
||||||
* @brief Configuration functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Configuration functions #####
|
|
||||||
===============================================================================
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set configuration of a dedicated Exti line.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @param pExtiConfig Pointer on EXTI configuration to be set.
|
|
||||||
* @retval HAL Status.
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig)
|
|
||||||
{
|
|
||||||
uint32_t regval;
|
|
||||||
uint32_t linepos;
|
|
||||||
uint32_t maskline;
|
|
||||||
|
|
||||||
/* Check null pointer */
|
|
||||||
if ((hexti == NULL) || (pExtiConfig == NULL))
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check parameters */
|
|
||||||
assert_param(IS_EXTI_LINE(pExtiConfig->Line));
|
|
||||||
assert_param(IS_EXTI_MODE(pExtiConfig->Mode));
|
|
||||||
|
|
||||||
/* Assign line number to handle */
|
|
||||||
hexti->Line = pExtiConfig->Line;
|
|
||||||
|
|
||||||
/* Compute line mask */
|
|
||||||
linepos = (pExtiConfig->Line & EXTI_PIN_MASK);
|
|
||||||
maskline = (1uL << linepos);
|
|
||||||
|
|
||||||
/* Configure triggers for configurable lines */
|
|
||||||
if ((pExtiConfig->Line & EXTI_CONFIG) != 0x00u)
|
|
||||||
{
|
|
||||||
assert_param(IS_EXTI_TRIGGER(pExtiConfig->Trigger));
|
|
||||||
|
|
||||||
/* Configure rising trigger */
|
|
||||||
/* Mask or set line */
|
|
||||||
if ((pExtiConfig->Trigger & EXTI_TRIGGER_RISING) != 0x00u)
|
|
||||||
{
|
|
||||||
EXTI->RTSR |= maskline;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EXTI->RTSR &= ~maskline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure falling trigger */
|
|
||||||
/* Mask or set line */
|
|
||||||
if ((pExtiConfig->Trigger & EXTI_TRIGGER_FALLING) != 0x00u)
|
|
||||||
{
|
|
||||||
EXTI->FTSR |= maskline;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EXTI->FTSR &= ~maskline;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Configure gpio port selection in case of gpio exti line */
|
|
||||||
if ((pExtiConfig->Line & EXTI_GPIO) == EXTI_GPIO)
|
|
||||||
{
|
|
||||||
assert_param(IS_EXTI_GPIO_PORT(pExtiConfig->GPIOSel));
|
|
||||||
assert_param(IS_EXTI_GPIO_PIN(linepos));
|
|
||||||
|
|
||||||
regval = SYSCFG->EXTICR[linepos >> 2u];
|
|
||||||
regval &= ~(SYSCFG_EXTICR1_EXTI0 << (SYSCFG_EXTICR1_EXTI1_Pos * (linepos & 0x03u)));
|
|
||||||
regval |= (pExtiConfig->GPIOSel << (SYSCFG_EXTICR1_EXTI1_Pos * (linepos & 0x03u)));
|
|
||||||
SYSCFG->EXTICR[linepos >> 2u] = regval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure interrupt mode : read current mode */
|
|
||||||
/* Mask or set line */
|
|
||||||
if ((pExtiConfig->Mode & EXTI_MODE_INTERRUPT) != 0x00u)
|
|
||||||
{
|
|
||||||
EXTI->IMR |= maskline;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EXTI->IMR &= ~maskline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure event mode : read current mode */
|
|
||||||
/* Mask or set line */
|
|
||||||
if ((pExtiConfig->Mode & EXTI_MODE_EVENT) != 0x00u)
|
|
||||||
{
|
|
||||||
EXTI->EMR |= maskline;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EXTI->EMR &= ~maskline;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get configuration of a dedicated Exti line.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @param pExtiConfig Pointer on structure to store Exti configuration.
|
|
||||||
* @retval HAL Status.
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig)
|
|
||||||
{
|
|
||||||
uint32_t regval;
|
|
||||||
uint32_t linepos;
|
|
||||||
uint32_t maskline;
|
|
||||||
|
|
||||||
/* Check null pointer */
|
|
||||||
if ((hexti == NULL) || (pExtiConfig == NULL))
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the parameter */
|
|
||||||
assert_param(IS_EXTI_LINE(hexti->Line));
|
|
||||||
|
|
||||||
/* Store handle line number to configuration structure */
|
|
||||||
pExtiConfig->Line = hexti->Line;
|
|
||||||
|
|
||||||
/* Compute line mask */
|
|
||||||
linepos = (pExtiConfig->Line & EXTI_PIN_MASK);
|
|
||||||
maskline = (1uL << linepos);
|
|
||||||
|
|
||||||
/* 1] Get core mode : interrupt */
|
|
||||||
|
|
||||||
/* Check if selected line is enable */
|
|
||||||
if ((EXTI->IMR & maskline) != 0x00u)
|
|
||||||
{
|
|
||||||
pExtiConfig->Mode = EXTI_MODE_INTERRUPT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pExtiConfig->Mode = EXTI_MODE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get event mode */
|
|
||||||
/* Check if selected line is enable */
|
|
||||||
if ((EXTI->EMR & maskline) != 0x00u)
|
|
||||||
{
|
|
||||||
pExtiConfig->Mode |= EXTI_MODE_EVENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 2] Get trigger for configurable lines : rising */
|
|
||||||
if ((pExtiConfig->Line & EXTI_CONFIG) != 0x00u)
|
|
||||||
{
|
|
||||||
/* Check if configuration of selected line is enable */
|
|
||||||
if ((EXTI->RTSR & maskline) != 0x00u)
|
|
||||||
{
|
|
||||||
pExtiConfig->Trigger = EXTI_TRIGGER_RISING;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pExtiConfig->Trigger = EXTI_TRIGGER_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get falling configuration */
|
|
||||||
/* Check if configuration of selected line is enable */
|
|
||||||
if ((EXTI->FTSR & maskline) != 0x00u)
|
|
||||||
{
|
|
||||||
pExtiConfig->Trigger |= EXTI_TRIGGER_FALLING;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get Gpio port selection for gpio lines */
|
|
||||||
if ((pExtiConfig->Line & EXTI_GPIO) == EXTI_GPIO)
|
|
||||||
{
|
|
||||||
assert_param(IS_EXTI_GPIO_PIN(linepos));
|
|
||||||
|
|
||||||
regval = SYSCFG->EXTICR[linepos >> 2u];
|
|
||||||
pExtiConfig->GPIOSel = ((regval << (SYSCFG_EXTICR1_EXTI1_Pos * (3uL - (linepos & 0x03u)))) >> 24);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pExtiConfig->GPIOSel = 0x00u;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* No Trigger selected */
|
|
||||||
pExtiConfig->Trigger = EXTI_TRIGGER_NONE;
|
|
||||||
pExtiConfig->GPIOSel = 0x00u;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear whole configuration of a dedicated Exti line.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @retval HAL Status.
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti)
|
|
||||||
{
|
|
||||||
uint32_t regval;
|
|
||||||
uint32_t linepos;
|
|
||||||
uint32_t maskline;
|
|
||||||
|
|
||||||
/* Check null pointer */
|
|
||||||
if (hexti == NULL)
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the parameter */
|
|
||||||
assert_param(IS_EXTI_LINE(hexti->Line));
|
|
||||||
|
|
||||||
/* compute line mask */
|
|
||||||
linepos = (hexti->Line & EXTI_PIN_MASK);
|
|
||||||
maskline = (1uL << linepos);
|
|
||||||
|
|
||||||
/* 1] Clear interrupt mode */
|
|
||||||
EXTI->IMR = (EXTI->IMR & ~maskline);
|
|
||||||
|
|
||||||
/* 2] Clear event mode */
|
|
||||||
EXTI->EMR = (EXTI->EMR & ~maskline);
|
|
||||||
|
|
||||||
/* 3] Clear triggers in case of configurable lines */
|
|
||||||
if ((hexti->Line & EXTI_CONFIG) != 0x00u)
|
|
||||||
{
|
|
||||||
EXTI->RTSR = (EXTI->RTSR & ~maskline);
|
|
||||||
EXTI->FTSR = (EXTI->FTSR & ~maskline);
|
|
||||||
|
|
||||||
/* Get Gpio port selection for gpio lines */
|
|
||||||
if ((hexti->Line & EXTI_GPIO) == EXTI_GPIO)
|
|
||||||
{
|
|
||||||
assert_param(IS_EXTI_GPIO_PIN(linepos));
|
|
||||||
|
|
||||||
regval = SYSCFG->EXTICR[linepos >> 2u];
|
|
||||||
regval &= ~(SYSCFG_EXTICR1_EXTI0 << (SYSCFG_EXTICR1_EXTI1_Pos * (linepos & 0x03u)));
|
|
||||||
SYSCFG->EXTICR[linepos >> 2u] = regval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register callback for a dedicated Exti line.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @param CallbackID User callback identifier.
|
|
||||||
* This parameter can be one of @arg @ref EXTI_CallbackIDTypeDef values.
|
|
||||||
* @param pPendingCbfn function pointer to be stored as callback.
|
|
||||||
* @retval HAL Status.
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void))
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
switch (CallbackID)
|
|
||||||
{
|
|
||||||
case HAL_EXTI_COMMON_CB_ID:
|
|
||||||
hexti->PendingCallback = pPendingCbfn;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
status = HAL_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Store line number as handle private field.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @param ExtiLine Exti line number.
|
|
||||||
* This parameter can be from 0 to @ref EXTI_LINE_NB.
|
|
||||||
* @retval HAL Status.
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_EXTI_LINE(ExtiLine));
|
|
||||||
|
|
||||||
/* Check null pointer */
|
|
||||||
if (hexti == NULL)
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Store line number as handle private field */
|
|
||||||
hexti->Line = ExtiLine;
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup EXTI_Exported_Functions_Group2
|
|
||||||
* @brief EXTI IO functions.
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### IO operation functions #####
|
|
||||||
===============================================================================
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Handle EXTI interrupt request.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @retval none.
|
|
||||||
*/
|
|
||||||
void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti)
|
|
||||||
{
|
|
||||||
uint32_t regval;
|
|
||||||
uint32_t maskline;
|
|
||||||
|
|
||||||
/* Compute line mask */
|
|
||||||
maskline = (1uL << (hexti->Line & EXTI_PIN_MASK));
|
|
||||||
|
|
||||||
/* Get pending bit */
|
|
||||||
regval = (EXTI->PR & maskline);
|
|
||||||
if (regval != 0x00u)
|
|
||||||
{
|
|
||||||
/* Clear pending bit */
|
|
||||||
EXTI->PR = maskline;
|
|
||||||
|
|
||||||
/* Call callback */
|
|
||||||
if (hexti->PendingCallback != NULL)
|
|
||||||
{
|
|
||||||
hexti->PendingCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get interrupt pending bit of a dedicated line.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @param Edge Specify which pending edge as to be checked.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref EXTI_TRIGGER_RISING_FALLING
|
|
||||||
* This parameter is kept for compatibility with other series.
|
|
||||||
* @retval 1 if interrupt is pending else 0.
|
|
||||||
*/
|
|
||||||
uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge)
|
|
||||||
{
|
|
||||||
uint32_t regval;
|
|
||||||
uint32_t linepos;
|
|
||||||
uint32_t maskline;
|
|
||||||
|
|
||||||
/* Check parameters */
|
|
||||||
assert_param(IS_EXTI_LINE(hexti->Line));
|
|
||||||
assert_param(IS_EXTI_CONFIG_LINE(hexti->Line));
|
|
||||||
assert_param(IS_EXTI_PENDING_EDGE(Edge));
|
|
||||||
|
|
||||||
/* Compute line mask */
|
|
||||||
linepos = (hexti->Line & EXTI_PIN_MASK);
|
|
||||||
maskline = (1uL << linepos);
|
|
||||||
|
|
||||||
/* return 1 if bit is set else 0 */
|
|
||||||
regval = ((EXTI->PR & maskline) >> linepos);
|
|
||||||
return regval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear interrupt pending bit of a dedicated line.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @param Edge Specify which pending edge as to be clear.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref EXTI_TRIGGER_RISING_FALLING
|
|
||||||
* This parameter is kept for compatibility with other series.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge)
|
|
||||||
{
|
|
||||||
uint32_t maskline;
|
|
||||||
|
|
||||||
/* Check parameters */
|
|
||||||
assert_param(IS_EXTI_LINE(hexti->Line));
|
|
||||||
assert_param(IS_EXTI_CONFIG_LINE(hexti->Line));
|
|
||||||
assert_param(IS_EXTI_PENDING_EDGE(Edge));
|
|
||||||
|
|
||||||
/* Compute line mask */
|
|
||||||
maskline = (1uL << (hexti->Line & EXTI_PIN_MASK));
|
|
||||||
|
|
||||||
/* Clear Pending bit */
|
|
||||||
EXTI->PR = maskline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Generate a software interrupt for a dedicated line.
|
|
||||||
* @param hexti Exti handle.
|
|
||||||
* @retval None.
|
|
||||||
*/
|
|
||||||
void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti)
|
|
||||||
{
|
|
||||||
uint32_t maskline;
|
|
||||||
|
|
||||||
/* Check parameters */
|
|
||||||
assert_param(IS_EXTI_LINE(hexti->Line));
|
|
||||||
assert_param(IS_EXTI_CONFIG_LINE(hexti->Line));
|
|
||||||
|
|
||||||
/* Compute line mask */
|
|
||||||
maskline = (1uL << (hexti->Line & EXTI_PIN_MASK));
|
|
||||||
|
|
||||||
/* Generate Software interrupt */
|
|
||||||
EXTI->SWIER = maskline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,769 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_flash.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief FLASH HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of the internal FLASH memory:
|
|
||||||
* + Program operations functions
|
|
||||||
* + Memory Control functions
|
|
||||||
* + Peripheral State functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### FLASH peripheral features #####
|
|
||||||
==============================================================================
|
|
||||||
[..] The Flash memory interface manages CPU AHB I-Code and D-Code accesses
|
|
||||||
to the Flash memory. It implements the erase and program Flash memory operations
|
|
||||||
and the read and write protection mechanisms.
|
|
||||||
|
|
||||||
[..] The Flash memory interface accelerates code execution with a system of instruction
|
|
||||||
prefetch.
|
|
||||||
|
|
||||||
[..] The FLASH main features are:
|
|
||||||
(+) Flash memory read operations
|
|
||||||
(+) Flash memory program/erase operations
|
|
||||||
(+) Read / write protections
|
|
||||||
(+) Prefetch on I-Code
|
|
||||||
(+) Option Bytes programming
|
|
||||||
|
|
||||||
|
|
||||||
##### How to use this driver #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
This driver provides functions and macros to configure and program the FLASH
|
|
||||||
memory of all STM32L0xx devices.
|
|
||||||
|
|
||||||
(#) FLASH Memory I/O Programming functions: this group includes all needed
|
|
||||||
functions to erase and program the main memory:
|
|
||||||
(++) Lock and Unlock the FLASH interface
|
|
||||||
(++) Erase function: Erase page
|
|
||||||
(++) Program functions: Fast Word and Half Page(should be
|
|
||||||
executed from internal SRAM).
|
|
||||||
|
|
||||||
(#) DATA EEPROM Programming functions: this group includes all
|
|
||||||
needed functions to erase and program the DATA EEPROM memory:
|
|
||||||
(++) Lock and Unlock the DATA EEPROM interface.
|
|
||||||
(++) Erase function: Erase Byte, erase HalfWord, erase Word, erase
|
|
||||||
Double Word (should be executed from internal SRAM).
|
|
||||||
(++) Program functions: Fast Program Byte, Fast Program Half-Word,
|
|
||||||
FastProgramWord, Program Byte, Program Half-Word,
|
|
||||||
Program Word and Program Double-Word (should be executed
|
|
||||||
from internal SRAM).
|
|
||||||
|
|
||||||
(#) FLASH Option Bytes Programming functions: this group includes all needed
|
|
||||||
functions to manage the Option Bytes:
|
|
||||||
(++) Lock and Unlock the Option Bytes
|
|
||||||
(++) Set/Reset the write protection
|
|
||||||
(++) Set the Read protection Level
|
|
||||||
(++) Program the user Option Bytes
|
|
||||||
(++) Launch the Option Bytes loader
|
|
||||||
(++) Set/Get the Read protection Level.
|
|
||||||
(++) Set/Get the BOR level.
|
|
||||||
(++) Get the Write protection.
|
|
||||||
(++) Get the user option bytes.
|
|
||||||
|
|
||||||
(#) Interrupts and flags management functions : this group
|
|
||||||
includes all needed functions to:
|
|
||||||
(++) Handle FLASH interrupts
|
|
||||||
(++) Wait for last FLASH operation according to its status
|
|
||||||
(++) Get error flag status
|
|
||||||
|
|
||||||
(#) FLASH Interface configuration functions: this group includes
|
|
||||||
the management of following features:
|
|
||||||
(++) Enable/Disable the RUN PowerDown mode.
|
|
||||||
(++) Enable/Disable the SLEEP PowerDown mode.
|
|
||||||
|
|
||||||
(#) FLASH Peripheral State methods: this group includes
|
|
||||||
the management of following features:
|
|
||||||
(++) Wait for the FLASH operation
|
|
||||||
(++) Get the specific FLASH error flag
|
|
||||||
|
|
||||||
[..] In addition to these function, this driver includes a set of macros allowing
|
|
||||||
to handle the following operations:
|
|
||||||
|
|
||||||
(+) Set/Get the latency
|
|
||||||
(+) Enable/Disable the prefetch buffer
|
|
||||||
(+) Enable/Disable the preread buffer
|
|
||||||
(+) Enable/Disable the Flash power-down
|
|
||||||
(+) Enable/Disable the FLASH interrupts
|
|
||||||
(+) Monitor the FLASH flags status
|
|
||||||
|
|
||||||
##### Programming operation functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..]
|
|
||||||
This subsection provides a set of functions allowing to manage the FLASH
|
|
||||||
program operations.
|
|
||||||
|
|
||||||
[..] The FLASH Memory Programming functions, includes the following functions:
|
|
||||||
(+) HAL_FLASH_Unlock(void);
|
|
||||||
(+) HAL_FLASH_Lock(void);
|
|
||||||
(+) HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint32_t Data)
|
|
||||||
(+) HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint32_t Data)
|
|
||||||
|
|
||||||
[..] Any operation of erase or program should follow these steps:
|
|
||||||
(#) Call the HAL_FLASH_Unlock() function to enable the flash control register and
|
|
||||||
program memory access.
|
|
||||||
(#) Call the desired function to erase page or program data.
|
|
||||||
(#) Call the HAL_FLASH_Lock() to disable the flash program memory access
|
|
||||||
(recommended to protect the FLASH memory against possible unwanted operation).
|
|
||||||
|
|
||||||
##### Option Bytes Programming functions #####
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
[..] The FLASH_Option Bytes Programming_functions, includes the following functions:
|
|
||||||
(+) HAL_FLASH_OB_Unlock(void);
|
|
||||||
(+) HAL_FLASH_OB_Lock(void);
|
|
||||||
(+) HAL_FLASH_OB_Launch(void);
|
|
||||||
(+) HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
|
|
||||||
(+) HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
|
|
||||||
|
|
||||||
[..] Any operation of erase or program should follow these steps:
|
|
||||||
(#) Call the HAL_FLASH_OB_Unlock() function to enable the Flash option control
|
|
||||||
register access.
|
|
||||||
(#) Call the following functions to program the desired option bytes.
|
|
||||||
(++) HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
|
|
||||||
(#) Once all needed option bytes to be programmed are correctly written, call the
|
|
||||||
HAL_FLASH_OB_Launch(void) function to launch the Option Bytes programming process.
|
|
||||||
(#) Call the HAL_FLASH_OB_Lock() to disable the Flash option control register access (recommended
|
|
||||||
to protect the option Bytes against possible unwanted operations).
|
|
||||||
|
|
||||||
[..] Proprietary code Read Out Protection (PcROP):
|
|
||||||
(#) The PcROP sector is selected by using the same option bytes as the Write
|
|
||||||
protection. As a result, these 2 options are exclusive each other.
|
|
||||||
(#) To activate PCROP mode for Flash sectors(s), you need to follow the sequence below:
|
|
||||||
(++) Use this function HAL_FLASHEx_AdvOBProgram with PCROPState = OB_PCROP_STATE_ENABLE.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
|
||||||
|
|
||||||
/** @defgroup FLASH FLASH
|
|
||||||
* @brief FLASH HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/** @defgroup FLASH_Private_Constants FLASH Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macro ---------------------------- ---------------------------------*/
|
|
||||||
/** @defgroup FLASH_Private_Macros FLASH Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/** @defgroup FLASH_Private_Variables FLASH Private Variables
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Variables used for Erase pages under interruption*/
|
|
||||||
FLASH_ProcessTypeDef pFlash;
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/** @defgroup FLASH_Private_Functions FLASH Private Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
static void FLASH_SetErrorCode(void);
|
|
||||||
extern void FLASH_PageErase(uint32_t PageAddress);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions ---------------------------------------------------------*/
|
|
||||||
/** @defgroup FLASH_Exported_Functions FLASH Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Exported_Functions_Group1 Programming operation functions
|
|
||||||
* @brief Programming operation functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Program word at a specified address
|
|
||||||
* @note To correctly run this function, the HAL_FLASH_Unlock() function
|
|
||||||
* must be called before.
|
|
||||||
* Call the HAL_FLASH_Lock() to disable the flash memory access
|
|
||||||
* (recommended to protect the FLASH memory against possible unwanted operation).
|
|
||||||
*
|
|
||||||
* @param TypeProgram Indicate the way to program at a specified address.
|
|
||||||
* This parameter can be a value of @ref FLASH_Type_Program
|
|
||||||
* @param Address Specifie the address to be programmed.
|
|
||||||
* @param Data Specifie the data to be programmed
|
|
||||||
*
|
|
||||||
* @retval HAL_StatusTypeDef HAL Status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint32_t Data)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_ERROR;
|
|
||||||
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(&pFlash);
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
|
|
||||||
assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
|
|
||||||
if(status == HAL_OK)
|
|
||||||
{
|
|
||||||
/* Clean the error context */
|
|
||||||
pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
|
|
||||||
|
|
||||||
/*Program word (32-bit) at a specified address.*/
|
|
||||||
*(__IO uint32_t *)Address = Data;
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(&pFlash);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Program word at a specified address with interrupt enabled.
|
|
||||||
*
|
|
||||||
* @param TypeProgram Indicate the way to program at a specified address.
|
|
||||||
* This parameter can be a value of @ref FLASH_Type_Program
|
|
||||||
* @param Address Specifie the address to be programmed.
|
|
||||||
* @param Data Specifie the data to be programmed
|
|
||||||
*
|
|
||||||
* @retval HAL_StatusTypeDef HAL Status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint32_t Data)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(&pFlash);
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
|
|
||||||
assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
|
|
||||||
|
|
||||||
/* Enable End of FLASH Operation and Error source interrupts */
|
|
||||||
__HAL_FLASH_ENABLE_IT(FLASH_IT_EOP | FLASH_IT_ERR);
|
|
||||||
|
|
||||||
pFlash.Address = Address;
|
|
||||||
pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM;
|
|
||||||
/* Clean the error context */
|
|
||||||
pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
|
|
||||||
|
|
||||||
if(TypeProgram == FLASH_TYPEPROGRAM_WORD)
|
|
||||||
{
|
|
||||||
/* Program word (32-bit) at a specified address. */
|
|
||||||
*(__IO uint32_t *)Address = Data;
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles FLASH interrupt request.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_FLASH_IRQHandler(void)
|
|
||||||
{
|
|
||||||
uint32_t addresstmp = 0;
|
|
||||||
|
|
||||||
/* Check FLASH operation error flags */
|
|
||||||
|
|
||||||
/* WARNING : On the first cut of STM32L031xx and STM32L041xx devices,
|
|
||||||
* (RefID = 0x1000) the FLASH_FLAG_OPTVERR bit was not behaving
|
|
||||||
* as expected. If the user run an application using the first
|
|
||||||
* cut of the STM32L031xx device or the first cut of the STM32L041xx
|
|
||||||
* device, the check on the FLASH_FLAG_OPTVERR bit should be ignored.
|
|
||||||
*
|
|
||||||
* Note :The revId of the device can be retrieved via the HAL_GetREVID()
|
|
||||||
* function.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
if( __HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_FWWERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_NOTZEROERR) )
|
|
||||||
{
|
|
||||||
if(pFlash.ProcedureOnGoing == FLASH_PROC_PAGEERASE)
|
|
||||||
{
|
|
||||||
/* Return the faulty sector */
|
|
||||||
addresstmp = pFlash.Page;
|
|
||||||
pFlash.Page = 0xFFFFFFFFU;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Return the faulty address */
|
|
||||||
addresstmp = pFlash.Address;
|
|
||||||
}
|
|
||||||
/* Save the Error code */
|
|
||||||
FLASH_SetErrorCode();
|
|
||||||
|
|
||||||
/* FLASH error interrupt user callback */
|
|
||||||
HAL_FLASH_OperationErrorCallback(addresstmp);
|
|
||||||
|
|
||||||
/* Stop the procedure ongoing */
|
|
||||||
pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check FLASH End of Operation flag */
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
|
|
||||||
{
|
|
||||||
/* Clear FLASH End of Operation pending bit */
|
|
||||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
|
|
||||||
|
|
||||||
/* Process can continue only if no error detected */
|
|
||||||
if(pFlash.ProcedureOnGoing != FLASH_PROC_NONE)
|
|
||||||
{
|
|
||||||
if(pFlash.ProcedureOnGoing == FLASH_PROC_PAGEERASE)
|
|
||||||
{
|
|
||||||
/* Nb of pages to erased can be decreased */
|
|
||||||
pFlash.NbPagesToErase--;
|
|
||||||
|
|
||||||
/* Check if there are still pages to erase */
|
|
||||||
if(pFlash.NbPagesToErase != 0U)
|
|
||||||
{
|
|
||||||
addresstmp = pFlash.Page;
|
|
||||||
/*Indicate user which sector has been erased */
|
|
||||||
HAL_FLASH_EndOfOperationCallback(addresstmp);
|
|
||||||
|
|
||||||
/*Increment sector number*/
|
|
||||||
addresstmp = pFlash.Page + FLASH_PAGE_SIZE;
|
|
||||||
pFlash.Page = addresstmp;
|
|
||||||
|
|
||||||
/* If the erase operation is completed, disable the ERASE Bit */
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_ERASE);
|
|
||||||
|
|
||||||
FLASH_PageErase(addresstmp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* No more pages to Erase, user callback can be called. */
|
|
||||||
/* Reset Sector and stop Erase pages procedure */
|
|
||||||
pFlash.Page = addresstmp = 0xFFFFFFFFU;
|
|
||||||
pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
|
|
||||||
/* FLASH EOP interrupt user callback */
|
|
||||||
HAL_FLASH_EndOfOperationCallback(addresstmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* If the program operation is completed, disable the PROG Bit */
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_PROG);
|
|
||||||
|
|
||||||
/* Program ended. Return the selected address */
|
|
||||||
/* FLASH EOP interrupt user callback */
|
|
||||||
HAL_FLASH_EndOfOperationCallback(pFlash.Address);
|
|
||||||
|
|
||||||
/* Reset Address and stop Program procedure */
|
|
||||||
pFlash.Address = 0xFFFFFFFFU;
|
|
||||||
pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(pFlash.ProcedureOnGoing == FLASH_PROC_NONE)
|
|
||||||
{
|
|
||||||
/* Operation is completed, disable the PROG and ERASE */
|
|
||||||
CLEAR_BIT(FLASH->PECR, (FLASH_PECR_ERASE | FLASH_PECR_PROG));
|
|
||||||
|
|
||||||
/* Disable End of FLASH Operation and Error source interrupts */
|
|
||||||
__HAL_FLASH_DISABLE_IT(FLASH_IT_EOP | FLASH_IT_ERR);
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(&pFlash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief FLASH end of operation interrupt callback
|
|
||||||
* @param ReturnValue The value saved in this parameter depends on the ongoing procedure
|
|
||||||
* - Pages Erase: Address of the page which has been erased
|
|
||||||
* (if 0xFFFFFFFF, it means that all the selected pages have been erased)
|
|
||||||
* - Program: Address which was selected for data program
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
__weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue)
|
|
||||||
{
|
|
||||||
/* Prevent unused argument(s) compilation warning */
|
|
||||||
UNUSED(ReturnValue);
|
|
||||||
|
|
||||||
/* NOTE : This function Should not be modified, when the callback is needed,
|
|
||||||
the HAL_FLASH_EndOfOperationCallback could be implemented in the user file
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief FLASH operation error interrupt callback
|
|
||||||
* @param ReturnValue The value saved in this parameter depends on the ongoing procedure
|
|
||||||
* - Pages Erase: Address of the page which returned an error
|
|
||||||
* - Program: Address which was selected for data program
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
__weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue)
|
|
||||||
{
|
|
||||||
/* Prevent unused argument(s) compilation warning */
|
|
||||||
UNUSED(ReturnValue);
|
|
||||||
|
|
||||||
/* NOTE : This function Should not be modified, when the callback is needed,
|
|
||||||
the HAL_FLASH_OperationErrorCallback could be implemented in the user file
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Exported_Functions_Group2 Peripheral Control functions
|
|
||||||
* @brief management functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Peripheral Control functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..]
|
|
||||||
This subsection provides a set of functions allowing to control the FLASH
|
|
||||||
memory operations.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Unlock the FLASH control register access
|
|
||||||
* @retval HAL Status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_Unlock(void)
|
|
||||||
{
|
|
||||||
uint32_t primask_bit;
|
|
||||||
|
|
||||||
/* Unlocking FLASH_PECR register access*/
|
|
||||||
if(HAL_IS_BIT_SET(FLASH->PECR, FLASH_PECR_PELOCK))
|
|
||||||
{
|
|
||||||
/* Disable interrupts to avoid any interruption during unlock sequence */
|
|
||||||
primask_bit = __get_PRIMASK();
|
|
||||||
__disable_irq();
|
|
||||||
|
|
||||||
WRITE_REG(FLASH->PEKEYR, FLASH_PEKEY1);
|
|
||||||
WRITE_REG(FLASH->PEKEYR, FLASH_PEKEY2);
|
|
||||||
|
|
||||||
/* Re-enable the interrupts: restore previous priority mask */
|
|
||||||
__set_PRIMASK(primask_bit);
|
|
||||||
|
|
||||||
if(HAL_IS_BIT_SET(FLASH->PECR, FLASH_PECR_PELOCK))
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HAL_IS_BIT_SET(FLASH->PECR, FLASH_PECR_PRGLOCK))
|
|
||||||
{
|
|
||||||
/* Disable interrupts to avoid any interruption during unlock sequence */
|
|
||||||
primask_bit = __get_PRIMASK();
|
|
||||||
__disable_irq();
|
|
||||||
|
|
||||||
/* Unlocking the program memory access */
|
|
||||||
WRITE_REG(FLASH->PRGKEYR, FLASH_PRGKEY1);
|
|
||||||
WRITE_REG(FLASH->PRGKEYR, FLASH_PRGKEY2);
|
|
||||||
|
|
||||||
/* Re-enable the interrupts: restore previous priority mask */
|
|
||||||
__set_PRIMASK(primask_bit);
|
|
||||||
|
|
||||||
if (HAL_IS_BIT_SET(FLASH->PECR, FLASH_PECR_PRGLOCK))
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Locks the FLASH control register access
|
|
||||||
* @retval HAL Status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_Lock(void)
|
|
||||||
{
|
|
||||||
/* Set the PRGLOCK Bit to lock the FLASH Registers access */
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_PRGLOCK);
|
|
||||||
|
|
||||||
/* Set the PELOCK Bit to lock the PECR Register access */
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_PELOCK);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Unlock the FLASH Option Control Registers access.
|
|
||||||
* @retval HAL Status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void)
|
|
||||||
{
|
|
||||||
uint32_t primask_bit;
|
|
||||||
|
|
||||||
if(HAL_IS_BIT_SET(FLASH->PECR, FLASH_PECR_OPTLOCK))
|
|
||||||
{
|
|
||||||
/* Disable interrupts to avoid any interruption during unlock sequence */
|
|
||||||
primask_bit = __get_PRIMASK();
|
|
||||||
__disable_irq();
|
|
||||||
|
|
||||||
/* Unlocking FLASH_PECR register access*/
|
|
||||||
if(HAL_IS_BIT_SET(FLASH->PECR, FLASH_PECR_PELOCK))
|
|
||||||
{
|
|
||||||
/* Unlocking FLASH_PECR register access*/
|
|
||||||
WRITE_REG(FLASH->PEKEYR, FLASH_PEKEY1);
|
|
||||||
WRITE_REG(FLASH->PEKEYR, FLASH_PEKEY2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unlocking the option bytes block access */
|
|
||||||
WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY1);
|
|
||||||
WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY2);
|
|
||||||
|
|
||||||
/* Re-enable the interrupts: restore previous priority mask */
|
|
||||||
__set_PRIMASK(primask_bit);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Lock the FLASH Option Control Registers access.
|
|
||||||
* @retval HAL Status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_OB_Lock(void)
|
|
||||||
{
|
|
||||||
/* Set the OPTLOCK Bit to lock the option bytes block access */
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_OPTLOCK);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Launch the option byte loading.
|
|
||||||
* @note This function will reset automatically the MCU.
|
|
||||||
* @retval HAL Status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_FLASH_OB_Launch(void)
|
|
||||||
{
|
|
||||||
/* Set the OBL_Launch bit to launch the option byte loading */
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_OBL_LAUNCH);
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
return(FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_Exported_Functions_Group3 Peripheral errors functions
|
|
||||||
* @brief Peripheral errors functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Peripheral Errors functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..]
|
|
||||||
This subsection permit to get in run-time errors of the FLASH peripheral.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the specific FLASH error flag.
|
|
||||||
* @retval FLASH_ErrorCode The returned value can be:
|
|
||||||
* @ref FLASH_Error_Codes
|
|
||||||
*/
|
|
||||||
uint32_t HAL_FLASH_GetError(void)
|
|
||||||
{
|
|
||||||
return pFlash.ErrorCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_Private_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Wait for a FLASH operation to complete.
|
|
||||||
* @param Timeout maximum flash operation timeout
|
|
||||||
* @retval HAL Status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
|
|
||||||
{
|
|
||||||
/* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
|
|
||||||
Even if the FLASH operation fails, the BUSY flag will be reset and an error
|
|
||||||
flag will be set */
|
|
||||||
|
|
||||||
uint32_t tickstart = HAL_GetTick();
|
|
||||||
|
|
||||||
while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY))
|
|
||||||
{
|
|
||||||
if (Timeout != HAL_MAX_DELAY)
|
|
||||||
{
|
|
||||||
if((Timeout == 0U) || ((HAL_GetTick()-tickstart) > Timeout))
|
|
||||||
{
|
|
||||||
return HAL_TIMEOUT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check FLASH End of Operation flag */
|
|
||||||
if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
|
|
||||||
{
|
|
||||||
/* Clear FLASH End of Operation pending bit */
|
|
||||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( __HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_FWWERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_NOTZEROERR) )
|
|
||||||
{
|
|
||||||
/*Save the error code*/
|
|
||||||
|
|
||||||
/* WARNING : On the first cut of STM32L031xx and STM32L041xx devices,
|
|
||||||
* (RefID = 0x1000) the FLASH_FLAG_OPTVERR bit was not behaving
|
|
||||||
* as expected. If the user run an application using the first
|
|
||||||
* cut of the STM32L031xx device or the first cut of the STM32L041xx
|
|
||||||
* device, this error should be ignored. The revId of the device
|
|
||||||
* can be retrieved via the HAL_GetREVID() function.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
FLASH_SetErrorCode();
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* There is no error flag set */
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the specific FLASH error flag.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
static void FLASH_SetErrorCode(void)
|
|
||||||
{
|
|
||||||
uint32_t flags = 0;
|
|
||||||
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_WRP;
|
|
||||||
flags |= FLASH_FLAG_WRPERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_PGA;
|
|
||||||
flags |= FLASH_FLAG_PGAERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_SIZE;
|
|
||||||
flags |= FLASH_FLAG_SIZERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR))
|
|
||||||
{
|
|
||||||
/* WARNING : On the first cut of STM32L031xx and STM32L041xx devices,
|
|
||||||
* (RefID = 0x1000) the FLASH_FLAG_OPTVERR bit was not behaving
|
|
||||||
* as expected. If the user run an application using the first
|
|
||||||
* cut of the STM32L031xx device or the first cut of the STM32L041xx
|
|
||||||
* device, this error should be ignored. The revId of the device
|
|
||||||
* can be retrieved via the HAL_GetREVID() function.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_OPTV;
|
|
||||||
flags |= FLASH_FLAG_OPTVERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_RD;
|
|
||||||
flags |= FLASH_FLAG_RDERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_FWWERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_FWWERR;
|
|
||||||
flags |= HAL_FLASH_ERROR_FWWERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_NOTZEROERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_NOTZERO;
|
|
||||||
flags |= FLASH_FLAG_NOTZEROERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear FLASH error pending bits */
|
|
||||||
__HAL_FLASH_CLEAR_FLAG(flags);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
File diff suppressed because it is too large
Load Diff
@ -1,521 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_flash_ramfunc.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief FLASH RAMFUNC driver.
|
|
||||||
* This file provides a Flash firmware functions which should be
|
|
||||||
* executed from internal SRAM
|
|
||||||
*
|
|
||||||
* @verbatim
|
|
||||||
|
|
||||||
*** ARM Compiler ***
|
|
||||||
--------------------
|
|
||||||
[..] RAM functions are defined using the toolchain options.
|
|
||||||
Functions that are be executed in RAM should reside in a separate
|
|
||||||
source module. Using the 'Options for File' dialog you can simply change
|
|
||||||
the 'Code / Const' area of a module to a memory space in physical RAM.
|
|
||||||
Available memory areas are declared in the 'Target' tab of the
|
|
||||||
Options for Target' dialog.
|
|
||||||
|
|
||||||
*** ICCARM Compiler ***
|
|
||||||
-----------------------
|
|
||||||
[..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
|
|
||||||
|
|
||||||
*** GNU Compiler ***
|
|
||||||
--------------------
|
|
||||||
[..] RAM functions are defined using a specific toolchain attribute
|
|
||||||
"__attribute__((section(".RamFunc")))".
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
|
||||||
|
|
||||||
/** @addtogroup FLASH
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/** @addtogroup FLASH_Private_Variables
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
extern FLASH_ProcessTypeDef pFlash;
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_RAMFUNC FLASH_RAMFUNC
|
|
||||||
* @brief FLASH functions executed from RAM
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/** @defgroup FLASH_RAMFUNC_Private_Functions FLASH RAM Private Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
static __RAM_FUNC HAL_StatusTypeDef FLASHRAM_WaitForLastOperation(uint32_t Timeout);
|
|
||||||
static __RAM_FUNC HAL_StatusTypeDef FLASHRAM_SetErrorCode(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAM Exported Functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### ramfunc functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..]
|
|
||||||
This subsection provides a set of functions that should be executed from RAM
|
|
||||||
transfers.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the power down mode during RUN mode.
|
|
||||||
* @note This function can be used only when the user code is running from Internal SRAM.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableRunPowerDown(void)
|
|
||||||
{
|
|
||||||
/* Enable the Power Down in Run mode*/
|
|
||||||
__HAL_FLASH_POWER_DOWN_ENABLE();
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the power down mode during RUN mode.
|
|
||||||
* @note This function can be used only when the user code is running from Internal SRAM.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableRunPowerDown(void)
|
|
||||||
{
|
|
||||||
/* Disable the Power Down in Run mode*/
|
|
||||||
__HAL_FLASH_POWER_DOWN_DISABLE();
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_RAMFUNC_Exported_Functions_Group2 Programming and erasing operation functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(FLASH_PECR_PARALLBANK)
|
|
||||||
/**
|
|
||||||
* @brief Erases a specified 2 pages in program memory in parallel.
|
|
||||||
* @note This function can be used only for STM32L07xxx/STM32L08xxx devices.
|
|
||||||
* To correctly run this function, the @ref HAL_FLASH_Unlock() function
|
|
||||||
* must be called before.
|
|
||||||
* Call the @ref HAL_FLASH_Lock() to disable the flash memory access
|
|
||||||
* (recommended to protect the FLASH memory against possible unwanted operation).
|
|
||||||
* @param Page_Address1: The page address in program memory to be erased in
|
|
||||||
* the first Bank (BANK1). This parameter should be between FLASH_BASE
|
|
||||||
* and FLASH_BANK1_END.
|
|
||||||
* @param Page_Address2: The page address in program memory to be erased in
|
|
||||||
* the second Bank (BANK2). This parameter should be between FLASH_BANK2_BASE
|
|
||||||
* and FLASH_BANK2_END.
|
|
||||||
* @note A Page is erased in the Program memory only if the address to load
|
|
||||||
* is the start address of a page (multiple of @ref FLASH_PAGE_SIZE bytes).
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EraseParallelPage(uint32_t Page_Address1, uint32_t Page_Address2)
|
|
||||||
{
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
|
|
||||||
if(status == HAL_OK)
|
|
||||||
{
|
|
||||||
/* Proceed to erase the page */
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_PARALLBANK);
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_ERASE);
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_PROG);
|
|
||||||
|
|
||||||
/* Write 00000000h to the first word of the first program page to erase */
|
|
||||||
*(__IO uint32_t *)Page_Address1 = 0x00000000U;
|
|
||||||
/* Write 00000000h to the first word of the second program page to erase */
|
|
||||||
*(__IO uint32_t *)Page_Address2 = 0x00000000U;
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
|
|
||||||
/* If the erase operation is completed, disable the ERASE, PROG and PARALLBANK bits */
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_PROG);
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_ERASE);
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_PARALLBANK);
|
|
||||||
}
|
|
||||||
/* Return the Erase Status */
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Program 2 half pages in program memory in parallel (half page size is 16 Words).
|
|
||||||
* @note This function can be used only for STM32L07xxx/STM32L08xxx devices.
|
|
||||||
* @param Address1: specifies the first address to be written in the first bank
|
|
||||||
* (BANK1). This parameter should be between FLASH_BASE and (FLASH_BANK1_END - FLASH_PAGE_SIZE).
|
|
||||||
* @param pBuffer1: pointer to the buffer containing the data to be written
|
|
||||||
* to the first half page in the first bank.
|
|
||||||
* @param Address2: specifies the second address to be written in the second bank
|
|
||||||
* (BANK2). This parameter should be between FLASH_BANK2_BASE and (FLASH_BANK2_END - FLASH_PAGE_SIZE).
|
|
||||||
* @param pBuffer2: pointer to the buffer containing the data to be written
|
|
||||||
* to the second half page in the second bank.
|
|
||||||
* @note To correctly run this function, the @ref HAL_FLASH_Unlock() function
|
|
||||||
* must be called before.
|
|
||||||
* Call the @ref HAL_FLASH_Lock() to disable the flash memory access
|
|
||||||
* (recommended to protect the FLASH memory against possible unwanted operation).
|
|
||||||
* @note Half page write is possible only from SRAM.
|
|
||||||
* @note A half page is written to the program memory only if the first
|
|
||||||
* address to load is the start address of a half page (multiple of 64
|
|
||||||
* bytes) and the 15 remaining words to load are in the same half page.
|
|
||||||
* @note During the Program memory half page write all read operations are
|
|
||||||
* forbidden (this includes DMA read operations and debugger read
|
|
||||||
* operations such as breakpoints, periodic updates, etc.).
|
|
||||||
* @note If a PGAERR is set during a Program memory half page write, the
|
|
||||||
* complete write operation is aborted. Software should then reset the
|
|
||||||
* FPRG and PROG/DATA bits and restart the write operation from the
|
|
||||||
* beginning.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_ProgramParallelHalfPage(uint32_t Address1, uint32_t* pBuffer1, uint32_t Address2, uint32_t* pBuffer2)
|
|
||||||
{
|
|
||||||
uint32_t count = 0U;
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
|
|
||||||
if(status == HAL_OK)
|
|
||||||
{
|
|
||||||
/* Proceed to program the new half page */
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_PARALLBANK);
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_FPRG);
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_PROG);
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
if(status == HAL_OK)
|
|
||||||
{
|
|
||||||
/* Disable all IRQs */
|
|
||||||
__disable_irq();
|
|
||||||
|
|
||||||
/* Write the first half page directly with 16 different words */
|
|
||||||
while(count < 16U)
|
|
||||||
{
|
|
||||||
/* Address1 doesn't need to be increased */
|
|
||||||
*(__IO uint32_t*) Address1 = *pBuffer1;
|
|
||||||
pBuffer1++;
|
|
||||||
count ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write the second half page directly with 16 different words */
|
|
||||||
count = 0U;
|
|
||||||
while(count < 16U)
|
|
||||||
{
|
|
||||||
/* Address2 doesn't need to be increased */
|
|
||||||
*(__IO uint32_t*) Address2 = *pBuffer2;
|
|
||||||
pBuffer2++;
|
|
||||||
count ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable IRQs */
|
|
||||||
__enable_irq();
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if the write operation is completed, disable the PROG, FPRG and PARALLBANK bits */
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_PROG);
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_FPRG);
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_PARALLBANK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the Write Status */
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
#endif /* FLASH_PECR_PARALLBANK */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Program a half page in program memory.
|
|
||||||
* @param Address specifies the address to be written.
|
|
||||||
* @param pBuffer pointer to the buffer containing the data to be written to
|
|
||||||
* the half page.
|
|
||||||
* @note To correctly run this function, the @ref HAL_FLASH_Unlock() function
|
|
||||||
* must be called before.
|
|
||||||
* Call the @ref HAL_FLASH_Lock() to disable the flash memory access
|
|
||||||
* (recommended to protect the FLASH memory against possible unwanted operation)
|
|
||||||
* @note Half page write is possible only from SRAM.
|
|
||||||
* @note A half page is written to the program memory only if the first
|
|
||||||
* address to load is the start address of a half page (multiple of 64
|
|
||||||
* bytes) and the 15 remaining words to load are in the same half page.
|
|
||||||
* @note During the Program memory half page write all read operations are
|
|
||||||
* forbidden (this includes DMA read operations and debugger read
|
|
||||||
* operations such as breakpoints, periodic updates, etc.).
|
|
||||||
* @note If a PGAERR is set during a Program memory half page write, the
|
|
||||||
* complete write operation is aborted. Software should then reset the
|
|
||||||
* FPRG and PROG/DATA bits and restart the write operation from the
|
|
||||||
* beginning.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_HalfPageProgram(uint32_t Address, uint32_t* pBuffer)
|
|
||||||
{
|
|
||||||
uint32_t count = 0U;
|
|
||||||
HAL_StatusTypeDef status = HAL_OK;
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
|
|
||||||
if(status == HAL_OK)
|
|
||||||
{
|
|
||||||
/* Proceed to program the new half page */
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_FPRG);
|
|
||||||
SET_BIT(FLASH->PECR, FLASH_PECR_PROG);
|
|
||||||
|
|
||||||
/* Disable all IRQs */
|
|
||||||
__disable_irq();
|
|
||||||
|
|
||||||
/* Write one half page directly with 16 different words */
|
|
||||||
while(count < 16U)
|
|
||||||
{
|
|
||||||
/* Address doesn't need to be increased */
|
|
||||||
*(__IO uint32_t*) Address = *pBuffer;
|
|
||||||
pBuffer++;
|
|
||||||
count ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable IRQs */
|
|
||||||
__enable_irq();
|
|
||||||
|
|
||||||
/* Wait for last operation to be completed */
|
|
||||||
status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
|
|
||||||
|
|
||||||
/* If the write operation is completed, disable the PROG and FPRG bits */
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_PROG);
|
|
||||||
CLEAR_BIT(FLASH->PECR, FLASH_PECR_FPRG);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the Write Status */
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup FLASH_RAMFUNC_Exported_Functions_Group3 Peripheral errors functions
|
|
||||||
* @brief Peripheral errors functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Peripheral errors functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..]
|
|
||||||
This subsection permit to get in run-time errors of the FLASH peripheral.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the specific FLASH errors flag.
|
|
||||||
* @param Error pointer is the error value. It can be a mixed of:
|
|
||||||
* @arg @ref HAL_FLASH_ERROR_RD FLASH Read Protection error flag (PCROP)
|
|
||||||
* @arg @ref HAL_FLASH_ERROR_SIZE FLASH Programming Parallelism error flag
|
|
||||||
* @arg @ref HAL_FLASH_ERROR_PGA FLASH Programming Alignment error flag
|
|
||||||
* @arg @ref HAL_FLASH_ERROR_WRP FLASH Write protected error flag
|
|
||||||
* @arg @ref HAL_FLASH_ERROR_OPTV FLASH Option valid error flag
|
|
||||||
* @arg @ref HAL_FLASH_ERROR_FWWERR FLASH Write or Erase operation aborted
|
|
||||||
* @arg @ref HAL_FLASH_ERROR_NOTZERO FLASH Write operation is done in a not-erased region
|
|
||||||
* @retval HAL Status
|
|
||||||
*/
|
|
||||||
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_GetError(uint32_t * Error)
|
|
||||||
{
|
|
||||||
*Error = pFlash.ErrorCode;
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup FLASH_RAMFUNC_Private_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the specific FLASH error flag.
|
|
||||||
* @retval HAL Status
|
|
||||||
*/
|
|
||||||
static __RAM_FUNC HAL_StatusTypeDef FLASHRAM_SetErrorCode(void)
|
|
||||||
{
|
|
||||||
uint32_t flags = 0;
|
|
||||||
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_WRP;
|
|
||||||
flags |= FLASH_FLAG_WRPERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_PGA;
|
|
||||||
flags |= FLASH_FLAG_PGAERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_SIZE;
|
|
||||||
flags |= FLASH_FLAG_SIZERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR))
|
|
||||||
{
|
|
||||||
/* WARNING : On the first cut of STM32L031xx and STM32L041xx devices,
|
|
||||||
* (RefID = 0x1000) the FLASH_FLAG_OPTVERR bit was not behaving
|
|
||||||
* as expected. If the user run an application using the first
|
|
||||||
* cut of the STM32L031xx device or the first cut of the STM32L041xx
|
|
||||||
* device, this error should be ignored. The revId of the device
|
|
||||||
* can be retrieved via the HAL_GetREVID() function.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_OPTV;
|
|
||||||
flags |= FLASH_FLAG_OPTVERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_RD;
|
|
||||||
flags |= FLASH_FLAG_RDERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_FWWERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_FWWERR;
|
|
||||||
flags |= HAL_FLASH_ERROR_FWWERR;
|
|
||||||
}
|
|
||||||
if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_NOTZEROERR))
|
|
||||||
{
|
|
||||||
pFlash.ErrorCode |= HAL_FLASH_ERROR_NOTZERO;
|
|
||||||
flags |= FLASH_FLAG_NOTZEROERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear FLASH error pending bits */
|
|
||||||
__HAL_FLASH_CLEAR_FLAG(flags);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Wait for a FLASH operation to complete.
|
|
||||||
* @param Timeout maximum flash operationtimeout
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
static __RAM_FUNC HAL_StatusTypeDef FLASHRAM_WaitForLastOperation(uint32_t Timeout)
|
|
||||||
{
|
|
||||||
/* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
|
|
||||||
Even if the FLASH operation fails, the BUSY flag will be reset and an error
|
|
||||||
flag will be set */
|
|
||||||
|
|
||||||
while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) && (Timeout != 0x00U))
|
|
||||||
{
|
|
||||||
Timeout--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Timeout == 0x00U)
|
|
||||||
{
|
|
||||||
return HAL_TIMEOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check FLASH End of Operation flag */
|
|
||||||
if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
|
|
||||||
{
|
|
||||||
/* Clear FLASH End of Operation pending bit */
|
|
||||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( __HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_SIZERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_FWWERR) ||
|
|
||||||
__HAL_FLASH_GET_FLAG(FLASH_FLAG_NOTZEROERR) )
|
|
||||||
{
|
|
||||||
/*Save the error code*/
|
|
||||||
|
|
||||||
/* WARNING : On the first cut of STM32L031xx and STM32L041xx devices,
|
|
||||||
* (RefID = 0x1000) the FLASH_FLAG_OPTVERR bit was not behaving
|
|
||||||
* as expected. If the user run an application using the first
|
|
||||||
* cut of the STM32L031xx device or the first cut of the STM32L041xx
|
|
||||||
* device, this error should be ignored. The revId of the device
|
|
||||||
* can be retrieved via the HAL_GetREVID() function.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
FLASHRAM_SetErrorCode();
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* There is no error flag set */
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,538 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_gpio.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief GPIO HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of the General Purpose Input/Output (GPIO) peripheral:
|
|
||||||
* + Initialization and de-initialization functions
|
|
||||||
* + IO operation functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### GPIO Peripheral features #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
(+) Each port bit of the general-purpose I/O (GPIO) ports can be individually
|
|
||||||
configured by software in several modes:
|
|
||||||
(++) Input mode
|
|
||||||
(++) Analog mode
|
|
||||||
(++) Output mode
|
|
||||||
(++) Alternate function mode
|
|
||||||
(++) External interrupt/event lines
|
|
||||||
|
|
||||||
(+) During and just after reset, the alternate functions and external interrupt
|
|
||||||
lines are not active and the I/O ports are configured in input floating mode.
|
|
||||||
|
|
||||||
(+) All GPIO pins have weak internal pull-up and pull-down resistors, which can be
|
|
||||||
activated or not.
|
|
||||||
|
|
||||||
(+) In Output or Alternate mode, each IO can be configured on open-drain or push-pull
|
|
||||||
type and the IO speed can be selected depending on the VDD value.
|
|
||||||
|
|
||||||
(+) The microcontroller IO pins are connected to onboard peripherals/modules through a
|
|
||||||
multiplexer that allows only one peripheral alternate function (AF) connected
|
|
||||||
to an IO pin at a time. In this way, there can be no conflict between peripherals
|
|
||||||
sharing the same IO pin.
|
|
||||||
|
|
||||||
(+) All ports have external interrupt/event capability. To use external interrupt
|
|
||||||
lines, the port must be configured in input mode. All available GPIO pins are
|
|
||||||
connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.
|
|
||||||
|
|
||||||
(+) The external interrupt/event controller consists of up to 28 edge detectors
|
|
||||||
(16 lines are connected to GPIO) for generating event/interrupt requests (each
|
|
||||||
input line can be independently configured to select the type (interrupt or event)
|
|
||||||
and the corresponding trigger event (rising or falling or both). Each line can
|
|
||||||
also be masked independently.
|
|
||||||
|
|
||||||
##### How to use this driver #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
(#) Enable the GPIO IOPORT clock using the following function: __HAL_RCC_GPIOx_CLK_ENABLE().
|
|
||||||
|
|
||||||
(#) Configure the GPIO pin(s) using HAL_GPIO_Init().
|
|
||||||
(++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure
|
|
||||||
(++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef
|
|
||||||
structure.
|
|
||||||
(++) In case of Output or alternate function mode selection: the speed is
|
|
||||||
configured through "Speed" member from GPIO_InitTypeDef structure.
|
|
||||||
(++) In alternate mode is selection, the alternate function connected to the IO
|
|
||||||
is configured through "Alternate" member from GPIO_InitTypeDef structure.
|
|
||||||
(++) Analog mode is required when a pin is to be used as ADC channel
|
|
||||||
or DAC output.
|
|
||||||
(++) In case of external interrupt/event selection the "Mode" member from
|
|
||||||
GPIO_InitTypeDef structure select the type (interrupt or event) and
|
|
||||||
the corresponding trigger event (rising or falling or both).
|
|
||||||
|
|
||||||
(#) In case of external interrupt/event mode selection, configure NVIC IRQ priority
|
|
||||||
mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using
|
|
||||||
HAL_NVIC_EnableIRQ().
|
|
||||||
|
|
||||||
(#) HAL_GPIO_DeInit allows to set register values to their reset value. This function
|
|
||||||
is also to be used when unconfiguring pin which was used as an external interrupt
|
|
||||||
or in event mode. That is the only way to reset the corresponding bit in
|
|
||||||
EXTI & SYSCFG registers.
|
|
||||||
|
|
||||||
(#) To get the level of a pin configured in input mode use HAL_GPIO_ReadPin().
|
|
||||||
|
|
||||||
(#) To set/reset the level of a pin configured in output mode use
|
|
||||||
HAL_GPIO_WritePin()/HAL_GPIO_TogglePin().
|
|
||||||
|
|
||||||
(#) To lock pin configuration until next reset use HAL_GPIO_LockPin().
|
|
||||||
|
|
||||||
(#) During and just after reset, the alternate functions are not
|
|
||||||
active and the GPIO pins are configured in input floating mode (except JTAG
|
|
||||||
pins).
|
|
||||||
|
|
||||||
(#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general purpose
|
|
||||||
(PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has
|
|
||||||
priority over the GPIO function.
|
|
||||||
|
|
||||||
(#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as
|
|
||||||
general purpose PH0 and PH1, respectively, when the HSE oscillator is off.
|
|
||||||
The HSE has priority over the GPIO function.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
|
||||||
|
|
||||||
/** @addtogroup GPIO
|
|
||||||
* @brief GPIO HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup GPIO_Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
#define GPIO_MODE (0x00000003U)
|
|
||||||
#define EXTI_MODE (0x10000000U)
|
|
||||||
#define GPIO_MODE_IT (0x00010000U)
|
|
||||||
#define GPIO_MODE_EVT (0x00020000U)
|
|
||||||
#define RISING_EDGE (0x00100000U)
|
|
||||||
#define FALLING_EDGE (0x00200000U)
|
|
||||||
#define GPIO_OUTPUT_TYPE (0x00000010U)
|
|
||||||
|
|
||||||
#define GPIO_NUMBER (16U)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/** @addtogroup GPIO_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup GPIO_Exported_Functions_Group1
|
|
||||||
* @brief Initialization and de-initialization functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Initialization and de-initialization functions #####
|
|
||||||
===============================================================================
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initializes the GPIOx peripheral according to the specified parameters in the GPIO_Init.
|
|
||||||
* @param GPIOx where x can be (A..E and H) to select the GPIO peripheral for STM32L0XX family devices.
|
|
||||||
* Note that GPIOE is not available on all devices.
|
|
||||||
* @param GPIO_Init pointer to a GPIO_InitTypeDef structure that contains
|
|
||||||
* the configuration information for the specified GPIO peripheral.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
|
|
||||||
{
|
|
||||||
uint32_t position = 0x00U;
|
|
||||||
uint32_t iocurrent = 0x00U;
|
|
||||||
uint32_t temp = 0x00U;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
|
|
||||||
assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
|
|
||||||
assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx, (GPIO_Init->Pin)));
|
|
||||||
|
|
||||||
/* Configure the port pins */
|
|
||||||
while (((GPIO_Init->Pin) >> position) != 0)
|
|
||||||
{
|
|
||||||
/* Get the IO position */
|
|
||||||
iocurrent = (GPIO_Init->Pin) & (1U << position);
|
|
||||||
|
|
||||||
if (iocurrent)
|
|
||||||
{
|
|
||||||
/*--------------------- GPIO Mode Configuration ------------------------*/
|
|
||||||
/* In case of Output or Alternate function mode selection */
|
|
||||||
if ((GPIO_Init->Mode == GPIO_MODE_OUTPUT_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_PP) ||
|
|
||||||
(GPIO_Init->Mode == GPIO_MODE_OUTPUT_OD) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
|
|
||||||
{
|
|
||||||
/* Check the Speed parameter */
|
|
||||||
assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
|
|
||||||
/* Configure the IO Speed */
|
|
||||||
temp = GPIOx->OSPEEDR;
|
|
||||||
temp &= ~(GPIO_OSPEEDER_OSPEED0 << (position * 2U));
|
|
||||||
temp |= (GPIO_Init->Speed << (position * 2U));
|
|
||||||
GPIOx->OSPEEDR = temp;
|
|
||||||
|
|
||||||
/* Configure the IO Output Type */
|
|
||||||
temp = GPIOx->OTYPER;
|
|
||||||
temp &= ~(GPIO_OTYPER_OT_0 << position) ;
|
|
||||||
temp |= (((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4U) << position);
|
|
||||||
GPIOx->OTYPER = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Activate the Pull-up or Pull down resistor for the current IO */
|
|
||||||
temp = GPIOx->PUPDR;
|
|
||||||
temp &= ~(GPIO_PUPDR_PUPD0 << (position * 2U));
|
|
||||||
temp |= ((GPIO_Init->Pull) << (position * 2U));
|
|
||||||
GPIOx->PUPDR = temp;
|
|
||||||
|
|
||||||
/* In case of Alternate function mode selection */
|
|
||||||
if ((GPIO_Init->Mode == GPIO_MODE_AF_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
|
|
||||||
{
|
|
||||||
/* Check the Alternate function parameters */
|
|
||||||
assert_param(IS_GPIO_AF_INSTANCE(GPIOx));
|
|
||||||
assert_param(IS_GPIO_AF(GPIO_Init->Alternate));
|
|
||||||
|
|
||||||
/* Configure Alternate function mapped with the current IO */
|
|
||||||
temp = GPIOx->AFR[position >> 3U];
|
|
||||||
temp &= ~(0xFUL << ((uint32_t)(position & 0x07UL) * 4U));
|
|
||||||
temp |= ((uint32_t)(GPIO_Init->Alternate) << (((uint32_t)position & (uint32_t)0x07U) * 4U));
|
|
||||||
GPIOx->AFR[position >> 3U] = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure IO Direction mode (Input, Output, Alternate or Analog) */
|
|
||||||
temp = GPIOx->MODER;
|
|
||||||
temp &= ~(GPIO_MODER_MODE0 << (position * 2U));
|
|
||||||
temp |= ((GPIO_Init->Mode & GPIO_MODE) << (position * 2U));
|
|
||||||
GPIOx->MODER = temp;
|
|
||||||
|
|
||||||
/*--------------------- EXTI Mode Configuration ------------------------*/
|
|
||||||
/* Configure the External Interrupt or event for the current IO */
|
|
||||||
if ((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE)
|
|
||||||
{
|
|
||||||
/* Enable SYSCFG Clock */
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
||||||
|
|
||||||
temp = SYSCFG->EXTICR[position >> 2U];
|
|
||||||
CLEAR_BIT(temp, (0x0FUL) << (4U * (position & 0x03U)));
|
|
||||||
SET_BIT(temp, (GPIO_GET_INDEX(GPIOx)) << (4 * (position & 0x03U)));
|
|
||||||
SYSCFG->EXTICR[position >> 2U] = temp;
|
|
||||||
|
|
||||||
/* Clear EXTI line configuration */
|
|
||||||
temp = EXTI->IMR;
|
|
||||||
temp &= ~((uint32_t)iocurrent);
|
|
||||||
if ((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
|
|
||||||
{
|
|
||||||
temp |= iocurrent;
|
|
||||||
}
|
|
||||||
EXTI->IMR = temp;
|
|
||||||
|
|
||||||
temp = EXTI->EMR;
|
|
||||||
temp &= ~((uint32_t)iocurrent);
|
|
||||||
if ((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
|
|
||||||
{
|
|
||||||
temp |= iocurrent;
|
|
||||||
}
|
|
||||||
EXTI->EMR = temp;
|
|
||||||
|
|
||||||
/* Clear Rising Falling edge configuration */
|
|
||||||
temp = EXTI->RTSR;
|
|
||||||
temp &= ~((uint32_t)iocurrent);
|
|
||||||
if ((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE)
|
|
||||||
{
|
|
||||||
temp |= iocurrent;
|
|
||||||
}
|
|
||||||
EXTI->RTSR = temp;
|
|
||||||
|
|
||||||
temp = EXTI->FTSR;
|
|
||||||
temp &= ~((uint32_t)iocurrent);
|
|
||||||
if ((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE)
|
|
||||||
{
|
|
||||||
temp |= iocurrent;
|
|
||||||
}
|
|
||||||
EXTI->FTSR = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
position++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief De-initializes the GPIOx peripheral registers to their default reset values.
|
|
||||||
* @param GPIOx where x can be (A..E and H) to select the GPIO peripheral for STM32L0XX family devices.
|
|
||||||
* Note that GPIOE is not available on all devices.
|
|
||||||
* @param GPIO_Pin specifies the port bit to be written.
|
|
||||||
* This parameter can be one of GPIO_PIN_x where x can be (0..15).
|
|
||||||
* All port bits are not necessarily available on all GPIOs.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
|
|
||||||
{
|
|
||||||
uint32_t position = 0x00U;
|
|
||||||
uint32_t iocurrent = 0x00U;
|
|
||||||
uint32_t tmp = 0x00U;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx, GPIO_Pin));
|
|
||||||
|
|
||||||
/* Configure the port pins */
|
|
||||||
while ((GPIO_Pin >> position) != 0)
|
|
||||||
{
|
|
||||||
/* Get the IO position */
|
|
||||||
iocurrent = (GPIO_Pin) & (1U << position);
|
|
||||||
|
|
||||||
if (iocurrent)
|
|
||||||
{
|
|
||||||
/*------------------------- EXTI Mode Configuration --------------------*/
|
|
||||||
/* Clear the External Interrupt or Event for the current IO */
|
|
||||||
|
|
||||||
tmp = SYSCFG->EXTICR[position >> 2U];
|
|
||||||
tmp &= ((0x0FUL) << (4U * (position & 0x03U)));
|
|
||||||
if (tmp == (GPIO_GET_INDEX(GPIOx) << (4U * (position & 0x03U))))
|
|
||||||
{
|
|
||||||
/* Clear EXTI line configuration */
|
|
||||||
EXTI->IMR &= ~((uint32_t)iocurrent);
|
|
||||||
EXTI->EMR &= ~((uint32_t)iocurrent);
|
|
||||||
|
|
||||||
/* Clear Rising Falling edge configuration */
|
|
||||||
EXTI->RTSR &= ~((uint32_t)iocurrent);
|
|
||||||
EXTI->FTSR &= ~((uint32_t)iocurrent);
|
|
||||||
|
|
||||||
tmp = (0x0FUL) << (4U * (position & 0x03U));
|
|
||||||
SYSCFG->EXTICR[position >> 2U] &= ~tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------- GPIO Mode Configuration --------------------*/
|
|
||||||
/* Configure IO Direction in Input Floting Mode */
|
|
||||||
GPIOx->MODER |= (GPIO_MODER_MODE0 << (position * 2U));
|
|
||||||
|
|
||||||
/* Configure the default Alternate Function in current IO */
|
|
||||||
GPIOx->AFR[position >> 3U] &= ~(0xFUL << ((uint32_t)(position & 0x07UL) * 4U));
|
|
||||||
|
|
||||||
/* Deactivate the Pull-up oand Pull-down resistor for the current IO */
|
|
||||||
GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPD0 << (position * 2U));
|
|
||||||
|
|
||||||
/* Configure the default value IO Output Type */
|
|
||||||
GPIOx->OTYPER &= ~(GPIO_OTYPER_OT_0 << position);
|
|
||||||
|
|
||||||
/* Configure the default value for IO Speed */
|
|
||||||
GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEED0 << (position * 2U));
|
|
||||||
}
|
|
||||||
position++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup GPIO_Exported_Functions_Group2
|
|
||||||
* @brief GPIO Read and Write
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### IO operation functions #####
|
|
||||||
===============================================================================
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Reads the specified input port pin.
|
|
||||||
* @param GPIOx where x can be (A..E and H) to select the GPIO peripheral for STM32L0xx family devices.
|
|
||||||
* Note that GPIOE is not available on all devices.
|
|
||||||
* @param GPIO_Pin specifies the port bit to read.
|
|
||||||
* This parameter can be GPIO_PIN_x where x can be (0..15).
|
|
||||||
* All port bits are not necessarily available on all GPIOs.
|
|
||||||
* @retval The input port pin value.
|
|
||||||
*/
|
|
||||||
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
|
|
||||||
{
|
|
||||||
GPIO_PinState bitstatus;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx, GPIO_Pin));
|
|
||||||
|
|
||||||
if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
|
|
||||||
{
|
|
||||||
bitstatus = GPIO_PIN_SET;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bitstatus = GPIO_PIN_RESET;
|
|
||||||
}
|
|
||||||
return bitstatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets or clears the selected data port bit.
|
|
||||||
*
|
|
||||||
* @note This function uses GPIOx_BSRR register to allow atomic read/modify
|
|
||||||
* accesses. In this way, there is no risk of an IRQ occurring between
|
|
||||||
* the read and the modify access.
|
|
||||||
*
|
|
||||||
* @param GPIOx where x can be (A..E and H) to select the GPIO peripheral for STM32L0xx family devices.
|
|
||||||
* Note that GPIOE is not available on all devices.
|
|
||||||
* @param GPIO_Pin specifies the port bit to be written.
|
|
||||||
* This parameter can be one of GPIO_PIN_x where x can be (0..15).
|
|
||||||
* All port bits are not necessarily available on all GPIOs.
|
|
||||||
* @param PinState specifies the value to be written to the selected bit.
|
|
||||||
* This parameter can be one of the GPIO_PinState enum values:
|
|
||||||
* GPIO_PIN_RESET: to clear the port pin
|
|
||||||
* GPIO_PIN_SET: to set the port pin
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx, GPIO_Pin));
|
|
||||||
assert_param(IS_GPIO_PIN_ACTION(PinState));
|
|
||||||
|
|
||||||
if (PinState != GPIO_PIN_RESET)
|
|
||||||
{
|
|
||||||
GPIOx->BSRR = GPIO_Pin;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GPIOx->BRR = GPIO_Pin ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Toggles the specified GPIO pins.
|
|
||||||
* @param GPIOx Where x can be (A..E and H) to select the GPIO peripheral for STM32L0xx family devices.
|
|
||||||
* Note that GPIOE is not available on all devices.
|
|
||||||
* All port bits are not necessarily available on all GPIOs.
|
|
||||||
* @param GPIO_Pin Specifies the pins to be toggled.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
|
|
||||||
{
|
|
||||||
uint32_t odr;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx, GPIO_Pin));
|
|
||||||
|
|
||||||
/* get current Ouput Data Register value */
|
|
||||||
odr = GPIOx->ODR;
|
|
||||||
|
|
||||||
/* Set selected pins that were at low level, and reset ones that were high */
|
|
||||||
GPIOx->BSRR = ((odr & GPIO_Pin) << GPIO_NUMBER) | (~odr & GPIO_Pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Locks GPIO Pins configuration registers.
|
|
||||||
* @note The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR,
|
|
||||||
* GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
|
|
||||||
* @note The configuration of the locked GPIO pins can no longer be modified
|
|
||||||
* until the next reset.
|
|
||||||
* @param GPIOx where x can be (A..E and H) to select the GPIO peripheral for STM32L0xx family.
|
|
||||||
* Note that GPIOE is not available on all devices.
|
|
||||||
* @param GPIO_Pin specifies the port bit to be locked.
|
|
||||||
* This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
|
|
||||||
* All port bits are not necessarily available on all GPIOs.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
|
|
||||||
{
|
|
||||||
__IO uint32_t tmp = GPIO_LCKR_LCKK;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx, GPIO_Pin));
|
|
||||||
|
|
||||||
/* Apply lock key write sequence */
|
|
||||||
tmp |= GPIO_Pin;
|
|
||||||
/* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
|
|
||||||
GPIOx->LCKR = tmp;
|
|
||||||
/* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */
|
|
||||||
GPIOx->LCKR = GPIO_Pin;
|
|
||||||
/* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
|
|
||||||
GPIOx->LCKR = tmp;
|
|
||||||
/* Read LCKK register. This read is mandatory to complete key lock sequence */
|
|
||||||
tmp = GPIOx->LCKR;
|
|
||||||
|
|
||||||
/* read again in order to confirm lock is active */
|
|
||||||
if ((GPIOx->LCKR & GPIO_LCKR_LCKK) != RESET)
|
|
||||||
{
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief This function handles EXTI interrupt request.
|
|
||||||
* @param GPIO_Pin Specifies the pins connected to the EXTI line.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
|
|
||||||
{
|
|
||||||
/* EXTI line interrupt detected */
|
|
||||||
if (__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET)
|
|
||||||
{
|
|
||||||
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
|
|
||||||
HAL_GPIO_EXTI_Callback(GPIO_Pin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXTI line detection callbacks.
|
|
||||||
* @param GPIO_Pin Specifies the pins connected to the EXTI line.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
__weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|
||||||
{
|
|
||||||
/* Prevent unused argument(s) compilation warning */
|
|
||||||
UNUSED(GPIO_Pin);
|
|
||||||
|
|
||||||
/* NOTE: This function Should not be modified, when the callback is needed,
|
|
||||||
the HAL_GPIO_EXTI_Callback could be implemented in the user file
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,337 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_i2c_ex.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief I2C Extended HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of I2C Extended peripheral:
|
|
||||||
* + Extended features functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### I2C peripheral Extended features #####
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
[..] Comparing to other previous devices, the I2C interface for STM32L0xx
|
|
||||||
devices contains the following additional features
|
|
||||||
|
|
||||||
(+) Possibility to disable or enable Analog Noise Filter
|
|
||||||
(+) Use of a configured Digital Noise Filter
|
|
||||||
(+) Disable or enable wakeup from Stop mode(s)
|
|
||||||
(+) Disable or enable Fast Mode Plus
|
|
||||||
|
|
||||||
##### How to use this driver #####
|
|
||||||
==============================================================================
|
|
||||||
[..] This driver provides functions to configure Noise Filter and Wake Up Feature
|
|
||||||
(#) Configure I2C Analog noise filter using the function HAL_I2CEx_ConfigAnalogFilter()
|
|
||||||
(#) Configure I2C Digital noise filter using the function HAL_I2CEx_ConfigDigitalFilter()
|
|
||||||
(#) Configure the enable or disable of I2C Wake Up Mode using the functions :
|
|
||||||
(++) HAL_I2CEx_EnableWakeUp()
|
|
||||||
(++) HAL_I2CEx_DisableWakeUp()
|
|
||||||
(#) Configure the enable or disable of fast mode plus driving capability using the functions :
|
|
||||||
(++) HAL_I2CEx_EnableFastModePlus()
|
|
||||||
(++) HAL_I2CEx_DisableFastModePlus()
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx I2CEx
|
|
||||||
* @brief I2C Extended HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_I2C_MODULE_ENABLED
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Exported_Functions I2C Extended Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Exported_Functions_Group1 Extended features functions
|
|
||||||
* @brief Extended features functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Extended features functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Configure Noise Filters
|
|
||||||
(+) Configure Wake Up Feature
|
|
||||||
(+) Configure Fast Mode Plus
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure I2C Analog noise filter.
|
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @param AnalogFilter New state of the Analog filter.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
|
|
||||||
assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Reset I2Cx ANOFF bit */
|
|
||||||
hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF);
|
|
||||||
|
|
||||||
/* Set analog filter bit*/
|
|
||||||
hi2c->Instance->CR1 |= AnalogFilter;
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hi2c);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure I2C Digital noise filter.
|
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @param DigitalFilter Coefficient of digital noise filter between Min_Data=0x00 and Max_Data=0x0F.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
|
|
||||||
{
|
|
||||||
uint32_t tmpreg;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
|
|
||||||
assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Get the old register value */
|
|
||||||
tmpreg = hi2c->Instance->CR1;
|
|
||||||
|
|
||||||
/* Reset I2Cx DNF bits [11:8] */
|
|
||||||
tmpreg &= ~(I2C_CR1_DNF);
|
|
||||||
|
|
||||||
/* Set I2Cx DNF coefficient */
|
|
||||||
tmpreg |= DigitalFilter << 8U;
|
|
||||||
|
|
||||||
/* Store the new register value */
|
|
||||||
hi2c->Instance->CR1 = tmpreg;
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hi2c);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable I2C wakeup from Stop mode(s).
|
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hi2c->Instance));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Enable wakeup from stop mode */
|
|
||||||
hi2c->Instance->CR1 |= I2C_CR1_WUPEN;
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hi2c);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable I2C wakeup from Stop mode(s).
|
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hi2c->Instance));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Enable wakeup from stop mode */
|
|
||||||
hi2c->Instance->CR1 &= ~(I2C_CR1_WUPEN);
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hi2c);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (defined(SYSCFG_CFGR2_I2C_PB6_FMP) || defined(SYSCFG_CFGR2_I2C_PB7_FMP)) || (defined(SYSCFG_CFGR2_I2C_PB8_FMP) || defined(SYSCFG_CFGR2_I2C_PB9_FMP)) || (defined(SYSCFG_CFGR2_I2C1_FMP)) || defined(SYSCFG_CFGR2_I2C2_FMP) || defined(SYSCFG_CFGR2_I2C3_FMP)
|
|
||||||
/**
|
|
||||||
* @brief Enable the I2C fast mode plus driving capability.
|
|
||||||
* @param ConfigFastModePlus Selects the pin.
|
|
||||||
* This parameter can be one of the @ref I2CEx_FastModePlus values
|
|
||||||
* @note For I2C1, fast mode plus driving capability can be enabled on all selected
|
|
||||||
* I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently
|
|
||||||
* on each one of the following pins PB6, PB7, PB8 and PB9.
|
|
||||||
* @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability
|
|
||||||
* can be enabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
|
|
||||||
* @note For all I2C2 pins fast mode plus driving capability can be enabled
|
|
||||||
* only by using I2C_FASTMODEPLUS_I2C2 parameter.
|
|
||||||
* @note For all I2C3 pins fast mode plus driving capability can be enabled
|
|
||||||
* only by using I2C_FASTMODEPLUS_I2C3 parameter.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
|
|
||||||
{
|
|
||||||
/* Check the parameter */
|
|
||||||
assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
|
|
||||||
|
|
||||||
/* Enable SYSCFG clock */
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
||||||
|
|
||||||
/* Enable fast mode plus driving capability for selected pin */
|
|
||||||
SET_BIT(SYSCFG->CFGR2, (uint32_t)ConfigFastModePlus);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the I2C fast mode plus driving capability.
|
|
||||||
* @param ConfigFastModePlus Selects the pin.
|
|
||||||
* This parameter can be one of the @ref I2CEx_FastModePlus values
|
|
||||||
* @note For I2C1, fast mode plus driving capability can be disabled on all selected
|
|
||||||
* I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently
|
|
||||||
* on each one of the following pins PB6, PB7, PB8 and PB9.
|
|
||||||
* @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability
|
|
||||||
* can be disabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
|
|
||||||
* @note For all I2C2 pins fast mode plus driving capability can be disabled
|
|
||||||
* only by using I2C_FASTMODEPLUS_I2C2 parameter.
|
|
||||||
* @note For all I2C3 pins fast mode plus driving capability can be disabled
|
|
||||||
* only by using I2C_FASTMODEPLUS_I2C3 parameter.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
|
|
||||||
{
|
|
||||||
/* Check the parameter */
|
|
||||||
assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
|
|
||||||
|
|
||||||
/* Enable SYSCFG clock */
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
||||||
|
|
||||||
/* Disable fast mode plus driving capability for selected pin */
|
|
||||||
CLEAR_BIT(SYSCFG->CFGR2, (uint32_t)ConfigFastModePlus);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -1,733 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_pwr.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief PWR HAL module driver.
|
|
||||||
*
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of the Power Controller (PWR) peripheral:
|
|
||||||
* + Initialization/de-initialization functions
|
|
||||||
* + Peripheral Control functions
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
#ifdef HAL_PWR_MODULE_ENABLED
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWR
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWR_Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
/** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PVD_MODE_IT (0x00010000U)
|
|
||||||
#define PVD_MODE_EVT (0x00020000U)
|
|
||||||
#define PVD_RISING_EDGE (0x00000001U)
|
|
||||||
#define PVD_FALLING_EDGE (0x00000002U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @addtogroup PWR_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWR_Exported_Functions_Group1
|
|
||||||
* @brief Initialization and de-initialization functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Initialization and de-initialization functions #####
|
|
||||||
===============================================================================
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deinitializes the HAL PWR peripheral registers to their default reset values.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_DeInit(void)
|
|
||||||
{
|
|
||||||
__HAL_RCC_PWR_FORCE_RESET();
|
|
||||||
__HAL_RCC_PWR_RELEASE_RESET();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWR_Exported_Functions_Group2
|
|
||||||
* @brief Low Power modes configuration functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
##### Peripheral Control functions #####
|
|
||||||
===============================================================================
|
|
||||||
|
|
||||||
*** Backup domain ***
|
|
||||||
=========================
|
|
||||||
[..]
|
|
||||||
After reset, the backup domain (RTC registers, RTC backup data
|
|
||||||
registers) is protected against possible unwanted
|
|
||||||
write accesses.
|
|
||||||
To enable access to the RTC Domain and RTC registers, proceed as follows:
|
|
||||||
(+) Enable the Power Controller (PWR) APB1 interface clock using the
|
|
||||||
__HAL_RCC_PWR_CLK_ENABLE() macro.
|
|
||||||
(+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
|
|
||||||
|
|
||||||
*** PVD configuration ***
|
|
||||||
=========================
|
|
||||||
[..]
|
|
||||||
(+) The PVD is used to monitor the VDD power supply by comparing it to a
|
|
||||||
threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
|
|
||||||
(+) The PVD can use an external input analog voltage (PVD_IN) which is compared
|
|
||||||
internally to VREFINT. The PVD_IN (PB7) has to be configured in Analog mode
|
|
||||||
when PWR_PVDLevel_7 is selected (PLS[2:0] = 111).
|
|
||||||
|
|
||||||
(+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
|
|
||||||
than the PVD threshold. This event is internally connected to the EXTI
|
|
||||||
line16 and can generate an interrupt if enabled. This is done through
|
|
||||||
__HAL_PWR_PVD_EXTI_ENABLE_IT() macro.
|
|
||||||
(+) The PVD is stopped in Standby mode.
|
|
||||||
(+) The PVD feature is not supported on L0 Value line.
|
|
||||||
|
|
||||||
*** WakeUp pin configuration ***
|
|
||||||
================================
|
|
||||||
[..]
|
|
||||||
(+) WakeUp pin is used to wake up the system from Standby mode. This pin is
|
|
||||||
forced in input pull-down configuration and is active on rising edges.
|
|
||||||
(+) There are two WakeUp pins:
|
|
||||||
WakeUp Pin 1 on PA.00.
|
|
||||||
WakeUp Pin 2 on PC.13.
|
|
||||||
WakeUp Pin 3 on PE.06 .
|
|
||||||
|
|
||||||
|
|
||||||
[..]
|
|
||||||
*** Main and Backup Regulators configuration ***
|
|
||||||
================================================
|
|
||||||
|
|
||||||
(+) The main internal regulator can be configured to have a tradeoff between
|
|
||||||
performance and power consumption when the device does not operate at
|
|
||||||
the maximum frequency. This is done through __HAL_PWR_VOLTAGESCALING_CONFIG()
|
|
||||||
macro which configures the two VOS bits in PWR_CR register:
|
|
||||||
(++) PWR_REGULATOR_VOLTAGE_SCALE1 (VOS bits = 01), the regulator voltage output Scale 1 mode selected and
|
|
||||||
the System frequency can go up to 32 MHz.
|
|
||||||
(++) PWR_REGULATOR_VOLTAGE_SCALE2 (VOS bits = 10), the regulator voltage output Scale 2 mode selected and
|
|
||||||
the System frequency can go up to 16 MHz.
|
|
||||||
(++) PWR_REGULATOR_VOLTAGE_SCALE3 (VOS bits = 11), the regulator voltage output Scale 3 mode selected and
|
|
||||||
the System frequency can go up to 4.2 MHz.
|
|
||||||
|
|
||||||
Refer to the datasheets for more details.
|
|
||||||
|
|
||||||
*** Low Power modes configuration ***
|
|
||||||
=====================================
|
|
||||||
[..]
|
|
||||||
The device features 5 low-power modes:
|
|
||||||
(+) Low power run mode: regulator in low power mode, limited clock frequency,
|
|
||||||
limited number of peripherals running.
|
|
||||||
(+) Sleep mode: Cortex-M0+ core stopped, peripherals kept running.
|
|
||||||
(+) Low power sleep mode: Cortex-M0+ core stopped, limited clock frequency,
|
|
||||||
limited number of peripherals running, regulator in low power mode.
|
|
||||||
(+) Stop mode: All clocks are stopped, regulator running, regulator in low power mode.
|
|
||||||
(+) Standby mode: VCORE domain powered off
|
|
||||||
|
|
||||||
*** Low power run mode ***
|
|
||||||
=========================
|
|
||||||
[..]
|
|
||||||
To further reduce the consumption when the system is in Run mode, the regulator can be
|
|
||||||
configured in low power mode. In this mode, the system frequency should not exceed
|
|
||||||
MSI frequency range1.
|
|
||||||
In Low power run mode, all I/O pins keep the same state as in Run mode.
|
|
||||||
|
|
||||||
(+) Entry:
|
|
||||||
(++) VCORE in range2
|
|
||||||
(++) Decrease the system frequency not to exceed the frequency of MSI frequency range1.
|
|
||||||
(++) The regulator is forced in low power mode using the HAL_PWREx_EnableLowPowerRunMode()
|
|
||||||
function.
|
|
||||||
(+) Exit:
|
|
||||||
(++) The regulator is forced in Main regulator mode using the HAL_PWREx_DisableLowPowerRunMode()
|
|
||||||
function.
|
|
||||||
(++) Increase the system frequency if needed.
|
|
||||||
|
|
||||||
*** Sleep mode ***
|
|
||||||
==================
|
|
||||||
[..]
|
|
||||||
(+) Entry:
|
|
||||||
The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFx)
|
|
||||||
functions with
|
|
||||||
(++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
|
|
||||||
(++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
|
|
||||||
|
|
||||||
(+) Exit:
|
|
||||||
(++) Any peripheral interrupt acknowledged by the nested vectored interrupt
|
|
||||||
controller (NVIC) can wake up the device from Sleep mode. If the WFE instruction was used to enter sleep mode,
|
|
||||||
the MCU exits Sleep mode as soon as an event occurs.
|
|
||||||
|
|
||||||
*** Low power sleep mode ***
|
|
||||||
============================
|
|
||||||
[..]
|
|
||||||
(+) Entry:
|
|
||||||
The Low power sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFx)
|
|
||||||
functions with
|
|
||||||
(++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
|
|
||||||
(++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
|
|
||||||
(+) The Flash memory can be switched off by using the control bits (SLEEP_PD in the FLASH_ACR register.
|
|
||||||
This reduces power consumption but increases the wake-up time.
|
|
||||||
|
|
||||||
(+) Exit:
|
|
||||||
(++) If the WFI instruction was used to enter Low power sleep mode, any peripheral interrupt
|
|
||||||
acknowledged by the nested vectored interrupt controller (NVIC) can wake up the device
|
|
||||||
from Low power sleep mode. If the WFE instruction was used to enter Low power sleep mode,
|
|
||||||
the MCU exits Sleep mode as soon as an event occurs.
|
|
||||||
|
|
||||||
*** Stop mode ***
|
|
||||||
=================
|
|
||||||
[..]
|
|
||||||
The Stop mode is based on the Cortex-M0+ deepsleep mode combined with peripheral
|
|
||||||
clock gating. The voltage regulator can be configured either in normal or low-power mode.
|
|
||||||
In Stop mode, all clocks in the VCORE domain are stopped, the PLL, the MSI, the HSI and
|
|
||||||
the HSE RC oscillators are disabled. Internal SRAM and register contents are preserved.
|
|
||||||
To get the lowest consumption in Stop mode, the internal Flash memory also enters low
|
|
||||||
power mode. When the Flash memory is in power-down mode, an additional startup delay is
|
|
||||||
incurred when waking up from Stop mode.
|
|
||||||
To minimize the consumption In Stop mode, VREFINT, the BOR, PVD, and temperature
|
|
||||||
sensor can be switched off before entering Stop mode. They can be switched on again by
|
|
||||||
software after exiting Stop mode using the ULP bit in the PWR_CR register.
|
|
||||||
In Stop mode, all I/O pins keep the same state as in Run mode.
|
|
||||||
|
|
||||||
(+) Entry:
|
|
||||||
The Stop mode is entered using the HAL_PWR_EnterSTOPMode
|
|
||||||
function with:
|
|
||||||
(++) Main regulator ON.
|
|
||||||
(++) Low Power regulator ON.
|
|
||||||
(++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
|
|
||||||
(++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
|
|
||||||
(+) Exit:
|
|
||||||
(++) By issuing an interrupt or a wakeup event, the MSI or HSI16 RC
|
|
||||||
oscillator is selected as system clock depending the bit STOPWUCK in the RCC_CFGR
|
|
||||||
register
|
|
||||||
|
|
||||||
*** Standby mode ***
|
|
||||||
====================
|
|
||||||
[..]
|
|
||||||
The Standby mode allows to achieve the lowest power consumption. It is based on the
|
|
||||||
Cortex-M0+ deepsleep mode, with the voltage regulator disabled. The VCORE domain is
|
|
||||||
consequently powered off. The PLL, the MSI, the HSI oscillator and the HSE oscillator are
|
|
||||||
also switched off. SRAM and register contents are lost except for the RTC registers, RTC
|
|
||||||
backup registers and Standby circuitry.
|
|
||||||
|
|
||||||
To minimize the consumption In Standby mode, VREFINT, the BOR, PVD, and temperature
|
|
||||||
sensor can be switched off before entering the Standby mode. They can be switched
|
|
||||||
on again by software after exiting the Standby mode.
|
|
||||||
function.
|
|
||||||
|
|
||||||
(+) Entry:
|
|
||||||
(++) The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function.
|
|
||||||
(+) Exit:
|
|
||||||
(++) WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wakeup,
|
|
||||||
tamper event, time-stamp event, external reset in NRST pin, IWDG reset.
|
|
||||||
|
|
||||||
*** Auto-wakeup (AWU) from low-power mode ***
|
|
||||||
=============================================
|
|
||||||
[..]
|
|
||||||
The MCU can be woken up from low-power mode by an RTC Alarm event, an RTC
|
|
||||||
Wakeup event, a tamper event, a time-stamp event, or a comparator event,
|
|
||||||
without depending on an external interrupt (Auto-wakeup mode).
|
|
||||||
|
|
||||||
(+) RTC auto-wakeup (AWU) from the Stop mode
|
|
||||||
(++) To wake up from the Stop mode with an RTC alarm event, it is necessary to:
|
|
||||||
(+++) Configure the EXTI Line 17 to be sensitive to rising edges (Interrupt
|
|
||||||
or Event modes) using the EXTI_Init() function.
|
|
||||||
(+++) Enable the RTC Alarm Interrupt using the RTC_ITConfig() function
|
|
||||||
(+++) Configure the RTC to generate the RTC alarm using the RTC_SetAlarm()
|
|
||||||
and RTC_AlarmCmd() functions.
|
|
||||||
(++) To wake up from the Stop mode with an RTC Tamper or time stamp event, it
|
|
||||||
is necessary to:
|
|
||||||
(+++) Configure the EXTI Line 19 to be sensitive to rising edges (Interrupt
|
|
||||||
or Event modes) using the EXTI_Init() function.
|
|
||||||
(+++) Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig()
|
|
||||||
function.
|
|
||||||
(+++) Configure the RTC to detect the tamper or time stamp event using the
|
|
||||||
RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd()
|
|
||||||
functions.
|
|
||||||
(++) To wake up from the Stop mode with an RTC WakeUp event, it is necessary to:
|
|
||||||
(+++) Configure the EXTI Line 20 to be sensitive to rising edges (Interrupt
|
|
||||||
or Event modes) using the EXTI_Init() function.
|
|
||||||
(+++) Enable the RTC WakeUp Interrupt using the RTC_ITConfig() function.
|
|
||||||
(+++) Configure the RTC to generate the RTC WakeUp event using the RTC_WakeUpClockConfig(),
|
|
||||||
RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions.
|
|
||||||
|
|
||||||
(+) RTC auto-wakeup (AWU) from the Standby mode
|
|
||||||
(++) To wake up from the Standby mode with an RTC alarm event, it is necessary to:
|
|
||||||
(+++) Enable the RTC Alarm Interrupt using the RTC_ITConfig() function.
|
|
||||||
(+++) Configure the RTC to generate the RTC alarm using the RTC_SetAlarm()
|
|
||||||
and RTC_AlarmCmd() functions.
|
|
||||||
(++) To wake up from the Standby mode with an RTC Tamper or time stamp event, it
|
|
||||||
is necessary to:
|
|
||||||
(+++) Enable the RTC Tamper or time stamp Interrupt using the RTC_ITConfig()
|
|
||||||
function.
|
|
||||||
(+++) Configure the RTC to detect the tamper or time stamp event using the
|
|
||||||
RTC_TimeStampConfig(), RTC_TamperTriggerConfig() and RTC_TamperCmd()
|
|
||||||
functions.
|
|
||||||
(++) To wake up from the Standby mode with an RTC WakeUp event, it is necessary to:
|
|
||||||
(+++) Enable the RTC WakeUp Interrupt using the RTC_ITConfig() function
|
|
||||||
(+++) Configure the RTC to generate the RTC WakeUp event using the RTC_WakeUpClockConfig(),
|
|
||||||
RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions.
|
|
||||||
|
|
||||||
(+) Comparator auto-wakeup (AWU) from the Stop mode
|
|
||||||
(++) To wake up from the Stop mode with an comparator 1 or comparator 2 wakeup
|
|
||||||
event, it is necessary to:
|
|
||||||
(+++) Configure the EXTI Line 21 for comparator 1 or EXTI Line 22 for comparator 2
|
|
||||||
to be sensitive to to the selected edges (falling, rising or falling
|
|
||||||
and rising) (Interrupt or Event modes) using the EXTI_Init() function.
|
|
||||||
(+++) Configure the comparator to generate the event.
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables access to the backup domain (RTC registers, RTC
|
|
||||||
* backup data registers ).
|
|
||||||
* @note If the HSE divided by 2, 4, 8 or 16 is used as the RTC clock, the
|
|
||||||
* Backup Domain Access should be kept enabled.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_EnableBkUpAccess(void)
|
|
||||||
{
|
|
||||||
/* Enable access to RTC and backup registers */
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_DBP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables access to the backup domain
|
|
||||||
* @note Applies to RTC registers, RTC backup data registers.
|
|
||||||
* @note If the HSE divided by 2, 4, 8 or 16 is used as the RTC clock, the
|
|
||||||
* Backup Domain Access should be kept enabled.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_DisableBkUpAccess(void)
|
|
||||||
{
|
|
||||||
/* Disable access to RTC and backup registers */
|
|
||||||
CLEAR_BIT(PWR->CR, PWR_CR_DBP);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
/**
|
|
||||||
* @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
|
|
||||||
* @param sConfigPVD pointer to an PWR_PVDTypeDef structure that contains the configuration
|
|
||||||
* information for the PVD.
|
|
||||||
* @note Refer to the electrical characteristics of your device datasheet for
|
|
||||||
* more details about the voltage threshold corresponding to each
|
|
||||||
* detection level.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
|
|
||||||
assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
|
|
||||||
|
|
||||||
/* Set PLS[7:5] bits according to PVDLevel value */
|
|
||||||
MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
|
|
||||||
|
|
||||||
/* Clear any previous config. Keep it clear if no event or IT mode is selected */
|
|
||||||
__HAL_PWR_PVD_EXTI_DISABLE_EVENT();
|
|
||||||
__HAL_PWR_PVD_EXTI_DISABLE_IT();
|
|
||||||
__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
|
|
||||||
__HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();
|
|
||||||
|
|
||||||
/* Configure interrupt mode */
|
|
||||||
if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
|
|
||||||
{
|
|
||||||
__HAL_PWR_PVD_EXTI_ENABLE_IT();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure event mode */
|
|
||||||
if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
|
|
||||||
{
|
|
||||||
__HAL_PWR_PVD_EXTI_ENABLE_EVENT();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure the edge */
|
|
||||||
if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
|
|
||||||
{
|
|
||||||
__HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();
|
|
||||||
}
|
|
||||||
|
|
||||||
if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
|
|
||||||
{
|
|
||||||
__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables the Power Voltage Detector(PVD).
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_EnablePVD(void)
|
|
||||||
{
|
|
||||||
/* Enable the power voltage detector */
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_PVDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables the Power Voltage Detector(PVD).
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_DisablePVD(void)
|
|
||||||
{
|
|
||||||
/* Disable the power voltage detector */
|
|
||||||
CLEAR_BIT(PWR->CR, PWR_CR_PVDE);
|
|
||||||
}
|
|
||||||
#endif /* PWR_PVD_SUPPORT */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables the WakeUp PINx functionality.
|
|
||||||
* @param WakeUpPinx: Specifies the Power Wake-Up pin to enable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_WAKEUP_PIN1
|
|
||||||
* @arg PWR_WAKEUP_PIN2
|
|
||||||
* @arg PWR_WAKEUP_PIN3 for stm32l07xxx and stm32l08xxx devices only.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
|
|
||||||
{
|
|
||||||
/* Check the parameter */
|
|
||||||
assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
|
|
||||||
/* Enable the EWUPx pin */
|
|
||||||
SET_BIT(PWR->CSR, WakeUpPinx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables the WakeUp PINx functionality.
|
|
||||||
* @param WakeUpPinx: Specifies the Power Wake-Up pin to disable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_WAKEUP_PIN1
|
|
||||||
* @arg PWR_WAKEUP_PIN2
|
|
||||||
* @arg PWR_WAKEUP_PIN3 for stm32l07xxx and stm32l08xxx devices only.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
|
|
||||||
{
|
|
||||||
/* Check the parameter */
|
|
||||||
assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
|
|
||||||
/* Disable the EWUPx pin */
|
|
||||||
CLEAR_BIT(PWR->CSR, WakeUpPinx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enters Sleep mode.
|
|
||||||
* @note In Sleep mode, all I/O pins keep the same state as in Run mode.
|
|
||||||
* @param Regulator: Specifies the regulator state in SLEEP mode.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON
|
|
||||||
* @arg PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON
|
|
||||||
* @param SLEEPEntry: Specifies if SLEEP mode is entered with WFI or WFE instruction.
|
|
||||||
* When WFI entry is used, tick interrupt have to be disabled if not desired as
|
|
||||||
* the interrupt wake up source.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
|
|
||||||
* @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
|
|
||||||
{
|
|
||||||
uint32_t tmpreg = 0U;
|
|
||||||
uint32_t ulpbit, vrefinbit;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_PWR_REGULATOR(Regulator));
|
|
||||||
assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
|
|
||||||
|
|
||||||
/* It is forbidden to configure both EN_VREFINT=1 and ULP=1 if the device is
|
|
||||||
in Stop mode or in Sleep/Low-power sleep mode */
|
|
||||||
ulpbit = READ_BIT(PWR->CR, PWR_CR_ULP);
|
|
||||||
vrefinbit = READ_BIT(SYSCFG->CFGR3, SYSCFG_CFGR3_EN_VREFINT);
|
|
||||||
if((ulpbit != 0) && (vrefinbit != 0))
|
|
||||||
{
|
|
||||||
CLEAR_BIT(PWR->CR, PWR_CR_ULP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Select the regulator state in Sleep mode ---------------------------------*/
|
|
||||||
tmpreg = PWR->CR;
|
|
||||||
|
|
||||||
/* Clear PDDS and LPDS bits */
|
|
||||||
CLEAR_BIT(tmpreg, (PWR_CR_PDDS | PWR_CR_LPSDSR));
|
|
||||||
|
|
||||||
/* Set LPSDSR bit according to PWR_Regulator value */
|
|
||||||
SET_BIT(tmpreg, Regulator);
|
|
||||||
|
|
||||||
/* Store the new value */
|
|
||||||
PWR->CR = tmpreg;
|
|
||||||
|
|
||||||
/* Clear SLEEPDEEP bit of Cortex System Control Register */
|
|
||||||
CLEAR_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk);
|
|
||||||
|
|
||||||
/* Select SLEEP mode entry -------------------------------------------------*/
|
|
||||||
if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
|
|
||||||
{
|
|
||||||
/* Request Wait For Interrupt */
|
|
||||||
__WFI();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Request Wait For Event */
|
|
||||||
__SEV();
|
|
||||||
__WFE();
|
|
||||||
__WFE();
|
|
||||||
}
|
|
||||||
|
|
||||||
if((ulpbit != 0) && (vrefinbit != 0))
|
|
||||||
{
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_ULP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Additional NOP to ensure all pending instructions are flushed before entering low power mode */
|
|
||||||
__NOP();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enters Stop mode.
|
|
||||||
* @note In Stop mode, all I/O pins keep the same state as in Run mode.
|
|
||||||
* @note When exiting Stop mode by issuing an interrupt or a wakeup event,
|
|
||||||
* MSI or HSI16 RCoscillator is selected as system clock depending
|
|
||||||
* the bit STOPWUCK in the RCC_CFGR register.
|
|
||||||
* @note When the voltage regulator operates in low power mode, an additional
|
|
||||||
* startup delay is incurred when waking up from Stop mode.
|
|
||||||
* By keeping the internal regulator ON during Stop mode, the consumption
|
|
||||||
* is higher although the startup time is reduced.
|
|
||||||
* @note Before entering in this function, it is important to ensure that the WUF
|
|
||||||
* wakeup flag is cleared. To perform this action, it is possible to call the
|
|
||||||
* following macro : __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU)
|
|
||||||
*
|
|
||||||
* @param Regulator: Specifies the regulator state in Stop mode.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_MAINREGULATOR_ON: Stop mode with regulator ON
|
|
||||||
* @arg PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON
|
|
||||||
* @param STOPEntry: Specifies if Stop mode in entered with WFI or WFE instruction.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg PWR_STOPENTRY_WFI: Enter Stop mode with WFI instruction
|
|
||||||
* @arg PWR_STOPENTRY_WFE: Enter Stop mode with WFE instruction
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
|
|
||||||
{
|
|
||||||
uint32_t tmpreg = 0U;
|
|
||||||
uint32_t ulpbit, vrefinbit;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_PWR_REGULATOR(Regulator));
|
|
||||||
assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
|
|
||||||
|
|
||||||
/* It is forbidden to configure both EN_VREFINT=1 and ULP=1 if the device is
|
|
||||||
in Stop mode or in Sleep/Low-power sleep mode */
|
|
||||||
ulpbit = READ_BIT(PWR->CR, PWR_CR_ULP);
|
|
||||||
vrefinbit = READ_BIT(SYSCFG->CFGR3, SYSCFG_CFGR3_EN_VREFINT);
|
|
||||||
if((ulpbit != 0) && (vrefinbit != 0))
|
|
||||||
{
|
|
||||||
CLEAR_BIT(PWR->CR, PWR_CR_ULP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Select the regulator state in Stop mode ---------------------------------*/
|
|
||||||
tmpreg = PWR->CR;
|
|
||||||
|
|
||||||
/* Clear PDDS and LPDS bits */
|
|
||||||
CLEAR_BIT(tmpreg, (PWR_CR_PDDS | PWR_CR_LPSDSR));
|
|
||||||
|
|
||||||
/* Set LPSDSR bit according to PWR_Regulator value */
|
|
||||||
SET_BIT(tmpreg, Regulator);
|
|
||||||
|
|
||||||
/* Store the new value */
|
|
||||||
PWR->CR = tmpreg;
|
|
||||||
|
|
||||||
/* Set SLEEPDEEP bit of Cortex System Control Register */
|
|
||||||
SET_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk);
|
|
||||||
|
|
||||||
/* Select Stop mode entry --------------------------------------------------*/
|
|
||||||
if(STOPEntry == PWR_STOPENTRY_WFI)
|
|
||||||
{
|
|
||||||
/* Request Wait For Interrupt */
|
|
||||||
__WFI();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Request Wait For Event */
|
|
||||||
__SEV();
|
|
||||||
__WFE();
|
|
||||||
__WFE();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset SLEEPDEEP bit of Cortex System Control Register */
|
|
||||||
CLEAR_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk);
|
|
||||||
|
|
||||||
if((ulpbit != 0) && (vrefinbit != 0))
|
|
||||||
{
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_ULP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enters Standby mode.
|
|
||||||
* @note In Standby mode, all I/O pins are high impedance except for:
|
|
||||||
* - Reset pad (still available)
|
|
||||||
* - RTC_AF1 pin (PC13) if configured for tamper, time-stamp, RTC
|
|
||||||
* Alarm out, or RTC clock calibration out.
|
|
||||||
* - RTC_AF2 pin (PC13) if configured for tamper.
|
|
||||||
* - WKUP pin 1 (PA00) if enabled.
|
|
||||||
* - WKUP pin 2 (PC13) if enabled.
|
|
||||||
* - WKUP pin 3 (PE06) if enabled, for stm32l07xxx and stm32l08xxx devices only.
|
|
||||||
* - WKUP pin 3 (PA02) if enabled, for stm32l031xx devices only.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_EnterSTANDBYMode(void)
|
|
||||||
{
|
|
||||||
/* Select Standby mode */
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_PDDS);
|
|
||||||
|
|
||||||
/* Set SLEEPDEEP bit of Cortex System Control Register */
|
|
||||||
SET_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk);
|
|
||||||
|
|
||||||
/* This option is used to ensure that store operations are completed */
|
|
||||||
#if defined ( __CC_ARM)
|
|
||||||
__force_stores();
|
|
||||||
#endif
|
|
||||||
/* Request Wait For Interrupt */
|
|
||||||
__WFI();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Indicates Sleep-On-Exit when returning from Handler mode to Thread mode.
|
|
||||||
* @note Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor
|
|
||||||
* re-enters SLEEP mode when an interruption handling is over.
|
|
||||||
* Setting this bit is useful when the processor is expected to run only on
|
|
||||||
* interruptions handling.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_EnableSleepOnExit(void)
|
|
||||||
{
|
|
||||||
/* Set SLEEPONEXIT bit of Cortex System Control Register */
|
|
||||||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode.
|
|
||||||
* @note Clears SLEEPONEXIT bit of SCR register. When this bit is set, the processor
|
|
||||||
* re-enters SLEEP mode when an interruption handling is over.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_DisableSleepOnExit(void)
|
|
||||||
{
|
|
||||||
/* Clear SLEEPONEXIT bit of Cortex System Control Register */
|
|
||||||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables CORTEX M0+ SEVONPEND bit.
|
|
||||||
* @note Sets SEVONPEND bit of SCR register. When this bit is set, this causes
|
|
||||||
* WFE to wake up when an interrupt moves from inactive to pended.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_EnableSEVOnPend(void)
|
|
||||||
{
|
|
||||||
/* Set SEVONPEND bit of Cortex System Control Register */
|
|
||||||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables CORTEX M0+ SEVONPEND bit.
|
|
||||||
* @note Clears SEVONPEND bit of SCR register. When this bit is set, this causes
|
|
||||||
* WFE to wake up when an interrupt moves from inactive to pended.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_DisableSEVOnPend(void)
|
|
||||||
{
|
|
||||||
/* Clear SEVONPEND bit of Cortex System Control Register */
|
|
||||||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(PWR_PVD_SUPPORT)
|
|
||||||
/**
|
|
||||||
* @brief This function handles the PWR PVD interrupt request.
|
|
||||||
* @note This API should be called under the PVD_IRQHandler().
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWR_PVD_IRQHandler(void)
|
|
||||||
{
|
|
||||||
/* Check PWR exti flag */
|
|
||||||
if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET)
|
|
||||||
{
|
|
||||||
/* PWR PVD interrupt user callback */
|
|
||||||
HAL_PWR_PVDCallback();
|
|
||||||
|
|
||||||
/* Clear PWR Exti pending bit */
|
|
||||||
__HAL_PWR_PVD_EXTI_CLEAR_FLAG();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PWR PVD interrupt callback
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
__weak void HAL_PWR_PVDCallback(void)
|
|
||||||
{
|
|
||||||
/* NOTE : This function Should not be modified, when the callback is needed,
|
|
||||||
the HAL_PWR_PVDCallback could be implemented in the user file
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
#endif /* PWR_PVD_SUPPORT */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
@ -1,184 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_pwr_ex.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Extended PWR HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of the Power Controller (PWR) peripheral:
|
|
||||||
* + Extended Initialization and de-initialization functions
|
|
||||||
* + Extended Peripheral Control functions
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
#ifdef HAL_PWR_MODULE_ENABLED
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWREx
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWREx_Private
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup PWR_Extended_TimeOut_Value PWREx Flag Setting Time Out Value
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define PWR_FLAG_SETTING_DELAY_US 50U
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @addtogroup PWREx_Exported_Functions
|
|
||||||
* @brief Low Power modes configuration functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
##### Peripheral extended features functions #####
|
|
||||||
===============================================================================
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return Voltage Scaling Range.
|
|
||||||
* @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3)
|
|
||||||
*/
|
|
||||||
uint32_t HAL_PWREx_GetVoltageRange(void)
|
|
||||||
{
|
|
||||||
return (PWR->CR & PWR_CR_VOS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables the Fast WakeUp from Ultra Low Power mode.
|
|
||||||
* @note This bit works in conjunction with ULP bit.
|
|
||||||
* Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when
|
|
||||||
* exiting from low power mode.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWREx_EnableFastWakeUp(void)
|
|
||||||
{
|
|
||||||
/* Enable the fast wake up */
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_FWU);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables the Fast WakeUp from Ultra Low Power mode.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWREx_DisableFastWakeUp(void)
|
|
||||||
{
|
|
||||||
/* Disable the fast wake up */
|
|
||||||
CLEAR_BIT(PWR->CR, PWR_CR_FWU);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables the Ultra Low Power mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWREx_EnableUltraLowPower(void)
|
|
||||||
{
|
|
||||||
/* Enable the Ultra Low Power mode */
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_ULP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables the Ultra Low Power mode
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWREx_DisableUltraLowPower(void)
|
|
||||||
{
|
|
||||||
/* Disable the Ultra Low Power mode */
|
|
||||||
CLEAR_BIT(PWR->CR, PWR_CR_ULP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the Low Power Run mode.
|
|
||||||
* @note Low power run mode can only be entered when VCORE is in range 2.
|
|
||||||
* In addition, the dynamic voltage scaling must not be used when Low
|
|
||||||
* power run mode is selected. Only Stop and Sleep modes with regulator
|
|
||||||
* configured in Low power mode is allowed when Low power run mode is
|
|
||||||
* selected.
|
|
||||||
* @note The frequency of the system clock must be decreased to not exceed the
|
|
||||||
* frequency of RCC_MSIRANGE_1.
|
|
||||||
* @note In Low power run mode, all I/O pins keep the same state as in Run mode.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_PWREx_EnableLowPowerRunMode(void)
|
|
||||||
{
|
|
||||||
/* Enters the Low Power Run mode */
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_LPSDSR);
|
|
||||||
SET_BIT(PWR->CR, PWR_CR_LPRUN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the Low Power Run mode.
|
|
||||||
* @note Before HAL_PWREx_DisableLowPowerRunMode() completion, the function checks that
|
|
||||||
* REGLPF has been properly reset (otherwise, HAL_PWREx_DisableLowPowerRunMode
|
|
||||||
* returns HAL_TIMEOUT status). The system clock frequency can then be
|
|
||||||
* increased above 2 MHz.
|
|
||||||
* @retval HAL_StatusTypeDef
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void)
|
|
||||||
{
|
|
||||||
uint32_t wait_loop_index = 0U;
|
|
||||||
|
|
||||||
/* Exit the Low Power Run mode */
|
|
||||||
CLEAR_BIT(PWR->CR, PWR_CR_LPRUN);
|
|
||||||
CLEAR_BIT(PWR->CR, PWR_CR_LPSDSR);
|
|
||||||
|
|
||||||
/* Wait until REGLPF is reset */
|
|
||||||
wait_loop_index = (PWR_FLAG_SETTING_DELAY_US * (SystemCoreClock / 1000000U));
|
|
||||||
|
|
||||||
while ((wait_loop_index != 0U) && (HAL_IS_BIT_SET(PWR->CSR, PWR_CSR_REGLPF)))
|
|
||||||
{
|
|
||||||
wait_loop_index--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HAL_IS_BIT_SET(PWR->CSR, PWR_CSR_REGLPF))
|
|
||||||
{
|
|
||||||
return HAL_TIMEOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,427 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32l0xx_hal_tim_ex.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief TIM HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of the Timer Extended peripheral:
|
|
||||||
* + Time Master and Slave synchronization configuration
|
|
||||||
* + Timer remapping capabilities configuration
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### TIMER Extended features #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
The Timer Extended features include:
|
|
||||||
(#) Synchronization circuit to control the timer with external signals and to
|
|
||||||
interconnect several timers together.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
|
||||||
* All rights reserved.</center></h2>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32l0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32L0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup TIMEx TIMEx
|
|
||||||
* @brief TIM Extended HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_TIM_MODULE_ENABLED
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @defgroup TIMEx_Exported_Functions TIM Extended Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/** @defgroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
|
|
||||||
* @brief Peripheral Control functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### Peripheral Control functions #####
|
|
||||||
==============================================================================
|
|
||||||
[..]
|
|
||||||
This section provides functions allowing to:
|
|
||||||
(+) Configure Master synchronization.
|
|
||||||
(+) Configure timer remapping capabilities.
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configures the TIM in master mode.
|
|
||||||
* @param htim TIM handle.
|
|
||||||
* @param sMasterConfig pointer to a TIM_MasterConfigTypeDef structure that
|
|
||||||
* contains the selected trigger output (TRGO) and the Master/Slave
|
|
||||||
* mode.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
|
|
||||||
TIM_MasterConfigTypeDef *sMasterConfig)
|
|
||||||
{
|
|
||||||
uint32_t tmpcr2;
|
|
||||||
uint32_t tmpsmcr;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_TIM_MASTER_INSTANCE(htim->Instance));
|
|
||||||
assert_param(IS_TIM_TRGO_SOURCE(sMasterConfig->MasterOutputTrigger));
|
|
||||||
assert_param(IS_TIM_MSM_STATE(sMasterConfig->MasterSlaveMode));
|
|
||||||
|
|
||||||
/* Check input state */
|
|
||||||
__HAL_LOCK(htim);
|
|
||||||
|
|
||||||
/* Change the handler state */
|
|
||||||
htim->State = HAL_TIM_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Get the TIMx CR2 register value */
|
|
||||||
tmpcr2 = htim->Instance->CR2;
|
|
||||||
|
|
||||||
/* Get the TIMx SMCR register value */
|
|
||||||
tmpsmcr = htim->Instance->SMCR;
|
|
||||||
|
|
||||||
/* Reset the MMS Bits */
|
|
||||||
tmpcr2 &= ~TIM_CR2_MMS;
|
|
||||||
/* Select the TRGO source */
|
|
||||||
tmpcr2 |= sMasterConfig->MasterOutputTrigger;
|
|
||||||
|
|
||||||
/* Update TIMx CR2 */
|
|
||||||
htim->Instance->CR2 = tmpcr2;
|
|
||||||
|
|
||||||
if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
|
|
||||||
{
|
|
||||||
/* Reset the MSM Bit */
|
|
||||||
tmpsmcr &= ~TIM_SMCR_MSM;
|
|
||||||
/* Set master mode */
|
|
||||||
tmpsmcr |= sMasterConfig->MasterSlaveMode;
|
|
||||||
|
|
||||||
/* Update TIMx SMCR */
|
|
||||||
htim->Instance->SMCR = tmpsmcr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Change the htim state */
|
|
||||||
htim->State = HAL_TIM_STATE_READY;
|
|
||||||
|
|
||||||
__HAL_UNLOCK(htim);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configures the TIMx Remapping input capabilities.
|
|
||||||
@if STM32L073xx
|
|
||||||
* @note It is not possible to connect TIM2 and TIM21 on PB5(AF4) at the same time.
|
|
||||||
* When selecting TIM3_TI2_GPIOB5_AF4, Channel2 of TIM3 will be
|
|
||||||
* connected to PB5(AF4) and Channel2 of TIM21 will be connected to
|
|
||||||
* some other GPIOs. (refer to alternate functions for more details)
|
|
||||||
* When selecting TIM3_TI2_GPIO_DEF, Channel2 of Timer 3 will be
|
|
||||||
* connected an GPIO (other than PB5(AF4)) and Channel2 of TIM21
|
|
||||||
* will be connected to PB5(AF4).
|
|
||||||
* @note When TIM2 ETR is fed with HSI48, this ETR must be prescaled internally
|
|
||||||
* to the TIMER2 because the maximum system frequency is 32 MHz
|
|
||||||
@endif
|
|
||||||
* @param htim TIM handle.
|
|
||||||
* @param Remap specifies the TIM remapping source.
|
|
||||||
@if STM32L073xx
|
|
||||||
* For TIM2, the parameter is a combination of 2 fields (field1 | field2):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM2_ETR_GPIO: TIM2 ETR connected to GPIO (default):
|
|
||||||
* PA0(AF5) or PA5(AF2) or PA15(AF2) or PE9(AF2)
|
|
||||||
* @arg TIM2_ETR_HSI48: TIM2 ETR connected to HSI48
|
|
||||||
* @arg TIM2_ETR_HSI16: TIM2 ETR connected to HSI16
|
|
||||||
* @arg TIM2_ETR_LSE: TIM2 ETR connected to LSE
|
|
||||||
* @arg TIM2_ETR_COMP2_OUT: TIM2 ETR connected to COMP2 output
|
|
||||||
* @arg TIM2_ETR_COMP1_OUT: TIM2 ETR connected to COMP1 output
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM2_TI4_GPIO : TIM2 TI4 connected to GPIO1(default):
|
|
||||||
* PA3(AF2) or PB11(AF2) or PE12(AF0)
|
|
||||||
* @arg TIM2_TI4_COMP1: TIM2 TI4 connected to COMP1
|
|
||||||
* @arg TIM2_TI4_COMP2: TIM2 TI4 connected to COMP2
|
|
||||||
@endif
|
|
||||||
@if STM32L031xx
|
|
||||||
* For TIM2, the parameter is a combination of 2 fields (field1 | field2):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM2_ETR_GPIO: TIM2 ETR connected to GPIO (default):
|
|
||||||
* PA0(AF5) or PA5(AF2) or PA15(AF2)
|
|
||||||
* @arg TIM2_ETR_HSI16: TIM2 ETR connected to HS16 (HSIOUT)
|
|
||||||
* @arg TIM2_ETR_LSE: TIM2 ETR connected to LSE
|
|
||||||
* @arg TIM2_ETR_COMP2_OUT: TIM2 ETR connected to COMP2 output
|
|
||||||
* @arg TIM2_ETR_COMP1_OUT: TIM2 ETR connected to COMP1 output
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM2_TI4_GPIO : TIM2 TI4 connected to GPIO (default):
|
|
||||||
* PA3(AF2) or PB11(AF2) or PB1(AF5)
|
|
||||||
* @arg TIM2_TI4_COMP1_OUT: TIM2 TI4 connected to COMP1 output
|
|
||||||
* @arg TIM2_TI4_COMP2_OUT: TIM2 TI4 connected to COMP2 output
|
|
||||||
@endif
|
|
||||||
@if STM32L011xx
|
|
||||||
* For TIM2, the parameter is a combination of 2 fields (field1 | field2):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM2_ETR_GPIO: TIM2 ETR connected to GPIO (default):
|
|
||||||
* PA0(AF5) or PA5(AF2) or PA15(AF2)
|
|
||||||
* @arg TIM2_ETR_HSI16: TIM2 ETR connected to HS16 (HSIOUT)
|
|
||||||
* @arg TIM2_ETR_LSE: TIM2 ETR connected to LSE
|
|
||||||
* @arg TIM2_ETR_COMP2_OUT: TIM2 ETR connected to COMP2 output
|
|
||||||
* @arg TIM2_ETR_COMP1_OUT: TIM2 ETR connected to COMP1 output
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM2_TI4_GPIO : TIM2 TI4 connected to GPIO (default):
|
|
||||||
* PA3(AF2) or PB11(AF2) or PB1(AF5)
|
|
||||||
* @arg TIM2_TI4_COMP1_OUT: TIM2 TI4 connected to COMP1 output
|
|
||||||
* @arg TIM2_TI4_COMP2_OUT: TIM2 TI4 connected to COMP2 output
|
|
||||||
@endif
|
|
||||||
@if STM32L051xx
|
|
||||||
* For TIM2, the parameter is a combination of 2 fields (field1 | field2):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM2_ETR_GPIO: TIM2 ETR connected to GPIO (default):
|
|
||||||
* PA0(AF5) or PA5(AF2) or PA15(AF2) or PE9(AF2)
|
|
||||||
* @arg TIM2_ETR_HSI48: TIM2 ETR connected to HSI48
|
|
||||||
* @arg TIM2_ETR_LSE: TIM2 ETR connected to LSE
|
|
||||||
* @arg TIM2_ETR_COMP2_OUT: TIM2 ETR connected to COMP2 output
|
|
||||||
* @arg TIM2_ETR_COMP1_OUT: TIM2 ETR connected to COMP1 output
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM2_TI4_GPIO: TIM2 TI4 connected to GPIO1(default):
|
|
||||||
* PA3(AF2) or PB11(AF2) or PE12(AF0)
|
|
||||||
* @arg TIM2_TI4_COMP1: TIM2 TI4 connected to COMP1
|
|
||||||
* @arg TIM2_TI4_COMP2: TIM2 TI4 connected to COMP2
|
|
||||||
* @arg TIM2_TI4_GPIO2: TIM2 TI4 connected to GPIO2 :
|
|
||||||
* PA3(AF2) or PB11(AF2) or PE12(AF0)
|
|
||||||
@endif
|
|
||||||
@if STM32L073xx
|
|
||||||
*
|
|
||||||
* For TIM3, the parameter is a combination of 4 fields (field1 | field2 | field3 | field4):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM3_ETR_GPIO: TIM3 ETR connected to GPIO (default):
|
|
||||||
* PE2(AF2) or PD2(AF2) or PE2(AF2)
|
|
||||||
* @arg TIM3_ETR_HSI: TIM3 ETR connected to HSI
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM3_TI1_USB_SOF: TIM3 TI1 connected to USB_SOF (default)
|
|
||||||
* @arg TIM3_TI1_GPIO: TIM3 TI1 connected to GPIO :
|
|
||||||
* PE3(AF2) or PA6(AF2) or PC6(AF2) or PB4(AF2)
|
|
||||||
*
|
|
||||||
* field3 can have the following values:
|
|
||||||
* @arg TIM3_TI2_GPIOB5_AF4:TIM3 TI3 connected to P5(AF4)
|
|
||||||
* (refer to note)
|
|
||||||
* @arg TIM3_TI2_GPIO_DEF: TIM3 TI3 connected to GPIO (default):
|
|
||||||
* PA7(AF2) or PB5(AF4) or PC7(AF2) or PE7(AF2)
|
|
||||||
*
|
|
||||||
* field4 can have the following values:
|
|
||||||
* @arg TIM3_TI4_GPIO_DEF: TIM3 TI4 connected to GPIO:
|
|
||||||
* PB1(AF2) or PE6(AF2)
|
|
||||||
* @arg TIM3_TI4_GPIOC9_AF2:TIM3 TI4 connected to PC9(AF)2
|
|
||||||
@endif
|
|
||||||
@if STM32L073xx
|
|
||||||
* For TIM21, the parameter is a combination of 3 fields (field1 | field2 | field3):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM21_ETR_GPIO: TIM21 ETR connected to GPIO(default) :
|
|
||||||
* PC9(AF0) or PA1(AF5)
|
|
||||||
* @arg TIM21_ETR_COMP2_OUT:TIM21 ETR connected to COMP2 output
|
|
||||||
* @arg TIM21_ETR_COMP1_OUT:TIM21 ETR connected to COMP1 output
|
|
||||||
* @arg TIM21_ETR_LSE: TIM21 ETR connected to LSE
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM21_TI1_MCO: TIM21 TI1 connected to MCO
|
|
||||||
* @arg TIM21_TI1_RTC_WKUT_IT: TIM21 TI1 connected to RTC WAKEUP interrupt
|
|
||||||
* @arg TIM21_TI1_HSE_RTC: TIM21 TI1 connected to HSE_RTC
|
|
||||||
* @arg TIM21_TI1_MSI: TIM21 TI1 connected to MSI clock
|
|
||||||
* @arg TIM21_TI1_LSE: TIM21 TI1 connected to LSE
|
|
||||||
* @arg TIM21_TI1_LSI: TIM21 TI1 connected to LSI
|
|
||||||
* @arg TIM21_TI1_COMP1_OUT:TIM21 TI1 connected to COMP1_OUT
|
|
||||||
* @arg TIM21_TI1_GPIO: TIM21 TI1 connected to GPIO(default):
|
|
||||||
* PA2(AF0) or PB13(AF6) or PE5(AF0) or PD0(AF0)
|
|
||||||
*
|
|
||||||
* field3 can have the following values:
|
|
||||||
* @arg TIM21_TI2_GPIO: TIM21 TI2 connected to GPIO(default):
|
|
||||||
* PA3(AF0) or PB14(AF6) or PE6(AF0) or PD7(AF1)
|
|
||||||
* @arg TIM21_TI2_COMP2_OUT:TIM21 TI2 connected to COMP2 output
|
|
||||||
@endif
|
|
||||||
@if STM32L031xx
|
|
||||||
* For TIM21, the parameter is a combination of 3 fields (field1 | field2 | field3):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM21_ETR_GPIO: TIM21 ETR connected to GPIO(default) :
|
|
||||||
* PA1(AF5)
|
|
||||||
* @arg TIM21_ETR_COMP2_OUT:TIM21 ETR connected to COMP2 output
|
|
||||||
* @arg TIM21_ETR_COMP1_OUT:TIM21 ETR connected to COMP1 output
|
|
||||||
* @arg TIM21_ETR_LSE: TIM21 ETR connected to LSE
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM21_TI1_MCO: TIM21 TI1 connected to MCO
|
|
||||||
* @arg TIM21_TI1_RTC_WKUT_IT: TIM21 TI1 connected to RTC WAKEUP interrupt
|
|
||||||
* @arg TIM21_TI1_HSE_RTC: TIM21 TI1 connected to HSE_RTC
|
|
||||||
* @arg TIM21_TI1_MSI: TIM21 TI1 connected to MSI clock
|
|
||||||
* @arg TIM21_TI1_LSE: TIM21 TI1 connected to LSE
|
|
||||||
* @arg TIM21_TI1_LSI: TIM21 TI1 connected to LSI
|
|
||||||
* @arg TIM21_TI1_COMP1_OUT:TIM21 TI1 connected to COMP1_OUT
|
|
||||||
*
|
|
||||||
* field3 can have the following values:
|
|
||||||
* @arg TIM21_TI2_GPIO: TIM21 TI2 connected to GPIO(default):
|
|
||||||
* PA3(AF0) or PB14(AF6)
|
|
||||||
* @arg TIM21_TI2_COMP2_OUT:TIM21 TI2 connected to COMP2 output
|
|
||||||
@endif
|
|
||||||
@if STM32L011xx
|
|
||||||
* For TIM21, the parameter is a combination of 3 fields (field1 | field2 | field3):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM21_ETR_GPIO: TIM21 ETR connected to GPIO(default) :
|
|
||||||
* PA1(AF5)
|
|
||||||
* @arg TIM21_ETR_COMP2_OUT:TIM21 ETR connected to COMP2 output
|
|
||||||
* @arg TIM21_ETR_COMP1_OUT:TIM21 ETR connected to COMP1 output
|
|
||||||
* @arg TIM21_ETR_LSE: TIM21 ETR connected to LSE
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM21_TI1_MCO: TIM21 TI1 connected to MCO
|
|
||||||
* @arg TIM21_TI1_RTC_WKUT_IT: TIM21 TI1 connected to RTC WAKEUP interrupt
|
|
||||||
* @arg TIM21_TI1_HSE_RTC: TIM21 TI1 connected to HSE_RTC
|
|
||||||
* @arg TIM21_TI1_MSI: TIM21 TI1 connected to MSI clock
|
|
||||||
* @arg TIM21_TI1_LSE: TIM21 TI1 connected to LSE
|
|
||||||
* @arg TIM21_TI1_LSI: TIM21 TI1 connected to LSI
|
|
||||||
* @arg TIM21_TI1_COMP1_OUT:TIM21 TI1 connected to COMP1_OUT
|
|
||||||
*
|
|
||||||
* field3 can have the following values:
|
|
||||||
* @arg TIM21_TI2_GPIO: TIM21 TI2 connected to GPIO(default):
|
|
||||||
* PA3(AF0) or PB14(AF6)
|
|
||||||
* @arg TIM21_TI2_COMP2_OUT:TIM21 TI2 connected to COMP2 output
|
|
||||||
@endif
|
|
||||||
@if STM32L051xx
|
|
||||||
* For TIM21, the parameter is a combination of 3 fields (field1 | field2 | field3):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM21_ETR_GPIO: TIM21 ETR connected to GPIO(default) :
|
|
||||||
* PC9(AF0) or PA1(AF5)
|
|
||||||
* @arg TIM21_ETR_COMP2_OUT:TIM21 ETR connected to COMP2 output
|
|
||||||
* @arg TIM21_ETR_COMP1_OUT:TIM21 ETR connected to COMP1 output
|
|
||||||
* @arg TIM21_ETR_LSE: TIM21 ETR connected to LSE
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM21_TI1_MCO: TIM21 TI1 connected to MCO
|
|
||||||
* @arg TIM21_TI1_RTC_WKUT_IT: TIM21 TI1 connected to RTC WAKEUP interrupt
|
|
||||||
* @arg TIM21_TI1_HSE_RTC: TIM21 TI1 connected to HSE_RTC
|
|
||||||
* @arg TIM21_TI1_MSI: TIM21 TI1 connected to MSI clock
|
|
||||||
* @arg TIM21_TI1_LSE: TIM21 TI1 connected to LSE
|
|
||||||
* @arg TIM21_TI1_LSI: TIM21 TI1 connected to LSI
|
|
||||||
* @arg TIM21_TI1_COMP1_OUT:TIM21 TI1 connected to COMP1_OUT
|
|
||||||
* @arg TIM21_TI1_GPIO: TIM21 TI1 connected to GPIO(default):
|
|
||||||
* PA2(AF0) or PB13(AF6) or PE5(AF0) or PD0(AF0)
|
|
||||||
*
|
|
||||||
* field3 can have the following values:
|
|
||||||
* @arg TIM21_TI2_GPIO: TIM21 TI2 connected to GPIO(default):
|
|
||||||
* PA3(AF0) or PB14(AF6) or PE6(AF0) or PD7(AF1)
|
|
||||||
* @arg TIM21_TI2_COMP2_OUT:TIM21 TI2 connected to COMP2 output
|
|
||||||
@endif
|
|
||||||
@if STM32L073xx
|
|
||||||
*
|
|
||||||
* For TIM22, the parameter can have the following values:
|
|
||||||
* @arg TIM22_ETR_LSE: TIM22 ETR connected to LSE
|
|
||||||
* @arg TIM22_ETR_COMP2_OUT:TIM22 ETR connected to COMP2 output
|
|
||||||
* @arg TIM22_ETR_COMP1_OUT:TIM22 ETR connected to COMP1 output
|
|
||||||
* @arg TIM22_ETR_GPIO: TIM22 ETR connected to GPIO(default):
|
|
||||||
* PC8(AF0) or PA4(AF5)
|
|
||||||
* @arg TIM22_TI1_GPIO: TIM22 TI1 connected to GPIO(default):
|
|
||||||
* PC6(AF0) or PA6(AF5) or PB4(AF4) or PE0(AF3)
|
|
||||||
* @arg TIM22_TI1_COMP2_OUT:TIM22 TI1 connected to COMP2 output
|
|
||||||
* @arg TIM22_TI1_COMP1_OUT:TIM22 TI1 connected to COMP1 output
|
|
||||||
@endif
|
|
||||||
@if STM32L031xx
|
|
||||||
*
|
|
||||||
* For TIM22, the parameter is a combination of 2 fields (field1 | field2):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM22_ETR_LSE: TIM22 ETR connected to LSE
|
|
||||||
* @arg TIM22_ETR_COMP2_OUT:TIM22 ETR connected to COMP2 output
|
|
||||||
* @arg TIM22_ETR_COMP1_OUT:TIM22 ETR connected to COMP1 output
|
|
||||||
* @arg TIM22_ETR_GPIO: TIM22 ETR connected to GPIO(default):
|
|
||||||
* PA4(AF5)
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM22_TI1_GPIO: TIM22 TI1 connected to GPIO(default):
|
|
||||||
* PC0(AF6) or PA5(AF6) or PB4(AF4)
|
|
||||||
* @arg TIM22_TI1_COMP2_OUT:TIM22 TI1 connected to COMP2 output
|
|
||||||
* @arg TIM22_TI1_COMP1_OUT:TIM22 TI1 connected to COMP1 output
|
|
||||||
*
|
|
||||||
@endif
|
|
||||||
@if STM32L051xx
|
|
||||||
*
|
|
||||||
* For TIM22, the parameter is a combination of 2 fields (field1 | field2):
|
|
||||||
*
|
|
||||||
* field1 can have the following values:
|
|
||||||
* @arg TIM22_ETR_LSE: TIM22 ETR connected to LSE
|
|
||||||
* @arg TIM22_ETR_COMP2_OUT:TIM22 ETR connected to COMP2 output
|
|
||||||
* @arg TIM22_ETR_COMP1_OUT:TIM22 ETR connected to COMP1 output
|
|
||||||
* @arg TIM22_ETR_GPIO: TIM22 ETR connected to GPIO(default):
|
|
||||||
* PC8(AF0) or PA4(AF5)
|
|
||||||
*
|
|
||||||
* field2 can have the following values:
|
|
||||||
* @arg TIM22_TI1_GPIO: TIM22 TI1 connected to GPIO(default):
|
|
||||||
* PC6(AF0) or PA6(AF5) or PB4(AF4) or PE0(AF3)
|
|
||||||
* @arg TIM22_TI1_COMP2_OUT:TIM22 TI1 connected to COMP2 output
|
|
||||||
* @arg TIM22_TI1_COMP1_OUT:TIM22 TI1 connected to COMP1 output
|
|
||||||
@endif
|
|
||||||
*
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap)
|
|
||||||
{
|
|
||||||
__HAL_LOCK(htim);
|
|
||||||
|
|
||||||
/* Check parameters */
|
|
||||||
assert_param(IS_TIM_REMAP(htim->Instance, Remap));
|
|
||||||
|
|
||||||
/* Set the Timer remapping configuration */
|
|
||||||
WRITE_REG(htim->Instance->OR, Remap);
|
|
||||||
|
|
||||||
__HAL_UNLOCK(htim);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* HAL_TIM_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
85
fw/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c
Normal file
85
fw/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32l0xx_ll_pwr.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief PWR LL module driver.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© Copyright(c) 2016 STMicroelectronics.
|
||||||
|
* All rights reserved.</center></h2>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
#if defined(USE_FULL_LL_DRIVER)
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32l0xx_ll_pwr.h"
|
||||||
|
#include "stm32l0xx_ll_bus.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32L0xx_LL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(PWR)
|
||||||
|
|
||||||
|
/** @defgroup PWR_LL PWR
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup PWR_LL_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup PWR_LL_EF_Init
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief De-initialize the PWR registers to their default reset values.
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: PWR registers are de-initialized
|
||||||
|
* - ERROR: not applicable
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_PWR_DeInit(void)
|
||||||
|
{
|
||||||
|
/* Force reset of PWR clock */
|
||||||
|
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_PWR);
|
||||||
|
|
||||||
|
/* Release reset of PWR clock */
|
||||||
|
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_PWR);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif /* defined(PWR) */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* USE_FULL_LL_DRIVER */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -12,7 +12,7 @@ ProjectManager.NoMain=false
|
|||||||
PA0-CK_IN.Mode=Asynchronous
|
PA0-CK_IN.Mode=Asynchronous
|
||||||
RCC.LPUARTFreq_Value=2097000
|
RCC.LPUARTFreq_Value=2097000
|
||||||
RCC.PLLCLKFreq_Value=24000000
|
RCC.PLLCLKFreq_Value=24000000
|
||||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-LL-true,2-MX_DMA_Init-DMA-false-LL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_I2C1_Init-I2C1-false-LL-true,5-MX_LPUART1_UART_Init-LPUART1-false-LL-true
|
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-LL-true,2-MX_DMA_Init-DMA-false-LL-true,3-SystemClock_Config-RCC-false-LL-false,4-MX_I2C1_Init-I2C1-false-LL-true,5-MX_LPUART1_UART_Init-LPUART1-false-LL-true
|
||||||
Dma.LPUART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
Dma.LPUART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||||
RCC.RTCFreq_Value=37000
|
RCC.RTCFreq_Value=37000
|
||||||
LPUART1.WordLength=UART_WORDLENGTH_8B
|
LPUART1.WordLength=UART_WORDLENGTH_8B
|
||||||
|
Loading…
x
Reference in New Issue
Block a user