spi.hpp: Add C++ wrapper around Spi
* maa_spi_context becomes an opaque pointer * C++ wrapper class Spi created * swig now uses C++ wrapper Gpio to generate API Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
34
src/maa.i
34
src/maa.i
@@ -3,7 +3,7 @@
|
||||
#include "gpio.hpp"
|
||||
#include "pwm.hpp"
|
||||
#include "i2c.hpp"
|
||||
#include "spi.h"
|
||||
#include "spi.hpp"
|
||||
#include "aio.hpp"
|
||||
%}
|
||||
|
||||
@@ -29,37 +29,7 @@ const char * maa_get_version();
|
||||
|
||||
#### SPI ####
|
||||
|
||||
%rename(Spi) maa_spi_context;
|
||||
|
||||
%ignore spifd;
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
int spifd; /**< File descriptor to SPI Device */
|
||||
/*@}*/
|
||||
} maa_spi_context;
|
||||
|
||||
%nodefault maa_spi_context;
|
||||
%extend maa_spi_context {
|
||||
maa_spi_context()
|
||||
{
|
||||
return maa_spi_init();
|
||||
}
|
||||
~maa_spi_context()
|
||||
{
|
||||
}
|
||||
int mode(unsigned short mode)
|
||||
{
|
||||
return maa_spi_mode($self, mode);
|
||||
}
|
||||
int frequency(int hz)
|
||||
{
|
||||
return maa_spi_frequency($self, hz);
|
||||
}
|
||||
unsigned int write(unsigned int data)
|
||||
{
|
||||
return maa_spi_write($self, data);
|
||||
}
|
||||
}
|
||||
%include "spi.hpp"
|
||||
|
||||
#### AIO ####
|
||||
|
||||
|
||||
Reference in New Issue
Block a user