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

@ -50,10 +50,10 @@ DS1307::~DS1307()
mraa_i2c_stop(m_i2c);
}
mraa_result_t DS1307::writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
mraa::Result DS1307::writeBytes(uint8_t reg, uint8_t *buffer, int len)
{
if (!len || !buffer)
return MRAA_ERROR_INVALID_PARAMETER;
return mraa::ERROR_INVALID_PARAMETER;
// create a buffer 1 byte larger than the supplied buffer,
// store the register in the first byte
@ -67,10 +67,10 @@ mraa_result_t DS1307::writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
mraa_i2c_address(m_i2c, DS1307_I2C_ADDR);
return mraa_i2c_write(m_i2c, buf2, len + 1);
return (mraa::Result) mraa_i2c_write(m_i2c, buf2, len + 1);
}
uint8_t DS1307::readBytes(uint8_t reg, uint8_t *buffer, unsigned int len)
int DS1307::readBytes(uint8_t reg, uint8_t *buffer, int len)
{
if (!len || !buffer)
return 0;
@ -166,7 +166,7 @@ bool DS1307::setTime()
return writeBytes(0, buffer, 7);
}
mraa_result_t DS1307::enableClock()
mraa::Result DS1307::enableClock()
{
// the oscillator enable bit is the high bit of reg 0
// so read it, clear it, and write it back.
@ -179,7 +179,7 @@ mraa_result_t DS1307::enableClock()
return writeBytes(0, &buf, 1);
}
mraa_result_t DS1307::disableClock()
mraa::Result DS1307::disableClock()
{
// the oscillator enable bit is the high bit of reg 0
// so read it, set it, and write it back.

View File

@ -27,7 +27,7 @@
#pragma once
#include <string>
#include <mraa/i2c.h>
#include <mraa/i2c.hpp>
#define DS1307_I2C_BUS 0
#define DS1307_I2C_ADDR 0x68
@ -102,7 +102,7 @@ namespace upm {
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t enableClock();
mraa::Result enableClock();
/**
* Disables the oscillator on the clock. This prevents the clock
@ -110,7 +110,7 @@ namespace upm {
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t disableClock();
mraa::Result disableClock();
/**
* Writes value(s) into registers
@ -120,7 +120,7 @@ namespace upm {
* @param len Number of bytes to write
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t writeBytes(uint8_t reg, uint8_t *buffer, unsigned int len);
mraa::Result writeBytes(uint8_t reg, uint8_t *buffer, int len);
/**
* Reads value(s) from registers
@ -130,7 +130,7 @@ namespace upm {
* @param len Number of bytes to read
* @return Number of bytes read
*/
uint8_t readBytes(uint8_t reg, uint8_t *buffer, unsigned int len);
int readBytes(uint8_t reg, uint8_t *buffer, int len);
/**
* Converts a BCD value into decimal

View File

@ -1,24 +1,10 @@
%module javaupm_ds1307
%include "../upm.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%{
#include "ds1307.h"
%}
%typemap(jni) (uint8_t *buffer, unsigned int len) "jbyteArray";
%typemap(jtype) (uint8_t *buffer, unsigned int len) "byte[]";
%typemap(jstype) (uint8_t *buffer, unsigned int len) "byte[]";
%typemap(javain) (uint8_t *buffer, unsigned int len) "$javainput";
%typemap(in) (uint8_t *buffer, unsigned int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buffer, unsigned int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%include "ds1307.h"