├── Drivers ├── CMSIS │ ├── Include │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── core_cm4.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ └── core_cmSimd.h │ ├── stm32f30x.h │ └── system_stm32f30x.h └── STM32F30x_StdPeriph_Driver │ ├── Release_Notes.html │ ├── inc │ ├── stm32f30x_adc.h │ ├── stm32f30x_can.h │ ├── stm32f30x_comp.h │ ├── stm32f30x_crc.h │ ├── stm32f30x_dac.h │ ├── stm32f30x_dbgmcu.h │ ├── stm32f30x_dma.h │ ├── stm32f30x_exti.h │ ├── stm32f30x_flash.h │ ├── stm32f30x_fmc.h │ ├── stm32f30x_gpio.h │ ├── stm32f30x_hrtim.h │ ├── stm32f30x_i2c.h │ ├── stm32f30x_iwdg.h │ ├── stm32f30x_misc.h │ ├── stm32f30x_opamp.h │ ├── stm32f30x_pwr.h │ ├── stm32f30x_rcc.h │ ├── stm32f30x_rtc.h │ ├── stm32f30x_spi.h │ ├── stm32f30x_syscfg.h │ ├── stm32f30x_tim.h │ ├── stm32f30x_usart.h │ └── stm32f30x_wwdg.h │ └── src │ ├── stm32f30x_adc.c │ ├── stm32f30x_can.c │ ├── stm32f30x_comp.c │ ├── stm32f30x_crc.c │ ├── stm32f30x_dac.c │ ├── stm32f30x_dbgmcu.c │ ├── stm32f30x_dma.c │ ├── stm32f30x_exti.c │ ├── stm32f30x_flash.c │ ├── stm32f30x_fmc.c │ ├── stm32f30x_gpio.c │ ├── stm32f30x_hrtim.c │ ├── stm32f30x_i2c.c │ ├── stm32f30x_iwdg.c │ ├── stm32f30x_misc.c │ ├── stm32f30x_opamp.c │ ├── stm32f30x_pwr.c │ ├── stm32f30x_rcc.c │ ├── stm32f30x_rtc.c │ ├── stm32f30x_spi.c │ ├── stm32f30x_syscfg.c │ ├── stm32f30x_tim.c │ ├── stm32f30x_usart.c │ └── stm32f30x_wwdg.c ├── Image └── debug.png ├── LICENSE ├── MDK-ARM ├── PROFILER.bat ├── PROFILER.uvoptx └── PROFILER.uvprojx ├── README.md └── Src ├── main.c ├── profiling.c ├── profiling.h ├── startup_stm32f303xc.s ├── stm32f30x_conf.h ├── stm32f30x_it.c ├── stm32f30x_it.h └── system_stm32f30x.c /Drivers/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 31. July 2014 5 | * $Revision: V1.4.4 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: 31. July 2014 5 | * $Revision: V1.4.4 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/stm32f30x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Serj-Bashlayev/STM32_Profiler/641f239e0f976ccf938f5eb9c60f15e1a6f4e659/Drivers/CMSIS/stm32f30x.h -------------------------------------------------------------------------------- /Drivers/CMSIS/system_stm32f30x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f30x.h 4 | * @author MCD Application Team 5 | * @version V1.2.2 6 | * @date 27-February-2015 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F30x devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /** @addtogroup CMSIS 29 | * @{ 30 | */ 31 | 32 | /** @addtogroup stm32f30x_system 33 | * @{ 34 | */ 35 | 36 | /** 37 | * @brief Define to prevent recursive inclusion 38 | */ 39 | #ifndef __SYSTEM_STM32F30X_H 40 | #define __SYSTEM_STM32F30X_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Exported types ------------------------------------------------------------*/ 47 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 48 | /* Exported constants --------------------------------------------------------*/ 49 | /* Exported macro ------------------------------------------------------------*/ 50 | /* Exported functions ------------------------------------------------------- */ 51 | 52 | /** @addtogroup STM32F30x_System_Exported_Functions 53 | * @{ 54 | */ 55 | 56 | extern void SystemInit(void); 57 | extern void SystemCoreClockUpdate(void); 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /*__SYSTEM_STM32F30X_H */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 77 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Serj-Bashlayev/STM32_Profiler/641f239e0f976ccf938f5eb9c60f15e1a6f4e659/Drivers/STM32F30x_StdPeriph_Driver/Release_Notes.html -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_crc.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_CRC_H 31 | #define __STM32F30x_CRC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /*!< Includes ----------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup CRC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup CRC_ReverseInputData 52 | * @{ 53 | */ 54 | #define CRC_ReverseInputData_No ((uint32_t)0x00000000) /*!< No reverse operation of Input Data */ 55 | #define CRC_ReverseInputData_8bits CRC_CR_REV_IN_0 /*!< Reverse operation of Input Data on 8 bits */ 56 | #define CRC_ReverseInputData_16bits CRC_CR_REV_IN_1 /*!< Reverse operation of Input Data on 16 bits */ 57 | #define CRC_ReverseInputData_32bits CRC_CR_REV_IN /*!< Reverse operation of Input Data on 32 bits */ 58 | 59 | #define IS_CRC_REVERSE_INPUT_DATA(DATA) (((DATA) == CRC_ReverseInputData_No) || \ 60 | ((DATA) == CRC_ReverseInputData_8bits) || \ 61 | ((DATA) == CRC_ReverseInputData_16bits) || \ 62 | ((DATA) == CRC_ReverseInputData_32bits)) 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup CRC_PolynomialSize 69 | * @{ 70 | */ 71 | #define CRC_PolSize_7 CRC_CR_POLSIZE /*!< 7-bit polynomial for CRC calculation */ 72 | #define CRC_PolSize_8 CRC_CR_POLSIZE_1 /*!< 8-bit polynomial for CRC calculation */ 73 | #define CRC_PolSize_16 CRC_CR_POLSIZE_0 /*!< 16-bit polynomial for CRC calculation */ 74 | #define CRC_PolSize_32 ((uint32_t)0x00000000)/*!< 32-bit polynomial for CRC calculation */ 75 | 76 | #define IS_CRC_POL_SIZE(SIZE) (((SIZE) == CRC_PolSize_7) || \ 77 | ((SIZE) == CRC_PolSize_8) || \ 78 | ((SIZE) == CRC_PolSize_16) || \ 79 | ((SIZE) == CRC_PolSize_32)) 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /* Exported macro ------------------------------------------------------------*/ 86 | /* Exported functions ------------------------------------------------------- */ 87 | /* Configuration of the CRC computation unit **********************************/ 88 | void CRC_DeInit(void); 89 | void CRC_ResetDR(void); 90 | void CRC_PolynomialSizeSelect(uint32_t CRC_PolSize); 91 | void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData); 92 | void CRC_ReverseOutputDataCmd(FunctionalState NewState); 93 | void CRC_SetInitRegister(uint32_t CRC_InitValue); 94 | void CRC_SetPolynomial(uint32_t CRC_Pol); 95 | 96 | /* CRC computation ************************************************************/ 97 | uint32_t CRC_CalcCRC(uint32_t CRC_Data); 98 | uint32_t CRC_CalcCRC16bits(uint16_t CRC_Data); 99 | uint32_t CRC_CalcCRC8bits(uint8_t CRC_Data); 100 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 101 | uint32_t CRC_GetCRC(void); 102 | 103 | /* Independent register (IDR) access (write/read) *****************************/ 104 | void CRC_SetIDRegister(uint8_t CRC_IDValue); 105 | uint8_t CRC_GetIDRegister(void); 106 | 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | 111 | #endif /* __STM32F30x_CRC_H */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 122 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_dac.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_dac.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the DAC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_DAC_H 31 | #define __STM32F30x_DAC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup DAC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | #define DAC_CR_DMAUDRIE ((uint32_t)0x00002000) /*!< DAC channel DMA underrun interrupt enable */ 50 | 51 | /** 52 | * @brief DAC Init structure definition 53 | */ 54 | 55 | typedef struct 56 | { 57 | uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel. 58 | This parameter can be a value of @ref DAC_trigger_selection */ 59 | 60 | uint32_t DAC_WaveGeneration; /*!< Specifies whether DAC channel noise waves or triangle waves 61 | are generated, or whether no wave is generated. 62 | This parameter can be a value of @ref DAC_wave_generation */ 63 | 64 | uint32_t DAC_LFSRUnmask_TriangleAmplitude; /*!< Specifies the LFSR mask for noise wave generation or 65 | the maximum amplitude triangle generation for the DAC channel. 66 | This parameter can be a value of @ref DAC_lfsrunmask_triangleamplitude */ 67 | 68 | uint32_t DAC_Buffer_Switch; /*!< Specifies whether the DAC channel output buffer is enabled or disabled or 69 | the DAC channel output switch is enabled or disabled. 70 | This parameter can be a value of @ref DAC_buffer_switch */ 71 | }DAC_InitTypeDef; 72 | 73 | /* Exported constants --------------------------------------------------------*/ 74 | 75 | /** @defgroup DAC_Exported_Constants 76 | * @{ 77 | */ 78 | 79 | #define IS_DAC_ALL_PERIPH(PERIPH) (((PERIPH) == DAC1) || \ 80 | ((PERIPH) == DAC2)) 81 | 82 | #define IS_DAC_LIST1_PERIPH(PERIPH) (((PERIPH) == DAC1)) 83 | 84 | /** @defgroup DAC_trigger_selection 85 | * @{ 86 | */ 87 | 88 | #define DAC_Trigger_None ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register 89 | has been loaded, and not by external trigger */ 90 | #define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004) /*!< TIM6 TRGO selected as external conversion trigger for DAC1/2 channel1/2 */ 91 | #define DAC_Trigger_T3_TRGO ((uint32_t)0x0000000C) /*!< TIM3 TRGO selected as external conversion trigger for DAC1/2 channel1/2 */ 92 | #define DAC_Trigger_T8_TRGO ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC1 channel1/2 */ 93 | #define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014) /*!< TIM7 TRGO selected as external conversion trigger for DAC1/2 channel1/2 */ 94 | #define DAC_Trigger_T15_TRGO ((uint32_t)0x0000001C) /*!< TIM15 TRGO selected as external conversion trigger for DAC1/2 channel1/2 */ 95 | #define DAC_Trigger_HRTIM1_DACTRG1 ((uint32_t)0x0000001C) /*!< HRTIM1 DACTRG1 selected as external conversion trigger for DAC1 channel1/2 */ 96 | #define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024) /*!< TIM2 TRGO selected as external conversion trigger for DAC1/2 channel1/2 */ 97 | #define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */ 98 | #define DAC_Trigger_HRTIM1_DACTRG2 ((uint32_t)0x0000002C) /*!< HRTIM1 DACTRG2 selected as external conversion trigger for DAC1 channel1/2 */ 99 | #define DAC_Trigger_HRTIM1_DACTRG3 ((uint32_t)0x0000002C) /*!< HRTIM1 DACTRG3 selected as external conversion trigger for DAC2 channel1 */ 100 | #define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) /*!< EXTI Line9 event selected as external conversion trigger for DAC1/2 channel1/2 */ 101 | #define DAC_Trigger_Software ((uint32_t)0x0000003C) /*!< Conversion started by software trigger for DAC1/2 channel1/2 */ 102 | 103 | #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \ 104 | ((TRIGGER) == DAC_Trigger_T6_TRGO) || \ 105 | ((TRIGGER) == DAC_Trigger_T3_TRGO) || \ 106 | ((TRIGGER) == DAC_Trigger_T8_TRGO) || \ 107 | ((TRIGGER) == DAC_Trigger_T7_TRGO) || \ 108 | ((TRIGGER) == DAC_Trigger_T15_TRGO) || \ 109 | ((TRIGGER) == DAC_Trigger_HRTIM1_DACTRG1)|| \ 110 | ((TRIGGER) == DAC_Trigger_T2_TRGO) || \ 111 | ((TRIGGER) == DAC_Trigger_T4_TRGO) || \ 112 | ((TRIGGER) == DAC_Trigger_HRTIM1_DACTRG2)|| \ 113 | ((TRIGGER) == DAC_Trigger_HRTIM1_DACTRG3)|| \ 114 | ((TRIGGER) == DAC_Trigger_Ext_IT9) || \ 115 | ((TRIGGER) == DAC_Trigger_Software)) 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /** @defgroup DAC_wave_generation 122 | * @{ 123 | */ 124 | 125 | #define DAC_WaveGeneration_None ((uint32_t)0x00000000) 126 | #define DAC_WaveGeneration_Noise ((uint32_t)0x00000040) 127 | #define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080) 128 | 129 | #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \ 130 | ((WAVE) == DAC_WaveGeneration_Noise) || \ 131 | ((WAVE) == DAC_WaveGeneration_Triangle)) 132 | /** 133 | * @} 134 | */ 135 | 136 | /** @defgroup DAC_lfsrunmask_triangleamplitude 137 | * @{ 138 | */ 139 | 140 | #define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000) /*!< Unmask DAC channel LFSR bit0 for noise wave generation */ 141 | #define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */ 142 | #define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */ 143 | #define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300) /*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */ 144 | #define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */ 145 | #define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */ 146 | #define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */ 147 | #define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */ 148 | #define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */ 149 | #define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */ 150 | #define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */ 151 | #define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */ 152 | #define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000) /*!< Select max triangle amplitude of 1 */ 153 | #define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100) /*!< Select max triangle amplitude of 3 */ 154 | #define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200) /*!< Select max triangle amplitude of 7 */ 155 | #define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300) /*!< Select max triangle amplitude of 15 */ 156 | #define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400) /*!< Select max triangle amplitude of 31 */ 157 | #define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500) /*!< Select max triangle amplitude of 63 */ 158 | #define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600) /*!< Select max triangle amplitude of 127 */ 159 | #define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700) /*!< Select max triangle amplitude of 255 */ 160 | #define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800) /*!< Select max triangle amplitude of 511 */ 161 | #define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900) /*!< Select max triangle amplitude of 1023 */ 162 | #define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00) /*!< Select max triangle amplitude of 2047 */ 163 | #define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00) /*!< Select max triangle amplitude of 4095 */ 164 | 165 | #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \ 166 | ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \ 167 | ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \ 168 | ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \ 169 | ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \ 170 | ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \ 171 | ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \ 172 | ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \ 173 | ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \ 174 | ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \ 175 | ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \ 176 | ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \ 177 | ((VALUE) == DAC_TriangleAmplitude_1) || \ 178 | ((VALUE) == DAC_TriangleAmplitude_3) || \ 179 | ((VALUE) == DAC_TriangleAmplitude_7) || \ 180 | ((VALUE) == DAC_TriangleAmplitude_15) || \ 181 | ((VALUE) == DAC_TriangleAmplitude_31) || \ 182 | ((VALUE) == DAC_TriangleAmplitude_63) || \ 183 | ((VALUE) == DAC_TriangleAmplitude_127) || \ 184 | ((VALUE) == DAC_TriangleAmplitude_255) || \ 185 | ((VALUE) == DAC_TriangleAmplitude_511) || \ 186 | ((VALUE) == DAC_TriangleAmplitude_1023) || \ 187 | ((VALUE) == DAC_TriangleAmplitude_2047) || \ 188 | ((VALUE) == DAC_TriangleAmplitude_4095)) 189 | /** 190 | * @} 191 | */ 192 | 193 | /** @defgroup DAC_buffer_switch 194 | * @{ 195 | */ 196 | 197 | #define DAC_BufferSwitch_Disable ((uint32_t)0x00000000) 198 | #define DAC_BufferSwitch_Enable ((uint32_t)0x00000002) 199 | 200 | #define IS_DAC_BUFFER_SWITCH_STATE(STATE) (((STATE) == DAC_BufferSwitch_Enable) || \ 201 | ((STATE) == DAC_BufferSwitch_Disable)) 202 | /** 203 | * @} 204 | */ 205 | 206 | /** @defgroup DAC_Channel_selection 207 | * @{ 208 | */ 209 | #define DAC_Channel_1 ((uint32_t)0x00000000) 210 | #define DAC_Channel_2 ((uint32_t)0x00000010) 211 | 212 | #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \ 213 | ((CHANNEL) == DAC_Channel_2)) 214 | /** 215 | * @} 216 | */ 217 | 218 | /** @defgroup DAC_data_alignement 219 | * @{ 220 | */ 221 | 222 | #define DAC_Align_12b_R ((uint32_t)0x00000000) 223 | #define DAC_Align_12b_L ((uint32_t)0x00000004) 224 | #define DAC_Align_8b_R ((uint32_t)0x00000008) 225 | 226 | #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \ 227 | ((ALIGN) == DAC_Align_12b_L) || \ 228 | ((ALIGN) == DAC_Align_8b_R)) 229 | /** 230 | * @} 231 | */ 232 | 233 | /** @defgroup DAC_wave_generation 234 | * @{ 235 | */ 236 | 237 | #define DAC_Wave_Noise ((uint32_t)0x00000040) 238 | #define DAC_Wave_Triangle ((uint32_t)0x00000080) 239 | 240 | #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \ 241 | ((WAVE) == DAC_Wave_Triangle)) 242 | /** 243 | * @} 244 | */ 245 | 246 | /** @defgroup DAC_data 247 | * @{ 248 | */ 249 | 250 | #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) 251 | /** 252 | * @} 253 | */ 254 | 255 | /** @defgroup DAC_interrupts_definition 256 | * @{ 257 | */ 258 | #define DAC_IT_DMAUDR ((uint32_t)0x00002000) 259 | #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR)) 260 | 261 | /** 262 | * @} 263 | */ 264 | 265 | /** @defgroup DAC_flags_definition 266 | * @{ 267 | */ 268 | 269 | #define DAC_FLAG_DMAUDR ((uint32_t)0x00002000) 270 | #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR)) 271 | 272 | /** 273 | * @} 274 | */ 275 | 276 | /** 277 | * @} 278 | */ 279 | 280 | /* Exported macro ------------------------------------------------------------*/ 281 | /* Exported functions --------------------------------------------------------*/ 282 | 283 | /* Function used to set the DAC configuration to the default reset state *****/ 284 | void DAC_DeInit(DAC_TypeDef* DACx); 285 | 286 | /* DAC channels configuration: trigger, output buffer, data format functions */ 287 | void DAC_Init(DAC_TypeDef* DACx, uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct); 288 | void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct); 289 | void DAC_Cmd(DAC_TypeDef* DACx, uint32_t DAC_Channel, FunctionalState NewState); 290 | void DAC_SoftwareTriggerCmd(DAC_TypeDef* DACx, uint32_t DAC_Channel, FunctionalState NewState); 291 | void DAC_DualSoftwareTriggerCmd(DAC_TypeDef* DACx, FunctionalState NewState); 292 | void DAC_WaveGenerationCmd(DAC_TypeDef* DACx, uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState); 293 | void DAC_SetChannel1Data(DAC_TypeDef* DACx, uint32_t DAC_Align, uint16_t Data); 294 | void DAC_SetChannel2Data(DAC_TypeDef* DACx, uint32_t DAC_Align, uint16_t Data); 295 | void DAC_SetDualChannelData(DAC_TypeDef* DACx, uint32_t DAC_Align, uint16_t Data2, uint16_t Data1); 296 | uint16_t DAC_GetDataOutputValue(DAC_TypeDef* DACx, uint32_t DAC_Channel); 297 | 298 | /* DMA management functions ***************************************************/ 299 | void DAC_DMACmd(DAC_TypeDef* DACx, uint32_t DAC_Channel, FunctionalState NewState); 300 | 301 | /* Interrupts and flags management functions **********************************/ 302 | void DAC_ITConfig(DAC_TypeDef* DACx, uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState); 303 | FlagStatus DAC_GetFlagStatus(DAC_TypeDef* DACx, uint32_t DAC_Channel, uint32_t DAC_FLAG); 304 | void DAC_ClearFlag(DAC_TypeDef* DACx, uint32_t DAC_Channel, uint32_t DAC_FLAG); 305 | ITStatus DAC_GetITStatus(DAC_TypeDef* DACx, uint32_t DAC_Channel, uint32_t DAC_IT); 306 | void DAC_ClearITPendingBit(DAC_TypeDef* DACx, uint32_t DAC_Channel, uint32_t DAC_IT); 307 | 308 | #ifdef __cplusplus 309 | } 310 | #endif 311 | 312 | #endif /*__STM32F30x_DAC_H */ 313 | 314 | /** 315 | * @} 316 | */ 317 | 318 | /** 319 | * @} 320 | */ 321 | 322 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 323 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware library. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F30x_DBGMCU_H 30 | #define __STM32F30x_DBGMCU_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "stm32f30x.h" 38 | 39 | /** @addtogroup STM32F30x_StdPeriph_Driver 40 | * @{ 41 | */ 42 | 43 | /** @addtogroup DBGMCU 44 | * @{ 45 | */ 46 | 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 54 | #define DBGMCU_STOP ((uint32_t)0x00000002) 55 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 56 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF8) == 0x00) && ((PERIPH) != 0x00)) 57 | 58 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000001) 59 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00000002) 60 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00000004) 61 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00000010) 62 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00000020) 63 | #define DBGMCU_RTC_STOP ((uint32_t)0x00000400) 64 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000800) 65 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00001000) 66 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00200000) 67 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00400000) 68 | #define DBGMCU_CAN1_STOP ((uint32_t)0x02000000) 69 | #define DBGMCU_I2C3_SMBUS_TIMEOUT ((uint32_t)0x40000000) 70 | 71 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xBD9FE3C8) == 0x00) && ((PERIPH) != 0x00)) 72 | 73 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000001) 74 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00000002) 75 | #define DBGMCU_TIM15_STOP ((uint32_t)0x00000004) 76 | #define DBGMCU_TIM16_STOP ((uint32_t)0x00000008) 77 | #define DBGMCU_TIM17_STOP ((uint32_t)0x00000010) 78 | #define DBGMCU_TIM20_STOP ((uint32_t)0x00000020) 79 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFC0) == 0x00) && ((PERIPH) != 0x00)) 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /* Exported macro ------------------------------------------------------------*/ 86 | /* Exported functions --------------------------------------------------------*/ 87 | /* Device and Revision ID management functions ********************************/ 88 | uint32_t DBGMCU_GetREVID(void); 89 | uint32_t DBGMCU_GetDEVID(void); 90 | 91 | /* Peripherals Configuration functions ****************************************/ 92 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 93 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 94 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* __STM32F30x_DBGMCU_H */ 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 111 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_exti.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_exti.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the EXTI 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_EXTI_H 31 | #define __STM32F30x_EXTI_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup EXTI 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | 50 | /** 51 | * @brief EXTI mode enumeration 52 | */ 53 | 54 | typedef enum 55 | { 56 | EXTI_Mode_Interrupt = 0x00, 57 | EXTI_Mode_Event = 0x04 58 | }EXTIMode_TypeDef; 59 | 60 | #define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event)) 61 | 62 | /** 63 | * @brief EXTI Trigger enumeration 64 | */ 65 | 66 | typedef enum 67 | { 68 | EXTI_Trigger_Rising = 0x08, 69 | EXTI_Trigger_Falling = 0x0C, 70 | EXTI_Trigger_Rising_Falling = 0x10 71 | }EXTITrigger_TypeDef; 72 | 73 | #define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \ 74 | ((TRIGGER) == EXTI_Trigger_Falling) || \ 75 | ((TRIGGER) == EXTI_Trigger_Rising_Falling)) 76 | /** 77 | * @brief EXTI Init Structure definition 78 | */ 79 | 80 | typedef struct 81 | { 82 | uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled. 83 | This parameter can be any combination of @ref EXTI_Lines */ 84 | 85 | EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines. 86 | This parameter can be a value of @ref EXTIMode_TypeDef */ 87 | 88 | EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines. 89 | This parameter can be a value of @ref EXTITrigger_TypeDef */ 90 | 91 | FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines. 92 | This parameter can be set either to ENABLE or DISABLE */ 93 | }EXTI_InitTypeDef; 94 | 95 | /* Exported constants --------------------------------------------------------*/ 96 | 97 | /** @defgroup EXTI_Exported_Constants 98 | * @{ 99 | */ 100 | /** @defgroup EXTI_Lines 101 | * @{ 102 | */ 103 | 104 | #define EXTI_Line0 ((uint32_t)0x00) /*!< External interrupt line 0 */ 105 | #define EXTI_Line1 ((uint32_t)0x01) /*!< External interrupt line 1 */ 106 | #define EXTI_Line2 ((uint32_t)0x02) /*!< External interrupt line 2 */ 107 | #define EXTI_Line3 ((uint32_t)0x03) /*!< External interrupt line 3 */ 108 | #define EXTI_Line4 ((uint32_t)0x04) /*!< External interrupt line 4 */ 109 | #define EXTI_Line5 ((uint32_t)0x05) /*!< External interrupt line 5 */ 110 | #define EXTI_Line6 ((uint32_t)0x06) /*!< External interrupt line 6 */ 111 | #define EXTI_Line7 ((uint32_t)0x07) /*!< External interrupt line 7 */ 112 | #define EXTI_Line8 ((uint32_t)0x08) /*!< External interrupt line 8 */ 113 | #define EXTI_Line9 ((uint32_t)0x09) /*!< External interrupt line 9 */ 114 | #define EXTI_Line10 ((uint32_t)0x0A) /*!< External interrupt line 10 */ 115 | #define EXTI_Line11 ((uint32_t)0x0B) /*!< External interrupt line 11 */ 116 | #define EXTI_Line12 ((uint32_t)0x0C) /*!< External interrupt line 12 */ 117 | #define EXTI_Line13 ((uint32_t)0x0D) /*!< External interrupt line 13 */ 118 | #define EXTI_Line14 ((uint32_t)0x0E) /*!< External interrupt line 14 */ 119 | #define EXTI_Line15 ((uint32_t)0x0F) /*!< External interrupt line 15 */ 120 | #define EXTI_Line16 ((uint32_t)0x10) /*!< External interrupt line 16 121 | Connected to the PVD Output */ 122 | #define EXTI_Line17 ((uint32_t)0x11) /*!< Internal interrupt line 17 123 | Connected to the RTC Alarm 124 | event */ 125 | #define EXTI_Line18 ((uint32_t)0x12) /*!< Internal interrupt line 18 126 | Connected to the USB Device 127 | Wakeup from suspend event */ 128 | #define EXTI_Line19 ((uint32_t)0x13) /*!< Internal interrupt line 19 129 | Connected to the RTC Tamper 130 | and Time Stamp events */ 131 | #define EXTI_Line20 ((uint32_t)0x14) /*!< Internal interrupt line 20 132 | Connected to the RTC wakeup 133 | event */ 134 | #define EXTI_Line21 ((uint32_t)0x15) /*!< Internal interrupt line 21 135 | Connected to the Comparator 1 136 | event */ 137 | #define EXTI_Line22 ((uint32_t)0x16) /*!< Internal interrupt line 22 138 | Connected to the Comparator 2 139 | event */ 140 | #define EXTI_Line23 ((uint32_t)0x17) /*!< Internal interrupt line 23 141 | Connected to the I2C1 wakeup 142 | event */ 143 | #define EXTI_Line24 ((uint32_t)0x18) /*!< Internal interrupt line 24 144 | Connected to the I2C2 wakeup 145 | event */ 146 | #define EXTI_Line25 ((uint32_t)0x19) /*!< Internal interrupt line 25 147 | Connected to the USART1 wakeup 148 | event */ 149 | #define EXTI_Line26 ((uint32_t)0x1A) /*!< Internal interrupt line 26 150 | Connected to the USART2 wakeup 151 | event */ 152 | #define EXTI_Line27 ((uint32_t)0x1B) /*!< Internal interrupt line 27 153 | reserved */ 154 | #define EXTI_Line28 ((uint32_t)0x1C) /*!< Internal interrupt line 28 155 | Connected to the USART3 wakeup 156 | event */ 157 | #define EXTI_Line29 ((uint32_t)0x1D) /*!< Internal interrupt line 29 158 | Connected to the Comparator 3 159 | event */ 160 | #define EXTI_Line30 ((uint32_t)0x1E) /*!< Internal interrupt line 30 161 | Connected to the Comparator 4 162 | event */ 163 | #define EXTI_Line31 ((uint32_t)0x1F) /*!< Internal interrupt line 31 164 | Connected to the Comparator 5 165 | event */ 166 | #define EXTI_Line32 ((uint32_t)0x20) /*!< Internal interrupt line 32 167 | Connected to the Comparator 6 168 | event */ 169 | #define EXTI_Line33 ((uint32_t)0x21) /*!< Internal interrupt line 33 170 | Connected to the Comparator 7 171 | event */ 172 | #define EXTI_Line34 ((uint32_t)0x22) /*!< Internal interrupt line 34 173 | Connected to the USART4 wakeup 174 | event */ 175 | #define EXTI_Line35 ((uint32_t)0x23) /*!< Internal interrupt line 35 176 | Connected to the USART5 wakeup 177 | event */ 178 | 179 | #define IS_EXTI_LINE_ALL(LINE) ((LINE) <= 0x23) 180 | #define IS_EXTI_LINE_EXT(LINE) (((LINE) <= 0x16) || (((LINE) == EXTI_Line29) || ((LINE) == EXTI_Line30) || \ 181 | ((LINE) == EXTI_Line31) || ((LINE) == EXTI_Line32) || ((LINE) == EXTI_Line33))) 182 | 183 | #define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \ 184 | ((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \ 185 | ((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \ 186 | ((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \ 187 | ((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \ 188 | ((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \ 189 | ((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \ 190 | ((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \ 191 | ((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \ 192 | ((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19) || \ 193 | ((LINE) == EXTI_Line20) || ((LINE) == EXTI_Line21) || \ 194 | ((LINE) == EXTI_Line22) || ((LINE) == EXTI_Line29) || \ 195 | ((LINE) == EXTI_Line30) || ((LINE) == EXTI_Line31) || \ 196 | ((LINE) == EXTI_Line32) || ((LINE) == EXTI_Line33)) 197 | /** 198 | * @} 199 | */ 200 | 201 | /** 202 | * @} 203 | */ 204 | 205 | /* Exported macro ------------------------------------------------------------*/ 206 | /* Exported functions ------------------------------------------------------- */ 207 | /* Function used to set the EXTI configuration to the default reset state *****/ 208 | void EXTI_DeInit(void); 209 | 210 | /* Initialization and Configuration functions *********************************/ 211 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); 212 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct); 213 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line); 214 | 215 | /* Interrupts and flags management functions **********************************/ 216 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line); 217 | void EXTI_ClearFlag(uint32_t EXTI_Line); 218 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line); 219 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line); 220 | 221 | #ifdef __cplusplus 222 | } 223 | #endif 224 | 225 | #endif /* __STM32F30x_EXTI_H */ 226 | /** 227 | * @} 228 | */ 229 | 230 | /** 231 | * @} 232 | */ 233 | 234 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 235 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_flash.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the FLASH 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_FLASH_H 31 | #define __STM32F30x_FLASH_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup FLASH 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /** 50 | * @brief FLASH Status 51 | */ 52 | typedef enum 53 | { 54 | FLASH_BUSY = 1, 55 | FLASH_ERROR_WRP, 56 | FLASH_ERROR_PROGRAM, 57 | FLASH_COMPLETE, 58 | FLASH_TIMEOUT 59 | }FLASH_Status; 60 | 61 | /* Exported constants --------------------------------------------------------*/ 62 | 63 | /** @defgroup FLASH_Exported_Constants 64 | * @{ 65 | */ 66 | 67 | /** @defgroup Flash_Latency 68 | * @{ 69 | */ 70 | #define FLASH_Latency_0 ((uint8_t)0x0000) /*!< FLASH Zero Latency cycle */ 71 | #define FLASH_Latency_1 FLASH_ACR_LATENCY_0 /*!< FLASH One Latency cycle */ 72 | #define FLASH_Latency_2 FLASH_ACR_LATENCY_1 /*!< FLASH Two Latency cycles */ 73 | 74 | #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \ 75 | ((LATENCY) == FLASH_Latency_1) || \ 76 | ((LATENCY) == FLASH_Latency_2)) 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup FLASH_Interrupts 82 | * @{ 83 | */ 84 | 85 | #define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of programming interrupt source */ 86 | #define FLASH_IT_ERR FLASH_CR_ERRIE /*!< Error interrupt source */ 87 | #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000))) 88 | /** 89 | * @} 90 | */ 91 | /** @defgroup FLASH_Address 92 | * @{ 93 | */ 94 | 95 | #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0803FFFF)) 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @defgroup FLASH_OB_DATA_ADDRESS 102 | * @{ 103 | */ 104 | #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806)) 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** @defgroup Option_Bytes_Write_Protection 111 | * @{ 112 | */ 113 | 114 | #define OB_WRP_Pages0to1 ((uint32_t)0x00000001) /* Write protection of page 0 to 1 */ 115 | #define OB_WRP_Pages2to3 ((uint32_t)0x00000002) /* Write protection of page 2 to 3 */ 116 | #define OB_WRP_Pages4to5 ((uint32_t)0x00000004) /* Write protection of page 4 to 5 */ 117 | #define OB_WRP_Pages6to7 ((uint32_t)0x00000008) /* Write protection of page 6 to 7 */ 118 | #define OB_WRP_Pages8to9 ((uint32_t)0x00000010) /* Write protection of page 8 to 9 */ 119 | #define OB_WRP_Pages10to11 ((uint32_t)0x00000020) /* Write protection of page 10 to 11 */ 120 | #define OB_WRP_Pages12to13 ((uint32_t)0x00000040) /* Write protection of page 12 to 13 */ 121 | #define OB_WRP_Pages14to15 ((uint32_t)0x00000080) /* Write protection of page 14 to 15 */ 122 | #define OB_WRP_Pages16to17 ((uint32_t)0x00000100) /* Write protection of page 16 to 17 */ 123 | #define OB_WRP_Pages18to19 ((uint32_t)0x00000200) /* Write protection of page 18 to 19 */ 124 | #define OB_WRP_Pages20to21 ((uint32_t)0x00000400) /* Write protection of page 20 to 21 */ 125 | #define OB_WRP_Pages22to23 ((uint32_t)0x00000800) /* Write protection of page 22 to 23 */ 126 | #define OB_WRP_Pages24to25 ((uint32_t)0x00001000) /* Write protection of page 24 to 25 */ 127 | #define OB_WRP_Pages26to27 ((uint32_t)0x00002000) /* Write protection of page 26 to 27 */ 128 | #define OB_WRP_Pages28to29 ((uint32_t)0x00004000) /* Write protection of page 28 to 29 */ 129 | #define OB_WRP_Pages30to31 ((uint32_t)0x00008000) /* Write protection of page 30 to 31 */ 130 | #define OB_WRP_Pages32to33 ((uint32_t)0x00010000) /* Write protection of page 32 to 33 */ 131 | #define OB_WRP_Pages34to35 ((uint32_t)0x00020000) /* Write protection of page 34 to 35 */ 132 | #define OB_WRP_Pages36to37 ((uint32_t)0x00040000) /* Write protection of page 36 to 37 */ 133 | #define OB_WRP_Pages38to39 ((uint32_t)0x00080000) /* Write protection of page 38 to 39 */ 134 | #define OB_WRP_Pages40to41 ((uint32_t)0x00100000) /* Write protection of page 40 to 41 */ 135 | #define OB_WRP_Pages42to43 ((uint32_t)0x00200000) /* Write protection of page 42 to 43 */ 136 | #define OB_WRP_Pages44to45 ((uint32_t)0x00400000) /* Write protection of page 44 to 45 */ 137 | #define OB_WRP_Pages46to47 ((uint32_t)0x00800000) /* Write protection of page 46 to 47 */ 138 | #define OB_WRP_Pages48to49 ((uint32_t)0x01000000) /* Write protection of page 48 to 49 */ 139 | #define OB_WRP_Pages50to51 ((uint32_t)0x02000000) /* Write protection of page 50 to 51 */ 140 | #define OB_WRP_Pages52to53 ((uint32_t)0x04000000) /* Write protection of page 52 to 53 */ 141 | #define OB_WRP_Pages54to55 ((uint32_t)0x08000000) /* Write protection of page 54 to 55 */ 142 | #define OB_WRP_Pages56to57 ((uint32_t)0x10000000) /* Write protection of page 56 to 57 */ 143 | #define OB_WRP_Pages58to59 ((uint32_t)0x20000000) /* Write protection of page 58 to 59 */ 144 | #define OB_WRP_Pages60to61 ((uint32_t)0x40000000) /* Write protection of page 60 to 61 */ 145 | 146 | #ifdef STM32F303xE 147 | #define OB_WRP_Pages62to263 ((uint32_t)0x80000000) /* Write protection of page 62 to 263 */ 148 | #else 149 | #define OB_WRP_Pages62to127 ((uint32_t)0x80000000) /* Write protection of page 62 to 127 */ 150 | #endif /* STM32F303xE */ 151 | 152 | #define OB_WRP_AllPages ((uint32_t)0xFFFFFFFF) /*!< Write protection of all Sectors */ 153 | 154 | #define IS_OB_WRP(PAGE) (((PAGE) != 0x0000000)) 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /** @defgroup Option_Bytes_Read_Protection 161 | * @{ 162 | */ 163 | 164 | /** 165 | * @brief Read Protection Level 166 | */ 167 | #define OB_RDP_Level_0 ((uint8_t)0xAA) 168 | #define OB_RDP_Level_1 ((uint8_t)0xBB) 169 | /*#define OB_RDP_Level_2 ((uint8_t)0xCC)*/ /* Warning: When enabling read protection level 2 170 | it's no more possible to go back to level 1 or 0 */ 171 | 172 | #define IS_OB_RDP(LEVEL) (((LEVEL) == OB_RDP_Level_0)||\ 173 | ((LEVEL) == OB_RDP_Level_1))/*||\ 174 | ((LEVEL) == OB_RDP_Level_2))*/ 175 | /** 176 | * @} 177 | */ 178 | 179 | /** @defgroup Option_Bytes_IWatchdog 180 | * @{ 181 | */ 182 | 183 | #define OB_IWDG_SW ((uint8_t)0x01) /*!< Software IWDG selected */ 184 | #define OB_IWDG_HW ((uint8_t)0x00) /*!< Hardware IWDG selected */ 185 | #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW)) 186 | 187 | /** 188 | * @} 189 | */ 190 | 191 | /** @defgroup Option_Bytes_nRST_STOP 192 | * @{ 193 | */ 194 | 195 | #define OB_STOP_NoRST ((uint8_t)0x02) /*!< No reset generated when entering in STOP */ 196 | #define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */ 197 | #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST)) 198 | 199 | /** 200 | * @} 201 | */ 202 | 203 | /** @defgroup Option_Bytes_nRST_STDBY 204 | * @{ 205 | */ 206 | 207 | #define OB_STDBY_NoRST ((uint8_t)0x04) /*!< No reset generated when entering in STANDBY */ 208 | #define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */ 209 | #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST)) 210 | 211 | /** 212 | * @} 213 | */ 214 | /** @defgroup Option_Bytes_BOOT1 215 | * @{ 216 | */ 217 | 218 | #define OB_BOOT1_RESET ((uint8_t)0x00) /*!< BOOT1 Reset */ 219 | #define OB_BOOT1_SET ((uint8_t)0x10) /*!< BOOT1 Set */ 220 | #define IS_OB_BOOT1(BOOT1) (((BOOT1) == OB_BOOT1_RESET) || ((BOOT1) == OB_BOOT1_SET)) 221 | 222 | /** 223 | * @} 224 | */ 225 | /** @defgroup Option_Bytes_VDDA_Analog_Monitoring 226 | * @{ 227 | */ 228 | 229 | #define OB_VDDA_ANALOG_ON ((uint8_t)0x20) /*!< Analog monitoring on VDDA Power source ON */ 230 | #define OB_VDDA_ANALOG_OFF ((uint8_t)0x00) /*!< Analog monitoring on VDDA Power source OFF */ 231 | 232 | #define IS_OB_VDDA_ANALOG(ANALOG) (((ANALOG) == OB_VDDA_ANALOG_ON) || ((ANALOG) == OB_VDDA_ANALOG_OFF)) 233 | 234 | /** 235 | * @} 236 | */ 237 | 238 | /** @defgroup FLASH_Option_Bytes_SRAM_Parity_Enable 239 | * @{ 240 | */ 241 | 242 | #define OB_SRAM_PARITY_SET ((uint8_t)0x00) /*!< SRAM parity enable Set */ 243 | #define OB_SRAM_PARITY_RESET ((uint8_t)0x40) /*!< SRAM parity enable reset */ 244 | 245 | #define IS_OB_SRAM_PARITY(PARITY) (((PARITY) == OB_SRAM_PARITY_SET) || ((PARITY) == OB_SRAM_PARITY_RESET)) 246 | 247 | /** 248 | * @} 249 | */ 250 | 251 | /** @defgroup FLASH_Flags 252 | * @{ 253 | */ 254 | 255 | #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */ 256 | #define FLASH_FLAG_PGERR FLASH_SR_PGERR /*!< FLASH Programming error flag */ 257 | #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */ 258 | #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Programming flag */ 259 | 260 | #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFCB) == 0x00000000) && ((FLAG) != 0x00000000)) 261 | 262 | #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_PGERR) || \ 263 | ((FLAG) == FLASH_FLAG_WRPERR) || ((FLAG) == FLASH_FLAG_EOP)) 264 | /** 265 | * @} 266 | */ 267 | /** @defgroup Timeout_definition 268 | * @{ 269 | */ 270 | #define FLASH_ER_PRG_TIMEOUT ((uint32_t)0x000B0000) 271 | 272 | /** 273 | * @} 274 | */ 275 | 276 | /** 277 | * @} 278 | */ 279 | 280 | /* Exported macro ------------------------------------------------------------*/ 281 | /* Exported functions --------------------------------------------------------*/ 282 | 283 | /* FLASH Interface configuration functions ************************************/ 284 | void FLASH_SetLatency(uint32_t FLASH_Latency); 285 | void FLASH_HalfCycleAccessCmd(FunctionalState NewState); 286 | void FLASH_PrefetchBufferCmd(FunctionalState NewState); 287 | 288 | /* FLASH Memory Programming functions *****************************************/ 289 | void FLASH_Unlock(void); 290 | void FLASH_Lock(void); 291 | FLASH_Status FLASH_ErasePage(uint32_t Page_Address); 292 | FLASH_Status FLASH_EraseAllPages(void); 293 | FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data); 294 | FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data); 295 | 296 | /* Option Bytes Programming functions *****************************************/ 297 | void FLASH_OB_Unlock(void); 298 | void FLASH_OB_Lock(void); 299 | void FLASH_OB_Launch(void); 300 | FLASH_Status FLASH_OB_Erase(void); 301 | FLASH_Status FLASH_OB_EnableWRP(uint32_t OB_WRP); 302 | FLASH_Status FLASH_OB_RDPConfig(uint8_t OB_RDP); 303 | FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY); 304 | FLASH_Status FLASH_OB_BOOTConfig(uint8_t OB_BOOT1); 305 | FLASH_Status FLASH_OB_VDDAConfig(uint8_t OB_VDDA_ANALOG); 306 | FLASH_Status FLASH_OB_SRAMParityConfig(uint8_t OB_SRAM_Parity); 307 | FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER); 308 | FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data); 309 | uint8_t FLASH_OB_GetUser(void); 310 | uint32_t FLASH_OB_GetWRP(void); 311 | FlagStatus FLASH_OB_GetRDP(void); 312 | 313 | /* Interrupts and flags management functions **********************************/ 314 | void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState); 315 | FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG); 316 | void FLASH_ClearFlag(uint32_t FLASH_FLAG); 317 | FLASH_Status FLASH_GetStatus(void); 318 | FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout); 319 | 320 | #ifdef __cplusplus 321 | } 322 | #endif 323 | 324 | #endif /* __STM32F30x_FLASH_H */ 325 | 326 | /** 327 | * @} 328 | */ 329 | 330 | /** 331 | * @} 332 | */ 333 | 334 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 335 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_gpio.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the GPIO 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_GPIO_H 31 | #define __STM32F30x_GPIO_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup GPIO 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | 50 | #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \ 51 | ((PERIPH) == GPIOB) || \ 52 | ((PERIPH) == GPIOC) || \ 53 | ((PERIPH) == GPIOD) || \ 54 | ((PERIPH) == GPIOE) || \ 55 | ((PERIPH) == GPIOF) || \ 56 | ((PERIPH) == GPIOG) || \ 57 | ((PERIPH) == GPIOH)) 58 | 59 | #define IS_GPIO_LIST_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \ 60 | ((PERIPH) == GPIOB) || \ 61 | ((PERIPH) == GPIOC)|| \ 62 | ((PERIPH) == GPIOD) || \ 63 | ((PERIPH) == GPIOF)) 64 | /** @defgroup Configuration_Mode_enumeration 65 | * @{ 66 | */ 67 | typedef enum 68 | { 69 | GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */ 70 | GPIO_Mode_OUT = 0x01, /*!< GPIO Output Mode */ 71 | GPIO_Mode_AF = 0x02, /*!< GPIO Alternate function Mode */ 72 | GPIO_Mode_AN = 0x03 /*!< GPIO Analog In/Out Mode */ 73 | }GPIOMode_TypeDef; 74 | 75 | #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN)|| ((MODE) == GPIO_Mode_OUT) || \ 76 | ((MODE) == GPIO_Mode_AF)|| ((MODE) == GPIO_Mode_AN)) 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup Output_type_enumeration 82 | * @{ 83 | */ 84 | typedef enum 85 | { 86 | GPIO_OType_PP = 0x00, 87 | GPIO_OType_OD = 0x01 88 | }GPIOOType_TypeDef; 89 | 90 | #define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD)) 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** @defgroup Output_Maximum_frequency_enumeration 97 | * @{ 98 | */ 99 | typedef enum 100 | { 101 | GPIO_Speed_Level_1 = 0x01, /*!< Fast Speed */ 102 | GPIO_Speed_Level_2 = 0x02, /*!< Meduim Speed */ 103 | GPIO_Speed_Level_3 = 0x03 /*!< High Speed */ 104 | }GPIOSpeed_TypeDef; 105 | 106 | #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_Level_1) || ((SPEED) == GPIO_Speed_Level_2) || \ 107 | ((SPEED) == GPIO_Speed_Level_3)) 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup Configuration_Pull-Up_Pull-Down_enumeration 113 | * @{ 114 | */ 115 | typedef enum 116 | { 117 | GPIO_PuPd_NOPULL = 0x00, 118 | GPIO_PuPd_UP = 0x01, 119 | GPIO_PuPd_DOWN = 0x02 120 | }GPIOPuPd_TypeDef; 121 | 122 | #define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \ 123 | ((PUPD) == GPIO_PuPd_DOWN)) 124 | /** 125 | * @} 126 | */ 127 | 128 | /** @defgroup Bit_SET_and_Bit_RESET_enumeration 129 | * @{ 130 | */ 131 | typedef enum 132 | { 133 | Bit_RESET = 0, 134 | Bit_SET 135 | }BitAction; 136 | 137 | #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET)) 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @brief GPIO Init structure definition 144 | */ 145 | typedef struct 146 | { 147 | uint32_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured. 148 | This parameter can be any value of @ref GPIO_pins_define */ 149 | 150 | GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins. 151 | This parameter can be a value of @ref GPIOMode_TypeDef */ 152 | 153 | GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins. 154 | This parameter can be a value of @ref GPIOSpeed_TypeDef */ 155 | 156 | GPIOOType_TypeDef GPIO_OType; /*!< Specifies the operating output type for the selected pins. 157 | This parameter can be a value of @ref GPIOOType_TypeDef */ 158 | 159 | GPIOPuPd_TypeDef GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins. 160 | This parameter can be a value of @ref GPIOPuPd_TypeDef */ 161 | }GPIO_InitTypeDef; 162 | 163 | /* Exported constants --------------------------------------------------------*/ 164 | 165 | /** @defgroup GPIO_Exported_Constants 166 | * @{ 167 | */ 168 | 169 | /** @defgroup GPIO_pins_define 170 | * @{ 171 | */ 172 | #define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */ 173 | #define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */ 174 | #define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */ 175 | #define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */ 176 | #define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */ 177 | #define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */ 178 | #define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */ 179 | #define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */ 180 | #define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */ 181 | #define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */ 182 | #define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */ 183 | #define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */ 184 | #define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */ 185 | #define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */ 186 | #define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */ 187 | #define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */ 188 | #define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */ 189 | 190 | #define IS_GPIO_PIN(PIN) ((PIN) != (uint16_t)0x00) 191 | 192 | #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \ 193 | ((PIN) == GPIO_Pin_1) || \ 194 | ((PIN) == GPIO_Pin_2) || \ 195 | ((PIN) == GPIO_Pin_3) || \ 196 | ((PIN) == GPIO_Pin_4) || \ 197 | ((PIN) == GPIO_Pin_5) || \ 198 | ((PIN) == GPIO_Pin_6) || \ 199 | ((PIN) == GPIO_Pin_7) || \ 200 | ((PIN) == GPIO_Pin_8) || \ 201 | ((PIN) == GPIO_Pin_9) || \ 202 | ((PIN) == GPIO_Pin_10) || \ 203 | ((PIN) == GPIO_Pin_11) || \ 204 | ((PIN) == GPIO_Pin_12) || \ 205 | ((PIN) == GPIO_Pin_13) || \ 206 | ((PIN) == GPIO_Pin_14) || \ 207 | ((PIN) == GPIO_Pin_15)) 208 | 209 | /** 210 | * @} 211 | */ 212 | 213 | /** @defgroup GPIO_Pin_sources 214 | * @{ 215 | */ 216 | #define GPIO_PinSource0 ((uint8_t)0x00) 217 | #define GPIO_PinSource1 ((uint8_t)0x01) 218 | #define GPIO_PinSource2 ((uint8_t)0x02) 219 | #define GPIO_PinSource3 ((uint8_t)0x03) 220 | #define GPIO_PinSource4 ((uint8_t)0x04) 221 | #define GPIO_PinSource5 ((uint8_t)0x05) 222 | #define GPIO_PinSource6 ((uint8_t)0x06) 223 | #define GPIO_PinSource7 ((uint8_t)0x07) 224 | #define GPIO_PinSource8 ((uint8_t)0x08) 225 | #define GPIO_PinSource9 ((uint8_t)0x09) 226 | #define GPIO_PinSource10 ((uint8_t)0x0A) 227 | #define GPIO_PinSource11 ((uint8_t)0x0B) 228 | #define GPIO_PinSource12 ((uint8_t)0x0C) 229 | #define GPIO_PinSource13 ((uint8_t)0x0D) 230 | #define GPIO_PinSource14 ((uint8_t)0x0E) 231 | #define GPIO_PinSource15 ((uint8_t)0x0F) 232 | 233 | #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \ 234 | ((PINSOURCE) == GPIO_PinSource1) || \ 235 | ((PINSOURCE) == GPIO_PinSource2) || \ 236 | ((PINSOURCE) == GPIO_PinSource3) || \ 237 | ((PINSOURCE) == GPIO_PinSource4) || \ 238 | ((PINSOURCE) == GPIO_PinSource5) || \ 239 | ((PINSOURCE) == GPIO_PinSource6) || \ 240 | ((PINSOURCE) == GPIO_PinSource7) || \ 241 | ((PINSOURCE) == GPIO_PinSource8) || \ 242 | ((PINSOURCE) == GPIO_PinSource9) || \ 243 | ((PINSOURCE) == GPIO_PinSource10) || \ 244 | ((PINSOURCE) == GPIO_PinSource11) || \ 245 | ((PINSOURCE) == GPIO_PinSource12) || \ 246 | ((PINSOURCE) == GPIO_PinSource13) || \ 247 | ((PINSOURCE) == GPIO_PinSource14) || \ 248 | ((PINSOURCE) == GPIO_PinSource15)) 249 | /** 250 | * @} 251 | */ 252 | 253 | /** @defgroup GPIO_Alternate_function_selection_define 254 | * @{ 255 | */ 256 | 257 | /** 258 | * @brief AF 0 selection 259 | */ 260 | #define GPIO_AF_0 ((uint8_t)0x00) /* JTCK-SWCLK, JTDI, JTDO/TRACESW0, JTMS-SWDAT, 261 | MCO, NJTRST, TRACED, TRACECK */ 262 | /** 263 | * @brief AF 1 selection 264 | */ 265 | #define GPIO_AF_1 ((uint8_t)0x01) /* OUT, TIM2, TIM15, TIM16, TIM17 */ 266 | 267 | /** 268 | * @brief AF 2 selection 269 | */ 270 | #define GPIO_AF_2 ((uint8_t)0x02) /* COMP1_OUT, TIM1, TIM2, TIM3, TIM4, TIM8, TIM15, TIM16 */ 271 | 272 | /** 273 | * @brief AF 3 selection 274 | */ 275 | #define GPIO_AF_3 ((uint8_t)0x03) /* COMP7_OUT, TIM8, TIM15, Touch, HRTIM1 */ 276 | 277 | /** 278 | * @brief AF 4 selection 279 | */ 280 | #define GPIO_AF_4 ((uint8_t)0x04) /* I2C1, I2C2, TIM1, TIM8, TIM16, TIM17 */ 281 | 282 | /** 283 | * @brief AF 5 selection 284 | */ 285 | #define GPIO_AF_5 ((uint8_t)0x05) /* IR_OUT, I2S2, I2S3, SPI1, SPI2, TIM8, USART4, USART5 */ 286 | 287 | /** 288 | * @brief AF 6 selection 289 | */ 290 | #define GPIO_AF_6 ((uint8_t)0x06) /* IR_OUT, I2S2, I2S3, SPI2, SPI3, TIM1, TIM8 */ 291 | 292 | /** 293 | * @brief AF 7 selection 294 | */ 295 | #define GPIO_AF_7 ((uint8_t)0x07) /* AOP2_OUT, CAN, COMP3_OUT, COMP5_OUT, COMP6_OUT, 296 | USART1, USART2, USART3 */ 297 | 298 | /** 299 | * @brief AF 8 selection 300 | */ 301 | #define GPIO_AF_8 ((uint8_t)0x08) /* COMP1_OUT, COMP2_OUT, COMP3_OUT, COMP4_OUT, 302 | COMP5_OUT, COMP6_OUT */ 303 | 304 | /** 305 | * @brief AF 9 selection 306 | */ 307 | #define GPIO_AF_9 ((uint8_t)0x09) /* AOP4_OUT, CAN, TIM1, TIM8, TIM15 */ 308 | 309 | /** 310 | * @brief AF 10 selection 311 | */ 312 | #define GPIO_AF_10 ((uint8_t)0x0A) /* AOP1_OUT, AOP3_OUT, TIM2, TIM3, TIM4, TIM8, TIM17 */ 313 | 314 | /** 315 | * @brief AF 11 selection 316 | */ 317 | #define GPIO_AF_11 ((uint8_t)0x0B) /* TIM1, TIM8 */ 318 | 319 | /** 320 | * @brief AF 12 selection 321 | */ 322 | #define GPIO_AF_12 ((uint8_t)0x0C) /* TIM1, HRTIM1 */ 323 | 324 | /** 325 | * @brief AF 13 selection 326 | */ 327 | #define GPIO_AF_13 ((uint8_t)0x0D) /* HRTIM1, AOP2_OUT */ 328 | 329 | /** 330 | * @brief AF 14 selection 331 | */ 332 | #define GPIO_AF_14 ((uint8_t)0x0E) /* USBDM, USBDP */ 333 | 334 | /** 335 | * @brief AF 15 selection 336 | */ 337 | #define GPIO_AF_15 ((uint8_t)0x0F) /* OUT */ 338 | 339 | #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_0)||((AF) == GPIO_AF_1)||\ 340 | ((AF) == GPIO_AF_2)||((AF) == GPIO_AF_3)||\ 341 | ((AF) == GPIO_AF_4)||((AF) == GPIO_AF_5)||\ 342 | ((AF) == GPIO_AF_6)||((AF) == GPIO_AF_7)||\ 343 | ((AF) == GPIO_AF_8)||((AF) == GPIO_AF_9)||\ 344 | ((AF) == GPIO_AF_10)||((AF) == GPIO_AF_11)||\ 345 | ((AF) == GPIO_AF_12)||((AF) == GPIO_AF_13)||\ 346 | ((AF) == GPIO_AF_14)||((AF) == GPIO_AF_15)) 347 | 348 | /** 349 | * @} 350 | */ 351 | 352 | /** @defgroup GPIO_Speed_Legacy 353 | * @{ 354 | */ 355 | 356 | #define GPIO_Speed_10MHz GPIO_Speed_Level_1 /*!< Fast Speed:10MHz */ 357 | #define GPIO_Speed_2MHz GPIO_Speed_Level_2 /*!< Medium Speed:2MHz */ 358 | #define GPIO_Speed_50MHz GPIO_Speed_Level_3 /*!< High Speed:50MHz */ 359 | 360 | /** 361 | * @} 362 | */ 363 | 364 | /** 365 | * @} 366 | */ 367 | 368 | /* Exported macro ------------------------------------------------------------*/ 369 | /* Exported functions ------------------------------------------------------- */ 370 | /* Function used to set the GPIO configuration to the default reset state *****/ 371 | void GPIO_DeInit(GPIO_TypeDef* GPIOx); 372 | 373 | /* Initialization and Configuration functions *********************************/ 374 | void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); 375 | void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); 376 | void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 377 | 378 | /* GPIO Read and Write functions **********************************************/ 379 | uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 380 | uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); 381 | uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 382 | uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); 383 | void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 384 | void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 385 | void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); 386 | void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); 387 | 388 | /* GPIO Alternate functions configuration functions ***************************/ 389 | void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF); 390 | 391 | #ifdef __cplusplus 392 | } 393 | #endif 394 | 395 | #endif /* __STM32F30x_GPIO_H */ 396 | /** 397 | * @} 398 | */ 399 | 400 | /** 401 | * @} 402 | */ 403 | 404 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 405 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_hrtim.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Serj-Bashlayev/STM32_Profiler/641f239e0f976ccf938f5eb9c60f15e1a6f4e659/Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_hrtim.h -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_iwdg.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_IWDG_H 31 | #define __STM32F30x_IWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup IWDG 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup IWDG_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup IWDG_WriteAccess 56 | * @{ 57 | */ 58 | 59 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 60 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 61 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 62 | ((ACCESS) == IWDG_WriteAccess_Disable)) 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup IWDG_prescaler 68 | * @{ 69 | */ 70 | 71 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 72 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 73 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 74 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 75 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 76 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 77 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 78 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 79 | ((PRESCALER) == IWDG_Prescaler_8) || \ 80 | ((PRESCALER) == IWDG_Prescaler_16) || \ 81 | ((PRESCALER) == IWDG_Prescaler_32) || \ 82 | ((PRESCALER) == IWDG_Prescaler_64) || \ 83 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 84 | ((PRESCALER) == IWDG_Prescaler_256)) 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup IWDG_Flag 90 | * @{ 91 | */ 92 | 93 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 94 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 95 | #define IWDG_FLAG_WVU ((uint16_t)0x0002) 96 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU) || \ 97 | ((FLAG) == IWDG_FLAG_WVU)) 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @defgroup IWDG_Reload_Value 103 | * @{ 104 | */ 105 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** @defgroup IWDG_CounterWindow_Value 112 | * @{ 113 | */ 114 | #define IS_IWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0xFFF) 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /* Exported macro ------------------------------------------------------------*/ 124 | /* Exported functions --------------------------------------------------------*/ 125 | 126 | /* Prescaler and Counter configuration functions ******************************/ 127 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 128 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 129 | void IWDG_SetReload(uint16_t Reload); 130 | void IWDG_ReloadCounter(void); 131 | void IWDG_SetWindowValue(uint16_t WindowValue); 132 | 133 | /* IWDG activation function ***************************************************/ 134 | void IWDG_Enable(void); 135 | 136 | /* Flag management function ***************************************************/ 137 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __STM32F30x_IWDG_H */ 144 | 145 | /** 146 | * @} 147 | */ 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 154 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_misc.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the miscellaneous 8 | * firmware library functions (add-on to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_MISC_H 31 | #define __STM32F30x_MISC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup MISC 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | 50 | /** 51 | * @brief NVIC Init Structure definition 52 | */ 53 | 54 | typedef struct 55 | { 56 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 57 | This parameter can be a value of @ref IRQn_Type (For 58 | the complete STM32 Devices IRQ Channels list, please 59 | refer to stm32f30x.h file) */ 60 | 61 | uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel 62 | specified in NVIC_IRQChannel. This parameter can be a value 63 | between 0 and 15. 64 | A lower priority value indicates a higher priority */ 65 | 66 | 67 | uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified 68 | in NVIC_IRQChannel. This parameter can be a value 69 | between 0 and 15. 70 | A lower priority value indicates a higher priority */ 71 | 72 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 73 | will be enabled or disabled. 74 | This parameter can be set either to ENABLE or DISABLE */ 75 | } NVIC_InitTypeDef; 76 | 77 | /** 78 | * 79 | @verbatim 80 | The table below gives the allowed values of the pre-emption priority and subpriority according 81 | to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function 82 | ============================================================================================================================ 83 | NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description 84 | ============================================================================================================================ 85 | NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority 86 | | | | 4 bits for subpriority 87 | ---------------------------------------------------------------------------------------------------------------------------- 88 | NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority 89 | | | | 3 bits for subpriority 90 | ---------------------------------------------------------------------------------------------------------------------------- 91 | NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority 92 | | | | 2 bits for subpriority 93 | ---------------------------------------------------------------------------------------------------------------------------- 94 | NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority 95 | | | | 1 bits for subpriority 96 | ---------------------------------------------------------------------------------------------------------------------------- 97 | NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority 98 | | | | 0 bits for subpriority 99 | ============================================================================================================================ 100 | @endverbatim 101 | */ 102 | 103 | /* Exported constants --------------------------------------------------------*/ 104 | 105 | /** @defgroup MISC_Exported_Constants 106 | * @{ 107 | */ 108 | 109 | /** @defgroup MISC_Vector_Table_Base 110 | * @{ 111 | */ 112 | 113 | #define NVIC_VectTab_RAM ((uint32_t)0x20000000) 114 | #define NVIC_VectTab_FLASH ((uint32_t)0x08000000) 115 | #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ 116 | ((VECTTAB) == NVIC_VectTab_FLASH)) 117 | /** 118 | * @} 119 | */ 120 | 121 | /** @defgroup MISC_System_Low_Power 122 | * @{ 123 | */ 124 | 125 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 126 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 127 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 128 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ 129 | ((LP) == NVIC_LP_SLEEPDEEP) || \ 130 | ((LP) == NVIC_LP_SLEEPONEXIT)) 131 | /** 132 | * @} 133 | */ 134 | 135 | /** @defgroup MISC_Preemption_Priority_Group 136 | * @{ 137 | */ 138 | 139 | #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 140 | 4 bits for subpriority */ 141 | #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 142 | 3 bits for subpriority */ 143 | #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 144 | 2 bits for subpriority */ 145 | #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 146 | 1 bits for subpriority */ 147 | #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 148 | 0 bits for subpriority */ 149 | 150 | #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ 151 | ((GROUP) == NVIC_PriorityGroup_1) || \ 152 | ((GROUP) == NVIC_PriorityGroup_2) || \ 153 | ((GROUP) == NVIC_PriorityGroup_3) || \ 154 | ((GROUP) == NVIC_PriorityGroup_4)) 155 | 156 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 157 | 158 | #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 159 | 160 | #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /** @defgroup MISC_SysTick_clock_source 167 | */ 168 | 169 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 170 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 171 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ 172 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) 173 | /** 174 | * @} 175 | */ 176 | 177 | /** 178 | * @} 179 | */ 180 | 181 | /* Exported macro ------------------------------------------------------------*/ 182 | /* Exported functions --------------------------------------------------------*/ 183 | 184 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 185 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 186 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); 187 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 188 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 189 | 190 | #ifdef __cplusplus 191 | } 192 | #endif 193 | 194 | #endif /* __STM32F30x_MISC_H */ 195 | 196 | /** 197 | * @} 198 | */ 199 | 200 | /** 201 | * @} 202 | */ 203 | 204 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 205 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_opamp.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_opamp.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the operational 8 | * amplifiers (OPAMP) firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_OPAMP_H 31 | #define __STM32F30x_OPAMP_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup OPAMP 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | 50 | /** 51 | * @brief OPAMP Init structure definition 52 | */ 53 | 54 | typedef struct 55 | { 56 | 57 | uint32_t OPAMP_InvertingInput; /*!< Selects the inverting input of the operational amplifier. 58 | This parameter can be a value of @ref OPAMP_InvertingInput */ 59 | 60 | uint32_t OPAMP_NonInvertingInput; /*!< Selects the non inverting input of the operational amplifier. 61 | This parameter can be a value of @ref OPAMP_NonInvertingInput */ 62 | 63 | }OPAMP_InitTypeDef; 64 | 65 | /* Exported constants --------------------------------------------------------*/ 66 | 67 | /** @defgroup OPAMP_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** @defgroup OPAMP_Selection 72 | * @{ 73 | */ 74 | 75 | #define OPAMP_Selection_OPAMP1 ((uint32_t)0x00000000) /*!< OPAMP1 Selection */ 76 | #define OPAMP_Selection_OPAMP2 ((uint32_t)0x00000004) /*!< OPAMP2 Selection */ 77 | #define OPAMP_Selection_OPAMP3 ((uint32_t)0x00000008) /*!< OPAMP3 Selection */ 78 | #define OPAMP_Selection_OPAMP4 ((uint32_t)0x0000000C) /*!< OPAMP4 Selection */ 79 | 80 | #define IS_OPAMP_ALL_PERIPH(PERIPH) (((PERIPH) == OPAMP_Selection_OPAMP1) || \ 81 | ((PERIPH) == OPAMP_Selection_OPAMP2) || \ 82 | ((PERIPH) == OPAMP_Selection_OPAMP3) || \ 83 | ((PERIPH) == OPAMP_Selection_OPAMP4)) 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup OPAMP_InvertingInput 90 | * @{ 91 | */ 92 | 93 | #define OPAMP_InvertingInput_IO1 ((uint32_t)0x00000000) /*!< IO1 (PC5 for OPAMP1 and OPAMP2, PB10 for OPAMP3 and OPAMP4) 94 | connected to OPAMPx inverting input */ 95 | #define OPAMP_InvertingInput_IO2 OPAMP_CSR_VMSEL_0 /*!< IO2 (PA3 for OPAMP1, PA5 for OPAMP2, PB2 for OPAMP3, PD8 for OPAMP4) 96 | connected to OPAMPx inverting input */ 97 | #define OPAMP_InvertingInput_PGA OPAMP_CSR_VMSEL_1 /*!< Resistor feedback output connected to OPAMPx inverting input (PGA mode) */ 98 | #define OPAMP_InvertingInput_Vout OPAMP_CSR_VMSEL /*!< Vout connected to OPAMPx inverting input (follower mode) */ 99 | 100 | #define IS_OPAMP_INVERTING_INPUT(INPUT) (((INPUT) == OPAMP_InvertingInput_IO1) || \ 101 | ((INPUT) == OPAMP_InvertingInput_IO2) || \ 102 | ((INPUT) == OPAMP_InvertingInput_PGA) || \ 103 | ((INPUT) == OPAMP_InvertingInput_Vout)) 104 | /** 105 | * @} 106 | */ 107 | 108 | /** @defgroup OPAMP_NonInvertingInput 109 | * @{ 110 | */ 111 | 112 | #define OPAMP_NonInvertingInput_IO1 ((uint32_t)0x00000000) /*!< IO1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4) 113 | connected to OPAMPx non inverting input */ 114 | #define OPAMP_NonInvertingInput_IO2 OPAMP_CSR_VPSEL_0 /*!< IO2 (PA5 for OPAMP1, PB14 for OPAMP2, PA5 for OPAMP3, PB11 for OPAMP4) 115 | connected to OPAMPx non inverting input */ 116 | #define OPAMP_NonInvertingInput_IO3 OPAMP_CSR_VPSEL_1 /*!< IO3 (PA3 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PA4 for OPAMP4) 117 | connected to OPAMPx non inverting input */ 118 | #define OPAMP_NonInvertingInput_IO4 OPAMP_CSR_VPSEL /*!< IO4 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4) 119 | connected to OPAMPx non inverting input */ 120 | 121 | #define IS_OPAMP_NONINVERTING_INPUT(INPUT) (((INPUT) == OPAMP_NonInvertingInput_IO1) || \ 122 | ((INPUT) == OPAMP_NonInvertingInput_IO2) || \ 123 | ((INPUT) == OPAMP_NonInvertingInput_IO3) || \ 124 | ((INPUT) == OPAMP_NonInvertingInput_IO4)) 125 | /** 126 | * @} 127 | */ 128 | 129 | /** @defgroup OPAMP_PGAGain_Config 130 | * @{ 131 | */ 132 | 133 | #define OPAMP_OPAMP_PGAGain_2 ((uint32_t)0x00000000) 134 | #define OPAMP_OPAMP_PGAGain_4 OPAMP_CSR_PGGAIN_0 135 | #define OPAMP_OPAMP_PGAGain_8 OPAMP_CSR_PGGAIN_1 136 | #define OPAMP_OPAMP_PGAGain_16 ((uint32_t)0x0000C000) 137 | 138 | #define IS_OPAMP_PGAGAIN(GAIN) (((GAIN) == OPAMP_OPAMP_PGAGain_2) || \ 139 | ((GAIN) == OPAMP_OPAMP_PGAGain_4) || \ 140 | ((GAIN) == OPAMP_OPAMP_PGAGain_8) || \ 141 | ((GAIN) == OPAMP_OPAMP_PGAGain_16)) 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup OPAMP_PGAConnect_Config 147 | * @{ 148 | */ 149 | 150 | #define OPAMP_PGAConnect_No ((uint32_t)0x00000000) 151 | #define OPAMP_PGAConnect_IO1 OPAMP_CSR_PGGAIN_3 152 | #define OPAMP_PGAConnect_IO2 ((uint32_t)0x00030000) 153 | 154 | #define IS_OPAMP_PGACONNECT(CONNECT) (((CONNECT) == OPAMP_PGAConnect_No) || \ 155 | ((CONNECT) == OPAMP_PGAConnect_IO1) || \ 156 | ((CONNECT) == OPAMP_PGAConnect_IO2)) 157 | /** 158 | * @} 159 | */ 160 | 161 | /** @defgroup OPAMP_SecondaryInvertingInput 162 | * @{ 163 | */ 164 | 165 | #define IS_OPAMP_SECONDARY_INVINPUT(INVINPUT) (((INVINPUT) == OPAMP_InvertingInput_IO1) || \ 166 | ((INVINPUT) == OPAMP_InvertingInput_IO2)) 167 | /** 168 | * @} 169 | */ 170 | 171 | /** @defgroup OPAMP_Input 172 | * @{ 173 | */ 174 | 175 | #define OPAMP_Input_Inverting ((uint32_t)0x00000018) /*!< Inverting input */ 176 | #define OPAMP_Input_NonInverting ((uint32_t)0x00000013) /*!< Non inverting input */ 177 | 178 | #define IS_OPAMP_INPUT(INPUT) (((INPUT) == OPAMP_Input_Inverting) || \ 179 | ((INPUT) == OPAMP_Input_NonInverting)) 180 | 181 | /** 182 | * @} 183 | */ 184 | 185 | /** @defgroup OPAMP_Vref 186 | * @{ 187 | */ 188 | 189 | #define OPAMP_Vref_3VDDA ((uint32_t)0x00000000) /*!< OPMAP Vref = 3.3% VDDA */ 190 | #define OPAMP_Vref_10VDDA OPAMP_CSR_CALSEL_0 /*!< OPMAP Vref = 10% VDDA */ 191 | #define OPAMP_Vref_50VDDA OPAMP_CSR_CALSEL_1 /*!< OPMAP Vref = 50% VDDA */ 192 | #define OPAMP_Vref_90VDDA OPAMP_CSR_CALSEL /*!< OPMAP Vref = 90% VDDA */ 193 | 194 | #define IS_OPAMP_VREF(VREF) (((VREF) == OPAMP_Vref_3VDDA) || \ 195 | ((VREF) == OPAMP_Vref_10VDDA) || \ 196 | ((VREF) == OPAMP_Vref_50VDDA) || \ 197 | ((VREF) == OPAMP_Vref_90VDDA)) 198 | 199 | /** 200 | * @} 201 | */ 202 | 203 | /** @defgroup OPAMP_Trimming 204 | */ 205 | 206 | #define OPAMP_Trimming_Factory ((uint32_t)0x00000000) /*!< Factory trimming */ 207 | #define OPAMP_Trimming_User OPAMP_CSR_USERTRIM /*!< User trimming */ 208 | 209 | #define IS_OPAMP_TRIMMING(TRIMMING) (((TRIMMING) == OPAMP_Trimming_Factory) || \ 210 | ((TRIMMING) == OPAMP_Trimming_User)) 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /** @defgroup OPAMP_TrimValue 217 | * @{ 218 | */ 219 | 220 | #define IS_OPAMP_TRIMMINGVALUE(VALUE) ((VALUE) <= 0x0000001F) /*!< Trimming value */ 221 | 222 | /** 223 | * @} 224 | */ 225 | 226 | /** @defgroup OPAMP_OutputLevel 227 | * @{ 228 | */ 229 | 230 | #define OPAMP_OutputLevel_High OPAMP_CSR_OUTCAL 231 | #define OPAMP_OutputLevel_Low ((uint32_t)0x00000000) 232 | 233 | /** 234 | * @} 235 | */ 236 | 237 | /* Exported macro ------------------------------------------------------------*/ 238 | /* Exported functions ------------------------------------------------------- */ 239 | 240 | /* Function used to set the OPAMP configuration to the default reset state ***/ 241 | void OPAMP_DeInit(uint32_t OPAMP_Selection); 242 | 243 | /* Initialization and Configuration functions *********************************/ 244 | void OPAMP_Init(uint32_t OPAMP_Selection, OPAMP_InitTypeDef* OPAMP_InitStruct); 245 | void OPAMP_StructInit(OPAMP_InitTypeDef* OPAMP_InitStruct); 246 | void OPAMP_PGAConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_PGAGain, uint32_t OPAMP_PGAConnect); 247 | void OPAMP_VrefConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Vref); 248 | void OPAMP_VrefConnectADCCmd(uint32_t OPAMP_Selection, FunctionalState NewState); 249 | void OPAMP_TimerControlledMuxConfig(uint32_t OPAMP_Selection, OPAMP_InitTypeDef* OPAMP_InitStruct); 250 | void OPAMP_TimerControlledMuxCmd(uint32_t OPAMP_Selection, FunctionalState NewState); 251 | void OPAMP_Cmd(uint32_t OPAMP_Selection, FunctionalState NewState); 252 | uint32_t OPAMP_GetOutputLevel(uint32_t OPAMP_Selection); 253 | 254 | /* Calibration functions ******************************************************/ 255 | void OPAMP_VrefConnectNonInvertingInput(uint32_t OPAMP_Selection, FunctionalState NewState); 256 | void OPAMP_OffsetTrimModeSelect(uint32_t OPAMP_Selection, uint32_t OPAMP_Trimming); 257 | void OPAMP_OffsetTrimConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Input, uint32_t OPAMP_TrimValue); 258 | void OPAMP_StartCalibration(uint32_t OPAMP_Selection, FunctionalState NewState); 259 | 260 | /* OPAMP configuration locking function ***************************************/ 261 | void OPAMP_LockConfig(uint32_t OPAMP_Selection); 262 | 263 | #ifdef __cplusplus 264 | } 265 | #endif 266 | 267 | #endif /*__STM32F30x_OPAMP_H */ 268 | 269 | /** 270 | * @} 271 | */ 272 | 273 | /** 274 | * @} 275 | */ 276 | 277 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 278 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_pwr.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_PWR_H 31 | #define __STM32F30x_PWR_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup PWR 45 | * @{ 46 | */ 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | 51 | /** @defgroup PWR_Exported_Constants 52 | * @{ 53 | */ 54 | 55 | /** @defgroup PWR_PVD_detection_level 56 | * @{ 57 | */ 58 | 59 | #define PWR_PVDLevel_0 PWR_CR_PLS_LEV0 60 | #define PWR_PVDLevel_1 PWR_CR_PLS_LEV1 61 | #define PWR_PVDLevel_2 PWR_CR_PLS_LEV2 62 | #define PWR_PVDLevel_3 PWR_CR_PLS_LEV3 63 | #define PWR_PVDLevel_4 PWR_CR_PLS_LEV4 64 | #define PWR_PVDLevel_5 PWR_CR_PLS_LEV5 65 | #define PWR_PVDLevel_6 PWR_CR_PLS_LEV6 66 | #define PWR_PVDLevel_7 PWR_CR_PLS_LEV7 67 | 68 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \ 69 | ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \ 70 | ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \ 71 | ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7)) 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup PWR_WakeUp_Pins 77 | * @{ 78 | */ 79 | 80 | #define PWR_WakeUpPin_1 PWR_CSR_EWUP1 81 | #define PWR_WakeUpPin_2 PWR_CSR_EWUP2 82 | #define PWR_WakeUpPin_3 PWR_CSR_EWUP3 83 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUpPin_1) || \ 84 | ((PIN) == PWR_WakeUpPin_2) || \ 85 | ((PIN) == PWR_WakeUpPin_3)) 86 | /** 87 | * @} 88 | */ 89 | 90 | 91 | /** @defgroup PWR_Regulator_state_is_Sleep_STOP_mode 92 | * @{ 93 | */ 94 | 95 | #define PWR_Regulator_ON ((uint32_t)0x00000000) 96 | #define PWR_Regulator_LowPower PWR_CR_LPSDSR 97 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ 98 | ((REGULATOR) == PWR_Regulator_LowPower)) 99 | /** 100 | * @} 101 | */ 102 | 103 | /** @defgroup PWR_SLEEP_mode_entry 104 | * @{ 105 | */ 106 | 107 | #define PWR_SLEEPEntry_WFI ((uint8_t)0x01) 108 | #define PWR_SLEEPEntry_WFE ((uint8_t)0x02) 109 | #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPEntry_WFI) || ((ENTRY) == PWR_SLEEPEntry_WFE)) 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /** @defgroup PWR_STOP_mode_entry 116 | * @{ 117 | */ 118 | 119 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 120 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 121 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** @defgroup PWR_Flag 128 | * @{ 129 | */ 130 | 131 | #define PWR_FLAG_WU PWR_CSR_WUF 132 | #define PWR_FLAG_SB PWR_CSR_SBF 133 | #define PWR_FLAG_PVDO PWR_CSR_PVDO 134 | #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF 135 | 136 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 137 | ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_VREFINTRDY)) 138 | 139 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) 140 | /** 141 | * @} 142 | */ 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /* Exported macro ------------------------------------------------------------*/ 149 | /* Exported functions ------------------------------------------------------- */ 150 | 151 | /* Function used to set the PWR configuration to the default reset state ******/ 152 | void PWR_DeInit(void); 153 | 154 | /* Backup Domain Access function **********************************************/ 155 | void PWR_BackupAccessCmd(FunctionalState NewState); 156 | 157 | /* PVD configuration functions ************************************************/ 158 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 159 | void PWR_PVDCmd(FunctionalState NewState); 160 | 161 | /* WakeUp pins configuration functions ****************************************/ 162 | void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState); 163 | 164 | /* Low Power modes configuration functions ************************************/ 165 | void PWR_EnterSleepMode(uint8_t PWR_SLEEPEntry); 166 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 167 | void PWR_EnterSTANDBYMode(void); 168 | 169 | /* Flags management functions *************************************************/ 170 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 171 | void PWR_ClearFlag(uint32_t PWR_FLAG); 172 | 173 | #ifdef __cplusplus 174 | } 175 | #endif 176 | 177 | #endif /* __STM32F30x_PWR_H */ 178 | 179 | /** 180 | * @} 181 | */ 182 | 183 | /** 184 | * @} 185 | */ 186 | 187 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 188 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/inc/stm32f30x_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_wwdg.h 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file contains all the functions prototypes for the WWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2015 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F30x_WWDG_H 31 | #define __STM32F30x_WWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f30x.h" 39 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup WWDG 45 | * @{ 46 | */ 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | 50 | /** @defgroup WWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup WWDG_Prescaler 55 | * @{ 56 | */ 57 | 58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 63 | ((PRESCALER) == WWDG_Prescaler_2) || \ 64 | ((PRESCALER) == WWDG_Prescaler_4) || \ 65 | ((PRESCALER) == WWDG_Prescaler_8)) 66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /* Exported macro ------------------------------------------------------------*/ 78 | /* Exported functions ------------------------------------------------------- */ 79 | /* Function used to set the WWDG configuration to the default reset state ****/ 80 | void WWDG_DeInit(void); 81 | 82 | /* Prescaler, Refresh window and Counter configuration functions **************/ 83 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 84 | void WWDG_SetWindowValue(uint8_t WindowValue); 85 | void WWDG_EnableIT(void); 86 | void WWDG_SetCounter(uint8_t Counter); 87 | 88 | /* WWDG activation functions **************************************************/ 89 | void WWDG_Enable(uint8_t Counter); 90 | 91 | /* Interrupts and flags management functions **********************************/ 92 | FlagStatus WWDG_GetFlagStatus(void); 93 | void WWDG_ClearFlag(void); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* __STM32F30x_WWDG_H */ 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 110 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/src/stm32f30x_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_crc.c 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file provides firmware functions to manage the following 8 | * functionalities of CRC computation unit peripheral: 9 | * + Configuration of the CRC computation unit 10 | * + CRC computation of one/many 32-bit data 11 | * + CRC Independent register (IDR) access 12 | * 13 | @verbatim 14 | 15 | =============================================================================== 16 | ##### How to use this driver ##### 17 | =============================================================================== 18 | [..] 19 | (#) Enable CRC AHB clock using RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE) 20 | function. 21 | (#) Select the polynomial size: 7-bit, 8-bit, 16-bit or 32-bit. 22 | (#) Set the polynomial coefficients using CRC_SetPolynomial(); 23 | (#) If required, select the reverse operation on input data 24 | using CRC_ReverseInputDataSelect(); 25 | (#) If required, enable the reverse operation on output data 26 | using CRC_ReverseOutputDataCmd(Enable); 27 | (#) If required, set the initialization remainder value using 28 | CRC_SetInitRegister(); 29 | (#) use CRC_CalcCRC() function to compute the CRC of a 32-bit data 30 | or use CRC_CalcBlockCRC() function to compute the CRC if a 32-bit 31 | data buffer. 32 | 33 | @endverbatim 34 | 35 | ****************************************************************************** 36 | * @attention 37 | * 38 | *

