sitara_depot/components/free_rtos/ethernet_industry/eth_ecat_mailbox.cpp

48 lines
1.1 KiB
C++

/*
* eth_ecat_mailbox.cpp
*
* Created on: May 3, 2023
* Author: algin
*/
#include "eth_ecat_mailbox.hpp"
namespace free_rtos {
void EthEcatMailbox::mailbox_registration() {
std::vector<EcatSlave>& slaves = ecat_.get_slaves();
mailbox_slaves_.reserve(slaves.size());
for(EcatSlave& slave : slaves) {
mailbox_slaves_.push_back(EcatMailboxSlave{slave});
}
for(EcatMailboxSlave& mailbox_slave : mailbox_slaves_) {
mailbox_slave.read_mailbox_info_from_eeprom<command::FP>(ecat_.get_eeprom());
}
}
void EthEcatMailbox::sync_manager_registration() {
datagram::EcatTelegram& telegram = ecat_.get_telegram();
for(EcatMailboxSlave& mailbox_slave : mailbox_slaves_) {
mailbox_slave.register_sync_manager<command::FP>(telegram, sync_manager::SYNC_M1, sync_manager::SYNC_M0);
}
}
uint16_t EthEcatMailbox::config_init() {
uint16_t number_of_slaves = ecat_.config_init();
bool status;
mailbox_registration();
sync_manager_registration();
ecat_.enable_PDI();
status = ecat_.init_to_preop();
return number_of_slaves;
}
}