📄 pdo.h
字号:
/***************************************************************************
pdo.h - description
-------------------
begin : Fri May 17 2002
copyright : (C) 2002 by Raphael Zulliger
email : zulli@hsr.ch
***************************************************************************/
/***************************************************************************
* *
* This library is Copyright (c) Raphael Zulliger <zulli@gmx.net>. *
* It is licensed under the GNU Library General Public License (LGPL). *
* *
***************************************************************************/
/** \file
* \brief Responsible for PDO transfers (rx and tx)
*
* This file contains functions for receiving and transmitting PDOs.
* \warning Only PDOs with transfertype 255 (submit/receive on change)
* are implemeted at the moment.
*/
#ifndef __pdo_h__
#define __pdo_h__
#include <canop.h>
#include <def.h>
#include <objdict.h>
/** this struct is only for the receiving transfer-table. it is needed because of the different mapping
* parameter for one pdo. this means: one pdo (up to 64bit) can mapp the value on different variables
* e.g.: the value of bit 1 is for bit 1 of the variable UINT8 led1; and the value of bit 14 is for the
* variable UINT8 led12; */
typedef struct td_s_variable_mapping
{
/** pointer to the object of the corresponding variable for this mapping entry
*/
void* pObject;
/** value for the variable defined with pObject
*/
BYTE value;
/** size of BITs!!! to write
*/
BYTE size;
} s_variable_mapping;
/** Struct to store received PDOs.
*/
typedef struct td_s_pdo_receive_transfer_table
{
/** transmission type of the PDO: only transmissiontype 255 (0xFF) is supported yet.
*/
BYTE transmissionType;
/** if this entry has been processed or not. TRUE = already processed.
*/
BOOL processed;
/** count of used PDO mapping parameters
*/
BYTE count;
/** mapping parameters for this PDO
*/
s_variable_mapping mappingEntry[MAPPING_PARAMETER_COUNT];
} s_pdo_receive_transfer_table;
/** Sends PDO (if any data has changed) to other CANopen devices. Only transmissiontype
* 255 (0xFF) is supported yet. This function has to be called every time a PDO has
* changed and should be sent to foreign nodes. So you should either call this
* function in interrupt service routines, which modifies PDOs or in the while-loop
* in the operational( )-function (in file app.c)
*/
void processSendPDO( void );
/** This function should be called in every while-loop of the operational( )-function
* (file app.c). It is responsible to analyse incoming PDO messages. Therefore it
* sets local variables to the received values if there are some rx-PDOs defined.
* only transmissiontype 255 (0xFF) is supported yet.
* \param canopenMessage contains the CAN-Message that has arrived.
*/
void processReceivedPDO( s_rx_buffer_message* canopenMessage );
/** sends a PDO message to the CANopen device with the id bID and the data
* defined by the m
* \param bID ID of the PDO (not ID of the CANopen device!)
* \param pcData Pointer to the BYTE array (maximum length 8 Byte)
* \param bLength Length of the data (count of valid fields of the pbData array)
* \param bRemoteReceive TRUE for asking a device to send us this pdo, FALSE
* for sending a PDO to an other CANopen device
*/
void sendPDO( const WORD wID, const BYTE* pbData, const BYTE bLength, const BOOL bRemoteReceive );
/** At the moment the SlaveLib can only handle PDOs with transmissiontype 255.
* It sends PDOs and stores the values in the struct called TxPDOTransferTable.
* Therefore, if the next time processSendPDO is called, it checkes wheter the values
* have changed since last sending of a PDO or not. If the lether is the case,
* no data are sent. For some programs it is useful to always send a message due
* to several reasons. Therefore this function sets the previous stored data to invalid,
* so the function processSendPDO sends the new data (that may contain the same data
* as sent before) out to the CAN-Bus.
* \param bPDONr the number of the PDO. (normally 1..4, maybe also greater than 4)
* \return TRUE if successful, false if the operation failed.
*/
BOOL resetTxPDOData( BYTE bPDONr );
#endif // __pdo_h__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -