| @@ -0,0 +1,222 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx.h | |||
| * @author MCD Application Team | |||
| * @version V2.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief CMSIS STM32F4xx Device Peripheral Access Layer Header File. | |||
| * | |||
| * The file is the unique include file that the application programmer | |||
| * is using in the C source code, usually in main.c. This file contains: | |||
| * - Configuration section that allows to select: | |||
| * - The STM32F4xx device used in the target application | |||
| * - To use or not the peripheral's drivers in application code(i.e. | |||
| * code will be based on direct access to peripheral's registers | |||
| * rather than drivers API), this option is controlled by | |||
| * "#define USE_HAL_DRIVER" | |||
| * | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /** @addtogroup CMSIS | |||
| * @{ | |||
| */ | |||
| /** @addtogroup stm32f4xx | |||
| * @{ | |||
| */ | |||
| #ifndef __STM32F4xx_H | |||
| #define __STM32F4xx_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif /* __cplusplus */ | |||
| /** @addtogroup Library_configuration_section | |||
| * @{ | |||
| */ | |||
| /* Uncomment the line below according to the target STM32 device used in your | |||
| application | |||
| */ | |||
| #if !defined (STM32F405xx) && !defined (STM32F415xx) && !defined (STM32F407xx) && !defined (STM32F417xx) && \ | |||
| !defined (STM32F427xx) && !defined (STM32F437xx) && !defined (STM32F429xx) && !defined (STM32F439xx) && \ | |||
| !defined (STM32F401xC) && !defined (STM32F401xE) && !defined (STM32F411xE) | |||
| /* #define STM32F405xx */ /*!< STM32F405RG, STM32F405VG and STM32F405ZG Devices */ | |||
| /* #define STM32F415xx */ /*!< STM32F415RG, STM32F415VG and STM32F415ZG Devices */ | |||
| /* #define STM32F407xx */ /*!< STM32F407VG, STM32F407VE, STM32F407ZG, STM32F407ZE, STM32F407IG and STM32F407IE Devices */ | |||
| /* #define STM32F417xx */ /*!< STM32F417VG, STM32F417VE, STM32F417ZG, STM32F417ZE, STM32F417IG and STM32F417IE Devices */ | |||
| /* #define STM32F427xx */ /*!< STM32F427VG, STM32F427VI, STM32F427ZG, STM32F427ZI, STM32F427IG and STM32F427II Devices */ | |||
| /* #define STM32F437xx */ /*!< STM32F437VG, STM32F437VI, STM32F437ZG, STM32F437ZI, STM32F437IG and STM32F437II Devices */ | |||
| /* #define STM32F429xx */ /*!< STM32F429VG, STM32F429VI, STM32F429ZG, STM32F429ZI, STM32F429BG, STM32F429BI, STM32F429NG, | |||
| STM32F439NI, STM32F429IG and STM32F429II Devices */ | |||
| /* #define STM32F439xx */ /*!< STM32F439VG, STM32F439VI, STM32F439ZG, STM32F439ZI, STM32F439BG, STM32F439BI, STM32F439NG, | |||
| STM32F439NI, STM32F439IG and STM32F439II Devices */ | |||
| /* #define STM32F401xC */ /*!< STM32F401CB, STM32F401CC, STM32F401RB, STM32F401RC, STM32F401VB and STM32F401VC Devices */ | |||
| /* #define STM32F401xE */ /*!< STM32F401CD, STM32F401RD, STM32F401VD, STM32F401CE, STM32F401RE and STM32F401VE Devices */ | |||
| /* #define STM32F411xE */ /*!< STM32F411CD, STM32F411RD, STM32F411VD, STM32F411CE, STM32F411RE and STM32F411VE Devices */ | |||
| #endif | |||
| /* Tip: To avoid modifying this file each time you need to switch between these | |||
| devices, you can define the device in your toolchain compiler preprocessor. | |||
| */ | |||
| #if !defined (USE_HAL_DRIVER) | |||
| /** | |||
| * @brief Comment the line below if you will not use the peripherals drivers. | |||
| In this case, these drivers will not be included and the application code will | |||
| be based on direct access to peripherals registers | |||
| */ | |||
| /*#define USE_HAL_DRIVER */ | |||
| #endif /* USE_HAL_DRIVER */ | |||
| /** | |||
| * @brief CMSIS Device version number V2.1.0 | |||
| */ | |||
| #define __STM32F4xx_CMSIS_DEVICE_VERSION_MAIN (0x02) /*!< [31:24] main version */ | |||
| #define __STM32F4xx_CMSIS_DEVICE_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */ | |||
| #define __STM32F4xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ | |||
| #define __STM32F4xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */ | |||
| #define __STM32F4xx_CMSIS_DEVICE_VERSION ((__STM32F4xx_CMSIS_DEVICE_VERSION_MAIN << 24)\ | |||
| |(__STM32F4xx_CMSIS_DEVICE_VERSION_SUB1 << 16)\ | |||
| |(__STM32F4xx_CMSIS_DEVICE_VERSION_SUB2 << 8 )\ | |||
| |(__STM32F4xx_CMSIS_DEVICE_VERSION)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @addtogroup Device_Included | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F405xx) | |||
| #include "stm32f405xx.h" | |||
| #elif defined(STM32F415xx) | |||
| #include "stm32f415xx.h" | |||
| #elif defined(STM32F407xx) | |||
| #include "stm32f407xx.h" | |||
| #elif defined(STM32F417xx) | |||
| #include "stm32f417xx.h" | |||
| #elif defined(STM32F427xx) | |||
| #include "stm32f427xx.h" | |||
| #elif defined(STM32F437xx) | |||
| #include "stm32f437xx.h" | |||
| #elif defined(STM32F429xx) | |||
| #include "stm32f429xx.h" | |||
| #elif defined(STM32F439xx) | |||
| #include "stm32f439xx.h" | |||
| #elif defined(STM32F401xC) | |||
| #include "stm32f401xc.h" | |||
| #elif defined(STM32F401xE) | |||
| #include "stm32f401xe.h" | |||
| #elif defined(STM32F411xE) | |||
| #include "stm32f411xe.h" | |||
| #else | |||
| #error "Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)" | |||
| #endif | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @addtogroup Exported_types | |||
| * @{ | |||
| */ | |||
| typedef enum | |||
| { | |||
| RESET = 0, | |||
| SET = !RESET | |||
| } FlagStatus, ITStatus; | |||
| typedef enum | |||
| { | |||
| DISABLE = 0, | |||
| ENABLE = !DISABLE | |||
| } FunctionalState; | |||
| #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) | |||
| typedef enum | |||
| { | |||
| ERROR = 0, | |||
| SUCCESS = !ERROR | |||
| } ErrorStatus; | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @addtogroup Exported_macro | |||
| * @{ | |||
| */ | |||
| #define SET_BIT(REG, BIT) ((REG) |= (BIT)) | |||
| #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) | |||
| #define READ_BIT(REG, BIT) ((REG) & (BIT)) | |||
| #define CLEAR_REG(REG) ((REG) = (0x0)) | |||
| #define WRITE_REG(REG, VAL) ((REG) = (VAL)) | |||
| #define READ_REG(REG) ((REG)) | |||
| #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) | |||
| #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) | |||
| /** | |||
| * @} | |||
| */ | |||
| #if defined (USE_HAL_DRIVER) | |||
| #include "stm32f4xx_hal.h" | |||
| #endif /* USE_HAL_DRIVER */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif /* __cplusplus */ | |||
| #endif /* __STM32F4xx_H */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,122 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file system_stm32f4xx.h | |||
| * @author MCD Application Team | |||
| * @version V2.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /** @addtogroup CMSIS | |||
| * @{ | |||
| */ | |||
| /** @addtogroup stm32f4xx_system | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Define to prevent recursive inclusion | |||
| */ | |||
| #ifndef __SYSTEM_STM32F4XX_H | |||
| #define __SYSTEM_STM32F4XX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /** @addtogroup STM32F4xx_System_Includes | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @addtogroup STM32F4xx_System_Exported_types | |||
| * @{ | |||
| */ | |||
| /* This variable is updated in three ways: | |||
| 1) by calling CMSIS function SystemCoreClockUpdate() | |||
| 2) by calling HAL API function HAL_RCC_GetSysClockFreq() | |||
| 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency | |||
| Note: If you use this function to configure the system clock; then there | |||
| is no need to call the 2 first functions listed above, since SystemCoreClock | |||
| variable is updated automatically. | |||
| */ | |||
| extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @addtogroup STM32F4xx_System_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @addtogroup STM32F4xx_System_Exported_Macros | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @addtogroup STM32F4xx_System_Exported_Functions | |||
| * @{ | |||
| */ | |||
| extern void SystemInit(void); | |||
| extern void SystemCoreClockUpdate(void); | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /*__SYSTEM_STM32F4XX_H */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,194 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief This file contains all the functions prototypes for the HAL | |||
| * module driver. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_H | |||
| #define __STM32F4xx_HAL_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_conf.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup HAL | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Freeze/Unfreeze Peripherals in Debug mode | |||
| */ | |||
| #define __HAL_FREEZE_TIM2_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM2_STOP)) | |||
| #define __HAL_FREEZE_TIM3_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM3_STOP)) | |||
| #define __HAL_FREEZE_TIM4_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM4_STOP)) | |||
| #define __HAL_FREEZE_TIM5_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM5_STOP)) | |||
| #define __HAL_FREEZE_TIM6_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM6_STOP)) | |||
| #define __HAL_FREEZE_TIM7_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM7_STOP)) | |||
| #define __HAL_FREEZE_TIM12_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM12_STOP)) | |||
| #define __HAL_FREEZE_TIM13_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM13_STOP)) | |||
| #define __HAL_FREEZE_TIM14_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM14_STOP)) | |||
| #define __HAL_FREEZE_RTC_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_RTC_STOP)) | |||
| #define __HAL_FREEZE_WWDG_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_WWDG_STOP)) | |||
| #define __HAL_FREEZE_IWDG_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_IWDG_STOP)) | |||
| #define __HAL_FREEZE_I2C1_TIMEOUT_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)) | |||
| #define __HAL_FREEZE_I2C2_TIMEOUT_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)) | |||
| #define __HAL_FREEZE_I2C3_TIMEOUT_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT)) | |||
| #define __HAL_FREEZE_CAN1_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_CAN1_STOP)) | |||
| #define __HAL_FREEZE_CAN2_DBGMCU() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_CAN2_STOP)) | |||
| #define __HAL_FREEZE_TIM1_DBGMCU() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM1_STOP)) | |||
| #define __HAL_FREEZE_TIM8_DBGMCU() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM8_STOP)) | |||
| #define __HAL_FREEZE_TIM9_DBGMCU() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM9_STOP)) | |||
| #define __HAL_FREEZE_TIM10_DBGMCU() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM10_STOP)) | |||
| #define __HAL_FREEZE_TIM11_DBGMCU() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM11_STOP)) | |||
| #define __HAL_UNFREEZE_TIM2_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM2_STOP)) | |||
| #define __HAL_UNFREEZE_TIM3_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM3_STOP)) | |||
| #define __HAL_UNFREEZE_TIM4_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM4_STOP)) | |||
| #define __HAL_UNFREEZE_TIM5_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM5_STOP)) | |||
| #define __HAL_UNFREEZE_TIM6_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM6_STOP)) | |||
| #define __HAL_UNFREEZE_TIM7_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM7_STOP)) | |||
| #define __HAL_UNFREEZE_TIM12_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM12_STOP)) | |||
| #define __HAL_UNFREEZE_TIM13_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM13_STOP)) | |||
| #define __HAL_UNFREEZE_TIM14_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM14_STOP)) | |||
| #define __HAL_UNFREEZE_RTC_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_RTC_STOP)) | |||
| #define __HAL_UNFREEZE_WWDG_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_WWDG_STOP)) | |||
| #define __HAL_UNFREEZE_IWDG_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_IWDG_STOP)) | |||
| #define __HAL_UNFREEZE_I2C1_TIMEOUT_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)) | |||
| #define __HAL_UNFREEZE_I2C2_TIMEOUT_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)) | |||
| #define __HAL_UNFREEZE_I2C3_TIMEOUT_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT)) | |||
| #define __HAL_UNFREEZE_CAN1_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_CAN1_STOP)) | |||
| #define __HAL_UNFREEZE_CAN2_DBGMCU() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_CAN2_STOP)) | |||
| #define __HAL_UNFREEZE_TIM1_DBGMCU() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM1_STOP)) | |||
| #define __HAL_UNFREEZE_TIM8_DBGMCU() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM8_STOP)) | |||
| #define __HAL_UNFREEZE_TIM9_DBGMCU() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM9_STOP)) | |||
| #define __HAL_UNFREEZE_TIM10_DBGMCU() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM10_STOP)) | |||
| #define __HAL_UNFREEZE_TIM11_DBGMCU() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM11_STOP)) | |||
| /** @brief Main Flash memory mapped at 0x00000000 | |||
| */ | |||
| #define __HAL_REMAPMEMORY_FLASH() (SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE)) | |||
| /** @brief System Flash memory mapped at 0x00000000 | |||
| */ | |||
| #define __HAL_REMAPMEMORY_SYSTEMFLASH() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ | |||
| SYSCFG->MEMRMP |= SYSCFG_MEMRMP_MEM_MODE_0;\ | |||
| }while(0); | |||
| /** @brief Embedded SRAM mapped at 0x00000000 | |||
| */ | |||
| #define __HAL_REMAPMEMORY_SRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ | |||
| SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_0 | SYSCFG_MEMRMP_MEM_MODE_1);\ | |||
| }while(0); | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) | |||
| /** @brief FSMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 | |||
| */ | |||
| #define __HAL_REMAPMEMORY_FSMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ | |||
| SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ | |||
| }while(0); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| /** @brief FMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 | |||
| */ | |||
| #define __HAL_REMAPMEMORY_FMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ | |||
| SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ | |||
| }while(0); | |||
| /** @brief FMC/SDRAM Bank 1 and 2 mapped at 0x00000000 | |||
| */ | |||
| #define __HAL_REMAPMEMORY_FMC_SDRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ | |||
| SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_2);\ | |||
| }while(0); | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* 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); | |||
| /* Peripheral Control functions ************************************************/ | |||
| void HAL_IncTick(void); | |||
| void HAL_Delay(__IO uint32_t Delay); | |||
| uint32_t HAL_GetTick(void); | |||
| void HAL_SuspendTick(void); | |||
| void HAL_ResumeTick(void); | |||
| uint32_t HAL_GetHalVersion(void); | |||
| uint32_t HAL_GetREVID(void); | |||
| uint32_t HAL_GetDEVID(void); | |||
| void HAL_EnableDBGSleepMode(void); | |||
| void HAL_DisableDBGSleepMode(void); | |||
| void HAL_EnableDBGStopMode(void); | |||
| void HAL_DisableDBGStopMode(void); | |||
| void HAL_EnableDBGStandbyMode(void); | |||
| void HAL_DisableDBGStandbyMode(void); | |||
| void HAL_EnableCompensationCell(void); | |||
| void HAL_DisableCompensationCell(void); | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| void HAL_EnableMemorySwappingBank(void); | |||
| void HAL_DisableMemorySwappingBank(void); | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,745 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_adc.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of ADC HAL extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_ADC_H | |||
| #define __STM32F4xx_ADC_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup ADC | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_ADC_STATE_RESET = 0x00, /*!< ADC not yet initialized or disabled */ | |||
| HAL_ADC_STATE_READY = 0x01, /*!< ADC peripheral ready for use */ | |||
| HAL_ADC_STATE_BUSY = 0x02, /*!< An internal process is ongoing */ | |||
| HAL_ADC_STATE_BUSY_REG = 0x12, /*!< Regular conversion is ongoing */ | |||
| HAL_ADC_STATE_BUSY_INJ = 0x22, /*!< Injected conversion is ongoing */ | |||
| HAL_ADC_STATE_BUSY_INJ_REG = 0x32, /*!< Injected and regular conversion are ongoing */ | |||
| HAL_ADC_STATE_TIMEOUT = 0x03, /*!< Timeout state */ | |||
| HAL_ADC_STATE_ERROR = 0x04, /*!< ADC state error */ | |||
| HAL_ADC_STATE_EOC = 0x05, /*!< Conversion is completed */ | |||
| HAL_ADC_STATE_EOC_REG = 0x15, /*!< Regular conversion is completed */ | |||
| HAL_ADC_STATE_EOC_INJ = 0x25, /*!< Injected conversion is completed */ | |||
| HAL_ADC_STATE_EOC_INJ_REG = 0x35, /*!< Injected and regular conversion are completed */ | |||
| HAL_ADC_STATE_AWD = 0x06 /*!< ADC state analog watchdog */ | |||
| }HAL_ADC_StateTypeDef; | |||
| /** | |||
| * @brief ADC Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t ClockPrescaler; /*!< Select the frequency of the clock to the ADC. The clock is common for | |||
| all the ADCs. | |||
| This parameter can be a value of @ref ADC_ClockPrescaler */ | |||
| uint32_t Resolution; /*!< Configures the ADC resolution dual mode. | |||
| This parameter can be a value of @ref ADC_Resolution */ | |||
| uint32_t DataAlign; /*!< Specifies whether the ADC data alignment is left or right. | |||
| This parameter can be a value of @ref ADC_data_align */ | |||
| uint32_t ScanConvMode; /*!< Specifies whether the conversion is performed in Scan (multi channels) or | |||
| Single (one channel) mode. | |||
| This parameter can be set to ENABLE or DISABLE */ | |||
| uint32_t EOCSelection; /*!< Specifies whether the EOC flag is set | |||
| at the end of single channel conversion or at the end of all conversions. | |||
| This parameter can be a value of @ref ADC_EOCSelection */ | |||
| uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in Continuous or Single mode. | |||
| This parameter can be set to ENABLE or DISABLE. */ | |||
| uint32_t DMAContinuousRequests; /*!< Specifies whether the DMA requests is performed in Continuous or in Single mode. | |||
| This parameter can be set to ENABLE or DISABLE. */ | |||
| uint32_t NbrOfConversion; /*!< Specifies the number of ADC conversions that will be done using the sequencer for | |||
| regular channel group. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 16. */ | |||
| uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversion is performed in Discontinuous or not | |||
| for regular channels. | |||
| This parameter can be set to ENABLE or DISABLE. */ | |||
| uint32_t NbrOfDiscConversion; /*!< Specifies the number of ADC discontinuous conversions that will be done | |||
| using the sequencer for regular channel group. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 8. */ | |||
| uint32_t ExternalTrigConvEdge; /*!< Select the external trigger edge and enable the trigger of a regular group. | |||
| This parameter can be a value of @ref ADC_External_trigger_edge_Regular */ | |||
| uint32_t ExternalTrigConv; /*!< Select the external event used to trigger the start of conversion of a regular group. | |||
| This parameter can be a value of @ref ADC_External_trigger_Source_Regular */ | |||
| }ADC_InitTypeDef; | |||
| /** | |||
| * @brief ADC handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| ADC_TypeDef *Instance; /*!< Register base address */ | |||
| ADC_InitTypeDef Init; /*!< ADC required parameters */ | |||
| __IO uint32_t NbrOfCurrentConversionRank; /*!< ADC number of current conversion rank */ | |||
| DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */ | |||
| HAL_LockTypeDef Lock; /*!< ADC locking object */ | |||
| __IO HAL_ADC_StateTypeDef State; /*!< ADC communication state */ | |||
| __IO uint32_t ErrorCode; /*!< ADC Error code */ | |||
| }ADC_HandleTypeDef; | |||
| /** | |||
| * @brief ADC Configuration regular Channel structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Channel; /*!< The ADC channel to configure. | |||
| This parameter can be a value of @ref ADC_channels */ | |||
| uint32_t Rank; /*!< The rank in the regular group sequencer. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 16 */ | |||
| uint32_t SamplingTime; /*!< The sample time value to be set for the selected channel. | |||
| This parameter can be a value of @ref ADC_sampling_times */ | |||
| uint32_t Offset; /*!< Reserved for future use, can be set to 0 */ | |||
| }ADC_ChannelConfTypeDef; | |||
| /** | |||
| * @brief ADC Configuration multi-mode structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode. | |||
| This parameter can be a value of @ref ADC_analog_watchdog_selection */ | |||
| uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value. | |||
| This parameter must be a 12-bit value. */ | |||
| uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value. | |||
| This parameter must be a 12-bit value. */ | |||
| uint32_t Channel; /*!< Configures ADC channel for the analog watchdog. | |||
| This parameter has an effect only if watchdog mode is configured on single channel | |||
| This parameter can be a value of @ref ADC_channels */ | |||
| uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured | |||
| is interrupt mode or in polling mode. | |||
| This parameter can be set to ENABLE or DISABLE */ | |||
| uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */ | |||
| }ADC_AnalogWDGConfTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup ADC_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup ADC_Error_Code | |||
| * @{ | |||
| */ | |||
| #define HAL_ADC_ERROR_NONE ((uint32_t)0x00) /*!< No error */ | |||
| #define HAL_ADC_ERROR_OVR ((uint32_t)0x01) /*!< OVR error */ | |||
| #define HAL_ADC_ERROR_DMA ((uint32_t)0x02) /*!< DMA transfer error */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_ClockPrescaler | |||
| * @{ | |||
| */ | |||
| #define ADC_CLOCKPRESCALER_PCLK_DIV2 ((uint32_t)0x00000000) | |||
| #define ADC_CLOCKPRESCALER_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0) | |||
| #define ADC_CLOCKPRESCALER_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1) | |||
| #define ADC_CLOCKPRESCALER_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE) | |||
| #define IS_ADC_CLOCKPRESCALER(ADC_CLOCK) (((ADC_CLOCK) == ADC_CLOCKPRESCALER_PCLK_DIV2) || \ | |||
| ((ADC_CLOCK) == ADC_CLOCKPRESCALER_PCLK_DIV4) || \ | |||
| ((ADC_CLOCK) == ADC_CLOCKPRESCALER_PCLK_DIV6) || \ | |||
| ((ADC_CLOCK) == ADC_CLOCKPRESCALER_PCLK_DIV8)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_delay_between_2_sampling_phases | |||
| * @{ | |||
| */ | |||
| #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000) | |||
| #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0) | |||
| #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1) | |||
| #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) | |||
| #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2) | |||
| #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0)) | |||
| #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1)) | |||
| #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) | |||
| #define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3) | |||
| #define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0)) | |||
| #define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1)) | |||
| #define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) | |||
| #define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2)) | |||
| #define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0)) | |||
| #define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1)) | |||
| #define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY) | |||
| #define IS_ADC_SAMPLING_DELAY(DELAY) (((DELAY) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \ | |||
| ((DELAY) == ADC_TWOSAMPLINGDELAY_20CYCLES)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_Resolution | |||
| * @{ | |||
| */ | |||
| #define ADC_RESOLUTION12b ((uint32_t)0x00000000) | |||
| #define ADC_RESOLUTION10b ((uint32_t)ADC_CR1_RES_0) | |||
| #define ADC_RESOLUTION8b ((uint32_t)ADC_CR1_RES_1) | |||
| #define ADC_RESOLUTION6b ((uint32_t)ADC_CR1_RES) | |||
| #define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_RESOLUTION12b) || \ | |||
| ((RESOLUTION) == ADC_RESOLUTION10b) || \ | |||
| ((RESOLUTION) == ADC_RESOLUTION8b) || \ | |||
| ((RESOLUTION) == ADC_RESOLUTION6b)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_External_trigger_edge_Regular | |||
| * @{ | |||
| */ | |||
| #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000) | |||
| #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0) | |||
| #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1) | |||
| #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN) | |||
| #define IS_ADC_EXT_TRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \ | |||
| ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \ | |||
| ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \ | |||
| ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_External_trigger_Source_Regular | |||
| * @{ | |||
| */ | |||
| #define ADC_EXTERNALTRIGCONV_T1_CC1 ((uint32_t)0x00000000) | |||
| #define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0) | |||
| #define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1) | |||
| #define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGCONV_T2_CC3 ((uint32_t)ADC_CR2_EXTSEL_2) | |||
| #define ADC_EXTERNALTRIGCONV_T2_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1)) | |||
| #define ADC_EXTERNALTRIGCONV_T3_CC1 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGCONV_T3_TRGO ((uint32_t)ADC_CR2_EXTSEL_3) | |||
| #define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGCONV_T5_CC1 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1)) | |||
| #define ADC_EXTERNALTRIGCONV_T5_CC2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGCONV_T5_CC3 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2)) | |||
| #define ADC_EXTERNALTRIGCONV_T8_CC1 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1)) | |||
| #define ADC_EXTERNALTRIGCONV_Ext_IT11 ((uint32_t)ADC_CR2_EXTSEL) | |||
| #define IS_ADC_EXT_TRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC4) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC1) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC2) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC3) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \ | |||
| ((REGTRIG) == ADC_EXTERNALTRIGCONV_Ext_IT11)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_data_align | |||
| * @{ | |||
| */ | |||
| #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000) | |||
| #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN) | |||
| #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \ | |||
| ((ALIGN) == ADC_DATAALIGN_LEFT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_channels | |||
| * @{ | |||
| */ | |||
| #define ADC_CHANNEL_0 ((uint32_t)0x00000000) | |||
| #define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0) | |||
| #define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1) | |||
| #define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)) | |||
| #define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2) | |||
| #define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)) | |||
| #define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1)) | |||
| #define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)) | |||
| #define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3) | |||
| #define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)) | |||
| #define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1)) | |||
| #define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)) | |||
| #define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2)) | |||
| #define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)) | |||
| #define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1)) | |||
| #define ADC_CHANNEL_15 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)) | |||
| #define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4) | |||
| #define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0)) | |||
| #define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1)) | |||
| #define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_16) | |||
| #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17) | |||
| #define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18) | |||
| #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CHANNEL_0) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_1) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_2) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_3) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_4) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_5) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_6) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_7) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_8) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_9) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_10) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_11) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_12) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_13) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_14) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_15) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_16) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_17) || \ | |||
| ((CHANNEL) == ADC_CHANNEL_18)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_sampling_times | |||
| * @{ | |||
| */ | |||
| #define ADC_SAMPLETIME_3CYCLES ((uint32_t)0x00000000) | |||
| #define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0) | |||
| #define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1) | |||
| #define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0)) | |||
| #define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2) | |||
| #define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0)) | |||
| #define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1)) | |||
| #define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10) | |||
| #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_3CYCLES) || \ | |||
| ((TIME) == ADC_SAMPLETIME_15CYCLES) || \ | |||
| ((TIME) == ADC_SAMPLETIME_28CYCLES) || \ | |||
| ((TIME) == ADC_SAMPLETIME_56CYCLES) || \ | |||
| ((TIME) == ADC_SAMPLETIME_84CYCLES) || \ | |||
| ((TIME) == ADC_SAMPLETIME_112CYCLES) || \ | |||
| ((TIME) == ADC_SAMPLETIME_144CYCLES) || \ | |||
| ((TIME) == ADC_SAMPLETIME_480CYCLES)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_EOCSelection | |||
| * @{ | |||
| */ | |||
| #define EOC_SEQ_CONV ((uint32_t)0x00000000) | |||
| #define EOC_SINGLE_CONV ((uint32_t)0x00000001) | |||
| #define EOC_SINGLE_SEQ_CONV ((uint32_t)0x00000002) /*!< reserved for future use */ | |||
| #define IS_ADC_EOCSelection(EOCSelection) (((EOCSelection) == EOC_SINGLE_CONV) || \ | |||
| ((EOCSelection) == EOC_SEQ_CONV) || \ | |||
| ((EOCSelection) == EOC_SINGLE_SEQ_CONV)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_Event_type | |||
| * @{ | |||
| */ | |||
| #define AWD_EVENT ((uint32_t)ADC_FLAG_AWD) | |||
| #define OVR_EVENT ((uint32_t)ADC_FLAG_OVR) | |||
| #define IS_ADC_EVENT_TYPE(EVENT) (((EVENT) == AWD_EVENT) || \ | |||
| ((EVENT) == OVR_EVENT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_analog_watchdog_selection | |||
| * @{ | |||
| */ | |||
| #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN)) | |||
| #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN)) | |||
| #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN)) | |||
| #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN) | |||
| #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN) | |||
| #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN)) | |||
| #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000) | |||
| #define IS_ADC_ANALOG_WATCHDOG(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \ | |||
| ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \ | |||
| ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \ | |||
| ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) || \ | |||
| ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \ | |||
| ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \ | |||
| ((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_interrupts_definition | |||
| * @{ | |||
| */ | |||
| #define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE) | |||
| #define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE) | |||
| #define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE) | |||
| #define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE) | |||
| #define IS_ADC_IT(IT) (((IT) == ADC_IT_EOC) || ((IT) == ADC_IT_AWD) || \ | |||
| ((IT) == ADC_IT_JEOC)|| ((IT) == ADC_IT_OVR)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_flags_definition | |||
| * @{ | |||
| */ | |||
| #define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD) | |||
| #define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC) | |||
| #define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC) | |||
| #define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT) | |||
| #define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT) | |||
| #define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_channels_type | |||
| * @{ | |||
| */ | |||
| #define ALL_CHANNELS ((uint32_t)0x00000001) | |||
| #define REGULAR_CHANNELS ((uint32_t)0x00000002) /*!< reserved for future use */ | |||
| #define INJECTED_CHANNELS ((uint32_t)0x00000003) /*!< reserved for future use */ | |||
| #define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ALL_CHANNELS) || \ | |||
| ((CHANNEL_TYPE) == REGULAR_CHANNELS) || \ | |||
| ((CHANNEL_TYPE) == INJECTED_CHANNELS)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_thresholds | |||
| * @{ | |||
| */ | |||
| #define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= ((uint32_t)0xFFF)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_regular_length | |||
| * @{ | |||
| */ | |||
| #define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= ((uint32_t)1)) && ((LENGTH) <= ((uint32_t)16))) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_regular_rank | |||
| * @{ | |||
| */ | |||
| #define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= ((uint32_t)1)) && ((RANK) <= ((uint32_t)16))) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_regular_discontinuous_mode_number | |||
| * @{ | |||
| */ | |||
| #define IS_ADC_REGULAR_DISC_NUMBER(NUMBER) (((NUMBER) >= ((uint32_t)1)) && ((NUMBER) <= ((uint32_t)8))) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADC_range_verification | |||
| * @{ | |||
| */ | |||
| #define IS_ADC_RANGE(RESOLUTION, ADC_VALUE) \ | |||
| ((((RESOLUTION) == ADC_RESOLUTION12b) && ((ADC_VALUE) <= ((uint32_t)0x0FFF))) || \ | |||
| (((RESOLUTION) == ADC_RESOLUTION10b) && ((ADC_VALUE) <= ((uint32_t)0x03FF))) || \ | |||
| (((RESOLUTION) == ADC_RESOLUTION8b) && ((ADC_VALUE) <= ((uint32_t)0x00FF))) || \ | |||
| (((RESOLUTION) == ADC_RESOLUTION6b) && ((ADC_VALUE) <= ((uint32_t)0x003F)))) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset ADC handle state | |||
| * @param __HANDLE__: ADC handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET) | |||
| /** | |||
| * @brief Enable the ADC peripheral. | |||
| * @param __HANDLE__: ADC handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON) | |||
| /** | |||
| * @brief Disable the ADC peripheral. | |||
| * @param __HANDLE__: ADC handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON) | |||
| /** | |||
| * @brief Set ADC Regular channel sequence length. | |||
| * @param _NbrOfConversion_: Regular channel sequence length. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1) << 20) | |||
| /** | |||
| * @brief Set the ADC's sample time for channel numbers between 10 and 18. | |||
| * @param _SAMPLETIME_: Sample time parameter. | |||
| * @param _CHANNELNB_: Channel number. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * ((_CHANNELNB_) - 10))) | |||
| /** | |||
| * @brief Set the ADC's sample time for channel numbers between 0 and 9. | |||
| * @param _SAMPLETIME_: Sample time parameter. | |||
| * @param _CHANNELNB_: Channel number. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * (_CHANNELNB_))) | |||
| /** | |||
| * @brief Set the selected regular channel rank for rank between 1 and 6. | |||
| * @param _CHANNELNB_: Channel number. | |||
| * @param _RANKNB_: Rank number. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) ((_CHANNELNB_) << (5 * ((_RANKNB_) - 1))) | |||
| /** | |||
| * @brief Set the selected regular channel rank for rank between 7 and 12. | |||
| * @param _CHANNELNB_: Channel number. | |||
| * @param _RANKNB_: Rank number. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) ((_CHANNELNB_) << (5 * ((_RANKNB_) - 7))) | |||
| /** | |||
| * @brief Set the selected regular channel rank for rank between 13 and 16. | |||
| * @param _CHANNELNB_: Channel number. | |||
| * @param _RANKNB_: Rank number. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) ((_CHANNELNB_) << (5 * ((_RANKNB_) - 13))) | |||
| /** | |||
| * @brief Enable ADC continuous conversion mode. | |||
| * @param _CONTINUOUS_MODE_: Continuous mode. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1) | |||
| /** | |||
| * @brief Configures the number of discontinuous conversions for the regular group channels. | |||
| * @param _NBR_DISCONTINUOUSCONV_: Number of discontinuous conversions. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1) << 13) | |||
| /** | |||
| * @brief Enable ADC scan mode. | |||
| * @param _SCANCONV_MODE_: Scan conversion mode. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8) | |||
| /** | |||
| * @brief Enable the ADC end of conversion selection. | |||
| * @param _EOCSelection_MODE_: End of conversion selection mode. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10) | |||
| /** | |||
| * @brief Enable the ADC DMA continuous request. | |||
| * @param _DMAContReq_MODE_: DMA continuous request mode. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9) | |||
| /** | |||
| * @brief Enable the ADC end of conversion interrupt. | |||
| * @param __HANDLE__: specifies the ADC Handle. | |||
| * @param __INTERRUPT__: ADC Interrupt. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the ADC end of conversion interrupt. | |||
| * @param __HANDLE__: specifies the ADC Handle. | |||
| * @param __INTERRUPT__: ADC interrupt. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__)) | |||
| /** @brief Check if the specified ADC interrupt source is enabled or disabled. | |||
| * @param __HANDLE__: specifies the ADC Handle. | |||
| * @param __INTERRUPT__: specifies the ADC interrupt source to check. | |||
| * @retval The new state of __IT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
| /** | |||
| * @brief Clear the ADC's pending flags. | |||
| * @param __HANDLE__: specifies the ADC Handle. | |||
| * @param __FLAG__: ADC flag. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__)) | |||
| /** | |||
| * @brief Get the selected ADC's flag status. | |||
| * @param __HANDLE__: specifies the ADC Handle. | |||
| * @param __FLAG__: ADC flag. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) | |||
| /** | |||
| * @brief Return resolution bits in CR1 register. | |||
| * @param __HANDLE__: ADC handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES) | |||
| /* Include ADC HAL Extension module */ | |||
| #include "stm32f4xx_hal_adc_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions ***********************************/ | |||
| HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc); | |||
| HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc); | |||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc); | |||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc); | |||
| /* I/O operation functions ******************************************************/ | |||
| HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc); | |||
| HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc); | |||
| HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc); | |||
| HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc); | |||
| void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc); | |||
| HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length); | |||
| HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc); | |||
| uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc); | |||
| void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc); | |||
| void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc); | |||
| void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc); | |||
| void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc); | |||
| /* Peripheral Control functions *************************************************/ | |||
| HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig); | |||
| HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig); | |||
| /* Peripheral State functions ***************************************************/ | |||
| HAL_ADC_StateTypeDef HAL_ADC_GetState(ADC_HandleTypeDef* hadc); | |||
| uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /*__STM32F4xx_ADC_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,288 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_adc.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of ADC HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_ADC_EX_H | |||
| #define __STM32F4xx_ADC_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup ADCEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief ADC Configuration injected Channel structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t InjectedChannel; /*!< Configure the ADC injected channel. | |||
| This parameter can be a value of @ref ADC_channels */ | |||
| uint32_t InjectedRank; /*!< The rank in the injected group sequencer | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 4. */ | |||
| uint32_t InjectedSamplingTime; /*!< The sample time value to be set for the selected channel. | |||
| This parameter can be a value of @ref ADC_sampling_times */ | |||
| uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data when convert injected channels. | |||
| This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ | |||
| uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ADC conversions that will be done using the sequencer for | |||
| injected channel group. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 4. */ | |||
| uint32_t AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group | |||
| conversion after regular one */ | |||
| uint32_t InjectedDiscontinuousConvMode; /*!< Specifies whether the conversion is performed in Discontinuous mode or not for injected channels. | |||
| This parameter can be set to ENABLE or DISABLE. */ | |||
| uint32_t ExternalTrigInjecConvEdge; /*!< Select the external trigger edge and enable the trigger of an injected channels. | |||
| This parameter can be a value of @ref ADCEx_External_trigger_edge_Injected */ | |||
| uint32_t ExternalTrigInjecConv; /*!< Select the external event used to trigger the start of conversion of a injected channels. | |||
| This parameter can be a value of @ref ADCEx_External_trigger_Source_Injected */ | |||
| }ADC_InjectionConfTypeDef; | |||
| /** | |||
| * @brief ADC Configuration multi-mode structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Mode; /*!< Configures the ADC to operate in independent or multi mode. | |||
| This parameter can be a value of @ref ADCEx_Common_mode */ | |||
| uint32_t DMAAccessMode; /*!< Configures the Direct memory access mode for multi ADC mode. | |||
| This parameter can be a value of @ref ADCEx_Direct_memory_access_mode_for_multi_mode */ | |||
| uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases. | |||
| This parameter can be a value of @ref ADC_delay_between_2_sampling_phases */ | |||
| }ADC_MultiModeTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup ADCEx_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup ADCEx_Common_mode | |||
| * @{ | |||
| */ | |||
| #define ADC_MODE_INDEPENDENT ((uint32_t)0x00000000) | |||
| #define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)ADC_CCR_MULTI_0) | |||
| #define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)ADC_CCR_MULTI_1) | |||
| #define ADC_DUALMODE_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0)) | |||
| #define ADC_DUALMODE_REGSIMULT ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1)) | |||
| #define ADC_DUALMODE_INTERL ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0)) | |||
| #define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0)) | |||
| #define ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_0)) | |||
| #define ADC_TRIPLEMODE_REGSIMULT_AlterTrig ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_1)) | |||
| #define ADC_TRIPLEMODE_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0)) | |||
| #define ADC_TRIPLEMODE_REGSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1)) | |||
| #define ADC_TRIPLEMODE_INTERL ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0)) | |||
| #define ADC_TRIPLEMODE_ALTERTRIG ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0)) | |||
| #define IS_ADC_MODE(MODE) (((MODE) == ADC_MODE_INDEPENDENT) || \ | |||
| ((MODE) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \ | |||
| ((MODE) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \ | |||
| ((MODE) == ADC_DUALMODE_INJECSIMULT) || \ | |||
| ((MODE) == ADC_DUALMODE_REGSIMULT) || \ | |||
| ((MODE) == ADC_DUALMODE_INTERL) || \ | |||
| ((MODE) == ADC_DUALMODE_ALTERTRIG) || \ | |||
| ((MODE) == ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT) || \ | |||
| ((MODE) == ADC_TRIPLEMODE_REGSIMULT_AlterTrig) || \ | |||
| ((MODE) == ADC_TRIPLEMODE_INJECSIMULT) || \ | |||
| ((MODE) == ADC_TRIPLEMODE_REGSIMULT) || \ | |||
| ((MODE) == ADC_TRIPLEMODE_INTERL) || \ | |||
| ((MODE) == ADC_TRIPLEMODE_ALTERTRIG)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADCEx_Direct_memory_access_mode_for_multi_mode | |||
| * @{ | |||
| */ | |||
| #define ADC_DMAACCESSMODE_DISABLED ((uint32_t)0x00000000) /*!< DMA mode disabled */ | |||
| #define ADC_DMAACCESSMODE_1 ((uint32_t)ADC_CCR_DMA_0) /*!< DMA mode 1 enabled (2 / 3 half-words one by one - 1 then 2 then 3)*/ | |||
| #define ADC_DMAACCESSMODE_2 ((uint32_t)ADC_CCR_DMA_1) /*!< DMA mode 2 enabled (2 / 3 half-words by pairs - 2&1 then 1&3 then 3&2)*/ | |||
| #define ADC_DMAACCESSMODE_3 ((uint32_t)ADC_CCR_DMA) /*!< DMA mode 3 enabled (2 / 3 bytes by pairs - 2&1 then 1&3 then 3&2) */ | |||
| #define IS_ADC_DMA_ACCESS_MODE(MODE) (((MODE) == ADC_DMAACCESSMODE_DISABLED) || \ | |||
| ((MODE) == ADC_DMAACCESSMODE_1) || \ | |||
| ((MODE) == ADC_DMAACCESSMODE_2) || \ | |||
| ((MODE) == ADC_DMAACCESSMODE_3)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADCEx_External_trigger_edge_Injected | |||
| * @{ | |||
| */ | |||
| #define ADC_EXTERNALTRIGINJECCONVEDGE_NONE ((uint32_t)0x00000000) | |||
| #define ADC_EXTERNALTRIGINJECCONVEDGE_RISING ((uint32_t)ADC_CR2_JEXTEN_0) | |||
| #define ADC_EXTERNALTRIGINJECCONVEDGE_FALLING ((uint32_t)ADC_CR2_JEXTEN_1) | |||
| #define ADC_EXTERNALTRIGINJECCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_JEXTEN) | |||
| #define IS_ADC_EXT_INJEC_TRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_NONE) || \ | |||
| ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_RISING) || \ | |||
| ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_FALLING) || \ | |||
| ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_RISINGFALLING)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADCEx_External_trigger_Source_Injected | |||
| * @{ | |||
| */ | |||
| #define ADC_EXTERNALTRIGINJECCONV_T1_CC4 ((uint32_t)0x00000000) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ((uint32_t)ADC_CR2_JEXTSEL_0) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ((uint32_t)ADC_CR2_JEXTSEL_1) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T3_CC2 ((uint32_t)ADC_CR2_JEXTSEL_2) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T4_CC1 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T4_CC2 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T4_CC3 ((uint32_t)ADC_CR2_JEXTSEL_3) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T5_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T5_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T8_CC2 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T8_CC3 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_T8_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1)) | |||
| #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ((uint32_t)ADC_CR2_JEXTSEL) | |||
| #define IS_ADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC2) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC1) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC2) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_TRGO) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC3) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \ | |||
| ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADCEx_injected_channel_selection | |||
| * @{ | |||
| */ | |||
| #define ADC_INJECTED_RANK_1 ((uint32_t)0x00000001) | |||
| #define ADC_INJECTED_RANK_2 ((uint32_t)0x00000002) | |||
| #define ADC_INJECTED_RANK_3 ((uint32_t)0x00000003) | |||
| #define ADC_INJECTED_RANK_4 ((uint32_t)0x00000004) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADCEx_injected_length | |||
| * @{ | |||
| */ | |||
| #define IS_ADC_INJECTED_LENGTH(LENGTH) (((LENGTH) >= ((uint32_t)1)) && ((LENGTH) <= ((uint32_t)4))) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup ADCEx_injected_rank | |||
| * @{ | |||
| */ | |||
| #define IS_ADC_INJECTED_RANK(RANK) (((RANK) >= ((uint32_t)1)) && ((RANK) <= ((uint32_t)4))) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief Set the selected injected Channel rank. | |||
| * @param _CHANNELNB_: Channel number. | |||
| * @param _RANKNB_: Rank number. | |||
| * @param _JSQR_JL_: Sequence length. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_ADC_JSQR(_CHANNELNB_, _RANKNB_,_JSQR_JL_) \ | |||
| ((_CHANNELNB_) << (5 * (uint8_t)(((_RANKNB_) + 3) - (_JSQR_JL_)))) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* I/O operation functions ******************************************************/ | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc); | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc); | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc); | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc); | |||
| uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank); | |||
| HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length); | |||
| HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef* hadc); | |||
| uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef* hadc); | |||
| void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc); | |||
| /* Peripheral Control functions *************************************************/ | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected); | |||
| HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_MultiModeTypeDef* multimode); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /*__STM32F4xx_ADC_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,781 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_can.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of CAN HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_CAN_H | |||
| #define __STM32F4xx_HAL_CAN_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup CAN | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_CAN_STATE_RESET = 0x00, /*!< CAN not yet initialized or disabled */ | |||
| HAL_CAN_STATE_READY = 0x01, /*!< CAN initialized and ready for use */ | |||
| HAL_CAN_STATE_BUSY = 0x02, /*!< CAN process is ongoing */ | |||
| HAL_CAN_STATE_BUSY_TX = 0x12, /*!< CAN process is ongoing */ | |||
| HAL_CAN_STATE_BUSY_RX = 0x22, /*!< CAN process is ongoing */ | |||
| HAL_CAN_STATE_BUSY_TX_RX = 0x32, /*!< CAN process is ongoing */ | |||
| HAL_CAN_STATE_TIMEOUT = 0x03, /*!< Timeout state */ | |||
| HAL_CAN_STATE_ERROR = 0x04 /*!< CAN error state */ | |||
| }HAL_CAN_StateTypeDef; | |||
| /** | |||
| * @brief CAN init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Prescaler; /*!< Specifies the length of a time quantum. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 1024 */ | |||
| uint32_t Mode; /*!< Specifies the CAN operating mode. | |||
| This parameter can be a value of @ref CAN_operating_mode */ | |||
| uint32_t SJW; /*!< Specifies the maximum number of time quanta | |||
| the CAN hardware is allowed to lengthen or | |||
| shorten a bit to perform resynchronization. | |||
| This parameter can be a value of @ref CAN_synchronisation_jump_width */ | |||
| uint32_t BS1; /*!< Specifies the number of time quanta in Bit Segment 1. | |||
| This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_1 */ | |||
| uint32_t BS2; /*!< Specifies the number of time quanta in Bit Segment 2. | |||
| This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_2 */ | |||
| uint32_t TTCM; /*!< Enable or disable the time triggered communication mode. | |||
| This parameter can be set to ENABLE or DISABLE. */ | |||
| uint32_t ABOM; /*!< Enable or disable the automatic bus-off management. | |||
| This parameter can be set to ENABLE or DISABLE */ | |||
| uint32_t AWUM; /*!< Enable or disable the automatic wake-up mode. | |||
| This parameter can be set to ENABLE or DISABLE */ | |||
| uint32_t NART; /*!< Enable or disable the non-automatic retransmission mode. | |||
| This parameter can be set to ENABLE or DISABLE */ | |||
| uint32_t RFLM; /*!< Enable or disable the receive FIFO Locked mode. | |||
| This parameter can be set to ENABLE or DISABLE */ | |||
| uint32_t TXFP; /*!< Enable or disable the transmit FIFO priority. | |||
| This parameter can be set to ENABLE or DISABLE */ | |||
| }CAN_InitTypeDef; | |||
| /** | |||
| * @brief CAN filter configuration structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit | |||
| configuration, first one for a 16-bit configuration). | |||
| This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ | |||
| uint32_t FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit | |||
| configuration, second one for a 16-bit configuration). | |||
| This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ | |||
| uint32_t FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number, | |||
| according to the mode (MSBs for a 32-bit configuration, | |||
| first one for a 16-bit configuration). | |||
| This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ | |||
| uint32_t FilterMaskIdLow; /*!< Specifies the filter mask number or identification number, | |||
| according to the mode (LSBs for a 32-bit configuration, | |||
| second one for a 16-bit configuration). | |||
| This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ | |||
| uint32_t FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter. | |||
| This parameter can be a value of @ref CAN_filter_FIFO */ | |||
| uint32_t FilterNumber; /*!< Specifies the filter which will be initialized. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 27 */ | |||
| uint32_t FilterMode; /*!< Specifies the filter mode to be initialized. | |||
| This parameter can be a value of @ref CAN_filter_mode */ | |||
| uint32_t FilterScale; /*!< Specifies the filter scale. | |||
| This parameter can be a value of @ref CAN_filter_scale */ | |||
| uint32_t FilterActivation; /*!< Enable or disable the filter. | |||
| This parameter can be set to ENABLE or DISABLE. */ | |||
| uint32_t BankNumber; /*!< Select the start slave bank filter. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 28 */ | |||
| }CAN_FilterConfTypeDef; | |||
| /** | |||
| * @brief CAN Tx message structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t StdId; /*!< Specifies the standard identifier. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF */ | |||
| uint32_t ExtId; /*!< Specifies the extended identifier. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF */ | |||
| uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted. | |||
| This parameter can be a value of @ref CAN_identifier_type */ | |||
| uint32_t RTR; /*!< Specifies the type of frame for the message that will be transmitted. | |||
| This parameter can be a value of @ref CAN_remote_transmission_request */ | |||
| uint32_t DLC; /*!< Specifies the length of the frame that will be transmitted. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 8 */ | |||
| uint32_t Data[8]; /*!< Contains the data to be transmitted. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF */ | |||
| }CanTxMsgTypeDef; | |||
| /** | |||
| * @brief CAN Rx message structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t StdId; /*!< Specifies the standard identifier. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF */ | |||
| uint32_t ExtId; /*!< Specifies the extended identifier. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF */ | |||
| uint32_t IDE; /*!< Specifies the type of identifier for the message that will be received. | |||
| This parameter can be a value of @ref CAN_identifier_type */ | |||
| uint32_t RTR; /*!< Specifies the type of frame for the received message. | |||
| This parameter can be a value of @ref CAN_remote_transmission_request */ | |||
| uint32_t DLC; /*!< Specifies the length of the frame that will be received. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 8 */ | |||
| uint32_t Data[8]; /*!< Contains the data to be received. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF */ | |||
| uint32_t FMI; /*!< Specifies the index of the filter the message stored in the mailbox passes through. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF */ | |||
| uint32_t FIFONumber; /*!< Specifies the receive FIFO number. | |||
| This parameter can be CAN_FIFO0 or CAN_FIFO1 */ | |||
| }CanRxMsgTypeDef; | |||
| /** | |||
| * @brief CAN handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| CAN_TypeDef *Instance; /*!< Register base address */ | |||
| CAN_InitTypeDef Init; /*!< CAN required parameters */ | |||
| CanTxMsgTypeDef* pTxMsg; /*!< Pointer to transmit structure */ | |||
| CanRxMsgTypeDef* pRxMsg; /*!< Pointer to reception structure */ | |||
| __IO HAL_CAN_StateTypeDef State; /*!< CAN communication state */ | |||
| HAL_LockTypeDef Lock; /*!< CAN locking object */ | |||
| __IO uint32_t ErrorCode; /*!< CAN Error code */ | |||
| }CAN_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup CAN_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup HAL CAN Error Code | |||
| * @{ | |||
| */ | |||
| #define HAL_CAN_ERROR_NONE 0x00 /*!< No error */ | |||
| #define HAL_CAN_ERROR_EWG 0x01 /*!< EWG error */ | |||
| #define HAL_CAN_ERROR_EPV 0x02 /*!< EPV error */ | |||
| #define HAL_CAN_ERROR_BOF 0x04 /*!< BOF error */ | |||
| #define HAL_CAN_ERROR_STF 0x08 /*!< Stuff error */ | |||
| #define HAL_CAN_ERROR_FOR 0x10 /*!< Form error */ | |||
| #define HAL_CAN_ERROR_ACK 0x20 /*!< Acknowledgment error */ | |||
| #define HAL_CAN_ERROR_BR 0x40 /*!< Bit recessive */ | |||
| #define HAL_CAN_ERROR_BD 0x80 /*!< LEC dominant */ | |||
| #define HAL_CAN_ERROR_CRC 0x100 /*!< LEC transfer error */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_InitStatus | |||
| * @{ | |||
| */ | |||
| #define CAN_INITSTATUS_FAILED ((uint8_t)0x00) /*!< CAN initialization failed */ | |||
| #define CAN_INITSTATUS_SUCCESS ((uint8_t)0x01) /*!< CAN initialization OK */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_operating_mode | |||
| * @{ | |||
| */ | |||
| #define CAN_MODE_NORMAL ((uint32_t)0x00000000) /*!< Normal mode */ | |||
| #define CAN_MODE_LOOPBACK ((uint32_t)CAN_BTR_LBKM) /*!< Loopback mode */ | |||
| #define CAN_MODE_SILENT ((uint32_t)CAN_BTR_SILM) /*!< Silent mode */ | |||
| #define CAN_MODE_SILENT_LOOPBACK ((uint32_t)(CAN_BTR_LBKM | CAN_BTR_SILM)) /*!< Loopback combined with silent mode */ | |||
| #define IS_CAN_MODE(MODE) (((MODE) == CAN_MODE_NORMAL) || \ | |||
| ((MODE) == CAN_MODE_LOOPBACK)|| \ | |||
| ((MODE) == CAN_MODE_SILENT) || \ | |||
| ((MODE) == CAN_MODE_SILENT_LOOPBACK)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_synchronisation_jump_width | |||
| * @{ | |||
| */ | |||
| #define CAN_SJW_1TQ ((uint32_t)0x00000000) /*!< 1 time quantum */ | |||
| #define CAN_SJW_2TQ ((uint32_t)CAN_BTR_SJW_0) /*!< 2 time quantum */ | |||
| #define CAN_SJW_3TQ ((uint32_t)CAN_BTR_SJW_1) /*!< 3 time quantum */ | |||
| #define CAN_SJW_4TQ ((uint32_t)CAN_BTR_SJW) /*!< 4 time quantum */ | |||
| #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1TQ) || ((SJW) == CAN_SJW_2TQ)|| \ | |||
| ((SJW) == CAN_SJW_3TQ) || ((SJW) == CAN_SJW_4TQ)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_time_quantum_in_bit_segment_1 | |||
| * @{ | |||
| */ | |||
| #define CAN_BS1_1TQ ((uint32_t)0x00000000) /*!< 1 time quantum */ | |||
| #define CAN_BS1_2TQ ((uint32_t)CAN_BTR_TS1_0) /*!< 2 time quantum */ | |||
| #define CAN_BS1_3TQ ((uint32_t)CAN_BTR_TS1_1) /*!< 3 time quantum */ | |||
| #define CAN_BS1_4TQ ((uint32_t)(CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 4 time quantum */ | |||
| #define CAN_BS1_5TQ ((uint32_t)CAN_BTR_TS1_2) /*!< 5 time quantum */ | |||
| #define CAN_BS1_6TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_0)) /*!< 6 time quantum */ | |||
| #define CAN_BS1_7TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_1)) /*!< 7 time quantum */ | |||
| #define CAN_BS1_8TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 8 time quantum */ | |||
| #define CAN_BS1_9TQ ((uint32_t)CAN_BTR_TS1_3) /*!< 9 time quantum */ | |||
| #define CAN_BS1_10TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_0)) /*!< 10 time quantum */ | |||
| #define CAN_BS1_11TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_1)) /*!< 11 time quantum */ | |||
| #define CAN_BS1_12TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 12 time quantum */ | |||
| #define CAN_BS1_13TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2)) /*!< 13 time quantum */ | |||
| #define CAN_BS1_14TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2 | CAN_BTR_TS1_0)) /*!< 14 time quantum */ | |||
| #define CAN_BS1_15TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2 | CAN_BTR_TS1_1)) /*!< 15 time quantum */ | |||
| #define CAN_BS1_16TQ ((uint32_t)CAN_BTR_TS1) /*!< 16 time quantum */ | |||
| #define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16TQ) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_time_quantum_in_bit_segment_2 | |||
| * @{ | |||
| */ | |||
| #define CAN_BS2_1TQ ((uint32_t)0x00000000) /*!< 1 time quantum */ | |||
| #define CAN_BS2_2TQ ((uint32_t)CAN_BTR_TS2_0) /*!< 2 time quantum */ | |||
| #define CAN_BS2_3TQ ((uint32_t)CAN_BTR_TS2_1) /*!< 3 time quantum */ | |||
| #define CAN_BS2_4TQ ((uint32_t)(CAN_BTR_TS2_1 | CAN_BTR_TS2_0)) /*!< 4 time quantum */ | |||
| #define CAN_BS2_5TQ ((uint32_t)CAN_BTR_TS2_2) /*!< 5 time quantum */ | |||
| #define CAN_BS2_6TQ ((uint32_t)(CAN_BTR_TS2_2 | CAN_BTR_TS2_0)) /*!< 6 time quantum */ | |||
| #define CAN_BS2_7TQ ((uint32_t)(CAN_BTR_TS2_2 | CAN_BTR_TS2_1)) /*!< 7 time quantum */ | |||
| #define CAN_BS2_8TQ ((uint32_t)CAN_BTR_TS2) /*!< 8 time quantum */ | |||
| #define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8TQ) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_clock_prescaler | |||
| * @{ | |||
| */ | |||
| #define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_filter_number | |||
| * @{ | |||
| */ | |||
| #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_filter_mode | |||
| * @{ | |||
| */ | |||
| #define CAN_FILTERMODE_IDMASK ((uint8_t)0x00) /*!< Identifier mask mode */ | |||
| #define CAN_FILTERMODE_IDLIST ((uint8_t)0x01) /*!< Identifier list mode */ | |||
| #define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FILTERMODE_IDMASK) || \ | |||
| ((MODE) == CAN_FILTERMODE_IDLIST)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_filter_scale | |||
| * @{ | |||
| */ | |||
| #define CAN_FILTERSCALE_16BIT ((uint8_t)0x00) /*!< Two 16-bit filters */ | |||
| #define CAN_FILTERSCALE_32BIT ((uint8_t)0x01) /*!< One 32-bit filter */ | |||
| #define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FILTERSCALE_16BIT) || \ | |||
| ((SCALE) == CAN_FILTERSCALE_32BIT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_filter_FIFO | |||
| * @{ | |||
| */ | |||
| #define CAN_FILTER_FIFO0 ((uint8_t)0x00) /*!< Filter FIFO 0 assignment for filter x */ | |||
| #define CAN_FILTER_FIFO1 ((uint8_t)0x01) /*!< Filter FIFO 1 assignment for filter x */ | |||
| #define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FILTER_FIFO0) || \ | |||
| ((FIFO) == CAN_FILTER_FIFO1)) | |||
| /* Legacy defines */ | |||
| #define CAN_FilterFIFO0 CAN_FILTER_FIFO0 | |||
| #define CAN_FilterFIFO1 CAN_FILTER_FIFO1 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_Start_bank_filter_for_slave_CAN | |||
| * @{ | |||
| */ | |||
| #define IS_CAN_BANKNUMBER(BANKNUMBER) ((BANKNUMBER) <= 28) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_Tx | |||
| * @{ | |||
| */ | |||
| #define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02)) | |||
| #define IS_CAN_STDID(STDID) ((STDID) <= ((uint32_t)0x7FF)) | |||
| #define IS_CAN_EXTID(EXTID) ((EXTID) <= ((uint32_t)0x1FFFFFFF)) | |||
| #define IS_CAN_DLC(DLC) ((DLC) <= ((uint8_t)0x08)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_identifier_type | |||
| * @{ | |||
| */ | |||
| #define CAN_ID_STD ((uint32_t)0x00000000) /*!< Standard Id */ | |||
| #define CAN_ID_EXT ((uint32_t)0x00000004) /*!< Extended Id */ | |||
| #define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_ID_STD) || \ | |||
| ((IDTYPE) == CAN_ID_EXT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_remote_transmission_request | |||
| * @{ | |||
| */ | |||
| #define CAN_RTR_DATA ((uint32_t)0x00000000) /*!< Data frame */ | |||
| #define CAN_RTR_REMOTE ((uint32_t)0x00000002) /*!< Remote frame */ | |||
| #define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_DATA) || ((RTR) == CAN_RTR_REMOTE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_transmit_constants | |||
| * @{ | |||
| */ | |||
| #define CAN_TXSTATUS_FAILED ((uint8_t)0x00) /*!< CAN transmission failed */ | |||
| #define CAN_TXSTATUS_OK ((uint8_t)0x01) /*!< CAN transmission succeeded */ | |||
| #define CAN_TXSTATUS_PENDING ((uint8_t)0x02) /*!< CAN transmission pending */ | |||
| #define CAN_TXSTATUS_NOMAILBOX ((uint8_t)0x04) /*!< CAN cell did not provide CAN_TxStatus_NoMailBox */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_receive_FIFO_number_constants | |||
| * @{ | |||
| */ | |||
| #define CAN_FIFO0 ((uint8_t)0x00) /*!< CAN FIFO 0 used to receive */ | |||
| #define CAN_FIFO1 ((uint8_t)0x01) /*!< CAN FIFO 1 used to receive */ | |||
| #define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_flags | |||
| * @{ | |||
| */ | |||
| /* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus() | |||
| and CAN_ClearFlag() functions. */ | |||
| /* If the flag is 0x1XXXXXXX, it means that it can only be used with | |||
| CAN_GetFlagStatus() function. */ | |||
| /* Transmit Flags */ | |||
| #define CAN_FLAG_RQCP0 ((uint32_t)0x00000500) /*!< Request MailBox0 flag */ | |||
| #define CAN_FLAG_RQCP1 ((uint32_t)0x00000508) /*!< Request MailBox1 flag */ | |||
| #define CAN_FLAG_RQCP2 ((uint32_t)0x00000510) /*!< Request MailBox2 flag */ | |||
| #define CAN_FLAG_TXOK0 ((uint32_t)0x00000501) /*!< Transmission OK MailBox0 flag */ | |||
| #define CAN_FLAG_TXOK1 ((uint32_t)0x00000509) /*!< Transmission OK MailBox1 flag */ | |||
| #define CAN_FLAG_TXOK2 ((uint32_t)0x00000511) /*!< Transmission OK MailBox2 flag */ | |||
| #define CAN_FLAG_TME0 ((uint32_t)0x0000051A) /*!< Transmit mailbox 0 empty flag */ | |||
| #define CAN_FLAG_TME1 ((uint32_t)0x0000051B) /*!< Transmit mailbox 0 empty flag */ | |||
| #define CAN_FLAG_TME2 ((uint32_t)0x0000051C) /*!< Transmit mailbox 0 empty flag */ | |||
| /* Receive Flags */ | |||
| #define CAN_FLAG_FF0 ((uint32_t)0x00000203) /*!< FIFO 0 Full flag */ | |||
| #define CAN_FLAG_FOV0 ((uint32_t)0x00000204) /*!< FIFO 0 Overrun flag */ | |||
| #define CAN_FLAG_FF1 ((uint32_t)0x00000403) /*!< FIFO 1 Full flag */ | |||
| #define CAN_FLAG_FOV1 ((uint32_t)0x00000404) /*!< FIFO 1 Overrun flag */ | |||
| /* Operating Mode Flags */ | |||
| #define CAN_FLAG_WKU ((uint32_t)0x00000103) /*!< Wake up flag */ | |||
| #define CAN_FLAG_SLAK ((uint32_t)0x00000101) /*!< Sleep acknowledge flag */ | |||
| #define CAN_FLAG_SLAKI ((uint32_t)0x00000104) /*!< Sleep acknowledge flag */ | |||
| /* @note When SLAK interrupt is disabled (SLKIE=0), no polling on SLAKI is possible. | |||
| In this case the SLAK bit can be polled.*/ | |||
| /* Error Flags */ | |||
| #define CAN_FLAG_EWG ((uint32_t)0x00000300) /*!< Error warning flag */ | |||
| #define CAN_FLAG_EPV ((uint32_t)0x00000301) /*!< Error passive flag */ | |||
| #define CAN_FLAG_BOF ((uint32_t)0x00000302) /*!< Bus-Off flag */ | |||
| #define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_RQCP2) || ((FLAG) == CAN_FLAG_BOF) || \ | |||
| ((FLAG) == CAN_FLAG_EPV) || ((FLAG) == CAN_FLAG_EWG) || \ | |||
| ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_FOV0) || \ | |||
| ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_SLAK) || \ | |||
| ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1) || \ | |||
| ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0)) | |||
| #define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_SLAK) || ((FLAG) == CAN_FLAG_RQCP2) || \ | |||
| ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0) || \ | |||
| ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FOV0) || \ | |||
| ((FLAG) == CAN_FLAG_FF1) || ((FLAG) == CAN_FLAG_FOV1) || \ | |||
| ((FLAG) == CAN_FLAG_WKU)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CAN_interrupts | |||
| * @{ | |||
| */ | |||
| #define CAN_IT_TME ((uint32_t)CAN_IER_TMEIE) /*!< Transmit mailbox empty interrupt */ | |||
| /* Receive Interrupts */ | |||
| #define CAN_IT_FMP0 ((uint32_t)CAN_IER_FMPIE0) /*!< FIFO 0 message pending interrupt */ | |||
| #define CAN_IT_FF0 ((uint32_t)CAN_IER_FFIE0) /*!< FIFO 0 full interrupt */ | |||
| #define CAN_IT_FOV0 ((uint32_t)CAN_IER_FOVIE0) /*!< FIFO 0 overrun interrupt */ | |||
| #define CAN_IT_FMP1 ((uint32_t)CAN_IER_FMPIE1) /*!< FIFO 1 message pending interrupt */ | |||
| #define CAN_IT_FF1 ((uint32_t)CAN_IER_FFIE1) /*!< FIFO 1 full interrupt */ | |||
| #define CAN_IT_FOV1 ((uint32_t)CAN_IER_FOVIE1) /*!< FIFO 1 overrun interrupt */ | |||
| /* Operating Mode Interrupts */ | |||
| #define CAN_IT_WKU ((uint32_t)CAN_IER_WKUIE) /*!< Wake-up interrupt */ | |||
| #define CAN_IT_SLK ((uint32_t)CAN_IER_SLKIE) /*!< Sleep acknowledge interrupt */ | |||
| /* Error Interrupts */ | |||
| #define CAN_IT_EWG ((uint32_t)CAN_IER_EWGIE) /*!< Error warning interrupt */ | |||
| #define CAN_IT_EPV ((uint32_t)CAN_IER_EPVIE) /*!< Error passive interrupt */ | |||
| #define CAN_IT_BOF ((uint32_t)CAN_IER_BOFIE) /*!< Bus-off interrupt */ | |||
| #define CAN_IT_LEC ((uint32_t)CAN_IER_LECIE) /*!< Last error code interrupt */ | |||
| #define CAN_IT_ERR ((uint32_t)CAN_IER_ERRIE) /*!< Error Interrupt */ | |||
| /* Flags named as Interrupts : kept only for FW compatibility */ | |||
| #define CAN_IT_RQCP0 CAN_IT_TME | |||
| #define CAN_IT_RQCP1 CAN_IT_TME | |||
| #define CAN_IT_RQCP2 CAN_IT_TME | |||
| #define IS_CAN_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FMP0) ||\ | |||
| ((IT) == CAN_IT_FF0) || ((IT) == CAN_IT_FOV0) ||\ | |||
| ((IT) == CAN_IT_FMP1) || ((IT) == CAN_IT_FF1) ||\ | |||
| ((IT) == CAN_IT_FOV1) || ((IT) == CAN_IT_EWG) ||\ | |||
| ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\ | |||
| ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\ | |||
| ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK)) | |||
| #define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FF0) ||\ | |||
| ((IT) == CAN_IT_FOV0)|| ((IT) == CAN_IT_FF1) ||\ | |||
| ((IT) == CAN_IT_FOV1)|| ((IT) == CAN_IT_EWG) ||\ | |||
| ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\ | |||
| ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\ | |||
| ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Time out for INAK bit */ | |||
| #define INAK_TIMEOUT ((uint32_t)0x0000FFFF) | |||
| /* Time out for SLAK bit */ | |||
| #define SLAK_TIMEOUT ((uint32_t)0x0000FFFF) | |||
| /* Mailboxes definition */ | |||
| #define CAN_TXMAILBOX_0 ((uint8_t)0x00) | |||
| #define CAN_TXMAILBOX_1 ((uint8_t)0x01) | |||
| #define CAN_TXMAILBOX_2 ((uint8_t)0x02) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset CAN handle state | |||
| * @param __HANDLE__: specifies the CAN Handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CAN_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CAN_STATE_RESET) | |||
| /** | |||
| * @brief Enable the specified CAN interrupts. | |||
| * @param __HANDLE__: CAN handle | |||
| * @param __INTERRUPT__: CAN Interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CAN_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the specified CAN interrupts. | |||
| * @param __HANDLE__: CAN handle | |||
| * @param __INTERRUPT__: CAN Interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CAN_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) &= ~(__INTERRUPT__)) | |||
| /** | |||
| * @brief Return the number of pending received messages. | |||
| * @param __HANDLE__: CAN handle | |||
| * @param __FIFONUMBER__: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1. | |||
| * @retval The number of pending message. | |||
| */ | |||
| #define __HAL_CAN_MSG_PENDING(__HANDLE__, __FIFONUMBER__) (((__FIFONUMBER__) == CAN_FIFO0)? \ | |||
| ((uint8_t)((__HANDLE__)->Instance->RF0R&(uint32_t)0x03)) : ((uint8_t)((__HANDLE__)->Instance->RF1R&(uint32_t)0x03))) | |||
| /** @brief Check whether the specified CAN flag is set or not. | |||
| * @param __HANDLE__: CAN Handle | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg CAN_TSR_RQCP0: Request MailBox0 Flag | |||
| * @arg CAN_TSR_RQCP1: Request MailBox1 Flag | |||
| * @arg CAN_TSR_RQCP2: Request MailBox2 Flag | |||
| * @arg CAN_FLAG_TXOK0: Transmission OK MailBox0 Flag | |||
| * @arg CAN_FLAG_TXOK1: Transmission OK MailBox1 Flag | |||
| * @arg CAN_FLAG_TXOK2: Transmission OK MailBox2 Flag | |||
| * @arg CAN_FLAG_TME0: Transmit mailbox 0 empty Flag | |||
| * @arg CAN_FLAG_TME1: Transmit mailbox 1 empty Flag | |||
| * @arg CAN_FLAG_TME2: Transmit mailbox 2 empty Flag | |||
| * @arg CAN_FLAG_FMP0: FIFO 0 Message Pending Flag | |||
| * @arg CAN_FLAG_FF0: FIFO 0 Full Flag | |||
| * @arg CAN_FLAG_FOV0: FIFO 0 Overrun Flag | |||
| * @arg CAN_FLAG_FMP1: FIFO 1 Message Pending Flag | |||
| * @arg CAN_FLAG_FF1: FIFO 1 Full Flag | |||
| * @arg CAN_FLAG_FOV1: FIFO 1 Overrun Flag | |||
| * @arg CAN_FLAG_WKU: Wake up Flag | |||
| * @arg CAN_FLAG_SLAK: Sleep acknowledge Flag | |||
| * @arg CAN_FLAG_SLAKI: Sleep acknowledge Flag | |||
| * @arg CAN_FLAG_EWG: Error Warning Flag | |||
| * @arg CAN_FLAG_EPV: Error Passive Flag | |||
| * @arg CAN_FLAG_BOF: Bus-Off Flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define CAN_FLAG_MASK ((uint32_t)0x000000FF) | |||
| #define __HAL_CAN_GET_FLAG(__HANDLE__, __FLAG__) \ | |||
| ((((__FLAG__) >> 8) == 5)? ((((__HANDLE__)->Instance->TSR) & (1 << ((__FLAG__) & CAN_FLAG_MASK))) == (1 << ((__FLAG__) & CAN_FLAG_MASK))): \ | |||
| (((__FLAG__) >> 8) == 2)? ((((__HANDLE__)->Instance->RF0R) & (1 << ((__FLAG__) & CAN_FLAG_MASK))) == (1 << ((__FLAG__) & CAN_FLAG_MASK))): \ | |||
| (((__FLAG__) >> 8) == 4)? ((((__HANDLE__)->Instance->RF1R) & (1 << ((__FLAG__) & CAN_FLAG_MASK))) == (1 << ((__FLAG__) & CAN_FLAG_MASK))): \ | |||
| (((__FLAG__) >> 8) == 1)? ((((__HANDLE__)->Instance->MSR) & (1 << ((__FLAG__) & CAN_FLAG_MASK))) == (1 << ((__FLAG__) & CAN_FLAG_MASK))): \ | |||
| ((((__HANDLE__)->Instance->ESR) & (1 << ((__FLAG__) & CAN_FLAG_MASK))) == (1 << ((__FLAG__) & CAN_FLAG_MASK)))) | |||
| /** @brief Clear the specified CAN pending flag. | |||
| * @param __HANDLE__: CAN Handle. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg CAN_TSR_RQCP0: Request MailBox0 Flag | |||
| * @arg CAN_TSR_RQCP1: Request MailBox1 Flag | |||
| * @arg CAN_TSR_RQCP2: Request MailBox2 Flag | |||
| * @arg CAN_FLAG_TXOK0: Transmission OK MailBox0 Flag | |||
| * @arg CAN_FLAG_TXOK1: Transmission OK MailBox1 Flag | |||
| * @arg CAN_FLAG_TXOK2: Transmission OK MailBox2 Flag | |||
| * @arg CAN_FLAG_TME0: Transmit mailbox 0 empty Flag | |||
| * @arg CAN_FLAG_TME1: Transmit mailbox 1 empty Flag | |||
| * @arg CAN_FLAG_TME2: Transmit mailbox 2 empty Flag | |||
| * @arg CAN_FLAG_FMP0: FIFO 0 Message Pending Flag | |||
| * @arg CAN_FLAG_FF0: FIFO 0 Full Flag | |||
| * @arg CAN_FLAG_FOV0: FIFO 0 Overrun Flag | |||
| * @arg CAN_FLAG_FMP1: FIFO 1 Message Pending Flag | |||
| * @arg CAN_FLAG_FF1: FIFO 1 Full Flag | |||
| * @arg CAN_FLAG_FOV1: FIFO 1 Overrun Flag | |||
| * @arg CAN_FLAG_WKU: Wake up Flag | |||
| * @arg CAN_FLAG_SLAK: Sleep acknowledge Flag | |||
| * @arg CAN_FLAG_SLAKI: Sleep acknowledge Flag | |||
| * @arg CAN_FLAG_EWG: Error Warning Flag | |||
| * @arg CAN_FLAG_EPV: Error Passive Flag | |||
| * @arg CAN_FLAG_BOF: Bus-Off Flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_CAN_CLEAR_FLAG(__HANDLE__, __FLAG__) \ | |||
| ((((__FLAG__) >> 8) == 5)? (((__HANDLE__)->Instance->TSR) = ~((uint32_t)1 << ((__FLAG__) & CAN_FLAG_MASK))): \ | |||
| (((__FLAG__) >> 8) == 2)? (((__HANDLE__)->Instance->RF0R) = ~((uint32_t)1 << ((__FLAG__) & CAN_FLAG_MASK))): \ | |||
| (((__FLAG__) >> 8) == 4)? (((__HANDLE__)->Instance->RF1R) = ~((uint32_t)1 << ((__FLAG__) & CAN_FLAG_MASK))): \ | |||
| (((__FLAG__) >> 8) == 1)? (((__HANDLE__)->Instance->MSR) = ~((uint32_t)1 << ((__FLAG__) & CAN_FLAG_MASK))): \ | |||
| (((__HANDLE__)->Instance->ESR) = ~((uint32_t)1 << ((__FLAG__) & CAN_FLAG_MASK)))) | |||
| /** @brief Check if the specified CAN interrupt source is enabled or disabled. | |||
| * @param __HANDLE__: CAN Handle | |||
| * @param __INTERRUPT__: specifies the CAN interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg CAN_IT_TME: Transmit mailbox empty interrupt enable | |||
| * @arg CAN_IT_FMP0: FIFO0 message pending interrupt enablev | |||
| * @arg CAN_IT_FMP1: FIFO1 message pending interrupt enable | |||
| * @retval The new state of __IT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_CAN_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
| /** | |||
| * @brief Check the transmission status of a CAN Frame. | |||
| * @param __HANDLE__: CAN Handle | |||
| * @param __TRANSMITMAILBOX__: the number of the mailbox that is used for transmission. | |||
| * @retval The new status of transmission (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_CAN_TRANSMIT_STATUS(__HANDLE__, __TRANSMITMAILBOX__)\ | |||
| (((__TRANSMITMAILBOX__) == CAN_TXMAILBOX_0)? ((((__HANDLE__)->Instance->TSR) & (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0)) == (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0)) :\ | |||
| ((__TRANSMITMAILBOX__) == CAN_TXMAILBOX_1)? ((((__HANDLE__)->Instance->TSR) & (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1)) == (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1)) :\ | |||
| ((((__HANDLE__)->Instance->TSR) & (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2)) == (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2))) | |||
| /** | |||
| * @brief Release the specified receive FIFO. | |||
| * @param __HANDLE__: CAN handle | |||
| * @param __FIFONUMBER__: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CAN_FIFO_RELEASE(__HANDLE__, __FIFONUMBER__) (((__FIFONUMBER__) == CAN_FIFO0)? \ | |||
| ((__HANDLE__)->Instance->RF0R |= CAN_RF0R_RFOM0) : ((__HANDLE__)->Instance->RF1R |= CAN_RF1R_RFOM1)) | |||
| /** | |||
| * @brief Cancel a transmit request. | |||
| * @param __HANDLE__: CAN Handle | |||
| * @param __TRANSMITMAILBOX__: the number of the mailbox that is used for transmission. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CAN_CANCEL_TRANSMIT(__HANDLE__, __TRANSMITMAILBOX__)\ | |||
| (((__TRANSMITMAILBOX__) == CAN_TXMAILBOX_0)? ((__HANDLE__)->Instance->TSR |= CAN_TSR_ABRQ0) :\ | |||
| ((__TRANSMITMAILBOX__) == CAN_TXMAILBOX_1)? ((__HANDLE__)->Instance->TSR |= CAN_TSR_ABRQ1) :\ | |||
| ((__HANDLE__)->Instance->TSR |= CAN_TSR_ABRQ2)) | |||
| /** | |||
| * @brief Enable or disable the DBG Freeze for CAN. | |||
| * @param __HANDLE__: CAN Handle | |||
| * @param __NEWSTATE__: new state of the CAN peripheral. | |||
| * This parameter can be: ENABLE (CAN reception/transmission is frozen | |||
| * during debug. Reception FIFOs can still be accessed/controlled normally) | |||
| * or DISABLE (CAN is working during debug). | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CAN_DBG_FREEZE(__HANDLE__, __NEWSTATE__) (((__NEWSTATE__) == ENABLE)? \ | |||
| ((__HANDLE__)->Instance->MCR |= CAN_MCR_DBF) : ((__HANDLE__)->Instance->MCR &= ~CAN_MCR_DBF)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions ***********************************/ | |||
| HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef* hcan); | |||
| HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef* hcan, CAN_FilterConfTypeDef* sFilterConfig); | |||
| HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef* hcan); | |||
| void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan); | |||
| void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan); | |||
| /* I/O operation functions ******************************************************/ | |||
| HAL_StatusTypeDef HAL_CAN_Transmit(CAN_HandleTypeDef *hcan, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CAN_Transmit_IT(CAN_HandleTypeDef *hcan); | |||
| HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef *hcan, uint8_t FIFONumber, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef *hcan, uint8_t FIFONumber); | |||
| HAL_StatusTypeDef HAL_CAN_Sleep(CAN_HandleTypeDef *hcan); | |||
| HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan); | |||
| /* Peripheral State functions ***************************************************/ | |||
| void HAL_CAN_IRQHandler(CAN_HandleTypeDef* hcan); | |||
| uint32_t HAL_CAN_GetError(CAN_HandleTypeDef *hcan); | |||
| HAL_CAN_StateTypeDef HAL_CAN_GetState(CAN_HandleTypeDef* hcan); | |||
| void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* hcan); | |||
| void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan); | |||
| void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_CAN_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,407 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_conf_template.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief HAL configuration template file. | |||
| * This file should be copied to the application folder and renamed | |||
| * to stm32f4xx_hal_conf.h. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_CONF_H | |||
| #define __STM32F4xx_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_CAN_MODULE_ENABLED | |||
| #define HAL_CRC_MODULE_ENABLED | |||
| #define HAL_CRYP_MODULE_ENABLED | |||
| #define HAL_DAC_MODULE_ENABLED | |||
| #define HAL_DCMI_MODULE_ENABLED | |||
| #define HAL_DMA_MODULE_ENABLED | |||
| #define HAL_DMA2D_MODULE_ENABLED | |||
| #define HAL_ETH_MODULE_ENABLED | |||
| #define HAL_FLASH_MODULE_ENABLED | |||
| #define HAL_NAND_MODULE_ENABLED | |||
| #define HAL_NOR_MODULE_ENABLED | |||
| #define HAL_PCCARD_MODULE_ENABLED | |||
| #define HAL_SRAM_MODULE_ENABLED | |||
| #define HAL_SDRAM_MODULE_ENABLED | |||
| #define HAL_HASH_MODULE_ENABLED | |||
| #define HAL_GPIO_MODULE_ENABLED | |||
| #define HAL_I2C_MODULE_ENABLED | |||
| #define HAL_I2S_MODULE_ENABLED | |||
| #define HAL_IWDG_MODULE_ENABLED | |||
| #define HAL_LTDC_MODULE_ENABLED | |||
| #define HAL_PWR_MODULE_ENABLED | |||
| #define HAL_RCC_MODULE_ENABLED | |||
| #define HAL_RNG_MODULE_ENABLED | |||
| #define HAL_RTC_MODULE_ENABLED | |||
| #define HAL_SAI_MODULE_ENABLED | |||
| #define HAL_SD_MODULE_ENABLED | |||
| #define HAL_SPI_MODULE_ENABLED | |||
| #define HAL_TIM_MODULE_ENABLED | |||
| #define HAL_UART_MODULE_ENABLED | |||
| #define HAL_USART_MODULE_ENABLED | |||
| #define HAL_IRDA_MODULE_ENABLED | |||
| #define HAL_SMARTCARD_MODULE_ENABLED | |||
| #define HAL_WWDG_MODULE_ENABLED | |||
| #define HAL_CORTEX_MODULE_ENABLED | |||
| #define HAL_PCD_MODULE_ENABLED | |||
| #define HAL_HCD_MODULE_ENABLED | |||
| /* ########################## HSE/HSI 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)25000000) /*!< Value of the External oscillator in Hz */ | |||
| #endif /* HSE_VALUE */ | |||
| #if !defined (HSE_STARTUP_TIMEOUT) | |||
| #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */ | |||
| #endif /* HSE_STARTUP_TIMEOUT */ | |||
| /** | |||
| * @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)16000000) /*!< Value of the Internal oscillator in Hz*/ | |||
| #endif /* HSI_VALUE */ | |||
| /** | |||
| * @brief Internal Low Speed oscillator (LSI) value. | |||
| */ | |||
| #if !defined (LSI_VALUE) | |||
| #define LSI_VALUE ((uint32_t)40000) | |||
| #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. | |||
| */ | |||
| #if !defined (LSE_VALUE) | |||
| #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */ | |||
| #endif /* LSE_VALUE */ | |||
| /** | |||
| * @brief External clock source for I2S peripheral | |||
| * This value is used by the I2S HAL module to compute the I2S clock source | |||
| * frequency, this source is inserted directly through I2S_CKIN pad. | |||
| */ | |||
| #if !defined (EXTERNAL_CLOCK_VALUE) | |||
| #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000) /*!< Value of the Internal oscillator in Hz*/ | |||
| #endif /* EXTERNAL_CLOCK_VALUE */ | |||
| /* 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)3300) /*!< Value of VDD in mv */ | |||
| #define TICK_INT_PRIORITY ((uint32_t)0x0F) /*!< tick interrupt priority */ | |||
| #define USE_RTOS 0 | |||
| #define PREFETCH_ENABLE 1 | |||
| #define INSTRUCTION_CACHE_ENABLE 1 | |||
| #define DATA_CACHE_ENABLE 1 | |||
| /* ########################## Assert Selection ############################## */ | |||
| /** | |||
| * @brief Uncomment the line below to expanse the "assert_param" macro in the | |||
| * HAL drivers code | |||
| */ | |||
| /* #define USE_FULL_ASSERT 1 */ | |||
| /* ################## Ethernet peripheral configuration ##################### */ | |||
| /* Section 1 : Ethernet peripheral configuration */ | |||
| /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ | |||
| #define MAC_ADDR0 2 | |||
| #define MAC_ADDR1 0 | |||
| #define MAC_ADDR2 0 | |||
| #define MAC_ADDR3 0 | |||
| #define MAC_ADDR4 0 | |||
| #define MAC_ADDR5 0 | |||
| /* Definition of the Ethernet driver buffers size and count */ | |||
| #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ | |||
| #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ | |||
| #define ETH_RXBUFNB ((uint32_t)4) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ | |||
| #define ETH_TXBUFNB ((uint32_t)4) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ | |||
| /* Section 2: PHY configuration section */ | |||
| /* DP83848 PHY Address*/ | |||
| #define DP83848_PHY_ADDRESS 0x01 | |||
| /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ | |||
| #define PHY_RESET_DELAY ((uint32_t)0x000000FF) | |||
| /* PHY Configuration delay */ | |||
| #define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF) | |||
| #define PHY_READ_TO ((uint32_t)0x0000FFFF) | |||
| #define PHY_WRITE_TO ((uint32_t)0x0000FFFF) | |||
| /* Section 3: Common PHY Registers */ | |||
| #define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */ | |||
| #define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */ | |||
| #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ | |||
| #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ | |||
| #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ | |||
| #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ | |||
| #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ | |||
| #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ | |||
| #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ | |||
| #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ | |||
| #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ | |||
| #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ | |||
| #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ | |||
| #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ | |||
| #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ | |||
| /* Section 4: Extended PHY Registers */ | |||
| #define PHY_SR ((uint16_t)0x10) /*!< PHY status register Offset */ | |||
| #define PHY_MICR ((uint16_t)0x11) /*!< MII Interrupt Control Register */ | |||
| #define PHY_MISR ((uint16_t)0x12) /*!< MII Interrupt Status and Misc. Control Register */ | |||
| #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ | |||
| #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ | |||
| #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ | |||
| #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ | |||
| #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ | |||
| #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ | |||
| #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| /** | |||
| * @brief Include module's header file | |||
| */ | |||
| #ifdef HAL_RCC_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_rcc.h" | |||
| #endif /* HAL_RCC_MODULE_ENABLED */ | |||
| #ifdef HAL_GPIO_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_gpio.h" | |||
| #endif /* HAL_GPIO_MODULE_ENABLED */ | |||
| #ifdef HAL_DMA_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_dma.h" | |||
| #endif /* HAL_DMA_MODULE_ENABLED */ | |||
| #ifdef HAL_CORTEX_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_cortex.h" | |||
| #endif /* HAL_CORTEX_MODULE_ENABLED */ | |||
| #ifdef HAL_ADC_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_adc.h" | |||
| #endif /* HAL_ADC_MODULE_ENABLED */ | |||
| #ifdef HAL_CAN_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_can.h" | |||
| #endif /* HAL_CAN_MODULE_ENABLED */ | |||
| #ifdef HAL_CRC_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_crc.h" | |||
| #endif /* HAL_CRC_MODULE_ENABLED */ | |||
| #ifdef HAL_CRYP_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_cryp.h" | |||
| #endif /* HAL_CRYP_MODULE_ENABLED */ | |||
| #ifdef HAL_DMA2D_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_dma2d.h" | |||
| #endif /* HAL_DMA2D_MODULE_ENABLED */ | |||
| #ifdef HAL_DAC_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_dac.h" | |||
| #endif /* HAL_DAC_MODULE_ENABLED */ | |||
| #ifdef HAL_DCMI_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_dcmi.h" | |||
| #endif /* HAL_DCMI_MODULE_ENABLED */ | |||
| #ifdef HAL_ETH_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_eth.h" | |||
| #endif /* HAL_ETH_MODULE_ENABLED */ | |||
| #ifdef HAL_FLASH_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_flash.h" | |||
| #endif /* HAL_FLASH_MODULE_ENABLED */ | |||
| #ifdef HAL_SRAM_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_sram.h" | |||
| #endif /* HAL_SRAM_MODULE_ENABLED */ | |||
| #ifdef HAL_NOR_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_nor.h" | |||
| #endif /* HAL_NOR_MODULE_ENABLED */ | |||
| #ifdef HAL_NAND_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_nand.h" | |||
| #endif /* HAL_NAND_MODULE_ENABLED */ | |||
| #ifdef HAL_PCCARD_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_pccard.h" | |||
| #endif /* HAL_PCCARD_MODULE_ENABLED */ | |||
| #ifdef HAL_SDRAM_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_sdram.h" | |||
| #endif /* HAL_SDRAM_MODULE_ENABLED */ | |||
| #ifdef HAL_HASH_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_hash.h" | |||
| #endif /* HAL_HASH_MODULE_ENABLED */ | |||
| #ifdef HAL_I2C_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_i2c.h" | |||
| #endif /* HAL_I2C_MODULE_ENABLED */ | |||
| #ifdef HAL_I2S_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_i2s.h" | |||
| #endif /* HAL_I2S_MODULE_ENABLED */ | |||
| #ifdef HAL_IWDG_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_iwdg.h" | |||
| #endif /* HAL_IWDG_MODULE_ENABLED */ | |||
| #ifdef HAL_LTDC_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_ltdc.h" | |||
| #endif /* HAL_LTDC_MODULE_ENABLED */ | |||
| #ifdef HAL_PWR_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_pwr.h" | |||
| #endif /* HAL_PWR_MODULE_ENABLED */ | |||
| #ifdef HAL_RNG_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_rng.h" | |||
| #endif /* HAL_RNG_MODULE_ENABLED */ | |||
| #ifdef HAL_RTC_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_rtc.h" | |||
| #endif /* HAL_RTC_MODULE_ENABLED */ | |||
| #ifdef HAL_SAI_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_sai.h" | |||
| #endif /* HAL_SAI_MODULE_ENABLED */ | |||
| #ifdef HAL_SD_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_sd.h" | |||
| #endif /* HAL_SD_MODULE_ENABLED */ | |||
| #ifdef HAL_SPI_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_spi.h" | |||
| #endif /* HAL_SPI_MODULE_ENABLED */ | |||
| #ifdef HAL_TIM_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_tim.h" | |||
| #endif /* HAL_TIM_MODULE_ENABLED */ | |||
| #ifdef HAL_UART_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_uart.h" | |||
| #endif /* HAL_UART_MODULE_ENABLED */ | |||
| #ifdef HAL_USART_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_usart.h" | |||
| #endif /* HAL_USART_MODULE_ENABLED */ | |||
| #ifdef HAL_IRDA_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_irda.h" | |||
| #endif /* HAL_IRDA_MODULE_ENABLED */ | |||
| #ifdef HAL_SMARTCARD_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_smartcard.h" | |||
| #endif /* HAL_SMARTCARD_MODULE_ENABLED */ | |||
| #ifdef HAL_WWDG_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_wwdg.h" | |||
| #endif /* HAL_WWDG_MODULE_ENABLED */ | |||
| #ifdef HAL_PCD_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_pcd.h" | |||
| #endif /* HAL_PCD_MODULE_ENABLED */ | |||
| #ifdef HAL_HCD_MODULE_ENABLED | |||
| #include "stm32f4xx_hal_hcd.h" | |||
| #endif /* HAL_HCD_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)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) | |||
| /* Exported functions ------------------------------------------------------- */ | |||
| void assert_failed(uint8_t* file, uint32_t line); | |||
| #else | |||
| #define assert_param(expr) ((void)0) | |||
| #endif /* USE_FULL_ASSERT */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_CONF_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,163 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_cortex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of CORTEX HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_CORTEX_H | |||
| #define __STM32F4xx_HAL_CORTEX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup CORTEX | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup CORTEX_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup CORTEX_Preemption_Priority_Group | |||
| * @{ | |||
| */ | |||
| #define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bits for pre-emption priority | |||
| 4 bits for subpriority */ | |||
| #define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bits 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 bits for subpriority */ | |||
| #define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority | |||
| 0 bits for subpriority */ | |||
| #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PRIORITYGROUP_0) || \ | |||
| ((GROUP) == NVIC_PRIORITYGROUP_1) || \ | |||
| ((GROUP) == NVIC_PRIORITYGROUP_2) || \ | |||
| ((GROUP) == NVIC_PRIORITYGROUP_3) || \ | |||
| ((GROUP) == NVIC_PRIORITYGROUP_4)) | |||
| #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) | |||
| #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CORTEX_SysTick_clock_source | |||
| * @{ | |||
| */ | |||
| #define SYSTICK_CLKSOURCE_HCLK_DIV8 ((uint32_t)0x00000000) | |||
| #define SYSTICK_CLKSOURCE_HCLK ((uint32_t)0x00000004) | |||
| #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \ | |||
| ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported Macros -----------------------------------------------------------*/ | |||
| /** @brief Configures the SysTick clock source. | |||
| * @param __CLKSRC__: 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 | |||
| */ | |||
| #define __HAL_CORTEX_SYSTICKCLK_CONFIG(__CLKSRC__) \ | |||
| do { \ | |||
| if ((__CLKSRC__) == SYSTICK_CLKSOURCE_HCLK) \ | |||
| { \ | |||
| SysTick->CTRL |= SYSTICK_CLKSOURCE_HCLK; \ | |||
| } \ | |||
| else \ | |||
| SysTick->CTRL &= ~SYSTICK_CLKSOURCE_HCLK; \ | |||
| } while(0) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization and de-initialization functions *******************************/ | |||
| void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup); | |||
| 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); | |||
| /* Peripheral Control functions *************************************************/ | |||
| uint32_t HAL_NVIC_GetPriorityGrouping(void); | |||
| void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority); | |||
| uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn); | |||
| void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn); | |||
| void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn); | |||
| uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn); | |||
| void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource); | |||
| void HAL_SYSTICK_IRQHandler(void); | |||
| void HAL_SYSTICK_Callback(void); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_CORTEX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,145 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_crc.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of CRC HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_CRC_H | |||
| #define __STM32F4xx_HAL_CRC_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup CRC | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief CRC HAL State Structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_CRC_STATE_RESET = 0x00, /*!< CRC not yet initialized or disabled */ | |||
| HAL_CRC_STATE_READY = 0x01, /*!< CRC initialized and ready for use */ | |||
| HAL_CRC_STATE_BUSY = 0x02, /*!< CRC internal process is ongoing */ | |||
| HAL_CRC_STATE_TIMEOUT = 0x03, /*!< CRC timeout state */ | |||
| HAL_CRC_STATE_ERROR = 0x04 /*!< CRC error state */ | |||
| }HAL_CRC_StateTypeDef; | |||
| /** | |||
| * @brief CRC handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| CRC_TypeDef *Instance; /*!< Register base address */ | |||
| HAL_LockTypeDef Lock; /*!< CRC locking object */ | |||
| __IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */ | |||
| }CRC_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset CRC handle state | |||
| * @param __HANDLE__: CRC handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET) | |||
| /** | |||
| * @brief Resets CRC Data Register. | |||
| * @param __HANDLE__: CRC handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET) | |||
| /** | |||
| * @brief Stores a 8-bit data in the Independent Data(ID) register. | |||
| * @param __HANDLE__: CRC handle | |||
| * @param __VALUE: 8-bit value to be stored in the ID register | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (MODIFY_REG((__HANDLE__)->Instance->IDR, CRC_IDR_IDR, (__VALUE__)) | |||
| /** | |||
| * @brief Returns the 8-bit data stored in the Independent Data(ID) register. | |||
| * @param __HANDLE__: CRC handle | |||
| * @retval 8-bit value of the ID register | |||
| */ | |||
| #define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc); | |||
| HAL_StatusTypeDef HAL_CRC_DeInit (CRC_HandleTypeDef *hcrc); | |||
| void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc); | |||
| void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc); | |||
| /* Peripheral Control functions ************************************************/ | |||
| uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); | |||
| uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); | |||
| /* Peripheral State functions **************************************************/ | |||
| HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_CRC_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,403 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_cryp.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of CRYP HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_CRYP_H | |||
| #define __STM32F4xx_HAL_CRYP_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F437xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup CRYP | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief CRYP Configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. | |||
| This parameter can be a value of @ref CRYP_Data_Type */ | |||
| uint32_t KeySize; /*!< Used only in AES mode only : 128, 192 or 256 bit key length. | |||
| This parameter can be a value of @ref CRYP_Key_Size */ | |||
| uint8_t* pKey; /*!< The key used for encryption/decryption */ | |||
| uint8_t* pInitVect; /*!< The initialization vector used also as initialization | |||
| counter in CTR mode */ | |||
| uint8_t IVSize; /*!< The size of initialization vector. | |||
| This parameter (called nonce size in CCM) is used only | |||
| in AES-128/192/256 encryption/decryption CCM mode */ | |||
| uint8_t TagSize; /*!< The size of returned authentication TAG. | |||
| This parameter is used only in AES-128/192/256 | |||
| encryption/decryption CCM mode */ | |||
| uint8_t* Header; /*!< The header used in GCM and CCM modes */ | |||
| uint16_t HeaderSize; /*!< The size of header buffer in bytes */ | |||
| uint8_t* pScratch; /*!< Scratch buffer used to append the header. It's size must be equal to header size + 21 bytes. | |||
| This parameter is used only in AES-128/192/256 encryption/decryption CCM mode */ | |||
| }CRYP_InitTypeDef; | |||
| /** | |||
| * @brief HAL CRYP State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_CRYP_STATE_RESET = 0x00, /*!< CRYP not yet initialized or disabled */ | |||
| HAL_CRYP_STATE_READY = 0x01, /*!< CRYP initialized and ready for use */ | |||
| HAL_CRYP_STATE_BUSY = 0x02, /*!< CRYP internal processing is ongoing */ | |||
| HAL_CRYP_STATE_TIMEOUT = 0x03, /*!< CRYP timeout state */ | |||
| HAL_CRYP_STATE_ERROR = 0x04 /*!< CRYP error state */ | |||
| }HAL_CRYP_STATETypeDef; | |||
| /** | |||
| * @brief HAL CRYP phase structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_CRYP_PHASE_READY = 0x01, /*!< CRYP peripheral is ready for initialization. */ | |||
| HAL_CRYP_PHASE_PROCESS = 0x02, /*!< CRYP peripheral is in processing phase */ | |||
| HAL_CRYP_PHASE_FINAL = 0x03 /*!< CRYP peripheral is in final phase | |||
| This is relevant only with CCM and GCM modes */ | |||
| }HAL_PhaseTypeDef; | |||
| /** | |||
| * @brief CRYP handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| CRYP_InitTypeDef Init; /*!< CRYP required parameters */ | |||
| uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ | |||
| uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ | |||
| __IO uint16_t CrypInCount; /*!< Counter of inputed data */ | |||
| __IO uint16_t CrypOutCount; /*!< Counter of outputed data */ | |||
| HAL_StatusTypeDef Status; /*!< CRYP peripheral status */ | |||
| HAL_PhaseTypeDef Phase; /*!< CRYP peripheral phase */ | |||
| DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */ | |||
| DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */ | |||
| HAL_LockTypeDef Lock; /*!< CRYP locking object */ | |||
| __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ | |||
| }CRYP_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup CRYP_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup CRYP_Key_Size | |||
| * @{ | |||
| */ | |||
| #define CRYP_KEYSIZE_128B ((uint32_t)0x00000000) | |||
| #define CRYP_KEYSIZE_192B CRYP_CR_KEYSIZE_0 | |||
| #define CRYP_KEYSIZE_256B CRYP_CR_KEYSIZE_1 | |||
| #define IS_CRYP_KEYSIZE(KEYSIZE) (((KEYSIZE) == CRYP_KEYSIZE_128B) || \ | |||
| ((KEYSIZE) == CRYP_KEYSIZE_192B) || \ | |||
| ((KEYSIZE) == CRYP_KEYSIZE_256B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CRYP_Data_Type | |||
| * @{ | |||
| */ | |||
| #define CRYP_DATATYPE_32B ((uint32_t)0x00000000) | |||
| #define CRYP_DATATYPE_16B CRYP_CR_DATATYPE_0 | |||
| #define CRYP_DATATYPE_8B CRYP_CR_DATATYPE_1 | |||
| #define CRYP_DATATYPE_1B CRYP_CR_DATATYPE | |||
| #define IS_CRYP_DATATYPE(DATATYPE) (((DATATYPE) == CRYP_DATATYPE_32B) || \ | |||
| ((DATATYPE) == CRYP_DATATYPE_16B) || \ | |||
| ((DATATYPE) == CRYP_DATATYPE_8B) || \ | |||
| ((DATATYPE) == CRYP_DATATYPE_1B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CRYP_AlgoModeDirection | |||
| * @{ | |||
| */ | |||
| #define CRYP_CR_ALGOMODE_DIRECTION ((uint32_t)0x0008003C) | |||
| #define CRYP_CR_ALGOMODE_TDES_ECB_ENCRYPT ((uint32_t)0x00000000) | |||
| #define CRYP_CR_ALGOMODE_TDES_ECB_DECRYPT ((uint32_t)0x00000004) | |||
| #define CRYP_CR_ALGOMODE_TDES_CBC_ENCRYPT ((uint32_t)0x00000008) | |||
| #define CRYP_CR_ALGOMODE_TDES_CBC_DECRYPT ((uint32_t)0x0000000C) | |||
| #define CRYP_CR_ALGOMODE_DES_ECB_ENCRYPT ((uint32_t)0x00000010) | |||
| #define CRYP_CR_ALGOMODE_DES_ECB_DECRYPT ((uint32_t)0x00000014) | |||
| #define CRYP_CR_ALGOMODE_DES_CBC_ENCRYPT ((uint32_t)0x00000018) | |||
| #define CRYP_CR_ALGOMODE_DES_CBC_DECRYPT ((uint32_t)0x0000001C) | |||
| #define CRYP_CR_ALGOMODE_AES_ECB_ENCRYPT ((uint32_t)0x00000020) | |||
| #define CRYP_CR_ALGOMODE_AES_ECB_DECRYPT ((uint32_t)0x00000024) | |||
| #define CRYP_CR_ALGOMODE_AES_CBC_ENCRYPT ((uint32_t)0x00000028) | |||
| #define CRYP_CR_ALGOMODE_AES_CBC_DECRYPT ((uint32_t)0x0000002C) | |||
| #define CRYP_CR_ALGOMODE_AES_CTR_ENCRYPT ((uint32_t)0x00000030) | |||
| #define CRYP_CR_ALGOMODE_AES_CTR_DECRYPT ((uint32_t)0x00000034) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CRYP_Interrupt | |||
| * @{ | |||
| */ | |||
| #define CRYP_IT_INI ((uint32_t)CRYP_IMSCR_INIM) /*!< Input FIFO Interrupt */ | |||
| #define CRYP_IT_OUTI ((uint32_t)CRYP_IMSCR_OUTIM) /*!< Output FIFO Interrupt */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CRYP_Flags | |||
| * @{ | |||
| */ | |||
| #define CRYP_FLAG_BUSY ((uint32_t)0x00000010) /*!< The CRYP core is currently | |||
| processing a block of data | |||
| or a key preparation (for | |||
| AES decryption). */ | |||
| #define CRYP_FLAG_IFEM ((uint32_t)0x00000001) /*!< Input FIFO is empty */ | |||
| #define CRYP_FLAG_IFNF ((uint32_t)0x00000002) /*!< Input FIFO is not Full */ | |||
| #define CRYP_FLAG_OFNE ((uint32_t)0x00000004) /*!< Output FIFO is not empty */ | |||
| #define CRYP_FLAG_OFFU ((uint32_t)0x00000008) /*!< Output FIFO is Full */ | |||
| #define CRYP_FLAG_OUTRIS ((uint32_t)0x01000002) /*!< Output FIFO service raw | |||
| interrupt status */ | |||
| #define CRYP_FLAG_INRIS ((uint32_t)0x01000001) /*!< Input FIFO service raw | |||
| interrupt status */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset CRYP handle state | |||
| * @param __HANDLE__: specifies the CRYP handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET) | |||
| /** | |||
| * @brief Enable/Disable the CRYP peripheral. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRYP_ENABLE() (CRYP->CR |= CRYP_CR_CRYPEN) | |||
| #define __HAL_CRYP_DISABLE() (CRYP->CR &= ~CRYP_CR_CRYPEN) | |||
| /** | |||
| * @brief Flush the data FIFO. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRYP_FIFO_FLUSH() (CRYP->CR |= CRYP_CR_FFLUSH) | |||
| /** | |||
| * @brief Set the algorithm mode: AES-ECB, AES-CBC, AES-CTR, DES-ECB, DES-CBC. | |||
| * @param MODE: The algorithm mode. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRYP_SET_MODE(MODE) CRYP->CR |= (uint32_t)(MODE) | |||
| /** @brief Check whether the specified CRYP flag is set or not. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg CRYP_FLAG_BUSY: The CRYP core is currently processing a block of data | |||
| * or a key preparation (for AES decryption). | |||
| * @arg CRYP_FLAG_IFEM: Input FIFO is empty | |||
| * @arg CRYP_FLAG_IFNF: Input FIFO is not full | |||
| * @arg CRYP_FLAG_INRIS: Input FIFO service raw interrupt is pending | |||
| * @arg CRYP_FLAG_OFNE: Output FIFO is not empty | |||
| * @arg CRYP_FLAG_OFFU: Output FIFO is full | |||
| * @arg CRYP_FLAG_OUTRIS: Input FIFO service raw interrupt is pending | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define CRYP_FLAG_MASK ((uint32_t)0x0000001F) | |||
| #define __HAL_CRYP_GET_FLAG(__FLAG__) ((((uint8_t)((__FLAG__) >> 24)) == 0x01)?(((CRYP->RISR) & ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK)): \ | |||
| (((CRYP->RISR) & ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK))) | |||
| /** @brief Check whether the specified CRYP interrupt is set or not. | |||
| * @param __INTERRUPT__: specifies the interrupt to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg CRYP_IT_INRIS: Input FIFO service raw interrupt is pending | |||
| * @arg CRYP_IT_OUTRIS: Output FIFO service raw interrupt is pending | |||
| * @retval The new state of __INTERRUPT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_CRYP_GET_IT(__INTERRUPT__) ((CRYP->MISR & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
| /** | |||
| * @brief Enable the CRYP interrupt. | |||
| * @param __INTERRUPT__: CRYP Interrupt. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRYP_ENABLE_IT(__INTERRUPT__) ((CRYP->IMSCR) |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the CRYP interrupt. | |||
| * @param __INTERRUPT__: CRYP interrupt. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRYP_DISABLE_IT(__INTERRUPT__) ((CRYP->IMSCR) &= ~(__INTERRUPT__)) | |||
| /* Include CRYP HAL Extension module */ | |||
| #include "stm32f4xx_hal_cryp_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions ********************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); | |||
| HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); | |||
| /* AES encryption/decryption using polling ***********************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); | |||
| /* AES encryption/decryption using interrupt *********************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| /* AES encryption/decryption using DMA ***************************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| /* DES encryption/decryption using polling ***********************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| /* DES encryption/decryption using interrupt *********************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| /* DES encryption/decryption using DMA ***************************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| /* TDES encryption/decryption using polling **********************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); | |||
| /* TDES encryption/decryption using interrupt ********************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| /* TDES encryption/decryption using DMA **************************************/ | |||
| HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| /* Processing functions ******************************************************/ | |||
| void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); | |||
| /* Peripheral State functions ************************************************/ | |||
| HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); | |||
| /* MSP functions *************************************************************/ | |||
| void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); | |||
| void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); | |||
| /* CallBack functions ********************************************************/ | |||
| void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); | |||
| void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); | |||
| void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); | |||
| #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_CRYP_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,146 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_cryp_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of CRYP HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_CRYP_EX_H | |||
| #define __STM32F4xx_HAL_CRYP_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F437xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup CRYPEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup CRYPEx_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup CRYPEx_AlgoModeDirection | |||
| * @{ | |||
| */ | |||
| #define CRYP_CR_ALGOMODE_AES_GCM_ENCRYPT ((uint32_t)0x00080000) | |||
| #define CRYP_CR_ALGOMODE_AES_GCM_DECRYPT ((uint32_t)0x00080004) | |||
| #define CRYP_CR_ALGOMODE_AES_CCM_ENCRYPT ((uint32_t)0x00080008) | |||
| #define CRYP_CR_ALGOMODE_AES_CCM_DECRYPT ((uint32_t)0x0008000C) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CRYPEx_PhaseConfig | |||
| * The phases are relevant only to AES-GCM and AES-CCM | |||
| * @{ | |||
| */ | |||
| #define CRYP_PHASE_INIT ((uint32_t)0x00000000) | |||
| #define CRYP_PHASE_HEADER CRYP_CR_GCM_CCMPH_0 | |||
| #define CRYP_PHASE_PAYLOAD CRYP_CR_GCM_CCMPH_1 | |||
| #define CRYP_PHASE_FINAL CRYP_CR_GCM_CCMPH | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief Set the phase: Init, header, payload, final. | |||
| * This is relevant only for GCM and CCM modes. | |||
| * @param PHASE: The phase. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_CRYP_SET_PHASE(PHASE) do{CRYP->CR &= (uint32_t)(~CRYP_CR_GCM_CCMPH);\ | |||
| CRYP->CR |= (uint32_t)(PHASE);\ | |||
| }while(0) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* AES encryption/decryption using polling ***********************************/ | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Finish(CRYP_HandleTypeDef *hcryp, uint16_t Size, uint8_t *AuthTag, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Finish(CRYP_HandleTypeDef *hcryp, uint8_t *AuthTag, uint32_t Timeout); | |||
| /* AES encryption/decryption using interrupt *********************************/ | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| /* AES encryption/decryption using DMA ***************************************/ | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESGCM_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); | |||
| HAL_StatusTypeDef HAL_CRYPEx_AESCCM_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); | |||
| /* Processing functions ********************************************************/ | |||
| void HAL_CRYPEx_GCMCCM_IRQHandler(CRYP_HandleTypeDef *hcryp); | |||
| #endif /* STM32F437xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_CRYP_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,331 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dac.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of DAC HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_DAC_H | |||
| #define __STM32F4xx_HAL_DAC_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup DAC | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_DAC_STATE_RESET = 0x00, /*!< DAC not yet initialized or disabled */ | |||
| HAL_DAC_STATE_READY = 0x01, /*!< DAC initialized and ready for use */ | |||
| HAL_DAC_STATE_BUSY = 0x02, /*!< DAC internal processing is ongoing */ | |||
| HAL_DAC_STATE_TIMEOUT = 0x03, /*!< DAC timeout state */ | |||
| HAL_DAC_STATE_ERROR = 0x04 /*!< DAC error state */ | |||
| }HAL_DAC_StateTypeDef; | |||
| /** | |||
| * @brief DAC handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| DAC_TypeDef *Instance; /*!< Register base address */ | |||
| __IO HAL_DAC_StateTypeDef State; /*!< DAC communication state */ | |||
| HAL_LockTypeDef Lock; /*!< DAC locking object */ | |||
| DMA_HandleTypeDef *DMA_Handle1; /*!< Pointer DMA handler for channel 1 */ | |||
| DMA_HandleTypeDef *DMA_Handle2; /*!< Pointer DMA handler for channel 2 */ | |||
| __IO uint32_t ErrorCode; /*!< DAC Error code */ | |||
| }DAC_HandleTypeDef; | |||
| /** | |||
| * @brief DAC Configuration regular Channel structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel. | |||
| This parameter can be a value of @ref DAC_trigger_selection */ | |||
| uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled. | |||
| This parameter can be a value of @ref DAC_output_buffer */ | |||
| }DAC_ChannelConfTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup DAC_Error_Code | |||
| * @{ | |||
| */ | |||
| #define HAL_DAC_ERROR_NONE 0x00 /*!< No error */ | |||
| #define HAL_DAC_ERROR_DMAUNDERRUNCH1 0x01 /*!< DAC channel1 DAM underrun error */ | |||
| #define HAL_DAC_ERROR_DMAUNDERRUNCH2 0x02 /*!< DAC channel2 DAM underrun error */ | |||
| #define HAL_DAC_ERROR_DMA 0x04 /*!< DMA error */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_trigger_selection | |||
| * @{ | |||
| */ | |||
| #define DAC_TRIGGER_NONE ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register | |||
| has been loaded, and not by external trigger */ | |||
| #define DAC_TRIGGER_T2_TRGO ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TEN1)) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */ | |||
| #define DAC_TRIGGER_T4_TRGO ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */ | |||
| #define DAC_TRIGGER_T5_TRGO ((uint32_t)(DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM5 TRGO selected as external conversion trigger for DAC channel */ | |||
| #define DAC_TRIGGER_T6_TRGO ((uint32_t)DAC_CR_TEN1) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */ | |||
| #define DAC_TRIGGER_T7_TRGO ((uint32_t)(DAC_CR_TSEL1_1 | DAC_CR_TEN1)) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */ | |||
| #define DAC_TRIGGER_T8_TRGO ((uint32_t)(DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel */ | |||
| #define DAC_TRIGGER_EXT_IT9 ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TEN1)) /*!< EXTI Line9 event selected as external conversion trigger for DAC channel */ | |||
| #define DAC_TRIGGER_SOFTWARE ((uint32_t)(DAC_CR_TSEL1 | DAC_CR_TEN1)) /*!< Conversion started by software trigger for DAC channel */ | |||
| #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \ | |||
| ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \ | |||
| ((TRIGGER) == DAC_TRIGGER_T8_TRGO) || \ | |||
| ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \ | |||
| ((TRIGGER) == DAC_TRIGGER_T5_TRGO) || \ | |||
| ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \ | |||
| ((TRIGGER) == DAC_TRIGGER_T4_TRGO) || \ | |||
| ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \ | |||
| ((TRIGGER) == DAC_TRIGGER_SOFTWARE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_output_buffer | |||
| * @{ | |||
| */ | |||
| #define DAC_OUTPUTBUFFER_ENABLE ((uint32_t)0x00000000) | |||
| #define DAC_OUTPUTBUFFER_DISABLE ((uint32_t)DAC_CR_BOFF1) | |||
| #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OUTPUTBUFFER_ENABLE) || \ | |||
| ((STATE) == DAC_OUTPUTBUFFER_DISABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_Channel_selection | |||
| * @{ | |||
| */ | |||
| #define DAC_CHANNEL_1 ((uint32_t)0x00000000) | |||
| #define DAC_CHANNEL_2 ((uint32_t)0x00000010) | |||
| #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_CHANNEL_1) || \ | |||
| ((CHANNEL) == DAC_CHANNEL_2)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_data_alignement | |||
| * @{ | |||
| */ | |||
| #define DAC_ALIGN_12B_R ((uint32_t)0x00000000) | |||
| #define DAC_ALIGN_12B_L ((uint32_t)0x00000004) | |||
| #define DAC_ALIGN_8B_R ((uint32_t)0x00000008) | |||
| #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_ALIGN_12B_R) || \ | |||
| ((ALIGN) == DAC_ALIGN_12B_L) || \ | |||
| ((ALIGN) == DAC_ALIGN_8B_R)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_data | |||
| * @{ | |||
| */ | |||
| #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_flags_definition | |||
| * @{ | |||
| */ | |||
| #define DAC_FLAG_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1) | |||
| #define DAC_FLAG_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2) | |||
| #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR1) || \ | |||
| ((FLAG) == DAC_FLAG_DMAUDR2)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_IT_definition | |||
| * @{ | |||
| */ | |||
| #define DAC_IT_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1) | |||
| #define DAC_IT_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2) | |||
| #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR1) || \ | |||
| ((IT) == DAC_IT_DMAUDR2)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset DAC handle state | |||
| * @param __HANDLE__: specifies the DAC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DAC_STATE_RESET) | |||
| /** @brief Enable the DAC channel | |||
| * @param __HANDLE__: specifies the DAC handle. | |||
| * @param __DAC_Channel__: specifies the DAC channel | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DAC_ENABLE(__HANDLE__, __DAC_Channel__) \ | |||
| ((__HANDLE__)->Instance->CR |= (DAC_CR_EN1 << (__DAC_Channel__))) | |||
| /** @brief Disable the DAC channel | |||
| * @param __HANDLE__: specifies the DAC handle | |||
| * @param __DAC_Channel__: specifies the DAC channel. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DAC_DISABLE(__HANDLE__, __DAC_Channel__) \ | |||
| ((__HANDLE__)->Instance->CR &= ~(DAC_CR_EN1 << (__DAC_Channel__))) | |||
| /** @brief Set DHR12R1 alignment | |||
| * @param __ALIGNEMENT__: specifies the DAC alignement | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DHR12R1_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000008) + (__ALIGNEMENT__)) | |||
| /** @brief Set DHR12R2 alignment | |||
| * @param __ALIGNEMENT__: specifies the DAC alignement | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DHR12R2_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000014) + (__ALIGNEMENT__)) | |||
| /** @brief Set DHR12RD alignment | |||
| * @param __ALIGNEMENT__: specifies the DAC alignement | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DHR12RD_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000020) + (__ALIGNEMENT__)) | |||
| /** @brief Enable the DAC interrupt | |||
| * @param __HANDLE__: specifies the DAC handle | |||
| * @param __INTERRUPT__: specifies the DAC interrupt. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__)) | |||
| /** @brief Disable the DAC interrupt | |||
| * @param __HANDLE__: specifies the DAC handle | |||
| * @param __INTERRUPT__: specifies the DAC interrupt. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__)) | |||
| /** @brief Get the selected DAC's flag status. | |||
| * @param __HANDLE__: specifies the DAC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DAC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clear the DAC's flag. | |||
| * @param __HANDLE__: specifies the DAC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DAC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = (__FLAG__)) | |||
| /* Include DAC HAL Extension module */ | |||
| #include "stm32f4xx_hal_dac_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions *********************************/ | |||
| HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac); | |||
| HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac); | |||
| void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac); | |||
| void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac); | |||
| /* I/O operation functions ****************************************************/ | |||
| HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel); | |||
| HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel); | |||
| HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment); | |||
| HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel); | |||
| uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel); | |||
| /* Peripheral Control functions ***********************************************/ | |||
| HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel); | |||
| HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data); | |||
| /* Peripheral State functions *************************************************/ | |||
| HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac); | |||
| void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac); | |||
| uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac); | |||
| void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac); | |||
| void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac); | |||
| void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac); | |||
| void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /*__STM32F4xx_HAL_DAC_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,183 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dac.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of DAC HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_DAC_EX_H | |||
| #define __STM32F4xx_HAL_DAC_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup DACEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup DACEx_wave_generation | |||
| * @{ | |||
| */ | |||
| #define DAC_WAVEGENERATION_NONE ((uint32_t)0x00000000) | |||
| #define DAC_WAVEGENERATION_NOISE ((uint32_t)DAC_CR_WAVE1_0) | |||
| #define DAC_WAVEGENERATION_TRIANGLE ((uint32_t)DAC_CR_WAVE1_1) | |||
| #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WAVEGENERATION_NONE) || \ | |||
| ((WAVE) == DAC_WAVEGENERATION_NOISE) || \ | |||
| ((WAVE) == DAC_WAVEGENERATION_TRIANGLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DACEx_lfsrunmask_triangleamplitude | |||
| * @{ | |||
| */ | |||
| #define DAC_LFSRUNMASK_BIT0 ((uint32_t)0x00000000) /*!< Unmask DAC channel LFSR bit0 for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS1_0 ((uint32_t)DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS2_0 ((uint32_t)DAC_CR_MAMP1_1) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS3_0 ((uint32_t)DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0)/*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS4_0 ((uint32_t)DAC_CR_MAMP1_2) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS5_0 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS6_0 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS7_0 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS8_0 ((uint32_t)DAC_CR_MAMP1_3) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS9_0 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS10_0 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */ | |||
| #define DAC_LFSRUNMASK_BITS11_0 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */ | |||
| #define DAC_TRIANGLEAMPLITUDE_1 ((uint32_t)0x00000000) /*!< Select max triangle amplitude of 1 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_3 ((uint32_t)DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 3 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_7 ((uint32_t)DAC_CR_MAMP1_1) /*!< Select max triangle amplitude of 7 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_15 ((uint32_t)DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 15 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_31 ((uint32_t)DAC_CR_MAMP1_2) /*!< Select max triangle amplitude of 31 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_63 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 63 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_127 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1) /*!< Select max triangle amplitude of 127 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_255 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 255 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_511 ((uint32_t)DAC_CR_MAMP1_3) /*!< Select max triangle amplitude of 511 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_1023 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 1023 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_2047 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1) /*!< Select max triangle amplitude of 2047 */ | |||
| #define DAC_TRIANGLEAMPLITUDE_4095 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 4095 */ | |||
| #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUNMASK_BIT0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS1_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS2_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS3_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS4_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS5_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS6_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS7_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS8_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS9_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS10_0) || \ | |||
| ((VALUE) == DAC_LFSRUNMASK_BITS11_0) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_1) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_3) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_7) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_15) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_31) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_63) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_127) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_255) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_511) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_1023) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_2047) || \ | |||
| ((VALUE) == DAC_TRIANGLEAMPLITUDE_4095)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DACEx_wave_generation | |||
| * @{ | |||
| */ | |||
| #define DAC_WAVE_NOISE ((uint32_t)DAC_CR_WAVE1_0) | |||
| #define DAC_WAVE_TRIANGLE ((uint32_t)DAC_CR_WAVE1_1) | |||
| #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_WAVE_NOISE) || \ | |||
| ((WAVE) == DAC_WAVE_TRIANGLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Extension features functions ***********************************************/ | |||
| uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac); | |||
| HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude); | |||
| HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude); | |||
| HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2); | |||
| void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac); | |||
| void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac); | |||
| void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef* hdac); | |||
| void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef* hdac); | |||
| void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma); | |||
| void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma); | |||
| void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /*__STM32F4xx_HAL_DAC_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,498 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dcmi.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of DCMI HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_DCMI_H | |||
| #define __STM32F4xx_HAL_DCMI_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup DCMI | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief DCMI Error source | |||
| */ | |||
| typedef enum | |||
| { | |||
| DCMI_ERROR_SYNC = 1, /*!< Synchronisation error */ | |||
| DCMI_OVERRUN = 2, /*!< DCMI Overrun */ | |||
| }DCMI_ErrorTypeDef; | |||
| /** | |||
| * @brief DCMI Embedded Synchronisation CODE Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint8_t FrameStartCode; /*!< Specifies the code of the frame start delimiter. */ | |||
| uint8_t LineStartCode; /*!< Specifies the code of the line start delimiter. */ | |||
| uint8_t LineEndCode; /*!< Specifies the code of the line end delimiter. */ | |||
| uint8_t FrameEndCode; /*!< Specifies the code of the frame end delimiter. */ | |||
| }DCMI_CodesInitTypeDef; | |||
| /** | |||
| * @brief DCMI Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t SynchroMode; /*!< Specifies the Synchronization Mode: Hardware or Embedded. | |||
| This parameter can be a value of @ref DCMI_Synchronization_Mode */ | |||
| uint32_t PCKPolarity; /*!< Specifies the Pixel clock polarity: Falling or Rising. | |||
| This parameter can be a value of @ref DCMI_PIXCK_Polarity */ | |||
| uint32_t VSPolarity; /*!< Specifies the Vertical synchronization polarity: High or Low. | |||
| This parameter can be a value of @ref DCMI_VSYNC_Polarity */ | |||
| uint32_t HSPolarity; /*!< Specifies the Horizontal synchronization polarity: High or Low. | |||
| This parameter can be a value of @ref DCMI_HSYNC_Polarity */ | |||
| uint32_t CaptureRate; /*!< Specifies the frequency of frame capture: All, 1/2 or 1/4. | |||
| This parameter can be a value of @ref DCMI_Capture_Rate */ | |||
| uint32_t ExtendedDataMode; /*!< Specifies the data width: 8-bit, 10-bit, 12-bit or 14-bit. | |||
| This parameter can be a value of @ref DCMI_Extended_Data_Mode */ | |||
| DCMI_CodesInitTypeDef SyncroCode; /*!< Specifies the code of the frame start delimiter. */ | |||
| uint32_t JPEGMode; /*!< Enable or Disable the JPEG mode. | |||
| This parameter can be a value of @ref DCMI_MODE_JPEG */ | |||
| }DCMI_InitTypeDef; | |||
| /** | |||
| * @brief HAL DCMI State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_DCMI_STATE_RESET = 0x00, /*!< DCMI not yet initialized or disabled */ | |||
| HAL_DCMI_STATE_READY = 0x01, /*!< DCMI initialized and ready for use */ | |||
| HAL_DCMI_STATE_BUSY = 0x02, /*!< DCMI internal processing is ongoing */ | |||
| HAL_DCMI_STATE_TIMEOUT = 0x03, /*!< DCMI timeout state */ | |||
| HAL_DCMI_STATE_ERROR = 0x04 /*!< DCMI error state */ | |||
| }HAL_DCMI_StateTypeDef; | |||
| /** | |||
| * @brief DCMI handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| DCMI_TypeDef *Instance; /*!< DCMI Register base address */ | |||
| DCMI_InitTypeDef Init; /*!< DCMI parameters */ | |||
| HAL_LockTypeDef Lock; /*!< DCMI locking object */ | |||
| __IO HAL_DCMI_StateTypeDef State; /*!< DCMI state */ | |||
| __IO uint32_t XferCount; /*!< DMA transfer counter */ | |||
| __IO uint32_t XferSize; /*!< DMA transfer size */ | |||
| uint32_t XferTransferNumber; /*!< DMA transfer number */ | |||
| uint32_t pBuffPtr; /*!< Pointer to DMA output buffer */ | |||
| DMA_HandleTypeDef *DMA_Handle; /*!< Pointer to the DMA handler */ | |||
| __IO uint32_t ErrorCode; /*!< DCMI Error code */ | |||
| }DCMI_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup DCMI_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup DCMI_Error_Code | |||
| * @{ | |||
| */ | |||
| #define HAL_DCMI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ | |||
| #define HAL_DCMI_ERROR_OVF ((uint32_t)0x00000001) /*!< Overflow error */ | |||
| #define HAL_DCMI_ERROR_SYNC ((uint32_t)0x00000002) /*!< Synchronization error */ | |||
| #define HAL_DCMI_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Capture_Mode | |||
| * @{ | |||
| */ | |||
| #define DCMI_MODE_CONTINUOUS ((uint32_t)0x00000000) /*!< The received data are transferred continuously | |||
| into the destination memory through the DMA */ | |||
| #define DCMI_MODE_SNAPSHOT ((uint32_t)DCMI_CR_CM) /*!< Once activated, the interface waits for the start of | |||
| frame and then transfers a single frame through the DMA */ | |||
| #define IS_DCMI_CAPTURE_MODE(MODE)(((MODE) == DCMI_MODE_CONTINUOUS) || \ | |||
| ((MODE) == DCMI_MODE_SNAPSHOT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Synchronization_Mode | |||
| * @{ | |||
| */ | |||
| #define DCMI_SYNCHRO_HARDWARE ((uint32_t)0x00000000) /*!< Hardware synchronization data capture (frame/line start/stop) | |||
| is synchronized with the HSYNC/VSYNC signals */ | |||
| #define DCMI_SYNCHRO_EMBEDDED ((uint32_t)DCMI_CR_ESS) /*!< Embedded synchronization data capture is synchronized with | |||
| synchronization codes embedded in the data flow */ | |||
| #define IS_DCMI_SYNCHRO(MODE)(((MODE) == DCMI_SYNCHRO_HARDWARE) || \ | |||
| ((MODE) == DCMI_SYNCHRO_EMBEDDED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_PIXCK_Polarity | |||
| * @{ | |||
| */ | |||
| #define DCMI_PCKPOLARITY_FALLING ((uint32_t)0x00000000) /*!< Pixel clock active on Falling edge */ | |||
| #define DCMI_PCKPOLARITY_RISING ((uint32_t)DCMI_CR_PCKPOL) /*!< Pixel clock active on Rising edge */ | |||
| #define IS_DCMI_PCKPOLARITY(POLARITY)(((POLARITY) == DCMI_PCKPOLARITY_FALLING) || \ | |||
| ((POLARITY) == DCMI_PCKPOLARITY_RISING)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_VSYNC_Polarity | |||
| * @{ | |||
| */ | |||
| #define DCMI_VSPOLARITY_LOW ((uint32_t)0x00000000) /*!< Vertical synchronization active Low */ | |||
| #define DCMI_VSPOLARITY_HIGH ((uint32_t)DCMI_CR_VSPOL) /*!< Vertical synchronization active High */ | |||
| #define IS_DCMI_VSPOLARITY(POLARITY)(((POLARITY) == DCMI_VSPOLARITY_LOW) || \ | |||
| ((POLARITY) == DCMI_VSPOLARITY_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_HSYNC_Polarity | |||
| * @{ | |||
| */ | |||
| #define DCMI_HSPOLARITY_LOW ((uint32_t)0x00000000) /*!< Horizontal synchronization active Low */ | |||
| #define DCMI_HSPOLARITY_HIGH ((uint32_t)DCMI_CR_HSPOL) /*!< Horizontal synchronization active High */ | |||
| #define IS_DCMI_HSPOLARITY(POLARITY)(((POLARITY) == DCMI_HSPOLARITY_LOW) || \ | |||
| ((POLARITY) == DCMI_HSPOLARITY_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_MODE_JPEG | |||
| * @{ | |||
| */ | |||
| #define DCMI_JPEG_DISABLE ((uint32_t)0x00000000) /*!< Mode JPEG Disabled */ | |||
| #define DCMI_JPEG_ENABLE ((uint32_t)DCMI_CR_JPEG) /*!< Mode JPEG Enabled */ | |||
| #define IS_DCMI_MODE_JPEG(JPEG_MODE)(((JPEG_MODE) == DCMI_JPEG_DISABLE) || \ | |||
| ((JPEG_MODE) == DCMI_JPEG_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Capture_Rate | |||
| * @{ | |||
| */ | |||
| #define DCMI_CR_ALL_FRAME ((uint32_t)0x00000000) /*!< All frames are captured */ | |||
| #define DCMI_CR_ALTERNATE_2_FRAME ((uint32_t)DCMI_CR_FCRC_0) /*!< Every alternate frame captured */ | |||
| #define DCMI_CR_ALTERNATE_4_FRAME ((uint32_t)DCMI_CR_FCRC_1) /*!< One frame in 4 frames captured */ | |||
| #define IS_DCMI_CAPTURE_RATE(RATE) (((RATE) == DCMI_CR_ALL_FRAME) || \ | |||
| ((RATE) == DCMI_CR_ALTERNATE_2_FRAME) || \ | |||
| ((RATE) == DCMI_CR_ALTERNATE_4_FRAME)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Extended_Data_Mode | |||
| * @{ | |||
| */ | |||
| #define DCMI_EXTEND_DATA_8B ((uint32_t)0x00000000) /*!< Interface captures 8-bit data on every pixel clock */ | |||
| #define DCMI_EXTEND_DATA_10B ((uint32_t)DCMI_CR_EDM_0) /*!< Interface captures 10-bit data on every pixel clock */ | |||
| #define DCMI_EXTEND_DATA_12B ((uint32_t)DCMI_CR_EDM_1) /*!< Interface captures 12-bit data on every pixel clock */ | |||
| #define DCMI_EXTEND_DATA_14B ((uint32_t)(DCMI_CR_EDM_0 | DCMI_CR_EDM_1)) /*!< Interface captures 14-bit data on every pixel clock */ | |||
| #define IS_DCMI_EXTENDED_DATA(DATA)(((DATA) == DCMI_EXTEND_DATA_8B) || \ | |||
| ((DATA) == DCMI_EXTEND_DATA_10B) || \ | |||
| ((DATA) == DCMI_EXTEND_DATA_12B) || \ | |||
| ((DATA) == DCMI_EXTEND_DATA_14B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Window_Coordinate | |||
| * @{ | |||
| */ | |||
| #define DCMI_WINDOW_COORDINATE ((uint32_t)0x3FFF) /*!< Window coordinate */ | |||
| #define IS_DCMI_WINDOW_COORDINATE(COORDINATE) ((COORDINATE) <= DCMI_WINDOW_COORDINATE) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Window_Height | |||
| * @{ | |||
| */ | |||
| #define DCMI_WINDOW_HEIGHT ((uint32_t)0x1FFF) /*!< Window Height */ | |||
| #define IS_DCMI_WINDOW_HEIGHT(HEIGHT) ((HEIGHT) <= DCMI_WINDOW_HEIGHT) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_interrupt_sources | |||
| * @{ | |||
| */ | |||
| #define DCMI_IT_FRAME ((uint32_t)DCMI_IER_FRAME_IE) | |||
| #define DCMI_IT_OVF ((uint32_t)DCMI_IER_OVF_IE) | |||
| #define DCMI_IT_ERR ((uint32_t)DCMI_IER_ERR_IE) | |||
| #define DCMI_IT_VSYNC ((uint32_t)DCMI_IER_VSYNC_IE) | |||
| #define DCMI_IT_LINE ((uint32_t)DCMI_IER_LINE_IE) | |||
| #define IS_DCMI_CONFIG_IT(IT) ((((IT) & (uint16_t)0xFFE0) == 0x0000) && ((IT) != 0x0000)) | |||
| #define IS_DCMI_GET_IT(IT) (((IT) == DCMI_IT_FRAME) || \ | |||
| ((IT) == DCMI_IT_OVF) || \ | |||
| ((IT) == DCMI_IT_ERR) || \ | |||
| ((IT) == DCMI_IT_VSYNC) || \ | |||
| ((IT) == DCMI_IT_LINE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Flags | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief DCMI SR register | |||
| */ | |||
| #define DCMI_FLAG_HSYNC ((uint32_t)0x2001) | |||
| #define DCMI_FLAG_VSYNC ((uint32_t)0x2002) | |||
| #define DCMI_FLAG_FNE ((uint32_t)0x2004) | |||
| /** | |||
| * @brief DCMI RISR register | |||
| */ | |||
| #define DCMI_FLAG_FRAMERI ((uint32_t)DCMI_RISR_FRAME_RIS) | |||
| #define DCMI_FLAG_OVFRI ((uint32_t)DCMI_RISR_OVF_RIS) | |||
| #define DCMI_FLAG_ERRRI ((uint32_t)DCMI_RISR_ERR_RIS) | |||
| #define DCMI_FLAG_VSYNCRI ((uint32_t)DCMI_RISR_VSYNC_RIS) | |||
| #define DCMI_FLAG_LINERI ((uint32_t)DCMI_RISR_LINE_RIS) | |||
| /** | |||
| * @brief DCMI MISR register | |||
| */ | |||
| #define DCMI_FLAG_FRAMEMI ((uint32_t)0x1001) | |||
| #define DCMI_FLAG_OVFMI ((uint32_t)0x1002) | |||
| #define DCMI_FLAG_ERRMI ((uint32_t)0x1004) | |||
| #define DCMI_FLAG_VSYNCMI ((uint32_t)0x1008) | |||
| #define DCMI_FLAG_LINEMI ((uint32_t)0x1010) | |||
| #define IS_DCMI_GET_FLAG(FLAG) (((FLAG) == DCMI_FLAG_HSYNC) || \ | |||
| ((FLAG) == DCMI_FLAG_VSYNC) || \ | |||
| ((FLAG) == DCMI_FLAG_FNE) || \ | |||
| ((FLAG) == DCMI_FLAG_FRAMERI) || \ | |||
| ((FLAG) == DCMI_FLAG_OVFRI) || \ | |||
| ((FLAG) == DCMI_FLAG_ERRRI) || \ | |||
| ((FLAG) == DCMI_FLAG_VSYNCRI) || \ | |||
| ((FLAG) == DCMI_FLAG_LINERI) || \ | |||
| ((FLAG) == DCMI_FLAG_FRAMEMI) || \ | |||
| ((FLAG) == DCMI_FLAG_OVFMI) || \ | |||
| ((FLAG) == DCMI_FLAG_ERRMI) || \ | |||
| ((FLAG) == DCMI_FLAG_VSYNCMI) || \ | |||
| ((FLAG) == DCMI_FLAG_LINEMI)) | |||
| #define IS_DCMI_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFE0) == 0x0000) && ((FLAG) != 0x0000)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset DCMI handle state | |||
| * @param __HANDLE__: specifies the DCMI handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DCMI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DCMI_STATE_RESET) | |||
| /** | |||
| * @brief Enable the DCMI. | |||
| * @param __HANDLE__: DCMI handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DCMI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DCMI_CR_ENABLE) | |||
| /** | |||
| * @brief Disable the DCMI. | |||
| * @param __HANDLE__: DCMI handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DCMI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(DCMI_CR_ENABLE)) | |||
| /* Interrupt & Flag management */ | |||
| /** | |||
| * @brief Get the DCMI pending flags. | |||
| * @param __HANDLE__: DCMI handle | |||
| * @param __FLAG__: Get the specified flag. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg DCMI_FLAG_FRAMERI: Frame capture complete flag mask | |||
| * @arg DCMI_FLAG_OVFRI: Overflow flag mask | |||
| * @arg DCMI_FLAG_ERRRI: Synchronization error flag mask | |||
| * @arg DCMI_FLAG_VSYNCRI: VSYNC flag mask | |||
| * @arg DCMI_FLAG_LINERI: Line flag mask | |||
| * @retval The state of FLAG. | |||
| */ | |||
| #define __HAL_DCMI_GET_FLAG(__HANDLE__, __FLAG__)\ | |||
| ((((__FLAG__) & 0x3000) == 0x0)? ((__HANDLE__)->Instance->RISR & (__FLAG__)) :\ | |||
| (((__FLAG__) & 0x2000) == 0x0)? ((__HANDLE__)->Instance->MISR & (__FLAG__)) : ((__HANDLE__)->Instance->SR & (__FLAG__))) | |||
| /** | |||
| * @brief Clear the DCMI pending flags. | |||
| * @param __HANDLE__: DCMI handle | |||
| * @param __FLAG__: specifies the flag to clear. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg DCMI_FLAG_FRAMERI: Frame capture complete flag mask | |||
| * @arg DCMI_FLAG_OVFRI: Overflow flag mask | |||
| * @arg DCMI_FLAG_ERRRI: Synchronization error flag mask | |||
| * @arg DCMI_FLAG_VSYNCRI: VSYNC flag mask | |||
| * @arg DCMI_FLAG_LINERI: Line flag mask | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DCMI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) | |||
| /** | |||
| * @brief Enable the specified DCMI interrupts. | |||
| * @param __HANDLE__: DCMI handle | |||
| * @param __INTERRUPT__: specifies the DCMI interrupt sources to be enabled. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask | |||
| * @arg DCMI_IT_OVF: Overflow interrupt mask | |||
| * @arg DCMI_IT_ERR: Synchronization error interrupt mask | |||
| * @arg DCMI_IT_VSYNC: VSYNC interrupt mask | |||
| * @arg DCMI_IT_LINE: Line interrupt mask | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DCMI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the specified DCMI interrupts. | |||
| * @param __HANDLE__: DCMI handle | |||
| * @param __INTERRUPT__: specifies the DCMI interrupt sources to be enabled. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask | |||
| * @arg DCMI_IT_OVF: Overflow interrupt mask | |||
| * @arg DCMI_IT_ERR: Synchronization error interrupt mask | |||
| * @arg DCMI_IT_VSYNC: VSYNC interrupt mask | |||
| * @arg DCMI_IT_LINE: Line interrupt mask | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DCMI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__)) | |||
| /** | |||
| * @brief Check whether the specified DCMI interrupt has occurred or not. | |||
| * @param __HANDLE__: DCMI handle | |||
| * @param __INTERRUPT__: specifies the DCMI interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask | |||
| * @arg DCMI_IT_OVF: Overflow interrupt mask | |||
| * @arg DCMI_IT_ERR: Synchronization error interrupt mask | |||
| * @arg DCMI_IT_VSYNC: VSYNC interrupt mask | |||
| * @arg DCMI_IT_LINE: Line interrupt mask | |||
| * @retval The state of INTERRUPT. | |||
| */ | |||
| #define __HAL_DCMI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MISR & (__INTERRUPT__)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization and de-initialization functions *****************************/ | |||
| HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi); | |||
| HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi); | |||
| void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi); | |||
| void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi); | |||
| /* IO operation functions *****************************************************/ | |||
| HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length); | |||
| HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi); | |||
| void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi); | |||
| void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi); | |||
| void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi); | |||
| void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi); | |||
| void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi); | |||
| /* Peripheral Control functions ***********************************************/ | |||
| HAL_StatusTypeDef HAL_DCMI_ConfigCROP(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize); | |||
| HAL_StatusTypeDef HAL_DCMI_EnableCROP(DCMI_HandleTypeDef *hdcmi); | |||
| HAL_StatusTypeDef HAL_DCMI_DisableCROP(DCMI_HandleTypeDef *hdcmi); | |||
| /* Peripheral State functions *************************************************/ | |||
| HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi); | |||
| uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_DCMI_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,198 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_def.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief This file contains HAL common defines, enumeration, macros and | |||
| * structures definitions. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_DEF | |||
| #define __STM32F4xx_HAL_DEF | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx.h" | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL Status structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_OK = 0x00, | |||
| HAL_ERROR = 0x01, | |||
| HAL_BUSY = 0x02, | |||
| HAL_TIMEOUT = 0x03 | |||
| } HAL_StatusTypeDef; | |||
| /** | |||
| * @brief HAL Lock structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_UNLOCKED = 0x00, | |||
| HAL_LOCKED = 0x01 | |||
| } HAL_LockTypeDef; | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| #ifndef NULL | |||
| #define NULL (void *) 0 | |||
| #endif | |||
| #define HAL_MAX_DELAY 0xFFFFFFFF | |||
| #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) | |||
| #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) | |||
| #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 = 0) | |||
| #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 ( __GNUC__ ) | |||
| #ifndef __weak | |||
| #define __weak __attribute__((weak)) | |||
| #endif /* __weak */ | |||
| #ifndef __packed | |||
| #define __packed __attribute__((__packed__)) | |||
| #endif /* __packed */ | |||
| #endif /* __GNUC__ */ | |||
| /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ | |||
| #if defined (__GNUC__) /* 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 */ | |||
| #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 ) | |||
| /* ARM Compiler | |||
| ------------ | |||
| 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 HAL_StatusTypeDef | |||
| #elif defined ( __ICCARM__ ) | |||
| /* ICCARM Compiler | |||
| --------------- | |||
| RAM functions are defined using a specific toolchain keyword "__ramfunc". | |||
| */ | |||
| #define __RAM_FUNC __ramfunc HAL_StatusTypeDef | |||
| #elif defined ( __GNUC__ ) | |||
| /* GNU Compiler | |||
| ------------ | |||
| RAM functions are defined using a specific toolchain attribute | |||
| "__attribute__((section(".RamFunc")))". | |||
| */ | |||
| #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) | |||
| #endif | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* ___STM32F4xx_HAL_DEF */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,697 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dma.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of DMA HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_DMA_H | |||
| #define __STM32F4xx_HAL_DMA_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup DMA | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief DMA Configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Channel; /*!< Specifies the channel used for the specified stream. | |||
| This parameter can be a value of @ref DMA_Channel_selection */ | |||
| 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 Streamx. | |||
| 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 Stream */ | |||
| uint32_t Priority; /*!< Specifies the software priority for the DMAy Streamx. | |||
| This parameter can be a value of @ref DMA_Priority_level */ | |||
| uint32_t FIFOMode; /*!< Specifies if the FIFO mode or Direct mode will be used for the specified stream. | |||
| This parameter can be a value of @ref DMA_FIFO_direct_mode | |||
| @note The Direct mode (FIFO mode disabled) cannot be used if the | |||
| memory-to-memory data transfer is configured on the selected stream */ | |||
| uint32_t FIFOThreshold; /*!< Specifies the FIFO threshold level. | |||
| This parameter can be a value of @ref DMA_FIFO_threshold_level */ | |||
| uint32_t MemBurst; /*!< Specifies the Burst transfer configuration for the memory transfers. | |||
| It specifies the amount of data to be transferred in a single non interruptable | |||
| transaction. | |||
| This parameter can be a value of @ref DMA_Memory_burst | |||
| @note The burst mode is possible only if the address Increment mode is enabled. */ | |||
| uint32_t PeriphBurst; /*!< Specifies the Burst transfer configuration for the peripheral transfers. | |||
| It specifies the amount of data to be transferred in a single non interruptable | |||
| transaction. | |||
| This parameter can be a value of @ref DMA_Peripheral_burst | |||
| @note The burst mode is possible only if the address Increment mode is enabled. */ | |||
| }DMA_InitTypeDef; | |||
| /** | |||
| * @brief HAL DMA State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_DMA_STATE_RESET = 0x00, /*!< DMA not yet initialized or disabled */ | |||
| HAL_DMA_STATE_READY = 0x01, /*!< DMA initialized and ready for use */ | |||
| HAL_DMA_STATE_READY_MEM0 = 0x11, /*!< DMA Mem0 process success */ | |||
| HAL_DMA_STATE_READY_MEM1 = 0x21, /*!< DMA Mem1 process success */ | |||
| HAL_DMA_STATE_READY_HALF_MEM0 = 0x31, /*!< DMA Mem0 Half process success */ | |||
| HAL_DMA_STATE_READY_HALF_MEM1 = 0x41, /*!< DMA Mem1 Half process success */ | |||
| HAL_DMA_STATE_BUSY = 0x02, /*!< DMA process is ongoing */ | |||
| HAL_DMA_STATE_BUSY_MEM0 = 0x12, /*!< DMA Mem0 process is ongoing */ | |||
| HAL_DMA_STATE_BUSY_MEM1 = 0x22, /*!< DMA Mem1 process is ongoing */ | |||
| HAL_DMA_STATE_TIMEOUT = 0x03, /*!< DMA timeout state */ | |||
| HAL_DMA_STATE_ERROR = 0x04, /*!< DMA error state */ | |||
| }HAL_DMA_StateTypeDef; | |||
| /** | |||
| * @brief HAL DMA Error Code structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_DMA_FULL_TRANSFER = 0x00, /*!< Full transfer */ | |||
| HAL_DMA_HALF_TRANSFER = 0x01, /*!< Half Transfer */ | |||
| }HAL_DMA_LevelCompleteTypeDef; | |||
| /** | |||
| * @brief DMA handle Structure definition | |||
| */ | |||
| typedef struct __DMA_HandleTypeDef | |||
| { | |||
| DMA_Stream_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 (* XferM1CpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete Memory1 callback */ | |||
| void (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */ | |||
| __IO uint32_t ErrorCode; /*!< DMA Error code */ | |||
| }DMA_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup DMA_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup DMA_Error_Code | |||
| * @{ | |||
| */ | |||
| #define HAL_DMA_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ | |||
| #define HAL_DMA_ERROR_TE ((uint32_t)0x00000001) /*!< Transfer error */ | |||
| #define HAL_DMA_ERROR_FE ((uint32_t)0x00000002) /*!< FIFO error */ | |||
| #define HAL_DMA_ERROR_DME ((uint32_t)0x00000004) /*!< Direct Mode error */ | |||
| #define HAL_DMA_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Channel_selection | |||
| * @{ | |||
| */ | |||
| #define DMA_CHANNEL_0 ((uint32_t)0x00000000) /*!< DMA Channel 0 */ | |||
| #define DMA_CHANNEL_1 ((uint32_t)0x02000000) /*!< DMA Channel 1 */ | |||
| #define DMA_CHANNEL_2 ((uint32_t)0x04000000) /*!< DMA Channel 2 */ | |||
| #define DMA_CHANNEL_3 ((uint32_t)0x06000000) /*!< DMA Channel 3 */ | |||
| #define DMA_CHANNEL_4 ((uint32_t)0x08000000) /*!< DMA Channel 4 */ | |||
| #define DMA_CHANNEL_5 ((uint32_t)0x0A000000) /*!< DMA Channel 5 */ | |||
| #define DMA_CHANNEL_6 ((uint32_t)0x0C000000) /*!< DMA Channel 6 */ | |||
| #define DMA_CHANNEL_7 ((uint32_t)0x0E000000) /*!< DMA Channel 7 */ | |||
| #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ | |||
| ((CHANNEL) == DMA_CHANNEL_1) || \ | |||
| ((CHANNEL) == DMA_CHANNEL_2) || \ | |||
| ((CHANNEL) == DMA_CHANNEL_3) || \ | |||
| ((CHANNEL) == DMA_CHANNEL_4) || \ | |||
| ((CHANNEL) == DMA_CHANNEL_5) || \ | |||
| ((CHANNEL) == DMA_CHANNEL_6) || \ | |||
| ((CHANNEL) == DMA_CHANNEL_7)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Data_transfer_direction | |||
| * @{ | |||
| */ | |||
| #define DMA_PERIPH_TO_MEMORY ((uint32_t)0x00000000) /*!< Peripheral to memory direction */ | |||
| #define DMA_MEMORY_TO_PERIPH ((uint32_t)DMA_SxCR_DIR_0) /*!< Memory to peripheral direction */ | |||
| #define DMA_MEMORY_TO_MEMORY ((uint32_t)DMA_SxCR_DIR_1) /*!< Memory to memory direction */ | |||
| #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \ | |||
| ((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \ | |||
| ((DIRECTION) == DMA_MEMORY_TO_MEMORY)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Data_buffer_size | |||
| * @{ | |||
| */ | |||
| #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Peripheral_incremented_mode | |||
| * @{ | |||
| */ | |||
| #define DMA_PINC_ENABLE ((uint32_t)DMA_SxCR_PINC) /*!< Peripheral increment mode enable */ | |||
| #define DMA_PINC_DISABLE ((uint32_t)0x00000000) /*!< Peripheral increment mode disable */ | |||
| #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \ | |||
| ((STATE) == DMA_PINC_DISABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Memory_incremented_mode | |||
| * @{ | |||
| */ | |||
| #define DMA_MINC_ENABLE ((uint32_t)DMA_SxCR_MINC) /*!< Memory increment mode enable */ | |||
| #define DMA_MINC_DISABLE ((uint32_t)0x00000000) /*!< Memory increment mode disable */ | |||
| #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \ | |||
| ((STATE) == DMA_MINC_DISABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Peripheral_data_size | |||
| * @{ | |||
| */ | |||
| #define DMA_PDATAALIGN_BYTE ((uint32_t)0x00000000) /*!< Peripheral data alignment: Byte */ | |||
| #define DMA_PDATAALIGN_HALFWORD ((uint32_t)DMA_SxCR_PSIZE_0) /*!< Peripheral data alignment: HalfWord */ | |||
| #define DMA_PDATAALIGN_WORD ((uint32_t)DMA_SxCR_PSIZE_1) /*!< Peripheral data alignment: Word */ | |||
| #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \ | |||
| ((SIZE) == DMA_PDATAALIGN_HALFWORD) || \ | |||
| ((SIZE) == DMA_PDATAALIGN_WORD)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Memory_data_size | |||
| * @{ | |||
| */ | |||
| #define DMA_MDATAALIGN_BYTE ((uint32_t)0x00000000) /*!< Memory data alignment: Byte */ | |||
| #define DMA_MDATAALIGN_HALFWORD ((uint32_t)DMA_SxCR_MSIZE_0) /*!< Memory data alignment: HalfWord */ | |||
| #define DMA_MDATAALIGN_WORD ((uint32_t)DMA_SxCR_MSIZE_1) /*!< Memory data alignment: Word */ | |||
| #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \ | |||
| ((SIZE) == DMA_MDATAALIGN_HALFWORD) || \ | |||
| ((SIZE) == DMA_MDATAALIGN_WORD )) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_mode | |||
| * @{ | |||
| */ | |||
| #define DMA_NORMAL ((uint32_t)0x00000000) /*!< Normal mode */ | |||
| #define DMA_CIRCULAR ((uint32_t)DMA_SxCR_CIRC) /*!< Circular mode */ | |||
| #define DMA_PFCTRL ((uint32_t)DMA_SxCR_PFCTRL) /*!< Peripheral flow control mode */ | |||
| #define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \ | |||
| ((MODE) == DMA_CIRCULAR) || \ | |||
| ((MODE) == DMA_PFCTRL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Priority_level | |||
| * @{ | |||
| */ | |||
| #define DMA_PRIORITY_LOW ((uint32_t)0x00000000) /*!< Priority level: Low */ | |||
| #define DMA_PRIORITY_MEDIUM ((uint32_t)DMA_SxCR_PL_0) /*!< Priority level: Medium */ | |||
| #define DMA_PRIORITY_HIGH ((uint32_t)DMA_SxCR_PL_1) /*!< Priority level: High */ | |||
| #define DMA_PRIORITY_VERY_HIGH ((uint32_t)DMA_SxCR_PL) /*!< Priority level: Very High */ | |||
| #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \ | |||
| ((PRIORITY) == DMA_PRIORITY_MEDIUM) || \ | |||
| ((PRIORITY) == DMA_PRIORITY_HIGH) || \ | |||
| ((PRIORITY) == DMA_PRIORITY_VERY_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_FIFO_direct_mode | |||
| * @{ | |||
| */ | |||
| #define DMA_FIFOMODE_DISABLE ((uint32_t)0x00000000) /*!< FIFO mode disable */ | |||
| #define DMA_FIFOMODE_ENABLE ((uint32_t)DMA_SxFCR_DMDIS) /*!< FIFO mode enable */ | |||
| #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMODE_DISABLE ) || \ | |||
| ((STATE) == DMA_FIFOMODE_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_FIFO_threshold_level | |||
| * @{ | |||
| */ | |||
| #define DMA_FIFO_THRESHOLD_1QUARTERFULL ((uint32_t)0x00000000) /*!< FIFO threshold 1 quart full configuration */ | |||
| #define DMA_FIFO_THRESHOLD_HALFFULL ((uint32_t)DMA_SxFCR_FTH_0) /*!< FIFO threshold half full configuration */ | |||
| #define DMA_FIFO_THRESHOLD_3QUARTERSFULL ((uint32_t)DMA_SxFCR_FTH_1) /*!< FIFO threshold 3 quarts full configuration */ | |||
| #define DMA_FIFO_THRESHOLD_FULL ((uint32_t)DMA_SxFCR_FTH) /*!< FIFO threshold full configuration */ | |||
| #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFO_THRESHOLD_1QUARTERFULL ) || \ | |||
| ((THRESHOLD) == DMA_FIFO_THRESHOLD_HALFFULL) || \ | |||
| ((THRESHOLD) == DMA_FIFO_THRESHOLD_3QUARTERSFULL) || \ | |||
| ((THRESHOLD) == DMA_FIFO_THRESHOLD_FULL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Memory_burst | |||
| * @{ | |||
| */ | |||
| #define DMA_MBURST_SINGLE ((uint32_t)0x00000000) | |||
| #define DMA_MBURST_INC4 ((uint32_t)DMA_SxCR_MBURST_0) | |||
| #define DMA_MBURST_INC8 ((uint32_t)DMA_SxCR_MBURST_1) | |||
| #define DMA_MBURST_INC16 ((uint32_t)DMA_SxCR_MBURST) | |||
| #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MBURST_SINGLE) || \ | |||
| ((BURST) == DMA_MBURST_INC4) || \ | |||
| ((BURST) == DMA_MBURST_INC8) || \ | |||
| ((BURST) == DMA_MBURST_INC16)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Peripheral_burst | |||
| * @{ | |||
| */ | |||
| #define DMA_PBURST_SINGLE ((uint32_t)0x00000000) | |||
| #define DMA_PBURST_INC4 ((uint32_t)DMA_SxCR_PBURST_0) | |||
| #define DMA_PBURST_INC8 ((uint32_t)DMA_SxCR_PBURST_1) | |||
| #define DMA_PBURST_INC16 ((uint32_t)DMA_SxCR_PBURST) | |||
| #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PBURST_SINGLE) || \ | |||
| ((BURST) == DMA_PBURST_INC4) || \ | |||
| ((BURST) == DMA_PBURST_INC8) || \ | |||
| ((BURST) == DMA_PBURST_INC16)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_interrupt_enable_definitions | |||
| * @{ | |||
| */ | |||
| #define DMA_IT_TC ((uint32_t)DMA_SxCR_TCIE) | |||
| #define DMA_IT_HT ((uint32_t)DMA_SxCR_HTIE) | |||
| #define DMA_IT_TE ((uint32_t)DMA_SxCR_TEIE) | |||
| #define DMA_IT_DME ((uint32_t)DMA_SxCR_DMEIE) | |||
| #define DMA_IT_FE ((uint32_t)0x00000080) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_flag_definitions | |||
| * @{ | |||
| */ | |||
| #define DMA_FLAG_FEIF0_4 ((uint32_t)0x00800001) | |||
| #define DMA_FLAG_DMEIF0_4 ((uint32_t)0x00800004) | |||
| #define DMA_FLAG_TEIF0_4 ((uint32_t)0x00000008) | |||
| #define DMA_FLAG_HTIF0_4 ((uint32_t)0x00000010) | |||
| #define DMA_FLAG_TCIF0_4 ((uint32_t)0x00000020) | |||
| #define DMA_FLAG_FEIF1_5 ((uint32_t)0x00000040) | |||
| #define DMA_FLAG_DMEIF1_5 ((uint32_t)0x00000100) | |||
| #define DMA_FLAG_TEIF1_5 ((uint32_t)0x00000200) | |||
| #define DMA_FLAG_HTIF1_5 ((uint32_t)0x00000400) | |||
| #define DMA_FLAG_TCIF1_5 ((uint32_t)0x00000800) | |||
| #define DMA_FLAG_FEIF2_6 ((uint32_t)0x00010000) | |||
| #define DMA_FLAG_DMEIF2_6 ((uint32_t)0x00040000) | |||
| #define DMA_FLAG_TEIF2_6 ((uint32_t)0x00080000) | |||
| #define DMA_FLAG_HTIF2_6 ((uint32_t)0x00100000) | |||
| #define DMA_FLAG_TCIF2_6 ((uint32_t)0x00200000) | |||
| #define DMA_FLAG_FEIF3_7 ((uint32_t)0x00400000) | |||
| #define DMA_FLAG_DMEIF3_7 ((uint32_t)0x01000000) | |||
| #define DMA_FLAG_TEIF3_7 ((uint32_t)0x02000000) | |||
| #define DMA_FLAG_HTIF3_7 ((uint32_t)0x04000000) | |||
| #define DMA_FLAG_TCIF3_7 ((uint32_t)0x08000000) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset DMA handle state | |||
| * @param __HANDLE__: specifies the DMA handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET) | |||
| /** | |||
| * @brief Return the current DMA Stream FIFO filled level. | |||
| * @param __HANDLE__: DMA handle | |||
| * @retval The FIFO filling state. | |||
| * - DMA_FIFOStatus_Less1QuarterFull: when FIFO is less than 1 quarter-full | |||
| * and not empty. | |||
| * - DMA_FIFOStatus_1QuarterFull: if more than 1 quarter-full. | |||
| * - DMA_FIFOStatus_HalfFull: if more than 1 half-full. | |||
| * - DMA_FIFOStatus_3QuartersFull: if more than 3 quarters-full. | |||
| * - DMA_FIFOStatus_Empty: when FIFO is empty | |||
| * - DMA_FIFOStatus_Full: when FIFO is full | |||
| */ | |||
| #define __HAL_DMA_GET_FS(__HANDLE__) (((__HANDLE__)->Instance->FCR & (DMA_SxFCR_FS))) | |||
| /** | |||
| * @brief Enable the specified DMA Stream. | |||
| * @param __HANDLE__: DMA handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DMA_SxCR_EN) | |||
| /** | |||
| * @brief Disable the specified DMA Stream. | |||
| * @param __HANDLE__: DMA handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~DMA_SxCR_EN) | |||
| /* Interrupt & Flag management */ | |||
| /** | |||
| * @brief Return the current DMA Stream transfer complete flag. | |||
| * @param __HANDLE__: DMA handle | |||
| * @retval The specified transfer complete flag index. | |||
| */ | |||
| #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \ | |||
| (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TCIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TCIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TCIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TCIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TCIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TCIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TCIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TCIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TCIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TCIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TCIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TCIF2_6 :\ | |||
| DMA_FLAG_TCIF3_7) | |||
| /** | |||
| * @brief Return the current DMA Stream half transfer complete flag. | |||
| * @param __HANDLE__: DMA handle | |||
| * @retval The specified half transfer complete flag index. | |||
| */ | |||
| #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\ | |||
| (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_HTIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_HTIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_HTIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_HTIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_HTIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_HTIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_HTIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_HTIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_HTIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_HTIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_HTIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_HTIF2_6 :\ | |||
| DMA_FLAG_HTIF3_7) | |||
| /** | |||
| * @brief Return the current DMA Stream transfer error flag. | |||
| * @param __HANDLE__: DMA handle | |||
| * @retval The specified transfer error flag index. | |||
| */ | |||
| #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\ | |||
| (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TEIF2_6 :\ | |||
| DMA_FLAG_TEIF3_7) | |||
| /** | |||
| * @brief Return the current DMA Stream FIFO error flag. | |||
| * @param __HANDLE__: DMA handle | |||
| * @retval The specified FIFO error flag index. | |||
| */ | |||
| #define __HAL_DMA_GET_FE_FLAG_INDEX(__HANDLE__)\ | |||
| (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_FEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_FEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_FEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_FEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_FEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_FEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_FEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_FEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_FEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_FEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_FEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_FEIF2_6 :\ | |||
| DMA_FLAG_FEIF3_7) | |||
| /** | |||
| * @brief Return the current DMA Stream direct mode error flag. | |||
| * @param __HANDLE__: DMA handle | |||
| * @retval The specified direct mode error flag index. | |||
| */ | |||
| #define __HAL_DMA_GET_DME_FLAG_INDEX(__HANDLE__)\ | |||
| (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_DMEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_DMEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_DMEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_DMEIF0_4 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_DMEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_DMEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_DMEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_DMEIF1_5 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_DMEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_DMEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_DMEIF2_6 :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_DMEIF2_6 :\ | |||
| DMA_FLAG_DMEIF3_7) | |||
| /** | |||
| * @brief Get the DMA Stream 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_FLAG_DMEIFx: Direct mode error flag. | |||
| * @arg DMA_FLAG_FEIFx: FIFO error flag. | |||
| * Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Stream flag. | |||
| * @retval The state of FLAG (SET or RESET). | |||
| */ | |||
| #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)\ | |||
| (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HISR & (__FLAG__)) :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LISR & (__FLAG__)) :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HISR & (__FLAG__)) : (DMA1->LISR & (__FLAG__))) | |||
| /** | |||
| * @brief Clear the DMA Stream 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_TCIFx: Transfer complete flag. | |||
| * @arg DMA_FLAG_HTIFx: Half transfer complete flag. | |||
| * @arg DMA_FLAG_TEIFx: Transfer error flag. | |||
| * @arg DMA_FLAG_DMEIFx: Direct mode error flag. | |||
| * @arg DMA_FLAG_FEIFx: FIFO error flag. | |||
| * Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Stream flag. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) \ | |||
| (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HIFCR = (__FLAG__)) :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LIFCR = (__FLAG__)) :\ | |||
| ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HIFCR = (__FLAG__)) : (DMA1->LIFCR = (__FLAG__))) | |||
| /** | |||
| * @brief Enable the specified DMA Stream 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. | |||
| * @arg DMA_IT_FE: FIFO error interrupt mask. | |||
| * @arg DMA_IT_DME: Direct mode error interrupt. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \ | |||
| ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) : ((__HANDLE__)->Instance->FCR |= (__INTERRUPT__))) | |||
| /** | |||
| * @brief Disable the specified DMA Stream 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. | |||
| * @arg DMA_IT_FE: FIFO error interrupt mask. | |||
| * @arg DMA_IT_DME: Direct mode error interrupt. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \ | |||
| ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) : ((__HANDLE__)->Instance->FCR &= ~(__INTERRUPT__))) | |||
| /** | |||
| * @brief Check whether the specified DMA Stream interrupt has occurred 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. | |||
| * @arg DMA_IT_FE: FIFO error interrupt mask. | |||
| * @arg DMA_IT_DME: Direct mode error interrupt. | |||
| * @retval The state of DMA_IT. | |||
| */ | |||
| #define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \ | |||
| ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) : \ | |||
| ((__HANDLE__)->Instance->FCR & (__INTERRUPT__))) | |||
| /** | |||
| * @brief Writes the number of data units to be transferred on the DMA Stream. | |||
| * @param __HANDLE__: DMA handle | |||
| * @param __COUNTER__: Number of data units to be transferred (from 0 to 65535) | |||
| * Number of data items depends only on the Peripheral data format. | |||
| * | |||
| * @note If Peripheral data format is Bytes: number of data units is equal | |||
| * to total number of bytes to be transferred. | |||
| * | |||
| * @note If Peripheral data format is Half-Word: number of data units is | |||
| * equal to total number of bytes to be transferred / 2. | |||
| * | |||
| * @note If Peripheral data format is Word: number of data units is equal | |||
| * to total number of bytes to be transferred / 4. | |||
| * | |||
| * @retval The number of remaining data units in the current DMAy Streamx transfer. | |||
| */ | |||
| #define __HAL_DMA_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->NDTR = (uint16_t)(__COUNTER__)) | |||
| /** | |||
| * @brief Returns the number of remaining data units in the current DMAy Streamx transfer. | |||
| * @param __HANDLE__: DMA handle | |||
| * | |||
| * @retval The number of remaining data units in the current DMA Stream transfer. | |||
| */ | |||
| #define __HAL_DMA_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->NDTR) | |||
| /* Include DMA HAL Extension module */ | |||
| #include "stm32f4xx_hal_dma_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization and de-initialization functions *****************************/ | |||
| HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma); | |||
| HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma); | |||
| /* 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_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout); | |||
| void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma); | |||
| /* Peripheral State and Error functions ***************************************/ | |||
| HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma); | |||
| uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_DMA_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,504 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dma2d.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of DMA2D HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_DMA2D_H | |||
| #define __STM32F4xx_HAL_DMA2D_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup DMA2D | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| #define MAX_DMA2D_LAYER 2 | |||
| /** | |||
| * @brief DMA2D color Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Blue; /*!< Configures the blue value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ | |||
| uint32_t Green; /*!< Configures the green value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ | |||
| uint32_t Red; /*!< Configures the red value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ | |||
| } DMA2D_ColorTypeDef; | |||
| /** | |||
| * @brief DMA2D CLUT Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t *pCLUT; /*!< Configures the DMA2D CLUT memory address.*/ | |||
| uint32_t CLUTColorMode; /*!< configures the DMA2D CLUT color mode. | |||
| This parameter can be one value of @ref DMA2D_CLUT_CM */ | |||
| uint32_t Size; /*!< configures the DMA2D CLUT size. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.*/ | |||
| } DMA2D_CLUTCfgTypeDef; | |||
| /** | |||
| * @brief DMA2D Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Mode; /*!< configures the DMA2D transfer mode. | |||
| This parameter can be one value of @ref DMA2D_Mode */ | |||
| uint32_t ColorMode; /*!< configures the color format of the output image. | |||
| This parameter can be one value of @ref DMA2D_Color_Mode */ | |||
| uint32_t OutputOffset; /*!< Specifies the Offset value. | |||
| This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF. */ | |||
| } DMA2D_InitTypeDef; | |||
| /** | |||
| * @brief DMA2D Layer structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t InputOffset; /*!< configures the DMA2D foreground offset. | |||
| This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF. */ | |||
| uint32_t InputColorMode; /*!< configures the DMA2D foreground color mode . | |||
| This parameter can be one value of @ref DMA2D_Input_Color_Mode */ | |||
| uint32_t AlphaMode; /*!< configures the DMA2D foreground alpha mode. | |||
| This parameter can be one value of @ref DMA2D_ALPHA_MODE */ | |||
| uint32_t InputAlpha; /*!< Specifies the DMA2D foreground alpha value and color value in case of A8 or A4 color mode. | |||
| This parameter must be a number between Min_Data = 0x00000000 and Max_Data = 0xFFFFFFFF | |||
| in case of A8 or A4 color mode (ARGB). | |||
| Otherwise, This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.*/ | |||
| } DMA2D_LayerCfgTypeDef; | |||
| /** | |||
| * @brief HAL DMA2D State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_DMA2D_STATE_RESET = 0x00, /*!< DMA2D not yet initialized or disabled */ | |||
| HAL_DMA2D_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ | |||
| HAL_DMA2D_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ | |||
| HAL_DMA2D_STATE_TIMEOUT = 0x03, /*!< Timeout state */ | |||
| HAL_DMA2D_STATE_ERROR = 0x04, /*!< DMA2D state error */ | |||
| HAL_DMA2D_STATE_SUSPEND = 0x05 /*!< DMA2D process is suspended */ | |||
| }HAL_DMA2D_StateTypeDef; | |||
| /** | |||
| * @brief DMA2D handle Structure definition | |||
| */ | |||
| typedef struct __DMA2D_HandleTypeDef | |||
| { | |||
| DMA2D_TypeDef *Instance; /*!< DMA2D Register base address */ | |||
| DMA2D_InitTypeDef Init; /*!< DMA2D communication parameters */ | |||
| void (* XferCpltCallback)(struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D transfer complete callback */ | |||
| void (* XferErrorCallback)(struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D transfer error callback */ | |||
| DMA2D_LayerCfgTypeDef LayerCfg[MAX_DMA2D_LAYER]; /*!< DMA2D Layers parameters */ | |||
| HAL_LockTypeDef Lock; /*!< DMA2D Lock */ | |||
| __IO HAL_DMA2D_StateTypeDef State; /*!< DMA2D transfer state */ | |||
| __IO uint32_t ErrorCode; /*!< DMA2D Error code */ | |||
| } DMA2D_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup DMA2D_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup DMA2D_Layer | |||
| * @{ | |||
| */ | |||
| #define IS_DMA2D_LAYER(LAYER) ((LAYER) <= MAX_DMA2D_LAYER) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_Error_Code | |||
| * @{ | |||
| */ | |||
| #define HAL_DMA2D_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ | |||
| #define HAL_DMA2D_ERROR_TE ((uint32_t)0x00000001) /*!< Transfer error */ | |||
| #define HAL_DMA2D_ERROR_CE ((uint32_t)0x00000002) /*!< Configuration error */ | |||
| #define HAL_DMA2D_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_Mode | |||
| * @{ | |||
| */ | |||
| #define DMA2D_M2M ((uint32_t)0x00000000) /*!< DMA2D memory to memory transfer mode */ | |||
| #define DMA2D_M2M_PFC ((uint32_t)0x00010000) /*!< DMA2D memory to memory with pixel format conversion transfer mode */ | |||
| #define DMA2D_M2M_BLEND ((uint32_t)0x00020000) /*!< DMA2D memory to memory with blending transfer mode */ | |||
| #define DMA2D_R2M ((uint32_t)0x00030000) /*!< DMA2D register to memory transfer mode */ | |||
| #define IS_DMA2D_MODE(MODE) (((MODE) == DMA2D_M2M) || ((MODE) == DMA2D_M2M_PFC) || \ | |||
| ((MODE) == DMA2D_M2M_BLEND) || ((MODE) == DMA2D_R2M)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_Color_Mode | |||
| * @{ | |||
| */ | |||
| #define DMA2D_ARGB8888 ((uint32_t)0x00000000) /*!< ARGB8888 DMA2D color mode */ | |||
| #define DMA2D_RGB888 ((uint32_t)0x00000001) /*!< RGB888 DMA2D color mode */ | |||
| #define DMA2D_RGB565 ((uint32_t)0x00000002) /*!< RGB565 DMA2D color mode */ | |||
| #define DMA2D_ARGB1555 ((uint32_t)0x00000003) /*!< ARGB1555 DMA2D color mode */ | |||
| #define DMA2D_ARGB4444 ((uint32_t)0x00000004) /*!< ARGB4444 DMA2D color mode */ | |||
| #define IS_DMA2D_CMODE(MODE_ARGB) (((MODE_ARGB) == DMA2D_ARGB8888) || ((MODE_ARGB) == DMA2D_RGB888) || \ | |||
| ((MODE_ARGB) == DMA2D_RGB565) || ((MODE_ARGB) == DMA2D_ARGB1555) || \ | |||
| ((MODE_ARGB) == DMA2D_ARGB4444)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_COLOR_VALUE | |||
| * @{ | |||
| */ | |||
| #define COLOR_VALUE ((uint32_t)0x000000FF) /*!< color value mask */ | |||
| #define IS_DMA2D_COLOR(COLOR) ((COLOR) <= COLOR_VALUE) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_SIZE | |||
| * @{ | |||
| */ | |||
| #define DMA2D_PIXEL (DMA2D_NLR_PL >> 16) /*!< DMA2D pixel per line */ | |||
| #define DMA2D_LINE DMA2D_NLR_NL /*!< DMA2D number of line */ | |||
| #define IS_DMA2D_LINE(LINE) ((LINE) <= DMA2D_LINE) | |||
| #define IS_DMA2D_PIXEL(PIXEL) ((PIXEL) <= DMA2D_PIXEL) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_Offset | |||
| * @{ | |||
| */ | |||
| #define DMA2D_OFFSET DMA2D_FGOR_LO /*!< Line Offset */ | |||
| #define IS_DMA2D_OFFSET(OOFFSET) ((OOFFSET) <= DMA2D_OFFSET) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_Input_Color_Mode | |||
| * @{ | |||
| */ | |||
| #define CM_ARGB8888 ((uint32_t)0x00000000) /*!< ARGB8888 color mode */ | |||
| #define CM_RGB888 ((uint32_t)0x00000001) /*!< RGB888 color mode */ | |||
| #define CM_RGB565 ((uint32_t)0x00000002) /*!< RGB565 color mode */ | |||
| #define CM_ARGB1555 ((uint32_t)0x00000003) /*!< ARGB1555 color mode */ | |||
| #define CM_ARGB4444 ((uint32_t)0x00000004) /*!< ARGB4444 color mode */ | |||
| #define CM_L8 ((uint32_t)0x00000005) /*!< L8 color mode */ | |||
| #define CM_AL44 ((uint32_t)0x00000006) /*!< AL44 color mode */ | |||
| #define CM_AL88 ((uint32_t)0x00000007) /*!< AL88 color mode */ | |||
| #define CM_L4 ((uint32_t)0x00000008) /*!< L4 color mode */ | |||
| #define CM_A8 ((uint32_t)0x00000009) /*!< A8 color mode */ | |||
| #define CM_A4 ((uint32_t)0x0000000A) /*!< A4 color mode */ | |||
| #define IS_DMA2D_INPUT_COLOR_MODE(INPUT_CM) (((INPUT_CM) == CM_ARGB8888) || ((INPUT_CM) == CM_RGB888) || \ | |||
| ((INPUT_CM) == CM_RGB565) || ((INPUT_CM) == CM_ARGB1555) || \ | |||
| ((INPUT_CM) == CM_ARGB4444) || ((INPUT_CM) == CM_L8) || \ | |||
| ((INPUT_CM) == CM_AL44) || ((INPUT_CM) == CM_AL88) || \ | |||
| ((INPUT_CM) == CM_L4) || ((INPUT_CM) == CM_A8) || \ | |||
| ((INPUT_CM) == CM_A4)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_ALPHA_MODE | |||
| * @{ | |||
| */ | |||
| #define DMA2D_NO_MODIF_ALPHA ((uint32_t)0x00000000) /*!< No modification of the alpha channel value */ | |||
| #define DMA2D_REPLACE_ALPHA ((uint32_t)0x00000001) /*!< Replace original alpha channel value by programmed alpha value */ | |||
| #define DMA2D_COMBINE_ALPHA ((uint32_t)0x00000002) /*!< Replace original alpha channel value by programmed alpha value | |||
| with original alpha channel value */ | |||
| #define IS_DMA2D_ALPHA_MODE(AlphaMode) (((AlphaMode) == DMA2D_NO_MODIF_ALPHA) || \ | |||
| ((AlphaMode) == DMA2D_REPLACE_ALPHA) || \ | |||
| ((AlphaMode) == DMA2D_COMBINE_ALPHA)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_CLUT_CM | |||
| * @{ | |||
| */ | |||
| #define DMA2D_CCM_ARGB8888 ((uint32_t)0x00000000) /*!< ARGB8888 DMA2D C-LUT color mode */ | |||
| #define DMA2D_CCM_RGB888 ((uint32_t)0x00000001) /*!< RGB888 DMA2D C-LUT color mode */ | |||
| #define IS_DMA2D_CLUT_CM(CLUT_CM) (((CLUT_CM) == DMA2D_CCM_ARGB8888) || ((CLUT_CM) == DMA2D_CCM_RGB888)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_Size_Clut | |||
| * @{ | |||
| */ | |||
| #define DMA2D_CLUT_SIZE (DMA2D_FGPFCCR_CS >> 8) /*!< DMA2D C-LUT size */ | |||
| #define IS_DMA2D_CLUT_SIZE(CLUT_SIZE) ((CLUT_SIZE) <= DMA2D_CLUT_SIZE) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_DeadTime | |||
| * @{ | |||
| */ | |||
| #define LINE_WATERMARK DMA2D_LWR_LW | |||
| #define IS_DMA2D_LineWatermark(LineWatermark) ((LineWatermark) <= LINE_WATERMARK) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_Interrupts | |||
| * @{ | |||
| */ | |||
| #define DMA2D_IT_CE DMA2D_CR_CEIE /*!< Configuration Error Interrupt */ | |||
| #define DMA2D_IT_CTC DMA2D_CR_CTCIE /*!< C-LUT Transfer Complete Interrupt */ | |||
| #define DMA2D_IT_CAE DMA2D_CR_CAEIE /*!< C-LUT Access Error Interrupt */ | |||
| #define DMA2D_IT_TW DMA2D_CR_TWIE /*!< Transfer Watermark Interrupt */ | |||
| #define DMA2D_IT_TC DMA2D_CR_TCIE /*!< Transfer Complete Interrupt */ | |||
| #define DMA2D_IT_TE DMA2D_CR_TEIE /*!< Transfer Error Interrupt */ | |||
| #define IS_DMA2D_IT(IT) (((IT) == DMA2D_IT_CTC) || ((IT) == DMA2D_IT_CAE) || \ | |||
| ((IT) == DMA2D_IT_TW) || ((IT) == DMA2D_IT_TC) || \ | |||
| ((IT) == DMA2D_IT_TE) || ((IT) == DMA2D_IT_CE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA2D_Flag | |||
| * @{ | |||
| */ | |||
| #define DMA2D_FLAG_CE DMA2D_ISR_CEIF /*!< Configuration Error Interrupt Flag */ | |||
| #define DMA2D_FLAG_CTC DMA2D_ISR_CTCIF /*!< C-LUT Transfer Complete Interrupt Flag */ | |||
| #define DMA2D_FLAG_CAE DMA2D_ISR_CAEIF /*!< C-LUT Access Error Interrupt Flag */ | |||
| #define DMA2D_FLAG_TW DMA2D_ISR_TWIF /*!< Transfer Watermark Interrupt Flag */ | |||
| #define DMA2D_FLAG_TC DMA2D_ISR_TCIF /*!< Transfer Complete Interrupt Flag */ | |||
| #define DMA2D_FLAG_TE DMA2D_ISR_TEIF /*!< Transfer Error Interrupt Flag */ | |||
| #define IS_DMA2D_GET_FLAG(FLAG) (((FLAG) == DMA2D_FLAG_CTC) || ((FLAG) == DMA2D_FLAG_CAE) || \ | |||
| ((FLAG) == DMA2D_FLAG_TW) || ((FLAG) == DMA2D_FLAG_TC) || \ | |||
| ((FLAG) == DMA2D_FLAG_TE) || ((FLAG) == DMA2D_FLAG_CE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset DMA2D handle state | |||
| * @param __HANDLE__: specifies the DMA2D handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA2D_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA2D_STATE_RESET) | |||
| /** | |||
| * @brief Enable the DMA2D. | |||
| * @param __HANDLE__: DMA2D handle | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_DMA2D_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DMA2D_CR_START) | |||
| /** | |||
| * @brief Disable the DMA2D. | |||
| * @param __HANDLE__: DMA2D handle | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_DMA2D_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~DMA2D_CR_START) | |||
| /* Interrupt & Flag management */ | |||
| /** | |||
| * @brief Get the DMA2D pending flags. | |||
| * @param __HANDLE__: DMA2D handle | |||
| * @param __FLAG__: Get the specified flag. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg DMA2D_FLAG_CE: Configuration error flag | |||
| * @arg DMA2D_FLAG_CTC: C-LUT transfer complete flag | |||
| * @arg DMA2D_FLAG_CAE: C-LUT access error flag | |||
| * @arg DMA2D_FLAG_TW: Transfer Watermark flag | |||
| * @arg DMA2D_FLAG_TC: Transfer complete flag | |||
| * @arg DMA2D_FLAG_TE: Transfer error flag | |||
| * @retval The state of FLAG. | |||
| */ | |||
| #define __HAL_DMA2D_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR & (__FLAG__)) | |||
| /** | |||
| * @brief Clears the DMA2D pending flags. | |||
| * @param __HANDLE__: DMA2D handle | |||
| * @param __FLAG__: specifies the flag to clear. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg DMA2D_FLAG_CE: Configuration error flag | |||
| * @arg DMA2D_FLAG_CTC: C-LUT transfer complete flag | |||
| * @arg DMA2D_FLAG_CAE: C-LUT access error flag | |||
| * @arg DMA2D_FLAG_TW: Transfer Watermark flag | |||
| * @arg DMA2D_FLAG_TC: Transfer complete flag | |||
| * @arg DMA2D_FLAG_TE: Transfer error flag | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA2D_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->IFCR = (__FLAG__)) | |||
| /** | |||
| * @brief Enables the specified DMA2D interrupts. | |||
| * @param __HANDLE__: DMA2D handle | |||
| * @param __INTERRUPT__: specifies the DMA2D interrupt sources to be enabled. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg DMA2D_IT_CE: Configuration error interrupt mask | |||
| * @arg DMA2D_IT_CTC: C-LUT transfer complete interrupt mask | |||
| * @arg DMA2D_IT_CAE: C-LUT access error interrupt mask | |||
| * @arg DMA2D_IT_TW: Transfer Watermark interrupt mask | |||
| * @arg DMA2D_IT_TC: Transfer complete interrupt mask | |||
| * @arg DMA2D_IT_TE: Transfer error interrupt mask | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA2D_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disables the specified DMA2D interrupts. | |||
| * @param __HANDLE__: DMA2D handle | |||
| * @param __INTERRUPT__: specifies the DMA2D interrupt sources to be disabled. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg DMA2D_IT_CE: Configuration error interrupt mask | |||
| * @arg DMA2D_IT_CTC: C-LUT transfer complete interrupt mask | |||
| * @arg DMA2D_IT_CAE: C-LUT access error interrupt mask | |||
| * @arg DMA2D_IT_TW: Transfer Watermark interrupt mask | |||
| * @arg DMA2D_IT_TC: Transfer complete interrupt mask | |||
| * @arg DMA2D_IT_TE: Transfer error interrupt mask | |||
| * @retval None | |||
| */ | |||
| #define __HAL_DMA2D_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) | |||
| /** | |||
| * @brief Checks whether the specified DMA2D interrupt has occurred or not. | |||
| * @param __HANDLE__: DMA2D handle | |||
| * @param __INTERRUPT__: specifies the DMA2D interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg DMA2D_IT_CE: Configuration error interrupt mask | |||
| * @arg DMA2D_IT_CTC: C-LUT transfer complete interrupt mask | |||
| * @arg DMA2D_IT_CAE: C-LUT access error interrupt mask | |||
| * @arg DMA2D_IT_TW: Transfer Watermark interrupt mask | |||
| * @arg DMA2D_IT_TC: Transfer complete interrupt mask | |||
| * @arg DMA2D_IT_TE: Transfer error interrupt mask | |||
| * @retval The state of INTERRUPT. | |||
| */ | |||
| #define __HAL_DMA2D_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization and de-initialization functions *******************************/ | |||
| HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d); | |||
| HAL_StatusTypeDef HAL_DMA2D_DeInit (DMA2D_HandleTypeDef *hdma2d); | |||
| void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d); | |||
| void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d); | |||
| /* IO operation functions *******************************************************/ | |||
| HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Heigh); | |||
| HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Heigh); | |||
| HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Heigh); | |||
| HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Heigh); | |||
| HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d); | |||
| HAL_StatusTypeDef HAL_DMA2D_Resume(DMA2D_HandleTypeDef *hdma2d); | |||
| HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d); | |||
| HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout); | |||
| void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d); | |||
| /* Peripheral Control functions *************************************************/ | |||
| HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_DMA2D_DisableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line); | |||
| /* Peripheral State functions ***************************************************/ | |||
| HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d); | |||
| uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d); | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_DMA2D_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,92 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dma_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of DMA HAL extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_DMA_EX_H | |||
| #define __STM32F4xx_HAL_DMA_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup DMAEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL DMA Memory definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| MEMORY0 = 0x00, /*!< Memory 0 */ | |||
| MEMORY1 = 0x01, /*!< Memory 1 */ | |||
| }HAL_DMA_MemoryTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* IO operation functions *******************************************************/ | |||
| HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); | |||
| HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); | |||
| HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_DMA_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,363 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_flash.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of FLASH HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_FLASH_H | |||
| #define __STM32F4xx_HAL_FLASH_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup FLASH | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief FLASH Error structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| FLASH_ERROR_RD = 0x01, | |||
| FLASH_ERROR_PGS = 0x02, | |||
| FLASH_ERROR_PGP = 0x04, | |||
| FLASH_ERROR_PGA = 0x08, | |||
| FLASH_ERROR_WRP = 0x10, | |||
| FLASH_ERROR_OPERATION = 0x20 | |||
| }FLASH_ErrorTypeDef; | |||
| /** | |||
| * @brief FLASH Procedure structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| FLASH_PROC_NONE = 0, | |||
| FLASH_PROC_SECTERASE, | |||
| FLASH_PROC_MASSERASE, | |||
| FLASH_PROC_PROGRAM | |||
| } 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 NbSectorsToErase; /*Internal variable to save the remaining sectors to erase in IT context*/ | |||
| __IO uint8_t VoltageForErase; /*Internal variable to provide voltange range selected by user in IT context*/ | |||
| __IO uint32_t Sector; /*Internal variable to define the current sector which is erasing*/ | |||
| __IO uint32_t Bank; /*Internal variable to save current bank selected during mass erase*/ | |||
| __IO uint32_t Address; /*Internal variable to save address selected for program*/ | |||
| HAL_LockTypeDef Lock; /* FLASH locking object */ | |||
| __IO FLASH_ErrorTypeDef ErrorCode; /* FLASH error code */ | |||
| }FLASH_ProcessTypeDef; | |||
| /** | |||
| * @brief FLASH Error source | |||
| */ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup FLASH_Exported_Constants FLASH Exported Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup FLASH_Type_Program FLASH Type Program | |||
| * @{ | |||
| */ | |||
| #define TYPEPROGRAM_BYTE ((uint32_t)0x00) /*!< Program byte (8-bit) at a specified address */ | |||
| #define TYPEPROGRAM_HALFWORD ((uint32_t)0x01) /*!< Program a half-word (16-bit) at a specified address */ | |||
| #define TYPEPROGRAM_WORD ((uint32_t)0x02) /*!< Program a word (32-bit) at a specified address */ | |||
| #define TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x03) /*!< Program a double word (64-bit) at a specified address */ | |||
| #define IS_TYPEPROGRAM(VALUE)(((VALUE) == TYPEPROGRAM_BYTE) || \ | |||
| ((VALUE) == TYPEPROGRAM_HALFWORD) || \ | |||
| ((VALUE) == TYPEPROGRAM_WORD) || \ | |||
| ((VALUE) == TYPEPROGRAM_DOUBLEWORD)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASH_Flag_definition FLASH Flag definition | |||
| * @brief Flag definition | |||
| * @{ | |||
| */ | |||
| #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Operation flag */ | |||
| #define FLASH_FLAG_OPERR FLASH_SR_SOP /*!< FLASH operation Error flag */ | |||
| #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_PGPERR FLASH_SR_PGPERR /*!< FLASH Programming Parallelism error flag */ | |||
| #define FLASH_FLAG_PGSERR FLASH_SR_PGSERR /*!< FLASH Programming Sequence error flag */ | |||
| #define FLASH_FLAG_RDERR ((uint32_t)0x00000100) /*!< Read Protection error flag (PCROP) */ | |||
| #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASH_Interrupt_definition FLASH Interrupt definition | |||
| * @brief FLASH Interrupt definition | |||
| * @{ | |||
| */ | |||
| #define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */ | |||
| #define FLASH_IT_ERR ((uint32_t)0x02000000) /*!< Error Interrupt source */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASH_Program_Parallelism FLASH Program Parallelism | |||
| * @{ | |||
| */ | |||
| #define FLASH_PSIZE_BYTE ((uint32_t)0x00000000) | |||
| #define FLASH_PSIZE_HALF_WORD ((uint32_t)0x00000100) | |||
| #define FLASH_PSIZE_WORD ((uint32_t)0x00000200) | |||
| #define FLASH_PSIZE_DOUBLE_WORD ((uint32_t)0x00000300) | |||
| #define CR_PSIZE_MASK ((uint32_t)0xFFFFFCFF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASH_Keys FLASH Keys | |||
| * @{ | |||
| */ | |||
| #define RDP_KEY ((uint16_t)0x00A5) | |||
| #define FLASH_KEY1 ((uint32_t)0x45670123) | |||
| #define FLASH_KEY2 ((uint32_t)0xCDEF89AB) | |||
| #define FLASH_OPT_KEY1 ((uint32_t)0x08192A3B) | |||
| #define FLASH_OPT_KEY2 ((uint32_t)0x4C5D6E7F) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief ACR register byte 0 (Bits[7:0]) base address | |||
| */ | |||
| #define ACR_BYTE0_ADDRESS ((uint32_t)0x40023C00) | |||
| /** | |||
| * @brief OPTCR register byte 0 (Bits[7:0]) base address | |||
| */ | |||
| #define OPTCR_BYTE0_ADDRESS ((uint32_t)0x40023C14) | |||
| /** | |||
| * @brief OPTCR register byte 1 (Bits[15:8]) base address | |||
| */ | |||
| #define OPTCR_BYTE1_ADDRESS ((uint32_t)0x40023C15) | |||
| /** | |||
| * @brief OPTCR register byte 2 (Bits[23:16]) base address | |||
| */ | |||
| #define OPTCR_BYTE2_ADDRESS ((uint32_t)0x40023C16) | |||
| /** | |||
| * @brief OPTCR register byte 3 (Bits[31:24]) base address | |||
| */ | |||
| #define OPTCR_BYTE3_ADDRESS ((uint32_t)0x40023C17) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief Set the FLASH Latency. | |||
| * @param __LATENCY__: FLASH Latency | |||
| * The value of this parameter depend on device used within the same series | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (*(__IO uint8_t *)ACR_BYTE0_ADDRESS = (uint8_t)(__LATENCY__)) | |||
| /** | |||
| * @brief Enable the FLASH prefetch buffer. | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTEN) | |||
| /** | |||
| * @brief Disable the FLASH prefetch buffer. | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTEN)) | |||
| /** | |||
| * @brief Enable the FLASH instruction cache. | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_INSTRUCTION_CACHE_ENABLE() (FLASH->ACR |= FLASH_ACR_ICEN) | |||
| /** | |||
| * @brief Disable the FLASH instruction cache. | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_INSTRUCTION_CACHE_DISABLE() (FLASH->ACR &= (~FLASH_ACR_ICEN)) | |||
| /** | |||
| * @brief Enable the FLASH data cache. | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_DATA_CACHE_ENABLE() (FLASH->ACR |= FLASH_ACR_DCEN) | |||
| /** | |||
| * @brief Disable the FLASH data cache. | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_DATA_CACHE_DISABLE() (FLASH->ACR &= (~FLASH_ACR_DCEN)) | |||
| /** | |||
| * @brief Resets the FLASH instruction Cache. | |||
| * @note This function must be used only when the Instruction Cache is disabled. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_FLASH_INSTRUCTION_CACHE_RESET() (FLASH->ACR |= FLASH_ACR_ICRST) | |||
| /** | |||
| * @brief Resets the FLASH data Cache. | |||
| * @note This function must be used only when the data Cache is disabled. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_FLASH_DATA_CACHE_RESET() (FLASH->ACR |= FLASH_ACR_DCRST) | |||
| /** | |||
| * @brief Enable the specified FLASH interrupt. | |||
| * @param __INTERRUPT__ : FLASH interrupt | |||
| * This parameter can be any combination of the following values: | |||
| * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt | |||
| * @arg FLASH_IT_ERR: Error Interrupt | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) (FLASH->CR |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the specified FLASH interrupt. | |||
| * @param __INTERRUPT__ : FLASH interrupt | |||
| * This parameter can be any combination of the following values: | |||
| * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt | |||
| * @arg FLASH_IT_ERR: Error Interrupt | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) (FLASH->CR &= ~(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 FLASH_FLAG_EOP : FLASH End of Operation flag | |||
| * @arg FLASH_FLAG_OPERR : FLASH operation Error flag | |||
| * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag | |||
| * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag | |||
| * @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag | |||
| * @arg FLASH_FLAG_PGSERR: FLASH Programming Sequence error flag | |||
| * @arg FLASH_FLAG_RDERR : FLASH Read Protection error flag (PCROP) | |||
| * @arg FLASH_FLAG_BSY : FLASH Busy flag | |||
| * @retval The new state of __FLAG__ (SET or RESET). | |||
| */ | |||
| #define __HAL_FLASH_GET_FLAG(__FLAG__) ((FLASH->SR & (__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 FLASH_FLAG_EOP : FLASH End of Operation flag | |||
| * @arg FLASH_FLAG_OPERR : FLASH operation Error flag | |||
| * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag | |||
| * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag | |||
| * @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag | |||
| * @arg FLASH_FLAG_PGSERR: FLASH Programming Sequence error flag | |||
| * @arg FLASH_FLAG_RDERR : FLASH Read Protection error flag (PCROP) | |||
| * @retval none | |||
| */ | |||
| #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) (FLASH->SR = (__FLAG__)) | |||
| /* Include FLASH HAL Extension module */ | |||
| #include "stm32f4xx_hal_flash_ex.h" | |||
| #include "stm32f4xx_hal_flash_ramfunc.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Program operation functions ***********************************************/ | |||
| HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); | |||
| HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); | |||
| /* FLASH IRQ handler method */ | |||
| void HAL_FLASH_IRQHandler(void); | |||
| /* Callbacks in non blocking modes */ | |||
| void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); | |||
| void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); | |||
| /* 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); | |||
| /* Option bytes control */ | |||
| HAL_StatusTypeDef HAL_FLASH_OB_Launch(void); | |||
| /* Peripheral State functions ************************************************/ | |||
| FLASH_ErrorTypeDef HAL_FLASH_GetError(void); | |||
| HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_FLASH_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,759 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_flash_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of FLASH HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_FLASH_EX_H | |||
| #define __STM32F4xx_HAL_FLASH_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup FLASHEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief FLASH Erase structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t TypeErase; /*!< Mass erase or sector Erase. | |||
| This parameter can be a value of @ref FLASHEx_Type_Erase */ | |||
| uint32_t Banks; /*!< Select banks to erase when Mass erase is enabled. | |||
| This parameter must be a value of @ref FLASHEx_Banks */ | |||
| uint32_t Sector; /*!< Initial FLASH sector to erase when Mass erase is disabled | |||
| This parameter must be a value of @ref FLASHEx_Sectors */ | |||
| uint32_t NbSectors; /*!< Number of sectors to be erased. | |||
| This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/ | |||
| uint32_t VoltageRange;/*!< The device voltage range which defines the erase parallelism | |||
| This parameter must be a value of @ref FLASHEx_Voltage_Range */ | |||
| } FLASH_EraseInitTypeDef; | |||
| /** | |||
| * @brief FLASH Option Bytes Program structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t OptionType; /*!< Option byte to be configured. | |||
| This parameter can be a value of @ref FLASHEx_Option_Type */ | |||
| uint32_t WRPState; /*!< Write protection activation or deactivation. | |||
| This parameter can be a value of @ref FLASHEx_WRP_State */ | |||
| uint32_t WRPSector; /*!< Specifies the sector(s) to be write protected. | |||
| The value of this parameter depend on device used within the same series */ | |||
| uint32_t Banks; /*!< Select banks for WRP activation/deactivation of all sectors. | |||
| This parameter must be a value of @ref FLASHEx_Banks */ | |||
| uint32_t RDPLevel; /*!< Set the read protection level. | |||
| This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */ | |||
| uint32_t BORLevel; /*!< Set the BOR Level. | |||
| This parameter can be a value of @ref FLASHEx_BOR_Reset_Level */ | |||
| uint8_t USERConfig; /*!< Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. */ | |||
| } FLASH_OBProgramInitTypeDef; | |||
| /** | |||
| * @brief FLASH Advanced Option Bytes Program structure definition | |||
| */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| typedef struct | |||
| { | |||
| uint32_t OptionType; /*!< Option byte to be configured for extension. | |||
| This parameter can be a value of @ref FLASHEx_Advanced_Option_Type */ | |||
| uint32_t PCROPState; /*!< PCROP activation or deactivation. | |||
| This parameter can be a value of @ref FLASHEx_PCROP_State */ | |||
| #if defined (STM32F401xC) || defined (STM32F401xE) || defined (STM32F411xE) | |||
| uint16_t Sectors; /*!< specifies the sector(s) set for PCROP. | |||
| This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ | |||
| #endif /* STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| uint32_t Banks; /*!< Select banks for PCROP activation/deactivation of all sectors. | |||
| This parameter must be a value of @ref FLASHEx_Banks */ | |||
| uint16_t SectorsBank1; /*!< Specifies the sector(s) set for PCROP for Bank1. | |||
| This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ | |||
| uint16_t SectorsBank2; /*!< Specifies the sector(s) set for PCROP for Bank2. | |||
| This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ | |||
| uint8_t BootConfig; /*!< Specifies Option bytes for boot config. | |||
| This parameter can be a value of @ref FLASHEx_Dual_Boot */ | |||
| #endif /*STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| } FLASH_AdvOBProgramInitTypeDef; | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup FLASHEx_Type_Erase FLASH Type Erase | |||
| * @{ | |||
| */ | |||
| #define TYPEERASE_SECTORS ((uint32_t)0x00) /*!< Sectors erase only */ | |||
| #define TYPEERASE_MASSERASE ((uint32_t)0x01) /*!< Flash Mass erase activation */ | |||
| #define IS_TYPEERASE(VALUE)(((VALUE) == TYPEERASE_SECTORS) || \ | |||
| ((VALUE) == TYPEERASE_MASSERASE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Voltage_Range FLASH Voltage Range | |||
| * @{ | |||
| */ | |||
| #define VOLTAGE_RANGE_1 ((uint32_t)0x00) /*!< Device operating range: 1.8V to 2.1V */ | |||
| #define VOLTAGE_RANGE_2 ((uint32_t)0x01) /*!< Device operating range: 2.1V to 2.7V */ | |||
| #define VOLTAGE_RANGE_3 ((uint32_t)0x02) /*!< Device operating range: 2.7V to 3.6V */ | |||
| #define VOLTAGE_RANGE_4 ((uint32_t)0x03) /*!< Device operating range: 2.7V to 3.6V + External Vpp */ | |||
| #define IS_VOLTAGERANGE(RANGE)(((RANGE) == VOLTAGE_RANGE_1) || \ | |||
| ((RANGE) == VOLTAGE_RANGE_2) || \ | |||
| ((RANGE) == VOLTAGE_RANGE_3) || \ | |||
| ((RANGE) == VOLTAGE_RANGE_4)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_WRP_State FLASH WRP State | |||
| * @{ | |||
| */ | |||
| #define WRPSTATE_DISABLE ((uint32_t)0x00) /*!< Disable the write protection of the desired bank 1 sectors */ | |||
| #define WRPSTATE_ENABLE ((uint32_t)0x01) /*!< Enable the write protection of the desired bank 1 sectors */ | |||
| #define IS_WRPSTATE(VALUE)(((VALUE) == WRPSTATE_DISABLE) || \ | |||
| ((VALUE) == WRPSTATE_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Option_Type FLASH Option Type | |||
| * @{ | |||
| */ | |||
| #define OPTIONBYTE_WRP ((uint32_t)0x01) /*!< WRP option byte configuration */ | |||
| #define OPTIONBYTE_RDP ((uint32_t)0x02) /*!< RDP option byte configuration */ | |||
| #define OPTIONBYTE_USER ((uint32_t)0x04) /*!< USER option byte configuration */ | |||
| #define OPTIONBYTE_BOR ((uint32_t)0x08) /*!< BOR option byte configuration */ | |||
| #define IS_OPTIONBYTE(VALUE)(((VALUE) < (OPTIONBYTE_WRP|OPTIONBYTE_RDP|OPTIONBYTE_USER|OPTIONBYTE_BOR))) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASH Option Bytes Read Protection | |||
| * @{ | |||
| */ | |||
| #define OB_RDP_LEVEL_0 ((uint8_t)0xAA) | |||
| #define OB_RDP_LEVEL_1 ((uint8_t)0x55) | |||
| /*#define OB_RDP_LEVEL_2 ((uint8_t)0xCC)*/ /*!< Warning: When enabling read protection level 2 | |||
| it s no more possible to go back to level 1 or 0 */ | |||
| #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\ | |||
| ((LEVEL) == OB_RDP_LEVEL_1))/*||\ | |||
| ((LEVEL) == OB_RDP_LEVEL_2))*/ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASH Option Bytes IWatchdog | |||
| * @{ | |||
| */ | |||
| #define OB_IWDG_SW ((uint8_t)0x20) /*!< Software IWDG selected */ | |||
| #define OB_IWDG_HW ((uint8_t)0x00) /*!< Hardware IWDG selected */ | |||
| #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASH Option Bytes nRST_STOP | |||
| * @{ | |||
| */ | |||
| #define OB_STOP_NO_RST ((uint8_t)0x40) /*!< No reset generated when entering in STOP */ | |||
| #define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */ | |||
| #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASH Option Bytes nRST_STDBY | |||
| * @{ | |||
| */ | |||
| #define OB_STDBY_NO_RST ((uint8_t)0x80) /*!< No reset generated when entering in STANDBY */ | |||
| #define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */ | |||
| #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_BOR_Reset_Level FLASH BOR Reset Level | |||
| * @{ | |||
| */ | |||
| #define OB_BOR_LEVEL3 ((uint8_t)0x00) /*!< Supply voltage ranges from 2.70 to 3.60 V */ | |||
| #define OB_BOR_LEVEL2 ((uint8_t)0x04) /*!< Supply voltage ranges from 2.40 to 2.70 V */ | |||
| #define OB_BOR_LEVEL1 ((uint8_t)0x08) /*!< Supply voltage ranges from 2.10 to 2.40 V */ | |||
| #define OB_BOR_OFF ((uint8_t)0x0C) /*!< Supply voltage ranges from 1.62 to 2.10 V */ | |||
| #define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\ | |||
| ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF)) | |||
| /** | |||
| * @} | |||
| */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| /** @defgroup FLASHEx_PCROP_State FLASH PCROP State | |||
| * @{ | |||
| */ | |||
| #define PCROPSTATE_DISABLE ((uint32_t)0x00) /*!< Disable PCROP */ | |||
| #define PCROPSTATE_ENABLE ((uint32_t)0x01) /*!< Enable PCROP */ | |||
| #define IS_PCROPSTATE(VALUE)(((VALUE) == PCROPSTATE_DISABLE) || \ | |||
| ((VALUE) == PCROPSTATE_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| /** @defgroup FLASHEx_Advanced_Option_Type FLASH Advanced Option Type | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| #define OBEX_PCROP ((uint32_t)0x01) /*!< PCROP option byte configuration */ | |||
| #define OBEX_BOOTCONFIG ((uint32_t)0x02) /*!< BOOTConfig option byte configuration */ | |||
| #define IS_OBEX(VALUE)(((VALUE) == OBEX_PCROP) || \ | |||
| ((VALUE) == OBEX_BOOTCONFIG)) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define OBEX_PCROP ((uint32_t)0x01) /*!<PCROP option byte configuration */ | |||
| #define IS_OBEX(VALUE)(((VALUE) == OBEX_PCROP)) | |||
| #endif /* STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASH_Latency FLASH Latency | |||
| * @{ | |||
| */ | |||
| /*------------------------------------------- STM32F42xxx/STM32F43xxx------------------------------------------*/ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */ | |||
| #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */ | |||
| #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */ | |||
| #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */ | |||
| #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */ | |||
| #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */ | |||
| #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */ | |||
| #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */ | |||
| #define FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS /*!< FLASH Eight Latency cycles */ | |||
| #define FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS /*!< FLASH Nine Latency cycles */ | |||
| #define FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS /*!< FLASH Ten Latency cycles */ | |||
| #define FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS /*!< FLASH Eleven Latency cycles */ | |||
| #define FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS /*!< FLASH Twelve Latency cycles */ | |||
| #define FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS /*!< FLASH Thirteen Latency cycles */ | |||
| #define FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS /*!< FLASH Fourteen Latency cycles */ | |||
| #define FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS /*!< FLASH Fifteen Latency cycles */ | |||
| #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \ | |||
| ((LATENCY) == FLASH_LATENCY_1) || \ | |||
| ((LATENCY) == FLASH_LATENCY_2) || \ | |||
| ((LATENCY) == FLASH_LATENCY_3) || \ | |||
| ((LATENCY) == FLASH_LATENCY_4) || \ | |||
| ((LATENCY) == FLASH_LATENCY_5) || \ | |||
| ((LATENCY) == FLASH_LATENCY_6) || \ | |||
| ((LATENCY) == FLASH_LATENCY_7) || \ | |||
| ((LATENCY) == FLASH_LATENCY_8) || \ | |||
| ((LATENCY) == FLASH_LATENCY_9) || \ | |||
| ((LATENCY) == FLASH_LATENCY_10) || \ | |||
| ((LATENCY) == FLASH_LATENCY_11) || \ | |||
| ((LATENCY) == FLASH_LATENCY_12) || \ | |||
| ((LATENCY) == FLASH_LATENCY_13) || \ | |||
| ((LATENCY) == FLASH_LATENCY_14) || \ | |||
| ((LATENCY) == FLASH_LATENCY_15)) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| /*--------------------------------------------------------------------------------------------------------------*/ | |||
| /*-------------------------- STM32F40xxx/STM32F41xxx/STM32F401xx/STM32F411xx -----------------------------------*/ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */ | |||
| #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */ | |||
| #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */ | |||
| #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */ | |||
| #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */ | |||
| #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */ | |||
| #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */ | |||
| #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */ | |||
| #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \ | |||
| ((LATENCY) == FLASH_LATENCY_1) || \ | |||
| ((LATENCY) == FLASH_LATENCY_2) || \ | |||
| ((LATENCY) == FLASH_LATENCY_3) || \ | |||
| ((LATENCY) == FLASH_LATENCY_4) || \ | |||
| ((LATENCY) == FLASH_LATENCY_5) || \ | |||
| ((LATENCY) == FLASH_LATENCY_6) || \ | |||
| ((LATENCY) == FLASH_LATENCY_7)) | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| /*--------------------------------------------------------------------------------------------------------------*/ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Banks FLASH Banks | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #define FLASH_BANK_1 ((uint32_t)1) /*!< Bank 1 */ | |||
| #define FLASH_BANK_2 ((uint32_t)2) /*!< Bank 2 */ | |||
| #define FLASH_BANK_BOTH ((uint32_t)FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2 */ | |||
| #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \ | |||
| ((BANK) == FLASH_BANK_2) || \ | |||
| ((BANK) == FLASH_BANK_BOTH)) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define FLASH_BANK_1 ((uint32_t)1) /*!< Bank 1 */ | |||
| #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1)) | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_MassErase_bit FLASH Mass Erase bit | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #define FLASH_MER_BIT (FLASH_CR_MER1 | FLASH_CR_MER2) /*!< 2 MER bits here to clear */ | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define FLASH_MER_BIT (FLASH_CR_MER) /*!< only 1 MER Bit */ | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Sectors FLASH Sectors | |||
| * @{ | |||
| */ | |||
| /*------------------------------------------ STM32F42xxx/STM32F43xxx--------------------------------------*/ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #define FLASH_SECTOR_0 ((uint32_t)0) /*!< Sector Number 0 */ | |||
| #define FLASH_SECTOR_1 ((uint32_t)1) /*!< Sector Number 1 */ | |||
| #define FLASH_SECTOR_2 ((uint32_t)2) /*!< Sector Number 2 */ | |||
| #define FLASH_SECTOR_3 ((uint32_t)3) /*!< Sector Number 3 */ | |||
| #define FLASH_SECTOR_4 ((uint32_t)4) /*!< Sector Number 4 */ | |||
| #define FLASH_SECTOR_5 ((uint32_t)5) /*!< Sector Number 5 */ | |||
| #define FLASH_SECTOR_6 ((uint32_t)6) /*!< Sector Number 6 */ | |||
| #define FLASH_SECTOR_7 ((uint32_t)7) /*!< Sector Number 7 */ | |||
| #define FLASH_SECTOR_8 ((uint32_t)8) /*!< Sector Number 8 */ | |||
| #define FLASH_SECTOR_9 ((uint32_t)9) /*!< Sector Number 9 */ | |||
| #define FLASH_SECTOR_10 ((uint32_t)10) /*!< Sector Number 10 */ | |||
| #define FLASH_SECTOR_11 ((uint32_t)11) /*!< Sector Number 11 */ | |||
| #define FLASH_SECTOR_12 ((uint32_t)12) /*!< Sector Number 12 */ | |||
| #define FLASH_SECTOR_13 ((uint32_t)13) /*!< Sector Number 13 */ | |||
| #define FLASH_SECTOR_14 ((uint32_t)14) /*!< Sector Number 14 */ | |||
| #define FLASH_SECTOR_15 ((uint32_t)15) /*!< Sector Number 15 */ | |||
| #define FLASH_SECTOR_16 ((uint32_t)16) /*!< Sector Number 16 */ | |||
| #define FLASH_SECTOR_17 ((uint32_t)17) /*!< Sector Number 17 */ | |||
| #define FLASH_SECTOR_18 ((uint32_t)18) /*!< Sector Number 18 */ | |||
| #define FLASH_SECTOR_19 ((uint32_t)19) /*!< Sector Number 19 */ | |||
| #define FLASH_SECTOR_20 ((uint32_t)20) /*!< Sector Number 20 */ | |||
| #define FLASH_SECTOR_21 ((uint32_t)21) /*!< Sector Number 21 */ | |||
| #define FLASH_SECTOR_22 ((uint32_t)22) /*!< Sector Number 22 */ | |||
| #define FLASH_SECTOR_23 ((uint32_t)23) /*!< Sector Number 23 */ | |||
| #define FLASH_SECTOR_TOTAL 24 | |||
| #define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23)) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) | |||
| #define FLASH_SECTOR_0 ((uint32_t)0) /*!< Sector Number 0 */ | |||
| #define FLASH_SECTOR_1 ((uint32_t)1) /*!< Sector Number 1 */ | |||
| #define FLASH_SECTOR_2 ((uint32_t)2) /*!< Sector Number 2 */ | |||
| #define FLASH_SECTOR_3 ((uint32_t)3) /*!< Sector Number 3 */ | |||
| #define FLASH_SECTOR_4 ((uint32_t)4) /*!< Sector Number 4 */ | |||
| #define FLASH_SECTOR_5 ((uint32_t)5) /*!< Sector Number 5 */ | |||
| #define FLASH_SECTOR_6 ((uint32_t)6) /*!< Sector Number 6 */ | |||
| #define FLASH_SECTOR_7 ((uint32_t)7) /*!< Sector Number 7 */ | |||
| #define FLASH_SECTOR_8 ((uint32_t)8) /*!< Sector Number 8 */ | |||
| #define FLASH_SECTOR_9 ((uint32_t)9) /*!< Sector Number 9 */ | |||
| #define FLASH_SECTOR_10 ((uint32_t)10) /*!< Sector Number 10 */ | |||
| #define FLASH_SECTOR_11 ((uint32_t)11) /*!< Sector Number 11 */ | |||
| #define FLASH_SECTOR_TOTAL 12 | |||
| #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11)) | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /*--------------------------------------------- STM32F401xC -------------------------------------------*/ | |||
| #if defined(STM32F401xC) | |||
| #define FLASH_SECTOR_0 ((uint32_t)0) /*!< Sector Number 0 */ | |||
| #define FLASH_SECTOR_1 ((uint32_t)1) /*!< Sector Number 1 */ | |||
| #define FLASH_SECTOR_2 ((uint32_t)2) /*!< Sector Number 2 */ | |||
| #define FLASH_SECTOR_3 ((uint32_t)3) /*!< Sector Number 3 */ | |||
| #define FLASH_SECTOR_4 ((uint32_t)4) /*!< Sector Number 4 */ | |||
| #define FLASH_SECTOR_5 ((uint32_t)5) /*!< Sector Number 5 */ | |||
| #define FLASH_SECTOR_TOTAL 6 | |||
| #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5)) | |||
| #endif /* STM32F401xC */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /*--------------------------------------- STM32F401xE/STM32F411xE -------------------------------------*/ | |||
| #if defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define FLASH_SECTOR_0 ((uint32_t)0) /*!< Sector Number 0 */ | |||
| #define FLASH_SECTOR_1 ((uint32_t)1) /*!< Sector Number 1 */ | |||
| #define FLASH_SECTOR_2 ((uint32_t)2) /*!< Sector Number 2 */ | |||
| #define FLASH_SECTOR_3 ((uint32_t)3) /*!< Sector Number 3 */ | |||
| #define FLASH_SECTOR_4 ((uint32_t)4) /*!< Sector Number 4 */ | |||
| #define FLASH_SECTOR_5 ((uint32_t)5) /*!< Sector Number 5 */ | |||
| #define FLASH_SECTOR_6 ((uint32_t)6) /*!< Sector Number 6 */ | |||
| #define FLASH_SECTOR_7 ((uint32_t)7) /*!< Sector Number 7 */ | |||
| #define FLASH_SECTOR_TOTAL 8 | |||
| #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\ | |||
| ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7)) | |||
| #endif /* STM32F401xE || STM32F411xE */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < FLASH_END)) | |||
| #define IS_NBSECTORS(NBSECTORS) (((NBSECTORS) != 0) && ((NBSECTORS) <= FLASH_SECTOR_TOTAL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection | |||
| * @{ | |||
| */ | |||
| /*----------------------------------------- STM32F42xxx/STM32F43xxx-------------------------------------*/ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001) /*!< Write protection of Sector0 */ | |||
| #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002) /*!< Write protection of Sector1 */ | |||
| #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004) /*!< Write protection of Sector2 */ | |||
| #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008) /*!< Write protection of Sector3 */ | |||
| #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010) /*!< Write protection of Sector4 */ | |||
| #define OB_WRP_SECTOR_5 ((uint32_t)0x00000020) /*!< Write protection of Sector5 */ | |||
| #define OB_WRP_SECTOR_6 ((uint32_t)0x00000040) /*!< Write protection of Sector6 */ | |||
| #define OB_WRP_SECTOR_7 ((uint32_t)0x00000080) /*!< Write protection of Sector7 */ | |||
| #define OB_WRP_SECTOR_8 ((uint32_t)0x00000100) /*!< Write protection of Sector8 */ | |||
| #define OB_WRP_SECTOR_9 ((uint32_t)0x00000200) /*!< Write protection of Sector9 */ | |||
| #define OB_WRP_SECTOR_10 ((uint32_t)0x00000400) /*!< Write protection of Sector10 */ | |||
| #define OB_WRP_SECTOR_11 ((uint32_t)0x00000800) /*!< Write protection of Sector11 */ | |||
| #define OB_WRP_SECTOR_12 ((uint32_t)0x00000001 << 12) /*!< Write protection of Sector12 */ | |||
| #define OB_WRP_SECTOR_13 ((uint32_t)0x00000002 << 12) /*!< Write protection of Sector13 */ | |||
| #define OB_WRP_SECTOR_14 ((uint32_t)0x00000004 << 12) /*!< Write protection of Sector14 */ | |||
| #define OB_WRP_SECTOR_15 ((uint32_t)0x00000008 << 12) /*!< Write protection of Sector15 */ | |||
| #define OB_WRP_SECTOR_16 ((uint32_t)0x00000010 << 12) /*!< Write protection of Sector16 */ | |||
| #define OB_WRP_SECTOR_17 ((uint32_t)0x00000020 << 12) /*!< Write protection of Sector17 */ | |||
| #define OB_WRP_SECTOR_18 ((uint32_t)0x00000040 << 12) /*!< Write protection of Sector18 */ | |||
| #define OB_WRP_SECTOR_19 ((uint32_t)0x00000080 << 12) /*!< Write protection of Sector19 */ | |||
| #define OB_WRP_SECTOR_20 ((uint32_t)0x00000100 << 12) /*!< Write protection of Sector20 */ | |||
| #define OB_WRP_SECTOR_21 ((uint32_t)0x00000200 << 12) /*!< Write protection of Sector21 */ | |||
| #define OB_WRP_SECTOR_22 ((uint32_t)0x00000400 << 12) /*!< Write protection of Sector22 */ | |||
| #define OB_WRP_SECTOR_23 ((uint32_t)0x00000800 << 12) /*!< Write protection of Sector23 */ | |||
| #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF << 12) /*!< Write protection of all Sectors */ | |||
| #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFF000000) == 0x00000000) && ((SECTOR) != 0x00000000)) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) | |||
| #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001) /*!< Write protection of Sector0 */ | |||
| #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002) /*!< Write protection of Sector1 */ | |||
| #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004) /*!< Write protection of Sector2 */ | |||
| #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008) /*!< Write protection of Sector3 */ | |||
| #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010) /*!< Write protection of Sector4 */ | |||
| #define OB_WRP_SECTOR_5 ((uint32_t)0x00000020) /*!< Write protection of Sector5 */ | |||
| #define OB_WRP_SECTOR_6 ((uint32_t)0x00000040) /*!< Write protection of Sector6 */ | |||
| #define OB_WRP_SECTOR_7 ((uint32_t)0x00000080) /*!< Write protection of Sector7 */ | |||
| #define OB_WRP_SECTOR_8 ((uint32_t)0x00000100) /*!< Write protection of Sector8 */ | |||
| #define OB_WRP_SECTOR_9 ((uint32_t)0x00000200) /*!< Write protection of Sector9 */ | |||
| #define OB_WRP_SECTOR_10 ((uint32_t)0x00000400) /*!< Write protection of Sector10 */ | |||
| #define OB_WRP_SECTOR_11 ((uint32_t)0x00000800) /*!< Write protection of Sector11 */ | |||
| #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF) /*!< Write protection of all Sectors */ | |||
| #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000)) | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /*--------------------------------------------- STM32F401xC -------------------------------------------*/ | |||
| #if defined(STM32F401xC) | |||
| #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001) /*!< Write protection of Sector0 */ | |||
| #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002) /*!< Write protection of Sector1 */ | |||
| #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004) /*!< Write protection of Sector2 */ | |||
| #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008) /*!< Write protection of Sector3 */ | |||
| #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010) /*!< Write protection of Sector4 */ | |||
| #define OB_WRP_SECTOR_5 ((uint32_t)0x00000020) /*!< Write protection of Sector5 */ | |||
| #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF) /*!< Write protection of all Sectors */ | |||
| #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000)) | |||
| #endif /* STM32F401xC */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /*--------------------------------------- STM32F401xE/STM32F411xE -------------------------------------*/ | |||
| #if defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define OB_WRP_SECTOR_0 ((uint32_t)0x00000001) /*!< Write protection of Sector0 */ | |||
| #define OB_WRP_SECTOR_1 ((uint32_t)0x00000002) /*!< Write protection of Sector1 */ | |||
| #define OB_WRP_SECTOR_2 ((uint32_t)0x00000004) /*!< Write protection of Sector2 */ | |||
| #define OB_WRP_SECTOR_3 ((uint32_t)0x00000008) /*!< Write protection of Sector3 */ | |||
| #define OB_WRP_SECTOR_4 ((uint32_t)0x00000010) /*!< Write protection of Sector4 */ | |||
| #define OB_WRP_SECTOR_5 ((uint32_t)0x00000020) /*!< Write protection of Sector5 */ | |||
| #define OB_WRP_SECTOR_6 ((uint32_t)0x00000040) /*!< Write protection of Sector6 */ | |||
| #define OB_WRP_SECTOR_7 ((uint32_t)0x00000080) /*!< Write protection of Sector7 */ | |||
| #define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF) /*!< Write protection of all Sectors */ | |||
| #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000)) | |||
| #endif /* STM32F401xE || STM32F411xE */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASH Option Bytes PC ReadWrite Protection | |||
| * @{ | |||
| */ | |||
| /*----------------------------------------- STM32F42xxx/STM32F43xxx-------------------------------------*/ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001) /*!< PC Read/Write protection of Sector0 */ | |||
| #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002) /*!< PC Read/Write protection of Sector1 */ | |||
| #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004) /*!< PC Read/Write protection of Sector2 */ | |||
| #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008) /*!< PC Read/Write protection of Sector3 */ | |||
| #define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010) /*!< PC Read/Write protection of Sector4 */ | |||
| #define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020) /*!< PC Read/Write protection of Sector5 */ | |||
| #define OB_PCROP_SECTOR_6 ((uint32_t)0x00000040) /*!< PC Read/Write protection of Sector6 */ | |||
| #define OB_PCROP_SECTOR_7 ((uint32_t)0x00000080) /*!< PC Read/Write protection of Sector7 */ | |||
| #define OB_PCROP_SECTOR_8 ((uint32_t)0x00000100) /*!< PC Read/Write protection of Sector8 */ | |||
| #define OB_PCROP_SECTOR_9 ((uint32_t)0x00000200) /*!< PC Read/Write protection of Sector9 */ | |||
| #define OB_PCROP_SECTOR_10 ((uint32_t)0x00000400) /*!< PC Read/Write protection of Sector10 */ | |||
| #define OB_PCROP_SECTOR_11 ((uint32_t)0x00000800) /*!< PC Read/Write protection of Sector11 */ | |||
| #define OB_PCROP_SECTOR_12 ((uint32_t)0x00000001) /*!< PC Read/Write protection of Sector12 */ | |||
| #define OB_PCROP_SECTOR_13 ((uint32_t)0x00000002) /*!< PC Read/Write protection of Sector13 */ | |||
| #define OB_PCROP_SECTOR_14 ((uint32_t)0x00000004) /*!< PC Read/Write protection of Sector14 */ | |||
| #define OB_PCROP_SECTOR_15 ((uint32_t)0x00000008) /*!< PC Read/Write protection of Sector15 */ | |||
| #define OB_PCROP_SECTOR_16 ((uint32_t)0x00000010) /*!< PC Read/Write protection of Sector16 */ | |||
| #define OB_PCROP_SECTOR_17 ((uint32_t)0x00000020) /*!< PC Read/Write protection of Sector17 */ | |||
| #define OB_PCROP_SECTOR_18 ((uint32_t)0x00000040) /*!< PC Read/Write protection of Sector18 */ | |||
| #define OB_PCROP_SECTOR_19 ((uint32_t)0x00000080) /*!< PC Read/Write protection of Sector19 */ | |||
| #define OB_PCROP_SECTOR_20 ((uint32_t)0x00000100) /*!< PC Read/Write protection of Sector20 */ | |||
| #define OB_PCROP_SECTOR_21 ((uint32_t)0x00000200) /*!< PC Read/Write protection of Sector21 */ | |||
| #define OB_PCROP_SECTOR_22 ((uint32_t)0x00000400) /*!< PC Read/Write protection of Sector22 */ | |||
| #define OB_PCROP_SECTOR_23 ((uint32_t)0x00000800) /*!< PC Read/Write protection of Sector23 */ | |||
| #define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFF) /*!< PC Read/Write protection of all Sectors */ | |||
| #define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000)) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /*--------------------------------------------- STM32F401xC -------------------------------------------*/ | |||
| #if defined(STM32F401xC) | |||
| #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001) /*!< PC Read/Write protection of Sector0 */ | |||
| #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002) /*!< PC Read/Write protection of Sector1 */ | |||
| #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004) /*!< PC Read/Write protection of Sector2 */ | |||
| #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008) /*!< PC Read/Write protection of Sector3 */ | |||
| #define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010) /*!< PC Read/Write protection of Sector4 */ | |||
| #define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020) /*!< PC Read/Write protection of Sector5 */ | |||
| #define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFF) /*!< PC Read/Write protection of all Sectors */ | |||
| #define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000)) | |||
| #endif /* STM32F401xC */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /*--------------------------------------- STM32F401xE/STM32F411xE -------------------------------------*/ | |||
| #if defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001) /*!< PC Read/Write protection of Sector0 */ | |||
| #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002) /*!< PC Read/Write protection of Sector1 */ | |||
| #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004) /*!< PC Read/Write protection of Sector2 */ | |||
| #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008) /*!< PC Read/Write protection of Sector3 */ | |||
| #define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010) /*!< PC Read/Write protection of Sector4 */ | |||
| #define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020) /*!< PC Read/Write protection of Sector5 */ | |||
| #define OB_PCROP_SECTOR_6 ((uint32_t)0x00000040) /*!< PC Read/Write protection of Sector6 */ | |||
| #define OB_PCROP_SECTOR_7 ((uint32_t)0x00000080) /*!< PC Read/Write protection of Sector7 */ | |||
| #define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFF) /*!< PC Read/Write protection of all Sectors */ | |||
| #define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000)) | |||
| #endif /* STM32F401xE || STM32F411xE */ | |||
| /*-----------------------------------------------------------------------------------------------------*/ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Dual_Boot FLASH Dual Boot | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #define OB_DUAL_BOOT_ENABLE ((uint8_t)0x10) /*!< Dual Bank Boot Enable */ | |||
| #define OB_DUAL_BOOT_DISABLE ((uint8_t)0x00) /*!< Dual Bank Boot Disable, always boot on User Flash */ | |||
| #define IS_OB_BOOT(BOOT) (((BOOT) == OB_DUAL_BOOT_ENABLE) || ((BOOT) == OB_DUAL_BOOT_DISABLE)) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASHEx_Selection_Protection_Mode FLASH Selection Protection Mode | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define OB_PCROP_DESELECTED ((uint8_t)0x00) /*!< Disabled PcROP, nWPRi bits used for Write Protection on sector i */ | |||
| #define OB_PCROP_SELECTED ((uint8_t)0x80) /*!< Enable PcROP, nWPRi bits used for PCRoP Protection on sector i */ | |||
| #define IS_OB_PCROP_SELECT(PCROP) (((PCROP) == OB_PCROP_SELECTED) || ((PCROP) == OB_PCROP_DESELECTED)) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief OPTCR1 register byte 2 (Bits[23:16]) base address | |||
| */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #define OPTCR1_BYTE2_ADDRESS ((uint32_t)0x40023C1A) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Extension Program operation functions *************************************/ | |||
| HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError); | |||
| HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); | |||
| HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); | |||
| void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram (FLASH_AdvOBProgramInitTypeDef *pAdvOBInit); | |||
| void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit); | |||
| HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void); | |||
| HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void); | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| uint16_t HAL_FLASHEx_OB_GetBank2WRP(void); | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */ | |||
| void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_FLASH_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,84 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_flash_ramfunc.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of FLASH RAMFUNC driver. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_FLASH_RAMFUNC_H | |||
| #define __STM32F4xx_FLASH_RAMFUNC_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F411xE) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup FLASH_RAMFUNC | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| __RAM_FUNC HAL_FLASHEx_StopFlashInterfaceClk(void); | |||
| __RAM_FUNC HAL_FLASHEx_StartFlashInterfaceClk(void); | |||
| __RAM_FUNC HAL_FLASHEx_EnableFlashSleepMode(void); | |||
| __RAM_FUNC HAL_FLASHEx_DisableFlashSleepMode(void); | |||
| #endif /* STM32F411xE */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,271 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_gpio.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of GPIO HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_GPIO_H | |||
| #define __STM32F4xx_HAL_GPIO_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup GPIO | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief GPIO Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Pin; /*!< Specifies the GPIO pins to be configured. | |||
| This parameter can be any value 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 GPIO_Alternat_function_selection */ | |||
| }GPIO_InitTypeDef; | |||
| /** | |||
| * @brief GPIO Bit SET and Bit RESET enumeration | |||
| */ | |||
| typedef enum | |||
| { | |||
| GPIO_PIN_RESET = 0, | |||
| 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 | |||
| * @{ | |||
| */ | |||
| /** @defgroup GPIO_pins_define | |||
| * @{ | |||
| */ | |||
| #define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */ | |||
| #define GPIO_PIN_1 ((uint16_t)0x0002) /* Pin 1 selected */ | |||
| #define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */ | |||
| #define GPIO_PIN_3 ((uint16_t)0x0008) /* Pin 3 selected */ | |||
| #define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */ | |||
| #define GPIO_PIN_5 ((uint16_t)0x0020) /* Pin 5 selected */ | |||
| #define GPIO_PIN_6 ((uint16_t)0x0040) /* Pin 6 selected */ | |||
| #define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */ | |||
| #define GPIO_PIN_8 ((uint16_t)0x0100) /* Pin 8 selected */ | |||
| #define GPIO_PIN_9 ((uint16_t)0x0200) /* Pin 9 selected */ | |||
| #define GPIO_PIN_10 ((uint16_t)0x0400) /* Pin 10 selected */ | |||
| #define GPIO_PIN_11 ((uint16_t)0x0800) /* Pin 11 selected */ | |||
| #define GPIO_PIN_12 ((uint16_t)0x1000) /* Pin 12 selected */ | |||
| #define GPIO_PIN_13 ((uint16_t)0x2000) /* Pin 13 selected */ | |||
| #define GPIO_PIN_14 ((uint16_t)0x4000) /* Pin 14 selected */ | |||
| #define GPIO_PIN_15 ((uint16_t)0x8000) /* Pin 15 selected */ | |||
| #define GPIO_PIN_All ((uint16_t)0xFFFF) /* All pins selected */ | |||
| #define GPIO_PIN_MASK ((uint32_t)0x0000FFFF) /* PIN mask for assert test */ | |||
| #define IS_GPIO_PIN(PIN) (((PIN) & GPIO_PIN_MASK ) != (uint32_t)0x00) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup GPIO_mode_define | |||
| * @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 ((uint32_t)0x00000000) /*!< Input Floating Mode */ | |||
| #define GPIO_MODE_OUTPUT_PP ((uint32_t)0x00000001) /*!< Output Push Pull Mode */ | |||
| #define GPIO_MODE_OUTPUT_OD ((uint32_t)0x00000011) /*!< Output Open Drain Mode */ | |||
| #define GPIO_MODE_AF_PP ((uint32_t)0x00000002) /*!< Alternate Function Push Pull Mode */ | |||
| #define GPIO_MODE_AF_OD ((uint32_t)0x00000012) /*!< Alternate Function Open Drain Mode */ | |||
| #define GPIO_MODE_ANALOG ((uint32_t)0x00000003) /*!< Analog Mode */ | |||
| #define GPIO_MODE_IT_RISING ((uint32_t)0x10110000) /*!< External Interrupt Mode with Rising edge trigger detection */ | |||
| #define GPIO_MODE_IT_FALLING ((uint32_t)0x10210000) /*!< External Interrupt Mode with Falling edge trigger detection */ | |||
| #define GPIO_MODE_IT_RISING_FALLING ((uint32_t)0x10310000) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ | |||
| #define GPIO_MODE_EVT_RISING ((uint32_t)0x10120000) /*!< External Event Mode with Rising edge trigger detection */ | |||
| #define GPIO_MODE_EVT_FALLING ((uint32_t)0x10220000) /*!< External Event Mode with Falling edge trigger detection */ | |||
| #define GPIO_MODE_EVT_RISING_FALLING ((uint32_t)0x10320000) /*!< 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 | |||
| * @brief GPIO Output Maximum frequency | |||
| * @{ | |||
| */ | |||
| #define GPIO_SPEED_LOW ((uint32_t)0x00000000) /*!< Low speed */ | |||
| #define GPIO_SPEED_MEDIUM ((uint32_t)0x00000001) /*!< Medium speed */ | |||
| #define GPIO_SPEED_FAST ((uint32_t)0x00000002) /*!< Fast speed */ | |||
| #define GPIO_SPEED_HIGH ((uint32_t)0x00000003) /*!< High speed */ | |||
| #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_SPEED_LOW) || ((SPEED) == GPIO_SPEED_MEDIUM) || \ | |||
| ((SPEED) == GPIO_SPEED_FAST) || ((SPEED) == GPIO_SPEED_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup GPIO_pull_define | |||
| * @brief GPIO Pull-Up or Pull-Down Activation | |||
| * @{ | |||
| */ | |||
| #define GPIO_NOPULL ((uint32_t)0x00000000) /*!< No Pull-up or Pull-down activation */ | |||
| #define GPIO_PULLUP ((uint32_t)0x00000001) /*!< Pull-up activation */ | |||
| #define GPIO_PULLDOWN ((uint32_t)0x00000002) /*!< Pull-down activation */ | |||
| #define IS_GPIO_PULL(PULL) (((PULL) == GPIO_NOPULL) || ((PULL) == GPIO_PULLUP) || \ | |||
| ((PULL) == GPIO_PULLDOWN)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** | |||
| * @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 "stm32f4xx_hal_gpio_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* 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 *******************************************************/ | |||
| 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); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_GPIO_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,826 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_gpio_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of GPIO HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_GPIO_EX_H | |||
| #define __STM32F4xx_HAL_GPIO_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup GPIO | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup GPIO_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup GPIO_Alternat_function_selection | |||
| * @{ | |||
| */ | |||
| /*------------------------- STM32F429xx/STM32F439xx---------------------------*/ | |||
| #if defined (STM32F429xx) || defined (STM32F439xx) | |||
| /** | |||
| * @brief AF 0 selection | |||
| */ | |||
| #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ | |||
| #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ | |||
| #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ | |||
| #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ | |||
| #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 1 selection | |||
| */ | |||
| #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ | |||
| #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 2 selection | |||
| */ | |||
| #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 3 selection | |||
| */ | |||
| #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 4 selection | |||
| */ | |||
| #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 5 selection | |||
| */ | |||
| #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI5 ((uint8_t)0x05) /* SPI5 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI6 ((uint8_t)0x05) /* SPI6 Alternate Function mapping */ | |||
| #define GPIO_AF5_I2S3ext ((uint8_t)0x05) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 6 selection | |||
| */ | |||
| #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ | |||
| #define GPIO_AF6_I2S2ext ((uint8_t)0x06) /* I2S2ext_SD Alternate Function mapping */ | |||
| #define GPIO_AF6_SAI1 ((uint8_t)0x06) /* SAI1 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 7 selection | |||
| */ | |||
| #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ | |||
| #define GPIO_AF7_I2S3ext ((uint8_t)0x07) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 8 selection | |||
| */ | |||
| #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ | |||
| #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ | |||
| #define GPIO_AF8_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ | |||
| #define GPIO_AF8_UART7 ((uint8_t)0x08) /* UART7 Alternate Function mapping */ | |||
| #define GPIO_AF8_UART8 ((uint8_t)0x08) /* UART8 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 9 selection | |||
| */ | |||
| #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */ | |||
| #define GPIO_AF9_CAN2 ((uint8_t)0x09) /* CAN2 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM12 ((uint8_t)0x09) /* TIM12 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ | |||
| #define GPIO_AF9_LTDC ((uint8_t)0x09) /* LCD-TFT Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 10 selection | |||
| */ | |||
| #define GPIO_AF10_OTG_FS ((uint8_t)0xA) /* OTG_FS Alternate Function mapping */ | |||
| #define GPIO_AF10_OTG_HS ((uint8_t)0xA) /* OTG_HS Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 11 selection | |||
| */ | |||
| #define GPIO_AF11_ETH ((uint8_t)0x0B) /* ETHERNET Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 12 selection | |||
| */ | |||
| #define GPIO_AF12_FMC ((uint8_t)0xC) /* FMC Alternate Function mapping */ | |||
| #define GPIO_AF12_OTG_HS_FS ((uint8_t)0xC) /* OTG HS configured in FS, Alternate Function mapping */ | |||
| #define GPIO_AF12_SDIO ((uint8_t)0xC) /* SDIO Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 13 selection | |||
| */ | |||
| #define GPIO_AF13_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 14 selection | |||
| */ | |||
| #define GPIO_AF14_LTDC ((uint8_t)0x0E) /* LCD-TFT Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 15 selection | |||
| */ | |||
| #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ | |||
| #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ | |||
| ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ | |||
| ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ | |||
| ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ | |||
| ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ | |||
| ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ | |||
| ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ | |||
| ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ | |||
| ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ | |||
| ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ | |||
| ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ | |||
| ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ | |||
| ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ | |||
| ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ | |||
| ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ | |||
| ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ | |||
| ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ | |||
| ((AF) == GPIO_AF15_EVENTOUT) || ((AF) == GPIO_AF5_SPI4) || \ | |||
| ((AF) == GPIO_AF5_SPI5) || ((AF) == GPIO_AF5_SPI6) || \ | |||
| ((AF) == GPIO_AF8_UART7) || ((AF) == GPIO_AF8_UART8) || \ | |||
| ((AF) == GPIO_AF12_FMC) || ((AF) == GPIO_AF6_SAI1) || \ | |||
| ((AF) == GPIO_AF14_LTDC)) | |||
| #endif /* STM32F429xx || STM32F439xx */ | |||
| /*------------------------------------------------------------------------------------------*/ | |||
| /*---------------------------------- STM32F427xx/STM32F437xx--------------------------------*/ | |||
| #if defined (STM32F427xx) || defined (STM32F437xx) | |||
| /** | |||
| * @brief AF 0 selection | |||
| */ | |||
| #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ | |||
| #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ | |||
| #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ | |||
| #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ | |||
| #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 1 selection | |||
| */ | |||
| #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ | |||
| #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 2 selection | |||
| */ | |||
| #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 3 selection | |||
| */ | |||
| #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 4 selection | |||
| */ | |||
| #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 5 selection | |||
| */ | |||
| #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI5 ((uint8_t)0x05) /* SPI5 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI6 ((uint8_t)0x05) /* SPI6 Alternate Function mapping */ | |||
| #define GPIO_AF5_I2S3ext ((uint8_t)0x05) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 6 selection | |||
| */ | |||
| #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ | |||
| #define GPIO_AF6_I2S2ext ((uint8_t)0x06) /* I2S2ext_SD Alternate Function mapping */ | |||
| #define GPIO_AF6_SAI1 ((uint8_t)0x06) /* SAI1 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 7 selection | |||
| */ | |||
| #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ | |||
| #define GPIO_AF7_I2S3ext ((uint8_t)0x07) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 8 selection | |||
| */ | |||
| #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ | |||
| #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ | |||
| #define GPIO_AF8_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ | |||
| #define GPIO_AF8_UART7 ((uint8_t)0x08) /* UART7 Alternate Function mapping */ | |||
| #define GPIO_AF8_UART8 ((uint8_t)0x08) /* UART8 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 9 selection | |||
| */ | |||
| #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */ | |||
| #define GPIO_AF9_CAN2 ((uint8_t)0x09) /* CAN2 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM12 ((uint8_t)0x09) /* TIM12 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 10 selection | |||
| */ | |||
| #define GPIO_AF10_OTG_FS ((uint8_t)0xA) /* OTG_FS Alternate Function mapping */ | |||
| #define GPIO_AF10_OTG_HS ((uint8_t)0xA) /* OTG_HS Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 11 selection | |||
| */ | |||
| #define GPIO_AF11_ETH ((uint8_t)0x0B) /* ETHERNET Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 12 selection | |||
| */ | |||
| #define GPIO_AF12_FMC ((uint8_t)0xC) /* FMC Alternate Function mapping */ | |||
| #define GPIO_AF12_OTG_HS_FS ((uint8_t)0xC) /* OTG HS configured in FS, Alternate Function mapping */ | |||
| #define GPIO_AF12_SDIO ((uint8_t)0xC) /* SDIO Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 13 selection | |||
| */ | |||
| #define GPIO_AF13_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 15 selection | |||
| */ | |||
| #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ | |||
| #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ | |||
| ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ | |||
| ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ | |||
| ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ | |||
| ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ | |||
| ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ | |||
| ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ | |||
| ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ | |||
| ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ | |||
| ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ | |||
| ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ | |||
| ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ | |||
| ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ | |||
| ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ | |||
| ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ | |||
| ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ | |||
| ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ | |||
| ((AF) == GPIO_AF15_EVENTOUT) || ((AF) == GPIO_AF5_SPI4) || \ | |||
| ((AF) == GPIO_AF5_SPI5) || ((AF) == GPIO_AF5_SPI6) || \ | |||
| ((AF) == GPIO_AF8_UART7) || ((AF) == GPIO_AF8_UART8) || \ | |||
| ((AF) == GPIO_AF12_FMC) || ((AF) == GPIO_AF6_SAI1)) | |||
| #endif /* STM32F427xx || STM32F437xx */ | |||
| /*------------------------------------------------------------------------------------------*/ | |||
| /*---------------------------------- STM32F407xx/STM32F417xx--------------------------------*/ | |||
| #if defined (STM32F407xx) || defined (STM32F417xx) | |||
| /** | |||
| * @brief AF 0 selection | |||
| */ | |||
| #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ | |||
| #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ | |||
| #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ | |||
| #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ | |||
| #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 1 selection | |||
| */ | |||
| #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ | |||
| #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 2 selection | |||
| */ | |||
| #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 3 selection | |||
| */ | |||
| #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 4 selection | |||
| */ | |||
| #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 5 selection | |||
| */ | |||
| #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ | |||
| #define GPIO_AF5_I2S3ext ((uint8_t)0x05) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 6 selection | |||
| */ | |||
| #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ | |||
| #define GPIO_AF6_I2S2ext ((uint8_t)0x06) /* I2S2ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 7 selection | |||
| */ | |||
| #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ | |||
| #define GPIO_AF7_I2S3ext ((uint8_t)0x07) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 8 selection | |||
| */ | |||
| #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ | |||
| #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ | |||
| #define GPIO_AF8_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 9 selection | |||
| */ | |||
| #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */ | |||
| #define GPIO_AF9_CAN2 ((uint8_t)0x09) /* CAN2 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM12 ((uint8_t)0x09) /* TIM12 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 10 selection | |||
| */ | |||
| #define GPIO_AF10_OTG_FS ((uint8_t)0xA) /* OTG_FS Alternate Function mapping */ | |||
| #define GPIO_AF10_OTG_HS ((uint8_t)0xA) /* OTG_HS Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 11 selection | |||
| */ | |||
| #define GPIO_AF11_ETH ((uint8_t)0x0B) /* ETHERNET Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 12 selection | |||
| */ | |||
| #define GPIO_AF12_FSMC ((uint8_t)0xC) /* FSMC Alternate Function mapping */ | |||
| #define GPIO_AF12_OTG_HS_FS ((uint8_t)0xC) /* OTG HS configured in FS, Alternate Function mapping */ | |||
| #define GPIO_AF12_SDIO ((uint8_t)0xC) /* SDIO Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 13 selection | |||
| */ | |||
| #define GPIO_AF13_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 15 selection | |||
| */ | |||
| #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ | |||
| #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ | |||
| ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ | |||
| ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ | |||
| ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ | |||
| ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ | |||
| ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ | |||
| ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ | |||
| ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ | |||
| ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ | |||
| ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ | |||
| ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ | |||
| ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ | |||
| ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ | |||
| ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ | |||
| ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ | |||
| ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ | |||
| ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ | |||
| ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT)) | |||
| #endif /* STM32F407xx || STM32F417xx */ | |||
| /*------------------------------------------------------------------------------------------*/ | |||
| /*---------------------------------- STM32F405xx/STM32F415xx--------------------------------*/ | |||
| #if defined (STM32F405xx) || defined (STM32F415xx) | |||
| /** | |||
| * @brief AF 0 selection | |||
| */ | |||
| #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ | |||
| #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ | |||
| #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ | |||
| #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ | |||
| #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 1 selection | |||
| */ | |||
| #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ | |||
| #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 2 selection | |||
| */ | |||
| #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 3 selection | |||
| */ | |||
| #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 4 selection | |||
| */ | |||
| #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 5 selection | |||
| */ | |||
| #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ | |||
| #define GPIO_AF5_I2S3ext ((uint8_t)0x05) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 6 selection | |||
| */ | |||
| #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ | |||
| #define GPIO_AF6_I2S2ext ((uint8_t)0x06) /* I2S2ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 7 selection | |||
| */ | |||
| #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ | |||
| #define GPIO_AF7_I2S3ext ((uint8_t)0x07) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 8 selection | |||
| */ | |||
| #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ | |||
| #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ | |||
| #define GPIO_AF8_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 9 selection | |||
| */ | |||
| #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */ | |||
| #define GPIO_AF9_CAN2 ((uint8_t)0x09) /* CAN2 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM12 ((uint8_t)0x09) /* TIM12 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ | |||
| #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 10 selection | |||
| */ | |||
| #define GPIO_AF10_OTG_FS ((uint8_t)0xA) /* OTG_FS Alternate Function mapping */ | |||
| #define GPIO_AF10_OTG_HS ((uint8_t)0xA) /* OTG_HS Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 12 selection | |||
| */ | |||
| #define GPIO_AF12_FSMC ((uint8_t)0xC) /* FSMC Alternate Function mapping */ | |||
| #define GPIO_AF12_OTG_HS_FS ((uint8_t)0xC) /* OTG HS configured in FS, Alternate Function mapping */ | |||
| #define GPIO_AF12_SDIO ((uint8_t)0xC) /* SDIO Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 15 selection | |||
| */ | |||
| #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ | |||
| #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ | |||
| ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ | |||
| ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ | |||
| ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ | |||
| ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ | |||
| ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ | |||
| ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ | |||
| ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ | |||
| ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ | |||
| ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ | |||
| ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ | |||
| ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ | |||
| ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ | |||
| ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ | |||
| ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ | |||
| ((AF) == GPIO_AF12_OTG_HS_FS) || ((AF) == GPIO_AF12_SDIO) || \ | |||
| ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT)) | |||
| #endif /* STM32F405xx || STM32F415xx */ | |||
| /*------------------------------------------------------------------------------------------*/ | |||
| /*---------------------------------------- STM32F401xx--------------------------------------*/ | |||
| #if defined(STM32F401xC) || defined(STM32F401xE) | |||
| /** | |||
| * @brief AF 0 selection | |||
| */ | |||
| #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ | |||
| #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ | |||
| #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ | |||
| #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ | |||
| #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 1 selection | |||
| */ | |||
| #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ | |||
| #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 2 selection | |||
| */ | |||
| #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 3 selection | |||
| */ | |||
| #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 4 selection | |||
| */ | |||
| #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 5 selection | |||
| */ | |||
| #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */ | |||
| #define GPIO_AF5_I2S3ext ((uint8_t)0x05) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 6 selection | |||
| */ | |||
| #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ | |||
| #define GPIO_AF6_I2S2ext ((uint8_t)0x06) /* I2S2ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 7 selection | |||
| */ | |||
| #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ | |||
| #define GPIO_AF7_I2S3ext ((uint8_t)0x07) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 8 selection | |||
| */ | |||
| #define GPIO_AF8_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 9 selection | |||
| */ | |||
| #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ | |||
| #define GPIO_AF9_I2C2 ((uint8_t)0x09) /* I2C2 Alternate Function mapping */ | |||
| #define GPIO_AF9_I2C3 ((uint8_t)0x09) /* I2C3 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 10 selection | |||
| */ | |||
| #define GPIO_AF10_OTG_FS ((uint8_t)0xA) /* OTG_FS Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 12 selection | |||
| */ | |||
| #define GPIO_AF12_SDIO ((uint8_t)0xC) /* SDIO Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 15 selection | |||
| */ | |||
| #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ | |||
| #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ | |||
| ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ | |||
| ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ | |||
| ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ | |||
| ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ | |||
| ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF4_I2C1) || \ | |||
| ((AF) == GPIO_AF4_I2C2) || ((AF) == GPIO_AF4_I2C3) || \ | |||
| ((AF) == GPIO_AF5_SPI1) || ((AF) == GPIO_AF5_SPI2) || \ | |||
| ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF5_SPI4) || \ | |||
| ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ | |||
| ((AF) == GPIO_AF8_USART6) || ((AF) == GPIO_AF10_OTG_FS) || \ | |||
| ((AF) == GPIO_AF9_I2C2) || ((AF) == GPIO_AF9_I2C3) || \ | |||
| ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF15_EVENTOUT)) | |||
| #endif /* STM32F401xC || STM32F401xE */ | |||
| /*------------------------------------------------------------------------------------------*/ | |||
| /*---------------------------------------- STM32F411xx--------------------------------------*/ | |||
| #if defined(STM32F411xE) | |||
| /** | |||
| * @brief AF 0 selection | |||
| */ | |||
| #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ | |||
| #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ | |||
| #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ | |||
| #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ | |||
| #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 1 selection | |||
| */ | |||
| #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ | |||
| #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 2 selection | |||
| */ | |||
| #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ | |||
| #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 3 selection | |||
| */ | |||
| #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ | |||
| #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 4 selection | |||
| */ | |||
| #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ | |||
| #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 5 selection | |||
| */ | |||
| #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1/I2S1 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI3 ((uint8_t)0x05) /* SPI3/I2S3 Alternate Function mapping */ | |||
| #define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */ | |||
| #define GPIO_AF5_I2S3ext ((uint8_t)0x05) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 6 selection | |||
| */ | |||
| #define GPIO_AF6_SPI2 ((uint8_t)0x06) /* I2S2 Alternate Function mapping */ | |||
| #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ | |||
| #define GPIO_AF6_SPI4 ((uint8_t)0x06) /* SPI4/I2S4 Alternate Function mapping */ | |||
| #define GPIO_AF6_SPI5 ((uint8_t)0x06) /* SPI5/I2S5 Alternate Function mapping */ | |||
| #define GPIO_AF6_I2S2ext ((uint8_t)0x06) /* I2S2ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 7 selection | |||
| */ | |||
| #define GPIO_AF7_SPI3 ((uint8_t)0x07) /* SPI3/I2S3 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ | |||
| #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ | |||
| #define GPIO_AF7_I2S3ext ((uint8_t)0x07) /* I2S3ext_SD Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 8 selection | |||
| */ | |||
| #define GPIO_AF8_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 9 selection | |||
| */ | |||
| #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ | |||
| #define GPIO_AF9_I2C2 ((uint8_t)0x09) /* I2C2 Alternate Function mapping */ | |||
| #define GPIO_AF9_I2C3 ((uint8_t)0x09) /* I2C3 Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 10 selection | |||
| */ | |||
| #define GPIO_AF10_OTG_FS ((uint8_t)0xA) /* OTG_FS Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 12 selection | |||
| */ | |||
| #define GPIO_AF12_SDIO ((uint8_t)0xC) /* SDIO Alternate Function mapping */ | |||
| /** | |||
| * @brief AF 15 selection | |||
| */ | |||
| #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ | |||
| #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ | |||
| ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ | |||
| ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ | |||
| ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ | |||
| ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ | |||
| ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF4_I2C1) || \ | |||
| ((AF) == GPIO_AF4_I2C2) || ((AF) == GPIO_AF4_I2C3) || \ | |||
| ((AF) == GPIO_AF5_SPI1) || ((AF) == GPIO_AF5_SPI2) || \ | |||
| ((AF) == GPIO_AF5_SPI3) || ((AF) == GPIO_AF6_SPI4) || \ | |||
| ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF5_SPI4) || \ | |||
| ((AF) == GPIO_AF6_SPI5) || ((AF) == GPIO_AF7_SPI3) || \ | |||
| ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ | |||
| ((AF) == GPIO_AF8_USART6) || ((AF) == GPIO_AF10_OTG_FS) || \ | |||
| ((AF) == GPIO_AF9_I2C2) || ((AF) == GPIO_AF9_I2C3) || \ | |||
| ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF15_EVENTOUT)) | |||
| #endif /* STM32F411xE */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_GPIO_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,331 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_hash.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of HASH HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_HASH_H | |||
| #define __STM32F4xx_HAL_HASH_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F437xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup HASH | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HASH Configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. | |||
| This parameter can be a value of @ref HASH_Data_Type */ | |||
| uint32_t KeySize; /*!< The key size is used only in HMAC operation */ | |||
| uint8_t* pKey; /*!< The key is used only in HMAC operation */ | |||
| }HASH_InitTypeDef; | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_HASH_STATE_RESET = 0x00, /*!< HASH not yet initialized or disabled */ | |||
| HAL_HASH_STATE_READY = 0x01, /*!< HASH initialized and ready for use */ | |||
| HAL_HASH_STATE_BUSY = 0x02, /*!< HASH internal process is ongoing */ | |||
| HAL_HASH_STATE_TIMEOUT = 0x03, /*!< HASH timeout state */ | |||
| HAL_HASH_STATE_ERROR = 0x04 /*!< HASH error state */ | |||
| }HAL_HASH_STATETypeDef; | |||
| /** | |||
| * @brief HAL phase structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_HASH_PHASE_READY = 0x01, /*!< HASH peripheral is ready for initialization */ | |||
| HAL_HASH_PHASE_PROCESS = 0x02, /*!< HASH peripheral is in processing phase */ | |||
| }HAL_HASHPhaseTypeDef; | |||
| /** | |||
| * @brief HASH Handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| HASH_InitTypeDef Init; /*!< HASH required parameters */ | |||
| uint8_t *pHashInBuffPtr; /*!< Pointer to input buffer */ | |||
| uint8_t *pHashOutBuffPtr; /*!< Pointer to input buffer */ | |||
| __IO uint32_t HashBuffSize; /*!< Size of buffer to be processed */ | |||
| __IO uint32_t HashInCount; /*!< Counter of inputed data */ | |||
| __IO uint32_t HashITCounter; /*!< Counter of issued interrupts */ | |||
| HAL_StatusTypeDef Status; /*!< HASH peripheral status */ | |||
| HAL_HASHPhaseTypeDef Phase; /*!< HASH peripheral phase */ | |||
| DMA_HandleTypeDef *hdmain; /*!< HASH In DMA handle parameters */ | |||
| HAL_LockTypeDef Lock; /*!< HASH locking object */ | |||
| __IO HAL_HASH_STATETypeDef State; /*!< HASH peripheral state */ | |||
| } HASH_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup HASH_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup HASH_Algo_Selection | |||
| * @{ | |||
| */ | |||
| #define HASH_AlgoSelection_SHA1 ((uint32_t)0x0000) /*!< HASH function is SHA1 */ | |||
| #define HASH_AlgoSelection_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */ | |||
| #define HASH_AlgoSelection_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */ | |||
| #define HASH_AlgoSelection_MD5 HASH_CR_ALGO_0 /*!< HASH function is MD5 */ | |||
| #define IS_HASH_ALGOSELECTION(ALGOSELECTION) (((ALGOSELECTION) == HASH_AlgoSelection_SHA1) || \ | |||
| ((ALGOSELECTION) == HASH_AlgoSelection_SHA224) || \ | |||
| ((ALGOSELECTION) == HASH_AlgoSelection_SHA256) || \ | |||
| ((ALGOSELECTION) == HASH_AlgoSelection_MD5)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HASH_Algorithm_Mode | |||
| * @{ | |||
| */ | |||
| #define HASH_AlgoMode_HASH ((uint32_t)0x00000000) /*!< Algorithm is HASH */ | |||
| #define HASH_AlgoMode_HMAC HASH_CR_MODE /*!< Algorithm is HMAC */ | |||
| #define IS_HASH_ALGOMODE(ALGOMODE) (((ALGOMODE) == HASH_AlgoMode_HASH) || \ | |||
| ((ALGOMODE) == HASH_AlgoMode_HMAC)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HASH_Data_Type | |||
| * @{ | |||
| */ | |||
| #define HASH_DATATYPE_32B ((uint32_t)0x0000) /*!< 32-bit data. No swapping */ | |||
| #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */ | |||
| #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */ | |||
| #define HASH_DATATYPE_1B HASH_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */ | |||
| #define IS_HASH_DATATYPE(DATATYPE) (((DATATYPE) == HASH_DATATYPE_32B)|| \ | |||
| ((DATATYPE) == HASH_DATATYPE_16B)|| \ | |||
| ((DATATYPE) == HASH_DATATYPE_8B) || \ | |||
| ((DATATYPE) == HASH_DATATYPE_1B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HASH_HMAC_Long_key_only_for_HMAC_mode | |||
| * @{ | |||
| */ | |||
| #define HASH_HMACKeyType_ShortKey ((uint32_t)0x00000000) /*!< HMAC Key is <= 64 bytes */ | |||
| #define HASH_HMACKeyType_LongKey HASH_CR_LKEY /*!< HMAC Key is > 64 bytes */ | |||
| #define IS_HASH_HMAC_KEYTYPE(KEYTYPE) (((KEYTYPE) == HASH_HMACKeyType_ShortKey) || \ | |||
| ((KEYTYPE) == HASH_HMACKeyType_LongKey)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HASH_flags_definition | |||
| * @{ | |||
| */ | |||
| #define HASH_FLAG_DINIS HASH_SR_DINIS /*!< 16 locations are free in the DIN : A new block can be entered into the input buffer */ | |||
| #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */ | |||
| #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */ | |||
| #define HASH_FLAG_BUSY HASH_SR_BUSY /*!< The hash core is Busy : processing a block of data */ | |||
| #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : The input buffer contains at least one word of data */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HASH_interrupts_definition | |||
| * @{ | |||
| */ | |||
| #define HASH_IT_DINI HASH_IMR_DINIM /*!< A new block can be entered into the input buffer (DIN) */ | |||
| #define HASH_IT_DCI HASH_IMR_DCIM /*!< Digest calculation complete */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset HASH handle state | |||
| * @param __HANDLE__: specifies the HASH handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET) | |||
| /** @brief Check whether the specified HASH flag is set or not. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg HASH_FLAG_DINIS: A new block can be entered into the input buffer. | |||
| * @arg HASH_FLAG_DCIS: Digest calculation complete | |||
| * @arg HASH_FLAG_DMAS: DMA interface is enabled (DMAE=1) or a transfer is ongoing | |||
| * @arg HASH_FLAG_BUSY: The hash core is Busy : processing a block of data | |||
| * @arg HASH_FLAG_DINNE: DIN not empty : The input buffer contains at least one word of data | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_HASH_GET_FLAG(__FLAG__) ((HASH->SR & (__FLAG__)) == (__FLAG__)) | |||
| /** | |||
| * @brief Macros for HMAC finish. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define HAL_HMAC_MD5_Finish HAL_HASH_MD5_Finish | |||
| #define HAL_HMAC_SHA1_Finish HAL_HASH_SHA1_Finish | |||
| #define HAL_HMAC_SHA224_Finish HAL_HASH_SHA224_Finish | |||
| #define HAL_HMAC_SHA256_Finish HAL_HASH_SHA256_Finish | |||
| /** | |||
| * @brief Enable the multiple DMA mode. | |||
| * This feature is available only in STM32F429x and STM32F439x devices. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __HAL_HASH_SET_MDMAT() HASH->CR |= HASH_CR_MDMAT | |||
| /** | |||
| * @brief Disable the multiple DMA mode. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __HAL_HASH_RESET_MDMAT() HASH->CR &= (uint32_t)(~HASH_CR_MDMAT) | |||
| /** | |||
| * @brief Start the digest computation | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __HAL_HASH_START_DIGEST() HASH->STR |= HASH_STR_DCAL | |||
| /** | |||
| * @brief Set the number of valid bits in last word written in Data register | |||
| * @param SIZE: size in byte of last data written in Data register. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_HASH_SET_NBVALIDBITS(SIZE) do{HASH->STR &= ~(HASH_STR_NBW);\ | |||
| HASH->STR |= 8 * ((SIZE) % 4);\ | |||
| }while(0) | |||
| /* Include HASH HAL Extension module */ | |||
| #include "stm32f4xx_hal_hash_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization and de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash); | |||
| HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash); | |||
| /* HASH processing using polling *********************************************/ | |||
| HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| /* HASH-MAC processing using polling *****************************************/ | |||
| HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| /* HASH processing using interrupt *******************************************/ | |||
| HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer); | |||
| HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer); | |||
| /* HASH processing using DMA *************************************************/ | |||
| HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| /* HASH-HMAC processing using DMA ********************************************/ | |||
| HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| /* Processing functions ******************************************************/ | |||
| void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash); | |||
| /* Peripheral State functions ************************************************/ | |||
| HAL_HASH_STATETypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash); | |||
| void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash); | |||
| void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash); | |||
| void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash); | |||
| void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash); | |||
| void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash); | |||
| #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_HASH_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,105 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_hash_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of HASH HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_HASH_EX_H | |||
| #define __STM32F4xx_HAL_HASH_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F437xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup HASHEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* HASH processing using polling *********************************************/ | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA224_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA256_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA224_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA256_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| /* HASH-MAC processing using polling *****************************************/ | |||
| HAL_StatusTypeDef HAL_HMACEx_SHA224_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_HMACEx_SHA256_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| /* HASH processing using interrupt *******************************************/ | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer); | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer); | |||
| /* HASH processing using DMA *************************************************/ | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA224_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA256_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| HAL_StatusTypeDef HAL_HASHEx_SHA256_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout); | |||
| /* HASH-HMAC processing using DMA ********************************************/ | |||
| HAL_StatusTypeDef HAL_HMACEx_SHA224_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| HAL_StatusTypeDef HAL_HMACEx_SHA256_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size); | |||
| /* Processing functions ******************************************************/ | |||
| void HAL_HASHEx_IRQHandler(HASH_HandleTypeDef *hhash); | |||
| #endif /* STM32F437xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_HASH_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,224 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_hcd.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of HCD HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_HCD_H | |||
| #define __STM32F4xx_HAL_HCD_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_ll_usb.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup HCD | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HCD Status structures structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_HCD_STATE_RESET = 0x00, | |||
| HAL_HCD_STATE_READY = 0x01, | |||
| HAL_HCD_STATE_ERROR = 0x02, | |||
| HAL_HCD_STATE_BUSY = 0x03, | |||
| HAL_HCD_STATE_TIMEOUT = 0x04 | |||
| } HCD_StateTypeDef; | |||
| typedef USB_OTG_GlobalTypeDef HCD_TypeDef; | |||
| typedef USB_OTG_CfgTypeDef HCD_InitTypeDef; | |||
| typedef USB_OTG_HCTypeDef HCD_HCTypeDef ; | |||
| typedef USB_OTG_URBStateTypeDef HCD_URBStateTypeDef ; | |||
| typedef USB_OTG_HCStateTypeDef HCD_HCStateTypeDef ; | |||
| /** | |||
| * @brief HCD Handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| HCD_TypeDef *Instance; /*!< Register base address */ | |||
| HCD_InitTypeDef Init; /*!< HCD required parameters */ | |||
| HCD_HCTypeDef hc[15]; /*!< Host channels parameters */ | |||
| HAL_LockTypeDef Lock; /*!< HCD peripheral status */ | |||
| __IO HCD_StateTypeDef State; /*!< HCD communication state */ | |||
| void *pData; /*!< Pointer Stack Handler */ | |||
| } HCD_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup HCD_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup HCD_Instance_definition | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| #define IS_HCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS) || \ | |||
| ((INSTANCE) == USB_OTG_HS)) | |||
| #elif defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define IS_HCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS)) | |||
| #endif | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HCD_Speed | |||
| * @{ | |||
| */ | |||
| #define HCD_SPEED_HIGH 0 | |||
| #define HCD_SPEED_LOW 2 | |||
| #define HCD_SPEED_FULL 3 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HCD_PHY_Module | |||
| * @{ | |||
| */ | |||
| #define HCD_PHY_ULPI 1 | |||
| #define HCD_PHY_EMBEDDED 2 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @defgroup HCD_Interrupt_Clock | |||
| * @brief macros to handle interrupts and specific clock configurations | |||
| * @{ | |||
| */ | |||
| #define __HAL_HCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance) | |||
| #define __HAL_HCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance) | |||
| #define __HAL_HCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
| #define __HAL_HCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) = (__INTERRUPT__)) | |||
| #define __HAL_HCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0) | |||
| #define __HAL_HCD_CLEAR_HC_INT(chnum, __INTERRUPT__) (USBx_HC(chnum)->HCINT = (__INTERRUPT__)) | |||
| #define __HAL_HCD_MASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_CHHM) | |||
| #define __HAL_HCD_UNMASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_CHHM) | |||
| #define __HAL_HCD_MASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_ACKM) | |||
| #define __HAL_HCD_UNMASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_ACKM) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd); | |||
| HAL_StatusTypeDef HAL_HCD_DeInit (HCD_HandleTypeDef *hhcd); | |||
| HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd, | |||
| uint8_t ch_num, | |||
| uint8_t epnum, | |||
| uint8_t dev_address, | |||
| uint8_t speed, | |||
| uint8_t ep_type, | |||
| uint16_t mps); | |||
| HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, | |||
| uint8_t ch_num); | |||
| void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd); | |||
| void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd); | |||
| /* I/O operation functions *****************************************************/ | |||
| HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd, | |||
| uint8_t pipe, | |||
| uint8_t direction , | |||
| uint8_t ep_type, | |||
| uint8_t token, | |||
| uint8_t* pbuff, | |||
| uint16_t length, | |||
| uint8_t do_ping); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd); | |||
| void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd); | |||
| void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd); | |||
| void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd); | |||
| void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, | |||
| uint8_t chnum, | |||
| HCD_URBStateTypeDef urb_state); | |||
| /* Peripheral Control functions ************************************************/ | |||
| HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd); | |||
| HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd); | |||
| HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd); | |||
| /* Peripheral State functions **************************************************/ | |||
| HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef *hhcd); | |||
| HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef *hhcd, uint8_t chnum); | |||
| uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef *hhcd, uint8_t chnum); | |||
| HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef *hhcd, uint8_t chnum); | |||
| uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd); | |||
| uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_HCD_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,461 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_i2c.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of I2C HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_I2C_H | |||
| #define __STM32F4xx_HAL_I2C_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup I2C | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief I2C Configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t ClockSpeed; /*!< Specifies the clock frequency. | |||
| This parameter must be set to a value lower than 400kHz */ | |||
| uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle. | |||
| This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */ | |||
| 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 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; | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_I2C_STATE_RESET = 0x00, /*!< I2C not yet initialized or disabled */ | |||
| HAL_I2C_STATE_READY = 0x01, /*!< I2C initialized and ready for use */ | |||
| HAL_I2C_STATE_BUSY = 0x02, /*!< I2C internal process is ongoing */ | |||
| HAL_I2C_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ | |||
| HAL_I2C_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ | |||
| HAL_I2C_STATE_MEM_BUSY_TX = 0x32, /*!< Memory Data Transmission process is ongoing */ | |||
| HAL_I2C_STATE_MEM_BUSY_RX = 0x42, /*!< Memory Data Reception process is ongoing */ | |||
| HAL_I2C_STATE_TIMEOUT = 0x03, /*!< I2C timeout state */ | |||
| HAL_I2C_STATE_ERROR = 0x04 /*!< I2C error state */ | |||
| }HAL_I2C_StateTypeDef; | |||
| /** | |||
| * @brief HAL I2C Error Code structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_I2C_ERROR_NONE = 0x00, /*!< No error */ | |||
| HAL_I2C_ERROR_BERR = 0x01, /*!< BERR error */ | |||
| HAL_I2C_ERROR_ARLO = 0x02, /*!< ARLO error */ | |||
| HAL_I2C_ERROR_AF = 0x04, /*!< AF error */ | |||
| HAL_I2C_ERROR_OVR = 0x08, /*!< OVR error */ | |||
| HAL_I2C_ERROR_DMA = 0x10, /*!< DMA transfer error */ | |||
| HAL_I2C_ERROR_TIMEOUT = 0x20 /*!< Timeout error */ | |||
| }HAL_I2C_ErrorTypeDef; | |||
| /** | |||
| * @brief I2C handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| 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 */ | |||
| 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_ErrorTypeDef ErrorCode; /* I2C Error code */ | |||
| }I2C_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup I2C_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup I2C_duty_cycle_in_fast_mode | |||
| * @{ | |||
| */ | |||
| #define I2C_DUTYCYCLE_2 ((uint32_t)0x00000000) | |||
| #define I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY | |||
| #define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DUTYCYCLE_2) || \ | |||
| ((CYCLE) == I2C_DUTYCYCLE_16_9)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2C_addressing_mode | |||
| * @{ | |||
| */ | |||
| #define I2C_ADDRESSINGMODE_7BIT ((uint32_t)0x00004000) | |||
| #define I2C_ADDRESSINGMODE_10BIT (I2C_OAR1_ADDMODE | ((uint32_t)0x00004000)) | |||
| #define IS_I2C_ADDRESSING_MODE(ADDRESS) (((ADDRESS) == I2C_ADDRESSINGMODE_7BIT) || \ | |||
| ((ADDRESS) == I2C_ADDRESSINGMODE_10BIT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2C_dual_addressing_mode | |||
| * @{ | |||
| */ | |||
| #define I2C_DUALADDRESS_DISABLED ((uint32_t)0x00000000) | |||
| #define I2C_DUALADDRESS_ENABLED I2C_OAR2_ENDUAL | |||
| #define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLED) || \ | |||
| ((ADDRESS) == I2C_DUALADDRESS_ENABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2C_general_call_addressing_mode | |||
| * @{ | |||
| */ | |||
| #define I2C_GENERALCALL_DISABLED ((uint32_t)0x00000000) | |||
| #define I2C_GENERALCALL_ENABLED I2C_CR1_ENGC | |||
| #define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLED) || \ | |||
| ((CALL) == I2C_GENERALCALL_ENABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2C_nostretch_mode | |||
| * @{ | |||
| */ | |||
| #define I2C_NOSTRETCH_DISABLED ((uint32_t)0x00000000) | |||
| #define I2C_NOSTRETCH_ENABLED I2C_CR1_NOSTRETCH | |||
| #define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLED) || \ | |||
| ((STRETCH) == I2C_NOSTRETCH_ENABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2C_Memory_Address_Size | |||
| * @{ | |||
| */ | |||
| #define I2C_MEMADD_SIZE_8BIT ((uint32_t)0x00000001) | |||
| #define I2C_MEMADD_SIZE_16BIT ((uint32_t)0x00000010) | |||
| #define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \ | |||
| ((SIZE) == I2C_MEMADD_SIZE_16BIT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2C_Interrupt_configuration_definition | |||
| * @{ | |||
| */ | |||
| #define I2C_IT_BUF I2C_CR2_ITBUFEN | |||
| #define I2C_IT_EVT I2C_CR2_ITEVTEN | |||
| #define I2C_IT_ERR I2C_CR2_ITERREN | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2C_Flag_definition | |||
| * @{ | |||
| */ | |||
| #define I2C_FLAG_SMBALERT ((uint32_t)0x00018000) | |||
| #define I2C_FLAG_TIMEOUT ((uint32_t)0x00014000) | |||
| #define I2C_FLAG_PECERR ((uint32_t)0x00011000) | |||
| #define I2C_FLAG_OVR ((uint32_t)0x00010800) | |||
| #define I2C_FLAG_AF ((uint32_t)0x00010400) | |||
| #define I2C_FLAG_ARLO ((uint32_t)0x00010200) | |||
| #define I2C_FLAG_BERR ((uint32_t)0x00010100) | |||
| #define I2C_FLAG_TXE ((uint32_t)0x00010080) | |||
| #define I2C_FLAG_RXNE ((uint32_t)0x00010040) | |||
| #define I2C_FLAG_STOPF ((uint32_t)0x00010010) | |||
| #define I2C_FLAG_ADD10 ((uint32_t)0x00010008) | |||
| #define I2C_FLAG_BTF ((uint32_t)0x00010004) | |||
| #define I2C_FLAG_ADDR ((uint32_t)0x00010002) | |||
| #define I2C_FLAG_SB ((uint32_t)0x00010001) | |||
| #define I2C_FLAG_DUALF ((uint32_t)0x00100080) | |||
| #define I2C_FLAG_SMBHOST ((uint32_t)0x00100040) | |||
| #define I2C_FLAG_SMBDEFAULT ((uint32_t)0x00100020) | |||
| #define I2C_FLAG_GENCALL ((uint32_t)0x00100010) | |||
| #define I2C_FLAG_TRA ((uint32_t)0x00100004) | |||
| #define I2C_FLAG_BUSY ((uint32_t)0x00100002) | |||
| #define I2C_FLAG_MSL ((uint32_t)0x00100001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset I2C handle state | |||
| * @param __HANDLE__: specifies the I2C Handle. | |||
| * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET) | |||
| /** @brief Enable or disable the specified I2C interrupts. | |||
| * @param __HANDLE__: specifies the I2C Handle. | |||
| * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. | |||
| * @param __INTERRUPT__: specifies the interrupt source to enable or disable. | |||
| * This parameter can be one of the following values: | |||
| * @arg I2C_IT_BUF: Buffer interrupt enable | |||
| * @arg I2C_IT_EVT: Event interrupt enable | |||
| * @arg I2C_IT_ERR: Error interrupt enable | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__)) | |||
| #define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__))) | |||
| /** @brief Checks if the specified I2C interrupt source is enabled or disabled. | |||
| * @param __HANDLE__: specifies the I2C Handle. | |||
| * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. | |||
| * @param __INTERRUPT__: specifies the I2C interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg I2C_IT_BUF: Buffer interrupt enable | |||
| * @arg I2C_IT_EVT: Event interrupt enable | |||
| * @arg I2C_IT_ERR: Error interrupt enable | |||
| * @retval The new state of __INTERRUPT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
| /** @brief Checks whether the specified I2C flag is set or not. | |||
| * @param __HANDLE__: specifies the I2C Handle. | |||
| * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg I2C_FLAG_SMBALERT: SMBus Alert flag | |||
| * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag | |||
| * @arg I2C_FLAG_PECERR: PEC error in reception flag | |||
| * @arg I2C_FLAG_OVR: Overrun/Underrun flag | |||
| * @arg I2C_FLAG_AF: Acknowledge failure flag | |||
| * @arg I2C_FLAG_ARLO: Arbitration lost flag | |||
| * @arg I2C_FLAG_BERR: Bus error flag | |||
| * @arg I2C_FLAG_TXE: Data register empty flag | |||
| * @arg I2C_FLAG_RXNE: Data register not empty flag | |||
| * @arg I2C_FLAG_STOPF: Stop detection flag | |||
| * @arg I2C_FLAG_ADD10: 10-bit header sent flag | |||
| * @arg I2C_FLAG_BTF: Byte transfer finished flag | |||
| * @arg I2C_FLAG_ADDR: Address sent flag | |||
| * Address matched flag | |||
| * @arg I2C_FLAG_SB: Start bit flag | |||
| * @arg I2C_FLAG_DUALF: Dual flag | |||
| * @arg I2C_FLAG_SMBHOST: SMBus host header | |||
| * @arg I2C_FLAG_SMBDEFAULT: SMBus default header | |||
| * @arg I2C_FLAG_GENCALL: General call header flag | |||
| * @arg I2C_FLAG_TRA: Transmitter/Receiver flag | |||
| * @arg I2C_FLAG_BUSY: Bus busy flag | |||
| * @arg I2C_FLAG_MSL: Master/Slave flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define I2C_FLAG_MASK ((uint32_t)0x0000FFFF) | |||
| #define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 16)) == 0x01)?((((__HANDLE__)->Instance->SR1) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)): \ | |||
| ((((__HANDLE__)->Instance->SR2) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK))) | |||
| /** @brief Clears the I2C pending flags which are cleared by writing 0 in a specific bit. | |||
| * @param __HANDLE__: specifies the I2C Handle. | |||
| * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. | |||
| * @param __FLAG__: specifies the flag to clear. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg I2C_FLAG_SMBALERT: SMBus Alert flag | |||
| * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag | |||
| * @arg I2C_FLAG_PECERR: PEC error in reception flag | |||
| * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode) | |||
| * @arg I2C_FLAG_AF: Acknowledge failure flag | |||
| * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode) | |||
| * @arg I2C_FLAG_BERR: Bus error flag | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR1 = ~((__FLAG__) & I2C_FLAG_MASK)) | |||
| /** @brief Clears the I2C ADDR pending flag. | |||
| * @param __HANDLE__: specifies the I2C Handle. | |||
| * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR1;\ | |||
| (__HANDLE__)->Instance->SR2;}while(0) | |||
| /** @brief Clears the I2C STOPF pending flag. | |||
| * @param __HANDLE__: specifies the I2C Handle. | |||
| * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR1;\ | |||
| (__HANDLE__)->Instance->CR1 |= I2C_CR1_PE;}while(0) | |||
| #define __HAL_I2C_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= I2C_CR1_PE) | |||
| #define __HAL_I2C_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~I2C_CR1_PE) | |||
| #define __HAL_I2C_FREQRANGE(__PCLK__) ((__PCLK__)/1000000) | |||
| #define __HAL_I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (((__SPEED__) <= 100000) ? ((__FREQRANGE__) + 1) : ((((__FREQRANGE__) * 300) / 1000) + 1)) | |||
| #define __HAL_I2C_SPEED_STANDARD(__PCLK__, __SPEED__) (((((__PCLK__)/((__SPEED__) << 1)) & I2C_CCR_CCR) < 4)? 4:((__PCLK__) / ((__SPEED__) << 1))) | |||
| #define __HAL_I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__DUTYCYCLE__) == I2C_DUTYCYCLE_2)? ((__PCLK__) / ((__SPEED__) * 3)) : (((__PCLK__) / ((__SPEED__) * 25)) | I2C_DUTYCYCLE_16_9)) | |||
| #define __HAL_I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__SPEED__) <= 100000)? (__HAL_I2C_SPEED_STANDARD((__PCLK__), (__SPEED__))) : \ | |||
| ((__HAL_I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__)) & I2C_CCR_CCR) == 0)? 1 : \ | |||
| ((__HAL_I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__))) | I2C_CCR_FS)) | |||
| #define __HAL_I2C_7BIT_ADD_WRITE(__ADDRESS__) ((uint8_t)((__ADDRESS__) & (~I2C_OAR1_ADD0))) | |||
| #define __HAL_I2C_7BIT_ADD_READ(__ADDRESS__) ((uint8_t)((__ADDRESS__) | I2C_OAR1_ADD0)) | |||
| #define __HAL_I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF)))) | |||
| #define __HAL_I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF0)))) | |||
| #define __HAL_I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF1)))) | |||
| #define __HAL_I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00))) >> 8))) | |||
| #define __HAL_I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF)))) | |||
| #define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) > 0) && ((SPEED) <= 400000)) | |||
| #define IS_I2C_OWN_ADDRESS1(ADDRESS1) (((ADDRESS1) & (uint32_t)(0xFFFFFC00)) == 0) | |||
| #define IS_I2C_OWN_ADDRESS2(ADDRESS2) (((ADDRESS2) & (uint32_t)(0xFFFFFF01)) == 0) | |||
| /* Include I2C HAL Extension module */ | |||
| #include "stm32f4xx_hal_i2c_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/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); | |||
| /* I/O 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); | |||
| /******* 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); | |||
| /******* 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_MemTxCpltCallback(I2C_HandleTypeDef *hi2c); | |||
| void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c); | |||
| void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c); | |||
| /* Peripheral Control and State functions **************************************/ | |||
| HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c); | |||
| uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_I2C_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,112 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_i2c_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of I2C HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_I2C_EX_H | |||
| #define __STM32F4xx_HAL_I2C_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup I2CEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup I2CEx_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup I2CEx_Analog_Filter | |||
| * @{ | |||
| */ | |||
| #define I2C_ANALOGFILTER_ENABLED ((uint32_t)0x00000000) | |||
| #define I2C_ANALOGFILTER_DISABLED I2C_FLTR_ANOFF | |||
| #define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLED) || \ | |||
| ((FILTER) == I2C_ANALOGFILTER_DISABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2CEx_Digital_Filter | |||
| * @{ | |||
| */ | |||
| #define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000F) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Peripheral Control functions ************************************************/ | |||
| HAL_StatusTypeDef HAL_I2CEx_AnalogFilter_Config(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter); | |||
| HAL_StatusTypeDef HAL_I2CEx_DigitalFilter_Config(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter); | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F401xC || STM32F401xE */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_I2C_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,445 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_i2s.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of I2S HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_I2S_H | |||
| #define __STM32F4xx_HAL_I2S_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup I2S | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief I2S Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Mode; /*!< Specifies the I2S operating mode. | |||
| This parameter can be a value of @ref I2S_Mode */ | |||
| uint32_t Standard; /*!< Specifies the standard used for the I2S communication. | |||
| This parameter can be a value of @ref I2S_Standard */ | |||
| uint32_t DataFormat; /*!< Specifies the data format for the I2S communication. | |||
| This parameter can be a value of @ref I2S_Data_Format */ | |||
| uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not. | |||
| This parameter can be a value of @ref I2S_MCLK_Output */ | |||
| uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication. | |||
| This parameter can be a value of @ref I2S_Audio_Frequency */ | |||
| uint32_t CPOL; /*!< Specifies the idle state of the I2S clock. | |||
| This parameter can be a value of @ref I2S_Clock_Polarity */ | |||
| uint32_t ClockSource; /*!< Specifies the I2S Clock Source. | |||
| This parameter can be a value of @ref I2S_Clock_Source */ | |||
| uint32_t FullDuplexMode; /*!< Specifies the I2S FullDuplex mode. | |||
| This parameter can be a value of @ref I2S_FullDuplex_Mode */ | |||
| }I2S_InitTypeDef; | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_I2S_STATE_RESET = 0x00, /*!< I2S not yet initialized or disabled */ | |||
| HAL_I2S_STATE_READY = 0x01, /*!< I2S initialized and ready for use */ | |||
| HAL_I2S_STATE_BUSY = 0x02, /*!< I2S internal process is ongoing */ | |||
| HAL_I2S_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ | |||
| HAL_I2S_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ | |||
| HAL_I2S_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ | |||
| HAL_I2S_STATE_TIMEOUT = 0x03, /*!< I2S timeout state */ | |||
| HAL_I2S_STATE_ERROR = 0x04 /*!< I2S error state */ | |||
| }HAL_I2S_StateTypeDef; | |||
| /** | |||
| * @brief HAL I2S Error Code structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_I2S_ERROR_NONE = 0x00, /*!< No error */ | |||
| HAL_I2S_ERROR_UDR = 0x01, /*!< I2S Underrun error */ | |||
| HAL_I2S_ERROR_OVR = 0x02, /*!< I2S Overrun error */ | |||
| HAL_I2SEX_ERROR_UDR = 0x04, /*!< I2S extended Underrun error */ | |||
| HAL_I2SEX_ERROR_OVR = 0x08, /*!< I2S extended Overrun error */ | |||
| HAL_I2S_ERROR_FRE = 0x10, /*!< I2S Frame format error */ | |||
| HAL_I2S_ERROR_DMA = 0x20 /*!< DMA transfer error */ | |||
| }HAL_I2S_ErrorTypeDef; | |||
| /** | |||
| * @brief I2S handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| SPI_TypeDef *Instance; /* I2S registers base address */ | |||
| I2S_InitTypeDef Init; /* I2S communication parameters */ | |||
| uint16_t *pTxBuffPtr; /* Pointer to I2S Tx transfer buffer */ | |||
| __IO uint16_t TxXferSize; /* I2S Tx transfer size */ | |||
| __IO uint16_t TxXferCount; /* I2S Tx transfer Counter */ | |||
| uint16_t *pRxBuffPtr; /* Pointer to I2S Rx transfer buffer */ | |||
| __IO uint16_t RxXferSize; /* I2S Rx transfer size */ | |||
| __IO uint16_t RxXferCount; /* I2S Rx transfer counter */ | |||
| DMA_HandleTypeDef *hdmatx; /* I2S Tx DMA handle parameters */ | |||
| DMA_HandleTypeDef *hdmarx; /* I2S Rx DMA handle parameters */ | |||
| __IO HAL_LockTypeDef Lock; /* I2S locking object */ | |||
| __IO HAL_I2S_StateTypeDef State; /* I2S communication state */ | |||
| __IO HAL_I2S_ErrorTypeDef ErrorCode; /* I2S Error code */ | |||
| }I2S_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup I2S_Exported_Constants | |||
| * @{ | |||
| */ | |||
| #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE)) | |||
| /** @defgroup I2S_Clock_Source | |||
| * @{ | |||
| */ | |||
| #define I2S_CLOCK_PLL ((uint32_t)0x00000000) | |||
| #define I2S_CLOCK_EXTERNAL ((uint32_t)0x00000001) | |||
| #define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) || \ | |||
| ((CLOCK) == I2S_CLOCK_PLL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_Mode | |||
| * @{ | |||
| */ | |||
| #define I2S_MODE_SLAVE_TX ((uint32_t)0x00000000) | |||
| #define I2S_MODE_SLAVE_RX ((uint32_t)0x00000100) | |||
| #define I2S_MODE_MASTER_TX ((uint32_t)0x00000200) | |||
| #define I2S_MODE_MASTER_RX ((uint32_t)0x00000300) | |||
| #define IS_I2S_MODE(MODE) (((MODE) == I2S_MODE_SLAVE_TX) || \ | |||
| ((MODE) == I2S_MODE_SLAVE_RX) || \ | |||
| ((MODE) == I2S_MODE_MASTER_TX) || \ | |||
| ((MODE) == I2S_MODE_MASTER_RX)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_Standard | |||
| * @{ | |||
| */ | |||
| #define I2S_STANDARD_PHILIPS ((uint32_t)0x00000000) | |||
| #define I2S_STANDARD_MSB ((uint32_t)0x00000010) | |||
| #define I2S_STANDARD_LSB ((uint32_t)0x00000020) | |||
| #define I2S_STANDARD_PCM_SHORT ((uint32_t)0x00000030) | |||
| #define I2S_STANDARD_PCM_LONG ((uint32_t)0x000000B0) | |||
| #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_STANDARD_PHILIPS) || \ | |||
| ((STANDARD) == I2S_STANDARD_MSB) || \ | |||
| ((STANDARD) == I2S_STANDARD_LSB) || \ | |||
| ((STANDARD) == I2S_STANDARD_PCM_SHORT) || \ | |||
| ((STANDARD) == I2S_STANDARD_PCM_LONG)) | |||
| /** @defgroup I2S_Legacy | |||
| * @{ | |||
| */ | |||
| #define I2S_STANDARD_PHILLIPS I2S_STANDARD_PHILIPS | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_Data_Format | |||
| * @{ | |||
| */ | |||
| #define I2S_DATAFORMAT_16B ((uint32_t)0x00000000) | |||
| #define I2S_DATAFORMAT_16B_EXTENDED ((uint32_t)0x00000001) | |||
| #define I2S_DATAFORMAT_24B ((uint32_t)0x00000003) | |||
| #define I2S_DATAFORMAT_32B ((uint32_t)0x00000005) | |||
| #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DATAFORMAT_16B) || \ | |||
| ((FORMAT) == I2S_DATAFORMAT_16B_EXTENDED) || \ | |||
| ((FORMAT) == I2S_DATAFORMAT_24B) || \ | |||
| ((FORMAT) == I2S_DATAFORMAT_32B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_MCLK_Output | |||
| * @{ | |||
| */ | |||
| #define I2S_MCLKOUTPUT_ENABLE ((uint32_t)SPI_I2SPR_MCKOE) | |||
| #define I2S_MCLKOUTPUT_DISABLE ((uint32_t)0x00000000) | |||
| #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOUTPUT_ENABLE) || \ | |||
| ((OUTPUT) == I2S_MCLKOUTPUT_DISABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_Audio_Frequency | |||
| * @{ | |||
| */ | |||
| #define I2S_AUDIOFREQ_192K ((uint32_t)192000) | |||
| #define I2S_AUDIOFREQ_96K ((uint32_t)96000) | |||
| #define I2S_AUDIOFREQ_48K ((uint32_t)48000) | |||
| #define I2S_AUDIOFREQ_44K ((uint32_t)44100) | |||
| #define I2S_AUDIOFREQ_32K ((uint32_t)32000) | |||
| #define I2S_AUDIOFREQ_22K ((uint32_t)22050) | |||
| #define I2S_AUDIOFREQ_16K ((uint32_t)16000) | |||
| #define I2S_AUDIOFREQ_11K ((uint32_t)11025) | |||
| #define I2S_AUDIOFREQ_8K ((uint32_t)8000) | |||
| #define I2S_AUDIOFREQ_DEFAULT ((uint32_t)2) | |||
| #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AUDIOFREQ_8K) && \ | |||
| ((FREQ) <= I2S_AUDIOFREQ_192K)) || \ | |||
| ((FREQ) == I2S_AUDIOFREQ_DEFAULT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_FullDuplex_Mode | |||
| * @{ | |||
| */ | |||
| #define I2S_FULLDUPLEXMODE_DISABLE ((uint32_t)0x00000000) | |||
| #define I2S_FULLDUPLEXMODE_ENABLE ((uint32_t)0x00000001) | |||
| #define IS_I2S_FULLDUPLEX_MODE(MODE) (((MODE) == I2S_FULLDUPLEXMODE_DISABLE) || \ | |||
| ((MODE) == I2S_FULLDUPLEXMODE_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_Clock_Polarity | |||
| * @{ | |||
| */ | |||
| #define I2S_CPOL_LOW ((uint32_t)0x00000000) | |||
| #define I2S_CPOL_HIGH ((uint32_t)SPI_I2SCFGR_CKPOL) | |||
| #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_LOW) || \ | |||
| ((CPOL) == I2S_CPOL_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_Interrupt_configuration_definition | |||
| * @{ | |||
| */ | |||
| #define I2S_IT_TXE SPI_CR2_TXEIE | |||
| #define I2S_IT_RXNE SPI_CR2_RXNEIE | |||
| #define I2S_IT_ERR SPI_CR2_ERRIE | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup I2S_Flag_definition | |||
| * @{ | |||
| */ | |||
| #define I2S_FLAG_TXE SPI_SR_TXE | |||
| #define I2S_FLAG_RXNE SPI_SR_RXNE | |||
| #define I2S_FLAG_UDR SPI_SR_UDR | |||
| #define I2S_FLAG_OVR SPI_SR_OVR | |||
| #define I2S_FLAG_FRE SPI_SR_FRE | |||
| #define I2S_FLAG_CHSIDE SPI_SR_CHSIDE | |||
| #define I2S_FLAG_BSY SPI_SR_BSY | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset I2S handle state | |||
| * @param __HANDLE__: specifies the I2S Handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET) | |||
| /** @brief Enable or disable the specified SPI peripheral (in I2S mode). | |||
| * @param __HANDLE__: specifies the I2S Handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2S_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->I2SCFGR |= SPI_I2SCFGR_I2SE) | |||
| #define __HAL_I2S_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->I2SCFGR &= ~SPI_I2SCFGR_I2SE) | |||
| /** @brief Enable or disable the specified I2S interrupts. | |||
| * @param __HANDLE__: specifies the I2S Handle. | |||
| * @param __INTERRUPT__: specifies the interrupt source to enable or disable. | |||
| * This parameter can be one of the following values: | |||
| * @arg I2S_IT_TXE: Tx buffer empty interrupt enable | |||
| * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable | |||
| * @arg I2S_IT_ERR: Error interrupt enable | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__)) | |||
| #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= ~(__INTERRUPT__)) | |||
| /** @brief Checks if the specified I2S interrupt source is enabled or disabled. | |||
| * @param __HANDLE__: specifies the I2S Handle. | |||
| * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral. | |||
| * @param __INTERRUPT__: specifies the I2S interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg I2S_IT_TXE: Tx buffer empty interrupt enable | |||
| * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable | |||
| * @arg I2S_IT_ERR: Error interrupt enable | |||
| * @retval The new state of __IT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
| /** @brief Checks whether the specified I2S flag is set or not. | |||
| * @param __HANDLE__: specifies the I2S Handle. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg I2S_FLAG_RXNE: Receive buffer not empty flag | |||
| * @arg I2S_FLAG_TXE: Transmit buffer empty flag | |||
| * @arg I2S_FLAG_UDR: Underrun flag | |||
| * @arg I2S_FLAG_OVR: Overrun flag | |||
| * @arg I2S_FLAG_FRE: Frame error flag | |||
| * @arg I2S_FLAG_CHSIDE: Channel Side flag | |||
| * @arg I2S_FLAG_BSY: Busy flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clears the I2S OVR pending flag. | |||
| * @param __HANDLE__: specifies the I2S Handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__) do{(__HANDLE__)->Instance->DR;\ | |||
| (__HANDLE__)->Instance->SR;}while(0) | |||
| /** @brief Clears the I2S UDR pending flag. | |||
| * @param __HANDLE__: specifies the I2S Handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__)((__HANDLE__)->Instance->SR) | |||
| /* Include I2S Extension module */ | |||
| #include "stm32f4xx_hal_i2s_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s); | |||
| HAL_StatusTypeDef HAL_I2S_DeInit (I2S_HandleTypeDef *hi2s); | |||
| void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s); | |||
| void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s); | |||
| /* I/O operation functions *****************************************************/ | |||
| /* Blocking mode: Polling */ | |||
| HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); | |||
| void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s); | |||
| /* Non-Blocking mode: DMA */ | |||
| HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s); | |||
| HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s); | |||
| HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s); | |||
| /* Peripheral Control and State functions **************************************/ | |||
| HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s); | |||
| HAL_I2S_ErrorTypeDef HAL_I2S_GetError(I2S_HandleTypeDef *hi2s); | |||
| /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/ | |||
| void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s); | |||
| void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s); | |||
| void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s); | |||
| void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s); | |||
| void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s); | |||
| void I2S_DMATxCplt(DMA_HandleTypeDef *hdma); | |||
| void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma); | |||
| void I2S_DMARxCplt(DMA_HandleTypeDef *hdma); | |||
| void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma); | |||
| void I2S_DMAError(DMA_HandleTypeDef *hdma); | |||
| HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, uint32_t Status, uint32_t Timeout); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_I2S_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,86 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_i2s_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of I2S HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_I2S_EX_H | |||
| #define __STM32F4xx_HAL_I2S_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup I2SEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Extended features functions **************************************************/ | |||
| /* Blocking mode: Polling */ | |||
| HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size, uint32_t Timeout); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size); | |||
| /* Non-Blocking mode: DMA */ | |||
| HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size); | |||
| HAL_StatusTypeDef I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_I2S_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,443 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_irda.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of IRDA HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_IRDA_H | |||
| #define __STM32F4xx_HAL_IRDA_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup IRDA | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief IRDA Init Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate. | |||
| The baud rate is computed using the following formula: | |||
| - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate))) | |||
| - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ | |||
| uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. | |||
| This parameter can be a value of @ref IRDA_Word_Length */ | |||
| uint32_t Parity; /*!< Specifies the parity mode. | |||
| This parameter can be a value of @ref IRDA_Parity | |||
| @note When parity is enabled, the computed parity is inserted | |||
| at the MSB position of the transmitted data (9th bit when | |||
| the word length is set to 9 data bits; 8th bit when the | |||
| word length is set to 8 data bits). */ | |||
| uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. | |||
| This parameter can be a value of @ref IRDA_Mode */ | |||
| uint8_t Prescaler; /*!< Specifies the Prescaler */ | |||
| uint32_t IrDAMode; /*!< Specifies the IrDA mode | |||
| This parameter can be a value of @ref IrDA_Low_Power */ | |||
| }IRDA_InitTypeDef; | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_IRDA_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ | |||
| HAL_IRDA_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ | |||
| HAL_IRDA_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ | |||
| HAL_IRDA_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ | |||
| HAL_IRDA_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ | |||
| HAL_IRDA_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ | |||
| HAL_IRDA_STATE_TIMEOUT = 0x03, /*!< Timeout state */ | |||
| HAL_IRDA_STATE_ERROR = 0x04 /*!< Error */ | |||
| }HAL_IRDA_StateTypeDef; | |||
| /** | |||
| * @brief HAL IRDA Error Code structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_IRDA_ERROR_NONE = 0x00, /*!< No error */ | |||
| HAL_IRDA_ERROR_PE = 0x01, /*!< Parity error */ | |||
| HAL_IRDA_ERROR_NE = 0x02, /*!< Noise error */ | |||
| HAL_IRDA_ERROR_FE = 0x04, /*!< frame error */ | |||
| HAL_IRDA_ERROR_ORE = 0x08, /*!< Overrun error */ | |||
| HAL_IRDA_ERROR_DMA = 0x10 /*!< DMA transfer error */ | |||
| }HAL_IRDA_ErrorTypeDef; | |||
| /** | |||
| * @brief IRDA handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| USART_TypeDef *Instance; /* USART registers base address */ | |||
| IRDA_InitTypeDef Init; /* IRDA communication parameters */ | |||
| uint8_t *pTxBuffPtr; /* Pointer to IRDA Tx transfer Buffer */ | |||
| uint16_t TxXferSize; /* IRDA Tx Transfer size */ | |||
| uint16_t TxXferCount; /* IRDA Tx Transfer Counter */ | |||
| uint8_t *pRxBuffPtr; /* Pointer to IRDA Rx transfer Buffer */ | |||
| uint16_t RxXferSize; /* IRDA Rx Transfer size */ | |||
| uint16_t RxXferCount; /* IRDA Rx Transfer Counter */ | |||
| DMA_HandleTypeDef *hdmatx; /* IRDA Tx DMA Handle parameters */ | |||
| DMA_HandleTypeDef *hdmarx; /* IRDA Rx DMA Handle parameters */ | |||
| HAL_LockTypeDef Lock; /* Locking object */ | |||
| __IO HAL_IRDA_StateTypeDef State; /* IRDA communication state */ | |||
| __IO HAL_IRDA_ErrorTypeDef ErrorCode; /* IRDA Error code */ | |||
| }IRDA_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup IRDA_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup IRDA_Word_Length | |||
| * @{ | |||
| */ | |||
| #define IRDA_WORDLENGTH_8B ((uint32_t)0x00000000) | |||
| #define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M) | |||
| #define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \ | |||
| ((LENGTH) == IRDA_WORDLENGTH_9B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IRDA_Parity | |||
| * @{ | |||
| */ | |||
| #define IRDA_PARITY_NONE ((uint32_t)0x00000000) | |||
| #define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE) | |||
| #define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) | |||
| #define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \ | |||
| ((PARITY) == IRDA_PARITY_EVEN) || \ | |||
| ((PARITY) == IRDA_PARITY_ODD)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IRDA_Mode | |||
| * @{ | |||
| */ | |||
| #define IRDA_MODE_RX ((uint32_t)USART_CR1_RE) | |||
| #define IRDA_MODE_TX ((uint32_t)USART_CR1_TE) | |||
| #define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) | |||
| #define IS_IRDA_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3) == 0x00) && ((MODE) != (uint32_t)0x000000)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IrDA_Low_Power | |||
| * @{ | |||
| */ | |||
| #define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP) | |||
| #define IRDA_POWERMODE_NORMAL ((uint32_t)0x00000000) | |||
| #define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \ | |||
| ((MODE) == IRDA_POWERMODE_NORMAL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IRDA_Flags | |||
| * Elements values convention: 0xXXXX | |||
| * - 0xXXXX : Flag mask in the SR register | |||
| * @{ | |||
| */ | |||
| #define IRDA_FLAG_TXE ((uint32_t)0x00000080) | |||
| #define IRDA_FLAG_TC ((uint32_t)0x00000040) | |||
| #define IRDA_FLAG_RXNE ((uint32_t)0x00000020) | |||
| #define IRDA_FLAG_IDLE ((uint32_t)0x00000010) | |||
| #define IRDA_FLAG_ORE ((uint32_t)0x00000008) | |||
| #define IRDA_FLAG_NE ((uint32_t)0x00000004) | |||
| #define IRDA_FLAG_FE ((uint32_t)0x00000002) | |||
| #define IRDA_FLAG_PE ((uint32_t)0x00000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IRDA_Interrupt_definition | |||
| * Elements values convention: 0xY000XXXX | |||
| * - XXXX : Interrupt mask in the XX register | |||
| * - Y : Interrupt source register (2bits) | |||
| * - 01: CR1 register | |||
| * - 10: CR2 register | |||
| * - 11: CR3 register | |||
| * | |||
| * @{ | |||
| */ | |||
| #define IRDA_IT_PE ((uint32_t)0x10000100) | |||
| #define IRDA_IT_TXE ((uint32_t)0x10000080) | |||
| #define IRDA_IT_TC ((uint32_t)0x10000040) | |||
| #define IRDA_IT_RXNE ((uint32_t)0x10000020) | |||
| #define IRDA_IT_IDLE ((uint32_t)0x10000010) | |||
| #define IRDA_IT_LBD ((uint32_t)0x20000040) | |||
| #define IRDA_IT_CTS ((uint32_t)0x30000400) | |||
| #define IRDA_IT_ERR ((uint32_t)0x30000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset IRDA handle state | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IRDA_STATE_RESET) | |||
| /** @brief Flushs the IRDA DR register | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| */ | |||
| #define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) | |||
| /** @brief Checks whether the specified IRDA flag is set or not. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg IRDA_FLAG_TXE: Transmit data register empty flag | |||
| * @arg IRDA_FLAG_TC: Transmission Complete flag | |||
| * @arg IRDA_FLAG_RXNE: Receive data register not empty flag | |||
| * @arg IRDA_FLAG_IDLE: Idle Line detection flag | |||
| * @arg IRDA_FLAG_ORE: OverRun Error flag | |||
| * @arg IRDA_FLAG_NE: Noise Error flag | |||
| * @arg IRDA_FLAG_FE: Framing Error flag | |||
| * @arg IRDA_FLAG_PE: Parity Error flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clears the specified IRDA pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg IRDA_FLAG_TC: Transmission Complete flag. | |||
| * @arg IRDA_FLAG_RXNE: Receive data register not empty flag. | |||
| * | |||
| * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun | |||
| * error) and IDLE (Idle line detected) flags are cleared by software | |||
| * sequence: a read operation to USART_SR register followed by a read | |||
| * operation to USART_DR register. | |||
| * @note RXNE flag can be also cleared by a read to the USART_DR register. | |||
| * @note TC flag can be also cleared by software sequence: a read operation to | |||
| * USART_SR register followed by a write operation to USART_DR register. | |||
| * @note TXE flag is cleared only by a write to the USART_DR register. | |||
| * | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) | |||
| /** @brief Clear the IRDA PE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\ | |||
| (__HANDLE__)->Instance->DR;}while(0) | |||
| /** @brief Clear the IRDA FE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the IRDA NE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the IRDA ORE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the IRDA IDLE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Enables or disables the specified IRDA interrupt. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @param __INTERRUPT__: specifies the IRDA interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt | |||
| * @arg IRDA_IT_TC: Transmission complete interrupt | |||
| * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt | |||
| * @arg IRDA_IT_IDLE: Idle line detection interrupt | |||
| * @arg IRDA_IT_PE: Parity Error interrupt | |||
| * @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error) | |||
| * @param NewState: new state of the specified IRDA interrupt. | |||
| * This parameter can be: ENABLE or DISABLE. | |||
| * @retval None | |||
| */ | |||
| #define IRDA_IT_MASK ((uint32_t)0x0000FFFF) | |||
| #define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ | |||
| (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \ | |||
| ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK))) | |||
| #define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ | |||
| (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \ | |||
| ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK))) | |||
| /** @brief Checks whether the specified IRDA interrupt has occurred or not. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @param __IT__: specifies the IRDA interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg IRDA_IT_TXE: Transmit Data Register empty interrupt | |||
| * @arg IRDA_IT_TC: Transmission complete interrupt | |||
| * @arg IRDA_IT_RXNE: Receive Data register not empty interrupt | |||
| * @arg IRDA_IT_IDLE: Idle line detection interrupt | |||
| * @arg USART_IT_ERR: Error interrupt | |||
| * @arg IRDA_IT_PE: Parity Error interrupt | |||
| * @retval The new state of __IT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28) == 2)? \ | |||
| (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK)) | |||
| #define __IRDA_ENABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 |= USART_CR1_UE) | |||
| #define __IRDA_DISABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) | |||
| #define __DIV(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_))) | |||
| #define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_))/100) | |||
| #define __DIVFRAQ(_PCLK_, _BAUD_) (((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100) | |||
| #define __IRDA_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4)|(__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F)) | |||
| #define IS_IRDA_BAUDRATE(BAUDRATE) ((BAUDRATE) < 115201) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda); | |||
| HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda); | |||
| void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda); | |||
| void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda); | |||
| /* IO operation functions *******************************************************/ | |||
| HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda); | |||
| HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda); | |||
| HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda); | |||
| void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda); | |||
| void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda); | |||
| void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda); | |||
| void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda); | |||
| void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda); | |||
| void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda); | |||
| /* Peripheral State functions **************************************************/ | |||
| HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda); | |||
| uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_IRDA_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,248 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_iwdg.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of IWDG HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_IWDG_H | |||
| #define __STM32F4xx_HAL_IWDG_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup IWDG | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief IWDG HAL State Structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_IWDG_STATE_RESET = 0x00, /*!< IWDG not yet initialized or disabled */ | |||
| HAL_IWDG_STATE_READY = 0x01, /*!< IWDG initialized and ready for use */ | |||
| HAL_IWDG_STATE_BUSY = 0x02, /*!< IWDG internal process is ongoing */ | |||
| HAL_IWDG_STATE_TIMEOUT = 0x03, /*!< IWDG timeout state */ | |||
| HAL_IWDG_STATE_ERROR = 0x04 /*!< IWDG error state */ | |||
| }HAL_IWDG_StateTypeDef; | |||
| /** | |||
| * @brief IWDG Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Prescaler; /*!< Select the prescaler of the IWDG. | |||
| This parameter can be a value of @ref IWDG_Prescaler */ | |||
| uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ | |||
| }IWDG_InitTypeDef; | |||
| /** | |||
| * @brief IWDG handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| IWDG_TypeDef *Instance; /*!< Register base address */ | |||
| IWDG_InitTypeDef Init; /*!< IWDG required parameters */ | |||
| HAL_LockTypeDef Lock; /*!< IWDG locking object */ | |||
| __IO HAL_IWDG_StateTypeDef State; /*!< IWDG communication state */ | |||
| }IWDG_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup IWDG_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup IWDG_Registers_BitMask | |||
| * @{ | |||
| */ | |||
| /* --- KR Register ---*/ | |||
| /* KR register bit mask */ | |||
| #define KR_KEY_RELOAD ((uint32_t)0xAAAA) /*!< IWDG reload counter enable */ | |||
| #define KR_KEY_ENABLE ((uint32_t)0xCCCC) /*!< IWDG peripheral enable */ | |||
| #define KR_KEY_EWA ((uint32_t)0x5555) /*!< IWDG KR write Access enable */ | |||
| #define KR_KEY_DWA ((uint32_t)0x0000) /*!< IWDG KR write Access disable */ | |||
| #define IS_IWDG_KR(__KR__) (((__KR__) == KR_KEY_RELOAD) || \ | |||
| ((__KR__) == KR_KEY_ENABLE))|| \ | |||
| ((__KR__) == KR_KEY_EWA)) || \ | |||
| ((__KR__) == KR_KEY_DWA)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IWDG_Flag_definition | |||
| * @{ | |||
| */ | |||
| #define IWDG_FLAG_PVU ((uint32_t)0x0001) /*!< Watchdog counter prescaler value update flag */ | |||
| #define IWDG_FLAG_RVU ((uint32_t)0x0002) /*!< Watchdog counter reload value update flag */ | |||
| #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || \ | |||
| ((FLAG) == IWDG_FLAG_RVU)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IWDG_Prescaler | |||
| * @{ | |||
| */ | |||
| #define IWDG_PRESCALER_4 ((uint8_t)0x00) /*!< IWDG prescaler set to 4 */ | |||
| #define IWDG_PRESCALER_8 ((uint8_t)(IWDG_PR_PR_0)) /*!< IWDG prescaler set to 8 */ | |||
| #define IWDG_PRESCALER_16 ((uint8_t)(IWDG_PR_PR_1)) /*!< IWDG prescaler set to 16 */ | |||
| #define IWDG_PRESCALER_32 ((uint8_t)(IWDG_PR_PR_1 | IWDG_PR_PR_0)) /*!< IWDG prescaler set to 32 */ | |||
| #define IWDG_PRESCALER_64 ((uint8_t)(IWDG_PR_PR_2)) /*!< IWDG prescaler set to 64 */ | |||
| #define IWDG_PRESCALER_128 ((uint8_t)(IWDG_PR_PR_2 | IWDG_PR_PR_0)) /*!< IWDG prescaler set to 128 */ | |||
| #define IWDG_PRESCALER_256 ((uint8_t)(IWDG_PR_PR_2 | IWDG_PR_PR_1)) /*!< IWDG prescaler set to 256 */ | |||
| #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_PRESCALER_4) || \ | |||
| ((PRESCALER) == IWDG_PRESCALER_8) || \ | |||
| ((PRESCALER) == IWDG_PRESCALER_16) || \ | |||
| ((PRESCALER) == IWDG_PRESCALER_32) || \ | |||
| ((PRESCALER) == IWDG_PRESCALER_64) || \ | |||
| ((PRESCALER) == IWDG_PRESCALER_128)|| \ | |||
| ((PRESCALER) == IWDG_PRESCALER_256)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IWDG_Reload_Value | |||
| * @{ | |||
| */ | |||
| #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset IWDG handle state | |||
| * @param __HANDLE__: IWDG handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IWDG_STATE_RESET) | |||
| /** | |||
| * @brief Enables the IWDG peripheral. | |||
| * @param __HANDLE__: IWDG handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, KR_KEY_ENABLE) | |||
| /** | |||
| * @brief Reloads IWDG counter with value defined in the reload register | |||
| * (write access to IWDG_PR and IWDG_RLR registers disabled). | |||
| * @param __HANDLE__: IWDG handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, KR_KEY_RELOAD) | |||
| /** | |||
| * @brief Enables write access to IWDG_PR and IWDG_RLR registers. | |||
| * @param __HANDLE__: IWDG handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, KR_KEY_EWA) | |||
| /** | |||
| * @brief Disables write access to IWDG_PR and IWDG_RLR registers. | |||
| * @param __HANDLE__: IWDG handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, KR_KEY_DWA) | |||
| /** | |||
| * @brief Gets the selected IWDG's flag status. | |||
| * @param __HANDLE__: IWDG handle | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg IWDG_FLAG_PVU: Watchdog counter reload value update flag | |||
| * @arg IWDG_FLAG_RVU: Watchdog counter prescaler value flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_IWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions ********************************/ | |||
| HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); | |||
| void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg); | |||
| /* I/O operation functions ****************************************************/ | |||
| HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg); | |||
| HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); | |||
| /* Peripheral State functions ************************************************/ | |||
| HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_IWDG_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,582 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_ltdc.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of LTDC HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_LTDC_H | |||
| #define __STM32F4xx_HAL_LTDC_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup LTDC | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| #define MAX_LAYER 2 | |||
| /** | |||
| * @brief LTDC color structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint8_t Blue; /*!< Configures the blue value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ | |||
| uint8_t Green; /*!< Configures the green value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ | |||
| uint8_t Red; /*!< Configures the red value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ | |||
| uint8_t Reserved; /*!< Reserved 0xFF */ | |||
| } LTDC_ColorTypeDef; | |||
| /** | |||
| * @brief LTDC Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t HSPolarity; /*!< configures the horizontal synchronization polarity. | |||
| This parameter can be one value of @ref LTDC_HS_POLARITY */ | |||
| uint32_t VSPolarity; /*!< configures the vertical synchronization polarity. | |||
| This parameter can be one value of @ref LTDC_VS_POLARITY */ | |||
| uint32_t DEPolarity; /*!< configures the data enable polarity. | |||
| This parameter can be one of value of @ref LTDC_DE_POLARITY */ | |||
| uint32_t PCPolarity; /*!< configures the pixel clock polarity. | |||
| This parameter can be one of value of @ref LTDC_PC_POLARITY */ | |||
| uint32_t HorizontalSync; /*!< configures the number of Horizontal synchronization width. | |||
| This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ | |||
| uint32_t VerticalSync; /*!< configures the number of Vertical synchronization heigh. | |||
| This parameter must be a number between Min_Data = 0x000 and Max_Data = 0x7FF. */ | |||
| uint32_t AccumulatedHBP; /*!< configures the accumulated horizontal back porch width. | |||
| This parameter must be a number between Min_Data = LTDC_HorizontalSync and Max_Data = 0xFFF. */ | |||
| uint32_t AccumulatedVBP; /*!< configures the accumulated vertical back porch heigh. | |||
| This parameter must be a number between Min_Data = LTDC_VerticalSync and Max_Data = 0x7FF. */ | |||
| uint32_t AccumulatedActiveW; /*!< configures the accumulated active width. | |||
| This parameter must be a number between Min_Data = LTDC_AccumulatedHBP and Max_Data = 0xFFF. */ | |||
| uint32_t AccumulatedActiveH; /*!< configures the accumulated active heigh. | |||
| This parameter must be a number between Min_Data = LTDC_AccumulatedVBP and Max_Data = 0x7FF. */ | |||
| uint32_t TotalWidth; /*!< configures the total width. | |||
| This parameter must be a number between Min_Data = LTDC_AccumulatedActiveW and Max_Data = 0xFFF. */ | |||
| uint32_t TotalHeigh; /*!< configures the total heigh. | |||
| This parameter must be a number between Min_Data = LTDC_AccumulatedActiveH and Max_Data = 0x7FF. */ | |||
| LTDC_ColorTypeDef Backcolor; /*!< Configures the background color. */ | |||
| } LTDC_InitTypeDef; | |||
| /** | |||
| * @brief LTDC Layer structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t WindowX0; /*!< Configures the Window Horizontal Start Position. | |||
| This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ | |||
| uint32_t WindowX1; /*!< Configures the Window Horizontal Stop Position. | |||
| This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ | |||
| uint32_t WindowY0; /*!< Configures the Window vertical Start Position. | |||
| This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */ | |||
| uint32_t WindowY1; /*!< Configures the Window vertical Stop Position. | |||
| This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ | |||
| uint32_t PixelFormat; /*!< Specifies the pixel format. | |||
| This parameter can be one of value of @ref LTDC_Pixelformat */ | |||
| uint32_t Alpha; /*!< Specifies the constant alpha used for blending. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ | |||
| uint32_t Alpha0; /*!< Configures the default alpha value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ | |||
| uint32_t BlendingFactor1; /*!< Select the blending factor 1. | |||
| This parameter can be one of value of @ref LTDC_BlendingFactor1 */ | |||
| uint32_t BlendingFactor2; /*!< Select the blending factor 2. | |||
| This parameter can be one of value of @ref LTDC_BlendingFactor2 */ | |||
| uint32_t FBStartAdress; /*!< Configures the color frame buffer address */ | |||
| uint32_t ImageWidth; /*!< Configures the color frame buffer line length. | |||
| This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x1FFF. */ | |||
| uint32_t ImageHeight; /*!< Specifies the number of line in frame buffer. | |||
| This parameter must be a number between Min_Data = 0x000 and Max_Data = 0x7FF. */ | |||
| LTDC_ColorTypeDef Backcolor; /*!< Configures the layer background color. */ | |||
| } LTDC_LayerCfgTypeDef; | |||
| /** | |||
| * @brief HAL LTDC State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_LTDC_STATE_RESET = 0x00, /*!< LTDC not yet initialized or disabled */ | |||
| HAL_LTDC_STATE_READY = 0x01, /*!< LTDC initialized and ready for use */ | |||
| HAL_LTDC_STATE_BUSY = 0x02, /*!< LTDC internal process is ongoing */ | |||
| HAL_LTDC_STATE_TIMEOUT = 0x03, /*!< LTDC Timeout state */ | |||
| HAL_LTDC_STATE_ERROR = 0x04 /*!< LTDC state error */ | |||
| }HAL_LTDC_StateTypeDef; | |||
| /** | |||
| * @brief LTDC handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| LTDC_TypeDef *Instance; /*!< LTDC Register base address */ | |||
| LTDC_InitTypeDef Init; /*!< LTDC parameters */ | |||
| LTDC_LayerCfgTypeDef LayerCfg[MAX_LAYER]; /*!< LTDC Layers parameters */ | |||
| HAL_LockTypeDef Lock; /*!< LTDC Lock */ | |||
| __IO HAL_LTDC_StateTypeDef State; /*!< LTDC state */ | |||
| __IO uint32_t ErrorCode; /*!< LTDC Error code */ | |||
| } LTDC_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup LTDC_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup LTDC_Layer | |||
| * @{ | |||
| */ | |||
| #define IS_LTDC_LAYER(LAYER) ((LAYER) <= MAX_LAYER) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC Error Code | |||
| * @{ | |||
| */ | |||
| #define HAL_LTDC_ERROR_NONE ((uint32_t)0x00000000) /*!< LTDC No error */ | |||
| #define HAL_LTDC_ERROR_TE ((uint32_t)0x00000001) /*!< LTDC Transfer error */ | |||
| #define HAL_LTDC_ERROR_FU ((uint32_t)0x00000002) /*!< LTDC FIFO Underrun */ | |||
| #define HAL_LTDC_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< LTDC Timeout error */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_HS_POLARITY | |||
| * @{ | |||
| */ | |||
| #define LTDC_HSPOLARITY_AL ((uint32_t)0x00000000) /*!< Horizontal Synchronization is active low. */ | |||
| #define LTDC_HSPOLARITY_AH LTDC_GCR_HSPOL /*!< Horizontal Synchronization is active high. */ | |||
| #define IS_LTDC_HSPOL(HSPOL) (((HSPOL) == LTDC_HSPOLARITY_AL) || \ | |||
| ((HSPOL) == LTDC_HSPOLARITY_AH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_VS_POLARITY | |||
| * @{ | |||
| */ | |||
| #define LTDC_VSPOLARITY_AL ((uint32_t)0x00000000) /*!< Vertical Synchronization is active low. */ | |||
| #define LTDC_VSPOLARITY_AH LTDC_GCR_VSPOL /*!< Vertical Synchronization is active high. */ | |||
| #define IS_LTDC_VSPOL(VSPOL) (((VSPOL) == LTDC_VSPOLARITY_AL) || \ | |||
| ((VSPOL) == LTDC_VSPOLARITY_AH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_DE_POLARITY | |||
| * @{ | |||
| */ | |||
| #define LTDC_DEPOLARITY_AL ((uint32_t)0x00000000) /*!< Data Enable, is active low. */ | |||
| #define LTDC_DEPOLARITY_AH LTDC_GCR_DEPOL /*!< Data Enable, is active high. */ | |||
| #define IS_LTDC_DEPOL(DEPOL) (((DEPOL) == LTDC_DEPOLARITY_AL) || \ | |||
| ((DEPOL) == LTDC_DEPOLARITY_AH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_PC_POLARITY | |||
| * @{ | |||
| */ | |||
| #define LTDC_PCPOLARITY_IPC ((uint32_t)0x00000000) /*!< input pixel clock. */ | |||
| #define LTDC_PCPOLARITY_IIPC LTDC_GCR_PCPOL /*!< inverted input pixel clock. */ | |||
| #define IS_LTDC_PCPOL(PCPOL) (((PCPOL) == LTDC_PCPOLARITY_IPC) || \ | |||
| ((PCPOL) == LTDC_PCPOLARITY_IIPC)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_SYNC | |||
| * @{ | |||
| */ | |||
| #define LTDC_HORIZONTALSYNC (LTDC_SSCR_HSW >> 16) /*!< Horizontal synchronization width. */ | |||
| #define LTDC_VERTICALSYNC LTDC_SSCR_VSH /*!< Vertical synchronization heigh. */ | |||
| #define IS_LTDC_HSYNC(HSYNC) ((HSYNC) <= LTDC_HORIZONTALSYNC) | |||
| #define IS_LTDC_VSYNC(VSYNC) ((VSYNC) <= LTDC_VERTICALSYNC) | |||
| #define IS_LTDC_AHBP(AHBP) ((AHBP) <= LTDC_HORIZONTALSYNC) | |||
| #define IS_LTDC_AVBP(AVBP) ((AVBP) <= LTDC_VERTICALSYNC) | |||
| #define IS_LTDC_AAW(AAW) ((AAW) <= LTDC_HORIZONTALSYNC) | |||
| #define IS_LTDC_AAH(AAH) ((AAH) <= LTDC_VERTICALSYNC) | |||
| #define IS_LTDC_TOTALW(TOTALW) ((TOTALW) <= LTDC_HORIZONTALSYNC) | |||
| #define IS_LTDC_TOTALH(TOTALH) ((TOTALH) <= LTDC_VERTICALSYNC) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_BACK_COLOR | |||
| * @{ | |||
| */ | |||
| #define LTDC_COLOR ((uint32_t)0x000000FF) /*!< Color mask */ | |||
| #define IS_LTDC_BLUEVALUE(BBLUE) ((BBLUE) <= LTDC_COLOR) | |||
| #define IS_LTDC_GREENVALUE(BGREEN) ((BGREEN) <= LTDC_COLOR) | |||
| #define IS_LTDC_REDVALUE(BRED) ((BRED) <= LTDC_COLOR) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_BlendingFactor1 | |||
| * @{ | |||
| */ | |||
| #define LTDC_BLENDING_FACTOR1_CA ((uint32_t)0x00000400) /*!< Blending factor : Cte Alpha */ | |||
| #define LTDC_BLENDING_FACTOR1_PAxCA ((uint32_t)0x00000600) /*!< Blending factor : Cte Alpha x Pixel Alpha*/ | |||
| #define IS_LTDC_BLENDING_FACTOR1(BlendingFactor1) (((BlendingFactor1) == LTDC_BLENDING_FACTOR1_CA) || \ | |||
| ((BlendingFactor1) == LTDC_BLENDING_FACTOR1_PAxCA)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_BlendingFactor2 | |||
| * @{ | |||
| */ | |||
| #define LTDC_BLENDING_FACTOR2_CA ((uint32_t)0x00000005) /*!< Blending factor : Cte Alpha */ | |||
| #define LTDC_BLENDING_FACTOR2_PAxCA ((uint32_t)0x00000007) /*!< Blending factor : Cte Alpha x Pixel Alpha*/ | |||
| #define IS_LTDC_BLENDING_FACTOR2(BlendingFactor2) (((BlendingFactor2) == LTDC_BLENDING_FACTOR2_CA) || \ | |||
| ((BlendingFactor2) == LTDC_BLENDING_FACTOR2_PAxCA)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_Pixelformat | |||
| * @{ | |||
| */ | |||
| #define LTDC_PIXEL_FORMAT_ARGB8888 ((uint32_t)0x00000000) /*!< ARGB8888 LTDC pixel format */ | |||
| #define LTDC_PIXEL_FORMAT_RGB888 ((uint32_t)0x00000001) /*!< RGB888 LTDC pixel format */ | |||
| #define LTDC_PIXEL_FORMAT_RGB565 ((uint32_t)0x00000002) /*!< RGB565 LTDC pixel format */ | |||
| #define LTDC_PIXEL_FORMAT_ARGB1555 ((uint32_t)0x00000003) /*!< ARGB1555 LTDC pixel format */ | |||
| #define LTDC_PIXEL_FORMAT_ARGB4444 ((uint32_t)0x00000004) /*!< ARGB4444 LTDC pixel format */ | |||
| #define LTDC_PIXEL_FORMAT_L8 ((uint32_t)0x00000005) /*!< L8 LTDC pixel format */ | |||
| #define LTDC_PIXEL_FORMAT_AL44 ((uint32_t)0x00000006) /*!< AL44 LTDC pixel format */ | |||
| #define LTDC_PIXEL_FORMAT_AL88 ((uint32_t)0x00000007) /*!< AL88 LTDC pixel format */ | |||
| #define IS_LTDC_PIXEL_FORMAT(Pixelformat) (((Pixelformat) == LTDC_PIXEL_FORMAT_ARGB8888) || ((Pixelformat) == LTDC_PIXEL_FORMAT_RGB888) || \ | |||
| ((Pixelformat) == LTDC_PIXEL_FORMAT_RGB565) || ((Pixelformat) == LTDC_PIXEL_FORMAT_ARGB1555) || \ | |||
| ((Pixelformat) == LTDC_PIXEL_FORMAT_ARGB4444) || ((Pixelformat) == LTDC_PIXEL_FORMAT_L8) || \ | |||
| ((Pixelformat) == LTDC_PIXEL_FORMAT_AL44) || ((Pixelformat) == LTDC_PIXEL_FORMAT_AL88)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_Alpha | |||
| * @{ | |||
| */ | |||
| #define LTDC_ALPHA LTDC_LxCACR_CONSTA /*!< LTDC Cte Alpha mask */ | |||
| #define IS_LTDC_ALPHA(ALPHA) ((ALPHA) <= LTDC_ALPHA) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_LAYER_Config | |||
| * @{ | |||
| */ | |||
| #define LTDC_STOPPOSITION (LTDC_LxWHPCR_WHSPPOS >> 16) /*!< LTDC Layer stop position */ | |||
| #define LTDC_STARTPOSITION LTDC_LxWHPCR_WHSTPOS /*!< LTDC Layer start position */ | |||
| #define LTDC_COLOR_FRAME_BUFFER LTDC_LxCFBLR_CFBLL /*!< LTDC Layer Line length */ | |||
| #define LTDC_LINE_NUMBER LTDC_LxCFBLNR_CFBLNBR /*!< LTDC Layer Line number */ | |||
| #define IS_LTDC_HCONFIGST(HCONFIGST) ((HCONFIGST) <= LTDC_STARTPOSITION) | |||
| #define IS_LTDC_HCONFIGSP(HCONFIGSP) ((HCONFIGSP) <= LTDC_STOPPOSITION) | |||
| #define IS_LTDC_VCONFIGST(VCONFIGST) ((VCONFIGST) <= LTDC_STARTPOSITION) | |||
| #define IS_LTDC_VCONFIGSP(VCONFIGSP) ((VCONFIGSP) <= LTDC_STOPPOSITION) | |||
| #define IS_LTDC_CFBP(CFBP) ((CFBP) <= LTDC_COLOR_FRAME_BUFFER) | |||
| #define IS_LTDC_CFBLL(CFBLL) ((CFBLL) <= LTDC_COLOR_FRAME_BUFFER) | |||
| #define IS_LTDC_CFBLNBR(CFBLNBR) ((CFBLNBR) <= LTDC_LINE_NUMBER) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_LIPosition | |||
| * @{ | |||
| */ | |||
| #define IS_LTDC_LIPOS(LIPOS) ((LIPOS) <= 0x7FF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_Interrupts | |||
| * @{ | |||
| */ | |||
| #define LTDC_IT_LI LTDC_IER_LIE | |||
| #define LTDC_IT_FU LTDC_IER_FUIE | |||
| #define LTDC_IT_TE LTDC_IER_TERRIE | |||
| #define LTDC_IT_RR LTDC_IER_RRIE | |||
| #define IS_LTDC_IT(IT) ((((IT) & (uint32_t)0xFFFFFFF0) == 0x00) && ((IT) != 0x00)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup LTDC_Flag | |||
| * @{ | |||
| */ | |||
| #define LTDC_FLAG_LI LTDC_ISR_LIF | |||
| #define LTDC_FLAG_FU LTDC_ISR_FUIF | |||
| #define LTDC_FLAG_TE LTDC_ISR_TERRIF | |||
| #define LTDC_FLAG_RR LTDC_ISR_RRIF | |||
| #define IS_LTDC_FLAG(FLAG) (((FLAG) == LTDC_FLAG_LI) || ((FLAG) == LTDC_FLAG_FU) || \ | |||
| ((FLAG) == LTDC_FLAG_TERR) || ((FLAG) == LTDC_FLAG_RR)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset LTDC handle state | |||
| * @param __HANDLE__: specifies the LTDC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_LTDC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LTDC_STATE_RESET) | |||
| /** | |||
| * @brief Enable the LTDC. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_LTDC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->GCR |= LTDC_GCR_LTDCEN) | |||
| /** | |||
| * @brief Disable the LTDC. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_LTDC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->GCR &= ~(LTDC_GCR_LTDCEN)) | |||
| /** | |||
| * @brief Enable the LTDC Layer. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @param __LAYER__: Specify the layer to be enabled | |||
| This parameter can be 0 or 1 | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_LTDC_LAYER(__HANDLE__, __LAYER__) ((LTDC_Layer_TypeDef *)(((uint32_t)((__HANDLE__)->Instance)) + 0x84 + (0x80*(__LAYER__)))) | |||
| #define __HAL_LTDC_LAYER_ENABLE(__HANDLE__, __LAYER__) ((__HAL_LTDC_LAYER((__HANDLE__), (__LAYER__)))->CR |= (uint32_t)LTDC_LxCR_LEN) | |||
| /** | |||
| * @brief Disable the LTDC Layer. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @param __LAYER__: Specify the layer to be disabled | |||
| This parameter can be 0 or 1 | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_LTDC_LAYER_DISABLE(__HANDLE__, __LAYER__) ((__HAL_LTDC_LAYER((__HANDLE__), (__LAYER__)))->CR &= ~(uint32_t)LTDC_LxCR_LEN) | |||
| /** | |||
| * @brief Reload Layer Configuration. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_LTDC_RELOAD_CONFIG(__HANDLE__) ((__HANDLE__)->Instance->SRCR |= LTDC_SRCR_IMR) | |||
| /* Interrupt & Flag management */ | |||
| /** | |||
| * @brief Get the LTDC pending flags. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @param __FLAG__: Get the specified flag. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg LTDC_FLAG_LI: Line Interrupt flag | |||
| * @arg LTDC_FLAG_FU: FIFO Underrun Interrupt flag | |||
| * @arg LTDC_FLAG_TE: Transfer Error interrupt flag | |||
| * @arg LTDC_FLAG_RR: Register Reload Interrupt Flag | |||
| * @retval The state of FLAG (SET or RESET). | |||
| */ | |||
| #define __HAL_LTDC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR & (__FLAG__)) | |||
| /** | |||
| * @brief Clears the LTDC pending flags. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @param __FLAG__: specifies the flag to clear. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg LTDC_FLAG_LI: Line Interrupt flag | |||
| * @arg LTDC_FLAG_FU: FIFO Underrun Interrupt flag | |||
| * @arg LTDC_FLAG_TE: Transfer Error interrupt flag | |||
| * @arg LTDC_FLAG_RR: Register Reload Interrupt Flag | |||
| * @retval None | |||
| */ | |||
| #define __HAL_LTDC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) | |||
| /** | |||
| * @brief Enables the specified LTDC interrupts. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @param __INTERRUPT__: specifies the LTDC interrupt sources to be enabled. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg LTDC_IT_LI: Line Interrupt flag | |||
| * @arg LTDC_IT_FU: FIFO Underrun Interrupt flag | |||
| * @arg LTDC_IT_TE: Transfer Error interrupt flag | |||
| * @arg LTDC_IT_RR: Register Reload Interrupt Flag | |||
| * @retval None | |||
| */ | |||
| #define __HAL_LTDC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disables the specified LTDC interrupts. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @param __INTERRUPT__: specifies the LTDC interrupt sources to be disabled. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg LTDC_IT_LI: Line Interrupt flag | |||
| * @arg LTDC_IT_FU: FIFO Underrun Interrupt flag | |||
| * @arg LTDC_IT_TE: Transfer Error interrupt flag | |||
| * @arg LTDC_IT_RR: Register Reload Interrupt Flag | |||
| * @retval None | |||
| */ | |||
| #define __HAL_LTDC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__)) | |||
| /** | |||
| * @brief Checks whether the specified LTDC interrupt has occurred or not. | |||
| * @param __HANDLE__: LTDC handle | |||
| * @param __INTERRUPT__: specifies the LTDC interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg LTDC_IT_LI: Line Interrupt flag | |||
| * @arg LTDC_IT_FU: FIFO Underrun Interrupt flag | |||
| * @arg LTDC_IT_TE: Transfer Error interrupt flag | |||
| * @arg LTDC_IT_RR: Register Reload Interrupt Flag | |||
| * @retval The state of INTERRUPT (SET or RESET). | |||
| */ | |||
| #define __HAL_LTDC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->ISR & (__INTERRUPT__)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization and de-initialization functions *****************************/ | |||
| HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc); | |||
| HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc); | |||
| void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc); | |||
| void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc); | |||
| void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc); | |||
| void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc); | |||
| /* IO operation functions *****************************************************/ | |||
| void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc); | |||
| /* Peripheral Control functions ***********************************************/ | |||
| HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); | |||
| HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line); | |||
| HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc); | |||
| HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc); | |||
| /* Peripheral State functions *************************************************/ | |||
| HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc); | |||
| uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc); | |||
| #endif /* STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_LTDC_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,250 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_nand.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of NAND HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_NAND_H | |||
| #define __STM32F4xx_HAL_NAND_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) | |||
| #include "stm32f4xx_ll_fsmc.h" | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #include "stm32f4xx_ll_fmc.h" | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup NAND | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Exported typedef ----------------------------------------------------------*/ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL NAND State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_NAND_STATE_RESET = 0x00, /*!< NAND not yet initialized or disabled */ | |||
| HAL_NAND_STATE_READY = 0x01, /*!< NAND initialized and ready for use */ | |||
| HAL_NAND_STATE_BUSY = 0x02, /*!< NAND internal process is ongoing */ | |||
| HAL_NAND_STATE_ERROR = 0x03 /*!< NAND error state */ | |||
| }HAL_NAND_StateTypeDef; | |||
| /** | |||
| * @brief NAND Memory electronic signature Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| /*<! NAND memory electronic signature maker and device IDs */ | |||
| uint8_t Maker_Id; | |||
| uint8_t Device_Id; | |||
| uint8_t Third_Id; | |||
| uint8_t Fourth_Id; | |||
| }NAND_IDTypeDef; | |||
| /** | |||
| * @brief NAND Memory address Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint16_t Page; /*!< NAND memory Page address */ | |||
| uint16_t Zone; /*!< NAND memory Zone address */ | |||
| uint16_t Block; /*!< NAND memory Block address */ | |||
| }NAND_AddressTypedef; | |||
| /** | |||
| * @brief NAND Memory info Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t PageSize; /*!< NAND memory page (without spare area) size measured in K. bytes */ | |||
| uint32_t SpareAreaSize; /*!< NAND memory spare area size measured in K. bytes */ | |||
| uint32_t BlockSize; /*!< NAND memory block size number of pages */ | |||
| uint32_t BlockNbr; /*!< NAND memory number of blocks */ | |||
| uint32_t ZoneSize; /*!< NAND memory zone size measured in number of blocks */ | |||
| }NAND_InfoTypeDef; | |||
| /** | |||
| * @brief NAND handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| FMC_NAND_TypeDef *Instance; /*!< Register base address */ | |||
| FMC_NAND_InitTypeDef Init; /*!< NAND device control configuration parameters */ | |||
| HAL_LockTypeDef Lock; /*!< NAND locking object */ | |||
| __IO HAL_NAND_StateTypeDef State; /*!< NAND device access state */ | |||
| NAND_InfoTypeDef Info; /*!< NAND characteristic information structure */ | |||
| }NAND_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup NAND_Exported_Constants | |||
| * @{ | |||
| */ | |||
| #define NAND_DEVICE1 ((uint32_t)0x70000000) | |||
| #define NAND_DEVICE2 ((uint32_t)0x80000000) | |||
| #define NAND_WRITE_TIMEOUT ((uint32_t)0x01000000) | |||
| #define CMD_AREA ((uint32_t)(1<<16)) /* A16 = CLE high */ | |||
| #define ADDR_AREA ((uint32_t)(1<<17)) /* A17 = ALE high */ | |||
| #define NAND_CMD_AREA_A ((uint8_t)0x00) | |||
| #define NAND_CMD_AREA_B ((uint8_t)0x01) | |||
| #define NAND_CMD_AREA_C ((uint8_t)0x50) | |||
| #define NAND_CMD_AREA_TRUE1 ((uint8_t)0x30) | |||
| #define NAND_CMD_WRITE0 ((uint8_t)0x80) | |||
| #define NAND_CMD_WRITE_TRUE1 ((uint8_t)0x10) | |||
| #define NAND_CMD_ERASE0 ((uint8_t)0x60) | |||
| #define NAND_CMD_ERASE1 ((uint8_t)0xD0) | |||
| #define NAND_CMD_READID ((uint8_t)0x90) | |||
| #define NAND_CMD_STATUS ((uint8_t)0x70) | |||
| #define NAND_CMD_LOCK_STATUS ((uint8_t)0x7A) | |||
| #define NAND_CMD_RESET ((uint8_t)0xFF) | |||
| /* NAND memory status */ | |||
| #define NAND_VALID_ADDRESS ((uint32_t)0x00000100) | |||
| #define NAND_INVALID_ADDRESS ((uint32_t)0x00000200) | |||
| #define NAND_TIMEOUT_ERROR ((uint32_t)0x00000400) | |||
| #define NAND_BUSY ((uint32_t)0x00000000) | |||
| #define NAND_ERROR ((uint32_t)0x00000001) | |||
| #define NAND_READY ((uint32_t)0x00000040) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset NAND handle state | |||
| * @param __HANDLE__: specifies the NAND handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_NAND_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NAND_STATE_RESET) | |||
| /** | |||
| * @brief NAND memory address computation. | |||
| * @param __ADDRESS__: NAND memory address. | |||
| * @param __HANDLE__ : NAND handle. | |||
| * @retval NAND Raw address value | |||
| */ | |||
| #define __ARRAY_ADDRESS(__ADDRESS__ , __HANDLE__) ((__ADDRESS__)->Page + \ | |||
| (((__ADDRESS__)->Block + (((__ADDRESS__)->Zone) * ((__HANDLE__)->Info.ZoneSize)))* ((__HANDLE__)->Info.BlockSize))) | |||
| /** | |||
| * @brief NAND memory address cycling. | |||
| * @param __ADDRESS__: NAND memory address. | |||
| * @retval NAND address cycling value. | |||
| */ | |||
| #define __ADDR_1st_CYCLE(__ADDRESS__) (uint8_t)(__ADDRESS__) /* 1st addressing cycle */ | |||
| #define __ADDR_2nd_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 8) /* 2nd addressing cycle */ | |||
| #define __ADDR_3rd_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 16) /* 3rd addressing cycle */ | |||
| #define __ADDR_4th_CYCLE(__ADDRESS__) (uint8_t)((__ADDRESS__) >> 24) /* 4th addressing cycle */ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions ********************************/ | |||
| HAL_StatusTypeDef HAL_NAND_Init(NAND_HandleTypeDef *hnand, FMC_NAND_PCC_TimingTypeDef *ComSpace_Timing, FMC_NAND_PCC_TimingTypeDef *AttSpace_Timing); | |||
| HAL_StatusTypeDef HAL_NAND_DeInit(NAND_HandleTypeDef *hnand); | |||
| void HAL_NAND_MspInit(NAND_HandleTypeDef *hnand); | |||
| void HAL_NAND_MspDeInit(NAND_HandleTypeDef *hnand); | |||
| void HAL_NAND_IRQHandler(NAND_HandleTypeDef *hnand); | |||
| void HAL_NAND_ITCallback(NAND_HandleTypeDef *hnand); | |||
| /* IO operation functions ****************************************************/ | |||
| HAL_StatusTypeDef HAL_NAND_Read_ID(NAND_HandleTypeDef *hnand, NAND_IDTypeDef *pNAND_ID); | |||
| HAL_StatusTypeDef HAL_NAND_Reset(NAND_HandleTypeDef *hnand); | |||
| HAL_StatusTypeDef HAL_NAND_Read_Page(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumPageToRead); | |||
| HAL_StatusTypeDef HAL_NAND_Write_Page(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumPageToWrite); | |||
| HAL_StatusTypeDef HAL_NAND_Read_SpareArea(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumSpareAreaToRead); | |||
| HAL_StatusTypeDef HAL_NAND_Write_SpareArea(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress, uint8_t *pBuffer, uint32_t NumSpareAreaTowrite); | |||
| HAL_StatusTypeDef HAL_NAND_Erase_Block(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress); | |||
| uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand); | |||
| uint32_t HAL_NAND_Address_Inc(NAND_HandleTypeDef *hnand, NAND_AddressTypedef *pAddress); | |||
| /* NAND Control functions ****************************************************/ | |||
| HAL_StatusTypeDef HAL_NAND_ECC_Enable(NAND_HandleTypeDef *hnand); | |||
| HAL_StatusTypeDef HAL_NAND_ECC_Disable(NAND_HandleTypeDef *hnand); | |||
| HAL_StatusTypeDef HAL_NAND_GetECC(NAND_HandleTypeDef *hnand, uint32_t *ECCval, uint32_t Timeout); | |||
| /* NAND State functions *******************************************************/ | |||
| HAL_NAND_StateTypeDef HAL_NAND_GetState(NAND_HandleTypeDef *hnand); | |||
| uint32_t HAL_NAND_Read_Status(NAND_HandleTypeDef *hnand); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_NAND_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,243 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_nor.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of NOR HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_NOR_H | |||
| #define __STM32F4xx_HAL_NOR_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) | |||
| #include "stm32f4xx_ll_fsmc.h" | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #include "stm32f4xx_ll_fmc.h" | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup NOR | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Exported typedef ----------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL SRAM State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_NOR_STATE_RESET = 0x00, /*!< NOR not yet initialized or disabled */ | |||
| HAL_NOR_STATE_READY = 0x01, /*!< NOR initialized and ready for use */ | |||
| HAL_NOR_STATE_BUSY = 0x02, /*!< NOR internal processing is ongoing */ | |||
| HAL_NOR_STATE_ERROR = 0x03, /*!< NOR error state */ | |||
| HAL_NOR_STATE_PROTECTED = 0x04 /*!< NOR NORSRAM device write protected */ | |||
| }HAL_NOR_StateTypeDef; | |||
| /** | |||
| * @brief FMC NOR Status typedef | |||
| */ | |||
| typedef enum | |||
| { | |||
| NOR_SUCCESS = 0, | |||
| NOR_ONGOING, | |||
| NOR_ERROR, | |||
| NOR_TIMEOUT | |||
| }NOR_StatusTypedef; | |||
| /** | |||
| * @brief FMC NOR ID typedef | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint16_t Manufacturer_Code; /*!< Defines the device's manufacturer code used to identify the memory */ | |||
| uint16_t Device_Code1; | |||
| uint16_t Device_Code2; | |||
| uint16_t Device_Code3; /*!< Defines the devices' codes used to identify the memory. | |||
| These codes can be accessed by performing read operations with specific | |||
| control signals and addresses set.They can also be accessed by issuing | |||
| an Auto Select command */ | |||
| }NOR_IDTypeDef; | |||
| /** | |||
| * @brief FMC NOR CFI typedef | |||
| */ | |||
| typedef struct | |||
| { | |||
| /*!< Defines the information stored in the memory's Common flash interface | |||
| which contains a description of various electrical and timing parameters, | |||
| density information and functions supported by the memory */ | |||
| uint16_t CFI_1; | |||
| uint16_t CFI_2; | |||
| uint16_t CFI_3; | |||
| uint16_t CFI_4; | |||
| }NOR_CFITypeDef; | |||
| /** | |||
| * @brief NOR handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| FMC_NORSRAM_TypeDef *Instance; /*!< Register base address */ | |||
| FMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */ | |||
| FMC_NORSRAM_InitTypeDef Init; /*!< NOR device control configuration parameters */ | |||
| HAL_LockTypeDef Lock; /*!< NOR locking object */ | |||
| __IO HAL_NOR_StateTypeDef State; /*!< NOR device access state */ | |||
| }NOR_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup NOR_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /* NOR device IDs addresses */ | |||
| #define MC_ADDRESS ((uint16_t)0x0000) | |||
| #define DEVICE_CODE1_ADDR ((uint16_t)0x0001) | |||
| #define DEVICE_CODE2_ADDR ((uint16_t)0x000E) | |||
| #define DEVICE_CODE3_ADDR ((uint16_t)0x000F) | |||
| /* NOR CFI IDs addresses */ | |||
| #define CFI1_ADDRESS ((uint16_t)0x61) | |||
| #define CFI2_ADDRESS ((uint16_t)0x62) | |||
| #define CFI3_ADDRESS ((uint16_t)0x63) | |||
| #define CFI4_ADDRESS ((uint16_t)0x64) | |||
| /* NOR operation wait timeout */ | |||
| #define NOR_TMEOUT ((uint16_t)0xFFFF) | |||
| /* NOR memory data width */ | |||
| #define NOR_MEMORY_8B ((uint8_t)0x0) | |||
| #define NOR_MEMORY_16B ((uint8_t)0x1) | |||
| /* NOR memory device read/write start address */ | |||
| #define NOR_MEMORY_ADRESS1 ((uint32_t)0x60000000) | |||
| #define NOR_MEMORY_ADRESS2 ((uint32_t)0x64000000) | |||
| #define NOR_MEMORY_ADRESS3 ((uint32_t)0x68000000) | |||
| #define NOR_MEMORY_ADRESS4 ((uint32_t)0x6C000000) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset NOR handle state | |||
| * @param __HANDLE__: specifies the NOR handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NOR_STATE_RESET) | |||
| /** | |||
| * @brief NOR memory address shifting. | |||
| * @param __ADDRESS__: NOR memory address | |||
| * @retval NOR shifted address value | |||
| */ | |||
| #define __NOR_ADDR_SHIFT(__NOR_ADDRESS, __NOR_MEMORY_WIDTH_, __ADDRESS__) (((__NOR_MEMORY_WIDTH_) == NOR_MEMORY_8B)? ((uint32_t)((__NOR_ADDRESS) + (2 * (__ADDRESS__)))):\ | |||
| ((uint32_t)((__NOR_ADDRESS) + (__ADDRESS__)))) | |||
| /** | |||
| * @brief NOR memory write data to specified address. | |||
| * @param __ADDRESS__: NOR memory address | |||
| * @param __DATA__: Data to write | |||
| * @retval None | |||
| */ | |||
| #define __NOR_WRITE(__ADDRESS__, __DATA__) (*(__IO uint16_t *)((uint32_t)(__ADDRESS__)) = (__DATA__)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions ********************************/ | |||
| HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming); | |||
| HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor); | |||
| void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor); | |||
| void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor); | |||
| void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout); | |||
| /* I/O operation functions ***************************************************/ | |||
| HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID); | |||
| HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor); | |||
| HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData); | |||
| HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData); | |||
| HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize); | |||
| HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize); | |||
| HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address); | |||
| HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address); | |||
| HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI); | |||
| /* NOR Control functions *****************************************************/ | |||
| HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor); | |||
| HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor); | |||
| /* NOR State functions ********************************************************/ | |||
| HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor); | |||
| NOR_StatusTypedef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_NOR_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,185 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_pccard.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of PCCARD HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_PCCARD_H | |||
| #define __STM32F4xx_HAL_PCCARD_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) | |||
| #include "stm32f4xx_ll_fsmc.h" | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #include "stm32f4xx_ll_fmc.h" | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup PCCARD | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Exported typedef ----------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL SRAM State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_PCCARD_STATE_RESET = 0x00, /*!< PCCARD peripheral not yet initialized or disabled */ | |||
| HAL_PCCARD_STATE_READY = 0x01, /*!< PCCARD peripheral ready */ | |||
| HAL_PCCARD_STATE_BUSY = 0x02, /*!< PCCARD peripheral busy */ | |||
| HAL_PCCARD_STATE_ERROR = 0x04 /*!< PCCARD peripheral error */ | |||
| }HAL_PCCARD_StateTypeDef; | |||
| typedef enum | |||
| { | |||
| CF_SUCCESS = 0, | |||
| CF_ONGOING, | |||
| CF_ERROR, | |||
| CF_TIMEOUT | |||
| }CF_StatusTypedef; | |||
| /** | |||
| * @brief FMC_PCCARD handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| FMC_PCCARD_TypeDef *Instance; /*!< Register base address for PCCARD device */ | |||
| FMC_PCCARD_InitTypeDef Init; /*!< PCCARD device control configuration parameters */ | |||
| __IO HAL_PCCARD_StateTypeDef State; /*!< PCCARD device access state */ | |||
| HAL_LockTypeDef Lock; /*!< PCCARD Lock */ | |||
| }PCCARD_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup PCCARD_Exported_Constants | |||
| * @{ | |||
| */ | |||
| #define CF_DEVICE_ADDRESS ((uint32_t)0x90000000) | |||
| #define CF_ATTRIBUTE_SPACE_ADDRESS ((uint32_t)0x98000000) /* Attribute space size to @0x9BFF FFFF */ | |||
| #define CF_COMMON_SPACE_ADDRESS CF_DEVICE_ADDRESS /* Common space size to @0x93FF FFFF */ | |||
| #define CF_IO_SPACE_ADDRESS ((uint32_t)0x9C000000) /* IO space size to @0x9FFF FFFF */ | |||
| #define CF_IO_SPACE_PRIMARY_ADDR ((uint32_t)0x9C0001F0) /* IO space size to @0x9FFF FFFF */ | |||
| /* Compact Flash-ATA registers description */ | |||
| #define CF_DATA ((uint8_t)0x00) /* Data register */ | |||
| #define CF_SECTOR_COUNT ((uint8_t)0x02) /* Sector Count register */ | |||
| #define CF_SECTOR_NUMBER ((uint8_t)0x03) /* Sector Number register */ | |||
| #define CF_CYLINDER_LOW ((uint8_t)0x04) /* Cylinder low register */ | |||
| #define CF_CYLINDER_HIGH ((uint8_t)0x05) /* Cylinder high register */ | |||
| #define CF_CARD_HEAD ((uint8_t)0x06) /* Card/Head register */ | |||
| #define CF_STATUS_CMD ((uint8_t)0x07) /* Status(read)/Command(write) register */ | |||
| #define CF_STATUS_CMD_ALTERNATE ((uint8_t)0x0E) /* Alternate Status(read)/Command(write) register */ | |||
| #define CF_COMMON_DATA_AREA ((uint16_t)0x0400) /* Start of data area (for Common access only!) */ | |||
| /* Compact Flash-ATA commands */ | |||
| #define CF_READ_SECTOR_CMD ((uint8_t)0x20) | |||
| #define CF_WRITE_SECTOR_CMD ((uint8_t)0x30) | |||
| #define CF_ERASE_SECTOR_CMD ((uint8_t)0xC0) | |||
| #define CF_IDENTIFY_CMD ((uint8_t)0xEC) | |||
| /* Compact Flash status */ | |||
| #define CF_TIMEOUT_ERROR ((uint8_t)0x60) | |||
| #define CF_BUSY ((uint8_t)0x80) | |||
| #define CF_PROGR ((uint8_t)0x01) | |||
| #define CF_READY ((uint8_t)0x40) | |||
| #define CF_SECTOR_SIZE ((uint32_t)255) /* In half words */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset PCCARD handle state | |||
| * @param __HANDLE__: specifies the PCCARD handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_PCCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_PCCARD_STATE_RESET) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_PCCARD_Init(PCCARD_HandleTypeDef *hpccard, FMC_NAND_PCC_TimingTypeDef *ComSpaceTiming, FMC_NAND_PCC_TimingTypeDef *AttSpaceTiming, FMC_NAND_PCC_TimingTypeDef *IOSpaceTiming); | |||
| HAL_StatusTypeDef HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard); | |||
| void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard); | |||
| void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard); | |||
| /* IO operation functions *****************************************************/ | |||
| HAL_StatusTypeDef HAL_CF_Read_ID(PCCARD_HandleTypeDef *hpccard, uint8_t CompactFlash_ID[], uint8_t *pStatus); | |||
| HAL_StatusTypeDef HAL_CF_Write_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus); | |||
| HAL_StatusTypeDef HAL_CF_Read_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus); | |||
| HAL_StatusTypeDef HAL_CF_Erase_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t SectorAddress, uint8_t *pStatus); | |||
| HAL_StatusTypeDef HAL_CF_Reset(PCCARD_HandleTypeDef *hpccard); | |||
| void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard); | |||
| void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard); | |||
| /* PCCARD State functions *******************************************************/ | |||
| HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState(PCCARD_HandleTypeDef *hpccard); | |||
| CF_StatusTypedef HAL_CF_GetStatus(PCCARD_HandleTypeDef *hpccard); | |||
| CF_StatusTypedef HAL_CF_ReadStatus(PCCARD_HandleTypeDef *hpccard); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_PCCARD_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,281 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_pcd.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of PCD HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_PCD_H | |||
| #define __STM32F4xx_HAL_PCD_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_ll_usb.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup PCD | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief PCD State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_PCD_STATE_RESET = 0x00, | |||
| HAL_PCD_STATE_READY = 0x01, | |||
| HAL_PCD_STATE_ERROR = 0x02, | |||
| HAL_PCD_STATE_BUSY = 0x03, | |||
| HAL_PCD_STATE_TIMEOUT = 0x04 | |||
| } PCD_StateTypeDef; | |||
| typedef USB_OTG_GlobalTypeDef PCD_TypeDef; | |||
| typedef USB_OTG_CfgTypeDef PCD_InitTypeDef; | |||
| typedef USB_OTG_EPTypeDef PCD_EPTypeDef ; | |||
| /** | |||
| * @brief PCD Handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| PCD_TypeDef *Instance; /*!< Register base address */ | |||
| PCD_InitTypeDef Init; /*!< PCD required parameters */ | |||
| PCD_EPTypeDef IN_ep[15]; /*!< IN endpoint parameters */ | |||
| PCD_EPTypeDef OUT_ep[15]; /*!< OUT endpoint parameters */ | |||
| HAL_LockTypeDef Lock; /*!< PCD peripheral status */ | |||
| __IO PCD_StateTypeDef State; /*!< PCD communication state */ | |||
| uint32_t Setup[12]; /*!< Setup packet buffer */ | |||
| void *pData; /*!< Pointer to upper stack Handler */ | |||
| } PCD_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup PCD_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup PCD_Speed | |||
| * @{ | |||
| */ | |||
| #define PCD_SPEED_HIGH 0 | |||
| #define PCD_SPEED_HIGH_IN_FULL 1 | |||
| #define PCD_SPEED_FULL 2 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PCD_PHY_Module | |||
| * @{ | |||
| */ | |||
| #define PCD_PHY_ULPI 1 | |||
| #define PCD_PHY_EMBEDDED 2 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PCD_Instance_definition | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| #define IS_PCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS) || \ | |||
| ((INSTANCE) == USB_OTG_HS)) | |||
| #elif defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| #define IS_PCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS)) | |||
| #endif | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @defgroup PCD_Interrupt_Clock | |||
| * @brief macros to handle interrupts and specific clock configurations | |||
| * @{ | |||
| */ | |||
| #define __HAL_PCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance) | |||
| #define __HAL_PCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance) | |||
| #define __HAL_PCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
| #define __HAL_PCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) = (__INTERRUPT__)) | |||
| #define __HAL_PCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0) | |||
| #define __HAL_PCD_UNGATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) &= \ | |||
| ~(USB_OTG_PCGCCTL_STOPCLK) | |||
| #define __HAL_PCD_GATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) |= USB_OTG_PCGCCTL_STOPCLK | |||
| #define __HAL_PCD_IS_PHY_SUSPENDED(__HANDLE__) ((*(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE))&0x10) | |||
| #define USB_FS_EXTI_TRIGGER_RISING_EDGE ((uint32_t)0x08) | |||
| #define USB_FS_EXTI_TRIGGER_FALLING_EDGE ((uint32_t)0x0C) | |||
| #define USB_FS_EXTI_TRIGGER_BOTH_EDGE ((uint32_t)0x10) | |||
| #define USB_HS_EXTI_TRIGGER_RISING_EDGE ((uint32_t)0x08) | |||
| #define USB_HS_EXTI_TRIGGER_FALLING_EDGE ((uint32_t)0x0C) | |||
| #define USB_HS_EXTI_TRIGGER_BOTH_EDGE ((uint32_t)0x10) | |||
| #define USB_HS_EXTI_LINE_WAKEUP ((uint32_t)0x00100000) /*!< External interrupt line 20 Connected to the USB HS EXTI Line */ | |||
| #define USB_FS_EXTI_LINE_WAKEUP ((uint32_t)0x00040000) /*!< External interrupt line 18 Connected to the USB FS EXTI Line */ | |||
| #define __HAL_USB_HS_EXTI_ENABLE_IT() EXTI->IMR |= (USB_HS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_HS_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_HS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_HS_EXTI_GET_FLAG() EXTI->PR & (USB_HS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_HS_EXTI_CLEAR_FLAG() EXTI->PR = (USB_HS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_HS_EXTI_SET_RISING_EGDE_TRIGGER() EXTI->FTSR &= ~(USB_HS_EXTI_LINE_WAKEUP);\ | |||
| EXTI->RTSR |= USB_HS_EXTI_LINE_WAKEUP | |||
| #define __HAL_USB_HS_EXTI_SET_FALLING_EGDE_TRIGGER() EXTI->FTSR |= (USB_HS_EXTI_LINE_WAKEUP);\ | |||
| EXTI->RTSR &= ~(USB_HS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_HS_EXTI_SET_FALLINGRISING_TRIGGER() EXTI->RTSR &= ~(USB_HS_EXTI_LINE_WAKEUP);\ | |||
| EXTI->FTSR &= ~(USB_HS_EXTI_LINE_WAKEUP;)\ | |||
| EXTI->RTSR |= USB_HS_EXTI_LINE_WAKEUP;\ | |||
| EXTI->FTSR |= USB_HS_EXTI_LINE_WAKEUP | |||
| #define __HAL_USB_HS_EXTI_GENERATE_SWIT() (EXTI->SWIER |= USB_FS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_FS_EXTI_ENABLE_IT() EXTI->IMR |= USB_FS_EXTI_LINE_WAKEUP | |||
| #define __HAL_USB_FS_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_FS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_FS_EXTI_GET_FLAG() EXTI->PR & (USB_FS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_FS_EXTI_CLEAR_FLAG() EXTI->PR = USB_FS_EXTI_LINE_WAKEUP | |||
| #define __HAL_USB_FS_EXTI_SET_RISING_EGDE_TRIGGER() EXTI->FTSR &= ~(USB_FS_EXTI_LINE_WAKEUP);\ | |||
| EXTI->RTSR |= USB_FS_EXTI_LINE_WAKEUP | |||
| #define __HAL_USB_FS_EXTI_SET_FALLING_EGDE_TRIGGER() EXTI->FTSR |= (USB_FS_EXTI_LINE_WAKEUP);\ | |||
| EXTI->RTSR &= ~(USB_FS_EXTI_LINE_WAKEUP) | |||
| #define __HAL_USB_FS_EXTI_SET_FALLINGRISING_TRIGGER() EXTI->RTSR &= ~(USB_FS_EXTI_LINE_WAKEUP);\ | |||
| EXTI->FTSR &= ~(USB_FS_EXTI_LINE_WAKEUP);\ | |||
| EXTI->RTSR |= USB_FS_EXTI_LINE_WAKEUP;\ | |||
| EXTI->FTSR |= USB_FS_EXTI_LINE_WAKEUP | |||
| #define __HAL_USB_FS_EXTI_GENERATE_SWIT() (EXTI->SWIER |= USB_FS_EXTI_LINE_WAKEUP) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Include PCD HAL Extension module */ | |||
| #include "stm32f4xx_hal_pcd_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd); | |||
| HAL_StatusTypeDef HAL_PCD_DeInit (PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd); | |||
| /* I/O operation functions *****************************************************/ | |||
| /* Non-Blocking mode: Interrupt */ | |||
| HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd); | |||
| HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); | |||
| void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); | |||
| void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); | |||
| void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); | |||
| void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd); | |||
| void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd); | |||
| /* Peripheral Control functions ************************************************/ | |||
| HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd); | |||
| HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd); | |||
| HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address); | |||
| HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type); | |||
| HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
| HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len); | |||
| HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len); | |||
| uint16_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
| HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
| HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
| HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); | |||
| HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup(PCD_HandleTypeDef *hpcd); | |||
| HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup(PCD_HandleTypeDef *hpcd); | |||
| /* Create an alias to keep compatibility with the old name */ | |||
| #define HAL_PCD_SetTxFiFo HAL_PCDEx_SetTxFiFo | |||
| #define HAL_PCD_SetRxFiFo HAL_PCDEx_SetRxFiFo | |||
| /* Peripheral State functions **************************************************/ | |||
| PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_PCD_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,78 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_pcd_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of PCD HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_PCD_EX_H | |||
| #define __STM32F4xx_HAL_PCD_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup PCDEx | |||
| * @{ | |||
| */ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Peripheral Extended functions *********************************************/ | |||
| HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); | |||
| HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_PCD_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,337 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_pwr.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of PWR HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_PWR_H | |||
| #define __STM32F4xx_HAL_PWR_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup PWR | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @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; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /* ------------- PWR registers bit address in the alias region ---------------*/ | |||
| #define PWR_OFFSET (PWR_BASE - PERIPH_BASE) | |||
| /* --- CR Register ---*/ | |||
| /* Alias word address of DBP bit */ | |||
| #define CR_OFFSET (PWR_OFFSET + 0x00) | |||
| #define DBP_BitNumber 0x08 | |||
| #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4)) | |||
| /* Alias word address of PVDE bit */ | |||
| #define PVDE_BitNumber 0x04 | |||
| #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4)) | |||
| /* Alias word address of PMODE bit */ | |||
| #define PMODE_BitNumber 0x0E | |||
| #define CR_PMODE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PMODE_BitNumber * 4)) | |||
| /* --- CSR Register ---*/ | |||
| /* Alias word address of EWUP bit */ | |||
| #define CSR_OFFSET (PWR_OFFSET + 0x04) | |||
| #define EWUP_BitNumber 0x08 | |||
| #define CSR_EWUP_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4)) | |||
| /** @defgroup PWR_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup PWR_WakeUp_Pins | |||
| * @{ | |||
| */ | |||
| #define PWR_WAKEUP_PIN1 PWR_CSR_EWUP | |||
| #define IS_PWR_WAKEUP_PIN(PIN) ((PIN) == PWR_WAKEUP_PIN1) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PWR_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 | |||
| #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)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PWR_PVD_Mode | |||
| * @{ | |||
| */ | |||
| #define PWR_MODE_EVT ((uint32_t)0x00000000) /*!< No Interrupt */ | |||
| #define PWR_MODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */ | |||
| #define PWR_MODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */ | |||
| #define PWR_MODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ | |||
| #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_MODE_EVT) || ((MODE) == PWR_MODE_IT_RISING)|| \ | |||
| ((MODE) == PWR_MODE_IT_FALLING) || ((MODE) == PWR_MODE_IT_RISING_FALLING)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PWR_Regulator_state_in_STOP_mode | |||
| * @{ | |||
| */ | |||
| #define PWR_MAINREGULATOR_ON ((uint32_t)0x00000000) | |||
| #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS | |||
| #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ | |||
| ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PWR_SLEEP_mode_entry | |||
| * @{ | |||
| */ | |||
| #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01) | |||
| #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02) | |||
| #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PWR_STOP_mode_entry | |||
| * @{ | |||
| */ | |||
| #define PWR_STOPENTRY_WFI ((uint8_t)0x01) | |||
| #define PWR_STOPENTRY_WFE ((uint8_t)0x02) | |||
| #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PWR_Regulator_Voltage_Scale | |||
| * @{ | |||
| */ | |||
| #define PWR_REGULATOR_VOLTAGE_SCALE1 ((uint32_t)0x0000C000) | |||
| #define PWR_REGULATOR_VOLTAGE_SCALE2 ((uint32_t)0x00008000) | |||
| #define PWR_REGULATOR_VOLTAGE_SCALE3 ((uint32_t)0x00004000) | |||
| #define IS_PWR_REGULATOR_VOLTAGE(VOLTAGE) (((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \ | |||
| ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE2) || \ | |||
| ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE3)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PWR_Flag | |||
| * @{ | |||
| */ | |||
| #define PWR_FLAG_WU PWR_CSR_WUF | |||
| #define PWR_FLAG_SB PWR_CSR_SBF | |||
| #define PWR_FLAG_PVDO PWR_CSR_PVDO | |||
| #define PWR_FLAG_BRR PWR_CSR_BRR | |||
| #define PWR_FLAG_VOSRDY PWR_CSR_VOSRDY | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief macros configure the main internal regulator output voltage. | |||
| * @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 | |||
| * @arg PWR_REGULATOR_VOLTAGE_SCALE2: Regulator voltage output Scale 2 mode | |||
| * @arg PWR_REGULATOR_VOLTAGE_SCALE3: Regulator voltage output Scale 3 mode | |||
| * @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 A | |||
| * or 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. | |||
| * @arg PWR_FLAG_BRR: Backup regulator ready flag. This bit is not reset | |||
| * when the device wakes up from Standby mode or by a system reset | |||
| * or power reset. | |||
| * @arg PWR_FLAG_VOSRDY: This flag indicates that the Regulator voltage | |||
| * scaling output selection 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's 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__) (PWR->CR |= (__FLAG__) << 2) | |||
| #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!< External interrupt line 16 Connected to the PVD EXTI Line */ | |||
| /** | |||
| * @brief Enable the PVD Exti Line. | |||
| * @param __EXTILINE__: specifies the PVD Exti sources to be enabled. | |||
| * This parameter can be: | |||
| * @arg PWR_EXTI_LINE_PVD | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_PVD_EXTI_ENABLE_IT(__EXTILINE__) (EXTI->IMR |= (__EXTILINE__)) | |||
| /** | |||
| * @brief Disable the PVD EXTI Line. | |||
| * @param __EXTILINE__: specifies the PVD EXTI sources to be disabled. | |||
| * This parameter can be: | |||
| * @arg PWR_EXTI_LINE_PVD | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_PVD_EXTI_DISABLE_IT(__EXTILINE__) (EXTI->IMR &= ~(__EXTILINE__)) | |||
| /** | |||
| * @brief checks whether the specified PVD Exti interrupt flag is set or not. | |||
| * @param __EXTILINE__: specifies the PVD Exti sources to be cleared. | |||
| * This parameter can be: | |||
| * @arg PWR_EXTI_LINE_PVD | |||
| * @retval EXTI PVD Line Status. | |||
| */ | |||
| #define __HAL_PVD_EXTI_GET_FLAG(__EXTILINE__) (EXTI->PR & (__EXTILINE__)) | |||
| /** | |||
| * @brief Clear the PVD Exti flag. | |||
| * @param __EXTILINE__: specifies the PVD Exti sources to be cleared. | |||
| * This parameter can be: | |||
| * @arg PWR_EXTI_LINE_PVD | |||
| * @retval None. | |||
| */ | |||
| #define __HAL_PVD_EXTI_CLEAR_FLAG(__EXTILINE__) (EXTI->PR = (__EXTILINE__)) | |||
| /** | |||
| * @brief Generates a Software interrupt on selected EXTI line. | |||
| * @param __EXTILINE__: specifies the PVD EXTI sources to be disabled. | |||
| * This parameter can be: | |||
| * @arg PWR_EXTI_LINE_PVD | |||
| * @retval None | |||
| */ | |||
| #define __HAL_PVD_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER |= (__EXTI_LINE__)) | |||
| /* Include PWR HAL Extension module */ | |||
| #include "stm32f4xx_hal_pwr_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization and de-initialization functions *****************************/ | |||
| void HAL_PWR_DeInit(void); | |||
| void HAL_PWR_EnableBkUpAccess(void); | |||
| void HAL_PWR_DisableBkUpAccess(void); | |||
| /* Peripheral Control functions **********************************************/ | |||
| /* PVD configuration */ | |||
| void HAL_PWR_PVDConfig(PWR_PVDTypeDef *sConfigPVD); | |||
| void HAL_PWR_EnablePVD(void); | |||
| void HAL_PWR_DisablePVD(void); | |||
| /* WakeUp pins configuration */ | |||
| void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx); | |||
| void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); | |||
| /* Low Power modes entry */ | |||
| 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_PVD_IRQHandler(void); | |||
| void HAL_PWR_PVDCallback(void); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_PWR_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,197 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_pwr_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of PWR HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_PWR_EX_H | |||
| #define __STM32F4xx_HAL_PWR_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup PWREx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /* ------------- PWR registers bit address in the alias region ---------------*/ | |||
| /* --- CR Register ---*/ | |||
| /* Alias word address of FPDS bit */ | |||
| #define FPDS_BitNumber 0x09 | |||
| #define CR_FPDS_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (FPDS_BitNumber * 4)) | |||
| /* Alias word address of ODEN bit */ | |||
| #define ODEN_BitNumber 0x10 | |||
| #define CR_ODEN_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (ODEN_BitNumber * 4)) | |||
| /* Alias word address of ODSWEN bit */ | |||
| #define ODSWEN_BitNumber 0x11 | |||
| #define CR_ODSWEN_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (ODSWEN_BitNumber * 4)) | |||
| /* Alias word address of MRLVDS bit */ | |||
| #define MRLVDS_BitNumber 0x0B | |||
| #define CR_MRLVDS_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (MRLVDS_BitNumber * 4)) | |||
| /* Alias word address of LPLVDS bit */ | |||
| #define LPLVDS_BitNumber 0x0A | |||
| #define CR_LPLVDS_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (LPLVDS_BitNumber * 4)) | |||
| /* --- CSR Register ---*/ | |||
| /* Alias word address of BRE bit */ | |||
| #define BRE_BitNumber 0x09 | |||
| #define CSR_BRE_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (BRE_BitNumber * 4)) | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /** @defgroup PWREx_Regulator_state_in_UnderDrive_mode | |||
| * @{ | |||
| */ | |||
| #define PWR_MAINREGULATOR_UNDERDRIVE_ON PWR_CR_MRUDS | |||
| #define PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON ((uint32_t)(PWR_CR_LPDS | PWR_CR_LPUDS)) | |||
| #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_UNDERDRIVE_ON) || \ | |||
| ((REGULATOR) == PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup PWREx_Over_Under_Drive_Flag | |||
| * @{ | |||
| */ | |||
| #define PWR_FLAG_ODRDY PWR_CSR_ODRDY | |||
| #define PWR_FLAG_ODSWRDY PWR_CSR_ODSWRDY | |||
| #define PWR_FLAG_UDRDY PWR_CSR_UDSWRDY | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /** @brief Macros to enable or disable the Over drive mode. | |||
| * @note These macros can be used only for STM32F42xx/STM3243xx devices. | |||
| */ | |||
| #define __HAL_PWR_OVERDRIVE_ENABLE() (*(__IO uint32_t *) CR_ODEN_BB = ENABLE) | |||
| #define __HAL_PWR_OVERDRIVE_DISABLE() (*(__IO uint32_t *) CR_ODEN_BB = DISABLE) | |||
| /** @brief Macros to enable or disable the Over drive switching. | |||
| * @note These macros can be used only for STM32F42xx/STM3243xx devices. | |||
| */ | |||
| #define __HAL_PWR_OVERDRIVESWITCHING_ENABLE() (*(__IO uint32_t *) CR_ODSWEN_BB = ENABLE) | |||
| #define __HAL_PWR_OVERDRIVESWITCHING_DISABLE() (*(__IO uint32_t *) CR_ODSWEN_BB = DISABLE) | |||
| /** @brief Macros to enable or disable the Under drive mode. | |||
| * @note This mode is enabled only with STOP low power mode. | |||
| * In this mode, the 1.2V domain is preserved in reduced leakage mode. This | |||
| * mode is only available when the main regulator or the low power regulator | |||
| * is in low voltage mode. | |||
| * @note If the Under-drive mode was enabled, it is automatically disabled after | |||
| * exiting Stop mode. | |||
| * When the voltage regulator operates in Under-drive mode, an additional | |||
| * startup delay is induced when waking up from Stop mode. | |||
| */ | |||
| #define __HAL_PWR_UNDERDRIVE_ENABLE() (PWR->CR |= (uint32_t)PWR_CR_UDEN) | |||
| #define __HAL_PWR_UNDERDRIVE_DISABLE() (PWR->CR &= (uint32_t)(~PWR_CR_UDEN)) | |||
| /** @brief Check PWR flag is set or not. | |||
| * @note These macros can be used only for STM32F42xx/STM3243xx devices. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg PWR_FLAG_ODRDY: This flag indicates that the Over-drive mode | |||
| * is ready | |||
| * @arg PWR_FLAG_ODSWRDY: This flag indicates that the Over-drive mode | |||
| * switching is ready | |||
| * @arg PWR_FLAG_UDRDY: This flag indicates that the Under-drive mode | |||
| * is enabled in Stop mode | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_PWR_GET_ODRUDR_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clear the Under-Drive Ready flag. | |||
| * @note These macros can be used only for STM32F42xx/STM3243xx devices. | |||
| */ | |||
| #define __HAL_PWR_CLEAR_ODRUDR_FLAG() (PWR->CSR |= PWR_FLAG_UDRDY) | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| void HAL_PWREx_EnableFlashPowerDown(void); | |||
| void HAL_PWREx_DisableFlashPowerDown(void); | |||
| HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void); | |||
| HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void); | |||
| #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| void HAL_PWREx_EnableMainRegulatorLowVoltage(void); | |||
| void HAL_PWREx_DisableMainRegulatorLowVoltage(void); | |||
| void HAL_PWREx_EnableLowRegulatorLowVoltage(void); | |||
| void HAL_PWREx_DisableLowRegulatorLowVoltage(void); | |||
| #endif /* STM32F401xC || STM32F401xE || STM32F411xE */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| HAL_StatusTypeDef HAL_PWREx_ActivateOverDrive(void); | |||
| HAL_StatusTypeDef HAL_PWREx_DeactivateOverDrive(void); | |||
| HAL_StatusTypeDef HAL_PWREx_EnterUnderDriveSTOPMode(uint32_t Regulator, uint8_t STOPEntry); | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_PWR_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,222 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_rng.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of RNG HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_RNG_H | |||
| #define __STM32F4xx_HAL_RNG_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ | |||
| defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup RNG | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief RNG HAL State Structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_RNG_STATE_RESET = 0x00, /*!< RNG not yet initialized or disabled */ | |||
| HAL_RNG_STATE_READY = 0x01, /*!< RNG initialized and ready for use */ | |||
| HAL_RNG_STATE_BUSY = 0x02, /*!< RNG internal process is ongoing */ | |||
| HAL_RNG_STATE_TIMEOUT = 0x03, /*!< RNG timeout state */ | |||
| HAL_RNG_STATE_ERROR = 0x04 /*!< RNG error state */ | |||
| }HAL_RNG_StateTypeDef; | |||
| /** | |||
| * @brief RNG Handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| RNG_TypeDef *Instance; /*!< Register base address */ | |||
| HAL_LockTypeDef Lock; /*!< RNG locking object */ | |||
| __IO HAL_RNG_StateTypeDef State; /*!< RNG communication state */ | |||
| }RNG_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup RNG_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup RNG_Interrupt_definition | |||
| * @{ | |||
| */ | |||
| #define RNG_IT_CEI ((uint32_t)0x20) /*!< Clock error interrupt */ | |||
| #define RNG_IT_SEI ((uint32_t)0x40) /*!< Seed error interrupt */ | |||
| #define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \ | |||
| ((IT) == RNG_IT_SEI)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RNG_Flag_definition | |||
| * @{ | |||
| */ | |||
| #define RNG_FLAG_DRDY ((uint32_t)0x0001) /*!< Data ready */ | |||
| #define RNG_FLAG_CECS ((uint32_t)0x0002) /*!< Clock error current status */ | |||
| #define RNG_FLAG_SECS ((uint32_t)0x0004) /*!< Seed error current status */ | |||
| #define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \ | |||
| ((FLAG) == RNG_FLAG_CECS) || \ | |||
| ((FLAG) == RNG_FLAG_SECS)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset RNG handle state | |||
| * @param __HANDLE__: RNG Handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET) | |||
| /** | |||
| * @brief Enables the RNG peripheral. | |||
| * @param __HANDLE__: RNG Handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN) | |||
| /** | |||
| * @brief Disables the RNG peripheral. | |||
| * @param __HANDLE__: RNG Handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN) | |||
| /** | |||
| * @brief Gets the selected RNG's flag status. | |||
| * @param __HANDLE__: RNG Handle | |||
| * @param __FLAG__: RNG flag | |||
| * @retval The new state of RNG_FLAG (SET or RESET). | |||
| */ | |||
| #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
| /** | |||
| * @brief Clears the RNG's pending flags. | |||
| * @param __HANDLE__: RNG Handle | |||
| * @param __FLAG__: RNG flag | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__)) | |||
| /** | |||
| * @brief Enables the RNG interrupts. | |||
| * @param __HANDLE__: RNG Handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE) | |||
| /** | |||
| * @brief Disables the RNG interrupts. | |||
| * @param __HANDLE__: RNG Handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE) | |||
| /** | |||
| * @brief Checks whether the specified RNG interrupt has occurred or not. | |||
| * @param __HANDLE__: RNG Handle | |||
| * @param __INTERRUPT__: specifies the RNG interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg RNG_FLAG_DRDY: Data ready interrupt | |||
| * @arg RNG_FLAG_CECS: Clock error interrupt | |||
| * @arg RNG_FLAG_SECS: Seed error interrupt | |||
| * @retval The new state of RNG_FLAG (SET or RESET). | |||
| */ | |||
| #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng); | |||
| HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng); | |||
| void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng); | |||
| void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng); | |||
| /* Peripheral Control functions ************************************************/ | |||
| uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng); | |||
| uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng); | |||
| void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng); | |||
| void HAL_RNG_ReadyCallback(RNG_HandleTypeDef* hrng); | |||
| void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng); | |||
| /* Peripheral State functions **************************************************/ | |||
| HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_RNG_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,766 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_rtc.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of RTC HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_RTC_H | |||
| #define __STM32F4xx_HAL_RTC_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup RTC | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_RTC_STATE_RESET = 0x00, /*!< RTC not yet initialized or disabled */ | |||
| HAL_RTC_STATE_READY = 0x01, /*!< RTC initialized and ready for use */ | |||
| HAL_RTC_STATE_BUSY = 0x02, /*!< RTC process is ongoing */ | |||
| HAL_RTC_STATE_TIMEOUT = 0x03, /*!< RTC timeout state */ | |||
| HAL_RTC_STATE_ERROR = 0x04 /*!< RTC error state */ | |||
| }HAL_RTCStateTypeDef; | |||
| /** | |||
| * @brief RTC Configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t HourFormat; /*!< Specifies the RTC Hour Format. | |||
| This parameter can be a value of @ref RTC_Hour_Formats */ | |||
| uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */ | |||
| uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value. | |||
| This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */ | |||
| uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output. | |||
| This parameter can be a value of @ref RTC_Output_selection_Definitions */ | |||
| uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal. | |||
| This parameter can be a value of @ref RTC_Output_Polarity_Definitions */ | |||
| uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode. | |||
| This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */ | |||
| }RTC_InitTypeDef; | |||
| /** | |||
| * @brief RTC Time structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint8_t Hours; /*!< Specifies the RTC Time Hour. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ | |||
| uint8_t Minutes; /*!< Specifies the RTC Time Minutes. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ | |||
| uint8_t Seconds; /*!< Specifies the RTC Time Seconds. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ | |||
| uint32_t SubSeconds; /*!< Specifies the RTC Time SubSeconds. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ | |||
| uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. | |||
| This parameter can be a value of @ref RTC_AM_PM_Definitions */ | |||
| uint32_t DayLightSaving; /*!< Specifies DayLight Save Operation. | |||
| This parameter can be a value of @ref RTC_DayLightSaving_Definitions */ | |||
| uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit | |||
| in CR register to store the operation. | |||
| This parameter can be a value of @ref RTC_StoreOperation_Definitions */ | |||
| }RTC_TimeTypeDef; | |||
| /** | |||
| * @brief RTC Date structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay. | |||
| This parameter can be a value of @ref RTC_WeekDay_Definitions */ | |||
| uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). | |||
| This parameter can be a value of @ref RTC_Month_Date_Definitions */ | |||
| uint8_t Date; /*!< Specifies the RTC Date. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ | |||
| uint8_t Year; /*!< Specifies the RTC Date Year. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ | |||
| }RTC_DateTypeDef; | |||
| /** | |||
| * @brief RTC Alarm structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ | |||
| uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. | |||
| This parameter can be a value of @ref RTC_AlarmMask_Definitions */ | |||
| uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. | |||
| This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */ | |||
| uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. | |||
| This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ | |||
| uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. | |||
| If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. | |||
| If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */ | |||
| uint32_t Alarm; /*!< Specifies the alarm . | |||
| This parameter can be a value of @ref RTC_Alarms_Definitions */ | |||
| }RTC_AlarmTypeDef; | |||
| /** | |||
| * @brief Time Handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| RTC_TypeDef *Instance; /*!< Register base address */ | |||
| RTC_InitTypeDef Init; /*!< RTC required parameters */ | |||
| HAL_LockTypeDef Lock; /*!< RTC locking object */ | |||
| __IO HAL_RTCStateTypeDef State; /*!< Time communication state */ | |||
| }RTC_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup RTC_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /* Masks Definition */ | |||
| #define RTC_TR_RESERVED_MASK ((uint32_t)0x007F7F7F) | |||
| #define RTC_DR_RESERVED_MASK ((uint32_t)0x00FFFF3F) | |||
| #define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF) | |||
| #define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F) | |||
| #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \ | |||
| RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \ | |||
| RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \ | |||
| RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F | \ | |||
| RTC_FLAG_RECALPF | RTC_FLAG_SHPF)) | |||
| #define RTC_TIMEOUT_VALUE 1000 | |||
| /** @defgroup RTC_Hour_Formats | |||
| * @{ | |||
| */ | |||
| #define RTC_HOURFORMAT_24 ((uint32_t)0x00000000) | |||
| #define RTC_HOURFORMAT_12 ((uint32_t)0x00000040) | |||
| #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \ | |||
| ((FORMAT) == RTC_HOURFORMAT_24)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Output_selection_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_OUTPUT_DISABLE ((uint32_t)0x00000000) | |||
| #define RTC_OUTPUT_ALARMA ((uint32_t)0x00200000) | |||
| #define RTC_OUTPUT_ALARMB ((uint32_t)0x00400000) | |||
| #define RTC_OUTPUT_WAKEUP ((uint32_t)0x00600000) | |||
| #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ | |||
| ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ | |||
| ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ | |||
| ((OUTPUT) == RTC_OUTPUT_WAKEUP)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Output_Polarity_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_OUTPUT_POLARITY_HIGH ((uint32_t)0x00000000) | |||
| #define RTC_OUTPUT_POLARITY_LOW ((uint32_t)0x00100000) | |||
| #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \ | |||
| ((POL) == RTC_OUTPUT_POLARITY_LOW)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Output_Type_ALARM_OUT | |||
| * @{ | |||
| */ | |||
| #define RTC_OUTPUT_TYPE_OPENDRAIN ((uint32_t)0x00000000) | |||
| #define RTC_OUTPUT_TYPE_PUSHPULL ((uint32_t)0x00040000) | |||
| #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \ | |||
| ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Asynchronous_Predivider | |||
| * @{ | |||
| */ | |||
| #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (uint32_t)0x7F) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Synchronous_Predivider | |||
| * @{ | |||
| */ | |||
| #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (uint32_t)0x7FFF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Time_Definitions | |||
| * @{ | |||
| */ | |||
| #define IS_RTC_HOUR12(HOUR) (((HOUR) > (uint32_t)0) && ((HOUR) <= (uint32_t)12)) | |||
| #define IS_RTC_HOUR24(HOUR) ((HOUR) <= (uint32_t)23) | |||
| #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= (uint32_t)59) | |||
| #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= (uint32_t)59) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_AM_PM_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_HOURFORMAT12_AM ((uint8_t)0x00) | |||
| #define RTC_HOURFORMAT12_PM ((uint8_t)0x40) | |||
| #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || ((PM) == RTC_HOURFORMAT12_PM)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_DayLightSaving_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_DAYLIGHTSAVING_SUB1H ((uint32_t)0x00020000) | |||
| #define RTC_DAYLIGHTSAVING_ADD1H ((uint32_t)0x00010000) | |||
| #define RTC_DAYLIGHTSAVING_NONE ((uint32_t)0x00000000) | |||
| #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \ | |||
| ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \ | |||
| ((SAVE) == RTC_DAYLIGHTSAVING_NONE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_StoreOperation_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_STOREOPERATION_RESET ((uint32_t)0x00000000) | |||
| #define RTC_STOREOPERATION_SET ((uint32_t)0x00040000) | |||
| #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \ | |||
| ((OPERATION) == RTC_STOREOPERATION_SET)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Input_parameter_format_definitions | |||
| * @{ | |||
| */ | |||
| #define FORMAT_BIN ((uint32_t)0x000000000) | |||
| #define FORMAT_BCD ((uint32_t)0x000000001) | |||
| #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == FORMAT_BIN) || ((FORMAT) == FORMAT_BCD)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Year_Date_Definitions | |||
| * @{ | |||
| */ | |||
| #define IS_RTC_YEAR(YEAR) ((YEAR) <= (uint32_t)99) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Month_Date_Definitions | |||
| * @{ | |||
| */ | |||
| /* Coded in BCD format */ | |||
| #define RTC_MONTH_JANUARY ((uint8_t)0x01) | |||
| #define RTC_MONTH_FEBRUARY ((uint8_t)0x02) | |||
| #define RTC_MONTH_MARCH ((uint8_t)0x03) | |||
| #define RTC_MONTH_APRIL ((uint8_t)0x04) | |||
| #define RTC_MONTH_MAY ((uint8_t)0x05) | |||
| #define RTC_MONTH_JUNE ((uint8_t)0x06) | |||
| #define RTC_MONTH_JULY ((uint8_t)0x07) | |||
| #define RTC_MONTH_AUGUST ((uint8_t)0x08) | |||
| #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09) | |||
| #define RTC_MONTH_OCTOBER ((uint8_t)0x10) | |||
| #define RTC_MONTH_NOVEMBER ((uint8_t)0x11) | |||
| #define RTC_MONTH_DECEMBER ((uint8_t)0x12) | |||
| #define IS_RTC_MONTH(MONTH) (((MONTH) >= (uint32_t)1) && ((MONTH) <= (uint32_t)12)) | |||
| #define IS_RTC_DATE(DATE) (((DATE) >= (uint32_t)1) && ((DATE) <= (uint32_t)31)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_WeekDay_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01) | |||
| #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02) | |||
| #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03) | |||
| #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04) | |||
| #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05) | |||
| #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06) | |||
| #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07) | |||
| #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Alarm_Definitions | |||
| * @{ | |||
| */ | |||
| #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) >(uint32_t) 0) && ((DATE) <= (uint32_t)31)) | |||
| #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ | |||
| ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_AlarmDateWeekDay_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_ALARMDATEWEEKDAYSEL_DATE ((uint32_t)0x00000000) | |||
| #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY ((uint32_t)0x40000000) | |||
| #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \ | |||
| ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_AlarmMask_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_ALARMMASK_NONE ((uint32_t)0x00000000) | |||
| #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4 | |||
| #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3 | |||
| #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2 | |||
| #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1 | |||
| #define RTC_ALARMMASK_ALL ((uint32_t)0x80808080) | |||
| #define IS_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Alarms_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_ALARM_A RTC_CR_ALRAE | |||
| #define RTC_ALARM_B RTC_CR_ALRBE | |||
| #define IS_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Alarm_Sub_Seconds_Value | |||
| * @{ | |||
| */ | |||
| #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= (uint32_t)0x00007FFF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_ALARMSUBSECONDMASK_ALL ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked. | |||
| There is no comparison on sub seconds | |||
| for Alarm */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_1 ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm | |||
| comparison. Only SS[0] is compared. */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_2 ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm | |||
| comparison. Only SS[1:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_3 ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm | |||
| comparison. Only SS[2:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_4 ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm | |||
| comparison. Only SS[3:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_5 ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm | |||
| comparison. Only SS[4:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_6 ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm | |||
| comparison. Only SS[5:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_7 ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm | |||
| comparison. Only SS[6:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_8 ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm | |||
| comparison. Only SS[7:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_9 ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm | |||
| comparison. Only SS[8:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_10 ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm | |||
| comparison. Only SS[9:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_11 ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm | |||
| comparison. Only SS[10:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_12 ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm | |||
| comparison.Only SS[11:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14_13 ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm | |||
| comparison. Only SS[12:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_SS14 ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm | |||
| comparison.Only SS[13:0] are compared */ | |||
| #define RTC_ALARMSUBSECONDMASK_None ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match | |||
| to activate alarm. */ | |||
| #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \ | |||
| ((MASK) == RTC_ALARMSUBSECONDMASK_None)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Interrupts_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_IT_TS ((uint32_t)0x00008000) | |||
| #define RTC_IT_WUT ((uint32_t)0x00004000) | |||
| #define RTC_IT_ALRB ((uint32_t)0x00002000) | |||
| #define RTC_IT_ALRA ((uint32_t)0x00001000) | |||
| #define RTC_IT_TAMP ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt */ | |||
| #define RTC_IT_TAMP1 ((uint32_t)0x00020000) | |||
| #define RTC_IT_TAMP2 ((uint32_t)0x00040000) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTC_Flags_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_FLAG_RECALPF ((uint32_t)0x00010000) | |||
| #define RTC_FLAG_TAMP2F ((uint32_t)0x00004000) | |||
| #define RTC_FLAG_TAMP1F ((uint32_t)0x00002000) | |||
| #define RTC_FLAG_TSOVF ((uint32_t)0x00001000) | |||
| #define RTC_FLAG_TSF ((uint32_t)0x00000800) | |||
| #define RTC_FLAG_WUTF ((uint32_t)0x00000400) | |||
| #define RTC_FLAG_ALRBF ((uint32_t)0x00000200) | |||
| #define RTC_FLAG_ALRAF ((uint32_t)0x00000100) | |||
| #define RTC_FLAG_INITF ((uint32_t)0x00000040) | |||
| #define RTC_FLAG_RSF ((uint32_t)0x00000020) | |||
| #define RTC_FLAG_INITS ((uint32_t)0x00000010) | |||
| #define RTC_FLAG_SHPF ((uint32_t)0x00000008) | |||
| #define RTC_FLAG_WUTWF ((uint32_t)0x00000004) | |||
| #define RTC_FLAG_ALRBWF ((uint32_t)0x00000002) | |||
| #define RTC_FLAG_ALRAWF ((uint32_t)0x00000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset RTC handle state | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) | |||
| /** | |||
| * @brief Disable the write protection for RTC registers. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \ | |||
| do{ \ | |||
| (__HANDLE__)->Instance->WPR = 0xCA; \ | |||
| (__HANDLE__)->Instance->WPR = 0x53; \ | |||
| } while(0) | |||
| /** | |||
| * @brief Enable the write protection for RTC registers. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \ | |||
| do{ \ | |||
| (__HANDLE__)->Instance->WPR = 0xFF; \ | |||
| } while(0) | |||
| /** | |||
| * @brief Enable the RTC ALARMA peripheral. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE)) | |||
| /** | |||
| * @brief Disable the RTC ALARMA peripheral. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE)) | |||
| /** | |||
| * @brief Enable the RTC ALARMB peripheral. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE)) | |||
| /** | |||
| * @brief Disable the RTC ALARMB peripheral. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE)) | |||
| /** | |||
| * @brief Enable the RTC Alarm interrupt. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg RTC_IT_ALRA: Alarm A interrupt | |||
| * @arg RTC_IT_ALRB: Alarm B interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the RTC Alarm interrupt. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg RTC_IT_ALRA: Alarm A interrupt | |||
| * @arg RTC_IT_ALRB: Alarm B interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) | |||
| /** | |||
| * @brief Check whether the specified RTC Alarm interrupt has occurred or not. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC Alarm interrupt sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_IT_ALRA: Alarm A interrupt | |||
| * @arg RTC_IT_ALRB: Alarm B interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __FLAG__) ((((((__HANDLE__)->Instance->ISR)& ((__FLAG__)>> 4)) & 0x0000FFFF) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Get the selected RTC Alarm's flag status. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_ALRAF | |||
| * @arg RTC_FLAG_ALRBF | |||
| * @arg RTC_FLAG_ALRAWF | |||
| * @arg RTC_FLAG_ALRBWF | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Clear the RTC Alarm's pending flags. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_ALRAF | |||
| * @arg RTC_FLAG_ALRBF | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) | |||
| #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)0x00020000) /*!< External interrupt line 17 Connected to the RTC Alarm event */ | |||
| #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */ | |||
| #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to the RTC Wakeup event */ | |||
| /** | |||
| * @brief Enable the RTC Exti line. | |||
| * @param __EXTILINE__: specifies the RTC Exti sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_EXTI_LINE_ALARM_EVENT | |||
| * @arg RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT | |||
| * @arg RTC_EXTI_LINE_WAKEUPTIMER_EVENT | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_EXTI_ENABLE_IT(__EXTILINE__) (EXTI->IMR |= (__EXTILINE__)) | |||
| /* alias define maintained for legacy */ | |||
| #define __HAL_RTC_ENABLE_IT __HAL_RTC_EXTI_ENABLE_IT | |||
| /** | |||
| * @brief Disable the RTC Exti line. | |||
| * @param __EXTILINE__: specifies the RTC Exti sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_EXTI_LINE_ALARM_EVENT | |||
| * @arg RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT | |||
| * @arg RTC_EXTI_LINE_WAKEUPTIMER_EVENT | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_EXTI_DISABLE_IT(__EXTILINE__) (EXTI->IMR &= ~(__EXTILINE__)) | |||
| /* alias define maintained for legacy */ | |||
| #define __HAL_RTC_DISABLE_IT __HAL_RTC_EXTI_DISABLE_IT | |||
| /** | |||
| * @brief Generates a Software interrupt on selected EXTI line. | |||
| * @param __EXTILINE__: specifies the RTC Exti sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_EXTI_LINE_ALARM_EVENT | |||
| * @arg RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT | |||
| * @arg RTC_EXTI_LINE_WAKEUPTIMER_EVENT | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER |= (__EXTI_LINE__)) | |||
| /** | |||
| * @brief Clear the RTC Exti flags. | |||
| * @param __FLAG__: specifies the RTC Exti sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_EXTI_LINE_ALARM_EVENT | |||
| * @arg RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT | |||
| * @arg RTC_EXTI_LINE_WAKEUPTIMER_EVENT | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__)) | |||
| /* alias define maintained for legacy */ | |||
| #define __HAL_RTC_CLEAR_FLAG __HAL_RTC_EXTI_CLEAR_FLAG | |||
| /* Include RTC HAL Extension module */ | |||
| #include "stm32f4xx_hal_rtc_ex.h" | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization and de-initialization functions ****************************/ | |||
| HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); | |||
| void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); | |||
| void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); | |||
| /* RTC Time and Date functions ************************************************/ | |||
| HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); | |||
| HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); | |||
| HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); | |||
| HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); | |||
| /* RTC Alarm functions ********************************************************/ | |||
| HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); | |||
| HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); | |||
| HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); | |||
| HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); | |||
| void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); | |||
| void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); | |||
| /* Peripheral Control functions ***********************************************/ | |||
| HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc); | |||
| /* Peripheral State functions *************************************************/ | |||
| HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc); | |||
| uint8_t RTC_ByteToBcd2(uint8_t Value); | |||
| uint8_t RTC_Bcd2ToByte(uint8_t Value); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_RTC_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,691 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_rtc_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of RTC HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_RTC_EX_H | |||
| #define __STM32F4xx_HAL_RTC_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup RTCEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief RTC Tamper structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Tamper; /*!< Specifies the Tamper Pin. | |||
| This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions */ | |||
| uint32_t PinSelection; /*!< Specifies the Tamper Pin. | |||
| This parameter can be a value of @ref RTCEx_Tamper_Pins_Selection */ | |||
| uint32_t Trigger; /*!< Specifies the Tamper Trigger. | |||
| This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */ | |||
| uint32_t Filter; /*!< Specifies the RTC Filter Tamper. | |||
| This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */ | |||
| uint32_t SamplingFrequency; /*!< Specifies the sampling frequency. | |||
| This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */ | |||
| uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration . | |||
| This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */ | |||
| uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp . | |||
| This parameter can be a value of @ref RTCEx_Tamper_Pull_UP_Definitions */ | |||
| uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. | |||
| This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */ | |||
| }RTC_TamperTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup RTCEx_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup RTCEx_Backup_Registers_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_BKP_DR0 ((uint32_t)0x00000000) | |||
| #define RTC_BKP_DR1 ((uint32_t)0x00000001) | |||
| #define RTC_BKP_DR2 ((uint32_t)0x00000002) | |||
| #define RTC_BKP_DR3 ((uint32_t)0x00000003) | |||
| #define RTC_BKP_DR4 ((uint32_t)0x00000004) | |||
| #define RTC_BKP_DR5 ((uint32_t)0x00000005) | |||
| #define RTC_BKP_DR6 ((uint32_t)0x00000006) | |||
| #define RTC_BKP_DR7 ((uint32_t)0x00000007) | |||
| #define RTC_BKP_DR8 ((uint32_t)0x00000008) | |||
| #define RTC_BKP_DR9 ((uint32_t)0x00000009) | |||
| #define RTC_BKP_DR10 ((uint32_t)0x0000000A) | |||
| #define RTC_BKP_DR11 ((uint32_t)0x0000000B) | |||
| #define RTC_BKP_DR12 ((uint32_t)0x0000000C) | |||
| #define RTC_BKP_DR13 ((uint32_t)0x0000000D) | |||
| #define RTC_BKP_DR14 ((uint32_t)0x0000000E) | |||
| #define RTC_BKP_DR15 ((uint32_t)0x0000000F) | |||
| #define RTC_BKP_DR16 ((uint32_t)0x00000010) | |||
| #define RTC_BKP_DR17 ((uint32_t)0x00000011) | |||
| #define RTC_BKP_DR18 ((uint32_t)0x00000012) | |||
| #define RTC_BKP_DR19 ((uint32_t)0x00000013) | |||
| #define IS_RTC_BKP(BKP) (((BKP) == RTC_BKP_DR0) || \ | |||
| ((BKP) == RTC_BKP_DR1) || \ | |||
| ((BKP) == RTC_BKP_DR2) || \ | |||
| ((BKP) == RTC_BKP_DR3) || \ | |||
| ((BKP) == RTC_BKP_DR4) || \ | |||
| ((BKP) == RTC_BKP_DR5) || \ | |||
| ((BKP) == RTC_BKP_DR6) || \ | |||
| ((BKP) == RTC_BKP_DR7) || \ | |||
| ((BKP) == RTC_BKP_DR8) || \ | |||
| ((BKP) == RTC_BKP_DR9) || \ | |||
| ((BKP) == RTC_BKP_DR10) || \ | |||
| ((BKP) == RTC_BKP_DR11) || \ | |||
| ((BKP) == RTC_BKP_DR12) || \ | |||
| ((BKP) == RTC_BKP_DR13) || \ | |||
| ((BKP) == RTC_BKP_DR14) || \ | |||
| ((BKP) == RTC_BKP_DR15) || \ | |||
| ((BKP) == RTC_BKP_DR16) || \ | |||
| ((BKP) == RTC_BKP_DR17) || \ | |||
| ((BKP) == RTC_BKP_DR18) || \ | |||
| ((BKP) == RTC_BKP_DR19)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Time_Stamp_Edges_definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_TIMESTAMPEDGE_RISING ((uint32_t)0x00000000) | |||
| #define RTC_TIMESTAMPEDGE_FALLING ((uint32_t)0x00000008) | |||
| #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \ | |||
| ((EDGE) == RTC_TIMESTAMPEDGE_FALLING)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Tamper_Pins_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_TAMPER_1 RTC_TAFCR_TAMP1E | |||
| #define RTC_TAMPER_2 RTC_TAFCR_TAMP2E | |||
| #define IS_TAMPER(TAMPER) ((((TAMPER) & (uint32_t)0xFFFFFFF6) == 0x00) && ((TAMPER) != (uint32_t)RESET)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Tamper_Pins_Selection | |||
| * @{ | |||
| */ | |||
| #define RTC_TAMPERPIN_PC13 ((uint32_t)0x00000000) | |||
| #define RTC_TAMPERPIN_PI8 ((uint32_t)0x00010000) | |||
| #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TAMPERPIN_PC13) || \ | |||
| ((PIN) == RTC_TAMPERPIN_PI8)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_TimeStamp_Pin_Selection | |||
| * @{ | |||
| */ | |||
| #define RTC_TIMESTAMPPIN_PC13 ((uint32_t)0x00000000) | |||
| #define RTC_TIMESTAMPPIN_PI8 ((uint32_t)0x00020000) | |||
| #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_PC13) || \ | |||
| ((PIN) == RTC_TIMESTAMPPIN_PI8)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Tamper_Trigger_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_TAMPERTRIGGER_RISINGEDGE ((uint32_t)0x00000000) | |||
| #define RTC_TAMPERTRIGGER_FALLINGEDGE ((uint32_t)0x00000002) | |||
| #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE | |||
| #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE | |||
| #define IS_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \ | |||
| ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \ | |||
| ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \ | |||
| ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Tamper_Filter_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_TAMPERFILTER_DISABLE ((uint32_t)0x00000000) /*!< Tamper filter is disabled */ | |||
| #define RTC_TAMPERFILTER_2SAMPLE ((uint32_t)0x00000800) /*!< Tamper is activated after 2 | |||
| consecutive samples at the active level */ | |||
| #define RTC_TAMPERFILTER_4SAMPLE ((uint32_t)0x00001000) /*!< Tamper is activated after 4 | |||
| consecutive samples at the active level */ | |||
| #define RTC_TAMPERFILTER_8SAMPLE ((uint32_t)0x00001800) /*!< Tamper is activated after 8 | |||
| consecutive samples at the active leve. */ | |||
| #define IS_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \ | |||
| ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \ | |||
| ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \ | |||
| ((FILTER) == RTC_TAMPERFILTER_8SAMPLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled | |||
| with a frequency = RTCCLK / 32768 */ | |||
| #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 ((uint32_t)0x00000100) /*!< Each of the tamper inputs are sampled | |||
| with a frequency = RTCCLK / 16384 */ | |||
| #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled | |||
| with a frequency = RTCCLK / 8192 */ | |||
| #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled | |||
| with a frequency = RTCCLK / 4096 */ | |||
| #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled | |||
| with a frequency = RTCCLK / 2048 */ | |||
| #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled | |||
| with a frequency = RTCCLK / 1024 */ | |||
| #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled | |||
| with a frequency = RTCCLK / 512 */ | |||
| #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled | |||
| with a frequency = RTCCLK / 256 */ | |||
| #define IS_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \ | |||
| ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \ | |||
| ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \ | |||
| ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \ | |||
| ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \ | |||
| ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \ | |||
| ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \ | |||
| ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK ((uint32_t)0x00000000) /*!< Tamper pins are pre-charged before | |||
| sampling during 1 RTCCLK cycle */ | |||
| #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK ((uint32_t)0x00002000) /*!< Tamper pins are pre-charged before | |||
| sampling during 2 RTCCLK cycles */ | |||
| #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK ((uint32_t)0x00004000) /*!< Tamper pins are pre-charged before | |||
| sampling during 4 RTCCLK cycles */ | |||
| #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK ((uint32_t)0x00006000) /*!< Tamper pins are pre-charged before | |||
| sampling during 8 RTCCLK cycles */ | |||
| #define IS_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \ | |||
| ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \ | |||
| ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \ | |||
| ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE ((uint32_t)RTC_TAFCR_TAMPTS) /*!< TimeStamp on Tamper Detection event saved */ | |||
| #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE ((uint32_t)0x00000000) /*!< TimeStamp on Tamper Detection event is not saved */ | |||
| #define IS_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ | |||
| ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Tamper_Pull_UP_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_TAMPER_PULLUP_ENABLE ((uint32_t)0x00000000) /*!< TimeStamp on Tamper Detection event saved */ | |||
| #define RTC_TAMPER_PULLUP_DISABLE ((uint32_t)RTC_TAFCR_TAMPPUDIS) /*!< TimeStamp on Tamper Detection event is not saved */ | |||
| #define IS_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \ | |||
| ((STATE) == RTC_TAMPER_PULLUP_DISABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Wakeup_Timer_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 ((uint32_t)0x00000000) | |||
| #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 ((uint32_t)0x00000001) | |||
| #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 ((uint32_t)0x00000002) | |||
| #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 ((uint32_t)0x00000003) | |||
| #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS ((uint32_t)0x00000004) | |||
| #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS ((uint32_t)0x00000006) | |||
| #define IS_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \ | |||
| ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \ | |||
| ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \ | |||
| ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \ | |||
| ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \ | |||
| ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS)) | |||
| #define IS_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Digital_Calibration_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_CALIBSIGN_POSITIVE ((uint32_t)0x00000000) | |||
| #define RTC_CALIBSIGN_NEGATIVE ((uint32_t)0x00000080) | |||
| #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CALIBSIGN_POSITIVE) || \ | |||
| ((SIGN) == RTC_CALIBSIGN_NEGATIVE)) | |||
| #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Smooth_calib_period_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_SMOOTHCALIB_PERIOD_32SEC ((uint32_t)0x00000000) /*!< If RTCCLK = 32768 Hz, Smooth calibation | |||
| period is 32s, else 2exp20 RTCCLK seconds */ | |||
| #define RTC_SMOOTHCALIB_PERIOD_16SEC ((uint32_t)0x00002000) /*!< If RTCCLK = 32768 Hz, Smooth calibation | |||
| period is 16s, else 2exp19 RTCCLK seconds */ | |||
| #define RTC_SMOOTHCALIB_PERIOD_8SEC ((uint32_t)0x00004000) /*!< If RTCCLK = 32768 Hz, Smooth calibation | |||
| period is 8s, else 2exp18 RTCCLK seconds */ | |||
| #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \ | |||
| ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \ | |||
| ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_SMOOTHCALIB_PLUSPULSES_SET ((uint32_t)0x00008000) /*!< The number of RTCCLK pulses added | |||
| during a X -second window = Y - CALM[8:0] | |||
| with Y = 512, 256, 128 when X = 32, 16, 8 */ | |||
| #define RTC_SMOOTHCALIB_PLUSPULSES_RESET ((uint32_t)0x00000000) /*!< The number of RTCCLK pulses subbstited | |||
| during a 32-second window = CALM[8:0] */ | |||
| #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \ | |||
| ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Smooth_calib_Minus_pulses_Definitions | |||
| * @{ | |||
| */ | |||
| #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_SHIFTADD1S_RESET ((uint32_t)0x00000000) | |||
| #define RTC_SHIFTADD1S_SET ((uint32_t)0x80000000) | |||
| #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \ | |||
| ((SEL) == RTC_SHIFTADD1S_SET)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Substract_Fraction_Of_Second_Value | |||
| * @{ | |||
| */ | |||
| #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup RTCEx_Calib_Output_selection_Definitions | |||
| * @{ | |||
| */ | |||
| #define RTC_CALIBOUTPUT_512HZ ((uint32_t)0x00000000) | |||
| #define RTC_CALIBOUTPUT_1HZ ((uint32_t)0x00080000) | |||
| #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \ | |||
| ((OUTPUT) == RTC_CALIBOUTPUT_1HZ)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief Enable the RTC WakeUp Timer peripheral. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE)) | |||
| /** | |||
| * @brief Enable the RTC TimeStamp peripheral. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE)) | |||
| /** | |||
| * @brief Disable the RTC WakeUp Timer peripheral. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE)) | |||
| /** | |||
| * @brief Disable the RTC TimeStamp peripheral. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE)) | |||
| /** | |||
| * @brief Enable the Coarse calibration process. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_COARSE_CALIB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_DCE)) | |||
| /** | |||
| * @brief Disable the Coarse calibration process. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_COARSE_CALIB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_DCE)) | |||
| /** | |||
| * @brief Enable the RTC calibration output. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE)) | |||
| /** | |||
| * @brief Disable the calibration output. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE)) | |||
| /** | |||
| * @brief Enable the clock reference detection. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON)) | |||
| /** | |||
| * @brief Disable the clock reference detection. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON)) | |||
| /** | |||
| * @brief Enable the RTC TimeStamp interrupt. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_IT_TS: TimeStamp interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Enable the RTC WakeUpTimer interrupt. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_IT_WUT: WakeUpTimer A interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the RTC TimeStamp interrupt. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_IT_TS: TimeStamp interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the RTC WakeUpTimer interrupt. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_IT_WUT: WakeUpTimer A interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) | |||
| /** | |||
| * @brief Check whether the specified RTC Tamper interrupt has occurred or not. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC Tamper interrupt sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_IT_TAMP1 | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_IT_WUT: WakeUpTimer A interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_IT_TS: TimeStamp interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Get the selected RTC TimeStamp's flag status. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC TimeStamp Flag sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_TSF | |||
| * @arg RTC_FLAG_TSOVF | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Get the selected RTC WakeUpTimer's flag status. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC WakeUpTimer Flag sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_WUTF | |||
| * @arg RTC_FLAG_WUTWF | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Get the selected RTC Tamper's flag status. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_TAMP1F | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Get the selected RTC shift operation's flag status. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC shift operation Flag is pending or not. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_SHPF | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) | |||
| /** | |||
| * @brief Clear the RTC Time Stamp's pending flags. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_TSF | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) | |||
| /** | |||
| * @brief Clear the RTC Tamper's pending flags. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_TAMP1F | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) | |||
| /** | |||
| * @brief Clear the RTC Wake Up timer's pending flags. | |||
| * @param __HANDLE__: specifies the RTC handle. | |||
| * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled. | |||
| * This parameter can be: | |||
| * @arg RTC_FLAG_WUTF | |||
| * @retval None | |||
| */ | |||
| #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* RTC TimeStamp and Tamper functions *****************************************/ | |||
| HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); | |||
| HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper); | |||
| HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper); | |||
| void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc); | |||
| void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); | |||
| void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); | |||
| void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); | |||
| /* RTC Wake-up functions ******************************************************/ | |||
| HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); | |||
| uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc); | |||
| uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc); | |||
| void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc); | |||
| void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); | |||
| /* Extension Control functions ************************************************/ | |||
| void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data); | |||
| uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef *hrtc, uint32_t CalibSign, uint32_t Value); | |||
| HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput); | |||
| HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc); | |||
| /* Extension RTC features functions *******************************************/ | |||
| void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); | |||
| HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_RTC_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,767 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_sai.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of SAI HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_SAI_H | |||
| #define __STM32F4xx_HAL_SAI_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup SAI | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief SAI Init Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Protocol; /*!< Specifies the SAI Block protocol. | |||
| This parameter can be a value of @ref SAI_Block_Protocol */ | |||
| uint32_t AudioMode; /*!< Specifies the SAI Block audio Mode. | |||
| This parameter can be a value of @ref SAI_Block_Mode */ | |||
| uint32_t DataSize; /*!< Specifies the SAI Block data size. | |||
| This parameter can be a value of @ref SAI_Block_Data_Size */ | |||
| uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. | |||
| This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission */ | |||
| uint32_t ClockStrobing; /*!< Specifies the SAI Block clock strobing edge sensitivity. | |||
| This parameter can be a value of @ref SAI_Block_Clock_Strobing */ | |||
| uint32_t Synchro; /*!< Specifies SAI Block synchronization | |||
| This parameter can be a value of @ref SAI_Block_Synchronization */ | |||
| uint32_t OutputDrive; /*!< Specifies when SAI Block outputs are driven. | |||
| This parameter can be a value of @ref SAI_Block_Output_Drive | |||
| @note this value has to be set before enabling the audio block | |||
| but after the audio block configuration. */ | |||
| uint32_t NoDivider; /*!< Specifies whether master clock will be divided or not. | |||
| This parameter can be a value of @ref SAI_Block_NoDivider | |||
| @note: If bit NODIV in the SAI_xCR1 register is cleared, the frame length | |||
| should be aligned to a number equal to a power of 2, from 8 to 256. | |||
| If bit NODIV in the SAI_xCR1 register is set, the frame length can | |||
| take any of the values without constraint since the input clock of | |||
| the audio block should be equal to the bit clock. | |||
| There is no MCLK_x clock which can be output. */ | |||
| uint32_t FIFOThreshold; /*!< Specifies SAI Block FIFO threshold. | |||
| This parameter can be a value of @ref SAI_Block_Fifo_Threshold */ | |||
| uint32_t ClockSource; /*!< Specifies the SAI Block x Clock source. | |||
| This parameter can be a value of @ref SAI_Clock_Source | |||
| @note: If ClockSource is equal to SAI_CLKSource_Ext, the PLLI2S | |||
| and PLLSAI divisions factors will be ignored. */ | |||
| uint32_t AudioFrequency; /*!< Specifies the audio frequency sampling. | |||
| This parameter can be a value of @ref SAI_Audio_Frequency */ | |||
| }SAI_InitTypeDef; | |||
| /** | |||
| * @brief SAI Block Frame Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t FrameLength; /*!< Specifies the Frame length, the number of SCK clocks for each audio frame. | |||
| This parameter must be a number between Min_Data = 8 and Max_Data = 256. | |||
| @note: If master clock MCLK_x pin is declared as an output, the frame length | |||
| should be aligned to a number equal to power of 2 in order to keep | |||
| in an audio frame, an integer number of MCLK pulses by bit Clock. */ | |||
| uint32_t ActiveFrameLength; /*!< Specifies the Frame synchronization active level length. | |||
| This Parameter specifies the length in number of bit clock (SCK + 1) | |||
| of the active level of FS signal in audio frame. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 128 */ | |||
| uint32_t FSDefinition; /*!< Specifies the Frame synchronization definition. | |||
| This parameter can be a value of @ref SAI_Block_FS_Definition */ | |||
| uint32_t FSPolarity; /*!< Specifies the Frame synchronization Polarity. | |||
| This parameter can be a value of @ref SAI_Block_FS_Polarity */ | |||
| uint32_t FSOffset; /*!< Specifies the Frame synchronization Offset. | |||
| This parameter can be a value of @ref SAI_Block_FS_Offset */ | |||
| }SAI_FrameInitTypeDef; | |||
| /** | |||
| * @brief SAI Block Slot Init Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t FirstBitOffset; /*!< Specifies the position of first data transfer bit in the slot. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 24 */ | |||
| uint32_t SlotSize; /*!< Specifies the Slot Size. | |||
| This parameter can be a value of @ref SAI_Block_Slot_Size */ | |||
| uint32_t SlotNumber; /*!< Specifies the number of slot in the audio frame. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 16 */ | |||
| uint32_t SlotActive; /*!< Specifies the slots in audio frame that will be activated. | |||
| This parameter can be a value of @ref SAI_Block_Slot_Active */ | |||
| }SAI_SlotInitTypeDef; | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_SAI_STATE_RESET = 0x00, /*!< SAI not yet initialized or disabled */ | |||
| HAL_SAI_STATE_READY = 0x01, /*!< SAI initialized and ready for use */ | |||
| HAL_SAI_STATE_BUSY = 0x02, /*!< SAI internal process is ongoing */ | |||
| HAL_SAI_STATE_BUSY_TX = 0x12, /*!< Data transmission process is ongoing */ | |||
| HAL_SAI_STATE_BUSY_RX = 0x22, /*!< Data reception process is ongoing */ | |||
| HAL_SAI_STATE_TIMEOUT = 0x03, /*!< SAI timeout state */ | |||
| HAL_SAI_STATE_ERROR = 0x04 /*!< SAI error state */ | |||
| }HAL_SAI_StateTypeDef; | |||
| /** | |||
| * @brief SAI handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| SAI_Block_TypeDef *Instance; /*!< SAI Blockx registers base address */ | |||
| SAI_InitTypeDef Init; /*!< SAI communication parameters */ | |||
| SAI_FrameInitTypeDef FrameInit; /*!< SAI Frame configuration parameters */ | |||
| SAI_SlotInitTypeDef SlotInit; /*!< SAI Slot configuration parameters */ | |||
| uint16_t *pTxBuffPtr; /*!< Pointer to SAI Tx transfer Buffer */ | |||
| uint16_t TxXferSize; /*!< SAI Tx transfer size */ | |||
| uint16_t TxXferCount; /*!< SAI Tx transfer counter */ | |||
| uint16_t *pRxBuffPtr; /*!< Pointer to SAI Rx transfer buffer */ | |||
| uint16_t RxXferSize; /*!< SAI Rx transfer size */ | |||
| uint16_t RxXferCount; /*!< SAI Rx transfer counter */ | |||
| DMA_HandleTypeDef *hdmatx; /*!< SAI Tx DMA handle parameters */ | |||
| DMA_HandleTypeDef *hdmarx; /*!< SAI Rx DMA handle parameters */ | |||
| HAL_LockTypeDef Lock; /*!< SAI locking object */ | |||
| __IO HAL_SAI_StateTypeDef State; /*!< SAI communication state */ | |||
| __IO uint32_t ErrorCode; /*!< SAI Error code */ | |||
| }SAI_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup SAI_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup SAI Error Code | |||
| * @{ | |||
| */ | |||
| #define HAL_SAI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ | |||
| #define HAL_SAI_ERROR_OVR ((uint32_t)0x00000001) /*!< Overrun Error */ | |||
| #define HAL_SAI_ERROR_UDR ((uint32_t)0x00000002) /*!< Underrun error */ | |||
| #define HAL_SAI_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Clock_Source | |||
| * @{ | |||
| */ | |||
| #define SAI_CLKSOURCE_PLLSAI ((uint32_t)RCC_SAIACLKSOURCE_PLLSAI) | |||
| #define SAI_CLKSOURCE_PLLI2S ((uint32_t)RCC_SAIACLKSOURCE_PLLI2S) | |||
| #define SAI_CLKSOURCE_EXT ((uint32_t)RCC_SAIACLKSOURCE_EXT) | |||
| #define IS_SAI_CLK_SOURCE(SOURCE) (((SOURCE) == SAI_CLKSOURCE_PLLSAI) ||\ | |||
| ((SOURCE) == SAI_CLKSOURCE_PLLI2S) ||\ | |||
| ((SOURCE) == SAI_CLKSOURCE_EXT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Audio_Frequency | |||
| * @{ | |||
| */ | |||
| #define SAI_AUDIO_FREQUENCY_192K ((uint32_t)192000) | |||
| #define SAI_AUDIO_FREQUENCY_96K ((uint32_t)96000) | |||
| #define SAI_AUDIO_FREQUENCY_48K ((uint32_t)48000) | |||
| #define SAI_AUDIO_FREQUENCY_44K ((uint32_t)44100) | |||
| #define SAI_AUDIO_FREQUENCY_32K ((uint32_t)32000) | |||
| #define SAI_AUDIO_FREQUENCY_22K ((uint32_t)22050) | |||
| #define SAI_AUDIO_FREQUENCY_16K ((uint32_t)16000) | |||
| #define SAI_AUDIO_FREQUENCY_11K ((uint32_t)11025) | |||
| #define SAI_AUDIO_FREQUENCY_8K ((uint32_t)8000) | |||
| #define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \ | |||
| ((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \ | |||
| ((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \ | |||
| ((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \ | |||
| ((AUDIO) == SAI_AUDIO_FREQUENCY_8K)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Mode | |||
| * @{ | |||
| */ | |||
| #define SAI_MODEMASTER_TX ((uint32_t)0x00000000) | |||
| #define SAI_MODEMASTER_RX ((uint32_t)0x00000001) | |||
| #define SAI_MODESLAVE_TX ((uint32_t)0x00000002) | |||
| #define SAI_MODESLAVE_RX ((uint32_t)0x00000003) | |||
| #define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_MODEMASTER_TX) || \ | |||
| ((MODE) == SAI_MODEMASTER_RX) || \ | |||
| ((MODE) == SAI_MODESLAVE_TX) || \ | |||
| ((MODE) == SAI_MODESLAVE_RX)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Protocol | |||
| * @{ | |||
| */ | |||
| #define SAI_FREE_PROTOCOL ((uint32_t)0x00000000) | |||
| #define SAI_AC97_PROTOCOL ((uint32_t)SAI_xCR1_PRTCFG_1) | |||
| #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL) || \ | |||
| ((PROTOCOL) == SAI_AC97_PROTOCOL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Data_Size | |||
| * @{ | |||
| */ | |||
| #define SAI_DATASIZE_8 ((uint32_t)0x00000040) | |||
| #define SAI_DATASIZE_10 ((uint32_t)0x00000060) | |||
| #define SAI_DATASIZE_16 ((uint32_t)0x00000080) | |||
| #define SAI_DATASIZE_20 ((uint32_t)0x000000A0) | |||
| #define SAI_DATASIZE_24 ((uint32_t)0x000000C0) | |||
| #define SAI_DATASIZE_32 ((uint32_t)0x000000E0) | |||
| #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8) || \ | |||
| ((DATASIZE) == SAI_DATASIZE_10) || \ | |||
| ((DATASIZE) == SAI_DATASIZE_16) || \ | |||
| ((DATASIZE) == SAI_DATASIZE_20) || \ | |||
| ((DATASIZE) == SAI_DATASIZE_24) || \ | |||
| ((DATASIZE) == SAI_DATASIZE_32)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_MSB_LSB_transmission | |||
| * @{ | |||
| */ | |||
| #define SAI_FIRSTBIT_MSB ((uint32_t)0x00000000) | |||
| #define SAI_FIRSTBIT_LSB ((uint32_t)SAI_xCR1_LSBFIRST) | |||
| #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \ | |||
| ((BIT) == SAI_FIRSTBIT_LSB)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Clock_Strobing | |||
| * @{ | |||
| */ | |||
| #define SAI_CLOCKSTROBING_FALLINGEDGE ((uint32_t)0x00000000) | |||
| #define SAI_CLOCKSTROBING_RISINGEDGE ((uint32_t)SAI_xCR1_CKSTR) | |||
| #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \ | |||
| ((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Synchronization | |||
| * @{ | |||
| */ | |||
| #define SAI_ASYNCHRONOUS ((uint32_t)0x00000000) | |||
| #define SAI_SYNCHRONOUS ((uint32_t)SAI_xCR1_SYNCEN_0) | |||
| #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \ | |||
| ((SYNCHRO) == SAI_SYNCHRONOUS)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Output_Drive | |||
| * @{ | |||
| */ | |||
| #define SAI_OUTPUTDRIVE_DISABLED ((uint32_t)0x00000000) | |||
| #define SAI_OUTPUTDRIVE_ENABLED ((uint32_t)SAI_xCR1_OUTDRIV) | |||
| #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLED) || \ | |||
| ((DRIVE) == SAI_OUTPUTDRIVE_ENABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_NoDivider | |||
| * @{ | |||
| */ | |||
| #define SAI_MASTERDIVIDER_ENABLED ((uint32_t)0x00000000) | |||
| #define SAI_MASTERDIVIDER_DISABLED ((uint32_t)SAI_xCR1_NODIV) | |||
| #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLED) || \ | |||
| ((NODIVIDER) == SAI_MASTERDIVIDER_DISABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Master_Divider | |||
| * @{ | |||
| */ | |||
| #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 15) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Frame_Length | |||
| * @{ | |||
| */ | |||
| #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8 <= (LENGTH)) && ((LENGTH) <= 256)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Active_FrameLength | |||
| * @{ | |||
| */ | |||
| #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1 <= (LENGTH)) && ((LENGTH) <= 128)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_FS_Definition | |||
| * @{ | |||
| */ | |||
| #define SAI_FS_STARTFRAME ((uint32_t)0x00000000) | |||
| #define SAI_FS_CHANNEL_IDENTIFICATION ((uint32_t)SAI_xFRCR_FSDEF) | |||
| #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \ | |||
| ((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_FS_Polarity | |||
| * @{ | |||
| */ | |||
| #define SAI_FS_ACTIVE_LOW ((uint32_t)0x00000000) | |||
| #define SAI_FS_ACTIVE_HIGH ((uint32_t)SAI_xFRCR_FSPO) | |||
| #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \ | |||
| ((POLARITY) == SAI_FS_ACTIVE_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_FS_Offset | |||
| * @{ | |||
| */ | |||
| #define SAI_FS_FIRSTBIT ((uint32_t)0x00000000) | |||
| #define SAI_FS_BEFOREFIRSTBIT ((uint32_t)SAI_xFRCR_FSOFF) | |||
| #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \ | |||
| ((OFFSET) == SAI_FS_BEFOREFIRSTBIT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Slot_FirstBit_Offset | |||
| * @{ | |||
| */ | |||
| #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Slot_Size | |||
| * @{ | |||
| */ | |||
| #define SAI_SLOTSIZE_DATASIZE ((uint32_t)0x00000000) | |||
| #define SAI_SLOTSIZE_16B ((uint32_t)SAI_xSLOTR_SLOTSZ_0) | |||
| #define SAI_SLOTSIZE_32B ((uint32_t)SAI_xSLOTR_SLOTSZ_1) | |||
| #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \ | |||
| ((SIZE) == SAI_SLOTSIZE_16B) || \ | |||
| ((SIZE) == SAI_SLOTSIZE_32B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Slot_Number | |||
| * @{ | |||
| */ | |||
| #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1 <= (NUMBER)) && ((NUMBER) <= 16)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Slot_Active | |||
| * @{ | |||
| */ | |||
| #define SAI_SLOT_NOTACTIVE ((uint32_t)0x00000000) | |||
| #define SAI_SLOTACTIVE_0 ((uint32_t)0x00010000) | |||
| #define SAI_SLOTACTIVE_1 ((uint32_t)0x00020000) | |||
| #define SAI_SLOTACTIVE_2 ((uint32_t)0x00040000) | |||
| #define SAI_SLOTACTIVE_3 ((uint32_t)0x00080000) | |||
| #define SAI_SLOTACTIVE_4 ((uint32_t)0x00100000) | |||
| #define SAI_SLOTACTIVE_5 ((uint32_t)0x00200000) | |||
| #define SAI_SLOTACTIVE_6 ((uint32_t)0x00400000) | |||
| #define SAI_SLOTACTIVE_7 ((uint32_t)0x00800000) | |||
| #define SAI_SLOTACTIVE_8 ((uint32_t)0x01000000) | |||
| #define SAI_SLOTACTIVE_9 ((uint32_t)0x02000000) | |||
| #define SAI_SLOTACTIVE_10 ((uint32_t)0x04000000) | |||
| #define SAI_SLOTACTIVE_11 ((uint32_t)0x08000000) | |||
| #define SAI_SLOTACTIVE_12 ((uint32_t)0x10000000) | |||
| #define SAI_SLOTACTIVE_13 ((uint32_t)0x20000000) | |||
| #define SAI_SLOTACTIVE_14 ((uint32_t)0x40000000) | |||
| #define SAI_SLOTACTIVE_15 ((uint32_t)0x80000000) | |||
| #define SAI_SLOTACTIVE_ALL ((uint32_t)0xFFFF0000) | |||
| #define IS_SAI_SLOT_ACTIVE(ACTIVE) ((ACTIVE) != 0) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Mono_Stereo_Mode | |||
| * @{ | |||
| */ | |||
| #define SAI_MONOMODE ((uint32_t)SAI_xCR1_MONO) | |||
| #define SAI_STREOMODE ((uint32_t)0x00000000) | |||
| #define IS_SAI_BLOCK_MONO_STREO_MODE(MODE) (((MODE) == SAI_MONOMODE) ||\ | |||
| ((MODE) == SAI_STREOMODE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_TRIState_Management | |||
| * @{ | |||
| */ | |||
| #define SAI_OUTPUT_NOTRELEASED ((uint32_t)0x00000000) | |||
| #define SAI_OUTPUT_RELEASED ((uint32_t)SAI_xCR2_TRIS) | |||
| #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\ | |||
| ((STATE) == SAI_OUTPUT_RELEASED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Fifo_Threshold | |||
| * @{ | |||
| */ | |||
| #define SAI_FIFOTHRESHOLD_EMPTY ((uint32_t)0x00000000) | |||
| #define SAI_FIFOTHRESHOLD_1QF ((uint32_t)0x00000001) | |||
| #define SAI_FIFOTHRESHOLD_HF ((uint32_t)0x00000002) | |||
| #define SAI_FIFOTHRESHOLD_3QF ((uint32_t)0x00000003) | |||
| #define SAI_FIFOTHRESHOLD_FULL ((uint32_t)0x00000004) | |||
| #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY) || \ | |||
| ((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF) || \ | |||
| ((THRESHOLD) == SAI_FIFOTHRESHOLD_HF) || \ | |||
| ((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF) || \ | |||
| ((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Companding_Mode | |||
| * @{ | |||
| */ | |||
| #define SAI_NOCOMPANDING ((uint32_t)0x00000000) | |||
| #define SAI_ULAW_1CPL_COMPANDING ((uint32_t)0x00008000) | |||
| #define SAI_ALAW_1CPL_COMPANDING ((uint32_t)0x0000C000) | |||
| #define SAI_ULAW_2CPL_COMPANDING ((uint32_t)0x0000A000) | |||
| #define SAI_ALAW_2CPL_COMPANDING ((uint32_t)0x0000E000) | |||
| #define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NOCOMPANDING) || \ | |||
| ((MODE) == SAI_ULAW_1CPL_COMPANDING) || \ | |||
| ((MODE) == SAI_ALAW_1CPL_COMPANDING) || \ | |||
| ((MODE) == SAI_ULAW_2CPL_COMPANDING) || \ | |||
| ((MODE) == SAI_ALAW_2CPL_COMPANDING)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Mute_Value | |||
| * @{ | |||
| */ | |||
| #define SAI_ZERO_VALUE ((uint32_t)0x00000000) | |||
| #define SAI_LAST_SENT_VALUE ((uint32_t)SAI_xCR2_MUTEVAL) | |||
| #define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZERO_VALUE) || \ | |||
| ((VALUE) == SAI_LAST_SENT_VALUE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Mute_Frame_Counter | |||
| * @{ | |||
| */ | |||
| #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Interrupts_Definition | |||
| * @{ | |||
| */ | |||
| #define SAI_IT_OVRUDR ((uint32_t)SAI_xIMR_OVRUDRIE) | |||
| #define SAI_IT_MUTEDET ((uint32_t)SAI_xIMR_MUTEDETIE) | |||
| #define SAI_IT_WCKCFG ((uint32_t)SAI_xIMR_WCKCFGIE) | |||
| #define SAI_IT_FREQ ((uint32_t)SAI_xIMR_FREQIE) | |||
| #define SAI_IT_CNRDY ((uint32_t)SAI_xIMR_CNRDYIE) | |||
| #define SAI_IT_AFSDET ((uint32_t)SAI_xIMR_AFSDETIE) | |||
| #define SAI_IT_LFSDET ((uint32_t)SAI_xIMR_LFSDETIE) | |||
| #define IS_SAI_BLOCK_CONFIG_IT(IT) (((IT) == SAI_IT_OVRUDR) || \ | |||
| ((IT) == SAI_IT_MUTEDET) || \ | |||
| ((IT) == SAI_IT_WCKCFG) || \ | |||
| ((IT) == SAI_IT_FREQ) || \ | |||
| ((IT) == SAI_IT_CNRDY) || \ | |||
| ((IT) == SAI_IT_AFSDET) || \ | |||
| ((IT) == SAI_IT_LFSDET)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Flags_Definition | |||
| * @{ | |||
| */ | |||
| #define SAI_FLAG_OVRUDR ((uint32_t)SAI_xSR_OVRUDR) | |||
| #define SAI_FLAG_MUTEDET ((uint32_t)SAI_xSR_MUTEDET) | |||
| #define SAI_FLAG_WCKCFG ((uint32_t)SAI_xSR_WCKCFG) | |||
| #define SAI_FLAG_FREQ ((uint32_t)SAI_xSR_FREQ) | |||
| #define SAI_FLAG_CNRDY ((uint32_t)SAI_xSR_CNRDY) | |||
| #define SAI_FLAG_AFSDET ((uint32_t)SAI_xSR_AFSDET) | |||
| #define SAI_FLAG_LFSDET ((uint32_t)SAI_xSR_LFSDET) | |||
| #define IS_SAI_BLOCK_GET_FLAG(FLAG) (((FLAG) == SAI_FLAG_OVRUDR) || \ | |||
| ((FLAG) == SAI_FLAG_MUTEDET) || \ | |||
| ((FLAG) == SAI_FLAG_WCKCFG) || \ | |||
| ((FLAG) == SAI_FLAG_FREQ) || \ | |||
| ((FLAG) == SAI_FLAG_CNRDY) || \ | |||
| ((FLAG) == SAI_FLAG_AFSDET) || \ | |||
| ((FLAG) == SAI_FLAG_LFSDET)) | |||
| #define IS_SAI_BLOCK_CLEAR_FLAG(FLAG) (((FLAG) == SAI_FLAG_OVRUDR) || \ | |||
| ((FLAG) == SAI_FLAG_MUTEDET) || \ | |||
| ((FLAG) == SAI_FLAG_WCKCFG) || \ | |||
| ((FLAG) == SAI_FLAG_FREQ) || \ | |||
| ((FLAG) == SAI_FLAG_CNRDY) || \ | |||
| ((FLAG) == SAI_FLAG_AFSDET) || \ | |||
| ((FLAG) == SAI_FLAG_LFSDET)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SAI_Block_Fifo_Status_Level | |||
| * @{ | |||
| */ | |||
| #define SAI_FIFOStatus_Empty ((uint32_t)0x00000000) | |||
| #define SAI_FIFOStatus_Less1QuarterFull ((uint32_t)0x00010000) | |||
| #define SAI_FIFOStatus_1QuarterFull ((uint32_t)0x00020000) | |||
| #define SAI_FIFOStatus_HalfFull ((uint32_t)0x00030000) | |||
| #define SAI_FIFOStatus_3QuartersFull ((uint32_t)0x00040000) | |||
| #define SAI_FIFOStatus_Full ((uint32_t)0x00050000) | |||
| #define IS_SAI_BLOCK_FIFO_STATUS(STATUS) (((STATUS) == SAI_FIFOStatus_Less1QuarterFull ) || \ | |||
| ((STATUS) == SAI_FIFOStatus_HalfFull) || \ | |||
| ((STATUS) == SAI_FIFOStatus_1QuarterFull) || \ | |||
| ((STATUS) == SAI_FIFOStatus_3QuartersFull) || \ | |||
| ((STATUS) == SAI_FIFOStatus_Full) || \ | |||
| ((STATUS) == SAI_FIFOStatus_Empty)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset SAI handle state | |||
| * @param __HANDLE__: specifies the SAI Handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET) | |||
| /** @brief Enable or disable the specified SAI interrupts. | |||
| * @param __HANDLE__: specifies the SAI Handle. | |||
| * @param __INTERRUPT__: specifies the interrupt source to enable or disable. | |||
| * This parameter can be one of the following values: | |||
| * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable | |||
| * @arg SAI_IT_MUTEDET: Mute detection interrupt enable | |||
| * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable | |||
| * @arg SAI_IT_FREQ: FIFO request interrupt enable | |||
| * @arg SAI_IT_CNRDY: Codec not ready interrupt enable | |||
| * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable | |||
| * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enabl | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__)) | |||
| #define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__))) | |||
| /** @brief Check if the specified SAI interrupt source is enabled or disabled. | |||
| * @param __HANDLE__: specifies the SAI Handle. | |||
| * This parameter can be SAI where x: 1, 2, or 3 to select the SAI peripheral. | |||
| * @param __INTERRUPT__: specifies the SAI interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SAI_IT_TXE: Tx buffer empty interrupt enable. | |||
| * @arg SAI_IT_RXNE: Rx buffer not empty interrupt enable. | |||
| * @arg SAI_IT_ERR: Error interrupt enable. | |||
| * @retval The new state of __INTERRUPT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
| /** @brief Check whether the specified SAI flag is set or not. | |||
| * @param __HANDLE__: specifies the SAI Handle. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SAI_FLAG_OVRUDR: Overrun underrun flag. | |||
| * @arg SAI_FLAG_MUTEDET: Mute detection flag. | |||
| * @arg SAI_FLAG_WCKCFG: Wrong Clock Configuration flag. | |||
| * @arg SAI_FLAG_FREQ: FIFO request flag. | |||
| * @arg SAI_FLAG_CNRDY: Codec not ready flag. | |||
| * @arg SAI_FLAG_AFSDET: Anticipated frame synchronization detection flag. | |||
| * @arg SAI_FLAG_LFSDET: Late frame synchronization detection flag. | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clears the specified SAI pending flag. | |||
| * @param __HANDLE__: specifies the SAI Handle. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg SAI_FLAG_OVRUDR: Clear Overrun underrun | |||
| * @arg SAI_FLAG_MUTEDET: Clear Mute detection | |||
| * @arg SAI_FLAG_WCKCFG: Clear Wrong Clock Configuration | |||
| * @arg SAI_FLAG_FREQ: Clear FIFO request | |||
| * @arg SAI_FLAG_CNRDY: Clear Codec not ready | |||
| * @arg SAI_FLAG_AFSDET: Clear Anticipated frame synchronization detection | |||
| * @arg SAI_FLAG_LFSDET: Clear Late frame synchronization detection | |||
| * | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__)) | |||
| #define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SAI_xCR1_SAIEN) | |||
| #define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SAI_xCR1_SAIEN) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai); | |||
| HAL_StatusTypeDef HAL_SAI_DeInit (SAI_HandleTypeDef *hsai); | |||
| void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai); | |||
| void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai); | |||
| /* I/O operation functions *****************************************************/ | |||
| /* Blocking mode: Polling */ | |||
| HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size, uint32_t Timeout); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size); | |||
| /* Non-Blocking mode: DMA */ | |||
| HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai); | |||
| HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai); | |||
| HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai); | |||
| /* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ | |||
| void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai); | |||
| void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai); | |||
| void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai); | |||
| void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai); | |||
| void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai); | |||
| void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai); | |||
| /* Peripheral State functions **************************************************/ | |||
| HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai); | |||
| uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai); | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_SAI_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,699 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_sd.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of SD HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_SD_H | |||
| #define __STM32F4xx_HAL_SD_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_ll_sdmmc.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup SD | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** @defgroup SD_Exported_Types | |||
| * @{ | |||
| */ | |||
| #define SD_InitTypeDef SDIO_InitTypeDef | |||
| #define SD_TypeDef SDIO_TypeDef | |||
| /** | |||
| * @brief SDIO Handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| SD_TypeDef *Instance; /*!< SDIO register base address */ | |||
| SD_InitTypeDef Init; /*!< SD required parameters */ | |||
| HAL_LockTypeDef Lock; /*!< SD locking object */ | |||
| uint32_t CardType; /*!< SD card type */ | |||
| uint32_t RCA; /*!< SD relative card address */ | |||
| uint32_t CSD[4]; /*!< SD card specific data table */ | |||
| uint32_t CID[4]; /*!< SD card identification number table */ | |||
| __IO uint32_t SdTransferCplt; /*!< SD transfer complete flag in non blocking mode */ | |||
| __IO uint32_t SdTransferErr; /*!< SD transfer error flag in non blocking mode */ | |||
| __IO uint32_t DmaTransferCplt; /*!< SD DMA transfer complete flag */ | |||
| __IO uint32_t SdOperation; /*!< SD transfer operation (read/write) */ | |||
| DMA_HandleTypeDef *hdmarx; /*!< SD Rx DMA handle parameters */ | |||
| DMA_HandleTypeDef *hdmatx; /*!< SD Tx DMA handle parameters */ | |||
| }SD_HandleTypeDef; | |||
| /** | |||
| * @brief Card Specific Data: CSD Register | |||
| */ | |||
| typedef struct | |||
| { | |||
| __IO uint8_t CSDStruct; /*!< CSD structure */ | |||
| __IO uint8_t SysSpecVersion; /*!< System specification version */ | |||
| __IO uint8_t Reserved1; /*!< Reserved */ | |||
| __IO uint8_t TAAC; /*!< Data read access time 1 */ | |||
| __IO uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */ | |||
| __IO uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */ | |||
| __IO uint16_t CardComdClasses; /*!< Card command classes */ | |||
| __IO uint8_t RdBlockLen; /*!< Max. read data block length */ | |||
| __IO uint8_t PartBlockRead; /*!< Partial blocks for read allowed */ | |||
| __IO uint8_t WrBlockMisalign; /*!< Write block misalignment */ | |||
| __IO uint8_t RdBlockMisalign; /*!< Read block misalignment */ | |||
| __IO uint8_t DSRImpl; /*!< DSR implemented */ | |||
| __IO uint8_t Reserved2; /*!< Reserved */ | |||
| __IO uint32_t DeviceSize; /*!< Device Size */ | |||
| __IO uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */ | |||
| __IO uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */ | |||
| __IO uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */ | |||
| __IO uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */ | |||
| __IO uint8_t DeviceSizeMul; /*!< Device size multiplier */ | |||
| __IO uint8_t EraseGrSize; /*!< Erase group size */ | |||
| __IO uint8_t EraseGrMul; /*!< Erase group size multiplier */ | |||
| __IO uint8_t WrProtectGrSize; /*!< Write protect group size */ | |||
| __IO uint8_t WrProtectGrEnable; /*!< Write protect group enable */ | |||
| __IO uint8_t ManDeflECC; /*!< Manufacturer default ECC */ | |||
| __IO uint8_t WrSpeedFact; /*!< Write speed factor */ | |||
| __IO uint8_t MaxWrBlockLen; /*!< Max. write data block length */ | |||
| __IO uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */ | |||
| __IO uint8_t Reserved3; /*!< Reserved */ | |||
| __IO uint8_t ContentProtectAppli; /*!< Content protection application */ | |||
| __IO uint8_t FileFormatGrouop; /*!< File format group */ | |||
| __IO uint8_t CopyFlag; /*!< Copy flag (OTP) */ | |||
| __IO uint8_t PermWrProtect; /*!< Permanent write protection */ | |||
| __IO uint8_t TempWrProtect; /*!< Temporary write protection */ | |||
| __IO uint8_t FileFormat; /*!< File format */ | |||
| __IO uint8_t ECC; /*!< ECC code */ | |||
| __IO uint8_t CSD_CRC; /*!< CSD CRC */ | |||
| __IO uint8_t Reserved4; /*!< Always 1 */ | |||
| }HAL_SD_CSDTypedef; | |||
| /** | |||
| * @brief Card Identification Data: CID Register | |||
| */ | |||
| typedef struct | |||
| { | |||
| __IO uint8_t ManufacturerID; /*!< Manufacturer ID */ | |||
| __IO uint16_t OEM_AppliID; /*!< OEM/Application ID */ | |||
| __IO uint32_t ProdName1; /*!< Product Name part1 */ | |||
| __IO uint8_t ProdName2; /*!< Product Name part2 */ | |||
| __IO uint8_t ProdRev; /*!< Product Revision */ | |||
| __IO uint32_t ProdSN; /*!< Product Serial Number */ | |||
| __IO uint8_t Reserved1; /*!< Reserved1 */ | |||
| __IO uint16_t ManufactDate; /*!< Manufacturing Date */ | |||
| __IO uint8_t CID_CRC; /*!< CID CRC */ | |||
| __IO uint8_t Reserved2; /*!< Always 1 */ | |||
| }HAL_SD_CIDTypedef; | |||
| /** | |||
| * @brief SD Card Status returned by ACMD13 | |||
| */ | |||
| typedef struct | |||
| { | |||
| __IO uint8_t DAT_BUS_WIDTH; /*!< Shows the currently defined data bus width */ | |||
| __IO uint8_t SECURED_MODE; /*!< Card is in secured mode of operation */ | |||
| __IO uint16_t SD_CARD_TYPE; /*!< Carries information about card type */ | |||
| __IO uint32_t SIZE_OF_PROTECTED_AREA; /*!< Carries information about the capacity of protected area */ | |||
| __IO uint8_t SPEED_CLASS; /*!< Carries information about the speed class of the card */ | |||
| __IO uint8_t PERFORMANCE_MOVE; /*!< Carries information about the card's performance move */ | |||
| __IO uint8_t AU_SIZE; /*!< Carries information about the card's allocation unit size */ | |||
| __IO uint16_t ERASE_SIZE; /*!< Determines the number of AUs to be erased in one operation */ | |||
| __IO uint8_t ERASE_TIMEOUT; /*!< Determines the timeout for any number of AU erase */ | |||
| __IO uint8_t ERASE_OFFSET; /*!< Carries information about the erase offset */ | |||
| }HAL_SD_CardStatusTypedef; | |||
| /** | |||
| * @brief SD Card information structure | |||
| */ | |||
| typedef struct | |||
| { | |||
| HAL_SD_CSDTypedef SD_csd; /*!< SD card specific data register */ | |||
| HAL_SD_CIDTypedef SD_cid; /*!< SD card identification number register */ | |||
| uint64_t CardCapacity; /*!< Card capacity */ | |||
| uint32_t CardBlockSize; /*!< Card block size */ | |||
| uint16_t RCA; /*!< SD relative card address */ | |||
| uint8_t CardType; /*!< SD card type */ | |||
| }HAL_SD_CardInfoTypedef; | |||
| /** | |||
| * @brief SD Error status enumeration Structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| /** | |||
| * @brief SD specific error defines | |||
| */ | |||
| SD_CMD_CRC_FAIL = (1), /*!< Command response received (but CRC check failed) */ | |||
| SD_DATA_CRC_FAIL = (2), /*!< Data block sent/received (CRC check failed) */ | |||
| SD_CMD_RSP_TIMEOUT = (3), /*!< Command response timeout */ | |||
| SD_DATA_TIMEOUT = (4), /*!< Data timeout */ | |||
| SD_TX_UNDERRUN = (5), /*!< Transmit FIFO underrun */ | |||
| SD_RX_OVERRUN = (6), /*!< Receive FIFO overrun */ | |||
| SD_START_BIT_ERR = (7), /*!< Start bit not detected on all data signals in wide bus mode */ | |||
| SD_CMD_OUT_OF_RANGE = (8), /*!< Command's argument was out of range. */ | |||
| SD_ADDR_MISALIGNED = (9), /*!< Misaligned address */ | |||
| SD_BLOCK_LEN_ERR = (10), /*!< Transferred block length is not allowed for the card or the number of transferred bytes does not match the block length */ | |||
| SD_ERASE_SEQ_ERR = (11), /*!< An error in the sequence of erase command occurs. */ | |||
| SD_BAD_ERASE_PARAM = (12), /*!< An invalid selection for erase groups */ | |||
| SD_WRITE_PROT_VIOLATION = (13), /*!< Attempt to program a write protect block */ | |||
| SD_LOCK_UNLOCK_FAILED = (14), /*!< Sequence or password error has been detected in unlock command or if there was an attempt to access a locked card */ | |||
| SD_COM_CRC_FAILED = (15), /*!< CRC check of the previous command failed */ | |||
| SD_ILLEGAL_CMD = (16), /*!< Command is not legal for the card state */ | |||
| SD_CARD_ECC_FAILED = (17), /*!< Card internal ECC was applied but failed to correct the data */ | |||
| SD_CC_ERROR = (18), /*!< Internal card controller error */ | |||
| SD_GENERAL_UNKNOWN_ERROR = (19), /*!< General or unknown error */ | |||
| SD_STREAM_READ_UNDERRUN = (20), /*!< The card could not sustain data transfer in stream read operation. */ | |||
| SD_STREAM_WRITE_OVERRUN = (21), /*!< The card could not sustain data programming in stream mode */ | |||
| SD_CID_CSD_OVERWRITE = (22), /*!< CID/CSD overwrite error */ | |||
| SD_WP_ERASE_SKIP = (23), /*!< Only partial address space was erased */ | |||
| SD_CARD_ECC_DISABLED = (24), /*!< Command has been executed without using internal ECC */ | |||
| SD_ERASE_RESET = (25), /*!< Erase sequence was cleared before executing because an out of erase sequence command was received */ | |||
| SD_AKE_SEQ_ERROR = (26), /*!< Error in sequence of authentication. */ | |||
| SD_INVALID_VOLTRANGE = (27), | |||
| SD_ADDR_OUT_OF_RANGE = (28), | |||
| SD_SWITCH_ERROR = (29), | |||
| SD_SDIO_DISABLED = (30), | |||
| SD_SDIO_FUNCTION_BUSY = (31), | |||
| SD_SDIO_FUNCTION_FAILED = (32), | |||
| SD_SDIO_UNKNOWN_FUNCTION = (33), | |||
| /** | |||
| * @brief Standard error defines | |||
| */ | |||
| SD_INTERNAL_ERROR = (34), | |||
| SD_NOT_CONFIGURED = (35), | |||
| SD_REQUEST_PENDING = (36), | |||
| SD_REQUEST_NOT_APPLICABLE = (37), | |||
| SD_INVALID_PARAMETER = (38), | |||
| SD_UNSUPPORTED_FEATURE = (39), | |||
| SD_UNSUPPORTED_HW = (40), | |||
| SD_ERROR = (41), | |||
| SD_OK = (0) | |||
| }HAL_SD_ErrorTypedef; | |||
| /** | |||
| * @brief SD Transfer state enumeration structure | |||
| */ | |||
| typedef enum | |||
| { | |||
| SD_TRANSFER_OK = 0, /*!< Transfer success */ | |||
| SD_TRANSFER_BUSY = 1, /*!< Transfer is occurring */ | |||
| SD_TRANSFER_ERROR = 2 /*!< Transfer failed */ | |||
| }HAL_SD_TransferStateTypedef; | |||
| /** | |||
| * @brief SD Card State enumeration structure | |||
| */ | |||
| typedef enum | |||
| { | |||
| SD_CARD_READY = ((uint32_t)0x00000001), /*!< Card state is ready */ | |||
| SD_CARD_IDENTIFICATION = ((uint32_t)0x00000002), /*!< Card is in identification state */ | |||
| SD_CARD_STANDBY = ((uint32_t)0x00000003), /*!< Card is in standby state */ | |||
| SD_CARD_TRANSFER = ((uint32_t)0x00000004), /*!< Card is in transfer state */ | |||
| SD_CARD_SENDING = ((uint32_t)0x00000005), /*!< Card is sending an operation */ | |||
| SD_CARD_RECEIVING = ((uint32_t)0x00000006), /*!< Card is receiving operation information */ | |||
| SD_CARD_PROGRAMMING = ((uint32_t)0x00000007), /*!< Card is in programming state */ | |||
| SD_CARD_DISCONNECTED = ((uint32_t)0x00000008), /*!< Card is disconnected */ | |||
| SD_CARD_ERROR = ((uint32_t)0x000000FF) /*!< Card is in error state */ | |||
| }HAL_SD_CardStateTypedef; | |||
| /** | |||
| * @brief SD Operation enumeration structure | |||
| */ | |||
| typedef enum | |||
| { | |||
| SD_READ_SINGLE_BLOCK = 0, /*!< Read single block operation */ | |||
| SD_READ_MULTIPLE_BLOCK = 1, /*!< Read multiple blocks operation */ | |||
| SD_WRITE_SINGLE_BLOCK = 2, /*!< Write single block operation */ | |||
| SD_WRITE_MULTIPLE_BLOCK = 3 /*!< Write multiple blocks operation */ | |||
| }HAL_SD_OperationTypedef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup SD_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief SD Commands Index | |||
| */ | |||
| #define SD_CMD_GO_IDLE_STATE ((uint8_t)0) /*!< Resets the SD memory card. */ | |||
| #define SD_CMD_SEND_OP_COND ((uint8_t)1) /*!< Sends host capacity support information and activates the card's initialization process. */ | |||
| #define SD_CMD_ALL_SEND_CID ((uint8_t)2) /*!< Asks any card connected to the host to send the CID numbers on the CMD line. */ | |||
| #define SD_CMD_SET_REL_ADDR ((uint8_t)3) /*!< Asks the card to publish a new relative address (RCA). */ | |||
| #define SD_CMD_SET_DSR ((uint8_t)4) /*!< Programs the DSR of all cards. */ | |||
| #define SD_CMD_SDIO_SEN_OP_COND ((uint8_t)5) /*!< Sends host capacity support information (HCS) and asks the accessed card to send its | |||
| operating condition register (OCR) content in the response on the CMD line. */ | |||
| #define SD_CMD_HS_SWITCH ((uint8_t)6) /*!< Checks switchable function (mode 0) and switch card function (mode 1). */ | |||
| #define SD_CMD_SEL_DESEL_CARD ((uint8_t)7) /*!< Selects the card by its own relative address and gets deselected by any other address */ | |||
| #define SD_CMD_HS_SEND_EXT_CSD ((uint8_t)8) /*!< Sends SD Memory Card interface condition, which includes host supply voltage information | |||
| and asks the card whether card supports voltage. */ | |||
| #define SD_CMD_SEND_CSD ((uint8_t)9) /*!< Addressed card sends its card specific data (CSD) on the CMD line. */ | |||
| #define SD_CMD_SEND_CID ((uint8_t)10) /*!< Addressed card sends its card identification (CID) on the CMD line. */ | |||
| #define SD_CMD_READ_DAT_UNTIL_STOP ((uint8_t)11) /*!< SD card doesn't support it. */ | |||
| #define SD_CMD_STOP_TRANSMISSION ((uint8_t)12) /*!< Forces the card to stop transmission. */ | |||
| #define SD_CMD_SEND_STATUS ((uint8_t)13) /*!< Addressed card sends its status register. */ | |||
| #define SD_CMD_HS_BUSTEST_READ ((uint8_t)14) | |||
| #define SD_CMD_GO_INACTIVE_STATE ((uint8_t)15) /*!< Sends an addressed card into the inactive state. */ | |||
| #define SD_CMD_SET_BLOCKLEN ((uint8_t)16) /*!< Sets the block length (in bytes for SDSC) for all following block commands | |||
| (read, write, lock). Default block length is fixed to 512 Bytes. Not effective | |||
| for SDHS and SDXC. */ | |||
| #define SD_CMD_READ_SINGLE_BLOCK ((uint8_t)17) /*!< Reads single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of | |||
| fixed 512 bytes in case of SDHC and SDXC. */ | |||
| #define SD_CMD_READ_MULT_BLOCK ((uint8_t)18) /*!< Continuously transfers data blocks from card to host until interrupted by | |||
| STOP_TRANSMISSION command. */ | |||
| #define SD_CMD_HS_BUSTEST_WRITE ((uint8_t)19) /*!< 64 bytes tuning pattern is sent for SDR50 and SDR104. */ | |||
| #define SD_CMD_WRITE_DAT_UNTIL_STOP ((uint8_t)20) /*!< Speed class control command. */ | |||
| #define SD_CMD_SET_BLOCK_COUNT ((uint8_t)23) /*!< Specify block count for CMD18 and CMD25. */ | |||
| #define SD_CMD_WRITE_SINGLE_BLOCK ((uint8_t)24) /*!< Writes single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of | |||
| fixed 512 bytes in case of SDHC and SDXC. */ | |||
| #define SD_CMD_WRITE_MULT_BLOCK ((uint8_t)25) /*!< Continuously writes blocks of data until a STOP_TRANSMISSION follows. */ | |||
| #define SD_CMD_PROG_CID ((uint8_t)26) /*!< Reserved for manufacturers. */ | |||
| #define SD_CMD_PROG_CSD ((uint8_t)27) /*!< Programming of the programmable bits of the CSD. */ | |||
| #define SD_CMD_SET_WRITE_PROT ((uint8_t)28) /*!< Sets the write protection bit of the addressed group. */ | |||
| #define SD_CMD_CLR_WRITE_PROT ((uint8_t)29) /*!< Clears the write protection bit of the addressed group. */ | |||
| #define SD_CMD_SEND_WRITE_PROT ((uint8_t)30) /*!< Asks the card to send the status of the write protection bits. */ | |||
| #define SD_CMD_SD_ERASE_GRP_START ((uint8_t)32) /*!< Sets the address of the first write block to be erased. (For SD card only). */ | |||
| #define SD_CMD_SD_ERASE_GRP_END ((uint8_t)33) /*!< Sets the address of the last write block of the continuous range to be erased. */ | |||
| #define SD_CMD_ERASE_GRP_START ((uint8_t)35) /*!< Sets the address of the first write block to be erased. Reserved for each command | |||
| system set by switch function command (CMD6). */ | |||
| #define SD_CMD_ERASE_GRP_END ((uint8_t)36) /*!< Sets the address of the last write block of the continuous range to be erased. | |||
| Reserved for each command system set by switch function command (CMD6). */ | |||
| #define SD_CMD_ERASE ((uint8_t)38) /*!< Reserved for SD security applications. */ | |||
| #define SD_CMD_FAST_IO ((uint8_t)39) /*!< SD card doesn't support it (Reserved). */ | |||
| #define SD_CMD_GO_IRQ_STATE ((uint8_t)40) /*!< SD card doesn't support it (Reserved). */ | |||
| #define SD_CMD_LOCK_UNLOCK ((uint8_t)42) /*!< Sets/resets the password or lock/unlock the card. The size of the data block is set by | |||
| the SET_BLOCK_LEN command. */ | |||
| #define SD_CMD_APP_CMD ((uint8_t)55) /*!< Indicates to the card that the next command is an application specific command rather | |||
| than a standard command. */ | |||
| #define SD_CMD_GEN_CMD ((uint8_t)56) /*!< Used either to transfer a data block to the card or to get a data block from the card | |||
| for general purpose/application specific commands. */ | |||
| #define SD_CMD_NO_CMD ((uint8_t)64) | |||
| /** | |||
| * @brief Following commands are SD Card Specific commands. | |||
| * SDIO_APP_CMD should be sent before sending these commands. | |||
| */ | |||
| #define SD_CMD_APP_SD_SET_BUSWIDTH ((uint8_t)6) /*!< (ACMD6) Defines the data bus width to be used for data transfer. The allowed data bus | |||
| widths are given in SCR register. */ | |||
| #define SD_CMD_SD_APP_STAUS ((uint8_t)13) /*!< (ACMD13) Sends the SD status. */ | |||
| #define SD_CMD_SD_APP_SEND_NUM_WRITE_BLOCKS ((uint8_t)22) /*!< (ACMD22) Sends the number of the written (without errors) write blocks. Responds with | |||
| 32bit+CRC data block. */ | |||
| #define SD_CMD_SD_APP_OP_COND ((uint8_t)41) /*!< (ACMD41) Sends host capacity support information (HCS) and asks the accessed card to | |||
| send its operating condition register (OCR) content in the response on the CMD line. */ | |||
| #define SD_CMD_SD_APP_SET_CLR_CARD_DETECT ((uint8_t)42) /*!< (ACMD42) Connects/Disconnects the 50 KOhm pull-up resistor on CD/DAT3 (pin 1) of the card. */ | |||
| #define SD_CMD_SD_APP_SEND_SCR ((uint8_t)51) /*!< Reads the SD Configuration Register (SCR). */ | |||
| #define SD_CMD_SDIO_RW_DIRECT ((uint8_t)52) /*!< For SD I/O card only, reserved for security specification. */ | |||
| #define SD_CMD_SDIO_RW_EXTENDED ((uint8_t)53) /*!< For SD I/O card only, reserved for security specification. */ | |||
| /** | |||
| * @brief Following commands are SD Card Specific security commands. | |||
| * SD_CMD_APP_CMD should be sent before sending these commands. | |||
| */ | |||
| #define SD_CMD_SD_APP_GET_MKB ((uint8_t)43) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_GET_MID ((uint8_t)44) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_SET_CER_RN1 ((uint8_t)45) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_GET_CER_RN2 ((uint8_t)46) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_SET_CER_RES2 ((uint8_t)47) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_GET_CER_RES1 ((uint8_t)48) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_SECURE_READ_MULTIPLE_BLOCK ((uint8_t)18) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_SECURE_WRITE_MULTIPLE_BLOCK ((uint8_t)25) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_SECURE_ERASE ((uint8_t)38) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_CHANGE_SECURE_AREA ((uint8_t)49) /*!< For SD card only */ | |||
| #define SD_CMD_SD_APP_SECURE_WRITE_MKB ((uint8_t)48) /*!< For SD card only */ | |||
| /** | |||
| * @brief Supported SD Memory Cards | |||
| */ | |||
| #define STD_CAPACITY_SD_CARD_V1_1 ((uint32_t)0x00000000) | |||
| #define STD_CAPACITY_SD_CARD_V2_0 ((uint32_t)0x00000001) | |||
| #define HIGH_CAPACITY_SD_CARD ((uint32_t)0x00000002) | |||
| #define MULTIMEDIA_CARD ((uint32_t)0x00000003) | |||
| #define SECURE_DIGITAL_IO_CARD ((uint32_t)0x00000004) | |||
| #define HIGH_SPEED_MULTIMEDIA_CARD ((uint32_t)0x00000005) | |||
| #define SECURE_DIGITAL_IO_COMBO_CARD ((uint32_t)0x00000006) | |||
| #define HIGH_CAPACITY_MMC_CARD ((uint32_t)0x00000007) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @defgroup SD_Exported_macros | |||
| * @brief macros to handle interrupts and specific clock configurations | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Enable the SD device. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SD_SDIO_ENABLE() __SDIO_ENABLE() | |||
| /** | |||
| * @brief Disable the SD device. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SD_SDIO_DISABLE() __SDIO_DISABLE() | |||
| /** | |||
| * @brief Enable the SDIO DMA transfer. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SD_SDIO_DMA_ENABLE() __SDIO_DMA_ENABLE() | |||
| /** | |||
| * @brief Disable the SDIO DMA transfer. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SD_SDIO_DMA_DISABLE() __SDIO_DMA_DISABLE() | |||
| /** | |||
| * @brief Enable the SD device interrupt. | |||
| * @param __HANDLE__: SD Handle | |||
| * @param __INTERRUPT__: specifies the SDIO interrupt sources to be enabled. | |||
| * This parameter can be one or a combination of the following values: | |||
| * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt | |||
| * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt | |||
| * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt | |||
| * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt | |||
| * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt | |||
| * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt | |||
| * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide | |||
| * bus mode interrupt | |||
| * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt | |||
| * @arg SDIO_IT_TXACT: Data transmit in progress interrupt | |||
| * @arg SDIO_IT_RXACT: Data receive in progress interrupt | |||
| * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt | |||
| * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt | |||
| * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt | |||
| * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt | |||
| * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt | |||
| * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt | |||
| * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt | |||
| * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt | |||
| * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt | |||
| * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SD_SDIO_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the SD device interrupt. | |||
| * @param __HANDLE__: SD Handle | |||
| * @param __INTERRUPT__: specifies the SDIO interrupt sources to be disabled. | |||
| * This parameter can be one or a combination of the following values: | |||
| * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt | |||
| * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt | |||
| * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt | |||
| * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt | |||
| * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt | |||
| * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt | |||
| * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide | |||
| * bus mode interrupt | |||
| * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt | |||
| * @arg SDIO_IT_TXACT: Data transmit in progress interrupt | |||
| * @arg SDIO_IT_RXACT: Data receive in progress interrupt | |||
| * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt | |||
| * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt | |||
| * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt | |||
| * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt | |||
| * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt | |||
| * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt | |||
| * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt | |||
| * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt | |||
| * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt | |||
| * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SD_SDIO_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) | |||
| /** | |||
| * @brief Check whether the specified SD flag is set or not. | |||
| * @param __HANDLE__: SD Handle | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) | |||
| * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) | |||
| * @arg SDIO_FLAG_CTIMEOUT: Command response timeout | |||
| * @arg SDIO_FLAG_DTIMEOUT: Data timeout | |||
| * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error | |||
| * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error | |||
| * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) | |||
| * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) | |||
| * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero) | |||
| * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide bus mode. | |||
| * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) | |||
| * @arg SDIO_FLAG_CMDACT: Command transfer in progress | |||
| * @arg SDIO_FLAG_TXACT: Data transmit in progress | |||
| * @arg SDIO_FLAG_RXACT: Data receive in progress | |||
| * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty | |||
| * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full | |||
| * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full | |||
| * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full | |||
| * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty | |||
| * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty | |||
| * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO | |||
| * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO | |||
| * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received | |||
| * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61 | |||
| * @retval The new state of SD FLAG (SET or RESET). | |||
| */ | |||
| #define __HAL_SD_SDIO_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__)) | |||
| /** | |||
| * @brief Clear the SD's pending flags. | |||
| * @param __HANDLE__: SD Handle | |||
| * @param __FLAG__: specifies the flag to clear. | |||
| * This parameter can be one or a combination of the following values: | |||
| * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) | |||
| * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) | |||
| * @arg SDIO_FLAG_CTIMEOUT: Command response timeout | |||
| * @arg SDIO_FLAG_DTIMEOUT: Data timeout | |||
| * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error | |||
| * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error | |||
| * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) | |||
| * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) | |||
| * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero) | |||
| * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide bus mode | |||
| * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) | |||
| * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received | |||
| * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61 | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SD_SDIO_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__)) | |||
| /** | |||
| * @brief Check whether the specified SD interrupt has occurred or not. | |||
| * @param __HANDLE__: SD Handle | |||
| * @param __INTERRUPT__: specifies the SDIO interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt | |||
| * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt | |||
| * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt | |||
| * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt | |||
| * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt | |||
| * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt | |||
| * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide | |||
| * bus mode interrupt | |||
| * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt | |||
| * @arg SDIO_IT_TXACT: Data transmit in progress interrupt | |||
| * @arg SDIO_IT_RXACT: Data receive in progress interrupt | |||
| * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt | |||
| * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt | |||
| * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt | |||
| * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt | |||
| * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt | |||
| * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt | |||
| * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt | |||
| * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt | |||
| * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt | |||
| * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt | |||
| * @retval The new state of SD IT (SET or RESET). | |||
| */ | |||
| #define __HAL_SD_SDIO_GET_IT (__HANDLE__, __INTERRUPT__) __SDIO_GET_IT ((__HANDLE__)->Instance, __INTERRUPT__) | |||
| /** | |||
| * @brief Clear the SD's interrupt pending bits. | |||
| * @param __HANDLE__ : SD Handle | |||
| * @param __INTERRUPT__: specifies the interrupt pending bit to clear. | |||
| * This parameter can be one or a combination of the following values: | |||
| * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt | |||
| * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt | |||
| * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt | |||
| * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt | |||
| * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt | |||
| * @arg SDIO_IT_DATAEND: Data end (data counter, SDIO_DCOUNT, is zero) interrupt | |||
| * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide | |||
| * bus mode interrupt | |||
| * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt | |||
| * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SD_SDIO_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /** @addtogroup SD_Exported_Functions | |||
| * @{ | |||
| */ | |||
| /* Initialization/de-initialization functions ********************************/ | |||
| /** @addtogroup SD_Group1 | |||
| * @{ | |||
| */ | |||
| HAL_SD_ErrorTypedef HAL_SD_Init(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypedef *SDCardInfo); | |||
| HAL_StatusTypeDef HAL_SD_DeInit (SD_HandleTypeDef *hsd); | |||
| void HAL_SD_MspInit(SD_HandleTypeDef *hsd); | |||
| void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd); | |||
| /** | |||
| * @} | |||
| */ | |||
| /* I/O operation functions ***************************************************/ | |||
| /** @addtogroup SD_Group2 | |||
| * @{ | |||
| */ | |||
| /* Blocking mode: Polling */ | |||
| HAL_SD_ErrorTypedef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint32_t *pReadBuffer, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks); | |||
| HAL_SD_ErrorTypedef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint32_t *pWriteBuffer, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumberOfBlocks); | |||
| HAL_SD_ErrorTypedef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint64_t startaddr, uint64_t endaddr); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd); | |||
| /* Callback in non blocking modes (DMA) */ | |||
| void HAL_SD_DMA_RxCpltCallback(DMA_HandleTypeDef *hdma); | |||
| void HAL_SD_DMA_RxErrorCallback(DMA_HandleTypeDef *hdma); | |||
| void HAL_SD_DMA_TxCpltCallback(DMA_HandleTypeDef *hdma); | |||
| void HAL_SD_DMA_TxErrorCallback(DMA_HandleTypeDef *hdma); | |||
| void HAL_SD_XferCpltCallback(SD_HandleTypeDef *hsd); | |||
| void HAL_SD_XferErrorCallback(SD_HandleTypeDef *hsd); | |||
| /* Non-Blocking mode: DMA */ | |||
| HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pReadBuffer, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks); | |||
| HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWriteBuffer, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumberOfBlocks); | |||
| HAL_SD_ErrorTypedef HAL_SD_CheckWriteOperation(SD_HandleTypeDef *hsd, uint32_t Timeout); | |||
| HAL_SD_ErrorTypedef HAL_SD_CheckReadOperation(SD_HandleTypeDef *hsd, uint32_t Timeout); | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Peripheral Control functions **********************************************/ | |||
| /** @addtogroup SD_Group3 | |||
| * @{ | |||
| */ | |||
| HAL_SD_ErrorTypedef HAL_SD_Get_CardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypedef *pCardInfo); | |||
| HAL_SD_ErrorTypedef HAL_SD_WideBusOperation_Config(SD_HandleTypeDef *hsd, uint32_t WideMode); | |||
| HAL_SD_ErrorTypedef HAL_SD_StopTransfer(SD_HandleTypeDef *hsd); | |||
| HAL_SD_ErrorTypedef HAL_SD_HighSpeed (SD_HandleTypeDef *hsd); | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Peripheral State functions ************************************************/ | |||
| /** @addtogroup SD_Group4 | |||
| * @{ | |||
| */ | |||
| HAL_SD_ErrorTypedef HAL_SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus); | |||
| HAL_SD_ErrorTypedef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypedef *pCardStatus); | |||
| HAL_SD_TransferStateTypedef HAL_SD_GetStatus(SD_HandleTypeDef *hsd); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_SD_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,151 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_sdram.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of SDRAM HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_SDRAM_H | |||
| #define __STM32F4xx_HAL_SDRAM_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_ll_fmc.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup SDRAM | |||
| * @{ | |||
| */ | |||
| /* Exported typedef ----------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL SDRAM State structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_SDRAM_STATE_RESET = 0x00, /*!< SDRAM not yet initialized or disabled */ | |||
| HAL_SDRAM_STATE_READY = 0x01, /*!< SDRAM initialized and ready for use */ | |||
| HAL_SDRAM_STATE_BUSY = 0x02, /*!< SDRAM internal process is ongoing */ | |||
| HAL_SDRAM_STATE_ERROR = 0x03, /*!< SDRAM error state */ | |||
| HAL_SDRAM_STATE_WRITE_PROTECTED = 0x04, /*!< SDRAM device write protected */ | |||
| HAL_SDRAM_STATE_PRECHARGED = 0x05 /*!< SDRAM device precharged */ | |||
| }HAL_SDRAM_StateTypeDef; | |||
| /** | |||
| * @brief SDRAM handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| FMC_SDRAM_TypeDef *Instance; /*!< Register base address */ | |||
| FMC_SDRAM_InitTypeDef Init; /*!< SDRAM device configuration parameters */ | |||
| __IO HAL_SDRAM_StateTypeDef State; /*!< SDRAM access state */ | |||
| HAL_LockTypeDef Lock; /*!< SDRAM locking object */ | |||
| DMA_HandleTypeDef *hdma; /*!< Pointer DMA handler */ | |||
| }SDRAM_HandleTypeDef; | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset SDRAM handle state | |||
| * @param __HANDLE__: specifies the SDRAM handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SDRAM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SDRAM_STATE_RESET) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_SDRAM_Init(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_TimingTypeDef *Timing); | |||
| HAL_StatusTypeDef HAL_SDRAM_DeInit(SDRAM_HandleTypeDef *hsdram); | |||
| void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram); | |||
| void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram); | |||
| void HAL_SDRAM_IRQHandler(SDRAM_HandleTypeDef *hsdram); | |||
| void HAL_SDRAM_RefreshErrorCallback(SDRAM_HandleTypeDef *hsdram); | |||
| void HAL_SDRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma); | |||
| void HAL_SDRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma); | |||
| /* I/O operation functions *****************************************************/ | |||
| HAL_StatusTypeDef HAL_SDRAM_Read_8b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint8_t *pDstBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SDRAM_Write_8b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint8_t *pSrcBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SDRAM_Read_16b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint16_t *pDstBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SDRAM_Write_16b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint16_t *pSrcBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SDRAM_Read_32b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SDRAM_Write_32b(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SDRAM_Read_DMA(SDRAM_HandleTypeDef *hsdram, uint32_t * pAddress, uint32_t *pDstBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SDRAM_Write_DMA(SDRAM_HandleTypeDef *hsdram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize); | |||
| /* SDRAM Control functions *****************************************************/ | |||
| HAL_StatusTypeDef HAL_SDRAM_WriteProtection_Enable(SDRAM_HandleTypeDef *hsdram); | |||
| HAL_StatusTypeDef HAL_SDRAM_WriteProtection_Disable(SDRAM_HandleTypeDef *hsdram); | |||
| HAL_StatusTypeDef HAL_SDRAM_SendCommand(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_SDRAM_ProgramRefreshRate(SDRAM_HandleTypeDef *hsdram, uint32_t RefreshRate); | |||
| HAL_StatusTypeDef HAL_SDRAM_SetAutoRefreshNumber(SDRAM_HandleTypeDef *hsdram, uint32_t AutoRefreshNumber); | |||
| uint32_t HAL_SDRAM_GetModeStatus(SDRAM_HandleTypeDef *hsdram); | |||
| /* SDRAM State functions ********************************************************/ | |||
| HAL_SDRAM_StateTypeDef HAL_SDRAM_GetState(SDRAM_HandleTypeDef *hsdram); | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_SDRAM_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,493 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_smartcard.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of SMARTCARD HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_SMARTCARD_H | |||
| #define __STM32F4xx_HAL_SMARTCARD_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup SMARTCARD | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief SMARTCARD Init Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t BaudRate; /*!< This member configures the SmartCard communication baud rate. | |||
| The baud rate is computed using the following formula: | |||
| - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate))) | |||
| - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ | |||
| uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. | |||
| This parameter can be a value of @ref SMARTCARD_Word_Length */ | |||
| uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. | |||
| This parameter can be a value of @ref SMARTCARD_Stop_Bits */ | |||
| uint32_t Parity; /*!< Specifies the parity mode. | |||
| This parameter can be a value of @ref SMARTCARD_Parity | |||
| @note When parity is enabled, the computed parity is inserted | |||
| at the MSB position of the transmitted data (9th bit when | |||
| the word length is set to 9 data bits; 8th bit when the | |||
| word length is set to 8 data bits).*/ | |||
| uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. | |||
| This parameter can be a value of @ref SMARTCARD_Mode */ | |||
| uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. | |||
| This parameter can be a value of @ref SMARTCARD_Clock_Polarity */ | |||
| uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. | |||
| This parameter can be a value of @ref SMARTCARD_Clock_Phase */ | |||
| uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted | |||
| data bit (MSB) has to be output on the SCLK pin in synchronous mode. | |||
| This parameter can be a value of @ref SMARTCARD_Last_Bit */ | |||
| uint32_t Prescaler; /*!< Specifies the SmartCard Prescaler. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 255 */ | |||
| uint32_t GuardTime; /*!< Specifies the SmartCard Guard Time. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 255 */ | |||
| uint32_t NACKState; /*!< Specifies the SmartCard NACK Transmission state. | |||
| This parameter can be a value of @ref SmartCard_NACK_State */ | |||
| }SMARTCARD_InitTypeDef; | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_SMARTCARD_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ | |||
| HAL_SMARTCARD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ | |||
| HAL_SMARTCARD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ | |||
| HAL_SMARTCARD_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ | |||
| HAL_SMARTCARD_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ | |||
| HAL_SMARTCARD_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ | |||
| HAL_SMARTCARD_STATE_TIMEOUT = 0x03, /*!< Timeout state */ | |||
| HAL_SMARTCARD_STATE_ERROR = 0x04 /*!< Error */ | |||
| }HAL_SMARTCARD_StateTypeDef; | |||
| /** | |||
| * @brief HAL SMARTCARD Error Code structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_SMARTCARD_ERROR_NONE = 0x00, /*!< No error */ | |||
| HAL_SMARTCARD_ERROR_PE = 0x01, /*!< Parity error */ | |||
| HAL_SMARTCARD_ERROR_NE = 0x02, /*!< Noise error */ | |||
| HAL_SMARTCARD_ERROR_FE = 0x04, /*!< frame error */ | |||
| HAL_SMARTCARD_ERROR_ORE = 0x08, /*!< Overrun error */ | |||
| HAL_SMARTCARD_ERROR_DMA = 0x10 /*!< DMA transfer error */ | |||
| }HAL_SMARTCARD_ErrorTypeDef; | |||
| /** | |||
| * @brief SMARTCARD handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| USART_TypeDef *Instance; /* USART registers base address */ | |||
| SMARTCARD_InitTypeDef Init; /* SmartCard communication parameters */ | |||
| uint8_t *pTxBuffPtr; /* Pointer to SmartCard Tx transfer Buffer */ | |||
| uint16_t TxXferSize; /* SmartCard Tx Transfer size */ | |||
| uint16_t TxXferCount; /* SmartCard Tx Transfer Counter */ | |||
| uint8_t *pRxBuffPtr; /* Pointer to SmartCard Rx transfer Buffer */ | |||
| uint16_t RxXferSize; /* SmartCard Rx Transfer size */ | |||
| uint16_t RxXferCount; /* SmartCard Rx Transfer Counter */ | |||
| DMA_HandleTypeDef *hdmatx; /* SmartCard Tx DMA Handle parameters */ | |||
| DMA_HandleTypeDef *hdmarx; /* SmartCard Rx DMA Handle parameters */ | |||
| HAL_LockTypeDef Lock; /* Locking object */ | |||
| __IO HAL_SMARTCARD_StateTypeDef State; /* SmartCard communication state */ | |||
| __IO HAL_SMARTCARD_ErrorTypeDef ErrorCode; /* SMARTCARD Error code */ | |||
| }SMARTCARD_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup SMARTCARD_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup SMARTCARD_Word_Length | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_WORDLENGTH_8B ((uint32_t)0x00000000) | |||
| #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M) | |||
| #define IS_SMARTCARD_WORD_LENGTH(LENGTH) (((LENGTH) == SMARTCARD_WORDLENGTH_8B) || \ | |||
| ((LENGTH) == SMARTCARD_WORDLENGTH_9B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SMARTCARD_Stop_Bits | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_STOPBITS_1 ((uint32_t)0x00000000) | |||
| #define SMARTCARD_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) | |||
| #define SMARTCARD_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) | |||
| #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) | |||
| #define IS_SMARTCARD_STOPBITS(STOPBITS) (((STOPBITS) == SMARTCARD_STOPBITS_1) || \ | |||
| ((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \ | |||
| ((STOPBITS) == SMARTCARD_STOPBITS_1_5) || \ | |||
| ((STOPBITS) == SMARTCARD_STOPBITS_2)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SMARTCARD_Parity | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_PARITY_NONE ((uint32_t)0x00000000) | |||
| #define SMARTCARD_PARITY_EVEN ((uint32_t)USART_CR1_PCE) | |||
| #define SMARTCARD_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) | |||
| #define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_NONE) || \ | |||
| ((PARITY) == SMARTCARD_PARITY_EVEN) || \ | |||
| ((PARITY) == SMARTCARD_PARITY_ODD)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SMARTCARD_Mode | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_MODE_RX ((uint32_t)USART_CR1_RE) | |||
| #define SMARTCARD_MODE_TX ((uint32_t)USART_CR1_TE) | |||
| #define SMARTCARD_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) | |||
| #define IS_SMARTCARD_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3) == 0x00) && ((MODE) != (uint32_t)0x000000)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SMARTCARD_Clock_Polarity | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_POLARITY_LOW ((uint32_t)0x00000000) | |||
| #define SMARTCARD_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) | |||
| #define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SMARTCARD_Clock_Phase | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_PHASE_1EDGE ((uint32_t)0x00000000) | |||
| #define SMARTCARD_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) | |||
| #define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SMARTCARD_Last_Bit | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_LASTBIT_DISABLE ((uint32_t)0x00000000) | |||
| #define SMARTCARD_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) | |||
| #define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \ | |||
| ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SmartCard_NACK_State | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_NACK_ENABLED ((uint32_t)USART_CR3_NACK) | |||
| #define SMARTCARD_NACK_DISABLED ((uint32_t)0x00000000) | |||
| #define IS_SMARTCARD_NACK_STATE(NACK) (((NACK) == SMARTCARD_NACK_ENABLED) || \ | |||
| ((NACK) == SMARTCARD_NACK_DISABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SmartCard_DMA_Requests | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_DMAREQ_TX ((uint32_t)USART_CR3_DMAT) | |||
| #define SMARTCARD_DMAREQ_RX ((uint32_t)USART_CR3_DMAR) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SmartCard_Flags | |||
| * Elements values convention: 0xXXXX | |||
| * - 0xXXXX : Flag mask in the SR register | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_FLAG_TXE ((uint32_t)0x00000080) | |||
| #define SMARTCARD_FLAG_TC ((uint32_t)0x00000040) | |||
| #define SMARTCARD_FLAG_RXNE ((uint32_t)0x00000020) | |||
| #define SMARTCARD_FLAG_IDLE ((uint32_t)0x00000010) | |||
| #define SMARTCARD_FLAG_ORE ((uint32_t)0x00000008) | |||
| #define SMARTCARD_FLAG_NE ((uint32_t)0x00000004) | |||
| #define SMARTCARD_FLAG_FE ((uint32_t)0x00000002) | |||
| #define SMARTCARD_FLAG_PE ((uint32_t)0x00000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SmartCard_Interrupt_definition | |||
| * Elements values convention: 0xY000XXXX | |||
| * - XXXX : Interrupt mask in the XX register | |||
| * - Y : Interrupt source register (2bits) | |||
| * - 01: CR1 register | |||
| * - 10: CR3 register | |||
| * | |||
| * @{ | |||
| */ | |||
| #define SMARTCARD_IT_PE ((uint32_t)0x10000100) | |||
| #define SMARTCARD_IT_TXE ((uint32_t)0x10000080) | |||
| #define SMARTCARD_IT_TC ((uint32_t)0x10000040) | |||
| #define SMARTCARD_IT_RXNE ((uint32_t)0x10000020) | |||
| #define SMARTCARD_IT_IDLE ((uint32_t)0x10000010) | |||
| #define SMARTCARD_IT_ERR ((uint32_t)0x20000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset SMARTCARD handle state | |||
| * @param __HANDLE__: specifies the SMARTCARD Handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SMARTCARD_STATE_RESET) | |||
| /** @brief Flushs the Smartcard DR register | |||
| * @param __HANDLE__: specifies the SMARTCARD Handle. | |||
| */ | |||
| #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) | |||
| /** @brief Checks whether the specified Smartcard flag is set or not. | |||
| * @param __HANDLE__: specifies the SMARTCARD Handle. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag | |||
| * @arg SMARTCARD_FLAG_TC: Transmission Complete flag | |||
| * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag | |||
| * @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag | |||
| * @arg SMARTCARD_FLAG_ORE: OverRun Error flag | |||
| * @arg SMARTCARD_FLAG_NE: Noise Error flag | |||
| * @arg SMARTCARD_FLAG_FE: Framing Error flag | |||
| * @arg SMARTCARD_FLAG_PE: Parity Error flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clears the specified Smartcard pending flags. | |||
| * @param __HANDLE__: specifies the SMARTCARD Handle. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg SMARTCARD_FLAG_TC: Transmission Complete flag. | |||
| * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag. | |||
| * | |||
| * @note PE (Parity error), FE (Framing error), NE (Noise error) and ORE (OverRun | |||
| * error) flags are cleared by software sequence: a read operation to | |||
| * USART_SR register followed by a read operation to USART_DR register. | |||
| * @note RXNE flag can be also cleared by a read to the USART_DR register. | |||
| * @note TC flag can be also cleared by software sequence: a read operation to | |||
| * USART_SR register followed by a write operation to USART_DR register. | |||
| * @note TXE flag is cleared only by a write to the USART_DR register. | |||
| */ | |||
| #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) | |||
| /** @brief Clear the SMARTCARD PE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\ | |||
| (__HANDLE__)->Instance->DR;}while(0) | |||
| /** @brief Clear the SMARTCARD FE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the SMARTCARD NE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the SMARTCARD ORE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the SMARTCARD IDLE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Enables or disables the specified SmartCard interrupts. | |||
| * @param __HANDLE__: specifies the SMARTCARD Handle. | |||
| * @param __INTERRUPT__: specifies the SMARTCARD interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt | |||
| * @arg SMARTCARD_IT_TC: Transmission complete interrupt | |||
| * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt | |||
| * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt | |||
| * @arg SMARTCARD_IT_PE: Parity Error interrupt | |||
| * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error) | |||
| */ | |||
| #define SMARTCARD_IT_MASK ((uint32_t)0x0000FFFF) | |||
| #define __SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)): \ | |||
| ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK))) | |||
| #define __SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & SMARTCARD_IT_MASK)): \ | |||
| ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK))) | |||
| /** @brief Checks whether the specified SmartCard interrupt has occurred or not. | |||
| * @param __HANDLE__: specifies the SmartCard Handle. | |||
| * @param __IT__: specifies the SMARTCARD interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt | |||
| * @arg SMARTCARD_IT_TC: Transmission complete interrupt | |||
| * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt | |||
| * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt | |||
| * @arg SMARTCARD_IT_ERR: Error interrupt | |||
| * @arg SMARTCARD_IT_PE: Parity Error interrupt | |||
| * @retval The new state of __IT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1: (__HANDLE__)->Instance->CR3) & (((uint32_t)(__IT__)) & SMARTCARD_IT_MASK)) | |||
| /** @brief Macros to enable or disable the SmartCard interface. | |||
| * @param __HANDLE__: specifies the SmartCard Handle. | |||
| */ | |||
| #define __SMARTCARD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) | |||
| #define __SMARTCARD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) | |||
| /** @brief Macros to enable or disable the SmartCard DMA request. | |||
| * @param __HANDLE__: specifies the SmartCard Handle. | |||
| * @param __REQUEST__: specifies the SmartCard DMA request. | |||
| * This parameter can be one of the following values: | |||
| * @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request | |||
| * @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request | |||
| */ | |||
| #define __SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 |= (__REQUEST__)) | |||
| #define __SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 &= ~(__REQUEST__)) | |||
| #define __DIV(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_))) | |||
| #define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_))/100) | |||
| #define __DIVFRAQ(_PCLK_, _BAUD_) (((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100) | |||
| #define __SMARTCARD_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4)|(__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F)) | |||
| #define IS_SMARTCARD_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc); | |||
| HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc); | |||
| HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc); | |||
| void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc); | |||
| void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc); | |||
| /* IO operation functions *******************************************************/ | |||
| HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size); | |||
| void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc); | |||
| void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc); | |||
| void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc); | |||
| void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc); | |||
| /* Peripheral State functions **************************************************/ | |||
| HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc); | |||
| uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_SMARTCARD_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,488 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_spi.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of SPI HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_SPI_H | |||
| #define __STM32F4xx_HAL_SPI_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup SPI | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief SPI Configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Mode; /*!< Specifies the SPI operating mode. | |||
| This parameter can be a value of @ref SPI_mode */ | |||
| uint32_t Direction; /*!< Specifies the SPI Directional mode state. | |||
| This parameter can be a value of @ref SPI_Direction_mode */ | |||
| uint32_t DataSize; /*!< Specifies the SPI data size. | |||
| This parameter can be a value of @ref SPI_data_size */ | |||
| uint32_t CLKPolarity; /*!< Specifies the serial clock steady state. | |||
| This parameter can be a value of @ref SPI_Clock_Polarity */ | |||
| uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture. | |||
| This parameter can be a value of @ref SPI_Clock_Phase */ | |||
| uint32_t NSS; /*!< Specifies whether the NSS signal is managed by | |||
| hardware (NSS pin) or by software using the SSI bit. | |||
| This parameter can be a value of @ref SPI_Slave_Select_management */ | |||
| uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be | |||
| used to configure the transmit and receive SCK clock. | |||
| This parameter can be a value of @ref SPI_BaudRate_Prescaler | |||
| @note The communication clock is derived from the master | |||
| clock. The slave clock does not need to be set */ | |||
| uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. | |||
| This parameter can be a value of @ref SPI_MSB_LSB_transmission */ | |||
| uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not. | |||
| This parameter can be a value of @ref SPI_TI_mode */ | |||
| uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. | |||
| This parameter can be a value of @ref SPI_CRC_Calculation */ | |||
| uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */ | |||
| }SPI_InitTypeDef; | |||
| /** | |||
| * @brief HAL SPI State structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_SPI_STATE_RESET = 0x00, /*!< SPI not yet initialized or disabled */ | |||
| HAL_SPI_STATE_READY = 0x01, /*!< SPI initialized and ready for use */ | |||
| HAL_SPI_STATE_BUSY = 0x02, /*!< SPI process is ongoing */ | |||
| HAL_SPI_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ | |||
| HAL_SPI_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ | |||
| HAL_SPI_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ | |||
| HAL_SPI_STATE_ERROR = 0x03 /*!< SPI error state */ | |||
| }HAL_SPI_StateTypeDef; | |||
| /** | |||
| * @brief HAL SPI Error Code structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_SPI_ERROR_NONE = 0x00, /*!< No error */ | |||
| HAL_SPI_ERROR_MODF = 0x01, /*!< MODF error */ | |||
| HAL_SPI_ERROR_CRC = 0x02, /*!< CRC error */ | |||
| HAL_SPI_ERROR_OVR = 0x04, /*!< OVR error */ | |||
| HAL_SPI_ERROR_FRE = 0x08, /*!< FRE error */ | |||
| HAL_SPI_ERROR_DMA = 0x10, /*!< DMA transfer error */ | |||
| HAL_SPI_ERROR_FLAG = 0x20 /*!< Flag: RXNE,TXE, BSY */ | |||
| }HAL_SPI_ErrorTypeDef; | |||
| /** | |||
| * @brief SPI handle Structure definition | |||
| */ | |||
| typedef struct __SPI_HandleTypeDef | |||
| { | |||
| SPI_TypeDef *Instance; /* SPI registers base address */ | |||
| SPI_InitTypeDef Init; /* SPI communication parameters */ | |||
| uint8_t *pTxBuffPtr; /* Pointer to SPI Tx transfer Buffer */ | |||
| uint16_t TxXferSize; /* SPI Tx transfer size */ | |||
| uint16_t TxXferCount; /* SPI Tx Transfer Counter */ | |||
| uint8_t *pRxBuffPtr; /* Pointer to SPI Rx transfer Buffer */ | |||
| uint16_t RxXferSize; /* SPI Rx transfer size */ | |||
| uint16_t RxXferCount; /* SPI Rx Transfer Counter */ | |||
| DMA_HandleTypeDef *hdmatx; /* SPI Tx DMA handle parameters */ | |||
| DMA_HandleTypeDef *hdmarx; /* SPI Rx DMA handle parameters */ | |||
| void (*RxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Rx ISR */ | |||
| void (*TxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Tx ISR */ | |||
| HAL_LockTypeDef Lock; /* SPI locking object */ | |||
| __IO HAL_SPI_StateTypeDef State; /* SPI communication state */ | |||
| __IO HAL_SPI_ErrorTypeDef ErrorCode; /* SPI Error code */ | |||
| }SPI_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup SPI_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup SPI_mode | |||
| * @{ | |||
| */ | |||
| #define SPI_MODE_SLAVE ((uint32_t)0x00000000) | |||
| #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) | |||
| #define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \ | |||
| ((MODE) == SPI_MODE_MASTER)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_Direction_mode | |||
| * @{ | |||
| */ | |||
| #define SPI_DIRECTION_2LINES ((uint32_t)0x00000000) | |||
| #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY | |||
| #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE | |||
| #define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ | |||
| ((MODE) == SPI_DIRECTION_2LINES_RXONLY) || \ | |||
| ((MODE) == SPI_DIRECTION_1LINE)) | |||
| #define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ | |||
| ((MODE) == SPI_DIRECTION_1LINE)) | |||
| #define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_data_size | |||
| * @{ | |||
| */ | |||
| #define SPI_DATASIZE_8BIT ((uint32_t)0x00000000) | |||
| #define SPI_DATASIZE_16BIT SPI_CR1_DFF | |||
| #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \ | |||
| ((DATASIZE) == SPI_DATASIZE_8BIT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_Clock_Polarity | |||
| * @{ | |||
| */ | |||
| #define SPI_POLARITY_LOW ((uint32_t)0x00000000) | |||
| #define SPI_POLARITY_HIGH SPI_CR1_CPOL | |||
| #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \ | |||
| ((CPOL) == SPI_POLARITY_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_Clock_Phase | |||
| * @{ | |||
| */ | |||
| #define SPI_PHASE_1EDGE ((uint32_t)0x00000000) | |||
| #define SPI_PHASE_2EDGE SPI_CR1_CPHA | |||
| #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \ | |||
| ((CPHA) == SPI_PHASE_2EDGE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_Slave_Select_management | |||
| * @{ | |||
| */ | |||
| #define SPI_NSS_SOFT SPI_CR1_SSM | |||
| #define SPI_NSS_HARD_INPUT ((uint32_t)0x00000000) | |||
| #define SPI_NSS_HARD_OUTPUT ((uint32_t)0x00040000) | |||
| #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT) || \ | |||
| ((NSS) == SPI_NSS_HARD_INPUT) || \ | |||
| ((NSS) == SPI_NSS_HARD_OUTPUT)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_BaudRate_Prescaler | |||
| * @{ | |||
| */ | |||
| #define SPI_BAUDRATEPRESCALER_2 ((uint32_t)0x00000000) | |||
| #define SPI_BAUDRATEPRESCALER_4 ((uint32_t)0x00000008) | |||
| #define SPI_BAUDRATEPRESCALER_8 ((uint32_t)0x00000010) | |||
| #define SPI_BAUDRATEPRESCALER_16 ((uint32_t)0x00000018) | |||
| #define SPI_BAUDRATEPRESCALER_32 ((uint32_t)0x00000020) | |||
| #define SPI_BAUDRATEPRESCALER_64 ((uint32_t)0x00000028) | |||
| #define SPI_BAUDRATEPRESCALER_128 ((uint32_t)0x00000030) | |||
| #define SPI_BAUDRATEPRESCALER_256 ((uint32_t)0x00000038) | |||
| #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \ | |||
| ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \ | |||
| ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \ | |||
| ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \ | |||
| ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \ | |||
| ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \ | |||
| ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \ | |||
| ((PRESCALER) == SPI_BAUDRATEPRESCALER_256)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_MSB_LSB_transmission | |||
| * @{ | |||
| */ | |||
| #define SPI_FIRSTBIT_MSB ((uint32_t)0x00000000) | |||
| #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST | |||
| #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \ | |||
| ((BIT) == SPI_FIRSTBIT_LSB)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_TI_mode | |||
| * @{ | |||
| */ | |||
| #define SPI_TIMODE_DISABLED ((uint32_t)0x00000000) | |||
| #define SPI_TIMODE_ENABLED SPI_CR2_FRF | |||
| #define IS_SPI_TIMODE(MODE) (((MODE) == SPI_TIMODE_DISABLED) || \ | |||
| ((MODE) == SPI_TIMODE_ENABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_CRC_Calculation | |||
| * @{ | |||
| */ | |||
| #define SPI_CRCCALCULATION_DISABLED ((uint32_t)0x00000000) | |||
| #define SPI_CRCCALCULATION_ENABLED SPI_CR1_CRCEN | |||
| #define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLED) || \ | |||
| ((CALCULATION) == SPI_CRCCALCULATION_ENABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_Interrupt_configuration_definition | |||
| * @{ | |||
| */ | |||
| #define SPI_IT_TXE SPI_CR2_TXEIE | |||
| #define SPI_IT_RXNE SPI_CR2_RXNEIE | |||
| #define SPI_IT_ERR SPI_CR2_ERRIE | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SPI_Flag_definition | |||
| * @{ | |||
| */ | |||
| #define SPI_FLAG_RXNE SPI_SR_RXNE | |||
| #define SPI_FLAG_TXE SPI_SR_TXE | |||
| #define SPI_FLAG_CRCERR SPI_SR_CRCERR | |||
| #define SPI_FLAG_MODF SPI_SR_MODF | |||
| #define SPI_FLAG_OVR SPI_SR_OVR | |||
| #define SPI_FLAG_BSY SPI_SR_BSY | |||
| #define SPI_FLAG_FRE SPI_SR_FRE | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset SPI handle state | |||
| * @param __HANDLE__: specifies the SPI handle. | |||
| * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) | |||
| /** @brief Enable or disable the specified SPI interrupts. | |||
| * @param __HANDLE__: specifies the SPI handle. | |||
| * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
| * @param __INTERRUPT__: specifies the interrupt source to enable or disable. | |||
| * This parameter can be one of the following values: | |||
| * @arg SPI_IT_TXE: Tx buffer empty interrupt enable | |||
| * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable | |||
| * @arg SPI_IT_ERR: Error interrupt enable | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__)) | |||
| #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__))) | |||
| /** @brief Check if the specified SPI interrupt source is enabled or disabled. | |||
| * @param __HANDLE__: specifies the SPI handle. | |||
| * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
| * @param __INTERRUPT__: specifies the SPI interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SPI_IT_TXE: Tx buffer empty interrupt enable | |||
| * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable | |||
| * @arg SPI_IT_ERR: Error interrupt enable | |||
| * @retval The new state of __IT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) | |||
| /** @brief Check whether the specified SPI flag is set or not. | |||
| * @param __HANDLE__: specifies the SPI handle. | |||
| * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SPI_FLAG_RXNE: Receive buffer not empty flag | |||
| * @arg SPI_FLAG_TXE: Transmit buffer empty flag | |||
| * @arg SPI_FLAG_CRCERR: CRC error flag | |||
| * @arg SPI_FLAG_MODF: Mode fault flag | |||
| * @arg SPI_FLAG_OVR: Overrun flag | |||
| * @arg SPI_FLAG_BSY: Busy flag | |||
| * @arg SPI_FLAG_FRE: Frame format error flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clear the SPI CRCERR pending flag. | |||
| * @param __HANDLE__: specifies the SPI handle. | |||
| * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = ~(SPI_FLAG_CRCERR)) | |||
| /** @brief Clear the SPI MODF pending flag. | |||
| * @param __HANDLE__: specifies the SPI handle. | |||
| * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\ | |||
| (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE);}while(0) | |||
| /** @brief Clear the SPI OVR pending flag. | |||
| * @param __HANDLE__: specifies the SPI handle. | |||
| * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) do{(__HANDLE__)->Instance->DR;\ | |||
| (__HANDLE__)->Instance->SR;}while(0) | |||
| /** @brief Clear the SPI FRE pending flag. | |||
| * @param __HANDLE__: specifies the SPI handle. | |||
| * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR) | |||
| #define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_SPE) | |||
| #define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SPI_CR1_SPE) | |||
| #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x1) && ((POLYNOMIAL) <= 0xFFFF)) | |||
| #define __HAL_SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE) | |||
| #define __HAL_SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SPI_CR1_BIDIOE) | |||
| #define __HAL_SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (~SPI_CR1_CRCEN);\ | |||
| (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi); | |||
| HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi); | |||
| /* I/O operation functions *****************************************************/ | |||
| HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi); | |||
| HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi); | |||
| HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi); | |||
| void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi); | |||
| /* Peripheral State and Control functions **************************************/ | |||
| HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi); | |||
| HAL_SPI_ErrorTypeDef HAL_SPI_GetError(SPI_HandleTypeDef *hspi); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_SPI_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,152 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_sram.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of SRAM HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_SRAM_H | |||
| #define __STM32F4xx_HAL_SRAM_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) | |||
| #include "stm32f4xx_ll_fsmc.h" | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| #include "stm32f4xx_ll_fmc.h" | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup SRAM | |||
| * @{ | |||
| */ | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Exported typedef ----------------------------------------------------------*/ | |||
| /** | |||
| * @brief HAL SRAM State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_SRAM_STATE_RESET = 0x00, /*!< SRAM not yet initialized or disabled */ | |||
| HAL_SRAM_STATE_READY = 0x01, /*!< SRAM initialized and ready for use */ | |||
| HAL_SRAM_STATE_BUSY = 0x02, /*!< SRAM internal process is ongoing */ | |||
| HAL_SRAM_STATE_ERROR = 0x03, /*!< SRAM error state */ | |||
| HAL_SRAM_STATE_PROTECTED = 0x04 /*!< SRAM peripheral NORSRAM device write protected */ | |||
| }HAL_SRAM_StateTypeDef; | |||
| /** | |||
| * @brief SRAM handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| FMC_NORSRAM_TypeDef *Instance; /*!< Register base address */ | |||
| FMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */ | |||
| FMC_NORSRAM_InitTypeDef Init; /*!< SRAM device control configuration parameters */ | |||
| HAL_LockTypeDef Lock; /*!< SRAM locking object */ | |||
| __IO HAL_SRAM_StateTypeDef State; /*!< SRAM device access state */ | |||
| DMA_HandleTypeDef *hdma; /*!< Pointer DMA handler */ | |||
| }SRAM_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset SRAM handle state | |||
| * @param __HANDLE__: SRAM handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_SRAM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SRAM_STATE_RESET) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_SRAM_Init(SRAM_HandleTypeDef *hsram, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming); | |||
| HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram); | |||
| void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram); | |||
| void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram); | |||
| /* I/O operation functions *****************************************************/ | |||
| HAL_StatusTypeDef HAL_SRAM_Read_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pDstBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SRAM_Write_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pSrcBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SRAM_Read_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pDstBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SRAM_Write_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pSrcBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SRAM_Read_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SRAM_Write_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SRAM_Read_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize); | |||
| HAL_StatusTypeDef HAL_SRAM_Write_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize); | |||
| void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma); | |||
| void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma); | |||
| /* SRAM Control functions ******************************************************/ | |||
| HAL_StatusTypeDef HAL_SRAM_WriteOperation_Enable(SRAM_HandleTypeDef *hsram); | |||
| HAL_StatusTypeDef HAL_SRAM_WriteOperation_Disable(SRAM_HandleTypeDef *hsram); | |||
| /* SRAM State functions *********************************************************/ | |||
| HAL_SRAM_StateTypeDef HAL_SRAM_GetState(SRAM_HandleTypeDef *hsram); | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_SRAM_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,233 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_tim_ex.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of TIM HAL Extension module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_TIM_EX_H | |||
| #define __STM32F4xx_HAL_TIM_EX_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL | |||
| * @{ | |||
| */ | |||
| /** @addtogroup TIMEx | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief TIM Hall sensor Configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal. | |||
| This parameter can be a value of @ref TIM_Input_Capture_Polarity */ | |||
| uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler. | |||
| This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ | |||
| uint32_t IC1Filter; /*!< Specifies the input capture filter. | |||
| This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ | |||
| uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. | |||
| This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ | |||
| } TIM_HallSensor_InitTypeDef; | |||
| /** | |||
| * @brief TIM Master configuration Structure definition | |||
| */ | |||
| typedef struct { | |||
| uint32_t MasterOutputTrigger; /*!< Trigger output (TRGO) selection. | |||
| This parameter can be a value of @ref TIM_Master_Mode_Selection */ | |||
| uint32_t MasterSlaveMode; /*!< Master/slave mode selection. | |||
| This parameter can be a value of @ref TIM_Master_Slave_Mode */ | |||
| }TIM_MasterConfigTypeDef; | |||
| /** | |||
| * @brief TIM Break and Dead time configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t OffStateRunMode; /*!< TIM off state in run mode. | |||
| This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */ | |||
| uint32_t OffStateIDLEMode; /*!< TIM off state in IDLE mode. | |||
| This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */ | |||
| uint32_t LockLevel; /*!< TIM Lock level. | |||
| This parameter can be a value of @ref TIM_Lock_level */ | |||
| uint32_t DeadTime; /*!< TIM dead Time. | |||
| This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */ | |||
| uint32_t BreakState; /*!< TIM Break State. | |||
| This parameter can be a value of @ref TIM_Break_Input_enable_disable */ | |||
| uint32_t BreakPolarity; /*!< TIM Break input polarity. | |||
| This parameter can be a value of @ref TIM_Break_Polarity */ | |||
| uint32_t AutomaticOutput; /*!< TIM Automatic Output Enable state. | |||
| This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */ | |||
| }TIM_BreakDeadTimeConfigTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup TIMEx_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup TIMEx_Remap | |||
| * @{ | |||
| */ | |||
| #define TIM_TIM2_TIM8_TRGO (0x00000000) | |||
| #define TIM_TIM2_ETH_PTP (0x00000400) | |||
| #define TIM_TIM2_USBFS_SOF (0x00000800) | |||
| #define TIM_TIM2_USBHS_SOF (0x00000C00) | |||
| #define TIM_TIM5_GPIO (0x00000000) | |||
| #define TIM_TIM5_LSI (0x00000040) | |||
| #define TIM_TIM5_LSE (0x00000080) | |||
| #define TIM_TIM5_RTC (0x000000C0) | |||
| #define TIM_TIM11_GPIO (0x00000000) | |||
| #define TIM_TIM11_HSE (0x00000002) | |||
| #define IS_TIM_REMAP(TIM_REMAP) (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)||\ | |||
| ((TIM_REMAP) == TIM_TIM2_ETH_PTP)||\ | |||
| ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)||\ | |||
| ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)||\ | |||
| ((TIM_REMAP) == TIM_TIM5_GPIO)||\ | |||
| ((TIM_REMAP) == TIM_TIM5_LSI)||\ | |||
| ((TIM_REMAP) == TIM_TIM5_LSE)||\ | |||
| ((TIM_REMAP) == TIM_TIM5_RTC)||\ | |||
| ((TIM_REMAP) == TIM_TIM11_GPIO)||\ | |||
| ((TIM_REMAP) == TIM_TIM11_HSE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Timer Hall Sensor functions **********************************************/ | |||
| HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef* htim, TIM_HallSensor_InitTypeDef* sConfig); | |||
| HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef* htim); | |||
| void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef* htim); | |||
| void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef* htim); | |||
| /* Blocking mode: Polling */ | |||
| HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef* htim); | |||
| HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef* htim); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef* htim); | |||
| HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef* htim); | |||
| /* Non-Blocking mode: DMA */ | |||
| HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef* htim, uint32_t *pData, uint16_t Length); | |||
| HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef* htim); | |||
| /* Timer Complementary Output Compare functions *****************************/ | |||
| /* Blocking mode: Polling */ | |||
| HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| /* Non-Blocking mode: DMA */ | |||
| HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef* htim, uint32_t Channel, uint32_t *pData, uint16_t Length); | |||
| HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| /* Timer Complementary PWM functions ****************************************/ | |||
| /* Blocking mode: Polling */ | |||
| HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| /* Non-Blocking mode: DMA */ | |||
| HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef* htim, uint32_t Channel, uint32_t *pData, uint16_t Length); | |||
| HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef* htim, uint32_t Channel); | |||
| /* Timer Complementary One Pulse functions **********************************/ | |||
| /* Blocking mode: Polling */ | |||
| HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef* htim, uint32_t OutputChannel); | |||
| HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef* htim, uint32_t OutputChannel); | |||
| /* Non-Blocking mode: Interrupt */ | |||
| HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef* htim, uint32_t OutputChannel); | |||
| HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t OutputChannel); | |||
| /* Extnsion Control functions ************************************************/ | |||
| HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef* htim, uint32_t InputTrigger, uint32_t CommutationSource); | |||
| HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef* htim, uint32_t InputTrigger, uint32_t CommutationSource); | |||
| HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef* htim, uint32_t InputTrigger, uint32_t CommutationSource); | |||
| HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef* htim, TIM_MasterConfigTypeDef * sMasterConfig); | |||
| HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef* htim, TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig); | |||
| HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef* htim, uint32_t Remap); | |||
| /* Extension Callback *********************************************************/ | |||
| void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef* htim); | |||
| void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef* htim); | |||
| void HAL_TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma); | |||
| /* Extension Peripheral State functions **************************************/ | |||
| HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef* htim); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_TIM_EX_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,609 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_uart.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of UART HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_UART_H | |||
| #define __STM32F4xx_HAL_UART_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup UART | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief UART Init Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t BaudRate; /*!< This member configures the UART communication baud rate. | |||
| The baud rate is computed using the following formula: | |||
| - IntegerDivider = ((PCLKx) / (8 * (OVR8+1) * (huart->Init.BaudRate))) | |||
| - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8 * (OVR8+1)) + 0.5 | |||
| Where OVR8 is the "oversampling by 8 mode" configuration bit in the CR1 register. */ | |||
| uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. | |||
| This parameter can be a value of @ref UART_Word_Length */ | |||
| uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. | |||
| This parameter can be a value of @ref UART_Stop_Bits */ | |||
| uint32_t Parity; /*!< Specifies the parity mode. | |||
| This parameter can be a value of @ref UART_Parity | |||
| @note When parity is enabled, the computed parity is inserted | |||
| at the MSB position of the transmitted data (9th bit when | |||
| the word length is set to 9 data bits; 8th bit when the | |||
| word length is set to 8 data bits). */ | |||
| uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. | |||
| This parameter can be a value of @ref UART_Mode */ | |||
| uint32_t HwFlowCtl; /*!< Specifies wether the hardware flow control mode is enabled | |||
| or disabled. | |||
| This parameter can be a value of @ref UART_Hardware_Flow_Control */ | |||
| uint32_t OverSampling; /*!< Specifies wether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8). | |||
| This parameter can be a value of @ref UART_Over_Sampling */ | |||
| }UART_InitTypeDef; | |||
| /** | |||
| * @brief HAL UART State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_UART_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ | |||
| HAL_UART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ | |||
| HAL_UART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ | |||
| HAL_UART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ | |||
| HAL_UART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ | |||
| HAL_UART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */ | |||
| HAL_UART_STATE_TIMEOUT = 0x03, /*!< Timeout state */ | |||
| HAL_UART_STATE_ERROR = 0x04 /*!< Error */ | |||
| }HAL_UART_StateTypeDef; | |||
| /** | |||
| * @brief HAL UART Error Code structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_UART_ERROR_NONE = 0x00, /*!< No error */ | |||
| HAL_UART_ERROR_PE = 0x01, /*!< Parity error */ | |||
| HAL_UART_ERROR_NE = 0x02, /*!< Noise error */ | |||
| HAL_UART_ERROR_FE = 0x04, /*!< frame error */ | |||
| HAL_UART_ERROR_ORE = 0x08, /*!< Overrun error */ | |||
| HAL_UART_ERROR_DMA = 0x10 /*!< DMA transfer error */ | |||
| }HAL_UART_ErrorTypeDef; | |||
| /** | |||
| * @brief UART handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| USART_TypeDef *Instance; /* UART registers base address */ | |||
| UART_InitTypeDef Init; /* UART communication parameters */ | |||
| uint8_t *pTxBuffPtr; /* Pointer to UART Tx transfer Buffer */ | |||
| uint16_t TxXferSize; /* UART Tx Transfer size */ | |||
| uint16_t TxXferCount; /* UART Tx Transfer Counter */ | |||
| uint8_t *pRxBuffPtr; /* Pointer to UART Rx transfer Buffer */ | |||
| uint16_t RxXferSize; /* UART Rx Transfer size */ | |||
| uint16_t RxXferCount; /* UART Rx Transfer Counter */ | |||
| DMA_HandleTypeDef *hdmatx; /* UART Tx DMA Handle parameters */ | |||
| DMA_HandleTypeDef *hdmarx; /* UART Rx DMA Handle parameters */ | |||
| HAL_LockTypeDef Lock; /* Locking object */ | |||
| __IO HAL_UART_StateTypeDef State; /* UART communication state */ | |||
| __IO HAL_UART_ErrorTypeDef ErrorCode; /* UART Error code */ | |||
| }UART_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup UART_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup UART_Word_Length | |||
| * @{ | |||
| */ | |||
| #define UART_WORDLENGTH_8B ((uint32_t)0x00000000) | |||
| #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) | |||
| #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \ | |||
| ((LENGTH) == UART_WORDLENGTH_9B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_Stop_Bits | |||
| * @{ | |||
| */ | |||
| #define UART_STOPBITS_1 ((uint32_t)0x00000000) | |||
| #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) | |||
| #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \ | |||
| ((STOPBITS) == UART_STOPBITS_2)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_Parity | |||
| * @{ | |||
| */ | |||
| #define UART_PARITY_NONE ((uint32_t)0x00000000) | |||
| #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) | |||
| #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) | |||
| #define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \ | |||
| ((PARITY) == UART_PARITY_EVEN) || \ | |||
| ((PARITY) == UART_PARITY_ODD)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_Hardware_Flow_Control | |||
| * @{ | |||
| */ | |||
| #define UART_HWCONTROL_NONE ((uint32_t)0x00000000) | |||
| #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE) | |||
| #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE) | |||
| #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE)) | |||
| #define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\ | |||
| (((CONTROL) == UART_HWCONTROL_NONE) || \ | |||
| ((CONTROL) == UART_HWCONTROL_RTS) || \ | |||
| ((CONTROL) == UART_HWCONTROL_CTS) || \ | |||
| ((CONTROL) == UART_HWCONTROL_RTS_CTS)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_Mode | |||
| * @{ | |||
| */ | |||
| #define UART_MODE_RX ((uint32_t)USART_CR1_RE) | |||
| #define UART_MODE_TX ((uint32_t)USART_CR1_TE) | |||
| #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) | |||
| #define IS_UART_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3) == 0x00) && ((MODE) != (uint32_t)0x000000)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_State | |||
| * @{ | |||
| */ | |||
| #define UART_STATE_DISABLE ((uint32_t)0x00000000) | |||
| #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE) | |||
| #define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \ | |||
| ((STATE) == UART_STATE_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_Over_Sampling | |||
| * @{ | |||
| */ | |||
| #define UART_OVERSAMPLING_16 ((uint32_t)0x00000000) | |||
| #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8) | |||
| #define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \ | |||
| ((SAMPLING) == UART_OVERSAMPLING_8)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_LIN_Break_Detection_Length | |||
| * @{ | |||
| */ | |||
| #define UART_LINBREAKDETECTLENGTH_10B ((uint32_t)0x00000000) | |||
| #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)0x00000020) | |||
| #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \ | |||
| ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_WakeUp_functions | |||
| * @{ | |||
| */ | |||
| #define UART_WAKEUPMETHODE_IDLELINE ((uint32_t)0x00000000) | |||
| #define UART_WAKEUPMETHODE_ADDRESSMARK ((uint32_t)0x00000800) | |||
| #define IS_UART_WAKEUPMETHODE(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHODE_IDLELINE) || \ | |||
| ((WAKEUP) == UART_WAKEUPMETHODE_ADDRESSMARK)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_Flags | |||
| * Elements values convention: 0xXXXX | |||
| * - 0xXXXX : Flag mask in the SR register | |||
| * @{ | |||
| */ | |||
| #define UART_FLAG_CTS ((uint32_t)0x00000200) | |||
| #define UART_FLAG_LBD ((uint32_t)0x00000100) | |||
| #define UART_FLAG_TXE ((uint32_t)0x00000080) | |||
| #define UART_FLAG_TC ((uint32_t)0x00000040) | |||
| #define UART_FLAG_RXNE ((uint32_t)0x00000020) | |||
| #define UART_FLAG_IDLE ((uint32_t)0x00000010) | |||
| #define UART_FLAG_ORE ((uint32_t)0x00000008) | |||
| #define UART_FLAG_NE ((uint32_t)0x00000004) | |||
| #define UART_FLAG_FE ((uint32_t)0x00000002) | |||
| #define UART_FLAG_PE ((uint32_t)0x00000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup UART_Interrupt_definition | |||
| * Elements values convention: 0xY000XXXX | |||
| * - XXXX : Interrupt mask in the XX register | |||
| * - Y : Interrupt source register (2bits) | |||
| * - 01: CR1 register | |||
| * - 10: CR2 register | |||
| * - 11: CR3 register | |||
| * | |||
| * @{ | |||
| */ | |||
| #define UART_IT_PE ((uint32_t)0x10000100) | |||
| #define UART_IT_TXE ((uint32_t)0x10000080) | |||
| #define UART_IT_TC ((uint32_t)0x10000040) | |||
| #define UART_IT_RXNE ((uint32_t)0x10000020) | |||
| #define UART_IT_IDLE ((uint32_t)0x10000010) | |||
| #define UART_IT_LBD ((uint32_t)0x20000040) | |||
| #define UART_IT_CTS ((uint32_t)0x30000400) | |||
| #define UART_IT_ERR ((uint32_t)0x30000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset UART handle state | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_UART_STATE_RESET) | |||
| /** @brief Flushs the UART DR register | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| */ | |||
| #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) | |||
| /** @brief Checks whether the specified UART flag is set or not. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5) | |||
| * @arg UART_FLAG_LBD: LIN Break detection flag | |||
| * @arg UART_FLAG_TXE: Transmit data register empty flag | |||
| * @arg UART_FLAG_TC: Transmission Complete flag | |||
| * @arg UART_FLAG_RXNE: Receive data register not empty flag | |||
| * @arg UART_FLAG_IDLE: Idle Line detection flag | |||
| * @arg UART_FLAG_ORE: OverRun Error flag | |||
| * @arg UART_FLAG_NE: Noise Error flag | |||
| * @arg UART_FLAG_FE: Framing Error flag | |||
| * @arg UART_FLAG_PE: Parity Error flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clears the specified UART pending flag. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5). | |||
| * @arg UART_FLAG_LBD: LIN Break detection flag. | |||
| * @arg UART_FLAG_TC: Transmission Complete flag. | |||
| * @arg UART_FLAG_RXNE: Receive data register not empty flag. | |||
| * | |||
| * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun | |||
| * error) and IDLE (Idle line detected) flags are cleared by software | |||
| * sequence: a read operation to USART_SR register followed by a read | |||
| * operation to USART_DR register. | |||
| * @note RXNE flag can be also cleared by a read to the USART_DR register. | |||
| * @note TC flag can be also cleared by software sequence: a read operation to | |||
| * USART_SR register followed by a write operation to USART_DR register. | |||
| * @note TXE flag is cleared only by a write to the USART_DR register. | |||
| * | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) | |||
| /** @brief Clear the UART PE pending flag. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\ | |||
| (__HANDLE__)->Instance->DR;}while(0) | |||
| /** @brief Clear the UART FE pending flag. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the UART NE pending flag. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the UART ORE pending flag. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the UART IDLE pending flag. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Enables or disables the specified UART interrupt. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @param __INTERRUPT__: specifies the UART interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg UART_IT_CTS: CTS change interrupt | |||
| * @arg UART_IT_LBD: LIN Break detection interrupt | |||
| * @arg UART_IT_TXE: Transmit Data Register empty interrupt | |||
| * @arg UART_IT_TC: Transmission complete interrupt | |||
| * @arg UART_IT_RXNE: Receive Data register not empty interrupt | |||
| * @arg UART_IT_IDLE: Idle line detection interrupt | |||
| * @arg UART_IT_PE: Parity Error interrupt | |||
| * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) | |||
| * @param NewState: new state of the specified UART interrupt. | |||
| * This parameter can be: ENABLE or DISABLE. | |||
| * @retval None | |||
| */ | |||
| #define UART_IT_MASK ((uint32_t)0x0000FFFF) | |||
| #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & UART_IT_MASK)): \ | |||
| (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & UART_IT_MASK)): \ | |||
| ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & UART_IT_MASK))) | |||
| #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & UART_IT_MASK)): \ | |||
| (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & UART_IT_MASK)): \ | |||
| ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & UART_IT_MASK))) | |||
| /** @brief Checks whether the specified UART interrupt has occurred or not. | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or | |||
| * UART peripheral. | |||
| * @param __IT__: specifies the UART interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5) | |||
| * @arg UART_IT_LBD: LIN Break detection interrupt | |||
| * @arg UART_IT_TXE: Transmit Data Register empty interrupt | |||
| * @arg UART_IT_TC: Transmission complete interrupt | |||
| * @arg UART_IT_RXNE: Receive Data register not empty interrupt | |||
| * @arg UART_IT_IDLE: Idle line detection interrupt | |||
| * @arg USART_IT_ERR: Error interrupt | |||
| * @retval The new state of __IT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28) == 2)? \ | |||
| (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & UART_IT_MASK)) | |||
| /** @brief Enable CTS flow control | |||
| * This macro allows to enable CTS hardware flow control for a given UART instance, | |||
| * without need to call HAL_UART_Init() function. | |||
| * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. | |||
| * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need | |||
| * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : | |||
| * - UART instance should have already been initialised (through call of HAL_UART_Init() ) | |||
| * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) | |||
| * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * The Handle Instance can be USART1, USART2 or LPUART. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \ | |||
| do{ \ | |||
| SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \ | |||
| (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \ | |||
| } while(0) | |||
| /** @brief Disable CTS flow control | |||
| * This macro allows to disable CTS hardware flow control for a given UART instance, | |||
| * without need to call HAL_UART_Init() function. | |||
| * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. | |||
| * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need | |||
| * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : | |||
| * - UART instance should have already been initialised (through call of HAL_UART_Init() ) | |||
| * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) | |||
| * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * The Handle Instance can be USART1, USART2 or LPUART. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \ | |||
| do{ \ | |||
| CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \ | |||
| (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \ | |||
| } while(0) | |||
| /** @brief Enable RTS flow control | |||
| * This macro allows to enable RTS hardware flow control for a given UART instance, | |||
| * without need to call HAL_UART_Init() function. | |||
| * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. | |||
| * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need | |||
| * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : | |||
| * - UART instance should have already been initialised (through call of HAL_UART_Init() ) | |||
| * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) | |||
| * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * The Handle Instance can be USART1, USART2 or LPUART. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \ | |||
| do{ \ | |||
| SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \ | |||
| (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \ | |||
| } while(0) | |||
| /** @brief Disable RTS flow control | |||
| * This macro allows to disable RTS hardware flow control for a given UART instance, | |||
| * without need to call HAL_UART_Init() function. | |||
| * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. | |||
| * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need | |||
| * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : | |||
| * - UART instance should have already been initialised (through call of HAL_UART_Init() ) | |||
| * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) | |||
| * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * The Handle Instance can be USART1, USART2 or LPUART. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \ | |||
| do{ \ | |||
| CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\ | |||
| (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \ | |||
| } while(0) | |||
| /** @brief macros to enables or disables the UART's one bit sampling method | |||
| * @param __HANDLE__: specifies the UART Handle. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_UART_ONEBIT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) | |||
| #define __HAL_UART_ONEBIT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT)) | |||
| #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) | |||
| #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) | |||
| #define __DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_))) | |||
| #define __DIVMANT_SAMPLING16(_PCLK_, _BAUD_) (__DIV_SAMPLING16((_PCLK_), (_BAUD_))/100) | |||
| #define __DIVFRAQ_SAMPLING16(_PCLK_, _BAUD_) (((__DIV_SAMPLING16((_PCLK_), (_BAUD_)) - (__DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100) | |||
| #define __UART_BRR_SAMPLING16(_PCLK_, _BAUD_) ((__DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) << 4)|(__DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0x0F)) | |||
| #define __DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*25)/(2*(_BAUD_))) | |||
| #define __DIVMANT_SAMPLING8(_PCLK_, _BAUD_) (__DIV_SAMPLING8((_PCLK_), (_BAUD_))/100) | |||
| #define __DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_) (((__DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (__DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100) | |||
| #define __UART_BRR_SAMPLING8(_PCLK_, _BAUD_) ((__DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4)|(__DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x0F)) | |||
| #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001) | |||
| #define IS_UART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart); | |||
| HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart); | |||
| HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength); | |||
| HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethode); | |||
| HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart); | |||
| void HAL_UART_MspInit(UART_HandleTypeDef *huart); | |||
| void HAL_UART_MspDeInit(UART_HandleTypeDef *huart); | |||
| /* IO operation functions *******************************************************/ | |||
| HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart); | |||
| HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart); | |||
| HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart); | |||
| void HAL_UART_IRQHandler(UART_HandleTypeDef *huart); | |||
| void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart); | |||
| void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart); | |||
| void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart); | |||
| void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart); | |||
| void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart); | |||
| /* Peripheral Control functions ************************************************/ | |||
| HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart); | |||
| HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart); | |||
| HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart); | |||
| HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart); | |||
| HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart); | |||
| /* Peripheral State functions **************************************************/ | |||
| HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart); | |||
| uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_UART_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,490 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_usart.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of USART HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_USART_H | |||
| #define __STM32F4xx_HAL_USART_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup USART | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief USART Init Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t BaudRate; /*!< This member configures the Usart communication baud rate. | |||
| The baud rate is computed using the following formula: | |||
| - IntegerDivider = ((PCLKx) / (8 * (husart->Init.BaudRate))) | |||
| - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */ | |||
| uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. | |||
| This parameter can be a value of @ref USART_Word_Length */ | |||
| uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. | |||
| This parameter can be a value of @ref USART_Stop_Bits */ | |||
| uint32_t Parity; /*!< Specifies the parity mode. | |||
| This parameter can be a value of @ref USART_Parity | |||
| @note When parity is enabled, the computed parity is inserted | |||
| at the MSB position of the transmitted data (9th bit when | |||
| the word length is set to 9 data bits; 8th bit when the | |||
| word length is set to 8 data bits). */ | |||
| uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. | |||
| This parameter can be a value of @ref USART_Mode */ | |||
| uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. | |||
| This parameter can be a value of @ref USART_Clock_Polarity */ | |||
| uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. | |||
| This parameter can be a value of @ref USART_Clock_Phase */ | |||
| uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted | |||
| data bit (MSB) has to be output on the SCLK pin in synchronous mode. | |||
| This parameter can be a value of @ref USART_Last_Bit */ | |||
| }USART_InitTypeDef; | |||
| /** | |||
| * @brief HAL State structures definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_USART_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */ | |||
| HAL_USART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */ | |||
| HAL_USART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */ | |||
| HAL_USART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ | |||
| HAL_USART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ | |||
| HAL_USART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission Reception process is ongoing */ | |||
| HAL_USART_STATE_TIMEOUT = 0x03, /*!< Timeout state */ | |||
| HAL_USART_STATE_ERROR = 0x04 /*!< Error */ | |||
| }HAL_USART_StateTypeDef; | |||
| /** | |||
| * @brief HAL USART Error Code structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_USART_ERROR_NONE = 0x00, /*!< No error */ | |||
| HAL_USART_ERROR_PE = 0x01, /*!< Parity error */ | |||
| HAL_USART_ERROR_NE = 0x02, /*!< Noise error */ | |||
| HAL_USART_ERROR_FE = 0x04, /*!< frame error */ | |||
| HAL_USART_ERROR_ORE = 0x08, /*!< Overrun error */ | |||
| HAL_USART_ERROR_DMA = 0x10 /*!< DMA transfer error */ | |||
| }HAL_USART_ErrorTypeDef; | |||
| /** | |||
| * @brief USART handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| USART_TypeDef *Instance; /* USART registers base address */ | |||
| USART_InitTypeDef Init; /* Usart communication parameters */ | |||
| uint8_t *pTxBuffPtr; /* Pointer to Usart Tx transfer Buffer */ | |||
| uint16_t TxXferSize; /* Usart Tx Transfer size */ | |||
| __IO uint16_t TxXferCount; /* Usart Tx Transfer Counter */ | |||
| uint8_t *pRxBuffPtr; /* Pointer to Usart Rx transfer Buffer */ | |||
| uint16_t RxXferSize; /* Usart Rx Transfer size */ | |||
| __IO uint16_t RxXferCount; /* Usart Rx Transfer Counter */ | |||
| DMA_HandleTypeDef *hdmatx; /* Usart Tx DMA Handle parameters */ | |||
| DMA_HandleTypeDef *hdmarx; /* Usart Rx DMA Handle parameters */ | |||
| HAL_LockTypeDef Lock; /* Locking object */ | |||
| __IO HAL_USART_StateTypeDef State; /* Usart communication state */ | |||
| __IO HAL_USART_ErrorTypeDef ErrorCode; /* USART Error code */ | |||
| }USART_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup USART_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup USART_Word_Length | |||
| * @{ | |||
| */ | |||
| #define USART_WORDLENGTH_8B ((uint32_t)0x00000000) | |||
| #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) | |||
| #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_8B) || \ | |||
| ((LENGTH) == USART_WORDLENGTH_9B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Stop_Bits | |||
| * @{ | |||
| */ | |||
| #define USART_STOPBITS_1 ((uint32_t)0x00000000) | |||
| #define USART_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) | |||
| #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) | |||
| #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) | |||
| #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_STOPBITS_1) || \ | |||
| ((STOPBITS) == USART_STOPBITS_0_5) || \ | |||
| ((STOPBITS) == USART_STOPBITS_1_5) || \ | |||
| ((STOPBITS) == USART_STOPBITS_2)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Parity | |||
| * @{ | |||
| */ | |||
| #define USART_PARITY_NONE ((uint32_t)0x00000000) | |||
| #define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) | |||
| #define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) | |||
| #define IS_USART_PARITY(PARITY) (((PARITY) == USART_PARITY_NONE) || \ | |||
| ((PARITY) == USART_PARITY_EVEN) || \ | |||
| ((PARITY) == USART_PARITY_ODD)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Mode | |||
| * @{ | |||
| */ | |||
| #define USART_MODE_RX ((uint32_t)USART_CR1_RE) | |||
| #define USART_MODE_TX ((uint32_t)USART_CR1_TE) | |||
| #define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) | |||
| #define IS_USART_MODE(MODE) ((((MODE) & (uint32_t)0xFFF3) == 0x00) && ((MODE) != (uint32_t)0x00)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Clock | |||
| * @{ | |||
| */ | |||
| #define USART_CLOCK_DISABLED ((uint32_t)0x00000000) | |||
| #define USART_CLOCK_ENABLED ((uint32_t)USART_CR2_CLKEN) | |||
| #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_CLOCK_DISABLED) || \ | |||
| ((CLOCK) == USART_CLOCK_ENABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Clock_Polarity | |||
| * @{ | |||
| */ | |||
| #define USART_POLARITY_LOW ((uint32_t)0x00000000) | |||
| #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) | |||
| #define IS_USART_POLARITY(CPOL) (((CPOL) == USART_POLARITY_LOW) || ((CPOL) == USART_POLARITY_HIGH)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Clock_Phase | |||
| * @{ | |||
| */ | |||
| #define USART_PHASE_1EDGE ((uint32_t)0x00000000) | |||
| #define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) | |||
| #define IS_USART_PHASE(CPHA) (((CPHA) == USART_PHASE_1EDGE) || ((CPHA) == USART_PHASE_2EDGE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Last_Bit | |||
| * @{ | |||
| */ | |||
| #define USART_LASTBIT_DISABLE ((uint32_t)0x00000000) | |||
| #define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) | |||
| #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LASTBIT_DISABLE) || \ | |||
| ((LASTBIT) == USART_LASTBIT_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_NACK_State | |||
| * @{ | |||
| */ | |||
| #define USARTNACK_ENABLED ((uint32_t)USART_CR3_NACK) | |||
| #define USARTNACK_DISABLED ((uint32_t)0x00000000) | |||
| #define IS_USART_NACK_STATE(NACK) (((NACK) == USARTNACK_ENABLED) || \ | |||
| ((NACK) == USARTNACK_DISABLED)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Flags | |||
| * Elements values convention: 0xXXXX | |||
| * - 0xXXXX : Flag mask in the SR register | |||
| * @{ | |||
| */ | |||
| #define USART_FLAG_TXE ((uint32_t)0x00000080) | |||
| #define USART_FLAG_TC ((uint32_t)0x00000040) | |||
| #define USART_FLAG_RXNE ((uint32_t)0x00000020) | |||
| #define USART_FLAG_IDLE ((uint32_t)0x00000010) | |||
| #define USART_FLAG_ORE ((uint32_t)0x00000008) | |||
| #define USART_FLAG_NE ((uint32_t)0x00000004) | |||
| #define USART_FLAG_FE ((uint32_t)0x00000002) | |||
| #define USART_FLAG_PE ((uint32_t)0x00000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USART_Interrupt_definition | |||
| * Elements values convention: 0xY000XXXX | |||
| * - XXXX : Interrupt mask in the XX register | |||
| * - Y : Interrupt source register (2bits) | |||
| * - 01: CR1 register | |||
| * - 10: CR2 register | |||
| * - 11: CR3 register | |||
| * | |||
| * @{ | |||
| */ | |||
| #define USART_IT_PE ((uint32_t)0x10000100) | |||
| #define USART_IT_TXE ((uint32_t)0x10000080) | |||
| #define USART_IT_TC ((uint32_t)0x10000040) | |||
| #define USART_IT_RXNE ((uint32_t)0x10000020) | |||
| #define USART_IT_IDLE ((uint32_t)0x10000010) | |||
| #define USART_IT_LBD ((uint32_t)0x20000040) | |||
| #define USART_IT_CTS ((uint32_t)0x30000400) | |||
| #define USART_IT_ERR ((uint32_t)0x30000001) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset USART handle state | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET) | |||
| /** @brief Checks whether the specified Smartcard flag is set or not. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg USART_FLAG_TXE: Transmit data register empty flag | |||
| * @arg USART_FLAG_TC: Transmission Complete flag | |||
| * @arg USART_FLAG_RXNE: Receive data register not empty flag | |||
| * @arg USART_FLAG_IDLE: Idle Line detection flag | |||
| * @arg USART_FLAG_ORE: OverRun Error flag | |||
| * @arg USART_FLAG_NE: Noise Error flag | |||
| * @arg USART_FLAG_FE: Framing Error flag | |||
| * @arg USART_FLAG_PE: Parity Error flag | |||
| * @retval The new state of __FLAG__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
| /** @brief Clears the specified Smartcard pending flags. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be any combination of the following values: | |||
| * @arg USART_FLAG_TC: Transmission Complete flag. | |||
| * @arg USART_FLAG_RXNE: Receive data register not empty flag. | |||
| * | |||
| * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun | |||
| * error) and IDLE (Idle line detected) flags are cleared by software | |||
| * sequence: a read operation to USART_SR register followed by a read | |||
| * operation to USART_DR register. | |||
| * @note RXNE flag can be also cleared by a read to the USART_DR register. | |||
| * @note TC flag can be also cleared by software sequence: a read operation to | |||
| * USART_SR register followed by a write operation to USART_DR register. | |||
| * @note TXE flag is cleared only by a write to the USART_DR register. | |||
| * | |||
| * @retval None | |||
| */ | |||
| #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) | |||
| /** @brief Clear the USART PE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR;\ | |||
| (__HANDLE__)->Instance->DR;}while(0) | |||
| /** @brief Clear the USART FE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the USART NE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the UART ORE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Clear the USART IDLE pending flag. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__) | |||
| /** @brief Enables or disables the specified Usart interrupts. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @param __INTERRUPT__: specifies the USART interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg USART_IT_TXE: Transmit Data Register empty interrupt | |||
| * @arg USART_IT_TC: Transmission complete interrupt | |||
| * @arg USART_IT_RXNE: Receive Data register not empty interrupt | |||
| * @arg USART_IT_IDLE: Idle line detection interrupt | |||
| * @arg USART_IT_PE: Parity Error interrupt | |||
| * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) | |||
| * @param NewState: new state of the specified Usart interrupt. | |||
| * This parameter can be: ENABLE or DISABLE. | |||
| * @retval None | |||
| */ | |||
| #define USART_IT_MASK ((uint32_t)0x0000FFFF) | |||
| #define __USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & USART_IT_MASK)): \ | |||
| (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & USART_IT_MASK)): \ | |||
| ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & USART_IT_MASK))) | |||
| #define __USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28) == 1)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & USART_IT_MASK)): \ | |||
| (((__INTERRUPT__) >> 28) == 2)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & USART_IT_MASK)): \ | |||
| ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & USART_IT_MASK))) | |||
| /** @brief Checks whether the specified Usart interrupt has occurred or not. | |||
| * @param __HANDLE__: specifies the USART Handle. | |||
| * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral. | |||
| * @param __IT__: specifies the USART interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg USART_IT_TXE: Transmit Data Register empty interrupt | |||
| * @arg USART_IT_TC: Transmission complete interrupt | |||
| * @arg USART_IT_RXNE: Receive Data register not empty interrupt | |||
| * @arg USART_IT_IDLE: Idle line detection interrupt | |||
| * @arg USART_IT_ERR: Error interrupt | |||
| * @arg USART_IT_PE: Parity Error interrupt | |||
| * @retval The new state of __IT__ (TRUE or FALSE). | |||
| */ | |||
| #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28) == 1)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28) == 2)? \ | |||
| (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & USART_IT_MASK)) | |||
| #define __USART_ENABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 |= USART_CR1_UE) | |||
| #define __USART_DISABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) | |||
| #define __DIV(_PCLK_, _BAUD_) (((_PCLK_)*25)/(4*(_BAUD_))) | |||
| #define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_))/100) | |||
| #define __DIVFRAQ(_PCLK_, _BAUD_) (((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100) | |||
| #define __USART_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4)|(__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0F)) | |||
| #define IS_USART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart); | |||
| HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart); | |||
| void HAL_USART_MspInit(USART_HandleTypeDef *husart); | |||
| void HAL_USART_MspDeInit(USART_HandleTypeDef *husart); | |||
| /* IO operation functions *******************************************************/ | |||
| HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); | |||
| HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); | |||
| HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart); | |||
| HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart); | |||
| HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart); | |||
| void HAL_USART_IRQHandler(USART_HandleTypeDef *husart); | |||
| void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart); | |||
| void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart); | |||
| void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart); | |||
| void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart); | |||
| void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart); | |||
| void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart); | |||
| /* Peripheral State functions **************************************************/ | |||
| HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart); | |||
| uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_USART_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,268 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_wwdg.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of WWDG HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_HAL_WWDG_H | |||
| #define __STM32F4xx_HAL_WWDG_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup WWDG | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief WWDG HAL State Structure definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| HAL_WWDG_STATE_RESET = 0x00, /*!< WWDG not yet initialized or disabled */ | |||
| HAL_WWDG_STATE_READY = 0x01, /*!< WWDG initialized and ready for use */ | |||
| HAL_WWDG_STATE_BUSY = 0x02, /*!< WWDG internal process is ongoing */ | |||
| HAL_WWDG_STATE_TIMEOUT = 0x03, /*!< WWDG timeout state */ | |||
| HAL_WWDG_STATE_ERROR = 0x04 /*!< WWDG error state */ | |||
| }HAL_WWDG_StateTypeDef; | |||
| /** | |||
| * @brief WWDG Init structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG. | |||
| This parameter can be a value of @ref WWDG_Prescaler */ | |||
| uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter. | |||
| This parameter must be a number lower than Max_Data = 0x80 */ | |||
| uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value. | |||
| This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */ | |||
| }WWDG_InitTypeDef; | |||
| /** | |||
| * @brief WWDG handle Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| WWDG_TypeDef *Instance; /*!< Register base address */ | |||
| WWDG_InitTypeDef Init; /*!< WWDG required parameters */ | |||
| HAL_LockTypeDef Lock; /*!< WWDG locking object */ | |||
| __IO HAL_WWDG_StateTypeDef State; /*!< WWDG communication state */ | |||
| }WWDG_HandleTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup WWDG_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup WWDG_BitAddress_AliasRegion | |||
| * @brief WWDG registers bit address in the alias region | |||
| * @{ | |||
| */ | |||
| /* --- CFR Register ---*/ | |||
| /* Alias word address of EWI bit */ | |||
| #define CFR_BASE (uint32_t)(WWDG_BASE + 0x04) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup WWDG_Interrupt_definition | |||
| * @{ | |||
| */ | |||
| #define WWDG_IT_EWI ((uint32_t)WWDG_CFR_EWI) | |||
| #define IS_WWDG_IT(__IT__) ((__IT__) == WWDG_IT_EWI) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup WWDG_Flag_definition | |||
| * @brief WWDG Flag definition | |||
| * @{ | |||
| */ | |||
| #define WWDG_FLAG_EWIF ((uint32_t)WWDG_SR_EWIF) /*!< Early wakeup interrupt flag */ | |||
| #define IS_WWDG_FLAG(__FLAG__) ((__FLAG__) == WWDG_FLAG_EWIF)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup WWDG_Prescaler | |||
| * @{ | |||
| */ | |||
| #define WWDG_PRESCALER_1 ((uint32_t)0x00000000) /*!< WWDG counter clock = (PCLK1/4096)/1 */ | |||
| #define WWDG_PRESCALER_2 ((uint32_t)WWDG_CFR_WDGTB0) /*!< WWDG counter clock = (PCLK1/4096)/2 */ | |||
| #define WWDG_PRESCALER_4 ((uint32_t)WWDG_CFR_WDGTB1) /*!< WWDG counter clock = (PCLK1/4096)/4 */ | |||
| #define WWDG_PRESCALER_8 ((uint32_t)WWDG_CFR_WDGTB) /*!< WWDG counter clock = (PCLK1/4096)/8 */ | |||
| #define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \ | |||
| ((__PRESCALER__) == WWDG_PRESCALER_2) || \ | |||
| ((__PRESCALER__) == WWDG_PRESCALER_4) || \ | |||
| ((__PRESCALER__) == WWDG_PRESCALER_8)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup WWDG_Window | |||
| * @{ | |||
| */ | |||
| #define IS_WWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= 0x7F) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup WWDG_Counter | |||
| * @{ | |||
| */ | |||
| #define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= 0x40) && ((__COUNTER__) <= 0x7F)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /** @brief Reset WWDG handle state | |||
| * @param __HANDLE__: WWDG handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_WWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_WWDG_STATE_RESET) | |||
| /** | |||
| * @brief Enables the WWDG peripheral. | |||
| * @param __HANDLE__: WWDG handle | |||
| * @retval None | |||
| */ | |||
| #define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA) | |||
| /** | |||
| * @brief Gets the selected WWDG's flag status. | |||
| * @param __HANDLE__: WWDG handle | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag | |||
| * @retval The new state of WWDG_FLAG (SET or RESET). | |||
| */ | |||
| #define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) | |||
| /** | |||
| * @brief Clears the WWDG's pending flags. | |||
| * @param __HANDLE__: WWDG handle | |||
| * @param __FLAG__: specifies the flag to clear. | |||
| * This parameter can be one of the following values: | |||
| * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag | |||
| * @retval None | |||
| */ | |||
| #define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__)) | |||
| /** | |||
| * @brief Enables the WWDG early wakeup interrupt. | |||
| * @param __INTERRUPT__: specifies the interrupt to enable. | |||
| * This parameter can be one of the following values: | |||
| * @arg WWDG_IT_EWI: Early wakeup interrupt | |||
| * @note Once enabled this interrupt cannot be disabled except by a system reset. | |||
| * @retval None | |||
| */ | |||
| #define __HAL_WWDG_ENABLE_IT(__INTERRUPT__) (*(__IO uint32_t *) CFR_BASE |= (__INTERRUPT__)) | |||
| /** @brief Clear the WWDG's interrupt pending bits | |||
| * bits to clear the selected interrupt pending bits. | |||
| * @param __HANDLE__: WWDG handle | |||
| * @param __INTERRUPT__: specifies the interrupt pending bit to clear. | |||
| * This parameter can be one of the following values: | |||
| * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag | |||
| */ | |||
| #define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg); | |||
| HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg); | |||
| void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg); | |||
| void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg); | |||
| void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg); | |||
| /* I/O operation functions ******************************************************/ | |||
| HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg); | |||
| HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg); | |||
| HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter); | |||
| void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg); | |||
| /* Peripheral State functions **************************************************/ | |||
| HAL_WWDG_StateTypeDef HAL_WWDG_GetState(WWDG_HandleTypeDef *hwwdg); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_HAL_WWDG_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,973 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_ll_sdmmc.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of SDMMC HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_LL_SDMMC_H | |||
| #define __STM32F4xx_LL_SDMMC_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_Driver | |||
| * @{ | |||
| */ | |||
| /** @addtogroup SDMMC | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** @defgroup SDIO_Exported_Types SDIO Exported Types | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief SDMMC Configuration Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t ClockEdge; /*!< Specifies the clock transition on which the bit capture is made. | |||
| This parameter can be a value of @ref SDIO_Clock_Edge */ | |||
| uint32_t ClockBypass; /*!< Specifies whether the SDIO Clock divider bypass is | |||
| enabled or disabled. | |||
| This parameter can be a value of @ref SDIO_Clock_Bypass */ | |||
| uint32_t ClockPowerSave; /*!< Specifies whether SDIO Clock output is enabled or | |||
| disabled when the bus is idle. | |||
| This parameter can be a value of @ref SDIO_Clock_Power_Save */ | |||
| uint32_t BusWide; /*!< Specifies the SDIO bus width. | |||
| This parameter can be a value of @ref SDIO_Bus_Wide */ | |||
| uint32_t HardwareFlowControl; /*!< Specifies whether the SDIO hardware flow control is enabled or disabled. | |||
| This parameter can be a value of @ref SDIO_Hardware_Flow_Control */ | |||
| uint32_t ClockDiv; /*!< Specifies the clock frequency of the SDIO controller. | |||
| This parameter can be a value between Min_Data = 0 and Max_Data = 255 */ | |||
| }SDIO_InitTypeDef; | |||
| /** | |||
| * @brief SDIO Command Control structure | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t Argument; /*!< Specifies the SDIO command argument which is sent | |||
| to a card as part of a command message. If a command | |||
| contains an argument, it must be loaded into this register | |||
| before writing the command to the command register. */ | |||
| uint32_t CmdIndex; /*!< Specifies the SDIO command index. It must be Min_Data = 0 and | |||
| Max_Data = 64 */ | |||
| uint32_t Response; /*!< Specifies the SDIO response type. | |||
| This parameter can be a value of @ref SDIO_Response_Type */ | |||
| uint32_t WaitForInterrupt; /*!< Specifies whether SDIO wait for interrupt request is | |||
| enabled or disabled. | |||
| This parameter can be a value of @ref SDIO_Wait_Interrupt_State */ | |||
| uint32_t CPSM; /*!< Specifies whether SDIO Command path state machine (CPSM) | |||
| is enabled or disabled. | |||
| This parameter can be a value of @ref SDIO_CPSM_State */ | |||
| }SDIO_CmdInitTypeDef; | |||
| /** | |||
| * @brief SDIO Data Control structure | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t DataTimeOut; /*!< Specifies the data timeout period in card bus clock periods. */ | |||
| uint32_t DataLength; /*!< Specifies the number of data bytes to be transferred. */ | |||
| uint32_t DataBlockSize; /*!< Specifies the data block size for block transfer. | |||
| This parameter can be a value of @ref SDIO_Data_Block_Size */ | |||
| uint32_t TransferDir; /*!< Specifies the data transfer direction, whether the transfer | |||
| is a read or write. | |||
| This parameter can be a value of @ref SDIO_Transfer_Direction */ | |||
| uint32_t TransferMode; /*!< Specifies whether data transfer is in stream or block mode. | |||
| This parameter can be a value of @ref SDIO_Transfer_Type */ | |||
| uint32_t DPSM; /*!< Specifies whether SDIO Data path state machine (DPSM) | |||
| is enabled or disabled. | |||
| This parameter can be a value of @ref SDIO_DPSM_State */ | |||
| }SDIO_DataInitTypeDef; | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup SDIO_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup SDIO_Clock_Edge | |||
| * @{ | |||
| */ | |||
| #define SDIO_CLOCK_EDGE_RISING ((uint32_t)0x00000000) | |||
| #define SDIO_CLOCK_EDGE_FALLING SDIO_CLKCR_NEGEDGE | |||
| #define IS_SDIO_CLOCK_EDGE(EDGE) (((EDGE) == SDIO_CLOCK_EDGE_RISING) || \ | |||
| ((EDGE) == SDIO_CLOCK_EDGE_FALLING)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Clock_Bypass | |||
| * @{ | |||
| */ | |||
| #define SDIO_CLOCK_BYPASS_DISABLE ((uint32_t)0x00000000) | |||
| #define SDIO_CLOCK_BYPASS_ENABLE SDIO_CLKCR_BYPASS | |||
| #define IS_SDIO_CLOCK_BYPASS(BYPASS) (((BYPASS) == SDIO_CLOCK_BYPASS_DISABLE) || \ | |||
| ((BYPASS) == SDIO_CLOCK_BYPASS_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Clock_Power_Save | |||
| * @{ | |||
| */ | |||
| #define SDIO_CLOCK_POWER_SAVE_DISABLE ((uint32_t)0x00000000) | |||
| #define SDIO_CLOCK_POWER_SAVE_ENABLE SDIO_CLKCR_PWRSAV | |||
| #define IS_SDIO_CLOCK_POWER_SAVE(SAVE) (((SAVE) == SDIO_CLOCK_POWER_SAVE_DISABLE) || \ | |||
| ((SAVE) == SDIO_CLOCK_POWER_SAVE_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Bus_Wide | |||
| * @{ | |||
| */ | |||
| #define SDIO_BUS_WIDE_1B ((uint32_t)0x00000000) | |||
| #define SDIO_BUS_WIDE_4B SDIO_CLKCR_WIDBUS_0 | |||
| #define SDIO_BUS_WIDE_8B SDIO_CLKCR_WIDBUS_1 | |||
| #define IS_SDIO_BUS_WIDE(WIDE) (((WIDE) == SDIO_BUS_WIDE_1B) || \ | |||
| ((WIDE) == SDIO_BUS_WIDE_4B) || \ | |||
| ((WIDE) == SDIO_BUS_WIDE_8B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Hardware_Flow_Control | |||
| * @{ | |||
| */ | |||
| #define SDIO_HARDWARE_FLOW_CONTROL_DISABLE ((uint32_t)0x00000000) | |||
| #define SDIO_HARDWARE_FLOW_CONTROL_ENABLE SDIO_CLKCR_HWFC_EN | |||
| #define IS_SDIO_HARDWARE_FLOW_CONTROL(CONTROL) (((CONTROL) == SDIO_HARDWARE_FLOW_CONTROL_DISABLE) || \ | |||
| ((CONTROL) == SDIO_HARDWARE_FLOW_CONTROL_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Clock_Division | |||
| * @{ | |||
| */ | |||
| #define IS_SDIO_CLKDIV(DIV) ((DIV) <= 0xFF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Command_Index | |||
| * @{ | |||
| */ | |||
| #define IS_SDIO_CMD_INDEX(INDEX) ((INDEX) < 0x40) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Response_Type | |||
| * @{ | |||
| */ | |||
| #define SDIO_RESPONSE_NO ((uint32_t)0x00000000) | |||
| #define SDIO_RESPONSE_SHORT SDIO_CMD_WAITRESP_0 | |||
| #define SDIO_RESPONSE_LONG SDIO_CMD_WAITRESP | |||
| #define IS_SDIO_RESPONSE(RESPONSE) (((RESPONSE) == SDIO_RESPONSE_NO) || \ | |||
| ((RESPONSE) == SDIO_RESPONSE_SHORT) || \ | |||
| ((RESPONSE) == SDIO_RESPONSE_LONG)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Wait_Interrupt_State | |||
| * @{ | |||
| */ | |||
| #define SDIO_WAIT_NO ((uint32_t)0x00000000) | |||
| #define SDIO_WAIT_IT SDIO_CMD_WAITINT | |||
| #define SDIO_WAIT_PEND SDIO_CMD_WAITPEND | |||
| #define IS_SDIO_WAIT(WAIT) (((WAIT) == SDIO_WAIT_NO) || \ | |||
| ((WAIT) == SDIO_WAIT_IT) || \ | |||
| ((WAIT) == SDIO_WAIT_PEND)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_CPSM_State | |||
| * @{ | |||
| */ | |||
| #define SDIO_CPSM_DISABLE ((uint32_t)0x00000000) | |||
| #define SDIO_CPSM_ENABLE SDIO_CMD_CPSMEN | |||
| #define IS_SDIO_CPSM(CPSM) (((CPSM) == SDIO_CPSM_DISABLE) || \ | |||
| ((CPSM) == SDIO_CPSM_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Response_Registers | |||
| * @{ | |||
| */ | |||
| #define SDIO_RESP1 ((uint32_t)0x00000000) | |||
| #define SDIO_RESP2 ((uint32_t)0x00000004) | |||
| #define SDIO_RESP3 ((uint32_t)0x00000008) | |||
| #define SDIO_RESP4 ((uint32_t)0x0000000C) | |||
| #define IS_SDIO_RESP(RESP) (((RESP) == SDIO_RESP1) || \ | |||
| ((RESP) == SDIO_RESP2) || \ | |||
| ((RESP) == SDIO_RESP3) || \ | |||
| ((RESP) == SDIO_RESP4)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Data_Length | |||
| * @{ | |||
| */ | |||
| #define IS_SDIO_DATA_LENGTH(LENGTH) ((LENGTH) <= 0x01FFFFFF) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Data_Block_Size | |||
| * @{ | |||
| */ | |||
| #define SDIO_DATABLOCK_SIZE_1B ((uint32_t)0x00000000) | |||
| #define SDIO_DATABLOCK_SIZE_2B SDIO_DCTRL_DBLOCKSIZE_0 | |||
| #define SDIO_DATABLOCK_SIZE_4B SDIO_DCTRL_DBLOCKSIZE_1 | |||
| #define SDIO_DATABLOCK_SIZE_8B ((uint32_t)0x00000030) | |||
| #define SDIO_DATABLOCK_SIZE_16B SDIO_DCTRL_DBLOCKSIZE_2 | |||
| #define SDIO_DATABLOCK_SIZE_32B ((uint32_t)0x00000050) | |||
| #define SDIO_DATABLOCK_SIZE_64B ((uint32_t)0x00000060) | |||
| #define SDIO_DATABLOCK_SIZE_128B ((uint32_t)0x00000070) | |||
| #define SDIO_DATABLOCK_SIZE_256B SDIO_DCTRL_DBLOCKSIZE_3 | |||
| #define SDIO_DATABLOCK_SIZE_512B ((uint32_t)0x00000090) | |||
| #define SDIO_DATABLOCK_SIZE_1024B ((uint32_t)0x000000A0) | |||
| #define SDIO_DATABLOCK_SIZE_2048B ((uint32_t)0x000000B0) | |||
| #define SDIO_DATABLOCK_SIZE_4096B ((uint32_t)0x000000C0) | |||
| #define SDIO_DATABLOCK_SIZE_8192B ((uint32_t)0x000000D0) | |||
| #define SDIO_DATABLOCK_SIZE_16384B ((uint32_t)0x000000E0) | |||
| #define IS_SDIO_BLOCK_SIZE(SIZE) (((SIZE) == SDIO_DATABLOCK_SIZE_1B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_2B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_4B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_8B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_16B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_32B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_64B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_128B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_256B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_512B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_1024B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_2048B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_4096B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_8192B) || \ | |||
| ((SIZE) == SDIO_DATABLOCK_SIZE_16384B)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Transfer_Direction | |||
| * @{ | |||
| */ | |||
| #define SDIO_TRANSFER_DIR_TO_CARD ((uint32_t)0x00000000) | |||
| #define SDIO_TRANSFER_DIR_TO_SDIO SDIO_DCTRL_DTDIR | |||
| #define IS_SDIO_TRANSFER_DIR(DIR) (((DIR) == SDIO_TRANSFER_DIR_TO_CARD) || \ | |||
| ((DIR) == SDIO_TRANSFER_DIR_TO_SDIO)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Transfer_Type | |||
| * @{ | |||
| */ | |||
| #define SDIO_TRANSFER_MODE_BLOCK ((uint32_t)0x00000000) | |||
| #define SDIO_TRANSFER_MODE_STREAM SDIO_DCTRL_DTMODE | |||
| #define IS_SDIO_TRANSFER_MODE(MODE) (((MODE) == SDIO_TRANSFER_MODE_BLOCK) || \ | |||
| ((MODE) == SDIO_TRANSFER_MODE_STREAM)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_DPSM_State | |||
| * @{ | |||
| */ | |||
| #define SDIO_DPSM_DISABLE ((uint32_t)0x00000000) | |||
| #define SDIO_DPSM_ENABLE SDIO_DCTRL_DTEN | |||
| #define IS_SDIO_DPSM(DPSM) (((DPSM) == SDIO_DPSM_DISABLE) ||\ | |||
| ((DPSM) == SDIO_DPSM_ENABLE)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Read_Wait_Mode | |||
| * @{ | |||
| */ | |||
| #define SDIO_READ_WAIT_MODE_CLK ((uint32_t)0x00000000) | |||
| #define SDIO_READ_WAIT_MODE_DATA2 ((uint32_t)0x00000001) | |||
| #define IS_SDIO_READWAIT_MODE(MODE) (((MODE) == SDIO_READ_WAIT_MODE_CLK) || \ | |||
| ((MODE) == SDIO_READ_WAIT_MODE_DATA2)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Interrupt_sources | |||
| * @{ | |||
| */ | |||
| #define SDIO_IT_CCRCFAIL SDIO_STA_CCRCFAIL | |||
| #define SDIO_IT_DCRCFAIL SDIO_STA_DCRCFAIL | |||
| #define SDIO_IT_CTIMEOUT SDIO_STA_CTIMEOUT | |||
| #define SDIO_IT_DTIMEOUT SDIO_STA_DTIMEOUT | |||
| #define SDIO_IT_TXUNDERR SDIO_STA_TXUNDERR | |||
| #define SDIO_IT_RXOVERR SDIO_STA_RXOVERR | |||
| #define SDIO_IT_CMDREND SDIO_STA_CMDREND | |||
| #define SDIO_IT_CMDSENT SDIO_STA_CMDSENT | |||
| #define SDIO_IT_DATAEND SDIO_STA_DATAEND | |||
| #define SDIO_IT_STBITERR SDIO_STA_STBITERR | |||
| #define SDIO_IT_DBCKEND SDIO_STA_DBCKEND | |||
| #define SDIO_IT_CMDACT SDIO_STA_CMDACT | |||
| #define SDIO_IT_TXACT SDIO_STA_TXACT | |||
| #define SDIO_IT_RXACT SDIO_STA_RXACT | |||
| #define SDIO_IT_TXFIFOHE SDIO_STA_TXFIFOHE | |||
| #define SDIO_IT_RXFIFOHF SDIO_STA_RXFIFOHF | |||
| #define SDIO_IT_TXFIFOF SDIO_STA_TXFIFOF | |||
| #define SDIO_IT_RXFIFOF SDIO_STA_RXFIFOF | |||
| #define SDIO_IT_TXFIFOE SDIO_STA_TXFIFOE | |||
| #define SDIO_IT_RXFIFOE SDIO_STA_RXFIFOE | |||
| #define SDIO_IT_TXDAVL SDIO_STA_TXDAVL | |||
| #define SDIO_IT_RXDAVL SDIO_STA_RXDAVL | |||
| #define SDIO_IT_SDIOIT SDIO_STA_SDIOIT | |||
| #define SDIO_IT_CEATAEND SDIO_STA_CEATAEND | |||
| #define IS_SDIO_IT(IT) ((((IT) & (uint32_t)0xFF000000) == 0x00) && ((IT) != (uint32_t)0x00)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Flags | |||
| * @{ | |||
| */ | |||
| #define SDIO_FLAG_CCRCFAIL SDIO_STA_CCRCFAIL | |||
| #define SDIO_FLAG_DCRCFAIL SDIO_STA_DCRCFAIL | |||
| #define SDIO_FLAG_CTIMEOUT SDIO_STA_CTIMEOUT | |||
| #define SDIO_FLAG_DTIMEOUT SDIO_STA_DTIMEOUT | |||
| #define SDIO_FLAG_TXUNDERR SDIO_STA_TXUNDERR | |||
| #define SDIO_FLAG_RXOVERR SDIO_STA_RXOVERR | |||
| #define SDIO_FLAG_CMDREND SDIO_STA_CMDREND | |||
| #define SDIO_FLAG_CMDSENT SDIO_STA_CMDSENT | |||
| #define SDIO_FLAG_DATAEND SDIO_STA_DATAEND | |||
| #define SDIO_FLAG_STBITERR SDIO_STA_STBITERR | |||
| #define SDIO_FLAG_DBCKEND SDIO_STA_DBCKEND | |||
| #define SDIO_FLAG_CMDACT SDIO_STA_CMDACT | |||
| #define SDIO_FLAG_TXACT SDIO_STA_TXACT | |||
| #define SDIO_FLAG_RXACT SDIO_STA_RXACT | |||
| #define SDIO_FLAG_TXFIFOHE SDIO_STA_TXFIFOHE | |||
| #define SDIO_FLAG_RXFIFOHF SDIO_STA_RXFIFOHF | |||
| #define SDIO_FLAG_TXFIFOF SDIO_STA_TXFIFOF | |||
| #define SDIO_FLAG_RXFIFOF SDIO_STA_RXFIFOF | |||
| #define SDIO_FLAG_TXFIFOE SDIO_STA_TXFIFOE | |||
| #define SDIO_FLAG_RXFIFOE SDIO_STA_RXFIFOE | |||
| #define SDIO_FLAG_TXDAVL SDIO_STA_TXDAVL | |||
| #define SDIO_FLAG_RXDAVL SDIO_STA_RXDAVL | |||
| #define SDIO_FLAG_SDIOIT SDIO_STA_SDIOIT | |||
| #define SDIO_FLAG_CEATAEND SDIO_STA_CEATAEND | |||
| #define IS_SDIO_FLAG(FLAG) (((FLAG) == SDIO_FLAG_CCRCFAIL) || \ | |||
| ((FLAG) == SDIO_FLAG_DCRCFAIL) || \ | |||
| ((FLAG) == SDIO_FLAG_CTIMEOUT) || \ | |||
| ((FLAG) == SDIO_FLAG_DTIMEOUT) || \ | |||
| ((FLAG) == SDIO_FLAG_TXUNDERR) || \ | |||
| ((FLAG) == SDIO_FLAG_RXOVERR) || \ | |||
| ((FLAG) == SDIO_FLAG_CMDREND) || \ | |||
| ((FLAG) == SDIO_FLAG_CMDSENT) || \ | |||
| ((FLAG) == SDIO_FLAG_DATAEND) || \ | |||
| ((FLAG) == SDIO_FLAG_STBITERR) || \ | |||
| ((FLAG) == SDIO_FLAG_DBCKEND) || \ | |||
| ((FLAG) == SDIO_FLAG_CMDACT) || \ | |||
| ((FLAG) == SDIO_FLAG_TXACT) || \ | |||
| ((FLAG) == SDIO_FLAG_RXACT) || \ | |||
| ((FLAG) == SDIO_FLAG_TXFIFOHE) || \ | |||
| ((FLAG) == SDIO_FLAG_RXFIFOHF) || \ | |||
| ((FLAG) == SDIO_FLAG_TXFIFOF) || \ | |||
| ((FLAG) == SDIO_FLAG_RXFIFOF) || \ | |||
| ((FLAG) == SDIO_FLAG_TXFIFOE) || \ | |||
| ((FLAG) == SDIO_FLAG_RXFIFOE) || \ | |||
| ((FLAG) == SDIO_FLAG_TXDAVL) || \ | |||
| ((FLAG) == SDIO_FLAG_RXDAVL) || \ | |||
| ((FLAG) == SDIO_FLAG_SDIOIT) || \ | |||
| ((FLAG) == SDIO_FLAG_CEATAEND)) | |||
| #define IS_SDIO_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFF3FF800) == 0x00) && ((FLAG) != (uint32_t)0x00)) | |||
| #define IS_SDIO_GET_IT(IT) (((IT) == SDIO_IT_CCRCFAIL) || \ | |||
| ((IT) == SDIO_IT_DCRCFAIL) || \ | |||
| ((IT) == SDIO_IT_CTIMEOUT) || \ | |||
| ((IT) == SDIO_IT_DTIMEOUT) || \ | |||
| ((IT) == SDIO_IT_TXUNDERR) || \ | |||
| ((IT) == SDIO_IT_RXOVERR) || \ | |||
| ((IT) == SDIO_IT_CMDREND) || \ | |||
| ((IT) == SDIO_IT_CMDSENT) || \ | |||
| ((IT) == SDIO_IT_DATAEND) || \ | |||
| ((IT) == SDIO_IT_STBITERR) || \ | |||
| ((IT) == SDIO_IT_DBCKEND) || \ | |||
| ((IT) == SDIO_IT_CMDACT) || \ | |||
| ((IT) == SDIO_IT_TXACT) || \ | |||
| ((IT) == SDIO_IT_RXACT) || \ | |||
| ((IT) == SDIO_IT_TXFIFOHE) || \ | |||
| ((IT) == SDIO_IT_RXFIFOHF) || \ | |||
| ((IT) == SDIO_IT_TXFIFOF) || \ | |||
| ((IT) == SDIO_IT_RXFIFOF) || \ | |||
| ((IT) == SDIO_IT_TXFIFOE) || \ | |||
| ((IT) == SDIO_IT_RXFIFOE) || \ | |||
| ((IT) == SDIO_IT_TXDAVL) || \ | |||
| ((IT) == SDIO_IT_RXDAVL) || \ | |||
| ((IT) == SDIO_IT_SDIOIT) || \ | |||
| ((IT) == SDIO_IT_CEATAEND)) | |||
| #define IS_SDIO_CLEAR_IT(IT) ((((IT) & (uint32_t)0xFF3FF800) == 0x00) && ((IT) != (uint32_t)0x00)) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup SDIO_Instance_definition | |||
| * @{ | |||
| */ | |||
| #define IS_SDIO_ALL_INSTANCE(INSTANCE) ((INSTANCE) == SDIO) | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| /* ------------ SDIO registers bit address in the alias region -------------- */ | |||
| #define SDIO_OFFSET (SDIO_BASE - PERIPH_BASE) | |||
| /* --- CLKCR Register ---*/ | |||
| /* Alias word address of CLKEN bit */ | |||
| #define CLKCR_OFFSET (SDIO_OFFSET + 0x04) | |||
| #define CLKEN_BitNumber 0x08 | |||
| #define CLKCR_CLKEN_BB (PERIPH_BB_BASE + (CLKCR_OFFSET * 32) + (CLKEN_BitNumber * 4)) | |||
| /* --- CMD Register ---*/ | |||
| /* Alias word address of SDIOSUSPEND bit */ | |||
| #define CMD_OFFSET (SDIO_OFFSET + 0x0C) | |||
| #define SDIOSUSPEND_BitNumber 0x0B | |||
| #define CMD_SDIOSUSPEND_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (SDIOSUSPEND_BitNumber * 4)) | |||
| /* Alias word address of ENCMDCOMPL bit */ | |||
| #define ENCMDCOMPL_BitNumber 0x0C | |||
| #define CMD_ENCMDCOMPL_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ENCMDCOMPL_BitNumber * 4)) | |||
| /* Alias word address of NIEN bit */ | |||
| #define NIEN_BitNumber 0x0D | |||
| #define CMD_NIEN_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (NIEN_BitNumber * 4)) | |||
| /* Alias word address of ATACMD bit */ | |||
| #define ATACMD_BitNumber 0x0E | |||
| #define CMD_ATACMD_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ATACMD_BitNumber * 4)) | |||
| /* --- DCTRL Register ---*/ | |||
| /* Alias word address of DMAEN bit */ | |||
| #define DCTRL_OFFSET (SDIO_OFFSET + 0x2C) | |||
| #define DMAEN_BitNumber 0x03 | |||
| #define DCTRL_DMAEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (DMAEN_BitNumber * 4)) | |||
| /* Alias word address of RWSTART bit */ | |||
| #define RWSTART_BitNumber 0x08 | |||
| #define DCTRL_RWSTART_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTART_BitNumber * 4)) | |||
| /* Alias word address of RWSTOP bit */ | |||
| #define RWSTOP_BitNumber 0x09 | |||
| #define DCTRL_RWSTOP_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTOP_BitNumber * 4)) | |||
| /* Alias word address of RWMOD bit */ | |||
| #define RWMOD_BitNumber 0x0A | |||
| #define DCTRL_RWMOD_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWMOD_BitNumber * 4)) | |||
| /* Alias word address of SDIOEN bit */ | |||
| #define SDIOEN_BitNumber 0x0B | |||
| #define DCTRL_SDIOEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (SDIOEN_BitNumber * 4)) | |||
| /* ---------------------- SDIO registers bit mask --------------------------- */ | |||
| /* --- CLKCR Register ---*/ | |||
| /* CLKCR register clear mask */ | |||
| #define CLKCR_CLEAR_MASK ((uint32_t)(SDIO_CLKCR_CLKDIV | SDIO_CLKCR_PWRSAV |\ | |||
| SDIO_CLKCR_BYPASS | SDIO_CLKCR_WIDBUS |\ | |||
| SDIO_CLKCR_NEGEDGE | SDIO_CLKCR_HWFC_EN)) | |||
| /* --- PWRCTRL Register ---*/ | |||
| /* --- DCTRL Register ---*/ | |||
| /* SDIO DCTRL Clear Mask */ | |||
| #define DCTRL_CLEAR_MASK ((uint32_t)(SDIO_DCTRL_DTEN | SDIO_DCTRL_DTDIR |\ | |||
| SDIO_DCTRL_DTMODE | SDIO_DCTRL_DBLOCKSIZE)) | |||
| /* --- CMD Register ---*/ | |||
| /* CMD Register clear mask */ | |||
| #define CMD_CLEAR_MASK ((uint32_t)(SDIO_CMD_CMDINDEX | SDIO_CMD_WAITRESP |\ | |||
| SDIO_CMD_WAITINT | SDIO_CMD_WAITPEND |\ | |||
| SDIO_CMD_CPSMEN | SDIO_CMD_SDIOSUSPEND)) | |||
| /* SDIO RESP Registers Address */ | |||
| #define SDIO_RESP_ADDR ((uint32_t)(SDIO_BASE + 0x14)) | |||
| /* SDIO Intialization Frequency (400KHz max) */ | |||
| #define SDIO_INIT_CLK_DIV ((uint8_t)0x76) | |||
| /* SDIO Data Transfer Frequency (25MHz max) */ | |||
| #define SDIO_TRANSFER_CLK_DIV ((uint8_t)0x0) | |||
| /** @defgroup SDIO_Interrupt_Clock | |||
| * @brief macros to handle interrupts and specific clock configurations | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Enable the SDIO device. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_ENABLE() (*(__IO uint32_t *)CLKCR_CLKEN_BB = ENABLE) | |||
| /** | |||
| * @brief Disable the SDIO device. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_DISABLE() (*(__IO uint32_t *)CLKCR_CLKEN_BB = DISABLE) | |||
| /** | |||
| * @brief Enable the SDIO DMA transfer. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_DMA_ENABLE() (*(__IO uint32_t *)DCTRL_DMAEN_BB = ENABLE) | |||
| /** | |||
| * @brief Disable the SDIO DMA transfer. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_DMA_DISABLE() (*(__IO uint32_t *)DCTRL_DMAEN_BB = DISABLE) | |||
| /** | |||
| * @brief Enable the SDIO device interrupt. | |||
| * @param __INSTANCE__ : Pointer to SDIO register base | |||
| * @param __INTERRUPT__ : specifies the SDIO interrupt sources to be enabled. | |||
| * This parameter can be one or a combination of the following values: | |||
| * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt | |||
| * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt | |||
| * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt | |||
| * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt | |||
| * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt | |||
| * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt | |||
| * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide | |||
| * bus mode interrupt | |||
| * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt | |||
| * @arg SDIO_IT_TXACT: Data transmit in progress interrupt | |||
| * @arg SDIO_IT_RXACT: Data receive in progress interrupt | |||
| * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt | |||
| * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt | |||
| * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt | |||
| * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt | |||
| * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt | |||
| * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt | |||
| * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt | |||
| * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt | |||
| * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt | |||
| * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->MASK |= (__INTERRUPT__)) | |||
| /** | |||
| * @brief Disable the SDIO device interrupt. | |||
| * @param __INSTANCE__ : Pointer to SDIO register base | |||
| * @param __INTERRUPT__ : specifies the SDIO interrupt sources to be disabled. | |||
| * This parameter can be one or a combination of the following values: | |||
| * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt | |||
| * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt | |||
| * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt | |||
| * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt | |||
| * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt | |||
| * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt | |||
| * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide | |||
| * bus mode interrupt | |||
| * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt | |||
| * @arg SDIO_IT_TXACT: Data transmit in progress interrupt | |||
| * @arg SDIO_IT_RXACT: Data receive in progress interrupt | |||
| * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt | |||
| * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt | |||
| * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt | |||
| * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt | |||
| * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt | |||
| * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt | |||
| * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt | |||
| * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt | |||
| * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt | |||
| * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->MASK &= ~(__INTERRUPT__)) | |||
| /** | |||
| * @brief Checks whether the specified SDIO flag is set or not. | |||
| * @param __INSTANCE__ : Pointer to SDIO register base | |||
| * @param __FLAG__: specifies the flag to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) | |||
| * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) | |||
| * @arg SDIO_FLAG_CTIMEOUT: Command response timeout | |||
| * @arg SDIO_FLAG_DTIMEOUT: Data timeout | |||
| * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error | |||
| * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error | |||
| * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) | |||
| * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) | |||
| * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero) | |||
| * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide bus mode. | |||
| * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) | |||
| * @arg SDIO_FLAG_CMDACT: Command transfer in progress | |||
| * @arg SDIO_FLAG_TXACT: Data transmit in progress | |||
| * @arg SDIO_FLAG_RXACT: Data receive in progress | |||
| * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty | |||
| * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full | |||
| * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full | |||
| * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full | |||
| * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty | |||
| * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty | |||
| * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO | |||
| * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO | |||
| * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received | |||
| * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61 | |||
| * @retval The new state of SDIO_FLAG (SET or RESET). | |||
| */ | |||
| #define __SDIO_GET_FLAG(__INSTANCE__, __FLAG__) (((__INSTANCE__)->STA &(__FLAG__)) != RESET) | |||
| /** | |||
| * @brief Clears the SDIO pending flags. | |||
| * @param __INSTANCE__ : Pointer to SDIO register base | |||
| * @param __FLAG__: specifies the flag to clear. | |||
| * This parameter can be one or a combination of the following values: | |||
| * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) | |||
| * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) | |||
| * @arg SDIO_FLAG_CTIMEOUT: Command response timeout | |||
| * @arg SDIO_FLAG_DTIMEOUT: Data timeout | |||
| * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error | |||
| * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error | |||
| * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) | |||
| * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) | |||
| * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero) | |||
| * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide bus mode | |||
| * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) | |||
| * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received | |||
| * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61 | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->ICR = (__FLAG__)) | |||
| /** | |||
| * @brief Checks whether the specified SDIO interrupt has occurred or not. | |||
| * @param __INSTANCE__ : Pointer to SDIO register base | |||
| * @param __INTERRUPT__: specifies the SDIO interrupt source to check. | |||
| * This parameter can be one of the following values: | |||
| * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt | |||
| * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt | |||
| * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt | |||
| * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt | |||
| * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt | |||
| * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt | |||
| * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide | |||
| * bus mode interrupt | |||
| * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt | |||
| * @arg SDIO_IT_TXACT: Data transmit in progress interrupt | |||
| * @arg SDIO_IT_RXACT: Data receive in progress interrupt | |||
| * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt | |||
| * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt | |||
| * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt | |||
| * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt | |||
| * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt | |||
| * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt | |||
| * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt | |||
| * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt | |||
| * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt | |||
| * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt | |||
| * @retval The new state of SDIO_IT (SET or RESET). | |||
| */ | |||
| #define __SDIO_GET_IT (__INSTANCE__, __INTERRUPT__) (((__INSTANCE__)->STA &(__INTERRUPT__)) == (__INTERRUPT__)) | |||
| /** | |||
| * @brief Clears the SDIO's interrupt pending bits. | |||
| * @param __INSTANCE__ : Pointer to SDIO register base | |||
| * @param __INTERRUPT__: specifies the interrupt pending bit to clear. | |||
| * This parameter can be one or a combination of the following values: | |||
| * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt | |||
| * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt | |||
| * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt | |||
| * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt | |||
| * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt | |||
| * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt | |||
| * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt | |||
| * @arg SDIO_IT_DATAEND: Data end (data counter, SDIO_DCOUNT, is zero) interrupt | |||
| * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide | |||
| * bus mode interrupt | |||
| * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt | |||
| * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_CLEAR_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->ICR = (__INTERRUPT__)) | |||
| /** | |||
| * @brief Enable Start the SD I/O Read Wait operation. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_START_READWAIT_ENABLE() (*(__IO uint32_t *) DCTRL_RWSTART_BB = ENABLE) | |||
| /** | |||
| * @brief Disable Start the SD I/O Read Wait operations. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_START_READWAIT_DISABLE() (*(__IO uint32_t *) DCTRL_RWSTART_BB = DISABLE) | |||
| /** | |||
| * @brief Enable Start the SD I/O Read Wait operation. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_STOP_READWAIT_ENABLE() (*(__IO uint32_t *) DCTRL_RWSTOP_BB = ENABLE) | |||
| /** | |||
| * @brief Disable Stop the SD I/O Read Wait operations. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_STOP_READWAIT_DISABLE() (*(__IO uint32_t *) DCTRL_RWSTOP_BB = DISABLE) | |||
| /** | |||
| * @brief Enable the SD I/O Mode Operation. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_OPERATION_ENABLE() (*(__IO uint32_t *) DCTRL_SDIOEN_BB = ENABLE) | |||
| /** | |||
| * @brief Disable the SD I/O Mode Operation. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_OPERATION_DISABLE() (*(__IO uint32_t *) DCTRL_SDIOEN_BB = DISABLE) | |||
| /** | |||
| * @brief Enable the SD I/O Suspend command sending. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_SUSPEND_CMD_ENABLE() (*(__IO uint32_t *) CMD_SDIOSUSPEND_BB = ENABLE) | |||
| /** | |||
| * @brief Disable the SD I/O Suspend command sending. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_SUSPEND_CMD_DISABLE() (*(__IO uint32_t *) CMD_SDIOSUSPEND_BB = DISABLE) | |||
| /** | |||
| * @brief Enable the command completion signal. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_CEATA_CMD_COMPLETION_ENABLE() (*(__IO uint32_t *) CMD_ENCMDCOMPL_BB = ENABLE) | |||
| /** | |||
| * @brief Disable the command completion signal. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_CEATA_CMD_COMPLETION_DISABLE() (*(__IO uint32_t *) CMD_ENCMDCOMPL_BB = DISABLE) | |||
| /** | |||
| * @brief Enable the CE-ATA interrupt. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_CEATA_ENABLE_IT() (*(__IO uint32_t *) CMD_NIEN_BB = (uint32_t)0) | |||
| /** | |||
| * @brief Disable the CE-ATA interrupt. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_CEATA_DISABLE_IT() (*(__IO uint32_t *) CMD_NIEN_BB = (uint32_t)1) | |||
| /** | |||
| * @brief Enable send CE-ATA command (CMD61). | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_CEATA_SENDCMD_ENABLE() (*(__IO uint32_t *) CMD_ATACMD_BB = ENABLE) | |||
| /** | |||
| * @brief Disable send CE-ATA command (CMD61). | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| #define __SDIO_CEATA_SENDCMD_DISABLE() (*(__IO uint32_t *) CMD_ATACMD_BB = DISABLE) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| /** @addtogroup SDIO_Exported_Functions | |||
| * @{ | |||
| */ | |||
| /* Initialization/de-initialization functions **********************************/ | |||
| /** @addtogroup HAL_SDIO_Group1 | |||
| * @{ | |||
| */ | |||
| HAL_StatusTypeDef SDIO_Init(SDIO_TypeDef *SDIOx, SDIO_InitTypeDef Init); | |||
| /** | |||
| * @} | |||
| */ | |||
| /* I/O operation functions *****************************************************/ | |||
| /** @addtogroup HAL_SDIO_Group2 | |||
| * @{ | |||
| */ | |||
| /* Blocking mode: Polling */ | |||
| uint32_t SDIO_ReadFIFO(SDIO_TypeDef *SDIOx); | |||
| HAL_StatusTypeDef SDIO_WriteFIFO(SDIO_TypeDef *SDIOx, uint32_t *pWriteData); | |||
| /** | |||
| * @} | |||
| */ | |||
| /* Peripheral Control functions ************************************************/ | |||
| /** @addtogroup HAL_SDIO_Group3 | |||
| * @{ | |||
| */ | |||
| HAL_StatusTypeDef SDIO_PowerState_ON(SDIO_TypeDef *SDIOx); | |||
| HAL_StatusTypeDef SDIO_PowerState_OFF(SDIO_TypeDef *SDIOx); | |||
| uint32_t SDIO_GetPowerState(SDIO_TypeDef *SDIOx); | |||
| /* Command path state machine (CPSM) management functions */ | |||
| HAL_StatusTypeDef SDIO_SendCommand(SDIO_TypeDef *SDIOx, SDIO_CmdInitTypeDef *SDIO_CmdInitStruct); | |||
| uint8_t SDIO_GetCommandResponse(SDIO_TypeDef *SDIOx); | |||
| uint32_t SDIO_GetResponse(uint32_t SDIO_RESP); | |||
| /* Data path state machine (DPSM) management functions */ | |||
| HAL_StatusTypeDef SDIO_DataConfig(SDIO_TypeDef *SDIOx, SDIO_DataInitTypeDef* SDIO_DataInitStruct); | |||
| uint32_t SDIO_GetDataCounter(SDIO_TypeDef *SDIOx); | |||
| uint32_t SDIO_GetFIFOCount(SDIO_TypeDef *SDIOx); | |||
| /* SDIO IO Cards mode management functions */ | |||
| HAL_StatusTypeDef SDIO_SetSDIOReadWaitMode(uint32_t SDIO_ReadWaitMode); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_LL_SDMMC_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,459 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_ll_usb.h | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief Header file of USB Core HAL module. | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Define to prevent recursive inclusion -------------------------------------*/ | |||
| #ifndef __STM32F4xx_LL_USB_H | |||
| #define __STM32F4xx_LL_USB_H | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal_def.h" | |||
| /** @addtogroup STM32F4xx_HAL | |||
| * @{ | |||
| */ | |||
| /** @addtogroup USB_Core | |||
| * @{ | |||
| */ | |||
| /* Exported types ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief USB Mode definition | |||
| */ | |||
| typedef enum | |||
| { | |||
| USB_OTG_DEVICE_MODE = 0, | |||
| USB_OTG_HOST_MODE = 1, | |||
| USB_OTG_DRD_MODE = 2 | |||
| }USB_OTG_ModeTypeDef; | |||
| /** | |||
| * @brief URB States definition | |||
| */ | |||
| typedef enum { | |||
| URB_IDLE = 0, | |||
| URB_DONE, | |||
| URB_NOTREADY, | |||
| URB_NYET, | |||
| URB_ERROR, | |||
| URB_STALL | |||
| }USB_OTG_URBStateTypeDef; | |||
| /** | |||
| * @brief Host channel States definition | |||
| */ | |||
| typedef enum { | |||
| HC_IDLE = 0, | |||
| HC_XFRC, | |||
| HC_HALTED, | |||
| HC_NAK, | |||
| HC_NYET, | |||
| HC_STALL, | |||
| HC_XACTERR, | |||
| HC_BBLERR, | |||
| HC_DATATGLERR | |||
| }USB_OTG_HCStateTypeDef; | |||
| /** | |||
| * @brief PCD Initialization Structure definition | |||
| */ | |||
| typedef struct | |||
| { | |||
| uint32_t dev_endpoints; /*!< Device Endpoints number. | |||
| This parameter depends on the used USB core. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ | |||
| uint32_t Host_channels; /*!< Host Channels number. | |||
| This parameter Depends on the used USB core. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ | |||
| uint32_t speed; /*!< USB Core speed. | |||
| This parameter can be any value of @ref USB_Core_Speed_ */ | |||
| uint32_t dma_enable; /*!< Enable or disable of the USB embedded DMA. */ | |||
| uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. | |||
| This parameter can be any value of @ref USB_EP0_MPS_ */ | |||
| uint32_t phy_itface; /*!< Select the used PHY interface. | |||
| This parameter can be any value of @ref USB_Core_PHY_ */ | |||
| uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ | |||
| uint32_t low_power_enable; /*!< Enable or disable the low power mode. */ | |||
| uint32_t vbus_sensing_enable; /*!< Enable or disable the VBUS Sensing feature. */ | |||
| uint32_t use_dedicated_ep1; /*!< Enable or disable the use of the dedicated EP1 interrupt. */ | |||
| uint32_t use_external_vbus; /*!< Enable or disable the use of the external VBUS. */ | |||
| }USB_OTG_CfgTypeDef; | |||
| typedef struct | |||
| { | |||
| uint8_t num; /*!< Endpoint number | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ | |||
| uint8_t is_in; /*!< Endpoint direction | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
| uint8_t is_stall; /*!< Endpoint stall condition | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
| uint8_t type; /*!< Endpoint type | |||
| This parameter can be any value of @ref USB_EP_Type_ */ | |||
| uint8_t data_pid_start; /*!< Initial data PID | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
| uint8_t even_odd_frame; /*!< IFrame parity | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
| uint16_t tx_fifo_num; /*!< Transmission FIFO number | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ | |||
| uint32_t maxpacket; /*!< Endpoint Max packet size | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ | |||
| uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ | |||
| uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address */ | |||
| uint32_t xfer_len; /*!< Current transfer length */ | |||
| uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ | |||
| }USB_OTG_EPTypeDef; | |||
| typedef struct | |||
| { | |||
| uint8_t dev_addr ; /*!< USB device address. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 255 */ | |||
| uint8_t ch_num; /*!< Host channel number. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ | |||
| uint8_t ep_num; /*!< Endpoint number. | |||
| This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ | |||
| uint8_t ep_is_in; /*!< Endpoint direction | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
| uint8_t speed; /*!< USB Host speed. | |||
| This parameter can be any value of @ref USB_Core_Speed_ */ | |||
| uint8_t do_ping; /*!< Enable or disable the use of the PING protocol for HS mode. */ | |||
| uint8_t process_ping; /*!< Execute the PING protocol for HS mode. */ | |||
| uint8_t ep_type; /*!< Endpoint Type. | |||
| This parameter can be any value of @ref USB_EP_Type_ */ | |||
| uint16_t max_packet; /*!< Endpoint Max packet size. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ | |||
| uint8_t data_pid; /*!< Initial data PID. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
| uint8_t *xfer_buff; /*!< Pointer to transfer buffer. */ | |||
| uint32_t xfer_len; /*!< Current transfer length. */ | |||
| uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer. */ | |||
| uint8_t toggle_in; /*!< IN transfer current toggle flag. | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
| uint8_t toggle_out; /*!< OUT transfer current toggle flag | |||
| This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ | |||
| uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address. */ | |||
| uint32_t ErrCnt; /*!< Host channel error count.*/ | |||
| USB_OTG_URBStateTypeDef urb_state; /*!< URB state. | |||
| This parameter can be any value of @ref USB_OTG_URBStateTypeDef */ | |||
| USB_OTG_HCStateTypeDef state; /*!< Host Channel state. | |||
| This parameter can be any value of @ref USB_OTG_HCStateTypeDef */ | |||
| }USB_OTG_HCTypeDef; | |||
| /* Exported constants --------------------------------------------------------*/ | |||
| /** @defgroup PCD_Exported_Constants | |||
| * @{ | |||
| */ | |||
| /** @defgroup USB_Core_Mode_ | |||
| * @{ | |||
| */ | |||
| #define USB_OTG_MODE_DEVICE 0 | |||
| #define USB_OTG_MODE_HOST 1 | |||
| #define USB_OTG_MODE_DRD 2 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_Core_Speed_ | |||
| * @{ | |||
| */ | |||
| #define USB_OTG_SPEED_HIGH 0 | |||
| #define USB_OTG_SPEED_HIGH_IN_FULL 1 | |||
| #define USB_OTG_SPEED_LOW 2 | |||
| #define USB_OTG_SPEED_FULL 3 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_Core_PHY_ | |||
| * @{ | |||
| */ | |||
| #define USB_OTG_ULPI_PHY 1 | |||
| #define USB_OTG_EMBEDDED_PHY 2 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_Core_MPS_ | |||
| * @{ | |||
| */ | |||
| #define USB_OTG_HS_MAX_PACKET_SIZE 512 | |||
| #define USB_OTG_FS_MAX_PACKET_SIZE 64 | |||
| #define USB_OTG_MAX_EP0_SIZE 64 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_Core_Phy_Frequency_ | |||
| * @{ | |||
| */ | |||
| #define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ (0 << 1) | |||
| #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ (1 << 1) | |||
| #define DSTS_ENUMSPD_LS_PHY_6MHZ (2 << 1) | |||
| #define DSTS_ENUMSPD_FS_PHY_48MHZ (3 << 1) | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_CORE_Frame_Interval_ | |||
| * @{ | |||
| */ | |||
| #define DCFG_FRAME_INTERVAL_80 0 | |||
| #define DCFG_FRAME_INTERVAL_85 1 | |||
| #define DCFG_FRAME_INTERVAL_90 2 | |||
| #define DCFG_FRAME_INTERVAL_95 3 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_EP0_MPS_ | |||
| * @{ | |||
| */ | |||
| #define DEP0CTL_MPS_64 0 | |||
| #define DEP0CTL_MPS_32 1 | |||
| #define DEP0CTL_MPS_16 2 | |||
| #define DEP0CTL_MPS_8 3 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_EP_Speed_ | |||
| * @{ | |||
| */ | |||
| #define EP_SPEED_LOW 0 | |||
| #define EP_SPEED_FULL 1 | |||
| #define EP_SPEED_HIGH 2 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_EP_Type_ | |||
| * @{ | |||
| */ | |||
| #define EP_TYPE_CTRL 0 | |||
| #define EP_TYPE_ISOC 1 | |||
| #define EP_TYPE_BULK 2 | |||
| #define EP_TYPE_INTR 3 | |||
| #define EP_TYPE_MSK 3 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup USB_STS_Defines_ | |||
| * @{ | |||
| */ | |||
| #define STS_GOUT_NAK 1 | |||
| #define STS_DATA_UPDT 2 | |||
| #define STS_XFER_COMP 3 | |||
| #define STS_SETUP_COMP 4 | |||
| #define STS_SETUP_UPDT 6 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HCFG_SPEED_Defines_ | |||
| * @{ | |||
| */ | |||
| #define HCFG_30_60_MHZ 0 | |||
| #define HCFG_48_MHZ 1 | |||
| #define HCFG_6_MHZ 2 | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HPRT0_PRTSPD_SPEED_Defines_ | |||
| * @{ | |||
| */ | |||
| #define HPRT0_PRTSPD_HIGH_SPEED 0 | |||
| #define HPRT0_PRTSPD_FULL_SPEED 1 | |||
| #define HPRT0_PRTSPD_LOW_SPEED 2 | |||
| /** | |||
| * @} | |||
| */ | |||
| #define HCCHAR_CTRL 0 | |||
| #define HCCHAR_ISOC 1 | |||
| #define HCCHAR_BULK 2 | |||
| #define HCCHAR_INTR 3 | |||
| #define HC_PID_DATA0 0 | |||
| #define HC_PID_DATA2 1 | |||
| #define HC_PID_DATA1 2 | |||
| #define HC_PID_SETUP 3 | |||
| #define GRXSTS_PKTSTS_IN 2 | |||
| #define GRXSTS_PKTSTS_IN_XFER_COMP 3 | |||
| #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR 5 | |||
| #define GRXSTS_PKTSTS_CH_HALTED 7 | |||
| #define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_PCGCCTL_BASE) | |||
| #define USBx_HPRT0 *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_HOST_PORT_BASE) | |||
| #define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t )USBx + USB_OTG_DEVICE_BASE)) | |||
| #define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + (i)*USB_OTG_EP_REG_SIZE)) | |||
| #define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + (i)*USB_OTG_EP_REG_SIZE)) | |||
| #define USBx_DFIFO(i) *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_FIFO_BASE + (i) * USB_OTG_FIFO_SIZE) | |||
| #define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t )USBx + USB_OTG_HOST_BASE)) | |||
| #define USBx_HC(i) ((USB_OTG_HostChannelTypeDef *)((uint32_t)USBx + USB_OTG_HOST_CHANNEL_BASE + (i)*USB_OTG_HOST_CHANNEL_SIZE)) | |||
| /* Exported macro ------------------------------------------------------------*/ | |||
| #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__)) | |||
| #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__)) | |||
| #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__)) | |||
| #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__)) | |||
| /* Exported functions --------------------------------------------------------*/ | |||
| HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init); | |||
| HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init); | |||
| HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx , USB_OTG_ModeTypeDef mode); | |||
| HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx , uint8_t speed); | |||
| HAL_StatusTypeDef USB_FlushRxFifo (USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num ); | |||
| HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); | |||
| HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); | |||
| HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); | |||
| HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); | |||
| HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep, uint8_t dma); | |||
| HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep, uint8_t dma); | |||
| HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len, uint8_t dma); | |||
| void * USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len); | |||
| HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep); | |||
| HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep); | |||
| HAL_StatusTypeDef USB_SetDevAddress (USB_OTG_GlobalTypeDef *USBx, uint8_t address); | |||
| HAL_StatusTypeDef USB_DevConnect (USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_DevDisconnect (USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_ActivateSetup (USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t dma, uint8_t *psetup); | |||
| uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx); | |||
| uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx); | |||
| uint32_t USB_ReadInterrupts (USB_OTG_GlobalTypeDef *USBx); | |||
| uint32_t USB_ReadDevAllOutEpInterrupt (USB_OTG_GlobalTypeDef *USBx); | |||
| uint32_t USB_ReadDevOutEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum); | |||
| uint32_t USB_ReadDevAllInEpInterrupt (USB_OTG_GlobalTypeDef *USBx); | |||
| uint32_t USB_ReadDevInEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum); | |||
| void USB_ClearInterrupts (USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt); | |||
| HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); | |||
| HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx , uint8_t freq); | |||
| HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_DriveVbus (USB_OTG_GlobalTypeDef *USBx, uint8_t state); | |||
| uint32_t USB_GetHostSpeed (USB_OTG_GlobalTypeDef *USBx); | |||
| uint32_t USB_GetCurrentFrame (USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, | |||
| uint8_t ch_num, | |||
| uint8_t epnum, | |||
| uint8_t dev_address, | |||
| uint8_t speed, | |||
| uint8_t ep_type, | |||
| uint16_t mps); | |||
| HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDef *hc, uint8_t dma); | |||
| uint32_t USB_HC_ReadInterrupt (USB_OTG_GlobalTypeDef *USBx); | |||
| HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx , uint8_t hc_num); | |||
| HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx , uint8_t ch_num); | |||
| HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx); | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif /* __STM32F4xx_LL_USB_H */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,536 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @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) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup HAL | |||
| * @brief HAL module driver. | |||
| * @{ | |||
| */ | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /** | |||
| * @brief STM32F4xx HAL Driver version number V1.1.0 | |||
| */ | |||
| #define __STM32F4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */ | |||
| #define __STM32F4xx_HAL_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */ | |||
| #define __STM32F4xx_HAL_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ | |||
| #define __STM32F4xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */ | |||
| #define __STM32F4xx_HAL_VERSION ((__STM32F4xx_HAL_VERSION_MAIN << 24)\ | |||
| |(__STM32F4xx_HAL_VERSION_SUB1 << 16)\ | |||
| |(__STM32F4xx_HAL_VERSION_SUB2 << 8 )\ | |||
| |(__STM32F4xx_HAL_VERSION_RC)) | |||
| #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) | |||
| /* ------------ RCC registers bit address in the alias region ----------- */ | |||
| #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE) | |||
| /* --- MEMRMP Register ---*/ | |||
| /* Alias word address of UFB_MODE bit */ | |||
| #define MEMRMP_OFFSET SYSCFG_OFFSET | |||
| #define UFB_MODE_BitNumber ((uint8_t)0x8) | |||
| #define UFB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (UFB_MODE_BitNumber * 4)) | |||
| /* --- CMPCR Register ---*/ | |||
| /* Alias word address of CMP_PD bit */ | |||
| #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20) | |||
| #define CMP_PD_BitNumber ((uint8_t)0x00) | |||
| #define CMPCR_CMP_PD_BB (PERIPH_BB_BASE + (CMPCR_OFFSET * 32) + (CMP_PD_BitNumber * 4)) | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| static __IO uint32_t uwTick; | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup HAL_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup HAL_Group1 Initialization and de-initialization Functions | |||
| * @brief Initialization and de-initialization functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Initialization and de-initialization functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Initializes the Flash interface the NVIC allocation and initial clock | |||
| configuration. It initializes the systick also when timeout is needed | |||
| and the backup domain when enabled. | |||
| (+) de-Initializes 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 is used to initialize the HAL Library; it must be the first | |||
| * instruction to be executed in the main program (before to call any other | |||
| * HAL function), it performs the following: | |||
| * Configure the Flash prefetch, instruction and Data caches. | |||
| * Configures the SysTick to generate an interrupt each 1 millisecond, | |||
| * which is clocked by the HSI (at this stage, the clock is not yet | |||
| * configured and thus the system is running from the internal HSI at 16 MHz). | |||
| * Set NVIC Group Priority to 4. | |||
| * Calls the HAL_MspInit() callback function defined in user file | |||
| * "stm32f4xx_hal_msp.c" to do the global low level hardware initialization | |||
| * | |||
| * @note SysTick is used as time base for the HAL_Delay() function, the application | |||
| * need to ensure that the SysTick time base is always set to 1 millisecond | |||
| * to have correct HAL operation. | |||
| * @param None | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_Init(void) | |||
| { | |||
| /* Configure Flash prefetch, Instruction cache, Data cache */ | |||
| #if (INSTRUCTION_CACHE_ENABLE != 0) | |||
| __HAL_FLASH_INSTRUCTION_CACHE_ENABLE(); | |||
| #endif /* INSTRUCTION_CACHE_ENABLE */ | |||
| #if (DATA_CACHE_ENABLE != 0) | |||
| __HAL_FLASH_DATA_CACHE_ENABLE(); | |||
| #endif /* DATA_CACHE_ENABLE */ | |||
| #if (PREFETCH_ENABLE != 0) | |||
| __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); | |||
| #endif /* PREFETCH_ENABLE */ | |||
| /* Set Interrupt Group Priority */ | |||
| HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); | |||
| /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */ | |||
| HAL_InitTick(TICK_INT_PRIORITY); | |||
| /* Init the low level hardware */ | |||
| HAL_MspInit(); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief This function de-Initializes common part of the HAL and stops the systick. | |||
| * This function is optional. | |||
| * @param None | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DeInit(void) | |||
| { | |||
| /* Reset of all peripherals */ | |||
| __APB1_FORCE_RESET(); | |||
| __APB1_RELEASE_RESET(); | |||
| __APB2_FORCE_RESET(); | |||
| __APB2_RELEASE_RESET(); | |||
| __AHB1_FORCE_RESET(); | |||
| __AHB1_RELEASE_RESET(); | |||
| __AHB2_FORCE_RESET(); | |||
| __AHB2_RELEASE_RESET(); | |||
| __AHB3_FORCE_RESET(); | |||
| __AHB3_RELEASE_RESET(); | |||
| /* De-Init the low level hardware */ | |||
| HAL_MspDeInit(); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Initializes the MSP. | |||
| * @param None | |||
| * @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. | |||
| * @param None | |||
| * @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 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*/ | |||
| HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); | |||
| /*Configure the SysTick IRQ priority */ | |||
| HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup HAL_Group2 HAL Control functions | |||
| * @brief HAL Control functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### HAL Control functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Provide a tick value in millisecond | |||
| (+) Provide a blocking delay in millisecond | |||
| (+) Suspend the time base source interrupt | |||
| (+) Resume the time base source interrupt | |||
| (+) Get the HAL API driver version | |||
| (+) Get the device identifier | |||
| (+) Get the device revision identifier | |||
| (+) Enable/Disable Debug module during SLEEP mode | |||
| (+) Enable/Disable Debug module during STOP mode | |||
| (+) Enable/Disable Debug module during STANDBY mode | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief This function is called to increment a global variable "uwTick" | |||
| * used as application time base. | |||
| * @note In the default implementation, this variable is incremented each 1ms | |||
| * in Systick ISR. | |||
| * @note This function is declared as __weak to be overwritten in case of other | |||
| * implementations in user file. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_IncTick(void) | |||
| { | |||
| uwTick++; | |||
| } | |||
| /** | |||
| * @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. | |||
| * @param None | |||
| * @retval tick value | |||
| */ | |||
| __weak uint32_t HAL_GetTick(void) | |||
| { | |||
| return uwTick; | |||
| } | |||
| /** | |||
| * @brief This function provides accurate 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(__IO uint32_t Delay) | |||
| { | |||
| uint32_t tickstart = 0; | |||
| tickstart = HAL_GetTick(); | |||
| while((HAL_GetTick() - tickstart) < Delay) | |||
| { | |||
| } | |||
| } | |||
| /** | |||
| * @brief Suspend Tick increment. | |||
| * @note In the default implementation , SysTick timer is the source of time base. It is | |||
| * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() | |||
| * is called, the 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. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_SuspendTick(void) | |||
| { | |||
| /* Disable SysTick Interrupt */ | |||
| SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; | |||
| } | |||
| /** | |||
| * @brief Resume Tick increment. | |||
| * @note In the default implementation , SysTick timer is the source of time base. It is | |||
| * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() | |||
| * is called, the 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. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_ResumeTick(void) | |||
| { | |||
| /* Enable SysTick Interrupt */ | |||
| SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; | |||
| } | |||
| /** | |||
| * @brief Returns the HAL revision | |||
| * @param None | |||
| * @retval version : 0xXYZR (8bits for each decimal, R for RC) | |||
| */ | |||
| uint32_t HAL_GetHalVersion(void) | |||
| { | |||
| return __STM32F4xx_HAL_VERSION; | |||
| } | |||
| /** | |||
| * @brief Returns the device revision identifier. | |||
| * @param None | |||
| * @retval Device revision identifier | |||
| */ | |||
| uint32_t HAL_GetREVID(void) | |||
| { | |||
| return((DBGMCU->IDCODE) >> 16); | |||
| } | |||
| /** | |||
| * @brief Returns the device identifier. | |||
| * @param None | |||
| * @retval Device identifier | |||
| */ | |||
| uint32_t HAL_GetDEVID(void) | |||
| { | |||
| return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK); | |||
| } | |||
| /** | |||
| * @brief Enable the Debug Module during SLEEP mode | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_EnableDBGSleepMode(void) | |||
| { | |||
| SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); | |||
| } | |||
| /** | |||
| * @brief Disable the Debug Module during SLEEP mode | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_DisableDBGSleepMode(void) | |||
| { | |||
| CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); | |||
| } | |||
| /** | |||
| * @brief Enable the Debug Module during STOP mode | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_EnableDBGStopMode(void) | |||
| { | |||
| SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); | |||
| } | |||
| /** | |||
| * @brief Disable the Debug Module during STOP mode | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_DisableDBGStopMode(void) | |||
| { | |||
| CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); | |||
| } | |||
| /** | |||
| * @brief Enable the Debug Module during STANDBY mode | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_EnableDBGStandbyMode(void) | |||
| { | |||
| SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); | |||
| } | |||
| /** | |||
| * @brief Disable the Debug Module during STANDBY mode | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_DisableDBGStandbyMode(void) | |||
| { | |||
| CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); | |||
| } | |||
| /** | |||
| * @brief Enables the I/O Compensation Cell. | |||
| * @note The I/O compensation cell can be used only when the device supply | |||
| * voltage ranges from 2.4 to 3.6 V. | |||
| * @retval None | |||
| */ | |||
| void HAL_EnableCompensationCell(void) | |||
| { | |||
| *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)ENABLE; | |||
| } | |||
| /** | |||
| * @brief Power-down the I/O Compensation Cell. | |||
| * @note The I/O compensation cell can be used only when the device supply | |||
| * voltage ranges from 2.4 to 3.6 V. | |||
| * @retval None | |||
| */ | |||
| void HAL_DisableCompensationCell(void) | |||
| { | |||
| *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)DISABLE; | |||
| } | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) | |||
| /** | |||
| * @brief Enables the Internal FLASH Bank Swapping. | |||
| * | |||
| * @note This function can be used only for STM32F42xxx/43xxx devices. | |||
| * | |||
| * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000) | |||
| * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000) | |||
| * | |||
| * @retval None | |||
| */ | |||
| void HAL_EnableMemorySwappingBank(void) | |||
| { | |||
| *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)ENABLE; | |||
| } | |||
| /** | |||
| * @brief Disables the Internal FLASH Bank Swapping. | |||
| * | |||
| * @note This function can be used only for STM32F42xxx/43xxx devices. | |||
| * | |||
| * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000) | |||
| * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000) | |||
| * | |||
| * @retval None | |||
| */ | |||
| void HAL_DisableMemorySwappingBank(void) | |||
| { | |||
| *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)DISABLE; | |||
| } | |||
| #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,840 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_adc_ex.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief This file provides firmware functions to manage the following | |||
| * functionalities of the ADC extension peripheral: | |||
| * + Extended features functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] | |||
| (#)Initialize the ADC low level resources by implementing the HAL_ADC_MspInit(): | |||
| (##) Enable the ADC interface clock using __ADC_CLK_ENABLE() | |||
| (##) ADC pins configuration | |||
| (+++) Enable the clock for the ADC GPIOs using the following function: | |||
| __GPIOx_CLK_ENABLE() | |||
| (+++) Configure these ADC pins in analog mode using HAL_GPIO_Init() | |||
| (##) In case of using interrupts (e.g. HAL_ADC_Start_IT()) | |||
| (+++) Configure the ADC interrupt priority using HAL_NVIC_SetPriority() | |||
| (+++) Enable the ADC IRQ handler using HAL_NVIC_EnableIRQ() | |||
| (+++) In ADC IRQ handler, call HAL_ADC_IRQHandler() | |||
| (##) In case of using DMA to control data transfer (e.g. HAL_ADC_Start_DMA()) | |||
| (+++) Enable the DMAx interface clock using __DMAx_CLK_ENABLE() | |||
| (+++) Configure and enable two DMA streams stream for managing data | |||
| transfer from peripheral to memory (output stream) | |||
| (+++) Associate the initilalized DMA handle to the ADC DMA handle | |||
| using __HAL_LINKDMA() | |||
| (+++) Configure the priority and enable the NVIC for the transfer complete | |||
| interrupt on the two DMA Streams. The output stream should have higher | |||
| priority than the input stream. | |||
| (#) Configure the ADC Prescaler, conversion resolution and data alignment | |||
| using the HAL_ADC_Init() function. | |||
| (#) Configure the ADC Injected channels group features, use HAL_ADC_Init() | |||
| and HAL_ADC_ConfigChannel() functions. | |||
| (#) Three operation modes are available within this driver : | |||
| *** Polling mode IO operation *** | |||
| ================================= | |||
| [..] | |||
| (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart() | |||
| (+) Wait for end of conversion using HAL_ADC_PollForConversion(), at this stage | |||
| user can specify the value of timeout according to his end application | |||
| (+) To read the ADC converted values, use the HAL_ADCEx_InjectedGetValue() function. | |||
| (+) Stop the ADC peripheral using HAL_ADCEx_InjectedStop() | |||
| *** Interrupt mode IO operation *** | |||
| =================================== | |||
| [..] | |||
| (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart_IT() | |||
| (+) Use HAL_ADC_IRQHandler() called under ADC_IRQHandler() Interrupt subroutine | |||
| (+) At ADC end of conversion HAL_ADCEx_InjectedConvCpltCallback() function is executed and user can | |||
| add his own code by customization of function pointer HAL_ADCEx_InjectedConvCpltCallback | |||
| (+) In case of ADC Error, HAL_ADCEx_InjectedErrorCallback() function is executed and user can | |||
| add his own code by customization of function pointer HAL_ADCEx_InjectedErrorCallback | |||
| (+) Stop the ADC peripheral using HAL_ADCEx_InjectedStop_IT() | |||
| *** DMA mode IO operation *** | |||
| ============================== | |||
| [..] | |||
| (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart_DMA(), at this stage the user specify the length | |||
| of data to be transferred at each end of conversion | |||
| (+) At The end of data transfer ba HAL_ADCEx_InjectedConvCpltCallback() function is executed and user can | |||
| add his own code by customization of function pointer HAL_ADCEx_InjectedConvCpltCallback | |||
| (+) In case of transfer Error, HAL_ADCEx_InjectedErrorCallback() function is executed and user can | |||
| add his own code by customization of function pointer HAL_ADCEx_InjectedErrorCallback | |||
| (+) Stop the ADC peripheral using HAL_ADCEx_InjectedStop_DMA() | |||
| *** Multi mode ADCs Regular channels configuration *** | |||
| ====================================================== | |||
| [..] | |||
| (+) Select the Multi mode ADC regular channels features (dual or triple mode) | |||
| and configure the DMA mode using HAL_ADCEx_MultiModeConfigChannel() functions. | |||
| (+) Start the ADC peripheral using HAL_ADCEx_MultiModeStart_DMA(), at this stage the user specify the length | |||
| of data to be transferred at each end of conversion | |||
| (+) Read the ADCs converted values using the HAL_ADCEx_MultiModeGetValue() function. | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup ADCEx | |||
| * @brief ADC Extended driver modules | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_ADC_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma); | |||
| static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma); | |||
| static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma); | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup ADCEx_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup ADCEx_Group1 Extended features functions | |||
| * @brief Extended features functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Extended features functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Start conversion of injected channel. | |||
| (+) Stop conversion of injected channel. | |||
| (+) Start multimode and enable DMA transfer. | |||
| (+) Stop multimode and disable DMA transfer. | |||
| (+) Get result of injected channel conversion. | |||
| (+) Get result of multimode conversion. | |||
| (+) Configure injected channels. | |||
| (+) Configure multimode. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Enables the selected ADC software start conversion of the injected channels. | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc) | |||
| { | |||
| uint32_t i = 0, tmp1 = 0, tmp2 = 0; | |||
| /* Process locked */ | |||
| __HAL_LOCK(hadc); | |||
| /* Check if a regular conversion is ongoing */ | |||
| if(hadc->State == HAL_ADC_STATE_BUSY_REG) | |||
| { | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_BUSY_INJ_REG; | |||
| } | |||
| else | |||
| { | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_BUSY_INJ; | |||
| } | |||
| /* Check if ADC peripheral is disabled in order to enable it and wait during | |||
| Tstab time the ADC's stabilization */ | |||
| if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON) | |||
| { | |||
| /* Enable the Peripheral */ | |||
| __HAL_ADC_ENABLE(hadc); | |||
| /* Delay inserted to wait during Tstab time the ADC's stabilazation */ | |||
| for(; i <= 540; i++) | |||
| { | |||
| __NOP(); | |||
| } | |||
| } | |||
| /* Check if Multimode enabled */ | |||
| if(HAL_IS_BIT_CLR(ADC->CCR, ADC_CCR_MULTI)) | |||
| { | |||
| tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN); | |||
| tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO); | |||
| if(tmp1 && tmp2) | |||
| { | |||
| /* Enable the selected ADC software conversion for injected group */ | |||
| hadc->Instance->CR2 |= ADC_CR2_JSWSTART; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN); | |||
| tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO); | |||
| if((hadc->Instance == ADC1) && tmp1 && tmp2) | |||
| { | |||
| /* Enable the selected ADC software conversion for injected group */ | |||
| hadc->Instance->CR2 |= ADC_CR2_JSWSTART; | |||
| } | |||
| } | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hadc); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Enables the interrupt and starts ADC conversion of injected channels. | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * | |||
| * @retval HAL status. | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc) | |||
| { | |||
| uint32_t i = 0, tmp1 = 0, tmp2 =0; | |||
| /* Process locked */ | |||
| __HAL_LOCK(hadc); | |||
| /* Check if a regular conversion is ongoing */ | |||
| if(hadc->State == HAL_ADC_STATE_BUSY_REG) | |||
| { | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_BUSY_INJ_REG; | |||
| } | |||
| else | |||
| { | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_BUSY_INJ; | |||
| } | |||
| /* Set ADC error code to none */ | |||
| hadc->ErrorCode = HAL_ADC_ERROR_NONE; | |||
| /* Check if ADC peripheral is disabled in order to enable it and wait during | |||
| Tstab time the ADC's stabilization */ | |||
| if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON) | |||
| { | |||
| /* Enable the Peripheral */ | |||
| __HAL_ADC_ENABLE(hadc); | |||
| /* Delay inserted to wait during Tstab time the ADC's stabilazation */ | |||
| for(; i <= 540; i++) | |||
| { | |||
| __NOP(); | |||
| } | |||
| } | |||
| /* Enable the ADC end of conversion interrupt for injected group */ | |||
| __HAL_ADC_ENABLE_IT(hadc, ADC_IT_JEOC); | |||
| /* Enable the ADC overrun interrupt */ | |||
| __HAL_ADC_ENABLE_IT(hadc, ADC_IT_OVR); | |||
| /* Check if Multimode enabled */ | |||
| if(HAL_IS_BIT_CLR(ADC->CCR, ADC_CCR_MULTI)) | |||
| { | |||
| tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN); | |||
| tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO); | |||
| if(tmp1 && tmp2) | |||
| { | |||
| /* Enable the selected ADC software conversion for injected group */ | |||
| hadc->Instance->CR2 |= ADC_CR2_JSWSTART; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN); | |||
| tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO); | |||
| if((hadc->Instance == ADC1) && tmp1 && tmp2) | |||
| { | |||
| /* Enable the selected ADC software conversion for injected group */ | |||
| hadc->Instance->CR2 |= ADC_CR2_JSWSTART; | |||
| } | |||
| } | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hadc); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Disables ADC and stop conversion of injected channels. | |||
| * | |||
| * @note Caution: This function will stop also regular channels. | |||
| * | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @retval HAL status. | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc) | |||
| { | |||
| /* Disable the Peripheral */ | |||
| __HAL_ADC_DISABLE(hadc); | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_READY; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Poll for injected conversion complete | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @param Timeout: Timeout value in millisecond. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout) | |||
| { | |||
| uint32_t tickstart = 0; | |||
| /* Get tick */ | |||
| tickstart = HAL_GetTick(); | |||
| /* Check End of conversion flag */ | |||
| while(!(__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_JEOC))) | |||
| { | |||
| /* Check for the Timeout */ | |||
| if(Timeout != HAL_MAX_DELAY) | |||
| { | |||
| if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) | |||
| { | |||
| hadc->State= HAL_ADC_STATE_TIMEOUT; | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hadc); | |||
| return HAL_TIMEOUT; | |||
| } | |||
| } | |||
| } | |||
| /* Check if a regular conversion is ready */ | |||
| if(hadc->State == HAL_ADC_STATE_EOC_REG) | |||
| { | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_EOC_INJ_REG; | |||
| } | |||
| else | |||
| { | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_EOC_INJ; | |||
| } | |||
| /* Return ADC state */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Disables the interrupt and stop ADC conversion of injected channels. | |||
| * | |||
| * @note Caution: This function will stop also regular channels. | |||
| * | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @retval HAL status. | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc) | |||
| { | |||
| /* Disable the ADC end of conversion interrupt for regular group */ | |||
| __HAL_ADC_DISABLE_IT(hadc, ADC_IT_EOC); | |||
| /* Disable the ADC end of conversion interrupt for injected group */ | |||
| __HAL_ADC_DISABLE_IT(hadc, ADC_CR1_JEOCIE); | |||
| /* Enable the Periphral */ | |||
| __HAL_ADC_DISABLE(hadc); | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_READY; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Gets the converted value from data register of injected channel. | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @param InjectedRank: the ADC injected rank. | |||
| * This parameter can be one of the following values: | |||
| * @arg ADC_INJECTED_RANK_1: Injected Channel1 selected | |||
| * @arg ADC_INJECTED_RANK_2: Injected Channel2 selected | |||
| * @arg ADC_INJECTED_RANK_3: Injected Channel3 selected | |||
| * @arg ADC_INJECTED_RANK_4: Injected Channel4 selected | |||
| * @retval None | |||
| */ | |||
| uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank) | |||
| { | |||
| __IO uint32_t tmp = 0; | |||
| /* Check the parameters */ | |||
| assert_param(IS_ADC_INJECTED_RANK(InjectedRank)); | |||
| /* Clear the ADCx's flag for injected end of conversion */ | |||
| __HAL_ADC_CLEAR_FLAG(hadc,ADC_FLAG_JEOC); | |||
| /* Return the selected ADC converted value */ | |||
| switch(InjectedRank) | |||
| { | |||
| case ADC_INJECTED_RANK_4: | |||
| { | |||
| tmp = hadc->Instance->JDR4; | |||
| } | |||
| break; | |||
| case ADC_INJECTED_RANK_3: | |||
| { | |||
| tmp = hadc->Instance->JDR3; | |||
| } | |||
| break; | |||
| case ADC_INJECTED_RANK_2: | |||
| { | |||
| tmp = hadc->Instance->JDR2; | |||
| } | |||
| break; | |||
| case ADC_INJECTED_RANK_1: | |||
| { | |||
| tmp = hadc->Instance->JDR1; | |||
| } | |||
| break; | |||
| default: | |||
| break; | |||
| } | |||
| return tmp; | |||
| } | |||
| /** | |||
| * @brief Enables ADC DMA request after last transfer (Multi-ADC mode) and enables ADC peripheral | |||
| * | |||
| * @note Caution: This function must be used only with the ADC master. | |||
| * | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @param pData: Pointer to buffer in which transferred from ADC peripheral to memory will be stored. | |||
| * @param Length: The length of data to be transferred from ADC peripheral to memory. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length) | |||
| { | |||
| uint16_t counter = 0; | |||
| /* Check the parameters */ | |||
| assert_param(IS_FUNCTIONAL_STATE(hadc->Init.ContinuousConvMode)); | |||
| assert_param(IS_ADC_EXT_TRIG_EDGE(hadc->Init.ExternalTrigConvEdge)); | |||
| assert_param(IS_FUNCTIONAL_STATE(hadc->Init.DMAContinuousRequests)); | |||
| /* Process locked */ | |||
| __HAL_LOCK(hadc); | |||
| /* Enable ADC overrun interrupt */ | |||
| __HAL_ADC_ENABLE_IT(hadc, ADC_IT_OVR); | |||
| if (hadc->Init.DMAContinuousRequests != DISABLE) | |||
| { | |||
| /* Enable the selected ADC DMA request after last transfer */ | |||
| ADC->CCR |= ADC_CCR_DDS; | |||
| } | |||
| else | |||
| { | |||
| /* Disable the selected ADC EOC rising on each regular channel conversion */ | |||
| ADC->CCR &= ~ADC_CCR_DDS; | |||
| } | |||
| /* Set the DMA transfer complete callback */ | |||
| hadc->DMA_Handle->XferCpltCallback = ADC_MultiModeDMAConvCplt; | |||
| /* Set the DMA half transfer complete callback */ | |||
| hadc->DMA_Handle->XferHalfCpltCallback = ADC_MultiModeDMAHalfConvCplt; | |||
| /* Set the DMA error callback */ | |||
| hadc->DMA_Handle->XferErrorCallback = ADC_MultiModeDMAError ; | |||
| /* Enable the DMA Stream */ | |||
| HAL_DMA_Start_IT(hadc->DMA_Handle, (uint32_t)&ADC->CDR, (uint32_t)pData, Length); | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_BUSY_REG; | |||
| /* Check if ADC peripheral is disabled in order to enable it and wait during | |||
| Tstab time the ADC's stabilization */ | |||
| if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON) | |||
| { | |||
| /* Enable the Peripheral */ | |||
| __HAL_ADC_ENABLE(hadc); | |||
| /* Delay inserted to wait during Tstab time the ADC's stabilazation */ | |||
| for(; counter <= 540; counter++) | |||
| { | |||
| __NOP(); | |||
| } | |||
| } | |||
| /* if no external trigger present enable software conversion of regular channels */ | |||
| if (hadc->Init.ExternalTrigConvEdge == ADC_EXTERNALTRIGCONVEDGE_NONE) | |||
| { | |||
| /* Enable the selected ADC software conversion for regular group */ | |||
| hadc->Instance->CR2 |= (uint32_t)ADC_CR2_SWSTART; | |||
| } | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hadc); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Disables ADC DMA (multi-ADC mode) and disables ADC peripheral | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef* hadc) | |||
| { | |||
| /* Process locked */ | |||
| __HAL_LOCK(hadc); | |||
| /* Enable the Peripheral */ | |||
| __HAL_ADC_DISABLE(hadc); | |||
| /* Disable ADC overrun interrupt */ | |||
| __HAL_ADC_DISABLE_IT(hadc, ADC_IT_OVR); | |||
| /* Disable the selected ADC DMA request after last transfer */ | |||
| ADC->CCR &= ~ADC_CCR_DDS; | |||
| /* Disable the ADC DMA Stream */ | |||
| HAL_DMA_Abort(hadc->DMA_Handle); | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_READY; | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hadc); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Returns the last ADC1, ADC2 and ADC3 regular conversions results | |||
| * data in the selected multi mode. | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @retval The converted data value. | |||
| */ | |||
| uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef* hadc) | |||
| { | |||
| /* Return the multi mode conversion value */ | |||
| return ADC->CDR; | |||
| } | |||
| /** | |||
| * @brief Injected conversion complete callback in non blocking mode | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_ADC_InjectedConvCpltCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief Configures for the selected ADC injected channel its corresponding | |||
| * rank in the sequencer and its sample time. | |||
| * @param hadc: pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @param sConfigInjected: ADC configuration structure for injected channel. | |||
| * @retval None | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc, ADC_InjectionConfTypeDef* sConfigInjected) | |||
| { | |||
| #ifdef USE_FULL_ASSERT | |||
| uint32_t tmp = 0; | |||
| #endif /* USE_FULL_ASSERT */ | |||
| /* Check the parameters */ | |||
| assert_param(IS_ADC_CHANNEL(sConfigInjected->InjectedChannel)); | |||
| assert_param(IS_ADC_INJECTED_RANK(sConfigInjected->InjectedRank)); | |||
| assert_param(IS_ADC_SAMPLE_TIME(sConfigInjected->InjectedSamplingTime)); | |||
| assert_param(IS_ADC_EXT_INJEC_TRIG(sConfigInjected->ExternalTrigInjecConv)); | |||
| assert_param(IS_ADC_EXT_INJEC_TRIG_EDGE(sConfigInjected->ExternalTrigInjecConvEdge)); | |||
| assert_param(IS_ADC_INJECTED_LENGTH(sConfigInjected->InjectedNbrOfConversion)); | |||
| assert_param(IS_FUNCTIONAL_STATE(sConfigInjected->AutoInjectedConv)); | |||
| assert_param(IS_FUNCTIONAL_STATE(sConfigInjected->InjectedDiscontinuousConvMode)); | |||
| #ifdef USE_FULL_ASSERT | |||
| tmp = __HAL_ADC_GET_RESOLUTION(hadc); | |||
| assert_param(IS_ADC_RANGE(tmp, sConfigInjected->InjectedOffset)); | |||
| #endif /* USE_FULL_ASSERT */ | |||
| /* Process locked */ | |||
| __HAL_LOCK(hadc); | |||
| /* if ADC_Channel_10 ... ADC_Channel_18 is selected */ | |||
| if (sConfigInjected->InjectedChannel > ADC_CHANNEL_9) | |||
| { | |||
| /* Clear the old sample time */ | |||
| hadc->Instance->SMPR1 &= ~__HAL_ADC_SMPR1(ADC_SMPR1_SMP10, sConfigInjected->InjectedChannel); | |||
| /* Set the new sample time */ | |||
| hadc->Instance->SMPR1 |= __HAL_ADC_SMPR1(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel); | |||
| } | |||
| else /* ADC_Channel include in ADC_Channel_[0..9] */ | |||
| { | |||
| /* Clear the old sample time */ | |||
| hadc->Instance->SMPR2 &= ~__HAL_ADC_SMPR2(ADC_SMPR2_SMP0, sConfigInjected->InjectedChannel); | |||
| /* Set the new sample time */ | |||
| hadc->Instance->SMPR2 |= __HAL_ADC_SMPR2(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel); | |||
| } | |||
| /*---------------------------- ADCx JSQR Configuration -----------------*/ | |||
| hadc->Instance->JSQR &= ~(ADC_JSQR_JL); | |||
| hadc->Instance->JSQR |= __HAL_ADC_SQR1(sConfigInjected->InjectedNbrOfConversion); | |||
| /* Rank configuration */ | |||
| /* Clear the old SQx bits for the selected rank */ | |||
| hadc->Instance->JSQR &= ~__HAL_ADC_JSQR(ADC_JSQR_JSQ1, sConfigInjected->InjectedRank,sConfigInjected->InjectedNbrOfConversion); | |||
| /* Set the SQx bits for the selected rank */ | |||
| hadc->Instance->JSQR |= __HAL_ADC_JSQR(sConfigInjected->InjectedChannel, sConfigInjected->InjectedRank,sConfigInjected->InjectedNbrOfConversion); | |||
| /* Select external trigger to start conversion */ | |||
| hadc->Instance->CR2 &= ~(ADC_CR2_JEXTSEL); | |||
| hadc->Instance->CR2 |= sConfigInjected->ExternalTrigInjecConv; | |||
| /* Select external trigger polarity */ | |||
| hadc->Instance->CR2 &= ~(ADC_CR2_JEXTEN); | |||
| hadc->Instance->CR2 |= sConfigInjected->ExternalTrigInjecConvEdge; | |||
| if (sConfigInjected->AutoInjectedConv != DISABLE) | |||
| { | |||
| /* Enable the selected ADC automatic injected group conversion */ | |||
| hadc->Instance->CR1 |= ADC_CR1_JAUTO; | |||
| } | |||
| else | |||
| { | |||
| /* Disable the selected ADC automatic injected group conversion */ | |||
| hadc->Instance->CR1 &= ~(ADC_CR1_JAUTO); | |||
| } | |||
| if (sConfigInjected->InjectedDiscontinuousConvMode != DISABLE) | |||
| { | |||
| /* Enable the selected ADC injected discontinuous mode */ | |||
| hadc->Instance->CR1 |= ADC_CR1_JDISCEN; | |||
| } | |||
| else | |||
| { | |||
| /* Disable the selected ADC injected discontinuous mode */ | |||
| hadc->Instance->CR1 &= ~(ADC_CR1_JDISCEN); | |||
| } | |||
| switch(sConfigInjected->InjectedRank) | |||
| { | |||
| case 1: | |||
| /* Set injected channel 1 offset */ | |||
| hadc->Instance->JOFR1 &= ~(ADC_JOFR1_JOFFSET1); | |||
| hadc->Instance->JOFR1 |= sConfigInjected->InjectedOffset; | |||
| break; | |||
| case 2: | |||
| /* Set injected channel 2 offset */ | |||
| hadc->Instance->JOFR2 &= ~(ADC_JOFR2_JOFFSET2); | |||
| hadc->Instance->JOFR2 |= sConfigInjected->InjectedOffset; | |||
| break; | |||
| case 3: | |||
| /* Set injected channel 3 offset */ | |||
| hadc->Instance->JOFR3 &= ~(ADC_JOFR3_JOFFSET3); | |||
| hadc->Instance->JOFR3 |= sConfigInjected->InjectedOffset; | |||
| break; | |||
| default: | |||
| /* Set injected channel 4 offset */ | |||
| hadc->Instance->JOFR4 &= ~(ADC_JOFR4_JOFFSET4); | |||
| hadc->Instance->JOFR4 |= sConfigInjected->InjectedOffset; | |||
| break; | |||
| } | |||
| /* if ADC1 Channel_18 is selected enable VBAT Channel */ | |||
| if ((hadc->Instance == ADC1) && (sConfigInjected->InjectedChannel == ADC_CHANNEL_VBAT)) | |||
| { | |||
| /* Enable the VBAT channel*/ | |||
| ADC->CCR |= ADC_CCR_VBATE; | |||
| } | |||
| /* if ADC1 Channel_16 or Channel_17 is selected enable TSVREFE Channel(Temperature sensor and VREFINT) */ | |||
| if ((hadc->Instance == ADC1) && ((sConfigInjected->InjectedChannel == ADC_CHANNEL_TEMPSENSOR) || (sConfigInjected->InjectedChannel == ADC_CHANNEL_VREFINT))) | |||
| { | |||
| /* Enable the TSVREFE channel*/ | |||
| ADC->CCR |= ADC_CCR_TSVREFE; | |||
| } | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hadc); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Configures the ADC multi-mode | |||
| * @param hadc : pointer to a ADC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified ADC. | |||
| * @param multimode : pointer to an ADC_MultiModeTypeDef structure that contains | |||
| * the configuration information for multimode. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_MultiModeTypeDef* multimode) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_ADC_MODE(multimode->Mode)); | |||
| assert_param(IS_ADC_DMA_ACCESS_MODE(multimode->DMAAccessMode)); | |||
| assert_param(IS_ADC_SAMPLING_DELAY(multimode->TwoSamplingDelay)); | |||
| /* Process locked */ | |||
| __HAL_LOCK(hadc); | |||
| /* Set ADC mode */ | |||
| ADC->CCR &= ~(ADC_CCR_MULTI); | |||
| ADC->CCR |= multimode->Mode; | |||
| /* Set the ADC DMA access mode */ | |||
| ADC->CCR &= ~(ADC_CCR_DMA); | |||
| ADC->CCR |= multimode->DMAAccessMode; | |||
| /* Set delay between two sampling phases */ | |||
| ADC->CCR &= ~(ADC_CCR_DELAY); | |||
| ADC->CCR |= multimode->TwoSamplingDelay; | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hadc); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief DMA transfer complete callback. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma) | |||
| { | |||
| ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| /* Check if an injected conversion is ready */ | |||
| if(hadc->State == HAL_ADC_STATE_EOC_INJ) | |||
| { | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_EOC_INJ_REG; | |||
| } | |||
| else | |||
| { | |||
| /* Change ADC state */ | |||
| hadc->State = HAL_ADC_STATE_EOC_REG; | |||
| } | |||
| HAL_ADC_ConvCpltCallback(hadc); | |||
| } | |||
| /** | |||
| * @brief DMA half transfer complete callback. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma) | |||
| { | |||
| ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| /* Conversion complete callback */ | |||
| HAL_ADC_ConvHalfCpltCallback(hadc); | |||
| } | |||
| /** | |||
| * @brief DMA error callback | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma) | |||
| { | |||
| ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| hadc->State= HAL_ADC_STATE_ERROR; | |||
| /* Set ADC error code to DMA error */ | |||
| hadc->ErrorCode |= HAL_ADC_ERROR_DMA; | |||
| HAL_ADC_ErrorCallback(hadc); | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* HAL_ADC_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,422 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_cortex.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief CORTEX HAL module driver. | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of the CORTEX: | |||
| * + Initialization and de-initialization 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-M4 exceptions are managed by CMSIS functions. | |||
| (#) Configure the NVIC Priority Grouping using HAL_NVIC_SetPriorityGrouping() | |||
| function according to the following table. | |||
| (#) Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority(). | |||
| (#) Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ(). | |||
| (#) please refer to programing manual for details in how to configure priority. | |||
| -@- When the NVIC_PRIORITYGROUP_0 is selected, IRQ pre-emption is no more possible. | |||
| The pending IRQ priority will be managed only by the sub priority. | |||
| -@- IRQ priority order (sorted by highest to lowest priority): | |||
| (+@) Lowest pre-emption priority | |||
| (+@) Lowest sub priority | |||
| (+@) Lowest hardware priority (IRQ number) | |||
| [..] | |||
| *** 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 (0x0F). | |||
| (++) 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 macro | |||
| __HAL_CORTEX_SYSTICKCLK_CONFIG(SYSTICK_CLKSOURCE_HCLK_DIV8) just after the | |||
| HAL_SYSTICK_Config() function call. The __HAL_CORTEX_SYSTICKCLK_CONFIG() macro is defined | |||
| inside the stm32f4xx_hal_cortex.h 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) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup CORTEX | |||
| * @brief CORTEX HAL module driver | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_CORTEX_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup CORTEX_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup CORTEX_Group1 Initialization and de-initialization functions | |||
| * @brief Initialization and Configuration functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### Initialization and de-initialization functions ##### | |||
| ============================================================================== | |||
| [..] | |||
| This section provides the CORTEX HAL driver functions allowing to configure Interrupts | |||
| Systick functionalities | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Sets the priority grouping field (pre-emption priority and subpriority) | |||
| * using the required unlock sequence. | |||
| * @param PriorityGroup: The priority grouping bits length. | |||
| * This parameter can be one of the following values: | |||
| * @arg NVIC_PRIORITYGROUP_0: 0 bits for pre-emption priority | |||
| * 4 bits for subpriority | |||
| * @arg NVIC_PRIORITYGROUP_1: 1 bits for pre-emption priority | |||
| * 3 bits for subpriority | |||
| * @arg NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority | |||
| * 2 bits for subpriority | |||
| * @arg NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority | |||
| * 1 bits for subpriority | |||
| * @arg NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority | |||
| * 0 bits for subpriority | |||
| * @note When the NVIC_PriorityGroup_0 is selected, IRQ pre-emption is no more possible. | |||
| * The pending IRQ priority will be managed only by the subpriority. | |||
| * @retval None | |||
| */ | |||
| void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup)); | |||
| /* Set the PRIGROUP[10:8] bits according to the PriorityGroup parameter value */ | |||
| NVIC_SetPriorityGrouping(PriorityGroup); | |||
| } | |||
| /** | |||
| * @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 stm32f4xx.h file) | |||
| * @param PreemptPriority: The pre-emption priority for the IRQn channel. | |||
| * This parameter can be a value between 0 and 15 | |||
| * A lower priority value indicates a higher priority | |||
| * @param SubPriority: the subpriority level for the IRQ channel. | |||
| * This parameter can be a value between 0 and 15 | |||
| * A lower priority value indicates a higher priority. | |||
| * @retval None | |||
| */ | |||
| void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority) | |||
| { | |||
| uint32_t prioritygroup = 0x00; | |||
| /* Check the parameters */ | |||
| assert_param(IS_NVIC_SUB_PRIORITY(SubPriority)); | |||
| assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority)); | |||
| prioritygroup = NVIC_GetPriorityGrouping(); | |||
| NVIC_SetPriority(IRQn, NVIC_EncodePriority(prioritygroup, PreemptPriority, SubPriority)); | |||
| } | |||
| /** | |||
| * @brief Enables 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 stm32f4xx.h file) | |||
| * @retval None | |||
| */ | |||
| void HAL_NVIC_EnableIRQ(IRQn_Type IRQn) | |||
| { | |||
| /* Enable interrupt */ | |||
| NVIC_EnableIRQ(IRQn); | |||
| } | |||
| /** | |||
| * @brief Disables 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 stm32f4xx.h file) | |||
| * @retval None | |||
| */ | |||
| void HAL_NVIC_DisableIRQ(IRQn_Type IRQn) | |||
| { | |||
| /* Disable interrupt */ | |||
| NVIC_DisableIRQ(IRQn); | |||
| } | |||
| /** | |||
| * @brief Initiates a system reset request to reset the MCU. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_NVIC_SystemReset(void) | |||
| { | |||
| /* System Reset */ | |||
| NVIC_SystemReset(); | |||
| } | |||
| /** | |||
| * @brief Initializes the System Timer and its interrupt, and starts the System Tick Timer. | |||
| * 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); | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CORTEX_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 grouping field from the NVIC Interrupt Controller. | |||
| * @param None | |||
| * @retval Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field) | |||
| */ | |||
| uint32_t HAL_NVIC_GetPriorityGrouping(void) | |||
| { | |||
| /* Get the PRIGROUP[10:8] field value */ | |||
| return NVIC_GetPriorityGrouping(); | |||
| } | |||
| /** | |||
| * @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 stm32f4xx.h file) | |||
| * @param PriorityGroup: the priority grouping bits length. | |||
| * This parameter can be one of the following values: | |||
| * @arg NVIC_PRIORITYGROUP_0: 0 bits for pre-emption priority | |||
| * 4 bits for subpriority | |||
| * @arg NVIC_PRIORITYGROUP_1: 1 bits for pre-emption priority | |||
| * 3 bits for subpriority | |||
| * @arg NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority | |||
| * 2 bits for subpriority | |||
| * @arg NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority | |||
| * 1 bits for subpriority | |||
| * @arg NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority | |||
| * 0 bits for subpriority | |||
| * @param pPreemptPriority: Pointer on the Preemptive priority value (starting from 0). | |||
| * @param pSubPriority: Pointer on the Subpriority value (starting from 0). | |||
| * @retval None | |||
| */ | |||
| void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup)); | |||
| /* Get priority for Cortex-M system or device specific interrupts */ | |||
| NVIC_DecodePriority(NVIC_GetPriority(IRQn), PriorityGroup, pPreemptPriority, pSubPriority); | |||
| } | |||
| /** | |||
| * @brief Sets Pending bit of an external interrupt. | |||
| * @param IRQn External interrupt number | |||
| * This parameter can be an enumerator of @ref IRQn_Type enumeration | |||
| * (For the complete STM32 Devices IRQ Channels list, please refer to stm32f4xx.h file) | |||
| * @retval None | |||
| */ | |||
| void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn) | |||
| { | |||
| /* Set interrupt pending */ | |||
| NVIC_SetPendingIRQ(IRQn); | |||
| } | |||
| /** | |||
| * @brief Gets Pending Interrupt (reads the pending register in the NVIC | |||
| * and returns 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 stm32f4xx.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 Clears 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 stm32f4xx.h file) | |||
| * @retval None | |||
| */ | |||
| void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn) | |||
| { | |||
| /* Clear pending interrupt */ | |||
| NVIC_ClearPendingIRQ(IRQn); | |||
| } | |||
| /** | |||
| * @brief Gets active interrupt ( reads the active register in NVIC and returns the active bit). | |||
| * @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 stm32f4xx.h file) | |||
| * @retval status: - 0 Interrupt status is not pending. | |||
| * - 1 Interrupt status is pending. | |||
| */ | |||
| uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn) | |||
| { | |||
| /* Return 1 if active else 0 */ | |||
| return NVIC_GetActive(IRQn); | |||
| } | |||
| /** | |||
| * @brief Configures 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 This function handles SYSTICK interrupt request. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_SYSTICK_IRQHandler(void) | |||
| { | |||
| HAL_SYSTICK_Callback(); | |||
| } | |||
| /** | |||
| * @brief SYSTICK callback. | |||
| * @param None | |||
| * @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 | |||
| */ | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* HAL_CORTEX_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,339 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_crc.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief CRC HAL module driver. | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of the Cyclic Redundancy Check (CRC) peripheral: | |||
| * + Initialization and de-initialization functions | |||
| * + Peripheral Control functions | |||
| * + Peripheral State functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] | |||
| The CRC HAL driver can be used as follows: | |||
| (#) Enable CRC AHB clock using __CRC_CLK_ENABLE(); | |||
| (#) Use HAL_CRC_Accumulate() function to compute the CRC value of | |||
| a 32-bit data buffer using combination of the previous CRC value | |||
| and the new one. | |||
| (#) Use HAL_CRC_Calculate() function to compute the CRC Value of | |||
| a new 32-bit data buffer. This function resets the CRC computation | |||
| unit before starting the computation to avoid getting wrong CRC values. | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup CRC | |||
| * @brief CRC HAL module driver. | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_CRC_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup CRC_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup CRC_Group1 Initialization and de-initialization functions | |||
| * @brief Initialization and Configuration functions. | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### Initialization and de-initialization functions ##### | |||
| ============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Initialize the CRC according to the specified parameters | |||
| in the CRC_InitTypeDef and create the associated handle | |||
| (+) DeInitialize the CRC peripheral | |||
| (+) Initialize the CRC MSP | |||
| (+) DeInitialize CRC MSP | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Initializes the CRC according to the specified | |||
| * parameters in the CRC_InitTypeDef and creates the associated handle. | |||
| * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains | |||
| * the configuration information for CRC | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc) | |||
| { | |||
| /* Check the CRC handle allocation */ | |||
| if(hcrc == NULL) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check the parameters */ | |||
| assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance)); | |||
| if(hcrc->State == HAL_CRC_STATE_RESET) | |||
| { | |||
| /* Init the low level hardware */ | |||
| HAL_CRC_MspInit(hcrc); | |||
| } | |||
| /* Change CRC peripheral state */ | |||
| hcrc->State = HAL_CRC_STATE_BUSY; | |||
| /* Change CRC peripheral state */ | |||
| hcrc->State = HAL_CRC_STATE_READY; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief DeInitializes the CRC peripheral. | |||
| * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains | |||
| * the configuration information for CRC | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc) | |||
| { | |||
| /* Check the CRC handle allocation */ | |||
| if(hcrc == NULL) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check the parameters */ | |||
| assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance)); | |||
| /* Change CRC peripheral state */ | |||
| hcrc->State = HAL_CRC_STATE_BUSY; | |||
| /* DeInit the low level hardware */ | |||
| HAL_CRC_MspDeInit(hcrc); | |||
| /* Change CRC peripheral state */ | |||
| hcrc->State = HAL_CRC_STATE_RESET; | |||
| /* Release Lock */ | |||
| __HAL_UNLOCK(hcrc); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Initializes the CRC MSP. | |||
| * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains | |||
| * the configuration information for CRC | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_CRC_MspInit could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief DeInitializes the CRC MSP. | |||
| * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains | |||
| * the configuration information for CRC | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_CRC_MspDeInit could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CRC_Group2 Peripheral Control functions | |||
| * @brief management functions. | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### Peripheral Control functions ##### | |||
| ============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Compute the 32-bit CRC value of 32-bit data buffer, | |||
| using combination of the previous CRC value and the new one. | |||
| (+) Compute the 32-bit CRC value of 32-bit data buffer, | |||
| independently of the previous CRC value. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Computes the 32-bit CRC of 32-bit data buffer using combination | |||
| * of the previous CRC value and the new one. | |||
| * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains | |||
| * the configuration information for CRC | |||
| * @param pBuffer: pointer to the buffer containing the data to be computed | |||
| * @param BufferLength: length of the buffer to be computed | |||
| * @retval 32-bit CRC | |||
| */ | |||
| uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength) | |||
| { | |||
| uint32_t index = 0; | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hcrc); | |||
| /* Change CRC peripheral state */ | |||
| hcrc->State = HAL_CRC_STATE_BUSY; | |||
| /* Enter Data to the CRC calculator */ | |||
| for(index = 0; index < BufferLength; index++) | |||
| { | |||
| hcrc->Instance->DR = pBuffer[index]; | |||
| } | |||
| /* Change CRC peripheral state */ | |||
| hcrc->State = HAL_CRC_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hcrc); | |||
| /* Return the CRC computed value */ | |||
| return hcrc->Instance->DR; | |||
| } | |||
| /** | |||
| * @brief Computes the 32-bit CRC of 32-bit data buffer independently | |||
| * of the previous CRC value. | |||
| * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains | |||
| * the configuration information for CRC | |||
| * @param pBuffer: Pointer to the buffer containing the data to be computed | |||
| * @param BufferLength: Length of the buffer to be computed | |||
| * @retval 32-bit CRC | |||
| */ | |||
| uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength) | |||
| { | |||
| uint32_t index = 0; | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hcrc); | |||
| /* Change CRC peripheral state */ | |||
| hcrc->State = HAL_CRC_STATE_BUSY; | |||
| /* Reset CRC Calculation Unit */ | |||
| __HAL_CRC_DR_RESET(hcrc); | |||
| /* Enter Data to the CRC calculator */ | |||
| for(index = 0; index < BufferLength; index++) | |||
| { | |||
| hcrc->Instance->DR = pBuffer[index]; | |||
| } | |||
| /* Change CRC peripheral state */ | |||
| hcrc->State = HAL_CRC_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hcrc); | |||
| /* Return the CRC computed value */ | |||
| return hcrc->Instance->DR; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup CRC_Group3 Peripheral State functions | |||
| * @brief Peripheral State functions. | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### Peripheral State functions ##### | |||
| ============================================================================== | |||
| [..] | |||
| This subsection permits to get in run-time the status of the peripheral | |||
| and the data flow. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Returns the CRC state. | |||
| * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains | |||
| * the configuration information for CRC | |||
| * @retval HAL state | |||
| */ | |||
| HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc) | |||
| { | |||
| return hcrc->State; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* HAL_CRC_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,940 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dac.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief DAC HAL module driver. | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of the Digital to Analog Converter (DAC) peripheral: | |||
| * + Initialization and de-initialization functions | |||
| * + IO operation functions | |||
| * + Peripheral Control functions | |||
| * + Peripheral State and Errors functions | |||
| * | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### DAC Peripheral features ##### | |||
| ============================================================================== | |||
| [..] | |||
| *** DAC Channels *** | |||
| ==================== | |||
| [..] | |||
| The device integrates two 12-bit Digital Analog Converters that can | |||
| be used independently or simultaneously (dual mode): | |||
| (#) DAC channel1 with DAC_OUT1 (PA4) as output | |||
| (#) DAC channel2 with DAC_OUT2 (PA5) as output | |||
| *** DAC Triggers *** | |||
| ==================== | |||
| [..] | |||
| Digital to Analog conversion can be non-triggered using DAC_Trigger_None | |||
| and DAC_OUT1/DAC_OUT2 is available once writing to DHRx register. | |||
| [..] | |||
| Digital to Analog conversion can be triggered by: | |||
| (#) External event: EXTI Line 9 (any GPIOx_Pin9) using DAC_Trigger_Ext_IT9. | |||
| The used pin (GPIOx_Pin9) must be configured in input mode. | |||
| (#) Timers TRGO: TIM2, TIM4, TIM5, TIM6, TIM7 and TIM8 | |||
| (DAC_Trigger_T2_TRGO, DAC_Trigger_T4_TRGO...) | |||
| (#) Software using DAC_Trigger_Software | |||
| *** DAC Buffer mode feature *** | |||
| =============================== | |||
| [..] | |||
| Each DAC channel integrates an output buffer that can be used to | |||
| reduce the output impedance, and to drive external loads directly | |||
| without having to add an external operational amplifier. | |||
| To enable, the output buffer use | |||
| sConfig.DAC_OutputBuffer = DAC_OutputBuffer_Enable; | |||
| [..] | |||
| (@) Refer to the device datasheet for more details about output | |||
| impedance value with and without output buffer. | |||
| *** DAC wave generation feature *** | |||
| =================================== | |||
| [..] | |||
| Both DAC channels can be used to generate | |||
| (#) Noise wave | |||
| (#) Triangle wave | |||
| *** DAC data format *** | |||
| ======================= | |||
| [..] | |||
| The DAC data format can be: | |||
| (#) 8-bit right alignment using DAC_ALIGN_8B_R | |||
| (#) 12-bit left alignment using DAC_ALIGN_12B_L | |||
| (#) 12-bit right alignment using DAC_ALIGN_12B_R | |||
| *** DAC data value to voltage correspondence *** | |||
| ================================================ | |||
| [..] | |||
| The analog output voltage on each DAC channel pin is determined | |||
| by the following equation: | |||
| DAC_OUTx = VREF+ * DOR / 4095 | |||
| with DOR is the Data Output Register | |||
| VEF+ is the input voltage reference (refer to the device datasheet) | |||
| e.g. To set DAC_OUT1 to 0.7V, use | |||
| Assuming that VREF+ = 3.3V, DAC_OUT1 = (3.3 * 868) / 4095 = 0.7V | |||
| *** DMA requests *** | |||
| ===================== | |||
| [..] | |||
| A DMA1 request can be generated when an external trigger (but not | |||
| a software trigger) occurs if DMA1 requests are enabled using | |||
| HAL_DAC_Start_DMA() | |||
| [..] | |||
| DMA1 requests are mapped as following: | |||
| (#) DAC channel1 : mapped on DMA1 Stream5 channel7 which must be | |||
| already configured | |||
| (#) DAC channel2 : mapped on DMA1 Stream6 channel7 which must be | |||
| already configured | |||
| -@- For Dual mode and specific signal (Triangle and noise) generation please | |||
| refer to Extension Features Driver description | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] | |||
| (+) DAC APB clock must be enabled to get write access to DAC | |||
| registers using HAL_DAC_Init() | |||
| (+) Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode. | |||
| (+) Configure the DAC channel using HAL_DAC_ConfigChannel() function. | |||
| (+) Enable the DAC channel using HAL_DAC_Start() or HAL_DAC_Start_DMA functions | |||
| *** Polling mode IO operation *** | |||
| ================================= | |||
| [..] | |||
| (+) Start the DAC peripheral using HAL_DAC_Start() | |||
| (+) To read the DAC last data output value value, use the HAL_DAC_GetValue() function. | |||
| (+) Stop the DAC peripheral using HAL_DAC_Stop() | |||
| *** DMA mode IO operation *** | |||
| ============================== | |||
| [..] | |||
| (+) Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify the length | |||
| of data to be transferred at each end of conversion | |||
| (+) At The end of data transfer HAL_DAC_ConvCpltCallbackCh1()or HAL_DAC_ConvCpltCallbackCh2() | |||
| function is executed and user can add his own code by customization of function pointer | |||
| HAL_DAC_ConvCpltCallbackCh1 or HAL_DAC_ConvCpltCallbackCh2 | |||
| (+) In case of transfer Error, HAL_DAC_ErrorCallbackCh1() function is executed and user can | |||
| add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1 | |||
| (+) Stop the DAC peripheral using HAL_DAC_Stop_DMA() | |||
| *** DAC HAL driver macros list *** | |||
| ============================================= | |||
| [..] | |||
| Below the list of most used macros in DAC HAL driver. | |||
| (+) __HAL_DAC_ENABLE : Enable the DAC peripheral | |||
| (+) __HAL_DAC_DISABLE : Disable the DAC peripheral | |||
| (+) __HAL_DAC_CLEAR_FLAG: Clear the DAC's pending flags | |||
| (+) __HAL_DAC_GET_FLAG: Get the selected DAC's flag status | |||
| [..] | |||
| (@) You can refer to the DAC HAL driver header file for more useful macros | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup DAC | |||
| * @brief DAC driver modules | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_DAC_MODULE_ENABLED | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma); | |||
| static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma); | |||
| static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma); | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup DAC_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup DAC_Group1 Initialization and de-initialization functions | |||
| * @brief Initialization and Configuration functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### Initialization and de-initialization functions ##### | |||
| ============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Initialize and configure the DAC. | |||
| (+) De-initialize the DAC. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Initializes the DAC peripheral according to the specified parameters | |||
| * in the DAC_InitStruct. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* Check DAC handle */ | |||
| if(hdac == NULL) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance)); | |||
| if(hdac->State == HAL_DAC_STATE_RESET) | |||
| { | |||
| /* Init the low level hardware */ | |||
| HAL_DAC_MspInit(hdac); | |||
| } | |||
| /* Initialize the DAC state*/ | |||
| hdac->State = HAL_DAC_STATE_BUSY; | |||
| /* Set DAC error code to none */ | |||
| hdac->ErrorCode = HAL_DAC_ERROR_NONE; | |||
| /* Initialize the DAC state*/ | |||
| hdac->State = HAL_DAC_STATE_READY; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Deinitializes the DAC peripheral registers to their default reset values. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* Check DAC handle */ | |||
| if(hdac == NULL) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance)); | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_BUSY; | |||
| /* DeInit the low level hardware */ | |||
| HAL_DAC_MspDeInit(hdac); | |||
| /* Set DAC error code to none */ | |||
| hdac->ErrorCode = HAL_DAC_ERROR_NONE; | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_RESET; | |||
| /* Release Lock */ | |||
| __HAL_UNLOCK(hdac); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Initializes the DAC MSP. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_MspInit could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief DeInitializes the DAC MSP. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_MspDeInit could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_Group2 IO operation functions | |||
| * @brief IO operation functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### IO operation functions ##### | |||
| ============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Start conversion. | |||
| (+) Stop conversion. | |||
| (+) Start conversion and enable DMA transfer. | |||
| (+) Stop conversion and disable DMA transfer. | |||
| (+) Get result of conversion. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Enables DAC and starts conversion of channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_CHANNEL_1: DAC Channel1 selected | |||
| * @arg DAC_CHANNEL_2: DAC Channel2 selected | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel) | |||
| { | |||
| uint32_t tmp1 = 0, tmp2 = 0; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| /* Process locked */ | |||
| __HAL_LOCK(hdac); | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_BUSY; | |||
| /* Enable the Peripharal */ | |||
| __HAL_DAC_ENABLE(hdac, Channel); | |||
| if(Channel == DAC_CHANNEL_1) | |||
| { | |||
| tmp1 = hdac->Instance->CR & DAC_CR_TEN1; | |||
| tmp2 = hdac->Instance->CR & DAC_CR_TSEL1; | |||
| /* Check if software trigger enabled */ | |||
| if((tmp1 == DAC_CR_TEN1) && (tmp2 == DAC_CR_TSEL1)) | |||
| { | |||
| /* Enable the selected DAC software conversion */ | |||
| hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| tmp1 = hdac->Instance->CR & DAC_CR_TEN2; | |||
| tmp2 = hdac->Instance->CR & DAC_CR_TSEL2; | |||
| /* Check if software trigger enabled */ | |||
| if((tmp1 == DAC_CR_TEN2) && (tmp2 == DAC_CR_TSEL2)) | |||
| { | |||
| /* Enable the selected DAC software conversion*/ | |||
| hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG2; | |||
| } | |||
| } | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_READY; | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hdac); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Disables DAC and stop conversion of channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_CHANNEL_1: DAC Channel1 selected | |||
| * @arg DAC_CHANNEL_2: DAC Channel2 selected | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| /* Disable the Peripheral */ | |||
| __HAL_DAC_DISABLE(hdac, Channel); | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_READY; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Enables DAC and starts conversion of channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_CHANNEL_1: DAC Channel1 selected | |||
| * @arg DAC_CHANNEL_2: DAC Channel2 selected | |||
| * @param pData: The destination peripheral Buffer address. | |||
| * @param Length: The length of data to be transferred from memory to DAC peripheral | |||
| * @param Alignment: Specifies the data alignment for DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected | |||
| * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected | |||
| * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment) | |||
| { | |||
| uint32_t tmpreg = 0; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| assert_param(IS_DAC_ALIGN(Alignment)); | |||
| /* Process locked */ | |||
| __HAL_LOCK(hdac); | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_BUSY; | |||
| if(Channel == DAC_CHANNEL_1) | |||
| { | |||
| /* Set the DMA transfer complete callback for channel1 */ | |||
| hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1; | |||
| /* Set the DMA half transfer complete callback for channel1 */ | |||
| hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1; | |||
| /* Set the DMA error callback for channel1 */ | |||
| hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1; | |||
| /* Enable the selected DAC channel1 DMA request */ | |||
| hdac->Instance->CR |= DAC_CR_DMAEN1; | |||
| /* Case of use of channel 1 */ | |||
| switch(Alignment) | |||
| { | |||
| case DAC_ALIGN_12B_R: | |||
| /* Get DHR12R1 address */ | |||
| tmpreg = (uint32_t)&hdac->Instance->DHR12R1; | |||
| break; | |||
| case DAC_ALIGN_12B_L: | |||
| /* Get DHR12L1 address */ | |||
| tmpreg = (uint32_t)&hdac->Instance->DHR12L1; | |||
| break; | |||
| case DAC_ALIGN_8B_R: | |||
| /* Get DHR8R1 address */ | |||
| tmpreg = (uint32_t)&hdac->Instance->DHR8R1; | |||
| break; | |||
| default: | |||
| break; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| /* Set the DMA transfer complete callback for channel2 */ | |||
| hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2; | |||
| /* Set the DMA half transfer complete callback for channel2 */ | |||
| hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2; | |||
| /* Set the DMA error callback for channel2 */ | |||
| hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2; | |||
| /* Enable the selected DAC channel2 DMA request */ | |||
| hdac->Instance->CR |= DAC_CR_DMAEN2; | |||
| /* Case of use of channel 2 */ | |||
| switch(Alignment) | |||
| { | |||
| case DAC_ALIGN_12B_R: | |||
| /* Get DHR12R2 address */ | |||
| tmpreg = (uint32_t)&hdac->Instance->DHR12R2; | |||
| break; | |||
| case DAC_ALIGN_12B_L: | |||
| /* Get DHR12L2 address */ | |||
| tmpreg = (uint32_t)&hdac->Instance->DHR12L2; | |||
| break; | |||
| case DAC_ALIGN_8B_R: | |||
| /* Get DHR8R2 address */ | |||
| tmpreg = (uint32_t)&hdac->Instance->DHR8R2; | |||
| break; | |||
| default: | |||
| break; | |||
| } | |||
| } | |||
| /* Enable the DMA Stream */ | |||
| if(Channel == DAC_CHANNEL_1) | |||
| { | |||
| /* Enable the DAC DMA underrun interrupt */ | |||
| __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1); | |||
| /* Enable the DMA Stream */ | |||
| HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length); | |||
| } | |||
| else | |||
| { | |||
| /* Enable the DAC DMA underrun interrupt */ | |||
| __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR2); | |||
| /* Enable the DMA Stream */ | |||
| HAL_DMA_Start_IT(hdac->DMA_Handle2, (uint32_t)pData, tmpreg, Length); | |||
| } | |||
| /* Enable the Peripharal */ | |||
| __HAL_DAC_ENABLE(hdac, Channel); | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdac); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Disables DAC and stop conversion of channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_CHANNEL_1: DAC Channel1 selected | |||
| * @arg DAC_CHANNEL_2: DAC Channel2 selected | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel) | |||
| { | |||
| HAL_StatusTypeDef status = HAL_OK; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| /* Disable the selected DAC channel DMA request */ | |||
| hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << Channel); | |||
| /* Disable the Peripharal */ | |||
| __HAL_DAC_DISABLE(hdac, Channel); | |||
| /* Disable the DMA Channel */ | |||
| /* Channel1 is used */ | |||
| if(Channel == DAC_CHANNEL_1) | |||
| { | |||
| status = HAL_DMA_Abort(hdac->DMA_Handle1); | |||
| } | |||
| else /* Channel2 is used for */ | |||
| { | |||
| status = HAL_DMA_Abort(hdac->DMA_Handle2); | |||
| } | |||
| /* Check if DMA Channel effectively disabled */ | |||
| if(status == HAL_ERROR) | |||
| { | |||
| /* Update ADC state machine to error */ | |||
| hdac->State = HAL_DAC_STATE_ERROR; | |||
| } | |||
| else | |||
| { | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_READY; | |||
| } | |||
| /* Return function status */ | |||
| return status; | |||
| } | |||
| /** | |||
| * @brief Returns the last data output value of the selected DAC channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_CHANNEL_1: DAC Channel1 selected | |||
| * @arg DAC_CHANNEL_2: DAC Channel2 selected | |||
| * @retval The selected DAC channel data output value. | |||
| */ | |||
| uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| /* Returns the DAC channel data output register value */ | |||
| if(Channel == DAC_CHANNEL_1) | |||
| { | |||
| return hdac->Instance->DOR1; | |||
| } | |||
| else | |||
| { | |||
| return hdac->Instance->DOR2; | |||
| } | |||
| } | |||
| /** | |||
| * @brief Handles DAC interrupt request | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* Check Overrun flag */ | |||
| if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1)) | |||
| { | |||
| /* Change DAC state to error state */ | |||
| hdac->State = HAL_DAC_STATE_ERROR; | |||
| /* Set DAC error code to chanel1 DMA underrun error */ | |||
| hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH1; | |||
| /* Clear the underrun flag */ | |||
| __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1); | |||
| /* Disable the selected DAC channel1 DMA request */ | |||
| hdac->Instance->CR &= ~DAC_CR_DMAEN1; | |||
| /* Error callback */ | |||
| HAL_DAC_DMAUnderrunCallbackCh1(hdac); | |||
| } | |||
| else | |||
| { | |||
| /* Change DAC state to error state */ | |||
| hdac->State = HAL_DAC_STATE_ERROR; | |||
| /* Set DAC error code to channel2 DMA underrun error */ | |||
| hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH2; | |||
| /* Clear the underrun flag */ | |||
| __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR2); | |||
| /* Disable the selected DAC channel1 DMA request */ | |||
| hdac->Instance->CR &= ~DAC_CR_DMAEN2; | |||
| /* Error callback */ | |||
| HAL_DACEx_DMAUnderrunCallbackCh2(hdac); | |||
| } | |||
| } | |||
| /** | |||
| * @brief Conversion complete callback in non blocking mode for Channel1 | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_ConvCpltCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief Conversion half DMA transfer callback in non blocking mode for Channel1 | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_ConvHalfCpltCallbackCh1 could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief Error DAC callback for Channel1. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_ErrorCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief DMA underrun DAC callback for channel1. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_DMAUnderrunCallbackCh1 could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_Group3 Peripheral Control functions | |||
| * @brief Peripheral Control functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### Peripheral Control functions ##### | |||
| ============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Configure channels. | |||
| (+) Set the specified data holding register value for DAC channel. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Configures the selected DAC channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param sConfig: DAC configuration structure. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_CHANNEL_1: DAC Channel1 selected | |||
| * @arg DAC_CHANNEL_2: DAC Channel2 selected | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel) | |||
| { | |||
| uint32_t tmpreg1 = 0, tmpreg2 = 0; | |||
| /* Check the DAC parameters */ | |||
| assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger)); | |||
| assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer)); | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| /* Process locked */ | |||
| __HAL_LOCK(hdac); | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_BUSY; | |||
| /* Get the DAC CR value */ | |||
| tmpreg1 = DAC->CR; | |||
| /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */ | |||
| tmpreg1 &= ~(((uint32_t)(DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1 | DAC_CR_BOFF1)) << Channel); | |||
| /* Configure for the selected DAC channel: buffer output, trigger */ | |||
| /* Set TSELx and TENx bits according to DAC_Trigger value */ | |||
| /* Set BOFFx bit according to DAC_OutputBuffer value */ | |||
| tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer); | |||
| /* Calculate CR register value depending on DAC_Channel */ | |||
| tmpreg1 |= tmpreg2 << Channel; | |||
| /* Write to DAC CR */ | |||
| DAC->CR = tmpreg1; | |||
| /* Disable wave generation */ | |||
| DAC->CR &= ~(DAC_CR_WAVE1 << Channel); | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_READY; | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hdac); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Set the specified data holding register value for DAC channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_CHANNEL_1: DAC Channel1 selected | |||
| * @arg DAC_CHANNEL_2: DAC Channel2 selected | |||
| * @param Alignment: Specifies the data alignment. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected | |||
| * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected | |||
| * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected | |||
| * @param Data: Data to be loaded in the selected data holding register. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data) | |||
| { | |||
| __IO uint32_t tmp = 0; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| assert_param(IS_DAC_ALIGN(Alignment)); | |||
| assert_param(IS_DAC_DATA(Data)); | |||
| tmp = (uint32_t)hdac->Instance; | |||
| if(Channel == DAC_CHANNEL_1) | |||
| { | |||
| tmp += __HAL_DHR12R1_ALIGNEMENT(Alignment); | |||
| } | |||
| else | |||
| { | |||
| tmp += __HAL_DHR12R2_ALIGNEMENT(Alignment); | |||
| } | |||
| /* Set the DAC channel1 selected data holding register */ | |||
| *(__IO uint32_t *) tmp = Data; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DAC_Group4 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 DAC state. | |||
| (+) Check the DAC Errors. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief return the DAC state | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval HAL state | |||
| */ | |||
| HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* Return DAC state */ | |||
| return hdac->State; | |||
| } | |||
| /** | |||
| * @brief Return the DAC error code | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval DAC Error Code | |||
| */ | |||
| uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac) | |||
| { | |||
| return hdac->ErrorCode; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief DMA conversion complete callback. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma) | |||
| { | |||
| DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| HAL_DAC_ConvCpltCallbackCh1(hdac); | |||
| hdac->State= HAL_DAC_STATE_READY; | |||
| } | |||
| /** | |||
| * @brief DMA half transfer complete callback. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma) | |||
| { | |||
| DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| /* Conversion complete callback */ | |||
| HAL_DAC_ConvHalfCpltCallbackCh1(hdac); | |||
| } | |||
| /** | |||
| * @brief DMA error callback | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma) | |||
| { | |||
| DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| /* Set DAC error code to DMA error */ | |||
| hdac->ErrorCode |= HAL_DAC_ERROR_DMA; | |||
| HAL_DAC_ErrorCallbackCh1(hdac); | |||
| hdac->State= HAL_DAC_STATE_READY; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| #endif /* HAL_DAC_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,378 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dac_ex.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief DAC HAL module driver. | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of DAC extension peripheral: | |||
| * + Extended features functions | |||
| * | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] | |||
| (+) When Dual mode is enabled (i.e DAC Channel1 and Channel2 are used simultaneously) : | |||
| Use HAL_DACEx_DualGetValue() to get digital data to be converted and use | |||
| HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in Channel 1 and Channel 2. | |||
| (+) Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal. | |||
| (+) Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal. | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup DACEx | |||
| * @brief DAC driver modules | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_DAC_MODULE_ENABLED | |||
| #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup DACEx_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup DACEx_Group1 Extended features functions | |||
| * @brief Extended features functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### Extended features functions ##### | |||
| ============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Start conversion. | |||
| (+) Stop conversion. | |||
| (+) Start conversion and enable DMA transfer. | |||
| (+) Stop conversion and disable DMA transfer. | |||
| (+) Get result of conversion. | |||
| (+) Get result of dual mode conversion. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Returns the last data output value of the selected DAC channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval The selected DAC channel data output value. | |||
| */ | |||
| uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac) | |||
| { | |||
| uint32_t tmp = 0; | |||
| tmp |= hdac->Instance->DOR1; | |||
| tmp |= hdac->Instance->DOR2 << 16; | |||
| /* Returns the DAC channel data output register value */ | |||
| return tmp; | |||
| } | |||
| /** | |||
| * @brief Enables or disables the selected DAC channel wave generation. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * DAC_CHANNEL_1 / DAC_CHANNEL_2 | |||
| * @param Amplitude: Select max triangle amplitude. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047 | |||
| * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095 | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude)); | |||
| /* Process locked */ | |||
| __HAL_LOCK(hdac); | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_BUSY; | |||
| /* Enable the selected wave generation for the selected DAC channel */ | |||
| hdac->Instance->CR |= (DAC_WAVE_TRIANGLE | Amplitude) << Channel; | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_READY; | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hdac); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Enables or disables the selected DAC channel wave generation. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Channel: The selected DAC channel. | |||
| * This parameter can be one of the following values: | |||
| * DAC_CHANNEL_1 / DAC_CHANNEL_2 | |||
| * @param Amplitude: Unmask DAC channel LFSR for noise wave generation. | |||
| * This parameter can be one of the following values: | |||
| * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation | |||
| * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_CHANNEL(Channel)); | |||
| assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude)); | |||
| /* Process locked */ | |||
| __HAL_LOCK(hdac); | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_BUSY; | |||
| /* Enable the selected wave generation for the selected DAC channel */ | |||
| hdac->Instance->CR |= (DAC_WAVE_NOISE | Amplitude) << Channel; | |||
| /* Change DAC state */ | |||
| hdac->State = HAL_DAC_STATE_READY; | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hdac); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Set the specified data holding register value for dual DAC channel. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @param Alignment: Specifies the data alignment for dual channel DAC. | |||
| * This parameter can be one of the following values: | |||
| * DAC_ALIGN_8B_R: 8bit right data alignment selected | |||
| * DAC_ALIGN_12B_L: 12bit left data alignment selected | |||
| * DAC_ALIGN_12B_R: 12bit right data alignment selected | |||
| * @param Data1: Data for DAC Channel2 to be loaded in the selected data holding register. | |||
| * @param Data2: Data for DAC Channel1 to be loaded in the selected data holding register. | |||
| * @note In dual mode, a unique register access is required to write in both | |||
| * DAC channels at the same time. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2) | |||
| { | |||
| uint32_t data = 0, tmp = 0; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DAC_ALIGN(Alignment)); | |||
| assert_param(IS_DAC_DATA(Data1)); | |||
| assert_param(IS_DAC_DATA(Data2)); | |||
| /* Calculate and set dual DAC data holding register value */ | |||
| if (Alignment == DAC_ALIGN_8B_R) | |||
| { | |||
| data = ((uint32_t)Data2 << 8) | Data1; | |||
| } | |||
| else | |||
| { | |||
| data = ((uint32_t)Data2 << 16) | Data1; | |||
| } | |||
| tmp = (uint32_t)hdac->Instance; | |||
| tmp += __HAL_DHR12RD_ALIGNEMENT(Alignment); | |||
| /* Set the dual DAC selected data holding register */ | |||
| *(__IO uint32_t *)tmp = data; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief Conversion complete callback in non blocking mode for Channel2 | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_ConvCpltCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief Conversion half DMA transfer callback in non blocking mode for Channel2 | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_ConvHalfCpltCallbackCh2 could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief Error DAC callback for Channel2. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_ErrorCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief DMA underrun DAC callback for channel2. | |||
| * @param hdac: pointer to a DAC_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DAC. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DAC_DMAUnderrunCallbackCh2 could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief DMA conversion complete callback. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma) | |||
| { | |||
| DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| HAL_DACEx_ConvCpltCallbackCh2(hdac); | |||
| hdac->State= HAL_DAC_STATE_READY; | |||
| } | |||
| /** | |||
| * @brief DMA half transfer complete callback. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma) | |||
| { | |||
| DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| /* Conversion complete callback */ | |||
| HAL_DACEx_ConvHalfCpltCallbackCh2(hdac); | |||
| } | |||
| /** | |||
| * @brief DMA error callback | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma) | |||
| { | |||
| DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| /* Set DAC error code to DMA error */ | |||
| hdac->ErrorCode |= HAL_DAC_ERROR_DMA; | |||
| HAL_DACEx_ErrorCallbackCh2(hdac); | |||
| hdac->State= HAL_DAC_STATE_READY; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| #endif /* HAL_DAC_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,818 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dcmi.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief DCMI HAL module driver | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of the Digital Camera Interface (DCMI) peripheral: | |||
| * + Initialization and de-initialization functions | |||
| * + IO operation functions | |||
| * + Peripheral Control functions | |||
| * + Peripheral State and Error functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] | |||
| The sequence below describes how to use this driver to capture image | |||
| from a camera module connected to the DCMI Interface. | |||
| This sequence does not take into account the configuration of the | |||
| camera module, which should be made before to configure and enable | |||
| the DCMI to capture images. | |||
| (#) Program the required configuration through following parameters: | |||
| horizontal and vertical polarity, pixel clock polarity, Capture Rate, | |||
| Synchronization Mode, code of the frame delimiter and data width | |||
| using HAL_DCMI_Init() function. | |||
| (#) Configure the DMA2_Stream1 channel1 to transfer Data from DCMI DR | |||
| register to the destination memory buffer. | |||
| (#) Program the required configuration through following parameters: | |||
| DCMI mode, destination memory Buffer address and the data length | |||
| and enable capture using HAL_DCMI_Start_DMA() function. | |||
| (#) Optionally, configure and Enable the CROP feature to select a rectangular | |||
| window from the received image using HAL_DCMI_ConfigCrop() | |||
| and HAL_DCMI_EnableCROP() functions | |||
| (#) The capture can be stopped using HAL_DCMI_Stop() function. | |||
| (#) To control DCMI state you can use the function HAL_DCMI_GetState(). | |||
| *** DCMI HAL driver macros list *** | |||
| ============================================= | |||
| [..] | |||
| Below the list of most used macros in DCMI HAL driver. | |||
| (+) __HAL_DCMI_ENABLE: Enable the DCMI peripheral. | |||
| (+) __HAL_DCMI_DISABLE: Disable the DCMI peripheral. | |||
| (+) __HAL_DCMI_GET_FLAG: Get the DCMI pending flags. | |||
| (+) __HAL_DCMI_CLEAR_FLAG: Clear the DCMI pending flags. | |||
| (+) __HAL_DCMI_ENABLE_IT: Enable the specified DCMI interrupts. | |||
| (+) __HAL_DCMI_DISABLE_IT: Disable the specified DCMI interrupts. | |||
| (+) __HAL_DCMI_GET_IT_SOURCE: Check whether the specified DCMI interrupt has occurred or not. | |||
| [..] | |||
| (@) You can refer to the DCMI HAL driver header file for more useful macros | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup DCMI | |||
| * @brief DCMI HAL module driver | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_DCMI_MODULE_ENABLED | |||
| #if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| #define HAL_TIMEOUT_DCMI_STOP ((uint32_t)1000) /* 1s */ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma); | |||
| static void DCMI_DMAError(DMA_HandleTypeDef *hdma); | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup DCMI_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup DCMI_Group1 Initialization and Configuration functions | |||
| * @brief Initialization and Configuration functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Initialization and Configuration functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Initialize and configure the DCMI | |||
| (+) De-initialize the DCMI | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Initializes the DCMI according to the specified | |||
| * parameters in the DCMI_InitTypeDef and create the associated handle. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* Check the DCMI peripheral state */ | |||
| if(hdcmi == NULL) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check function parameters */ | |||
| assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance)); | |||
| assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity)); | |||
| assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity)); | |||
| assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity)); | |||
| assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode)); | |||
| assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate)); | |||
| assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode)); | |||
| assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode)); | |||
| if(hdcmi->State == HAL_DCMI_STATE_RESET) | |||
| { | |||
| /* Init the low level hardware */ | |||
| HAL_DCMI_MspInit(hdcmi); | |||
| } | |||
| /* Change the DCMI state */ | |||
| hdcmi->State = HAL_DCMI_STATE_BUSY; | |||
| /* Configures the HS, VS, DE and PC polarity */ | |||
| hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 | | |||
| DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG | | |||
| DCMI_CR_ESS); | |||
| hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate | \ | |||
| hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity | \ | |||
| hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode | \ | |||
| hdcmi->Init.JPEGMode); | |||
| if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED) | |||
| { | |||
| DCMI->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode) | | |||
| ((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << 8)| | |||
| ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << 16) | | |||
| ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << 24)); | |||
| } | |||
| /* Enable the Line interrupt */ | |||
| __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE); | |||
| /* Enable the VSYNC interrupt */ | |||
| __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_VSYNC); | |||
| /* Enable the Frame capture complete interrupt */ | |||
| __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME); | |||
| /* Enable the Synchronization error interrupt */ | |||
| __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_ERR); | |||
| /* Enable the Overflow interrupt */ | |||
| __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_OVF); | |||
| /* Enable DCMI by setting DCMIEN bit */ | |||
| __HAL_DCMI_ENABLE(hdcmi); | |||
| /* Update error code */ | |||
| hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE; | |||
| /* Initialize the DCMI state*/ | |||
| hdcmi->State = HAL_DCMI_STATE_READY; | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Deinitializes the DCMI peripheral registers to their default reset | |||
| * values. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* DeInit the low level hardware */ | |||
| HAL_DCMI_MspDeInit(hdcmi); | |||
| /* Update error code */ | |||
| hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE; | |||
| /* Initialize the DCMI state*/ | |||
| hdcmi->State = HAL_DCMI_STATE_RESET; | |||
| /* Release Lock */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Initializes the DCMI MSP. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DCMI_MspInit could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief DeInitializes the DCMI MSP. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DCMI_MspDeInit could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Group2 IO operation functions | |||
| * @brief IO operation functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### IO operation functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Configure destination address and data length and | |||
| Enables DCMI DMA request and enables DCMI capture | |||
| (+) Stop the DCMI capture. | |||
| (+) Handles DCMI interrupt request. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Enables DCMI DMA request and enables DCMI capture | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @param DCMI_Mode: DCMI capture mode snapshot or continuous grab. | |||
| * @param pData: The destination memory Buffer address (LCD Frame buffer). | |||
| * @param Length: The length of capture to be transferred. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length) | |||
| { | |||
| /* Initialise the second memory address */ | |||
| uint32_t SecondMemAddress = 0; | |||
| /* Check function parameters */ | |||
| assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode)); | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hdcmi); | |||
| /* Lock the DCMI peripheral state */ | |||
| hdcmi->State = HAL_DCMI_STATE_BUSY; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode)); | |||
| /* Configure the DCMI Mode */ | |||
| hdcmi->Instance->CR &= ~(DCMI_CR_CM); | |||
| hdcmi->Instance->CR |= (uint32_t)(DCMI_Mode); | |||
| /* Set the DMA memory0 conversion complete callback */ | |||
| hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAConvCplt; | |||
| /* Set the DMA error callback */ | |||
| hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError; | |||
| if(Length <= 0xFFFF) | |||
| { | |||
| /* Enable the DMA Stream */ | |||
| HAL_DMA_Start_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, Length); | |||
| } | |||
| else /* DCMI_DOUBLE_BUFFER Mode */ | |||
| { | |||
| /* Set the DMA memory1 conversion complete callback */ | |||
| hdcmi->DMA_Handle->XferM1CpltCallback = DCMI_DMAConvCplt; | |||
| /* Initialise transfer parameters */ | |||
| hdcmi->XferCount = 1; | |||
| hdcmi->XferSize = Length; | |||
| hdcmi->pBuffPtr = pData; | |||
| /* Get the number of buffer */ | |||
| while(hdcmi->XferSize > 0xFFFF) | |||
| { | |||
| hdcmi->XferSize = (hdcmi->XferSize/2); | |||
| hdcmi->XferCount = hdcmi->XferCount*2; | |||
| } | |||
| /* Update DCMI counter and transfer number*/ | |||
| hdcmi->XferCount = (hdcmi->XferCount - 2); | |||
| hdcmi->XferTransferNumber = hdcmi->XferCount; | |||
| /* Update second memory address */ | |||
| SecondMemAddress = (uint32_t)(pData + (4*hdcmi->XferSize)); | |||
| /* Start DMA multi buffer transfer */ | |||
| HAL_DMAEx_MultiBufferStart_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, SecondMemAddress, hdcmi->XferSize); | |||
| } | |||
| /* Enable Capture */ | |||
| DCMI->CR |= DCMI_CR_CAPTURE; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Disable DCMI DMA request and Disable DCMI capture | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi) | |||
| { | |||
| uint32_t tickstart = 0; | |||
| /* Lock the DCMI peripheral state */ | |||
| hdcmi->State = HAL_DCMI_STATE_BUSY; | |||
| __HAL_DCMI_DISABLE(hdcmi); | |||
| /* Disable Capture */ | |||
| DCMI->CR &= ~(DCMI_CR_CAPTURE); | |||
| /* Get tick */ | |||
| tickstart = HAL_GetTick(); | |||
| /* Check if the DCMI capture effectively disabled */ | |||
| while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0) | |||
| { | |||
| if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DCMI_STOP) | |||
| { | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| /* Update error code */ | |||
| hdcmi->ErrorCode |= HAL_DCMI_ERROR_TIMEOUT; | |||
| /* Change DCMI state */ | |||
| hdcmi->State = HAL_DCMI_STATE_TIMEOUT; | |||
| return HAL_TIMEOUT; | |||
| } | |||
| } | |||
| /* Disable the DMA */ | |||
| HAL_DMA_Abort(hdcmi->DMA_Handle); | |||
| /* Update error code */ | |||
| hdcmi->ErrorCode |= HAL_DCMI_ERROR_NONE; | |||
| /* Change DCMI state */ | |||
| hdcmi->State = HAL_DCMI_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Handles DCMI interrupt request. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for the DCMI. | |||
| * @retval None | |||
| */ | |||
| void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* Synchronization error interrupt management *******************************/ | |||
| if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_ERRRI) != RESET) | |||
| { | |||
| if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_ERR) != RESET) | |||
| { | |||
| /* Disable the Synchronization error interrupt */ | |||
| __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_ERR); | |||
| /* Clear the Synchronization error flag */ | |||
| __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_ERRRI); | |||
| /* Update error code */ | |||
| hdcmi->ErrorCode |= HAL_DCMI_ERROR_SYNC; | |||
| /* Change DCMI state */ | |||
| hdcmi->State = HAL_DCMI_STATE_ERROR; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| /* Abort the DMA Transfer */ | |||
| HAL_DMA_Abort(hdcmi->DMA_Handle); | |||
| /* Synchronization error Callback */ | |||
| HAL_DCMI_ErrorCallback(hdcmi); | |||
| } | |||
| } | |||
| /* Overflow interrupt management ********************************************/ | |||
| if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_OVFRI) != RESET) | |||
| { | |||
| if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_OVF) != RESET) | |||
| { | |||
| /* Disable the Overflow interrupt */ | |||
| __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_OVF); | |||
| /* Clear the Overflow flag */ | |||
| __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_OVFRI); | |||
| /* Update error code */ | |||
| hdcmi->ErrorCode |= HAL_DCMI_ERROR_OVF; | |||
| /* Change DCMI state */ | |||
| hdcmi->State = HAL_DCMI_STATE_ERROR; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| /* Abort the DMA Transfer */ | |||
| HAL_DMA_Abort(hdcmi->DMA_Handle); | |||
| /* Overflow Callback */ | |||
| HAL_DCMI_ErrorCallback(hdcmi); | |||
| } | |||
| } | |||
| /* Line Interrupt management ************************************************/ | |||
| if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_LINERI) != RESET) | |||
| { | |||
| if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_LINE) != RESET) | |||
| { | |||
| /* Clear the Line interrupt flag */ | |||
| __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_LINERI); | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| /* Line interrupt Callback */ | |||
| HAL_DCMI_LineEventCallback(hdcmi); | |||
| } | |||
| } | |||
| /* VSYNC interrupt management ***********************************************/ | |||
| if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_VSYNCRI) != RESET) | |||
| { | |||
| if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_VSYNC) != RESET) | |||
| { | |||
| /* Disable the VSYNC interrupt */ | |||
| __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_VSYNC); | |||
| /* Clear the VSYNC flag */ | |||
| __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_VSYNCRI); | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| /* VSYNC Callback */ | |||
| HAL_DCMI_VsyncEventCallback(hdcmi); | |||
| } | |||
| } | |||
| /* End of Frame interrupt management ****************************************/ | |||
| if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET) | |||
| { | |||
| if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_FRAME) != RESET) | |||
| { | |||
| /* Disable the End of Frame interrupt */ | |||
| __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_FRAME); | |||
| /* Clear the End of Frame flag */ | |||
| __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_FRAMERI); | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| /* End of Frame Callback */ | |||
| HAL_DCMI_FrameEventCallback(hdcmi); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * @brief Error DCMI callback. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DCMI_ErrorCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief Line Event callback. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DCMI_LineEventCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief VSYNC Event callback. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DCMI_VsyncEventCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @brief Frame Event callback. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_DCMI_FrameEventCallback could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Group3 Peripheral Control functions | |||
| * @brief Peripheral Control functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Peripheral Control functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Configure the CROP feature. | |||
| (+) Enable/Disable the CROP feature. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Configure the DCMI CROP coordinate. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @param YSize: DCMI Line number | |||
| * @param XSize: DCMI Pixel per line | |||
| * @param X0: DCMI window X offset | |||
| * @param Y0: DCMI window Y offset | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DCMI_ConfigCROP(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize) | |||
| { | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hdcmi); | |||
| /* Lock the DCMI peripheral state */ | |||
| hdcmi->State = HAL_DCMI_STATE_BUSY; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DCMI_WINDOW_COORDINATE(X0)); | |||
| assert_param(IS_DCMI_WINDOW_COORDINATE(Y0)); | |||
| assert_param(IS_DCMI_WINDOW_COORDINATE(XSize)); | |||
| assert_param(IS_DCMI_WINDOW_HEIGHT(YSize)); | |||
| /* Configure CROP */ | |||
| DCMI->CWSIZER = (XSize | (YSize << 16)); | |||
| DCMI->CWSTRTR = (X0 | (Y0 << 16)); | |||
| /* Initialize the DCMI state*/ | |||
| hdcmi->State = HAL_DCMI_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Disable the Crop feature. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DCMI_DisableCROP(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hdcmi); | |||
| /* Lock the DCMI peripheral state */ | |||
| hdcmi->State = HAL_DCMI_STATE_BUSY; | |||
| /* Disable DCMI Crop feature */ | |||
| DCMI->CR &= ~(uint32_t)DCMI_CR_CROP; | |||
| /* Change the DCMI state*/ | |||
| hdcmi->State = HAL_DCMI_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Enable the Crop feature. | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DCMI_EnableCROP(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hdcmi); | |||
| /* Lock the DCMI peripheral state */ | |||
| hdcmi->State = HAL_DCMI_STATE_BUSY; | |||
| /* Enable DCMI Crop feature */ | |||
| DCMI->CR |= (uint32_t)DCMI_CR_CROP; | |||
| /* Change the DCMI state*/ | |||
| hdcmi->State = HAL_DCMI_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DCMI_Group4 Peripheral State functions | |||
| * @brief Peripheral State functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Peripheral State and Errors functions ##### | |||
| =============================================================================== | |||
| [..] | |||
| This subsection provides functions allowing to | |||
| (+) Check the DCMI state. | |||
| (+) Get the specific DCMI error flag. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Return the DCMI state | |||
| * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval HAL state | |||
| */ | |||
| HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| return hdcmi->State; | |||
| } | |||
| /** | |||
| * @brief Return the DCMI error code | |||
| * @param hdcmi : pointer to a DCMI_HandleTypeDef structure that contains | |||
| * the configuration information for DCMI. | |||
| * @retval DCMI Error Code | |||
| */ | |||
| uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi) | |||
| { | |||
| return hdcmi->ErrorCode; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief DMA conversion complete callback. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma) | |||
| { | |||
| uint32_t tmp = 0; | |||
| DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| hdcmi->State= HAL_DCMI_STATE_READY; | |||
| if(hdcmi->XferCount != 0) | |||
| { | |||
| /* Update memory 0 address location */ | |||
| tmp = ((hdcmi->DMA_Handle->Instance->CR) & DMA_SxCR_CT); | |||
| if(((hdcmi->XferCount % 2) == 0) && (tmp != 0)) | |||
| { | |||
| tmp = hdcmi->DMA_Handle->Instance->M0AR; | |||
| HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8*hdcmi->XferSize)), MEMORY0); | |||
| hdcmi->XferCount--; | |||
| } | |||
| /* Update memory 1 address location */ | |||
| else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0) | |||
| { | |||
| tmp = hdcmi->DMA_Handle->Instance->M1AR; | |||
| HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8*hdcmi->XferSize)), MEMORY1); | |||
| hdcmi->XferCount--; | |||
| } | |||
| } | |||
| /* Update memory 0 address location */ | |||
| else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) != 0) | |||
| { | |||
| hdcmi->DMA_Handle->Instance->M0AR = hdcmi->pBuffPtr; | |||
| } | |||
| /* Update memory 1 address location */ | |||
| else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0) | |||
| { | |||
| tmp = hdcmi->pBuffPtr; | |||
| hdcmi->DMA_Handle->Instance->M1AR = (tmp + (4*hdcmi->XferSize)); | |||
| hdcmi->XferCount = hdcmi->XferTransferNumber; | |||
| } | |||
| if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET) | |||
| { | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdcmi); | |||
| /* FRAME Callback */ | |||
| HAL_DCMI_FrameEventCallback(hdcmi); | |||
| } | |||
| } | |||
| /** | |||
| * @brief DMA error callback | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA module. | |||
| * @retval None | |||
| */ | |||
| static void DCMI_DMAError(DMA_HandleTypeDef *hdma) | |||
| { | |||
| DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; | |||
| hdcmi->State= HAL_DCMI_STATE_READY; | |||
| HAL_DCMI_ErrorCallback(hdcmi); | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ | |||
| #endif /* HAL_DCMI_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,910 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dma.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @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 Stream | |||
| (except for internal SRAM/FLASH memories: no initialization is | |||
| necessary) please refer to Reference manual for connection between peripherals | |||
| and DMA requests . | |||
| (#) For a given Stream, program the required configuration through the following parameters: | |||
| Transfer Direction, Source and Destination data formats, | |||
| Circular, Normal or peripheral flow control mode, Stream Priority level, | |||
| Source and Destination Increment mode, FIFO mode and its Threshold (if needed), | |||
| Burst mode for Source and/or Destination (if needed) using HAL_DMA_Init() function. | |||
| *** 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 by customization of function pointer XferCpltCallback and | |||
| XferErrorCallback (i.e a member of DMA handle structure). | |||
| [..] | |||
| (#) 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. | |||
| -@- The FIFO is used mainly to reduce bus usage and to allow data packing/unpacking: it is | |||
| possible to set different Data Sizes for the Peripheral and the Memory (ie. you can set | |||
| Half-Word data size for the peripheral to access its data register and set Word data size | |||
| for the Memory to gain in access time. Each two half words will be packed and written in | |||
| a single access to a Word in the Memory). | |||
| -@- When FIFO is disabled, it is not allowed to configure different Data Sizes for Source | |||
| and Destination. In this case the Peripheral Data Size will be applied to both Source | |||
| and Destination. | |||
| *** DMA HAL driver macros list *** | |||
| ============================================= | |||
| [..] | |||
| Below the list of most used macros in DMA HAL driver. | |||
| (+) __HAL_DMA_ENABLE: Enable the specified DMA Stream. | |||
| (+) __HAL_DMA_DISABLE: Disable the specified DMA Stream. | |||
| (+) __HAL_DMA_GET_FS: Return the current DMA Stream FIFO filled level. | |||
| (+) __HAL_DMA_GET_FLAG: Get the DMA Stream pending flags. | |||
| (+) __HAL_DMA_CLEAR_FLAG: Clear the DMA Stream pending flags. | |||
| (+) __HAL_DMA_ENABLE_IT: Enable the specified DMA Stream interrupts. | |||
| (+) __HAL_DMA_DISABLE_IT: Disable the specified DMA Stream interrupts. | |||
| (+) __HAL_DMA_GET_IT_SOURCE: Check whether the specified DMA Stream 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) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup DMA | |||
| * @brief DMA HAL module driver | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_DMA_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| #define HAL_TIMEOUT_DMA_ABORT ((uint32_t)1000) /* 1s */ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength); | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup DMA_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup DMA_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 Stream source | |||
| and destination addresses, incrementation and data sizes, transfer direction, | |||
| circular/normal mode selection, memory-to-memory mode selection and Stream priority value. | |||
| [..] | |||
| The HAL_DMA_Init() function follows the DMA configuration procedures as described in | |||
| reference manual. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Initializes the DMA according to the specified | |||
| * parameters in the DMA_InitTypeDef and create the associated handle. | |||
| * @param hdma: Pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma) | |||
| { | |||
| uint32_t tmp = 0; | |||
| /* Check the DMA peripheral state */ | |||
| if(hdma == NULL) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check the parameters */ | |||
| assert_param(IS_DMA_STREAM_ALL_INSTANCE(hdma->Instance)); | |||
| assert_param(IS_DMA_CHANNEL(hdma->Init.Channel)); | |||
| 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)); | |||
| assert_param(IS_DMA_FIFO_MODE_STATE(hdma->Init.FIFOMode)); | |||
| /* Check the memory burst, peripheral burst and FIFO threshold parameters only | |||
| when FIFO mode is enabled */ | |||
| if(hdma->Init.FIFOMode != DMA_FIFOMODE_DISABLE) | |||
| { | |||
| assert_param(IS_DMA_FIFO_THRESHOLD(hdma->Init.FIFOThreshold)); | |||
| assert_param(IS_DMA_MEMORY_BURST(hdma->Init.MemBurst)); | |||
| assert_param(IS_DMA_PERIPHERAL_BURST(hdma->Init.PeriphBurst)); | |||
| } | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_BUSY; | |||
| /* Get the CR register value */ | |||
| tmp = hdma->Instance->CR; | |||
| /* Clear CHSEL, MBURST, PBURST, PL, MSIZE, PSIZE, MINC, PINC, CIRC, DIR and CT bits */ | |||
| tmp &= ((uint32_t)~(DMA_SxCR_CHSEL | DMA_SxCR_MBURST | DMA_SxCR_PBURST | \ | |||
| DMA_SxCR_PL | DMA_SxCR_MSIZE | DMA_SxCR_PSIZE | \ | |||
| DMA_SxCR_MINC | DMA_SxCR_PINC | DMA_SxCR_CIRC | \ | |||
| DMA_SxCR_DIR | DMA_SxCR_CT )); | |||
| /* Prepare the DMA Stream configuration */ | |||
| tmp |= hdma->Init.Channel | hdma->Init.Direction | | |||
| hdma->Init.PeriphInc | hdma->Init.MemInc | | |||
| hdma->Init.PeriphDataAlignment | hdma->Init.MemDataAlignment | | |||
| hdma->Init.Mode | hdma->Init.Priority; | |||
| /* the Memory burst and peripheral burst are not used when the FIFO is disabled */ | |||
| if(hdma->Init.FIFOMode == DMA_FIFOMODE_ENABLE) | |||
| { | |||
| /* Get memory burst and peripheral burst */ | |||
| tmp |= hdma->Init.MemBurst | hdma->Init.PeriphBurst; | |||
| } | |||
| /* Write to DMA Stream CR register */ | |||
| hdma->Instance->CR = tmp; | |||
| /* Get the FCR register value */ | |||
| tmp = hdma->Instance->FCR; | |||
| /* Clear Direct mode and FIFO threshold bits */ | |||
| tmp &= (uint32_t)~(DMA_SxFCR_DMDIS | DMA_SxFCR_FTH); | |||
| /* Prepare the DMA Stream FIFO configuration */ | |||
| tmp |= hdma->Init.FIFOMode; | |||
| /* the FIFO threshold is not used when the FIFO mode is disabled */ | |||
| if(hdma->Init.FIFOMode == DMA_FIFOMODE_ENABLE) | |||
| { | |||
| /* Get the FIFO threshold */ | |||
| tmp |= hdma->Init.FIFOThreshold; | |||
| } | |||
| /* Write to DMA Stream FCR */ | |||
| hdma->Instance->FCR = tmp; | |||
| /* Initialise the error code */ | |||
| hdma->ErrorCode = HAL_DMA_ERROR_NONE; | |||
| /* Initialize the DMA state */ | |||
| hdma->State = HAL_DMA_STATE_READY; | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief DeInitializes the DMA peripheral | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma) | |||
| { | |||
| /* Check the DMA peripheral state */ | |||
| if(hdma == NULL) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check the DMA peripheral state */ | |||
| if(hdma->State == HAL_DMA_STATE_BUSY) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Disable the selected DMA Streamx */ | |||
| __HAL_DMA_DISABLE(hdma); | |||
| /* Reset DMA Streamx control register */ | |||
| hdma->Instance->CR = 0; | |||
| /* Reset DMA Streamx number of data to transfer register */ | |||
| hdma->Instance->NDTR = 0; | |||
| /* Reset DMA Streamx peripheral address register */ | |||
| hdma->Instance->PAR = 0; | |||
| /* Reset DMA Streamx memory 0 address register */ | |||
| hdma->Instance->M0AR = 0; | |||
| /* Reset DMA Streamx memory 1 address register */ | |||
| hdma->Instance->M1AR = 0; | |||
| /* Reset DMA Streamx FIFO control register */ | |||
| hdma->Instance->FCR = (uint32_t)0x00000021; | |||
| /* Clear all flags */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)); | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)); | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)); | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); | |||
| /* 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_Group2 I/O operation functions | |||
| * @brief I/O 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 Starts the DMA Transfer. | |||
| * @param hdma : pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @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) | |||
| { | |||
| /* Process locked */ | |||
| __HAL_LOCK(hdma); | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_BUSY; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DMA_BUFFER_SIZE(DataLength)); | |||
| /* Disable the peripheral */ | |||
| __HAL_DMA_DISABLE(hdma); | |||
| /* Configure the source, destination address and the data length */ | |||
| DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength); | |||
| /* Enable the Peripheral */ | |||
| __HAL_DMA_ENABLE(hdma); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @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 Stream. | |||
| * @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) | |||
| { | |||
| /* Process locked */ | |||
| __HAL_LOCK(hdma); | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_BUSY; | |||
| /* Check the parameters */ | |||
| assert_param(IS_DMA_BUFFER_SIZE(DataLength)); | |||
| /* Disable the peripheral */ | |||
| __HAL_DMA_DISABLE(hdma); | |||
| /* Configure the source, destination address and the data length */ | |||
| DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength); | |||
| /* Enable the transfer complete interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_TC); | |||
| /* Enable the Half transfer complete interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_HT); | |||
| /* Enable the transfer Error interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_TE); | |||
| /* Enable the FIFO Error interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_FE); | |||
| /* Enable the direct mode Error interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_DME); | |||
| /* Enable the Peripheral */ | |||
| __HAL_DMA_ENABLE(hdma); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Aborts the DMA Transfer. | |||
| * @param hdma : pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * | |||
| * @note After disabling a DMA Stream, a check for wait until the DMA Stream is | |||
| * effectively disabled is added. If a Stream is disabled | |||
| * while a data transfer is ongoing, the current data will be transferred | |||
| * and the Stream will be effectively disabled only after the transfer of | |||
| * this single data is finished. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma) | |||
| { | |||
| uint32_t tickstart = 0; | |||
| /* Disable the stream */ | |||
| __HAL_DMA_DISABLE(hdma); | |||
| /* Get tick */ | |||
| tickstart = HAL_GetTick(); | |||
| /* Check if the DMA Stream is effectively disabled */ | |||
| while((hdma->Instance->CR & DMA_SxCR_EN) != 0) | |||
| { | |||
| /* Check for the Timeout */ | |||
| if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DMA_ABORT) | |||
| { | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_TIMEOUT; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| /* Change the DMA state */ | |||
| hdma->State = HAL_DMA_STATE_TIMEOUT; | |||
| return HAL_TIMEOUT; | |||
| } | |||
| } | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| /* Change the DMA state*/ | |||
| hdma->State = HAL_DMA_STATE_READY; | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Polling for transfer complete. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @param CompleteLevel: Specifies the DMA level complete. | |||
| * @param Timeout: Timeout duration. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout) | |||
| { | |||
| uint32_t temp, tmp, tmp1, tmp2; | |||
| uint32_t tickstart = 0; | |||
| /* Get the level transfer complete flag */ | |||
| if(CompleteLevel == HAL_DMA_FULL_TRANSFER) | |||
| { | |||
| /* Transfer Complete flag */ | |||
| temp = __HAL_DMA_GET_TC_FLAG_INDEX(hdma); | |||
| } | |||
| else | |||
| { | |||
| /* Half Transfer Complete flag */ | |||
| temp = __HAL_DMA_GET_HT_FLAG_INDEX(hdma); | |||
| } | |||
| /* Get tick */ | |||
| tickstart = HAL_GetTick(); | |||
| while(__HAL_DMA_GET_FLAG(hdma, temp) == RESET) | |||
| { | |||
| tmp = __HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)); | |||
| tmp1 = __HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)); | |||
| tmp2 = __HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)); | |||
| if((tmp != RESET) || (tmp1 != RESET) || (tmp2 != RESET)) | |||
| { | |||
| if(tmp != RESET) | |||
| { | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_TE; | |||
| /* Clear the transfer error flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)); | |||
| } | |||
| if(tmp1 != RESET) | |||
| { | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_FE; | |||
| /* Clear the FIFO error flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)); | |||
| } | |||
| if(tmp2 != RESET) | |||
| { | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_DME; | |||
| /* Clear the Direct Mode error flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)); | |||
| } | |||
| /* Change the DMA state */ | |||
| hdma->State= HAL_DMA_STATE_ERROR; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check for the Timeout */ | |||
| if(Timeout != HAL_MAX_DELAY) | |||
| { | |||
| if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) | |||
| { | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_TIMEOUT; | |||
| /* Change the DMA state */ | |||
| hdma->State = HAL_DMA_STATE_TIMEOUT; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| return HAL_TIMEOUT; | |||
| } | |||
| } | |||
| } | |||
| if(CompleteLevel == HAL_DMA_FULL_TRANSFER) | |||
| { | |||
| /* Multi_Buffering mode enabled */ | |||
| if(((hdma->Instance->CR) & (uint32_t)(DMA_SxCR_DBM)) != 0) | |||
| { | |||
| /* Clear the half transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); | |||
| /* Clear the transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); | |||
| /* Current memory buffer used is Memory 0 */ | |||
| if((hdma->Instance->CR & DMA_SxCR_CT) == 0) | |||
| { | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_READY_MEM0; | |||
| } | |||
| /* Current memory buffer used is Memory 1 */ | |||
| else if((hdma->Instance->CR & DMA_SxCR_CT) != 0) | |||
| { | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_READY_MEM1; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| /* Clear the half transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); | |||
| /* Clear the transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); | |||
| /* The selected Streamx EN bit is cleared (DMA is disabled and all transfers | |||
| are complete) */ | |||
| hdma->State = HAL_DMA_STATE_READY_MEM0; | |||
| } | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| } | |||
| else | |||
| { | |||
| /* Multi_Buffering mode enabled */ | |||
| if(((hdma->Instance->CR) & (uint32_t)(DMA_SxCR_DBM)) != 0) | |||
| { | |||
| /* Clear the half transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); | |||
| /* Current memory buffer used is Memory 0 */ | |||
| if((hdma->Instance->CR & DMA_SxCR_CT) == 0) | |||
| { | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_READY_HALF_MEM0; | |||
| } | |||
| /* Current memory buffer used is Memory 1 */ | |||
| else if((hdma->Instance->CR & DMA_SxCR_CT) != 0) | |||
| { | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_READY_HALF_MEM1; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| /* Clear the half transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_READY_HALF_MEM0; | |||
| } | |||
| } | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Handles DMA interrupt request. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @retval None | |||
| */ | |||
| void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma) | |||
| { | |||
| /* Transfer Error Interrupt management ***************************************/ | |||
| if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)) != RESET) | |||
| { | |||
| if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_TE) != RESET) | |||
| { | |||
| /* Disable the transfer error interrupt */ | |||
| __HAL_DMA_DISABLE_IT(hdma, DMA_IT_TE); | |||
| /* Clear the transfer error flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)); | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_TE; | |||
| /* Change the DMA state */ | |||
| hdma->State = HAL_DMA_STATE_ERROR; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| if(hdma->XferErrorCallback != NULL) | |||
| { | |||
| /* Transfer error callback */ | |||
| hdma->XferErrorCallback(hdma); | |||
| } | |||
| } | |||
| } | |||
| /* FIFO Error Interrupt management ******************************************/ | |||
| if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)) != RESET) | |||
| { | |||
| if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_FE) != RESET) | |||
| { | |||
| /* Disable the FIFO Error interrupt */ | |||
| __HAL_DMA_DISABLE_IT(hdma, DMA_IT_FE); | |||
| /* Clear the FIFO error flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)); | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_FE; | |||
| /* Change the DMA state */ | |||
| hdma->State = HAL_DMA_STATE_ERROR; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| if(hdma->XferErrorCallback != NULL) | |||
| { | |||
| /* Transfer error callback */ | |||
| hdma->XferErrorCallback(hdma); | |||
| } | |||
| } | |||
| } | |||
| /* Direct Mode Error Interrupt management ***********************************/ | |||
| if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)) != RESET) | |||
| { | |||
| if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_DME) != RESET) | |||
| { | |||
| /* Disable the direct mode Error interrupt */ | |||
| __HAL_DMA_DISABLE_IT(hdma, DMA_IT_DME); | |||
| /* Clear the direct mode error flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)); | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_DME; | |||
| /* Change the DMA state */ | |||
| hdma->State = HAL_DMA_STATE_ERROR; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| if(hdma->XferErrorCallback != NULL) | |||
| { | |||
| /* Transfer error callback */ | |||
| hdma->XferErrorCallback(hdma); | |||
| } | |||
| } | |||
| } | |||
| /* Half Transfer Complete Interrupt management ******************************/ | |||
| if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)) != RESET) | |||
| { | |||
| if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_HT) != RESET) | |||
| { | |||
| /* Multi_Buffering mode enabled */ | |||
| if(((hdma->Instance->CR) & (uint32_t)(DMA_SxCR_DBM)) != 0) | |||
| { | |||
| /* Clear the half transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); | |||
| /* Current memory buffer used is Memory 0 */ | |||
| if((hdma->Instance->CR & DMA_SxCR_CT) == 0) | |||
| { | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_READY_HALF_MEM0; | |||
| } | |||
| /* Current memory buffer used is Memory 1 */ | |||
| else if((hdma->Instance->CR & DMA_SxCR_CT) != 0) | |||
| { | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_READY_HALF_MEM1; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| /* Disable the half transfer interrupt if the DMA mode is not CIRCULAR */ | |||
| if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0) | |||
| { | |||
| /* Disable the half transfer interrupt */ | |||
| __HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT); | |||
| } | |||
| /* Clear the half transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); | |||
| /* Change DMA peripheral state */ | |||
| hdma->State = HAL_DMA_STATE_READY_HALF_MEM0; | |||
| } | |||
| if(hdma->XferHalfCpltCallback != NULL) | |||
| { | |||
| /* Half transfer callback */ | |||
| hdma->XferHalfCpltCallback(hdma); | |||
| } | |||
| } | |||
| } | |||
| /* Transfer Complete Interrupt management ***********************************/ | |||
| if(__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)) != RESET) | |||
| { | |||
| if(__HAL_DMA_GET_IT_SOURCE(hdma, DMA_IT_TC) != RESET) | |||
| { | |||
| if(((hdma->Instance->CR) & (uint32_t)(DMA_SxCR_DBM)) != 0) | |||
| { | |||
| /* Clear the transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); | |||
| /* Current memory buffer used is Memory 1 */ | |||
| if((hdma->Instance->CR & DMA_SxCR_CT) == 0) | |||
| { | |||
| if(hdma->XferM1CpltCallback != NULL) | |||
| { | |||
| /* Transfer complete Callback for memory1 */ | |||
| hdma->XferM1CpltCallback(hdma); | |||
| } | |||
| } | |||
| /* Current memory buffer used is Memory 0 */ | |||
| else if((hdma->Instance->CR & DMA_SxCR_CT) != 0) | |||
| { | |||
| if(hdma->XferCpltCallback != NULL) | |||
| { | |||
| /* Transfer complete Callback for memory0 */ | |||
| hdma->XferCpltCallback(hdma); | |||
| } | |||
| } | |||
| } | |||
| /* Disable the transfer complete interrupt if the DMA mode is not CIRCULAR */ | |||
| else | |||
| { | |||
| if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0) | |||
| { | |||
| /* Disable the transfer complete interrupt */ | |||
| __HAL_DMA_DISABLE_IT(hdma, DMA_IT_TC); | |||
| } | |||
| /* Clear the transfer complete flag */ | |||
| __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); | |||
| /* Update error code */ | |||
| hdma->ErrorCode |= HAL_DMA_ERROR_NONE; | |||
| /* Change the DMA state */ | |||
| hdma->State = HAL_DMA_STATE_READY_MEM0; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hdma); | |||
| if(hdma->XferCpltCallback != NULL) | |||
| { | |||
| /* Transfer complete callback */ | |||
| hdma->XferCpltCallback(hdma); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup DMA_Group3 Peripheral State functions | |||
| * @brief Peripheral State functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### State and Errors functions ##### | |||
| =============================================================================== | |||
| [..] | |||
| This subsection provides functions allowing to | |||
| (+) Check the DMA state | |||
| (+) Get error code | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Returns the DMA state. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @retval HAL state | |||
| */ | |||
| HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma) | |||
| { | |||
| 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 Stream. | |||
| * @retval DMA Error Code | |||
| */ | |||
| uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma) | |||
| { | |||
| return hdma->ErrorCode; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief Sets the DMA Transfer parameter. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @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) | |||
| { | |||
| /* Configure DMA Stream data length */ | |||
| hdma->Instance->NDTR = DataLength; | |||
| /* Peripheral to Memory */ | |||
| if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH) | |||
| { | |||
| /* Configure DMA Stream destination address */ | |||
| hdma->Instance->PAR = DstAddress; | |||
| /* Configure DMA Stream source address */ | |||
| hdma->Instance->M0AR = SrcAddress; | |||
| } | |||
| /* Memory to Peripheral */ | |||
| else | |||
| { | |||
| /* Configure DMA Stream source address */ | |||
| hdma->Instance->PAR = SrcAddress; | |||
| /* Configure DMA Stream destination address */ | |||
| hdma->Instance->M0AR = DstAddress; | |||
| } | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* HAL_DMA_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,294 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_dma_ex.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief DMA Extension HAL module driver | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of the DMA Extension peripheral: | |||
| * + Extended features functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] | |||
| The DMA Extension HAL driver can be used as follows: | |||
| (#) Start a multi buffer transfer using the HAL_DMA_MultiBufferStart() function | |||
| for polling mode or HAL_DMA_MultiBufferStart_IT() for interrupt mode. | |||
| -@- In Memory-to-Memory transfer mode, Multi (Double) Buffer mode is not allowed. | |||
| -@- When Multi (Double) Buffer mode is enabled the, transfer is circular by default. | |||
| -@- In Multi (Double) buffer mode, it is possible to update the base address for | |||
| the AHB memory port on the fly (DMA_SxM0AR or DMA_SxM1AR) when the stream is enabled. | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup DMAEx | |||
| * @brief DMA Extended HAL module driver | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_DMA_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| static void DMA_MultiBufferSetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength); | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup DMAEx_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup DMAEx_Group1 Extended features functions | |||
| * @brief Extended features functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Extended features functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Configure the source, destination address and data length and | |||
| Start MultiBuffer DMA transfer | |||
| (+) Configure the source, destination address and data length and | |||
| Start MultiBuffer DMA transfer with interrupt | |||
| (+) Change on the fly the memory0 or memory1 address. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Starts the multi_buffer DMA Transfer. | |||
| * @param hdma : pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @param SrcAddress: The source memory Buffer address | |||
| * @param DstAddress: The destination memory Buffer address | |||
| * @param SecondMemAddress: The second memory Buffer address in case of multi buffer Transfer | |||
| * @param DataLength: The length of data to be transferred from source to destination | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength) | |||
| { | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hdma); | |||
| /* Current memory buffer used is Memory 0 */ | |||
| if((hdma->Instance->CR & DMA_SxCR_CT) == 0) | |||
| { | |||
| hdma->State = HAL_DMA_STATE_BUSY_MEM0; | |||
| } | |||
| /* Current memory buffer used is Memory 1 */ | |||
| else if((hdma->Instance->CR & DMA_SxCR_CT) != 0) | |||
| { | |||
| hdma->State = HAL_DMA_STATE_BUSY_MEM1; | |||
| } | |||
| /* Check the parameters */ | |||
| assert_param(IS_DMA_BUFFER_SIZE(DataLength)); | |||
| /* Disable the peripheral */ | |||
| __HAL_DMA_DISABLE(hdma); | |||
| /* Enable the double buffer mode */ | |||
| hdma->Instance->CR |= (uint32_t)DMA_SxCR_DBM; | |||
| /* Configure DMA Stream destination address */ | |||
| hdma->Instance->M1AR = SecondMemAddress; | |||
| /* Configure the source, destination address and the data length */ | |||
| DMA_MultiBufferSetConfig(hdma, SrcAddress, DstAddress, DataLength); | |||
| /* Enable the peripheral */ | |||
| __HAL_DMA_ENABLE(hdma); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Starts the multi_buffer DMA Transfer with interrupt enabled. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @param SrcAddress: The source memory Buffer address | |||
| * @param DstAddress: The destination memory Buffer address | |||
| * @param SecondMemAddress: The second memory Buffer address in case of multi buffer Transfer | |||
| * @param DataLength: The length of data to be transferred from source to destination | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength) | |||
| { | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hdma); | |||
| /* Current memory buffer used is Memory 0 */ | |||
| if((hdma->Instance->CR & DMA_SxCR_CT) == 0) | |||
| { | |||
| hdma->State = HAL_DMA_STATE_BUSY_MEM0; | |||
| } | |||
| /* Current memory buffer used is Memory 1 */ | |||
| else if((hdma->Instance->CR & DMA_SxCR_CT) != 0) | |||
| { | |||
| hdma->State = HAL_DMA_STATE_BUSY_MEM1; | |||
| } | |||
| /* Check the parameters */ | |||
| assert_param(IS_DMA_BUFFER_SIZE(DataLength)); | |||
| /* Disable the peripheral */ | |||
| __HAL_DMA_DISABLE(hdma); | |||
| /* Enable the Double buffer mode */ | |||
| hdma->Instance->CR |= (uint32_t)DMA_SxCR_DBM; | |||
| /* Configure DMA Stream destination address */ | |||
| hdma->Instance->M1AR = SecondMemAddress; | |||
| /* Configure the source, destination address and the data length */ | |||
| DMA_MultiBufferSetConfig(hdma, SrcAddress, DstAddress, DataLength); | |||
| /* Enable the transfer complete interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_TC); | |||
| /* Enable the Half transfer interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_HT); | |||
| /* Enable the transfer Error interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_TE); | |||
| /* Enable the fifo Error interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_FE); | |||
| /* Enable the direct mode Error interrupt */ | |||
| __HAL_DMA_ENABLE_IT(hdma, DMA_IT_DME); | |||
| /* Enable the peripheral */ | |||
| __HAL_DMA_ENABLE(hdma); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Change the memory0 or memory1 address on the fly. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @param Address: The new address | |||
| * @param memory: the memory to be changed, This parameter can be one of | |||
| * the following values: | |||
| * MEMORY0 / | |||
| * MEMORY1 | |||
| * @note The MEMORY0 address can be changed only when the current transfer use | |||
| * MEMORY1 and the MEMORY1 address can be changed only when the current | |||
| * transfer use MEMORY0. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory) | |||
| { | |||
| if(memory == MEMORY0) | |||
| { | |||
| /* change the memory0 address */ | |||
| hdma->Instance->M0AR = Address; | |||
| } | |||
| else | |||
| { | |||
| /* change the memory1 address */ | |||
| hdma->Instance->M1AR = Address; | |||
| } | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief Set the DMA Transfer parameter. | |||
| * @param hdma: pointer to a DMA_HandleTypeDef structure that contains | |||
| * the configuration information for the specified DMA Stream. | |||
| * @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_MultiBufferSetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength) | |||
| { | |||
| /* Configure DMA Stream data length */ | |||
| hdma->Instance->NDTR = DataLength; | |||
| /* Peripheral to Memory */ | |||
| if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH) | |||
| { | |||
| /* Configure DMA Stream destination address */ | |||
| hdma->Instance->PAR = DstAddress; | |||
| /* Configure DMA Stream source address */ | |||
| hdma->Instance->M0AR = SrcAddress; | |||
| } | |||
| /* Memory to Peripheral */ | |||
| else | |||
| { | |||
| /* Configure DMA Stream source address */ | |||
| hdma->Instance->PAR = SrcAddress; | |||
| /* Configure DMA Stream destination address */ | |||
| hdma->Instance->M0AR = DstAddress; | |||
| } | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* HAL_DMA_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,749 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_flash.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @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 Errors 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 and cache lines. | |||
| [..] The FLASH main features are: | |||
| (+) Flash memory read operations | |||
| (+) Flash memory program/erase operations | |||
| (+) Read / write protections | |||
| (+) Prefetch on I-Code | |||
| (+) 64 cache lines of 128 bits on I-Code | |||
| (+) 8 cache lines of 128 bits on D-Code | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] | |||
| This driver provides functions and macros to configure and program the FLASH | |||
| memory of all STM32F4xx devices. | |||
| (#) FLASH Memory IO Programming functions: | |||
| (++) Lock and Unlock the FLASH interface using HAL_FLASH_Unlock() and | |||
| HAL_FLASH_Lock() functions | |||
| (++) Program functions: byte, half word, word and double word | |||
| (++) There Two modes of programming : | |||
| (+++) Polling mode using HAL_FLASH_Program() function | |||
| (+++) Interrupt mode using HAL_FLASH_Program_IT() function | |||
| (#) Interrupts and flags management functions : | |||
| (++) Handle FLASH interrupts by calling HAL_FLASH_IRQHandler() | |||
| (++) Wait for last FLASH operation according to its status | |||
| (++) Get error flag status by calling HAL_SetErrorCode() | |||
| [..] | |||
| In addition to these functions, this driver includes a set of macros allowing | |||
| to handle the following operations: | |||
| (+) Set the latency | |||
| (+) Enable/Disable the prefetch buffer | |||
| (+) Enable/Disable the Instruction cache and the Data cache | |||
| (+) Reset the Instruction cache and the Data cache | |||
| (+) Enable/Disable the FLASH interrupts | |||
| (+) Monitor the FLASH flags status | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup FLASH | |||
| * @brief FLASH HAL module driver | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_FLASH_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| #define SECTOR_MASK ((uint32_t)0xFFFFFF07) | |||
| #define HAL_FLASH_TIMEOUT_VALUE ((uint32_t)50000)/* 50 s */ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Variable used for Erase sectors under interruption */ | |||
| FLASH_ProcessTypeDef pFlash; | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Program operations */ | |||
| static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data); | |||
| static void FLASH_Program_Word(uint32_t Address, uint32_t Data); | |||
| static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data); | |||
| static void FLASH_Program_Byte(uint32_t Address, uint8_t Data); | |||
| static void FLASH_SetErrorCode(void); | |||
| HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup FLASH_Private_Functions FLASH Private functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup FLASH_Group1 Programming operation functions | |||
| * @brief Programming operation functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Programming operation functions ##### | |||
| =============================================================================== | |||
| [..] | |||
| This subsection provides a set of functions allowing to manage the FLASH | |||
| program operations. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Program byte, halfword, word or double word at a specified address | |||
| * @param TypeProgram: Indicate the way to program at a specified address. | |||
| * This parameter can be a value of @ref FLASH_Type_Program | |||
| * @param Address: specifies the address to be programmed. | |||
| * @param Data: specifies the data to be programmed | |||
| * | |||
| * @retval HAL_StatusTypeDef HAL Status | |||
| */ | |||
| HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data) | |||
| { | |||
| HAL_StatusTypeDef status = HAL_ERROR; | |||
| /* Process Locked */ | |||
| __HAL_LOCK(&pFlash); | |||
| /* Check the parameters */ | |||
| assert_param(IS_TYPEPROGRAM(TypeProgram)); | |||
| /* Wait for last operation to be completed */ | |||
| status = FLASH_WaitForLastOperation((uint32_t)HAL_FLASH_TIMEOUT_VALUE); | |||
| if(status == HAL_OK) | |||
| { | |||
| if(TypeProgram == TYPEPROGRAM_BYTE) | |||
| { | |||
| /*Program byte (8-bit) at a specified address.*/ | |||
| FLASH_Program_Byte(Address, (uint8_t) Data); | |||
| } | |||
| else if(TypeProgram == TYPEPROGRAM_HALFWORD) | |||
| { | |||
| /*Program halfword (16-bit) at a specified address.*/ | |||
| FLASH_Program_HalfWord(Address, (uint16_t) Data); | |||
| } | |||
| else if(TypeProgram == TYPEPROGRAM_WORD) | |||
| { | |||
| /*Program word (32-bit) at a specified address.*/ | |||
| FLASH_Program_Word(Address, (uint32_t) Data); | |||
| } | |||
| else | |||
| { | |||
| /*Program double word (64-bit) at a specified address.*/ | |||
| FLASH_Program_DoubleWord(Address, Data); | |||
| } | |||
| /* Wait for last operation to be completed */ | |||
| status = FLASH_WaitForLastOperation((uint32_t)HAL_FLASH_TIMEOUT_VALUE); | |||
| /* If the program operation is completed, disable the PG Bit */ | |||
| FLASH->CR &= (~FLASH_CR_PG); | |||
| } | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(&pFlash); | |||
| return status; | |||
| } | |||
| /** | |||
| * @brief Program byte, halfword, word or double 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: specifies the address to be programmed. | |||
| * @param Data: specifies the data to be programmed | |||
| * | |||
| * @retval HAL Status | |||
| */ | |||
| HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data) | |||
| { | |||
| HAL_StatusTypeDef status = HAL_OK; | |||
| /* Process Locked */ | |||
| __HAL_LOCK(&pFlash); | |||
| /* Check the parameters */ | |||
| assert_param(IS_TYPEPROGRAM(TypeProgram)); | |||
| /* Enable End of FLASH Operation interrupt */ | |||
| __HAL_FLASH_ENABLE_IT(FLASH_IT_EOP); | |||
| /* Enable Error source interrupt */ | |||
| __HAL_FLASH_ENABLE_IT(FLASH_IT_ERR); | |||
| /* Clear pending flags (if any) */ | |||
| __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |\ | |||
| FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR| FLASH_FLAG_PGSERR); | |||
| pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM; | |||
| pFlash.Address = Address; | |||
| if(TypeProgram == TYPEPROGRAM_BYTE) | |||
| { | |||
| /*Program byte (8-bit) at a specified address.*/ | |||
| FLASH_Program_Byte(Address, (uint8_t) Data); | |||
| } | |||
| else if(TypeProgram == TYPEPROGRAM_HALFWORD) | |||
| { | |||
| /*Program halfword (16-bit) at a specified address.*/ | |||
| FLASH_Program_HalfWord(Address, (uint16_t) Data); | |||
| } | |||
| else if(TypeProgram == TYPEPROGRAM_WORD) | |||
| { | |||
| /*Program word (32-bit) at a specified address.*/ | |||
| FLASH_Program_Word(Address, (uint32_t) Data); | |||
| } | |||
| else | |||
| { | |||
| /*Program double word (64-bit) at a specified address.*/ | |||
| FLASH_Program_DoubleWord(Address, Data); | |||
| } | |||
| return status; | |||
| } | |||
| /** | |||
| * @brief This function handles FLASH interrupt request. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| void HAL_FLASH_IRQHandler(void) | |||
| { | |||
| uint32_t temp; | |||
| /* If the program operation is completed, disable the PG Bit */ | |||
| FLASH->CR &= (~FLASH_CR_PG); | |||
| /* If the erase operation is completed, disable the SER Bit */ | |||
| FLASH->CR &= (~FLASH_CR_SER); | |||
| FLASH->CR &= SECTOR_MASK; | |||
| /* if the erase operation is completed, disable the MER Bit */ | |||
| FLASH->CR &= (~FLASH_MER_BIT); | |||
| /* Check FLASH End of Operation flag */ | |||
| if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP) != RESET) | |||
| { | |||
| if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE) | |||
| { | |||
| /*Nb of sector to erased can be decreased*/ | |||
| pFlash.NbSectorsToErase--; | |||
| /* Check if there are still sectors to erase*/ | |||
| if(pFlash.NbSectorsToErase != 0) | |||
| { | |||
| temp = pFlash.Sector; | |||
| /*Indicate user which sector has been erased*/ | |||
| HAL_FLASH_EndOfOperationCallback(temp); | |||
| /* Clear pending flags (if any) */ | |||
| __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |\ | |||
| FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR| FLASH_FLAG_PGSERR); | |||
| /*Increment sector number*/ | |||
| temp = ++pFlash.Sector; | |||
| FLASH_Erase_Sector(temp, pFlash.VoltageForErase); | |||
| } | |||
| else | |||
| { | |||
| /*No more sectors to Erase, user callback can be called.*/ | |||
| /*Reset Sector and stop Erase sectors procedure*/ | |||
| pFlash.Sector = temp = 0xFFFFFFFF; | |||
| pFlash.ProcedureOnGoing = FLASH_PROC_NONE; | |||
| /* FLASH EOP interrupt user callback */ | |||
| HAL_FLASH_EndOfOperationCallback(temp); | |||
| /* Clear FLASH End of Operation pending bit */ | |||
| __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| if (pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE) | |||
| { | |||
| /*MassErase ended. Return the selected bank*/ | |||
| /* FLASH EOP interrupt user callback */ | |||
| HAL_FLASH_EndOfOperationCallback(pFlash.Bank); | |||
| } | |||
| else | |||
| { | |||
| /*Program ended. Return the selected address*/ | |||
| /* FLASH EOP interrupt user callback */ | |||
| HAL_FLASH_EndOfOperationCallback(pFlash.Address); | |||
| } | |||
| pFlash.ProcedureOnGoing = FLASH_PROC_NONE; | |||
| /* Clear FLASH End of Operation pending bit */ | |||
| __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP); | |||
| } | |||
| } | |||
| /* Check FLASH operation error flags */ | |||
| if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | \ | |||
| FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR)) != RESET) | |||
| { | |||
| if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE) | |||
| { | |||
| /*return the faulty sector*/ | |||
| temp = pFlash.Sector; | |||
| pFlash.Sector = 0xFFFFFFFF; | |||
| } | |||
| else if (pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE) | |||
| { | |||
| /*return the faulty bank*/ | |||
| temp = pFlash.Bank; | |||
| } | |||
| else | |||
| { | |||
| /*retrun the faulty address*/ | |||
| temp = pFlash.Address; | |||
| } | |||
| /*Save the Error code*/ | |||
| FLASH_SetErrorCode(); | |||
| /* FLASH error interrupt user callback */ | |||
| HAL_FLASH_OperationErrorCallback(temp); | |||
| /* Clear FLASH error pending bits */ | |||
| __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR |\ | |||
| FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR); | |||
| /*Stop the procedure ongoing*/ | |||
| pFlash.ProcedureOnGoing = FLASH_PROC_NONE; | |||
| } | |||
| if(pFlash.ProcedureOnGoing == FLASH_PROC_NONE) | |||
| { | |||
| /* Disable End of FLASH Operation interrupt */ | |||
| __HAL_FLASH_DISABLE_IT(FLASH_IT_EOP); | |||
| /* Disable Error source interrupt */ | |||
| __HAL_FLASH_DISABLE_IT(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 | |||
| * Mass Erase: Bank number which has been requested to erase | |||
| * Sectors Erase: Sector which has been erased | |||
| * (if 0xFFFFFFFF, it means that all the selected sectors have been erased) | |||
| * Program: Address which was selected for data program | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_FLASH_EndOfOperationCallback(uint32_t 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 | |||
| * Mass Erase: Bank number which has been requested to erase | |||
| * Sectors Erase: Sector number which returned an error | |||
| * Program: Address which was selected for data program | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_FLASH_OperationErrorCallback(uint32_t 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_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 | |||
| * @param None | |||
| * @retval HAL Status | |||
| */ | |||
| HAL_StatusTypeDef HAL_FLASH_Unlock(void) | |||
| { | |||
| if((FLASH->CR & FLASH_CR_LOCK) != RESET) | |||
| { | |||
| /* Authorize the FLASH Registers access */ | |||
| FLASH->KEYR = FLASH_KEY1; | |||
| FLASH->KEYR = FLASH_KEY2; | |||
| } | |||
| else | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Locks the FLASH control register access | |||
| * @param None | |||
| * @retval HAL Status | |||
| */ | |||
| HAL_StatusTypeDef HAL_FLASH_Lock(void) | |||
| { | |||
| /* Set the LOCK Bit to lock the FLASH Registers access */ | |||
| FLASH->CR |= FLASH_CR_LOCK; | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Unlock the FLASH Option Control Registers access. | |||
| * @param None | |||
| * @retval HAL Status | |||
| */ | |||
| HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void) | |||
| { | |||
| if((FLASH->OPTCR & FLASH_OPTCR_OPTLOCK) != RESET) | |||
| { | |||
| /* Authorizes the Option Byte register programming */ | |||
| FLASH->OPTKEYR = FLASH_OPT_KEY1; | |||
| FLASH->OPTKEYR = FLASH_OPT_KEY2; | |||
| } | |||
| else | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Lock the FLASH Option Control Registers access. | |||
| * @param None | |||
| * @retval HAL Status | |||
| */ | |||
| HAL_StatusTypeDef HAL_FLASH_OB_Lock(void) | |||
| { | |||
| /* Set the OPTLOCK Bit to lock the FLASH Option Byte Registers access */ | |||
| FLASH->OPTCR |= FLASH_OPTCR_OPTLOCK; | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Launch the option byte loading. | |||
| * @param None | |||
| * @retval HAL Status | |||
| */ | |||
| HAL_StatusTypeDef HAL_FLASH_OB_Launch(void) | |||
| { | |||
| /* Set the OPTSTRT bit in OPTCR register */ | |||
| *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS |= FLASH_OPTCR_OPTSTRT; | |||
| /* Wait for last operation to be completed */ | |||
| return(FLASH_WaitForLastOperation((uint32_t)HAL_FLASH_TIMEOUT_VALUE)); | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup FLASH_Group3 Peripheral State and Errors functions | |||
| * @brief Peripheral Errors functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Peripheral Errors functions ##### | |||
| =============================================================================== | |||
| [..] | |||
| This subsection permits to get in run-time Errors of the FLASH peripheral. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Get the specific FLASH error flag. | |||
| * @param None | |||
| * @retval FLASH_ErrorCode: The returned value can be: | |||
| * @arg FLASH_ERROR_RD: FLASH Read Protection error flag (PCROP) | |||
| * @arg FLASH_ERROR_PGS: FLASH Programming Sequence error flag | |||
| * @arg FLASH_ERROR_PGP: FLASH Programming Parallelism error flag | |||
| * @arg FLASH_ERROR_PGA: FLASH Programming Alignment error flag | |||
| * @arg FLASH_ERROR_WRP: FLASH Write protected error flag | |||
| * @arg FLASH_ERROR_OPERATION: FLASH operation Error flag | |||
| */ | |||
| FLASH_ErrorTypeDef HAL_FLASH_GetError(void) | |||
| { | |||
| return pFlash.ErrorCode; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief Wait for a FLASH operation to complete. | |||
| * @param Timeout: maximum flash operationtimeout | |||
| * @retval HAL Status | |||
| */ | |||
| HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout) | |||
| { | |||
| uint32_t tickstart = 0; | |||
| /* 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 */ | |||
| /* Get tick */ | |||
| tickstart = HAL_GetTick(); | |||
| while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) != RESET) | |||
| { | |||
| if(Timeout != HAL_MAX_DELAY) | |||
| { | |||
| if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) | |||
| { | |||
| return HAL_TIMEOUT; | |||
| } | |||
| } | |||
| } | |||
| if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | \ | |||
| FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR)) != RESET) | |||
| { | |||
| /*Save the error code*/ | |||
| FLASH_SetErrorCode(); | |||
| return HAL_ERROR; | |||
| } | |||
| /* If there is an error flag set */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Program a double word (64-bit) at a specified address. | |||
| * @note This function must be used when the device voltage range is from | |||
| * 2.7V to 3.6V and an External Vpp is present. | |||
| * | |||
| * @note If an erase and a program operations are requested simultaneously, | |||
| * the erase operation is performed before the program one. | |||
| * | |||
| * @param Address: specifies the address to be programmed. | |||
| * @param Data: specifies the data to be programmed. | |||
| * @retval None | |||
| */ | |||
| static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_FLASH_ADDRESS(Address)); | |||
| /* If the previous operation is completed, proceed to program the new data */ | |||
| FLASH->CR &= CR_PSIZE_MASK; | |||
| FLASH->CR |= FLASH_PSIZE_DOUBLE_WORD; | |||
| FLASH->CR |= FLASH_CR_PG; | |||
| *(__IO uint64_t*)Address = Data; | |||
| } | |||
| /** | |||
| * @brief Program word (32-bit) at a specified address. | |||
| * @note This function must be used when the device voltage range is from | |||
| * 2.7V to 3.6V. | |||
| * | |||
| * @note If an erase and a program operations are requested simultaneously, | |||
| * the erase operation is performed before the program one. | |||
| * | |||
| * @param Address: specifies the address to be programmed. | |||
| * @param Data: specifies the data to be programmed. | |||
| * @retval None | |||
| */ | |||
| static void FLASH_Program_Word(uint32_t Address, uint32_t Data) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_FLASH_ADDRESS(Address)); | |||
| /* If the previous operation is completed, proceed to program the new data */ | |||
| FLASH->CR &= CR_PSIZE_MASK; | |||
| FLASH->CR |= FLASH_PSIZE_WORD; | |||
| FLASH->CR |= FLASH_CR_PG; | |||
| *(__IO uint32_t*)Address = Data; | |||
| } | |||
| /** | |||
| * @brief Program a half-word (16-bit) at a specified address. | |||
| * @note This function must be used when the device voltage range is from | |||
| * 2.7V to 3.6V. | |||
| * | |||
| * @note If an erase and a program operations are requested simultaneously, | |||
| * the erase operation is performed before the program one. | |||
| * | |||
| * @param Address: specifies the address to be programmed. | |||
| * @param Data: specifies the data to be programmed. | |||
| * @retval None | |||
| */ | |||
| static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_FLASH_ADDRESS(Address)); | |||
| /* If the previous operation is completed, proceed to program the new data */ | |||
| FLASH->CR &= CR_PSIZE_MASK; | |||
| FLASH->CR |= FLASH_PSIZE_HALF_WORD; | |||
| FLASH->CR |= FLASH_CR_PG; | |||
| *(__IO uint16_t*)Address = Data; | |||
| } | |||
| /** | |||
| * @brief Program byte (8-bit) at a specified address. | |||
| * @note This function must be used when the device voltage range is from | |||
| * 2.7V to 3.6V. | |||
| * | |||
| * @note If an erase and a program operations are requested simultaneously, | |||
| * the erase operation is performed before the program one. | |||
| * | |||
| * @param Address: specifies the address to be programmed. | |||
| * @param Data: specifies the data to be programmed. | |||
| * @retval None | |||
| */ | |||
| static void FLASH_Program_Byte(uint32_t Address, uint8_t Data) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_FLASH_ADDRESS(Address)); | |||
| /* If the previous operation is completed, proceed to program the new data */ | |||
| FLASH->CR &= CR_PSIZE_MASK; | |||
| FLASH->CR |= FLASH_PSIZE_BYTE; | |||
| FLASH->CR |= FLASH_CR_PG; | |||
| *(__IO uint8_t*)Address = Data; | |||
| } | |||
| /** | |||
| * @brief Set the specific FLASH error flag. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| static void FLASH_SetErrorCode(void) | |||
| { | |||
| if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) != RESET) | |||
| { | |||
| pFlash.ErrorCode = FLASH_ERROR_WRP; | |||
| } | |||
| if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) != RESET) | |||
| { | |||
| pFlash.ErrorCode |= FLASH_ERROR_PGA; | |||
| } | |||
| if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGPERR) != RESET) | |||
| { | |||
| pFlash.ErrorCode |= FLASH_ERROR_PGP; | |||
| } | |||
| if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR) != RESET) | |||
| { | |||
| pFlash.ErrorCode |= FLASH_ERROR_PGS; | |||
| } | |||
| if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) != RESET) | |||
| { | |||
| pFlash.ErrorCode |= FLASH_ERROR_RD; | |||
| } | |||
| if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR) != RESET) | |||
| { | |||
| pFlash.ErrorCode |= FLASH_ERROR_OPERATION; | |||
| } | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* HAL_FLASH_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,199 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_flash_ramfunc.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief FLASH RAMFUNC module driver. | |||
| * This file provides a FLASH firmware functions which should be | |||
| * executed from internal SRAM | |||
| * + Stop/Start the flash interface while System Run | |||
| * + Enable/Disable the flash sleep while System Run | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### APIs executed from Internal RAM ##### | |||
| ============================================================================== | |||
| [..] | |||
| *** 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) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup FLASH_RAMFUNC | |||
| * @brief FLASH functions executed from RAM | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_FLASH_MODULE_ENABLED | |||
| #if defined(STM32F411xE) | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup FLASH_RAMFUNC_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup FLASH_RAMFUNC_Group1 Peripheral features functions executed from internal RAM | |||
| * @brief Peripheral Extended features functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### ramfunc functions ##### | |||
| =============================================================================== | |||
| [..] | |||
| This subsection provides a set of functions that should be executed from RAM | |||
| transfers. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Stop the flash interface while System Run | |||
| * @note This mode is only available for STM32F411xx devices. | |||
| * @note This mode could n't be set while executing with the flash itself. | |||
| * It should be done with specific routine executed from RAM. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| __RAM_FUNC HAL_FLASHEx_StopFlashInterfaceClk(void) | |||
| { | |||
| /* Enable Power ctrl clock */ | |||
| __PWR_CLK_ENABLE(); | |||
| /* Stop the flash interface while System Run */ | |||
| SET_BIT(PWR->CR, PWR_CR_FISSR); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Start the flash interface while System Run | |||
| * @note This mode is only available for STM32F411xx devices. | |||
| * @note This mode could n't be set while executing with the flash itself. | |||
| * It should be done with specific routine executed from RAM. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| __RAM_FUNC HAL_FLASHEx_StartFlashInterfaceClk(void) | |||
| { | |||
| /* Enable Power ctrl clock */ | |||
| __PWR_CLK_ENABLE(); | |||
| /* Start the flash interface while System Run */ | |||
| CLEAR_BIT(PWR->CR, PWR_CR_FISSR); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Enable the flash sleep while System Run | |||
| * @note This mode is only available for STM32F411xx devices. | |||
| * @note This mode could n't be set while executing with the flash itself. | |||
| * It should be done with specific routine executed from RAM. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| __RAM_FUNC HAL_FLASHEx_EnableFlashSleepMode(void) | |||
| { | |||
| /* Enable Power ctrl clock */ | |||
| __PWR_CLK_ENABLE(); | |||
| /* Enable the flash sleep while System Run */ | |||
| SET_BIT(PWR->CR, PWR_CR_FMSSR); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Disable the flash sleep while System Run | |||
| * @note This mode is only available for STM32F411xx devices. | |||
| * @note This mode could n't be set while executing with the flash itself. | |||
| * It should be done with specific routine executed from RAM. | |||
| * @param None | |||
| * @retval None | |||
| */ | |||
| __RAM_FUNC HAL_FLASHEx_DisableFlashSleepMode(void) | |||
| { | |||
| /* Enable Power ctrl clock */ | |||
| __PWR_CLK_ENABLE(); | |||
| /* Disable the flash sleep while System Run */ | |||
| CLEAR_BIT(PWR->CR, PWR_CR_FMSSR); | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* STM32F411xE */ | |||
| #endif /* HAL_FLASH_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,534 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_gpio.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @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 23 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 AHB clock using the following function: __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(). | |||
| (#) 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(). | |||
| (#) 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) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup GPIO | |||
| * @brief GPIO HAL module driver | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_GPIO_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| #define GET_GPIO_SOURCE(__GPIOx__) \ | |||
| (((uint32_t)(__GPIOx__) == ((uint32_t)GPIOA_BASE))? (uint32_t)0 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0400)))? (uint32_t)1 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0800)))? (uint32_t)2 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0C00)))? (uint32_t)3 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x1000)))? (uint32_t)4 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x1400)))? (uint32_t)5 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x1800)))? (uint32_t)6 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x1C00)))? (uint32_t)7 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x2000)))? (uint32_t)8 :\ | |||
| ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x2400)))? (uint32_t)9 : (uint32_t)10) | |||
| #define GPIO_MODE ((uint32_t)0x00000003) | |||
| #define EXTI_MODE ((uint32_t)0x10000000) | |||
| #define GPIO_MODE_IT ((uint32_t)0x00010000) | |||
| #define GPIO_MODE_EVT ((uint32_t)0x00020000) | |||
| #define RISING_EDGE ((uint32_t)0x00100000) | |||
| #define FALLING_EDGE ((uint32_t)0x00200000) | |||
| #define GPIO_OUTPUT_TYPE ((uint32_t)0x00000010) | |||
| #define GPIO_NUMBER ((uint32_t)16) | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup GPIO_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup GPIO_Group1 Initialization and de-initialization functions | |||
| * @brief Initialization and Configuration 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..K) to select the GPIO peripheral for STM32F429X device or | |||
| * x can be (A..I) to select the GPIO peripheral for STM32F40XX and STM32F427X 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; | |||
| uint32_t ioposition = 0x00; | |||
| uint32_t iocurrent = 0x00; | |||
| uint32_t temp = 0x00; | |||
| /* Check the parameters */ | |||
| assert_param(IS_GPIO_PIN(GPIO_Init->Pin)); | |||
| assert_param(IS_GPIO_MODE(GPIO_Init->Mode)); | |||
| assert_param(IS_GPIO_PULL(GPIO_Init->Pull)); | |||
| /* Configure the port pins */ | |||
| for(position = 0; position < GPIO_NUMBER; position++) | |||
| { | |||
| /* Get the IO position */ | |||
| ioposition = ((uint32_t)0x01) << position; | |||
| /* Get the current IO position */ | |||
| iocurrent = (uint32_t)(GPIO_Init->Pin) & ioposition; | |||
| if(iocurrent == ioposition) | |||
| { | |||
| /*--------------------- GPIO Mode Configuration ------------------------*/ | |||
| /* 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 parameter */ | |||
| assert_param(IS_GPIO_AF(GPIO_Init->Alternate)); | |||
| /* Configure Alternate function mapped with the current IO */ | |||
| temp = GPIOx->AFR[position >> 3]; | |||
| temp &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ; | |||
| temp |= ((uint32_t)(GPIO_Init->Alternate) << (((uint32_t)position & (uint32_t)0x07) * 4)); | |||
| GPIOx->AFR[position >> 3] = temp; | |||
| } | |||
| /* Configure IO Direction mode (Input, Output, Alternate or Analog) */ | |||
| temp = GPIOx->MODER; | |||
| temp &= ~(GPIO_MODER_MODER0 << (position * 2)); | |||
| temp |= ((GPIO_Init->Mode & GPIO_MODE) << (position * 2)); | |||
| GPIOx->MODER = temp; | |||
| /* 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_OSPEEDR0 << (position * 2)); | |||
| temp |= (GPIO_Init->Speed << (position * 2)); | |||
| GPIOx->OSPEEDR = temp; | |||
| /* Configure the IO Output Type */ | |||
| temp = GPIOx->OTYPER; | |||
| temp &= ~(GPIO_OTYPER_OT_0 << position) ; | |||
| temp |= (((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4) << position); | |||
| GPIOx->OTYPER = temp; | |||
| } | |||
| /* Activate the Pull-up or Pull down resistor for the current IO */ | |||
| temp = GPIOx->PUPDR; | |||
| temp &= ~(GPIO_PUPDR_PUPDR0 << (position * 2)); | |||
| temp |= ((GPIO_Init->Pull) << (position * 2)); | |||
| GPIOx->PUPDR = 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 */ | |||
| __SYSCFG_CLK_ENABLE(); | |||
| temp = SYSCFG->EXTICR[position >> 2]; | |||
| temp &= ~(((uint32_t)0x0F) << (4 * (position & 0x03))); | |||
| temp |= ((uint32_t)(GET_GPIO_SOURCE(GPIOx)) << (4 * (position & 0x03))); | |||
| SYSCFG->EXTICR[position >> 2] = 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; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * @brief De-initializes the GPIOx peripheral registers to their default reset values. | |||
| * @param GPIOx: where x can be (A..K) to select the GPIO peripheral for STM32F429X device or | |||
| * x can be (A..I) to select the GPIO peripheral for STM32F40XX and STM32F427X 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). | |||
| * @retval None | |||
| */ | |||
| void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin) | |||
| { | |||
| uint32_t position; | |||
| uint32_t ioposition = 0x00; | |||
| uint32_t iocurrent = 0x00; | |||
| uint32_t tmp = 0x00; | |||
| /* Configure the port pins */ | |||
| for(position = 0; position < GPIO_NUMBER; position++) | |||
| { | |||
| /* Get the IO position */ | |||
| ioposition = ((uint32_t)0x01) << position; | |||
| /* Get the current IO position */ | |||
| iocurrent = (GPIO_Pin) & ioposition; | |||
| if(iocurrent == ioposition) | |||
| { | |||
| /*------------------------- GPIO Mode Configuration --------------------*/ | |||
| /* Configure IO Direction in Input Floting Mode */ | |||
| GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (position * 2)); | |||
| /* Configure the default Alternate Function in current IO */ | |||
| GPIOx->AFR[position >> 3] &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ; | |||
| /* Configure the default value for IO Speed */ | |||
| GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (position * 2)); | |||
| /* Configure the default value IO Output Type */ | |||
| GPIOx->OTYPER &= ~(GPIO_OTYPER_OT_0 << position) ; | |||
| /* Deactivate the Pull-up oand Pull-down resistor for the current IO */ | |||
| GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << (position * 2)); | |||
| /*------------------------- EXTI Mode Configuration --------------------*/ | |||
| /* Configure the External Interrupt or event for the current IO */ | |||
| tmp = ((uint32_t)0x0F) << (4 * (position & 0x03)); | |||
| SYSCFG->EXTICR[position >> 2] &= ~tmp; | |||
| /* 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); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup GPIO_Group2 IO operation functions | |||
| * @brief GPIO Read and Write | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### IO operation functions ##### | |||
| =============================================================================== | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Reads the specified input port pin. | |||
| * @param GPIOx: where x can be (A..K) to select the GPIO peripheral for STM32F429X device or | |||
| * x can be (A..I) to select the GPIO peripheral for STM32F40XX and STM32F427X devices. | |||
| * @param GPIO_Pin: specifies the port bit to read. | |||
| * This parameter can be GPIO_PIN_x where x can be (0..15). | |||
| * @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(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..K) to select the GPIO peripheral for STM32F429X device or | |||
| * x can be (A..I) to select the GPIO peripheral for STM32F40XX and STM32F427X 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). | |||
| * @param PinState: specifies the value to be written to the selected bit. | |||
| * This parameter can be one of the GPIO_PinState enum values: | |||
| * @arg GPIO_PIN_RESET: to clear the port pin | |||
| * @arg 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(GPIO_Pin)); | |||
| assert_param(IS_GPIO_PIN_ACTION(PinState)); | |||
| if(PinState != GPIO_PIN_RESET) | |||
| { | |||
| GPIOx->BSRRL = GPIO_Pin; | |||
| } | |||
| else | |||
| { | |||
| GPIOx->BSRRH = GPIO_Pin ; | |||
| } | |||
| } | |||
| /** | |||
| * @brief Toggles the specified GPIO pins. | |||
| * @param GPIOx: Where x can be (A..K) to select the GPIO peripheral for STM32F429X device or | |||
| * x can be (A..I) to select the GPIO peripheral for STM32F40XX and STM32F427X devices. | |||
| * @param GPIO_Pin: Specifies the pins to be toggled. | |||
| * @retval None | |||
| */ | |||
| void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) | |||
| { | |||
| /* Check the parameters */ | |||
| assert_param(IS_GPIO_PIN(GPIO_Pin)); | |||
| GPIOx->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..F) to select the GPIO peripheral for STM32F4 family | |||
| * @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). | |||
| * @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(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 bit*/ | |||
| tmp = GPIOx->LCKR; | |||
| 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 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 EXTI line | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_GPIO_EXTI_Callback(uint16_t 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****/ | |||
| @@ -0,0 +1,205 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_i2c_ex.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief I2C Extension HAL module driver. | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of I2C extension peripheral: | |||
| * + Extension features functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### I2C peripheral extension features ##### | |||
| ============================================================================== | |||
| [..] Comparing to other previous devices, the I2C interface for STM32F427xx/437xx/ | |||
| 429xx/439xx devices contains the following additional features : | |||
| (+) Possibility to disable or enable Analog Noise Filter | |||
| (+) Use of a configured Digital Noise Filter | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] This driver provides functions to configure Noise Filter | |||
| (#) Configure I2C Analog noise filter using the function HAL_I2C_AnalogFilter_Config() | |||
| (#) Configure I2C Digital noise filter using the function HAL_I2C_DigitalFilter_Config() | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup I2CEx | |||
| * @brief I2C HAL module driver | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_I2C_MODULE_ENABLED | |||
| #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ | |||
| defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup I2CEx_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup I2CEx_Group1 Extension features functions | |||
| * @brief Extension features functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Extension features functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Configure Noise Filters | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Configures 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_AnalogFilter_Config(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter) | |||
| { | |||
| uint32_t tmp = 0; | |||
| /* Check the parameters */ | |||
| assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); | |||
| assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter)); | |||
| tmp = hi2c->State; | |||
| if((tmp == HAL_I2C_STATE_BUSY) || (tmp == HAL_I2C_STATE_BUSY_TX) || (tmp == HAL_I2C_STATE_BUSY_RX)) | |||
| { | |||
| return HAL_BUSY; | |||
| } | |||
| hi2c->State = HAL_I2C_STATE_BUSY; | |||
| /* Disable the selected I2C peripheral */ | |||
| __HAL_I2C_DISABLE(hi2c); | |||
| /* Reset I2Cx ANOFF bit */ | |||
| hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF); | |||
| /* Disable the analog filter */ | |||
| hi2c->Instance->FLTR |= AnalogFilter; | |||
| __HAL_I2C_ENABLE(hi2c); | |||
| hi2c->State = HAL_I2C_STATE_READY; | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Configures 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 0x00 and 0x0F. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_I2CEx_DigitalFilter_Config(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter) | |||
| { | |||
| uint16_t tmpreg = 0; | |||
| uint32_t tmp = 0; | |||
| /* Check the parameters */ | |||
| assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); | |||
| assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter)); | |||
| tmp = hi2c->State; | |||
| if((tmp == HAL_I2C_STATE_BUSY) || (tmp == HAL_I2C_STATE_BUSY_TX) || (tmp == HAL_I2C_STATE_BUSY_RX)) | |||
| { | |||
| return HAL_BUSY; | |||
| } | |||
| hi2c->State = HAL_I2C_STATE_BUSY; | |||
| /* Disable the selected I2C peripheral */ | |||
| __HAL_I2C_DISABLE(hi2c); | |||
| /* Get the old register value */ | |||
| tmpreg = hi2c->Instance->FLTR; | |||
| /* Reset I2Cx DNF bit [3:0] */ | |||
| tmpreg &= ~(I2C_FLTR_DNF); | |||
| /* Set I2Cx DNF coefficient */ | |||
| tmpreg |= DigitalFilter; | |||
| /* Store the new register value */ | |||
| hi2c->Instance->FLTR = tmpreg; | |||
| __HAL_I2C_ENABLE(hi2c); | |||
| hi2c->State = HAL_I2C_STATE_READY; | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F401xC || STM32F401xE */ | |||
| #endif /* HAL_I2C_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,752 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_i2s_ex.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief I2S HAL module driver. | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of I2S extension peripheral: | |||
| * + Extension features Functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### I2S Extension features ##### | |||
| ============================================================================== | |||
| [..] | |||
| (#) In I2S full duplex mode, each SPI peripheral is able to manage sending and receiving | |||
| data simultaneously using two data lines. Each SPI peripheral has an extended block | |||
| called I2Sxext (i.e I2S2ext for SPI2 and I2S3ext for SPI3). | |||
| (#) The extension block is not a full SPI IP, it is used only as I2S slave to | |||
| implement full duplex mode. The extension block uses the same clock sources | |||
| as its master. | |||
| (#) Both I2Sx and I2Sx_ext can be configured as transmitters or receivers. | |||
| [..] | |||
| (@) Only I2Sx can deliver SCK and WS to I2Sx_ext in full duplex mode, where | |||
| I2Sx can be I2S2 or I2S3. | |||
| ##### How to use this driver ##### | |||
| =============================================================================== | |||
| [..] | |||
| Three operation modes are available within this driver : | |||
| *** Polling mode IO operation *** | |||
| ================================= | |||
| [..] | |||
| (+) Send and receive in the same time an amount of data in blocking mode using HAL_I2S_TransmitReceive() | |||
| *** Interrupt mode IO operation *** | |||
| =================================== | |||
| [..] | |||
| (+) Send and receive in the same time an amount of data in non blocking mode using HAL_I2S_TransmitReceive_IT() | |||
| (+) At transmission end of half transfer HAL_I2S_TxHalfCpltCallback is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_TxHalfCpltCallback | |||
| (+) At transmission end of transfer HAL_I2S_TxCpltCallback is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_TxCpltCallback | |||
| (+) At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback | |||
| (+) At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_RxCpltCallback | |||
| (+) In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_ErrorCallback | |||
| *** DMA mode IO operation *** | |||
| ============================== | |||
| [..] | |||
| (+) Send and receive an amount of data in non blocking mode (DMA) using HAL_I2S_TransmitReceive_DMA() | |||
| (+) At transmission end of half transfer HAL_I2S_TxHalfCpltCallback is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_TxHalfCpltCallback | |||
| (+) At transmission end of transfer HAL_I2S_TxCpltCallback is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_TxCpltCallback | |||
| (+) At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback | |||
| (+) At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_RxCpltCallback | |||
| (+) In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can | |||
| add his own code by customization of function pointer HAL_I2S_ErrorCallback | |||
| (+) Pause the DMA Transfer using HAL_I2S_DMAPause() | |||
| (+) Resume the DMA Transfer using HAL_I2S_DMAResume() | |||
| (+) Stop the DMA Transfer using HAL_I2S_DMAStop() | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup I2SEx | |||
| * @brief I2S HAL module driver | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_I2S_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup I2SEx_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup I2SEx_Group1 Extension features functions | |||
| * @brief Extension features functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Extension features Functions ##### | |||
| =============================================================================== | |||
| [..] | |||
| This subsection provides a set of functions allowing to manage the I2S data | |||
| transfers. | |||
| (#) There are two modes of transfer: | |||
| (++) Blocking mode : The communication is performed in the polling mode. | |||
| The status of all data processing is returned by the same function | |||
| after finishing transfer. | |||
| (++) No-Blocking mode : The communication is performed using Interrupts | |||
| or DMA. These functions return the status of the transfer startup. | |||
| The end of the data processing will be indicated through the | |||
| dedicated I2S IRQ when using Interrupt mode or the DMA IRQ when | |||
| using DMA mode. | |||
| (#) Blocking mode functions are : | |||
| (++) HAL_I2S_TransmitReceive() | |||
| (#) No-Blocking mode functions with Interrupt are : | |||
| (++) HAL_I2S_TransmitReceive_IT() | |||
| (#) No-Blocking mode functions with DMA are : | |||
| (++) HAL_I2S_TransmitReceive_DMA() | |||
| (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: | |||
| (++) HAL_I2S_TxCpltCallback() | |||
| (++) HAL_I2S_RxCpltCallback() | |||
| (++) HAL_I2S_ErrorCallback() | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Full-Duplex Transmit/Receive data in blocking mode. | |||
| * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains | |||
| * the configuration information for I2S module | |||
| * @param pTxData: a 16-bit pointer to the Transmit data buffer. | |||
| * @param pRxData: a 16-bit pointer to the Receive data buffer. | |||
| * @param Size: number of data sample to be sent: | |||
| * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S | |||
| * configuration phase, the Size parameter means the number of 16-bit data length | |||
| * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected | |||
| * the Size parameter means the number of 16-bit data length. | |||
| * @param Timeout: Timeout duration | |||
| * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization | |||
| * between Master and Slave(example: audio streaming). | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size, uint32_t Timeout) | |||
| { | |||
| uint32_t tickstart = 0; | |||
| uint32_t tmp1 = 0, tmp2 = 0; | |||
| if((pTxData == NULL ) || (pRxData == NULL ) || (Size == 0)) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check the I2S State */ | |||
| if(hi2s->State == HAL_I2S_STATE_READY) | |||
| { | |||
| tmp1 = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN); | |||
| tmp2 = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN); | |||
| /* Check the Data format: When a 16-bit data frame or a 16-bit data frame extended | |||
| is selected during the I2S configuration phase, the Size parameter means the number | |||
| of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data | |||
| frame is selected the Size parameter means the number of 16-bit data length. */ | |||
| if((tmp1 == I2S_DATAFORMAT_24B)|| \ | |||
| (tmp2 == I2S_DATAFORMAT_32B)) | |||
| { | |||
| hi2s->TxXferSize = Size*2; | |||
| hi2s->TxXferCount = Size*2; | |||
| hi2s->RxXferSize = Size*2; | |||
| hi2s->RxXferCount = Size*2; | |||
| } | |||
| else | |||
| { | |||
| hi2s->TxXferSize = Size; | |||
| hi2s->TxXferCount = Size; | |||
| hi2s->RxXferSize = Size; | |||
| hi2s->RxXferCount = Size; | |||
| } | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hi2s); | |||
| /* Set the I2S State busy TX/RX */ | |||
| hi2s->State = HAL_I2S_STATE_BUSY_TX_RX; | |||
| tmp1 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG; | |||
| tmp2 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG; | |||
| /* Check if the I2S_MODE_MASTER_TX or I2S_MODE_SLAVE_TX Mode is selected */ | |||
| if((tmp1 == I2S_MODE_MASTER_TX) || (tmp2 == I2S_MODE_SLAVE_TX)) | |||
| { | |||
| /* Check if the I2S is already enabled: The I2S is kept enabled at the end of transaction | |||
| to avoid the clock de-synchronization between Master and Slave. */ | |||
| if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) | |||
| { | |||
| /* Enable I2Sext(receiver) before enabling I2Sx peripheral */ | |||
| I2SxEXT(hi2s->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE; | |||
| /* Enable I2Sx peripheral */ | |||
| __HAL_I2S_ENABLE(hi2s); | |||
| } | |||
| while(hi2s->TxXferCount > 0) | |||
| { | |||
| /* Wait until TXE flag is set */ | |||
| if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, RESET, Timeout) != HAL_OK) | |||
| { | |||
| return HAL_TIMEOUT; | |||
| } | |||
| hi2s->Instance->DR = (*pTxData++); | |||
| /* Get tick */ | |||
| tickstart = HAL_GetTick(); | |||
| /* Wait until RXNE flag is set */ | |||
| while((I2SxEXT(hi2s->Instance)->SR & SPI_SR_RXNE) != SPI_SR_RXNE) | |||
| { | |||
| if(Timeout != HAL_MAX_DELAY) | |||
| { | |||
| if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) | |||
| { | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hi2s); | |||
| return HAL_TIMEOUT; | |||
| } | |||
| } | |||
| } | |||
| (*pRxData++) = I2SxEXT(hi2s->Instance)->DR; | |||
| hi2s->TxXferCount--; | |||
| hi2s->RxXferCount--; | |||
| } | |||
| } | |||
| /* The I2S_MODE_MASTER_RX or I2S_MODE_SLAVE_RX Mode is selected */ | |||
| else | |||
| { | |||
| /* Check if the I2S is already enabled */ | |||
| if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) | |||
| { | |||
| /* Enable I2S peripheral before the I2Sext*/ | |||
| __HAL_I2S_ENABLE(hi2s); | |||
| /* Enable I2Sext(transmitter) after enabling I2Sx peripheral */ | |||
| I2SxEXT(hi2s->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE; | |||
| } | |||
| else | |||
| { | |||
| /* Check if Master Receiver mode is selected */ | |||
| if((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_RX) | |||
| { | |||
| /* Clear the Overrun Flag by a read operation on the SPI_DR register followed by a read | |||
| access to the SPI_SR register. */ | |||
| __HAL_I2S_CLEAR_OVRFLAG(hi2s); | |||
| } | |||
| } | |||
| while(hi2s->TxXferCount > 0) | |||
| { | |||
| /* Get tick */ | |||
| tickstart = HAL_GetTick(); | |||
| /* Wait until TXE flag is set */ | |||
| while((I2SxEXT(hi2s->Instance)->SR & SPI_SR_TXE) != SPI_SR_TXE) | |||
| { | |||
| if(Timeout != HAL_MAX_DELAY) | |||
| { | |||
| if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) | |||
| { | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hi2s); | |||
| return HAL_TIMEOUT; | |||
| } | |||
| } | |||
| } | |||
| I2SxEXT(hi2s->Instance)->DR = (*pTxData++); | |||
| /* Wait until RXNE flag is set */ | |||
| if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_RXNE, RESET, Timeout) != HAL_OK) | |||
| { | |||
| return HAL_TIMEOUT; | |||
| } | |||
| (*pRxData++) = hi2s->Instance->DR; | |||
| hi2s->TxXferCount--; | |||
| hi2s->RxXferCount--; | |||
| } | |||
| } | |||
| /* Set the I2S State ready */ | |||
| hi2s->State = HAL_I2S_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hi2s); | |||
| return HAL_OK; | |||
| } | |||
| else | |||
| { | |||
| return HAL_BUSY; | |||
| } | |||
| } | |||
| /** | |||
| * @brief Full-Duplex Transmit/Receive data in non-blocking mode using Interrupt | |||
| * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains | |||
| * the configuration information for I2S module | |||
| * @param pTxData: a 16-bit pointer to the Transmit data buffer. | |||
| * @param pRxData: a 16-bit pointer to the Receive data buffer. | |||
| * @param Size: number of data sample to be sent: | |||
| * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S | |||
| * configuration phase, the Size parameter means the number of 16-bit data length | |||
| * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected | |||
| * the Size parameter means the number of 16-bit data length. | |||
| * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization | |||
| * between Master and Slave(example: audio streaming). | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size) | |||
| { | |||
| uint32_t tmp1 = 0, tmp2 = 0; | |||
| if(hi2s->State == HAL_I2S_STATE_READY) | |||
| { | |||
| if((pTxData == NULL ) || (pRxData == NULL ) || (Size == 0)) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| hi2s->pTxBuffPtr = pTxData; | |||
| hi2s->pRxBuffPtr = pRxData; | |||
| tmp1 = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN); | |||
| tmp2 = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN); | |||
| /* Check the Data format: When a 16-bit data frame or a 16-bit data frame extended | |||
| is selected during the I2S configuration phase, the Size parameter means the number | |||
| of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data | |||
| frame is selected the Size parameter means the number of 16-bit data length. */ | |||
| if((tmp1 == I2S_DATAFORMAT_24B)||\ | |||
| (tmp2 == I2S_DATAFORMAT_32B)) | |||
| { | |||
| hi2s->TxXferSize = Size*2; | |||
| hi2s->TxXferCount = Size*2; | |||
| hi2s->RxXferSize = Size*2; | |||
| hi2s->RxXferCount = Size*2; | |||
| } | |||
| else | |||
| { | |||
| hi2s->TxXferSize = Size; | |||
| hi2s->TxXferCount = Size; | |||
| hi2s->RxXferSize = Size; | |||
| hi2s->RxXferCount = Size; | |||
| } | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hi2s); | |||
| hi2s->State = HAL_I2S_STATE_BUSY_TX_RX; | |||
| hi2s->ErrorCode = HAL_I2S_ERROR_NONE; | |||
| tmp1 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG; | |||
| tmp2 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG; | |||
| /* Check if the I2S_MODE_MASTER_TX or I2S_MODE_SLAVE_TX Mode is selected */ | |||
| if((tmp1 == I2S_MODE_MASTER_TX) || (tmp2 == I2S_MODE_SLAVE_TX)) | |||
| { | |||
| /* Enable I2Sext RXNE and ERR interrupts */ | |||
| I2SxEXT(hi2s->Instance)->CR2 |= (I2S_IT_RXNE | I2S_IT_ERR); | |||
| /* Enable I2Sx TXE and ERR interrupts */ | |||
| __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_TXE | I2S_IT_ERR)); | |||
| /* Check if the I2S is already enabled */ | |||
| if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) | |||
| { | |||
| /* Enable I2Sext(receiver) before enabling I2Sx peripheral */ | |||
| I2SxEXT(hi2s->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE; | |||
| /* Enable I2Sx peripheral */ | |||
| __HAL_I2S_ENABLE(hi2s); | |||
| } | |||
| } | |||
| /* The I2S_MODE_MASTER_RX or I2S_MODE_SLAVE_RX Mode is selected */ | |||
| else | |||
| { | |||
| /* Enable I2Sext TXE and ERR interrupts */ | |||
| I2SxEXT(hi2s->Instance)->CR2 |= (I2S_IT_TXE |I2S_IT_ERR); | |||
| /* Enable I2Sext RXNE and ERR interrupts */ | |||
| __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_RXNE | I2S_IT_ERR)); | |||
| /* Check if the I2S is already enabled */ | |||
| if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) | |||
| { | |||
| /* Check if the I2S_MODE_MASTER_RX is selected */ | |||
| if((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_RX) | |||
| { | |||
| /* Prepare the First Data before enabling the I2S */ | |||
| if(hi2s->TxXferCount != 0) | |||
| { | |||
| /* Transmit First data */ | |||
| I2SxEXT(hi2s->Instance)->DR = (*hi2s->pTxBuffPtr++); | |||
| hi2s->TxXferCount--; | |||
| if(hi2s->TxXferCount == 0) | |||
| { | |||
| /* Disable I2Sext TXE interrupt */ | |||
| I2SxEXT(hi2s->Instance)->CR2 &= ~I2S_IT_TXE; | |||
| } | |||
| } | |||
| } | |||
| /* Enable I2S peripheral */ | |||
| __HAL_I2S_ENABLE(hi2s); | |||
| /* Enable I2Sext(transmitter) after enabling I2Sx peripheral */ | |||
| I2SxEXT(hi2s->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE; | |||
| } | |||
| } | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hi2s); | |||
| return HAL_OK; | |||
| } | |||
| else | |||
| { | |||
| return HAL_BUSY; | |||
| } | |||
| } | |||
| /** | |||
| * @brief Full-Duplex Transmit/Receive data in non-blocking mode using DMA | |||
| * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains | |||
| * the configuration information for I2S module | |||
| * @param pTxData: a 16-bit pointer to the Transmit data buffer. | |||
| * @param pRxData: a 16-bit pointer to the Receive data buffer. | |||
| * @param Size: number of data sample to be sent: | |||
| * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S | |||
| * configuration phase, the Size parameter means the number of 16-bit data length | |||
| * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected | |||
| * the Size parameter means the number of 16-bit data length. | |||
| * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization | |||
| * between Master and Slave(example: audio streaming). | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size) | |||
| { | |||
| uint32_t *tmp; | |||
| uint32_t tmp1 = 0, tmp2 = 0; | |||
| if((pTxData == NULL ) || (pRxData == NULL ) || (Size == 0)) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| if(hi2s->State == HAL_I2S_STATE_READY) | |||
| { | |||
| hi2s->pTxBuffPtr = pTxData; | |||
| hi2s->pRxBuffPtr = pRxData; | |||
| tmp1 = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN); | |||
| tmp2 = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN); | |||
| /* Check the Data format: When a 16-bit data frame or a 16-bit data frame extended | |||
| is selected during the I2S configuration phase, the Size parameter means the number | |||
| of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data | |||
| frame is selected the Size parameter means the number of 16-bit data length. */ | |||
| if((tmp1 == I2S_DATAFORMAT_24B)||\ | |||
| (tmp2 == I2S_DATAFORMAT_32B)) | |||
| { | |||
| hi2s->TxXferSize = Size*2; | |||
| hi2s->TxXferCount = Size*2; | |||
| hi2s->RxXferSize = Size*2; | |||
| hi2s->RxXferCount = Size*2; | |||
| } | |||
| else | |||
| { | |||
| hi2s->TxXferSize = Size; | |||
| hi2s->TxXferCount = Size; | |||
| hi2s->RxXferSize = Size; | |||
| hi2s->RxXferCount = Size; | |||
| } | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hi2s); | |||
| hi2s->State = HAL_I2S_STATE_BUSY_TX_RX; | |||
| hi2s->ErrorCode = HAL_I2S_ERROR_NONE; | |||
| /* Set the I2S Rx DMA Half transfert complete callback */ | |||
| hi2s->hdmarx->XferHalfCpltCallback = I2S_DMARxHalfCplt; | |||
| /* Set the I2S Rx DMA transfert complete callback */ | |||
| hi2s->hdmarx->XferCpltCallback = I2S_DMARxCplt; | |||
| /* Set the I2S Rx DMA error callback */ | |||
| hi2s->hdmarx->XferErrorCallback = I2S_DMAError; | |||
| /* Set the I2S Tx DMA Half transfert complete callback */ | |||
| hi2s->hdmatx->XferHalfCpltCallback = I2S_DMATxHalfCplt; | |||
| /* Set the I2S Tx DMA transfert complete callback */ | |||
| hi2s->hdmatx->XferCpltCallback = I2S_DMATxCplt; | |||
| /* Set the I2S Tx DMA error callback */ | |||
| hi2s->hdmatx->XferErrorCallback = I2S_DMAError; | |||
| tmp1 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG; | |||
| tmp2 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG; | |||
| /* Check if the I2S_MODE_MASTER_TX or I2S_MODE_SLAVE_TX Mode is selected */ | |||
| if((tmp1 == I2S_MODE_MASTER_TX) || (tmp2 == I2S_MODE_SLAVE_TX)) | |||
| { | |||
| /* Enable the Rx DMA Stream */ | |||
| tmp = (uint32_t*)&pRxData; | |||
| HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&I2SxEXT(hi2s->Instance)->DR, *(uint32_t*)tmp, hi2s->RxXferSize); | |||
| /* Enable Rx DMA Request */ | |||
| I2SxEXT(hi2s->Instance)->CR2 |= SPI_CR2_RXDMAEN; | |||
| /* Enable the Tx DMA Stream */ | |||
| tmp = (uint32_t*)&pTxData; | |||
| HAL_DMA_Start_IT(hi2s->hdmatx, *(uint32_t*)tmp, (uint32_t)&hi2s->Instance->DR, hi2s->TxXferSize); | |||
| /* Enable Tx DMA Request */ | |||
| hi2s->Instance->CR2 |= SPI_CR2_TXDMAEN; | |||
| /* Check if the I2S is already enabled */ | |||
| if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) | |||
| { | |||
| /* Enable I2Sext(receiver) before enabling I2Sx peripheral */ | |||
| I2SxEXT(hi2s->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE; | |||
| /* Enable I2S peripheral after the I2Sext */ | |||
| __HAL_I2S_ENABLE(hi2s); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| /* Enable the Tx DMA Stream */ | |||
| tmp = (uint32_t*)&pTxData; | |||
| HAL_DMA_Start_IT(hi2s->hdmatx, *(uint32_t*)tmp, (uint32_t)&I2SxEXT(hi2s->Instance)->DR, hi2s->TxXferSize); | |||
| /* Enable Tx DMA Request */ | |||
| I2SxEXT(hi2s->Instance)->CR2 |= SPI_CR2_TXDMAEN; | |||
| /* Enable the Rx DMA Stream */ | |||
| tmp = (uint32_t*)&pRxData; | |||
| HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&hi2s->Instance->DR, *(uint32_t*)tmp, hi2s->RxXferSize); | |||
| /* Enable Rx DMA Request */ | |||
| hi2s->Instance->CR2 |= SPI_CR2_RXDMAEN; | |||
| /* Check if the I2S is already enabled */ | |||
| if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) | |||
| { | |||
| /* Enable I2S peripheral before the I2Sext */ | |||
| __HAL_I2S_ENABLE(hi2s); | |||
| /* Enable I2Sext(transmitter) after enabling I2Sx peripheral */ | |||
| I2SxEXT(hi2s->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE; | |||
| } | |||
| else | |||
| { | |||
| /* Check if Master Receiver mode is selected */ | |||
| if((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_RX) | |||
| { | |||
| /* Clear the Overrun Flag by a read operation on the SPI_DR register followed by a read | |||
| access to the SPI_SR register. */ | |||
| __HAL_I2S_CLEAR_OVRFLAG(hi2s); | |||
| } | |||
| } | |||
| } | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hi2s); | |||
| return HAL_OK; | |||
| } | |||
| else | |||
| { | |||
| return HAL_BUSY; | |||
| } | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @brief Full-Duplex Transmit/Receive data in non-blocking mode using Interrupt | |||
| * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains | |||
| * the configuration information for I2S module | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s) | |||
| { | |||
| uint32_t tmp1 = 0, tmp2 = 0; | |||
| if(hi2s->State == HAL_I2S_STATE_BUSY_TX_RX) | |||
| { | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hi2s); | |||
| tmp1 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG; | |||
| tmp2 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG; | |||
| /* Check if the I2S_MODE_MASTER_TX or I2S_MODE_SLAVE_TX Mode is selected */ | |||
| if((tmp1 == I2S_MODE_MASTER_TX) || (tmp2 == I2S_MODE_SLAVE_TX)) | |||
| { | |||
| if(hi2s->TxXferCount != 0) | |||
| { | |||
| if(__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_TXE) != RESET) | |||
| { | |||
| /* Transmit data */ | |||
| hi2s->Instance->DR = (*hi2s->pTxBuffPtr++); | |||
| hi2s->TxXferCount--; | |||
| if(hi2s->TxXferCount == 0) | |||
| { | |||
| /* Disable TXE interrupt */ | |||
| __HAL_I2S_DISABLE_IT(hi2s, I2S_IT_TXE); | |||
| } | |||
| } | |||
| } | |||
| if(hi2s->RxXferCount != 0) | |||
| { | |||
| if((I2SxEXT(hi2s->Instance)->SR & SPI_SR_RXNE) == SPI_SR_RXNE) | |||
| { | |||
| /* Receive data */ | |||
| (*hi2s->pRxBuffPtr++) = I2SxEXT(hi2s->Instance)->DR; | |||
| hi2s->RxXferCount--; | |||
| if(hi2s->RxXferCount == 0) | |||
| { | |||
| /* Disable I2Sext RXNE interrupt */ | |||
| I2SxEXT(hi2s->Instance)->CR2 &= ~I2S_IT_RXNE; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /* The I2S_MODE_MASTER_RX or I2S_MODE_SLAVE_RX Mode is selected */ | |||
| else | |||
| { | |||
| if(hi2s->TxXferCount != 0) | |||
| { | |||
| if((I2SxEXT(hi2s->Instance)->SR & SPI_SR_TXE) == SPI_SR_TXE) | |||
| { | |||
| /* Transmit data */ | |||
| I2SxEXT(hi2s->Instance)->DR = (*hi2s->pTxBuffPtr++); | |||
| hi2s->TxXferCount--; | |||
| if(hi2s->TxXferCount == 0) | |||
| { | |||
| /* Disable I2Sext TXE interrupt */ | |||
| I2SxEXT(hi2s->Instance)->CR2 &= ~I2S_IT_TXE; | |||
| HAL_I2S_TxCpltCallback(hi2s); | |||
| } | |||
| } | |||
| } | |||
| if(hi2s->RxXferCount != 0) | |||
| { | |||
| if(__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_RXNE) != RESET) | |||
| { | |||
| /* Receive data */ | |||
| (*hi2s->pRxBuffPtr++) = hi2s->Instance->DR; | |||
| hi2s->RxXferCount--; | |||
| if(hi2s->RxXferCount == 0) | |||
| { | |||
| /* Disable RXNE interrupt */ | |||
| __HAL_I2S_DISABLE_IT(hi2s, I2S_IT_RXNE); | |||
| HAL_I2S_RxCpltCallback(hi2s); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| tmp1 = hi2s->RxXferCount; | |||
| tmp2 = hi2s->TxXferCount; | |||
| if((tmp1 == 0) && (tmp2 == 0)) | |||
| { | |||
| /* Disable I2Sx ERR interrupt */ | |||
| __HAL_I2S_DISABLE_IT(hi2s, I2S_IT_ERR); | |||
| /* Disable I2Sext ERR interrupt */ | |||
| I2SxEXT(hi2s->Instance)->CR2 &= ~I2S_IT_ERR; | |||
| hi2s->State = HAL_I2S_STATE_READY; | |||
| } | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hi2s); | |||
| return HAL_OK; | |||
| } | |||
| else | |||
| { | |||
| return HAL_BUSY; | |||
| } | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* HAL_I2S_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||
| @@ -0,0 +1,355 @@ | |||
| /** | |||
| ****************************************************************************** | |||
| * @file stm32f4xx_hal_iwdg.c | |||
| * @author MCD Application Team | |||
| * @version V1.1.0 | |||
| * @date 19-June-2014 | |||
| * @brief IWDG HAL module driver. | |||
| * This file provides firmware functions to manage the following | |||
| * functionalities of the Independent Watchdog (IWDG) peripheral: | |||
| * + Initialization and de-initialization functions | |||
| * + IO operation functions | |||
| * + Peripheral State functions | |||
| * | |||
| @verbatim | |||
| ============================================================================== | |||
| ##### IWDG Generic features ##### | |||
| ============================================================================== | |||
| [..] | |||
| (+) The IWDG can be started by either software or hardware (configurable | |||
| through option byte). | |||
| (+) The IWDG is clocked by its own dedicated Low-Speed clock (LSI) and | |||
| thus stays active even if the main clock fails. | |||
| Once the IWDG is started, the LSI is forced ON and cannot be disabled | |||
| (LSI cannot be disabled too), and the counter starts counting down from | |||
| the reset value of 0xFFF. When it reaches the end of count value (0x000) | |||
| a system reset is generated. | |||
| (+) The IWDG counter should be refreshed at regular intervals, otherwise the | |||
| watchdog generates an MCU reset when the counter reaches 0. | |||
| (+) The IWDG is implemented in the VDD voltage domain that is still functional | |||
| in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY). | |||
| IWDGRST flag in RCC_CSR register can be used to inform when an IWDG | |||
| reset occurs. | |||
| (+) Min-max timeout value @32KHz (LSI): ~125us / ~32.7s | |||
| The IWDG timeout may vary due to LSI frequency dispersion. STM32F4xx | |||
| devices provide the capability to measure the LSI frequency (LSI clock | |||
| connected internally to TIM5 CH4 input capture). The measured value | |||
| can be used to have an IWDG timeout with an acceptable accuracy. | |||
| ##### How to use this driver ##### | |||
| ============================================================================== | |||
| [..] | |||
| If Window option is disabled | |||
| (+) Use IWDG using HAL_IWDG_Init() function to : | |||
| (++) Enable write access to IWDG_PR, IWDG_RLR. | |||
| (++) Configure the IWDG prescaler, counter reload value. | |||
| This reload value will be loaded in the IWDG counter each time the counter | |||
| is reloaded, then the IWDG will start counting down from this value. | |||
| [..] | |||
| (+) Use IWDG using HAL_IWDG_Start() function to: | |||
| (++) Reload IWDG counter with value defined in the IWDG_RLR register. | |||
| (++) Start the IWDG, when the IWDG is used in software mode (no need | |||
| to enable the LSI, it will be enabled by hardware). | |||
| (+) Then the application program must refresh the IWDG counter at regular | |||
| intervals during normal operation to prevent an MCU reset, using | |||
| HAL_IWDG_Refresh() function. | |||
| [..] | |||
| if Window option is enabled: | |||
| (+) Use IWDG using HAL_IWDG_Start() function to enable IWDG downcounter | |||
| (+) Use IWDG using HAL_IWDG_Init() function to : | |||
| (++) Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. | |||
| (++) Configure the IWDG prescaler, reload value and window value. | |||
| (+) Then the application program must refresh the IWDG counter at regular | |||
| intervals during normal operation to prevent an MCU reset, using | |||
| HAL_IWDG_Refresh() function. | |||
| *** IWDG HAL driver macros list *** | |||
| ==================================== | |||
| [..] | |||
| Below the list of most used macros in IWDG HAL driver. | |||
| (+) __HAL_IWDG_START: Enable the IWDG peripheral | |||
| (+) __HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in the reload register | |||
| (+) __HAL_IWDG_ENABLE_WRITE_ACCESS : Enable write access to IWDG_PR and IWDG_RLR registers | |||
| (+) __HAL_IWDG_DISABLE_WRITE_ACCESS : Disable write access to IWDG_PR and IWDG_RLR registers | |||
| (+) __HAL_IWDG_GET_FLAG: Get the selected IWDG's flag status | |||
| @endverbatim | |||
| ****************************************************************************** | |||
| * @attention | |||
| * | |||
| * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without modification, | |||
| * are permitted provided that the following conditions are met: | |||
| * 1. Redistributions of source code must retain the above copyright notice, | |||
| * this list of conditions and the following disclaimer. | |||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | |||
| * this list of conditions and the following disclaimer in the documentation | |||
| * and/or other materials provided with the distribution. | |||
| * 3. Neither the name of STMicroelectronics nor the names of its contributors | |||
| * may be used to endorse or promote products derived from this software | |||
| * without specific prior written permission. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
| * | |||
| ****************************************************************************** | |||
| */ | |||
| /* Includes ------------------------------------------------------------------*/ | |||
| #include "stm32f4xx_hal.h" | |||
| /** @addtogroup STM32F4xx_HAL_Driver | |||
| * @{ | |||
| */ | |||
| /** @defgroup IWDG | |||
| * @brief IWDG HAL module driver. | |||
| * @{ | |||
| */ | |||
| #ifdef HAL_IWDG_MODULE_ENABLED | |||
| /* Private typedef -----------------------------------------------------------*/ | |||
| /* Private define ------------------------------------------------------------*/ | |||
| #define IWDG_TIMEOUT_FLAG ((uint32_t)1000) /* 1 s */ | |||
| /* Private macro -------------------------------------------------------------*/ | |||
| /* Private variables ---------------------------------------------------------*/ | |||
| /* Private function prototypes -----------------------------------------------*/ | |||
| /* Private functions ---------------------------------------------------------*/ | |||
| /** @defgroup IWDG_Private_Functions | |||
| * @{ | |||
| */ | |||
| /** @defgroup IWDG_Group1 Initialization and de-initialization functions | |||
| * @brief Initialization and Configuration functions. | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Initialization and de-initialization functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Initialize the IWDG according to the specified parameters | |||
| in the IWDG_InitTypeDef and create the associated handle | |||
| (+) Initialize the IWDG MSP | |||
| (+) DeInitialize IWDG MSP | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Initializes the IWDG according to the specified | |||
| * parameters in the IWDG_InitTypeDef and creates the associated handle. | |||
| * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains | |||
| * the configuration information for the specified IWDG module. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg) | |||
| { | |||
| /* Check the IWDG handle allocation */ | |||
| if(hiwdg == NULL) | |||
| { | |||
| return HAL_ERROR; | |||
| } | |||
| /* Check the parameters */ | |||
| assert_param(IS_IWDG_ALL_INSTANCE(hiwdg->Instance)); | |||
| assert_param(IS_IWDG_PRESCALER(hiwdg->Init.Prescaler)); | |||
| assert_param(IS_IWDG_RELOAD(hiwdg->Init.Reload)); | |||
| if(hiwdg->State == HAL_IWDG_STATE_RESET) | |||
| { | |||
| /* Init the low level hardware */ | |||
| HAL_IWDG_MspInit(hiwdg); | |||
| } | |||
| /* Change IWDG peripheral state */ | |||
| hiwdg->State = HAL_IWDG_STATE_BUSY; | |||
| /* Enable write access to IWDG_PR and IWDG_RLR registers */ | |||
| __HAL_IWDG_ENABLE_WRITE_ACCESS(hiwdg); | |||
| /* Write to IWDG registers the IWDG_Prescaler & IWDG_Reload values to work with */ | |||
| MODIFY_REG(hiwdg->Instance->PR, IWDG_PR_PR, hiwdg->Init.Prescaler); | |||
| MODIFY_REG(hiwdg->Instance->RLR, IWDG_RLR_RL, hiwdg->Init.Reload); | |||
| /* Change IWDG peripheral state */ | |||
| hiwdg->State = HAL_IWDG_STATE_READY; | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Initializes the IWDG MSP. | |||
| * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains | |||
| * the configuration information for the specified IWDG module. | |||
| * @retval None | |||
| */ | |||
| __weak void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg) | |||
| { | |||
| /* NOTE : This function Should not be modified, when the callback is needed, | |||
| the HAL_IWDG_MspInit could be implemented in the user file | |||
| */ | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IWDG_Group2 IO operation functions | |||
| * @brief IO operation functions | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### IO operation functions ##### | |||
| =============================================================================== | |||
| [..] This section provides functions allowing to: | |||
| (+) Start the IWDG. | |||
| (+) Refresh the IWDG. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Starts the IWDG. | |||
| * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains | |||
| * the configuration information for the specified IWDG module. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg) | |||
| { | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hiwdg); | |||
| /* Change IWDG peripheral state */ | |||
| hiwdg->State = HAL_IWDG_STATE_BUSY; | |||
| /* Start the IWDG peripheral */ | |||
| __HAL_IWDG_START(hiwdg); | |||
| /* Reload IWDG counter with value defined in the RLR register */ | |||
| __HAL_IWDG_RELOAD_COUNTER(hiwdg); | |||
| /* Change IWDG peripheral state */ | |||
| hiwdg->State = HAL_IWDG_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hiwdg); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @brief Refreshes the IWDG. | |||
| * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains | |||
| * the configuration information for the specified IWDG module. | |||
| * @retval HAL status | |||
| */ | |||
| HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg) | |||
| { | |||
| uint32_t tickstart = 0; | |||
| /* Process Locked */ | |||
| __HAL_LOCK(hiwdg); | |||
| /* Change IWDG peripheral state */ | |||
| hiwdg->State = HAL_IWDG_STATE_BUSY; | |||
| tickstart = HAL_GetTick(); | |||
| /* Wait until RVU flag is RESET */ | |||
| while(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_RVU) != RESET) | |||
| { | |||
| if((HAL_GetTick() - tickstart ) > IWDG_TIMEOUT_FLAG) | |||
| { | |||
| /* Set IWDG state */ | |||
| hiwdg->State = HAL_IWDG_STATE_TIMEOUT; | |||
| /* Process unlocked */ | |||
| __HAL_UNLOCK(hiwdg); | |||
| return HAL_TIMEOUT; | |||
| } | |||
| } | |||
| /* Reload IWDG counter with value defined in the reload register */ | |||
| __HAL_IWDG_RELOAD_COUNTER(hiwdg); | |||
| /* Change IWDG peripheral state */ | |||
| hiwdg->State = HAL_IWDG_STATE_READY; | |||
| /* Process Unlocked */ | |||
| __HAL_UNLOCK(hiwdg); | |||
| /* Return function status */ | |||
| return HAL_OK; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** @defgroup IWDG_Group3 Peripheral State functions | |||
| * @brief Peripheral State functions. | |||
| * | |||
| @verbatim | |||
| =============================================================================== | |||
| ##### Peripheral State functions ##### | |||
| =============================================================================== | |||
| [..] | |||
| This subsection permits to get in run-time the status of the peripheral | |||
| and the data flow. | |||
| @endverbatim | |||
| * @{ | |||
| */ | |||
| /** | |||
| * @brief Returns the IWDG state. | |||
| * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains | |||
| * the configuration information for the specified IWDG module. | |||
| * @retval HAL state | |||
| */ | |||
| HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg) | |||
| { | |||
| return hiwdg->State; | |||
| } | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| #endif /* HAL_IWDG_MODULE_ENABLED */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /** | |||
| * @} | |||
| */ | |||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |||