Merge pull request #17 from CrustyAuklet/master

Changes for MSVC and add i2c_start() to API
This commit is contained in:
James Bowman 2019-08-26 09:06:37 -07:00 committed by GitHub
commit 53131672e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -5,8 +5,8 @@
#include <fcntl.h> #include <fcntl.h>
#if !defined(WIN32) #if !defined(WIN32)
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif
#include <unistd.h> #include <unistd.h>
#endif
#include <errno.h> #include <errno.h>
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include <inttypes.h> #include <inttypes.h>
@ -55,7 +55,7 @@ HANDLE openSerialPort(const char *portname)
if (portname[0] == 'C') if (portname[0] == 'C')
fmt = "\\\\.\\%s"; fmt = "\\\\.\\%s";
else else
fmt == "%s"; fmt = "%s";
snprintf(fullname, sizeof(fullname), fmt, portname); snprintf(fullname, sizeof(fullname), fmt, portname);
DWORD accessdirection = GENERIC_READ | GENERIC_WRITE; DWORD accessdirection = GENERIC_READ | GENERIC_WRITE;
HANDLE hSerial = CreateFile((LPCSTR)fullname, HANDLE hSerial = CreateFile((LPCSTR)fullname,

View File

@ -32,6 +32,7 @@ void i2c_connect(I2CDriver *sd, const char* portname);
void i2c_getstatus(I2CDriver *sd); void i2c_getstatus(I2CDriver *sd);
int i2c_write(I2CDriver *sd, const uint8_t bytes[], size_t nn); int i2c_write(I2CDriver *sd, const uint8_t bytes[], size_t nn);
void i2c_read(I2CDriver *sd, uint8_t bytes[], size_t nn); void i2c_read(I2CDriver *sd, uint8_t bytes[], size_t nn);
int i2c_start(I2CDriver *sd, uint8_t dev, uint8_t op);
void i2c_stop(I2CDriver *sd); void i2c_stop(I2CDriver *sd);
void i2c_monitor(I2CDriver *sd, int enable); void i2c_monitor(I2CDriver *sd, int enable);