update __cpu_time__ to support RTOS

This commit is contained in:
Gabriel Wang 2023-05-23 09:08:03 +01:00
parent 0a84512a24
commit 1382df9645
6 changed files with 12 additions and 12 deletions

View File

@ -75,7 +75,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>7</CpuCode>
<DebugOpt>
@ -297,7 +297,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
<IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>7</CpuCode>
<DebugOpt>

View File

@ -195,9 +195,9 @@ int main (void)
}
__cpu_time__(10) {
delay_us(3000);
delay_us(30000);
}
delay_us(7000);
delay_us(70000);
}
}

Binary file not shown.

View File

@ -357,9 +357,9 @@ __asm(".global __ensure_systick_wrapper\n\t");
#define __cpu_time__(__CNT, ...) \
static int64_t SAFE_NAME(s_lTimestamp) = 0, SAFE_NAME(s_lTotal) = 0; \
static uint32_t s_wLoopCounter = (__CNT); \
using(int64_t lStart = 0, ({ \
using(float __usage__ = 0, ({ \
if (0 == s_wLoopCounter) { \
float __usage__ = (float)((double)SAFE_NAME(s_lTotal) \
__usage__ = (float)((double)SAFE_NAME(s_lTotal) \
/ (double)( get_system_ticks() \
- SAFE_NAME(s_lTimestamp))); \
__usage__ *= 100.0f; \
@ -375,8 +375,8 @@ __asm(".global __ensure_systick_wrapper\n\t");
SAFE_NAME(s_lTimestamp) = get_system_ticks(); \
s_wLoopCounter = (__CNT); \
} \
lStart = get_system_ticks();}), \
({SAFE_NAME(s_lTotal) += get_system_ticks() - lStart; \
start_task_cycle_counter();}), \
({SAFE_NAME(s_lTotal) += stop_task_cycle_counter(); \
s_wLoopCounter--;}))
/*!

Binary file not shown.

View File

@ -357,9 +357,9 @@ __asm(".global __ensure_systick_wrapper\n\t");
#define __cpu_time__(__CNT, ...) \
static int64_t SAFE_NAME(s_lTimestamp) = 0, SAFE_NAME(s_lTotal) = 0; \
static uint32_t s_wLoopCounter = (__CNT); \
using(int64_t lStart = 0, ({ \
using(float __usage__ = 0, ({ \
if (0 == s_wLoopCounter) { \
float __usage__ = (float)((double)SAFE_NAME(s_lTotal) \
__usage__ = (float)((double)SAFE_NAME(s_lTotal) \
/ (double)( get_system_ticks() \
- SAFE_NAME(s_lTimestamp))); \
__usage__ *= 100.0f; \
@ -375,8 +375,8 @@ __asm(".global __ensure_systick_wrapper\n\t");
SAFE_NAME(s_lTimestamp) = get_system_ticks(); \
s_wLoopCounter = (__CNT); \
} \
lStart = get_system_ticks();}), \
({SAFE_NAME(s_lTotal) += get_system_ticks() - lStart; \
start_task_cycle_counter();}), \
({SAFE_NAME(s_lTotal) += stop_task_cycle_counter(); \
s_wLoopCounter--;}))
/*!