Private
Public Access
2
0

i2c.hpp: Add C++ wrapper around I2c

* maa_i2c_context bcomes an opaque pointer
* C++ wrapper class I2c created
* swig now uses C++ wrapper I2c to generate API

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2014-05-16 10:28:26 +01:00
parent 9e823b7f1d
commit e491f99228
7 changed files with 104 additions and 71 deletions

View File

@@ -2,7 +2,7 @@
#include "maa.h"
#include "gpio.h"
#include "pwm.h"
#include "i2c.h"
#include "i2c.hpp"
#include "spi.h"
#include "aio.hpp"
%}
@@ -126,48 +126,7 @@ typedef struct {
#### i2c ####
%nodefault maa_i2c_context;
%rename(I2c) maa_i2c_context;
%ignore fh;
typedef struct {
/*@{*/
int hz; /**< frequency of communication */
int fh; /**< the file handle to the /dev/i2c-* device */
int addr; /**< the address of the i2c slave */
/*@}*/
} maa_i2c_context;
%nodefault maa_i2c_context;
%extend maa_i2c_context {
maa_i2c_context()
{
return maa_i2c_init(0);
}
~maa_i2c_context()
{
}
int frequency(int hz)
{
return maa_i2c_frequency($self, hz);
}
int read(char *data, int length)
{
return maa_i2c_read($self, data, length);
}
int read()
{
return maa_i2c_read_byte($self);
}
int write(char *data, int length)
{
return maa_i2c_write($self, data, length);
}
int write(int data)
{
return maa_i2c_write_byte($self, data);
}
}
%include "i2c.hpp"
#### PWM ####