63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
/*!\file
|
||
* \brief \todo Описание файла.
|
||
*/
|
||
/*
|
||
* SlipCommunicationSetup.cpp
|
||
*
|
||
* Created on: 13 июн. 2019 г.
|
||
* Author: titov
|
||
*/
|
||
|
||
#include "SlipCommunicationSetup.hh"
|
||
|
||
#include "../../peripheral/IGpio.hh"
|
||
#include "../../peripheral/IUartPort.hh"
|
||
|
||
#include "../../driver/DiscreteOutput_DoublePin.hh"
|
||
#include "../../driver/SlipCommunication.hh"
|
||
|
||
#include "../../systemic/Process.hpp"
|
||
|
||
bool application::board::SlipCommunicationSetup::input( Environment & env ) {
|
||
|
||
return grab( port, env.rholder.getShared<peripheral::IUartPort>( links.uart_id ) )
|
||
and grab( re, env.rholder.getShared<peripheral::IGpio>( links.gpio_re_id ) )
|
||
and grab( de, env.rholder.getShared<peripheral::IGpio>( links.gpio_de_id ) )
|
||
and (mpStsAddrValid = env.statuses.get ( links.address_valid_id ))
|
||
and (mpSigAddrBus = env.signals.get ( links.address_bus_id ));
|
||
|
||
}
|
||
|
||
application::board::SlipCommunicationSetup::SlipCommunicationSetup(
|
||
const Links & links, const Setting & hardware, const configuration::ProcessConfig & proc ) : links(links), cfg(hardware), params(proc) {}
|
||
|
||
void application::board::SlipCommunicationSetup::build( Environment & env ) {
|
||
typedef driver::detail::DiscreteOutput_DoublePin DE;
|
||
|
||
DE * de_out = memories::instance_object<DE>(
|
||
env.static_object_ma,
|
||
*de, cfg.active_de, *re, cfg.active_re
|
||
);
|
||
|
||
typedef driver::SlipCommunication SC;
|
||
|
||
SC * slip_communication = memories::instance_object<SC>(
|
||
env.static_object_ma,
|
||
*port, *de_out
|
||
);
|
||
|
||
slip_communication->setAddress ( cfg.address ? cfg.address: *mpSigAddrBus );
|
||
|
||
env.rholder.share<driver::ISlipCommunication>( *slip_communication, links.slip_com_id );
|
||
|
||
systemic::ProcScheduler::ProcessParameter proc = {
|
||
.priority = params.priority,
|
||
.period = params.period, .phase = params.phase,
|
||
.controlled = false
|
||
};
|
||
|
||
env.scheduler.registerProcess( params.processor_id, *slip_communication,
|
||
proc );
|
||
|
||
}
|