Private
Public Access
2
0

i2cslave: first possibly working implementation of i2cslave api

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2014-04-11 15:46:27 +01:00
parent 84beaf2c05
commit 7eb9fa64a9
5 changed files with 13 additions and 2 deletions

View File

@@ -144,6 +144,7 @@ public:
protected:
int _hz;
int i2c_handle;
int _addr;
};
}

View File

@@ -25,6 +25,7 @@
#pragma once
#include "i2c.h"
#include "i2cslave.h"
#include "gpio.h"
#define MAA_LIBRARY_VERSION 1

View File

@@ -6,6 +6,7 @@ include_directories(
set (maa_LIB_SRCS
${PROJECT_SOURCE_DIR}/src/maa.cxx
${PROJECT_SOURCE_DIR}/src/i2c/i2c.cxx
${PROJECT_SOURCE_DIR}/src/i2c/i2cslave.cxx
${PROJECT_SOURCE_DIR}/src/i2c/smbus.c
${PROJECT_SOURCE_DIR}/src/gpio/gpio.c
)

View File

@@ -47,7 +47,10 @@ I2CSlave::frequency(int hz)
int
I2CSlave::read(char *data, int length)
{
return 0;
if (this->read(data, length) == length) {
return length;
}
return -1;
}
int
@@ -81,8 +84,12 @@ I2CSlave::write(int data)
}
void
I2CSlave::address(int address)
I2CSlave::address(int addr)
{
_addr = addr;
if (ioctl(i2c_handle, I2C_SLAVE_FORCE, addr) < 0) {
fprintf(stderr, "Failed to set slave address %d\n", addr);
}
}
void

View File

@@ -4,4 +4,5 @@
%include "maa.h"
%include "i2c.h"
%include "i2cslave.h"
%include "gpio.h"