Skip to content

Commit

Permalink
v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Dec 8, 2024
1 parent 8895f2b commit 0ff3224
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 60 deletions.
8 changes: 4 additions & 4 deletions example/example.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DbgFM</Key>
<Name>-I -S"System Generator:cpu_core" -L"armcortexm0ct" -O4102 -C0 -MC".\VHT\VHT_MPS2_Cortex-M0.exe" -MF -PF -MA</Name>
<Name>-I -S"System Generator:FVP_MPS2_Cortex_M0" -L"armcortexm0ct" -O4102 -C0 -MC".\avh-fvp\bin\models\FVP_MPS2_Cortex-M0.exe" -MF -PF -MA</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
Expand Down Expand Up @@ -204,7 +204,7 @@
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>1</aLwin>
<aLwin>0</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
Expand All @@ -221,7 +221,7 @@
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
<aSer4>1</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
Expand Down Expand Up @@ -817,7 +817,7 @@

<Group>
<GroupName>::Device</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
Expand Down
8 changes: 4 additions & 4 deletions example/example.uvprojx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<TargetName>example_arm_compiler_6</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>6220000::V6.22::ARMCLANG</pCCUsed>
<pCCUsed>6230000::V6.23::.\ArmCompilerforEmbedded6.24</pCCUsed>
<uAC6>1</uAC6>
<TargetOption>
<TargetCommonOption>
Expand Down Expand Up @@ -134,11 +134,11 @@
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>0</Capability>
<DriverSelection>-1</DriverSelection>
<DriverSelection>4096</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3></Flash3>
<Flash3>"" ()</Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
Expand Down Expand Up @@ -449,7 +449,7 @@
<TargetName>library</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>6210000::V6.21::ARMCLANG</pCCUsed>
<pCCUsed>6230000::V6.23::.\ArmCompilerforEmbedded6.24</pCCUsed>
<uAC6>1</uAC6>
<TargetOption>
<TargetCommonOption>
Expand Down
4 changes: 2 additions & 2 deletions example/gcc_example.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
<IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>7</CpuCode>
<DebugOpt>
Expand Down Expand Up @@ -280,7 +280,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>7</CpuCode>
<DebugOpt>
Expand Down
49 changes: 45 additions & 4 deletions example/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <stdio.h>
#include <cmsis_compiler.h>
#include "perf_counter.h"
#include <stdlib.h>


#ifndef __PERF_CNT_USE_LONG_CLOCK__
Expand Down Expand Up @@ -126,6 +127,47 @@ uint32_t calculate_stack_usage_bottomup(void)
/*----------------------------------------------------------------------------
Main function
*----------------------------------------------------------------------------*/

typedef struct {
uint8_t chPT;
void *ptResource;
} pt_led_flash_cb_t;

#undef this
#define this (*ptThis)

fsm_rt_t pt_example_led_flash(pt_led_flash_cb_t *ptThis)
{

PERFC_PT_BEGIN(this.chPT)

do {

PERFC_PT_WAIT_RESOURCE_UNTIL(
(this.ptResource != NULL), /* quit condition */
this.ptResource = malloc(100); /* try to allocate memory */
)

printf("LED ON [%lld]\r\n", get_system_ms());

PERFC_PT_DELAY_MS(500);

printf("LED OFF [%lld]\r\n", get_system_ms());

PERFC_PT_DELAY_MS(500);

free(this.ptResource);

} while(1);

PERFC_PT_END()

return fsm_rt_cpl;

}

static pt_led_flash_cb_t s_tExamplePT = {0};

int main (void)
{
int32_t iCycleResult = 0;
Expand Down Expand Up @@ -205,10 +247,9 @@ int main (void)
}) {
delay_us(50000);
}



delay_us(20000);

delay_us(20000);

