├── .gitignore ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F4xx │ │ │ └── Include │ │ │ ├── stm32f4xx.h │ │ │ └── system_stm32f4xx.h │ └── Include │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── arm_const_structs.h │ │ └── arm_common_tables.h └── STM32F4xx_HAL_Driver │ ├── Inc │ ├── stm32f4xx_hal_flash_ramfunc.h │ ├── stm32f4xx_hal_dma_ex.h │ ├── stm32f4xx_hal_i2c_ex.h │ ├── stm32f4xx_hal_def.h │ ├── stm32f4xx_hal_gpio.h │ ├── stm32f4xx_hal.h │ ├── stm32f4xx_hal_pwr.h │ └── stm32f4xx_hal_flash.h │ └── Src │ ├── stm32f4xx_hal_i2c_ex.c │ ├── stm32f4xx_hal_flash_ramfunc.c │ └── stm32f4xx_hal_dma_ex.c ├── README.md ├── PCA9685.xml ├── PCA9685 Run.cfg ├── .project ├── LICENSE ├── .settings └── language.settings.xml ├── Inc ├── pca9685.h ├── gpio.h ├── i2c.h ├── stm32f4xx_it.h └── main.h ├── Src ├── gpio.c ├── stm32f4xx_hal_msp.c ├── i2c.c ├── pca9685.c ├── stm32f4xx_it.c └── main.c ├── PCA9685.ioc ├── STM32F401RETx_FLASH.ld ├── syscalls.c └── .mxproject /.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | */Backup/ -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamik/PCA9685_Servo_STM32_HAL/HEAD/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | STM32 HAL library for PCA9685 PWM LED and Servo driver. 2 | 3 | This project uses STM32CubeMX and SW4STM32 IDE with STM32L053R8 Nucleo. 4 | 5 | https://msalamon.pl/jak-pomachac-swoim-orczykiem-stm32-spotyka-sie-z-serwem/ -------------------------------------------------------------------------------- /PCA9685.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PCA9685 5 | STM32F401RETx 6 | SWD 7 | ST-LinkV2-1 8 | 9 | 10 | -------------------------------------------------------------------------------- /PCA9685 Run.cfg: -------------------------------------------------------------------------------- 1 | # This is an PCA9685 board with a single STM32F401RETx chip 2 | # 3 | # Generated by System Workbench for STM32 4 | # Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s) 5 | 6 | source [find interface/stlink.cfg] 7 | 8 | set WORKAREASIZE 0x8000 9 | 10 | transport select "hla_swd" 11 | 12 | set CHIPNAME STM32F401RETx 13 | set BOARDNAME PCA9685 14 | 15 | # Enable debug when in low power modes 16 | set ENABLE_LOW_POWER 1 17 | 18 | # Stop Watchdog counters when halt 19 | set STOP_WATCHDOG 1 20 | 21 | # STlink Debug clock frequency 22 | set CLOCK_FREQ 4000 23 | 24 | # use hardware reset, connect under reset 25 | # connect_assert_srst needed if low power mode application running (WFI...) 26 | reset_config srst_only srst_nogate connect_assert_srst 27 | set CONNECT_UNDER_RESET 1 28 | 29 | source [find target/stm32f4x.cfg] 30 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PCA9685 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | fr.ac6.mcu.ide.core.MCUProjectNature 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Mateusz Salamon 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Inc/pca9685.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pca9685.h 3 | * 4 | * Created on: 20.01.2019 5 | * Author: Mateusz Salamon 6 | * mateusz@msalamon.pl 7 | * 8 | * Website: https://msalamon.pl/nigdy-wiecej-multipleksowania-na-gpio!-max7219-w-akcji-cz-3/ 9 | * GitHub: https://github.com/lamik/Servos_PWM_STM32_HAL 10 | */ 11 | 12 | #ifndef PCA9685_H_ 13 | #define PCA9685_H_ 14 | 15 | // 16 | // Enable Servo control mode 17 | // 18 | #define PCA9685_SERVO_MODE 19 | 20 | #ifdef PCA9685_SERVO_MODE 21 | // 22 | // Servo min and max values for TURINGY TG9e Servos 23 | // 24 | #define SERVO_MIN 110 25 | #define SERVO_MAX 500 26 | #define MIN_ANGLE 0.0 27 | #define MAX_ANGLE 180.0 28 | #endif 29 | 30 | // 31 | // Adjustable address 0x80 - 0xFE 32 | // 33 | #define PCA9685_ADDRESS 0x80 34 | 35 | // 36 | // Registers 37 | // 38 | #define PCA9685_SUBADR1 0x2 39 | #define PCA9685_SUBADR2 0x3 40 | #define PCA9685_SUBADR3 0x4 41 | 42 | #define PCA9685_MODE1 0x0 43 | #define PCA9685_PRESCALE 0xFE 44 | 45 | #define PCA9685_LED0_ON_L 0x6 46 | #define PCA9685_LED0_ON_H 0x7 47 | #define PCA9685_LED0_OFF_L 0x8 48 | #define PCA9685_LED0_OFF_H 0x9 49 | 50 | #define PCA9685_ALLLED_ON_L 0xFA 51 | #define PCA9685_ALLLED_ON_H 0xFB 52 | #define PCA9685_ALLLED_OFF_L 0xFC 53 | #define PCA9685_ALLLED_OFF_H 0xFD 54 | 55 | #define PCA9685_MODE1_ALCALL_BIT 0 56 | typedef enum 57 | { 58 | PCA9685_MODE1_SUB1_BIT = 3, 59 | PCA9685_MODE1_SUB2_BIT = 2, 60 | PCA9685_MODE1_SUB3_BIT = 1 61 | }SubaddressBit; 62 | #define PCA9685_MODE1_SLEEP_BIT 4 63 | #define PCA9685_MODE1_AI_BIT 5 64 | #define PCA9685_MODE1_EXTCLK_BIT 6 65 | #define PCA9685_MODE1_RESTART_BIT 7 66 | 67 | 68 | typedef enum 69 | { 70 | PCA9685_OK = 0, 71 | PCA9685_ERROR = 1 72 | }PCA9685_STATUS; 73 | 74 | PCA9685_STATUS PCA9685_SoftwareReset(void); 75 | PCA9685_STATUS PCA9685_SleepMode(uint8_t Enable); 76 | PCA9685_STATUS PCA9685_RestartMode(uint8_t Enable); 77 | PCA9685_STATUS PCA9685_AutoIncrement(uint8_t Enable); 78 | 79 | #ifndef PCA9685_SERVO_MODE 80 | PCA9685_STATUS PCA9685_SetPwmFrequency(uint16_t Frequency); 81 | #endif 82 | 83 | PCA9685_STATUS PCA9685_SetPwm(uint8_t Channel, uint16_t OnTime, uint16_t OffTime); 84 | PCA9685_STATUS PCA9685_SetPin(uint8_t Channel, uint16_t Value, uint8_t Invert); 85 | #ifdef PCA9685_SERVO_MODE 86 | PCA9685_STATUS PCA9685_SetServoAngle(uint8_t Channel, float Angle); 87 | #endif 88 | 89 | PCA9685_STATUS PCA9685_Init(I2C_HandleTypeDef *hi2c); 90 | 91 | #endif /* PCA9685_H_ */ 92 | -------------------------------------------------------------------------------- /Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : gpio.h 4 | * Description : This file contains all the functions prototypes for 5 | * the gpio 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | 40 | /* Define to prevent recursive inclusion -------------------------------------*/ 41 | #ifndef __gpio_H 42 | #define __gpio_H 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "main.h" 49 | 50 | /* USER CODE BEGIN Includes */ 51 | 52 | /* USER CODE END Includes */ 53 | 54 | /* USER CODE BEGIN Private defines */ 55 | 56 | /* USER CODE END Private defines */ 57 | 58 | void MX_GPIO_Init(void); 59 | 60 | /* USER CODE BEGIN Prototypes */ 61 | 62 | /* USER CODE END Prototypes */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif /*__ pinoutConfig_H */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /Inc/i2c.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : I2C.h 4 | * Description : This file provides code for the configuration 5 | * of the I2C instances. 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | /* Define to prevent recursive inclusion -------------------------------------*/ 40 | #ifndef __i2c_H 41 | #define __i2c_H 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "main.h" 48 | 49 | /* USER CODE BEGIN Includes */ 50 | 51 | /* USER CODE END Includes */ 52 | 53 | extern I2C_HandleTypeDef hi2c1; 54 | 55 | /* USER CODE BEGIN Private defines */ 56 | 57 | /* USER CODE END Private defines */ 58 | 59 | void MX_I2C1_Init(void); 60 | 61 | /* USER CODE BEGIN Prototypes */ 62 | 63 | /* USER CODE END Prototypes */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | #endif /*__ i2c_H */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 79 | -------------------------------------------------------------------------------- /Inc/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2019 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* USER CODE END Header */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_IT_H 38 | #define __STM32F4xx_IT_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Private includes ----------------------------------------------------------*/ 45 | /* USER CODE BEGIN Includes */ 46 | 47 | /* USER CODE END Includes */ 48 | 49 | /* Exported types ------------------------------------------------------------*/ 50 | /* USER CODE BEGIN ET */ 51 | 52 | /* USER CODE END ET */ 53 | 54 | /* Exported constants --------------------------------------------------------*/ 55 | /* USER CODE BEGIN EC */ 56 | 57 | /* USER CODE END EC */ 58 | 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* USER CODE BEGIN EM */ 61 | 62 | /* USER CODE END EM */ 63 | 64 | /* Exported functions prototypes ---------------------------------------------*/ 65 | void NMI_Handler(void); 66 | void HardFault_Handler(void); 67 | void MemManage_Handler(void); 68 | void BusFault_Handler(void); 69 | void UsageFault_Handler(void); 70 | void SVC_Handler(void); 71 | void DebugMon_Handler(void); 72 | void PendSV_Handler(void); 73 | void SysTick_Handler(void); 74 | /* USER CODE BEGIN EFP */ 75 | 76 | /* USER CODE END EFP */ 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* __STM32F4xx_IT_H */ 83 | 84 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 85 | -------------------------------------------------------------------------------- /Src/gpio.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : gpio.c 4 | * Description : This file provides code for the configuration 5 | * of all used GPIO pins. 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "gpio.h" 42 | /* USER CODE BEGIN 0 */ 43 | 44 | /* USER CODE END 0 */ 45 | 46 | /*----------------------------------------------------------------------------*/ 47 | /* Configure GPIO */ 48 | /*----------------------------------------------------------------------------*/ 49 | /* USER CODE BEGIN 1 */ 50 | 51 | /* USER CODE END 1 */ 52 | 53 | /** Configure pins 54 | */ 55 | void MX_GPIO_Init(void) 56 | { 57 | 58 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 59 | 60 | /* GPIO Ports Clock Enable */ 61 | __HAL_RCC_GPIOC_CLK_ENABLE(); 62 | __HAL_RCC_GPIOB_CLK_ENABLE(); 63 | 64 | /*Configure GPIO pin Output Level */ 65 | HAL_GPIO_WritePin(TEST_GPIO_Port, TEST_Pin, GPIO_PIN_RESET); 66 | 67 | /*Configure GPIO pin : PtPin */ 68 | GPIO_InitStruct.Pin = TEST_Pin; 69 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 70 | GPIO_InitStruct.Pull = GPIO_NOPULL; 71 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 72 | HAL_GPIO_Init(TEST_GPIO_Port, &GPIO_InitStruct); 73 | 74 | } 75 | 76 | /* USER CODE BEGIN 2 */ 77 | 78 | /* USER CODE END 2 */ 79 | 80 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 81 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | ** This notice applies to any and all portions of this file 9 | * that are not between comment pairs USER CODE BEGIN and 10 | * USER CODE END. Other portions of this file, whether 11 | * inserted by the user or by software development tools 12 | * are owned by their respective copyright owners. 13 | * 14 | * COPYRIGHT(c) 2019 STMicroelectronics 15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************** 39 | */ 40 | /* USER CODE END Header */ 41 | 42 | /* Define to prevent recursive inclusion -------------------------------------*/ 43 | #ifndef __MAIN_H 44 | #define __MAIN_H 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | /* Includes ------------------------------------------------------------------*/ 51 | #include "stm32f4xx_hal.h" 52 | #include "stm32f4xx_hal.h" 53 | 54 | /* Private includes ----------------------------------------------------------*/ 55 | /* USER CODE BEGIN Includes */ 56 | 57 | /* USER CODE END Includes */ 58 | 59 | /* Exported types ------------------------------------------------------------*/ 60 | /* USER CODE BEGIN ET */ 61 | 62 | /* USER CODE END ET */ 63 | 64 | /* Exported constants --------------------------------------------------------*/ 65 | /* USER CODE BEGIN EC */ 66 | 67 | /* USER CODE END EC */ 68 | 69 | /* Exported macro ------------------------------------------------------------*/ 70 | /* USER CODE BEGIN EM */ 71 | 72 | /* USER CODE END EM */ 73 | 74 | /* Exported functions prototypes ---------------------------------------------*/ 75 | void Error_Handler(void); 76 | 77 | /* USER CODE BEGIN EFP */ 78 | 79 | /* USER CODE END EFP */ 80 | 81 | /* Private defines -----------------------------------------------------------*/ 82 | #define TEST_Pin GPIO_PIN_9 83 | #define TEST_GPIO_Port GPIOC 84 | /* USER CODE BEGIN Private defines */ 85 | 86 | /* USER CODE END Private defines */ 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* __MAIN_H */ 93 | 94 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 95 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 38 | #define __STM32F4xx_FLASH_RAMFUNC_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 44 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f4xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F4xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup FLASH_RAMFUNC 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported macro ------------------------------------------------------------*/ 59 | /* Exported functions --------------------------------------------------------*/ 60 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 61 | * @{ 62 | */ 63 | 64 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 65 | * @{ 66 | */ 67 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void); 68 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void); 69 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void); 70 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void); 71 | /** 72 | * @} 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | 93 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 94 | 95 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 96 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /** @addtogroup CMSIS 37 | * @{ 38 | */ 39 | 40 | /** @addtogroup stm32f4xx_system 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Define to prevent recursive inclusion 46 | */ 47 | #ifndef __SYSTEM_STM32F4XX_H 48 | #define __SYSTEM_STM32F4XX_H 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** @addtogroup STM32F4xx_System_Includes 55 | * @{ 56 | */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @addtogroup STM32F4xx_System_Exported_types 64 | * @{ 65 | */ 66 | /* This variable is updated in three ways: 67 | 1) by calling CMSIS function SystemCoreClockUpdate() 68 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 69 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 70 | Note: If you use this function to configure the system clock; then there 71 | is no need to call the 2 first functions listed above, since SystemCoreClock 72 | variable is updated automatically. 73 | */ 74 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 75 | 76 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 77 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F4xx_System_Exported_Constants 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @addtogroup STM32F4xx_System_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @addtogroup STM32F4xx_System_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | extern void SystemInit(void); 104 | extern void SystemCoreClockUpdate(void); 105 | /** 106 | * @} 107 | */ 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /*__SYSTEM_STM32F4XX_H */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /Src/stm32f4xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * File Name : stm32f4xx_hal_msp.c 5 | * Description : This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | ** This notice applies to any and all portions of this file 9 | * that are not between comment pairs USER CODE BEGIN and 10 | * USER CODE END. Other portions of this file, whether 11 | * inserted by the user or by software development tools 12 | * are owned by their respective copyright owners. 13 | * 14 | * COPYRIGHT(c) 2019 STMicroelectronics 15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************** 39 | */ 40 | /* USER CODE END Header */ 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | #include "main.h" 44 | /* USER CODE BEGIN Includes */ 45 | 46 | /* USER CODE END Includes */ 47 | 48 | /* Private typedef -----------------------------------------------------------*/ 49 | /* USER CODE BEGIN TD */ 50 | 51 | /* USER CODE END TD */ 52 | 53 | /* Private define ------------------------------------------------------------*/ 54 | /* USER CODE BEGIN Define */ 55 | 56 | /* USER CODE END Define */ 57 | 58 | /* Private macro -------------------------------------------------------------*/ 59 | /* USER CODE BEGIN Macro */ 60 | 61 | /* USER CODE END Macro */ 62 | 63 | /* Private variables ---------------------------------------------------------*/ 64 | /* USER CODE BEGIN PV */ 65 | 66 | /* USER CODE END PV */ 67 | 68 | /* Private function prototypes -----------------------------------------------*/ 69 | /* USER CODE BEGIN PFP */ 70 | 71 | /* USER CODE END PFP */ 72 | 73 | /* External functions --------------------------------------------------------*/ 74 | /* USER CODE BEGIN ExternalFunctions */ 75 | 76 | /* USER CODE END ExternalFunctions */ 77 | 78 | /* USER CODE BEGIN 0 */ 79 | 80 | /* USER CODE END 0 */ 81 | /** 82 | * Initializes the Global MSP. 83 | */ 84 | void HAL_MspInit(void) 85 | { 86 | /* USER CODE BEGIN MspInit 0 */ 87 | 88 | /* USER CODE END MspInit 0 */ 89 | 90 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 91 | __HAL_RCC_PWR_CLK_ENABLE(); 92 | 93 | /* System interrupt init*/ 94 | 95 | /* USER CODE BEGIN MspInit 1 */ 96 | 97 | /* USER CODE END MspInit 1 */ 98 | } 99 | 100 | /* USER CODE BEGIN 1 */ 101 | 102 | /* USER CODE END 1 */ 103 | 104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105 | -------------------------------------------------------------------------------- /PCA9685.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | I2C1.ClockSpeed=400000 4 | I2C1.DutyCycle=I2C_DUTYCYCLE_2 5 | I2C1.I2C_Mode=I2C_Fast 6 | I2C1.IPParameters=I2C_Mode,ClockSpeed,DutyCycle 7 | KeepUserPlacement=false 8 | Mcu.Family=STM32F4 9 | Mcu.IP0=I2C1 10 | Mcu.IP1=NVIC 11 | Mcu.IP2=RCC 12 | Mcu.IP3=SYS 13 | Mcu.IPNb=4 14 | Mcu.Name=STM32F401R(D-E)Tx 15 | Mcu.Package=LQFP64 16 | Mcu.Pin0=PC9 17 | Mcu.Pin1=PB8 18 | Mcu.Pin2=PB9 19 | Mcu.Pin3=VP_SYS_VS_Systick 20 | Mcu.PinsNb=4 21 | Mcu.ThirdPartyNb=0 22 | Mcu.UserConstants= 23 | Mcu.UserName=STM32F401RETx 24 | MxCube.Version=5.0.0 25 | MxDb.Version=DB.5.0.0 26 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false 27 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false 28 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false 29 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false 30 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false 31 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false 32 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 33 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false 34 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false 35 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false 36 | PB8.Locked=true 37 | PB8.Mode=I2C 38 | PB8.Signal=I2C1_SCL 39 | PB9.Locked=true 40 | PB9.Mode=I2C 41 | PB9.Signal=I2C1_SDA 42 | PC9.GPIOParameters=GPIO_Label 43 | PC9.GPIO_Label=TEST 44 | PC9.Locked=true 45 | PC9.Signal=GPIO_Output 46 | PCC.Checker=false 47 | PCC.Line=STM32F401 48 | PCC.MCU=STM32F401R(D-E)Tx 49 | PCC.PartNumber=STM32F401RETx 50 | PCC.Seq0=0 51 | PCC.Series=STM32F4 52 | PCC.Temperature=25 53 | PCC.Vdd=null 54 | PinOutPanel.RotationAngle=0 55 | ProjectManager.AskForMigrate=true 56 | ProjectManager.BackupPrevious=true 57 | ProjectManager.CompilerOptimize=6 58 | ProjectManager.ComputerToolchain=false 59 | ProjectManager.CoupleFile=true 60 | ProjectManager.CustomerFirmwarePackage= 61 | ProjectManager.DefaultFWLocation=true 62 | ProjectManager.DeletePrevious=true 63 | ProjectManager.DeviceId=STM32F401RETx 64 | ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.23.0 65 | ProjectManager.FreePins=false 66 | ProjectManager.HalAssertFull=false 67 | ProjectManager.HeapSize=0x200 68 | ProjectManager.KeepUserCode=true 69 | ProjectManager.LastFirmware=true 70 | ProjectManager.LibraryCopy=1 71 | ProjectManager.MainLocation=Src 72 | ProjectManager.NoMain=false 73 | ProjectManager.PreviousToolchain=SW4STM32 74 | ProjectManager.ProjectBuild=false 75 | ProjectManager.ProjectFileName=PCA9685.ioc 76 | ProjectManager.ProjectName=PCA9685 77 | ProjectManager.StackSize=0x400 78 | ProjectManager.TargetToolchain=SW4STM32 79 | ProjectManager.ToolChainLocation= 80 | ProjectManager.UnderRoot=true 81 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_I2C1_Init-I2C1-false-HAL-true 82 | RCC.48MHZClocksFreq_Value=42000000 83 | RCC.AHBFreq_Value=84000000 84 | RCC.APB1CLKDivider=RCC_HCLK_DIV2 85 | RCC.APB1Freq_Value=42000000 86 | RCC.APB1TimFreq_Value=84000000 87 | RCC.APB2Freq_Value=84000000 88 | RCC.APB2TimFreq_Value=84000000 89 | RCC.CortexFreq_Value=84000000 90 | RCC.FCLKCortexFreq_Value=84000000 91 | RCC.HCLKFreq_Value=84000000 92 | RCC.HSE_VALUE=25000000 93 | RCC.HSI_VALUE=16000000 94 | RCC.I2SClocksFreq_Value=192000000 95 | RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,FCLKCortexFreq_Value,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLM,PLLN,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S 96 | RCC.LSE_VALUE=32768 97 | RCC.LSI_VALUE=32000 98 | RCC.MCO2PinFreq_Value=84000000 99 | RCC.PLLCLKFreq_Value=84000000 100 | RCC.PLLM=8 101 | RCC.PLLN=84 102 | RCC.PLLQCLKFreq_Value=42000000 103 | RCC.RTCFreq_Value=32000 104 | RCC.RTCHSEDivFreq_Value=12500000 105 | RCC.SYSCLKFreq_VALUE=84000000 106 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK 107 | RCC.VCOI2SOutputFreq_Value=384000000 108 | RCC.VCOInputFreq_Value=2000000 109 | RCC.VCOOutputFreq_Value=168000000 110 | RCC.VcooutputI2S=192000000 111 | VP_SYS_VS_Systick.Mode=SysTick 112 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 113 | board=custom 114 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_DMA_EX_H 38 | #define __STM32F4xx_HAL_DMA_EX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Includes ------------------------------------------------------------------*/ 45 | #include "stm32f4xx_hal_def.h" 46 | 47 | /** @addtogroup STM32F4xx_HAL_Driver 48 | * @{ 49 | */ 50 | 51 | /** @addtogroup DMAEx 52 | * @{ 53 | */ 54 | 55 | /* Exported types ------------------------------------------------------------*/ 56 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 57 | * @brief DMAEx Exported types 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @brief HAL DMA Memory definition 63 | */ 64 | typedef enum 65 | { 66 | MEMORY0 = 0x00U, /*!< Memory 0 */ 67 | MEMORY1 = 0x01U /*!< Memory 1 */ 68 | }HAL_DMA_MemoryTypeDef; 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /* Exported functions --------------------------------------------------------*/ 75 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 76 | * @brief DMAEx Exported functions 77 | * @{ 78 | */ 79 | 80 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 81 | * @brief Extended features functions 82 | * @{ 83 | */ 84 | 85 | /* IO operation functions *******************************************************/ 86 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 87 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 88 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 89 | 90 | /** 91 | * @} 92 | */ 93 | /** 94 | * @} 95 | */ 96 | 97 | /* Private functions ---------------------------------------------------------*/ 98 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 99 | * @brief DMAEx Private functions 100 | * @{ 101 | */ 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | 118 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/ 119 | 120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 121 | -------------------------------------------------------------------------------- /Src/i2c.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : I2C.c 4 | * Description : This file provides code for the configuration 5 | * of the I2C instances. 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "i2c.h" 42 | 43 | /* USER CODE BEGIN 0 */ 44 | 45 | /* USER CODE END 0 */ 46 | 47 | I2C_HandleTypeDef hi2c1; 48 | 49 | /* I2C1 init function */ 50 | void MX_I2C1_Init(void) 51 | { 52 | 53 | hi2c1.Instance = I2C1; 54 | hi2c1.Init.ClockSpeed = 400000; 55 | hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; 56 | hi2c1.Init.OwnAddress1 = 0; 57 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 58 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; 59 | hi2c1.Init.OwnAddress2 = 0; 60 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; 61 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; 62 | if (HAL_I2C_Init(&hi2c1) != HAL_OK) 63 | { 64 | Error_Handler(); 65 | } 66 | 67 | } 68 | 69 | void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle) 70 | { 71 | 72 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 73 | if(i2cHandle->Instance==I2C1) 74 | { 75 | /* USER CODE BEGIN I2C1_MspInit 0 */ 76 | 77 | /* USER CODE END I2C1_MspInit 0 */ 78 | 79 | __HAL_RCC_GPIOB_CLK_ENABLE(); 80 | /**I2C1 GPIO Configuration 81 | PB8 ------> I2C1_SCL 82 | PB9 ------> I2C1_SDA 83 | */ 84 | GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; 85 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; 86 | GPIO_InitStruct.Pull = GPIO_PULLUP; 87 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 88 | GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; 89 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 90 | 91 | /* I2C1 clock enable */ 92 | __HAL_RCC_I2C1_CLK_ENABLE(); 93 | /* USER CODE BEGIN I2C1_MspInit 1 */ 94 | 95 | /* USER CODE END I2C1_MspInit 1 */ 96 | } 97 | } 98 | 99 | void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle) 100 | { 101 | 102 | if(i2cHandle->Instance==I2C1) 103 | { 104 | /* USER CODE BEGIN I2C1_MspDeInit 0 */ 105 | 106 | /* USER CODE END I2C1_MspDeInit 0 */ 107 | /* Peripheral clock disable */ 108 | __HAL_RCC_I2C1_CLK_DISABLE(); 109 | 110 | /**I2C1 GPIO Configuration 111 | PB8 ------> I2C1_SCL 112 | PB9 ------> I2C1_SDA 113 | */ 114 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8|GPIO_PIN_9); 115 | 116 | /* USER CODE BEGIN I2C1_MspDeInit 1 */ 117 | 118 | /* USER CODE END I2C1_MspDeInit 1 */ 119 | } 120 | } 121 | 122 | /* USER CODE BEGIN 1 */ 123 | 124 | /* USER CODE END 1 */ 125 | 126 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 127 | -------------------------------------------------------------------------------- /Src/pca9685.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pca9685.c 3 | * 4 | * Created on: 20.01.2019 5 | * Author: Mateusz Salamon 6 | * mateusz@msalamon.pl 7 | * 8 | * Website: https://msalamon.pl/nigdy-wiecej-multipleksowania-na-gpio!-max7219-w-akcji-cz-3/ 9 | * GitHub: https://github.com/lamik/Servos_PWM_STM32_HAL 10 | */ 11 | 12 | #include "main.h" 13 | #include "i2c.h" 14 | 15 | #include "pca9685.h" 16 | #include "math.h" 17 | 18 | I2C_HandleTypeDef *pca9685_i2c; 19 | 20 | PCA9685_STATUS PCA9685_SetBit(uint8_t Register, uint8_t Bit, uint8_t Value) 21 | { 22 | uint8_t tmp; 23 | if(Value) Value = 1; 24 | 25 | if(HAL_OK != HAL_I2C_Mem_Read(pca9685_i2c, PCA9685_ADDRESS, Register, 1, &tmp, 1, 10)) 26 | { 27 | return PCA9685_ERROR; 28 | } 29 | tmp &= ~((1<= 1526) 84 | { 85 | Prescale = 0x03; 86 | } 87 | else if(Frequency <= 24) 88 | { 89 | Prescale = 0xFF; 90 | } 91 | else 92 | { 93 | PrescalerVal = (25000000 / (4096.0 * (float)Frequency)) - 1; 94 | Prescale = floor(PrescalerVal + 0.5); 95 | } 96 | 97 | // 98 | // To change the frequency, PCA9685 have to be in Sleep mode. 99 | // 100 | PCA9685_SleepMode(1); 101 | HAL_I2C_Mem_Write(pca9685_i2c, PCA9685_ADDRESS, PCA9685_PRESCALE, 1, &Prescale, 1, 10); // Write Prescale value 102 | PCA9685_SleepMode(0); 103 | PCA9685_RestartMode(1); 104 | return PCA9685_OK; 105 | } 106 | 107 | PCA9685_STATUS PCA9685_SetPwm(uint8_t Channel, uint16_t OnTime, uint16_t OffTime) 108 | { 109 | uint8_t RegisterAddress; 110 | uint8_t Message[4]; 111 | 112 | RegisterAddress = PCA9685_LED0_ON_L + (4 * Channel); 113 | Message[0] = OnTime & 0xFF; 114 | Message[1] = OnTime>>8; 115 | Message[2] = OffTime & 0xFF; 116 | Message[3] = OffTime>>8; 117 | 118 | if(HAL_OK != HAL_I2C_Mem_Write(pca9685_i2c, PCA9685_ADDRESS, RegisterAddress, 1, Message, 4, 10)) 119 | { 120 | return PCA9685_ERROR; 121 | } 122 | 123 | return PCA9685_OK; 124 | } 125 | 126 | PCA9685_STATUS PCA9685_SetPin(uint8_t Channel, uint16_t Value, uint8_t Invert) 127 | { 128 | if(Value > 4095) Value = 4095; 129 | 130 | if (Invert) { 131 | if (Value == 0) { 132 | // Special value for signal fully on. 133 | return PCA9685_SetPwm(Channel, 4096, 0); 134 | } 135 | else if (Value == 4095) { 136 | // Special value for signal fully off. 137 | return PCA9685_SetPwm(Channel, 0, 4096); 138 | } 139 | else { 140 | return PCA9685_SetPwm(Channel, 0, 4095-Value); 141 | } 142 | } 143 | else { 144 | if (Value == 4095) { 145 | // Special value for signal fully on. 146 | return PCA9685_SetPwm(Channel, 4096, 0); 147 | } 148 | else if (Value == 0) { 149 | // Special value for signal fully off. 150 | return PCA9685_SetPwm(Channel, 0, 4096); 151 | } 152 | else { 153 | return PCA9685_SetPwm(Channel, 0, Value); 154 | } 155 | } 156 | } 157 | 158 | #ifdef PCA9685_SERVO_MODE 159 | PCA9685_STATUS PCA9685_SetServoAngle(uint8_t Channel, float Angle) 160 | { 161 | float Value; 162 | if(Angle < MIN_ANGLE) Angle = MIN_ANGLE; 163 | if(Angle > MAX_ANGLE) Angle = MAX_ANGLE; 164 | 165 | Value = (Angle - MIN_ANGLE) * ((float)SERVO_MAX - (float)SERVO_MIN) / (MAX_ANGLE - MIN_ANGLE) + (float)SERVO_MIN; 166 | 167 | return PCA9685_SetPin(Channel, (uint16_t)Value, 0); 168 | } 169 | #endif 170 | 171 | PCA9685_STATUS PCA9685_Init(I2C_HandleTypeDef *hi2c) 172 | { 173 | pca9685_i2c = hi2c; 174 | 175 | PCA9685_SoftwareReset(); 176 | #ifdef PCA9685_SERVO_MODE 177 | PCA9685_SetPwmFrequency(48); 178 | #else 179 | PCA9685_SetPwmFrequency(1000); 180 | #endif 181 | PCA9685_AutoIncrement(1); 182 | 183 | return PCA9685_OK; 184 | } 185 | -------------------------------------------------------------------------------- /STM32F401RETx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Abstract : Linker script for STM32F401RETx Device with 8 | ** 512KByte FLASH, 96KByte RAM 9 | ** 10 | ** Set heap size, stack size and stack location according 11 | ** to application requirements. 12 | ** 13 | ** Set memory bank area and size if external memory is used. 14 | ** 15 | ** Target : STMicroelectronics STM32 16 | ** 17 | ** 18 | ** Distribution: The file is distributed as is, without any warranty 19 | ** of any kind. 20 | ** 21 | ** (c)Copyright Ac6. 22 | ** You may use this file as-is or modify it according to the needs of your 23 | ** project. Distribution of this file (unmodified or modified) is not 24 | ** permitted. Ac6 permit registered System Workbench for MCU users the 25 | ** rights to distribute the assembled, compiled & linked contents of this 26 | ** file as part of an application binary file, provided that it is built 27 | ** using the System Workbench for MCU toolchain. 28 | ** 29 | ***************************************************************************** 30 | */ 31 | 32 | /* Entry Point */ 33 | ENTRY(Reset_Handler) 34 | 35 | /* Highest address of the user mode stack */ 36 | _estack = 0x20018000; /* end of RAM */ 37 | /* Generate a link error if heap and stack don't fit into RAM */ 38 | _Min_Heap_Size = 0x200; /* required amount of heap */ 39 | _Min_Stack_Size = 0x400; /* required amount of stack */ 40 | 41 | /* Specify the memory areas */ 42 | MEMORY 43 | { 44 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K 45 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K 46 | } 47 | 48 | /* Define output sections */ 49 | SECTIONS 50 | { 51 | /* The startup code goes first into FLASH */ 52 | .isr_vector : 53 | { 54 | . = ALIGN(4); 55 | KEEP(*(.isr_vector)) /* Startup code */ 56 | . = ALIGN(4); 57 | } >FLASH 58 | 59 | /* The program code and other data goes into FLASH */ 60 | .text : 61 | { 62 | . = ALIGN(4); 63 | *(.text) /* .text sections (code) */ 64 | *(.text*) /* .text* sections (code) */ 65 | *(.glue_7) /* glue arm to thumb code */ 66 | *(.glue_7t) /* glue thumb to arm code */ 67 | *(.eh_frame) 68 | 69 | KEEP (*(.init)) 70 | KEEP (*(.fini)) 71 | 72 | . = ALIGN(4); 73 | _etext = .; /* define a global symbols at end of code */ 74 | } >FLASH 75 | 76 | /* Constant data goes into FLASH */ 77 | .rodata : 78 | { 79 | . = ALIGN(4); 80 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 81 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 82 | . = ALIGN(4); 83 | } >FLASH 84 | 85 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 86 | .ARM : { 87 | __exidx_start = .; 88 | *(.ARM.exidx*) 89 | __exidx_end = .; 90 | } >FLASH 91 | 92 | .preinit_array : 93 | { 94 | PROVIDE_HIDDEN (__preinit_array_start = .); 95 | KEEP (*(.preinit_array*)) 96 | PROVIDE_HIDDEN (__preinit_array_end = .); 97 | } >FLASH 98 | .init_array : 99 | { 100 | PROVIDE_HIDDEN (__init_array_start = .); 101 | KEEP (*(SORT(.init_array.*))) 102 | KEEP (*(.init_array*)) 103 | PROVIDE_HIDDEN (__init_array_end = .); 104 | } >FLASH 105 | .fini_array : 106 | { 107 | PROVIDE_HIDDEN (__fini_array_start = .); 108 | KEEP (*(SORT(.fini_array.*))) 109 | KEEP (*(.fini_array*)) 110 | PROVIDE_HIDDEN (__fini_array_end = .); 111 | } >FLASH 112 | 113 | /* used by the startup to initialize data */ 114 | _sidata = LOADADDR(.data); 115 | 116 | /* Initialized data sections goes into RAM, load LMA copy after code */ 117 | .data : 118 | { 119 | . = ALIGN(4); 120 | _sdata = .; /* create a global symbol at data start */ 121 | *(.data) /* .data sections */ 122 | *(.data*) /* .data* sections */ 123 | 124 | . = ALIGN(4); 125 | _edata = .; /* define a global symbol at data end */ 126 | } >RAM AT> FLASH 127 | 128 | 129 | /* Uninitialized data section */ 130 | . = ALIGN(4); 131 | .bss : 132 | { 133 | /* This is used by the startup in order to initialize the .bss secion */ 134 | _sbss = .; /* define a global symbol at bss start */ 135 | __bss_start__ = _sbss; 136 | *(.bss) 137 | *(.bss*) 138 | *(COMMON) 139 | 140 | . = ALIGN(4); 141 | _ebss = .; /* define a global symbol at bss end */ 142 | __bss_end__ = _ebss; 143 | } >RAM 144 | 145 | /* User_heap_stack section, used to check that there is enough RAM left */ 146 | ._user_heap_stack : 147 | { 148 | . = ALIGN(8); 149 | PROVIDE ( end = . ); 150 | PROVIDE ( _end = . ); 151 | . = . + _Min_Heap_Size; 152 | . = . + _Min_Stack_Size; 153 | . = ALIGN(8); 154 | } >RAM 155 | 156 | 157 | 158 | /* Remove information from the standard libraries */ 159 | /DISCARD/ : 160 | { 161 | libc.a ( * ) 162 | libm.a ( * ) 163 | libgcc.a ( * ) 164 | } 165 | 166 | .ARM.attributes 0 : { *(.ARM.attributes) } 167 | } 168 | 169 | 170 | -------------------------------------------------------------------------------- /syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ***************************************************************************** 3 | ** 4 | ** File : syscalls.c 5 | ** 6 | ** Abstract : System Workbench Minimal System calls file 7 | ** 8 | ** For more information about which c-functions 9 | ** need which of these lowlevel functions 10 | ** please consult the Newlib libc-manual 11 | ** 12 | ** Environment : System Workbench for MCU 13 | ** 14 | ** Distribution: The file is distributed as is without any warranty 15 | ** of any kind. 16 | ** 17 | ***************************************************************************** 18 | ** 19 | **

© COPYRIGHT(c) 2014 Ac6

20 | ** 21 | ** Redistribution and use in source and binary forms, with or without modification, 22 | ** are permitted provided that the following conditions are met: 23 | ** 1. Redistributions of source code must retain the above copyright notice, 24 | ** this list of conditions and the following disclaimer. 25 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 26 | ** this list of conditions and the following disclaimer in the documentation 27 | ** and/or other materials provided with the distribution. 28 | ** 3. Neither the name of Ac6 nor the names of its contributors 29 | ** may be used to endorse or promote products derived from this software 30 | ** without specific prior written permission. 31 | ** 32 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 36 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 38 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 39 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 40 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | ** 43 | ***************************************************************************** 44 | */ 45 | 46 | /* Includes */ 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | 56 | 57 | /* Variables */ 58 | //#undef errno 59 | extern int errno; 60 | extern int __io_putchar(int ch) __attribute__((weak)); 61 | extern int __io_getchar(void) __attribute__((weak)); 62 | 63 | register char * stack_ptr asm("sp"); 64 | 65 | char *__env[1] = { 0 }; 66 | char **environ = __env; 67 | 68 | 69 | /* Functions */ 70 | void initialise_monitor_handles() 71 | { 72 | } 73 | 74 | int _getpid(void) 75 | { 76 | return 1; 77 | } 78 | 79 | int _kill(int pid, int sig) 80 | { 81 | errno = EINVAL; 82 | return -1; 83 | } 84 | 85 | void _exit (int status) 86 | { 87 | _kill(status, -1); 88 | while (1) {} /* Make sure we hang here */ 89 | } 90 | 91 | int _read (int file, char *ptr, int len) 92 | { 93 | int DataIdx; 94 | 95 | for (DataIdx = 0; DataIdx < len; DataIdx++) 96 | { 97 | *ptr++ = __io_getchar(); 98 | } 99 | 100 | return len; 101 | } 102 | 103 | int _write(int file, char *ptr, int len) 104 | { 105 | int DataIdx; 106 | 107 | for (DataIdx = 0; DataIdx < len; DataIdx++) 108 | { 109 | __io_putchar(*ptr++); 110 | } 111 | return len; 112 | } 113 | 114 | caddr_t _sbrk(int incr) 115 | { 116 | extern char end asm("end"); 117 | static char *heap_end; 118 | char *prev_heap_end; 119 | 120 | if (heap_end == 0) 121 | heap_end = &end; 122 | 123 | prev_heap_end = heap_end; 124 | if (heap_end + incr > stack_ptr) 125 | { 126 | // write(1, "Heap and stack collision\n", 25); 127 | // abort(); 128 | errno = ENOMEM; 129 | return (caddr_t) -1; 130 | } 131 | 132 | heap_end += incr; 133 | 134 | return (caddr_t) prev_heap_end; 135 | } 136 | 137 | int _close(int file) 138 | { 139 | return -1; 140 | } 141 | 142 | 143 | int _fstat(int file, struct stat *st) 144 | { 145 | st->st_mode = S_IFCHR; 146 | return 0; 147 | } 148 | 149 | int _isatty(int file) 150 | { 151 | return 1; 152 | } 153 | 154 | int _lseek(int file, int ptr, int dir) 155 | { 156 | return 0; 157 | } 158 | 159 | int _open(char *path, int flags, ...) 160 | { 161 | /* Pretend like we always fail */ 162 | return -1; 163 | } 164 | 165 | int _wait(int *status) 166 | { 167 | errno = ECHILD; 168 | return -1; 169 | } 170 | 171 | int _unlink(char *name) 172 | { 173 | errno = ENOENT; 174 | return -1; 175 | } 176 | 177 | int _times(struct tms *buf) 178 | { 179 | return -1; 180 | } 181 | 182 | int _stat(char *file, struct stat *st) 183 | { 184 | st->st_mode = S_IFCHR; 185 | return 0; 186 | } 187 | 188 | int _link(char *old, char *new) 189 | { 190 | errno = EMLINK; 191 | return -1; 192 | } 193 | 194 | int _fork(void) 195 | { 196 | errno = EAGAIN; 197 | return -1; 198 | } 199 | 200 | int _execve(char *name, char **argv, char **env) 201 | { 202 | errno = ENOMEM; 203 | return -1; 204 | } 205 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_i2c_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of I2C HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2017 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_HAL_I2C_EX_H 38 | #define __STM32F4xx_HAL_I2C_EX_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 45 | defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) ||\ 46 | defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || defined(STM32F423xx) 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "stm32f4xx_hal_def.h" 49 | 50 | /** @addtogroup STM32F4xx_HAL_Driver 51 | * @{ 52 | */ 53 | 54 | /** @addtogroup I2CEx 55 | * @{ 56 | */ 57 | 58 | /* Exported types ------------------------------------------------------------*/ 59 | /* Exported constants --------------------------------------------------------*/ 60 | /** @defgroup I2CEx_Exported_Constants I2C Exported Constants 61 | * @{ 62 | */ 63 | 64 | /** @defgroup I2CEx_Analog_Filter I2C Analog Filter 65 | * @{ 66 | */ 67 | #define I2C_ANALOGFILTER_ENABLE 0x00000000U 68 | #define I2C_ANALOGFILTER_DISABLE I2C_FLTR_ANOFF 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /* Exported macro ------------------------------------------------------------*/ 78 | /* Exported functions --------------------------------------------------------*/ 79 | /** @addtogroup I2CEx_Exported_Functions 80 | * @{ 81 | */ 82 | 83 | /** @addtogroup I2CEx_Exported_Functions_Group1 84 | * @{ 85 | */ 86 | /* Peripheral Control functions ************************************************/ 87 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter); 88 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter); 89 | /** 90 | * @} 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | /* Private types -------------------------------------------------------------*/ 97 | /* Private variables ---------------------------------------------------------*/ 98 | /* Private constants ---------------------------------------------------------*/ 99 | /** @defgroup I2CEx_Private_Constants I2C Private Constants 100 | * @{ 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /* Private macros ------------------------------------------------------------*/ 108 | /** @defgroup I2CEx_Private_Macros I2C Private Macros 109 | * @{ 110 | */ 111 | #define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \ 112 | ((FILTER) == I2C_ANALOGFILTER_DISABLE)) 113 | #define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU) 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | #endif /* STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F401xC ||\ 127 | STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx ||\ 128 | STM32F413xx || STM32F423xx */ 129 | 130 | #ifdef __cplusplus 131 | } 132 | #endif 133 | 134 | #endif /* __STM32F4xx_HAL_I2C_EX_H */ 135 | 136 | 137 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 138 | -------------------------------------------------------------------------------- /.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/Kiedy STM32 steruje serwem/Kod/STM32_servo/PCA9685/Inc 3 | HeaderFiles=gpio.h;i2c.h;stm32f4xx_it.h;stm32f4xx_hal_conf.h;main.h; 4 | SourcePath=D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/Kiedy STM32 steruje serwem/Kod/STM32_servo/PCA9685/Src 5 | SourceFiles=gpio.c;i2c.c;stm32f4xx_it.c;stm32f4xx_hal_msp.c;main.c; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xe.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h; 9 | 10 | [PreviousUsedSW4STM32Files] 11 | SourceFiles=..\Src\main.c;..\Src\gpio.c;..\Src\i2c.c;..\Src\stm32f4xx_it.c;..\Src\stm32f4xx_hal_msp.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;../\Src/system_stm32f4xx.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;../\Src/system_stm32f4xx.c;../Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;D:/GoogleDrive/Blog msalamon.pl/Materialy do wpisow/Kiedy STM32 steruje serwem/Kod/STM32_servo/PCA9685//startup/startup_stm32f401xe.s; 12 | HeaderPath=..\Drivers\STM32F4xx_HAL_Driver\Inc;..\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F4xx\Include;..\Drivers\CMSIS\Include;..\Inc; 13 | CDefines=__weak:__attribute__((weak));__packed:__attribute__((__packed__)); 14 | 15 | -------------------------------------------------------------------------------- /Src/stm32f4xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2019 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* USER CODE END Header */ 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "main.h" 38 | #include "stm32f4xx_it.h" 39 | /* Private includes ----------------------------------------------------------*/ 40 | /* USER CODE BEGIN Includes */ 41 | /* USER CODE END Includes */ 42 | 43 | /* Private typedef -----------------------------------------------------------*/ 44 | /* USER CODE BEGIN TD */ 45 | 46 | /* USER CODE END TD */ 47 | 48 | /* Private define ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN PD */ 50 | 51 | /* USER CODE END PD */ 52 | 53 | /* Private macro -------------------------------------------------------------*/ 54 | /* USER CODE BEGIN PM */ 55 | 56 | /* USER CODE END PM */ 57 | 58 | /* Private variables ---------------------------------------------------------*/ 59 | /* USER CODE BEGIN PV */ 60 | 61 | /* USER CODE END PV */ 62 | 63 | /* Private function prototypes -----------------------------------------------*/ 64 | /* USER CODE BEGIN PFP */ 65 | 66 | /* USER CODE END PFP */ 67 | 68 | /* Private user code ---------------------------------------------------------*/ 69 | /* USER CODE BEGIN 0 */ 70 | 71 | /* USER CODE END 0 */ 72 | 73 | /* External variables --------------------------------------------------------*/ 74 | /* USER CODE BEGIN EV */ 75 | 76 | /* USER CODE END EV */ 77 | 78 | /******************************************************************************/ 79 | /* Cortex-M4 Processor Interruption and Exception Handlers */ 80 | /******************************************************************************/ 81 | /** 82 | * @brief This function handles Non maskable interrupt. 83 | */ 84 | void NMI_Handler(void) 85 | { 86 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 87 | 88 | /* USER CODE END NonMaskableInt_IRQn 0 */ 89 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 90 | 91 | /* USER CODE END NonMaskableInt_IRQn 1 */ 92 | } 93 | 94 | /** 95 | * @brief This function handles Hard fault interrupt. 96 | */ 97 | void HardFault_Handler(void) 98 | { 99 | /* USER CODE BEGIN HardFault_IRQn 0 */ 100 | 101 | /* USER CODE END HardFault_IRQn 0 */ 102 | while (1) 103 | { 104 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 105 | /* USER CODE END W1_HardFault_IRQn 0 */ 106 | } 107 | } 108 | 109 | /** 110 | * @brief This function handles Memory management fault. 111 | */ 112 | void MemManage_Handler(void) 113 | { 114 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 115 | 116 | /* USER CODE END MemoryManagement_IRQn 0 */ 117 | while (1) 118 | { 119 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 120 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 121 | } 122 | } 123 | 124 | /** 125 | * @brief This function handles Pre-fetch fault, memory access fault. 126 | */ 127 | void BusFault_Handler(void) 128 | { 129 | /* USER CODE BEGIN BusFault_IRQn 0 */ 130 | 131 | /* USER CODE END BusFault_IRQn 0 */ 132 | while (1) 133 | { 134 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 135 | /* USER CODE END W1_BusFault_IRQn 0 */ 136 | } 137 | } 138 | 139 | /** 140 | * @brief This function handles Undefined instruction or illegal state. 141 | */ 142 | void UsageFault_Handler(void) 143 | { 144 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 145 | 146 | /* USER CODE END UsageFault_IRQn 0 */ 147 | while (1) 148 | { 149 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 150 | /* USER CODE END W1_UsageFault_IRQn 0 */ 151 | } 152 | } 153 | 154 | /** 155 | * @brief This function handles System service call via SWI instruction. 156 | */ 157 | void SVC_Handler(void) 158 | { 159 | /* USER CODE BEGIN SVCall_IRQn 0 */ 160 | 161 | /* USER CODE END SVCall_IRQn 0 */ 162 | /* USER CODE BEGIN SVCall_IRQn 1 */ 163 | 164 | /* USER CODE END SVCall_IRQn 1 */ 165 | } 166 | 167 | /** 168 | * @brief This function handles Debug monitor. 169 | */ 170 | void DebugMon_Handler(void) 171 | { 172 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 173 | 174 | /* USER CODE END DebugMonitor_IRQn 0 */ 175 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 176 | 177 | /* USER CODE END DebugMonitor_IRQn 1 */ 178 | } 179 | 180 | /** 181 | * @brief This function handles Pendable request for system service. 182 | */ 183 | void PendSV_Handler(void) 184 | { 185 | /* USER CODE BEGIN PendSV_IRQn 0 */ 186 | 187 | /* USER CODE END PendSV_IRQn 0 */ 188 | /* USER CODE BEGIN PendSV_IRQn 1 */ 189 | 190 | /* USER CODE END PendSV_IRQn 1 */ 191 | } 192 | 193 | /** 194 | * @brief This function handles System tick timer. 195 | */ 196 | void SysTick_Handler(void) 197 | { 198 | /* USER CODE BEGIN SysTick_IRQn 0 */ 199 | 200 | /* USER CODE END SysTick_IRQn 0 */ 201 | HAL_IncTick(); 202 | /* USER CODE BEGIN SysTick_IRQn 1 */ 203 | 204 | /* USER CODE END SysTick_IRQn 1 */ 205 | } 206 | 207 | /******************************************************************************/ 208 | /* STM32F4xx Peripheral Interrupt Handlers */ 209 | /* Add here the Interrupt Handlers for the used peripherals. */ 210 | /* For the available peripheral interrupt handler names, */ 211 | /* please refer to the startup file (startup_stm32f4xx.s). */ 212 | /******************************************************************************/ 213 | 214 | /* USER CODE BEGIN 1 */ 215 | 216 | /* USER CODE END 1 */ 217 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 218 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. October 2015 5 | * $Revision: V.1.4.5 a 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | /* extern const q31_t realCoefAQ31[1024]; */ 50 | /* extern const q31_t realCoefBQ31[1024]; */ 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoef_16_q31[24]; 62 | extern const q31_t twiddleCoef_32_q31[48]; 63 | extern const q31_t twiddleCoef_64_q31[96]; 64 | extern const q31_t twiddleCoef_128_q31[192]; 65 | extern const q31_t twiddleCoef_256_q31[384]; 66 | extern const q31_t twiddleCoef_512_q31[768]; 67 | extern const q31_t twiddleCoef_1024_q31[1536]; 68 | extern const q31_t twiddleCoef_2048_q31[3072]; 69 | extern const q31_t twiddleCoef_4096_q31[6144]; 70 | extern const q15_t twiddleCoef_16_q15[24]; 71 | extern const q15_t twiddleCoef_32_q15[48]; 72 | extern const q15_t twiddleCoef_64_q15[96]; 73 | extern const q15_t twiddleCoef_128_q15[192]; 74 | extern const q15_t twiddleCoef_256_q15[384]; 75 | extern const q15_t twiddleCoef_512_q15[768]; 76 | extern const q15_t twiddleCoef_1024_q15[1536]; 77 | extern const q15_t twiddleCoef_2048_q15[3072]; 78 | extern const q15_t twiddleCoef_4096_q15[6144]; 79 | extern const float32_t twiddleCoef_rfft_32[32]; 80 | extern const float32_t twiddleCoef_rfft_64[64]; 81 | extern const float32_t twiddleCoef_rfft_128[128]; 82 | extern const float32_t twiddleCoef_rfft_256[256]; 83 | extern const float32_t twiddleCoef_rfft_512[512]; 84 | extern const float32_t twiddleCoef_rfft_1024[1024]; 85 | extern const float32_t twiddleCoef_rfft_2048[2048]; 86 | extern const float32_t twiddleCoef_rfft_4096[4096]; 87 | 88 | 89 | /* floating-point bit reversal tables */ 90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 99 | 100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 109 | 110 | /* fixed-point bit reversal tables */ 111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) 112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) 113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) 114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) 115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) 116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) 117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) 118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 120 | 121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; 122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; 123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; 124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; 125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; 126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; 127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 130 | 131 | /* Tables for Fast Math Sine and Cosine */ 132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 135 | 136 | #endif /* ARM_COMMON_TABLES_H */ 137 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_i2c_ex.c 4 | * @author MCD Application Team 5 | * @brief I2C Extension HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of I2C extension peripheral: 8 | * + Extension features functions 9 | * 10 | @verbatim 11 | ============================================================================== 12 | ##### I2C peripheral extension features ##### 13 | ============================================================================== 14 | 15 | [..] Comparing to other previous devices, the I2C interface for STM32F427xx/437xx/ 16 | 429xx/439xx devices contains the following additional features : 17 | 18 | (+) Possibility to disable or enable Analog Noise Filter 19 | (+) Use of a configured Digital Noise Filter 20 | 21 | ##### How to use this driver ##### 22 | ============================================================================== 23 | [..] This driver provides functions to configure Noise Filter 24 | (#) Configure I2C Analog noise filter using the function HAL_I2C_AnalogFilter_Config() 25 | (#) Configure I2C Digital noise filter using the function HAL_I2C_DigitalFilter_Config() 26 | 27 | @endverbatim 28 | ****************************************************************************** 29 | * @attention 30 | * 31 | *

© COPYRIGHT(c) 2017 STMicroelectronics

32 | * 33 | * Redistribution and use in source and binary forms, with or without modification, 34 | * are permitted provided that the following conditions are met: 35 | * 1. Redistributions of source code must retain the above copyright notice, 36 | * this list of conditions and the following disclaimer. 37 | * 2. Redistributions in binary form must reproduce the above copyright notice, 38 | * this list of conditions and the following disclaimer in the documentation 39 | * and/or other materials provided with the distribution. 40 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 41 | * may be used to endorse or promote products derived from this software 42 | * without specific prior written permission. 43 | * 44 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 45 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 46 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 47 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 48 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 49 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 50 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 51 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 52 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 54 | * 55 | ****************************************************************************** 56 | */ 57 | 58 | /* Includes ------------------------------------------------------------------*/ 59 | #include "stm32f4xx_hal.h" 60 | 61 | /** @addtogroup STM32F4xx_HAL_Driver 62 | * @{ 63 | */ 64 | 65 | /** @defgroup I2CEx I2CEx 66 | * @brief I2C HAL module driver 67 | * @{ 68 | */ 69 | 70 | #ifdef HAL_I2C_MODULE_ENABLED 71 | 72 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 73 | defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) ||\ 74 | defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || defined(STM32F423xx) 75 | /* Private typedef -----------------------------------------------------------*/ 76 | /* Private define ------------------------------------------------------------*/ 77 | /* Private macro -------------------------------------------------------------*/ 78 | /* Private variables ---------------------------------------------------------*/ 79 | /* Private function prototypes -----------------------------------------------*/ 80 | /* Exported functions --------------------------------------------------------*/ 81 | /** @defgroup I2CEx_Exported_Functions I2C Exported Functions 82 | * @{ 83 | */ 84 | 85 | 86 | /** @defgroup I2CEx_Exported_Functions_Group1 Extension features functions 87 | * @brief Extension features functions 88 | * 89 | @verbatim 90 | =============================================================================== 91 | ##### Extension features functions ##### 92 | =============================================================================== 93 | [..] This section provides functions allowing to: 94 | (+) Configure Noise Filters 95 | 96 | @endverbatim 97 | * @{ 98 | */ 99 | 100 | /** 101 | * @brief Configures I2C Analog noise filter. 102 | * @param hi2c pointer to a I2C_HandleTypeDef structure that contains 103 | * the configuration information for the specified I2Cx peripheral. 104 | * @param AnalogFilter new state of the Analog filter. 105 | * @retval HAL status 106 | */ 107 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter) 108 | { 109 | /* Check the parameters */ 110 | assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); 111 | assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter)); 112 | 113 | if(hi2c->State == HAL_I2C_STATE_READY) 114 | { 115 | hi2c->State = HAL_I2C_STATE_BUSY; 116 | 117 | /* Disable the selected I2C peripheral */ 118 | __HAL_I2C_DISABLE(hi2c); 119 | 120 | /* Reset I2Cx ANOFF bit */ 121 | hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF); 122 | 123 | /* Disable the analog filter */ 124 | hi2c->Instance->FLTR |= AnalogFilter; 125 | 126 | __HAL_I2C_ENABLE(hi2c); 127 | 128 | hi2c->State = HAL_I2C_STATE_READY; 129 | 130 | return HAL_OK; 131 | } 132 | else 133 | { 134 | return HAL_BUSY; 135 | } 136 | } 137 | 138 | /** 139 | * @brief Configures I2C Digital noise filter. 140 | * @param hi2c pointer to a I2C_HandleTypeDef structure that contains 141 | * the configuration information for the specified I2Cx peripheral. 142 | * @param DigitalFilter Coefficient of digital noise filter between 0x00 and 0x0F. 143 | * @retval HAL status 144 | */ 145 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter) 146 | { 147 | uint16_t tmpreg = 0; 148 | 149 | /* Check the parameters */ 150 | assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); 151 | assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter)); 152 | 153 | if(hi2c->State == HAL_I2C_STATE_READY) 154 | { 155 | hi2c->State = HAL_I2C_STATE_BUSY; 156 | 157 | /* Disable the selected I2C peripheral */ 158 | __HAL_I2C_DISABLE(hi2c); 159 | 160 | /* Get the old register value */ 161 | tmpreg = hi2c->Instance->FLTR; 162 | 163 | /* Reset I2Cx DNF bit [3:0] */ 164 | tmpreg &= ~(I2C_FLTR_DNF); 165 | 166 | /* Set I2Cx DNF coefficient */ 167 | tmpreg |= DigitalFilter; 168 | 169 | /* Store the new register value */ 170 | hi2c->Instance->FLTR = tmpreg; 171 | 172 | __HAL_I2C_ENABLE(hi2c); 173 | 174 | hi2c->State = HAL_I2C_STATE_READY; 175 | 176 | return HAL_OK; 177 | } 178 | else 179 | { 180 | return HAL_BUSY; 181 | } 182 | } 183 | 184 | /** 185 | * @} 186 | */ 187 | 188 | /** 189 | * @} 190 | */ 191 | #endif /* STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F401xC ||\ 192 | STM32F401xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F413xx ||\ 193 | STM32F423xx */ 194 | 195 | #endif /* HAL_I2C_MODULE_ENABLED */ 196 | /** 197 | * @} 198 | */ 199 | 200 | /** 201 | * @} 202 | */ 203 | 204 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 205 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.c 4 | * @author MCD Application Team 5 | * @brief FLASH RAMFUNC module driver. 6 | * This file provides a FLASH firmware functions which should be 7 | * executed from internal SRAM 8 | * + Stop/Start the flash interface while System Run 9 | * + Enable/Disable the flash sleep while System Run 10 | @verbatim 11 | ============================================================================== 12 | ##### APIs executed from Internal RAM ##### 13 | ============================================================================== 14 | [..] 15 | *** ARM Compiler *** 16 | -------------------- 17 | [..] RAM functions are defined using the toolchain options. 18 | Functions that are be executed in RAM should reside in a separate 19 | source module. Using the 'Options for File' dialog you can simply change 20 | the 'Code / Const' area of a module to a memory space in physical RAM. 21 | Available memory areas are declared in the 'Target' tab of the 22 | Options for Target' dialog. 23 | 24 | *** ICCARM Compiler *** 25 | ----------------------- 26 | [..] RAM functions are defined using a specific toolchain keyword "__ramfunc". 27 | 28 | *** GNU Compiler *** 29 | -------------------- 30 | [..] RAM functions are defined using a specific toolchain attribute 31 | "__attribute__((section(".RamFunc")))". 32 | 33 | @endverbatim 34 | ****************************************************************************** 35 | * @attention 36 | * 37 | *

© COPYRIGHT(c) 2017 STMicroelectronics

38 | * 39 | * Redistribution and use in source and binary forms, with or without modification, 40 | * are permitted provided that the following conditions are met: 41 | * 1. Redistributions of source code must retain the above copyright notice, 42 | * this list of conditions and the following disclaimer. 43 | * 2. Redistributions in binary form must reproduce the above copyright notice, 44 | * this list of conditions and the following disclaimer in the documentation 45 | * and/or other materials provided with the distribution. 46 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 47 | * may be used to endorse or promote products derived from this software 48 | * without specific prior written permission. 49 | * 50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 51 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 53 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 56 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 57 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 58 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 59 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 | * 61 | ****************************************************************************** 62 | */ 63 | 64 | /* Includes ------------------------------------------------------------------*/ 65 | #include "stm32f4xx_hal.h" 66 | 67 | /** @addtogroup STM32F4xx_HAL_Driver 68 | * @{ 69 | */ 70 | 71 | /** @defgroup FLASH_RAMFUNC FLASH RAMFUNC 72 | * @brief FLASH functions executed from RAM 73 | * @{ 74 | */ 75 | #ifdef HAL_FLASH_MODULE_ENABLED 76 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ 77 | defined(STM32F412Rx) || defined(STM32F412Cx) 78 | 79 | /* Private typedef -----------------------------------------------------------*/ 80 | /* Private define ------------------------------------------------------------*/ 81 | /* Private macro -------------------------------------------------------------*/ 82 | /* Private variables ---------------------------------------------------------*/ 83 | /* Private function prototypes -----------------------------------------------*/ 84 | /* Exported functions --------------------------------------------------------*/ 85 | /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAMFUNC Exported Functions 86 | * @{ 87 | */ 88 | 89 | /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions executed from internal RAM 90 | * @brief Peripheral Extended features functions 91 | * 92 | @verbatim 93 | 94 | =============================================================================== 95 | ##### ramfunc functions ##### 96 | =============================================================================== 97 | [..] 98 | This subsection provides a set of functions that should be executed from RAM 99 | transfers. 100 | 101 | @endverbatim 102 | * @{ 103 | */ 104 | 105 | /** 106 | * @brief Stop the flash interface while System Run 107 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 108 | * @note This mode couldn't be set while executing with the flash itself. 109 | * It should be done with specific routine executed from RAM. 110 | * @retval HAL status 111 | */ 112 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void) 113 | { 114 | /* Enable Power ctrl clock */ 115 | __HAL_RCC_PWR_CLK_ENABLE(); 116 | /* Stop the flash interface while System Run */ 117 | SET_BIT(PWR->CR, PWR_CR_FISSR); 118 | 119 | return HAL_OK; 120 | } 121 | 122 | /** 123 | * @brief Start the flash interface while System Run 124 | * @note This mode is only available for STM32F411xx/STM32F446xx devices. 125 | * @note This mode couldn't be set while executing with the flash itself. 126 | * It should be done with specific routine executed from RAM. 127 | * @retval HAL status 128 | */ 129 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void) 130 | { 131 | /* Enable Power ctrl clock */ 132 | __HAL_RCC_PWR_CLK_ENABLE(); 133 | /* Start the flash interface while System Run */ 134 | CLEAR_BIT(PWR->CR, PWR_CR_FISSR); 135 | 136 | return HAL_OK; 137 | } 138 | 139 | /** 140 | * @brief Enable the flash sleep while System Run 141 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 142 | * @note This mode could n't be set while executing with the flash itself. 143 | * It should be done with specific routine executed from RAM. 144 | * @retval HAL status 145 | */ 146 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void) 147 | { 148 | /* Enable Power ctrl clock */ 149 | __HAL_RCC_PWR_CLK_ENABLE(); 150 | /* Enable the flash sleep while System Run */ 151 | SET_BIT(PWR->CR, PWR_CR_FMSSR); 152 | 153 | return HAL_OK; 154 | } 155 | 156 | /** 157 | * @brief Disable the flash sleep while System Run 158 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 159 | * @note This mode couldn't be set while executing with the flash itself. 160 | * It should be done with specific routine executed from RAM. 161 | * @retval HAL status 162 | */ 163 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void) 164 | { 165 | /* Enable Power ctrl clock */ 166 | __HAL_RCC_PWR_CLK_ENABLE(); 167 | /* Disable the flash sleep while System Run */ 168 | CLEAR_BIT(PWR->CR, PWR_CR_FMSSR); 169 | 170 | return HAL_OK; 171 | } 172 | 173 | /** 174 | * @} 175 | */ 176 | 177 | /** 178 | * @} 179 | */ 180 | 181 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 182 | #endif /* HAL_FLASH_MODULE_ENABLED */ 183 | /** 184 | * @} 185 | */ 186 | 187 | /** 188 | * @} 189 | */ 190 | 191 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 192 | -------------------------------------------------------------------------------- /Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | * Created on: 20.01.2019 39 | * Author: Mateusz Salamon 40 | * mateusz@msalamon.pl 41 | * 42 | * Website: https://msalamon.pl/nigdy-wiecej-multipleksowania-na-gpio!-max7219-w-akcji-cz-3/ 43 | * GitHub: https://github.com/lamik/Servos_PWM_STM32_HAL 44 | */ 45 | /* USER CODE END Header */ 46 | 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "main.h" 49 | #include "i2c.h" 50 | #include "gpio.h" 51 | 52 | /* Private includes ----------------------------------------------------------*/ 53 | /* USER CODE BEGIN Includes */ 54 | #include "pca9685.h" 55 | /* USER CODE END Includes */ 56 | 57 | /* Private typedef -----------------------------------------------------------*/ 58 | /* USER CODE BEGIN PTD */ 59 | 60 | /* USER CODE END PTD */ 61 | 62 | /* Private define ------------------------------------------------------------*/ 63 | /* USER CODE BEGIN PD */ 64 | #define SERVO_COUNT 5 65 | /* USER CODE END PD */ 66 | 67 | /* Private macro -------------------------------------------------------------*/ 68 | /* USER CODE BEGIN PM */ 69 | 70 | /* USER CODE END PM */ 71 | 72 | /* Private variables ---------------------------------------------------------*/ 73 | 74 | /* USER CODE BEGIN PV */ 75 | uint8_t ActiveServo; 76 | /* USER CODE END PV */ 77 | 78 | /* Private function prototypes -----------------------------------------------*/ 79 | void SystemClock_Config(void); 80 | /* USER CODE BEGIN PFP */ 81 | 82 | /* USER CODE END PFP */ 83 | 84 | /* Private user code ---------------------------------------------------------*/ 85 | /* USER CODE BEGIN 0 */ 86 | 87 | /* USER CODE END 0 */ 88 | 89 | /** 90 | * @brief The application entry point. 91 | * @retval int 92 | */ 93 | int main(void) 94 | { 95 | /* USER CODE BEGIN 1 */ 96 | 97 | /* USER CODE END 1 */ 98 | 99 | /* MCU Configuration--------------------------------------------------------*/ 100 | 101 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 102 | HAL_Init(); 103 | 104 | /* USER CODE BEGIN Init */ 105 | 106 | /* USER CODE END Init */ 107 | 108 | /* Configure the system clock */ 109 | SystemClock_Config(); 110 | 111 | /* USER CODE BEGIN SysInit */ 112 | 113 | /* USER CODE END SysInit */ 114 | 115 | /* Initialize all configured peripherals */ 116 | MX_GPIO_Init(); 117 | MX_I2C1_Init(); 118 | /* USER CODE BEGIN 2 */ 119 | PCA9685_Init(&hi2c1); 120 | PCA9685_SetServoAngle(0, 0); 121 | PCA9685_SetServoAngle(1, 0); 122 | PCA9685_SetServoAngle(2, 0); 123 | PCA9685_SetServoAngle(3, 0); 124 | PCA9685_SetServoAngle(4, 0); 125 | 126 | HAL_Delay(2000); 127 | /* USER CODE END 2 */ 128 | 129 | /* Infinite loop */ 130 | /* USER CODE BEGIN WHILE */ 131 | while (1) 132 | { 133 | for (uint8_t Angle = 0; Angle < 180; Angle++) { 134 | PCA9685_SetServoAngle(ActiveServo, Angle); 135 | } 136 | HAL_Delay(500); 137 | for (uint16_t Angle = 180; Angle > 0; Angle--) { 138 | PCA9685_SetServoAngle(ActiveServo, Angle); 139 | } 140 | HAL_Delay(500); 141 | ActiveServo++; 142 | if (ActiveServo >= SERVO_COUNT) ActiveServo = 0; 143 | /* USER CODE END WHILE */ 144 | 145 | /* USER CODE BEGIN 3 */ 146 | } 147 | /* USER CODE END 3 */ 148 | } 149 | 150 | /** 151 | * @brief System Clock Configuration 152 | * @retval None 153 | */ 154 | void SystemClock_Config(void) 155 | { 156 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 157 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 158 | 159 | /**Configure the main internal regulator output voltage 160 | */ 161 | __HAL_RCC_PWR_CLK_ENABLE(); 162 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); 163 | /**Initializes the CPU, AHB and APB busses clocks 164 | */ 165 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 166 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 167 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 168 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 169 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; 170 | RCC_OscInitStruct.PLL.PLLM = 8; 171 | RCC_OscInitStruct.PLL.PLLN = 84; 172 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; 173 | RCC_OscInitStruct.PLL.PLLQ = 4; 174 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 175 | { 176 | Error_Handler(); 177 | } 178 | /**Initializes the CPU, AHB and APB busses clocks 179 | */ 180 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 181 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 182 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 183 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 184 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 185 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 186 | 187 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) 188 | { 189 | Error_Handler(); 190 | } 191 | } 192 | 193 | /* USER CODE BEGIN 4 */ 194 | 195 | /* USER CODE END 4 */ 196 | 197 | /** 198 | * @brief This function is executed in case of error occurrence. 199 | * @retval None 200 | */ 201 | void Error_Handler(void) 202 | { 203 | /* USER CODE BEGIN Error_Handler_Debug */ 204 | /* User can add his own implementation to report the HAL error return state */ 205 | 206 | /* USER CODE END Error_Handler_Debug */ 207 | } 208 | 209 | #ifdef USE_FULL_ASSERT 210 | /** 211 | * @brief Reports the name of the source file and the source line number 212 | * where the assert_param error has occurred. 213 | * @param file: pointer to the source file name 214 | * @param line: assert_param error line source number 215 | * @retval None 216 | */ 217 | void assert_failed(uint8_t *file, uint32_t line) 218 | { 219 | /* USER CODE BEGIN 6 */ 220 | /* User can add his own implementation to report the file name and line number, 221 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 222 | /* USER CODE END 6 */ 223 | } 224 | #endif /* USE_FULL_ASSERT */ 225 | 226 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 227 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© COPYRIGHT(c) 2017 STMicroelectronics

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

© COPYRIGHT(c) 2017 STMicroelectronics

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

© COPYRIGHT(c) 2017 STMicroelectronics

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

© COPYRIGHT(c) 2017 STMicroelectronics

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

© COPYRIGHT(c) 2017 STMicroelectronics

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

© COPYRIGHT(c) 2017 STMicroelectronics

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