40#ifndef LIBETHERCAT_MBX_H
41#define LIBETHERCAT_MBX_H
43#include <libosal/types.h>
44#include <libosal/osal.h>
48#if LIBETHERCAT_MBX_SUPPORT_COE == 1
52#if LIBETHERCAT_MBX_SUPPORT_SOE == 1
56#if LIBETHERCAT_MBX_SUPPORT_FOE == 1
60#if LIBETHERCAT_MBX_SUPPORT_EOE == 1
74#define MAILBOX_WRITE (osal_uint16_t)(0u)
75#define MAILBOX_READ (osal_uint16_t)(1u)
81#define MESSAGE_POOL_DEBUG(type) {}
146#if LIBETHERCAT_MBX_SUPPORT_COE == 1
150#if LIBETHERCAT_MBX_SUPPORT_SOE == 1
154#if LIBETHERCAT_MBX_SUPPORT_FOE == 1
158#if LIBETHERCAT_MBX_SUPPORT_EOE == 1
162 osal_uint32_t sm_state_bitno;
262#define ec_mbx_get_free_recv_buffer(pec, slave, entry, timeout, lock) \
263 pool_get(&(pec)->mbx_message_pool_recv_free, &(entry), (timeout))
265#define ec_mbx_get_free_send_buffer_old(pec, slave, entry, timeout, lock) \
266 pool_get(&(pec)->mbx_message_pool_send_free, &(entry), (timeout))
283#define ec_mbx_return_free_send_buffer(pec, slave, entry) \
284 pool_put(&(pec)->mbx_message_pool_send_free, (entry))
286#define ec_mbx_return_free_recv_buffer(pec, slave, entry) \
287 pool_put(&(pec)->mbx_message_pool_recv_free, (entry))
ethercat master common stuff
file over ethercat fuctions
int ec_mbx_next_counter(ec_t *pec, int slave, int *seq_counter)
Get next sequence counter.
void ec_mbx_deinit(ec_t *pec, osal_uint16_t slave)
Deinit mailbox structure.
struct PACKED ec_mbx_buffer ec_mbx_buffer_t
ethercat mailbox data
void ec_mbx_enqueue_head(ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry)
Enqueue mailbox message to send queue.
void ec_mbx_sched_read(ec_t *pec, osal_uint16_t slave)
Trigger read of mailbox.
int ec_mbx_get_free_send_buffer(ec_t *pec, osal_uint16_t slave, pool_entry_t **pp_entry, osal_timer_t *timeout)
Get free mailbox send buffer from slaves send message pool.
void ec_mbx_init(ec_t *pec, osal_uint16_t slave)
Initialize mailbox structure.
int ec_mbx_check(ec_t *pec, int slave, osal_uint16_t mbx_flag)
Checks if mailbox protocol is supported by slave.
void ec_mbx_enqueue_tail(ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry)
Enqueue mailbox message to send queue.
struct PACKED ec_mbx_header ec_mbx_header_t
ethercat mailbox header
@ EC_MBX_ERR
error mailbox
Definition mbx.h:93
@ EC_MBX_EOE
Ethernet over EtherCAT mailbox.
Definition mbx.h:95
@ EC_MBX_AOE
ADS over EtherCAT mailbox.
Definition mbx.h:94
@ EC_MBX_COE
CANopen over EtherCAT mailbox.
Definition mbx.h:96
@ EC_MBX_VOE
Vendor over EtherCAT mailbox.
Definition mbx.h:99
@ EC_MBX_SOE
Servo over EtherCAT mailbox.
Definition mbx.h:98
@ EC_MBX_FOE
File over EtherCAT mailbox.
Definition mbx.h:97
Data pool implementation.
ethercat mailbox data
Definition mbx.h:112
ec_mbx_header_t mbx_hdr
mailbox header
Definition mbx.h:113
ec_data_t mbx_data
mailbox data
Definition mbx.h:114
int handler_running
Mailbox handler thread running flag.
Definition mbx.h:122
osal_mutex_t sync_mutex
Sync mutex for handler flags.
Definition mbx.h:119
osal_uint8_t mbx_state
State if not mapped.
Definition mbx.h:171
osal_mutex_t lock
mailbox lock
Definition mbx.h:135
ec_t * pec
Pointer to ethercat master structure.
Definition mbx.h:123
pool_t message_pool_send_queued
Pool with mailbox buffers ready to be sent.
Definition mbx.h:144
osal_uint8_t * sm_state
Sync manager state of read mailbox.
Definition mbx.h:163
osal_uint32_t handler_flags
Flags signalling handler recv of send action.
Definition mbx.h:118
int seq_counter
mailbox sequence counter
Definition mbx.h:142
osal_binary_semaphore_t sync_sem
Mailbox sync semaphore.
Definition mbx.h:120
osal_task_t handler_tid
Mailbox handler thread handle.
Definition mbx.h:133
int slave
Number of EtherCAT slave.
Definition mbx.h:128
ethercat master structure
Definition ec.h:188
Pool queue entry.
Definition pool.h:67
the datagram pool itself
Definition pool.h:81