annotate Discovery/Src/firmwareJumpToApplication.c @ 952:33e24b77cc6c Evo_2_23

Bugfix ppo2 high/low check in OC mode: The fallback option which is used in CC mode was applied to the OC mode as well. As result the check could be deactivated depending on the fallback state, even if a OC dive is performed. now the check will always be performed if the dive mode is OC. Added vibration warning: The internal buzzer of the GPIO_V2 may now be used as additional warning notificator. It can be activated using the check button in the customer view menu. The vibration will be active while the warning message is displayed in the dive window. In case the diver is in the menu then the warning will be active for a shorter duration.
author Ideenmodellierer
date Sun, 29 Dec 2024 18:33:02 +0100
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file firmwareJumpToApplication.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 05-May-2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * @since 05-May-2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * @brief jump to application in higher flash region
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 ##### How to use #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ##### From AN2557 #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 STM32F10xxx In-Application programming CD00161640.pdf 2010
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 User program conditions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 The user application to be loaded into the Flash memory using IAP should be built with
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 these configuration settings:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 1. Set the program load address at 0x08003000, using your toolchain linker file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 2. Relocate the vector table at address 0x08003000, using the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 "NVIC_SetVectorTable"function or the VECT_TAB_OFFSET definition inside the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 "system_stm32f10x.c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 can be found here system_stm32f4xx.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 * <h2><center>&copy; COPYRIGHT(c) 2015 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 #include "stdio.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 #include "firmwareJumpToApplication.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 /* Exported variables --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 typedef void (*pFunction)(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 #define ApplicationAddress 0x08040000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 pFunction Jump_To_Application;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 uint32_t JumpAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 uint8_t firmware_MainCodeIsProgammed(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 uint32_t content_start;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 content_start = *(__IO uint32_t*)ApplicationAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 if ((content_start & 0x2FFE0000 ) == 0x20000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 return 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 void firmware_JumpTo_Application(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 /* Test if user code is programmed starting from address "ApplicationAddress" */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 /* Jump to user application */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 Jump_To_Application = (pFunction) JumpAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 /* Initialize user application's Stack Pointer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 __set_MSP(*(__IO uint32_t*) ApplicationAddress);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 Jump_To_Application();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 while (1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 {}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 /* Private functions ---------------------------------------------------------*/