Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

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