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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user