Skip to content

Commit e891d6a

Browse files
author
David Saada
committed
NVStore: Use wait_ms to delay instead of Thread::wait.
1 parent f43e7b1 commit e891d6a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

features/nvstore/TESTS/nvstore/functionality/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifdef MBED_CONF_RTOS_PRESENT
1919
#include "Thread.h"
2020
#endif
21+
#include "mbed_wait_api.h"
2122
#include "greentea-client/test_env.h"
2223
#include "unity/unity.h"
2324
#include "utest/utest.h"
@@ -391,7 +392,7 @@ static void thread_test_worker()
391392
thread_test_check_key(key);
392393
}
393394

394-
rtos::Thread::wait(1);
395+
wait_ms(1);
395396
}
396397
}
397398
#endif
@@ -431,7 +432,7 @@ static void nvstore_multi_thread_test()
431432
threads[i]->start(callback(thread_test_worker));
432433
}
433434

434-
rtos::Thread::wait(thr_test_num_secs * 1000);
435+
wait_ms(thr_test_num_secs * 1000);
435436

436437
for (i = 0; i < num_threads; i++) {
437438
threads[i]->terminate();
@@ -440,7 +441,7 @@ static void nvstore_multi_thread_test()
440441

441442
delete[] threads;
442443

443-
rtos::Thread::wait(1000);
444+
wait_ms(1000);
444445

445446
nvstore.deinit();
446447

features/nvstore/source/nvstore.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "mbed_critical.h"
2525
#include "mbed_assert.h"
2626
#include "Thread.h"
27+
#include "mbed_wait_api.h"
2728
#include <algorithm>
2829
#include <string.h>
2930
#include <stdio.h>
@@ -182,7 +183,7 @@ int NVStore::flash_write_area(uint8_t area, uint32_t offset, uint32_t size, cons
182183
if (!ret) {
183184
return ret;
184185
}
185-
rtos::Thread::wait(1);
186+
wait_ms(1);
186187
}
187188
return ret;
188189
}
@@ -197,7 +198,7 @@ int NVStore::flash_erase_area(uint8_t area)
197198
if (!ret) {
198199
return ret;
199200
}
200-
rtos::Thread::wait(1);
201+
wait_ms(1);
201202
}
202203
return ret;
203204
}
@@ -723,8 +724,9 @@ int NVStore::init()
723724
// wait until init is finished.
724725
init_attempts_val = core_util_atomic_incr_u32(&_init_attempts, 1);
725726
if (init_attempts_val != 1) {
726-
while (!_init_done)
727-
rtos::Thread::wait(1);
727+
while (!_init_done) {
728+
wait_ms(1);
729+
}
728730
return NVSTORE_SUCCESS;
729731
}
730732

0 commit comments

Comments
 (0)