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,24 +2,10 @@
%include "../upm.i"
%include "stdint.i"
%include "arrays_java.i";
%include "../java_buffer.i"
%{
#include "m24lr64e.h"
%}
%typemap(jni) (uint8_t *buf, unsigned int len) "jbyteArray";
%typemap(jtype) (uint8_t *buf, unsigned int len) "byte[]";
%typemap(jstype) (uint8_t *buf, unsigned int len) "byte[]";
%typemap(javain) (uint8_t *buf, unsigned int len) "$javainput";
%typemap(in) (uint8_t *buf, unsigned int len) {
$1 = (uint8_t *) JCALL2(GetByteArrayElements, jenv, $input, NULL);
$2 = JCALL1(GetArrayLength, jenv, $input);
}
%typemap(freearg) (uint8_t *buf, unsigned int len) {
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
}
%include "m24lr64e.h"

View File

@ -163,9 +163,9 @@ uint8_t M24LR64E::getAFI()
return EEPROM_Read_Byte(AFI_ADDR);
}
void M24LR64E::getUID(uint8_t* buf)
void M24LR64E::getUID(uint8_t* buffer)
{
EEPROM_Read_Bytes(UID_ADDR,buf,UID_LENGTH);
EEPROM_Read_Bytes(UID_ADDR, buffer, UID_LENGTH);
}
uint32_t M24LR64E::getMemorySize()
@ -184,14 +184,14 @@ void M24LR64E::clearMemory()
}
}
void M24LR64E::writeByte(unsigned int address, uint8_t data)
mraa::Result M24LR64E::writeByte(unsigned int address, uint8_t data)
{
EEPROM_Write_Byte(address, data);
return EEPROM_Write_Byte(address, data);
}
void M24LR64E::writeBytes(unsigned int address, uint8_t* buf, unsigned int len)
mraa::Result M24LR64E::writeBytes(unsigned int address, uint8_t* buffer, int len)
{
EEPROM_Write_Bytes(address, buf, len);
return EEPROM_Write_Bytes(address, buffer, len);
}
uint8_t M24LR64E::readByte(unsigned int address)
@ -199,31 +199,34 @@ uint8_t M24LR64E::readByte(unsigned int address)
return EEPROM_Read_Byte(address);
}
void M24LR64E::readBytes(unsigned int address, uint8_t* buf, unsigned int len)
int M24LR64E::readBytes(unsigned int address, uint8_t* buffer, int len)
{
EEPROM_Read_Bytes(address, buf, len);
return EEPROM_Read_Bytes(address, buffer, len);
}
void M24LR64E::EEPROM_Write_Byte(unsigned int address, uint8_t data)
mraa::Result M24LR64E::EEPROM_Write_Byte(unsigned int address, uint8_t data)
{
const int pktLen = 3;
uint8_t buf[pktLen];
mraa::Result rv;
buf[0] = ((address >> 8) & 0xff);
buf[1] = (address & 0xff);
buf[2] = data;
if (m_i2c.write(buf, pktLen))
if ((rv = m_i2c.write(buf, pktLen)))
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
usleep(I2C_WRITE_TIME * 1000);
return rv;
}
void M24LR64E::EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
unsigned int len)
mraa::Result M24LR64E::EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
int len)
{
const int pktLen = 2 + len;
uint8_t buf[pktLen];
mraa::Result rv;
buf[0] = ((address >> 8) & 0xff);
buf[1] = (address & 0xff);
@ -231,10 +234,12 @@ void M24LR64E::EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
for (int i=0; i<len; i++)
buf[2+i] = data[i];
if (m_i2c.write(buf, pktLen))
if ((rv = m_i2c.write(buf, pktLen)))
cerr << __FUNCTION__ << "@" << __LINE__ << ": write failed" << endl;
usleep(I2C_WRITE_TIME * 1000);
return rv;
}
uint8_t M24LR64E::EEPROM_Read_Byte(unsigned int address)
@ -265,8 +270,8 @@ uint8_t M24LR64E::EEPROM_Read_Byte(unsigned int address)
return buf[0];
}
unsigned int M24LR64E::EEPROM_Read_Bytes(unsigned int address,
uint8_t* buf, unsigned int len)
int M24LR64E::EEPROM_Read_Bytes(unsigned int address,
uint8_t* buffer, int len)
{
const int apktLen = 2;
uint8_t abuf[apktLen];
@ -280,7 +285,7 @@ unsigned int M24LR64E::EEPROM_Read_Bytes(unsigned int address,
return false;
}
int rv = m_i2c.read(buf, len);
int rv = m_i2c.read(buffer, len);
if (rv != len)
{
cerr << __FUNCTION__ << "@" << __LINE__ << ": read failed" << endl;

View File

@ -218,7 +218,7 @@ namespace upm {
*
* @param buf Buffer to hold the returned UID. Must be UID_LENGTH bytes.
*/
void getUID(uint8_t* buf);
void getUID(uint8_t* buffer);
/**
* Returns the memory size
@ -239,7 +239,7 @@ namespace upm {
* @param address Address to write to
* @param data Data to write
*/
void writeByte(unsigned int address, uint8_t data);
mraa::Result writeByte(unsigned int address, uint8_t data);
/**
* Writes bytes to the EEPROM
@ -248,7 +248,7 @@ namespace upm {
* @param data Data to write
* @param data Length of the data buffer
*/
void writeBytes(unsigned int address, uint8_t* buf, unsigned int len);
mraa::Result writeBytes(unsigned int address, uint8_t* buffer, int len);
/**
* Reads a byte from the EEPROM
@ -265,16 +265,16 @@ namespace upm {
* @param buffer Buffer to store data
* @param len Number of bytes to read
*/
void readBytes(unsigned int address, uint8_t* buf, unsigned int len);
int readBytes(unsigned int address, uint8_t* buffer, int len);
protected:
mraa::I2c m_i2c;
void EEPROM_Write_Byte(unsigned int address, uint8_t data);
void EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
unsigned int len);
mraa::Result EEPROM_Write_Byte(unsigned int address, uint8_t data);
mraa::Result EEPROM_Write_Bytes(unsigned int address, uint8_t* data,
int len);
uint8_t EEPROM_Read_Byte(unsigned int address);
unsigned int EEPROM_Read_Bytes(unsigned int address,
uint8_t* buf, unsigned int len);
int EEPROM_Read_Bytes(unsigned int address,
uint8_t* buffer, int len);
private:
uint8_t m_addr;