libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
libxr_system.cpp
1#include "libxr.hpp"
2#include "timer.hpp"
3
4extern "C" void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
5{
6 static volatile const char *task_name = pcTaskName;
7 UNUSED(task_name);
8 UNUSED(xTask);
9 ASSERT(false);
10}
11
12void LibXR::PlatformInit(uint32_t timer_pri, uint32_t timer_stack_depth)
13{
14 if (Timebase::timebase == nullptr)
15 {
16 /* You should initialize Timebase first */
17 ASSERT(false);
18 }
19
20 LibXR::Timer::priority_ = static_cast<LibXR::Thread::Priority>(timer_pri);
21 LibXR::Timer::stack_depth_ = timer_stack_depth;
22
23 uint32_t time_need_to_catch_up = Timebase::GetMilliseconds() - xTaskGetTickCount();
24
25 if (time_need_to_catch_up > 0)
26 {
27 xTaskCatchUpTicks(time_need_to_catch_up);
28 }
29}
30
31void *operator new(std::size_t size)
32{
33 if (size == 0)
34 {
35 return pvPortMalloc(size);
36 }
37 auto ans = pvPortMalloc(size);
38 ASSERT(ans != nullptr);
39 return ans;
40}
41
42void operator delete(void *ptr) noexcept { vPortFree(ptr); }
43void operator delete(void *ptr, std::size_t size) noexcept
44{
45 UNUSED(size);
46 vPortFree(ptr);
47}
Priority
线程优先级枚举 Enumeration for thread priorities
Definition thread.hpp:22
static uint32_t stack_depth_
线程栈深度 Thread stack depth
Definition timer.hpp:243
static LibXR::Thread::Priority priority_
线程优先级 Thread priority
Definition timer.hpp:242
void PlatformInit()
平台初始化函数 Platform initialization function