© COPYRIGHT 2014 STMicroelectronics

39 | * 40 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 41 | * You may not use this file except in compliance with the License. 42 | * You may obtain a copy of the License at: 43 | * 44 | * http://www.st.com/software_license_agreement_liberty_v2 45 | * 46 | * Unless required by applicable law or agreed to in writing, software 47 | * distributed under the License is distributed on an "AS IS" BASIS, 48 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 49 | * See the License for the specific language governing permissions and 50 | * limitations under the License. 51 | * 52 | ****************************************************************************** 53 | */ 54 | 55 | /* Includes ------------------------------------------------------------------*/ 56 | #include "stm32f30x_crc.h" 57 | 58 | /** @addtogroup STM32F30x_StdPeriph_Driver 59 | * @{ 60 | */ 61 | 62 | /** @defgroup CRC 63 | * @brief CRC driver modules 64 | * @{ 65 | */ 66 | 67 | /* Private typedef -----------------------------------------------------------*/ 68 | /* Private define ------------------------------------------------------------*/ 69 | /* Private macro -------------------------------------------------------------*/ 70 | /* Private variables ---------------------------------------------------------*/ 71 | /* Private function prototypes -----------------------------------------------*/ 72 | /* Private functions ---------------------------------------------------------*/ 73 | 74 | /** @defgroup CRC_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** @defgroup CRC_Group1 Configuration of the CRC computation unit functions 79 | * @brief Configuration of the CRC computation unit functions 80 | * 81 | @verbatim 82 | =============================================================================== 83 | ##### CRC configuration functions ##### 84 | =============================================================================== 85 | 86 | @endverbatim 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @brief Deinitializes CRC peripheral registers to their default reset values. 92 | * @param None 93 | * @retval None 94 | */ 95 | void CRC_DeInit(void) 96 | { 97 | /* Set DR register to reset value */ 98 | CRC->DR = 0xFFFFFFFF; 99 | /* Set the POL register to the reset value: 0x04C11DB7 */ 100 | CRC->POL = 0x04C11DB7; 101 | /* Reset IDR register */ 102 | CRC->IDR = 0x00; 103 | /* Set INIT register to reset value */ 104 | CRC->INIT = 0xFFFFFFFF; 105 | /* Reset the CRC calculation unit */ 106 | CRC->CR = CRC_CR_RESET; 107 | } 108 | 109 | /** 110 | * @brief Resets the CRC calculation unit and sets INIT register content in DR register. 111 | * @param None 112 | * @retval None 113 | */ 114 | void CRC_ResetDR(void) 115 | { 116 | /* Reset CRC generator */ 117 | CRC->CR |= CRC_CR_RESET; 118 | } 119 | 120 | /** 121 | * @brief Selects the polynomial size. 122 | * @param CRC_PolSize: Specifies the polynomial size. 123 | * This parameter can be: 124 | * @arg CRC_PolSize_7: 7-bit polynomial for CRC calculation 125 | * @arg CRC_PolSize_8: 8-bit polynomial for CRC calculation 126 | * @arg CRC_PolSize_16: 16-bit polynomial for CRC calculation 127 | * @arg CRC_PolSize_32: 32-bit polynomial for CRC calculation 128 | * @retval None 129 | */ 130 | void CRC_PolynomialSizeSelect(uint32_t CRC_PolSize) 131 | { 132 | uint32_t tmpcr = 0; 133 | 134 | /* Check the parameter */ 135 | assert_param(IS_CRC_POL_SIZE(CRC_PolSize)); 136 | 137 | /* Get CR register value */ 138 | tmpcr = CRC->CR; 139 | 140 | /* Reset POL_SIZE bits */ 141 | tmpcr &= (uint32_t)~((uint32_t)CRC_CR_POLSIZE); 142 | /* Set the polynomial size */ 143 | tmpcr |= (uint32_t)CRC_PolSize; 144 | 145 | /* Write to CR register */ 146 | CRC->CR = (uint32_t)tmpcr; 147 | } 148 | 149 | /** 150 | * @brief Selects the reverse operation to be performed on input data. 151 | * @param CRC_ReverseInputData: Specifies the reverse operation on input data. 152 | * This parameter can be: 153 | * @arg CRC_ReverseInputData_No: No reverse operation is performed 154 | * @arg CRC_ReverseInputData_8bits: reverse operation performed on 8 bits 155 | * @arg CRC_ReverseInputData_16bits: reverse operation performed on 16 bits 156 | * @arg CRC_ReverseInputData_32bits: reverse operation performed on 32 bits 157 | * @retval None 158 | */ 159 | void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData) 160 | { 161 | uint32_t tmpcr = 0; 162 | 163 | /* Check the parameter */ 164 | assert_param(IS_CRC_REVERSE_INPUT_DATA(CRC_ReverseInputData)); 165 | 166 | /* Get CR register value */ 167 | tmpcr = CRC->CR; 168 | 169 | /* Reset REV_IN bits */ 170 | tmpcr &= (uint32_t)~((uint32_t)CRC_CR_REV_IN); 171 | /* Set the reverse operation */ 172 | tmpcr |= (uint32_t)CRC_ReverseInputData; 173 | 174 | /* Write to CR register */ 175 | CRC->CR = (uint32_t)tmpcr; 176 | } 177 | 178 | /** 179 | * @brief Enables or disable the reverse operation on output data. 180 | * The reverse operation on output data is performed on 32-bit. 181 | * @param NewState: new state of the reverse operation on output data. 182 | * This parameter can be: ENABLE or DISABLE. 183 | * @retval None 184 | */ 185 | void CRC_ReverseOutputDataCmd(FunctionalState NewState) 186 | { 187 | /* Check the parameters */ 188 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 189 | 190 | if (NewState != DISABLE) 191 | { 192 | /* Enable reverse operation on output data */ 193 | CRC->CR |= CRC_CR_REV_OUT; 194 | } 195 | else 196 | { 197 | /* Disable reverse operation on output data */ 198 | CRC->CR &= (uint32_t)~((uint32_t)CRC_CR_REV_OUT); 199 | } 200 | } 201 | 202 | /** 203 | * @brief Initializes the INIT register. 204 | * @note After resetting CRC calculation unit, CRC_InitValue is stored in DR register 205 | * @param CRC_InitValue: Programmable initial CRC value 206 | * @retval None 207 | */ 208 | void CRC_SetInitRegister(uint32_t CRC_InitValue) 209 | { 210 | CRC->INIT = CRC_InitValue; 211 | } 212 | 213 | /** 214 | * @brief Initializes the polynomial coefficients. 215 | * @param CRC_Pol: Polynomial to be used for CRC calculation. 216 | * @retval None 217 | */ 218 | void CRC_SetPolynomial(uint32_t CRC_Pol) 219 | { 220 | CRC->POL = CRC_Pol; 221 | } 222 | 223 | /** 224 | * @} 225 | */ 226 | 227 | /** @defgroup CRC_Group2 CRC computation of one/many 32-bit data functions 228 | * @brief CRC computation of one/many 32-bit data functions 229 | * 230 | @verbatim 231 | =============================================================================== 232 | ##### CRC computation functions ##### 233 | =============================================================================== 234 | 235 | @endverbatim 236 | * @{ 237 | */ 238 | 239 | /** 240 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 241 | * @param CRC_Data: data word(32-bit) to compute its CRC 242 | * @retval 32-bit CRC 243 | */ 244 | uint32_t CRC_CalcCRC(uint32_t CRC_Data) 245 | { 246 | CRC->DR = CRC_Data; 247 | 248 | return (CRC->DR); 249 | } 250 | 251 | /** 252 | * @brief Computes the 16-bit CRC of a given 16-bit data. 253 | * @param CRC_Data: data half-word(16-bit) to compute its CRC 254 | * @retval 16-bit CRC 255 | */ 256 | uint32_t CRC_CalcCRC16bits(uint16_t CRC_Data) 257 | { 258 | *(uint16_t*)(CRC_BASE) = (uint16_t) CRC_Data; 259 | 260 | return (CRC->DR); 261 | } 262 | 263 | /** 264 | * @brief Computes the 8-bit CRC of a given 8-bit data. 265 | * @param CRC_Data: 8-bit data to compute its CRC 266 | * @retval 8-bit CRC 267 | */ 268 | uint32_t CRC_CalcCRC8bits(uint8_t CRC_Data) 269 | { 270 | *(uint8_t*)(CRC_BASE) = (uint8_t) CRC_Data; 271 | 272 | return (CRC->DR); 273 | } 274 | 275 | /** 276 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 277 | * @param pBuffer: pointer to the buffer containing the data to be computed 278 | * @param BufferLength: length of the buffer to be computed 279 | * @retval 32-bit CRC 280 | */ 281 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 282 | { 283 | uint32_t index = 0; 284 | 285 | for(index = 0; index < BufferLength; index++) 286 | { 287 | CRC->DR = pBuffer[index]; 288 | } 289 | return (CRC->DR); 290 | } 291 | 292 | /** 293 | * @brief Returns the current CRC value. 294 | * @param None 295 | * @retval 32-bit CRC 296 | */ 297 | uint32_t CRC_GetCRC(void) 298 | { 299 | return (CRC->DR); 300 | } 301 | 302 | /** 303 | * @} 304 | */ 305 | 306 | /** @defgroup CRC_Group3 CRC Independent Register (IDR) access functions 307 | * @brief CRC Independent Register (IDR) access (write/read) functions 308 | * 309 | @verbatim 310 | =============================================================================== 311 | ##### CRC Independent Register (IDR) access functions ##### 312 | =============================================================================== 313 | 314 | @endverbatim 315 | * @{ 316 | */ 317 | 318 | /** 319 | * @brief Stores an 8-bit data in the Independent Data(ID) register. 320 | * @param CRC_IDValue: 8-bit value to be stored in the ID register 321 | * @retval None 322 | */ 323 | void CRC_SetIDRegister(uint8_t CRC_IDValue) 324 | { 325 | CRC->IDR = CRC_IDValue; 326 | } 327 | 328 | /** 329 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 330 | * @param None 331 | * @retval 8-bit value of the ID register 332 | */ 333 | uint8_t CRC_GetIDRegister(void) 334 | { 335 | return (CRC->IDR); 336 | } 337 | 338 | /** 339 | * @} 340 | */ 341 | 342 | /** 343 | * @} 344 | */ 345 | 346 | /** 347 | * @} 348 | */ 349 | 350 | /** 351 | * @} 352 | */ 353 | 354 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 355 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/src/stm32f30x_dbgmcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_dbgmcu.c 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file provides firmware functions to manage the following 8 | * functionalities of the Debug MCU (DBGMCU) peripheral: 9 | * + Device and Revision ID management 10 | * + Peripherals Configuration 11 | ****************************************************************************** 12 | * @attention 13 | * 14 | *

© COPYRIGHT 2015 STMicroelectronics

15 | * 16 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 17 | * You may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at: 19 | * 20 | * http://www.st.com/software_license_agreement_liberty_v2 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | ****************************************************************************** 29 | */ 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f30x_dbgmcu.h" 33 | 34 | /** @addtogroup STM32F30x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @defgroup DBGMCU 39 | * @brief DBGMCU driver modules 40 | * @{ 41 | */ 42 | 43 | /* Private typedef -----------------------------------------------------------*/ 44 | /* Private define ------------------------------------------------------------*/ 45 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 46 | 47 | /* Private macro -------------------------------------------------------------*/ 48 | /* Private variables ---------------------------------------------------------*/ 49 | /* Private function prototypes -----------------------------------------------*/ 50 | /* Private functions ---------------------------------------------------------*/ 51 | 52 | /** @defgroup DBGMCU_Private_Functions 53 | * @{ 54 | */ 55 | 56 | /** @defgroup DBGMCU_Group1 Device and Revision ID management functions 57 | * @brief Device and Revision ID management functions 58 | * 59 | @verbatim 60 | ============================================================================== 61 | ##### Device and Revision ID management functions ##### 62 | ============================================================================== 63 | 64 | @endverbatim 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @brief Returns the device revision identifier. 70 | * @param None 71 | * @retval Device revision identifier 72 | */ 73 | uint32_t DBGMCU_GetREVID(void) 74 | { 75 | return(DBGMCU->IDCODE >> 16); 76 | } 77 | 78 | /** 79 | * @brief Returns the device identifier. 80 | * @param None 81 | * @retval Device identifier 82 | */ 83 | uint32_t DBGMCU_GetDEVID(void) 84 | { 85 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 86 | } 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @defgroup DBGMCU_Group2 Peripherals Configuration functions 93 | * @brief Peripherals Configuration 94 | * 95 | @verbatim 96 | ============================================================================== 97 | ##### Peripherals Configuration functions ##### 98 | ============================================================================== 99 | 100 | @endverbatim 101 | * @{ 102 | */ 103 | 104 | /** 105 | * @brief Configures low power mode behavior when the MCU is in Debug mode. 106 | * @param DBGMCU_Periph: specifies the low power mode. 107 | * This parameter can be any combination of the following values: 108 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode. 109 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode. 110 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode. 111 | * @param NewState: new state of the specified low power mode in Debug mode. 112 | * This parameter can be: ENABLE or DISABLE. 113 | * @retval None 114 | */ 115 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 116 | { 117 | /* Check the parameters */ 118 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 119 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 120 | if (NewState != DISABLE) 121 | { 122 | DBGMCU->CR |= DBGMCU_Periph; 123 | } 124 | else 125 | { 126 | DBGMCU->CR &= ~DBGMCU_Periph; 127 | } 128 | } 129 | 130 | /** 131 | * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode. 132 | * @param DBGMCU_Periph: specifies the APB1 peripheral. 133 | * This parameter can be any combination of the following values: 134 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted. 135 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted. 136 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted. 137 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted. 138 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted. 139 | * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter are stopped when 140 | * Core is halted. 141 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted. 142 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted. 143 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when 144 | * Core is halted. 145 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when 146 | * Core is halted. 147 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted. 148 | * @arg DBGMCU_I2C3_SMBUS_TIMEOUT: I2C3 SMBUS timeout mode stopped when 149 | * Core is halted. 150 | * @param NewState: new state of the specified APB1 peripheral in Debug mode. 151 | * This parameter can be: ENABLE or DISABLE. 152 | * @retval None 153 | */ 154 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState) 155 | { 156 | /* Check the parameters */ 157 | assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph)); 158 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 159 | 160 | if (NewState != DISABLE) 161 | { 162 | DBGMCU->APB1FZ |= DBGMCU_Periph; 163 | } 164 | else 165 | { 166 | DBGMCU->APB1FZ &= ~DBGMCU_Periph; 167 | } 168 | } 169 | 170 | /** 171 | * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode. 172 | * @param DBGMCU_Periph: specifies the APB2 peripheral. 173 | * This parameter can be any combination of the following values: 174 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted. 175 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted. 176 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted. 177 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted. 178 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted. 179 | * @arg DBGMCU_TIM20_STOP: TIM20 counter stopped when Core is halted. 180 | * @param NewState: new state of the specified APB2 peripheral in Debug mode. 181 | * This parameter can be: ENABLE or DISABLE. 182 | * @retval None 183 | */ 184 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState) 185 | { 186 | /* Check the parameters */ 187 | assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph)); 188 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 189 | 190 | if (NewState != DISABLE) 191 | { 192 | DBGMCU->APB2FZ |= DBGMCU_Periph; 193 | } 194 | else 195 | { 196 | DBGMCU->APB2FZ &= ~DBGMCU_Periph; 197 | } 198 | } 199 | 200 | /** 201 | * @} 202 | */ 203 | 204 | /** 205 | * @} 206 | */ 207 | 208 | /** 209 | * @} 210 | */ 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 217 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/src/stm32f30x_exti.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_exti.c 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file provides firmware functions to manage the following 8 | * functionalities of the EXTI peripheral: 9 | * + Initialization and Configuration 10 | * + Interrupts and flags management 11 | * 12 | @verbatim 13 | =============================================================================== 14 | ##### EXTI features ##### 15 | =============================================================================== 16 | [..] External interrupt/event lines are mapped as following: 17 | (#) All available GPIO pins are connected to the 16 external 18 | interrupt/event lines from EXTI0 to EXTI15. 19 | (#) EXTI line 16 is connected to the PVD output 20 | (#) EXTI line 17 is connected to the RTC Alarm event 21 | (#) EXTI line 18 is connected to USB Device wakeup event 22 | (#) EXTI line 19 is connected to the RTC Tamper and TimeStamp events 23 | (#) EXTI line 20 is connected to the RTC wakeup event 24 | (#) EXTI line 21 is connected to the Comparator 1 wakeup event 25 | (#) EXTI line 22 is connected to the Comparator 2 wakeup event 26 | (#) EXTI line 23 is connected to the I2C1 wakeup event 27 | (#) EXTI line 24 is connected to the I2C2 wakeup event 28 | (#) EXTI line 25 is connected to the USART1 wakeup event 29 | (#) EXTI line 26 is connected to the USART2 wakeup event 30 | (#) EXTI line 27 is reserved 31 | (#) EXTI line 28 is connected to the USART3 wakeup event 32 | (#) EXTI line 29 is connected to the Comparator 3 event 33 | (#) EXTI line 30 is connected to the Comparator 4 event 34 | (#) EXTI line 31 is connected to the Comparator 5 event 35 | (#) EXTI line 32 is connected to the Comparator 6 event 36 | (#) EXTI line 33 is connected to the Comparator 7 event 37 | (#) EXTI line 34 is connected for thr UART4 wakeup event 38 | (#) EXTI line 35 is connected for the UART5 wakeup event 39 | 40 | ##### How to use this driver ##### 41 | =============================================================================== 42 | [..] In order to use an I/O pin as an external interrupt source, 43 | follow steps below: 44 | (#) Configure the I/O in input mode using GPIO_Init(). 45 | (#) Select the input source pin for the EXTI line using 46 | SYSCFG_EXTILineConfig(). 47 | (#) Select the mode(interrupt, event) and configure the trigger 48 | selection (Rising, falling or both) using EXTI_Init(). For the 49 | internal interrupt, the trigger selection is not needed 50 | (the active edge is always the rising one). 51 | (#) Configure NVIC IRQ channel mapped to the EXTI line using NVIC_Init(). 52 | (#) Optionally, you can generate a software interrupt using the function 53 | EXTI_GenerateSWInterrupt(). 54 | [..] 55 | (@) SYSCFG APB clock must be enabled to get write access to SYSCFG_EXTICRx 56 | registers using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 57 | 58 | @endverbatim 59 | 60 | ****************************************************************************** 61 | * @attention 62 | * 63 | *

© COPYRIGHT 2015 STMicroelectronics

64 | * 65 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 66 | * You may not use this file except in compliance with the License. 67 | * You may obtain a copy of the License at: 68 | * 69 | * http://www.st.com/software_license_agreement_liberty_v2 70 | * 71 | * Unless required by applicable law or agreed to in writing, software 72 | * distributed under the License is distributed on an "AS IS" BASIS, 73 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 74 | * See the License for the specific language governing permissions and 75 | * limitations under the License. 76 | * 77 | ****************************************************************************** 78 | */ 79 | 80 | /* Includes ------------------------------------------------------------------*/ 81 | #include "stm32f30x_exti.h" 82 | 83 | /** @addtogroup STM32F30x_StdPeriph_Driver 84 | * @{ 85 | */ 86 | 87 | /** @defgroup EXTI 88 | * @brief EXTI driver modules 89 | * @{ 90 | */ 91 | 92 | 93 | /* Private typedef -----------------------------------------------------------*/ 94 | /* Private define ------------------------------------------------------------*/ 95 | #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */ 96 | 97 | /* Private macro -------------------------------------------------------------*/ 98 | /* Private variables ---------------------------------------------------------*/ 99 | /* Private function prototypes -----------------------------------------------*/ 100 | /* Private functions ---------------------------------------------------------*/ 101 | 102 | /** @defgroup EXTI_Private_Functions 103 | * @{ 104 | */ 105 | 106 | /** @defgroup EXTI_Group1 Initialization and Configuration functions 107 | * @brief Initialization and Configuration functions 108 | * 109 | @verbatim 110 | =============================================================================== 111 | ##### Initialization and Configuration functions ##### 112 | =============================================================================== 113 | 114 | @endverbatim 115 | * @{ 116 | */ 117 | 118 | /** 119 | * @brief Deinitializes the EXTI peripheral registers to their default reset 120 | * values. 121 | * @param None 122 | * @retval None 123 | */ 124 | void EXTI_DeInit(void) 125 | { 126 | EXTI->IMR = 0x1F800000; 127 | EXTI->EMR = 0x00000000; 128 | EXTI->RTSR = 0x00000000; 129 | EXTI->FTSR = 0x00000000; 130 | EXTI->SWIER = 0x00000000; 131 | EXTI->PR = 0xE07FFFFF; 132 | EXTI->IMR2 = 0x0000000C; 133 | EXTI->EMR2 = 0x00000000; 134 | EXTI->RTSR2 = 0x00000000; 135 | EXTI->FTSR2 = 0x00000000; 136 | EXTI->SWIER2 = 0x00000000; 137 | EXTI->PR2 = 0x00000003; 138 | } 139 | 140 | /** 141 | * @brief Initializes the EXTI peripheral according to the specified 142 | * parameters in the EXTI_InitStruct. 143 | * EXTI_Line specifies the EXTI line (EXTI0....EXTI35). 144 | * EXTI_Mode specifies which EXTI line is used as interrupt or an event. 145 | * EXTI_Trigger selects the trigger. When the trigger occurs, interrupt 146 | * pending bit will be set. 147 | * EXTI_LineCmd controls (Enable/Disable) the EXTI line. 148 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure that 149 | * contains the configuration information for the EXTI peripheral. 150 | * @retval None 151 | */ 152 | 153 | 154 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) 155 | { 156 | uint32_t tmp = 0; 157 | 158 | /* Check the parameters */ 159 | assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode)); 160 | assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger)); 161 | assert_param(IS_EXTI_LINE_ALL(EXTI_InitStruct->EXTI_Line)); 162 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd)); 163 | 164 | tmp = (uint32_t)EXTI_BASE; 165 | 166 | if (EXTI_InitStruct->EXTI_LineCmd != DISABLE) 167 | { 168 | /* Clear EXTI line configuration */ 169 | *(__IO uint32_t *) (((uint32_t) &(EXTI->IMR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 170 | *(__IO uint32_t *) (((uint32_t) &(EXTI->EMR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 171 | 172 | tmp += EXTI_InitStruct->EXTI_Mode + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20); 173 | 174 | *(__IO uint32_t *) tmp |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 175 | 176 | tmp = (uint32_t)EXTI_BASE; 177 | 178 | /* Clear Rising Falling edge configuration */ 179 | *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 180 | *(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 181 | 182 | /* Select the trigger for the selected interrupts */ 183 | if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling) 184 | { 185 | /* Rising Falling edge */ 186 | *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 187 | *(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 188 | } 189 | else 190 | { 191 | tmp += EXTI_InitStruct->EXTI_Trigger + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20); 192 | 193 | *(__IO uint32_t *) tmp |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 194 | } 195 | } 196 | 197 | else 198 | { 199 | tmp += EXTI_InitStruct->EXTI_Mode + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20); 200 | 201 | /* Disable the selected external lines */ 202 | *(__IO uint32_t *) tmp &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F)); 203 | } 204 | 205 | } 206 | 207 | /** 208 | * @brief Fills each EXTI_InitStruct member with its reset value. 209 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will 210 | * be initialized. 211 | * @retval None 212 | */ 213 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) 214 | { 215 | EXTI_InitStruct->EXTI_Line = EXTI_LINENONE; 216 | EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; 217 | EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Rising_Falling; 218 | EXTI_InitStruct->EXTI_LineCmd = DISABLE; 219 | } 220 | 221 | /** 222 | * @brief Generates a Software interrupt on selected EXTI line. 223 | * @param EXTI_Line: specifies the EXTI line on which the software interrupt 224 | * will be generated. 225 | * This parameter can be any combination of EXTI_Linex where x can be (0..20). 226 | * @retval None 227 | */ 228 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line) 229 | { 230 | /* Check the parameters */ 231 | assert_param(IS_EXTI_LINE_EXT(EXTI_Line)); 232 | 233 | *(__IO uint32_t *) (((uint32_t) &(EXTI->SWIER)) + ((EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_Line & 0x1F)); 234 | 235 | } 236 | 237 | /** 238 | * @} 239 | */ 240 | 241 | /** @defgroup EXTI_Group2 Interrupts and flags management functions 242 | * @brief EXTI Interrupts and flags management functions 243 | * 244 | @verbatim 245 | =============================================================================== 246 | ##### Interrupts and flags management functions ##### 247 | =============================================================================== 248 | [..] 249 | This section provides functions allowing to configure the EXTI Interrupts 250 | sources and check or clear the flags or pending bits status. 251 | 252 | @endverbatim 253 | * @{ 254 | */ 255 | 256 | /** 257 | * @brief Checks whether the specified EXTI line flag is set or not. 258 | * @param EXTI_Line: specifies the EXTI line flag to check. 259 | * This parameter can be any combination of EXTI_Linex where x can be (0..20). 260 | * @retval The new state of EXTI_Line (SET or RESET). 261 | */ 262 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line) 263 | { 264 | FlagStatus bitstatus = RESET; 265 | 266 | /* Check the parameters */ 267 | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); 268 | 269 | if ((*(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20)& (uint32_t)(1 << (EXTI_Line & 0x1F))) != (uint32_t)RESET) 270 | { 271 | bitstatus = SET; 272 | } 273 | else 274 | { 275 | bitstatus = RESET; 276 | } 277 | return bitstatus; 278 | } 279 | 280 | /** 281 | * @brief Clears the EXTI's line pending flags. 282 | * @param EXTI_Line: specifies the EXTI lines flags to clear. 283 | * This parameter can be any combination of EXTI_Linex where x can be (0..20). 284 | * @retval None 285 | */ 286 | void EXTI_ClearFlag(uint32_t EXTI_Line) 287 | { 288 | /* Check the parameters */ 289 | assert_param(IS_EXTI_LINE_EXT(EXTI_Line)); 290 | 291 | *(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20) = (1 << (EXTI_Line & 0x1F)); 292 | } 293 | 294 | /** 295 | * @brief Checks whether the specified EXTI line is asserted or not. 296 | * @param EXTI_Line: specifies the EXTI line to check. 297 | * This parameter can be any combination of EXTI_Linex where x can be (0..20). 298 | * @retval The new state of EXTI_Line (SET or RESET). 299 | */ 300 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line) 301 | { 302 | ITStatus bitstatus = RESET; 303 | 304 | /* Check the parameters */ 305 | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); 306 | 307 | if ((*(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20)& (uint32_t)(1 << (EXTI_Line & 0x1F))) != (uint32_t)RESET) 308 | { 309 | bitstatus = SET; 310 | } 311 | else 312 | { 313 | bitstatus = RESET; 314 | } 315 | return bitstatus; 316 | 317 | } 318 | 319 | /** 320 | * @brief Clears the EXTI's line pending bits. 321 | * @param EXTI_Line: specifies the EXTI lines to clear. 322 | * This parameter can be any combination of EXTI_Linex where x can be (0..20). 323 | * @retval None 324 | */ 325 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line) 326 | { 327 | /* Check the parameters */ 328 | assert_param(IS_EXTI_LINE_EXT(EXTI_Line)); 329 | 330 | *(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20) = (1 << (EXTI_Line & 0x1F)); 331 | } 332 | 333 | /** 334 | * @} 335 | */ 336 | 337 | /** 338 | * @} 339 | */ 340 | 341 | /** 342 | * @} 343 | */ 344 | 345 | /** 346 | * @} 347 | */ 348 | 349 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 350 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/src/stm32f30x_iwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_iwdg.c 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file provides firmware functions to manage the following 8 | * functionalities of the Independent watchdog (IWDG) peripheral: 9 | * + Prescaler and Counter configuration 10 | * + IWDG activation 11 | * + Flag management 12 | * 13 | @verbatim 14 | 15 | =============================================================================== 16 | ##### IWDG features ##### 17 | =============================================================================== 18 | [..] The IWDG can be started by either software or hardware (configurable 19 | through option byte). 20 | [..] The IWDG is clocked by its own dedicated low-speed clock (LSI) and 21 | thus stays active even if the main clock fails. 22 | Once the IWDG is started, the LSI is forced ON and cannot be disabled 23 | (LSI cannot be disabled too), and the counter starts counting down from 24 | the reset value of 0xFFF. When it reaches the end of count value (0x000) 25 | a system reset is generated. 26 | The IWDG counter should be reloaded at regular intervals to prevent 27 | an MCU reset. 28 | [..] The IWDG is implemented in the VDD voltage domain that is still functional 29 | in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY). 30 | [..] IWDGRST flag in RCC_CSR register can be used to inform when a IWDG 31 | reset occurs. 32 | [..] Min-max timeout value @41KHz (LSI): ~0.1ms / ~25.5s 33 | The IWDG timeout may vary due to LSI frequency dispersion. STM32F30x 34 | devices provide the capability to measure the LSI frequency (LSI clock 35 | connected internally to TIM16 CH1 input capture). The measured value 36 | can be used to have an IWDG timeout with an acceptable accuracy. 37 | For more information, please refer to the STM32F30x Reference manual. 38 | 39 | ##### How to use this driver ##### 40 | =============================================================================== 41 | [..] This driver allows to use IWDG peripheral with either window option enabled 42 | or disabled. To do so follow one of the two procedures below. 43 | (#) Window option is enabled: 44 | (++) Start the IWDG using IWDG_Enable() function, when the IWDG is used 45 | in software mode (no need to enable the LSI, it will be enabled 46 | by hardware). 47 | (++) Enable write access to IWDG_PR and IWDG_RLR registers using 48 | IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable) function. 49 | (++) Configure the IWDG prescaler using IWDG_SetPrescaler() function. 50 | (++) Configure the IWDG counter value using IWDG_SetReload() function. 51 | This value will be loaded in the IWDG counter each time the counter 52 | is reloaded, then the IWDG will start counting down from this value. 53 | (++) Wait for the IWDG registers to be updated using IWDG_GetFlagStatus() function. 54 | (++) Configure the IWDG refresh window using IWDG_SetWindowValue() function. 55 | 56 | (#) Window option is disabled: 57 | (++) Enable write access to IWDG_PR and IWDG_RLR registers using 58 | IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable) function. 59 | (++) Configure the IWDG prescaler using IWDG_SetPrescaler() function. 60 | (++) Configure the IWDG counter value using IWDG_SetReload() function. 61 | This value will be loaded in the IWDG counter each time the counter 62 | is reloaded, then the IWDG will start counting down from this value. 63 | (++) Wait for the IWDG registers to be updated using IWDG_GetFlagStatus() function. 64 | (++) reload the IWDG counter at regular intervals during normal operation 65 | to prevent an MCU reset, using IWDG_ReloadCounter() function. 66 | (++) Start the IWDG using IWDG_Enable() function, when the IWDG is used 67 | in software mode (no need to enable the LSI, it will be enabled 68 | by hardware). 69 | 70 | @endverbatim 71 | 72 | ****************************************************************************** 73 | * @attention 74 | * 75 | *

© COPYRIGHT 2015 STMicroelectronics

76 | * 77 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 78 | * You may not use this file except in compliance with the License. 79 | * You may obtain a copy of the License at: 80 | * 81 | * http://www.st.com/software_license_agreement_liberty_v2 82 | * 83 | * Unless required by applicable law or agreed to in writing, software 84 | * distributed under the License is distributed on an "AS IS" BASIS, 85 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 86 | * See the License for the specific language governing permissions and 87 | * limitations under the License. 88 | * 89 | ****************************************************************************** 90 | */ 91 | 92 | /* Includes ------------------------------------------------------------------*/ 93 | #include "stm32f30x_iwdg.h" 94 | 95 | /** @addtogroup STM32F30x_StdPeriph_Driver 96 | * @{ 97 | */ 98 | 99 | /** @defgroup IWDG 100 | * @brief IWDG driver modules 101 | * @{ 102 | */ 103 | 104 | /* Private typedef -----------------------------------------------------------*/ 105 | /* Private define ------------------------------------------------------------*/ 106 | /* ---------------------- IWDG registers bit mask ----------------------------*/ 107 | /* KR register bit mask */ 108 | #define KR_KEY_RELOAD ((uint16_t)0xAAAA) 109 | #define KR_KEY_ENABLE ((uint16_t)0xCCCC) 110 | 111 | /* Private macro -------------------------------------------------------------*/ 112 | /* Private variables ---------------------------------------------------------*/ 113 | /* Private function prototypes -----------------------------------------------*/ 114 | /* Private functions ---------------------------------------------------------*/ 115 | 116 | /** @defgroup IWDG_Private_Functions 117 | * @{ 118 | */ 119 | 120 | /** @defgroup IWDG_Group1 Prescaler and Counter configuration functions 121 | * @brief Prescaler and Counter configuration functions 122 | * 123 | @verbatim 124 | =============================================================================== 125 | ##### Prescaler and Counter configuration functions ##### 126 | =============================================================================== 127 | 128 | @endverbatim 129 | * @{ 130 | */ 131 | 132 | /** 133 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. 134 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. 135 | * This parameter can be one of the following values: 136 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers 137 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers 138 | * @retval None 139 | */ 140 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) 141 | { 142 | /* Check the parameters */ 143 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); 144 | IWDG->KR = IWDG_WriteAccess; 145 | } 146 | 147 | /** 148 | * @brief Sets IWDG Prescaler value. 149 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. 150 | * This parameter can be one of the following values: 151 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 152 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 153 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 154 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 155 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 156 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 157 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 158 | * @retval None 159 | */ 160 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) 161 | { 162 | /* Check the parameters */ 163 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); 164 | IWDG->PR = IWDG_Prescaler; 165 | } 166 | 167 | /** 168 | * @brief Sets IWDG Reload value. 169 | * @param Reload: specifies the IWDG Reload value. 170 | * This parameter must be a number between 0 and 0x0FFF. 171 | * @retval None 172 | */ 173 | void IWDG_SetReload(uint16_t Reload) 174 | { 175 | /* Check the parameters */ 176 | assert_param(IS_IWDG_RELOAD(Reload)); 177 | IWDG->RLR = Reload; 178 | } 179 | 180 | /** 181 | * @brief Reloads IWDG counter with value defined in the reload register 182 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 183 | * @param None 184 | * @retval None 185 | */ 186 | void IWDG_ReloadCounter(void) 187 | { 188 | IWDG->KR = KR_KEY_RELOAD; 189 | } 190 | 191 | 192 | /** 193 | * @brief Sets the IWDG window value. 194 | * @param WindowValue: specifies the window value to be compared to the downcounter. 195 | * @retval None 196 | */ 197 | void IWDG_SetWindowValue(uint16_t WindowValue) 198 | { 199 | /* Check the parameters */ 200 | assert_param(IS_IWDG_WINDOW_VALUE(WindowValue)); 201 | IWDG->WINR = WindowValue; 202 | } 203 | 204 | /** 205 | * @} 206 | */ 207 | 208 | /** @defgroup IWDG_Group2 IWDG activation function 209 | * @brief IWDG activation function 210 | * 211 | @verbatim 212 | =============================================================================== 213 | ##### IWDG activation function ##### 214 | =============================================================================== 215 | 216 | @endverbatim 217 | * @{ 218 | */ 219 | 220 | /** 221 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). 222 | * @param None 223 | * @retval None 224 | */ 225 | void IWDG_Enable(void) 226 | { 227 | IWDG->KR = KR_KEY_ENABLE; 228 | } 229 | 230 | /** 231 | * @} 232 | */ 233 | 234 | /** @defgroup IWDG_Group3 Flag management function 235 | * @brief Flag management function 236 | * 237 | @verbatim 238 | =============================================================================== 239 | ##### Flag management function ##### 240 | =============================================================================== 241 | 242 | @endverbatim 243 | * @{ 244 | */ 245 | 246 | /** 247 | * @brief Checks whether the specified IWDG flag is set or not. 248 | * @param IWDG_FLAG: specifies the flag to check. 249 | * This parameter can be one of the following values: 250 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going 251 | * @arg IWDG_FLAG_RVU: Reload Value Update on going 252 | * @arg IWDG_FLAG_WVU: Counter Window Value Update on going 253 | * @retval The new state of IWDG_FLAG (SET or RESET). 254 | */ 255 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) 256 | { 257 | FlagStatus bitstatus = RESET; 258 | /* Check the parameters */ 259 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); 260 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) 261 | { 262 | bitstatus = SET; 263 | } 264 | else 265 | { 266 | bitstatus = RESET; 267 | } 268 | /* Return the flag status */ 269 | return bitstatus; 270 | } 271 | 272 | /** 273 | * @} 274 | */ 275 | 276 | /** 277 | * @} 278 | */ 279 | 280 | /** 281 | * @} 282 | */ 283 | 284 | /** 285 | * @} 286 | */ 287 | 288 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 289 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/src/stm32f30x_misc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_misc.c 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file provides all the miscellaneous firmware functions (add-on 8 | * to CMSIS functions). 9 | * 10 | @verbatim 11 | 12 | =============================================================================== 13 | ##### How to configure Interrupts using driver ##### 14 | =============================================================================== 15 | [..] This section provide functions allowing to configure the NVIC interrupts 16 | (IRQ). The Cortex-M4 exceptions are managed by CMSIS functions. 17 | (#) Configure the NVIC Priority Grouping using NVIC_PriorityGroupConfig() 18 | function according to the following table. 19 | The table below gives the allowed values of the pre-emption priority 20 | and subpriority according to the Priority Grouping configuration 21 | performed by NVIC_PriorityGroupConfig function. 22 | 23 | (#) Enable and Configure the priority of the selected IRQ Channels. 24 | [..] 25 | (@) When the NVIC_PriorityGroup_0 is selected, it will no any nested interrupt, 26 | the IRQ priority will be managed only by subpriority. 27 | The sub-priority is only used to sort pending exception priorities, 28 | and does not affect active exceptions. 29 | (@) Lower priority values gives higher priority. 30 | (@) Priority Order: 31 | (#@) Lowest Preemption priority. 32 | (#@) Lowest Subpriority. 33 | (#@) Lowest hardware priority (IRQn position). 34 | 35 | @endverbatim 36 | 37 | ****************************************************************************** 38 | * @attention 39 | * 40 | *

