support rt-thread

This commit is contained in:
Meco Man 2022-06-13 20:02:01 -04:00
parent 776059f701
commit ead6f8b0a0
2 changed files with 31 additions and 15 deletions

View File

@ -1,18 +1,12 @@
Import('rtconfig')
from building import *
src = ['perf_counter.c', 'os/rt-thread/perf_os_patch_rt_thread.c']
if rtconfig.PLATFORM in ['armcc', 'armclang']: # Keil-MDK
src += ['systick_wrapper_ual.s']
if rtconfig.PLATFORM == 'gcc':
src += ['systick_wrapper_gcc.s']
src = ['perf_counter.c', 'os/perf_os_patch_rt_thread.c']
cwd = GetCurrentDir()
path = [cwd]
group = []
group = DefineGroup('perf_counter', src, depend = ['PKG_USING_PERFCOUNTER'], CPPPATH = path)
group = DefineGroup('perf_counter', src, depend = ['PKG_USING_PERF_COUNTER'], CPPDEFINES = ['__PERF_CNT_USE_RTOS__'], CPPPATH = path)
Return('group')

View File

@ -52,8 +52,8 @@ struct __task_cycle_info_t {
#ifndef RT_USING_HOOK
#error In order to use perf_counter:RT-Thread-Patch, please define RT_USING_HOOK\
in rtconfig.h. If you don't want to use this patch, please un-select it in RTE.
#error "In order to use perf_counter:RT-Thread-Patch, please define RT_USING_HOOK \
in rtconfig.h. If you don't want to use this patch, please un-select it in RTE."
#endif
@ -75,12 +75,34 @@ void __rt_thread_scheduler_hook(struct rt_thread *from, struct rt_thread *to)
__on_context_switch_in(to->stack_addr);
}
void __perf_os_patch_init(void)
{
rt_scheduler_sethook(&__rt_thread_scheduler_hook);
}
task_cycle_info_t * get_rtos_task_cycle_info(void)
{
return &(((struct __task_cycle_info_t *)rt_current_thread->stack_addr)->tInfo);
}
void __perf_os_patch_init(void)
{
#ifdef PKG_USING_PERF_COUNTER
rt_tick_sethook(user_code_insert_to_systick_handler);
#endif
rt_scheduler_sethook(__rt_thread_scheduler_hook);
}
#ifdef PKG_USING_PERF_COUNTER
void __ensure_systick_wrapper(void)
{
}
#define DBG_TAG "perf_counter"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static int _perf_counter_init(void)
{
extern uint32_t SystemCoreClock;
init_cycle_counter(true);
LOG_I("perf_counter init, SystemCoreClock:%d", SystemCoreClock);
return 0;
}
INIT_PREV_EXPORT(_perf_counter_init);
#endif