lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: [lwip-users] lwIP and uC/OS-II


From: hnclcj
Subject: Re: Re: [lwip-users] lwIP and uC/OS-II
Date: Thu, 1 Jul 2010 00:34:11 +0800

 
 
 
2010-07-01
#ifndef __SYS_ARCH_H__
#define __SYS_ARCH_H__
#include    "os_cpu.h"
#include    "os_cfg.h"
#include    "ucos_ii.h"
#define LWIP_STK_SIZE                  1200
#define LWIP_TASK_MAX                  5
#define LWIP_START_PRIO                5     //so priority of lwip tasks is from 5-9
#define MAX_QUEUES                     35    // 
#define MAX_QUEUE_ENTRIES              35    // number of mboxs
#define SYS_MBOX_NULL                  (void*)0
#define SYS_SEM_NULL                   (void*)0
typedef struct
{
    OS_EVENT *pQ;
    void     *pvQEntries[MAX_QUEUE_ENTRIES];
} TQ_DESCR,  *PQ_DESCR;
typedef OS_EVENT   *sys_sem_t;
typedef PQ_DESCR    sys_mbox_t;
typedef OS_CPU_SR   sys_prot_t;
typedef INT8U       sys_thread_t;
int join_source_group  (int sd, INT32U grpaddr, INT32U srcaddr, INT32U iaddr);
int leave_source_group (int sd, INT32U grpaddr, INT32U srcaddr, INT32U iaddr);
#endif
 
 

hnclcj

发件人: Marco
发送时间: 2010-06-30  23:43:02
收件人: Mailing list for lwIP users
抄送:
主题: Re: [lwip-users] lwIP and uC/OS-II
Thanks for the quick answer and sending me the port. Is there any
special configuration options for lwIP that goes along with this port?
On Wed, Jun 30, 2010 at 3:42 PM, hnclcj <address@hidden> wrote:
>
> /*******************************************************************************************************/
> const  void * const         pvNullPointer = NULL;
> static OS_MEM              *pQueueMem;
> static char                 pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR)];
> static u8_t                 curr_prio_offset;
> static struct sys_timeouts  lwip_timeouts[LWIP_TASK_MAX];
>        struct sys_timeouts  null_timeouts;
>        OS_STK               LWIP_TASK_STK[LWIP_TASK_MAX][LWIP_STK_SIZE];
> /*******************************************************************************************************/
> sys_mbox_t sys_mbox_new (int size)
> {
>     u8_t      err;
>     PQ_DESCR  pQDesc;
>     size   = size;
>     pQDesc = (PQ_DESCR)OSMemGet(pQueueMem, &err);
>     if (err == OS_NO_ERR) {
>         pQDesc->pQ = OSQCreate(&(pQDesc->pvQEntries[0]), MAX_QUEUE_ENTRIES);
>         if (pQDesc->pQ != NULL) {
>             return pQDesc;
>         }
>     }
>     return SYS_MBOX_NULL;
> }
> /*******************************************************************************************************/
> void sys_mbox_free (sys_mbox_t mbox)
> {
>     u8_t      err;
>     u8_t      cnt;
> for (cnt=0; cnt<0xfe; cnt++) {
>         OSQFlush(mbox->pQ);
>         OSQDel(mbox->pQ, OS_DEL_NO_PEND, &err);
>         if (err == OS_ERR_NONE) {
>             break;
>         } else {
>             OSTimeDly(1);
>         }
> }
>     OSMemPut(pQueueMem, mbox);
> }
> /*******************************************************************************************************/
> void sys_mbox_post (sys_mbox_t mbox, void *msg)
> {
>     if (msg == NULL) {
>         msg = (void *)&pvNullPointer;
>     }
>     (void)OSQPost(mbox->pQ, msg);
> }
> /*******************************************************************************************************/
> err_t      sys_mbox_trypost       (sys_mbox_t mbox, void *msg)
> {
>     u8_t err;
>     if (msg == NULL) {
>         msg = (void *)&pvNullPointer;
>     }
>     err = OSQPost(mbox->pQ, msg);
>     if (err == OS_NO_ERR) {
>         return ERR_OK;
>     } else {
>         return !ERR_OK;
>     }
> }
> /*******************************************************************************************************/
> u32_t   sys_arch_mbox_fetch (sys_mbox_t mbox, void **msg, u32_t timeout)
> {
> /*    u32_t  ucos_timeout;
>     void  *temp;
>     u8_t   err;
>     ucos_timeout = 0;
>     if(timeout != 0) {
>         ucos_timeout = (timeout * OS_TICKS_PER_SEC)/1000;
>         if(ucos_timeout < 1)
>             ucos_timeout = 1;
>          else if (ucos_timeout > 65535)
>             ucos_timeout = 65535;
>     }
>     temp    = OSQPend(mbox->pQ, ucos_timeout, &err);
>     timeout = SYS_ARCH_TIMEOUT;
>     *msg    = NULL;
>     if (err == OS_NO_ERR) {
>         timeout = !SYS_ARCH_TIMEOUT;
>         if (msg != NULL) {
>             if (temp != (void *)&pvNullPointer) {
>                 *msg = temp;
>             }
>         }
>     }
>     return timeout;
> */
>     u8_t   err;
>     u32_t  ucos_timeout;
>     void  *temp;
>     ucos_timeout = 0;
>     if(timeout != 0) {
>         ucos_timeout = (timeout * OS_TICKS_PER_SEC)/1000;
>         if(ucos_timeout < 1)
>             ucos_timeout = 1;
>          else if (ucos_timeout > 65535)
>             ucos_timeout = 65535;
>     }
>     temp = OSQPend(mbox->pQ, ucos_timeout, &err);
>     if (msg != NULL) {
>         if (temp == (void *)&pvNullPointer) {
>             *msg = NULL;
>         } else {
>             *msg = temp;
>         }
>     }
>     if ( err == OS_TIMEOUT ) {
>         timeout = SYS_ARCH_TIMEOUT;//0;
>     } else {
>         timeout = !SYS_ARCH_TIMEOUT;
>     }
>     return timeout;
> }
> /*******************************************************************************************************/
> u32_t      sys_arch_mbox_tryfetch (sys_mbox_t mbox, void **msg)
> {
>     void  *temp;
>     u32_t  result;
>     u8_t   err;
>     temp   = OSQAccept(mbox->pQ, &err);
>     *msg   = NULL;
>     result = SYS_MBOX_EMPTY;
>     if ( err == OS_NO_ERR ) {
> //        if (temp != (void *)&pvNullPointer) {
>             *msg    = temp;
>              result = !SYS_MBOX_EMPTY;
> //        }
>     }
>     return result;
> }
> /*******************************************************************************************************/
> sys_sem_t sys_sem_new (u8_t count)
> {
>     sys_sem_t pSem;
>     pSem = OSSemCreate(count);
>     return pSem;
> }
> /*******************************************************************************************************/
> void sys_sem_signal(sys_sem_t sem)
> {
>     OSSemPost(sem);
> }
> /*******************************************************************************************************/
> u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
> {
>     u8_t err;
>     u32_t ucos_timeout;
>     ucos_timeout = 0;
>     if(timeout != 0) {
>         ucos_timeout = (timeout * OS_TICKS_PER_SEC)/1000;
>         if(ucos_timeout < 1)
>             ucos_timeout = 1;
>         else if(ucos_timeout > 65535)
>         ucos_timeout = 65535;
>     }
>     OSSemPend (sem, ucos_timeout, &err);
>     if (err == OS_TIMEOUT) {
>         return SYS_ARCH_TIMEOUT;
>     } else {
>         return !SYS_ARCH_TIMEOUT;
>     }
> }
> /*******************************************************************************************************/
> void sys_sem_free(sys_sem_t sem)
> {
>     u8_t      err;
>     u8_t      cnt;
>     for (cnt=0; cnt<0xfe; cnt++) {
>         OSSemDel(sem, OS_DEL_NO_PEND, &err);
>         if (err == OS_ERR_NONE) {
>             break;
>         } else {
>             OSTimeDly(1);
>         }
> }
> }
> /*******************************************************************************************************/
> void sys_init(void)
> {
>     u8_t i;
>     u8_t err;
>     pQueueMem        = OSMemCreate((void*)pcQueueMemoryPool, MAX_QUEUES, sizeof(TQ_DESCR), &err);
>     curr_prio_offset = 0;
>     for (i=0; i<LWIP_TASK_MAX; i++){
>         lwip_timeouts[i].next = NULL;
>     }
> }
> /*******************************************************************************************************/
> struct sys_timeouts *sys_arch_timeouts (void)
> {
>     u8_t   curr_prio;
>     s16_t  offset;//err,
>     OS_TCB curr_task_pcb;
>     null_timeouts.next = NULL;
>     OSTaskQuery(OS_PRIO_SELF, &curr_task_pcb);
>     curr_prio = curr_task_pcb.OSTCBPrio;
>     offset    = curr_prio - LWIP_START_PRIO;
>     if (offset < 0 || offset >= LWIP_TASK_MAX) {
>         return &null_timeouts;
>     }
>     return &lwip_timeouts[offset];
> }
> /*******************************************************************************************************/
> sys_thread_t sys_thread_new (char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio)
> {
>     name      = name;
>     stacksize = stacksize;
>     if (curr_prio_offset < LWIP_TASK_MAX) {
>         OSTaskCreate(thread, (void *)arg, &LWIP_TASK_STK[curr_prio_offset][LWIP_STK_SIZE-1],LWIP_START_PRIO+curr_prio_offset );
>         curr_prio_offset++;
>     } else {
>        // PRINT(" lwip task prio out of range ! error! ");
>     }
>     return (LWIP_START_PRIO+curr_prio_offset);
> }
> /*******************************************************************************************************/
> sys_prot_t sys_arch_protect(void)
> {
>     sys_prot_t cpu_sr;
>     OS_ENTER_CRITICAL();
> return cpu_sr;
> }
> /*******************************************************************************************************/
> void sys_arch_unprotect(sys_prot_t pval)
> {
> sys_prot_t cpu_sr;
>     cpu_sr = pval;
> OS_EXIT_CRITICAL();
> }
>
> 2010-06-30
> ________________________________
> hnclcj
> ________________________________
> 发件人: Marco
> 发送时间: 2010-06-30  20:18:11
> 收件人: lwip-users
> 抄送:
> 主题: [lwip-users] lwIP and uC/OS-II
> Hi all,
> I am new to lwIP. I am deploying uC/OS-II in my project and was
> wondering, if there is a recent port for lwIP to uC/OS-II.
> On the download page of lwIP there is a link to Guido Konrad's
> uC/OS-II port, but the link is dead...
> Any hints and directions for recent uC/OS-II ports are highly appreciated!
> Thanks a lot in advance!
> --
> Best regards,
>  Marco
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users
.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]