精简不再使用的功能
This commit is contained in:
parent
3385010825
commit
7116f2a986
16
Debug.cpp
16
Debug.cpp
|
@ -103,22 +103,10 @@ void operator delete[](void* p)
|
|||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
|
||||
/**
|
||||
* @brief Reports the name of the source file and the source line number
|
||||
* where the assert_param error has occurred.
|
||||
* @param file: pointer to the source file name
|
||||
* @param line: assert_param error line source number
|
||||
* @retval : None
|
||||
*/
|
||||
void assert_failed(uint8_t* file, uint32_t line)
|
||||
{
|
||||
/* User can add his own implementation to report the file name and line number,
|
||||
ex: debug_printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||
/*if(_printf_sp) */debug_printf("Assert Failed! Line %d, %s\r\n", line, file);
|
||||
debug_printf("Assert Failed! Line %d, %s\r\n", line, file);
|
||||
|
||||
if(Sys.OnStop) Sys.OnStop();
|
||||
|
||||
/* Infinite loop */
|
||||
while (1) { }
|
||||
}
|
||||
|
||||
|
@ -126,8 +114,6 @@ void assert_failed(const char* msg, uint8_t* file, uint32_t line)
|
|||
{
|
||||
debug_printf("%s Line %d, %s\r\n", msg, line, file);
|
||||
|
||||
if(Sys.OnStop) Sys.OnStop();
|
||||
|
||||
while (1) { }
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "Interrupt.h"
|
||||
#include "SerialPort.h"
|
||||
|
||||
TInterrupt Interrupt;
|
||||
|
||||
|
@ -216,11 +217,13 @@ extern "C"
|
|||
}
|
||||
#endif
|
||||
|
||||
if(!Sys.OnError || Sys.OnError(exception))
|
||||
{
|
||||
if(Sys.OnStop) Sys.OnStop();
|
||||
while(true);
|
||||
}
|
||||
#if DEBUG
|
||||
ShowFault(exception);
|
||||
|
||||
SerialPort* sp = SerialPort::GetMessagePort();
|
||||
if(sp) sp->Flush();
|
||||
#endif
|
||||
while(true);
|
||||
}
|
||||
|
||||
__asm void FaultHandler() __attribute__((section("SubHandler")));
|
||||
|
|
55
Sys.cpp
55
Sys.cpp
|
@ -1,7 +1,6 @@
|
|||
#include "Sys.h"
|
||||
|
||||
#include "Time.h"
|
||||
#include "SerialPort.h"
|
||||
|
||||
TSys Sys;
|
||||
TTime Time;
|
||||
|
@ -16,6 +15,10 @@ extern uint __microlib_freelist_initialised;
|
|||
#define BIT(x) (1 << (x))
|
||||
#endif
|
||||
|
||||
#ifndef TINY
|
||||
static int _Index; // MCU在型号表中的索引
|
||||
#endif
|
||||
|
||||
#ifdef STM32F1
|
||||
char MemNames[] = "468BCDEFGIK";
|
||||
uint MemSizes[] = { 16, 32, 64, 128, 256, 384, 512, 768, 1024, 2048, 3072 };
|
||||
|
@ -103,26 +106,6 @@ uint16_t Get_JTAG_ID()
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool SysError(uint code)
|
||||
{
|
||||
debug_printf("系统错误!0x%02x\r\n", code);
|
||||
|
||||
#if DEBUG
|
||||
ShowFault(code);
|
||||
|
||||
SerialPort* sp = SerialPort::GetMessagePort();
|
||||
if(sp) sp->Flush();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SysStop()
|
||||
{
|
||||
debug_printf("系统停止!\r\n");
|
||||
//while(true);
|
||||
}
|
||||
|
||||
TSys::TSys()
|
||||
{
|
||||
#ifdef STM32F0
|
||||
|
@ -185,18 +168,8 @@ TSys::TSys()
|
|||
InitHeapStack(StackTop());
|
||||
#endif
|
||||
|
||||
StartTime = 0;
|
||||
OnTick = NULL;
|
||||
OnSleep = NULL;
|
||||
|
||||
#if DEBUG
|
||||
OnError = SysError;
|
||||
OnStop = SysStop;
|
||||
#else
|
||||
OnError = 0;
|
||||
OnStop = 0;
|
||||
#endif
|
||||
|
||||
#ifdef STM32F1
|
||||
// 关闭JTAG仿真接口,只打开SW仿真。
|
||||
RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // 打开时钟
|
||||
|
@ -214,14 +187,8 @@ TSys::TSys()
|
|||
#endif
|
||||
|
||||
Started = false;
|
||||
OnStart = NULL;
|
||||
}
|
||||
|
||||
/*TSys::~TSys()
|
||||
{
|
||||
if(OnStop) OnStop();
|
||||
}*/
|
||||
|
||||
void ShowTime(void* param)
|
||||
{
|
||||
debug_printf("\r");
|
||||
|
@ -282,9 +249,6 @@ typedef struct
|
|||
void TSys::ShowInfo()
|
||||
{
|
||||
#if DEBUG
|
||||
// 刚刚初始化完成的时间
|
||||
ulong initedTime = Time.Current();
|
||||
|
||||
byte* ver = (byte*)&Version;
|
||||
debug_printf("%s::%s Code:%04X ", Company, Name, Code);
|
||||
debug_printf("Ver:%x.%x Build:%s\r\n", *ver++, *ver++, BuildTime);
|
||||
|
@ -390,8 +354,6 @@ void TSys::ShowInfo()
|
|||
|
||||
debug_printf("Time : ");
|
||||
Time.Now().Show(true);
|
||||
// 系统启动时间
|
||||
debug_printf("Start: %dms (Inited: %dms)\r\n", (uint)(Time.Current() - StartTime), (uint)(initedTime - StartTime));
|
||||
debug_printf("Support: http://www.NewLifeX.com\r\n");
|
||||
|
||||
debug_printf("\r\n");
|
||||
|
@ -458,14 +420,7 @@ void TSys::Start()
|
|||
#if DEBUG
|
||||
//AddTask(ShowTime, NULL, 2000000, 2000000);
|
||||
#endif
|
||||
if(OnStart)
|
||||
{
|
||||
// 设置重载值,让其每1ms重载一次
|
||||
//Time.SetMax(1000);
|
||||
OnStart();
|
||||
}
|
||||
else
|
||||
Task::Scheduler()->Start();
|
||||
Task::Scheduler()->Start();
|
||||
}
|
||||
|
||||
void TimeSleep(uint us)
|
||||
|
|
8
Sys.h
8
Sys.h
|
@ -88,7 +88,6 @@ public:
|
|||
ushort RAMSize; // 芯片RAM容量
|
||||
|
||||
TSys(); // 构造函数
|
||||
//~TSys(); // 析构函数
|
||||
|
||||
void InitClock(); // 初始化系统时钟
|
||||
void Init(); // 初始化系统
|
||||
|
@ -96,8 +95,6 @@ public:
|
|||
uint HeapBase(); // 堆起始地址,前面是静态分配内存
|
||||
uint StackTop(); // 栈顶,后面是初始化不清零区域
|
||||
|
||||
ulong StartTime; // 启动时间,微秒
|
||||
Func OnTick;
|
||||
void Sleep(uint ms); // 毫秒级延迟
|
||||
void Delay(uint us); // 微秒级延迟
|
||||
typedef void (*FuncU32)(uint param);
|
||||
|
@ -106,10 +103,6 @@ public:
|
|||
bool CheckMemory();
|
||||
|
||||
void Reset(); // 重启系统
|
||||
bool (*OnError)(uint code); // 系统出错时引发,返回值决定是否停止系统
|
||||
Func OnStop;
|
||||
private:
|
||||
int _Index; // MCU在型号表中的索引
|
||||
|
||||
public:
|
||||
// 创建任务,返回任务编号。dueTime首次调度时间ms,period调度间隔ms,-1表示仅处理一次
|
||||
|
@ -122,7 +115,6 @@ public:
|
|||
|
||||
bool Started;
|
||||
void Start(); // 开始系统大循环
|
||||
Func OnStart;
|
||||
};
|
||||
|
||||
extern TSys Sys; //创建一个全局的Sys对象 会在main函数之前执行构造函数(!!!!!)
|
||||
|
|
1
Task.cpp
1
Task.cpp
|
@ -226,7 +226,6 @@ void TaskScheduler::Execute(uint msMax)
|
|||
{
|
||||
ulong now = Time.Current();
|
||||
ulong end = now + msMax;
|
||||
now -= Sys.StartTime; // 当前时间。减去系统启动时间,避免修改系统时间后导致调度停摆
|
||||
ulong min = UInt64_Max; // 最小时间,这个时间就会有任务到来
|
||||
|
||||
TimeCost tc;
|
||||
|
|
|
@ -420,7 +420,7 @@ void Thread::Schedule()
|
|||
//SmartIRQ irq;
|
||||
__disable_irq();
|
||||
|
||||
Sys.OnTick = OnTick;
|
||||
//Sys.OnTick = OnTick;
|
||||
Sys.OnSleep = OnSleep;
|
||||
|
||||
// 先切换好了才换栈,因为里面有很多层调用,不确定新栈空间是否足够
|
||||
|
@ -651,8 +651,6 @@ void Thread::Init()
|
|||
Main = main;
|
||||
|
||||
Interrupt.SetPriority(PendSV_IRQn, 0xFF);
|
||||
|
||||
Sys.OnStart = Schedule;
|
||||
}
|
||||
|
||||
// 每个线程结束时执行该方法,销毁线程
|
||||
|
|
Loading…
Reference in New Issue