?? probe_rs232_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: RS-232
*
* Filename : probe_rs232_os.c
* Version : V1.20
* Programmer(s) : Brian Nagel
* Note(s) : (1) This file is the uC/OS-II layer for the uC/Probe RS-232 Communication Module.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <probe_rs232.h>
#include <ucos_ii.h>
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONSTANTS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL TABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
#if (PROBE_RS232_PARSE_TASK > 0)
static OS_STK ProbeRS232_OS_TaskStk[PROBE_RS232_TASK_STK_SIZE];
#if (OS_SEM_EN > 0)
static OS_EVENT *ProbeRS232_OS_Sem;
#endif
#endif
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
#if (PROBE_RS232_PARSE_TASK > 0)
static void ProbeRS232_OS_Task(void *p_arg);
#endif
/*
*********************************************************************************************************
* LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/
#if (PROBE_RS232_PARSE_TASK > 0) && (OS_SEM_EN == 0)
#error "If PROBE_RS232_PARSE_TASK is set to DEF_TRUE, then semaphores MUST be enabled."
#endif
/*
*********************************************************************************************************
*********************************************************************************************************
** GLOBAL FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* Initialize uC/OS-II Objects for uC/Probe RS-232 Communication Module
*
* Description: This function creates system objects--a semaphore and a task--for the RS-232 communication.
*
* Argument(s): None.
*
* Returns : None
*********************************************************************************************************
*/
#if (PROBE_RS232_PARSE_TASK > 0)
void ProbeRS232_OS_Init (void)
{
#if (OS_TASK_NAME_SIZE > 13) || (OS_EVENT_NAME_SIZE > 13)
CPU_INT08U err;
#endif
#if (OS_SEM_EN > 0)
ProbeRS232_OS_Sem = OSSemCreate(0);
#if (OS_EVENT_NAME_SIZE > 16)
OSEventNameSet(ProbeRS232_OS_Sem, (CPU_INT08U *)"uC/Probe RS-232", &err);
#else
#if (OS_EVENT_NAME_SIZE > 13)
OSEventNameSet(ProbeRS232_OS_Sem, (CPU_INT08U *)"Probe RS-232", &err);
#endif
#endif
#endif
#if (OS_TASK_CREATE_EXT_EN > 0)
#if (OS_STK_GROWTH == 1)
(void)OSTaskCreateExt(ProbeRS232_OS_Task,
(void *)0, /* No arguments passed to OSView_Task() */
&ProbeRS232_OS_TaskStk[PROBE_RS232_TASK_STK_SIZE - 1],/* Set Top-Of-Stack */
PROBE_RS232_TASK_PRIO, /* Lowest priority level */
PROBE_RS232_TASK_PRIO,
&ProbeRS232_OS_TaskStk[0], /* Set Bottom-Of-Stack */
PROBE_RS232_TASK_STK_SIZE,
(void *)0, /* No TCB extension */
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR); /* Enable stack checking + clear stack */
#else
(void)OSTaskCreateExt(ProbeRS232_OS_Task,
(void *)0, /* No arguments passed to OSView_Task() */
&ProbeRS232_OS_TaskStk[0], /* Set Top-Of-Stack */
PROBE_RS232_TASK_PRIO, /* Lowest priority level */
PROBE_RS232_TASK_PRIO,
&ProbeRS232_OS_TaskStk[PROBE_RS232_TASK_STK_SIZE - 1],/* Set Bottom-Of-Stack */
PROBE_RS232_TASK_STK_SIZE,
(void *)0, /* No TCB extension */
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR); /* Enable stack checking + clear stack */
#endif
#else
#if (OS_STK_GROWTH == 1)
(void)OSTaskCreate(ProbeRS232_OS_Task,
(void *)0,
&ProbeRS232_OS_TaskStk[PROBE_RS232_TASK_STK_SIZE - 1],
PROBE_RS232_TASK_PRIO);
#else
(void)OSTaskCreate(ProbeRS232_OS_Task,
(void *)0,
&ProbeRS232_OS_TaskStk[0],
PROBE_RS232_TASK_PRIO);
#endif
#endif
#if (OS_TASK_NAME_SIZE > 16)
OSTaskNameSet(PROBE_RS232_TASK_PRIO, (CPU_INT08U *)"uC/Probe RS-232", &err);
#else
#if (OS_TASK_NAME_SIZE > 13)
OSTaskNameSet(PROBE_RS232_TASK_PRIO, (CPU_INT08U *)"Probe RS-232", &err);
#endif
#endif
}
#endif
/*
*********************************************************************************************************
* Wait for a Packet
*
* Description: This function causes the calling task to wait for a packet to be received.
*
* Argument(s): None
*
* Returns : None
*********************************************************************************************************
*/
#if (PROBE_RS232_PARSE_TASK > 0)
void ProbeRS232_OS_Pend (void)
{
#if (OS_SEM_EN > 0)
CPU_INT08U err;
OSSemPend(ProbeRS232_OS_Sem, 0, &err); /* Wait for a packet to be received */
#endif
}
#endif
/*
*********************************************************************************************************
* Notify Packet Reception
*
* Description: This function notifies a pending task that a packet has been receieved.
*
* Argument(s): None
*
* Returns : None
*********************************************************************************************************
*/
#if (PROBE_RS232_PARSE_TASK > 0) && (OS_SEM_EN > 0)
void ProbeRS232_OS_Post (void)
{
#if (OS_SEM_EN > 0)
OSSemPost(ProbeRS232_OS_Sem); /* A packet has been received */
#endif
}
#endif
/*
*********************************************************************************************************
*********************************************************************************************************
** LOCAL FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* uC/OS-II Task
*
* Description: This task waits for packets to be received, formalates responses, and begins transmission.
*
* Argument(s): p_arg is the argument passed to ProbeRS232_OS_Task() by 'OSTaskCreate()'.
*
* Returns : None
*********************************************************************************************************
*/
#if (PROBE_RS232_PARSE_TASK > 0)
static void ProbeRS232_OS_Task (void *p_arg)
{
ProbeRS232_Task(p_arg);
}
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -