├── .cproject ├── .gitignore ├── .mxproject ├── .project ├── .settings ├── com.atollic.truestudio.debug.hardware_device.prefs ├── language.settings.xml └── org.eclipse.cdt.managedbuilder.core.prefs ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F4xx │ │ │ └── Include │ │ │ ├── stm32f407xx.h │ │ │ ├── stm32f4xx.h │ │ │ └── system_stm32f4xx.h │ └── Include │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armcc_V6.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── core_sc000.h │ │ └── core_sc300.h └── STM32F4xx_HAL_Driver │ ├── Inc │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32f4xx_hal.h │ ├── stm32f4xx_hal_cortex.h │ ├── stm32f4xx_hal_def.h │ ├── stm32f4xx_hal_dma.h │ ├── stm32f4xx_hal_dma_ex.h │ ├── stm32f4xx_hal_flash.h │ ├── stm32f4xx_hal_flash_ex.h │ ├── stm32f4xx_hal_flash_ramfunc.h │ ├── stm32f4xx_hal_gpio.h │ ├── stm32f4xx_hal_gpio_ex.h │ ├── stm32f4xx_hal_i2c.h │ ├── stm32f4xx_hal_i2c_ex.h │ ├── stm32f4xx_hal_pwr.h │ ├── stm32f4xx_hal_pwr_ex.h │ ├── stm32f4xx_hal_rcc.h │ ├── stm32f4xx_hal_rcc_ex.h │ ├── stm32f4xx_hal_tim.h │ └── stm32f4xx_hal_tim_ex.h │ └── Src │ ├── stm32f4xx_hal.c │ ├── stm32f4xx_hal_cortex.c │ ├── stm32f4xx_hal_dma.c │ ├── stm32f4xx_hal_dma_ex.c │ ├── stm32f4xx_hal_flash.c │ ├── stm32f4xx_hal_flash_ex.c │ ├── stm32f4xx_hal_flash_ramfunc.c │ ├── stm32f4xx_hal_gpio.c │ ├── stm32f4xx_hal_i2c.c │ ├── stm32f4xx_hal_i2c_ex.c │ ├── stm32f4xx_hal_pwr.c │ ├── stm32f4xx_hal_pwr_ex.c │ ├── stm32f4xx_hal_rcc.c │ ├── stm32f4xx_hal_rcc_ex.c │ ├── stm32f4xx_hal_tim.c │ └── stm32f4xx_hal_tim_ex.c ├── Inc ├── main.h ├── stm32f4xx_hal_conf.h └── stm32f4xx_it.h ├── README.md ├── STM32F407VG_FLASH.ld ├── STM32F4_HAL_I2C_DS3231.elf.launch ├── STM32F4_HAL_I2C_DS3231.ioc ├── Src ├── main.c ├── stm32_ds3231.c ├── stm32_ds3231.h ├── stm32f4xx_hal_msp.c ├── stm32f4xx_it.c └── system_stm32f4xx.c ├── ds3231.JPG └── startup └── startup_stm32f407xx.s /.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | -------------------------------------------------------------------------------- /.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=D:/Workspace/GitHub/STM32F4_HAL_EXAMPLES/STM32F4_HAL_I2C_DS3231/Inc 3 | HeaderFiles=stm32f4xx_it.h;stm32f4xx_hal_conf.h;main.h; 4 | SourcePath=D:/Workspace/GitHub/STM32F4_HAL_EXAMPLES/STM32F4_HAL_I2C_DS3231/Src 5 | SourceFiles=stm32f4xx_it.c;stm32f4xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedTStudioFiles] 11 | SourceFiles=..\Src\main.c;..\Src\stm32f4xx_it.c;..\Src\stm32f4xx_hal_msp.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;../\Src/system_stm32f4xx.c;../Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;null; 12 | HeaderPath=..\Drivers\STM32F4xx_HAL_Driver\Inc;..\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F4xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | CDefines=__weak:__attribute__((weak));__packed:__attribute__((__packed__)); 14 | 15 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | STM32F4_HAL_I2C_DS3231 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | ?children? 14 | ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| 15 | 16 | 17 | ?name? 18 | 19 | 20 | 21 | org.eclipse.cdt.make.core.append_environment 22 | true 23 | 24 | 25 | org.eclipse.cdt.make.core.buildArguments 26 | 27 | 28 | 29 | org.eclipse.cdt.make.core.buildCommand 30 | make 31 | 32 | 33 | org.eclipse.cdt.make.core.buildLocation 34 | ${workspace_loc:/STM32100B-EVAL/Debug} 35 | 36 | 37 | org.eclipse.cdt.make.core.contents 38 | org.eclipse.cdt.make.core.activeConfigSettings 39 | 40 | 41 | org.eclipse.cdt.make.core.enableAutoBuild 42 | false 43 | 44 | 45 | org.eclipse.cdt.make.core.enableCleanBuild 46 | true 47 | 48 | 49 | org.eclipse.cdt.make.core.enableFullBuild 50 | true 51 | 52 | 53 | org.eclipse.cdt.make.core.stopOnError 54 | true 55 | 56 | 57 | org.eclipse.cdt.make.core.useDefaultBuildCmd 58 | true 59 | 60 | 61 | 62 | 63 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 64 | 65 | 66 | 67 | 68 | 69 | org.eclipse.cdt.core.cnature 70 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 71 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /.settings/com.atollic.truestudio.debug.hardware_device.prefs: -------------------------------------------------------------------------------- 1 | BOARD=None 2 | CODE_LOCATION=FLASH 3 | ENDIAN=Little-endian 4 | MCU=STM32F407VG 5 | MCU_VENDOR=STMicroelectronics 6 | MODEL=Lite 7 | PROBE=ST-LINK 8 | PROJECT_FORMAT_VERSION=2 9 | TARGET=ARM\u00AE 10 | VERSION=4.1.0 11 | eclipse.preferences.version=1 12 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/CPATH/delimiter=; 3 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/C_INCLUDE_PATH/delimiter=; 5 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/C_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/append=true 7 | environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/appendContributed=true 8 | environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/LIBRARY_PATH/delimiter=; 9 | environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/LIBRARY_PATH/operation=remove 10 | environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/append=true 11 | environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/appendContributed=true 12 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eziya/STM32_HAL_DS3231/1b916c673ade6d15e3a3caaec1d1f4288e2da768/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /** @addtogroup CMSIS 37 | * @{ 38 | */ 39 | 40 | /** @addtogroup stm32f4xx_system 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Define to prevent recursive inclusion 46 | */ 47 | #ifndef __SYSTEM_STM32F4XX_H 48 | #define __SYSTEM_STM32F4XX_H 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** @addtogroup STM32F4xx_System_Includes 55 | * @{ 56 | */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @addtogroup STM32F4xx_System_Exported_types 64 | * @{ 65 | */ 66 | /* This variable is updated in three ways: 67 | 1) by calling CMSIS function SystemCoreClockUpdate() 68 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 69 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 70 | Note: If you use this function to configure the system clock; then there 71 | is no need to call the 2 first functions listed above, since SystemCoreClock 72 | variable is updated automatically. 73 | */ 74 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 75 | 76 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 77 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F4xx_System_Exported_Constants 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @addtogroup STM32F4xx_System_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @addtogroup STM32F4xx_System_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | extern void SystemInit(void); 104 | extern void SystemCoreClockUpdate(void); 105 | /** 106 | * @} 107 | */ 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /*__SYSTEM_STM32F4XX_H */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. October 2015 5 | * $Revision: V.1.4.5 a 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | /* extern const q31_t realCoefAQ31[1024]; */ 50 | /* extern const q31_t realCoefBQ31[1024]; */ 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoef_16_q31[24]; 62 | extern const q31_t twiddleCoef_32_q31[48]; 63 | extern const q31_t twiddleCoef_64_q31[96]; 64 | extern const q31_t twiddleCoef_128_q31[192]; 65 | extern const q31_t twiddleCoef_256_q31[384]; 66 | extern const q31_t twiddleCoef_512_q31[768]; 67 | extern const q31_t twiddleCoef_1024_q31[1536]; 68 | extern const q31_t twiddleCoef_2048_q31[3072]; 69 | extern const q31_t twiddleCoef_4096_q31[6144]; 70 | extern const q15_t twiddleCoef_16_q15[24]; 71 | extern const q15_t twiddleCoef_32_q15[48]; 72 | extern const q15_t twiddleCoef_64_q15[96]; 73 | extern const q15_t twiddleCoef_128_q15[192]; 74 | extern const q15_t twiddleCoef_256_q15[384]; 75 | extern const q15_t twiddleCoef_512_q15[768]; 76 | extern const q15_t twiddleCoef_1024_q15[1536]; 77 | extern const q15_t twiddleCoef_2048_q15[3072]; 78 | extern const q15_t twiddleCoef_4096_q15[6144]; 79 | extern const float32_t twiddleCoef_rfft_32[32]; 80 | extern const float32_t twiddleCoef_rfft_64[64]; 81 | extern const float32_t twiddleCoef_rfft_128[128]; 82 | extern const float32_t twiddleCoef_rfft_256[256]; 83 | extern const float32_t twiddleCoef_rfft_512[512]; 84 | extern const float32_t twiddleCoef_rfft_1024[1024]; 85 | extern const float32_t twiddleCoef_rfft_2048[2048]; 86 | extern const float32_t twiddleCoef_rfft_4096[4096]; 87 | 88 | 89 | /* floating-point bit reversal tables */ 90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 99 | 100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 109 | 110 | /* fixed-point bit reversal tables */ 111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) 112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) 113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) 114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) 115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) 116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) 117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) 118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 120 | 121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; 122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; 123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; 124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; 125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; 126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; 127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 130 | 131 | /* Tables for Fast Math Sine and Cosine */ 132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 135 | 136 | #endif /* ARM_COMMON_TABLES_H */ 137 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal.h 4 | * @author MCD Application Team 5 | * @brief This file contains all the functions prototypes for the HAL 6 | * module driver. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© COPYRIGHT(c) 2017 STMicroelectronics

11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | ****************************************************************************** 35 | */ 36 | 37 | /* Define to prevent recursive inclusion -------------------------------------*/ 38 | #ifndef __STM32F4xx_HAL_H 39 | #define __STM32F4xx_HAL_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* Includes ------------------------------------------------------------------*/ 46 | #include "stm32f4xx_hal_conf.h" 47 | 48 | /** @addtogroup STM32F4xx_HAL_Driver 49 | * @{ 50 | */ 51 | 52 | /** @addtogroup HAL 53 | * @{ 54 | */ 55 | 56 | /* Exported types ------------------------------------------------------------*/ 57 | /* Exported constants --------------------------------------------------------*/ 58 | 59 | /** @defgroup HAL_Exported_Constants HAL Exported Constants 60 | * @{ 61 | */ 62 | 63 | /** @defgroup HAL_TICK_FREQ Tick Frequency 64 | * @{ 65 | */ 66 | typedef enum 67 | { 68 | HAL_TICK_FREQ_10HZ = 100U, 69 | HAL_TICK_FREQ_100HZ = 10U, 70 | HAL_TICK_FREQ_1KHZ = 1U, 71 | HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ 72 | } HAL_TickFreqTypeDef; 73 | /** 74 | * @} 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /* Exported macro ------------------------------------------------------------*/ 82 | /** @defgroup HAL_Exported_Macros HAL Exported Macros 83 | * @{ 84 | */ 85 | 86 | /** @brief Freeze/Unfreeze Peripherals in Debug mode 87 | */ 88 | #define __HAL_DBGMCU_FREEZE_TIM2() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM2_STOP)) 89 | #define __HAL_DBGMCU_FREEZE_TIM3() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM3_STOP)) 90 | #define __HAL_DBGMCU_FREEZE_TIM4() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM4_STOP)) 91 | #define __HAL_DBGMCU_FREEZE_TIM5() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM5_STOP)) 92 | #define __HAL_DBGMCU_FREEZE_TIM6() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM6_STOP)) 93 | #define __HAL_DBGMCU_FREEZE_TIM7() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM7_STOP)) 94 | #define __HAL_DBGMCU_FREEZE_TIM12() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM12_STOP)) 95 | #define __HAL_DBGMCU_FREEZE_TIM13() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM13_STOP)) 96 | #define __HAL_DBGMCU_FREEZE_TIM14() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM14_STOP)) 97 | #define __HAL_DBGMCU_FREEZE_RTC() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_RTC_STOP)) 98 | #define __HAL_DBGMCU_FREEZE_WWDG() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_WWDG_STOP)) 99 | #define __HAL_DBGMCU_FREEZE_IWDG() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_IWDG_STOP)) 100 | #define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)) 101 | #define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)) 102 | #define __HAL_DBGMCU_FREEZE_I2C3_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT)) 103 | #define __HAL_DBGMCU_FREEZE_CAN1() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_CAN1_STOP)) 104 | #define __HAL_DBGMCU_FREEZE_CAN2() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_CAN2_STOP)) 105 | #define __HAL_DBGMCU_FREEZE_TIM1() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM1_STOP)) 106 | #define __HAL_DBGMCU_FREEZE_TIM8() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM8_STOP)) 107 | #define __HAL_DBGMCU_FREEZE_TIM9() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM9_STOP)) 108 | #define __HAL_DBGMCU_FREEZE_TIM10() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM10_STOP)) 109 | #define __HAL_DBGMCU_FREEZE_TIM11() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM11_STOP)) 110 | 111 | #define __HAL_DBGMCU_UNFREEZE_TIM2() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM2_STOP)) 112 | #define __HAL_DBGMCU_UNFREEZE_TIM3() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM3_STOP)) 113 | #define __HAL_DBGMCU_UNFREEZE_TIM4() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM4_STOP)) 114 | #define __HAL_DBGMCU_UNFREEZE_TIM5() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM5_STOP)) 115 | #define __HAL_DBGMCU_UNFREEZE_TIM6() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM6_STOP)) 116 | #define __HAL_DBGMCU_UNFREEZE_TIM7() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM7_STOP)) 117 | #define __HAL_DBGMCU_UNFREEZE_TIM12() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM12_STOP)) 118 | #define __HAL_DBGMCU_UNFREEZE_TIM13() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM13_STOP)) 119 | #define __HAL_DBGMCU_UNFREEZE_TIM14() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM14_STOP)) 120 | #define __HAL_DBGMCU_UNFREEZE_RTC() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_RTC_STOP)) 121 | #define __HAL_DBGMCU_UNFREEZE_WWDG() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_WWDG_STOP)) 122 | #define __HAL_DBGMCU_UNFREEZE_IWDG() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_IWDG_STOP)) 123 | #define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)) 124 | #define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)) 125 | #define __HAL_DBGMCU_UNFREEZE_I2C3_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT)) 126 | #define __HAL_DBGMCU_UNFREEZE_CAN1() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_CAN1_STOP)) 127 | #define __HAL_DBGMCU_UNFREEZE_CAN2() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_CAN2_STOP)) 128 | #define __HAL_DBGMCU_UNFREEZE_TIM1() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM1_STOP)) 129 | #define __HAL_DBGMCU_UNFREEZE_TIM8() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM8_STOP)) 130 | #define __HAL_DBGMCU_UNFREEZE_TIM9() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM9_STOP)) 131 | #define __HAL_DBGMCU_UNFREEZE_TIM10() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM10_STOP)) 132 | #define __HAL_DBGMCU_UNFREEZE_TIM11() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM11_STOP)) 133 | 134 | /** @brief Main Flash memory mapped at 0x00000000 135 | */ 136 | #define __HAL_SYSCFG_REMAPMEMORY_FLASH() (SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE)) 137 | 138 | /** @brief System Flash memory mapped at 0x00000000 139 | */ 140 | #define __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ 141 | SYSCFG->MEMRMP |= SYSCFG_MEMRMP_MEM_MODE_0;\ 142 | }while(0); 143 | 144 | /** @brief Embedded SRAM mapped at 0x00000000 145 | */ 146 | #define __HAL_SYSCFG_REMAPMEMORY_SRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ 147 | SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_0 | SYSCFG_MEMRMP_MEM_MODE_1);\ 148 | }while(0); 149 | 150 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) 151 | /** @brief FSMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 152 | */ 153 | #define __HAL_SYSCFG_REMAPMEMORY_FSMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ 154 | SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ 155 | }while(0); 156 | #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ 157 | 158 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 159 | defined(STM32F469xx) || defined(STM32F479xx) 160 | /** @brief FMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 161 | */ 162 | #define __HAL_SYSCFG_REMAPMEMORY_FMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ 163 | SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ 164 | }while(0); 165 | 166 | /** @brief FMC/SDRAM Bank 1 and 2 mapped at 0x00000000 167 | */ 168 | #define __HAL_SYSCFG_REMAPMEMORY_FMC_SDRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ 169 | SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_2);\ 170 | }while(0); 171 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 172 | 173 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F413xx) || defined(STM32F423xx) 174 | /** @defgroup Cortex_Lockup_Enable Cortex Lockup Enable 175 | * @{ 176 | */ 177 | /** @brief SYSCFG Break Lockup lock 178 | * Enables and locks the connection of Cortex-M4 LOCKUP (Hardfault) output to TIM1/8 input 179 | * @note The selected configuration is locked and can be unlocked by system reset 180 | */ 181 | #define __HAL_SYSCFG_BREAK_PVD_LOCK() do {SYSCFG->CFGR2 &= ~(SYSCFG_CFGR2_PVD_LOCK); \ 182 | SYSCFG->CFGR2 |= SYSCFG_CFGR2_PVD_LOCK; \ 183 | }while(0) 184 | /** 185 | * @} 186 | */ 187 | 188 | /** @defgroup PVD_Lock_Enable PVD Lock 189 | * @{ 190 | */ 191 | /** @brief SYSCFG Break PVD lock 192 | * Enables and locks the PVD connection with Timer1/8 Break Input, , as well as the PVDE and PLS[2:0] in the PWR_CR register 193 | * @note The selected configuration is locked and can be unlocked by system reset 194 | */ 195 | #define __HAL_SYSCFG_BREAK_LOCKUP_LOCK() do {SYSCFG->CFGR2 &= ~(SYSCFG_CFGR2_LOCKUP_LOCK); \ 196 | SYSCFG->CFGR2 |= SYSCFG_CFGR2_LOCKUP_LOCK; \ 197 | }while(0) 198 | /** 199 | * @} 200 | */ 201 | #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx || STM32F413xx || STM32F423xx */ 202 | /** 203 | * @} 204 | */ 205 | 206 | /** @defgroup HAL_Private_Macros HAL Private Macros 207 | * @{ 208 | */ 209 | #define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ) || \ 210 | ((FREQ) == HAL_TICK_FREQ_100HZ) || \ 211 | ((FREQ) == HAL_TICK_FREQ_1KHZ)) 212 | /** 213 | * @} 214 | */ 215 | 216 | /* Exported functions --------------------------------------------------------*/ 217 | /** @addtogroup HAL_Exported_Functions 218 | * @{ 219 | */ 220 | /** @addtogroup HAL_Exported_Functions_Group1 221 | * @{ 222 | */ 223 | /* Initialization and Configuration functions ******************************/ 224 | HAL_StatusTypeDef HAL_Init(void); 225 | HAL_StatusTypeDef HAL_DeInit(void); 226 | void HAL_MspInit(void); 227 | void HAL_MspDeInit(void); 228 | HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority); 229 | /** 230 | * @} 231 | */ 232 | 233 | /** @addtogroup HAL_Exported_Functions_Group2 234 | * @{ 235 | */ 236 | /* Peripheral Control functions ************************************************/ 237 | void HAL_IncTick(void); 238 | void HAL_Delay(uint32_t Delay); 239 | uint32_t HAL_GetTick(void); 240 | uint32_t HAL_GetTickPrio(void); 241 | HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq); 242 | HAL_TickFreqTypeDef HAL_GetTickFreq(void); 243 | void HAL_SuspendTick(void); 244 | void HAL_ResumeTick(void); 245 | uint32_t HAL_GetHalVersion(void); 246 | uint32_t HAL_GetREVID(void); 247 | uint32_t HAL_GetDEVID(void); 248 | void HAL_DBGMCU_EnableDBGSleepMode(void); 249 | void HAL_DBGMCU_DisableDBGSleepMode(void); 250 | void HAL_DBGMCU_EnableDBGStopMode(void); 251 | void HAL_DBGMCU_DisableDBGStopMode(void); 252 | void HAL_DBGMCU_EnableDBGStandbyMode(void); 253 | void HAL_DBGMCU_DisableDBGStandbyMode(void); 254 | void HAL_EnableCompensationCell(void); 255 | void HAL_DisableCompensationCell(void); 256 | void HAL_GetUID(uint32_t *UID); 257 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 258 | defined(STM32F469xx) || defined(STM32F479xx) 259 | void HAL_EnableMemorySwappingBank(void); 260 | void HAL_DisableMemorySwappingBank(void); 261 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 262 | /** 263 | * @} 264 | */ 265 | 266 | /** 267 | * @} 268 | */ 269 | /* Private types -------------------------------------------------------------*/ 270 | /* Private variables ---------------------------------------------------------*/ 271 | /** @defgroup HAL_Private_Variables HAL Private Variables 272 | * @{ 273 | */ 274 | /** 275 | * @} 276 | */ 277 | /* Private constants ---------------------------------------------------------*/ 278 | /** @defgroup HAL_Private_Constants HAL Private Constants 279 | * @{ 280 | */ 281 | /** 282 | * @} 283 | */ 284 | /* Private macros ------------------------------------------------------------*/ 285 | /* Private functions ---------------------------------------------------------*/ 286 | /** 287 | * @} 288 | */ 289 | 290 | /** 291 | * @} 292 | */ 293 | 294 | #ifdef __cplusplus 295 | } 296 | #endif 297 | 298 | #endif /* __STM32F4xx_HAL_H */ 299 | 300 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 301 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© COPYRIGHT(c) 2017 STMicroelectronics

