reworked mcp initialization
This commit is contained in:
@@ -50,6 +50,17 @@ bool PinController::read_pin(uint8_t address)
|
||||
|
||||
void PinController::initialize_port_expander(const uint8_t i2c_address, const uint8_t pin_base)
|
||||
{
|
||||
auto initialized_port_extender = this->initialized_port_extenders.insert(std::pair<uint8_t, uint8_t>(i2c_address, pin_base);
|
||||
if(initialized_port_extender->second)
|
||||
{
|
||||
if(initialized_port_extender->first->second != pin_base)
|
||||
{
|
||||
CLOG(ERROR, OUTPUT_LOGGER) << "Port extender with address " << i2c_address
|
||||
<< " is already initialized with pin base " << pin_base;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
mcp23017Setup(pin_base, i2c_address);
|
||||
char hex_string[4];
|
||||
sprintf(hex_string, "%X", i2c_address);
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
static std::once_flag GPIO_LIB_INITIALIZED;
|
||||
|
||||
static std::mutex lock;
|
||||
|
||||
std::map<uint8_t, uint8_t> initialized_port_extenders;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user