author | groke6 |
Mon, 04 Feb 2008 16:40:44 +0100 | |
changeset 381 | 854c43cdc24a |
parent 366 | 47763dd15e00 |
child 426 | 8011552b1319 |
permissions | -rw-r--r-- |
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 |
||
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
29 |
#include "can.h" |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
30 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
31 |
typedef struct struct_s_PDO_status s_PDO_status; |
0 | 32 |
|
33 |
#include "data.h" |
|
34 |
||
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
35 |
/* Status of the TPDO : */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
36 |
#define PDO_INHIBITED 0x01 |
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
37 |
#define PDO_RTR_SYNC_READY 0x01 |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
38 |
|
0 | 39 |
/** The PDO structure */ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
40 |
struct struct_s_PDO_status { |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
41 |
UNS8 transmit_type_parameter; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
42 |
TIMER_HANDLE event_timer; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
43 |
TIMER_HANDLE inhibit_timer; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
44 |
Message last_message; |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
45 |
}; |
0 | 46 |
|
366 | 47 |
#define s_PDO_status_Initializer {0, TIMER_NONE, TIMER_NONE, Message_Initializer} |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
48 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
49 |
/** definitions of the different types of PDOs' transmission |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
50 |
* |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
51 |
* SYNCHRO(n) means that the PDO will be transmited every n SYNC signal. |
0 | 52 |
*/ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
53 |
#define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
54 |
#define TRANS_SYNC_MIN 1 /* Trans after reception of n SYNC. n = 1 to 240 */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
55 |
#define TRANS_SYNC_MAX 240 /* Trans after reception of n SYNC. n = 1 to 240 */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
56 |
#define TRANS_RTR_SYNC 252 /* Transmission on request */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
57 |
#define TRANS_RTR 253 /* Transmission on request */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
58 |
#define TRANS_EVENT_SPECIFIC 254 /* Transmission on event */ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
59 |
#define TRANS_EVENT_PROFILE 255 /* Transmission on event */ |
0 | 60 |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
61 |
/** Prepare the PDO defined at index to be sent |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
62 |
* |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
63 |
* |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
64 |
* |
0 | 65 |
* Copy all the data to transmit in process_var |
66 |
* *pwCobId : returns the value of the cobid. (subindex 1) |
|
67 |
* Return 0 or 0xFF if error. |
|
68 |
*/ |
|
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
69 |
UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo); |
0 | 70 |
|
71 |
/** Transmit a PDO request frame on the bus bus_id |
|
72 |
* to the slave. |
|
73 |
* bus_id is hardware dependant |
|
74 |
* Returns 0xFF if error, other in success. |
|
75 |
*/ |
|
236
905677ed00f3
Full preliminary implementation of TPDO transmit type:
etisserant
parents:
235
diff
changeset
|
76 |
UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex ); |
0 | 77 |
|
78 |
/** Compute a PDO frame reception |
|
79 |
* bus_id is hardware dependant |
|
80 |
* return 0xFF if error, else return 0 |
|
81 |
*/ |
|
82 |
UNS8 proceedPDO (CO_Data* d, Message *m); |
|
83 |
||
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
84 |
/** Used by the application to signal changes in process data |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
85 |
* that could be mapped to some TPDO. |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
86 |
* This do not necessarily imply PDO emission. |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
87 |
* Function iterates on all TPDO and look TPDO transmit |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
88 |
* type and content change before sending it. |
0 | 89 |
*/ |
235
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
90 |
UNS8 sendPDOevent (CO_Data* d); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
91 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
92 |
/** Function iterates on all TPDO and look TPDO transmit |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
93 |
* type and content change before sending it. |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
94 |
*/ |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
95 |
UNS8 _sendPDOevent(CO_Data* d, UNS8 isSyncEvent); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
96 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
97 |
|
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
98 |
void PDOInit(CO_Data* d); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
99 |
void PDOStop(CO_Data* d); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
100 |
void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum); |
f812bf6b7237
Preliminary implementation of Event Timer and Inhibit Timer driven TPDO
etisserant
parents:
201
diff
changeset
|
101 |
void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum); |
0 | 102 |
|
201 | 103 |
/* copy bit per bit in little endian */ |
104 |
void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian); |
|
0 | 105 |
#endif |