![](/media/cache/profiles/IMG_2753.JPG.50x50_q85.jpg)
Can_open_masternode
framework/include/pdo.h@0:9dd7c6129683, 2011-05-30 (annotated)
- Committer:
- sam_grove
- Date:
- Mon May 30 07:36:47 2011 +0000
- Revision:
- 0:9dd7c6129683
Initial public release of master node example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove |
0:9dd7c6129683 | 1 | /* |
sam_grove |
0:9dd7c6129683 | 2 | This file is part of CanFestival, a library implementing CanOpen Stack. |
sam_grove |
0:9dd7c6129683 | 3 | |
sam_grove |
0:9dd7c6129683 | 4 | Copyright (C): Edouard TISSERANT and Francis DUPIN |
sam_grove |
0:9dd7c6129683 | 5 | |
sam_grove |
0:9dd7c6129683 | 6 | See COPYING file for copyrights details. |
sam_grove |
0:9dd7c6129683 | 7 | |
sam_grove |
0:9dd7c6129683 | 8 | This library is free software; you can redistribute it and/or |
sam_grove |
0:9dd7c6129683 | 9 | modify it under the terms of the GNU Lesser General Public |
sam_grove |
0:9dd7c6129683 | 10 | License as published by the Free Software Foundation; either |
sam_grove |
0:9dd7c6129683 | 11 | version 2.1 of the License, or (at your option) any later version. |
sam_grove |
0:9dd7c6129683 | 12 | |
sam_grove |
0:9dd7c6129683 | 13 | This library is distributed in the hope that it will be useful, |
sam_grove |
0:9dd7c6129683 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
sam_grove |
0:9dd7c6129683 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
sam_grove |
0:9dd7c6129683 | 16 | Lesser General Public License for more details. |
sam_grove |
0:9dd7c6129683 | 17 | |
sam_grove |
0:9dd7c6129683 | 18 | You should have received a copy of the GNU Lesser General Public |
sam_grove |
0:9dd7c6129683 | 19 | License along with this library; if not, write to the Free Software |
sam_grove |
0:9dd7c6129683 | 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
sam_grove |
0:9dd7c6129683 | 21 | */ |
sam_grove |
0:9dd7c6129683 | 22 | |
sam_grove |
0:9dd7c6129683 | 23 | /** @defgroup pdo Process Data Object (PDO) |
sam_grove |
0:9dd7c6129683 | 24 | * PDO is a communication object defined by the DPO communication parameter and PDA mapping parameter objects. |
sam_grove |
0:9dd7c6129683 | 25 | * It is an uncomfirmed communication service without protocol overhead. |
sam_grove |
0:9dd7c6129683 | 26 | * @ingroup comobj |
sam_grove |
0:9dd7c6129683 | 27 | */ |
sam_grove |
0:9dd7c6129683 | 28 | |
sam_grove |
0:9dd7c6129683 | 29 | #ifndef __pdo_h__ |
sam_grove |
0:9dd7c6129683 | 30 | #define __pdo_h__ |
sam_grove |
0:9dd7c6129683 | 31 | |
sam_grove |
0:9dd7c6129683 | 32 | #include <applicfg.h> |
sam_grove |
0:9dd7c6129683 | 33 | #include <def.h> |
sam_grove |
0:9dd7c6129683 | 34 | |
sam_grove |
0:9dd7c6129683 | 35 | #include "canopen_can.h" |
sam_grove |
0:9dd7c6129683 | 36 | |
sam_grove |
0:9dd7c6129683 | 37 | typedef struct struct_s_PDO_status s_PDO_status; |
sam_grove |
0:9dd7c6129683 | 38 | |
sam_grove |
0:9dd7c6129683 | 39 | #include "data.h" |
sam_grove |
0:9dd7c6129683 | 40 | |
sam_grove |
0:9dd7c6129683 | 41 | #ifdef __cplusplus |
sam_grove |
0:9dd7c6129683 | 42 | extern "C"{ |
sam_grove |
0:9dd7c6129683 | 43 | #endif |
sam_grove |
0:9dd7c6129683 | 44 | |
sam_grove |
0:9dd7c6129683 | 45 | /* Status of the TPDO : */ |
sam_grove |
0:9dd7c6129683 | 46 | #define PDO_INHIBITED 0x01 |
sam_grove |
0:9dd7c6129683 | 47 | #define PDO_RTR_SYNC_READY 0x01 |
sam_grove |
0:9dd7c6129683 | 48 | |
sam_grove |
0:9dd7c6129683 | 49 | /** The PDO structure */ |
sam_grove |
0:9dd7c6129683 | 50 | struct struct_s_PDO_status { |
sam_grove |
0:9dd7c6129683 | 51 | UNS8 transmit_type_parameter; |
sam_grove |
0:9dd7c6129683 | 52 | TIMER_HANDLE event_timer; |
sam_grove |
0:9dd7c6129683 | 53 | TIMER_HANDLE inhibit_timer; |
sam_grove |
0:9dd7c6129683 | 54 | Message last_message; |
sam_grove |
0:9dd7c6129683 | 55 | }; |
sam_grove |
0:9dd7c6129683 | 56 | |
sam_grove |
0:9dd7c6129683 | 57 | #define s_PDO_status_Initializer {0, TIMER_NONE, TIMER_NONE, Message_Initializer} |
sam_grove |
0:9dd7c6129683 | 58 | |
sam_grove |
0:9dd7c6129683 | 59 | /** definitions of the different types of PDOs' transmission |
sam_grove |
0:9dd7c6129683 | 60 | * |
sam_grove |
0:9dd7c6129683 | 61 | * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal. |
sam_grove |
0:9dd7c6129683 | 62 | */ |
sam_grove |
0:9dd7c6129683 | 63 | #define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */ |
sam_grove |
0:9dd7c6129683 | 64 | #define TRANS_SYNC_ACYCLIC 0 /* Trans after reception of n SYNC. n = 1 to 240 */ |
sam_grove |
0:9dd7c6129683 | 65 | #define TRANS_SYNC_MIN 1 /* Trans after reception of n SYNC. n = 1 to 240 */ |
sam_grove |
0:9dd7c6129683 | 66 | #define TRANS_SYNC_MAX 240 /* Trans after reception of n SYNC. n = 1 to 240 */ |
sam_grove |
0:9dd7c6129683 | 67 | #define TRANS_RTR_SYNC 252 /* Transmission on request */ |
sam_grove |
0:9dd7c6129683 | 68 | #define TRANS_RTR 253 /* Transmission on request */ |
sam_grove |
0:9dd7c6129683 | 69 | #define TRANS_EVENT_SPECIFIC 254 /* Transmission on event */ |
sam_grove |
0:9dd7c6129683 | 70 | #define TRANS_EVENT_PROFILE 255 /* Transmission on event */ |
sam_grove |
0:9dd7c6129683 | 71 | |
sam_grove |
0:9dd7c6129683 | 72 | /** |
sam_grove |
0:9dd7c6129683 | 73 | * @brief Copy all the data to transmit in process_var |
sam_grove |
0:9dd7c6129683 | 74 | * Prepare the PDO defined at index to be sent |
sam_grove |
0:9dd7c6129683 | 75 | * *pwCobId : returns the value of the cobid. (subindex 1) |
sam_grove |
0:9dd7c6129683 | 76 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 77 | * @param numPdo The PDO number |
sam_grove |
0:9dd7c6129683 | 78 | * @param *pdo Pointer on a CAN message structure |
sam_grove |
0:9dd7c6129683 | 79 | * @return 0 or 0xFF if error. |
sam_grove |
0:9dd7c6129683 | 80 | */ |
sam_grove |
0:9dd7c6129683 | 81 | UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo); |
sam_grove |
0:9dd7c6129683 | 82 | |
sam_grove |
0:9dd7c6129683 | 83 | /** |
sam_grove |
0:9dd7c6129683 | 84 | * @ingroup pdo |
sam_grove |
0:9dd7c6129683 | 85 | * @brief Transmit a PDO request frame on the network to the slave. |
sam_grove |
0:9dd7c6129683 | 86 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 87 | * @param RPDOIndex Index of the receive PDO |
sam_grove |
0:9dd7c6129683 | 88 | * @return |
sam_grove |
0:9dd7c6129683 | 89 | * - CanFestival file descriptor is returned upon success. |
sam_grove |
0:9dd7c6129683 | 90 | * - 0xFF is returned if RPDO Index is not found. |
sam_grove |
0:9dd7c6129683 | 91 | |
sam_grove |
0:9dd7c6129683 | 92 | * @return 0xFF if error, other in success. |
sam_grove |
0:9dd7c6129683 | 93 | */ |
sam_grove |
0:9dd7c6129683 | 94 | UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex ); |
sam_grove |
0:9dd7c6129683 | 95 | |
sam_grove |
0:9dd7c6129683 | 96 | /** |
sam_grove |
0:9dd7c6129683 | 97 | * @brief Compute a PDO frame reception |
sam_grove |
0:9dd7c6129683 | 98 | * bus_id is hardware dependant |
sam_grove |
0:9dd7c6129683 | 99 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 100 | * @param *m Pointer on a CAN message structure |
sam_grove |
0:9dd7c6129683 | 101 | * @return 0xFF if error, else return 0 |
sam_grove |
0:9dd7c6129683 | 102 | */ |
sam_grove |
0:9dd7c6129683 | 103 | UNS8 proceedPDO (CO_Data* d, Message *m); |
sam_grove |
0:9dd7c6129683 | 104 | |
sam_grove |
0:9dd7c6129683 | 105 | /** |
sam_grove |
0:9dd7c6129683 | 106 | * @brief Used by the application to signal changes in process data |
sam_grove |
0:9dd7c6129683 | 107 | * that could be mapped to some TPDO. |
sam_grove |
0:9dd7c6129683 | 108 | * This do not necessarily imply PDO emission. |
sam_grove |
0:9dd7c6129683 | 109 | * Function iterates on all TPDO and look TPDO transmit |
sam_grove |
0:9dd7c6129683 | 110 | * type and content change before sending it. |
sam_grove |
0:9dd7c6129683 | 111 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 112 | */ |
sam_grove |
0:9dd7c6129683 | 113 | UNS8 sendPDOevent (CO_Data* d); |
sam_grove |
0:9dd7c6129683 | 114 | UNS8 sendOnePDOevent (CO_Data* d, UNS8 pdoNum); |
sam_grove |
0:9dd7c6129683 | 115 | |
sam_grove |
0:9dd7c6129683 | 116 | /** |
sam_grove |
0:9dd7c6129683 | 117 | * @ingroup pdo |
sam_grove |
0:9dd7c6129683 | 118 | * @brief Function iterates on all TPDO and look TPDO transmit |
sam_grove |
0:9dd7c6129683 | 119 | * type and content change before sending it. |
sam_grove |
0:9dd7c6129683 | 120 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 121 | * @param isSyncEvent |
sam_grove |
0:9dd7c6129683 | 122 | */ |
sam_grove |
0:9dd7c6129683 | 123 | UNS8 _sendPDOevent(CO_Data* d, UNS8 isSyncEvent); |
sam_grove |
0:9dd7c6129683 | 124 | |
sam_grove |
0:9dd7c6129683 | 125 | /** |
sam_grove |
0:9dd7c6129683 | 126 | * @brief Initialize PDO feature |
sam_grove |
0:9dd7c6129683 | 127 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 128 | */ |
sam_grove |
0:9dd7c6129683 | 129 | void PDOInit(CO_Data* d); |
sam_grove |
0:9dd7c6129683 | 130 | |
sam_grove |
0:9dd7c6129683 | 131 | /** |
sam_grove |
0:9dd7c6129683 | 132 | * @brief Stop PDO feature |
sam_grove |
0:9dd7c6129683 | 133 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 134 | */ |
sam_grove |
0:9dd7c6129683 | 135 | void PDOStop(CO_Data* d); |
sam_grove |
0:9dd7c6129683 | 136 | |
sam_grove |
0:9dd7c6129683 | 137 | /** |
sam_grove |
0:9dd7c6129683 | 138 | * @ingroup pdo |
sam_grove |
0:9dd7c6129683 | 139 | * @brief Set timer for PDO event |
sam_grove |
0:9dd7c6129683 | 140 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 141 | * @param pdoNum The PDO number |
sam_grove |
0:9dd7c6129683 | 142 | */ |
sam_grove |
0:9dd7c6129683 | 143 | void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum); |
sam_grove |
0:9dd7c6129683 | 144 | |
sam_grove |
0:9dd7c6129683 | 145 | /** |
sam_grove |
0:9dd7c6129683 | 146 | * @ingroup pdo |
sam_grove |
0:9dd7c6129683 | 147 | * @brief Inhibit timer for PDO event |
sam_grove |
0:9dd7c6129683 | 148 | * @param *d Pointer on a CAN object data structure |
sam_grove |
0:9dd7c6129683 | 149 | * @param pdoNum The PDO number |
sam_grove |
0:9dd7c6129683 | 150 | */ |
sam_grove |
0:9dd7c6129683 | 151 | void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum); |
sam_grove |
0:9dd7c6129683 | 152 | |
sam_grove |
0:9dd7c6129683 | 153 | /* copy bit per bit in little endian */ |
sam_grove |
0:9dd7c6129683 | 154 | void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian); |
sam_grove |
0:9dd7c6129683 | 155 | |
sam_grove |
0:9dd7c6129683 | 156 | #ifdef __cplusplus |
sam_grove |
0:9dd7c6129683 | 157 | } |
sam_grove |
0:9dd7c6129683 | 158 | #endif |
sam_grove |
0:9dd7c6129683 | 159 | #endif |