diff --git a/Kernel/Interrupt.cpp b/Kernel/Interrupt.cpp index 571a85a4..49238828 100644 --- a/Kernel/Interrupt.cpp +++ b/Kernel/Interrupt.cpp @@ -2,25 +2,16 @@ #include "Interrupt.h" -TInterrupt Interrupt; +extern InterruptCallback Vectors[]; // 对外的中断向量表 +extern void* Params[]; // 每一个中断向量对应的参数 -//#define IS_IRQ(irq) (irq >= -16 && irq <= VectorySize - 16) +TInterrupt Interrupt; void TInterrupt::Init() const { OnInit(); } -/*TInterrupt::~TInterrupt() -{ - // 恢复中断向量表 -#if defined(STM32F1) || defined(STM32F4) - NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0); -#else - SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_Flash); -#endif -}*/ - bool TInterrupt::Activate(short irq, InterruptCallback isr, void* param) { short irq2 = irq + 16; // exception = irq + 16 @@ -42,10 +33,8 @@ bool TInterrupt::Deactivate(short irq) // 关键性代码,放到开头 INROOT void TInterrupt::Process(uint num) const { - auto& inter = Interrupt; - //assert_param(num < VectorySize); - //assert_param(Interrupt.Vectors[num]); - if(!inter.Vectors[num]) return; + //auto& inter = Interrupt; + if(!Vectors[num]) return; // 内存检查 #if DEBUG @@ -53,8 +42,8 @@ INROOT void TInterrupt::Process(uint num) const #endif // 找到应用层中断委托并调用 - auto isr = (InterruptCallback)inter.Vectors[num]; - void* param = (void*)inter.Params[num]; + auto isr = (InterruptCallback)Vectors[num]; + void* param = (void*)Params[num]; isr(num - 16, param); } diff --git a/Kernel/Interrupt.h b/Kernel/Interrupt.h index 0b88788f..31af6b1e 100644 --- a/Kernel/Interrupt.h +++ b/Kernel/Interrupt.h @@ -4,28 +4,12 @@ // 中断委托(中断号,参数) typedef void (*InterruptCallback)(ushort num, void* param); -#ifdef STM32F1 - #define VectorySize 84 -#elif defined(STM32F0) - #define VectorySize 48 -#elif defined(GD32F150) - #define VectorySize 64 -#elif defined(STM32F4) - #define VectorySize (86 + 16 + 1) -#else - #define VectorySize 32 -#endif - //VectorySize 64 未考证 // 中断管理类 class TInterrupt { public: - InterruptCallback Vectors[VectorySize]; // 对外的中断向量表 - void* Params[VectorySize]; // 每一个中断向量对应的参数 - void Init() const; // 初始化中断向量表 - //~TInterrupt(); void Process(uint num) const; diff --git a/Platform/CortexM/Interrupt.cpp b/Platform/CortexM/Interrupt.cpp index 4df4b4bf..a8acf20e 100644 --- a/Platform/CortexM/Interrupt.cpp +++ b/Platform/CortexM/Interrupt.cpp @@ -7,6 +7,21 @@ #define IS_IRQ(irq) (irq >= -16 && irq <= VectorySize - 16) +#ifdef STM32F1 + #define VectorySize 84 +#elif defined(STM32F0) + #define VectorySize 48 +#elif defined(GD32F150) + #define VectorySize 64 +#elif defined(STM32F4) + #define VectorySize (86 + 16 + 1) +#else + #define VectorySize 32 +#endif + +InterruptCallback Vectors[VectorySize]; // 对外的中断向量表 +void* Params[VectorySize]; // 每一个中断向量对应的参数 + bool TInterrupt::OnActivate(short irq) { assert_param(IS_IRQ(irq)); diff --git a/TinyIP/Arp.cpp b/TinyIP/Arp.cpp index 875e3065..46d92bb6 100644 --- a/TinyIP/Arp.cpp +++ b/TinyIP/Arp.cpp @@ -20,13 +20,7 @@ ArpSocket::ArpSocket(TinyIP* tip) : TinySocket(tip, IP_NONE) { //Type = IP_NONE; -#ifdef STM32F0 - Count = 4; -#elif defined(STM32F1) - Count = 16; -#elif defined(STM32F4) - Count = 64; -#endif + Count = 8; _Arps = nullptr; Enable = true;