Skip to content

Commit fd38cfe

Browse files
committed
add schedule test and systick_count
1 parent 83bb054 commit fd38cfe

File tree

8 files changed

+890
-879
lines changed

8 files changed

+890
-879
lines changed

bsp/stm32f10x/applications/SConscript

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ Import('rtconfig')
33
from building import *
44

55
cwd = os.path.join(str(Dir('#')), 'applications')
6-
src = Glob('*.c')
6+
src = ['application.c']
7+
src = src + ['startup.c']
8+
9+
if GetDepend('RT_USING_TEST_SCHEDULE'):
10+
src = src + ['systick_count_asm.s']
11+
src = src + ['test_schedule.c']
12+
713
CPPPATH = [cwd, str(Dir('#'))]
814

915
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)

bsp/stm32f10x/applications/application.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void rt_init_thread_entry(void* parameter)
142142
}
143143
#endif /* #ifdef RT_USING_RTGUI */
144144
}
145-
145+
extern int test_schedule_init(void);
146146
int rt_application_init(void)
147147
{
148148
rt_thread_t init_thread;
@@ -176,6 +176,8 @@ int rt_application_init(void)
176176
if (init_thread != RT_NULL)
177177
rt_thread_startup(init_thread);
178178

179+
180+
test_schedule_init();
179181
return 0;
180182
}
181183

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef __SYSTICK_COUNT_H__
2+
#define __SYSTICK_COUNT_H__
3+
4+
//=====global include==============
5+
//#include "core_cm3.h"
6+
#include "stm32f10x.h"
7+
#include <rtthread.h>
8+
9+
rt_uint32_t clk_elapse; //32bit unsigned integer for countting clk
10+
rt_uint32_t start_value=0xA5A55A5A; //32bit unsigned integer for countting clk
11+
rt_uint32_t end_value; //32bit unsigned integer for countting clk
12+
13+
SysTick_Type *tick = SysTick;
14+
15+
16+
rt_inline void stop_count(void)
17+
{
18+
end_value = tick->VAL;
19+
}
20+
21+
rt_inline void calc_count(void)
22+
{
23+
if(end_value<start_value)
24+
{
25+
clk_elapse = start_value - end_value;
26+
}
27+
else
28+
{
29+
clk_elapse = start_value + (tick->LOAD - end_value);
30+
}
31+
rt_kprintf("Start = %d\t End = %d\tUsed %d\tclk(s) Reload = %d\r\n",start_value,end_value,clk_elapse,tick->LOAD);
32+
}
33+
34+
//=====function declaration===============
35+
//void start_count(void);
36+
37+
#endif /* __SYSTICK_COUNT_H__ */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
SYSTICK_CURRENT EQU 0xE000E018 ;
2+
SYSTICK_RELOAD EQU 0xE000E014 ;
3+
4+
5+
AREA |.text|, CODE, READONLY, ALIGN=2
6+
THUMB
7+
REQUIRE8
8+
PRESERVE8
9+
10+
;Import value
11+
IMPORT clk_elapse
12+
IMPORT start_value
13+
IMPORT end_value
14+
15+
;/*
16+
; * void start_count(void);
17+
; start_value = tick->VAL;
18+
; */
19+
start_count PROC
20+
EXPORT start_count
21+
22+
23+
LDR r1, =start_value
24+
LDR r0, =SYSTICK_CURRENT
25+
LDR r0, [r0]
26+
27+
STR r0, [r1]
28+
29+
BX lr
30+
31+
ENDP
32+
33+
34+
stop_count PROC
35+
;EXPORT stop_count
36+
37+
LDR r0, =SYSTICK_CURRENT
38+
LDR r0, [r0]
39+
40+
LDR r1, =end_value
41+
STR r0, [r1]
42+
43+
BX lr
44+
45+
ENDP
46+
47+
48+
END ;end of this file
49+

0 commit comments

Comments
 (0)