⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sps.h

📁 由smsc公司改进的lwip2.1.1基于嵌入式系统的TCP/ip协议栈
💻 H
📖 第 1 页 / 共 5 页
字号:

/*****************************************************************************
* FUNCTION: Task_Allocate
* DESCRIPTION: 
*    Allocates a task structure. This must be called on a task before it 
*    can be scheduled.
* PARAMETERS:
*    priority, This decides the order with which task functions are called. 
*              When more than one task is ready to run, the tasks with higher
*              priority(higher value) are run first. The priority value
*              should never be set higher than TASK_MANAGER_HIGHEST_PRIORITY.
*    taskFunction, pointer to the function that will be called.
*    taskParameter, parameters that will be passed to the taskFunction
* RETURNS:
*    a pointer to the allocated TASK structure.
*    or NULL if a TASK structure could not be allocated.
* NOTE:
*    Set TASK_COUNT to the maximum TASK structures that will need to be allocated.
*****************************************************************************/
struct TASK * Task_Allocate(
	u8_t priority, TASK_FUNCTION taskFunction, void * taskParameter);


/*****************************************************************************
* FUNCTION: Task_Free
* DESCRIPTION:
*    Frees a TASK structure.
*****************************************************************************/
void Task_Free(struct TASK * task);

	
/*****************************************************************************
* FUNCTION: Task_SetParameter
* DESCRIPTION:
*    Reassignes the parameter of the task. 
*****************************************************************************/
void Task_SetParameter(struct TASK * task, void * taskParameter);


/*****************************************************************************
* FUNCTION: Task_SetAlwaysOnInterruptActivationList
* DESCRIPTION:
*    Sets the mAlwaysOnInterruptActivationList variable of the task. 
*****************************************************************************/
void Task_SetAlwaysOnInterruptActivationList(struct TASK * task, u8_t val);


/*****************************************************************************
* MACRO: Task_IsIdle
* DESCRIPTION:
*    Returns non-zero if the task is idle (not scheduled).
*    Returns zero if the task is not idle (is scheduled).
*****************************************************************************/
int Task_IsIdle(struct TASK * task);


/*****************************************************************************
* FUNCTION: TaskManager_CancelTask:
* DESCRIPTION: Cancels a task that was previously scheduled
*    but not yet called. This function has the same single threaded
*    requirements as the scheduler functions. 
*****************************************************************************/
void TaskManager_CancelTask(struct TASK * task);


/*****************************************************************************
* FUNCTION: TaskManager_ScheduleAsSoonAsPossible
* DESCRIPTION:  
*    Schedules a task to be run as soon as possible
*****************************************************************************/
void TaskManager_ScheduleAsSoonAsPossible(struct TASK * task);


/*****************************************************************************
* FUNCTION: TaskManager_ScheduleByTimer
* DESCRIPTION:
*    Schedules a task to be run after a given number of milliSeconds
*****************************************************************************/
void TaskManager_ScheduleByTimer(struct TASK * task, u32_t milliSeconds);


/*****************************************************************************
* FUNCTION: TaskManager_ScheduleByInterruptActivation
* DESCRIPTION: 
*    Prepares a task for an interrupt activation where the
*    interrupt will call TaskManager_InterruptActivation
* NOTE: This function name is deprecated, use
*    TaskManager_ScheduleBySignalActivation instead
*****************************************************************************/
void TaskManager_ScheduleByInterruptActivation(struct TASK * task);
#define TaskManager_ScheduleBySignalActivation TaskManager_ScheduleByInterruptActivation


/*****************************************************************************
* FUNCTION: TaskManager_InterruptActivation
* DESCRIPTION: 
*    This function can be called from an interrupt sub routine
*    to activate a task that was previously scheduled with
*    TaskManager_ScheduleByInterruptActivation
* NOTE: This function name is deprecated, use
*    TaskManager_SignalActivation instead
*****************************************************************************/
void TaskManager_InterruptActivation(struct TASK * task);
#define TaskManager_SignalActivation TaskManager_InterruptActivation


/*****************************************************************************
* FUNCTION: PacketBuffer_GetThisLength
* DESCRIPTION:
*    Gets the length of this packetBuffer
*****************************************************************************/
u16_t PacketBuffer_GetThisLength(struct PACKET_BUFFER * packetBuffer);


/*****************************************************************************
* FUNCTION: PacketBuffer_GetTotalLength
* DESCRIPTION:
*    Gets the length of the packet buffer chain
*****************************************************************************/
u32_t PacketBuffer_GetTotalLength(struct PACKET_BUFFER * packetBuffer);


/*****************************************************************************
* FUNCTION: PacketBuffer_GetNextPointer
* DESCRIPTION:
*    Gets the pointer to the next PACKET_BUFFER in the chain
*****************************************************************************/
struct PACKET_BUFFER * PacketBuffer_GetNextPointer(struct PACKET_BUFFER * packetBuffer);


