BOOT APP 软中断重映射 搞定, 不影响正常非BOOT/APP固件编译

This commit is contained in:
WangQiang 2016-04-13 02:02:38 +00:00
parent 7529c26040
commit 79fa713abd
4 changed files with 45 additions and 3 deletions

View File

@ -14,13 +14,21 @@ void TInterrupt::Init() const
#if defined(STM32F1) || defined(STM32F4)
NVIC->ICER[1] = 0xFFFFFFFF;
NVIC->ICER[2] = 0xFFFFFFFF;
#endif
#endif // defined(STM32F1) || defined(STM32F4)
// 清除所有中断位
NVIC->ICPR[0] = 0xFFFFFFFF;
#if defined(STM32F1) || defined(STM32F4)
NVIC->ICPR[1] = 0xFFFFFFFF;
NVIC->ICPR[2] = 0xFFFFFFFF;
#endif // defined(STM32F1) || defined(STM32F4)
#if defined(BOOT) || defined(APP)
StrBoot.pUserHandler = RealHandler;;
#endif
#if defined(APP)
GlobalEnable();
#endif
#ifdef STM32F4
@ -32,7 +40,7 @@ void TInterrupt::Init() const
SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk
| SCB_SHCSR_BUSFAULTENA_Msk
| SCB_SHCSR_MEMFAULTENA_Msk;
#endif
#endif // STM32F4
#ifdef STM32F1
/*SCB->AIRCR = (0x5FA << SCB_AIRCR_VECTKEY_Pos) // 解锁
| (7 << SCB_AIRCR_PRIGROUP_Pos); // 没有优先组位*/
@ -42,7 +50,7 @@ void TInterrupt::Init() const
SCB->SHCSR |= SCB_SHCSR_USGFAULTENA
| SCB_SHCSR_BUSFAULTENA
| SCB_SHCSR_MEMFAULTENA;
#endif
#endif // STM32F1
// 初始化EXTI中断线为默认值
EXTI_DeInit();
@ -193,7 +201,18 @@ bool TInterrupt::IsHandler() const { return GetIPSR() & 0x01; }
#ifdef TINY
__ASM void FaultHandler() { }
#else
#if defined(BOOT) || defined(APP)
void UserHandler()
{
StrBoot.pUserHandler();
}
void RealHandler()
#else
void UserHandler()
#endif
{
uint num = GetIPSR();
assert_param(num < VectorySize);

View File

@ -97,6 +97,11 @@ extern "C"
{
void FaultHandler(void);
void UserHandler(void);
#if defined(BOOT) || defined(APP)
void RealHandler(void);
#endif
void ShowFault(uint exception);
}

View File

@ -8,6 +8,13 @@
TSys Sys;
const TTime Time;
#if defined(BOOT) || defined(APP)
//#pragma location = 0x20000000
struct BootCofig StrBoot __attribute__((at(0x2000fff0)));
#endif
extern uint __heap_base;
extern uint __heap_limit;
extern uint __initial_sp;

11
Sys.h
View File

@ -49,6 +49,17 @@ void assert_failed2(const char* msg, const char* file, unsigned int line);
// 委托
#include "Delegate.h"
#if defined(BOOT) || defined(APP)
struct BootCofig
{
Func pUserHandler;
void* Reserved1;
void* Reserved2;
void* Reserved3;
};
extern struct BootCofig StrBoot;
#endif
// 判定指针是否在ROM区
#define IN_ROM_SECTION(p) ( (int)p < 0x20000000 )