📄 sys_arch.h
字号:
/*
*********************************************************************************************************
* lwIP TCP/IP Stack
* port for uC/OS-II RTOS on TIC6711 DSK
*
* File : sys_arch.h
* By : ZengMing @ DEP,Tsinghua University,Beijing,China
* Reference: YangYe's source code for SkyEye project
*********************************************************************************************************
*/
/**
* 由于lwip实现临界区保护的方法与ucos一致,所以只需直接定义移植说明一文提出的那几个用于临界保护的宏即
* 可实现LwIP的临界保护机制,不需要再实现sys_arch_protect()和sys_arch_unprotect()函数了。
*/
#ifndef __SYS_ARCH_H__
#define __SYS_ARCH_H__
#include "os_cpu.h"
#include "os_cfg.h"
#include "ucos_ii.h"
#define LWIP_STK_SIZE 2600 //by 千杯不醉
//和tcp/ip相关任务的起始优先级,在本例中优先级可
//以从(5-9).注意tcpip_thread在所有tcp/ip相关进程中应该是优先级最高的.在本例中就是优先级5
//如果用户需要创建和tcp/ip无关任务,如uart任务等,
//不要使用5-9的优先级
#define LWIP_TASK_MAX 1 //max number of lwip tasks
#define LWIP_START_PRIO 5 //first prio of lwip tasks
//!!!! so priority of lwip tasks is from 5-9
#define SYS_MBOX_NULL (void*)0
#define SYS_SEM_NULL (void*)0
/*
* 最大队列数目,在这里定义这个宏是为了对消息数组分配内存
*
*/
#define MAX_QUEUES 4
#define MAX_QUEUE_ENTRIES 8
//lwip中的mbox相当于ucos的消息队列
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;//the structure defined above
typedef INT8U sys_thread_t;
/* Critical Region Protection */
/* These functions must be implemented in the sys_arch.c file.
In some implementations they can provide a more light-weight protection
mechanism than using semaphores. Otherwise semaphores can be used for
implementation */
/** SYS_ARCH_DECL_PROTECT
* declare a protection variable. This macro will default to defining a variable of
* type sys_prot_t. If a particular port needs a different implementation, then
* this macro may be defined in sys_arch.h.
*/
#define SYS_ARCH_DECL_PROTECT(lev) u32_t lev = 0;
/** SYS_ARCH_PROTECT
* Perform a "fast" protect. This could be implemented by
* disabling interrupts for an embedded system or by using a semaphore or
* mutex. The implementation should allow calling SYS_ARCH_PROTECT when
* already protected. The old protection level is returned in the variable
* "lev". This macro will default to calling the sys_arch_protect() function
* which should be implemented in sys_arch.c. If a particular port needs a
* different implementation, then this macro may be defined in sys_arch.h
*/
#define SYS_ARCH_PROTECT(lev) OS_ENTER_CRITICAL()
/** SYS_ARCH_UNPROTECT
* Perform a "fast" set of the protection level to "lev". This could be
* implemented by setting the interrupt level to "lev" within the MACRO or by
* using a semaphore or mutex. This macro will default to calling the
* sys_arch_unprotect() function which should be implemented in
* sys_arch.c. If a particular port needs a different implementation, then
* this macro may be defined in sys_arch.h
*/
#define SYS_ARCH_UNPROTECT(lev) OS_EXIT_CRITICAL()
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -