java: Changed size_t and unsigned int to int in array declarations. Renamed buf to buffer where necesarry. Moved most Java array typemaps to java_buffer.i. Fixed some String buffers.

Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/upm.i
This commit is contained in:
Petre Eftime
2015-09-07 19:00:30 +03:00
committed by Mihai Tudor Panu
parent ab730038fd
commit 2cab79b4c2
50 changed files with 237 additions and 326 deletions

View File

@ -2,13 +2,10 @@
%include "../upm.i"
%include "typemaps.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%apply short *OUTPUT { short * ptrX, short * ptrY, short * ptrZ };
%{
#include "mma7455.h"
%}
%typemap(jni) short* "jshortArray"
%typemap(jstype) short* "short[]"
%typemap(jtype) short* "short[]"
@ -25,19 +22,8 @@
%ignore readData(short *, short *, short *);
%typemap(jni) (unsigned char *buf, unsigned char size) "jbyteArray";
%typemap(jtype) (unsigned char *buf, unsigned char size) "byte[]";
%typemap(jstype) (unsigned char *buf, unsigned char size) "byte[]";
%typemap(javain) (unsigned char *buf, unsigned char size) "$javainput";
%typemap(in) (unsigned char *buf, unsigned char size) {
$1 = (unsigned char *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (unsigned char *buf, unsigned char size) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%{
#include "mma7455.h"
%}
%include "mma7455.h"

View File

@ -50,7 +50,7 @@ MMA7455::MMA7455 (int bus, int devAddr) : m_i2ControlCtx(bus) {
// setting GLVL 0x1 (64LSB/g) and MODE 0x1 (Measurement Mode)
data = (BIT (MMA7455_GLVL0) | BIT (MMA7455_MODE0));
error = ic2WriteReg (MMA7455_MCTL, &data, 0x1);
error = i2cWriteReg (MMA7455_MCTL, &data, 0x1);
if (error != mraa::SUCCESS) {
std::cout << "ERROR :: MMA7455 instance wan not created (Mode)" << std::endl;
return;
@ -80,7 +80,7 @@ MMA7455::calibrate () {
xyz.value.y += 2 * -xyz.value.y;
xyz.value.z += 2 * -(xyz.value.z - 64);
error = ic2WriteReg (MMA7455_XOFFL, (unsigned char *) &xyz, 0x6);
error = i2cWriteReg (MMA7455_XOFFL, (unsigned char *) &xyz, 0x6);
if (error != mraa::SUCCESS) {
return error;
}
@ -97,7 +97,7 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
int nBytes = 0;
/*do {
nBytes = ic2ReadReg (MMA7455_STATUS, &data, 0x1);
nBytes = i2cReadReg (MMA7455_STATUS, &data, 0x1);
} while ( !(data & MMA7455_DRDY) && nBytes == mraa::SUCCESS);
if (nBytes == mraa::SUCCESS) {
@ -105,7 +105,7 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
return mraa::SUCCESS;
}*/
nBytes = ic2ReadReg (MMA7455_XOUTL, (unsigned char *) &xyz, 0x6);
nBytes = i2cReadReg (MMA7455_XOUTL, (unsigned char *) &xyz, 0x6);
if (nBytes == 0) {
std::cout << "NO_GDB :: 2" << std::endl;
return mraa::ERROR_UNSPECIFIED;
@ -140,7 +140,7 @@ short *MMA7455::readData() {
#endif
int
MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size) {
MMA7455::i2cReadReg (unsigned char reg, uint8_t *buffer, int len) {
if (mraa::SUCCESS != m_i2ControlCtx.address(m_controlAddr)) {
return 0;
}
@ -153,22 +153,22 @@ MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size)
return 0;
}
return (int) m_i2ControlCtx.read(buf, size);
return (int) m_i2ControlCtx.read(buffer, len);
}
mraa::Result
MMA7455::ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size) {
MMA7455::i2cWriteReg (unsigned char reg, uint8_t *buffer, int len) {
mraa::Result error = mraa::SUCCESS;
uint8_t data[size + 1];
uint8_t data[len + 1];
data[0] = reg;
memcpy(&data[1], buf, size);
memcpy(&data[1], buffer, len);
error = m_i2ControlCtx.address (m_controlAddr);
if (error != mraa::SUCCESS) {
return error;
}
error = m_i2ControlCtx.write (data, size + 1);
error = m_i2ControlCtx.write (data, len + 1);
if (error != mraa::SUCCESS) {
return error;
}

View File

@ -214,19 +214,19 @@ class MMA7455 {
*
*
* @param reg Register address
* @param buf Register data buffer
* @param buffer Register data buffer
* @param size Buffer size
*/
int ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size);
int i2cReadReg (unsigned char reg, uint8_t *buffer, int len);
/**
*
*
* @param reg Register address
* @param buf Register data buffer
* @param buffer Register data buffer
* @param size Buffer size
*/
mraa::Result ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size);
mraa::Result i2cWriteReg (unsigned char reg, uint8_t *buffer, int len);
private:
std::string m_name;