11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | ****************************************************************************** 35 | */ 36 | 37 | /* Define to prevent recursive inclusion -------------------------------------*/ 38 | #ifndef __STM32F4xx_HAL_DEF 39 | #define __STM32F4xx_HAL_DEF 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* Includes ------------------------------------------------------------------*/ 46 | #include "stm32f4xx.h" 47 | #include "Legacy/stm32_hal_legacy.h" 48 | #include 49 | 50 | /* Exported types ------------------------------------------------------------*/ 51 | 52 | /** 53 | * @brief HAL Status structures definition 54 | */ 55 | typedef enum 56 | { 57 | HAL_OK = 0x00U, 58 | HAL_ERROR = 0x01U, 59 | HAL_BUSY = 0x02U, 60 | HAL_TIMEOUT = 0x03U 61 | } HAL_StatusTypeDef; 62 | 63 | /** 64 | * @brief HAL Lock structures definition 65 | */ 66 | typedef enum 67 | { 68 | HAL_UNLOCKED = 0x00U, 69 | HAL_LOCKED = 0x01U 70 | } HAL_LockTypeDef; 71 | 72 | /* Exported macro ------------------------------------------------------------*/ 73 | 74 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 75 | 76 | #define HAL_MAX_DELAY 0xFFFFFFFFU 77 | 78 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) 79 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) 80 | 81 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 82 | do{ \ 83 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 84 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 85 | } while(0U) 86 | 87 | /** @brief Reset the Handle's State field. 88 | * @param __HANDLE__ specifies the Peripheral Handle. 89 | * @note This macro can be used for the following purpose: 90 | * - When the Handle is declared as local variable; before passing it as parameter 91 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 92 | * to set to 0 the Handle's "State" field. 93 | * Otherwise, "State" field may have any random value and the first time the function 94 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 95 | * (i.e. HAL_PPP_MspInit() will not be executed). 96 | * - When there is a need to reconfigure the low level hardware: instead of calling 97 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 98 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 99 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 100 | * @retval None 101 | */ 102 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 103 | 104 | #if (USE_RTOS == 1U) 105 | /* Reserved for future use */ 106 | #error "USE_RTOS should be 0 in the current HAL release" 107 | #else 108 | #define __HAL_LOCK(__HANDLE__) \ 109 | do{ \ 110 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 111 | { \ 112 | return HAL_BUSY; \ 113 | } \ 114 | else \ 115 | { \ 116 | (__HANDLE__)->Lock = HAL_LOCKED; \ 117 | } \ 118 | }while (0U) 119 | 120 | #define __HAL_UNLOCK(__HANDLE__) \ 121 | do{ \ 122 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 123 | }while (0U) 124 | #endif /* USE_RTOS */ 125 | 126 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 127 | #ifndef __weak 128 | #define __weak __attribute__((weak)) 129 | #endif /* __weak */ 130 | #ifndef __packed 131 | #define __packed __attribute__((__packed__)) 132 | #endif /* __packed */ 133 | #endif /* __GNUC__ */ 134 | 135 | 136 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 137 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 138 | #ifndef __ALIGN_END 139 | #define __ALIGN_END __attribute__ ((aligned (4))) 140 | #endif /* __ALIGN_END */ 141 | #ifndef __ALIGN_BEGIN 142 | #define __ALIGN_BEGIN 143 | #endif /* __ALIGN_BEGIN */ 144 | #else 145 | #ifndef __ALIGN_END 146 | #define __ALIGN_END 147 | #endif /* __ALIGN_END */ 148 | #ifndef __ALIGN_BEGIN 149 | #if defined (__CC_ARM) /* ARM Compiler */ 150 | #define __ALIGN_BEGIN __align(4) 151 | #elif defined (__ICCARM__) /* IAR Compiler */ 152 | #define __ALIGN_BEGIN 153 | #endif /* __CC_ARM */ 154 | #endif /* __ALIGN_BEGIN */ 155 | #endif /* __GNUC__ */ 156 | 157 | 158 | /** 159 | * @brief __RAM_FUNC definition 160 | */ 161 | #if defined ( __CC_ARM ) 162 | /* ARM Compiler 163 | ------------ 164 | RAM functions are defined using the toolchain options. 165 | Functions that are executed in RAM should reside in a separate source module. 166 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 167 | area of a module to a memory space in physical RAM. 168 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 169 | dialog. 170 | */ 171 | #define __RAM_FUNC 172 | 173 | #elif defined ( __ICCARM__ ) 174 | /* ICCARM Compiler 175 | --------------- 176 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 177 | */ 178 | #define __RAM_FUNC __ramfunc 179 | 180 | #elif defined ( __GNUC__ ) 181 | /* GNU Compiler 182 | ------------ 183 | RAM functions are defined using a specific toolchain attribute 184 | "__attribute__((section(".RamFunc")))". 185 | */ 186 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 187 | 188 | #endif 189 | 190 | /** 191 | * @brief __NOINLINE definition 192 | */ 193 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 194 | /* ARM & GNUCompiler 195 | ---------------- 196 | */ 197 | #define __NOINLINE __attribute__ ( (noinline) ) 198 | 199 | #elif defined ( __ICCARM__ ) 200 | /* ICCARM Compiler 201 | --------------- 202 | */ 203 | #define __NOINLINE _Pragma("optimize = no_inline") 204 | 205 | #endif 206 | 207 | #ifdef __cplusplus 208 | } 209 | #endif 210 | 211 | #endif /* ___STM32F4xx_HAL_DEF */ 212 | 213 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 214 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_DMA_EX_H 38 | #define __STM32F4xx_HAL_DMA_EX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f4xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F4xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup DMAEx 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 57 | * @brief DMAEx Exported types 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @brief HAL DMA Memory definition 63 | */ 64 | typedef enum 65 | { 66 | MEMORY0 = 0x00U, /*!< Memory 0 */ 67 | MEMORY1 = 0x01U /*!< Memory 1 */ 68 | }HAL_DMA_MemoryTypeDef; 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /* Exported functions --------------------------------------------------------*/ 75 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 76 | * @brief DMAEx Exported functions 77 | * @{ 78 | */ 79 | 80 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 81 | * @brief Extended features functions 82 | * @{ 83 | */ 84 | 85 | /* IO operation functions *******************************************************/ 86 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 87 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 88 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 89 | 90 | /** 91 | * @} 92 | */ 93 | /** 94 | * @} 95 | */ 96 | 97 | /* Private functions ---------------------------------------------------------*/ 98 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 99 | * @brief DMAEx Private functions 100 | * @{ 101 | */ 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | 118 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/ 119 | 120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 121 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_FLASH_H 38 | #define __STM32F4xx_HAL_FLASH_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f4xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F4xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup FLASH 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /** @defgroup FLASH_Exported_Types FLASH Exported Types 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @brief FLASH Procedure structure definition 62 | */ 63 | typedef enum 64 | { 65 | FLASH_PROC_NONE = 0U, 66 | FLASH_PROC_SECTERASE, 67 | FLASH_PROC_MASSERASE, 68 | FLASH_PROC_PROGRAM 69 | } FLASH_ProcedureTypeDef; 70 | 71 | /** 72 | * @brief FLASH handle Structure definition 73 | */ 74 | typedef struct 75 | { 76 | __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*Internal variable to indicate which procedure is ongoing or not in IT context*/ 77 | 78 | __IO uint32_t NbSectorsToErase; /*Internal variable to save the remaining sectors to erase in IT context*/ 79 | 80 | __IO uint8_t VoltageForErase; /*Internal variable to provide voltage range selected by user in IT context*/ 81 | 82 | __IO uint32_t Sector; /*Internal variable to define the current sector which is erasing*/ 83 | 84 | __IO uint32_t Bank; /*Internal variable to save current bank selected during mass erase*/ 85 | 86 | __IO uint32_t Address; /*Internal variable to save address selected for program*/ 87 | 88 | HAL_LockTypeDef Lock; /* FLASH locking object */ 89 | 90 | __IO uint32_t ErrorCode; /* FLASH error code */ 91 | 92 | }FLASH_ProcessTypeDef; 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /* Exported constants --------------------------------------------------------*/ 99 | /** @defgroup FLASH_Exported_Constants FLASH Exported Constants 100 | * @{ 101 | */ 102 | /** @defgroup FLASH_Error_Code FLASH Error Code 103 | * @brief FLASH Error Code 104 | * @{ 105 | */ 106 | #define HAL_FLASH_ERROR_NONE 0x00000000U /*!< No error */ 107 | #define HAL_FLASH_ERROR_RD 0x00000001U /*!< Read Protection error */ 108 | #define HAL_FLASH_ERROR_PGS 0x00000002U /*!< Programming Sequence error */ 109 | #define HAL_FLASH_ERROR_PGP 0x00000004U /*!< Programming Parallelism error */ 110 | #define HAL_FLASH_ERROR_PGA 0x00000008U /*!< Programming Alignment error */ 111 | #define HAL_FLASH_ERROR_WRP 0x00000010U /*!< Write protection error */ 112 | #define HAL_FLASH_ERROR_OPERATION 0x00000020U /*!< Operation Error */ 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup FLASH_Type_Program FLASH Type Program 118 | * @{ 119 | */ 120 | #define FLASH_TYPEPROGRAM_BYTE 0x00000000U /*!< Program byte (8-bit) at a specified address */ 121 | #define FLASH_TYPEPROGRAM_HALFWORD 0x00000001U /*!< Program a half-word (16-bit) at a specified address */ 122 | #define FLASH_TYPEPROGRAM_WORD 0x00000002U /*!< Program a word (32-bit) at a specified address */ 123 | #define FLASH_TYPEPROGRAM_DOUBLEWORD 0x00000003U /*!< Program a double word (64-bit) at a specified address */ 124 | /** 125 | * @} 126 | */ 127 | 128 | /** @defgroup FLASH_Flag_definition FLASH Flag definition 129 | * @brief Flag definition 130 | * @{ 131 | */ 132 | #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Operation flag */ 133 | #define FLASH_FLAG_OPERR FLASH_SR_SOP /*!< FLASH operation Error flag */ 134 | #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */ 135 | #define FLASH_FLAG_PGAERR FLASH_SR_PGAERR /*!< FLASH Programming Alignment error flag */ 136 | #define FLASH_FLAG_PGPERR FLASH_SR_PGPERR /*!< FLASH Programming Parallelism error flag */ 137 | #define FLASH_FLAG_PGSERR FLASH_SR_PGSERR /*!< FLASH Programming Sequence error flag */ 138 | #if defined(FLASH_SR_RDERR) 139 | #define FLASH_FLAG_RDERR FLASH_SR_RDERR /*!< Read Protection error flag (PCROP) */ 140 | #endif /* FLASH_SR_RDERR */ 141 | #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */ 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup FLASH_Interrupt_definition FLASH Interrupt definition 147 | * @brief FLASH Interrupt definition 148 | * @{ 149 | */ 150 | #define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */ 151 | #define FLASH_IT_ERR 0x02000000U /*!< Error Interrupt source */ 152 | /** 153 | * @} 154 | */ 155 | 156 | /** @defgroup FLASH_Program_Parallelism FLASH Program Parallelism 157 | * @{ 158 | */ 159 | #define FLASH_PSIZE_BYTE 0x00000000U 160 | #define FLASH_PSIZE_HALF_WORD 0x00000100U 161 | #define FLASH_PSIZE_WORD 0x00000200U 162 | #define FLASH_PSIZE_DOUBLE_WORD 0x00000300U 163 | #define CR_PSIZE_MASK 0xFFFFFCFFU 164 | /** 165 | * @} 166 | */ 167 | 168 | /** @defgroup FLASH_Keys FLASH Keys 169 | * @{ 170 | */ 171 | #define RDP_KEY ((uint16_t)0x00A5) 172 | #define FLASH_KEY1 0x45670123U 173 | #define FLASH_KEY2 0xCDEF89ABU 174 | #define FLASH_OPT_KEY1 0x08192A3BU 175 | #define FLASH_OPT_KEY2 0x4C5D6E7FU 176 | /** 177 | * @} 178 | */ 179 | 180 | /** 181 | * @} 182 | */ 183 | 184 | /* Exported macro ------------------------------------------------------------*/ 185 | /** @defgroup FLASH_Exported_Macros FLASH Exported Macros 186 | * @{ 187 | */ 188 | /** 189 | * @brief Set the FLASH Latency. 190 | * @param __LATENCY__ FLASH Latency 191 | * The value of this parameter depend on device used within the same series 192 | * @retval none 193 | */ 194 | #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (*(__IO uint8_t *)ACR_BYTE0_ADDRESS = (uint8_t)(__LATENCY__)) 195 | 196 | /** 197 | * @brief Get the FLASH Latency. 198 | * @retval FLASH Latency 199 | * The value of this parameter depend on device used within the same series 200 | */ 201 | #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)) 202 | 203 | /** 204 | * @brief Enable the FLASH prefetch buffer. 205 | * @retval none 206 | */ 207 | #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTEN) 208 | 209 | /** 210 | * @brief Disable the FLASH prefetch buffer. 211 | * @retval none 212 | */ 213 | #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTEN)) 214 | 215 | /** 216 | * @brief Enable the FLASH instruction cache. 217 | * @retval none 218 | */ 219 | #define __HAL_FLASH_INSTRUCTION_CACHE_ENABLE() (FLASH->ACR |= FLASH_ACR_ICEN) 220 | 221 | /** 222 | * @brief Disable the FLASH instruction cache. 223 | * @retval none 224 | */ 225 | #define __HAL_FLASH_INSTRUCTION_CACHE_DISABLE() (FLASH->ACR &= (~FLASH_ACR_ICEN)) 226 | 227 | /** 228 | * @brief Enable the FLASH data cache. 229 | * @retval none 230 | */ 231 | #define __HAL_FLASH_DATA_CACHE_ENABLE() (FLASH->ACR |= FLASH_ACR_DCEN) 232 | 233 | /** 234 | * @brief Disable the FLASH data cache. 235 | * @retval none 236 | */ 237 | #define __HAL_FLASH_DATA_CACHE_DISABLE() (FLASH->ACR &= (~FLASH_ACR_DCEN)) 238 | 239 | /** 240 | * @brief Resets the FLASH instruction Cache. 241 | * @note This function must be used only when the Instruction Cache is disabled. 242 | * @retval None 243 | */ 244 | #define __HAL_FLASH_INSTRUCTION_CACHE_RESET() do {FLASH->ACR |= FLASH_ACR_ICRST; \ 245 | FLASH->ACR &= ~FLASH_ACR_ICRST; \ 246 | }while(0U) 247 | 248 | /** 249 | * @brief Resets the FLASH data Cache. 250 | * @note This function must be used only when the data Cache is disabled. 251 | * @retval None 252 | */ 253 | #define __HAL_FLASH_DATA_CACHE_RESET() do {FLASH->ACR |= FLASH_ACR_DCRST; \ 254 | FLASH->ACR &= ~FLASH_ACR_DCRST; \ 255 | }while(0U) 256 | /** 257 | * @brief Enable the specified FLASH interrupt. 258 | * @param __INTERRUPT__ FLASH interrupt 259 | * This parameter can be any combination of the following values: 260 | * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt 261 | * @arg FLASH_IT_ERR: Error Interrupt 262 | * @retval none 263 | */ 264 | #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) (FLASH->CR |= (__INTERRUPT__)) 265 | 266 | /** 267 | * @brief Disable the specified FLASH interrupt. 268 | * @param __INTERRUPT__ FLASH interrupt 269 | * This parameter can be any combination of the following values: 270 | * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt 271 | * @arg FLASH_IT_ERR: Error Interrupt 272 | * @retval none 273 | */ 274 | #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) (FLASH->CR &= ~(uint32_t)(__INTERRUPT__)) 275 | 276 | /** 277 | * @brief Get the specified FLASH flag status. 278 | * @param __FLAG__ specifies the FLASH flags to check. 279 | * This parameter can be any combination of the following values: 280 | * @arg FLASH_FLAG_EOP : FLASH End of Operation flag 281 | * @arg FLASH_FLAG_OPERR : FLASH operation Error flag 282 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag 283 | * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag 284 | * @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag 285 | * @arg FLASH_FLAG_PGSERR: FLASH Programming Sequence error flag 286 | * @arg FLASH_FLAG_RDERR : FLASH Read Protection error flag (PCROP) (*) 287 | * @arg FLASH_FLAG_BSY : FLASH Busy flag 288 | * (*) FLASH_FLAG_RDERR is not available for STM32F405xx/407xx/415xx/417xx devices 289 | * @retval The new state of __FLAG__ (SET or RESET). 290 | */ 291 | #define __HAL_FLASH_GET_FLAG(__FLAG__) ((FLASH->SR & (__FLAG__))) 292 | 293 | /** 294 | * @brief Clear the specified FLASH flags. 295 | * @param __FLAG__ specifies the FLASH flags to clear. 296 | * This parameter can be any combination of the following values: 297 | * @arg FLASH_FLAG_EOP : FLASH End of Operation flag 298 | * @arg FLASH_FLAG_OPERR : FLASH operation Error flag 299 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag 300 | * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag 301 | * @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag 302 | * @arg FLASH_FLAG_PGSERR: FLASH Programming Sequence error flag 303 | * @arg FLASH_FLAG_RDERR : FLASH Read Protection error flag (PCROP) (*) 304 | * (*) FLASH_FLAG_RDERR is not available for STM32F405xx/407xx/415xx/417xx devices 305 | * @retval none 306 | */ 307 | #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) (FLASH->SR = (__FLAG__)) 308 | /** 309 | * @} 310 | */ 311 | 312 | /* Include FLASH HAL Extension module */ 313 | #include "stm32f4xx_hal_flash_ex.h" 314 | #include "stm32f4xx_hal_flash_ramfunc.h" 315 | 316 | /* Exported functions --------------------------------------------------------*/ 317 | /** @addtogroup FLASH_Exported_Functions 318 | * @{ 319 | */ 320 | /** @addtogroup FLASH_Exported_Functions_Group1 321 | * @{ 322 | */ 323 | /* Program operation functions ***********************************************/ 324 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 325 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 326 | /* FLASH IRQ handler method */ 327 | void HAL_FLASH_IRQHandler(void); 328 | /* Callbacks in non blocking modes */ 329 | void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); 330 | void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); 331 | /** 332 | * @} 333 | */ 334 | 335 | /** @addtogroup FLASH_Exported_Functions_Group2 336 | * @{ 337 | */ 338 | /* Peripheral Control functions **********************************************/ 339 | HAL_StatusTypeDef HAL_FLASH_Unlock(void); 340 | HAL_StatusTypeDef HAL_FLASH_Lock(void); 341 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void); 342 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void); 343 | /* Option bytes control */ 344 | HAL_StatusTypeDef HAL_FLASH_OB_Launch(void); 345 | /** 346 | * @} 347 | */ 348 | 349 | /** @addtogroup FLASH_Exported_Functions_Group3 350 | * @{ 351 | */ 352 | /* Peripheral State functions ************************************************/ 353 | uint32_t HAL_FLASH_GetError(void); 354 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); 355 | /** 356 | * @} 357 | */ 358 | 359 | /** 360 | * @} 361 | */ 362 | /* Private types -------------------------------------------------------------*/ 363 | /* Private variables ---------------------------------------------------------*/ 364 | /** @defgroup FLASH_Private_Variables FLASH Private Variables 365 | * @{ 366 | */ 367 | 368 | /** 369 | * @} 370 | */ 371 | /* Private constants ---------------------------------------------------------*/ 372 | /** @defgroup FLASH_Private_Constants FLASH Private Constants 373 | * @{ 374 | */ 375 | 376 | /** 377 | * @brief ACR register byte 0 (Bits[7:0]) base address 378 | */ 379 | #define ACR_BYTE0_ADDRESS 0x40023C00U 380 | /** 381 | * @brief OPTCR register byte 0 (Bits[7:0]) base address 382 | */ 383 | #define OPTCR_BYTE0_ADDRESS 0x40023C14U 384 | /** 385 | * @brief OPTCR register byte 1 (Bits[15:8]) base address 386 | */ 387 | #define OPTCR_BYTE1_ADDRESS 0x40023C15U 388 | /** 389 | * @brief OPTCR register byte 2 (Bits[23:16]) base address 390 | */ 391 | #define OPTCR_BYTE2_ADDRESS 0x40023C16U 392 | /** 393 | * @brief OPTCR register byte 3 (Bits[31:24]) base address 394 | */ 395 | #define OPTCR_BYTE3_ADDRESS 0x40023C17U 396 | 397 | /** 398 | * @} 399 | */ 400 | 401 | /* Private macros ------------------------------------------------------------*/ 402 | /** @defgroup FLASH_Private_Macros FLASH Private Macros 403 | * @{ 404 | */ 405 | 406 | /** @defgroup FLASH_IS_FLASH_Definitions FLASH Private macros to check input parameters 407 | * @{ 408 | */ 409 | #define IS_FLASH_TYPEPROGRAM(VALUE)(((VALUE) == FLASH_TYPEPROGRAM_BYTE) || \ 410 | ((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \ 411 | ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \ 412 | ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD)) 413 | /** 414 | * @} 415 | */ 416 | 417 | /** 418 | * @} 419 | */ 420 | 421 | /* Private functions ---------------------------------------------------------*/ 422 | /** @defgroup FLASH_Private_Functions FLASH Private Functions 423 | * @{ 424 | */ 425 | 426 | /** 427 | * @} 428 | */ 429 | 430 | /** 431 | * @} 432 | */ 433 | 434 | /** 435 | * @} 436 | */ 437 | 438 | #ifdef __cplusplus 439 | } 440 | #endif 441 | 442 | #endif /* __STM32F4xx_HAL_FLASH_H */ 443 | 444 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 445 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 38 | #define __STM32F4xx_FLASH_RAMFUNC_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 44 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f4xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F4xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup FLASH_RAMFUNC 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported macro ------------------------------------------------------------*/ 59 | /* Exported functions --------------------------------------------------------*/ 60 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 61 | * @{ 62 | */ 63 | 64 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 65 | * @{ 66 | */ 67 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void); 68 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void); 69 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void); 70 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void); 71 | /** 72 | * @} 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | 93 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 94 | 95 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 96 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_gpio.h 4 | * @author MCD Application Team 5 | * @brief Header file of GPIO HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_GPIO_H 38 | #define __STM32F4xx_HAL_GPIO_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f4xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F4xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup GPIO 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /** @defgroup GPIO_Exported_Types GPIO Exported Types 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @brief GPIO Init structure definition 62 | */ 63 | typedef struct 64 | { 65 | uint32_t Pin; /*!< Specifies the GPIO pins to be configured. 66 | This parameter can be any value of @ref GPIO_pins_define */ 67 | 68 | uint32_t Mode; /*!< Specifies the operating mode for the selected pins. 69 | This parameter can be a value of @ref GPIO_mode_define */ 70 | 71 | uint32_t Pull; /*!< Specifies the Pull-up or Pull-Down activation for the selected pins. 72 | This parameter can be a value of @ref GPIO_pull_define */ 73 | 74 | uint32_t Speed; /*!< Specifies the speed for the selected pins. 75 | This parameter can be a value of @ref GPIO_speed_define */ 76 | 77 | uint32_t Alternate; /*!< Peripheral to be connected to the selected pins. 78 | This parameter can be a value of @ref GPIO_Alternate_function_selection */ 79 | }GPIO_InitTypeDef; 80 | 81 | /** 82 | * @brief GPIO Bit SET and Bit RESET enumeration 83 | */ 84 | typedef enum 85 | { 86 | GPIO_PIN_RESET = 0, 87 | GPIO_PIN_SET 88 | }GPIO_PinState; 89 | /** 90 | * @} 91 | */ 92 | 93 | /* Exported constants --------------------------------------------------------*/ 94 | 95 | /** @defgroup GPIO_Exported_Constants GPIO Exported Constants 96 | * @{ 97 | */ 98 | 99 | /** @defgroup GPIO_pins_define GPIO pins define 100 | * @{ 101 | */ 102 | #define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */ 103 | #define GPIO_PIN_1 ((uint16_t)0x0002) /* Pin 1 selected */ 104 | #define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */ 105 | #define GPIO_PIN_3 ((uint16_t)0x0008) /* Pin 3 selected */ 106 | #define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */ 107 | #define GPIO_PIN_5 ((uint16_t)0x0020) /* Pin 5 selected */ 108 | #define GPIO_PIN_6 ((uint16_t)0x0040) /* Pin 6 selected */ 109 | #define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */ 110 | #define GPIO_PIN_8 ((uint16_t)0x0100) /* Pin 8 selected */ 111 | #define GPIO_PIN_9 ((uint16_t)0x0200) /* Pin 9 selected */ 112 | #define GPIO_PIN_10 ((uint16_t)0x0400) /* Pin 10 selected */ 113 | #define GPIO_PIN_11 ((uint16_t)0x0800) /* Pin 11 selected */ 114 | #define GPIO_PIN_12 ((uint16_t)0x1000) /* Pin 12 selected */ 115 | #define GPIO_PIN_13 ((uint16_t)0x2000) /* Pin 13 selected */ 116 | #define GPIO_PIN_14 ((uint16_t)0x4000) /* Pin 14 selected */ 117 | #define GPIO_PIN_15 ((uint16_t)0x8000) /* Pin 15 selected */ 118 | #define GPIO_PIN_All ((uint16_t)0xFFFF) /* All pins selected */ 119 | 120 | #define GPIO_PIN_MASK 0x0000FFFFU /* PIN mask for assert test */ 121 | /** 122 | * @} 123 | */ 124 | 125 | /** @defgroup GPIO_mode_define GPIO mode define 126 | * @brief GPIO Configuration Mode 127 | * Elements values convention: 0xX0yz00YZ 128 | * - X : GPIO mode or EXTI Mode 129 | * - y : External IT or Event trigger detection 130 | * - z : IO configuration on External IT or Event 131 | * - Y : Output type (Push Pull or Open Drain) 132 | * - Z : IO Direction mode (Input, Output, Alternate or Analog) 133 | * @{ 134 | */ 135 | #define GPIO_MODE_INPUT 0x00000000U /*!< Input Floating Mode */ 136 | #define GPIO_MODE_OUTPUT_PP 0x00000001U /*!< Output Push Pull Mode */ 137 | #define GPIO_MODE_OUTPUT_OD 0x00000011U /*!< Output Open Drain Mode */ 138 | #define GPIO_MODE_AF_PP 0x00000002U /*!< Alternate Function Push Pull Mode */ 139 | #define GPIO_MODE_AF_OD 0x00000012U /*!< Alternate Function Open Drain Mode */ 140 | 141 | #define GPIO_MODE_ANALOG 0x00000003U /*!< Analog Mode */ 142 | 143 | #define GPIO_MODE_IT_RISING 0x10110000U /*!< External Interrupt Mode with Rising edge trigger detection */ 144 | #define GPIO_MODE_IT_FALLING 0x10210000U /*!< External Interrupt Mode with Falling edge trigger detection */ 145 | #define GPIO_MODE_IT_RISING_FALLING 0x10310000U /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ 146 | 147 | #define GPIO_MODE_EVT_RISING 0x10120000U /*!< External Event Mode with Rising edge trigger detection */ 148 | #define GPIO_MODE_EVT_FALLING 0x10220000U /*!< External Event Mode with Falling edge trigger detection */ 149 | #define GPIO_MODE_EVT_RISING_FALLING 0x10320000U /*!< External Event Mode with Rising/Falling edge trigger detection */ 150 | /** 151 | * @} 152 | */ 153 | 154 | /** @defgroup GPIO_speed_define GPIO speed define 155 | * @brief GPIO Output Maximum frequency 156 | * @{ 157 | */ 158 | #define GPIO_SPEED_FREQ_LOW 0x00000000U /*!< IO works at 2 MHz, please refer to the product datasheet */ 159 | #define GPIO_SPEED_FREQ_MEDIUM 0x00000001U /*!< range 12,5 MHz to 50 MHz, please refer to the product datasheet */ 160 | #define GPIO_SPEED_FREQ_HIGH 0x00000002U /*!< range 25 MHz to 100 MHz, please refer to the product datasheet */ 161 | #define GPIO_SPEED_FREQ_VERY_HIGH 0x00000003U /*!< range 50 MHz to 200 MHz, please refer to the product datasheet */ 162 | /** 163 | * @} 164 | */ 165 | 166 | /** @defgroup GPIO_pull_define GPIO pull define 167 | * @brief GPIO Pull-Up or Pull-Down Activation 168 | * @{ 169 | */ 170 | #define GPIO_NOPULL 0x00000000U /*!< No Pull-up or Pull-down activation */ 171 | #define GPIO_PULLUP 0x00000001U /*!< Pull-up activation */ 172 | #define GPIO_PULLDOWN 0x00000002U /*!< Pull-down activation */ 173 | /** 174 | * @} 175 | */ 176 | 177 | /** 178 | * @} 179 | */ 180 | 181 | /* Exported macro ------------------------------------------------------------*/ 182 | /** @defgroup GPIO_Exported_Macros GPIO Exported Macros 183 | * @{ 184 | */ 185 | 186 | /** 187 | * @brief Checks whether the specified EXTI line flag is set or not. 188 | * @param __EXTI_LINE__ specifies the EXTI line flag to check. 189 | * This parameter can be GPIO_PIN_x where x can be(0..15) 190 | * @retval The new state of __EXTI_LINE__ (SET or RESET). 191 | */ 192 | #define __HAL_GPIO_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__)) 193 | 194 | /** 195 | * @brief Clears the EXTI's line pending flags. 196 | * @param __EXTI_LINE__ specifies the EXTI lines flags to clear. 197 | * This parameter can be any combination of GPIO_PIN_x where x can be (0..15) 198 | * @retval None 199 | */ 200 | #define __HAL_GPIO_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__)) 201 | 202 | /** 203 | * @brief Checks whether the specified EXTI line is asserted or not. 204 | * @param __EXTI_LINE__ specifies the EXTI line to check. 205 | * This parameter can be GPIO_PIN_x where x can be(0..15) 206 | * @retval The new state of __EXTI_LINE__ (SET or RESET). 207 | */ 208 | #define __HAL_GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__)) 209 | 210 | /** 211 | * @brief Clears the EXTI's line pending bits. 212 | * @param __EXTI_LINE__ specifies the EXTI lines to clear. 213 | * This parameter can be any combination of GPIO_PIN_x where x can be (0..15) 214 | * @retval None 215 | */ 216 | #define __HAL_GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__)) 217 | 218 | /** 219 | * @brief Generates a Software interrupt on selected EXTI line. 220 | * @param __EXTI_LINE__ specifies the EXTI line to check. 221 | * This parameter can be GPIO_PIN_x where x can be(0..15) 222 | * @retval None 223 | */ 224 | #define __HAL_GPIO_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER |= (__EXTI_LINE__)) 225 | /** 226 | * @} 227 | */ 228 | 229 | /* Include GPIO HAL Extension module */ 230 | #include "stm32f4xx_hal_gpio_ex.h" 231 | 232 | /* Exported functions --------------------------------------------------------*/ 233 | /** @addtogroup GPIO_Exported_Functions 234 | * @{ 235 | */ 236 | 237 | /** @addtogroup GPIO_Exported_Functions_Group1 238 | * @{ 239 | */ 240 | /* Initialization and de-initialization functions *****************************/ 241 | void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init); 242 | void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin); 243 | /** 244 | * @} 245 | */ 246 | 247 | /** @addtogroup GPIO_Exported_Functions_Group2 248 | * @{ 249 | */ 250 | /* IO operation functions *****************************************************/ 251 | GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 252 | void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState); 253 | void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 254 | HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 255 | void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin); 256 | void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); 257 | 258 | /** 259 | * @} 260 | */ 261 | 262 | /** 263 | * @} 264 | */ 265 | /* Private types -------------------------------------------------------------*/ 266 | /* Private variables ---------------------------------------------------------*/ 267 | /* Private constants ---------------------------------------------------------*/ 268 | /** @defgroup GPIO_Private_Constants GPIO Private Constants 269 | * @{ 270 | */ 271 | 272 | /** 273 | * @} 274 | */ 275 | 276 | /* Private macros ------------------------------------------------------------*/ 277 | /** @defgroup GPIO_Private_Macros GPIO Private Macros 278 | * @{ 279 | */ 280 | #define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET)) 281 | #define IS_GPIO_PIN(PIN) ((((PIN) & GPIO_PIN_MASK ) != 0x00U) && (((PIN) & ~GPIO_PIN_MASK) == 0x00U)) 282 | #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_MODE_INPUT) ||\ 283 | ((MODE) == GPIO_MODE_OUTPUT_PP) ||\ 284 | ((MODE) == GPIO_MODE_OUTPUT_OD) ||\ 285 | ((MODE) == GPIO_MODE_AF_PP) ||\ 286 | ((MODE) == GPIO_MODE_AF_OD) ||\ 287 | ((MODE) == GPIO_MODE_IT_RISING) ||\ 288 | ((MODE) == GPIO_MODE_IT_FALLING) ||\ 289 | ((MODE) == GPIO_MODE_IT_RISING_FALLING) ||\ 290 | ((MODE) == GPIO_MODE_EVT_RISING) ||\ 291 | ((MODE) == GPIO_MODE_EVT_FALLING) ||\ 292 | ((MODE) == GPIO_MODE_EVT_RISING_FALLING) ||\ 293 | ((MODE) == GPIO_MODE_ANALOG)) 294 | #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_SPEED_FREQ_LOW) || ((SPEED) == GPIO_SPEED_FREQ_MEDIUM) || \ 295 | ((SPEED) == GPIO_SPEED_FREQ_HIGH) || ((SPEED) == GPIO_SPEED_FREQ_VERY_HIGH)) 296 | #define IS_GPIO_PULL(PULL) (((PULL) == GPIO_NOPULL) || ((PULL) == GPIO_PULLUP) || \ 297 | ((PULL) == GPIO_PULLDOWN)) 298 | /** 299 | * @} 300 | */ 301 | 302 | /* Private functions ---------------------------------------------------------*/ 303 | /** @defgroup GPIO_Private_Functions GPIO Private Functions 304 | * @{ 305 | */ 306 | 307 | /** 308 | * @} 309 | */ 310 | 311 | /** 312 | * @} 313 | */ 314 | 315 | /** 316 | * @} 317 | */ 318 | 319 | #ifdef __cplusplus 320 | } 321 | #endif 322 | 323 | #endif /* __STM32F4xx_HAL_GPIO_H */ 324 | 325 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 326 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_i2c_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of I2C HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_I2C_EX_H 38 | #define __STM32F4xx_HAL_I2C_EX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 45 | defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) ||\ 46 | defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || defined(STM32F423xx) 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "stm32f4xx_hal_def.h" 49 | 50 | /** @addtogroup STM32F4xx_HAL_Driver 51 | * @{ 52 | */ 53 | 54 | /** @addtogroup I2CEx 55 | * @{ 56 | */ 57 | 58 | /* Exported types ------------------------------------------------------------*/ 59 | /* Exported constants --------------------------------------------------------*/ 60 | /** @defgroup I2CEx_Exported_Constants I2C Exported Constants 61 | * @{ 62 | */ 63 | 64 | /** @defgroup I2CEx_Analog_Filter I2C Analog Filter 65 | * @{ 66 | */ 67 | #define I2C_ANALOGFILTER_ENABLE 0x00000000U 68 | #define I2C_ANALOGFILTER_DISABLE I2C_FLTR_ANOFF 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /* Exported macro ------------------------------------------------------------*/ 78 | /* Exported functions --------------------------------------------------------*/ 79 | /** @addtogroup I2CEx_Exported_Functions 80 | * @{ 81 | */ 82 | 83 | /** @addtogroup I2CEx_Exported_Functions_Group1 84 | * @{ 85 | */ 86 | /* Peripheral Control functions ************************************************/ 87 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter); 88 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter); 89 | /** 90 | * @} 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | /* Private types -------------------------------------------------------------*/ 97 | /* Private variables ---------------------------------------------------------*/ 98 | /* Private constants ---------------------------------------------------------*/ 99 | /** @defgroup I2CEx_Private_Constants I2C Private Constants 100 | * @{ 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /* Private macros ------------------------------------------------------------*/ 108 | /** @defgroup I2CEx_Private_Macros I2C Private Macros 109 | * @{ 110 | */ 111 | #define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \ 112 | ((FILTER) == I2C_ANALOGFILTER_DISABLE)) 113 | #define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU) 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | #endif /* STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F401xC ||\ 127 | STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx ||\ 128 | STM32F413xx || STM32F423xx */ 129 | 130 | #ifdef __cplusplus 131 | } 132 | #endif 133 | 134 | #endif /* __STM32F4xx_HAL_I2C_EX_H */ 135 | 136 | 137 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 138 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_pwr.h 4 | * @author MCD Application Team 5 | * @brief Header file of PWR HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_PWR_H 38 | #define __STM32F4xx_HAL_PWR_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f4xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F4xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup PWR 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | 57 | /** @defgroup PWR_Exported_Types PWR Exported Types 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @brief PWR PVD configuration structure definition 63 | */ 64 | typedef struct 65 | { 66 | uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level. 67 | This parameter can be a value of @ref PWR_PVD_detection_level */ 68 | 69 | uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins. 70 | This parameter can be a value of @ref PWR_PVD_Mode */ 71 | }PWR_PVDTypeDef; 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /* Exported constants --------------------------------------------------------*/ 78 | /** @defgroup PWR_Exported_Constants PWR Exported Constants 79 | * @{ 80 | */ 81 | 82 | /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins 83 | * @{ 84 | */ 85 | #define PWR_WAKEUP_PIN1 0x00000100U 86 | /** 87 | * @} 88 | */ 89 | 90 | /** @defgroup PWR_PVD_detection_level PWR PVD detection level 91 | * @{ 92 | */ 93 | #define PWR_PVDLEVEL_0 PWR_CR_PLS_LEV0 94 | #define PWR_PVDLEVEL_1 PWR_CR_PLS_LEV1 95 | #define PWR_PVDLEVEL_2 PWR_CR_PLS_LEV2 96 | #define PWR_PVDLEVEL_3 PWR_CR_PLS_LEV3 97 | #define PWR_PVDLEVEL_4 PWR_CR_PLS_LEV4 98 | #define PWR_PVDLEVEL_5 PWR_CR_PLS_LEV5 99 | #define PWR_PVDLEVEL_6 PWR_CR_PLS_LEV6 100 | #define PWR_PVDLEVEL_7 PWR_CR_PLS_LEV7/* External input analog voltage 101 | (Compare internally to VREFINT) */ 102 | /** 103 | * @} 104 | */ 105 | 106 | /** @defgroup PWR_PVD_Mode PWR PVD Mode 107 | * @{ 108 | */ 109 | #define PWR_PVD_MODE_NORMAL 0x00000000U /*!< basic mode is used */ 110 | #define PWR_PVD_MODE_IT_RISING 0x00010001U /*!< External Interrupt Mode with Rising edge trigger detection */ 111 | #define PWR_PVD_MODE_IT_FALLING 0x00010002U /*!< External Interrupt Mode with Falling edge trigger detection */ 112 | #define PWR_PVD_MODE_IT_RISING_FALLING 0x00010003U /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ 113 | #define PWR_PVD_MODE_EVENT_RISING 0x00020001U /*!< Event Mode with Rising edge trigger detection */ 114 | #define PWR_PVD_MODE_EVENT_FALLING 0x00020002U /*!< Event Mode with Falling edge trigger detection */ 115 | #define PWR_PVD_MODE_EVENT_RISING_FALLING 0x00020003U /*!< Event Mode with Rising/Falling edge trigger detection */ 116 | /** 117 | * @} 118 | */ 119 | 120 | 121 | /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in SLEEP/STOP mode 122 | * @{ 123 | */ 124 | #define PWR_MAINREGULATOR_ON 0x00000000U 125 | #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS 126 | /** 127 | * @} 128 | */ 129 | 130 | /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry 131 | * @{ 132 | */ 133 | #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01) 134 | #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02) 135 | /** 136 | * @} 137 | */ 138 | 139 | /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry 140 | * @{ 141 | */ 142 | #define PWR_STOPENTRY_WFI ((uint8_t)0x01) 143 | #define PWR_STOPENTRY_WFE ((uint8_t)0x02) 144 | /** 145 | * @} 146 | */ 147 | 148 | /** @defgroup PWR_Flag PWR Flag 149 | * @{ 150 | */ 151 | #define PWR_FLAG_WU PWR_CSR_WUF 152 | #define PWR_FLAG_SB PWR_CSR_SBF 153 | #define PWR_FLAG_PVDO PWR_CSR_PVDO 154 | #define PWR_FLAG_BRR PWR_CSR_BRR 155 | #define PWR_FLAG_VOSRDY PWR_CSR_VOSRDY 156 | /** 157 | * @} 158 | */ 159 | 160 | /** 161 | * @} 162 | */ 163 | 164 | /* Exported macro ------------------------------------------------------------*/ 165 | /** @defgroup PWR_Exported_Macro PWR Exported Macro 166 | * @{ 167 | */ 168 | 169 | /** @brief Check PWR flag is set or not. 170 | * @param __FLAG__ specifies the flag to check. 171 | * This parameter can be one of the following values: 172 | * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event 173 | * was received from the WKUP pin or from the RTC alarm (Alarm A 174 | * or Alarm B), RTC Tamper event, RTC TimeStamp event or RTC Wakeup. 175 | * An additional wakeup event is detected if the WKUP pin is enabled 176 | * (by setting the EWUP bit) when the WKUP pin level is already high. 177 | * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was 178 | * resumed from StandBy mode. 179 | * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled 180 | * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode 181 | * For this reason, this bit is equal to 0 after Standby or reset 182 | * until the PVDE bit is set. 183 | * @arg PWR_FLAG_BRR: Backup regulator ready flag. This bit is not reset 184 | * when the device wakes up from Standby mode or by a system reset 185 | * or power reset. 186 | * @arg PWR_FLAG_VOSRDY: This flag indicates that the Regulator voltage 187 | * scaling output selection is ready. 188 | * @retval The new state of __FLAG__ (TRUE or FALSE). 189 | */ 190 | #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__)) 191 | 192 | /** @brief Clear the PWR's pending flags. 193 | * @param __FLAG__ specifies the flag to clear. 194 | * This parameter can be one of the following values: 195 | * @arg PWR_FLAG_WU: Wake Up flag 196 | * @arg PWR_FLAG_SB: StandBy flag 197 | */ 198 | #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2U) 199 | 200 | /** 201 | * @brief Enable the PVD Exti Line 16. 202 | * @retval None. 203 | */ 204 | #define __HAL_PWR_PVD_EXTI_ENABLE_IT() (EXTI->IMR |= (PWR_EXTI_LINE_PVD)) 205 | 206 | /** 207 | * @brief Disable the PVD EXTI Line 16. 208 | * @retval None. 209 | */ 210 | #define __HAL_PWR_PVD_EXTI_DISABLE_IT() (EXTI->IMR &= ~(PWR_EXTI_LINE_PVD)) 211 | 212 | /** 213 | * @brief Enable event on PVD Exti Line 16. 214 | * @retval None. 215 | */ 216 | #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() (EXTI->EMR |= (PWR_EXTI_LINE_PVD)) 217 | 218 | /** 219 | * @brief Disable event on PVD Exti Line 16. 220 | * @retval None. 221 | */ 222 | #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(PWR_EXTI_LINE_PVD)) 223 | 224 | /** 225 | * @brief Enable the PVD Extended Interrupt Rising Trigger. 226 | * @retval None. 227 | */ 228 | #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD) 229 | 230 | /** 231 | * @brief Disable the PVD Extended Interrupt Rising Trigger. 232 | * @retval None. 233 | */ 234 | #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD) 235 | 236 | /** 237 | * @brief Enable the PVD Extended Interrupt Falling Trigger. 238 | * @retval None. 239 | */ 240 | #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD) 241 | 242 | 243 | /** 244 | * @brief Disable the PVD Extended Interrupt Falling Trigger. 245 | * @retval None. 246 | */ 247 | #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD) 248 | 249 | 250 | /** 251 | * @brief PVD EXTI line configuration: set rising & falling edge trigger. 252 | * @retval None. 253 | */ 254 | #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() do{__HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();\ 255 | __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();\ 256 | }while(0U) 257 | 258 | /** 259 | * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger. 260 | * This parameter can be: 261 | * @retval None. 262 | */ 263 | #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() do{__HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();\ 264 | __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();\ 265 | }while(0U) 266 | 267 | /** 268 | * @brief checks whether the specified PVD Exti interrupt flag is set or not. 269 | * @retval EXTI PVD Line Status. 270 | */ 271 | #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD)) 272 | 273 | /** 274 | * @brief Clear the PVD Exti flag. 275 | * @retval None. 276 | */ 277 | #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD)) 278 | 279 | /** 280 | * @brief Generates a Software interrupt on PVD EXTI line. 281 | * @retval None 282 | */ 283 | #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() (EXTI->SWIER |= (PWR_EXTI_LINE_PVD)) 284 | 285 | /** 286 | * @} 287 | */ 288 | 289 | /* Include PWR HAL Extension module */ 290 | #include "stm32f4xx_hal_pwr_ex.h" 291 | 292 | /* Exported functions --------------------------------------------------------*/ 293 | /** @addtogroup PWR_Exported_Functions PWR Exported Functions 294 | * @{ 295 | */ 296 | 297 | /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions 298 | * @{ 299 | */ 300 | /* Initialization and de-initialization functions *****************************/ 301 | void HAL_PWR_DeInit(void); 302 | void HAL_PWR_EnableBkUpAccess(void); 303 | void HAL_PWR_DisableBkUpAccess(void); 304 | /** 305 | * @} 306 | */ 307 | 308 | /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions 309 | * @{ 310 | */ 311 | /* Peripheral Control functions **********************************************/ 312 | /* PVD configuration */ 313 | void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD); 314 | void HAL_PWR_EnablePVD(void); 315 | void HAL_PWR_DisablePVD(void); 316 | 317 | /* WakeUp pins configuration */ 318 | void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx); 319 | void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); 320 | 321 | /* Low Power modes entry */ 322 | void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry); 323 | void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); 324 | void HAL_PWR_EnterSTANDBYMode(void); 325 | 326 | /* Power PVD IRQ Handler */ 327 | void HAL_PWR_PVD_IRQHandler(void); 328 | void HAL_PWR_PVDCallback(void); 329 | 330 | /* Cortex System Control functions *******************************************/ 331 | void HAL_PWR_EnableSleepOnExit(void); 332 | void HAL_PWR_DisableSleepOnExit(void); 333 | void HAL_PWR_EnableSEVOnPend(void); 334 | void HAL_PWR_DisableSEVOnPend(void); 335 | /** 336 | * @} 337 | */ 338 | 339 | /** 340 | * @} 341 | */ 342 | 343 | /* Private types -------------------------------------------------------------*/ 344 | /* Private variables ---------------------------------------------------------*/ 345 | /* Private constants ---------------------------------------------------------*/ 346 | /** @defgroup PWR_Private_Constants PWR Private Constants 347 | * @{ 348 | */ 349 | 350 | /** @defgroup PWR_PVD_EXTI_Line PWR PVD EXTI Line 351 | * @{ 352 | */ 353 | #define PWR_EXTI_LINE_PVD ((uint32_t)EXTI_IMR_MR16) /*!< External interrupt line 16 Connected to the PVD EXTI Line */ 354 | /** 355 | * @} 356 | */ 357 | 358 | /** @defgroup PWR_register_alias_address PWR Register alias address 359 | * @{ 360 | */ 361 | /* ------------- PWR registers bit address in the alias region ---------------*/ 362 | #define PWR_OFFSET (PWR_BASE - PERIPH_BASE) 363 | #define PWR_CR_OFFSET 0x00U 364 | #define PWR_CSR_OFFSET 0x04U 365 | #define PWR_CR_OFFSET_BB (PWR_OFFSET + PWR_CR_OFFSET) 366 | #define PWR_CSR_OFFSET_BB (PWR_OFFSET + PWR_CSR_OFFSET) 367 | /** 368 | * @} 369 | */ 370 | 371 | /** @defgroup PWR_CR_register_alias PWR CR Register alias address 372 | * @{ 373 | */ 374 | /* --- CR Register ---*/ 375 | /* Alias word address of DBP bit */ 376 | #define DBP_BIT_NUMBER PWR_CR_DBP_Pos 377 | #define CR_DBP_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (DBP_BIT_NUMBER * 4U)) 378 | 379 | /* Alias word address of PVDE bit */ 380 | #define PVDE_BIT_NUMBER PWR_CR_PVDE_Pos 381 | #define CR_PVDE_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (PVDE_BIT_NUMBER * 4U)) 382 | 383 | /* Alias word address of VOS bit */ 384 | #define VOS_BIT_NUMBER PWR_CR_VOS_Pos 385 | #define CR_VOS_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (VOS_BIT_NUMBER * 4U)) 386 | /** 387 | * @} 388 | */ 389 | 390 | /** @defgroup PWR_CSR_register_alias PWR CSR Register alias address 391 | * @{ 392 | */ 393 | /* --- CSR Register ---*/ 394 | /* Alias word address of EWUP bit */ 395 | #define EWUP_BIT_NUMBER PWR_CSR_EWUP_Pos 396 | #define CSR_EWUP_BB (PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32U) + (EWUP_BIT_NUMBER * 4U)) 397 | /** 398 | * @} 399 | */ 400 | 401 | /** 402 | * @} 403 | */ 404 | /* Private macros ------------------------------------------------------------*/ 405 | /** @defgroup PWR_Private_Macros PWR Private Macros 406 | * @{ 407 | */ 408 | 409 | /** @defgroup PWR_IS_PWR_Definitions PWR Private macros to check input parameters 410 | * @{ 411 | */ 412 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \ 413 | ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \ 414 | ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \ 415 | ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7)) 416 | #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \ 417 | ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \ 418 | ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \ 419 | ((MODE) == PWR_PVD_MODE_NORMAL)) 420 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ 421 | ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) 422 | #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE)) 423 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE)) 424 | /** 425 | * @} 426 | */ 427 | 428 | /** 429 | * @} 430 | */ 431 | 432 | /** 433 | * @} 434 | */ 435 | 436 | /** 437 | * @} 438 | */ 439 | 440 | #ifdef __cplusplus 441 | } 442 | #endif 443 | 444 | 445 | #endif /* __STM32F4xx_HAL_PWR_H */ 446 | 447 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 448 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_tim_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of TIM HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_TIM_EX_H 38 | #define __STM32F4xx_HAL_TIM_EX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f4xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F4xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup TIMEx 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /** @defgroup TIMEx_Exported_Types TIM Exported Types 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @brief TIM Hall sensor Configuration Structure definition 62 | */ 63 | 64 | typedef struct 65 | { 66 | 67 | uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal. 68 | This parameter can be a value of @ref TIM_Input_Capture_Polarity */ 69 | 70 | uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler. 71 | This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ 72 | 73 | uint32_t IC1Filter; /*!< Specifies the input capture filter. 74 | This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ 75 | 76 | uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. 77 | This parameter can be a number between Min_Data = 0x0000U and Max_Data = 0xFFFFU */ 78 | } TIM_HallSensor_InitTypeDef; 79 | 80 | /** 81 | * @brief TIM Master configuration Structure definition 82 | */ 83 | typedef struct { 84 | uint32_t MasterOutputTrigger; /*!< Trigger output (TRGO) selection. 85 | This parameter can be a value of @ref TIM_Master_Mode_Selection */ 86 | 87 | uint32_t MasterSlaveMode; /*!< Master/slave mode selection. 88 | This parameter can be a value of @ref TIM_Master_Slave_Mode */ 89 | }TIM_MasterConfigTypeDef; 90 | 91 | /** 92 | * @brief TIM Break and Dead time configuration Structure definition 93 | */ 94 | typedef struct 95 | { 96 | uint32_t OffStateRunMode; /*!< TIM off state in run mode. 97 | This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */ 98 | uint32_t OffStateIDLEMode; /*!< TIM off state in IDLE mode. 99 | This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */ 100 | uint32_t LockLevel; /*!< TIM Lock level. 101 | This parameter can be a value of @ref TIM_Lock_level */ 102 | uint32_t DeadTime; /*!< TIM dead Time. 103 | This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */ 104 | uint32_t BreakState; /*!< TIM Break State. 105 | This parameter can be a value of @ref TIM_Break_Input_enable_disable */ 106 | uint32_t BreakPolarity; /*!< TIM Break input polarity. 107 | This parameter can be a value of @ref TIM_Break_Polarity */ 108 | uint32_t AutomaticOutput; /*!< TIM Automatic Output Enable state. 109 | This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */ 110 | }TIM_BreakDeadTimeConfigTypeDef; 111 | /** 112 | * @} 113 | */ 114 | 115 | /* Exported constants --------------------------------------------------------*/ 116 | /** @defgroup TIMEx_Exported_Constants TIM Exported Constants 117 | * @{ 118 | */ 119 | 120 | /** @defgroup TIMEx_Remap TIM Remap 121 | * @{ 122 | */ 123 | #define TIM_TIM2_TIM8_TRGO 0x00000000U 124 | #define TIM_TIM2_ETH_PTP 0x00000400U 125 | #define TIM_TIM2_USBFS_SOF 0x00000800U 126 | #define TIM_TIM2_USBHS_SOF 0x00000C00U 127 | #define TIM_TIM5_GPIO 0x00000000U 128 | #define TIM_TIM5_LSI 0x00000040U 129 | #define TIM_TIM5_LSE 0x00000080U 130 | #define TIM_TIM5_RTC 0x000000C0U 131 | #define TIM_TIM11_GPIO 0x00000000U 132 | #define TIM_TIM11_HSE 0x00000002U 133 | 134 | #if defined(STM32F413xx) || defined(STM32F423xx) 135 | #define TIM_TIM9_TIM3_TRGO 0x10000000U 136 | #define TIM_TIM9_LPTIM 0x10000010U 137 | #define TIM_TIM5_TIM3_TRGO 0x10000000U 138 | #define TIM_TIM5_LPTIM 0x10000008U 139 | #define TIM_TIM1_TIM3_TRGO 0x10000000U 140 | #define TIM_TIM1_LPTIM 0x10000004U 141 | #endif /* STM32F413xx | STM32F423xx */ 142 | 143 | #if defined (STM32F446xx) 144 | #define TIM_TIM11_SPDIFRX 0x00000001U 145 | #endif /* STM32F446xx */ 146 | /** 147 | * @} 148 | */ 149 | 150 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F413xx) || defined(STM32F423xx) 151 | /** @defgroup TIMEx_SystemBreakInput TIM System Break Input 152 | * @{ 153 | */ 154 | #define TIM_SYSTEMBREAKINPUT_HARDFAULT 0x00000001U /* Core Lockup lock output(Hardfault) is connected to Break Input of TIM1 and TIM8 */ 155 | #define TIM_SYSTEMBREAKINPUT_PVD 0x00000004U /* PVD Interrupt is connected to Break Input of TIM1 and TIM8 */ 156 | #define TIM_SYSTEMBREAKINPUT_HARDFAULT_PVD 0x00000005U /* Core Lockup lock output(Hardfault) and PVD Interrupt are connected to Break Input of TIM1 and TIM8 */ 157 | /** 158 | * @} 159 | */ 160 | #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx || STM32F413xx || STM32F423xx */ 161 | 162 | /** 163 | * @} 164 | */ 165 | /* Exported macro ------------------------------------------------------------*/ 166 | /* Exported functions --------------------------------------------------------*/ 167 | /** @addtogroup TIMEx_Exported_Functions 168 | * @{ 169 | */ 170 | 171 | /** @addtogroup TIMEx_Exported_Functions_Group1 172 | * @{ 173 | */ 174 | /* Timer Hall Sensor functions **********************************************/ 175 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef* htim, TIM_HallSensor_InitTypeDef* sConfig); 176 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef* htim); 177 | 178 | void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef* htim); 179 | void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef* htim); 180 | 181 | /* Blocking mode: Polling */ 182 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef* htim); 183 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef* htim); 184 | /* Non-Blocking mode: Interrupt */ 185 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef* htim); 186 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef* htim); 187 | /* Non-Blocking mode: DMA */ 188 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef* htim, uint32_t *pData, uint16_t Length); 189 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef* htim); 190 | /** 191 | * @} 192 | */ 193 | 194 | /** @addtogroup TIMEx_Exported_Functions_Group2 195 | * @{ 196 | */ 197 | /* Timer Complementary Output Compare functions *****************************/ 198 | /* Blocking mode: Polling */ 199 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef* htim, uint32_t Channel); 200 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef* htim, uint32_t Channel); 201 | 202 | /* Non-Blocking mode: Interrupt */ 203 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef* htim, uint32_t Channel); 204 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t Channel); 205 | 206 | /* Non-Blocking mode: DMA */ 207 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef* htim, uint32_t Channel, uint32_t *pData, uint16_t Length); 208 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef* htim, uint32_t Channel); 209 | /** 210 | * @} 211 | */ 212 | 213 | /** @addtogroup TIMEx_Exported_Functions_Group3 214 | * @{ 215 | */ 216 | /* Timer Complementary PWM functions ****************************************/ 217 | /* Blocking mode: Polling */ 218 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef* htim, uint32_t Channel); 219 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef* htim, uint32_t Channel); 220 | 221 | /* Non-Blocking mode: Interrupt */ 222 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef* htim, uint32_t Channel); 223 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t Channel); 224 | /* Non-Blocking mode: DMA */ 225 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef* htim, uint32_t Channel, uint32_t *pData, uint16_t Length); 226 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef* htim, uint32_t Channel); 227 | /** 228 | * @} 229 | */ 230 | 231 | /** @addtogroup TIMEx_Exported_Functions_Group4 232 | * @{ 233 | */ 234 | /* Timer Complementary One Pulse functions **********************************/ 235 | /* Blocking mode: Polling */ 236 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef* htim, uint32_t OutputChannel); 237 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef* htim, uint32_t OutputChannel); 238 | 239 | /* Non-Blocking mode: Interrupt */ 240 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef* htim, uint32_t OutputChannel); 241 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t OutputChannel); 242 | /** 243 | * @} 244 | */ 245 | 246 | /** @addtogroup TIMEx_Exported_Functions_Group5 247 | * @{ 248 | */ 249 | /* Extension Control functions ************************************************/ 250 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef* htim, uint32_t InputTrigger, uint32_t CommutationSource); 251 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef* htim, uint32_t InputTrigger, uint32_t CommutationSource); 252 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef* htim, uint32_t InputTrigger, uint32_t CommutationSource); 253 | HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef* htim, TIM_MasterConfigTypeDef * sMasterConfig); 254 | HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef* htim, TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig); 255 | HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef* htim, uint32_t Remap); 256 | /** 257 | * @} 258 | */ 259 | 260 | /** @addtogroup TIMEx_Exported_Functions_Group6 261 | * @{ 262 | */ 263 | /* Extension Callback *********************************************************/ 264 | void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef* htim); 265 | void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef* htim); 266 | void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma); 267 | /** 268 | * @} 269 | */ 270 | 271 | /** @addtogroup TIMEx_Exported_Functions_Group7 272 | * @{ 273 | */ 274 | /* Extension Peripheral State functions **************************************/ 275 | HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef* htim); 276 | /** 277 | * @} 278 | */ 279 | 280 | /** 281 | * @} 282 | */ 283 | 284 | /* Private types -------------------------------------------------------------*/ 285 | /* Private variables ---------------------------------------------------------*/ 286 | /* Private constants ---------------------------------------------------------*/ 287 | /* Private macros ------------------------------------------------------------*/ 288 | /** @defgroup TIMEx_Private_Macros TIM Private Macros 289 | * @{ 290 | */ 291 | #if defined (STM32F446xx) 292 | #define IS_TIM_REMAP(TIM_REMAP) (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)||\ 293 | ((TIM_REMAP) == TIM_TIM2_ETH_PTP)||\ 294 | ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)||\ 295 | ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)||\ 296 | ((TIM_REMAP) == TIM_TIM5_GPIO)||\ 297 | ((TIM_REMAP) == TIM_TIM5_LSI)||\ 298 | ((TIM_REMAP) == TIM_TIM5_LSE)||\ 299 | ((TIM_REMAP) == TIM_TIM5_RTC)||\ 300 | ((TIM_REMAP) == TIM_TIM11_GPIO)||\ 301 | ((TIM_REMAP) == TIM_TIM11_SPDIFRX)||\ 302 | ((TIM_REMAP) == TIM_TIM11_HSE)) 303 | #elif defined(STM32F413xx) || defined(STM32F423xx) 304 | #define IS_TIM_REMAP(TIM_REMAP) (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)||\ 305 | ((TIM_REMAP) == TIM_TIM2_ETH_PTP)||\ 306 | ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)||\ 307 | ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)||\ 308 | ((TIM_REMAP) == TIM_TIM5_GPIO)||\ 309 | ((TIM_REMAP) == TIM_TIM5_LSI)||\ 310 | ((TIM_REMAP) == TIM_TIM5_LSE)||\ 311 | ((TIM_REMAP) == TIM_TIM5_RTC)||\ 312 | ((TIM_REMAP) == TIM_TIM11_GPIO)||\ 313 | ((TIM_REMAP) == TIM_TIM11_HSE)||\ 314 | ((TIM_REMAP) == TIM_TIM9_TIM3_TRGO)||\ 315 | ((TIM_REMAP) == TIM_TIM9_LPTIM)||\ 316 | ((TIM_REMAP) == TIM_TIM5_TIM3_TRGO)||\ 317 | ((TIM_REMAP) == TIM_TIM5_LPTIM)||\ 318 | ((TIM_REMAP) == TIM_TIM1_TIM3_TRGO)||\ 319 | ((TIM_REMAP) == TIM_TIM1_LPTIM)) 320 | #else 321 | #define IS_TIM_REMAP(TIM_REMAP) (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)||\ 322 | ((TIM_REMAP) == TIM_TIM2_ETH_PTP)||\ 323 | ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)||\ 324 | ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)||\ 325 | ((TIM_REMAP) == TIM_TIM5_GPIO)||\ 326 | ((TIM_REMAP) == TIM_TIM5_LSI)||\ 327 | ((TIM_REMAP) == TIM_TIM5_LSE)||\ 328 | ((TIM_REMAP) == TIM_TIM5_RTC)||\ 329 | ((TIM_REMAP) == TIM_TIM11_GPIO)||\ 330 | ((TIM_REMAP) == TIM_TIM11_HSE)) 331 | #endif /* STM32F446xx */ 332 | 333 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F413xx) || defined(STM32F423xx) 334 | #define IS_TIM_SYSTEMBREAKINPUT(BREAKINPUT) (((BREAKINPUT) == TIM_SYSTEMBREAKINPUT_HARDFAULT)||\ 335 | ((BREAKINPUT) == TIM_SYSTEMBREAKINPUT_PVD)||\ 336 | ((BREAKINPUT) == TIM_SYSTEMBREAKINPUT_HARDFAULT_PVD)) 337 | 338 | #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx || STM32F413xx || STM32F423xx */ 339 | 340 | #define IS_TIM_DEADTIME(DEADTIME) ((DEADTIME) <= 0xFFU) 341 | /** 342 | * @} 343 | */ 344 | 345 | /* Private functions ---------------------------------------------------------*/ 346 | /** @defgroup TIMEx_Private_Functions TIM Private Functions 347 | * @{ 348 | */ 349 | 350 | /** 351 | * @} 352 | */ 353 | 354 | /** 355 | * @} 356 | */ 357 | 358 | /** 359 | * @} 360 | */ 361 | 362 | #ifdef __cplusplus 363 | } 364 | #endif 365 | 366 | #endif /* __STM32F4xx_HAL_TIM_EX_H */ 367 | 368 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 369 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.c 4 | * @author MCD Application Team 5 | * @brief DMA Extension HAL module driver 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the DMA Extension peripheral: 8 | * + Extended features functions 9 | * 10 | @verbatim 11 | ============================================================================== 12 | ##### How to use this driver ##### 13 | ============================================================================== 14 | [..] 15 | The DMA Extension HAL driver can be used as follows: 16 | (#) Start a multi buffer transfer using the HAL_DMA_MultiBufferStart() function 17 | for polling mode or HAL_DMA_MultiBufferStart_IT() for interrupt mode. 18 | 19 | -@- In Memory-to-Memory transfer mode, Multi (Double) Buffer mode is not allowed. 20 | -@- When Multi (Double) Buffer mode is enabled the, transfer is circular by default. 21 | -@- In Multi (Double) buffer mode, it is possible to update the base address for 22 | the AHB memory port on the fly (DMA_SxM0AR or DMA_SxM1AR) when the stream is enabled. 23 | 24 | @endverbatim 25 | ****************************************************************************** 26 | * @attention 27 | * 28 | *

© COPYRIGHT(c) 2017 STMicroelectronics

29 | * 30 | * Redistribution and use in source and binary forms, with or without modification, 31 | * are permitted provided that the following conditions are met: 32 | * 1. Redistributions of source code must retain the above copyright notice, 33 | * this list of conditions and the following disclaimer. 34 | * 2. Redistributions in binary form must reproduce the above copyright notice, 35 | * this list of conditions and the following disclaimer in the documentation 36 | * and/or other materials provided with the distribution. 37 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 38 | * may be used to endorse or promote products derived from this software 39 | * without specific prior written permission. 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 42 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 44 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 47 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 48 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 49 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * 52 | ****************************************************************************** 53 | */ 54 | 55 | /* Includes ------------------------------------------------------------------*/ 56 | #include "stm32f4xx_hal.h" 57 | 58 | /** @addtogroup STM32F4xx_HAL_Driver 59 | * @{ 60 | */ 61 | 62 | /** @defgroup DMAEx DMAEx 63 | * @brief DMA Extended HAL module driver 64 | * @{ 65 | */ 66 | 67 | #ifdef HAL_DMA_MODULE_ENABLED 68 | 69 | /* Private types -------------------------------------------------------------*/ 70 | /* Private variables ---------------------------------------------------------*/ 71 | /* Private Constants ---------------------------------------------------------*/ 72 | /* Private macros ------------------------------------------------------------*/ 73 | /* Private functions ---------------------------------------------------------*/ 74 | /** @addtogroup DMAEx_Private_Functions 75 | * @{ 76 | */ 77 | static void DMA_MultiBufferSetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength); 78 | /** 79 | * @} 80 | */ 81 | 82 | /* Exported functions ---------------------------------------------------------*/ 83 | 84 | /** @addtogroup DMAEx_Exported_Functions 85 | * @{ 86 | */ 87 | 88 | 89 | /** @addtogroup DMAEx_Exported_Functions_Group1 90 | * 91 | @verbatim 92 | =============================================================================== 93 | ##### Extended features functions ##### 94 | =============================================================================== 95 | [..] This section provides functions allowing to: 96 | (+) Configure the source, destination address and data length and 97 | Start MultiBuffer DMA transfer 98 | (+) Configure the source, destination address and data length and 99 | Start MultiBuffer DMA transfer with interrupt 100 | (+) Change on the fly the memory0 or memory1 address. 101 | 102 | @endverbatim 103 | * @{ 104 | */ 105 | 106 | 107 | /** 108 | * @brief Starts the multi_buffer DMA Transfer. 109 | * @param hdma pointer to a DMA_HandleTypeDef structure that contains 110 | * the configuration information for the specified DMA Stream. 111 | * @param SrcAddress The source memory Buffer address 112 | * @param DstAddress The destination memory Buffer address 113 | * @param SecondMemAddress The second memory Buffer address in case of multi buffer Transfer 114 | * @param DataLength The length of data to be transferred from source to destination 115 | * @retval HAL status 116 | */ 117 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength) 118 | { 119 | HAL_StatusTypeDef status = HAL_OK; 120 | 121 | /* Check the parameters */ 122 | assert_param(IS_DMA_BUFFER_SIZE(DataLength)); 123 | 124 | /* Memory-to-memory transfer not supported in double buffering mode */ 125 | if (hdma->Init.Direction == DMA_MEMORY_TO_MEMORY) 126 | { 127 | hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED; 128 | status = HAL_ERROR; 129 | } 130 | else 131 | { 132 | /* Process Locked */ 133 | __HAL_LOCK(hdma); 134 | 135 | if(HAL_DMA_STATE_READY == hdma->State) 136 | { 137 | /* Change DMA peripheral state */ 138 | hdma->State = HAL_DMA_STATE_BUSY; 139 | 140 | /* Enable the double buffer mode */ 141 | hdma->Instance->CR |= (uint32_t)DMA_SxCR_DBM; 142 | 143 | /* Configure DMA Stream destination address */ 144 | hdma->Instance->M1AR = SecondMemAddress; 145 | 146 | /* Configure the source, destination address and the data length */ 147 | DMA_MultiBufferSetConfig(hdma, SrcAddress, DstAddress, DataLength); 148 | 149 | /* Enable the peripheral */ 150 | __HAL_DMA_ENABLE(hdma); 151 | } 152 | else 153 | { 154 | /* Return error status */ 155 | status = HAL_BUSY; 156 | } 157 | } 158 | return status; 159 | } 160 | 161 | /** 162 | * @brief Starts the multi_buffer DMA Transfer with interrupt enabled. 163 | * @param hdma pointer to a DMA_HandleTypeDef structure that contains 164 | * the configuration information for the specified DMA Stream. 165 | * @param SrcAddress The source memory Buffer address 166 | * @param DstAddress The destination memory Buffer address 167 | * @param SecondMemAddress The second memory Buffer address in case of multi buffer Transfer 168 | * @param DataLength The length of data to be transferred from source to destination 169 | * @retval HAL status 170 | */ 171 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength) 172 | { 173 | HAL_StatusTypeDef status = HAL_OK; 174 | 175 | /* Check the parameters */ 176 | assert_param(IS_DMA_BUFFER_SIZE(DataLength)); 177 | 178 | /* Memory-to-memory transfer not supported in double buffering mode */ 179 | if (hdma->Init.Direction == DMA_MEMORY_TO_MEMORY) 180 | { 181 | hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED; 182 | return HAL_ERROR; 183 | } 184 | 185 | /* Check callback functions */ 186 | if ((NULL == hdma->XferCpltCallback) || (NULL == hdma->XferM1CpltCallback) || (NULL == hdma->XferErrorCallback)) 187 | { 188 | hdma->ErrorCode = HAL_DMA_ERROR_PARAM; 189 | return HAL_ERROR; 190 | } 191 | 192 | /* Process locked */ 193 | __HAL_LOCK(hdma); 194 | 195 | if(HAL_DMA_STATE_READY == hdma->State) 196 | { 197 | /* Change DMA peripheral state */ 198 | hdma->State = HAL_DMA_STATE_BUSY; 199 | 200 | /* Initialize the error code */ 201 | hdma->ErrorCode = HAL_DMA_ERROR_NONE; 202 | 203 | /* Enable the Double buffer mode */ 204 | hdma->Instance->CR |= (uint32_t)DMA_SxCR_DBM; 205 | 206 | /* Configure DMA Stream destination address */ 207 | hdma->Instance->M1AR = SecondMemAddress; 208 | 209 | /* Configure the source, destination address and the data length */ 210 | DMA_MultiBufferSetConfig(hdma, SrcAddress, DstAddress, DataLength); 211 | 212 | /* Clear all flags */ 213 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); 214 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); 215 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)); 216 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)); 217 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)); 218 | 219 | /* Enable Common interrupts*/ 220 | hdma->Instance->CR |= DMA_IT_TC | DMA_IT_TE | DMA_IT_DME; 221 | hdma->Instance->FCR |= DMA_IT_FE; 222 | 223 | if((hdma->XferHalfCpltCallback != NULL) || (hdma->XferM1HalfCpltCallback != NULL)) 224 | { 225 | hdma->Instance->CR |= DMA_IT_HT; 226 | } 227 | 228 | /* Enable the peripheral */ 229 | __HAL_DMA_ENABLE(hdma); 230 | } 231 | else 232 | { 233 | /* Process unlocked */ 234 | __HAL_UNLOCK(hdma); 235 | 236 | /* Return error status */ 237 | status = HAL_BUSY; 238 | } 239 | return status; 240 | } 241 | 242 | /** 243 | * @brief Change the memory0 or memory1 address on the fly. 244 | * @param hdma pointer to a DMA_HandleTypeDef structure that contains 245 | * the configuration information for the specified DMA Stream. 246 | * @param Address The new address 247 | * @param memory the memory to be changed, This parameter can be one of 248 | * the following values: 249 | * MEMORY0 / 250 | * MEMORY1 251 | * @note The MEMORY0 address can be changed only when the current transfer use 252 | * MEMORY1 and the MEMORY1 address can be changed only when the current 253 | * transfer use MEMORY0. 254 | * @retval HAL status 255 | */ 256 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory) 257 | { 258 | if(memory == MEMORY0) 259 | { 260 | /* change the memory0 address */ 261 | hdma->Instance->M0AR = Address; 262 | } 263 | else 264 | { 265 | /* change the memory1 address */ 266 | hdma->Instance->M1AR = Address; 267 | } 268 | 269 | return HAL_OK; 270 | } 271 | 272 | /** 273 | * @} 274 | */ 275 | 276 | /** 277 | * @} 278 | */ 279 | 280 | /** @addtogroup DMAEx_Private_Functions 281 | * @{ 282 | */ 283 | 284 | /** 285 | * @brief Set the DMA Transfer parameter. 286 | * @param hdma pointer to a DMA_HandleTypeDef structure that contains 287 | * the configuration information for the specified DMA Stream. 288 | * @param SrcAddress The source memory Buffer address 289 | * @param DstAddress The destination memory Buffer address 290 | * @param DataLength The length of data to be transferred from source to destination 291 | * @retval HAL status 292 | */ 293 | static void DMA_MultiBufferSetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength) 294 | { 295 | /* Configure DMA Stream data length */ 296 | hdma->Instance->NDTR = DataLength; 297 | 298 | /* Peripheral to Memory */ 299 | if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH) 300 | { 301 | /* Configure DMA Stream destination address */ 302 | hdma->Instance->PAR = DstAddress; 303 | 304 | /* Configure DMA Stream source address */ 305 | hdma->Instance->M0AR = SrcAddress; 306 | } 307 | /* Memory to Peripheral */ 308 | else 309 | { 310 | /* Configure DMA Stream source address */ 311 | hdma->Instance->PAR = SrcAddress; 312 | 313 | /* Configure DMA Stream destination address */ 314 | hdma->Instance->M0AR = DstAddress; 315 | } 316 | } 317 | 318 | /** 319 | * @} 320 | */ 321 | 322 | #endif /* HAL_DMA_MODULE_ENABLED */ 323 | /** 324 | * @} 325 | */ 326 | 327 | /** 328 | * @} 329 | */ 330 | 331 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 332 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.c 4 | * @author MCD Application Team 5 | * @brief FLASH RAMFUNC module driver. 6 | * This file provides a FLASH firmware functions which should be 7 | * executed from internal SRAM 8 | * + Stop/Start the flash interface while System Run 9 | * + Enable/Disable the flash sleep while System Run 10 | @verbatim 11 | ============================================================================== 12 | ##### APIs executed from Internal RAM ##### 13 | ============================================================================== 14 | [..] 15 | *** ARM Compiler *** 16 | -------------------- 17 | [..] RAM functions are defined using the toolchain options. 18 | Functions that are be executed in RAM should reside in a separate 19 | source module. Using the 'Options for File' dialog you can simply change 20 | the 'Code / Const' area of a module to a memory space in physical RAM. 21 | Available memory areas are declared in the 'Target' tab of the 22 | Options for Target' dialog. 23 | 24 | *** ICCARM Compiler *** 25 | ----------------------- 26 | [..] RAM functions are defined using a specific toolchain keyword "__ramfunc". 27 | 28 | *** GNU Compiler *** 29 | -------------------- 30 | [..] RAM functions are defined using a specific toolchain attribute 31 | "__attribute__((section(".RamFunc")))". 32 | 33 | @endverbatim 34 | ****************************************************************************** 35 | * @attention 36 | * 37 | *

© COPYRIGHT(c) 2017 STMicroelectronics

38 | * 39 | * Redistribution and use in source and binary forms, with or without modification, 40 | * are permitted provided that the following conditions are met: 41 | * 1. Redistributions of source code must retain the above copyright notice, 42 | * this list of conditions and the following disclaimer. 43 | * 2. Redistributions in binary form must reproduce the above copyright notice, 44 | * this list of conditions and the following disclaimer in the documentation 45 | * and/or other materials provided with the distribution. 46 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 47 | * may be used to endorse or promote products derived from this software 48 | * without specific prior written permission. 49 | * 50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 51 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 53 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 56 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 57 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 58 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 59 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 | * 61 | ****************************************************************************** 62 | */ 63 | 64 | /* Includes ------------------------------------------------------------------*/ 65 | #include "stm32f4xx_hal.h" 66 | 67 | /** @addtogroup STM32F4xx_HAL_Driver 68 | * @{ 69 | */ 70 | 71 | /** @defgroup FLASH_RAMFUNC FLASH RAMFUNC 72 | * @brief FLASH functions executed from RAM 73 | * @{ 74 | */ 75 | #ifdef HAL_FLASH_MODULE_ENABLED 76 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ 77 | defined(STM32F412Rx) || defined(STM32F412Cx) 78 | 79 | /* Private typedef -----------------------------------------------------------*/ 80 | /* Private define ------------------------------------------------------------*/ 81 | /* Private macro -------------------------------------------------------------*/ 82 | /* Private variables ---------------------------------------------------------*/ 83 | /* Private function prototypes -----------------------------------------------*/ 84 | /* Exported functions --------------------------------------------------------*/ 85 | /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAMFUNC Exported Functions 86 | * @{ 87 | */ 88 | 89 | /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions executed from internal RAM 90 | * @brief Peripheral Extended features functions 91 | * 92 | @verbatim 93 | 94 | =============================================================================== 95 | ##### ramfunc functions ##### 96 | =============================================================================== 97 | [..] 98 | This subsection provides a set of functions that should be executed from RAM 99 | transfers. 100 | 101 | @endverbatim 102 | * @{ 103 | */ 104 | 105 | /** 106 | * @brief Stop the flash interface while System Run 107 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 108 | * @note This mode couldn't be set while executing with the flash itself. 109 | * It should be done with specific routine executed from RAM. 110 | * @retval HAL status 111 | */ 112 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void) 113 | { 114 | /* Enable Power ctrl clock */ 115 | __HAL_RCC_PWR_CLK_ENABLE(); 116 | /* Stop the flash interface while System Run */ 117 | SET_BIT(PWR->CR, PWR_CR_FISSR); 118 | 119 | return HAL_OK; 120 | } 121 | 122 | /** 123 | * @brief Start the flash interface while System Run 124 | * @note This mode is only available for STM32F411xx/STM32F446xx devices. 125 | * @note This mode couldn't be set while executing with the flash itself. 126 | * It should be done with specific routine executed from RAM. 127 | * @retval HAL status 128 | */ 129 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void) 130 | { 131 | /* Enable Power ctrl clock */ 132 | __HAL_RCC_PWR_CLK_ENABLE(); 133 | /* Start the flash interface while System Run */ 134 | CLEAR_BIT(PWR->CR, PWR_CR_FISSR); 135 | 136 | return HAL_OK; 137 | } 138 | 139 | /** 140 | * @brief Enable the flash sleep while System Run 141 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 142 | * @note This mode could n't be set while executing with the flash itself. 143 | * It should be done with specific routine executed from RAM. 144 | * @retval HAL status 145 | */ 146 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void) 147 | { 148 | /* Enable Power ctrl clock */ 149 | __HAL_RCC_PWR_CLK_ENABLE(); 150 | /* Enable the flash sleep while System Run */ 151 | SET_BIT(PWR->CR, PWR_CR_FMSSR); 152 | 153 | return HAL_OK; 154 | } 155 | 156 | /** 157 | * @brief Disable the flash sleep while System Run 158 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 159 | * @note This mode couldn't be set while executing with the flash itself. 160 | * It should be done with specific routine executed from RAM. 161 | * @retval HAL status 162 | */ 163 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void) 164 | { 165 | /* Enable Power ctrl clock */ 166 | __HAL_RCC_PWR_CLK_ENABLE(); 167 | /* Disable the flash sleep while System Run */ 168 | CLEAR_BIT(PWR->CR, PWR_CR_FMSSR); 169 | 170 | return HAL_OK; 171 | } 172 | 173 | /** 174 | * @} 175 | */ 176 | 177 | /** 178 | * @} 179 | */ 180 | 181 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 182 | #endif /* HAL_FLASH_MODULE_ENABLED */ 183 | /** 184 | * @} 185 | */ 186 | 187 | /** 188 | * @} 189 | */ 190 | 191 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 192 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_i2c_ex.c 4 | * @author MCD Application Team 5 | * @brief I2C Extension HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of I2C extension peripheral: 8 | * + Extension features functions 9 | * 10 | @verbatim 11 | ============================================================================== 12 | ##### I2C peripheral extension features ##### 13 | ============================================================================== 14 | 15 | [..] Comparing to other previous devices, the I2C interface for STM32F427xx/437xx/ 16 | 429xx/439xx devices contains the following additional features : 17 | 18 | (+) Possibility to disable or enable Analog Noise Filter 19 | (+) Use of a configured Digital Noise Filter 20 | 21 | ##### How to use this driver ##### 22 | ============================================================================== 23 | [..] This driver provides functions to configure Noise Filter 24 | (#) Configure I2C Analog noise filter using the function HAL_I2C_AnalogFilter_Config() 25 | (#) Configure I2C Digital noise filter using the function HAL_I2C_DigitalFilter_Config() 26 | 27 | @endverbatim 28 | ****************************************************************************** 29 | * @attention 30 | * 31 | *

