/
test_byte.c
77 lines (45 loc) · 1.13 KB
/
test_byte.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <raw_api.h>
#define TEST_TASK_STK_SIZE 1024
static RAW_TASK_OBJ test_task_obj;
static PORT_STACK test_task_stack1[TEST_TASK_STK_SIZE];
static RAW_U8 buffer[1024];
static RAW_BYTE_POOL_STRUCT byte_pool;
static RAW_U8 count = 0;
static void test_task1(void * pParam)
{
RAW_U8* addr;
while(1) {
if(RAW_SUCCESS == raw_byte_allocate(&byte_pool, (void**)&addr, 16)) {
count ++;
__put_char("ok1 ", 4);
}else {
__put_char("error1 ", 7);
}
raw_sleep(20);
if(RAW_SUCCESS == raw_byte_allocate(&byte_pool, (void**)&addr, 30)) {
count ++;
__put_char("ok2 ", 4);
}else {
__put_char("error2 ", 7);
}
raw_sleep(20);
}
}
extern int test_switch;
void test_byte()
{
if(1 == test_switch) {
return;
}
test_switch = 1;
if (RAW_SUCCESS != raw_byte_pool_create(&byte_pool,
"pool_byte1",
buffer,
1024)) {
__put_char("error ", 6);
return;
}
raw_task_create(&test_task_obj, (RAW_U8 *)"task1", 0,
5, 10, test_task_stack1,
TEST_TASK_STK_SIZE , test_task1, 1);
}