完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
如标题所示,移植在UCOSSIII系统下的LWIP性能好差,非常不稳定。打开原则的实验网页,有时候图片显示不了,控制LED 蜂鸣器的时候要点击发送好几次才可以.不够在原子哥的UCOSSII的性能好。[C] 纯文本查看 复制代码
/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels <adam@sics.se> * *//* Porting by Michael Vysotsky <michaelvy@hotmail.com> August 2011 */#define SYS_ARCH_GLOBALS/* lwIP includes. */#include "lwip/debug.h"#include "lwip/def.h"#include "lwip/lwip_sys.h"#include "lwip/mem.h"#include "includes.h"#include "delay.h"#include "arch/sys_arch.h"#include "malloc.h"#include "os_cfg_app.h"/*----------------------------------------------------------------------------*//* DEFINITIONS *//*----------------------------------------------------------------------------*/#define LWIP_ARCH_TICK_PER_MS 1000/OS_CFG_TICK_RATE_HZ /*----------------------------------------------------------------------------*//* VARIABLES *//*----------------------------------------------------------------------------*/static OS_MEM StackMem; //存储分区控制块const void * const pvNullPointer = (mem_ptr_t*)0xffffffff;__align(4) CPU_STK LwIP_Task_Stk[LWIP_TASK_MAX*LWIP_STK_SIZE]; //LWIP进程栈 8*256=2048 __align(4) CPU_INT08U LwIP_task_priopity_stask[LWIP_TASK_MAX]; //LWIP任务进程优先级 最大8个进程OS_TCB LwIP_task_TCB[LWIP_TASK_MAX]; //LWIP任务控制块 8 /*----------------------------------------------------------------------------*//* PROTOTYPES *//*----------------------------------------------------------------------------*//*--------------------Creates an empty mailbox.-------------------------------*/ err_t sys_mbox_new( sys_mbox_t *mbox, int size){ OS_ERR ucErr; OSQCreate(mbox,"LWIP quiue", size, &ucErr); LWIP_ASSERT( "OSQCreate ", ucErr == OS_ERR_NONE ); if( ucErr == OS_ERR_NONE){ return 0; } return -1;}/*-----------------------------------------------------------------------------------*//* Deallocates a mailbox. If there are messages still present in the如果当邮箱被释放 仍有消息存在邮箱中 mailbox when the mailbox is deallocated, it is an indication of a 将会有一个处理错误在LWIP中 programming error in lwIP and the developer should be notified. 开发者应该注意*/void sys_mbox_free(sys_mbox_t * mbox){ OS_ERR ucErr; LWIP_ASSERT( "sys_mbox_free ", mbox != SYS_MBOX_NULL ); OSQFlush(mbox,& ucErr); OSQDel(mbox, OS_OPT_DEL_ALWAYS, &ucErr); LWIP_ASSERT( "OSQDel ", ucErr == OS_ERR_NONE );}/*----------------------------------------------------------------------------------- * Posts the "msg" to the mailbox. */void sys_mbox_post(sys_mbox_t *mbox, void *msg){ OS_ERR ucErr; CPU_INT08U i=0; if( msg == NULL ) msg = (void*)&pvNullPointer; /* try 10 times */ while(i<10){ OSQPost(mbox, msg,0,OS_OPT_POST_ALL,&ucErr); if(ucErr == OS_ERR_NONE) break; i++; OSTimeDly(5,OS_OPT_TIME_DLY,&ucErr); } LWIP_ASSERT( "sys_mbox_post error!n", i !=10 ); }/* Try to post the "msg" to the mailbox. */err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg){ OS_ERR ucErr; if(msg == NULL ) msg = (void*)&pvNullPointer; OSQPost(mbox, msg,0,OS_OPT_POST_ALL,&ucErr); if(ucErr != OS_ERR_NONE){ return ERR_MEM; } return ERR_OK;}/*-----------------------------------------------------------------------------------*//* Blocks the thread until a message arrives in the mailbox, but does not block the thread longer than "timeout" milliseconds (similar to the sys_arch_sem_wait() function). The "msg" argument is a result parameter that is set by the function (i.e., by doing "*msg = ptr"). The "msg" parameter maybe NULL to indicate that the message should be dropped. The return values are the same as for the sys_arch_sem_wait() function: Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a timeout. Note that a function with a similar name, sys_mbox_fetch(), is implemented by lwIP. 等待消息达到邮箱*///等待邮箱中的消息//*mbox:消息邮箱//*msg:消息//timeout:超时时间,如果timeout为0的话,就一直等待//返回值:当timeout不为0时如果成功的话就返回等待的时间,//失败的话就返回超时SYS_ARCH_TIMEOUTu32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout){ OS_ERRucErr; OS_MSG_SIZE msg_size; CPU_TS ucos_timeout; CPU_TS in_timeout = timeout/LWIP_ARCH_TICK_PER_MS; if(timeout && in_timeout == 0) in_timeout = 1; *msg = OSQPend (mbox, //消息队列 in_timeout, //等待时间 OS_OPT_PEND_BLOCKING, //等待选项 &msg_size, //消息大小 &ucos_timeout, //获取时间戳 &ucErr); //错误代码 if ( ucErr == OS_ERR_TIMEOUT ) ucos_timeout = SYS_ARCH_TIMEOUT; return ucos_timeout; }/** * Check if an mbox is valid/allocated: 检查一个消息邮箱是否有效 * @param sys_mbox_t *mbox pointer mail box * @return 1 for valid, 0 for invalid */ int sys_mbox_valid(sys_mbox_t *mbox){ if(mbox->NamePtr) return (strcmp(mbox->NamePtr,"?Q"))? 1:0; else return 0;}/** * Set an mbox invalid so that sys_mbox_valid returns 0 */ void sys_mbox_set_invalid(sys_mbox_t *mbox){ if(sys_mbox_valid(mbox)) sys_mbox_free(mbox);}/* 创建一个信号量 * Creates and returns a new semaphore. The "count" argument specifies * the initial state of the semaphore. TBD finish and test */err_t sys_sem_new(sys_sem_t * sem, u8_t count){ OS_ERRucErr; OSSemCreate (sem,"LWIP Sem",count,&ucErr); if(ucErr != OS_ERR_NONE ){ LWIP_ASSERT("OSSemCreate ",ucErr == OS_ERR_NONE ); return -1; } return 0;}/* 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 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 thread didn't have to wait for the semaphore (i.e., it was already signaled), the function may return zero. Notice that lwIP implements a function with a similar name, sys_sem_wait(), that uses the sys_arch_sem_wait() function. 等待一个信号量*/u32_tsys_arch_sem_wait(sys_sem_t *sem, u32_t timeout){ OS_ERRucErr; CPU_TS ucos_timeout; CPU_TS in_timeout = timeout/LWIP_ARCH_TICK_PER_MS; //LWIP_ARCH_TICK_PER_MS=1000/OS_CFG_TICK_RATE_HZ=1 if(timeout && in_timeout == 0) in_timeout = 1; OSSemPend (sem, //信号量 in_timeout, //等待时间 OS_OPT_PEND_BLOCKING, //等待选项 &ucos_timeout, //获取时间戳 &ucErr); //错误代码 /* only when timeout! */ if(ucErr == OS_ERR_TIMEOUT) ucos_timeout = SYS_ARCH_TIMEOUT; return ucos_timeout;}/* * Signals a semaphore 发送一个信号量 */voidsys_sem_signal(sys_sem_t *sem){ OS_ERRucErr; OSSemPost(sem,OS_OPT_POST_ALL,&ucErr); LWIP_ASSERT("OSSemPost ",ucErr == OS_ERR_NONE ); }/* * Deallocates a semaphore 释放一个信号量 */voidsys_sem_free(sys_sem_t *sem){ OS_ERR ucErr; OSSemDel(sem, OS_OPT_DEL_ALWAYS, &ucErr ); LWIP_ASSERT( "OSSemDel ", ucErr == OS_ERR_NONE );}//查询一个信号量的状态,无效或有效int sys_sem_valid(sys_sem_t *sem){ if(sem->NamePtr) return (strcmp(sem->NamePtr,"?SEM"))? 1:0; else return 0;}/** Set a semaphore invalid so that sys_sem_valid returns 0 设置一个信号量无效*/void sys_sem_set_invalid(sys_sem_t *sem){ if(sys_sem_valid(sem)) sys_sem_free(sem);}/*-----------------------------------------------------------------------------------*//* memory interface *//*-----------------------------------------------------------------------------------*//* * Initialize sys arch */voidsys_init(void){ OS_ERR ucErr; memset(LwIP_task_priopity_stask,0,sizeof(LwIP_task_priopity_stask)); /* init mem used by sys_mbox_t, use ucosII functions */ //为LWIP创建8个任务(进程) OSMemCreate(&StackMem, //存储控制块 "LWIP TASK STK", //存储块名字 (void*)LwIP_Task_Stk, //存储区域的首地址 LWIP_TASK_MAX, //存储块的个数 8 LWIP_STK_SIZE*sizeof(CPU_STK), //存储块的大小,4字节为一个单位 256*8=2048 &ucErr); LWIP_ASSERT( "sys_init: failed OSMemCreate STK", ucErr == OS_ERR_NONE );}/*-----------------------------------------------------------------------------------*//*-----------------------------------------------------------------------------------*/// TBD /*-----------------------------------------------------------------------------------*//* 此函数的功能是创建一个新的进程并启动进程 Starts a new thread with priority "prio" that will begin its execution in the function "thread()". The "arg" argument will be passed as an argument to the thread() function. The id of the new thread is returned. Both the id and the priority are system dependent.*/sys_thread_t sys_thread_new(const char *name, //进程名字 "tcpip_thread" lwip_thread_fn thread, //进程任务 tcpip_thread void *arg, //进程任务参数 NULL int stacksize, //进程任务堆栈大小 1024 int prio) //进程任务优先级 { int i; OS_ERR ucErr; //返回的错误参数 CPU_INT08U ubPrio = LWIP_TASK_START_PRIO; //3 CPU_STK * task_stk ; //任务堆栈 int tsk_prio ; //任务优先级arg = arg; if(prio){ ubPrio +=(prio-1); for(i=0; i 上面是sys_arch.c文件[C] 纯文本查看 复制代码 #ifndef __LWIPOPTS_H__#define __LWIPOPTS_H__#include 哪位大哥帮忙看看,是哪里问题?或者是怎样配置才能达到最佳性能 |
|
相关推荐
2个回答
|
|
上面有个地方写错了,是"打开原子的实验网页"
|
|
|
|
UCOSIII我们也移植过,但是出现不稳定等原因,本来说是要修改的,但是一直忙也就给耽误了,后面找个时间移植一下UCOSIII+LWIP的
|
|
|
|
只有小组成员才能发言,加入小组>>
如何使用STM32+nrf24l01架构把有线USB设备无线化?
2549 浏览 7 评论
请问能利用51单片机和nRF24L01模块实现实时语音无线传输吗?
2333 浏览 5 评论
3165 浏览 3 评论
2806 浏览 8 评论
为什么ucosii上移植lwip后系统进入了HardFault_Handler?
2765 浏览 4 评论
请教各位大咖:有没有接收频率32M左右的芯片推荐的?先感谢啦!
612浏览 1评论
859浏览 0评论
974浏览 0评论
626浏览 0评论
453浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 19:05 , Processed in 1.158891 second(s), Total 80, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号