Private
Public Access
2
0

spi: Make Spi write() work from SWIG with typemaps

This change also changes the C++ API write(char) call to writeByte(uint8_t) and
the write() call now takes a uint8_t* instead of a char*. This should not alter
any code significantly and does not affect the C API.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-01-14 11:41:43 +00:00
parent 17ee0c9669
commit b7a0856f51
6 changed files with 160 additions and 11 deletions

View File

@@ -14,7 +14,23 @@
$2 = node::Buffer::Length($input);
}
// Spi write()
%typemap(in) (uint8_t *txBuf, int length) {
$1 = (uint8_t*) node::Buffer::Data($input);
$2 = node::Buffer::Length($input);
}
namespace mraa {
class Spi;
%typemap(out) uint8_t*
{
// need to loop over length
$result = node::Buffer::New((char*) $1, arg3)->handle_;
}
}
%newobject I2c::read(uint8_t *data, int length);
%newobject Spi::write(uint8_t *data, int length);
%typemap(in) (uint8_t *data, int length) {
int x;