Skip to content

Commit b9bef6b

Browse files
committed
[DISCO/NUCLEO_L053xx] adding to RTOS - part3
Reverting the DEFAULT_STACK_SIZE changes in cmsis.oh.h and adding changes to RTOS_x tests, to create threads with the neccessary reduced stack sizes for these targets.
1 parent 11d7b08 commit b9bef6b

File tree

8 files changed

+88
-15
lines changed

8 files changed

+88
-15
lines changed

libraries/rtos/rtx/TARGET_CORTEX_M/cmsis_os.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ used throughout the whole project.
121121
# define WORDS_STACK_SIZE 128
122122
#endif
123123

124-
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
125-
# define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*1)
126-
#else
127-
# define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4)
128-
#endif
124+
#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4)
129125

130126

131127
/// \note MUST REMAIN UNCHANGED: \b osFeature_xxx shall be consistent in every CMSIS-RTOS.

libraries/tests/rtos/mbed/basic/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
#include "mbed.h"
22
#include "rtos.h"
33

4+
/*
5+
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
6+
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
7+
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
8+
*/
9+
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
10+
#define STACK_SIZE DEFAULT_STACK_SIZE/4
11+
#else
12+
#define STACK_SIZE DEFAULT_STACK_SIZE
13+
#endif
14+
415
void print_char(char c = '*')
516
{
617
printf("%c", c);
@@ -19,7 +30,7 @@ void led2_thread(void const *argument) {
1930
}
2031

2132
int main() {
22-
Thread thread(led2_thread);
33+
Thread thread(led2_thread, NULL, osPriorityNormal, STACK_SIZE);
2334

2435
while (true) {
2536
led1 = !led1;

libraries/tests/rtos/mbed/isr/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
#define QUEUE_PUT_ISR_VALUE 128
88
#define QUEUE_PUT_THREAD_VALUE 127
99

10+
/*
11+
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
12+
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
13+
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
14+
*/
15+
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
16+
#define STACK_SIZE DEFAULT_STACK_SIZE/4
17+
#else
18+
#define STACK_SIZE DEFAULT_STACK_SIZE
19+
#endif
20+
1021
Queue<uint32_t, QUEUE_SIZE> queue;
1122

1223
DigitalOut myled(LED1);
@@ -25,7 +36,7 @@ void queue_thread(void const *argument) {
2536
}
2637

2738
int main (void) {
28-
Thread thread(queue_thread);
39+
Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE);
2940
Ticker ticker;
3041
ticker.attach(queue_isr, 1.0);
3142
int isr_puts_counter = 0;

libraries/tests/rtos/mbed/mail/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ typedef struct {
1313
#define QUEUE_SIZE 16
1414
#define QUEUE_PUT_DELAY 100
1515

16+
/*
17+
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
18+
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
19+
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
20+
*/
21+
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
22+
#define STACK_SIZE DEFAULT_STACK_SIZE/4
23+
#else
24+
#define STACK_SIZE DEFAULT_STACK_SIZE
25+
#endif
26+
1627
Mail<mail_t, QUEUE_SIZE> mail_box;
1728

1829
void send_thread (void const *argument) {
@@ -29,7 +40,7 @@ void send_thread (void const *argument) {
2940
}
3041

3142
int main (void) {
32-
Thread thread(send_thread);
43+
Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
3344
bool result = true;
3445
int result_counter = 0;
3546

libraries/tests/rtos/mbed/mutex/main.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
#define THREAD_DELAY 50
66
#define SIGNALS_TO_EMIT 100
77

8+
/*
9+
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
10+
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
11+
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
12+
*/
13+
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
14+
#define STACK_SIZE DEFAULT_STACK_SIZE/4
15+
#else
16+
#define STACK_SIZE DEFAULT_STACK_SIZE
17+
#endif
18+
819
void print_char(char c = '*')
920
{
1021
printf("%c", c);
@@ -52,8 +63,8 @@ int main() {
5263
const int t1_delay = THREAD_DELAY * 1;
5364
const int t2_delay = THREAD_DELAY * 2;
5465
const int t3_delay = THREAD_DELAY * 3;
55-
Thread t2(test_thread, (void *)t2_delay);
56-
Thread t3(test_thread, (void *)t3_delay);
66+
Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
67+
Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);
5768

5869
while (true) {
5970
// Thread 1 action

libraries/tests/rtos/mbed/queue/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ typedef struct {
1313
#define QUEUE_SIZE 16
1414
#define QUEUE_PUT_DELAY 100
1515

16+
/*
17+
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
18+
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
19+
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
20+
*/
21+
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
22+
#define STACK_SIZE DEFAULT_STACK_SIZE/4
23+
#else
24+
#define STACK_SIZE DEFAULT_STACK_SIZE
25+
#endif
26+
1627
MemoryPool<message_t, QUEUE_SIZE> mpool;
1728
Queue<message_t, QUEUE_SIZE> queue;
1829

@@ -31,7 +42,7 @@ void send_thread (void const *argument) {
3142
}
3243

3344
int main (void) {
34-
Thread thread(send_thread);
45+
Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
3546
bool result = true;
3647
int result_counter = 0;
3748

libraries/tests/rtos/mbed/semaphore/main.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
#define SEMAPHORE_SLOTS 2
77
#define SEM_CHANGES 100
88

9+
/*
10+
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
11+
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
12+
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
13+
*/
14+
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
15+
#define STACK_SIZE DEFAULT_STACK_SIZE/4
16+
#else
17+
#define STACK_SIZE DEFAULT_STACK_SIZE
18+
#endif
19+
920
void print_char(char c = '*')
1021
{
1122
printf("%c", c);
@@ -41,9 +52,9 @@ int main (void) {
4152
const int t1_delay = THREAD_DELAY * 1;
4253
const int t2_delay = THREAD_DELAY * 2;
4354
const int t3_delay = THREAD_DELAY * 3;
44-
Thread t1(test_thread, (void *)t1_delay);
45-
Thread t2(test_thread, (void *)t2_delay);
46-
Thread t3(test_thread, (void *)t3_delay);
55+
Thread t1(test_thread, (void *)t1_delay, osPriorityNormal, STACK_SIZE);
56+
Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
57+
Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);
4758

4859
while (true) {
4960
if (change_counter >= SEM_CHANGES or sem_defect == true) {

libraries/tests/rtos/mbed/signals/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
#define SIGNAL_HANDLE_DELEY 25
77
#define SIGNAL_SET_VALUE 0x01
88

9+
/*
10+
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
11+
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
12+
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
13+
*/
14+
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
15+
#define STACK_SIZE DEFAULT_STACK_SIZE/4
16+
#else
17+
#define STACK_SIZE DEFAULT_STACK_SIZE
18+
#endif
19+
920
DigitalOut led(LED1);
1021
volatile int signal_counter = 0;
1122

@@ -19,7 +30,7 @@ void led_thread(void const *argument) {
1930
}
2031

2132
int main (void) {
22-
Thread thread(led_thread);
33+
Thread thread(led_thread, NULL, osPriorityNormal, STACK_SIZE);
2334
bool result = true;
2435

2536
while (true) {

0 commit comments

Comments
 (0)