LWIP UCOS 移植步骤记录

  • Post author:
  • Post category:其他


今年5, 6月份的时候, 将LWIP移植到了ucos平台上, 把之前总结的移植的大致步骤记录在这里. 供参考和回忆.

当时的移植工作是基于ppp new 的branch, 解压后在doc的目录下的sys_arch.txt中, 有一点关于porting的工作的介绍.

1.主要是os相关的一些函数类和类型的处理. 在sys_arch.txt中有比较详细的介绍.

The general idea is that porting lwIP to new architectures requires only

small changes to a few header files and a new sys_arch implementation.

It is also possible to do a sys_arch implementation that does not rely on

any underlying operating system.

The sys_arch provides semaphores and mailboxes to lwIP.


有一些函数是必须实现的.

The following functions must be implemented by the sys_arch:

– void sys_init(void)

Is called to initialize the sys_arch layer.

在实际的实现中就是初始化了lwip_timeouts数组.

struct sys_timeouts lwip_timeouts[OS_LOWEST_PRIO+1];

– err_t sys_sem_new(sys_sem_t *sem, u8_t count)

创建sem

Creates a new semaphore. The semaphore is allocated to the memory that ‘sem’

points to (which can be both a pointer or the actual OS structure).

The “count” argument specifies the initial state of the semaphore (which is

either 0 or 1).

If the semaphore has been created, ERR_OK should be returned. Returning any

other error will provide a hint what went wrong, but except for assertions,

no real error handling is implemented.

– void sys_sem_free(sys_sem_t *sem)

释放sem

Deallocates a semaphore.

– void sys_sem_signal(sys_sem_t *sem)

其实就是sem的count加1

Signals a semaphore.

– u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)

等待其他地方sem的signal, 但是有一些特殊的要求.

Blocks the thread while waiting for the semaphore to be

signaled. If the “timeout” argument is non-zero, the thread should

only be blocked for the specified time (measured in

milliseconds). If the “timeout” argument is zero, the thread should be

blocked until the semaphore is signalled.

If the timeout argument is non-zero, the return value is the number of

milliseconds spent waiting for the semaphore to be signaled. If the

semaphore wasn’t signaled within the specified time, the return value is

SYS_ARCH_TIMEOUT. If the thre



版权声明:本文为jackjones_008原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。