© COPYRIGHT 2015 STMicroelectronics

41 | * 42 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 43 | * You may not use this file except in compliance with the License. 44 | * You may obtain a copy of the License at: 45 | * 46 | * http://www.st.com/software_license_agreement_liberty_v2 47 | * 48 | * Unless required by applicable law or agreed to in writing, software 49 | * distributed under the License is distributed on an "AS IS" BASIS, 50 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 51 | * See the License for the specific language governing permissions and 52 | * limitations under the License. 53 | * 54 | ****************************************************************************** 55 | */ 56 | 57 | /* Includes ------------------------------------------------------------------*/ 58 | #include "stm32f30x_misc.h" 59 | 60 | /** @addtogroup STM32F30x_StdPeriph_Driver 61 | * @{ 62 | */ 63 | 64 | /** @defgroup MISC 65 | * @brief MISC driver modules 66 | * @{ 67 | */ 68 | 69 | /* Private typedef -----------------------------------------------------------*/ 70 | /* Private define ------------------------------------------------------------*/ 71 | #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000) 72 | 73 | /* Private macro -------------------------------------------------------------*/ 74 | /* Private variables ---------------------------------------------------------*/ 75 | /* Private function prototypes -----------------------------------------------*/ 76 | /* Private functions ---------------------------------------------------------*/ 77 | 78 | /** @defgroup MISC_Private_Functions 79 | * @{ 80 | */ 81 | 82 | /** 83 | * @brief Configures the priority grouping: pre-emption priority and subpriority. 84 | * @param NVIC_PriorityGroup: specifies the priority grouping bits length. 85 | * This parameter can be one of the following values: 86 | * @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority. 87 | * 4 bits for subpriority. 88 | * @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority. 89 | * 3 bits for subpriority. 90 | * @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority. 91 | * 2 bits for subpriority. 92 | * @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority. 93 | * 1 bits for subpriority. 94 | * @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority. 95 | * 0 bits for subpriority. 96 | * @note When NVIC_PriorityGroup_0 is selected, it will no be any nested 97 | * interrupt. This interrupts priority is managed only with subpriority. 98 | * @retval None 99 | */ 100 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup) 101 | { 102 | /* Check the parameters */ 103 | assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup)); 104 | 105 | /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */ 106 | SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup; 107 | } 108 | 109 | /** 110 | * @brief Initializes the NVIC peripheral according to the specified 111 | * parameters in the NVIC_InitStruct. 112 | * @note To configure interrupts priority correctly, the NVIC_PriorityGroupConfig() 113 | * function should be called before. 114 | * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains 115 | * the configuration information for the specified NVIC peripheral. 116 | * @retval None 117 | */ 118 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct) 119 | { 120 | uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F; 121 | 122 | /* Check the parameters */ 123 | assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd)); 124 | assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority)); 125 | assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority)); 126 | 127 | if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE) 128 | { 129 | /* Compute the Corresponding IRQ Priority --------------------------------*/ 130 | tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08; 131 | tmppre = (0x4 - tmppriority); 132 | tmpsub = tmpsub >> tmppriority; 133 | 134 | tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre; 135 | tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub; 136 | tmppriority = tmppriority << 0x04; 137 | 138 | NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority; 139 | 140 | /* Enable the Selected IRQ Channels --------------------------------------*/ 141 | NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = 142 | (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 143 | } 144 | else 145 | { 146 | /* Disable the Selected IRQ Channels -------------------------------------*/ 147 | NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = 148 | (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 149 | } 150 | } 151 | 152 | /** 153 | * @brief Sets the vector table location and Offset. 154 | * @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory. 155 | * This parameter can be one of the following values: 156 | * @arg NVIC_VectTab_RAM 157 | * @arg NVIC_VectTab_FLASH 158 | * @param Offset: Vector Table base offset field. This value must be a multiple of 0x200. 159 | * @retval None 160 | */ 161 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset) 162 | { 163 | /* Check the parameters */ 164 | assert_param(IS_NVIC_VECTTAB(NVIC_VectTab)); 165 | assert_param(IS_NVIC_OFFSET(Offset)); 166 | 167 | SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80); 168 | } 169 | 170 | /** 171 | * @brief Selects the condition for the system to enter low power mode. 172 | * @param LowPowerMode: Specifies the new mode for the system to enter low power mode. 173 | * This parameter can be one of the following values: 174 | * @arg NVIC_LP_SEVONPEND 175 | * @arg NVIC_LP_SLEEPDEEP 176 | * @arg NVIC_LP_SLEEPONEXIT 177 | * @param NewState: new state of LP condition. This parameter can be: ENABLE or DISABLE. 178 | * @retval None 179 | */ 180 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState) 181 | { 182 | /* Check the parameters */ 183 | assert_param(IS_NVIC_LP(LowPowerMode)); 184 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 185 | 186 | if (NewState != DISABLE) 187 | { 188 | SCB->SCR |= LowPowerMode; 189 | } 190 | else 191 | { 192 | SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode); 193 | } 194 | } 195 | 196 | /** 197 | * @brief Configures the SysTick clock source. 198 | * @param SysTick_CLKSource: specifies the SysTick clock source. 199 | * This parameter can be one of the following values: 200 | * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source. 201 | * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source. 202 | * @retval None 203 | */ 204 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource) 205 | { 206 | /* Check the parameters */ 207 | assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource)); 208 | if (SysTick_CLKSource == SysTick_CLKSource_HCLK) 209 | { 210 | SysTick->CTRL |= SysTick_CLKSource_HCLK; 211 | } 212 | else 213 | { 214 | SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8; 215 | } 216 | } 217 | 218 | /** 219 | * @} 220 | */ 221 | 222 | /** 223 | * @} 224 | */ 225 | 226 | /** 227 | * @} 228 | */ 229 | 230 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 231 | -------------------------------------------------------------------------------- /Drivers/STM32F30x_StdPeriph_Driver/src/stm32f30x_wwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_wwdg.c 4 | * @author MCD Application Team 5 | * @version V1.2.3 6 | * @date 10-July-2015 7 | * @brief This file provides firmware functions to manage the following 8 | * functionalities of the Window watchdog (WWDG) peripheral: 9 | * + Prescaler, Refresh window and Counter configuration 10 | * + WWDG activation 11 | * + Interrupts and flags management 12 | * 13 | * @verbatim 14 | * 15 | ============================================================================== 16 | ##### WWDG features ##### 17 | ============================================================================== 18 | 19 | [..] Once enabled the WWDG generates a system reset on expiry of a programmed 20 | time period, unless the program refreshes the counter (downcounter) 21 | before to reach 0x3F value (i.e. a reset is generated when the counter 22 | value rolls over from 0x40 to 0x3F). 23 | [..] An MCU reset is also generated if the counter value is refreshed 24 | before the counter has reached the refresh window value. This 25 | implies that the counter must be refreshed in a limited window. 26 | 27 | [..] Once enabled the WWDG cannot be disabled except by a system reset. 28 | 29 | [..] WWDGRST flag in RCC_CSR register can be used to inform when a WWDG 30 | reset occurs. 31 | 32 | [..] The WWDG counter input clock is derived from the APB clock divided 33 | by a programmable prescaler. 34 | 35 | [..] WWDG counter clock = PCLK1 / Prescaler. 36 | [..] WWDG timeout = (WWDG counter clock) * (counter value). 37 | 38 | [..] Min-max timeout value @36MHz (PCLK1): ~114us / ~58.3ms. 39 | 40 | ##### How to use this driver ##### 41 | ============================================================================== 42 | [..] 43 | (#) Enable WWDG clock using RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE) 44 | function. 45 | 46 | (#) Configure the WWDG prescaler using WWDG_SetPrescaler() function. 47 | 48 | (#) Configure the WWDG refresh window using WWDG_SetWindowValue() function. 49 | 50 | (#) Set the WWDG counter value and start it using WWDG_Enable() function. 51 | When the WWDG is enabled the counter value should be configured to 52 | a value greater than 0x40 to prevent generating an immediate reset. 53 | 54 | (#) Optionally you can enable the Early wakeup interrupt which is 55 | generated when the counter reach 0x40. 56 | Once enabled this interrupt cannot be disabled except by a system reset. 57 | 58 | (#) Then the application program must refresh the WWDG counter at regular 59 | intervals during normal operation to prevent an MCU reset, using 60 | WWDG_SetCounter() function. This operation must occur only when 61 | the counter value is lower than the refresh window value, 62 | programmed using WWDG_SetWindowValue(). 63 | 64 | @endverbatim 65 | 66 | ****************************************************************************** 67 | * @attention 68 | * 69 | *

