0
|
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 {
|
71
|
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 |
*/
|
0
|
37 |
UNS8 data[PDO_MAX_LEN];
|
|
38 |
}s_process_var;
|
|
39 |
|
|
40 |
#include "data.h"
|
|
41 |
|
|
42 |
/** The PDO structure */
|
|
43 |
typedef struct struct_s_PDO {
|
71
|
44 |
UNS32 cobId; /* COB-ID */
|
|
45 |
UNS8 len; /* Number of data transmitted (in data[]) */
|
|
46 |
UNS8 data[8]; /* Contain the data */
|
0
|
47 |
}s_PDO;
|
|
48 |
|
|
49 |
/** Transmit a PDO data frame on the bus bus_id
|
|
50 |
* pdo is a structure which contains the pdo to transmit
|
|
51 |
* bus_id is hardware dependant
|
|
52 |
* return canSend(bus_id,&m) or 0xFF if error
|
|
53 |
* request can take the value REQUEST or NOT_A_REQUEST
|
|
54 |
*/
|
|
55 |
UNS8 sendPDO (CO_Data* d, s_PDO pdo, UNS8 request);
|
|
56 |
|
|
57 |
/** Prepare a PDO frame transmission,
|
|
58 |
* whose different parameters are stored in process_var table,
|
|
59 |
* to the slave.
|
|
60 |
* bus_id is hardware dependant
|
|
61 |
* call the function sendPDO
|
|
62 |
* return the result of the function sendPDO or 0xFF if error
|
|
63 |
*/
|
|
64 |
UNS8 PDOmGR (CO_Data* d, UNS32 cobId);
|
|
65 |
|
|
66 |
/** Prepare the PDO defined at index to be sent by PDOmGR
|
|
67 |
* Copy all the data to transmit in process_var
|
|
68 |
* *pwCobId : returns the value of the cobid. (subindex 1)
|
|
69 |
* Return 0 or 0xFF if error.
|
|
70 |
*/
|
|
71 |
UNS8 buildPDO (CO_Data* d, UNS16 index);
|
|
72 |
|
|
73 |
/** Transmit a PDO request frame on the bus bus_id
|
|
74 |
* to the slave.
|
|
75 |
* bus_id is hardware dependant
|
|
76 |
* Returns 0xFF if error, other in success.
|
|
77 |
*/
|
|
78 |
UNS8 sendPDOrequest (CO_Data* d, UNS32 cobId);
|
|
79 |
|
|
80 |
/** Compute a PDO frame reception
|
|
81 |
* bus_id is hardware dependant
|
|
82 |
* return 0xFF if error, else return 0
|
|
83 |
*/
|
|
84 |
UNS8 proceedPDO (CO_Data* d, Message *m);
|
|
85 |
|
|
86 |
/* used by the application to send a variable by PDO.
|
|
87 |
* Check in which PDO the variable is mapped, and send the PDO.
|
|
88 |
* of course, the others variables mapped in the PDO are also sent !
|
|
89 |
* ( ie when a specific event occured)
|
|
90 |
* bus_id is hardware dependant
|
|
91 |
* variable is a pointer to the variable which has to be sent. Must be
|
|
92 |
* defined in the object dictionary
|
|
93 |
* return 0xFF if error, else return 0
|
|
94 |
*/
|
|
95 |
UNS8 sendPDOevent (CO_Data* d, void * variable);
|
|
96 |
|
|
97 |
#endif
|