static void Halt(); // 系统挂起
This commit is contained in:
parent
5c17fb3716
commit
dee50c83de
|
@ -65,6 +65,20 @@ void TInterrupt::Process(uint num) const
|
||||||
isr(num - 16, param);
|
isr(num - 16, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 系统挂起
|
||||||
|
void TInterrupt::Halt()
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
TraceStack::Show();
|
||||||
|
|
||||||
|
//auto sp = SerialPort::GetMessagePort();
|
||||||
|
//if(sp) sp->Flush();
|
||||||
|
#endif
|
||||||
|
while(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************** SmartIRQ ********************************/
|
||||||
|
|
||||||
// 智能IRQ,初始化时备份,销毁时还原
|
// 智能IRQ,初始化时备份,销毁时还原
|
||||||
SmartIRQ::SmartIRQ(bool enable)
|
SmartIRQ::SmartIRQ(bool enable)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +106,7 @@ SmartIRQ::~SmartIRQ()
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*================================ 锁 ================================*/
|
/******************************** Lock ********************************/
|
||||||
|
|
||||||
#include "TTime.h"
|
#include "TTime.h"
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
//~TInterrupt();
|
//~TInterrupt();
|
||||||
|
|
||||||
void Process(uint num) const;
|
void Process(uint num) const;
|
||||||
|
|
||||||
// 注册中断函数(中断号,函数,参数)
|
// 注册中断函数(中断号,函数,参数)
|
||||||
bool Activate(short irq, InterruptCallback isr, void* param = nullptr);
|
bool Activate(short irq, InterruptCallback isr, void* param = nullptr);
|
||||||
// 解除中断注册
|
// 解除中断注册
|
||||||
|
@ -56,7 +56,9 @@ public:
|
||||||
static bool GlobalState(); // 全局中断开关状态
|
static bool GlobalState(); // 全局中断开关状态
|
||||||
|
|
||||||
static bool IsHandler(); // 是否在中断里面
|
static bool IsHandler(); // 是否在中断里面
|
||||||
|
|
||||||
|
static void Halt(); // 系统挂起
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnInit() const;
|
void OnInit() const;
|
||||||
bool OnActivate(short irq);
|
bool OnActivate(short irq);
|
||||||
|
|
|
@ -150,9 +150,7 @@ void assert_failed2(cstring msg, cstring file, unsigned int line)
|
||||||
{
|
{
|
||||||
debug_printf("%s Line %d, %s\r\n", msg, line, file);
|
debug_printf("%s Line %d, %s\r\n", msg, line, file);
|
||||||
|
|
||||||
TraceStack::Show();
|
TInterrupt::Halt();
|
||||||
|
|
||||||
while (1) { }
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,7 @@ void assert_failed(uint8_t* file, unsigned int line)
|
||||||
{
|
{
|
||||||
debug_printf("Assert Failed! Line %d, %s\r\n", line, file);
|
debug_printf("Assert Failed! Line %d, %s\r\n", line, file);
|
||||||
|
|
||||||
TraceStack::Show();
|
TInterrupt::Halt();
|
||||||
|
|
||||||
while (1) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool assert_ptr_(const void* p)
|
bool assert_ptr_(const void* p)
|
||||||
|
|
|
@ -98,13 +98,7 @@ extern "C"
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEBUG
|
TInterrupt::Halt();
|
||||||
TraceStack::Show();
|
|
||||||
|
|
||||||
//auto sp = SerialPort::GetMessagePort();
|
|
||||||
//if(sp) sp->Flush();
|
|
||||||
#endif
|
|
||||||
while(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined ( __CC_ARM )
|
#if defined ( __CC_ARM )
|
||||||
|
@ -143,7 +137,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
__asm volatile (
|
__asm volatile (
|
||||||
#if defined(STM32F0) || defined(GD32F150)
|
#if defined(STM32F0) || defined(GD32F150)
|
||||||
"push {r4-r7} \n\t"
|
"push {r4-r7} \n\t"
|
||||||
#else
|
#else
|
||||||
"add sp,sp,#16 \n\t"
|
"add sp,sp,#16 \n\t"
|
||||||
"push {r0-r11} \n\t"
|
"push {r0-r11} \n\t"
|
||||||
|
|
|
@ -77,34 +77,16 @@ void TInterrupt::DecodePriority (uint priority, uint priorityGroup, uint* pPreem
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
/* 在GD32F130C8中时常有一个FAULT_SubHandler跳转的错误,
|
|
||||||
经查是因为FAULT_SubHandler和FaultHandler离得太远,导致b跳转无法到达,
|
|
||||||
因此把这两个函数指定到同一个段中,使得它们地址分布上紧挨着
|
|
||||||
*/
|
|
||||||
void FAULT_SubHandler(uint* registers, uint exception)
|
void FAULT_SubHandler(uint* registers, uint exception)
|
||||||
{
|
{
|
||||||
#ifdef STM32F0
|
|
||||||
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x\r\n", registers[5], registers[6], registers[7]);
|
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x\r\n", registers[5], registers[6], registers[7]);
|
||||||
for(int i=0; i<=7; i++)
|
for(int i=0; i<=7; i++)
|
||||||
{
|
{
|
||||||
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
||||||
}
|
}
|
||||||
debug_printf("R12=0x%08x\r\n", registers[4]);
|
debug_printf("R12=0x%08x\r\n", registers[4]);
|
||||||
#else
|
|
||||||
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x SP=0x%08x\r\n", registers[13], registers[14], registers[15], registers[16]);
|
|
||||||
for(int i=0; i<=12; i++)
|
|
||||||
{
|
|
||||||
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DEBUG
|
TInterrupt::Halt();
|
||||||
TraceStack::Show();
|
|
||||||
|
|
||||||
//auto sp = SerialPort::GetMessagePort();
|
|
||||||
//if(sp) sp->Flush();
|
|
||||||
#endif
|
|
||||||
while(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined ( __CC_ARM )
|
#if defined ( __CC_ARM )
|
||||||
|
@ -143,7 +125,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
__asm volatile (
|
__asm volatile (
|
||||||
#if defined(STM32F0) || defined(GD32F150)
|
#if defined(STM32F0) || defined(GD32F150)
|
||||||
"push {r4-r7} \n\t"
|
"push {r4-r7} \n\t"
|
||||||
#else
|
#else
|
||||||
"add sp,sp,#16 \n\t"
|
"add sp,sp,#16 \n\t"
|
||||||
"push {r0-r11} \n\t"
|
"push {r0-r11} \n\t"
|
||||||
|
|
|
@ -77,34 +77,15 @@ void TInterrupt::DecodePriority (uint priority, uint priorityGroup, uint* pPreem
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
/* 在GD32F130C8中时常有一个FAULT_SubHandler跳转的错误,
|
|
||||||
经查是因为FAULT_SubHandler和FaultHandler离得太远,导致b跳转无法到达,
|
|
||||||
因此把这两个函数指定到同一个段中,使得它们地址分布上紧挨着
|
|
||||||
*/
|
|
||||||
void FAULT_SubHandler(uint* registers, uint exception)
|
void FAULT_SubHandler(uint* registers, uint exception)
|
||||||
{
|
{
|
||||||
#ifdef STM32F0
|
|
||||||
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x\r\n", registers[5], registers[6], registers[7]);
|
|
||||||
for(int i=0; i<=7; i++)
|
|
||||||
{
|
|
||||||
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
|
||||||
}
|
|
||||||
debug_printf("R12=0x%08x\r\n", registers[4]);
|
|
||||||
#else
|
|
||||||
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x SP=0x%08x\r\n", registers[13], registers[14], registers[15], registers[16]);
|
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x SP=0x%08x\r\n", registers[13], registers[14], registers[15], registers[16]);
|
||||||
for(int i=0; i<=12; i++)
|
for(int i=0; i<=12; i++)
|
||||||
{
|
{
|
||||||
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DEBUG
|
TInterrupt::Halt();
|
||||||
TraceStack::Show();
|
|
||||||
|
|
||||||
//auto sp = SerialPort::GetMessagePort();
|
|
||||||
//if(sp) sp->Flush();
|
|
||||||
#endif
|
|
||||||
while(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined ( __CC_ARM )
|
#if defined ( __CC_ARM )
|
||||||
|
@ -143,7 +124,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
__asm volatile (
|
__asm volatile (
|
||||||
#if defined(STM32F0) || defined(GD32F150)
|
#if defined(STM32F0) || defined(GD32F150)
|
||||||
"push {r4-r7} \n\t"
|
"push {r4-r7} \n\t"
|
||||||
#else
|
#else
|
||||||
"add sp,sp,#16 \n\t"
|
"add sp,sp,#16 \n\t"
|
||||||
"push {r0-r11} \n\t"
|
"push {r0-r11} \n\t"
|
||||||
|
|
|
@ -77,34 +77,15 @@ void TInterrupt::DecodePriority (uint priority, uint priorityGroup, uint* pPreem
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
/* 在GD32F130C8中时常有一个FAULT_SubHandler跳转的错误,
|
|
||||||
经查是因为FAULT_SubHandler和FaultHandler离得太远,导致b跳转无法到达,
|
|
||||||
因此把这两个函数指定到同一个段中,使得它们地址分布上紧挨着
|
|
||||||
*/
|
|
||||||
void FAULT_SubHandler(uint* registers, uint exception)
|
void FAULT_SubHandler(uint* registers, uint exception)
|
||||||
{
|
{
|
||||||
#ifdef STM32F0
|
|
||||||
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x\r\n", registers[5], registers[6], registers[7]);
|
|
||||||
for(int i=0; i<=7; i++)
|
|
||||||
{
|
|
||||||
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
|
||||||
}
|
|
||||||
debug_printf("R12=0x%08x\r\n", registers[4]);
|
|
||||||
#else
|
|
||||||
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x SP=0x%08x\r\n", registers[13], registers[14], registers[15], registers[16]);
|
debug_printf("LR=0x%08x PC=0x%08x PSR=0x%08x SP=0x%08x\r\n", registers[13], registers[14], registers[15], registers[16]);
|
||||||
for(int i=0; i<=12; i++)
|
for(int i=0; i<=12; i++)
|
||||||
{
|
{
|
||||||
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
debug_printf("R%d=0x%08x\r\n", i, registers[i]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DEBUG
|
TInterrupt::Halt();
|
||||||
TraceStack::Show();
|
|
||||||
|
|
||||||
//auto sp = SerialPort::GetMessagePort();
|
|
||||||
//if(sp) sp->Flush();
|
|
||||||
#endif
|
|
||||||
while(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined ( __CC_ARM )
|
#if defined ( __CC_ARM )
|
||||||
|
@ -143,7 +124,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
__asm volatile (
|
__asm volatile (
|
||||||
#if defined(STM32F0) || defined(GD32F150)
|
#if defined(STM32F0) || defined(GD32F150)
|
||||||
"push {r4-r7} \n\t"
|
"push {r4-r7} \n\t"
|
||||||
#else
|
#else
|
||||||
"add sp,sp,#16 \n\t"
|
"add sp,sp,#16 \n\t"
|
||||||
"push {r0-r11} \n\t"
|
"push {r0-r11} \n\t"
|
||||||
|
|
|
@ -614,6 +614,7 @@ bool TokenClient::OnPing(TokenMessage& msg, TokenController* ctrl)
|
||||||
|
|
||||||
if (!msg.Reply) return false;
|
if (!msg.Reply) return false;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
TokenPingMessage pinMsg;
|
TokenPingMessage pinMsg;
|
||||||
pinMsg.ReadMessage(msg);
|
pinMsg.ReadMessage(msg);
|
||||||
UInt64 start = pinMsg.LocalTime;
|
UInt64 start = pinMsg.LocalTime;
|
||||||
|
@ -628,6 +629,8 @@ bool TokenClient::OnPing(TokenMessage& msg, TokenController* ctrl)
|
||||||
Delay = cost;
|
Delay = cost;
|
||||||
|
|
||||||
debug_printf("心跳延迟 %dms / %dms \r\n", cost, Delay);
|
debug_printf("心跳延迟 %dms / %dms \r\n", cost, Delay);
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue