feat(UML-1462): Добавлена настройка периода обмена PDO

This commit is contained in:
algin 2023-06-19 11:33:11 +03:00
parent 0ffd4fa0fb
commit 9a96d327f6
5 changed files with 12 additions and 8 deletions

View File

@ -45,15 +45,19 @@ void EthEcatPdoFMMU::wait_op() {
init_sem.post();
process_sem.pend();
read(0, process_data);
for(uint32_t i = 0; i < 250; i++) {
read(0, process_data);
read_write(0, 0, process_data);
//read(0, process_data);
/*
for(uint8_t& byte : process_data) {
DebugP_log("0x%01x", byte);
}
DebugP_log("\r\n");
*/
write(0, process_data);
//write(0, process_data);
}
init_sem.post();

View File

@ -18,7 +18,7 @@ EthEcat::EthEcat(Eth& eth)
, telegram_{eth}
, eeprom_{telegram_} { }
void EthEcat::Init(TEthMacPorts port_id) {
void EthEcat::Init(TEthMacPorts port_id, uint32_t period_microsec = 250) {
port_id_ = port_id;
telegram_.init(port_id);
@ -28,7 +28,7 @@ void EthEcat::Init(TEthMacPorts port_id) {
.clock_src_mux_addr = 0x430081B0u, // sysconfig
.int_num = 152u, // sysconfig
.int_priority = 4, // sysconfig
.period_us = 125 /// microsec
.period_us = period_microsec /// microsec
};
ecat_timer_.Init(ecat_tmr_sett);

View File

@ -209,7 +209,7 @@ public:
EthEcat(Eth& eth);
void Init(TEthMacPorts port_id);
void Init(TEthMacPorts port_id, uint32_t period_microsec);
void set_slaves_to_default();
uint16_t slaves_detecting();

View File

@ -19,10 +19,10 @@ namespace free_rtos {
* pdo_write(...), pdo_read(...) или pdo_write_async(...), pdo_read_async(...)
*/
bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base) {
bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec = 250) {
bool status = false;
ecat_.Init(port_id);
ecat_.Init(port_id, period_microsec);
ecat_.config_init(address_base);

View File

@ -38,7 +38,7 @@ public:
, ecat_sdo_mailbox_{ecat_buffer_sdo_}
, ecat_pdo_fmmu_{ecat_buffer_pdo_} { }
bool config_init(TEthMacPorts port_id, uint16_t address_base);
bool config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec);
void process(); // Внутри бесконечный цикл. Запускать в отдельном потоке
std::vector<ecat_buffer::PDOMap>& get_ecat_pdo_map();