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

📄 semaphore.h

📁 使用GPS驱动中间件,先初始化GPS,发送相关命令,等待接收地理的数据,若接收到数据,可从液晶屏中显示.
💻 H
字号:
/**
 * \file ucos2_semaphore.h
 * \author Wei Yongming <ymwei@minigui.org>
 * \date 2004/02/03
 * 
 * semaphore.h: This header contains the pthread semaphore definitions 
 *              needed to support MiniGUI under uC/OS-II. 
 *
 \verbatim
    Copyright (C) 2004 Feynman Software.

    This file is part of MiniGUI, a compact cross-platform Graphics 
    User Interface (GUI) support system for real-time embedded systems.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 \endverbatim
 */

/*
 * $Id: ucos2_semaphore.h,v 1.5 2004/10/20 02:02:11 weiym Exp $
 *
 *             MiniGUI for Linux/uClinux, eCos, uC/OS-II, VxWorks version 1.6.x
 *             Copyright (C) 1998-2002 Wei Yongming.
 *             Copyright (C) 2002-2004 Feynman Software.
 */

#ifndef UCOSII_SEMAPHORE_H
#define UCOSII_SEMAPHORE_H

#include "common.h"

#ifdef __UCOSII__

#define sem_t ucos2_sem_t

#define SEM_VALUE_MAX	USHRT_MAX

//-----------------------------------------------------------------------------
// Semaphore object definition

typedef struct
{
    void* os_sema;
} sem_t;

//-----------------------------------------------------------------------------
// Semaphore functions

// Initialize semaphore to value.
// pshared is not supported under uC/OS-II.
int sem_init  (sem_t *sem, int pshared, unsigned int value);

// Destroy the semaphore.
int sem_destroy  (sem_t *sem);

// Decrement value if >0 or wait for a post.
int sem_wait  (sem_t *sem);

// Decrement value if >0, return -1 if not.
int sem_trywait  (sem_t *sem);

// Increment value and wake a waiter if one is present.
int sem_post  (sem_t *sem);

// Get current value
int sem_getvalue  (sem_t *sem, int *sval);

#if 0 /* We do not implement the named semaphore functions */

//-----------------------------------------------------------------------------
// Named semaphore functions

// Open an existing named semaphore, or create it.
sem_t *sem_open  (const char *name, int oflag, ...);

// Close descriptor for semaphore.
int sem_close  (sem_t *sem);

// Remove named semaphore
int sem_unlink  (const char *name);

//-----------------------------------------------------------------------------
// Special return value for sem_open()

#define SEM_FAILED      ((sem_t *)NULL)

#endif /* We do not implement the named semaphore functions */

#endif /* __UCOSII__ */
#endif /* UCOSII_SEMAPHORE_H */

⌨️ 快捷键说明

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