Skip to content

Commit 0ff3224

Browse files
committed
v2.4.0
1 parent 8895f2b commit 0ff3224

7 files changed

+255
-60
lines changed

example/example.uvoptx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
<SetRegEntry>
131131
<Number>0</Number>
132132
<Key>DbgFM</Key>
133-
<Name>-I -S"System Generator:cpu_core" -L"armcortexm0ct" -O4102 -C0 -MC".\VHT\VHT_MPS2_Cortex-M0.exe" -MF -PF -MA</Name>
133+
<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>
134134
</SetRegEntry>
135135
<SetRegEntry>
136136
<Number>0</Number>
@@ -204,7 +204,7 @@
204204
<DebugFlag>
205205
<trace>0</trace>
206206
<periodic>1</periodic>
207-
<aLwin>1</aLwin>
207+
<aLwin>0</aLwin>
208208
<aCover>0</aCover>
209209
<aSer1>0</aSer1>
210210
<aSer2>0</aSer2>
@@ -221,7 +221,7 @@
221221
<aLa>0</aLa>
222222
<aPa1>0</aPa1>
223223
<AscS4>0</AscS4>
224-
<aSer4>0</aSer4>
224+
<aSer4>1</aSer4>
225225
<StkLoc>0</StkLoc>
226226
<TrcWin>0</TrcWin>
227227
<newCpu>0</newCpu>
@@ -817,7 +817,7 @@
817817

818818
<Group>
819819
<GroupName>::Device</GroupName>
820-
<tvExp>1</tvExp>
820+
<tvExp>0</tvExp>
821821
<tvExpOptDlg>0</tvExpOptDlg>
822822
<cbSel>0</cbSel>
823823
<RteFlg>1</RteFlg>

example/example.uvprojx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<TargetName>example_arm_compiler_6</TargetName>
1111
<ToolsetNumber>0x4</ToolsetNumber>
1212
<ToolsetName>ARM-ADS</ToolsetName>
13-
<pCCUsed>6220000::V6.22::ARMCLANG</pCCUsed>
13+
<pCCUsed>6230000::V6.23::.\ArmCompilerforEmbedded6.24</pCCUsed>
1414
<uAC6>1</uAC6>
1515
<TargetOption>
1616
<TargetCommonOption>
@@ -134,11 +134,11 @@
134134
<RunIndependent>0</RunIndependent>
135135
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
136136
<Capability>0</Capability>
137-
<DriverSelection>-1</DriverSelection>
137+
<DriverSelection>4096</DriverSelection>
138138
</Flash1>
139139
<bUseTDR>1</bUseTDR>
140140
<Flash2>BIN\UL2CM3.DLL</Flash2>
141-
<Flash3></Flash3>
141+
<Flash3>"" ()</Flash3>
142142
<Flash4></Flash4>
143143
<pFcarmOut></pFcarmOut>
144144
<pFcarmGrp></pFcarmGrp>
@@ -449,7 +449,7 @@
449449
<TargetName>library</TargetName>
450450
<ToolsetNumber>0x4</ToolsetNumber>
451451
<ToolsetName>ARM-ADS</ToolsetName>
452-
<pCCUsed>6210000::V6.21::ARMCLANG</pCCUsed>
452+
<pCCUsed>6230000::V6.23::.\ArmCompilerforEmbedded6.24</pCCUsed>
453453
<uAC6>1</uAC6>
454454
<TargetOption>
455455
<TargetCommonOption>

example/gcc_example.uvoptx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<OPTFL>
7676
<tvExp>1</tvExp>
7777
<tvExpOptDlg>0</tvExpOptDlg>
78-
<IsCurrentTarget>1</IsCurrentTarget>
78+
<IsCurrentTarget>0</IsCurrentTarget>
7979
</OPTFL>
8080
<CpuCode>7</CpuCode>
8181
<DebugOpt>
@@ -280,7 +280,7 @@
280280
<OPTFL>
281281
<tvExp>1</tvExp>
282282
<tvExpOptDlg>0</tvExpOptDlg>
283-
<IsCurrentTarget>0</IsCurrentTarget>
283+
<IsCurrentTarget>1</IsCurrentTarget>
284284
</OPTFL>
285285
<CpuCode>7</CpuCode>
286286
<DebugOpt>

example/main.c

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <stdio.h>
2020
#include <cmsis_compiler.h>
2121
#include "perf_counter.h"
22+
#include <stdlib.h>
2223

2324

2425
#ifndef __PERF_CNT_USE_LONG_CLOCK__
@@ -126,6 +127,47 @@ uint32_t calculate_stack_usage_bottomup(void)
126127
/*----------------------------------------------------------------------------
127128
Main function
128129
*----------------------------------------------------------------------------*/
130+
131+
typedef struct {
132+
uint8_t chPT;
133+
void *ptResource;
134+
} pt_led_flash_cb_t;
135+
136+
#undef this
137+
#define this (*ptThis)
138+
139+
fsm_rt_t pt_example_led_flash(pt_led_flash_cb_t *ptThis)
140+
{
141+
142+
PERFC_PT_BEGIN(this.chPT)
143+
144+
do {
145+
146+
PERFC_PT_WAIT_RESOURCE_UNTIL(
147+
(this.ptResource != NULL), /* quit condition */
148+
this.ptResource = malloc(100); /* try to allocate memory */
149+
)
150+
151+
printf("LED ON [%lld]\r\n", get_system_ms());
152+
153+
PERFC_PT_DELAY_MS(500);
154+
155+
printf("LED OFF [%lld]\r\n", get_system_ms());
156+
157+
PERFC_PT_DELAY_MS(500);
158+
159+
free(this.ptResource);
160+
161+
} while(1);
162+
163+
PERFC_PT_END()
164+
165+
return fsm_rt_cpl;
166+
167+
}
168+
169+
static pt_led_flash_cb_t s_tExamplePT = {0};
170+
129171
int main (void)
130172
{
131173
int32_t iCycleResult = 0;
@@ -205,10 +247,9 @@ int main (void)
205247
}) {
206248
delay_us(50000);
207249
}
208-
209-
210-
211-
delay_us(20000);
212250

