40#ifndef LIBETHERCAT_MBX_H
41#define LIBETHERCAT_MBX_H
43#include <libosal/types.h>
44#include <libosal/osal.h>
45#include <libosal/task.h>
49#if LIBETHERCAT_MBX_SUPPORT_COE == 1
53#if LIBETHERCAT_MBX_SUPPORT_SOE == 1
57#if LIBETHERCAT_MBX_SUPPORT_FOE == 1
61#if LIBETHERCAT_MBX_SUPPORT_EOE == 1
75#define MAILBOX_WRITE (osal_uint16_t)(0u)
76#define MAILBOX_READ (osal_uint16_t)(1u)
82#define MESSAGE_POOL_DEBUG(type) {}
147#if LIBETHERCAT_MBX_SUPPORT_COE == 1
151#if LIBETHERCAT_MBX_SUPPORT_SOE == 1
155#if LIBETHERCAT_MBX_SUPPORT_FOE == 1
159#if LIBETHERCAT_MBX_SUPPORT_EOE == 1
163 osal_uint32_t sm_state_bitno;
263#define ec_mbx_get_free_recv_buffer(pec, slave, entry, timeout, lock) \
264 pool_get(&(pec)->mbx_message_pool_recv_free, &(entry), (timeout))
266#define ec_mbx_get_free_send_buffer_old(pec, slave, entry, timeout, lock) \
267 pool_get(&(pec)->mbx_message_pool_send_free, &(entry), (timeout))
284#define ec_mbx_return_free_send_buffer(pec, slave, entry) \
285 pool_put(&(pec)->mbx_message_pool_send_free, (entry))
287#define ec_mbx_return_free_recv_buffer(pec, slave, entry) \
288 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.
void ec_mbx_do_handle(ec_t *pec, uint16_t slave)
Handle slaves mailbox.
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:94
@ EC_MBX_EOE
Ethernet over EtherCAT mailbox.
Definition mbx.h:96
@ EC_MBX_AOE
ADS over EtherCAT mailbox.
Definition mbx.h:95
@ EC_MBX_COE
CANopen over EtherCAT mailbox.
Definition mbx.h:97
@ EC_MBX_VOE
Vendor over EtherCAT mailbox.
Definition mbx.h:100
@ EC_MBX_SOE
Servo over EtherCAT mailbox.
Definition mbx.h:99
@ EC_MBX_FOE
File over EtherCAT mailbox.
Definition mbx.h:98
Data pool implementation.
ethercat mailbox data
Definition mbx.h:113
ec_mbx_header_t mbx_hdr
mailbox header
Definition mbx.h:114
ec_data_t mbx_data
mailbox data
Definition mbx.h:115
int handler_running
Mailbox handler thread running flag.
Definition mbx.h:123
osal_mutex_t sync_mutex
Sync mutex for handler flags.
Definition mbx.h:120
osal_uint8_t mbx_state
State if not mapped.
Definition mbx.h:172
osal_mutex_t lock
mailbox lock
Definition mbx.h:136
ec_t * pec
Pointer to ethercat master structure.
Definition mbx.h:124
pool_t message_pool_send_queued
Pool with mailbox buffers ready to be sent.
Definition mbx.h:145
osal_uint8_t * sm_state
Sync manager state of read mailbox.
Definition mbx.h:164
osal_uint32_t handler_flags
Flags signalling handler recv of send action.
Definition mbx.h:119
int seq_counter
mailbox sequence counter
Definition mbx.h:143
osal_binary_semaphore_t sync_sem
Mailbox sync semaphore.
Definition mbx.h:121
osal_task_t handler_tid
Mailbox handler thread handle.
Definition mbx.h:134
int slave
Number of EtherCAT slave.
Definition mbx.h:129
ethercat master structure
Definition ec.h:192
Pool queue entry.
Definition pool.h:67
the datagram pool itself
Definition pool.h:84