mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #7980 from kjbracey-arm/thread_deprecations
Clean up rtos::Thread deprecation warningspull/8222/merge
commit
ec03df4823
|
@ -79,7 +79,7 @@ void test_multi_ticker(void)
|
||||||
ticker[i].attach_us(callback(increment_multi_counter), MULTI_TICKER_TIME_MS * 1000);
|
ticker[i].attach_us(callback(increment_multi_counter), MULTI_TICKER_TIME_MS * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::wait(MULTI_TICKER_TIME_MS + extra_wait);
|
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + extra_wait);
|
||||||
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
|
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
|
||||||
|
|
||||||
for (int i = 0; i < TICKER_COUNT; i++) {
|
for (int i = 0; i < TICKER_COUNT; i++) {
|
||||||
|
@ -95,7 +95,7 @@ void test_multi_ticker(void)
|
||||||
ticker[i].attach_us(callback(increment_multi_counter), (MULTI_TICKER_TIME_MS + i) * 1000);
|
ticker[i].attach_us(callback(increment_multi_counter), (MULTI_TICKER_TIME_MS + i) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::wait(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
|
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
|
||||||
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
|
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
|
||||||
|
|
||||||
for (int i = 0; i < TICKER_COUNT; i++) {
|
for (int i = 0; i < TICKER_COUNT; i++) {
|
||||||
|
|
|
@ -391,7 +391,7 @@ static void test_case_multithread_malloc_free()
|
||||||
threads[i].start(callback(malloc_free, &threads_continue));
|
threads[i].start(callback(malloc_free, &threads_continue));
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::wait(wait_time_us);
|
ThisThread::sleep_for(wait_time_us);
|
||||||
threads_continue = false;
|
threads_continue = false;
|
||||||
|
|
||||||
for (int i = 0; i < NUM_TEST_THREADS; i++) {
|
for (int i = 0; i < NUM_TEST_THREADS; i++) {
|
||||||
|
|
|
@ -39,13 +39,13 @@ class TestClass {
|
||||||
public:
|
public:
|
||||||
TestClass()
|
TestClass()
|
||||||
{
|
{
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
instance_count++;
|
instance_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_something()
|
void do_something()
|
||||||
{
|
{
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
~TestClass()
|
~TestClass()
|
||||||
|
@ -83,7 +83,7 @@ void test_case_func_race()
|
||||||
// Start start first thread
|
// Start start first thread
|
||||||
t1.start(cb);
|
t1.start(cb);
|
||||||
// Start second thread while the first is inside the constructor
|
// Start second thread while the first is inside the constructor
|
||||||
Thread::wait(250);
|
ThisThread::sleep_for(250);
|
||||||
t2.start(cb);
|
t2.start(cb);
|
||||||
|
|
||||||
// Wait for the threads to finish
|
// Wait for the threads to finish
|
||||||
|
@ -105,7 +105,7 @@ void test_case_class_race()
|
||||||
// Start start first thread
|
// Start start first thread
|
||||||
t1.start(cb);
|
t1.start(cb);
|
||||||
// Start second thread while the first is inside the constructor
|
// Start second thread while the first is inside the constructor
|
||||||
Thread::wait(250);
|
ThisThread::sleep_for(250);
|
||||||
t2.start(cb);
|
t2.start(cb);
|
||||||
|
|
||||||
// Wait for the threads to finish
|
// Wait for the threads to finish
|
||||||
|
|
|
@ -195,7 +195,7 @@ void test_multi_ticker(void)
|
||||||
ticker[i].attach_us(callback(increment_multi_counter), MULTI_TICKER_TIME_MS * 1000);
|
ticker[i].attach_us(callback(increment_multi_counter), MULTI_TICKER_TIME_MS * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::wait(MULTI_TICKER_TIME_MS + extra_wait);
|
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + extra_wait);
|
||||||
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
|
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
|
||||||
|
|
||||||
for (int i = 0; i < TICKER_COUNT; i++) {
|
for (int i = 0; i < TICKER_COUNT; i++) {
|
||||||
|
@ -211,7 +211,7 @@ void test_multi_ticker(void)
|
||||||
ticker[i].attach_us(callback(increment_multi_counter), (MULTI_TICKER_TIME_MS + i) * 1000);
|
ticker[i].attach_us(callback(increment_multi_counter), (MULTI_TICKER_TIME_MS + i) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::wait(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
|
ThisThread::sleep_for(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
|
||||||
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
|
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
|
||||||
|
|
||||||
for (int i = 0; i < TICKER_COUNT; i++) {
|
for (int i = 0; i < TICKER_COUNT; i++) {
|
||||||
|
|
|
@ -177,7 +177,7 @@ void test_multiple(void)
|
||||||
for (size_t i = 0; i < NUM_TIMEOUTS; i++) {
|
for (size_t i = 0; i < NUM_TIMEOUTS; i++) {
|
||||||
timeouts[i].attach_callback(mbed::callback(cnt_callback, &callback_count), TEST_DELAY_US);
|
timeouts[i].attach_callback(mbed::callback(cnt_callback, &callback_count), TEST_DELAY_US);
|
||||||
}
|
}
|
||||||
Thread::wait(TEST_DELAY_MS + 2);
|
ThisThread::sleep_for(TEST_DELAY_MS + 2);
|
||||||
TEST_ASSERT_EQUAL(NUM_TIMEOUTS, callback_count);
|
TEST_ASSERT_EQUAL(NUM_TIMEOUTS, callback_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ void sleep_manager_locking_thread_test()
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < 100; i++) {
|
for (uint32_t i = 0; i < 100; i++) {
|
||||||
sleep_manager_lock_deep_sleep();
|
sleep_manager_lock_deep_sleep();
|
||||||
Thread::wait(25);
|
ThisThread::sleep_for(25);
|
||||||
sleep_manager_unlock_deep_sleep();
|
sleep_manager_unlock_deep_sleep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void sleep_manager_multithread_test()
|
||||||
Thread t2(osPriorityNormal, TEST_STACK_SIZE);
|
Thread t2(osPriorityNormal, TEST_STACK_SIZE);
|
||||||
|
|
||||||
t1.start(callback(cb));
|
t1.start(callback(cb));
|
||||||
Thread::wait(25);
|
ThisThread::sleep_for(25);
|
||||||
t2.start(callback(cb));
|
t2.start(callback(cb));
|
||||||
|
|
||||||
// Wait for the threads to finish
|
// Wait for the threads to finish
|
||||||
|
|
|
@ -56,7 +56,7 @@ void get_cpu_usage()
|
||||||
uint8_t usage = 100 - ((diff * 100) / (SAMPLE_TIME * 1000));
|
uint8_t usage = 100 - ((diff * 100) / (SAMPLE_TIME * 1000));
|
||||||
prev_idle_time = stats.idle_time;
|
prev_idle_time = stats.idle_time;
|
||||||
TEST_ASSERT_NOT_EQUAL(0, usage);
|
TEST_ASSERT_NOT_EQUAL(0, usage);
|
||||||
Thread::wait(SAMPLE_TIME);
|
ThisThread::sleep_for(SAMPLE_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void test_cpu_info(void)
|
||||||
mbed_stats_cpu_t stats;
|
mbed_stats_cpu_t stats;
|
||||||
// Additional read to make sure timer is initialized
|
// Additional read to make sure timer is initialized
|
||||||
mbed_stats_cpu_get(&stats);
|
mbed_stats_cpu_get(&stats);
|
||||||
Thread::wait(3);
|
ThisThread::sleep_for(3);
|
||||||
mbed_stats_cpu_get(&stats);
|
mbed_stats_cpu_get(&stats);
|
||||||
TEST_ASSERT_NOT_EQUAL(0, stats.uptime);
|
TEST_ASSERT_NOT_EQUAL(0, stats.uptime);
|
||||||
TEST_ASSERT_NOT_EQUAL(0, stats.idle_time);
|
TEST_ASSERT_NOT_EQUAL(0, stats.idle_time);
|
||||||
|
@ -83,7 +83,7 @@ void test_cpu_load(void)
|
||||||
|
|
||||||
// Steadily increase the system load
|
// Steadily increase the system load
|
||||||
for (int count = 1; ; count++) {
|
for (int count = 1; ; count++) {
|
||||||
Thread::wait(LOOP_TIME);
|
ThisThread::sleep_for(LOOP_TIME);
|
||||||
if (wait_time <= 0) {
|
if (wait_time <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ void increment_with_delay()
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
counter++;
|
counter++;
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void test_case_multi_threads_blocked()
|
||||||
uint32_t ret = ef.set(FLAG_SIGNAL_DEC);
|
uint32_t ret = ef.set(FLAG_SIGNAL_DEC);
|
||||||
TEST_ASSERT_FALSE(ret & osFlagsError);
|
TEST_ASSERT_FALSE(ret & osFlagsError);
|
||||||
|
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
|
|
||||||
count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS);
|
count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS);
|
||||||
TEST_ASSERT_EQUAL(1, (count - old_count));
|
TEST_ASSERT_EQUAL(1, (count - old_count));
|
||||||
|
|
|
@ -48,7 +48,7 @@ static const int test_timeout = 40;
|
||||||
void update_tick_thread(Mutex *mutex)
|
void update_tick_thread(Mutex *mutex)
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread::wait(1);
|
ThisThread::sleep_for(1);
|
||||||
mutex->lock();
|
mutex->lock();
|
||||||
++elapsed_time_ms;
|
++elapsed_time_ms;
|
||||||
mutex->unlock();
|
mutex->unlock();
|
||||||
|
@ -56,7 +56,7 @@ void update_tick_thread(Mutex *mutex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Tests is to measure the accuracy of Thread::wait() over a period of time
|
/** Tests is to measure the accuracy of ThisThread::sleep_for() over a period of time
|
||||||
|
|
||||||
Given
|
Given
|
||||||
a thread updating elapsed_time_ms every milli sec
|
a thread updating elapsed_time_ms every milli sec
|
||||||
|
@ -109,7 +109,7 @@ void test(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
Case cases[] = {
|
Case cases[] = {
|
||||||
Case("Test Thread::wait accuracy", test)
|
Case("Test ThisThread::sleep_for accuracy", test)
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
|
|
@ -75,7 +75,7 @@ void send_thread(EventFlags *ef)
|
||||||
const uint32_t flag = flags & (1 << i);
|
const uint32_t flag = flags & (1 << i);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
ef->set(flag);
|
ef->set(flag);
|
||||||
Thread::wait(wait_ms);
|
ThisThread::sleep_for(wait_ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ void send_thread_sync(EventFlags *ef)
|
||||||
if (flag) {
|
if (flag) {
|
||||||
sync_sem.wait();
|
sync_sem.wait();
|
||||||
ef->set(flag);
|
ef->set(flag);
|
||||||
Thread::wait(wait_ms);
|
ThisThread::sleep_for(wait_ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ void test_heap_allocation_free(void)
|
||||||
check_and_free_heap(head, max_allocation_size);
|
check_and_free_heap(head, max_allocation_size);
|
||||||
|
|
||||||
// Force a task switch so a stack check is performed
|
// Force a task switch so a stack check is performed
|
||||||
Thread::wait(10);
|
ThisThread::sleep_for(10);
|
||||||
|
|
||||||
printf("Total size dynamically allocated: %luB\n", max_allocation_size);
|
printf("Total size dynamically allocated: %luB\n", max_allocation_size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ void send_thread(Mail<mail_t, QUEUE_SIZE> *m)
|
||||||
mail->thread_id = thread_id;
|
mail->thread_id = thread_id;
|
||||||
mail->data = data++;
|
mail->data = data++;
|
||||||
m->put(mail);
|
m->put(mail);
|
||||||
Thread::wait(wait_ms);
|
ThisThread::sleep_for(wait_ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void receive_thread(Mail<mail_t, queue_size> *m)
|
||||||
int result_counter = 0;
|
int result_counter = 0;
|
||||||
uint32_t data = thread_id * DATA_BASE;
|
uint32_t data = thread_id * DATA_BASE;
|
||||||
|
|
||||||
Thread::wait(wait_ms);
|
ThisThread::sleep_for(wait_ms);
|
||||||
for (uint32_t i = 0; i < queue_size; i++) {
|
for (uint32_t i = 0; i < queue_size; i++) {
|
||||||
osEvent evt = m->get();
|
osEvent evt = m->get();
|
||||||
if (evt.status == osEventMail) {
|
if (evt.status == osEventMail) {
|
||||||
|
@ -108,7 +108,7 @@ void test_single_thread_order(void)
|
||||||
thread.start(callback(send_thread<THREAD_1_ID, QUEUE_PUT_DELAY_1, QUEUE_SIZE>, &mail_box));
|
thread.start(callback(send_thread<THREAD_1_ID, QUEUE_PUT_DELAY_1, QUEUE_SIZE>, &mail_box));
|
||||||
|
|
||||||
// wait for some mail to be collected
|
// wait for some mail to be collected
|
||||||
Thread::wait(10);
|
ThisThread::sleep_for(10);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < QUEUE_SIZE; i++) {
|
for (uint32_t i = 0; i < QUEUE_SIZE; i++) {
|
||||||
// mail receive (main thread)
|
// mail receive (main thread)
|
||||||
|
@ -150,7 +150,7 @@ void test_multi_thread_order(void)
|
||||||
thread3.start(callback(send_thread<THREAD_3_ID, QUEUE_PUT_DELAY_3, 4>, &mail_box));
|
thread3.start(callback(send_thread<THREAD_3_ID, QUEUE_PUT_DELAY_3, 4>, &mail_box));
|
||||||
|
|
||||||
// wait for some mail to be collected
|
// wait for some mail to be collected
|
||||||
Thread::wait(10);
|
ThisThread::sleep_for(10);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < QUEUE_SIZE; i++) {
|
for (uint32_t i = 0; i < QUEUE_SIZE; i++) {
|
||||||
// mail receive (main thread)
|
// mail receive (main thread)
|
||||||
|
@ -211,7 +211,7 @@ void test_multi_thread_multi_mail_order(void)
|
||||||
mail->data = data[id]++;
|
mail->data = data[id]++;
|
||||||
mail_box[id].put(mail);
|
mail_box[id].put(mail);
|
||||||
|
|
||||||
Thread::wait(i * 10);
|
ThisThread::sleep_for(i * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread1.join();
|
thread1.join();
|
||||||
|
|
|
@ -90,7 +90,7 @@ void test_multithread_allocation(void)
|
||||||
|
|
||||||
// Give the test time to run
|
// Give the test time to run
|
||||||
while (test_time--) {
|
while (test_time--) {
|
||||||
Thread::wait(1000);
|
ThisThread::sleep_for(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Join and delete all threads
|
// Join and delete all threads
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool manipulate_protected_zone(const int thread_delay)
|
||||||
change_counter++;
|
change_counter++;
|
||||||
core_util_critical_section_exit();
|
core_util_critical_section_exit();
|
||||||
|
|
||||||
Thread::wait(thread_delay);
|
ThisThread::sleep_for(thread_delay);
|
||||||
|
|
||||||
core_util_critical_section_enter();
|
core_util_critical_section_enter();
|
||||||
changing_counter = false;
|
changing_counter = false;
|
||||||
|
@ -100,7 +100,7 @@ void test_multiple_threads(void)
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Thread 1 action
|
// Thread 1 action
|
||||||
Thread::wait(t1_delay);
|
ThisThread::sleep_for(t1_delay);
|
||||||
manipulate_protected_zone(t1_delay);
|
manipulate_protected_zone(t1_delay);
|
||||||
|
|
||||||
core_util_critical_section_enter();
|
core_util_critical_section_enter();
|
||||||
|
|
|
@ -37,7 +37,7 @@ using namespace utest::v1;
|
||||||
template <uint32_t ms>
|
template <uint32_t ms>
|
||||||
void thread_put_uint_msg(Queue<uint32_t, 1> *q)
|
void thread_put_uint_msg(Queue<uint32_t, 1> *q)
|
||||||
{
|
{
|
||||||
Thread::wait(ms);
|
ThisThread::sleep_for(ms);
|
||||||
osStatus stat = q->put((uint32_t *) TEST_UINT_MSG);
|
osStatus stat = q->put((uint32_t *) TEST_UINT_MSG);
|
||||||
TEST_ASSERT_EQUAL(osOK, stat);
|
TEST_ASSERT_EQUAL(osOK, stat);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ void thread_put_uint_msg(Queue<uint32_t, 1> *q)
|
||||||
template <uint32_t ms, uint32_t val>
|
template <uint32_t ms, uint32_t val>
|
||||||
void thread_get_uint_msg(Queue<uint32_t, 1> *q)
|
void thread_get_uint_msg(Queue<uint32_t, 1> *q)
|
||||||
{
|
{
|
||||||
Thread::wait(ms);
|
ThisThread::sleep_for(ms);
|
||||||
osEvent evt = q->get();
|
osEvent evt = q->get();
|
||||||
TEST_ASSERT_EQUAL(osEventMessage, evt.status);
|
TEST_ASSERT_EQUAL(osEventMessage, evt.status);
|
||||||
TEST_ASSERT_EQUAL(val, evt.value.v);
|
TEST_ASSERT_EQUAL(val, evt.value.v);
|
||||||
|
|
|
@ -52,7 +52,7 @@ void test_thread(int const *delay)
|
||||||
if (sem_lock_failed) {
|
if (sem_lock_failed) {
|
||||||
sem_defect = true;
|
sem_defect = true;
|
||||||
}
|
}
|
||||||
Thread::wait(thread_delay);
|
ThisThread::sleep_for(thread_delay);
|
||||||
sem_counter--;
|
sem_counter--;
|
||||||
change_counter++;
|
change_counter++;
|
||||||
two_slots.release();
|
two_slots.release();
|
||||||
|
@ -123,7 +123,7 @@ void test_single_thread()
|
||||||
|
|
||||||
res = t.start(callback(single_thread, &data));
|
res = t.start(callback(single_thread, &data));
|
||||||
TEST_ASSERT_EQUAL(osOK, res);
|
TEST_ASSERT_EQUAL(osOK, res);
|
||||||
Thread::wait(SHORT_WAIT);
|
ThisThread::sleep_for(SHORT_WAIT);
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(Thread::WaitingSemaphore, t.get_state());
|
TEST_ASSERT_EQUAL(Thread::WaitingSemaphore, t.get_state());
|
||||||
TEST_ASSERT_EQUAL(0, data.data);
|
TEST_ASSERT_EQUAL(0, data.data);
|
||||||
|
@ -131,7 +131,7 @@ void test_single_thread()
|
||||||
res = sem.release();
|
res = sem.release();
|
||||||
TEST_ASSERT_EQUAL(osOK, res);
|
TEST_ASSERT_EQUAL(osOK, res);
|
||||||
|
|
||||||
Thread::wait(SHORT_WAIT);
|
ThisThread::sleep_for(SHORT_WAIT);
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(1, data.data);
|
TEST_ASSERT_EQUAL(1, data.data);
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void test_timeout()
|
||||||
timer.start();
|
timer.start();
|
||||||
res = t.start(callback(timeout_thread, &sem));
|
res = t.start(callback(timeout_thread, &sem));
|
||||||
TEST_ASSERT_EQUAL(osOK, res);
|
TEST_ASSERT_EQUAL(osOK, res);
|
||||||
Thread::wait(SHORT_WAIT);
|
ThisThread::sleep_for(SHORT_WAIT);
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(Thread::WaitingSemaphore, t.get_state());
|
TEST_ASSERT_EQUAL(Thread::WaitingSemaphore, t.get_state());
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ void run_wait_clear(Sync *sync)
|
||||||
{
|
{
|
||||||
sync->sem_parent.release();
|
sync->sem_parent.release();
|
||||||
sync->sem_child.wait();
|
sync->sem_child.wait();
|
||||||
int32_t ret = Thread::signal_clr(signals);
|
int32_t ret = ThisThread::flags_clear(signals);
|
||||||
TEST_ASSERT_EQUAL(test_val, ret);
|
TEST_ASSERT_EQUAL(test_val, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,10 +114,10 @@ void run_double_wait_clear(Sync *sync)
|
||||||
|
|
||||||
sync->sem_parent.release();
|
sync->sem_parent.release();
|
||||||
sync->sem_child.wait();
|
sync->sem_child.wait();
|
||||||
ret = Thread::signal_clr(signals1);
|
ret = ThisThread::flags_clear(signals1);
|
||||||
TEST_ASSERT_EQUAL(test_val1, ret);
|
TEST_ASSERT_EQUAL(test_val1, ret);
|
||||||
|
|
||||||
ret = Thread::signal_clr(signals2);
|
ret = ThisThread::flags_clear(signals2);
|
||||||
TEST_ASSERT_EQUAL(test_val2, ret);
|
TEST_ASSERT_EQUAL(test_val2, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ void run_loop_wait_clear(Sync *sync)
|
||||||
int32_t signal = 1 << i;
|
int32_t signal = 1 << i;
|
||||||
signals |= signal;
|
signals |= signal;
|
||||||
sync->sem_child.wait();
|
sync->sem_child.wait();
|
||||||
int32_t ret = Thread::signal_clr(NO_SIGNALS);
|
int32_t ret = ThisThread::flags_clear(NO_SIGNALS);
|
||||||
TEST_ASSERT_EQUAL(signals, ret);
|
TEST_ASSERT_EQUAL(signals, ret);
|
||||||
sync->sem_parent.release();
|
sync->sem_parent.release();
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,7 +474,7 @@ void test_thread_wait()
|
||||||
Timer timer;
|
Timer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
Thread::wait(150);
|
ThisThread::sleep_for(150);
|
||||||
|
|
||||||
TEST_ASSERT_UINT32_WITHIN(50000, 150000, timer.read_us());
|
TEST_ASSERT_UINT32_WITHIN(50000, 150000, timer.read_us());
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ void test_deleted()
|
||||||
|
|
||||||
void test_delay_thread()
|
void test_delay_thread()
|
||||||
{
|
{
|
||||||
Thread::wait(50);
|
ThisThread::sleep_for(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Testing thread states: wait delay
|
/** Testing thread states: wait delay
|
||||||
|
|
|
@ -119,7 +119,7 @@ void TCPSOCKET_ECHOTEST_NONBLOCK()
|
||||||
|
|
||||||
tcpsocket_connect_to_echo_srv(sock);
|
tcpsocket_connect_to_echo_srv(sock);
|
||||||
sock.set_blocking(false);
|
sock.set_blocking(false);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
int bytes2send;
|
int bytes2send;
|
||||||
int sent;
|
int sent;
|
||||||
|
|
|
@ -41,7 +41,7 @@ void TCPSOCKET_ECHOTEST_BURST()
|
||||||
{
|
{
|
||||||
TCPSocket sock;
|
TCPSocket sock;
|
||||||
tcpsocket_connect_to_echo_srv(sock);
|
tcpsocket_connect_to_echo_srv(sock);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
// TX buffer to be preserved for comparison
|
// TX buffer to be preserved for comparison
|
||||||
fill_tx_buffer_ascii(tcp_global::tx_buffer, BURST_SIZE);
|
fill_tx_buffer_ascii(tcp_global::tx_buffer, BURST_SIZE);
|
||||||
|
@ -94,7 +94,7 @@ void TCPSOCKET_ECHOTEST_BURST_NONBLOCK()
|
||||||
TCPSocket sock;
|
TCPSocket sock;
|
||||||
tcpsocket_connect_to_echo_srv(sock);
|
tcpsocket_connect_to_echo_srv(sock);
|
||||||
sock.set_blocking(false);
|
sock.set_blocking(false);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
// TX buffer to be preserved for comparison
|
// TX buffer to be preserved for comparison
|
||||||
fill_tx_buffer_ascii(tcp_global::tx_buffer, BURST_SIZE);
|
fill_tx_buffer_ascii(tcp_global::tx_buffer, BURST_SIZE);
|
||||||
|
|
|
@ -63,7 +63,7 @@ void TCPSOCKET_ENDPOINT_CLOSE()
|
||||||
TEST_FAIL();
|
TEST_FAIL();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
int recvd = 0;
|
int recvd = 0;
|
||||||
int recvd_total = 0;
|
int recvd_total = 0;
|
||||||
|
|
|
@ -170,7 +170,7 @@ void TCPSOCKET_RECV_100K_NONBLOCK()
|
||||||
}
|
}
|
||||||
|
|
||||||
sock.set_blocking(false);
|
sock.set_blocking(false);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
rcv_n_chk_against_rfc864_pattern_nonblock(sock);
|
rcv_n_chk_against_rfc864_pattern_nonblock(sock);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ void TCPSOCKET_RECV_TIMEOUT()
|
||||||
TCPSocket sock;
|
TCPSocket sock;
|
||||||
tcpsocket_connect_to_echo_srv(sock);
|
tcpsocket_connect_to_echo_srv(sock);
|
||||||
sock.set_timeout(100);
|
sock.set_timeout(100);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
int recvd = 0;
|
int recvd = 0;
|
||||||
int pkt_unrecvd;
|
int pkt_unrecvd;
|
||||||
|
|
|
@ -47,7 +47,7 @@ static void check_const_len_rand_sequence()
|
||||||
{
|
{
|
||||||
TCPSocket sock;
|
TCPSocket sock;
|
||||||
tcpsocket_connect_to_echo_srv(sock);
|
tcpsocket_connect_to_echo_srv(sock);
|
||||||
sock.sigio(callback(_sigio_handler1, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler1, ThisThread::get_id()));
|
||||||
|
|
||||||
static const int BUFF_SIZE = 10;
|
static const int BUFF_SIZE = 10;
|
||||||
static char rx_buff[BUFF_SIZE] = {0};
|
static char rx_buff[BUFF_SIZE] = {0};
|
||||||
|
@ -104,7 +104,7 @@ static void check_var_len_rand_sequence()
|
||||||
{
|
{
|
||||||
TCPSocket sock;
|
TCPSocket sock;
|
||||||
tcpsocket_connect_to_echo_srv(sock);
|
tcpsocket_connect_to_echo_srv(sock);
|
||||||
sock.sigio(callback(_sigio_handler2, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler2, ThisThread::get_id()));
|
||||||
|
|
||||||
static const int BUFF_SIZE = 1001;
|
static const int BUFF_SIZE = 1001;
|
||||||
static char rx_buff[BUFF_SIZE];
|
static char rx_buff[BUFF_SIZE];
|
||||||
|
|
|
@ -127,7 +127,7 @@ void UDPSOCKET_ECHOTEST_NONBLOCK()
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
||||||
sock.set_blocking(false);
|
sock.set_blocking(false);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
int sent;
|
int sent;
|
||||||
int s_idx = 0;
|
int s_idx = 0;
|
||||||
|
|
|
@ -78,7 +78,7 @@ void UDPSOCKET_ECHOTEST_BURST()
|
||||||
const int TIMEOUT = 5000; // [ms]
|
const int TIMEOUT = 5000; // [ms]
|
||||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
||||||
sock.set_timeout(TIMEOUT);
|
sock.set_timeout(TIMEOUT);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
// TX buffers to be preserved for comparison
|
// TX buffers to be preserved for comparison
|
||||||
prepare_tx_buffers();
|
prepare_tx_buffers();
|
||||||
|
@ -156,7 +156,7 @@ void UDPSOCKET_ECHOTEST_BURST_NONBLOCK()
|
||||||
UDPSocket sock;
|
UDPSocket sock;
|
||||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
||||||
sock.set_blocking(false);
|
sock.set_blocking(false);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
// TX buffers to be preserved for comparison
|
// TX buffers to be preserved for comparison
|
||||||
prepare_tx_buffers();
|
prepare_tx_buffers();
|
||||||
|
|
|
@ -46,7 +46,7 @@ void UDPSOCKET_RECV_TIMEOUT()
|
||||||
UDPSocket sock;
|
UDPSocket sock;
|
||||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
|
||||||
sock.set_timeout(100);
|
sock.set_timeout(100);
|
||||||
sock.sigio(callback(_sigio_handler, Thread::gettid()));
|
sock.sigio(callback(_sigio_handler, ThisThread::get_id()));
|
||||||
|
|
||||||
int recvd;
|
int recvd;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
extern mac_api_s *mac_interface;
|
extern mac_api_s *mac_interface;
|
||||||
RawSerial pc(USBTX, USBRX);
|
RawSerial pc(USBTX, USBRX);
|
||||||
osThreadId main_thread;
|
osThreadId_t main_thread;
|
||||||
static CircularBuffer<uint8_t, RX_BUFFER_SIZE> rx_buffer;
|
static CircularBuffer<uint8_t, RX_BUFFER_SIZE> rx_buffer;
|
||||||
static uint8_t ns_heap[HEAP_FOR_MAC_TESTER_SIZE];
|
static uint8_t ns_heap[HEAP_FOR_MAC_TESTER_SIZE];
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ static void rx_interrupt(void)
|
||||||
uint8_t c = pc.getc();
|
uint8_t c = pc.getc();
|
||||||
rx_buffer.push(c);
|
rx_buffer.push(c);
|
||||||
if (main_thread != NULL) {
|
if (main_thread != NULL) {
|
||||||
osSignalSet(main_thread, 1);
|
osThreadFlagsSet(main_thread, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ static void trace_printer(const char *str)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
main_thread = osThreadGetId();
|
main_thread = ThisThread::get_id();
|
||||||
pc.baud(MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
|
pc.baud(MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
|
||||||
pc.attach(rx_interrupt);
|
pc.attach(rx_interrupt);
|
||||||
ns_hal_init(ns_heap, HEAP_FOR_MAC_TESTER_SIZE, app_heap_error_handler, NULL);
|
ns_hal_init(ns_heap, HEAP_FOR_MAC_TESTER_SIZE, app_heap_error_handler, NULL);
|
||||||
|
@ -148,12 +148,8 @@ int main(void)
|
||||||
tr_info("Created driver & SW MAC");
|
tr_info("Created driver & SW MAC");
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
osEvent os_event = Thread::signal_wait(1);
|
ThisThread::flags_wait_any(1);
|
||||||
if (os_event.status != osEventSignal) {
|
handle_rx_data();
|
||||||
osThreadYield();
|
|
||||||
} else {
|
|
||||||
handle_rx_data();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -518,7 +518,7 @@ static void udp_receiver_thread(SInfo *info)
|
||||||
int *packetSizes = info->getPacketSizeArray();
|
int *packetSizes = info->getPacketSizeArray();
|
||||||
nsapi_size_or_error_t ret = 0;
|
nsapi_size_or_error_t ret = 0;
|
||||||
|
|
||||||
info->setReceiverThreadId(Thread::gettid());
|
info->setReceiverThreadId(ThisThread::get_id());
|
||||||
|
|
||||||
while (i < n) {
|
while (i < n) {
|
||||||
ret = static_cast<UDPSocket &>(info->socket()).recvfrom(&addr, info->getReceiveBuffer() + received, info->getDataCount() - received);
|
ret = static_cast<UDPSocket &>(info->socket()).recvfrom(&addr, info->getReceiveBuffer() + received, info->getDataCount() - received);
|
||||||
|
@ -531,7 +531,7 @@ static void udp_receiver_thread(SInfo *info)
|
||||||
i++;
|
i++;
|
||||||
info->setRecvTotal(info->getRecvTotal() + ret);
|
info->setRecvTotal(info->getRecvTotal() + ret);
|
||||||
} else if (ret == NSAPI_ERROR_WOULD_BLOCK) {
|
} else if (ret == NSAPI_ERROR_WOULD_BLOCK) {
|
||||||
Thread::signal_wait(SIGNAL_SIGIO);
|
ThisThread::flags_wait_all(SIGNAL_SIGIO);
|
||||||
} else {
|
} else {
|
||||||
handle_nsapi_size_or_error("Thread: UDPSocket::recvfrom()", ret);
|
handle_nsapi_size_or_error("Thread: UDPSocket::recvfrom()", ret);
|
||||||
return;
|
return;
|
||||||
|
@ -660,7 +660,7 @@ static void tcp_receiver_thread(SInfo *info)
|
||||||
int bufferSize = info->getDataCount();
|
int bufferSize = info->getDataCount();
|
||||||
nsapi_size_or_error_t ret = 0;
|
nsapi_size_or_error_t ret = 0;
|
||||||
|
|
||||||
info->setReceiverThreadId(Thread::gettid());
|
info->setReceiverThreadId(ThisThread::get_id());
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
received = 0;
|
received = 0;
|
||||||
|
@ -673,7 +673,7 @@ static void tcp_receiver_thread(SInfo *info)
|
||||||
received += ret;
|
received += ret;
|
||||||
info->setRecvTotal(info->getRecvTotal() + ret);
|
info->setRecvTotal(info->getRecvTotal() + ret);
|
||||||
} else if (ret == NSAPI_ERROR_WOULD_BLOCK) {
|
} else if (ret == NSAPI_ERROR_WOULD_BLOCK) {
|
||||||
Thread::signal_wait(SIGNAL_SIGIO);
|
ThisThread::flags_wait_all(SIGNAL_SIGIO);
|
||||||
} else {
|
} else {
|
||||||
handle_nsapi_size_or_error("Thread: TCPSocket::recv()", ret);
|
handle_nsapi_size_or_error("Thread: TCPSocket::recv()", ret);
|
||||||
return;
|
return;
|
||||||
|
@ -729,7 +729,7 @@ static nsapi_size_or_error_t tcp_send_command_handler(SInfo *info, int argc, cha
|
||||||
void *data;
|
void *data;
|
||||||
nsapi_size_or_error_t ret = 0;
|
nsapi_size_or_error_t ret = 0;
|
||||||
|
|
||||||
info->setSenderThreadId(Thread::gettid());
|
info->setSenderThreadId(ThisThread::get_id());
|
||||||
|
|
||||||
if (cmd_parameter_int(argc, argv, "--data_len", &len)) {
|
if (cmd_parameter_int(argc, argv, "--data_len", &len)) {
|
||||||
data = malloc(len);
|
data = malloc(len);
|
||||||
|
@ -809,7 +809,7 @@ static void bg_traffic_thread(SInfo *info)
|
||||||
char sbuffer[data_len + 1] = "dummydata_";
|
char sbuffer[data_len + 1] = "dummydata_";
|
||||||
char rbuffer[data_len + 1];
|
char rbuffer[data_len + 1];
|
||||||
int scount, rtotal = 0;
|
int scount, rtotal = 0;
|
||||||
info->setSenderThreadId(Thread::gettid());
|
info->setSenderThreadId(ThisThread::get_id());
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!info->available()) {
|
if (!info->available()) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ set(unittest-test-sources
|
||||||
stubs/Timer_stub.cpp
|
stubs/Timer_stub.cpp
|
||||||
stubs/equeue_stub.c
|
stubs/equeue_stub.c
|
||||||
stubs/Kernel_stub.cpp
|
stubs/Kernel_stub.cpp
|
||||||
stubs/Thread_stub.cpp
|
stubs/ThisThread_stub.cpp
|
||||||
stubs/randLIB_stub.cpp
|
stubs/randLIB_stub.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) , Arm Limited and affiliates.
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtos/ThisThread.h"
|
||||||
|
|
||||||
|
namespace rtos {
|
||||||
|
|
||||||
|
void ThisThread::sleep_until(uint64_t millisec)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -297,17 +297,17 @@ static void rf_if_unlock(void)
|
||||||
#ifdef MBED_CONF_RTOS_PRESENT
|
#ifdef MBED_CONF_RTOS_PRESENT
|
||||||
static void rf_if_cca_timer_signal(void)
|
static void rf_if_cca_timer_signal(void)
|
||||||
{
|
{
|
||||||
rf->irq_thread.signal_set(SIG_TIMER_CCA);
|
rf->irq_thread.flags_set(SIG_TIMER_CCA);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rf_if_cal_timer_signal(void)
|
static void rf_if_cal_timer_signal(void)
|
||||||
{
|
{
|
||||||
rf->irq_thread.signal_set(SIG_TIMER_CAL);
|
rf->irq_thread.flags_set(SIG_TIMER_CAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rf_if_ack_timer_signal(void)
|
static void rf_if_ack_timer_signal(void)
|
||||||
{
|
{
|
||||||
rf->irq_thread.signal_set(SIG_TIMER_ACK);
|
rf->irq_thread.flags_set(SIG_TIMER_ACK);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ static void rf_if_disable_irq(void)
|
||||||
#ifdef MBED_CONF_RTOS_PRESENT
|
#ifdef MBED_CONF_RTOS_PRESENT
|
||||||
static void rf_if_interrupt_handler(void)
|
static void rf_if_interrupt_handler(void)
|
||||||
{
|
{
|
||||||
rf->irq_thread.signal_set(SIG_RADIO);
|
rf->irq_thread.flags_set(SIG_RADIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Started during construction of rf, so variable
|
// Started during construction of rf, so variable
|
||||||
|
@ -1048,21 +1048,18 @@ static void rf_if_interrupt_handler(void)
|
||||||
void RFBits::rf_if_irq_task(void)
|
void RFBits::rf_if_irq_task(void)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
osEvent event = irq_thread.signal_wait(0);
|
uint32_t flags = ThisThread::flags_wait_any(SIG_ALL);
|
||||||
if (event.status != osEventSignal) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
rf_if_lock();
|
rf_if_lock();
|
||||||
if (event.value.signals & SIG_RADIO) {
|
if (flags & SIG_RADIO) {
|
||||||
rf_if_irq_task_process_irq();
|
rf_if_irq_task_process_irq();
|
||||||
}
|
}
|
||||||
if (event.value.signals & SIG_TIMER_ACK) {
|
if (flags & SIG_TIMER_ACK) {
|
||||||
rf_ack_wait_timer_interrupt();
|
rf_ack_wait_timer_interrupt();
|
||||||
}
|
}
|
||||||
if (event.value.signals & SIG_TIMER_CCA) {
|
if (flags & SIG_TIMER_CCA) {
|
||||||
rf_cca_timer_interrupt();
|
rf_cca_timer_interrupt();
|
||||||
}
|
}
|
||||||
if (event.value.signals & SIG_TIMER_CAL) {
|
if (flags & SIG_TIMER_CAL) {
|
||||||
rf_calibration_timer_interrupt();
|
rf_calibration_timer_interrupt();
|
||||||
}
|
}
|
||||||
rf_if_unlock();
|
rf_if_unlock();
|
||||||
|
|
|
@ -1094,16 +1094,13 @@ static void rf_init_phy_mode(void)
|
||||||
static void PHY_InterruptHandler(void)
|
static void PHY_InterruptHandler(void)
|
||||||
{
|
{
|
||||||
MCR20Drv_IRQ_Disable();
|
MCR20Drv_IRQ_Disable();
|
||||||
irq_thread->signal_set(1);
|
irq_thread->flags_set(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PHY_InterruptThread(void)
|
static void PHY_InterruptThread(void)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
osEvent event = irq_thread->signal_wait(0);
|
ThisThread::flags_wait_all(1);
|
||||||
if (event.status != osEventSignal) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
handle_interrupt();
|
handle_interrupt();
|
||||||
MCR20Drv_IRQ_Enable();
|
MCR20Drv_IRQ_Enable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "platform/mbed_poll.h"
|
#include "platform/mbed_poll.h"
|
||||||
|
|
||||||
#if MBED_CONF_RTOS_PRESENT
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
#include "rtos/Thread.h"
|
#include "rtos/ThisThread.h"
|
||||||
#else
|
#else
|
||||||
#include "platform/mbed_wait_api.h"
|
#include "platform/mbed_wait_api.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -332,7 +332,7 @@ void UARTSerial::wait_ms(uint32_t millisec)
|
||||||
* want to just sleep until next tick.
|
* want to just sleep until next tick.
|
||||||
*/
|
*/
|
||||||
#if MBED_CONF_RTOS_PRESENT
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
rtos::Thread::wait(millisec);
|
rtos::ThisThread::sleep_for(millisec);
|
||||||
#else
|
#else
|
||||||
::wait_ms(millisec);
|
::wait_ms(millisec);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -382,13 +382,13 @@ static void test_disconnect()
|
||||||
TEST_ASSERT(st == NSAPI_STATUS_GLOBAL_UP);
|
TEST_ASSERT(st == NSAPI_STATUS_GLOBAL_UP);
|
||||||
TEST_ASSERT(nw->disconnect() == NSAPI_ERROR_OK);
|
TEST_ASSERT(nw->disconnect() == NSAPI_ERROR_OK);
|
||||||
// wait to process URC's, received after disconnect
|
// wait to process URC's, received after disconnect
|
||||||
rtos::Thread::wait(500);
|
rtos::ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_detach()
|
static void test_detach()
|
||||||
{
|
{
|
||||||
// in PPP mode there is NO CARRIER waiting so flush it out
|
// in PPP mode there is NO CARRIER waiting so flush it out
|
||||||
rtos::Thread::wait(6 * 1000);
|
rtos::ThisThread::sleep_for(6 * 1000);
|
||||||
((AT_CellularNetwork *)nw)->get_at_handler().flush();
|
((AT_CellularNetwork *)nw)->get_at_handler().flush();
|
||||||
|
|
||||||
nsapi_connection_status_t st = nw->get_connection_status();
|
nsapi_connection_status_t st = nw->get_connection_status();
|
||||||
|
@ -396,7 +396,7 @@ static void test_detach()
|
||||||
|
|
||||||
TEST_ASSERT(nw->detach() == NSAPI_ERROR_OK);
|
TEST_ASSERT(nw->detach() == NSAPI_ERROR_OK);
|
||||||
// wait to process URC's, received after detach
|
// wait to process URC's, received after detach
|
||||||
rtos::Thread::wait(500);
|
rtos::ThisThread::sleep_for(500);
|
||||||
st = nw->get_connection_status();
|
st = nw->get_connection_status();
|
||||||
TEST_ASSERT(st == NSAPI_STATUS_DISCONNECTED);
|
TEST_ASSERT(st == NSAPI_STATUS_DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "FileHandle.h"
|
#include "FileHandle.h"
|
||||||
#include "mbed_wait_api.h"
|
#include "mbed_wait_api.h"
|
||||||
#include "mbed_debug.h"
|
#include "mbed_debug.h"
|
||||||
#include "rtos/Thread.h"
|
#include "rtos/ThisThread.h"
|
||||||
#include "Kernel.h"
|
#include "Kernel.h"
|
||||||
#include "CellularUtil.h"
|
#include "CellularUtil.h"
|
||||||
|
|
||||||
|
@ -1043,7 +1043,7 @@ void ATHandler::cmd_start(const char *cmd)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_at_send_delay) {
|
if (_at_send_delay) {
|
||||||
rtos::Thread::wait_until(_last_response_stop + _at_send_delay);
|
rtos::ThisThread::sleep_until(_last_response_stop + _at_send_delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_last_err != NSAPI_ERROR_OK) {
|
if (_last_err != NSAPI_ERROR_OK) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ static uint32_t print_dec(char *buf, uint32_t value);
|
||||||
void greentea_metrics_setup()
|
void greentea_metrics_setup()
|
||||||
{
|
{
|
||||||
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
|
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
|
||||||
Thread::attach_terminate_hook(on_thread_terminate);
|
Kernel::attach_thread_terminate_hook(on_thread_terminate);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ void greentea_metrics_report()
|
||||||
send_heap_info();
|
send_heap_info();
|
||||||
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
|
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
|
||||||
send_stack_info();
|
send_stack_info();
|
||||||
Thread::attach_terminate_hook(NULL);
|
Kernel::attach_thread_terminate_hook(NULL);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBED_CPU_STATS_ENABLED)
|
#if defined(MBED_CPU_STATS_ENABLED)
|
||||||
send_CPU_info();
|
send_CPU_info();
|
||||||
|
|
|
@ -157,13 +157,10 @@ static phy_device_driver_s device_driver = {
|
||||||
static void rf_thread_loop()
|
static void rf_thread_loop()
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
osEvent event = rf_thread.signal_wait(0);
|
uint32_t flags = ThisThread::flags_wait_any(0x7FFFFFFF);
|
||||||
if (event.status != osEventSignal) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
platform_enter_critical();
|
platform_enter_critical();
|
||||||
if (event.value.signals & SIGNAL_COUNT_RADIO) {
|
if (flags & SIGNAL_COUNT_RADIO) {
|
||||||
handle_IRQ_events();
|
handle_IRQ_events();
|
||||||
}
|
}
|
||||||
platform_exit_critical();
|
platform_exit_critical();
|
||||||
|
@ -806,7 +803,7 @@ static void rf_mac_tx_interrupt(void)
|
||||||
extern "C" void fIrqMacHwHandler(void)
|
extern "C" void fIrqMacHwHandler(void)
|
||||||
{
|
{
|
||||||
NVIC_DisableIRQ(MacHw_IRQn);
|
NVIC_DisableIRQ(MacHw_IRQn);
|
||||||
rf_thread.signal_set(SIGNAL_COUNT_RADIO);
|
rf_thread.flags_set(SIGNAL_COUNT_RADIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_IRQ_events(void)
|
static void handle_IRQ_events(void)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
#include "rtos/ThisThread.h"
|
||||||
#include "netsocket/nsapi_types.h"
|
#include "netsocket/nsapi_types.h"
|
||||||
#include "mbed_shared_queues.h"
|
#include "mbed_shared_queues.h"
|
||||||
#include "ethernet_api.h"
|
#include "ethernet_api.h"
|
||||||
|
@ -157,7 +158,7 @@ void RZ_A1_EMAC::_recv_callback(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RZ_A1_EMAC::recv_callback(void) {
|
void RZ_A1_EMAC::recv_callback(void) {
|
||||||
recvThread.signal_set(1);
|
recvThread.flags_set(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RZ_A1_EMAC::recv_task(void) {
|
void RZ_A1_EMAC::recv_task(void) {
|
||||||
|
@ -166,7 +167,7 @@ void RZ_A1_EMAC::recv_task(void) {
|
||||||
int cnt;
|
int cnt;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
rtos::Thread::signal_wait(1);
|
rtos::ThisThread::flags_wait_all(1);
|
||||||
for (cnt = 0; cnt < 16; cnt++) {
|
for (cnt = 0; cnt < 16; cnt++) {
|
||||||
recv_size = ethernet_receive();
|
recv_size = ethernet_receive();
|
||||||
if (recv_size == 0) {
|
if (recv_size == 0) {
|
||||||
|
|
|
@ -171,7 +171,7 @@ void USBHost::usb_process()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
USB_INFO("New device connected: %p [hub: %d - port: %d]", &devices[i], usb_msg->hub, usb_msg->port);
|
USB_INFO("New device connected: %p [hub: %d - port: %d]", &devices[i], usb_msg->hub, usb_msg->port);
|
||||||
|
@ -599,7 +599,7 @@ USB_TYPE USBHost::resetDevice(USBDeviceConnected * dev)
|
||||||
int index = findDevice(dev);
|
int index = findDevice(dev);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
USB_DBG("Resetting hub %d, port %d\n", dev->getHub(), dev->getPort());
|
USB_DBG("Resetting hub %d, port %d\n", dev->getHub(), dev->getPort());
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
if (dev->getHub() == 0) {
|
if (dev->getHub() == 0) {
|
||||||
resetRootHub();
|
resetRootHub();
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ USB_TYPE USBHost::resetDevice(USBDeviceConnected * dev)
|
||||||
dev->getHubParent()->portReset(dev->getPort());
|
dev->getHubParent()->portReset(dev->getPort());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
deviceReset[index] = true;
|
deviceReset[index] = true;
|
||||||
return USB_TYPE_OK;
|
return USB_TYPE_OK;
|
||||||
}
|
}
|
||||||
|
@ -974,7 +974,7 @@ USB_TYPE USBHost::enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerato
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
// Some devices may require this delay
|
// Some devices may require this delay
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
|
|
||||||
return USB_TYPE_OK;
|
return USB_TYPE_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ int WANDongleSerialPort::readPacket()
|
||||||
{
|
{
|
||||||
//lock_rx.unlock();
|
//lock_rx.unlock();
|
||||||
USB_ERR("host->bulkRead() returned %d", res);
|
USB_ERR("host->bulkRead() returned %d", res);
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -123,7 +123,7 @@ int WANDongleSerialPort::writePacket()
|
||||||
{
|
{
|
||||||
//lock_tx.unlock();
|
//lock_tx.unlock();
|
||||||
USB_ERR("host->bulkWrite() returned %d", res);
|
USB_ERR("host->bulkWrite() returned %d", res);
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -232,7 +232,7 @@ void USBHostHub::portReset(uint8_t port)
|
||||||
USB_DBG("reset port %d on hub: %p [this: %p]", port, dev, this)
|
USB_DBG("reset port %d on hub: %p [this: %p]", port, dev, this)
|
||||||
setPortFeature(PORT_RESET_FEATURE, port);
|
setPortFeature(PORT_RESET_FEATURE, port);
|
||||||
#if defined(TARGET_RZ_A1H)
|
#if defined(TARGET_RZ_A1H)
|
||||||
Thread::wait(50); // Reset release waiting for Hi-Speed check.
|
ThisThread::sleep_for(50); // Reset release waiting for Hi-Speed check.
|
||||||
#endif
|
#endif
|
||||||
while(1) {
|
while(1) {
|
||||||
status = getPortStatus(port);
|
status = getPortStatus(port);
|
||||||
|
@ -249,7 +249,7 @@ void USBHostHub::portReset(uint8_t port)
|
||||||
host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
|
host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Thread::wait(10);
|
ThisThread::sleep_for(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -322,7 +322,7 @@ int USBHostMSD::init()
|
||||||
uint16_t i, timeout = 10, ret;
|
uint16_t i, timeout = 10, ret;
|
||||||
getMaxLun();
|
getMaxLun();
|
||||||
for (i = 0; i < timeout; i++) {
|
for (i = 0; i < timeout; i++) {
|
||||||
Thread::wait(100);
|
ThisThread::sleep_for(100);
|
||||||
if (!testUnitReady())
|
if (!testUnitReady())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
mtx.lock();
|
mtx.lock();
|
||||||
while (((write + 1) % size) == read) {
|
while (((write + 1) % size) == read) {
|
||||||
mtx.unlock();
|
mtx.unlock();
|
||||||
Thread::wait(10);
|
ThisThread::sleep_for(10);
|
||||||
mtx.lock();
|
mtx.lock();
|
||||||
}
|
}
|
||||||
buf[write++] = k;
|
buf[write++] = k;
|
||||||
|
|
|
@ -17,7 +17,7 @@ void queue_isr() {
|
||||||
void queue_thread(void const *argument) {
|
void queue_thread(void const *argument) {
|
||||||
while (true) {
|
while (true) {
|
||||||
queue.put((uint32_t*)1);
|
queue.put((uint32_t*)1);
|
||||||
Thread::wait(1000);
|
ThisThread::sleep_for(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ DigitalOut led2(LED2);
|
||||||
void led2_thread(void const *argument) {
|
void led2_thread(void const *argument) {
|
||||||
while (true) {
|
while (true) {
|
||||||
led2 = !led2;
|
led2 = !led2;
|
||||||
Thread::wait(1000);
|
ThisThread::sleep_for(1000);
|
||||||
print_char();
|
print_char();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,6 @@ int main() {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
led1 = !led1;
|
led1 = !led1;
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,6 @@ int main() {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
led2 = !led2;
|
led2 = !led2;
|
||||||
Thread::wait(1000);
|
ThisThread::sleep_for(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ void queue_isr() {
|
||||||
void queue_thread(void const *argument) {
|
void queue_thread(void const *argument) {
|
||||||
while (true) {
|
while (true) {
|
||||||
queue.put((uint32_t*)QUEUE_PUT_THREAD_VALUE);
|
queue.put((uint32_t*)QUEUE_PUT_THREAD_VALUE);
|
||||||
Thread::wait(THREAD_DELAY);
|
ThisThread::sleep_for(THREAD_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ void send_thread (void const *argument) {
|
||||||
mail->current = CREATE_CURRENT(i);
|
mail->current = CREATE_CURRENT(i);
|
||||||
mail->counter = i;
|
mail->counter = i;
|
||||||
mail_box.put(mail);
|
mail_box.put(mail);
|
||||||
Thread::wait(QUEUE_PUT_DELAY);
|
ThisThread::sleep_for(QUEUE_PUT_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ bool manipulate_protected_zone(const int thread_delay) {
|
||||||
led = !led;
|
led = !led;
|
||||||
change_counter++;
|
change_counter++;
|
||||||
print_char('.');
|
print_char('.');
|
||||||
Thread::wait(thread_delay);
|
ThisThread::sleep_for(thread_delay);
|
||||||
|
|
||||||
changing_counter = false;
|
changing_counter = false;
|
||||||
stdio_mutex.unlock(); // UNLOCK
|
stdio_mutex.unlock(); // UNLOCK
|
||||||
|
@ -94,7 +94,7 @@ int main() {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Thread 1 action
|
// Thread 1 action
|
||||||
Thread::wait(t1_delay);
|
ThisThread::sleep_for(t1_delay);
|
||||||
manipulate_protected_zone(t1_delay);
|
manipulate_protected_zone(t1_delay);
|
||||||
if (change_counter >= SIGNALS_TO_EMIT or mutex_defect == true) {
|
if (change_counter >= SIGNALS_TO_EMIT or mutex_defect == true) {
|
||||||
t2.terminate();
|
t2.terminate();
|
||||||
|
|
|
@ -49,7 +49,7 @@ void send_thread (void const *argument) {
|
||||||
message->current = CREATE_CURRENT(i);
|
message->current = CREATE_CURRENT(i);
|
||||||
message->counter = i;
|
message->counter = i;
|
||||||
queue.put(message);
|
queue.put(message);
|
||||||
Thread::wait(QUEUE_PUT_DELAY);
|
ThisThread::sleep_for(QUEUE_PUT_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ void test_thread(void const *delay) {
|
||||||
if (sem_lock_failed) {
|
if (sem_lock_failed) {
|
||||||
sem_defect = true;
|
sem_defect = true;
|
||||||
}
|
}
|
||||||
Thread::wait(thread_delay);
|
ThisThread::sleep_for(thread_delay);
|
||||||
print_char('.');
|
print_char('.');
|
||||||
sem_counter--;
|
sem_counter--;
|
||||||
change_counter++;
|
change_counter++;
|
||||||
|
|
|
@ -35,7 +35,7 @@ volatile int signal_counter = 0;
|
||||||
void led_thread(void const *argument) {
|
void led_thread(void const *argument) {
|
||||||
while (true) {
|
while (true) {
|
||||||
// Signal flags that are reported as event are automatically cleared.
|
// Signal flags that are reported as event are automatically cleared.
|
||||||
Thread::signal_wait(SIGNAL_SET_VALUE);
|
ThisThread::flags_wait_all(SIGNAL_SET_VALUE);
|
||||||
led = !led;
|
led = !led;
|
||||||
signal_counter++;
|
signal_counter++;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ int main (void) {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread::wait(2 * SIGNAL_HANDLE_DELEY);
|
ThisThread::sleep_for(2 * SIGNAL_HANDLE_DELEY);
|
||||||
thread.signal_set(SIGNAL_SET_VALUE);
|
thread.signal_set(SIGNAL_SET_VALUE);
|
||||||
if (signal_counter == SIGNALS_TO_EMIT) {
|
if (signal_counter == SIGNALS_TO_EMIT) {
|
||||||
printf("Handled %d signals\r\n", signal_counter);
|
printf("Handled %d signals\r\n", signal_counter);
|
||||||
|
|
|
@ -42,5 +42,5 @@ int main(void) {
|
||||||
led_3_timer.start(50);
|
led_3_timer.start(50);
|
||||||
led_4_timer.start(25);
|
led_4_timer.start(25);
|
||||||
|
|
||||||
Thread::wait(osWaitForever);
|
ThisThread::sleep_for(osWaitForever);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ void msd_task(void const *)
|
||||||
|
|
||||||
// try to connect a MSD device
|
// try to connect a MSD device
|
||||||
while(!msd.connect()) {
|
while(!msd.connect()) {
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
if (fs.mount(&msd) != 0) {
|
if (fs.mount(&msd) != 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -46,14 +46,14 @@ void msd_task(void const *)
|
||||||
} else {
|
} else {
|
||||||
printf("FILE == NULL\r\n");
|
printf("FILE == NULL\r\n");
|
||||||
}
|
}
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
printf("again\n");
|
printf("again\n");
|
||||||
// if device disconnected, try to connect again
|
// if device disconnected, try to connect again
|
||||||
while (msd.connected()) {
|
while (msd.connected()) {
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
while (fs.unmount() < 0) {
|
while (fs.unmount() < 0) {
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
printf("unmount\n");
|
printf("unmount\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,6 @@ int main()
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
led=!led;
|
led=!led;
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,14 @@ void mouse_task(void const *) {
|
||||||
while(1) {
|
while(1) {
|
||||||
// try to connect a USB mouse
|
// try to connect a USB mouse
|
||||||
while(!mouse.connect())
|
while(!mouse.connect())
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
|
|
||||||
// when connected, attach handler called on mouse event
|
// when connected, attach handler called on mouse event
|
||||||
mouse.attachEvent(onMouseEvent);
|
mouse.attachEvent(onMouseEvent);
|
||||||
|
|
||||||
// wait until the mouse is disconnected
|
// wait until the mouse is disconnected
|
||||||
while(mouse.connected())
|
while(mouse.connected())
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,6 @@ int main() {
|
||||||
Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4);
|
Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4);
|
||||||
while(1) {
|
while(1) {
|
||||||
led=!led;
|
led=!led;
|
||||||
Thread::wait(500);
|
ThisThread::sleep_for(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "FileHandle.h"
|
#include "FileHandle.h"
|
||||||
#if MBED_CONF_RTOS_PRESENT
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
#include "rtos/Kernel.h"
|
#include "rtos/Kernel.h"
|
||||||
#include "rtos/Thread.h"
|
#include "rtos/ThisThread.h"
|
||||||
using namespace rtos;
|
using namespace rtos;
|
||||||
#else
|
#else
|
||||||
#include "drivers/Timer.h"
|
#include "drivers/Timer.h"
|
||||||
|
@ -83,7 +83,7 @@ int poll(pollfh fhs[], unsigned nfhs, int timeout)
|
||||||
#ifdef MBED_CONF_RTOS_PRESENT
|
#ifdef MBED_CONF_RTOS_PRESENT
|
||||||
// TODO - proper blocking
|
// TODO - proper blocking
|
||||||
// wait for condition variable, wait queue whatever here
|
// wait for condition variable, wait queue whatever here
|
||||||
rtos::Thread::wait(1);
|
rtos::ThisThread::sleep_for(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
|
|
@ -57,7 +57,7 @@ extern "C" {
|
||||||
* @note
|
* @note
|
||||||
* If the RTOS is present, this function always spins to get the exact number of microseconds,
|
* If the RTOS is present, this function always spins to get the exact number of microseconds,
|
||||||
* which potentially affects power (such as preventing deep sleep) and multithread performance.
|
* which potentially affects power (such as preventing deep sleep) and multithread performance.
|
||||||
* You can avoid it by using Thread::wait().
|
* You can avoid it by using ThisThread::sleep_for().
|
||||||
*/
|
*/
|
||||||
void wait(float s);
|
void wait(float s);
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ void wait(float s);
|
||||||
* @note
|
* @note
|
||||||
* If the RTOS is present, this function always spins to get the exact number of microseconds,
|
* If the RTOS is present, this function always spins to get the exact number of microseconds,
|
||||||
* which potentially affects power (such as preventing deep sleep) and multithread performance.
|
* which potentially affects power (such as preventing deep sleep) and multithread performance.
|
||||||
* You can avoid it by using Thread::wait().
|
* You can avoid it by using ThisThread::sleep_for().
|
||||||
*/
|
*/
|
||||||
void wait_ms(int ms);
|
void wait_ms(int ms);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ void wait_us(int us)
|
||||||
if ((us >= 1000) && core_util_are_interrupts_enabled()) {
|
if ((us >= 1000) && core_util_are_interrupts_enabled()) {
|
||||||
// Use the RTOS to wait for millisecond delays if possible
|
// Use the RTOS to wait for millisecond delays if possible
|
||||||
sleep_manager_lock_deep_sleep();
|
sleep_manager_lock_deep_sleep();
|
||||||
Thread::wait((uint32_t)us / 1000);
|
rtos::ThisThread::sleep_for((uint32_t)us / 1000);
|
||||||
sleep_manager_unlock_deep_sleep();
|
sleep_manager_unlock_deep_sleep();
|
||||||
}
|
}
|
||||||
// Use busy waiting for sub-millisecond delays, or for the whole
|
// Use busy waiting for sub-millisecond delays, or for the whole
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
#include "rtos/ConditionVariable.h"
|
#include "rtos/ConditionVariable.h"
|
||||||
#include "rtos/Kernel.h"
|
#include "rtos/Kernel.h"
|
||||||
#include "rtos/Thread.h"
|
#include "rtos/ThisThread.h"
|
||||||
|
|
||||||
#include "mbed_error.h"
|
#include "mbed_error.h"
|
||||||
#include "mbed_assert.h"
|
#include "mbed_assert.h"
|
||||||
|
@ -46,7 +46,7 @@ void ConditionVariable::wait()
|
||||||
bool ConditionVariable::wait_for(uint32_t millisec)
|
bool ConditionVariable::wait_for(uint32_t millisec)
|
||||||
{
|
{
|
||||||
Waiter current_thread;
|
Waiter current_thread;
|
||||||
MBED_ASSERT(_mutex.get_owner() == Thread::gettid());
|
MBED_ASSERT(_mutex.get_owner() == ThisThread::get_id());
|
||||||
MBED_ASSERT(_mutex._count == 1);
|
MBED_ASSERT(_mutex._count == 1);
|
||||||
_add_wait_list(&_wait_list, ¤t_thread);
|
_add_wait_list(&_wait_list, ¤t_thread);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ bool ConditionVariable::wait_until(uint64_t millisec)
|
||||||
|
|
||||||
void ConditionVariable::notify_one()
|
void ConditionVariable::notify_one()
|
||||||
{
|
{
|
||||||
MBED_ASSERT(_mutex.get_owner() == Thread::gettid());
|
MBED_ASSERT(_mutex.get_owner() == ThisThread::get_id());
|
||||||
if (_wait_list != NULL) {
|
if (_wait_list != NULL) {
|
||||||
_wait_list->sem.release();
|
_wait_list->sem.release();
|
||||||
_remove_wait_list(&_wait_list, _wait_list);
|
_remove_wait_list(&_wait_list, _wait_list);
|
||||||
|
@ -93,7 +93,7 @@ void ConditionVariable::notify_one()
|
||||||
|
|
||||||
void ConditionVariable::notify_all()
|
void ConditionVariable::notify_all()
|
||||||
{
|
{
|
||||||
MBED_ASSERT(_mutex.get_owner() == Thread::gettid());
|
MBED_ASSERT(_mutex.get_owner() == ThisThread::get_id());
|
||||||
while (_wait_list != NULL) {
|
while (_wait_list != NULL) {
|
||||||
_wait_list->sem.release();
|
_wait_list->sem.release();
|
||||||
_remove_wait_list(&_wait_list, _wait_list);
|
_remove_wait_list(&_wait_list, _wait_list);
|
||||||
|
|
Loading…
Reference in New Issue