📄 cpfifo.h.svn-base
字号:
/*****************************************************************************\* CANpie ** ** File : cpfifo.h ** Description : ** Author : Uwe Koppe ** e-mail : koppe@microcontrol.net ** ** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ** ** 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. ** ** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ** ** History ** Vers. Date Comment Aut. ** ----- ---------- --------------------------------------------- ---- ** 0.1 04.09.1999 Initial version UK ** 0.2 18.01.2000 Fixed bug in pointer calculation UK ** 0.3 - no changes - ** 0.4 - no changes - ** 0.5 - no changes - ** 0.6 15.06.2000 added fixed FIFO size support UK ** set to CANpie release 0.6 ** 0.7 30.11.2000 Bugfix for static FIFO (overflow) UK ** 0.8 14.02.2001 complete rewrite, check FIFO status UK ** *\*****************************************************************************/#ifndef _CP_FIFO_H_#define _CP_FIFO_H_//------------------------------------------------------------------------------// CVS version information:// $Id: cpfifo.h,v 1.2 2005/06/01 21:28:00 microcontrol Exp $//------------------------------------------------------------------------------/*-----------------------------------------------------------------------------** Online documentation for Doxygen*//*! \file cpfifo.h** \brief CANpie FIFO functions**** The FIFO functions care for the handling of messages between the user** interface (user functions) and the specific hardware implementation.** The are currently two implementations for the FIFO: one with dynamic** memory allocation (using malloc() and free() functions) and a second** with static memory size. The latter is typically used for microcontroller** implementations with low memory resources. Selection of the type is done** by setting the definition CP_FIFO_TYPE in the file cpconfig.h to the** appropriate value. The size of the static FIFOs can be setup in the** cpfifo.h file via the definitions CP_FIFO_TRM_SIZE and CP_FIFO_RCV_SIZE.***//*----------------------------------------------------------------------------*\** Include files **** **\*----------------------------------------------------------------------------*/#include "canpie.h"/*----------------------------------------------------------------------------*\** Definitions & Enumerations **** **\*----------------------------------------------------------------------------*/struct CpFifo_s { /*! This pointer is the first entry of an array of messages. The ** total number of messages is given by the field <b>uwFifoSize</b>. */ _TsCpCanMsg * ptsMsgList; /*! The 'uwFifoSize' field holds the number of maximum messages ** that can be stored in the FIFO. */ _U16 uwFifoSize; _U16 uwHeadPos; _U16 uwTailPos;};typedef struct CpFifo_s _TsCpFifo;/*-------------------------------------------------------------------------** Function prototypes***//*!** \brief Setup FIFO** \param ptsFifoV pointer to FIFO**** \return Error code taken from the CpErr enumeration. If no error** occured, the function will return CpErr_OK.**** This function reserves memory for the specified FIFO buffer. If** a static FIFO is used (CP_FIFO_TYPE == 1) the parameter 'size'** is not evaluated.***/_U08 CpFifoInit(_TsCpFifo * ptsFifoV, _U16 uwSizeV);/*!** \brief Remove FIFO** \param ptsFifoV pointer to FIFO**** \return Error code taken from the CpErr enumeration. If no error** occured, the function will return CpErr_OK.**** This function frees the reserved memory for the specified FIFO** buffer. If a static FIFO is used (CP_FIFO_TYPE == 1) this function** simply returns CpErr_OK.***/_U08 CpFifoRelease(_TsCpFifo * ptsFifoV);/*!** \brief Clear FIFO contents** \param ptsFifoV pointer to FIFO**** This function clears the specified FIFO buffer. All messages inside** the FIFO are erased.***/void CpFifoClear(_TsCpFifo * ptsFifoV );/*!** \brief Check if FIFO is empty** \param ptsFifoV pointer to FIFO**** \return number of messages stored in FIFO*/_U16 CpFifoMsgCount(_TsCpFifo * ptsFifoV);/*!** \brief Push message into FIFO** \param ptsFifoV pointer to FIFO** \param ptsCanMsgV pointer to CAN message**** \return Error code taken from the CpErr enumeration. If no error** occured, the function will return CpErr_OK.**** Push a message into the FIFO buffer, given by the parameter ** 'ptsFifoV'. If the buffer is full, the function will return** 'CpErr_FIFO_FULL'.***/_U08 CpFifoPush(_TsCpFifo * ptsFifoV, _TsCpCanMsg * ptsCanMsgV);/*!** \brief Pop message from FIFO** \param ptsFifoV pointer to FIFO** \param ptsCanMsgV pointer to CAN message**** \return Error code taken from the CpErr enumeration. If no error** occured, the function will return CpErr_OK.**** Pop a message from the FIFO buffer, given by the parameter ** 'ptsFifoV'. If the buffer is empty, the function will ** return 'CpErr_FIFO_EMPTY'.***/_U08 CpFifoPop(_TsCpFifo * ptsFifoV, _TsCpCanMsg * ptsCanMsgV);#endif // _CP_FIFO_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -