]> rtime.felk.cvut.cz Git - CanFestival-3.git/blob - include/pdo.h
Re-write doxygen tags in headers files to generate User API documentation
[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 /** @defgroup pdo Process Data Object (PDO)
24  *  PDO is a communication object defined by the DPO communication parameter and PDA mapping parameter objects.
25  *  It is an uncomfirmed communication service without protocol overhead.
26  *  @ingroup comobj
27  */
28  
29 #ifndef __pdo_h__
30 #define __pdo_h__
31
32 #include <applicfg.h>
33 #include <def.h>
34
35 #include "can.h"
36
37 typedef struct struct_s_PDO_status s_PDO_status;
38
39 #include "data.h"
40
41 /* Status of the TPDO : */
42 #define PDO_INHIBITED 0x01
43 #define PDO_RTR_SYNC_READY 0x01
44
45 /** The PDO structure */
46 struct struct_s_PDO_status {
47   UNS8 transmit_type_parameter;
48   TIMER_HANDLE event_timer;
49   TIMER_HANDLE inhibit_timer;
50   Message last_message;
51 };
52
53 #define s_PDO_status_Initializer {0, TIMER_NONE, TIMER_NONE, Message_Initializer}
54
55 /** definitions of the different types of PDOs' transmission
56  * 
57  * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal.
58  */
59 #define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */
60 #define TRANS_SYNC_ACYCLIC    0    /* Trans after reception of n SYNC. n = 1 to 240 */
61 #define TRANS_SYNC_MIN        1    /* Trans after reception of n SYNC. n = 1 to 240 */
62 #define TRANS_SYNC_MAX        240  /* Trans after reception of n SYNC. n = 1 to 240 */
63 #define TRANS_RTR_SYNC        252  /* Transmission on request */
64 #define TRANS_RTR             253  /* Transmission on request */
65 #define TRANS_EVENT_SPECIFIC  254  /* Transmission on event */
66 #define TRANS_EVENT_PROFILE   255  /* Transmission on event */
67
68 /**
69  * @ingroup pdo 
70  * @brief Copy all the data to transmit in process_var
71  * Prepare the PDO defined at index to be sent
72  * *pwCobId : returns the value of the cobid. (subindex 1)
73  * @param *d Pointer on a CAN object data structure
74  * @param numPdo The PDO number
75  * @param *pdo Pointer on a CAN message structure
76  * @return 0 or 0xFF if error.
77  */
78 UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo);
79
80 /** 
81  * @ingroup pdo
82  * @brief Transmit a PDO request frame on the bus bus_id
83  * to the slave.
84  * bus_id is hardware dependant
85  * @param *d Pointer on a CAN object data structure
86  * @param RPDOIndex Index of the receive PDO
87  * @return 0xFF if error, other in success.
88  */
89 UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex );
90
91 /**
92  * @brief Compute a PDO frame reception
93  * bus_id is hardware dependant
94  * @param *d Pointer on a CAN object data structure
95  * @param *m Pointer on a CAN message structure
96  * @return 0xFF if error, else return 0
97  */
98 UNS8 proceedPDO (CO_Data* d, Message *m);
99
100 /**
101  * @ingroup pdo 
102  * @brief Used by the application to signal changes in process data
103  * that could be mapped to some TPDO.
104  * This do not necessarily imply PDO emission.
105  * Function iterates on all TPDO and look TPDO transmit 
106  * type and content change before sending it.    
107  * @param *d Pointer on a CAN object data structure
108  */
109 UNS8 sendPDOevent (CO_Data* d);
110
111 /** 
112  * @ingroup pdo
113  * @brief Function iterates on all TPDO and look TPDO transmit 
114  * type and content change before sending it.
115  * @param *d Pointer on a CAN object data structure
116  * @param isSyncEvent
117  */
118 UNS8 _sendPDOevent(CO_Data* d, UNS8 isSyncEvent);
119
120 /** 
121  * @ingroup pdo
122  * @brief Initialize PDO feature 
123  * @param *d Pointer on a CAN object data structure
124  */
125 void PDOInit(CO_Data* d);
126
127 /** 
128  * @ingroup pdo
129  * @brief Stop PDO feature 
130  * @param *d Pointer on a CAN object data structure
131  */
132 void PDOStop(CO_Data* d);
133
134 /** 
135  * @ingroup pdo
136  * @brief Set timer for PDO event
137  * @param *d Pointer on a CAN object data structure
138  * @param pdoNum The PDO number
139  */
140 void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum);
141
142 /** 
143  * @ingroup pdo
144  * @brief Inhibit timer for PDO event
145  * @param *d Pointer on a CAN object data structure
146  * @param pdoNum The PDO number
147  */
148 void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum);
149
150 /* copy bit per bit in little endian */
151 void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian);
152 #endif