251+
delay_us(20000);
252+
253+
pt_example_led_flash(&s_tExamplePT);
213254
}
214255
}

perf_counter.c

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ struct __task_cycle_info_t {
6464

6565
/*============================ GLOBAL VARIABLES ==============================*/
6666
/*============================ LOCAL VARIABLES ===============================*/
67-
volatile int64_t g_lLastTimeStamp = 0;
67+
6868
volatile static int64_t s_lOldTimestamp;
69-
volatile int32_t g_nOffset = 0;
69+
volatile static int64_t s_lOldTimestampUS;
70+
volatile static int64_t s_lOldTimestampMS;
7071
volatile static uint32_t s_wUSUnit = 1;
7172
volatile static uint32_t s_wMSUnit = 1;
7273
volatile static uint32_t s_wMSResidule = 0;
@@ -76,6 +77,9 @@ volatile static int64_t s_lSystemUS = 0;
7677

7778
volatile static int64_t s_lSystemClockCounts = 0;
7879

80+
volatile int32_t g_nOffset = 0;
81+
volatile int64_t g_lLastTimeStamp = 0;
82+
7983
/*============================ PROTOTYPES ====================================*/
8084

8185
/* low level interface for porting */
@@ -112,22 +116,23 @@ void perfc_port_insert_to_system_timer_insert_ovf_handler(void)
112116
// update system ms counter
113117
do {
114118
int64_t lTemp = s_wMSResidule + lLoad;
115-
119+
116120
int64_t lMS = lTemp / s_wMSUnit;
117121
s_lSystemMS += lMS;
118122
s_wMSResidule = (uint32_t)((int64_t)lTemp - (int64_t)lMS * s_wMSUnit);
119123

120124
} while(0);
125+
}
121126

127+
__IRQ_SAFE {
122128
// update system us counter
123129
do {
124130
int64_t lTemp = s_wUSResidule + lLoad;
125-
131+
126132
int64_t lUS = lTemp / s_wUSUnit;
127133
s_lSystemUS += lUS;
128134

129135
s_wUSResidule = (uint32_t)((int64_t)lTemp - (int64_t)lUS * s_wUSUnit);
130-
131136
} while(0);
132137
}
133138
}
@@ -169,6 +174,8 @@ bool init_cycle_counter(bool bIsSysTickOccupied)
169174
s_lSystemMS = 0; // reset system millisecond counter
170175
s_lSystemUS = 0; // reset system microsecond counter
171176
s_lOldTimestamp = 0;
177+
s_lOldTimestampUS = 0;
178+
s_lOldTimestampMS = 0;
172179

173180
__perf_os_patch_init();
174181

@@ -322,7 +329,15 @@ int64_t get_system_ms(void)
322329
int64_t lTemp = 0;
323330

324331
__IRQ_SAFE {
325-
lTemp = s_lSystemMS + ((check_systick() + (int64_t)s_wMSResidule) / s_wMSUnit);
332+
lTemp = s_lSystemMS
333+
+ ( (check_systick()
334+
+ (int64_t)s_wMSResidule) / s_wMSUnit);
335+
336+
if (lTemp < s_lOldTimestampMS) {
337+
lTemp = s_lOldTimestampMS;
338+
} else {
339+
s_lOldTimestampMS = lTemp;
340+
}
326341
}
327342

328343
return lTemp;
@@ -333,7 +348,16 @@ int64_t get_system_us(void)
333348
int64_t lTemp = 0;
334349

335350
__IRQ_SAFE {
336-
lTemp = s_lSystemUS + ((check_systick() + (int64_t)s_wUSResidule) / s_wUSUnit);
351+
lTemp = s_lSystemUS
352+
+ ( (check_systick()
353+
+ (int64_t)s_wUSResidule) / s_wUSUnit);
354+
355+
if (lTemp < s_lOldTimestampUS) {
356+
lTemp = s_lOldTimestampUS;
357+
} else {
358+
s_lOldTimestampUS = lTemp;
359+
}
360+
337361
}
338362

339363
return lTemp;
@@ -370,7 +394,6 @@ bool __perfc_is_time_out(int64_t lPeriod, int64_t *plTimestamp, bool bAutoReload
370394

371395
int64_t lTimestamp = get_system_ticks();
372396

373-
374397
if (0 == *plTimestamp) {
375398
*plTimestamp = lPeriod;
376399
*plTimestamp += lTimestamp;
@@ -411,8 +434,6 @@ uint32_t EventRecorderTimerGetCount (void)
411434
return get_system_ticks();
412435
}
413436

414-
415-
416437
__WEAK
417438
task_cycle_info_t * get_rtos_task_cycle_info(void)
418439
{

0 commit comments

Comments
 (0)