]> rtime.felk.cvut.cz Git - CanFestival-3.git/blobdiff - include/pdo.h
Second time, Re-write doxygen tags in headers files to generate User API documentation
[CanFestival-3.git] / include / pdo.h
index 741caa85f2e5fa912d99cbee2a888a4cb98397da..03af28b38e5f103ca86f304b083e8562188b6895 100644 (file)
@@ -20,78 +20,129 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+/** @defgroup pdo Process Data Object (PDO)
+ *  PDO is a communication object defined by the DPO communication parameter and PDA mapping parameter objects.
+ *  It is an uncomfirmed communication service without protocol overhead.
+ *  @ingroup comobj
+ */
 #ifndef __pdo_h__
 #define __pdo_h__
 
 #include <applicfg.h>
 #include <def.h>
 
-/* The process_var structure
- Used to store the PDO before the transmission or the reception.
-*/
-typedef struct struct_s_process_var {
-  UNS8 count; /* Size of data. Ex : for a PDO of 6 bytes of data, count = 6 */
-  /* WARNING s_process_var.data is subject to ENDIANISATION 
-   * (with respect to CANOPEN_BIG_ENDIAN)
-   */
-  UNS8 data[PDO_MAX_LEN];
-}s_process_var;
+#include "can.h"
+
+typedef struct struct_s_PDO_status s_PDO_status;
 
 #include "data.h"
 
-/** The PDO structure */
-typedef struct struct_s_PDO {
-  UNS32 cobId;   /* COB-ID */
-  UNS8           len;    /* Number of data transmitted (in data[]) */
-  UNS8           data[8]; /* Contain the data */
-}s_PDO;
-
-/** Transmit a PDO data frame on the bus bus_id
- * pdo is a structure which contains the pdo to transmit
- * bus_id is hardware dependant
- * return canSend(bus_id,&m) or 0xFF if error
- * request can take the value  REQUEST or NOT_A_REQUEST
- */
-UNS8 sendPDO (CO_Data* d, s_PDO pdo, UNS8 request);
+/* Status of the TPDO : */
+#define PDO_INHIBITED 0x01
+#define PDO_RTR_SYNC_READY 0x01
 
-/** Prepare a PDO frame transmission, 
- * whose different parameters are stored in process_var table,
- * to the slave.
- * bus_id is hardware dependant
- * call the function sendPDO
- * return the result of the function sendPDO or 0xFF if error
+/** The PDO structure */
+struct struct_s_PDO_status {
+  UNS8 transmit_type_parameter;
+  TIMER_HANDLE event_timer;
+  TIMER_HANDLE inhibit_timer;
+  Message last_message;
+};
+
+#define s_PDO_status_Initializer {0, TIMER_NONE, TIMER_NONE, Message_Initializer}
+
+/** definitions of the different types of PDOs' transmission
+ * 
+ * SYNCHRO(n) means that the PDO will be transmited every n SYNC signal.
  */
-UNS8 PDOmGR (CO_Data* d, UNS32 cobId);
-
-/** Prepare the PDO defined at index to be sent by  PDOmGR
- * Copy all the data to transmit in process_var
+#define TRANS_EVERY_N_SYNC(n) (n) /*n = 1 to 240 */
+#define TRANS_SYNC_ACYCLIC    0    /* Trans after reception of n SYNC. n = 1 to 240 */
+#define TRANS_SYNC_MIN        1    /* Trans after reception of n SYNC. n = 1 to 240 */
+#define TRANS_SYNC_MAX        240  /* Trans after reception of n SYNC. n = 1 to 240 */
+#define TRANS_RTR_SYNC        252  /* Transmission on request */
+#define TRANS_RTR             253  /* Transmission on request */
+#define TRANS_EVENT_SPECIFIC  254  /* Transmission on event */
+#define TRANS_EVENT_PROFILE   255  /* Transmission on event */
+
+/** 
+ * @brief Copy all the data to transmit in process_var
+ * Prepare the PDO defined at index to be sent
  * *pwCobId : returns the value of the cobid. (subindex 1)
- * Return 0 or 0xFF if error.
+ * @param *d Pointer on a CAN object data structure
+ * @param numPdo The PDO number
+ * @param *pdo Pointer on a CAN message structure
+ * @return 0 or 0xFF if error.
  */
-UNS8 buildPDO (CO_Data* d, UNS16 index);
+UNS8 buildPDO(CO_Data* d, UNS8 numPdo, Message *pdo);
 
-/** Transmit a PDO request frame on the bus bus_id
+/** 
+ * @ingroup pdo
+ * @brief Transmit a PDO request frame on the bus bus_id
  * to the slave.
  * bus_id is hardware dependant
- * Returns 0xFF if error, other in success.
+ * @param *d Pointer on a CAN object data structure
+ * @param RPDOIndex Index of the receive PDO
+ * @return 0xFF if error, other in success.
  */
-UNS8 sendPDOrequest (CO_Data* d, UNS32 cobId);
+UNS8 sendPDOrequest( CO_Data* d, UNS16 RPDOIndex );
 
-/** Compute a PDO frame reception
+/**
+ * @brief Compute a PDO frame reception
  * bus_id is hardware dependant
- * return 0xFF if error, else return 0
+ * @param *d Pointer on a CAN object data structure
+ * @param *m Pointer on a CAN message structure
+ * @return 0xFF if error, else return 0
  */
 UNS8 proceedPDO (CO_Data* d, Message *m);
 
-/* used by the application to send a variable by PDO.
- * Check in which PDO the variable is mapped, and send the PDO. 
- * of course, the others variables mapped in the PDO are also sent !
- * ( ie when a specific event occured)
- * bus_id is hardware dependant
- * variable is a pointer to the variable which has to be sent. Must be
- * defined in the object dictionary
- * return 0xFF if error, else return 0
+/** 
+ * @brief Used by the application to signal changes in process data
+ * that could be mapped to some TPDO.
+ * This do not necessarily imply PDO emission.
+ * Function iterates on all TPDO and look TPDO transmit 
+ * type and content change before sending it.    
+ * @param *d Pointer on a CAN object data structure
+ */
+UNS8 sendPDOevent (CO_Data* d);
+
+/** 
+ * @ingroup pdo
+ * @brief Function iterates on all TPDO and look TPDO transmit 
+ * type and content change before sending it.
+ * @param *d Pointer on a CAN object data structure
+ * @param isSyncEvent
+ */
+UNS8 _sendPDOevent(CO_Data* d, UNS8 isSyncEvent);
+
+/** 
+ * @brief Initialize PDO feature 
+ * @param *d Pointer on a CAN object data structure
+ */
+void PDOInit(CO_Data* d);
+
+/** 
+ * @brief Stop PDO feature 
+ * @param *d Pointer on a CAN object data structure
+ */
+void PDOStop(CO_Data* d);
+
+/** 
+ * @ingroup pdo
+ * @brief Set timer for PDO event
+ * @param *d Pointer on a CAN object data structure
+ * @param pdoNum The PDO number
+ */
+void PDOEventTimerAlarm(CO_Data* d, UNS32 pdoNum);
+
+/** 
+ * @ingroup pdo
+ * @brief Inhibit timer for PDO event
+ * @param *d Pointer on a CAN object data structure
+ * @param pdoNum The PDO number
  */
-UNS8 sendPDOevent (CO_Data* d, void * variable);
+void PDOInhibitTimerAlarm(CO_Data* d, UNS32 pdoNum);
 
+/* copy bit per bit in little endian */
+void CopyBits(UNS8 NbBits, UNS8* SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8* DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian);
 #endif