/*****************************************************************************
* FUNCTION: PacketBuffer_SetThisLength
* DESCRIPTION:
*    Sets the thisLength field of the packetBuffer
*****************************************************************************/
void PacketBuffer_SetThisLength(struct PACKET_BUFFER * packetBuffer, u16_t thisLength);


/*****************************************************************************
* FUNCTION: PacketBuffer_SetTotalLength
* DESCRIPTION:
*    Sets the totalLength field of the packetBuffer
*****************************************************************************/
void PacketBuffer_SetTotalLength(struct PACKET_BUFFER * packetBuffer, u32_t totalLength);


/*****************************************************************************
* FUNCTION: PacketBuffer_SetNextPointer
* DESCRIPTION:
*    Sets the nextPointer field of the packetBuffer
*****************************************************************************/
void PacketBuffer_SetNextPointer(struct PACKET_BUFFER * packetBuffer, struct PACKET_BUFFER * nextPacketBuffer);


/*****************************************************************************
* FUNCTION: PacketBuffer_GetStartPoint
* DESCRIPTION:
*    Returns the start point of the active region in a packet buffer
*****************************************************************************/
u8_t * PacketBuffer_GetStartPoint(struct PACKET_BUFFER * packetBuffer);


/*****************************************************************************
* FUNCTION: PacketBuffer_MoveStartPoint
* DESCRIPTION: 
*    Moves the start point of the active region by an offset. A positive 
*    offset means that the start point moves to a more positive address.
*    This is used to remove header space from the active region. A negative 
*    offset means the the start point moves to a less positive address. 
*    This is used to add header space to the active region.
*****************************************************************************/
err_t PacketBuffer_MoveStartPoint(struct PACKET_BUFFER * packetBuffer,s16_t offset);


/*****************************************************************************
* FUNCTION: PacketBuffer_DecreaseReference
* DESCRIPTION:
*    Decreases the reference count of a packet buffer. If the
*    mReferenceCount becomes zero then it decreases the reference count
*    of the packet buffer point to by mNext(if not NULL), and then returns
*    this packet buffer to the appropriate packet buffer pool.
*****************************************************************************/
void PacketBuffer_DecreaseReference(struct PACKET_BUFFER * packetBuffer);


/*****************************************************************************
* FUNCTION: PacketBuffer_IncreaseReference
* DESCRIPTION:
*    Increases the reference count of a packet buffer. This prevents a
*    following call to PacketBuffer_DecreaseReference from deallocating the 
*    packet buffer
*****************************************************************************/
void PacketBuffer_IncreaseReference(struct PACKET_BUFFER * packetBuffer);


/*****************************************************************************
* FUNCTION: PacketBuffer_SetNext
* DESCRIPTION:
*    Finds the last buffer of packet and sets its next pointer to nextPacket
*    NOTE: No length fields are modified. 
*        The last buffer is defined by (mThisLength==mTotalLength)
*****************************************************************************/
void PacketBuffer_SetNext(struct PACKET_BUFFER * packet, struct PACKET_BUFFER * nextPacket);


/*****************************************************************************
* FUNCTION: PacketBuffer_GetNext
* DESCRIPTION:
*    Returns the next pointer of the last buffer of the supplied packet.
*    NOTE: the last buffer is defined by (mThisLength==mTotalLength)
*****************************************************************************/
struct PACKET_BUFFER * PacketBuffer_GetNext(struct PACKET_BUFFER * packet);


/*****************************************************************************
* FUNCTION: PacketBuffer_GetSetNext
* DESCRIPTION:
*    Returns the current next pointer of the last buffer of the supplied packet.
*    Sets the next pointer of the last buffer to nextPacket.
*    NOTE: the last buffer is defined by (mThisLength==mTotalLength)
*****************************************************************************/
struct PACKET_BUFFER * PacketBuffer_GetSetNext(struct PACKET_BUFFER * packet,struct PACKET_BUFFER * nextPacket);


/*****************************************************************************
* FUNCTION: PacketBuffer_CopyFromExternalBuffer
* DESCRIPTION:
*    Copies data from an external buffer to a packet buffer
* PARAMETERS:
*    packet, this is the packet buffer list to copy data to.
*    offset, The offset within the packet buffer list where
*            to start copying data to.
*    data, a pointer to the external buffer where data is copied from.
*    length, the length of the external buffer where data is copied from.
*****************************************************************************/
void PacketBuffer_CopyFromExternalBuffer(struct PACKET_BUFFER * packet,u32_t offset, u8_t * data, u32_t length);


/*****************************************************************************
* FUNCTION: PacketBuffer_CopyToExternalBuffer
* DESCRIPTION:
*    Copies data from a packet buffer to an external buffer
* PARAMETERS:
*    packet, this is the packet buffer list to copy data from.
*    offset, The offset within the packet buffer list where
*            to start copying data from.
*    data, a pointer to the external buffer where data is copied to.
*    length, the length of the external buffer where data is copied to.
*****************************************************************************/
void PacketBuffer_CopyToExternalBuffer(struct PACKET_BUFFER * packet,u32_t offset, u8_t * data, u32_t length);


/*****************************************************************************
* FUNCTION: PacketBuffer_GetTailBuffer
* DESCRIPTION:
*    Gets the tail buffer of the first chain in a list of chains.
*****************************************************************************/
struct PACKET_BUFFER * PacketBuffer_GetTailBuffer(struct PACKET_BUFFER * packet);


extern IPV4_ADDRESS IPV4_ADDRESS_ANY;
extern IPV4_ADDRESS IPV4_ADDRESS_BROADCAST;


#define IPV4_ADDRESS_STRING_SIZE	(16)

char * IPV4_ADDRESS_TO_STRING(char * stringDataSpace,IPV4_ADDRESS address);

#define IPV4_ADDRESS_IS_ANY(pIpAddress) (((pIpAddress)==NULL)||((*(pIpAddress))==((IPV4_ADDRESS)0)))


u8_t IPV4_ADDRESS_IS_BROADCAST(IPV4_ADDRESS ipAddress,struct NETWORK_INTERFACE * networkInterface);


#define IPV4_ADDRESS_COMPARE(ipAddress1,ipAddress2) ((ipAddress1)==(ipAddress2))


#define IPV4_ADDRESS_NETWORK_COMPARE(ipAddress1,ipAddress2,netMask)	\
	((ipAddress1&netMask)==(ipAddress2&netMask))



#if (ENDIAN_SETTING==LITTLE_ENDIAN)
#define IPV4_ADDRESS_IS_MULTICAST(ipAddress) ((((u32_t)(ipAddress)) & ((u32_t)0x000000F0)) == ((u32_t)0x000000E0))
#define IPV4_ADDRESS_GET_BYTE_1(ipAddress) ((u8_t)((ipAddress)))
#define IPV4_ADDRESS_GET_BYTE_2(ipAddress) ((u8_t)((ipAddress)>>8))
#define IPV4_ADDRESS_GET_BYTE_3(ipAddress) ((u8_t)((ipAddress)>>16))
#define IPV4_ADDRESS_GET_BYTE_4(ipAddress) ((u8_t)((ipAddress)>>24))
#define IPV4_ADDRESS_MAKE(byte1,byte2,byte3,byte4)	\
	((IPV4_ADDRESS)((((u32_t)((u8_t)(byte4)))<<24)|	\
				(((u32_t)((u8_t)(byte3)))<<16)|		\
				(((u32_t)((u8_t)(byte2)))<<8)|		\
				((u32_t)((u8_t)(byte1)))))
#elif (ENDIAN_SETTING==BIG_ENDIAN)
#define IPV4_ADDRESS_IS_MULTICAST(ipAddress) ((((u32_t)(ipAddress)) & ((u32_t)0xF0000000)) == ((u32_t)0xE0000000))
#define IPV4_ADDRESS_GET_BYTE_1(ipAddress) ((u8_t)((ipAddress)>>24))
#define IPV4_ADDRESS_GET_BYTE_2(ipAddress) ((u8_t)((ipAddress)>>16))
#define IPV4_ADDRESS_GET_BYTE_3(ipAddress) ((u8_t)((ipAddress)>>8))
#define IPV4_ADDRESS_GET_BYTE_4(ipAddress) ((u8_t)((ipAddress)))
#define IPV4_ADDRESS_MAKE(byte1,byte2,byte3,byte4)	\
	((IPV4_ADDRESS)((((u32_t)((u8_t)(byte1)))<<24)|	\
				(((u32_t)((u8_t)(byte2)))<<16)|		\
				(((u32_t)((u8_t)(byte3)))<<8)|		\
				((u32_t)((u8_t)(byte4)))))
#else
#error Invalid ENDIAN_SETTING
#endif


#define IPV4_ADDRESS_SET(ipAddress,byte1,byte2,byte3,byte4)	\
	ipAddress=IPV4_ADDRESS_MAKE(byte1,byte2,byte3,byte4)


/*****************************************************************************
* FUNCTION: Sps_Run
* DESCRIPTION:
*    Runs all scheduled tasks, will not exit until
*    TaskManager_StopRunning is called 
*****************************************************************************/
void Sps_Run(void);


/*****************************************************************************
* FUNCTION: Sps_StopRunning
* DESCRIPTION:
*    Signals the TaskManager_Run function to exit at its 
*    earliest convenience, can be called from any thread, any time.
*****************************************************************************/
void Sps_StopRunning(void);


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -