/* * eth_ecat_api.hpp * * Created on: May 29, 2023 * Author: algin */ #ifndef FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_API_HPP_ #define FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_API_HPP_ #define COMX 1 #include "free_rtos/ethernet/eth.hpp" #include "free_rtos/ethernet_industry/eth_ecat.hpp" #include "free_rtos/ethernet_industry/eth_ecat_buffer.hpp" #include "free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.hpp" #include "free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.hpp" namespace free_rtos { class EthEcatApi { public: EthEcatApi(Eth *eth) : eth_{eth} , ecat_{*eth} , ecat_buffer_sdo_{ecat_} , ecat_buffer_pdo_{ecat_} , ecat_sdo_mailbox_{ecat_buffer_sdo_} , ecat_pdo_fmmu_{ecat_buffer_pdo_} { } bool config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec = 250, ecat_pdo_fmmu::ProcessCallback callback = nullptr); template void process(Allocator& allocator) { ecat_pdo_fmmu_.process(allocator); } template void process_fake(Allocator& allocator, uint32_t period_microsec, ecat_pdo_fmmu::ProcessCallback callback) { ecat_pdo_fmmu_.process_fake(allocator, period_microsec, callback); } std::vector& get_ecat_pdo_map(); uint32_t get_pdo_counter() { return ecat_pdo_fmmu_.get_pdo_counter(); } const telegram::EcatTelegramStatus& get_telegram_status() { return ecat_.get_telegram_status(); } template ecat_sdo_mailbox::CompleteSize sdo_write(size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) { return ecat_sdo_mailbox_.sdo_write(slave_index, index, subindex, data...); } template ecat_sdo_mailbox::CompleteSize sdo_read(size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) { return ecat_sdo_mailbox_.sdo_read(slave_index, index, subindex, data...); } template bool pdo_write(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) { return ecat_pdo_fmmu_.pdo_write(timeout_ticks, offset, data...); } template bool pdo_read(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) { return ecat_pdo_fmmu_.pdo_read(timeout_ticks, offset, data...); } void pdo_write_async_static(custom_promise::IPromise& promise) { ecat_pdo_fmmu_.pdo_write_async_static(promise); } void pdo_read_async_static(custom_promise::IPromise& promise) { ecat_pdo_fmmu_.pdo_read_async_static(promise); } void pdo_write_async(custom_promise::IPromise& promise) { ecat_pdo_fmmu_.pdo_write_async(promise); } void pdo_read_async(custom_promise::IPromise& promise) { ecat_pdo_fmmu_.pdo_read_async(promise); } private: Eth *eth_; EthEcat ecat_; ecat_buffer::EthEcatBuffer ecat_buffer_sdo_; ecat_buffer::EthEcatBuffer ecat_buffer_pdo_; ecat_sdo_mailbox::EthEcatSdoMailbox ecat_sdo_mailbox_; ecat_pdo_fmmu::EthEcatPdoFMMU ecat_pdo_fmmu_; }; } #endif /* FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_API_HPP_ */