
#ifndef ETHERCAT_MASTER_MAILBOX_GATEWAY_H
#define ETHERCAT_MASTER_MAILBOX_GATEWAY_H

#include "../ethercat_types.h"
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef DYNAMIC_LOAD

BOOL     WriteSlaveRegister(uint16_t master_index, uint16_t slave_index,
                             uint16_t reg_addr, uint8_t* data, uint32_t len);
BOOL     ReadSlaveRegister(uint16_t master_index, uint16_t slave_index,
                            uint16_t reg_addr, uint8_t* data, uint32_t len);
BOOL     ConfigureSyncManager(uint16_t master_index, uint16_t slave_index,
                               uint8_t sm_index, uint16_t start_addr, uint16_t length,
                               uint8_t control, BOOL enable);
BOOL     ConfigureFMMU(uint16_t master_index, uint16_t slave_index,
                        uint8_t fmmu_index, uint32_t logical_addr, uint16_t length,
                        uint8_t logical_start_bit, uint8_t logical_end_bit,
                        uint16_t physical_addr, uint8_t physical_start_bit,
                        uint8_t fmmu_type, BOOL enable);

BOOL     EnableOutputSyncManager(uint16_t master_index, uint16_t slave_index);
BOOL     DisableOutputSyncManager(uint16_t master_index, uint16_t slave_index);
BOOL     GetSlaveOpOnlyFlag(uint16_t master_index, uint16_t slave_index);

BOOL     SetSlaveErrorAck(uint16_t master_index, uint16_t slave_index, BOOL set_ack);
BOOL     GetSlaveDeviceEmulationFlag(uint16_t master_index, uint16_t slave_index);

BOOL     SetSlaveWatchdog(uint16_t master_index, uint16_t slave_index, uint32_t timeout_ms);
BOOL     SetSlavePdiWatchdog(uint16_t master_index, uint16_t slave_index, uint32_t timeout_ms);
BOOL     GetSlaveWatchdogConfig(uint16_t master_index, uint16_t slave_index, ec_watchdog_config_t* config);
BOOL     GetSlaveWatchdogStatus(uint16_t master_index, uint16_t slave_index, ec_watchdog_status_t* status);
int      SetAllSlaveWatchdog(uint16_t master_index, uint32_t timeout_ms);
int      SetAllSlavePdiWatchdog(uint16_t master_index, uint32_t timeout_ms);

#endif

#ifdef __cplusplus
}
#endif

#endif
