Skip to content

Commit 7049594

Browse files
committed
minor update
1 parent dd594ae commit 7049594

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

example/example.uvoptx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@
723723
<GroupNumber>1</GroupNumber>
724724
<FileNumber>4</FileNumber>
725725
<FileType>1</FileType>
726-
<tvExp>0</tvExp>
726+
<tvExp>1</tvExp>
727727
<tvExpOptDlg>0</tvExpOptDlg>
728728
<bDave2>0</bDave2>
729729
<PathWithFileName>.\pt_example.c</PathWithFileName>

example/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ int main (void)
229229
cpt_example_led_flash_init(&s_tExampleCPT[1], s_dwStack1, sizeof(s_dwStack1));
230230

231231
while (1) {
232-
232+
#if 0
233233
__perf_counter_printf__("System Stack Remain: %"PRIu32 "\r\n",
234234
perfc_stack_remain((uintptr_t)&Image$$ARM_LIB_STACK$$ZI$$Base));
235235

@@ -272,7 +272,7 @@ int main (void)
272272

273273

274274
perfc_coroutine_call((perfc_coroutine_t *)&s_tExampleCPT[1]);
275-
275+
#endif
276276
pt_example_led_flash(&s_tExamplePT);
277277
}
278278
}

example/pt_example.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ pt_led_flash_cb_t * pt_example_led_flash_init(pt_led_flash_cb_t *ptThis)
5656
fsm_rt_t pt_example_led_flash(pt_led_flash_cb_t *ptThis)
5757
{
5858

59-
PERFC_PT_BEGIN(this.chState)
59+
PERFC_PT_BEGIN(this)
6060

6161
do {
6262
PERFC_PT_WAIT_FOR_RES_UNTIL(
6363
(this.ptResource != NULL), /* quit condition */
6464
this.ptResource = malloc(100); /* try to allocate memory */
65-
)
65+
);
6666

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

example/pt_example.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern "C" {
3030
/*============================ MACROFIED FUNCTIONS ===========================*/
3131
/*============================ TYPES =========================================*/
3232
typedef struct {
33-
uint8_t chState;
33+
implement(perfc_pt_t);
3434
void *ptResource;
3535
} pt_led_flash_cb_t;
3636

perfc_task_pt.h

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,24 @@ SUCH DAMAGE.
8787
8888
Author: Adam Dunkels
8989
*/
90-
#define PERFC_PT_BEGIN(__state) \
90+
#define PERFC_PT_BEGIN(__pt) \
9191
enum { \
9292
count_offset = __COUNTER__ + 1, \
9393
}; \
94-
uint8_t *ptPTState = &(__state); \
95-
switch (__state) { \
94+
perfc_pt_t *ptPTCB = (((perfc_pt_t *)&(__pt))); \
95+
switch (ptPTCB->chState) { \
9696
case __COUNTER__ - count_offset:
9797

9898
#define PERFC_PT_ENTRY(...) \
99-
(*ptPTState) = (__COUNTER__ - count_offset + 1) >> 1; \
99+
(ptPTCB->chState) = (__COUNTER__ - count_offset + 1) >> 1; \
100100
__VA_ARGS__ \
101-
case (__COUNTER__ - count_offset) >> 1: (void)(*ptPTState);
101+
case (__COUNTER__ - count_offset) >> 1: (void)(ptPTCB->chState);
102102

103103
#define PERFC_PT_YIELD(...) \
104104
PERFC_PT_ENTRY(return __VA_ARGS__;)
105105

106106
#define PERFC_PT_END() \
107-
(*ptPTState) = 0; \
107+
(ptPTCB->chState) = 0; \
108108
break; \
109109
}
110110

@@ -121,7 +121,7 @@ Author: Adam Dunkels
121121

122122
#define PERFC_PT_WAIT_FOR_OBJ_UNTIL(__CONDITION, ...) \
123123
{ \
124-
PERFC_PT__ENTRY() \
124+
PERFC_PT_ENTRY() \
125125
__VA_ARGS__; \
126126
if (!(__CONDITION)) { \
127127
PERFC_PT_GOTO_PREV_ENTRY(fsm_rt_wait_for_obj); \
@@ -139,17 +139,11 @@ Author: Adam Dunkels
139139

140140
#define PERFC_PT_DELAY_MS(__ms, ...) \
141141
{ \
142-
PERFC_PT_ENTRY( \
143-
static int64_t PERFC_SAFE_NAME(s_lTimestamp); \
144-
UNUSED_PARAM(PERFC_SAFE_NAME(s_lTimestamp)); \
145-
int64_t *PERFC_SAFE_NAME(plTimestamp) \
146-
= (&PERFC_SAFE_NAME(s_lTimestamp), ##__VA_ARGS__); \
147-
*PERFC_SAFE_NAME(plTimestamp) = get_system_ms(); \
148-
) \
149-
PERFC_SAFE_NAME(plTimestamp) \
150-
= (&PERFC_SAFE_NAME(s_lTimestamp), ##__VA_ARGS__); \
142+
PERFC_PT_ENTRY( \
143+
ptPTCB->lTimestamp = get_system_ms(); \
144+
) \
151145
int64_t PERFC_SAFE_NAME(lElapsedMs) = \
152-
get_system_ms() - *PERFC_SAFE_NAME(plTimestamp); \
146+
get_system_ms() - ptPTCB->lTimestamp; \
153147
if (PERFC_SAFE_NAME(lElapsedMs) < (__ms)) { \
154148
PERFC_PT_GOTO_PREV_ENTRY(fsm_rt_on_going); \
155149
} \
@@ -286,6 +280,11 @@ label_switch_start:
286280

287281
/*============================ TYPES =========================================*/
288282

283+
typedef struct perfc_pt_t {
284+
uint8_t chState;
285+
int64_t lTimestamp;
286+
} perfc_pt_t;
287+
289288
#if __C_LANGUAGE_EXTENSIONS_PERFC_COROUTINE__
290289

291290
typedef struct perfc_cpt_t {

0 commit comments

Comments
 (0)