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

📄 cp_core.h.svn-base

📁 canpie 一个can bus的协议栈 - CAN interface for embedded control - CAN interface for PC (without local
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
//****************************************************************************//
// File:          cp_core.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 Lesser General Public License as published   //
// by the Free Software Foundation; either version 2.1 of the License, or     //
// (at your option) any later version.                                        //
//============================================================================//
//                                                                            //
// Date        History                                                        //
// ----------  -------------------------------------------------------------- //
// 29.07.2003  Initial version                                                //
//                                                                            //
//****************************************************************************//


#ifndef  _CP_CORE_H_
#define  _CP_CORE_H_


//------------------------------------------------------------------------------
// CVS version information:
// $Id: cp_core.h,v 1.5 2006/03/28 09:53:21 koppe Exp $
//------------------------------------------------------------------------------


/*----------------------------------------------------------------------------*\
** Include files                                                              **
**                                                                            **
\*----------------------------------------------------------------------------*/


#include "canpie.h"


//-----------------------------------------------------------------------------
/*!
** \file    cp_core.h
** \brief   CANpie core functions
**
**
*/

/*----------------------------------------------------------------------------*\
** Definitions                                                                **
**                                                                            **
\*----------------------------------------------------------------------------*/


/*-------------------------------------------------------------------------
** A driver with only one channel and small memory resources does not need
** the 'channel' parameter.
** The definition CP_SMALL_CODE is checked for the value '1' and the
** function prototypes are converted then. The function call in the
** application stays the same (with 'channel' parameter).
**
*/
#if   CP_SMALL_CODE == 1

#define  CpCoreAutobaud(CH, A, B)            CpCoreAutobaud(A, B)
#define  CpCoreBaudrate(CH, A)               CpCoreBaudrate(A)
#define  CpCoreBittiming(CH, A)              CpCoreBittiming(A)

#define  CpCoreBufferGetData(CH, A, B)       CpCoreBufferGetData(A, B)
#define  CpCoreBufferGetDlc(CH, A, B)        CpCoreBufferGetDlc(A, B)
#define  CpCoreBufferInit(CH, A, B, C)       CpCoreBufferInit(A, B, C)
#define  CpCoreBufferRelease(CH, A)          CpCoreBufferRelease(A)
#define  CpCoreBufferSetData(CH, A, B)       CpCoreBufferSetData(A, B)
#define  CpCoreBufferSetDlc(CH, A, B)        CpCoreBufferSetDlc(A, B)
#define  CpCoreBufferSend(CH, A)             CpCoreBufferSend(A)

#define  CpCoreCanMode(CH, A)                CpCoreCanMode(A)
#define  CpCoreCanStatus(CH, A)              CpCoreCanStatus(A)

//#define  CpCoreDriverInit(A, CH)             CpCoreDriverInit()
//#define  CpCoreDriverRelease(CH)             CpCoreDriverRelease()

#define  CpCoreFilterAll(CH, A)              CpCoreFilterAll(A)
#define  CpCoreFilterMsg(CH, A, B)           CpCoreFilterMsg(A, B)

#define  CpCoreHDI(CH, A)                    CpCoreHDI(A)

#define  CpCoreIntFunctions(CH, A, B, C)     CpCoreIntFunctions(A, B, C)

#define  CpCoreMsgRead(CH, A, B)             CpCoreMsgRead(A, B)
#define  CpCoreMsgWrite(CH, A, B)            CpCoreMsgTransmit(A, B)

#define  CpCoreRegRead(CH, A, B)             CpCoreRegRead(A, B)
#define  CpCoreRegWrite(CH, A, B)            CpCoreRegWrite(A, B)

#define  CpCoreStatistic(CH, A)              CpCoreStatistic(A)

#endif


/*----------------------------------------------------------------------------*\
** Function prototypes                                                        **
**                                                                            **
\*----------------------------------------------------------------------------*/



_TvCpStatus CpCoreAutobaud(_TsCpPort * ptsPortV, _U08 * pubBaudSelV, _U16 * puwWaitV);


/*!
** \brief   Set bitrate of CAN controller
** \param   ptsPortV       CAN channel of the hardware
** \param   ubBaudSelV     Baudrate selection
**
** \return  Error code taken from the CpErr enumeration. If no error
**          occured, the function will return CpErr_OK.
**
** This function directly writes to the bit timing registers of the CAN
** controller. The value for the parameter \e ubBaudSelV is taken
** from the CP_BAUD enumeration.
**
*/
_TvCpStatus CpCoreBaudrate(_TsCpPort * ptsPortV, _U08 ubBaudSelV);


_TvCpStatus CpCoreBittiming(_TsCpPort * ptsPortV, _TsCpBitTiming * ptsBitrateV);


/*!
** \brief   Get data from message buffer
** \param   ptsPortV       CAN channel of the hardware
** \param   ubBufferIdxV   Buffer number
** \param   pubDataV       Buffer for data
**
** \return  Error code taken from the CpErr enumeration
**
** This function is the fastest method to get data from a FullCAN message
** buffer. The buffer has to be configured by a call to CpCoreBufferInit() before.
**
*/
_TvCpStatus CpCoreBufferGetData( _TsCpPort * ptsPortV, _U08 ubBufferIdxV,
                                 _U08 * pubDataV);


/*!
** \brief   Get DLC of specified buffer
** \param   ptsPortV       CAN channel of the hardware
** \param   ubBufferIdxV   Buffer number
** \param   pubDlcV        Data Length Code
**
** \return  Error code taken from the CpErr enumeration. If no error
**          occured, the function will return CpErr_OK.
**
** This function retrieves the Data Length Code (DLC) of the selected buffer
** \e ubBufferIdxV.
*/
_TvCpStatus CpCoreBufferGetDlc(  _TsCpPort * ptsPortV, _U08 ubBufferIdxV,
                                 _U08 * pubDlcV);


/*!
** \brief   Initialize buffer in FullCAN controller
** \param   ptsPortV       CAN channel of the hardware
** \param   ptsCanMsgV     Pointer to a CAN message structure
** \param   ubBufferIdxV   Buffer number
** \param   ubDirectionV   Direction of message
**
** \return  Error code taken from the #CpErr enumeration. If no error
**          occured, the function will return CpErr_OK.
**
** This function allocates the message buffer in a FullCAN controller.
** The number of the message buffer inside the FullCAN controller is
** denoted via the parameter ubBufferIdxV.
** The parameter ubDirectionV can have the following values:
** \li CP_BUFFER_DIR_RX: receive
** \li CP_BUFFER_DIR_TX: transmit
**
*/
_TvCpStatus CpCoreBufferInit( _TsCpPort * ptsPortV, _TsCpCanMsg * ptsCanMsgV,
                              _U08 ubBufferIdxV, _U08 ubDirectionV);


/*!
** \brief   Release message buffer of FullCAN controller
** \param   ptsPortV       CAN channel of the hardware
** \param   ubBufferIdxV   Buffer number
**
** \return  Error code taken from the CpErr enumeration. If no error
**          occured, the function will return CpErr_OK.
**
*/
_TvCpStatus CpCoreBufferRelease( _TsCpPort * ptsPortV, _U08 ubBufferIdxV);


/*!
** \brief   Set data of message buffer
** \param   ptsPortV       CAN channel of the hardware
** \param   ubBufferIdxV   Buffer number
** \param   pubDataV       Pointer to data buffer
**
** \return  Error code taken from the CpErr enumeration
**
** This function is the fastest method to set the data bytes of a CAN message.
** It can be used in combination with the function CpCoreBufferSend(). It
** will write 8 data bytes into the buffer defined by \e ubBufferIdxV. The
** buffer has to be configured by CpCoreBufferInit() in advance. The size
** of the data buffer \e pubDataV must have a size of 8 bytes.
**
** The following example demonstrates the access to the data bytes of a CAN
** message:
** \code
**  _U08 aubDataT[8];   // buffer for 8 bytes
**
** aubDataT[0] = 0x11;  // byte 0: set to 11hex
** aubDataT[1] = 0x22;  // byte 1: set to 22hex

** //--- copy the stuff to message buffer 1 ---------------
** CpCoreBufferSetData(CP_CHANNEL_1, CP_BUFFER_1, &aubDataT);
**
** //--- send this message out ----------------------------
** CpCoreBufferSend(CP_CHANNEL_1, CP_BUFFER_1);
** \endcode
**
*/
_TvCpStatus CpCoreBufferSetData( _TsCpPort * ptsPortV, _U08 ubBufferIdxV,
                                 _U08 * pubDataV);


/*!
** \brief   Set DLC of specified buffer
** \param   ptsPortV       CAN channel of the hardware
** \param   ubBufferIdxV   Buffer number
** \param   ubDlcV         Data Length Code
**
** \return  Error code taken from the CpErr enumeration. If no error
**          occured, the function will return CpErr_OK.
**
** This function sets the Data Length Code (DLC) of the selected buffer
** ubBufferIdxV. The DLC must be in the range from 0 to 8.
*/
_TvCpStatus CpCoreBufferSetDlc(  _TsCpPort * ptsPortV, _U08 ubBufferIdxV,
                                 _U08 ubDlcV);

⌨️ 快捷键说明

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