|
@@ -0,0 +1,107 @@
|
|
|
+/**
|
|
|
+ ******************************************************************************
|
|
|
+ * File Name : main.c
|
|
|
+ * Description : Main program body
|
|
|
+ ******************************************************************************
|
|
|
+ *
|
|
|
+ * COPYRIGHT(c) 2015 STMicroelectronics
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without modification,
|
|
|
+ * are permitted provided that the following conditions are met:
|
|
|
+ * 1. Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer in the documentation
|
|
|
+ * and/or other materials provided with the distribution.
|
|
|
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
|
|
|
+ * may be used to endorse or promote products derived from this software
|
|
|
+ * without specific prior written permission.
|
|
|
+ *
|
|
|
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
+ *
|
|
|
+ ******************************************************************************
|
|
|
+ */
|
|
|
+
|
|
|
+#ifndef __APP_LOADER_H__
|
|
|
+#define __APP_LOADER_H__
|
|
|
+
|
|
|
+/* Includes ------------------------------------------------------------------*/
|
|
|
+#define STM32F103 1
|
|
|
+#define STM32F072 0
|
|
|
+
|
|
|
+#if STM32F103
|
|
|
+ #include "stm32f1xx_hal.h"
|
|
|
+ #define NEW_VECTOR_OFFSET (uint32_t)0x00003000
|
|
|
+#elif STM32F072
|
|
|
+ #include "stm32f0xx_hal.h"
|
|
|
+ #define APPLICATION_ADDRESS (uint32_t)0x08003000
|
|
|
+ #define NEW_VECTOR_ADDRESS (uint32_t)0x20000000
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+/* USER CODE BEGIN Includes */
|
|
|
+
|
|
|
+/* USER CODE END Includes */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/* Private variables ---------------------------------------------------------*/
|
|
|
+
|
|
|
+/* USER CODE BEGIN PV */
|
|
|
+/* Private variables ---------------------------------------------------------*/
|
|
|
+
|
|
|
+/* USER CODE END PV */
|
|
|
+
|
|
|
+/* Private function prototypes -----------------------------------------------*/
|
|
|
+
|
|
|
+/* USER CODE BEGIN PFP */
|
|
|
+/* Private function prototypes -----------------------------------------------*/
|
|
|
+extern void IAP_Init(void)
|
|
|
+{
|
|
|
+ #if (STM32F103 == 1)
|
|
|
+
|
|
|
+ #ifdef VECT_TAB_SRAM
|
|
|
+ SCB->VTOR = SRAM_BASE | NEW_VECTOR_OFFSET; /* Vector Table Relocation in Internal SRAM. */
|
|
|
+ #else
|
|
|
+ SCB->VTOR = FLASH_BASE | NEW_VECTOR_OFFSET; /* Vector Table Relocation in Internal FLASH. */
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #elif (STM32F072 == 1)
|
|
|
+ /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
|
|
|
+ uint32_t i = 0;
|
|
|
+ /* Copy the vector table from the Flash (mapped at the base of the application
|
|
|
+ load address 0x08003000) to the base address of the SRAM at 0x20000000. */
|
|
|
+ for(i = 0; i < 48; i++)
|
|
|
+ {
|
|
|
+ *((uint32_t*)(NEW_VECTOR_ADDRESS + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
|
|
|
+ }
|
|
|
+ /* Enable the SYSCFG peripheral clock*/
|
|
|
+ __HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
|
+
|
|
|
+ /* Remap SRAM at 0x00000000 */
|
|
|
+ __HAL_SYSCFG_REMAPMEMORY_SRAM();
|
|
|
+ #endif
|
|
|
+}
|
|
|
+
|
|
|
+#endif /*___APP_LOADER_H__ */
|
|
|
+
|
|
|
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
|
+
|
|
|
+
|