Private
Public Access
2
0

maa: Refactor maa build system and partly implement i2c

* API headers moved to api/
* smbus file added from libi2c and kernel i2c header cleaned up
* fix compilation of swig and use i2c.h header

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2014-04-10 16:53:19 +01:00
parent 8b715745fc
commit 9994ea855c
16 changed files with 654 additions and 62 deletions

View File

@@ -26,11 +26,17 @@
*/
#include "i2c.h"
#include "smbus.h"
using namespace maa;
I2C::I2C(unsigned int sda, unsigned int scl)
{
// Galileo only has one I2C device which is always /dev/i2c-0
// reliability is a fickle friend!
if (i2c_handle = open("/dev/i2c-0", O_RDWR) < 1) {
fprintf(stderr, "Failed to open requested i2c port");
}
}
void
@@ -48,7 +54,11 @@ I2C::read(int address, char *data, int length, bool repeated)
int
I2C::read(int ack)
{
return 0;
int byte;
if (byte = i2c_smbus_read_byte(i2c_handle) < 0) {
return -1;
}
return byte;
}
int