© COPYRIGHT 2015 STMicroelectronics

70 | * 71 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 72 | * You may not use this file except in compliance with the License. 73 | * You may obtain a copy of the License at: 74 | * 75 | * http://www.st.com/software_license_agreement_liberty_v2 76 | * 77 | * Unless required by applicable law or agreed to in writing, software 78 | * distributed under the License is distributed on an "AS IS" BASIS, 79 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 80 | * See the License for the specific language governing permissions and 81 | * limitations under the License. 82 | * 83 | ****************************************************************************** 84 | */ 85 | 86 | /* Includes ------------------------------------------------------------------*/ 87 | #include "stm32f30x_wwdg.h" 88 | #include "stm32f30x_rcc.h" 89 | 90 | /** @addtogroup STM32F30x_StdPeriph_Driver 91 | * @{ 92 | */ 93 | 94 | /** @defgroup WWDG 95 | * @brief WWDG driver modules 96 | * @{ 97 | */ 98 | 99 | /* Private typedef -----------------------------------------------------------*/ 100 | /* Private define ------------------------------------------------------------*/ 101 | /* --------------------- WWDG registers bit mask ---------------------------- */ 102 | /* CFR register bit mask */ 103 | #define CFR_WDGTB_MASK ((uint32_t)0xFFFFFE7F) 104 | #define CFR_W_MASK ((uint32_t)0xFFFFFF80) 105 | #define BIT_MASK ((uint8_t)0x7F) 106 | 107 | /* Private macro -------------------------------------------------------------*/ 108 | /* Private variables ---------------------------------------------------------*/ 109 | /* Private function prototypes -----------------------------------------------*/ 110 | /* Private functions ---------------------------------------------------------*/ 111 | 112 | /** @defgroup WWDG_Private_Functions 113 | * @{ 114 | */ 115 | 116 | /** @defgroup WWDG_Group1 Prescaler, Refresh window and Counter configuration functions 117 | * @brief Prescaler, Refresh window and Counter configuration functions 118 | * 119 | @verbatim 120 | ============================================================================== 121 | ##### Prescaler, Refresh window and Counter configuration functions ##### 122 | ============================================================================== 123 | 124 | @endverbatim 125 | * @{ 126 | */ 127 | 128 | /** 129 | * @brief Deinitializes the WWDG peripheral registers to their default reset values. 130 | * @param None 131 | * @retval None 132 | */ 133 | void WWDG_DeInit(void) 134 | { 135 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE); 136 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE); 137 | } 138 | 139 | /** 140 | * @brief Sets the WWDG Prescaler. 141 | * @param WWDG_Prescaler: specifies the WWDG Prescaler. 142 | * This parameter can be one of the following values: 143 | * @arg WWDG_Prescaler_1: WWDG counter clock = (PCLK1/4096)/1 144 | * @arg WWDG_Prescaler_2: WWDG counter clock = (PCLK1/4096)/2 145 | * @arg WWDG_Prescaler_4: WWDG counter clock = (PCLK1/4096)/4 146 | * @arg WWDG_Prescaler_8: WWDG counter clock = (PCLK1/4096)/8 147 | * @retval None 148 | */ 149 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler) 150 | { 151 | uint32_t tmpreg = 0; 152 | /* Check the parameters */ 153 | assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler)); 154 | /* Clear WDGTB[1:0] bits */ 155 | tmpreg = WWDG->CFR & CFR_WDGTB_MASK; 156 | /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */ 157 | tmpreg |= WWDG_Prescaler; 158 | /* Store the new value */ 159 | WWDG->CFR = tmpreg; 160 | } 161 | 162 | /** 163 | * @brief Sets the WWDG window value. 164 | * @param WindowValue: specifies the window value to be compared to the downcounter. 165 | * This parameter value must be lower than 0x80. 166 | * @retval None 167 | */ 168 | void WWDG_SetWindowValue(uint8_t WindowValue) 169 | { 170 | __IO uint32_t tmpreg = 0; 171 | 172 | /* Check the parameters */ 173 | assert_param(IS_WWDG_WINDOW_VALUE(WindowValue)); 174 | /* Clear W[6:0] bits */ 175 | 176 | tmpreg = WWDG->CFR & CFR_W_MASK; 177 | 178 | /* Set W[6:0] bits according to WindowValue value */ 179 | tmpreg |= WindowValue & (uint32_t) BIT_MASK; 180 | 181 | /* Store the new value */ 182 | WWDG->CFR = tmpreg; 183 | } 184 | 185 | /** 186 | * @brief Enables the WWDG Early Wakeup interrupt(EWI). 187 | * @note Once enabled this interrupt cannot be disabled except by a system reset. 188 | * @param None 189 | * @retval None 190 | */ 191 | void WWDG_EnableIT(void) 192 | { 193 | WWDG->CFR |= WWDG_CFR_EWI; 194 | } 195 | 196 | /** 197 | * @brief Sets the WWDG counter value. 198 | * @param Counter: specifies the watchdog counter value. 199 | * This parameter must be a number between 0x40 and 0x7F (to prevent generating 200 | * an immediate reset). 201 | * @retval None 202 | */ 203 | void WWDG_SetCounter(uint8_t Counter) 204 | { 205 | /* Check the parameters */ 206 | assert_param(IS_WWDG_COUNTER(Counter)); 207 | /* Write to T[6:0] bits to configure the counter value, no need to do 208 | a read-modify-write; writing a 0 to WDGA bit does nothing */ 209 | WWDG->CR = Counter & BIT_MASK; 210 | } 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /** @defgroup WWDG_Group2 WWDG activation functions 217 | * @brief WWDG activation functions 218 | * 219 | @verbatim 220 | ============================================================================== 221 | ##### WWDG activation function ##### 222 | ============================================================================== 223 | 224 | @endverbatim 225 | * @{ 226 | */ 227 | 228 | /** 229 | * @brief Enables WWDG and load the counter value. 230 | * @param Counter: specifies the watchdog counter value. 231 | * This parameter must be a number between 0x40 and 0x7F (to prevent generating 232 | * an immediate reset). 233 | * @retval None 234 | */ 235 | void WWDG_Enable(uint8_t Counter) 236 | { 237 | /* Check the parameters */ 238 | assert_param(IS_WWDG_COUNTER(Counter)); 239 | WWDG->CR = WWDG_CR_WDGA | Counter; 240 | } 241 | 242 | /** 243 | * @} 244 | */ 245 | 246 | /** @defgroup WWDG_Group3 Interrupts and flags management functions 247 | * @brief Interrupts and flags management functions 248 | * 249 | @verbatim 250 | ============================================================================== 251 | ##### Interrupts and flags management functions ##### 252 | ============================================================================== 253 | 254 | @endverbatim 255 | * @{ 256 | */ 257 | 258 | /** 259 | * @brief Checks whether the Early Wakeup interrupt flag is set or not. 260 | * @param None 261 | * @retval The new state of the Early Wakeup interrupt flag (SET or RESET). 262 | */ 263 | FlagStatus WWDG_GetFlagStatus(void) 264 | { 265 | FlagStatus bitstatus = RESET; 266 | 267 | if ((WWDG->SR) != (uint32_t)RESET) 268 | { 269 | bitstatus = SET; 270 | } 271 | else 272 | { 273 | bitstatus = RESET; 274 | } 275 | return bitstatus; 276 | } 277 | 278 | /** 279 | * @brief Clears Early Wakeup interrupt flag. 280 | * @param None 281 | * @retval None 282 | */ 283 | void WWDG_ClearFlag(void) 284 | { 285 | WWDG->SR = (uint32_t)RESET; 286 | } 287 | 288 | /** 289 | * @} 290 | */ 291 | 292 | /** 293 | * @} 294 | */ 295 | 296 | /** 297 | * @} 298 | */ 299 | 300 | /** 301 | * @} 302 | */ 303 | 304 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 305 | -------------------------------------------------------------------------------- /Image/debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Serj-Bashlayev/STM32_Profiler/641f239e0f976ccf938f5eb9c60f15e1a6f4e659/Image/debug.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Sergey Bashlayev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MDK-ARM/PROFILER.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | del "OUTPUTFILE.TXT" 3 | UV4.exe -b %1 -j0 -o"OUTPUTFILE.TXT" 4 | echo. 5 | echo ================================================================ BUILD LOG ================================================================ 6 | type OUTPUTFILE.TXT 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Code profiling for STM32 2 | === 3 | 4 | Features 5 | --- 6 | Simple and fast code profiler for STM32 ARM Cortex-M CPU family. 7 | Allow measuring time intervals and printing it in table view to SWO debug port. 8 | Use Data Watchpoint and Trace (DWT) cycle counter (DWT_CYCCNT). 9 | >*Example data print* 10 | ``` 11 | Profiling "Start" sequence: 12 | --Event-----------------------|--timestamp--|---delta_t---- 13 | GLCD_Init : 41 us | + 41 us 14 | OLED_Init : 5288 us | + 5247 us 15 | u8g_SetFont : 5292 us | + 4 us 16 | HAL_Delay(10) : 10004967 us | + 9999675 us 17 | ``` 18 | Minimum measure time = 0 µs 19 | Maximum measure time = 59,6 sec at core clock 72 MHz 20 | Time accuracy ±1 µs. 21 | 22 | Easy to use. Easy to port to another ARM architecture and programming language. 23 | 24 | *Technical background: 25 | SWO is a dedicated pin of ARM's Cortex-M debug interface. While it can be used to output various information in real time by the CPU, it's main usage is terminal I/O in real time with very low intrusion. Most programs can perform debug outputs without losing their real time behavior.* 26 | *Cycle Count Register (DWT_CYCCNT): 32-bit, incrementing (up) cycle counter. When enabled, this counter counts the number of core cycles. Counting is suspended when the core is halted in Debug state. CYCCNT wraps to 0 on overflow.* 27 | 28 | How to use 29 | --- 30 | start profiling session 31 | **`PROFILING_START("*session name*");`** 32 | 33 | Insert timestamp command as many times as necessary.[[1]](#notes) 34 | **`PROFILING_EVENT("*event name*");`** 35 | 36 | close profiling session and read it times on Serial wire viewer (SWV) 37 | **`PROFILING_STOP();`** 38 | 39 | 40 | 41 | > *Example code* 42 | ```c 43 | int main(void) 44 | { 45 | SysTick_Config(SystemCoreClock / 1000); 46 | 47 | PROFILING_START("MAIN startup timing"); 48 | 49 | Init_IO(); 50 | PROFILING_EVENT("IO_Init()"); 51 | 52 | Init_TIM6(); 53 | PROFILING_EVENT("TIM6_Init()"); 54 | 55 | PROFILING_STOP(); 56 | 57 | while (1) 58 | { 59 | PROFILING_START("MAIN loop timing"); 60 | 61 | GPIO_WriteBit(GPIOE, GPIO_Pin_9, (((Tick % 1000) > 500) ? Bit_SET : Bit_RESET)); 62 | PROFILING_EVENT("GPIO_WriteBit(...)"); 63 | 64 | // Wait for update Tick 65 | delay_tick = Tick; 66 | while (delay_tick == Tick); 67 | PROFILING_EVENT("Wait for update Tick"); 68 | 69 | // Delay 1000 ms 70 | delay_tick = Tick + 1000; 71 | while (delay_tick > Tick); 72 | PROFILING_EVENT("DELAY 1 s"); 73 | 74 | // Stop profiling and print 75 | PROFILING_STOP(); 76 | } 77 | } 78 | ``` 79 | 80 | 81 | > *Debug (printf) Viewer example* 82 | ``` 83 | Profiling "MAIN startup timing" sequence: 84 | --Event-----------------------|--timestamp--|----delta_t--- 85 | IO_Init() : 9 µs | + 9 µs 86 | TIM6_Init() : 18 µs | + 8 µs 87 | 88 | Profiling "MAIN loop timing" sequence: 89 | --Event-----------------------|--timestamp--|----delta_t--- 90 | GPIO_WriteBit(...) : 1 µs | + 1 µs 91 | Wait for update Tick : 797 µs | + 795 µs 92 | DELAY 1 s : 1000797 µs | + 999999 µs 93 | 94 | ``` 95 | ![Keil µVision Debug (printf) Viewer](Image/debug.png) 96 | ------------- 97 | For more information, how to use the Keil µVision Debug (printf) Viewer see http://www.keil.com/support/man/docs/ulink2/ulink2_trace_itm_viewer.htm 98 | You can also use ST-LINK - Printf via SWO viewer feature or other debugging software with SWO Viewer support. 99 | 100 | ------------- 101 | `note 1` The maximum number of events is defined in MAX_EVENT_COUNT (profiling.h) 102 | -------------------------------------------------------------------------------- /Src/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file main.c 4 | * @author MCD Application Team 5 | * @version V1.1.2 6 | * @date 14-August-2015 7 | * @brief Main program body 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f30x.h" 30 | #include "profiling.h" 31 | #include 32 | 33 | extern __IO int32_t Tick; 34 | /* Private variables ---------------------------------------------------------*/ 35 | static int32_t delay_tick; 36 | 37 | /* Private function prototypes -----------------------------------------------*/ 38 | static void Init_TIM6(void); 39 | static void Init_IO(void); 40 | 41 | 42 | /** 43 | * @brief Timer6 interrupt handler (1 kHz) 44 | */ 45 | void TIM6_DAC_IRQHandler(void) 46 | { 47 | static uint16_t delayT6_sec = 0; 48 | static bool trigger = false; 49 | 50 | // TIM6 interrup owerflow 51 | if (TIM_GetITStatus(TIM6, TIM_IT_Update) == SET) 52 | { 53 | TIM_ClearITPendingBit(TIM6, TIM_IT_Update); 54 | // Led blink 1 Hz 55 | if (++delayT6_sec >= 500) 56 | { 57 | delayT6_sec = 0; 58 | trigger = !trigger; 59 | GPIO_WriteBit(GPIOE, GPIO_Pin_8, (trigger ? Bit_SET : Bit_RESET)); 60 | } 61 | } 62 | } 63 | 64 | 65 | /** 66 | * @brief MAIN 67 | */ 68 | int main(void) 69 | { 70 | SysTick_Config(SystemCoreClock / 1000); 71 | 72 | PROFILING_START("MAIN startup timing"); 73 | 74 | Init_IO(); 75 | PROFILING_EVENT("IO_Init()"); 76 | 77 | Init_TIM6(); 78 | PROFILING_EVENT("TIM6_Init()"); 79 | PROFILING_STOP(); 80 | 81 | while (1) 82 | { 83 | PROFILING_START("MAIN loop timing"); 84 | 85 | GPIO_WriteBit(GPIOE, GPIO_Pin_9, (((Tick % 1000) > 500) ? Bit_SET : Bit_RESET)); 86 | PROFILING_EVENT("GPIO_WriteBit(...)"); 87 | 88 | // Wait for update Tick 89 | delay_tick = Tick; 90 | while (delay_tick == Tick); 91 | PROFILING_EVENT("Wait for update Tick"); 92 | 93 | // Delay 1000 ms 94 | delay_tick = Tick + 1000; 95 | while (delay_tick > Tick); 96 | PROFILING_EVENT("DELAY 1 s"); 97 | 98 | // Stop profiling and print 99 | PROFILING_STOP(); 100 | } 101 | } 102 | 103 | 104 | /** 105 | * @brief Configure LEDs CPIO PE8, PE9, PE10 106 | */ 107 | static void Init_IO(void) 108 | { 109 | GPIO_InitTypeDef GPIO_InitStructure; 110 | 111 | /* GPIOE clock enable */ 112 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE); 113 | 114 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10; 115 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; 116 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 117 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 118 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; 119 | GPIO_Init(GPIOE, &GPIO_InitStructure); 120 | } 121 | 122 | 123 | /** 124 | * @brief TIM6 init function. 1kHz interrupt 125 | */ 126 | static void Init_TIM6(void) 127 | { 128 | NVIC_InitTypeDef NVIC_InitStructure; 129 | TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; 130 | 131 | /* TIM6 clock enable */ 132 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE); 133 | 134 | /* Enable the TIM6 gloabal Interrupt */ 135 | NVIC_InitStructure.NVIC_IRQChannel = TIM6_DAC_IRQn; 136 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; 137 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; 138 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 139 | NVIC_Init(&NVIC_InitStructure); 140 | 141 | /* Time base configuration */ 142 | TIM_TimeBaseStructure.TIM_Period = 1; 143 | TIM_TimeBaseStructure.TIM_Prescaler = 35999; 144 | TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; 145 | TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure); 146 | 147 | /* TIM enable counter */ 148 | TIM_Cmd(TIM6, ENABLE); 149 | 150 | /* TIM Interrupts enable */ 151 | TIM_ITConfig(TIM6, TIM_IT_Update, ENABLE); 152 | } 153 | 154 | -------------------------------------------------------------------------------- /Src/profiling.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Serj-Bashlayev/STM32_Profiler/641f239e0f976ccf938f5eb9c60f15e1a6f4e659/Src/profiling.c -------------------------------------------------------------------------------- /Src/profiling.h: -------------------------------------------------------------------------------- 1 | #ifndef _PROFILING_H 2 | #define _PROFILING_H 3 | 4 | #include "stm32f30x.h" 5 | //#include "stm32f1xx_hal.h" 6 | #include 7 | #include 8 | 9 | #define MAX_EVENT_COUNT 20 10 | 11 | void PROFILING_START(const char *profile_name); 12 | void PROFILING_EVENT(const char *event); 13 | void PROFILING_STOP(void); 14 | 15 | #endif // _PROFILING_H 16 | -------------------------------------------------------------------------------- /Src/stm32f30x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_conf.h 4 | * @author MCD Application Team 5 | * @version V1.2.2 6 | * @date 14-August-2015 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F30X_CONF_H 30 | #define __STM32F30X_CONF_H 31 | 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | /* Comment the line below to disable peripheral header file inclusion */ 35 | //#include "stm32f30x_adc.h" 36 | //#include "stm32f30x_can.h" 37 | //#include "stm32f30x_crc.h" 38 | //#include "stm32f30x_comp.h" 39 | //#include "stm32f30x_dac.h" 40 | //#include "stm32f30x_dbgmcu.h" 41 | //#include "stm32f30x_dma.h" 42 | //#include "stm32f30x_exti.h" 43 | //#include "stm32f30x_flash.h" 44 | //#include "stm32f30x_fmc.h" 45 | #include "stm32f30x_gpio.h" 46 | //#include "stm32f30x_hrtim.h" 47 | //#include "stm32f30x_syscfg.h" 48 | //#include "stm32f30x_i2c.h" 49 | //#include "stm32f30x_iwdg.h" 50 | //#include "stm32f30x_opamp.h" 51 | //#include "stm32f30x_pwr.h" 52 | #include "stm32f30x_rcc.h" 53 | //#include "stm32f30x_rtc.h" 54 | //#include "stm32f30x_spi.h" 55 | #include "stm32f30x_tim.h" 56 | //#include "stm32f30x_usart.h" 57 | //#include "stm32f30x_wwdg.h" 58 | #include "stm32f30x_misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 59 | 60 | /* Exported types ------------------------------------------------------------*/ 61 | /* Exported constants --------------------------------------------------------*/ 62 | /* Uncomment the line below to expanse the "assert_param" macro in the 63 | Standard Peripheral Library drivers code */ 64 | /* #define USE_FULL_ASSERT 1 */ 65 | 66 | /* Exported macro ------------------------------------------------------------*/ 67 | #ifdef USE_FULL_ASSERT 68 | 69 | /** 70 | * @brief The assert_param macro is used for function's parameters check. 71 | * @param expr: If expr is false, it calls assert_failed function which reports 72 | * the name of the source file and the source line number of the call 73 | * that failed. If expr is true, it returns no value. 74 | * @retval None 75 | */ 76 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 77 | /* Exported functions ------------------------------------------------------- */ 78 | void assert_failed(uint8_t* file, uint32_t line); 79 | #else 80 | #define assert_param(expr) ((void)0) 81 | #endif /* USE_FULL_ASSERT */ 82 | 83 | #endif /* __STM32F30X_CONF_H */ 84 | 85 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 86 | -------------------------------------------------------------------------------- /Src/stm32f30x_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_it.c 4 | * @author MCD Application Team 5 | * @version V1.2.2 6 | * @date 14-August-2015 7 | * @brief Main Interrupt Service Routines. 8 | * This file provides template for all exceptions handler and 9 | * peripherals interrupt service routine. 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© COPYRIGHT 2015 STMicroelectronics

