Merge pull request #66 from muman613/add-disconnect-branch
(feature) Added i2c_disconnect to c sdk
This commit is contained in:
commit
2fd1df4c7d
|
@ -184,8 +184,14 @@ void writeToSerialPort(int fd, const uint8_t *b, size_t s)
|
|||
for (i = 0; i < s; i++)
|
||||
printf("%02x ", 0xff & b[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void closeSerialPort(HANDLE hSerial)
|
||||
{
|
||||
close((int)hSerial);
|
||||
}
|
||||
|
||||
#endif // }
|
||||
|
||||
// ****************************** CCITT CRC *********************************
|
||||
|
@ -268,6 +274,15 @@ void i2c_connect(I2CDriver *sd, const char* portname)
|
|||
sd->e_ccitt_crc = sd->ccitt_crc;
|
||||
}
|
||||
|
||||
void i2c_disconnect(I2CDriver *sd)
|
||||
{
|
||||
if (sd->connected) {
|
||||
closeSerialPort(sd->port);
|
||||
sd->port = -1;
|
||||
sd->connected = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void charCommand(I2CDriver *sd, char c)
|
||||
{
|
||||
writeToSerialPort(sd->port, (uint8_t*)&c, 1);
|
||||
|
|
|
@ -29,6 +29,7 @@ typedef struct {
|
|||
} I2CDriver;
|
||||
|
||||
void i2c_connect(I2CDriver *sd, const char* portname);
|
||||
void i2c_disconnect(I2CDriver *sd);
|
||||
void i2c_getstatus(I2CDriver *sd);
|
||||
int i2c_write(I2CDriver *sd, const uint8_t bytes[], size_t nn);
|
||||
void i2c_read(I2CDriver *sd, uint8_t bytes[], size_t nn);
|
||||
|
|
Loading…
Reference in New Issue