Added STM32 platform for debugging and development
This commit is contained in:
@@ -13,7 +13,7 @@ namespace drivers
|
||||
{
|
||||
if (m_i2c.write(m_address, reg, {val}))
|
||||
return true;
|
||||
log_e("Unable to write register: reg[%d], val[%d] ", reg, val);
|
||||
LOG_ERROR("Unable to write register: reg[%d], val[%d] ", reg, val);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace drivers
|
||||
val = data.back();
|
||||
return true;
|
||||
}
|
||||
log_e("Unable to read register: reg[%d]");
|
||||
LOG_ERROR("Unable to read register: reg[%d]");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace drivers
|
||||
uint8_t currState(0);
|
||||
uint8_t newState(0);
|
||||
|
||||
if (ch < EXIO_PIN1 || ch > EXIO_PIN8)
|
||||
if (ch < OUT_PIN1 || ch > OUT_PIN8)
|
||||
{
|
||||
log_e("Invalid write to output channel: [%d]", ch);
|
||||
LOG_ERROR("Invalid write to output channel: [%d]", ch);
|
||||
return false;
|
||||
}
|
||||
if (!readPort(currState))
|
||||
@@ -52,16 +52,16 @@ namespace drivers
|
||||
{
|
||||
if (writeRegister(TCA9554_OUTPUT_REG, state))
|
||||
return true;
|
||||
log_e("Unable to write IO port: state[%02x]", state);
|
||||
LOG_ERROR("Unable to write IO port: state[%02x]", state);
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool TCA9554PWR::readOut(const uint8_t ch)
|
||||
{
|
||||
uint8_t currState(0);
|
||||
if (ch < EXIO_PIN1 || ch > EXIO_PIN8)
|
||||
if (ch < OUT_PIN1 || ch > OUT_PIN8)
|
||||
{
|
||||
log_e("Invalid read to output channel: [%d]", ch);
|
||||
LOG_ERROR("Invalid read to output channel: [%d]", ch);
|
||||
return false;
|
||||
}
|
||||
if (!readPort(currState))
|
||||
@@ -73,7 +73,7 @@ namespace drivers
|
||||
{
|
||||
if (readRegister(TCA9554_INPUT_REG, state))
|
||||
return true;
|
||||
log_e("Unable to read IO port: state[%02x]", state);
|
||||
LOG_ERROR("Unable to read IO port: state[%02x]", state);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,27 +15,25 @@
|
||||
#define Low 0x00
|
||||
#define High 0x01
|
||||
|
||||
#define EXIO_PIN1 0
|
||||
#define EXIO_PIN2 1
|
||||
#define EXIO_PIN3 2
|
||||
#define EXIO_PIN4 3
|
||||
#define EXIO_PIN5 4
|
||||
#define EXIO_PIN6 5
|
||||
#define EXIO_PIN7 6
|
||||
#define EXIO_PIN8 7
|
||||
|
||||
namespace drivers
|
||||
{
|
||||
class TCA9554PWR
|
||||
{
|
||||
I2C &m_i2c;
|
||||
uint8_t m_address;
|
||||
|
||||
private:
|
||||
const bool writeRegister(const uint8_t reg, const uint8_t val);
|
||||
const bool readRegister(const uint8_t reg, uint8_t &val);
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
OUT_PIN1,
|
||||
OUT_PIN2,
|
||||
OUT_PIN3,
|
||||
OUT_PIN4,
|
||||
OUT_PIN5,
|
||||
OUT_PIN6,
|
||||
OUT_PIN7,
|
||||
OUT_PIN8,
|
||||
OUT_PIN_MAX
|
||||
};
|
||||
|
||||
TCA9554PWR(I2C &i2c, const uint8_t address);
|
||||
|
||||
const bool setOut(const uint8_t channel, const bool state);
|
||||
@@ -43,5 +41,11 @@ namespace drivers
|
||||
|
||||
const bool readOut(const uint8_t channel);
|
||||
const bool readPort(uint8_t &state);
|
||||
|
||||
private:
|
||||
I2C &m_i2c;
|
||||
uint8_t m_address;
|
||||
const bool writeRegister(const uint8_t reg, const uint8_t val);
|
||||
const bool readRegister(const uint8_t reg, uint8_t &val);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user