pt_example_led_flash(&s_tExamplePT);
}
}
41 changes: 31 additions & 10 deletions perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ struct __task_cycle_info_t {

/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
volatile int64_t g_lLastTimeStamp = 0;

volatile static int64_t s_lOldTimestamp;
volatile int32_t g_nOffset = 0;
volatile static int64_t s_lOldTimestampUS;
volatile static int64_t s_lOldTimestampMS;
volatile static uint32_t s_wUSUnit = 1;
volatile static uint32_t s_wMSUnit = 1;
volatile static uint32_t s_wMSResidule = 0;
Expand All @@ -76,6 +77,9 @@ volatile static int64_t s_lSystemUS = 0;

volatile static int64_t s_lSystemClockCounts = 0;

volatile int32_t g_nOffset = 0;
volatile int64_t g_lLastTimeStamp = 0;

/*============================ PROTOTYPES ====================================*/

/* low level interface for porting */
Expand Down Expand Up @@ -112,22 +116,23 @@ void perfc_port_insert_to_system_timer_insert_ovf_handler(void)
// update system ms counter
do {
int64_t lTemp = s_wMSResidule + lLoad;

int64_t lMS = lTemp / s_wMSUnit;
s_lSystemMS += lMS;
s_wMSResidule = (uint32_t)((int64_t)lTemp - (int64_t)lMS * s_wMSUnit);

} while(0);
}

__IRQ_SAFE {
// update system us counter
do {
int64_t lTemp = s_wUSResidule + lLoad;

int64_t lUS = lTemp / s_wUSUnit;
s_lSystemUS += lUS;

s_wUSResidule = (uint32_t)((int64_t)lTemp - (int64_t)lUS * s_wUSUnit);

} while(0);
}
}
Expand Down Expand Up @@ -169,6 +174,8 @@ bool init_cycle_counter(bool bIsSysTickOccupied)
s_lSystemMS = 0; // reset system millisecond counter
s_lSystemUS = 0; // reset system microsecond counter
s_lOldTimestamp = 0;
s_lOldTimestampUS = 0;
s_lOldTimestampMS = 0;

__perf_os_patch_init();

Expand Down Expand Up @@ -322,7 +329,15 @@ int64_t get_system_ms(void)
int64_t lTemp = 0;

__IRQ_SAFE {
lTemp = s_lSystemMS + ((check_systick() + (int64_t)s_wMSResidule) / s_wMSUnit);
lTemp = s_lSystemMS
+ ( (check_systick()
+ (int64_t)s_wMSResidule) / s_wMSUnit);

if (lTemp < s_lOldTimestampMS) {
lTemp = s_lOldTimestampMS;
} else {
s_lOldTimestampMS = lTemp;
}
}

return lTemp;
Expand All @@ -333,7 +348,16 @@ int64_t get_system_us(void)
int64_t lTemp = 0;

__IRQ_SAFE {
lTemp = s_lSystemUS + ((check_systick() + (int64_t)s_wUSResidule) / s_wUSUnit);
lTemp = s_lSystemUS
+ ( (check_systick()
+ (int64_t)s_wUSResidule) / s_wUSUnit);

if (lTemp < s_lOldTimestampUS) {
lTemp = s_lOldTimestampUS;
} else {
s_lOldTimestampUS = lTemp;
}

}

return lTemp;
Expand Down Expand Up @@ -370,7 +394,6 @@ bool __perfc_is_time_out(int64_t lPeriod, int64_t *plTimestamp, bool bAutoReload

int64_t lTimestamp = get_system_ticks();


if (0 == *plTimestamp) {
*plTimestamp = lPeriod;
*plTimestamp += lTimestamp;
Expand Down Expand Up @@ -411,8 +434,6 @@ uint32_t EventRecorderTimerGetCount (void)
return get_system_ticks();
}



__WEAK
task_cycle_info_t * get_rtos_task_cycle_info(void)
{
Expand Down
Loading

0 comments on commit 0ff3224

Please sign in to comment.