]> rtime.felk.cvut.cz Git - CanFestival-3.git/blob - include/pdo.h
Added removal of dynamically loaded CAN driver interface library in clean make target
[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 #include "can.h"
30
31 typedef struct struct_s_PDO_status s_PDO_status;
32
33 #include "data.h"
34
35 /* Status of the TPDO : */
36 #define PDO_INHIBITED 0x01
37 #define PDO_RTR_SYNC_READY 0x01
38
39 /** The PDO structure */
40 struct struct_s_PDO_status {
41   UNS8 transmit_type_parameter;
42   TIMER_HANDLE event_timer;
43   TIMER_HANDLE inhibit_timer;
44   Message last_message;
45 };
46
47 #define s_PDO_status_Initializer {0, TIMER_NONE, TIMER_NONE, Message_Initializer}
48
49 /** definitions of the different types of PDOs' transmission
50  * 
51  * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal.
52  */
53 #define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */
54 #define TRANS_SYNC_ACYCLIC    0    /* Trans after reception of n SYNC. n = 1 to 240 */
55 #define TRANS_SYNC_MIN        1    /* Trans after reception of n SYNC. n = 1 to 240 */
56 #define TRANS_SYNC_MAX        240  /* Trans after reception of n SYNC. n = 1 to 240 */
57 #define TRANS_RTR_SYNC        252  /* Transmission on request */
58 #define TRANS_RTR             253  /* Transmission on request */
59 #define TRANS_EVENT_SPECIFIC  254  /* Transmission on event */
60 #define TRANS_EVENT_PROFILE   255  /* Transmission on event */
61
62 /** Prepare the PDO defined at index to be sent 
63  * 
64  * 
65  * 
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, UNS8 numPdo, Message *pdo);
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, UNS16 RPDOIndex );
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 signal changes in process data
86  * that could be mapped to some TPDO.
87  * This do not necessarily imply PDO emission.
88  * Function iterates on all TPDO and look TPDO transmit 
89  * type and content change before sending it.    
90  */
91 UNS8 sendPDOevent (CO_Data* d);
92
93 /** Function iterates on all TPDO and look TPDO transmit 
94  * type and content change before sending it.
95  */
96 UNS8 _sendPDOevent(CO_Data* d, UNS8 isSyncEvent);
97
98
99 void PDOInit(CO_Data* d);
100 void PDOStop(CO_Data* d);
101 void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum);
102 void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum);
103
104 /* copy bit per bit in little endian */
105 void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian);
106 #endif