24 #define __pdo_h__ |
24 #define __pdo_h__ |
25 |
25 |
26 #include <applicfg.h> |
26 #include <applicfg.h> |
27 #include <def.h> |
27 #include <def.h> |
28 |
28 |
29 /* The process_var structure |
29 #include "can.h" |
30 Used to store the PDO before the transmission or the reception. |
30 |
31 */ |
31 typedef struct struct_s_PDO_status s_PDO_status; |
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 */ |
|
37 UNS8 data[PDO_MAX_LEN]; |
|
38 }s_process_var; |
|
39 |
32 |
40 #include "data.h" |
33 #include "data.h" |
41 |
34 |
|
35 /* Status of the TPDO : */ |
|
36 #define PDO_INHIBITED 0x01 |
|
37 |
42 /** The PDO structure */ |
38 /** The PDO structure */ |
43 typedef struct struct_s_PDO { |
39 struct struct_s_PDO_status { |
44 UNS32 cobId; /* COB-ID */ |
40 UNS8 transmit_type_parameter; |
45 UNS8 len; /* Number of data transmitted (in data[]) */ |
41 TIMER_HANDLE event_timer; |
46 UNS8 data[8]; /* Contain the data */ |
42 TIMER_HANDLE inhibit_timer; |
47 }s_PDO; |
43 Message last_message; |
|
44 }; |
48 |
45 |
49 /** Transmit a PDO data frame on the bus bus_id |
46 #define s_PDO_staus_Initializer {0, TIMER_NONE, TIMER_NONE, Message_Initializer} |
50 * pdo is a structure which contains the pdo to transmit |
47 |
51 * bus_id is hardware dependant |
48 /** definitions of the different types of PDOs' transmission |
52 * return canSend(bus_id,&m) or 0xFF if error |
49 * |
53 * request can take the value REQUEST or NOT_A_REQUEST |
50 * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal. |
54 */ |
51 */ |
55 UNS8 sendPDO (CO_Data* d, s_PDO pdo, UNS8 request); |
52 #define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */ |
|
53 #define TRANS_SYNC_MIN 1 /* Trans after reception of n SYNC. n = 1 to 240 */ |
|
54 #define TRANS_SYNC_MAX 240 /* Trans after reception of n SYNC. n = 1 to 240 */ |
|
55 #define TRANS_RTR_SYNC 252 /* Transmission on request */ |
|
56 #define TRANS_RTR 253 /* Transmission on request */ |
|
57 #define TRANS_EVENT_SPECIFIC 254 /* Transmission on event */ |
|
58 #define TRANS_EVENT_PROFILE 255 /* Transmission on event */ |
56 |
59 |
57 /** Prepare a PDO frame transmission, |
60 /** Prepare the PDO defined at index to be sent |
58 * whose different parameters are stored in process_var table, |
61 * |
59 * to the slave. |
62 * |
60 * bus_id is hardware dependant |
63 * |
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 |
64 * Copy all the data to transmit in process_var |
68 * *pwCobId : returns the value of the cobid. (subindex 1) |
65 * *pwCobId : returns the value of the cobid. (subindex 1) |
69 * Return 0 or 0xFF if error. |
66 * Return 0 or 0xFF if error. |
70 */ |
67 */ |
71 UNS8 buildPDO (CO_Data* d, UNS16 index); |
68 UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo); |
72 |
69 |
73 /** Transmit a PDO request frame on the bus bus_id |
70 /** Transmit a PDO request frame on the bus bus_id |
74 * to the slave. |
71 * to the slave. |
75 * bus_id is hardware dependant |
72 * bus_id is hardware dependant |
76 * Returns 0xFF if error, other in success. |
73 * Returns 0xFF if error, other in success. |
81 * bus_id is hardware dependant |
78 * bus_id is hardware dependant |
82 * return 0xFF if error, else return 0 |
79 * return 0xFF if error, else return 0 |
83 */ |
80 */ |
84 UNS8 proceedPDO (CO_Data* d, Message *m); |
81 UNS8 proceedPDO (CO_Data* d, Message *m); |
85 |
82 |
86 /* used by the application to send a variable by PDO. |
83 /** Used by the application to signal changes in process data |
87 * Check in which PDO the variable is mapped, and send the PDO. |
84 * that could be mapped to some TPDO. |
88 * of course, the others variables mapped in the PDO are also sent ! |
85 * This do not necessarily imply PDO emission. |
89 * ( ie when a specific event occured) |
86 * Function iterates on all TPDO and look TPDO transmit |
90 * bus_id is hardware dependant |
87 * type and content change before sending it. |
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 */ |
88 */ |
95 UNS8 sendPDOevent (CO_Data* d, void * variable); |
89 UNS8 sendPDOevent (CO_Data* d); |
|
90 |
|
91 /** Function iterates on all TPDO and look TPDO transmit |
|
92 * type and content change before sending it. |
|
93 */ |
|
94 UNS8 _sendPDOevent(CO_Data* d, UNS8 isSyncEvent); |
|
95 |
|
96 |
|
97 void PDOInit(CO_Data* d); |
|
98 void PDOStop(CO_Data* d); |
|
99 void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum); |
|
100 void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum); |
96 |
101 |
97 /* copy bit per bit in little endian */ |
102 /* copy bit per bit in little endian */ |
98 void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian); |
103 void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian); |
99 #endif |
104 #endif |