69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
/*!\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) {}
|
|
|
|
|