73 lines
2.5 KiB
C++
73 lines
2.5 KiB
C++
/*
|
|
* 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 "ethernet/eth.hpp"
|
|
#include "ethernet_industry/eth_ecat.hpp"
|
|
#include "ethernet_industry/eth_ecat_buffer.hpp"
|
|
#include "ethernet_industry/CoE/eth_ecat_sdo_mailbox.hpp"
|
|
#include "ethernet_industry/CoE/eth_ecat_pdo_fmmu.hpp"
|
|
|
|
namespace free_rtos {
|
|
|
|
class EthEcatApi {
|
|
public:
|
|
static void init(Eth& eth);
|
|
static bool config_init(TEthMacPorts port_id, uint16_t address_base);
|
|
static void process(); // Внутри бесконечный цикл. Запускать в отдельном потоке
|
|
|
|
static std::vector<ecat_buffer::PDOMap>& get_ecat_pdo_map();
|
|
static uint32_t get_pdo_counter() {
|
|
return get_ecat_pdo_fmmu().get_pdo_counter();
|
|
}
|
|
|
|
template<typename... DataTypes>
|
|
static ecat_sdo_mailbox::CompleteSize sdo_write(size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) {
|
|
return get_ecat_sdo_mailbox().sdo_write<command::FP, DataTypes...>(slave_index, index, subindex, data...);
|
|
}
|
|
|
|
template<typename... DataTypes>
|
|
static ecat_sdo_mailbox::CompleteSize sdo_read(size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) {
|
|
return get_ecat_sdo_mailbox().sdo_read<command::FP, DataTypes...>(slave_index, index, subindex, data...);
|
|
}
|
|
|
|
template<typename... DataTypes>
|
|
static bool pdo_write(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) {
|
|
return get_ecat_pdo_fmmu().pdo_write<DataTypes...>(timeout_ticks, offset, data...);
|
|
}
|
|
|
|
template<typename... DataTypes>
|
|
static bool pdo_read(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) {
|
|
return get_ecat_pdo_fmmu().pdo_read<DataTypes...>(timeout_ticks, offset, data...);
|
|
}
|
|
|
|
static void pdo_write_async(custom_promise::IPromise& promise) {
|
|
get_ecat_pdo_fmmu().pdo_write_async(promise);
|
|
}
|
|
|
|
static void pdo_read_async(custom_promise::IPromise& promise) {
|
|
get_ecat_pdo_fmmu().pdo_read_async(promise);
|
|
}
|
|
|
|
private:
|
|
static Eth *eth_;
|
|
|
|
static EthEcat& get_ecat();
|
|
static ecat_buffer::EthEcatBuffer& get_ecat_buffer_sdo();
|
|
static ecat_buffer::EthEcatBuffer& get_ecat_buffer_pdo();
|
|
static ecat_sdo_mailbox::EthEcatSdoMailbox& get_ecat_sdo_mailbox();
|
|
static ecat_pdo_fmmu::EthEcatPdoFMMU& get_ecat_pdo_fmmu();
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_API_HPP_ */
|