Skip to content

Stop lwIP using us_ticker #6653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions features/FEATURE_LWIP/lwip-interface/lwip-sys/arch/lwip_sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
/* mbed includes */
#include "mbed_error.h"
#include "mbed_interface.h"
#include "us_ticker_api.h"
#include "mbed_rtos_storage.h"

/* lwIP includes. */
Expand Down Expand Up @@ -237,7 +236,7 @@ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) {
* of milliseconds until received.
*---------------------------------------------------------------------------*/
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) {
uint32_t start = us_ticker_read();
uint32_t start = osKernelGetTickCount();
uint32_t flags = osEventFlagsWait(mbox->id, SYS_MBOX_FETCH_EVENT,
osFlagsWaitAny | osFlagsNoClear, (timeout ? timeout : osWaitForever));
if ((flags & osFlagsError) || !(flags & SYS_MBOX_FETCH_EVENT))
Expand All @@ -254,7 +253,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) {
osEventFlagsClear(mbox->id, SYS_MBOX_FETCH_EVENT);

osKernelRestoreLock(state);
return (us_ticker_read() - start) / 1000;
return osKernelGetTickCount() - start;
}

/*---------------------------------------------------------------------------*
Expand Down Expand Up @@ -339,12 +338,12 @@ err_t sys_sem_new(sys_sem_t *sem, u8_t count) {
* u32_t -- Time elapsed or SYS_ARCH_TIMEOUT.
*---------------------------------------------------------------------------*/
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) {
u32_t start = us_ticker_read();
u32_t start = osKernelGetTickCount();

if (osSemaphoreAcquire(sem->id, (timeout != 0)?(timeout):(osWaitForever)) != osOK)
return SYS_ARCH_TIMEOUT;

return (us_ticker_read() - start) / 1000;
return osKernelGetTickCount() - start;
}

/*---------------------------------------------------------------------------*
Expand Down Expand Up @@ -414,7 +413,6 @@ osMutexAttr_t lwip_sys_mutex_attr;
mbed_rtos_storage_mutex_t lwip_sys_mutex_data;

void sys_init(void) {
us_ticker_read(); // Init sys tick
lwip_sys_mutex_attr.name = "lwip_sys_mutex";
lwip_sys_mutex_attr.cb_mem = &lwip_sys_mutex_data;
lwip_sys_mutex_attr.cb_size = sizeof(lwip_sys_mutex_data);
Expand All @@ -430,9 +428,7 @@ void sys_init(void) {
* Used by PPP as a timestamp-ish value
*---------------------------------------------------------------------------*/
u32_t sys_jiffies(void) {
static u32_t jiffies = 0;
jiffies += 1 + (us_ticker_read()/10000);
return jiffies;
return osKernelGetTickCount();
}

/*---------------------------------------------------------------------------*
Expand Down Expand Up @@ -477,7 +473,7 @@ void sys_arch_unprotect(sys_prot_t p) {
}

u32_t sys_now(void) {
return us_ticker_read() / 1000;
return osKernelGetTickCount();
}

void sys_msleep(u32_t ms) {
Expand Down