10
10
#error [NOT_SUPPORTED] test not supported
11
11
#endif
12
12
13
+ /*
14
+ * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
15
+ * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
16
+ * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
17
+ */
18
+ #if defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
19
+ #define STACK_SIZE 512
20
+ #else
21
+ #define STACK_SIZE DEFAULT_STACK_SIZE
22
+ #endif
23
+
13
24
using namespace utest ::v1;
14
25
15
26
// The counter type used accross all the tests
@@ -32,7 +43,7 @@ void increment_with_wait(counter_t* counter) {
32
43
}
33
44
34
45
void increment_with_child (counter_t * counter) {
35
- Thread child (counter, increment);
46
+ Thread child (counter, increment, osPriorityNormal, STACK_SIZE );
36
47
child.join ();
37
48
}
38
49
@@ -41,7 +52,7 @@ void increment_with_murder(counter_t* counter) {
41
52
// take ownership of the counter mutex so it prevent the child to
42
53
// modify counter.
43
54
LockGuard lock (counter->internal_mutex ());
44
- Thread child (counter, increment);
55
+ Thread child (counter, increment, osPriorityNormal, STACK_SIZE );
45
56
child.terminate ();
46
57
}
47
58
@@ -52,7 +63,7 @@ void increment_with_murder(counter_t* counter) {
52
63
template <void (*F)(counter_t *)>
53
64
void test_single_thread () {
54
65
counter_t counter (0 );
55
- Thread thread (&counter, F);
66
+ Thread thread (&counter, F, osPriorityNormal, STACK_SIZE );
56
67
thread.join ();
57
68
TEST_ASSERT_EQUAL (counter, 1 );
58
69
}
@@ -63,7 +74,7 @@ void test_parallel_threads() {
63
74
Thread *threads[N];
64
75
65
76
for (int i = 0 ; i < N; i++) {
66
- threads[i] = new Thread (&counter, F);
77
+ threads[i] = new Thread (&counter, F, osPriorityNormal, STACK_SIZE );
67
78
}
68
79
69
80
for (int i = 0 ; i < N; i++) {
@@ -79,7 +90,7 @@ void test_serial_threads() {
79
90
counter_t counter (0 );
80
91
81
92
for (int i = 0 ; i < N; i++) {
82
- Thread thread (&counter, F);
93
+ Thread thread (&counter, F, osPriorityNormal, STACK_SIZE );
83
94
thread.join ();
84
95
}
85
96
0 commit comments