Skip to content

Commit fe7f89c

Browse files
committed
New Initial
1 parent 3caf3f9 commit fe7f89c

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 7 [1.7.0_65]"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

.gitignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Created by http://www.gitignore.io
2+
3+
### Eclipse ###
4+
*.pydevproject
5+
.metadata
6+
.gradle
7+
bin/
8+
tmp/
9+
*.tmp
10+
*.bak
11+
*.swp
12+
*~.nib
13+
local.properties
14+
.settings/
15+
.loadpath
16+
17+
# External tool builders
18+
.externalToolBuilders/
19+
20+
# Locally stored "Eclipse launch configurations"
21+
*.launch
22+
23+
# CDT-specific
24+
.cproject
25+
26+
# PDT-specific
27+
.buildpath
28+
29+
# sbteclipse plugin
30+
.target
31+
32+
# TeXlipse plugin
33+
.texlipse
34+
35+
36+
### Java ###
37+
*.class
38+
39+
# Mobile Tools for Java (J2ME)
40+
.mtj.tmp/
41+
42+
# Package Files #
43+
*.jar
44+
*.war
45+
*.ear
46+
47+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
48+
hs_err_pid*
49+
50+
51+
### OSX ###
52+
.DS_Store
53+
.AppleDouble
54+
.LSOverride
55+
56+
# Icon must end with two \r
57+
Icon
58+
59+
# Thumbnails
60+
._*
61+
62+
# Files that might appear on external disk
63+
.Spotlight-V100
64+
.Trashes
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+
73+
74+
### C++ ###
75+
# Compiled Object files
76+
*.slo
77+
*.lo
78+
*.o
79+
*.obj
80+
81+
# Compiled Dynamic libraries
82+
*.so
83+
*.dylib
84+
*.dll
85+
86+
# Fortran module files
87+
*.mod
88+
89+
# Compiled Static libraries
90+
*.lai
91+
*.la
92+
*.a
93+
*.lib
94+
95+
# Executables
96+
*.exe
97+
*.out
98+
*.app
99+

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>I2CJava</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

src/com/cacaosd/i2cjava/I2C.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.cacaosd.i2cjava;
2+
3+
public class I2C {
4+
private static final String DEV_PATH = "/dev/i2c-";
5+
6+
private String bus;
7+
private String fullPath;
8+
9+
public I2C(byte device_address, String bus){
10+
this.bus = bus;
11+
this.setFullPath(DEV_PATH + this.bus);
12+
setDeviceAddress(device_address);
13+
}
14+
15+
public String getFullPath() {
16+
return fullPath;
17+
}
18+
19+
public void setFullPath(String fullPath) {
20+
this.fullPath = fullPath;
21+
}
22+
23+
public native void setDeviceAddress(byte device_address);
24+
public native byte getDeviceAddress();
25+
26+
public native void initialize();
27+
28+
public native void writeBit(byte register_address, byte data, byte bit_no);
29+
public native void writeBitNoExit(byte register_address, byte data, byte bit_no);
30+
public native void writeMoreBits(byte register_address, byte data, byte bit_length, byte start_bit);
31+
public native void writeMoreBitsNoExit(byte register_address, byte data, byte bit_length, byte start_bit);
32+
public native void writeByte(byte register_Address, byte data);
33+
public native void writeByteNoExit(byte register_Address, byte data);
34+
public native void writeByteBuffer(byte register_address, byte[] data);
35+
public native void writeByteBufferNoExit(byte register_address, byte[] data);
36+
public native void writeByteArduino(byte data);
37+
public native void writeByteArduinoNoExit(byte data);
38+
public native void writeByteBufferArduino(byte[] data);
39+
public native void writeByteBufferArduinoNoExit(byte[] data);
40+
41+
public native byte readBit(byte register_address, byte bit_no);
42+
public native byte readBitNoExit(byte register_address, byte bit_no);
43+
public native byte readMoreBits(byte register_address, byte length, byte start_bit);
44+
public native byte readMoreBitsNoExit(byte register_address, byte length, byte start_bit);
45+
public native byte readByte(byte register_address);
46+
public native byte readByteNoExit(byte register_address);
47+
public native byte[] readByteBuffer(byte register_address, byte length);
48+
public native byte[] readByteBufferNoExit(byte register_address, byte length);
49+
public native byte[] readByteBufferArduino(byte length);
50+
public native byte[] readByteBufferArduinoNoExit(byte length);
51+
public native short[] readWord(byte msb_address, byte lsb_address);
52+
public native short[] readWordNoExit(byte msb_address, byte lsb_address);
53+
54+
}

0 commit comments

Comments
 (0)