MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/application/drivers/Eeprom24LCxxBSetupInitializer.cpp
2024-06-07 11:12:56 +03:00

69 lines
1.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*!\file
* \brief \todo Описание файла.
*/
/*
* Eeprom24LCxxBSetup.cpp
*
* Created on: 4 июл. 2019 г.
* Author: titov
*/
#include "Eeprom24LCxxBSetup.hh"
#include "../../systemic/ValueLazyFast.hpp"
#include "../../systemic/Process.hpp"
bool application::board::Eeprom24LCxxBSetup::input( Environment & env ) {
return grab( i2c, env.rholder.getShared<I2c>( links.i2c_id ))
and grab( write_en_pin, env.rholder.getShared<driver::IDiscreteOutput>( links.write_enable_id ));
}
bool application::board::Eeprom24LCxxBSetup::prepare() {
return true;
}
void application::board::Eeprom24LCxxBSetup::build( Environment & env ) {
typedef driver::detail::I2cEeprom24LCxxB I2cEEPROM;
I2cEEPROM::Setting setting;
setting.address = cfg.address;
setting.baud_rate = cfg.baud_rate;
setting.page_size = cfg.page_size;
setting.polling_time = cfg.polling_time;
setting.size = cfg.size;
I2cEEPROM * eeprom = memories::instance_object<I2cEEPROM>(
env.static_object_ma,
*i2c, setting, *write_en_pin );
env.rholder.share<peripheral::IMemoryAccess>( *eeprom, links.memory_id );
typedef systemic::detail::ValueLazyFast<bool, I2cEEPROM, &I2cEEPROM::isError> StatusError;
env.statuses.add( links.error_id, memories::instance_object<StatusError>( env.static_setup_ma, *eeprom ) );
systemic::ProcScheduler::ProcessParameter proc = {
.priority = params.priority,
.period = params.period, .phase = params.phase,
.controlled = true
};
env.scheduler.registerProcess( params.processor_id, *eeprom,
proc );
}
application::board::Eeprom24LCxxBSetup::Eeprom24LCxxBSetup(
const Links & links, const Setting & setting, const configuration::ProcessConfig & proc ) :
i2c(nullptr), write_en_pin(nullptr),
cfg(setting), links(links), params(proc) {}