i2cslave: first possibly working implementation of i2cslave api
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -144,6 +144,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
int _hz;
|
int _hz;
|
||||||
int i2c_handle;
|
int i2c_handle;
|
||||||
|
int _addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
#include "i2cslave.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
#define MAA_LIBRARY_VERSION 1
|
#define MAA_LIBRARY_VERSION 1
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ include_directories(
|
|||||||
set (maa_LIB_SRCS
|
set (maa_LIB_SRCS
|
||||||
${PROJECT_SOURCE_DIR}/src/maa.cxx
|
${PROJECT_SOURCE_DIR}/src/maa.cxx
|
||||||
${PROJECT_SOURCE_DIR}/src/i2c/i2c.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/i2c/smbus.c
|
||||||
${PROJECT_SOURCE_DIR}/src/gpio/gpio.c
|
${PROJECT_SOURCE_DIR}/src/gpio/gpio.c
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ I2CSlave::frequency(int hz)
|
|||||||
int
|
int
|
||||||
I2CSlave::read(char *data, int length)
|
I2CSlave::read(char *data, int length)
|
||||||
{
|
{
|
||||||
return 0;
|
if (this->read(data, length) == length) {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -81,8 +84,12 @@ I2CSlave::write(int data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user