]> rtime.felk.cvut.cz Git - CanFestival-3.git/blob - include/pdo.h
Commit a new cvs repo.
[CanFestival-3.git] / include / pdo.h
1 /*
2 This file is part of CanFestival, a library implementing CanOpen Stack. 
3
4 Copyright (C): Edouard TISSERANT and Francis DUPIN
5
6 See COPYING file for copyrights details.
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 */
22
23 #ifndef __pdo_h__
24 #define __pdo_h__
25
26 #include <applicfg.h>
27 #include <def.h>
28
29 /* The process_var structure
30  Used to store the PDO before the transmission or the reception.
31 */
32 typedef struct struct_s_process_var {
33   UNS8 count; // Size of data. Ex : for a PDO of 6 bytes of data, count = 6
34   // WARNING s_process_var.data is subject to ENDIANISATION 
35   // (with respect to CANOPEN_BIG_ENDIAN)
36   UNS8 data[PDO_MAX_LEN];
37 }s_process_var;
38
39 #include "data.h"
40
41 /** The PDO structure */
42 typedef struct struct_s_PDO {
43   UNS32 cobId;    // COB-ID
44   UNS8           len;     // Number of data transmitted (in data[])
45   UNS8           data[8]; // Contain the data
46 }s_PDO;
47
48 /** Transmit a PDO data frame on the bus bus_id
49  * pdo is a structure which contains the pdo to transmit
50  * bus_id is hardware dependant
51  * return canSend(bus_id,&m) or 0xFF if error
52  * request can take the value  REQUEST or NOT_A_REQUEST
53  */
54 UNS8 sendPDO (CO_Data* d, s_PDO pdo, UNS8 request);
55
56 /** Prepare a PDO frame transmission, 
57  * whose different parameters are stored in process_var table,
58  * to the slave.
59  * bus_id is hardware dependant
60  * call the function sendPDO
61  * return the result of the function sendPDO or 0xFF if error
62  */
63 UNS8 PDOmGR (CO_Data* d, UNS32 cobId);
64
65 /** Prepare the PDO defined at index to be sent by  PDOmGR
66  * Copy all the data to transmit in process_var
67  * *pwCobId : returns the value of the cobid. (subindex 1)
68  * Return 0 or 0xFF if error.
69  */
70 UNS8 buildPDO (CO_Data* d, UNS16 index);
71
72 /** Transmit a PDO request frame on the bus bus_id
73  * to the slave.
74  * bus_id is hardware dependant
75  * Returns 0xFF if error, other in success.
76  */
77 UNS8 sendPDOrequest (CO_Data* d, UNS32 cobId);
78
79 /** Compute a PDO frame reception
80  * bus_id is hardware dependant
81  * return 0xFF if error, else return 0
82  */
83 UNS8 proceedPDO (CO_Data* d, Message *m);
84
85 /* used by the application to send a variable by PDO.
86  * Check in which PDO the variable is mapped, and send the PDO. 
87  * of course, the others variables mapped in the PDO are also sent !
88  * ( ie when a specific event occured)
89  * bus_id is hardware dependant
90  * variable is a pointer to the variable which has to be sent. Must be
91  * defined in the object dictionary
92  * return 0xFF if error, else return 0
93  */
94 UNS8 sendPDOevent (CO_Data* d, void * variable);
95
96 #endif