© COPYRIGHT(c) 2017 STMicroelectronics

32 | * 33 | * Redistribution and use in source and binary forms, with or without modification, 34 | * are permitted provided that the following conditions are met: 35 | * 1. Redistributions of source code must retain the above copyright notice, 36 | * this list of conditions and the following disclaimer. 37 | * 2. Redistributions in binary form must reproduce the above copyright notice, 38 | * this list of conditions and the following disclaimer in the documentation 39 | * and/or other materials provided with the distribution. 40 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 41 | * may be used to endorse or promote products derived from this software 42 | * without specific prior written permission. 43 | * 44 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 45 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 46 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 47 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 48 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 49 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 50 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 51 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 52 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 54 | * 55 | ****************************************************************************** 56 | */ 57 | 58 | /* Includes ------------------------------------------------------------------*/ 59 | #include "stm32f4xx_hal.h" 60 | 61 | /** @addtogroup STM32F4xx_HAL_Driver 62 | * @{ 63 | */ 64 | 65 | /** @defgroup I2CEx I2CEx 66 | * @brief I2C HAL module driver 67 | * @{ 68 | */ 69 | 70 | #ifdef HAL_I2C_MODULE_ENABLED 71 | 72 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 73 | defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) ||\ 74 | defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || defined(STM32F423xx) 75 | /* Private typedef -----------------------------------------------------------*/ 76 | /* Private define ------------------------------------------------------------*/ 77 | /* Private macro -------------------------------------------------------------*/ 78 | /* Private variables ---------------------------------------------------------*/ 79 | /* Private function prototypes -----------------------------------------------*/ 80 | /* Exported functions --------------------------------------------------------*/ 81 | /** @defgroup I2CEx_Exported_Functions I2C Exported Functions 82 | * @{ 83 | */ 84 | 85 | 86 | /** @defgroup I2CEx_Exported_Functions_Group1 Extension features functions 87 | * @brief Extension features functions 88 | * 89 | @verbatim 90 | =============================================================================== 91 | ##### Extension features functions ##### 92 | =============================================================================== 93 | [..] This section provides functions allowing to: 94 | (+) Configure Noise Filters 95 | 96 | @endverbatim 97 | * @{ 98 | */ 99 | 100 | /** 101 | * @brief Configures I2C Analog noise filter. 102 | * @param hi2c pointer to a I2C_HandleTypeDef structure that contains 103 | * the configuration information for the specified I2Cx peripheral. 104 | * @param AnalogFilter new state of the Analog filter. 105 | * @retval HAL status 106 | */ 107 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter) 108 | { 109 | /* Check the parameters */ 110 | assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); 111 | assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter)); 112 | 113 | if(hi2c->State == HAL_I2C_STATE_READY) 114 | { 115 | hi2c->State = HAL_I2C_STATE_BUSY; 116 | 117 | /* Disable the selected I2C peripheral */ 118 | __HAL_I2C_DISABLE(hi2c); 119 | 120 | /* Reset I2Cx ANOFF bit */ 121 | hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF); 122 | 123 | /* Disable the analog filter */ 124 | hi2c->Instance->FLTR |= AnalogFilter; 125 | 126 | __HAL_I2C_ENABLE(hi2c); 127 | 128 | hi2c->State = HAL_I2C_STATE_READY; 129 | 130 | return HAL_OK; 131 | } 132 | else 133 | { 134 | return HAL_BUSY; 135 | } 136 | } 137 | 138 | /** 139 | * @brief Configures I2C Digital noise filter. 140 | * @param hi2c pointer to a I2C_HandleTypeDef structure that contains 141 | * the configuration information for the specified I2Cx peripheral. 142 | * @param DigitalFilter Coefficient of digital noise filter between 0x00 and 0x0F. 143 | * @retval HAL status 144 | */ 145 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter) 146 | { 147 | uint16_t tmpreg = 0; 148 | 149 | /* Check the parameters */ 150 | assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); 151 | assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter)); 152 | 153 | if(hi2c->State == HAL_I2C_STATE_READY) 154 | { 155 | hi2c->State = HAL_I2C_STATE_BUSY; 156 | 157 | /* Disable the selected I2C peripheral */ 158 | __HAL_I2C_DISABLE(hi2c); 159 | 160 | /* Get the old register value */ 161 | tmpreg = hi2c->Instance->FLTR; 162 | 163 | /* Reset I2Cx DNF bit [3:0] */ 164 | tmpreg &= ~(I2C_FLTR_DNF); 165 | 166 | /* Set I2Cx DNF coefficient */ 167 | tmpreg |= DigitalFilter; 168 | 169 | /* Store the new register value */ 170 | hi2c->Instance->FLTR = tmpreg; 171 | 172 | __HAL_I2C_ENABLE(hi2c); 173 | 174 | hi2c->State = HAL_I2C_STATE_READY; 175 | 176 | return HAL_OK; 177 | } 178 | else 179 | { 180 | return HAL_BUSY; 181 | } 182 | } 183 | 184 | /** 185 | * @} 186 | */ 187 | 188 | /** 189 | * @} 190 | */ 191 | #endif /* STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F401xC ||\ 192 | STM32F401xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F413xx ||\ 193 | STM32F423xx */ 194 | 195 | #endif /* HAL_I2C_MODULE_ENABLED */ 196 | /** 197 | * @} 198 | */ 199 | 200 | /** 201 | * @} 202 | */ 203 | 204 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 205 | -------------------------------------------------------------------------------- /Inc/main.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : main.h 4 | * @brief : Header for main.c file. 5 | * This file contains the common defines of the application. 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | 40 | /* Define to prevent recursive inclusion -------------------------------------*/ 41 | #ifndef __MAIN_H__ 42 | #define __MAIN_H__ 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | 46 | /* USER CODE BEGIN Includes */ 47 | 48 | /* USER CODE END Includes */ 49 | 50 | /* Private define ------------------------------------------------------------*/ 51 | 52 | /* ########################## Assert Selection ############################## */ 53 | /** 54 | * @brief Uncomment the line below to expanse the "assert_param" macro in the 55 | * HAL drivers code 56 | */ 57 | /* #define USE_FULL_ASSERT 1U */ 58 | 59 | /* USER CODE BEGIN Private defines */ 60 | 61 | /* USER CODE END Private defines */ 62 | 63 | #ifdef __cplusplus 64 | extern "C" { 65 | #endif 66 | void _Error_Handler(char *, int); 67 | 68 | #define Error_Handler() _Error_Handler(__FILE__, __LINE__) 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __MAIN_H__ */ 74 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /Inc/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_it.h 4 | * @brief This file contains the headers of the interrupt handlers. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2019 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __STM32F4xx_IT_H 36 | #define __STM32F4xx_IT_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | #include "stm32f4xx_hal.h" 44 | #include "main.h" 45 | /* Exported types ------------------------------------------------------------*/ 46 | /* Exported constants --------------------------------------------------------*/ 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* Exported functions ------------------------------------------------------- */ 49 | 50 | void NMI_Handler(void); 51 | void HardFault_Handler(void); 52 | void MemManage_Handler(void); 53 | void BusFault_Handler(void); 54 | void UsageFault_Handler(void); 55 | void SVC_Handler(void); 56 | void DebugMon_Handler(void); 57 | void PendSV_Handler(void); 58 | void SysTick_Handler(void); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* __STM32F4xx_IT_H */ 65 | 66 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # STM32_HAL_DS3231 2 | DS3231 Library for STM32 HAL 3 | 4 | I've implemented DS3231 library for STM32 HAL. 5 | This library doesn't support all of DS3231 features and you may find flaws. 6 | 7 | 1) RTC Set / Get 8 | 2) Temperature / Get 9 | 3) Alarm#1 Set / Clear 10 | 4) Register Read / Write 11 | 12 | https://blog.naver.com/eziya76/221491571100
13 | 14 | ![ds3231](./ds3231.JPG)
15 | -------------------------------------------------------------------------------- /STM32F407VG_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** File : stm32_flash.ld 6 | ** 7 | ** Abstract : Linker script for STM32F407VG Device with 8 | ** 1024KByte FLASH, 128KByte RAM 9 | ** 10 | ** Set heap size, stack size and stack location according 11 | ** to application requirements. 12 | ** 13 | ** Set memory bank area and size if external memory is used. 14 | ** 15 | ** Target : STMicroelectronics STM32 16 | ** 17 | ** Environment : Atollic TrueSTUDIO(R) 18 | ** 19 | ** Distribution: The file is distributed as is, without any warranty 20 | ** of any kind. 21 | ** 22 | ** (c)Copyright Atollic AB. 23 | ** You may use this file as-is or modify it according to the needs of your 24 | ** project. This file may only be built (assembled or compiled and linked) 25 | ** using the Atollic TrueSTUDIO(R) product. The use of this file together 26 | ** with other tools than Atollic TrueSTUDIO(R) is not permitted. 27 | ** 28 | ***************************************************************************** 29 | */ 30 | 31 | /* Entry Point */ 32 | ENTRY(Reset_Handler) 33 | 34 | /* Highest address of the user mode stack */ 35 | _estack = 0x20020000; /* end of RAM */ 36 | /* Generate a link error if heap and stack don't fit into RAM */ 37 | _Min_Heap_Size = 0x200; /* required amount of heap */ 38 | _Min_Stack_Size = 0x400; /* required amount of stack */ 39 | 40 | /* Specify the memory areas */ 41 | MEMORY 42 | { 43 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 44 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K 45 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 46 | } 47 | 48 | /* Define output sections */ 49 | SECTIONS 50 | { 51 | /* The startup code goes first into FLASH */ 52 | .isr_vector : 53 | { 54 | . = ALIGN(4); 55 | KEEP(*(.isr_vector)) /* Startup code */ 56 | . = ALIGN(4); 57 | } >FLASH 58 | 59 | /* The program code and other data goes into FLASH */ 60 | .text : 61 | { 62 | . = ALIGN(4); 63 | *(.text) /* .text sections (code) */ 64 | *(.text*) /* .text* sections (code) */ 65 | *(.glue_7) /* glue arm to thumb code */ 66 | *(.glue_7t) /* glue thumb to arm code */ 67 | *(.eh_frame) 68 | 69 | KEEP (*(.init)) 70 | KEEP (*(.fini)) 71 | 72 | . = ALIGN(4); 73 | _etext = .; /* define a global symbols at end of code */ 74 | } >FLASH 75 | 76 | /* Constant data goes into FLASH */ 77 | .rodata : 78 | { 79 | . = ALIGN(4); 80 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 81 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 82 | . = ALIGN(4); 83 | } >FLASH 84 | 85 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 86 | .ARM : { 87 | __exidx_start = .; 88 | *(.ARM.exidx*) 89 | __exidx_end = .; 90 | } >FLASH 91 | 92 | .preinit_array : 93 | { 94 | PROVIDE_HIDDEN (__preinit_array_start = .); 95 | KEEP (*(.preinit_array*)) 96 | PROVIDE_HIDDEN (__preinit_array_end = .); 97 | } >FLASH 98 | .init_array : 99 | { 100 | PROVIDE_HIDDEN (__init_array_start = .); 101 | KEEP (*(SORT(.init_array.*))) 102 | KEEP (*(.init_array*)) 103 | PROVIDE_HIDDEN (__init_array_end = .); 104 | } >FLASH 105 | .fini_array : 106 | { 107 | PROVIDE_HIDDEN (__fini_array_start = .); 108 | KEEP (*(SORT(.fini_array.*))) 109 | KEEP (*(.fini_array*)) 110 | PROVIDE_HIDDEN (__fini_array_end = .); 111 | } >FLASH 112 | 113 | /* used by the startup to initialize data */ 114 | _sidata = LOADADDR(.data); 115 | 116 | /* Initialized data sections goes into RAM, load LMA copy after code */ 117 | .data : 118 | { 119 | . = ALIGN(4); 120 | _sdata = .; /* create a global symbol at data start */ 121 | *(.data) /* .data sections */ 122 | *(.data*) /* .data* sections */ 123 | 124 | . = ALIGN(4); 125 | _edata = .; /* define a global symbol at data end */ 126 | } >RAM AT> FLASH 127 | 128 | _siccmram = LOADADDR(.ccmram); 129 | 130 | /* CCM-RAM section 131 | * 132 | * IMPORTANT NOTE! 133 | * If initialized variables will be placed in this section, 134 | * the startup code needs to be modified to copy the init-values. 135 | */ 136 | .ccmram : 137 | { 138 | . = ALIGN(4); 139 | _sccmram = .; /* create a global symbol at ccmram start */ 140 | *(.ccmram) 141 | *(.ccmram*) 142 | 143 | . = ALIGN(4); 144 | _eccmram = .; /* create a global symbol at ccmram end */ 145 | } >CCMRAM AT> FLASH 146 | 147 | 148 | /* Uninitialized data section */ 149 | . = ALIGN(4); 150 | .bss : 151 | { 152 | /* This is used by the startup in order to initialize the .bss secion */ 153 | _sbss = .; /* define a global symbol at bss start */ 154 | __bss_start__ = _sbss; 155 | *(.bss) 156 | *(.bss*) 157 | *(COMMON) 158 | 159 | . = ALIGN(4); 160 | _ebss = .; /* define a global symbol at bss end */ 161 | __bss_end__ = _ebss; 162 | } >RAM 163 | 164 | /* User_heap_stack section, used to check that there is enough RAM left */ 165 | ._user_heap_stack : 166 | { 167 | . = ALIGN(4); 168 | PROVIDE ( end = . ); 169 | PROVIDE ( _end = . ); 170 | . = . + _Min_Heap_Size; 171 | . = . + _Min_Stack_Size; 172 | . = ALIGN(4); 173 | } >RAM 174 | 175 | 176 | 177 | /* Remove information from the standard libraries */ 178 | /DISCARD/ : 179 | { 180 | libc.a ( * ) 181 | libm.a ( * ) 182 | libgcc.a ( * ) 183 | } 184 | 185 | .ARM.attributes 0 : { *(.ARM.attributes) } 186 | } 187 | 188 | 189 | -------------------------------------------------------------------------------- /STM32F4_HAL_I2C_DS3231.elf.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /STM32F4_HAL_I2C_DS3231.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.DutyCycle=I2C_DUTYCYCLE_16_9 4 | I2C1.I2C_Mode=I2C_Fast 5 | I2C1.IPParameters=I2C_Mode,DutyCycle 6 | KeepUserPlacement=true 7 | Mcu.Family=STM32F4 8 | Mcu.IP0=I2C1 9 | Mcu.IP1=NVIC 10 | Mcu.IP2=RCC 11 | Mcu.IP3=SYS 12 | Mcu.IPNb=4 13 | Mcu.Name=STM32F407V(E-G)Tx 14 | Mcu.Package=LQFP100 15 | Mcu.Pin0=PH0-OSC_IN 16 | Mcu.Pin1=PH1-OSC_OUT 17 | Mcu.Pin2=PB8 18 | Mcu.Pin3=PB9 19 | Mcu.Pin4=VP_SYS_VS_Systick 20 | Mcu.PinsNb=5 21 | Mcu.ThirdPartyNb=0 22 | Mcu.UserConstants= 23 | Mcu.UserName=STM32F407VGTx 24 | MxCube.Version=4.27.0 25 | MxDb.Version=DB.4.0.270 26 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:true 27 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:true 28 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true 29 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true 30 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true 31 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:true 32 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_0 33 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:true 34 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true 35 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:true 36 | PB8.Locked=true 37 | PB8.Mode=I2C 38 | PB8.Signal=I2C1_SCL 39 | PB9.Locked=true 40 | PB9.Mode=I2C 41 | PB9.Signal=I2C1_SDA 42 | PCC.Checker=false 43 | PCC.Line=STM32F407/417 44 | PCC.MCU=STM32F407V(E-G)Tx 45 | PCC.PartNumber=STM32F407VGTx 46 | PCC.Seq0=0 47 | PCC.Series=STM32F4 48 | PCC.Temperature=25 49 | PCC.Vdd=3.3 50 | PH0-OSC_IN.Mode=HSE-External-Oscillator 51 | PH0-OSC_IN.Signal=RCC_OSC_IN 52 | PH1-OSC_OUT.Mode=HSE-External-Oscillator 53 | PH1-OSC_OUT.Signal=RCC_OSC_OUT 54 | PinOutPanel.RotationAngle=0 55 | ProjectManager.AskForMigrate=true 56 | ProjectManager.BackupPrevious=false 57 | ProjectManager.CompilerOptimize=6 58 | ProjectManager.ComputerToolchain=false 59 | ProjectManager.CoupleFile=false 60 | ProjectManager.CustomerFirmwarePackage= 61 | ProjectManager.DefaultFWLocation=true 62 | ProjectManager.DeletePrevious=true 63 | ProjectManager.DeviceId=STM32F407VGTx 64 | ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.21.0 65 | ProjectManager.FreePins=false 66 | ProjectManager.HalAssertFull=false 67 | ProjectManager.HeapSize=0x200 68 | ProjectManager.KeepUserCode=true 69 | ProjectManager.LastFirmware=true 70 | ProjectManager.LibraryCopy=1 71 | ProjectManager.MainLocation=Src 72 | ProjectManager.NoMain=false 73 | ProjectManager.PreviousToolchain=TrueSTUDIO 74 | ProjectManager.ProjectBuild=false 75 | ProjectManager.ProjectFileName=STM32F4_HAL_I2C_DS3231.ioc 76 | ProjectManager.ProjectName=STM32F4_HAL_I2C_DS3231 77 | ProjectManager.StackSize=0x400 78 | ProjectManager.TargetToolchain=TrueSTUDIO 79 | ProjectManager.ToolChainLocation= 80 | ProjectManager.UnderRoot=true 81 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_I2C1_Init-I2C1-false-HAL-true 82 | RCC.48MHZClocksFreq_Value=48000000 83 | RCC.AHBFreq_Value=168000000 84 | RCC.APB1CLKDivider=RCC_HCLK_DIV4 85 | RCC.APB1Freq_Value=42000000 86 | RCC.APB1TimFreq_Value=84000000 87 | RCC.APB2CLKDivider=RCC_HCLK_DIV2 88 | RCC.APB2Freq_Value=84000000 89 | RCC.APB2TimFreq_Value=168000000 90 | RCC.CortexFreq_Value=168000000 91 | RCC.EthernetFreq_Value=168000000 92 | RCC.FCLKCortexFreq_Value=168000000 93 | RCC.FamilyName=M 94 | RCC.HCLKFreq_Value=168000000 95 | RCC.HSE_VALUE=8000000 96 | RCC.HSI_VALUE=16000000 97 | RCC.I2SClocksFreq_Value=96000000 98 | RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLSourceVirtual,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S 99 | RCC.LSI_VALUE=32000 100 | RCC.MCO2PinFreq_Value=168000000 101 | RCC.PLLCLKFreq_Value=168000000 102 | RCC.PLLM=8 103 | RCC.PLLN=336 104 | RCC.PLLQ=7 105 | RCC.PLLQCLKFreq_Value=48000000 106 | RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE 107 | RCC.RTCFreq_Value=32000 108 | RCC.RTCHSEDivFreq_Value=4000000 109 | RCC.SYSCLKFreq_VALUE=168000000 110 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 111 | RCC.VCOI2SOutputFreq_Value=192000000 112 | RCC.VCOInputFreq_Value=1000000 113 | RCC.VCOOutputFreq_Value=336000000 114 | RCC.VcooutputI2S=96000000 115 | VP_SYS_VS_Systick.Mode=SysTick 116 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 117 | board=STM32F4DISCOVERY 118 | boardIOC=true 119 | -------------------------------------------------------------------------------- /Src/main.c: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include "main.h" 41 | #include "stm32f4xx_hal.h" 42 | 43 | /* USER CODE BEGIN Includes */ 44 | #include "stm32_ds3231.h" 45 | /* USER CODE END Includes */ 46 | 47 | /* Private variables ---------------------------------------------------------*/ 48 | I2C_HandleTypeDef hi2c1; 49 | 50 | /* USER CODE BEGIN PV */ 51 | /* Private variables ---------------------------------------------------------*/ 52 | 53 | /* USER CODE END PV */ 54 | 55 | /* Private function prototypes -----------------------------------------------*/ 56 | void SystemClock_Config(void); 57 | static void MX_GPIO_Init(void); 58 | static void MX_I2C1_Init(void); 59 | 60 | /* USER CODE BEGIN PFP */ 61 | /* Private function prototypes -----------------------------------------------*/ 62 | 63 | /* USER CODE END PFP */ 64 | 65 | /* USER CODE BEGIN 0 */ 66 | _RTC rtc = { 67 | .Year = 19, .Month = 12, .Date = 12, 68 | .DaysOfWeek = SUNDAY, 69 | .Hour = 12, .Min = 12, .Sec = 12 70 | }; 71 | 72 | uint8_t regVal; 73 | float rtcTemp; 74 | 75 | /* USER CODE END 0 */ 76 | 77 | /** 78 | * @brief The application entry point. 79 | * 80 | * @retval None 81 | */ 82 | int main(void) 83 | { 84 | /* USER CODE BEGIN 1 */ 85 | 86 | /* USER CODE END 1 */ 87 | 88 | /* MCU Configuration----------------------------------------------------------*/ 89 | 90 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 91 | HAL_Init(); 92 | 93 | /* USER CODE BEGIN Init */ 94 | 95 | /* USER CODE END Init */ 96 | 97 | /* Configure the system clock */ 98 | SystemClock_Config(); 99 | 100 | /* USER CODE BEGIN SysInit */ 101 | 102 | /* USER CODE END SysInit */ 103 | 104 | /* Initialize all configured peripherals */ 105 | MX_GPIO_Init(); 106 | MX_I2C1_Init(); 107 | /* USER CODE BEGIN 2 */ 108 | DS3231_Init(&hi2c1); 109 | DS3231_SetTime(&rtc); 110 | 111 | /* Configure Alarm1 */ 112 | DS3231_ClearAlarm1(); 113 | //DS3231_SetAlarm1(ALARM_MODE_ONCE_PER_SECOND, 0, 0, 0, 0); 114 | DS3231_SetAlarm1(ALARM_MODE_SEC_MATCHED, 0, 0, 0, 30); 115 | 116 | /* USER CODE END 2 */ 117 | 118 | /* Infinite loop */ 119 | /* USER CODE BEGIN WHILE */ 120 | while (1) 121 | { 122 | 123 | /* USER CODE END WHILE */ 124 | 125 | /* USER CODE BEGIN 3 */ 126 | DS3231_GetTime(&rtc); 127 | DS3231_ReadTemperature(&rtcTemp); 128 | 129 | ReadRegister(DS3231_REG_STATUS, ®Val); 130 | if(regVal & DS3231_STA_A1F) 131 | { 132 | regVal &= ~DS3231_STA_A1F; 133 | WriteRegister(DS3231_REG_STATUS, regVal); 134 | } 135 | 136 | HAL_Delay(1000); 137 | } 138 | /* USER CODE END 3 */ 139 | 140 | } 141 | 142 | /** 143 | * @brief System Clock Configuration 144 | * @retval None 145 | */ 146 | void SystemClock_Config(void) 147 | { 148 | 149 | RCC_OscInitTypeDef RCC_OscInitStruct; 150 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 151 | 152 | /**Configure the main internal regulator output voltage 153 | */ 154 | __HAL_RCC_PWR_CLK_ENABLE(); 155 | 156 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); 157 | 158 | /**Initializes the CPU, AHB and APB busses clocks 159 | */ 160 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 161 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 162 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 163 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 164 | RCC_OscInitStruct.PLL.PLLM = 8; 165 | RCC_OscInitStruct.PLL.PLLN = 336; 166 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; 167 | RCC_OscInitStruct.PLL.PLLQ = 7; 168 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 169 | { 170 | _Error_Handler(__FILE__, __LINE__); 171 | } 172 | 173 | /**Initializes the CPU, AHB and APB busses clocks 174 | */ 175 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 176 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 177 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 178 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 179 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; 180 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; 181 | 182 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) 183 | { 184 | _Error_Handler(__FILE__, __LINE__); 185 | } 186 | 187 | /**Configure the Systick interrupt time 188 | */ 189 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 190 | 191 | /**Configure the Systick 192 | */ 193 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 194 | 195 | /* SysTick_IRQn interrupt configuration */ 196 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 197 | } 198 | 199 | /* I2C1 init function */ 200 | static void MX_I2C1_Init(void) 201 | { 202 | 203 | hi2c1.Instance = I2C1; 204 | hi2c1.Init.ClockSpeed = 400000; 205 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_16_9; 206 | hi2c1.Init.OwnAddress1 = 0; 207 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 208 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 209 | hi2c1.Init.OwnAddress2 = 0; 210 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 211 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 212 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 213 | { 214 | _Error_Handler(__FILE__, __LINE__); 215 | } 216 | 217 | } 218 | 219 | /** Configure pins as 220 | * Analog 221 | * Input 222 | * Output 223 | * EVENT_OUT 224 | * EXTI 225 | */ 226 | static void MX_GPIO_Init(void) 227 | { 228 | 229 | /* GPIO Ports Clock Enable */ 230 | __HAL_RCC_GPIOH_CLK_ENABLE(); 231 | __HAL_RCC_GPIOB_CLK_ENABLE(); 232 | 233 | } 234 | 235 | /* USER CODE BEGIN 4 */ 236 | 237 | /* USER CODE END 4 */ 238 | 239 | /** 240 | * @brief This function is executed in case of error occurrence. 241 | * @param file: The file name as string. 242 | * @param line: The line in file as a number. 243 | * @retval None 244 | */ 245 | void _Error_Handler(char *file, int line) 246 | { 247 | /* USER CODE BEGIN Error_Handler_Debug */ 248 | /* User can add his own implementation to report the HAL error return state */ 249 | while(1) 250 | { 251 | } 252 | /* USER CODE END Error_Handler_Debug */ 253 | } 254 | 255 | #ifdef USE_FULL_ASSERT 256 | /** 257 | * @brief Reports the name of the source file and the source line number 258 | * where the assert_param error has occurred. 259 | * @param file: pointer to the source file name 260 | * @param line: assert_param error line source number 261 | * @retval None 262 | */ 263 | void assert_failed(uint8_t* file, uint32_t line) 264 | { 265 | /* USER CODE BEGIN 6 */ 266 | /* User can add his own implementation to report the file name and line number, 267 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 268 | /* USER CODE END 6 */ 269 | } 270 | #endif /* USE_FULL_ASSERT */ 271 | 272 | /** 273 | * @} 274 | */ 275 | 276 | /** 277 | * @} 278 | */ 279 | 280 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 281 | -------------------------------------------------------------------------------- /Src/stm32_ds3231.c: -------------------------------------------------------------------------------- 1 | /* 2 | * stm32_ds3231.c 3 | * 4 | * Created on: 2019. 3. 17. 5 | * Author: kiki 6 | */ 7 | #include "stm32f4xx_hal.h" 8 | #include "stm32_ds3231.h" 9 | 10 | #define DS3231_ADDR (0x68 << 1) 11 | 12 | I2C_HandleTypeDef *i2c; 13 | 14 | static uint8_t B2D(uint8_t bcd); 15 | static uint8_t D2B(uint8_t decimal); 16 | 17 | void DS3231_Init(I2C_HandleTypeDef *handle) 18 | { 19 | i2c = handle; 20 | } 21 | 22 | bool DS3231_GetTime(_RTC *rtc) 23 | { 24 | uint8_t startAddr = DS3231_REG_TIME; 25 | uint8_t buffer[7] = {0,}; 26 | 27 | if(HAL_I2C_Master_Transmit(i2c, DS3231_ADDR, &startAddr, 1, HAL_MAX_DELAY) != HAL_OK) return false; 28 | if(HAL_I2C_Master_Receive(i2c, DS3231_ADDR, buffer, sizeof(buffer), HAL_MAX_DELAY) != HAL_OK) return false; 29 | 30 | rtc->Sec = B2D(buffer[0] & 0x7F); 31 | rtc->Min = B2D(buffer[1] & 0x7F); 32 | rtc->Hour = B2D(buffer[2] & 0x3F); 33 | rtc->DaysOfWeek = buffer[3] & 0x07; 34 | rtc->Date = B2D(buffer[4] & 0x3F); 35 | rtc->Month = B2D(buffer[5] & 0x1F); 36 | rtc->Year = B2D(buffer[6]); 37 | 38 | return true; 39 | } 40 | 41 | bool DS3231_SetTime(_RTC *rtc) 42 | { 43 | uint8_t startAddr = DS3231_REG_TIME; 44 | uint8_t buffer[8] = {startAddr, D2B(rtc->Sec), D2B(rtc->Min), D2B(rtc->Hour), rtc->DaysOfWeek, D2B(rtc->Date), D2B(rtc->Month), D2B(rtc->Year)}; 45 | if(HAL_I2C_Master_Transmit(i2c, DS3231_ADDR, buffer, sizeof(buffer), HAL_MAX_DELAY) != HAL_OK) return false; 46 | 47 | return true; 48 | } 49 | 50 | bool DS3231_ReadTemperature(float *temp) 51 | { 52 | uint8_t startAddr = DS3231_REG_TEMP; 53 | uint8_t buffer[2] = {0,}; 54 | 55 | if(HAL_I2C_Master_Transmit(i2c, DS3231_ADDR, &startAddr, 1, HAL_MAX_DELAY) != HAL_OK) return false; 56 | if(HAL_I2C_Master_Receive(i2c, DS3231_ADDR, buffer, sizeof(buffer), HAL_MAX_DELAY) != HAL_OK) return false; 57 | 58 | int16_t value = (buffer[0] << 8) | (buffer[1]); 59 | value = (value >> 6); 60 | 61 | *temp = value / 4.0f; 62 | return true; 63 | } 64 | 65 | bool DS3231_SetAlarm1(uint8_t mode, uint8_t date, uint8_t hour, uint8_t min, uint8_t sec) 66 | { 67 | uint8_t alarmSecond = D2B(sec); 68 | uint8_t alarmMinute = D2B(min); 69 | uint8_t alarmHour = D2B(hour); 70 | uint8_t alarmDate = D2B(date); 71 | 72 | switch(mode) 73 | { 74 | case ALARM_MODE_ALL_MATCHED: 75 | break; 76 | case ALARM_MODE_HOUR_MIN_SEC_MATCHED: 77 | alarmDate |= 0x80; 78 | break; 79 | case ALARM_MODE_MIN_SEC_MATCHED: 80 | alarmDate |= 0x80; 81 | alarmHour |= 0x80; 82 | break; 83 | case ALARM_MODE_SEC_MATCHED: 84 | alarmDate |= 0x80; 85 | alarmHour |= 0x80; 86 | alarmMinute |= 0x80; 87 | break; 88 | case ALARM_MODE_ONCE_PER_SECOND: 89 | alarmDate |= 0x80; 90 | alarmHour |= 0x80; 91 | alarmMinute |= 0x80; 92 | alarmSecond |= 0x80; 93 | break; 94 | default: 95 | break; 96 | } 97 | 98 | /* Write Alarm Registers */ 99 | uint8_t startAddr = DS3231_REG_ALARM1; 100 | uint8_t buffer[5] = {startAddr, alarmSecond, alarmMinute, alarmHour, alarmDate}; 101 | if(HAL_I2C_Master_Transmit(i2c, DS3231_ADDR, buffer, sizeof(buffer), HAL_MAX_DELAY) != HAL_OK) return false; 102 | 103 | /* Enable Alarm1 at Control Register */ 104 | uint8_t ctrlReg = 0x00; 105 | ReadRegister(DS3231_REG_CONTROL, &ctrlReg); 106 | ctrlReg |= DS3231_CON_A1IE; 107 | ctrlReg |= DS3231_CON_INTCN; 108 | WriteRegister(DS3231_REG_CONTROL, ctrlReg); 109 | 110 | return true; 111 | } 112 | 113 | bool DS3231_ClearAlarm1() 114 | { 115 | uint8_t ctrlReg; 116 | uint8_t statusReg; 117 | 118 | /* Clear Control Register */ 119 | ReadRegister(DS3231_REG_CONTROL, &ctrlReg); 120 | ctrlReg &= ~DS3231_CON_A1IE; 121 | WriteRegister(DS3231_REG_CONTROL, ctrlReg); 122 | 123 | /* Clear Status Register */ 124 | ReadRegister(DS3231_REG_STATUS, &statusReg); 125 | statusReg &= ~DS3231_STA_A1F; 126 | WriteRegister(DS3231_REG_STATUS, statusReg); 127 | 128 | return true; 129 | } 130 | 131 | bool ReadRegister(uint8_t regAddr, uint8_t *value) 132 | { 133 | if(HAL_I2C_Master_Transmit(i2c, DS3231_ADDR, ®Addr, 1, HAL_MAX_DELAY) != HAL_OK) return false; 134 | if(HAL_I2C_Master_Receive(i2c, DS3231_ADDR, value, 1, HAL_MAX_DELAY) != HAL_OK) return false; 135 | 136 | return true; 137 | } 138 | 139 | bool WriteRegister(uint8_t regAddr, uint8_t value) 140 | { 141 | uint8_t buffer[2] = {regAddr, value}; 142 | if(HAL_I2C_Master_Transmit(i2c, DS3231_ADDR, buffer, sizeof(buffer), HAL_MAX_DELAY) != HAL_OK) return false; 143 | 144 | return true; 145 | } 146 | 147 | static uint8_t B2D(uint8_t bcd) 148 | { 149 | return (bcd >> 4) * 10 + (bcd & 0x0F); 150 | } 151 | 152 | static uint8_t D2B(uint8_t decimal) 153 | { 154 | return (((decimal / 10) << 4) | (decimal % 10)); 155 | } 156 | -------------------------------------------------------------------------------- /Src/stm32_ds3231.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stm32_ds3231.h 3 | * 4 | * Created on: 2019. 3. 17. 5 | * Author: Jihoon Lee 6 | */ 7 | 8 | #ifndef STM32_DS3231_H_ 9 | #define STM32_DS3231_H_ 10 | 11 | #include 12 | #include 13 | 14 | #define DS3231_REG_TIME 0x00 15 | #define DS3231_REG_ALARM1 0x07 16 | #define DS3231_REG_ALARM2 0x0B 17 | #define DS3231_REG_CONTROL 0x0E 18 | #define DS3231_REG_STATUS 0x0F 19 | #define DS3231_REG_TEMP 0x11 20 | 21 | #define DS3231_CON_EOSC 0x80 22 | #define DS3231_CON_BBSQW 0x40 23 | #define DS3231_CON_CONV 0x20 24 | #define DS3231_CON_RS2 0x10 25 | #define DS3231_CON_RS1 0x08 26 | #define DS3231_CON_INTCN 0x04 27 | #define DS3231_CON_A2IE 0x02 28 | #define DS3231_CON_A1IE 0x01 29 | 30 | #define DS3231_STA_OSF 0x80 31 | #define DS3231_STA_32KHZ 0x08 32 | #define DS3231_STA_BSY 0x04 33 | #define DS3231_STA_A2F 0x02 34 | #define DS3231_STA_A1F 0x01 35 | 36 | typedef enum 37 | { 38 | ALARM_MODE_ALL_MATCHED = 0, 39 | ALARM_MODE_HOUR_MIN_SEC_MATCHED, 40 | ALARM_MODE_MIN_SEC_MATCHED, 41 | ALARM_MODE_SEC_MATCHED, 42 | ALARM_MODE_ONCE_PER_SECOND 43 | } AlarmMode; 44 | 45 | typedef enum 46 | { 47 | SUNDAY = 1, 48 | MONDAY, 49 | TUESDAY, 50 | WEDNESDAY, 51 | THURSDAY, 52 | FRIDAY, 53 | SATURDAY 54 | } DaysOfWeek; 55 | 56 | typedef struct 57 | { 58 | uint8_t Year; 59 | uint8_t Month; 60 | uint8_t Date; 61 | uint8_t DaysOfWeek; 62 | uint8_t Hour; 63 | uint8_t Min; 64 | uint8_t Sec; 65 | } _RTC; 66 | 67 | void DS3231_Init(I2C_HandleTypeDef *handle); 68 | bool DS3231_GetTime(_RTC *rtc); 69 | bool DS3231_SetTime(_RTC *rtc); 70 | bool DS3231_ReadTemperature(float *temp); 71 | bool DS3231_SetAlarm1(AlarmMode mode, uint8_t date, uint8_t hour, uint8_t min, uint8_t sec); 72 | bool DS3231_ClearAlarm1(); 73 | bool ReadRegister(uint8_t regAddr, uint8_t *value); 74 | bool WriteRegister(uint8_t regAddr, uint8_t value); 75 | 76 | #endif /* STM32_DS3231_H_ */ 77 | -------------------------------------------------------------------------------- /Src/stm32f4xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : stm32f4xx_hal_msp.c 4 | * Description : This file provides code for the MSP Initialization 5 | * and de-Initialization codes. 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include "stm32f4xx_hal.h" 41 | extern void _Error_Handler(char *, int); 42 | /* USER CODE BEGIN 0 */ 43 | 44 | /* USER CODE END 0 */ 45 | /** 46 | * Initializes the Global MSP. 47 | */ 48 | void HAL_MspInit(void) 49 | { 50 | /* USER CODE BEGIN MspInit 0 */ 51 | 52 | /* USER CODE END MspInit 0 */ 53 | 54 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 55 | __HAL_RCC_PWR_CLK_ENABLE(); 56 | 57 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); 58 | 59 | /* System interrupt init*/ 60 | /* MemoryManagement_IRQn interrupt configuration */ 61 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); 62 | /* BusFault_IRQn interrupt configuration */ 63 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); 64 | /* UsageFault_IRQn interrupt configuration */ 65 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); 66 | /* SVCall_IRQn interrupt configuration */ 67 | HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); 68 | /* DebugMonitor_IRQn interrupt configuration */ 69 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); 70 | /* PendSV_IRQn interrupt configuration */ 71 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); 72 | /* SysTick_IRQn interrupt configuration */ 73 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 74 | 75 | /* USER CODE BEGIN MspInit 1 */ 76 | 77 | /* USER CODE END MspInit 1 */ 78 | } 79 | 80 | void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) 81 | { 82 | 83 | GPIO_InitTypeDef GPIO_InitStruct; 84 | if(hi2c->Instance==I2C1) 85 | { 86 | /* USER CODE BEGIN I2C1_MspInit 0 */ 87 | 88 | /* USER CODE END I2C1_MspInit 0 */ 89 | 90 | /**I2C1 GPIO Configuration 91 | PB8 ------> I2C1_SCL 92 | PB9 ------> I2C1_SDA 93 | */ 94 | GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; 95 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; 96 | GPIO_InitStruct.Pull = GPIO_PULLUP; 97 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 98 | GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; 99 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 100 | 101 | /* Peripheral clock enable */ 102 | __HAL_RCC_I2C1_CLK_ENABLE(); 103 | /* USER CODE BEGIN I2C1_MspInit 1 */ 104 | 105 | /* USER CODE END I2C1_MspInit 1 */ 106 | } 107 | 108 | } 109 | 110 | void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) 111 | { 112 | 113 | if(hi2c->Instance==I2C1) 114 | { 115 | /* USER CODE BEGIN I2C1_MspDeInit 0 */ 116 | 117 | /* USER CODE END I2C1_MspDeInit 0 */ 118 | /* Peripheral clock disable */ 119 | __HAL_RCC_I2C1_CLK_DISABLE(); 120 | 121 | /**I2C1 GPIO Configuration 122 | PB8 ------> I2C1_SCL 123 | PB9 ------> I2C1_SDA 124 | */ 125 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8|GPIO_PIN_9); 126 | 127 | /* USER CODE BEGIN I2C1_MspDeInit 1 */ 128 | 129 | /* USER CODE END I2C1_MspDeInit 1 */ 130 | } 131 | 132 | } 133 | 134 | /* USER CODE BEGIN 1 */ 135 | 136 | /* USER CODE END 1 */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 147 | -------------------------------------------------------------------------------- /Src/stm32f4xx_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_it.c 4 | * @brief Interrupt Service Routines. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2019 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "stm32f4xx_hal.h" 35 | #include "stm32f4xx.h" 36 | #include "stm32f4xx_it.h" 37 | 38 | /* USER CODE BEGIN 0 */ 39 | 40 | /* USER CODE END 0 */ 41 | 42 | /* External variables --------------------------------------------------------*/ 43 | 44 | /******************************************************************************/ 45 | /* Cortex-M4 Processor Interruption and Exception Handlers */ 46 | /******************************************************************************/ 47 | 48 | /** 49 | * @brief This function handles Non maskable interrupt. 50 | */ 51 | void NMI_Handler(void) 52 | { 53 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 54 | 55 | /* USER CODE END NonMaskableInt_IRQn 0 */ 56 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 57 | 58 | /* USER CODE END NonMaskableInt_IRQn 1 */ 59 | } 60 | 61 | /** 62 | * @brief This function handles Hard fault interrupt. 63 | */ 64 | void HardFault_Handler(void) 65 | { 66 | /* USER CODE BEGIN HardFault_IRQn 0 */ 67 | 68 | /* USER CODE END HardFault_IRQn 0 */ 69 | while (1) 70 | { 71 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 72 | /* USER CODE END W1_HardFault_IRQn 0 */ 73 | } 74 | /* USER CODE BEGIN HardFault_IRQn 1 */ 75 | 76 | /* USER CODE END HardFault_IRQn 1 */ 77 | } 78 | 79 | /** 80 | * @brief This function handles Memory management fault. 81 | */ 82 | void MemManage_Handler(void) 83 | { 84 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 85 | 86 | /* USER CODE END MemoryManagement_IRQn 0 */ 87 | while (1) 88 | { 89 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 90 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 91 | } 92 | /* USER CODE BEGIN MemoryManagement_IRQn 1 */ 93 | 94 | /* USER CODE END MemoryManagement_IRQn 1 */ 95 | } 96 | 97 | /** 98 | * @brief This function handles Pre-fetch fault, memory access fault. 99 | */ 100 | void BusFault_Handler(void) 101 | { 102 | /* USER CODE BEGIN BusFault_IRQn 0 */ 103 | 104 | /* USER CODE END BusFault_IRQn 0 */ 105 | while (1) 106 | { 107 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 108 | /* USER CODE END W1_BusFault_IRQn 0 */ 109 | } 110 | /* USER CODE BEGIN BusFault_IRQn 1 */ 111 | 112 | /* USER CODE END BusFault_IRQn 1 */ 113 | } 114 | 115 | /** 116 | * @brief This function handles Undefined instruction or illegal state. 117 | */ 118 | void UsageFault_Handler(void) 119 | { 120 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 121 | 122 | /* USER CODE END UsageFault_IRQn 0 */ 123 | while (1) 124 | { 125 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 126 | /* USER CODE END W1_UsageFault_IRQn 0 */ 127 | } 128 | /* USER CODE BEGIN UsageFault_IRQn 1 */ 129 | 130 | /* USER CODE END UsageFault_IRQn 1 */ 131 | } 132 | 133 | /** 134 | * @brief This function handles System service call via SWI instruction. 135 | */ 136 | void SVC_Handler(void) 137 | { 138 | /* USER CODE BEGIN SVCall_IRQn 0 */ 139 | 140 | /* USER CODE END SVCall_IRQn 0 */ 141 | /* USER CODE BEGIN SVCall_IRQn 1 */ 142 | 143 | /* USER CODE END SVCall_IRQn 1 */ 144 | } 145 | 146 | /** 147 | * @brief This function handles Debug monitor. 148 | */ 149 | void DebugMon_Handler(void) 150 | { 151 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 152 | 153 | /* USER CODE END DebugMonitor_IRQn 0 */ 154 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 155 | 156 | /* USER CODE END DebugMonitor_IRQn 1 */ 157 | } 158 | 159 | /** 160 | * @brief This function handles Pendable request for system service. 161 | */ 162 | void PendSV_Handler(void) 163 | { 164 | /* USER CODE BEGIN PendSV_IRQn 0 */ 165 | 166 | /* USER CODE END PendSV_IRQn 0 */ 167 | /* USER CODE BEGIN PendSV_IRQn 1 */ 168 | 169 | /* USER CODE END PendSV_IRQn 1 */ 170 | } 171 | 172 | /** 173 | * @brief This function handles System tick timer. 174 | */ 175 | void SysTick_Handler(void) 176 | { 177 | /* USER CODE BEGIN SysTick_IRQn 0 */ 178 | 179 | /* USER CODE END SysTick_IRQn 0 */ 180 | HAL_IncTick(); 181 | HAL_SYSTICK_IRQHandler(); 182 | /* USER CODE BEGIN SysTick_IRQn 1 */ 183 | 184 | /* USER CODE END SysTick_IRQn 1 */ 185 | } 186 | 187 | /******************************************************************************/ 188 | /* STM32F4xx Peripheral Interrupt Handlers */ 189 | /* Add here the Interrupt Handlers for the used peripherals. */ 190 | /* For the available peripheral interrupt handler names, */ 191 | /* please refer to the startup file (startup_stm32f4xx.s). */ 192 | /******************************************************************************/ 193 | 194 | /* USER CODE BEGIN 1 */ 195 | 196 | /* USER CODE END 1 */ 197 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 198 | -------------------------------------------------------------------------------- /ds3231.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eziya/STM32_HAL_DS3231/1b916c673ade6d15e3a3caaec1d1f4288e2da768/ds3231.JPG --------------------------------------------------------------------------------