14 | * 15 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 16 | * You may not use this file except in compliance with the License. 17 | * You may obtain a copy of the License at: 18 | * 19 | * http://www.st.com/software_license_agreement_liberty_v2 20 | * 21 | * Unless required by applicable law or agreed to in writing, software 22 | * distributed under the License is distributed on an "AS IS" BASIS, 23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | * See the License for the specific language governing permissions and 25 | * limitations under the License. 26 | * 27 | ****************************************************************************** 28 | */ 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f30x.h" 32 | #include "stm32f30x_it.h" 33 | 34 | __IO int32_t Tick; 35 | 36 | /** @addtogroup STM32F30x_StdPeriph_Templates 37 | * @{ 38 | */ 39 | 40 | /* Private typedef -----------------------------------------------------------*/ 41 | /* Private define ------------------------------------------------------------*/ 42 | /* Private macro -------------------------------------------------------------*/ 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* Private function prototypes -----------------------------------------------*/ 45 | /* Private functions ---------------------------------------------------------*/ 46 | 47 | /******************************************************************************/ 48 | /* Cortex-M4 Processor Exceptions Handlers */ 49 | /******************************************************************************/ 50 | 51 | /** 52 | * @brief This function handles NMI exception. 53 | * @param None 54 | * @retval None 55 | */ 56 | void NMI_Handler(void) 57 | { 58 | } 59 | 60 | /** 61 | * @brief This function handles Hard Fault exception. 62 | * @param None 63 | * @retval None 64 | */ 65 | void HardFault_Handler(void) 66 | { 67 | /* Go to infinite loop when Hard Fault exception occurs */ 68 | while (1) 69 | { 70 | } 71 | } 72 | 73 | /** 74 | * @brief This function handles Memory Manage exception. 75 | * @param None 76 | * @retval None 77 | */ 78 | void MemManage_Handler(void) 79 | { 80 | /* Go to infinite loop when Memory Manage exception occurs */ 81 | while (1) 82 | { 83 | } 84 | } 85 | 86 | /** 87 | * @brief This function handles Bus Fault exception. 88 | * @param None 89 | * @retval None 90 | */ 91 | void BusFault_Handler(void) 92 | { 93 | /* Go to infinite loop when Bus Fault exception occurs */ 94 | while (1) 95 | { 96 | } 97 | } 98 | 99 | /** 100 | * @brief This function handles Usage Fault exception. 101 | * @param None 102 | * @retval None 103 | */ 104 | void UsageFault_Handler(void) 105 | { 106 | /* Go to infinite loop when Usage Fault exception occurs */ 107 | while (1) 108 | { 109 | } 110 | } 111 | 112 | /** 113 | * @brief This function handles SVCall exception. 114 | * @param None 115 | * @retval None 116 | */ 117 | void SVC_Handler(void) 118 | { 119 | } 120 | 121 | /** 122 | * @brief This function handles Debug Monitor exception. 123 | * @param None 124 | * @retval None 125 | */ 126 | void DebugMon_Handler(void) 127 | { 128 | } 129 | 130 | /** 131 | * @brief This function handles PendSVC exception. 132 | * @param None 133 | * @retval None 134 | */ 135 | void PendSV_Handler(void) 136 | { 137 | } 138 | 139 | /** 140 | * @brief This function handles SysTick Handler. 141 | * @param None 142 | * @retval None 143 | */ 144 | void SysTick_Handler(void) 145 | { 146 | Tick++; 147 | } 148 | 149 | /******************************************************************************/ 150 | /* STM32F30x Peripherals Interrupt Handlers */ 151 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 152 | /* available peripheral interrupt handler's name please refer to the startup */ 153 | /* file (startup_stm32f30x.s). */ 154 | /******************************************************************************/ 155 | 156 | /** 157 | * @brief This function handles PPP interrupt request. 158 | * @param None 159 | * @retval None 160 | */ 161 | /*void PPP_IRQHandler(void) 162 | { 163 | }*/ 164 | 165 | /** 166 | * @} 167 | */ 168 | 169 | 170 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 171 | -------------------------------------------------------------------------------- /Src/stm32f30x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f30x_it.h 4 | * @author MCD Application Team 5 | * @version V1.2.2 6 | * @date 14-August-2015 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM32F30X_IT_H 30 | #define __STM32F30X_IT_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | //#include "main.h" 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported constants --------------------------------------------------------*/ 41 | /* Exported macro ------------------------------------------------------------*/ 42 | /* Exported functions ------------------------------------------------------- */ 43 | 44 | void NMI_Handler(void); 45 | void HardFault_Handler(void); 46 | void MemManage_Handler(void); 47 | void BusFault_Handler(void); 48 | void UsageFault_Handler(void); 49 | void SVC_Handler(void); 50 | void DebugMon_Handler(void); 51 | void PendSV_Handler(void); 52 | void SysTick_Handler(void); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif /* __STM32F30X_IT_H */ 59 | 60 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 61 | -------------------------------------------------------------------------------- /Src/system_stm32f30x.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f30x.c 4 | * @author MCD Application Team 5 | * @version V1.2.2 6 | * @date 27-February-2015 7 | * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. 8 | * This file contains the system clock configuration for STM32F30x devices, 9 | * and is generated by the clock configuration tool 10 | * stm32f30x_Clock_Configuration_V1.0.0.xls 11 | * 12 | * 1. This file provides two functions and one global variable to be called from 13 | * user application: 14 | * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier 15 | * and Divider factors, AHB/APBx prescalers and Flash settings), 16 | * depending on the configuration made in the clock xls tool. 17 | * This function is called at startup just after reset and 18 | * before branch to main program. This call is made inside 19 | * the "startup_stm32f30x.s" file. 20 | * 21 | * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used 22 | * by the user application to setup the SysTick 23 | * timer or configure other parameters. 24 | * 25 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must 26 | * be called whenever the core clock is changed 27 | * during program execution. 28 | * 29 | * 2. After each device reset the HSI (8 MHz) is used as system clock source. 30 | * Then SystemInit() function is called, in "startup_stm32f30x.s" file, to 31 | * configure the system clock before to branch to main program. 32 | * 33 | * 3. If the system clock source selected by user fails to startup, the SystemInit() 34 | * function will do nothing and HSI still used as system clock source. User can 35 | * add some code to deal with this issue inside the SetSysClock() function. 36 | * 37 | * 4. The default value of HSE crystal is set to 8MHz, refer to "HSE_VALUE" define 38 | * in "stm32f30x.h" file. When HSE is used as system clock source, directly or 39 | * through PLL, and you are using different crystal you have to adapt the HSE 40 | * value to your own configuration. 41 | * 42 | * 5. This file configures the system clock as follows: 43 | *============================================================================= 44 | * Supported STM32F30x device 45 | *----------------------------------------------------------------------------- 46 | * System Clock source | PLL (HSE) 47 | *----------------------------------------------------------------------------- 48 | * SYSCLK(Hz) | 72000000 49 | *----------------------------------------------------------------------------- 50 | * HCLK(Hz) | 72000000 51 | *----------------------------------------------------------------------------- 52 | * AHB Prescaler | 1 53 | *----------------------------------------------------------------------------- 54 | * APB2 Prescaler | 1 55 | *----------------------------------------------------------------------------- 56 | * APB1 Prescaler | 2 57 | *----------------------------------------------------------------------------- 58 | * HSE Frequency(Hz) | 8000000 59 | *---------------------------------------------------------------------------- 60 | * PLLMUL | 9 61 | *----------------------------------------------------------------------------- 62 | * PREDIV | 1 63 | *----------------------------------------------------------------------------- 64 | * USB Clock | DISABLE 65 | *----------------------------------------------------------------------------- 66 | * Flash Latency(WS) | 2 67 | *----------------------------------------------------------------------------- 68 | * Prefetch Buffer | ON 69 | *----------------------------------------------------------------------------- 70 | *============================================================================= 71 | ****************************************************************************** 72 | * @attention 73 | * 74 | *

© COPYRIGHT 2015 STMicroelectronics

75 | * 76 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 77 | * You may not use this file except in compliance with the License. 78 | * You may obtain a copy of the License at: 79 | * 80 | * http://www.st.com/software_license_agreement_liberty_v2 81 | * 82 | * Unless required by applicable law or agreed to in writing, software 83 | * distributed under the License is distributed on an "AS IS" BASIS, 84 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 85 | * See the License for the specific language governing permissions and 86 | * limitations under the License. 87 | * 88 | ****************************************************************************** 89 | */ 90 | /** @addtogroup CMSIS 91 | * @{ 92 | */ 93 | 94 | /** @addtogroup stm32f30x_system 95 | * @{ 96 | */ 97 | 98 | /** @addtogroup STM32F30x_System_Private_Includes 99 | * @{ 100 | */ 101 | 102 | #include "stm32f30x.h" 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /* Private typedef -----------------------------------------------------------*/ 109 | 110 | /** @addtogroup STM32F30x_System_Private_Defines 111 | * @{ 112 | */ 113 | /*!< Uncomment the following line if you need to relocate your vector Table in 114 | Internal SRAM. */ 115 | /* #define VECT_TAB_SRAM */ 116 | #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. 117 | This value must be a multiple of 0x200. */ 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Private macro -------------------------------------------------------------*/ 123 | 124 | /** @addtogroup STM32F30x_System_Private_Variables 125 | * @{ 126 | */ 127 | 128 | uint32_t SystemCoreClock = 72000000; 129 | 130 | __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** @addtogroup STM32F30x_System_Private_FunctionPrototypes 137 | * @{ 138 | */ 139 | 140 | static void SetSysClock(void); 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @addtogroup STM32F30x_System_Private_Functions 147 | * @{ 148 | */ 149 | 150 | /** 151 | * @brief Setup the microcontroller system 152 | * Initialize the Embedded Flash Interface, the PLL and update the 153 | * SystemFrequency variable. 154 | * @param None 155 | * @retval None 156 | */ 157 | void SystemInit(void) 158 | { 159 | /* FPU settings ------------------------------------------------------------*/ 160 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) 161 | SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ 162 | #endif 163 | 164 | /* Reset the RCC clock configuration to the default reset state ------------*/ 165 | /* Set HSION bit */ 166 | RCC->CR |= (uint32_t)0x00000001; 167 | 168 | /* Reset CFGR register */ 169 | RCC->CFGR &= 0xF87FC00C; 170 | 171 | /* Reset HSEON, CSSON and PLLON bits */ 172 | RCC->CR &= (uint32_t)0xFEF6FFFF; 173 | 174 | /* Reset HSEBYP bit */ 175 | RCC->CR &= (uint32_t)0xFFFBFFFF; 176 | 177 | /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE bits */ 178 | RCC->CFGR &= (uint32_t)0xFF80FFFF; 179 | 180 | /* Reset PREDIV1[3:0] bits */ 181 | RCC->CFGR2 &= (uint32_t)0xFFFFFFF0; 182 | 183 | /* Reset USARTSW[1:0], I2CSW and TIMs bits */ 184 | RCC->CFGR3 &= (uint32_t)0xFF00FCCC; 185 | 186 | /* Disable all interrupts */ 187 | RCC->CIR = 0x00000000; 188 | 189 | /* Configure the System clock source, PLL Multiplier and Divider factors, 190 | AHB/APBx prescalers and Flash settings ----------------------------------*/ 191 | SetSysClock(); 192 | 193 | #ifdef VECT_TAB_SRAM 194 | SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ 195 | #else 196 | SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ 197 | #endif 198 | } 199 | 200 | /** 201 | * @brief Update SystemCoreClock variable according to Clock Register Values. 202 | * The SystemCoreClock variable contains the core clock (HCLK), it can 203 | * be used by the user application to setup the SysTick timer or configure 204 | * other parameters. 205 | * 206 | * @note Each time the core clock (HCLK) changes, this function must be called 207 | * to update SystemCoreClock variable value. Otherwise, any configuration 208 | * based on this variable will be incorrect. 209 | * 210 | * @note - The system frequency computed by this function is not the real 211 | * frequency in the chip. It is calculated based on the predefined 212 | * constant and the selected clock source: 213 | * 214 | * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) 215 | * 216 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) 217 | * 218 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) 219 | * or HSI_VALUE(*) multiplied/divided by the PLL factors. 220 | * 221 | * (*) HSI_VALUE is a constant defined in stm32f30x.h file (default value 222 | * 8 MHz) but the real value may vary depending on the variations 223 | * in voltage and temperature. 224 | * 225 | * (**) HSE_VALUE is a constant defined in stm32f30x.h file (default value 226 | * 8 MHz), user has to ensure that HSE_VALUE is same as the real 227 | * frequency of the crystal used. Otherwise, this function may 228 | * have wrong result. 229 | * 230 | * - The result of this function could be not correct when using fractional 231 | * value for HSE crystal. 232 | * 233 | * @param None 234 | * @retval None 235 | */ 236 | void SystemCoreClockUpdate (void) 237 | { 238 | uint32_t tmp = 0, pllmull = 0, pllsource = 0, prediv1factor = 0; 239 | 240 | /* Get SYSCLK source -------------------------------------------------------*/ 241 | tmp = RCC->CFGR & RCC_CFGR_SWS; 242 | 243 | switch (tmp) 244 | { 245 | case 0x00: /* HSI used as system clock */ 246 | SystemCoreClock = HSI_VALUE; 247 | break; 248 | case 0x04: /* HSE used as system clock */ 249 | SystemCoreClock = HSE_VALUE; 250 | break; 251 | case 0x08: /* PLL used as system clock */ 252 | /* Get PLL clock source and multiplication factor ----------------------*/ 253 | pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; 254 | pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; 255 | pllmull = ( pllmull >> 18) + 2; 256 | 257 | if (pllsource == 0x00) 258 | { 259 | /* HSI oscillator clock divided by 2 selected as PLL clock entry */ 260 | SystemCoreClock = (HSI_VALUE >> 1) * pllmull; 261 | } 262 | else 263 | { 264 | prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; 265 | /* HSE oscillator clock selected as PREDIV1 clock entry */ 266 | SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; 267 | } 268 | break; 269 | default: /* HSI used as system clock */ 270 | SystemCoreClock = HSI_VALUE; 271 | break; 272 | } 273 | /* Compute HCLK clock frequency ----------------*/ 274 | /* Get HCLK prescaler */ 275 | tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; 276 | /* HCLK clock frequency */ 277 | SystemCoreClock >>= tmp; 278 | } 279 | 280 | /** 281 | * @brief Configures the System clock source, PLL Multiplier and Divider factors, 282 | * AHB/APBx prescalers and Flash settings 283 | * @note This function should be called only once the RCC clock configuration 284 | * is reset to the default reset state (done in SystemInit() function). 285 | * @param None 286 | * @retval None 287 | */ 288 | static void SetSysClock(void) 289 | { 290 | __IO uint32_t StartUpCounter = 0, HSEStatus = 0; 291 | 292 | /******************************************************************************/ 293 | /* PLL (clocked by HSE) used as System clock source */ 294 | /******************************************************************************/ 295 | 296 | /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------*/ 297 | /* Enable HSE */ 298 | RCC->CR |= ((uint32_t)RCC_CR_HSEON); 299 | 300 | /* Wait till HSE is ready and if Time out is reached exit */ 301 | do 302 | { 303 | HSEStatus = RCC->CR & RCC_CR_HSERDY; 304 | StartUpCounter++; 305 | } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); 306 | 307 | if ((RCC->CR & RCC_CR_HSERDY) != RESET) 308 | { 309 | HSEStatus = (uint32_t)0x01; 310 | } 311 | else 312 | { 313 | HSEStatus = (uint32_t)0x00; 314 | } 315 | 316 | if (HSEStatus == (uint32_t)0x01) 317 | { 318 | /* Enable Prefetch Buffer and set Flash Latency */ 319 | FLASH->ACR = FLASH_ACR_PRFTBE | (uint32_t)FLASH_ACR_LATENCY_1; 320 | 321 | /* HCLK = SYSCLK / 1 */ 322 | RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; 323 | 324 | /* PCLK2 = HCLK / 1 */ 325 | RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; 326 | 327 | /* PCLK1 = HCLK / 2 */ 328 | RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2; 329 | 330 | /* PLL configuration */ 331 | RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL)); 332 | RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLMULL9); 333 | 334 | /* Enable PLL */ 335 | RCC->CR |= RCC_CR_PLLON; 336 | 337 | /* Wait till PLL is ready */ 338 | while((RCC->CR & RCC_CR_PLLRDY) == 0) 339 | { 340 | } 341 | 342 | /* Select PLL as system clock source */ 343 | RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); 344 | RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; 345 | 346 | /* Wait till PLL is used as system clock source */ 347 | while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_PLL) 348 | { 349 | } 350 | } 351 | else 352 | { /* If HSE fails to start-up, the application will have wrong clock 353 | configuration. User can add here some code to deal with this error */ 354 | } 355 | } 356 | 357 | /** 358 | * @} 359 | */ 360 | 361 | /** 362 | * @} 363 | */ 364 | 365 | /** 366 | * @} 367 | */ 368 | 369 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 370 | 371 | --------------------------------------------------------------------------------