Skip to content

Commit 2885c1b

Browse files
authored
Merge pull request ARMmbed#3510 from ARMmbed/release-candidate
Release candidate for mbed-os-5.3.2
2 parents 0789928 + 0c4ccdc commit 2885c1b

File tree

1,312 files changed

+20886
-17048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,312 files changed

+20886
-17048
lines changed

TESTS/mbedmicro-rtos-mbed/isr/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void queue_isr() {
4040
myled = !myled;
4141
}
4242

43-
void queue_thread(void const *argument) {
43+
void queue_thread() {
4444
while (true) {
4545
queue.put((uint32_t*)QUEUE_PUT_THREAD_VALUE);
4646
Thread::wait(THREAD_DELAY);
@@ -50,7 +50,8 @@ void queue_thread(void const *argument) {
5050
int main (void) {
5151
GREENTEA_SETUP(20, "default_auto");
5252

53-
Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE);
53+
Thread thread(osPriorityNormal, STACK_SIZE);
54+
thread.start(queue_thread);
5455
Ticker ticker;
5556
ticker.attach(queue_isr, 1.0);
5657
int isr_puts_counter = 0;

TESTS/mbedmicro-rtos-mbed/mail/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct {
3838

3939
Mail<mail_t, QUEUE_SIZE> mail_box;
4040

41-
void send_thread (void const *argument) {
41+
void send_thread () {
4242
static uint32_t i = 10;
4343
while (true) {
4444
i++; // fake data update
@@ -54,7 +54,8 @@ void send_thread (void const *argument) {
5454
int main (void) {
5555
GREENTEA_SETUP(20, "default_auto");
5656

57-
Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
57+
Thread thread(osPriorityNormal, STACK_SIZE);
58+
thread.start(send_thread);
5859
bool result = true;
5960
int result_counter = 0;
6061

TESTS/mbedmicro-rtos-mbed/mutex/main.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ bool manipulate_protected_zone(const int thread_delay) {
7777
return result;
7878
}
7979

80-
void test_thread(void const *args) {
81-
const int thread_delay = int(args);
80+
void test_thread(int const *thread_delay) {
8281
while (true) {
83-
manipulate_protected_zone(thread_delay);
82+
manipulate_protected_zone(*thread_delay);
8483
}
8584
}
8685

@@ -90,8 +89,11 @@ int main() {
9089
const int t1_delay = THREAD_DELAY * 1;
9190
const int t2_delay = THREAD_DELAY * 2;
9291
const int t3_delay = THREAD_DELAY * 3;
93-
Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
94-
Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);
92+
Thread t2(osPriorityNormal, STACK_SIZE);
93+
Thread t3(osPriorityNormal, STACK_SIZE);
94+
95+
t2.start(callback(test_thread, &t2_delay));
96+
t3.start(callback(test_thread, &t3_delay));
9597

9698
while (true) {
9799
// Thread 1 action

TESTS/mbedmicro-rtos-mbed/queue/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ MemoryPool<message_t, QUEUE_SIZE> mpool;
4040
Queue<message_t, QUEUE_SIZE> queue;
4141

4242
/* Send Thread */
43-
void send_thread (void const *argument) {
43+
void send_thread () {
4444
static uint32_t i = 10;
4545
while (true) {
4646
i++; // Fake data update
@@ -56,7 +56,8 @@ void send_thread (void const *argument) {
5656
int main (void) {
5757
GREENTEA_SETUP(20, "default_auto");
5858

59-
Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
59+
Thread thread(osPriorityNormal, STACK_SIZE);
60+
thread.start(send_thread);
6061
bool result = true;
6162
int result_counter = 0;
6263

TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ volatile int change_counter = 0;
5656
volatile int sem_counter = 0;
5757
volatile bool sem_defect = false;
5858

59-
void test_thread(void const *delay) {
60-
const int thread_delay = int(delay);
59+
void test_thread(int const *delay) {
60+
const int thread_delay = *delay;
6161
while (true) {
6262
two_slots.wait();
6363
sem_counter++;
@@ -81,9 +81,13 @@ int main (void) {
8181
const int t1_delay = THREAD_DELAY * 1;
8282
const int t2_delay = THREAD_DELAY * 2;
8383
const int t3_delay = THREAD_DELAY * 3;
84-
Thread t1(test_thread, (void *)t1_delay, osPriorityNormal, STACK_SIZE);
85-
Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
86-
Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);
84+
Thread t1(osPriorityNormal, STACK_SIZE);
85+
Thread t2(osPriorityNormal, STACK_SIZE);
86+
Thread t3(osPriorityNormal, STACK_SIZE);
87+
88+
t1.start(callback(test_thread, &t1_delay));
89+
t2.start(callback(test_thread, &t2_delay));
90+
t3.start(callback(test_thread, &t3_delay));
8791

8892
while (true) {
8993
if (change_counter >= SEM_CHANGES or sem_defect == true) {

TESTS/mbedmicro-rtos-mbed/signals/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const int SIGNAL_HANDLE_DELEY = 25;
3232
DigitalOut led(LED1);
3333
int signal_counter = 0;
3434

35-
void led_thread(void const *argument) {
35+
void led_thread() {
3636
while (true) {
3737
// Signal flags that are reported as event are automatically cleared.
3838
Thread::signal_wait(SIGNAL_SET_VALUE);
@@ -44,7 +44,8 @@ void led_thread(void const *argument) {
4444
int main (void) {
4545
GREENTEA_SETUP(20, "default_auto");
4646

47-
Thread thread(led_thread, NULL, osPriorityNormal, STACK_SIZE);
47+
Thread thread(osPriorityNormal, STACK_SIZE);
48+
thread.start(led_thread);
4849
bool result = false;
4950

5051
printf("Handling %d signals...\r\n", SIGNALS_TO_EMIT);

TESTS/mbedmicro-rtos-mbed/threads/main.cpp

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,7 @@
1515
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
1616
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
1717
*/
18-
#if defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
19-
#define STACK_SIZE 512
20-
#elif defined(TARGET_STM32F070RB) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F103RB) || defined(TARGET_STM32F091RC)
21-
#define STACK_SIZE 512
22-
#elif defined(TARGET_STM32F410RB)
23-
#define STACK_SIZE 512
24-
#elif defined(TARGET_STM32L073RZ)
25-
#define STACK_SIZE 512
26-
#elif defined(TARGET_XDOT_L151CC)
27-
#define STACK_SIZE 1024
28-
#elif defined(TARGET_HI2110)
29-
#define STACK_SIZE 512
30-
#elif defined(TARGET_EFR32)
31-
#define STACK_SIZE 512
32-
#else
33-
#define STACK_SIZE DEFAULT_STACK_SIZE
34-
#endif
18+
#define PARALLEL_STACK_SIZE 512
3519

3620
using namespace utest::v1;
3721

@@ -55,7 +39,8 @@ void increment_with_wait(counter_t* counter) {
5539
}
5640

5741
void increment_with_child(counter_t* counter) {
58-
Thread child(counter, increment, osPriorityNormal, STACK_SIZE);
42+
Thread child;
43+
child.start(callback(increment, counter));
5944
child.join();
6045
}
6146

@@ -64,7 +49,8 @@ void increment_with_murder(counter_t* counter) {
6449
// take ownership of the counter mutex so it prevent the child to
6550
// modify counter.
6651
LockGuard lock(counter->internal_mutex());
67-
Thread child(counter, increment, osPriorityNormal, STACK_SIZE);
52+
Thread child;
53+
child.start(callback(increment, counter));
6854
child.terminate();
6955
}
7056

@@ -81,7 +67,8 @@ void self_terminate(Thread *self) {
8167
template <void (*F)(counter_t *)>
8268
void test_single_thread() {
8369
counter_t counter(0);
84-
Thread thread(&counter, F, osPriorityNormal, STACK_SIZE);
70+
Thread thread;
71+
thread.start(callback(F, &counter));
8572
thread.join();
8673
TEST_ASSERT_EQUAL(counter, 1);
8774
}
@@ -92,7 +79,8 @@ void test_parallel_threads() {
9279
Thread *threads[N];
9380

9481
for (int i = 0; i < N; i++) {
95-
threads[i] = new Thread(&counter, F, osPriorityNormal, STACK_SIZE);
82+
threads[i] = new Thread(osPriorityNormal, PARALLEL_STACK_SIZE);
83+
threads[i]->start(callback(F, &counter));
9684
}
9785

9886
for (int i = 0; i < N; i++) {
@@ -108,16 +96,17 @@ void test_serial_threads() {
10896
counter_t counter(0);
10997

11098
for (int i = 0; i < N; i++) {
111-
Thread thread(&counter, F, osPriorityNormal, STACK_SIZE);
99+
Thread thread;
100+
thread.start(callback(F, &counter));
112101
thread.join();
113102
}
114103

115104
TEST_ASSERT_EQUAL(counter, N);
116105
}
117106

118107
void test_self_terminate() {
119-
Thread *thread = new Thread(osPriorityNormal, STACK_SIZE);
120-
thread->start(thread, self_terminate);
108+
Thread *thread = new Thread();
109+
thread->start(callback(self_terminate, thread));
121110
thread->join();
122111
delete thread;
123112
}

0 commit comments

Comments
 (0)