--- a/master/mailbox.h Mon Mar 14 11:20:05 2011 +0100
+++ b/master/mailbox.h Mon Mar 14 16:57:47 2011 +0100
@@ -37,7 +37,8 @@
#ifndef __EC_MAILBOX_H__
#define __EC_MAILBOX_H__
-#include "slave.h"
+#include "globals.h"
+#include "datagram.h"
/*****************************************************************************/
@@ -47,12 +48,53 @@
/*****************************************************************************/
-uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t *, ec_datagram_t *,
+/** EtherCAT slave mailbox.
+ */
+struct ec_mailbox
+{
+ ec_datagram_t* datagram; /**< Datagram used for the mailbox content. */
+#ifdef EC_REDUCE_MBOXFRAMESIZE
+ ec_datagram_t end_datagram; /**< Datagram used for writing the end byte to the mailbox. */
+#endif
+};
+typedef struct ec_mailbox ec_mailbox_t; /**< \see ec_mailbox. */
+
+/*****************************************************************************/
+
+void ec_mbox_init(ec_mailbox_t *, ec_datagram_t*);
+void ec_mbox_clear(ec_mailbox_t*);
+/**
+ Checks the datagrams states.
+*/
+static inline int ec_mbox_is_datagram_state(ec_mailbox_t*mbox,
+ ec_datagram_state_t state) {
+ return (mbox->datagram->state == state)
+#ifdef EC_REDUCE_MBOXFRAMESIZE
+ && (mbox->end_datagram.type == EC_DATAGRAM_NONE || mbox->end_datagram.state == state)
+#endif
+ ;
+}
+
+/**
+ Checks the datagrams working counter.
+*/
+static inline int ec_mbox_is_datagram_wc(ec_mailbox_t*mbox,
+ size_t wc) {
+ return (mbox->datagram->working_counter == wc)
+#ifdef EC_REDUCE_MBOXFRAMESIZE
+ && (mbox->end_datagram.type == EC_DATAGRAM_NONE || mbox->end_datagram.working_counter == wc)
+#endif
+ ;
+}
+
+void ec_slave_mbox_queue_datagrams(const ec_slave_t*,ec_mailbox_t*);
+void ec_master_mbox_queue_datagrams(ec_master_t*, ec_mailbox_t*);
+uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t*,ec_mailbox_t *,
uint8_t, size_t);
-int ec_slave_mbox_prepare_check(const ec_slave_t *, ec_datagram_t *);
-int ec_slave_mbox_check(const ec_datagram_t *);
-int ec_slave_mbox_prepare_fetch(const ec_slave_t *, ec_datagram_t *);
-uint8_t *ec_slave_mbox_fetch(const ec_slave_t *, ec_datagram_t *,
+int ec_slave_mbox_prepare_check(const ec_slave_t*,ec_mailbox_t *);
+int ec_slave_mbox_check(ec_mailbox_t *);
+int ec_slave_mbox_prepare_fetch(const ec_slave_t*,ec_mailbox_t *);
+uint8_t *ec_slave_mbox_fetch(const ec_slave_t*,ec_mailbox_t *,
uint8_t *, size_t *);
/*****************************************************************************/