etisserant@0: /* etisserant@0: This file is part of CanFestival, a library implementing CanOpen Stack. etisserant@0: etisserant@0: Copyright (C): Edouard TISSERANT and Francis DUPIN etisserant@0: etisserant@0: See COPYING file for copyrights details. etisserant@0: etisserant@0: This library is free software; you can redistribute it and/or etisserant@0: modify it under the terms of the GNU Lesser General Public etisserant@0: License as published by the Free Software Foundation; either etisserant@0: version 2.1 of the License, or (at your option) any later version. etisserant@0: etisserant@0: This library is distributed in the hope that it will be useful, etisserant@0: but WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU etisserant@0: Lesser General Public License for more details. etisserant@0: etisserant@0: You should have received a copy of the GNU Lesser General Public etisserant@0: License along with this library; if not, write to the Free Software etisserant@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA etisserant@0: */ etisserant@0: etisserant@0: #ifndef __pdo_h__ etisserant@0: #define __pdo_h__ etisserant@0: etisserant@0: #include etisserant@0: #include etisserant@0: etisserant@0: /* The process_var structure etisserant@0: Used to store the PDO before the transmission or the reception. etisserant@0: */ etisserant@0: typedef struct struct_s_process_var { etisserant@0: UNS8 count; // Size of data. Ex : for a PDO of 6 bytes of data, count = 6 etisserant@0: // WARNING s_process_var.data is subject to ENDIANISATION etisserant@0: // (with respect to CANOPEN_BIG_ENDIAN) etisserant@0: UNS8 data[PDO_MAX_LEN]; etisserant@0: }s_process_var; etisserant@0: etisserant@0: #include "data.h" etisserant@0: etisserant@0: /** The PDO structure */ etisserant@0: typedef struct struct_s_PDO { etisserant@0: UNS32 cobId; // COB-ID etisserant@0: UNS8 len; // Number of data transmitted (in data[]) etisserant@0: UNS8 data[8]; // Contain the data etisserant@0: }s_PDO; etisserant@0: etisserant@0: /** Transmit a PDO data frame on the bus bus_id etisserant@0: * pdo is a structure which contains the pdo to transmit etisserant@0: * bus_id is hardware dependant etisserant@0: * return canSend(bus_id,&m) or 0xFF if error etisserant@0: * request can take the value REQUEST or NOT_A_REQUEST etisserant@0: */ etisserant@0: UNS8 sendPDO (CO_Data* d, s_PDO pdo, UNS8 request); etisserant@0: etisserant@0: /** Prepare a PDO frame transmission, etisserant@0: * whose different parameters are stored in process_var table, etisserant@0: * to the slave. etisserant@0: * bus_id is hardware dependant etisserant@0: * call the function sendPDO etisserant@0: * return the result of the function sendPDO or 0xFF if error etisserant@0: */ etisserant@0: UNS8 PDOmGR (CO_Data* d, UNS32 cobId); etisserant@0: etisserant@0: /** Prepare the PDO defined at index to be sent by PDOmGR etisserant@0: * Copy all the data to transmit in process_var etisserant@0: * *pwCobId : returns the value of the cobid. (subindex 1) etisserant@0: * Return 0 or 0xFF if error. etisserant@0: */ etisserant@0: UNS8 buildPDO (CO_Data* d, UNS16 index); etisserant@0: etisserant@0: /** Transmit a PDO request frame on the bus bus_id etisserant@0: * to the slave. etisserant@0: * bus_id is hardware dependant etisserant@0: * Returns 0xFF if error, other in success. etisserant@0: */ etisserant@0: UNS8 sendPDOrequest (CO_Data* d, UNS32 cobId); etisserant@0: etisserant@0: /** Compute a PDO frame reception etisserant@0: * bus_id is hardware dependant etisserant@0: * return 0xFF if error, else return 0 etisserant@0: */ etisserant@0: UNS8 proceedPDO (CO_Data* d, Message *m); etisserant@0: etisserant@0: /* used by the application to send a variable by PDO. etisserant@0: * Check in which PDO the variable is mapped, and send the PDO. etisserant@0: * of course, the others variables mapped in the PDO are also sent ! etisserant@0: * ( ie when a specific event occured) etisserant@0: * bus_id is hardware dependant etisserant@0: * variable is a pointer to the variable which has to be sent. Must be etisserant@0: * defined in the object dictionary etisserant@0: * return 0xFF if error, else return 0 etisserant@0: */ etisserant@0: UNS8 sendPDOevent (CO_Data* d, void * variable); etisserant@0: etisserant@0: #endif