📄 probe_com_os.c
字号:
/*
*********************************************************************************************************
* uC/Probe Communication
*
* (c) Copyright 2007; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may NOT be used to develop a similar product.
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* uC/Probe
*
* Communication: Generic
*
* Filename : probe_com_os.c
* Version : V1.20
* Programmer(s) : Brian Nagel
* Note(s) : (1) This file is the uC/OS-II layer for the uC/Probe Generic Communication Module.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <probe_com.h>
#include <ucos_ii.h>
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONSTANTS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL TABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
#if (PROBE_COM_SUPPORT_STR > 0) && (OS_SEM_EN > 0)
static OS_EVENT *ProbeCom_OS_Sem;
#endif
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/
#if (PROBE_COM_SUPPORT_STR > 0) && (OS_SEM_EN == 0)
#error "If PROBE_COM_SUPPORT_WR is set to DEF_TRUE, then semaphores MUST be enabled."
#endif
/*
*********************************************************************************************************
*********************************************************************************************************
** GLOBAL FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* Initialize uC/OS-II Objects for uC/Probe General Communication Module
*
* Description: This function creates one system object--a semaphore--to lock access to the string buffer.
*
* Argument(s): None.
*
* Returns : None
*********************************************************************************************************
*/
#if (PROBE_COM_SUPPORT_STR > 0)
void ProbeCom_OS_Init (void)
{
#if (OS_EVENT_NAME_SIZE > 10) && (OS_SEM_EN > 0)
CPU_INT08U err;
#endif
#if (OS_SEM_EN > 0)
ProbeCom_OS_Sem = OSSemCreate(1);
#if (OS_EVENT_NAME_SIZE > 13)
OSEventNameSet(ProbeCom_OS_Sem, (CPU_INT08U *)"uC/Probe Com", &err);
#else
#if (OS_EVENT_NAME_SIZE > 10)
OSEventNameSet(ProbeCom_OS_Sem, (CPU_INT08U *)"Probe Com", &err);
#endif
#endif
#endif
}
#endif
/*
*********************************************************************************************************
* Delay for a Certain Number of Ticks
*
* Description: This function implements a delay of a certain number of ticks.
*
* Argument(s): None.
*
* Returns : None
*********************************************************************************************************
*/
#if (PROBE_COM_SUPPORT_STR > 0)
void ProbeCom_OS_Dly (CPU_INT16U dly)
{
OSTimeDly(dly);
}
#endif
/*
*********************************************************************************************************
* Obtain String Buffer Lock
*
* Description: This function causes the calling task to obtain write access to the string buffer, waiting
* (if required) until it the buffer has been released by another task.
*
* Argument(s): wait specifies whether the function should wait until the semaphore is available
* or just check if the semaphore is available and, if it is, then accept it.
*
* Returns : DEF_TRUE if the semaphore was obtained
* DEF_FALSE if the semaphore was NOT obtained
*********************************************************************************************************
*/
#if (PROBE_COM_SUPPORT_STR > 0)
CPU_BOOLEAN ProbeCom_OS_Pend (CPU_BOOLEAN wait)
{
#if (OS_SEM_EN > 0)
CPU_INT08U tmp;
if (wait == DEF_TRUE) {
OSSemPend(ProbeCom_OS_Sem, 0, &tmp); /* Wait for string buffer to be released */
if (tmp != OS_NO_ERR) {
return (DEF_FALSE);
} else {
return (DEF_TRUE);
}
} else {
tmp = OSSemAccept(ProbeCom_OS_Sem); /* Wait for string buffer to be released */
if (tmp == 0) {
return (DEF_FALSE);
} else {
return (DEF_TRUE);
}
}
#else
return (DEF_TRUE);
#endif
}
#endif
/*
*********************************************************************************************************
* Release String Buffer Lock
*
* Description: This function releases the lock on write access to the string buffer.
*
* Argument(s): None
*
* Returns : None
*********************************************************************************************************
*/
#if (PROBE_COM_SUPPORT_STR > 0)
void ProbeCom_OS_Post (void)
{
#if (OS_SEM_EN > 0)
OSSemPost(ProbeCom_OS_Sem); /* String buffer is being released */
#endif
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -