54 #include "rnr/rnrconfig.h" 65 #if defined(ARCH_overo) || defined(ARCH_linaro) 72 int HekSysBoard::open(
const string& dev)
78 m_i2c.addr = HekIOExpI2CAddr;
83 if( i2c_open(&m_i2c, dev.c_str()) < 0 )
85 LOGSYSERROR(
"%s.", dev.c_str());
86 return -HEK_ECODE_NO_DEV;
89 LOGDIAG3(
"Hekateros i2c bus hardware initialized successfully.");
96 val = readIOExp(HekIOExpCmdPolarity0);
98 if( val != HekIOExpConstPolarity0 )
100 if( (rc = writeIOExp(HekIOExpCmdPolarity0, HekIOExpConstPolarity0)) < 0 )
107 val = readIOExp(HekIOExpCmdConfig0);
109 if( val != HekIOExpConstConfig0 )
111 if( (rc = writeIOExp(HekIOExpCmdConfig0, HekIOExpConstConfig0)) < 0 )
117 #endif // TGT_EMBEDDED 122 int HekSysBoard::close()
134 int HekSysBoard::scan()
139 int HekSysBoard::cmdReadFwVersion(
int &ver)
146 byte_t HekSysBoard::cmdReadLimits()
148 byte_t cmd = HekIOExpCmdInput0;
152 if(i2c_transfer(&m_i2c, HekIOExpI2CAddr, &cmd, 1, &val, 1) < 0)
154 LOGSYSERROR(
"i2c_transfer: %s: addr=0x%.02x, command=%u.",
155 HekI2CDevice, HekIOExpI2CAddr, cmd);
157 #endif // TGT_EMBEDDED 162 byte_t HekSysBoard::cmdReadAux()
164 byte_t cmd = HekIOExpCmdInput1;
168 if(i2c_transfer(&m_i2c, HekIOExpI2CAddr, &cmd, 1, &val, 1) < 0)
170 LOGSYSERROR(
"i2c_transfer: %s: addr=0x%.02x, command=%u.",
171 HekI2CDevice, HekIOExpI2CAddr, cmd);
173 #endif // TGT_EMBEDDED 178 int HekSysBoard::cmdReadPin(
int id)
188 cmd = HekIOExpCmdInput0;
193 cmd = HekIOExpCmdInput1;
197 mask = 0x01 << shift;
200 if(i2c_transfer(&m_i2c, HekIOExpI2CAddr, &cmd, 1, &bits, 1) < 0)
202 LOGSYSERROR(
"i2c_transfer: %s: addr=0x%.02x, command=%u.",
203 HekI2CDevice, HekIOExpI2CAddr, cmd);
205 else if( bits & mask )
209 #endif // TGT_EMBEDDED 214 int HekSysBoard::cmdWritePin(
int id,
int val)
224 cmd = HekIOExpCmdInput0;
226 bits = cmdReadLimits();
230 cmd = HekIOExpCmdInput0;
235 mask = 0x01 << shift;
236 bits = (bits & ~mask) | (val & mask);
242 if(i2c_write(&m_i2c, HekIOExpI2CAddr, buf, 2) < 0)
244 LOGSYSERROR(
"i2c_write: %s: addr=0x%.02x, command=%u.",
245 HekI2CDevice, HekIOExpI2CAddr, cmd);
246 return -HEK_ECODE_SYS;
248 #endif // TGT_EMBEDDED 254 int HekSysBoard::cmdConfigPin(
int id,
char dir)
260 int HekSysBoard::cmdSetAlarmLED(
int val)
266 int HekSysBoard::cmdSetStatusLED(
int val)
272 int HekSysBoard::cmdSetHaltingState()
278 byte_t HekSysBoard::readIOExp(byte_t byCmd)
283 if(i2c_transfer(&m_i2c, HekIOExpI2CAddr, &byCmd, 1, &byVal, 1) < 0)
285 LOGSYSERROR(
"i2c_transfer: %s: addr=0x%.02x, command=%u.",
286 HekI2CDevice, HekIOExpI2CAddr, byCmd);
288 #endif // TGT_EMBEDDED 293 int HekSysBoard::writeIOExp(byte_t byCmd, byte_t byVal)
301 if(i2c_write(&m_i2c, HekIOExpI2CAddr, buf, 2) < 0)
303 LOGSYSERROR(
"i2c_write: %s: addr=0x%.02x, command=%u.",
304 HekI2CDevice, HekIOExpI2CAddr, byCmd);
305 return -HEK_ECODE_SYS;
307 #endif // TGT_EMBEDDED <b><i>Hekateros</i></b> optical limit switches.
Top-level package include file.
<b><i>Hekateros</i></b> original system board.
The <b><i>Hekateros</i></b> namespace encapsulates all <b><i>Hekateros</i></b> related constructs...